3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-09-06 08:02:50 +02:00

Refactor registries to entirely use the platform

Dieser Commit ist enthalten in:
Matthew Miller 2019-02-16 19:35:13 +10:00
Ursprung 1b101740fe
Commit db1315e043
12 geänderte Dateien mit 1695 neuen und 1666 gelöschten Zeilen

Datei anzeigen

@ -33,12 +33,22 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.item.ItemType;
import org.bstats.bukkit.Metrics;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
@ -51,6 +61,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -88,6 +99,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
server = new BukkitServerInterface(this, getServer());
worldEdit.getPlatformManager().register(server);
loadAdapter(); // Need an adapter to work with special blocks with NBT data
setupRegistries();
worldEdit.loadMappings();
loadConfig(); // Load configuration
@ -109,6 +121,45 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
new Metrics(this);
}
public void setupRegistries() {
// Biome
for (Biome biome : Biome.values()) {
BiomeType.REGISTRY.register("minecraft:" + biome.name().toLowerCase(), new BiomeType("minecraft:" + biome.name().toLowerCase()));
}
// Block & Item
for (Material material : Material.values()) {
if (material.isBlock()) {
BlockType.REGISTRY.register(material.getKey().toString(), new BlockType(material.getKey().toString(), blockState -> {
// TODO Use something way less hacky than this.
ParserContext context = new ParserContext();
context.setPreferringWildcard(true);
context.setTryLegacy(false);
context.setRestricted(false);
try {
FuzzyBlockState state = (FuzzyBlockState) WorldEdit.getInstance().getBlockFactory().parseFromInput(
BukkitAdapter.adapt(blockState.getBlockType()).createBlockData().getAsString(), context
).toImmutableState();
BlockState defaultState = blockState.getBlockType().getAllStates().get(0);
for (Map.Entry<Property<?>, Object> propertyObjectEntry : state.getStates().entrySet()) {
defaultState = defaultState.with((Property) propertyObjectEntry.getKey(), propertyObjectEntry.getValue());
}
return defaultState;
} catch (InputParseException e) {
e.printStackTrace();
return blockState;
}
}));
}
if (material.isItem()) {
ItemType.REGISTRY.register(material.getKey().toString(), new ItemType(material.getKey().toString()));
}
}
// Entity
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
EntityType.REGISTRY.register("minecraft:" + entityType.name().toLowerCase(), new EntityType("minecraft:" + entityType.name().toLowerCase()));
}
}
private void loadConfig() {
createDefaultConfiguration("config.yml"); // Create the default configuration file

Datei anzeigen

@ -19,86 +19,25 @@
package com.sk89q.worldedit;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.util.logging.LogFormat;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.IntFunction;
/**
* Represents WorldEdit's configuration.
*/
public abstract class LocalConfiguration {
protected static final String[] defaultDisallowedBlocks = new String[] {
// dangerous stuff (physics/drops items)
BlockTypes.OAK_SAPLING.getId(),
BlockTypes.JUNGLE_SAPLING.getId(),
BlockTypes.DARK_OAK_SAPLING.getId(),
BlockTypes.SPRUCE_SAPLING.getId(),
BlockTypes.BIRCH_SAPLING.getId(),
BlockTypes.ACACIA_SAPLING.getId(),
BlockTypes.BLACK_BED.getId(),
BlockTypes.BLUE_BED.getId(),
BlockTypes.BROWN_BED.getId(),
BlockTypes.CYAN_BED.getId(),
BlockTypes.GRAY_BED.getId(),
BlockTypes.GREEN_BED.getId(),
BlockTypes.LIGHT_BLUE_BED.getId(),
BlockTypes.LIGHT_GRAY_BED.getId(),
BlockTypes.LIME_BED.getId(),
BlockTypes.MAGENTA_BED.getId(),
BlockTypes.ORANGE_BED.getId(),
BlockTypes.PINK_BED.getId(),
BlockTypes.PURPLE_BED.getId(),
BlockTypes.RED_BED.getId(),
BlockTypes.WHITE_BED.getId(),
BlockTypes.YELLOW_BED.getId(),
BlockTypes.POWERED_RAIL.getId(),
BlockTypes.DETECTOR_RAIL.getId(),
BlockTypes.GRASS.getId(),
BlockTypes.DEAD_BUSH.getId(),
BlockTypes.MOVING_PISTON.getId(),
BlockTypes.PISTON_HEAD.getId(),
BlockTypes.SUNFLOWER.getId(),
BlockTypes.ROSE_BUSH.getId(),
BlockTypes.DANDELION.getId(),
BlockTypes.POPPY.getId(),
BlockTypes.BROWN_MUSHROOM.getId(),
BlockTypes.RED_MUSHROOM.getId(),
BlockTypes.TNT.getId(),
BlockTypes.TORCH.getId(),
BlockTypes.FIRE.getId(),
BlockTypes.REDSTONE_WIRE.getId(),
BlockTypes.WHEAT.getId(),
BlockTypes.POTATOES.getId(),
BlockTypes.CARROTS.getId(),
BlockTypes.MELON_STEM.getId(),
BlockTypes.PUMPKIN_STEM.getId(),
BlockTypes.BEETROOTS.getId(),
BlockTypes.RAIL.getId(),
BlockTypes.LEVER.getId(),
BlockTypes.REDSTONE_TORCH.getId(),
BlockTypes.REDSTONE_WALL_TORCH.getId(),
BlockTypes.REPEATER.getId(),
BlockTypes.COMPARATOR.getId(),
BlockTypes.STONE_BUTTON.getId(),
BlockTypes.BIRCH_BUTTON.getId(),
BlockTypes.ACACIA_BUTTON.getId(),
BlockTypes.DARK_OAK_BUTTON.getId(),
BlockTypes.JUNGLE_BUTTON.getId(),
BlockTypes.OAK_BUTTON.getId(),
BlockTypes.SPRUCE_BUTTON.getId(),
BlockTypes.CACTUS.getId(),
BlockTypes.SUGAR_CANE.getId(),
// ores and stuff
BlockTypes.BEDROCK.getId(),
};
public boolean profile = false;
public boolean traceUnflushedSessions = false;
public Set<String> disallowedBlocks = new HashSet<>();
@ -117,7 +56,7 @@ public abstract class LocalConfiguration {
public String logFile = "";
public String logFormat = LogFormat.DEFAULT_FORMAT;
public boolean registerHelp = true; // what is the point of this, it's not even used
public String wandItem = ItemTypes.WOODEN_AXE.getId();
public String wandItem = "minecraft:wooden_axe";
public boolean superPickaxeDrop = true;
public boolean superPickaxeManyDrop = true;
public boolean noDoubleSlash = false;
@ -125,7 +64,7 @@ public abstract class LocalConfiguration {
public boolean useInventoryOverride = false;
public boolean useInventoryCreativeOverride = false;
public boolean navigationUseGlass = true;
public String navigationWand = ItemTypes.COMPASS.getId();
public String navigationWand = "minecraft:compass";
public int navigationWandMaxDistance = 50;
public int scriptTimeout = 3000;
public int calculationTimeout = 100;
@ -138,6 +77,73 @@ public abstract class LocalConfiguration {
public boolean allowSymlinks = false;
public boolean serverSideCUI = true;
protected String[] getDefaultDisallowedBlocks() {
List<BlockType> blockTypes = Lists.newArrayList(
BlockTypes.OAK_SAPLING,
BlockTypes.JUNGLE_SAPLING,
BlockTypes.DARK_OAK_SAPLING,
BlockTypes.SPRUCE_SAPLING,
BlockTypes.BIRCH_SAPLING,
BlockTypes.ACACIA_SAPLING,
BlockTypes.BLACK_BED,
BlockTypes.BLUE_BED,
BlockTypes.BROWN_BED,
BlockTypes.CYAN_BED,
BlockTypes.GRAY_BED,
BlockTypes.GREEN_BED,
BlockTypes.LIGHT_BLUE_BED,
BlockTypes.LIGHT_GRAY_BED,
BlockTypes.LIME_BED,
BlockTypes.MAGENTA_BED,
BlockTypes.ORANGE_BED,
BlockTypes.PINK_BED,
BlockTypes.PURPLE_BED,
BlockTypes.RED_BED,
BlockTypes.WHITE_BED,
BlockTypes.YELLOW_BED,
BlockTypes.POWERED_RAIL,
BlockTypes.DETECTOR_RAIL,
BlockTypes.GRASS,
BlockTypes.DEAD_BUSH,
BlockTypes.MOVING_PISTON,
BlockTypes.PISTON_HEAD,
BlockTypes.SUNFLOWER,
BlockTypes.ROSE_BUSH,
BlockTypes.DANDELION,
BlockTypes.POPPY,
BlockTypes.BROWN_MUSHROOM,
BlockTypes.RED_MUSHROOM,
BlockTypes.TNT,
BlockTypes.TORCH,
BlockTypes.FIRE,
BlockTypes.REDSTONE_WIRE,
BlockTypes.WHEAT,
BlockTypes.POTATOES,
BlockTypes.CARROTS,
BlockTypes.MELON_STEM,
BlockTypes.PUMPKIN_STEM,
BlockTypes.BEETROOTS,
BlockTypes.RAIL,
BlockTypes.LEVER,
BlockTypes.REDSTONE_TORCH,
BlockTypes.REDSTONE_WALL_TORCH,
BlockTypes.REPEATER,
BlockTypes.COMPARATOR,
BlockTypes.STONE_BUTTON,
BlockTypes.BIRCH_BUTTON,
BlockTypes.ACACIA_BUTTON,
BlockTypes.DARK_OAK_BUTTON,
BlockTypes.JUNGLE_BUTTON,
BlockTypes.OAK_BUTTON,
BlockTypes.SPRUCE_BUTTON,
BlockTypes.CACTUS,
BlockTypes.SUGAR_CANE,
// ores and stuff
BlockTypes.BEDROCK
);
return blockTypes.stream().filter(type -> !Objects.isNull(type)).map(BlockType::getId).toArray(String[]::new);
}
/**
* Load the configuration.
*/

Datei anzeigen

@ -77,7 +77,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
profile = getBool("profile", profile);
traceUnflushedSessions = getBool("trace-unflushed-sessions", traceUnflushedSessions);
disallowedBlocks = getStringSet("disallowed-blocks", defaultDisallowedBlocks);
disallowedBlocks = getStringSet("disallowed-blocks", getDefaultDisallowedBlocks());
defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit);
maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit);
defaultMaxPolygonalPoints = getInt("default-max-polygon-points", defaultMaxPolygonalPoints);

Datei anzeigen

@ -79,7 +79,7 @@ public class YAMLConfiguration extends LocalConfiguration {
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
disallowedBlocks = new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(defaultDisallowedBlocks)));
disallowedBlocks = new HashSet<>(config.getStringList("limits.disallowed-blocks", Lists.newArrayList(getDefaultDisallowedBlocks())));
allowedDataCycleBlocks = new HashSet<>(config.getStringList("limits.allowed-data-cycle-blocks", null));
registerHelp = config.getBoolean("register-help", true);

Datei anzeigen

@ -26,79 +26,79 @@ import javax.annotation.Nullable;
*/
public class BiomeTypes {
public static final BiomeType BADLANDS = register("minecraft:badlands");
public static final BiomeType BADLANDS_PLATEAU = register("minecraft:badlands_plateau");
public static final BiomeType BEACH = register("minecraft:beach");
public static final BiomeType BIRCH_FOREST = register("minecraft:birch_forest");
public static final BiomeType BIRCH_FOREST_HILLS = register("minecraft:birch_forest_hills");
public static final BiomeType COLD_OCEAN = register("minecraft:cold_ocean");
public static final BiomeType DARK_FOREST = register("minecraft:dark_forest");
public static final BiomeType DARK_FOREST_HILLS = register("minecraft:dark_forest_hills");
public static final BiomeType DEEP_COLD_OCEAN = register("minecraft:deep_cold_ocean");
public static final BiomeType DEEP_FROZEN_OCEAN = register("minecraft:deep_frozen_ocean");
public static final BiomeType DEEP_LUKEWARM_OCEAN = register("minecraft:deep_lukewarm_ocean");
public static final BiomeType DEEP_OCEAN = register("minecraft:deep_ocean");
public static final BiomeType DEEP_WARM_OCEAN = register("minecraft:deep_warm_ocean");
public static final BiomeType DESERT = register("minecraft:desert");
public static final BiomeType DESERT_HILLS = register("minecraft:desert_hills");
public static final BiomeType DESERT_LAKES = register("minecraft:desert_lakes");
public static final BiomeType END_BARRENS = register("minecraft:end_barrens");
public static final BiomeType END_HIGHLANDS = register("minecraft:end_highlands");
public static final BiomeType END_MIDLANDS = register("minecraft:end_midlands");
public static final BiomeType ERODED_BADLANDS = register("minecraft:eroded_badlands");
public static final BiomeType FLOWER_FOREST = register("minecraft:flower_forest");
public static final BiomeType FOREST = register("minecraft:forest");
public static final BiomeType FROZEN_OCEAN = register("minecraft:frozen_ocean");
public static final BiomeType FROZEN_RIVER = register("minecraft:frozen_river");
public static final BiomeType GIANT_SPRUCE_TAIGA = register("minecraft:giant_spruce_taiga");
public static final BiomeType GIANT_SPRUCE_TAIGA_HILLS = register("minecraft:giant_spruce_taiga_hills");
public static final BiomeType GIANT_TREE_TAIGA = register("minecraft:giant_tree_taiga");
public static final BiomeType GIANT_TREE_TAIGA_HILLS = register("minecraft:giant_tree_taiga_hills");
public static final BiomeType GRAVELLY_MOUNTAINS = register("minecraft:gravelly_mountains");
public static final BiomeType ICE_SPIKES = register("minecraft:ice_spikes");
public static final BiomeType JUNGLE = register("minecraft:jungle");
public static final BiomeType JUNGLE_EDGE = register("minecraft:jungle_edge");
public static final BiomeType JUNGLE_HILLS = register("minecraft:jungle_hills");
public static final BiomeType LUKEWARM_OCEAN = register("minecraft:lukewarm_ocean");
public static final BiomeType MODIFIED_BADLANDS_PLATEAU = register("minecraft:modified_badlands_plateau");
public static final BiomeType MODIFIED_GRAVELLY_MOUNTAINS = register("minecraft:modified_gravelly_mountains");
public static final BiomeType MODIFIED_JUNGLE = register("minecraft:modified_jungle");
public static final BiomeType MODIFIED_JUNGLE_EDGE = register("minecraft:modified_jungle_edge");
public static final BiomeType MODIFIED_WOODED_BADLANDS_PLATEAU = register("minecraft:modified_wooded_badlands_plateau");
public static final BiomeType MOUNTAIN_EDGE = register("minecraft:mountain_edge");
public static final BiomeType MOUNTAINS = register("minecraft:mountains");
public static final BiomeType MUSHROOM_FIELD_SHORE = register("minecraft:mushroom_field_shore");
public static final BiomeType MUSHROOM_FIELDS = register("minecraft:mushroom_fields");
public static final BiomeType NETHER = register("minecraft:nether");
public static final BiomeType OCEAN = register("minecraft:ocean");
public static final BiomeType PLAINS = register("minecraft:plains");
public static final BiomeType RIVER = register("minecraft:river");
public static final BiomeType SAVANNA = register("minecraft:savanna");
public static final BiomeType SAVANNA_PLATEAU = register("minecraft:savanna_plateau");
public static final BiomeType SHATTERED_SAVANNA = register("minecraft:shattered_savanna");
public static final BiomeType SHATTERED_SAVANNA_PLATEAU = register("minecraft:shattered_savanna_plateau");
public static final BiomeType SMALL_END_ISLANDS = register("minecraft:small_end_islands");
public static final BiomeType SNOWY_BEACH = register("minecraft:snowy_beach");
public static final BiomeType SNOWY_MOUNTAINS = register("minecraft:snowy_mountains");
public static final BiomeType SNOWY_TAIGA = register("minecraft:snowy_taiga");
public static final BiomeType SNOWY_TAIGA_HILLS = register("minecraft:snowy_taiga_hills");
public static final BiomeType SNOWY_TAIGA_MOUNTAINS = register("minecraft:snowy_taiga_mountains");
public static final BiomeType SNOWY_TUNDRA = register("minecraft:snowy_tundra");
public static final BiomeType STONE_SHORE = register("minecraft:stone_shore");
public static final BiomeType SUNFLOWER_PLAINS = register("minecraft:sunflower_plains");
public static final BiomeType SWAMP = register("minecraft:swamp");
public static final BiomeType SWAMP_HILLS = register("minecraft:swamp_hills");
public static final BiomeType TAIGA = register("minecraft:taiga");
public static final BiomeType TAIGA_HILLS = register("minecraft:taiga_hills");
public static final BiomeType TAIGA_MOUNTAINS = register("minecraft:taiga_mountains");
public static final BiomeType TALL_BIRCH_FOREST = register("minecraft:tall_birch_forest");
public static final BiomeType TALL_BIRCH_HILLS = register("minecraft:tall_birch_hills");
public static final BiomeType THE_END = register("minecraft:the_end");
public static final BiomeType THE_VOID = register("minecraft:the_void");
public static final BiomeType WARM_OCEAN = register("minecraft:warm_ocean");
public static final BiomeType WOODED_BADLANDS_PLATEAU = register("minecraft:wooded_badlands_plateau");
public static final BiomeType WOODED_HILLS = register("minecraft:wooded_hills");
public static final BiomeType WOODED_MOUNTAINS = register("minecraft:wooded_mountains");
@Nullable public static final BiomeType BADLANDS = get("minecraft:badlands");
@Nullable public static final BiomeType BADLANDS_PLATEAU = get("minecraft:badlands_plateau");
@Nullable public static final BiomeType BEACH = get("minecraft:beach");
@Nullable public static final BiomeType BIRCH_FOREST = get("minecraft:birch_forest");
@Nullable public static final BiomeType BIRCH_FOREST_HILLS = get("minecraft:birch_forest_hills");
@Nullable public static final BiomeType COLD_OCEAN = get("minecraft:cold_ocean");
@Nullable public static final BiomeType DARK_FOREST = get("minecraft:dark_forest");
@Nullable public static final BiomeType DARK_FOREST_HILLS = get("minecraft:dark_forest_hills");
@Nullable public static final BiomeType DEEP_COLD_OCEAN = get("minecraft:deep_cold_ocean");
@Nullable public static final BiomeType DEEP_FROZEN_OCEAN = get("minecraft:deep_frozen_ocean");
@Nullable public static final BiomeType DEEP_LUKEWARM_OCEAN = get("minecraft:deep_lukewarm_ocean");
@Nullable public static final BiomeType DEEP_OCEAN = get("minecraft:deep_ocean");
@Nullable public static final BiomeType DEEP_WARM_OCEAN = get("minecraft:deep_warm_ocean");
@Nullable public static final BiomeType DESERT = get("minecraft:desert");
@Nullable public static final BiomeType DESERT_HILLS = get("minecraft:desert_hills");
@Nullable public static final BiomeType DESERT_LAKES = get("minecraft:desert_lakes");
@Nullable public static final BiomeType END_BARRENS = get("minecraft:end_barrens");
@Nullable public static final BiomeType END_HIGHLANDS = get("minecraft:end_highlands");
@Nullable public static final BiomeType END_MIDLANDS = get("minecraft:end_midlands");
@Nullable public static final BiomeType ERODED_BADLANDS = get("minecraft:eroded_badlands");
@Nullable public static final BiomeType FLOWER_FOREST = get("minecraft:flower_forest");
@Nullable public static final BiomeType FOREST = get("minecraft:forest");
@Nullable public static final BiomeType FROZEN_OCEAN = get("minecraft:frozen_ocean");
@Nullable public static final BiomeType FROZEN_RIVER = get("minecraft:frozen_river");
@Nullable public static final BiomeType GIANT_SPRUCE_TAIGA = get("minecraft:giant_spruce_taiga");
@Nullable public static final BiomeType GIANT_SPRUCE_TAIGA_HILLS = get("minecraft:giant_spruce_taiga_hills");
@Nullable public static final BiomeType GIANT_TREE_TAIGA = get("minecraft:giant_tree_taiga");
@Nullable public static final BiomeType GIANT_TREE_TAIGA_HILLS = get("minecraft:giant_tree_taiga_hills");
@Nullable public static final BiomeType GRAVELLY_MOUNTAINS = get("minecraft:gravelly_mountains");
@Nullable public static final BiomeType ICE_SPIKES = get("minecraft:ice_spikes");
@Nullable public static final BiomeType JUNGLE = get("minecraft:jungle");
@Nullable public static final BiomeType JUNGLE_EDGE = get("minecraft:jungle_edge");
@Nullable public static final BiomeType JUNGLE_HILLS = get("minecraft:jungle_hills");
@Nullable public static final BiomeType LUKEWARM_OCEAN = get("minecraft:lukewarm_ocean");
@Nullable public static final BiomeType MODIFIED_BADLANDS_PLATEAU = get("minecraft:modified_badlands_plateau");
@Nullable public static final BiomeType MODIFIED_GRAVELLY_MOUNTAINS = get("minecraft:modified_gravelly_mountains");
@Nullable public static final BiomeType MODIFIED_JUNGLE = get("minecraft:modified_jungle");
@Nullable public static final BiomeType MODIFIED_JUNGLE_EDGE = get("minecraft:modified_jungle_edge");
@Nullable public static final BiomeType MODIFIED_WOODED_BADLANDS_PLATEAU = get("minecraft:modified_wooded_badlands_plateau");
@Nullable public static final BiomeType MOUNTAIN_EDGE = get("minecraft:mountain_edge");
@Nullable public static final BiomeType MOUNTAINS = get("minecraft:mountains");
@Nullable public static final BiomeType MUSHROOM_FIELD_SHORE = get("minecraft:mushroom_field_shore");
@Nullable public static final BiomeType MUSHROOM_FIELDS = get("minecraft:mushroom_fields");
@Nullable public static final BiomeType NETHER = get("minecraft:nether");
@Nullable public static final BiomeType OCEAN = get("minecraft:ocean");
@Nullable public static final BiomeType PLAINS = get("minecraft:plains");
@Nullable public static final BiomeType RIVER = get("minecraft:river");
@Nullable public static final BiomeType SAVANNA = get("minecraft:savanna");
@Nullable public static final BiomeType SAVANNA_PLATEAU = get("minecraft:savanna_plateau");
@Nullable public static final BiomeType SHATTERED_SAVANNA = get("minecraft:shattered_savanna");
@Nullable public static final BiomeType SHATTERED_SAVANNA_PLATEAU = get("minecraft:shattered_savanna_plateau");
@Nullable public static final BiomeType SMALL_END_ISLANDS = get("minecraft:small_end_islands");
@Nullable public static final BiomeType SNOWY_BEACH = get("minecraft:snowy_beach");
@Nullable public static final BiomeType SNOWY_MOUNTAINS = get("minecraft:snowy_mountains");
@Nullable public static final BiomeType SNOWY_TAIGA = get("minecraft:snowy_taiga");
@Nullable public static final BiomeType SNOWY_TAIGA_HILLS = get("minecraft:snowy_taiga_hills");
@Nullable public static final BiomeType SNOWY_TAIGA_MOUNTAINS = get("minecraft:snowy_taiga_mountains");
@Nullable public static final BiomeType SNOWY_TUNDRA = get("minecraft:snowy_tundra");
@Nullable public static final BiomeType STONE_SHORE = get("minecraft:stone_shore");
@Nullable public static final BiomeType SUNFLOWER_PLAINS = get("minecraft:sunflower_plains");
@Nullable public static final BiomeType SWAMP = get("minecraft:swamp");
@Nullable public static final BiomeType SWAMP_HILLS = get("minecraft:swamp_hills");
@Nullable public static final BiomeType TAIGA = get("minecraft:taiga");
@Nullable public static final BiomeType TAIGA_HILLS = get("minecraft:taiga_hills");
@Nullable public static final BiomeType TAIGA_MOUNTAINS = get("minecraft:taiga_mountains");
@Nullable public static final BiomeType TALL_BIRCH_FOREST = get("minecraft:tall_birch_forest");
@Nullable public static final BiomeType TALL_BIRCH_HILLS = get("minecraft:tall_birch_hills");
@Nullable public static final BiomeType THE_END = get("minecraft:the_end");
@Nullable public static final BiomeType THE_VOID = get("minecraft:the_void");
@Nullable public static final BiomeType WARM_OCEAN = get("minecraft:warm_ocean");
@Nullable public static final BiomeType WOODED_BADLANDS_PLATEAU = get("minecraft:wooded_badlands_plateau");
@Nullable public static final BiomeType WOODED_HILLS = get("minecraft:wooded_hills");
@Nullable public static final BiomeType WOODED_MOUNTAINS = get("minecraft:wooded_mountains");
private BiomeTypes() {
}

Datei anzeigen

@ -57,7 +57,12 @@ public class FuzzyBlockState extends BlockState {
Property<Object> objKey = (Property<Object>) entry.getKey();
state = state.with(objKey, entry.getValue());
}
return getBlockType().getDefaultState();
return state;
}
@Override
public BlockState toImmutableState() {
return getFullState();
}
/**

Datei anzeigen

@ -23,113 +23,105 @@ import javax.annotation.Nullable;
public class EntityTypes {
public static final EntityType AREA_EFFECT_CLOUD = register("minecraft:area_effect_cloud");
public static final EntityType ARMOR_STAND = register("minecraft:armor_stand");
public static final EntityType ARROW = register("minecraft:arrow");
public static final EntityType BAT = register("minecraft:bat");
public static final EntityType BLAZE = register("minecraft:blaze");
public static final EntityType BOAT = register("minecraft:boat");
public static final EntityType CAVE_SPIDER = register("minecraft:cave_spider");
public static final EntityType CHEST_MINECART = register("minecraft:chest_minecart");
public static final EntityType CHICKEN = register("minecraft:chicken");
public static final EntityType COD = register("minecraft:cod");
public static final EntityType COMMAND_BLOCK_MINECART = register("minecraft:command_block_minecart");
public static final EntityType COW = register("minecraft:cow");
public static final EntityType CREEPER = register("minecraft:creeper");
public static final EntityType DOLPHIN = register("minecraft:dolphin");
public static final EntityType DONKEY = register("minecraft:donkey");
public static final EntityType DRAGON_FIREBALL = register("minecraft:dragon_fireball");
public static final EntityType DROWNED = register("minecraft:drowned");
public static final EntityType EGG = register("minecraft:egg");
public static final EntityType ELDER_GUARDIAN = register("minecraft:elder_guardian");
public static final EntityType END_CRYSTAL = register("minecraft:end_crystal");
public static final EntityType ENDER_DRAGON = register("minecraft:ender_dragon");
public static final EntityType ENDER_PEARL = register("minecraft:ender_pearl");
public static final EntityType ENDERMAN = register("minecraft:enderman");
public static final EntityType ENDERMITE = register("minecraft:endermite");
public static final EntityType EVOKER = register("minecraft:evoker");
public static final EntityType EVOKER_FANGS = register("minecraft:evoker_fangs");
public static final EntityType EXPERIENCE_BOTTLE = register("minecraft:experience_bottle");
public static final EntityType EXPERIENCE_ORB = register("minecraft:experience_orb");
public static final EntityType EYE_OF_ENDER = register("minecraft:eye_of_ender");
public static final EntityType FALLING_BLOCK = register("minecraft:falling_block");
public static final EntityType FIREBALL = register("minecraft:fireball");
public static final EntityType FIREWORK_ROCKET = register("minecraft:firework_rocket");
public static final EntityType FISHING_BOBBER = register("minecraft:fishing_bobber");
public static final EntityType FURNACE_MINECART = register("minecraft:furnace_minecart");
public static final EntityType GHAST = register("minecraft:ghast");
public static final EntityType GIANT = register("minecraft:giant");
public static final EntityType GUARDIAN = register("minecraft:guardian");
public static final EntityType HOPPER_MINECART = register("minecraft:hopper_minecart");
public static final EntityType HORSE = register("minecraft:horse");
public static final EntityType HUSK = register("minecraft:husk");
public static final EntityType ILLUSIONER = register("minecraft:illusioner");
public static final EntityType IRON_GOLEM = register("minecraft:iron_golem");
public static final EntityType ITEM = register("minecraft:item");
public static final EntityType ITEM_FRAME = register("minecraft:item_frame");
public static final EntityType LEASH_KNOT = register("minecraft:leash_knot");
public static final EntityType LIGHTNING_BOLT = register("minecraft:lightning_bolt");
public static final EntityType LLAMA = register("minecraft:llama");
public static final EntityType LLAMA_SPIT = register("minecraft:llama_spit");
public static final EntityType MAGMA_CUBE = register("minecraft:magma_cube");
public static final EntityType MINECART = register("minecraft:minecart");
public static final EntityType MOOSHROOM = register("minecraft:mooshroom");
public static final EntityType MULE = register("minecraft:mule");
public static final EntityType OCELOT = register("minecraft:ocelot");
public static final EntityType PAINTING = register("minecraft:painting");
public static final EntityType PARROT = register("minecraft:parrot");
public static final EntityType PHANTOM = register("minecraft:phantom");
public static final EntityType PIG = register("minecraft:pig");
public static final EntityType PLAYER = register("minecraft:player");
public static final EntityType POLAR_BEAR = register("minecraft:polar_bear");
public static final EntityType POTION = register("minecraft:potion");
public static final EntityType PUFFERFISH = register("minecraft:pufferfish");
public static final EntityType RABBIT = register("minecraft:rabbit");
public static final EntityType SALMON = register("minecraft:salmon");
public static final EntityType SHEEP = register("minecraft:sheep");
public static final EntityType SHULKER = register("minecraft:shulker");
public static final EntityType SHULKER_BULLET = register("minecraft:shulker_bullet");
public static final EntityType SILVERFISH = register("minecraft:silverfish");
public static final EntityType SKELETON = register("minecraft:skeleton");
public static final EntityType SKELETON_HORSE = register("minecraft:skeleton_horse");
public static final EntityType SLIME = register("minecraft:slime");
public static final EntityType SMALL_FIREBALL = register("minecraft:small_fireball");
public static final EntityType SNOW_GOLEM = register("minecraft:snow_golem");
public static final EntityType SNOWBALL = register("minecraft:snowball");
public static final EntityType SPAWNER_MINECART = register("minecraft:spawner_minecart");
public static final EntityType SPECTRAL_ARROW = register("minecraft:spectral_arrow");
public static final EntityType SPIDER = register("minecraft:spider");
public static final EntityType SQUID = register("minecraft:squid");
public static final EntityType STRAY = register("minecraft:stray");
public static final EntityType TNT = register("minecraft:tnt");
public static final EntityType TNT_MINECART = register("minecraft:tnt_minecart");
public static final EntityType TRIDENT = register("minecraft:trident");
public static final EntityType TROPICAL_FISH = register("minecraft:tropical_fish");
public static final EntityType TURTLE = register("minecraft:turtle");
public static final EntityType VEX = register("minecraft:vex");
public static final EntityType VILLAGER = register("minecraft:villager");
public static final EntityType VINDICATOR = register("minecraft:vindicator");
public static final EntityType WITCH = register("minecraft:witch");
public static final EntityType WITHER = register("minecraft:wither");
public static final EntityType WITHER_SKELETON = register("minecraft:wither_skeleton");
public static final EntityType WITHER_SKULL = register("minecraft:wither_skull");
public static final EntityType WOLF = register("minecraft:wolf");
public static final EntityType ZOMBIE = register("minecraft:zombie");
public static final EntityType ZOMBIE_HORSE = register("minecraft:zombie_horse");
public static final EntityType ZOMBIE_PIGMAN = register("minecraft:zombie_pigman");
public static final EntityType ZOMBIE_VILLAGER = register("minecraft:zombie_villager");
@Nullable public static final EntityType AREA_EFFECT_CLOUD = get("minecraft:area_effect_cloud");
@Nullable public static final EntityType ARMOR_STAND = get("minecraft:armor_stand");
@Nullable public static final EntityType ARROW = get("minecraft:arrow");
@Nullable public static final EntityType BAT = get("minecraft:bat");
@Nullable public static final EntityType BLAZE = get("minecraft:blaze");
@Nullable public static final EntityType BOAT = get("minecraft:boat");
@Nullable public static final EntityType CAVE_SPIDER = get("minecraft:cave_spider");
@Nullable public static final EntityType CHEST_MINECART = get("minecraft:chest_minecart");
@Nullable public static final EntityType CHICKEN = get("minecraft:chicken");
@Nullable public static final EntityType COD = get("minecraft:cod");
@Nullable public static final EntityType COMMAND_BLOCK_MINECART = get("minecraft:command_block_minecart");
@Nullable public static final EntityType COW = get("minecraft:cow");
@Nullable public static final EntityType CREEPER = get("minecraft:creeper");
@Nullable public static final EntityType DOLPHIN = get("minecraft:dolphin");
@Nullable public static final EntityType DONKEY = get("minecraft:donkey");
@Nullable public static final EntityType DRAGON_FIREBALL = get("minecraft:dragon_fireball");
@Nullable public static final EntityType DROWNED = get("minecraft:drowned");
@Nullable public static final EntityType EGG = get("minecraft:egg");
@Nullable public static final EntityType ELDER_GUARDIAN = get("minecraft:elder_guardian");
@Nullable public static final EntityType END_CRYSTAL = get("minecraft:end_crystal");
@Nullable public static final EntityType ENDER_DRAGON = get("minecraft:ender_dragon");
@Nullable public static final EntityType ENDER_PEARL = get("minecraft:ender_pearl");
@Nullable public static final EntityType ENDERMAN = get("minecraft:enderman");
@Nullable public static final EntityType ENDERMITE = get("minecraft:endermite");
@Nullable public static final EntityType EVOKER = get("minecraft:evoker");
@Nullable public static final EntityType EVOKER_FANGS = get("minecraft:evoker_fangs");
@Nullable public static final EntityType EXPERIENCE_BOTTLE = get("minecraft:experience_bottle");
@Nullable public static final EntityType EXPERIENCE_ORB = get("minecraft:experience_orb");
@Nullable public static final EntityType EYE_OF_ENDER = get("minecraft:eye_of_ender");
@Nullable public static final EntityType FALLING_BLOCK = get("minecraft:falling_block");
@Nullable public static final EntityType FIREBALL = get("minecraft:fireball");
@Nullable public static final EntityType FIREWORK_ROCKET = get("minecraft:firework_rocket");
@Nullable public static final EntityType FISHING_BOBBER = get("minecraft:fishing_bobber");
@Nullable public static final EntityType FURNACE_MINECART = get("minecraft:furnace_minecart");
@Nullable public static final EntityType GHAST = get("minecraft:ghast");
@Nullable public static final EntityType GIANT = get("minecraft:giant");
@Nullable public static final EntityType GUARDIAN = get("minecraft:guardian");
@Nullable public static final EntityType HOPPER_MINECART = get("minecraft:hopper_minecart");
@Nullable public static final EntityType HORSE = get("minecraft:horse");
@Nullable public static final EntityType HUSK = get("minecraft:husk");
@Nullable public static final EntityType ILLUSIONER = get("minecraft:illusioner");
@Nullable public static final EntityType IRON_GOLEM = get("minecraft:iron_golem");
@Nullable public static final EntityType ITEM = get("minecraft:item");
@Nullable public static final EntityType ITEM_FRAME = get("minecraft:item_frame");
@Nullable public static final EntityType LEASH_KNOT = get("minecraft:leash_knot");
@Nullable public static final EntityType LIGHTNING_BOLT = get("minecraft:lightning_bolt");
@Nullable public static final EntityType LLAMA = get("minecraft:llama");
@Nullable public static final EntityType LLAMA_SPIT = get("minecraft:llama_spit");
@Nullable public static final EntityType MAGMA_CUBE = get("minecraft:magma_cube");
@Nullable public static final EntityType MINECART = get("minecraft:minecart");
@Nullable public static final EntityType MOOSHROOM = get("minecraft:mooshroom");
@Nullable public static final EntityType MULE = get("minecraft:mule");
@Nullable public static final EntityType OCELOT = get("minecraft:ocelot");
@Nullable public static final EntityType PAINTING = get("minecraft:painting");
@Nullable public static final EntityType PARROT = get("minecraft:parrot");
@Nullable public static final EntityType PHANTOM = get("minecraft:phantom");
@Nullable public static final EntityType PIG = get("minecraft:pig");
@Nullable public static final EntityType PLAYER = get("minecraft:player");
@Nullable public static final EntityType POLAR_BEAR = get("minecraft:polar_bear");
@Nullable public static final EntityType POTION = get("minecraft:potion");
@Nullable public static final EntityType PUFFERFISH = get("minecraft:pufferfish");
@Nullable public static final EntityType RABBIT = get("minecraft:rabbit");
@Nullable public static final EntityType SALMON = get("minecraft:salmon");
@Nullable public static final EntityType SHEEP = get("minecraft:sheep");
@Nullable public static final EntityType SHULKER = get("minecraft:shulker");
@Nullable public static final EntityType SHULKER_BULLET = get("minecraft:shulker_bullet");
@Nullable public static final EntityType SILVERFISH = get("minecraft:silverfish");
@Nullable public static final EntityType SKELETON = get("minecraft:skeleton");
@Nullable public static final EntityType SKELETON_HORSE = get("minecraft:skeleton_horse");
@Nullable public static final EntityType SLIME = get("minecraft:slime");
@Nullable public static final EntityType SMALL_FIREBALL = get("minecraft:small_fireball");
@Nullable public static final EntityType SNOW_GOLEM = get("minecraft:snow_golem");
@Nullable public static final EntityType SNOWBALL = get("minecraft:snowball");
@Nullable public static final EntityType SPAWNER_MINECART = get("minecraft:spawner_minecart");
@Nullable public static final EntityType SPECTRAL_ARROW = get("minecraft:spectral_arrow");
@Nullable public static final EntityType SPIDER = get("minecraft:spider");
@Nullable public static final EntityType SQUID = get("minecraft:squid");
@Nullable public static final EntityType STRAY = get("minecraft:stray");
@Nullable public static final EntityType TNT = get("minecraft:tnt");
@Nullable public static final EntityType TNT_MINECART = get("minecraft:tnt_minecart");
@Nullable public static final EntityType TRIDENT = get("minecraft:trident");
@Nullable public static final EntityType TROPICAL_FISH = get("minecraft:tropical_fish");
@Nullable public static final EntityType TURTLE = get("minecraft:turtle");
@Nullable public static final EntityType VEX = get("minecraft:vex");
@Nullable public static final EntityType VILLAGER = get("minecraft:villager");
@Nullable public static final EntityType VINDICATOR = get("minecraft:vindicator");
@Nullable public static final EntityType WITCH = get("minecraft:witch");
@Nullable public static final EntityType WITHER = get("minecraft:wither");
@Nullable public static final EntityType WITHER_SKELETON = get("minecraft:wither_skeleton");
@Nullable public static final EntityType WITHER_SKULL = get("minecraft:wither_skull");
@Nullable public static final EntityType WOLF = get("minecraft:wolf");
@Nullable public static final EntityType ZOMBIE = get("minecraft:zombie");
@Nullable public static final EntityType ZOMBIE_HORSE = get("minecraft:zombie_horse");
@Nullable public static final EntityType ZOMBIE_PIGMAN = get("minecraft:zombie_pigman");
@Nullable public static final EntityType ZOMBIE_VILLAGER = get("minecraft:zombie_villager");
private EntityTypes() {
}
private static EntityType register(final String id) {
return register(new EntityType(id));
}
public static EntityType register(final EntityType entityType) {
return EntityType.REGISTRY.register(entityType.getId(), entityType);
}
public static @Nullable EntityType get(final String id) {
return EntityType.REGISTRY.get(id);
}

Datei anzeigen

@ -42,7 +42,7 @@ public class BlockTransformExtentTest {
@Before
public void setUp() throws Exception {
BlockTypes.register(new BlockType("worldedit:test"));
BlockType.REGISTRY.register("worldedit:test", new BlockType("worldedit:test"));
}
@Test

Datei anzeigen

@ -129,14 +129,14 @@ public class ForgeWorldEdit {
for (ResourceLocation name : Block.REGISTRY.getKeys()) {
String nameStr = name.toString();
if (!BlockType.REGISTRY.keySet().contains(nameStr)) {
BlockTypes.register(new BlockType(nameStr));
BlockType.REGISTRY.register(nameStr, new BlockType(nameStr));
}
}
for (ResourceLocation name : Item.REGISTRY.getKeys()) {
String nameStr = name.toString();
if (!ItemType.REGISTRY.keySet().contains(nameStr)) {
ItemTypes.register(new ItemType(nameStr));
ItemType.REGISTRY.register(nameStr, new ItemType(nameStr));
}
}
}

Datei anzeigen

@ -33,7 +33,6 @@ import com.sk89q.worldedit.sponge.adapter.AdapterLoadException;
import com.sk89q.worldedit.sponge.adapter.SpongeImplAdapter;
import com.sk89q.worldedit.sponge.adapter.SpongeImplLoader;
import com.sk89q.worldedit.sponge.config.SpongeConfiguration;
import com.sk89q.worldedit.world.item.ItemTypes;
import org.bstats.sponge.Metrics2;
import org.slf4j.Logger;
import org.spongepowered.api.Sponge;
@ -141,14 +140,14 @@ public class SpongeWorldEdit {
// TODO Handle blockstate stuff
String id = blockType.getId();
if (!com.sk89q.worldedit.world.block.BlockType.REGISTRY.keySet().contains(id)) {
com.sk89q.worldedit.world.block.BlockTypes.register(new com.sk89q.worldedit.world.block.BlockType(id));
com.sk89q.worldedit.world.block.BlockType.REGISTRY.register(id, new com.sk89q.worldedit.world.block.BlockType(id));
}
}
for (ItemType itemType : Sponge.getRegistry().getAllOf(ItemType.class)) {
String id = itemType.getId();
if (!com.sk89q.worldedit.world.item.ItemType.REGISTRY.keySet().contains(id)) {
ItemTypes.register(new com.sk89q.worldedit.world.item.ItemType(id));
com.sk89q.worldedit.world.item.ItemType.REGISTRY.register(id, new com.sk89q.worldedit.world.item.ItemType(id));
}
}