Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 16:12:51 +02:00
Cleanup Bukkit internal id usage.
Dieser Commit ist enthalten in:
Ursprung
27c7d488a2
Commit
0088fe79b3
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -36,7 +35,6 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
private Map<Material, BukkitBlockMaterial> materialMap = new EnumMap<>(Material.class);
|
||||
private BlockState[] statesById = new BlockState[2 << 14];
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@ -59,26 +57,10 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
|
||||
@Override
|
||||
public OptionalInt getInternalBlockStateId(BlockState state) {
|
||||
if (state.getBlockType() == BlockTypes.AIR) {
|
||||
statesById[0] = state;
|
||||
return OptionalInt.of(0);
|
||||
}
|
||||
final OptionalInt id;
|
||||
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
|
||||
id = WorldEditPlugin.getInstance().getBukkitImplAdapter().getInternalBlockStateId(state);
|
||||
} else {
|
||||
id = super.getInternalBlockStateId(state);
|
||||
return WorldEditPlugin.getInstance().getBukkitImplAdapter().getInternalBlockStateId(state);
|
||||
}
|
||||
if (id.isPresent()) {
|
||||
final int idx = id.getAsInt();
|
||||
if (statesById.length <= idx) {
|
||||
BlockState[] newArr = new BlockState[statesById.length * 2];
|
||||
System.arraycopy(statesById, 0, newArr, 0, statesById.length);
|
||||
statesById = newArr;
|
||||
}
|
||||
statesById[idx] = state;
|
||||
}
|
||||
return id;
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
|
||||
public static class BukkitBlockMaterial extends PassthroughBlockMaterial {
|
||||
|
@ -48,6 +48,7 @@ import org.bukkit.block.Chest;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.DoubleChestInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -238,15 +239,12 @@ public class BukkitWorld extends AbstractWorld {
|
||||
@Override
|
||||
public boolean clearContainerBlockContents(BlockVector3 pt) {
|
||||
Block block = getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
BlockState state = block.getState();
|
||||
if (!(state instanceof org.bukkit.inventory.InventoryHolder)) {
|
||||
if (!(state instanceof InventoryHolder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
org.bukkit.inventory.InventoryHolder chest = (org.bukkit.inventory.InventoryHolder) state;
|
||||
InventoryHolder chest = (InventoryHolder) state;
|
||||
Inventory inven = chest.getInventory();
|
||||
if (chest instanceof Chest) {
|
||||
inven = getBlockInventory((Chest) chest);
|
||||
|
Binäre Datei nicht angezeigt.
@ -27,7 +27,7 @@ import java.util.OptionalInt;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
public class BlockStateIdAccess {
|
||||
public final class BlockStateIdAccess {
|
||||
|
||||
private BlockStateIdAccess() {
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren