mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
fix we -a param
This commit is contained in:
@@ -165,8 +165,12 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
}
|
||||
|
||||
public void initWorldEditHook() {
|
||||
for (Key newBlockId : this.blockRegisterOrder) {
|
||||
WorldEditHook.register(newBlockId);
|
||||
try {
|
||||
for (Key newBlockId : this.blockRegisterOrder) {
|
||||
WorldEditHook.register(newBlockId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.plugin.logger().warn("Failed to initialize world edit hook", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
package net.momirealms.craftengine.bukkit.block;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitBlockRegistry;
|
||||
import com.sk89q.worldedit.util.concurrency.LazyReference;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.ReflectionUtils;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WorldEditHook {
|
||||
private static final Field field$BlockType$blockMaterial;
|
||||
|
||||
public static void register(Key id) {
|
||||
BlockType.REGISTRY.register(id.toString(), new BlockType(id.toString(), blockState -> blockState));
|
||||
static {
|
||||
field$BlockType$blockMaterial = ReflectionUtils.getDeclaredField(BlockType.class, "blockMaterial");
|
||||
}
|
||||
|
||||
public static void register(Key id) throws ReflectiveOperationException {
|
||||
BlockType blockType = new BlockType(id.toString(), blockState -> blockState);
|
||||
field$BlockType$blockMaterial.set(blockType, LazyReference.from(() -> new BukkitBlockRegistry.BukkitBlockMaterial(null, Material.STONE)));
|
||||
BlockType.REGISTRY.register(id.toString(), blockType);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user