SPIGOT-824: SpongeAbsorbEvent

By: Articdive <articdive@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2018-07-23 17:20:52 +10:00
parent 86711e2d98
commit f07fb63fb3
3 changed files with 92 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.util;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import net.minecraft.server.BlockPosition;
@@ -10,39 +11,35 @@ import net.minecraft.server.World;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.block.CraftBlockState;
public class BlockStateListPopulator {
public class BlockStateListPopulator extends DummyGeneratorAccess {
private final World world;
private final List<CraftBlockState> list;
private final LinkedHashMap<BlockPosition, CraftBlockState> list;
public BlockStateListPopulator(World world) {
this(world, new ArrayList<CraftBlockState>());
this(world, new LinkedHashMap<>());
}
public BlockStateListPopulator(World world, List<CraftBlockState> list) {
public BlockStateListPopulator(World world, LinkedHashMap<BlockPosition, CraftBlockState> list) {
this.world = world;
this.list = list;
}
public void setTypeUpdate(BlockPosition position, IBlockData data) {
CraftBlockState state = CraftBlockState.getBlockState(world, position);
state.setData(data);
list.add(state);
}
public void setTypeAndData(BlockPosition position, IBlockData data, int flag) {
@Override
public boolean setTypeAndData(BlockPosition position, IBlockData data, int flag) {
CraftBlockState state = CraftBlockState.getBlockState(world, position, flag);
state.setData(data);
list.add(state);
list.put(position, state);
return true;
}
public void updateList() {
for (BlockState state : list) {
for (BlockState state : list.values()) {
state.update(true);
}
}
public List<CraftBlockState> getList() {
return list;
return new ArrayList<>(list.values());
}
public World getWorld() {

View File

@@ -39,7 +39,7 @@ public class DummyGeneratorAccess implements GeneratorAccess {
public static final GeneratorAccess INSTANCE = new DummyGeneratorAccess();
private DummyGeneratorAccess() {
protected DummyGeneratorAccess() {
}
@Override