mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-20 15:39:22 +00:00
fix we -a param
This commit is contained in:
@@ -165,9 +165,13 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initWorldEditHook() {
|
public void initWorldEditHook() {
|
||||||
|
try {
|
||||||
for (Key newBlockId : this.blockRegisterOrder) {
|
for (Key newBlockId : this.blockRegisterOrder) {
|
||||||
WorldEditHook.register(newBlockId);
|
WorldEditHook.register(newBlockId);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.plugin.logger().warn("Failed to initialize world edit hook", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -1,11 +1,24 @@
|
|||||||
package net.momirealms.craftengine.bukkit.block;
|
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 com.sk89q.worldedit.world.block.BlockType;
|
||||||
import net.momirealms.craftengine.core.util.Key;
|
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 {
|
public class WorldEditHook {
|
||||||
|
private static final Field field$BlockType$blockMaterial;
|
||||||
|
|
||||||
public static void register(Key id) {
|
static {
|
||||||
BlockType.REGISTRY.register(id.toString(), new BlockType(id.toString(), blockState -> blockState));
|
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