Update the block/item category registries - this won't build until a Spigot PR is merged though.

This commit is contained in:
Matthew Miller 2019-02-17 13:30:40 +10:00
parent a09489a9af
commit 50a286b070
4 changed files with 87 additions and 89 deletions

View File

@ -41,13 +41,17 @@ import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.FuzzyBlockState; import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.item.ItemCategory;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -158,6 +162,17 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) { for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
EntityType.REGISTRY.register("minecraft:" + entityType.name().toLowerCase(), new EntityType("minecraft:" + entityType.name().toLowerCase())); EntityType.REGISTRY.register("minecraft:" + entityType.name().toLowerCase(), new EntityType("minecraft:" + entityType.name().toLowerCase()));
} }
// Tags
try {
for (org.bukkit.Tag<Material> blockTag : Bukkit.getTags(Tag.REGISTRY_BLOCKS, Material.class)) {
BlockCategory.REGISTRY.register(blockTag.getKey().toString(), new BlockCategory(blockTag.getKey().toString()));
}
for (org.bukkit.Tag<Material> itemTag : Bukkit.getTags(Tag.REGISTRY_ITEMS, Material.class)) {
ItemCategory.REGISTRY.register(itemTag.getKey().toString(), new ItemCategory(itemTag.getKey().toString()));
}
} catch (NoSuchMethodError e) {
getLogger().warning("The version of Spigot/Paper you are using doesn't support Tags. The usage of tags with WorldEdit will not work until you update.");
}
} }
private void loadConfig() { private void loadConfig() {

View File

@ -26,50 +26,42 @@ import javax.annotation.Nullable;
*/ */
public final class BlockCategories { public final class BlockCategories {
public static final BlockCategory ACACIA_LOGS = register("minecraft:acacia_logs"); public static final BlockCategory ACACIA_LOGS = get("minecraft:acacia_logs");
public static final BlockCategory ANVIL = register("minecraft:anvil"); public static final BlockCategory ANVIL = get("minecraft:anvil");
public static final BlockCategory BANNERS = register("minecraft:banners"); public static final BlockCategory BANNERS = get("minecraft:banners");
public static final BlockCategory BIRCH_LOGS = register("minecraft:birch_logs"); public static final BlockCategory BIRCH_LOGS = get("minecraft:birch_logs");
public static final BlockCategory BUTTONS = register("minecraft:buttons"); public static final BlockCategory BUTTONS = get("minecraft:buttons");
public static final BlockCategory CARPETS = register("minecraft:carpets"); public static final BlockCategory CARPETS = get("minecraft:carpets");
public static final BlockCategory CORALS = register("minecraft:corals"); public static final BlockCategory CORALS = get("minecraft:corals");
public static final BlockCategory CORAL_BLOCKS = register("minecraft:coral_blocks"); public static final BlockCategory CORAL_BLOCKS = get("minecraft:coral_blocks");
public static final BlockCategory DARK_OAK_LOGS = register("minecraft:dark_oak_logs"); public static final BlockCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs");
public static final BlockCategory DOORS = register("minecraft:doors"); public static final BlockCategory DOORS = get("minecraft:doors");
public static final BlockCategory ENDERMAN_HOLDABLE = register("minecraft:enderman_holdable"); public static final BlockCategory ENDERMAN_HOLDABLE = get("minecraft:enderman_holdable");
public static final BlockCategory FLOWER_POTS = register("minecraft:flower_pots"); public static final BlockCategory FLOWER_POTS = get("minecraft:flower_pots");
public static final BlockCategory ICE = register("minecraft:ice"); public static final BlockCategory ICE = get("minecraft:ice");
public static final BlockCategory JUNGLE_LOGS = register("minecraft:jungle_logs"); public static final BlockCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
public static final BlockCategory LEAVES = register("minecraft:leaves"); public static final BlockCategory LEAVES = get("minecraft:leaves");
public static final BlockCategory LOGS = register("minecraft:logs"); public static final BlockCategory LOGS = get("minecraft:logs");
public static final BlockCategory OAK_LOGS = register("minecraft:oak_logs"); public static final BlockCategory OAK_LOGS = get("minecraft:oak_logs");
public static final BlockCategory PLANKS = register("minecraft:planks"); public static final BlockCategory PLANKS = get("minecraft:planks");
public static final BlockCategory RAILS = register("minecraft:rails"); public static final BlockCategory RAILS = get("minecraft:rails");
public static final BlockCategory SAND = register("minecraft:sand"); public static final BlockCategory SAND = get("minecraft:sand");
public static final BlockCategory SAPLINGS = register("minecraft:saplings"); public static final BlockCategory SAPLINGS = get("minecraft:saplings");
public static final BlockCategory SLABS = register("minecraft:slabs"); public static final BlockCategory SLABS = get("minecraft:slabs");
public static final BlockCategory SPRUCE_LOGS = register("minecraft:spruce_logs"); public static final BlockCategory SPRUCE_LOGS = get("minecraft:spruce_logs");
public static final BlockCategory STAIRS = register("minecraft:stairs"); public static final BlockCategory STAIRS = get("minecraft:stairs");
public static final BlockCategory STONE_BRICKS = register("minecraft:stone_bricks"); public static final BlockCategory STONE_BRICKS = get("minecraft:stone_bricks");
public static final BlockCategory VALID_SPAWN = register("minecraft:valid_spawn"); public static final BlockCategory VALID_SPAWN = get("minecraft:valid_spawn");
public static final BlockCategory WOODEN_BUTTONS = register("minecraft:wooden_buttons"); public static final BlockCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons");
public static final BlockCategory WOODEN_DOORS = register("minecraft:wooden_doors"); public static final BlockCategory WOODEN_DOORS = get("minecraft:wooden_doors");
public static final BlockCategory WOODEN_PRESSURE_PLATES = register("minecraft:wooden_pressure_plates"); public static final BlockCategory WOODEN_PRESSURE_PLATES = get("minecraft:wooden_pressure_plates");
public static final BlockCategory WOODEN_SLABS = register("minecraft:wooden_slabs"); public static final BlockCategory WOODEN_SLABS = get("minecraft:wooden_slabs");
public static final BlockCategory WOODEN_STAIRS = register("minecraft:wooden_stairs"); public static final BlockCategory WOODEN_STAIRS = get("minecraft:wooden_stairs");
public static final BlockCategory WOOL = register("minecraft:wool"); public static final BlockCategory WOOL = get("minecraft:wool");
private BlockCategories() { private BlockCategories() {
} }
private static BlockCategory register(final String id) {
return register(new BlockCategory(id));
}
public static BlockCategory register(final BlockCategory tag) {
return BlockCategory.REGISTRY.register(tag.getId(), tag);
}
public static @Nullable BlockCategory get(final String id) { public static @Nullable BlockCategory get(final String id) {
return BlockCategory.REGISTRY.get(id); return BlockCategory.REGISTRY.get(id);
} }

View File

@ -26,48 +26,40 @@ import javax.annotation.Nullable;
*/ */
public final class ItemCategories { public final class ItemCategories {
public static final ItemCategory ACACIA_LOGS = register("minecraft:acacia_logs"); public static final ItemCategory ACACIA_LOGS = get("minecraft:acacia_logs");
public static final ItemCategory ANVIL = register("minecraft:anvil"); public static final ItemCategory ANVIL = get("minecraft:anvil");
public static final ItemCategory BANNERS = register("minecraft:banners"); public static final ItemCategory BANNERS = get("minecraft:banners");
public static final ItemCategory BIRCH_LOGS = register("minecraft:birch_logs"); public static final ItemCategory BIRCH_LOGS = get("minecraft:birch_logs");
public static final ItemCategory BOATS = register("minecraft:boats"); public static final ItemCategory BOATS = get("minecraft:boats");
public static final ItemCategory BUTTONS = register("minecraft:buttons"); public static final ItemCategory BUTTONS = get("minecraft:buttons");
public static final ItemCategory CARPETS = register("minecraft:carpets"); public static final ItemCategory CARPETS = get("minecraft:carpets");
public static final ItemCategory CORAL = register("minecraft:coral"); public static final ItemCategory CORAL = get("minecraft:coral");
public static final ItemCategory CORAL_PLANTS = register("minecraft:coral_plants"); public static final ItemCategory CORAL_PLANTS = get("minecraft:coral_plants");
public static final ItemCategory DARK_OAK_LOGS = register("minecraft:dark_oak_logs"); public static final ItemCategory DARK_OAK_LOGS = get("minecraft:dark_oak_logs");
public static final ItemCategory DOORS = register("minecraft:doors"); public static final ItemCategory DOORS = get("minecraft:doors");
public static final ItemCategory FISHES = register("minecraft:fishes"); public static final ItemCategory FISHES = get("minecraft:fishes");
public static final ItemCategory JUNGLE_LOGS = register("minecraft:jungle_logs"); public static final ItemCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
public static final ItemCategory LEAVES = register("minecraft:leaves"); public static final ItemCategory LEAVES = get("minecraft:leaves");
public static final ItemCategory LOGS = register("minecraft:logs"); public static final ItemCategory LOGS = get("minecraft:logs");
public static final ItemCategory OAK_LOGS = register("minecraft:oak_logs"); public static final ItemCategory OAK_LOGS = get("minecraft:oak_logs");
public static final ItemCategory PLANKS = register("minecraft:planks"); public static final ItemCategory PLANKS = get("minecraft:planks");
public static final ItemCategory RAILS = register("minecraft:rails"); public static final ItemCategory RAILS = get("minecraft:rails");
public static final ItemCategory SAND = register("minecraft:sand"); public static final ItemCategory SAND = get("minecraft:sand");
public static final ItemCategory SAPLINGS = register("minecraft:saplings"); public static final ItemCategory SAPLINGS = get("minecraft:saplings");
public static final ItemCategory SLABS = register("minecraft:slabs"); public static final ItemCategory SLABS = get("minecraft:slabs");
public static final ItemCategory SPRUCE_LOGS = register("minecraft:spruce_logs"); public static final ItemCategory SPRUCE_LOGS = get("minecraft:spruce_logs");
public static final ItemCategory STAIRS = register("minecraft:stairs"); public static final ItemCategory STAIRS = get("minecraft:stairs");
public static final ItemCategory STONE_BRICKS = register("minecraft:stone_bricks"); public static final ItemCategory STONE_BRICKS = get("minecraft:stone_bricks");
public static final ItemCategory WOODEN_BUTTONS = register("minecraft:wooden_buttons"); public static final ItemCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons");
public static final ItemCategory WOODEN_DOORS = register("minecraft:wooden_doors"); public static final ItemCategory WOODEN_DOORS = get("minecraft:wooden_doors");
public static final ItemCategory WOODEN_PRESSURE_PLATES = register("minecraft:wooden_pressure_plates"); public static final ItemCategory WOODEN_PRESSURE_PLATES = get("minecraft:wooden_pressure_plates");
public static final ItemCategory WOODEN_SLABS = register("minecraft:wooden_slabs"); public static final ItemCategory WOODEN_SLABS = get("minecraft:wooden_slabs");
public static final ItemCategory WOODEN_STAIRS = register("minecraft:wooden_stairs"); public static final ItemCategory WOODEN_STAIRS = get("minecraft:wooden_stairs");
public static final ItemCategory WOOL = register("minecraft:wool"); public static final ItemCategory WOOL = get("minecraft:wool");
private ItemCategories() { private ItemCategories() {
} }
private static ItemCategory register(final String id) {
return register(new ItemCategory(id));
}
public static ItemCategory register(final ItemCategory tag) {
return ItemCategory.REGISTRY.register(tag.getId(), tag);
}
public static @Nullable ItemCategory get(final String id) { public static @Nullable ItemCategory get(final String id) {
return ItemCategory.REGISTRY.get(id); return ItemCategory.REGISTRY.get(id);
} }

View File

@ -23,21 +23,20 @@ import javax.annotation.Nullable;
public class WeatherTypes { public class WeatherTypes {
public static final WeatherType CLEAR = register("clear"); static {
public static final WeatherType RAIN = register("rain"); // This isn't really a proper registry - so inject these before they're obtained.
public static final WeatherType THUNDER_STORM = register("thunder_storm"); WeatherType.REGISTRY.register("clear", new WeatherType("clear"));
WeatherType.REGISTRY.register("rain", new WeatherType("rain"));
WeatherType.REGISTRY.register("thunder_storm", new WeatherType("thunder_storm"));
}
@Nullable public static final WeatherType CLEAR = get("clear");
@Nullable public static final WeatherType RAIN = get("rain");
@Nullable public static final WeatherType THUNDER_STORM = get("thunder_storm");
private WeatherTypes() { private WeatherTypes() {
} }
private static WeatherType register(final String id) {
return register(new WeatherType(id));
}
public static WeatherType register(final WeatherType weatherType) {
return WeatherType.REGISTRY.register(weatherType.getId(), weatherType);
}
public static @Nullable WeatherType get(final String id) { public static @Nullable WeatherType get(final String id) {
return WeatherType.REGISTRY.get(id); return WeatherType.REGISTRY.get(id);
} }