From 57c161a602f6537c9b32ed36d655bb10b91aae7d Mon Sep 17 00:00:00 2001 From: wizjany Date: Thu, 2 May 2019 00:08:19 -0400 Subject: [PATCH] Actually initialize GameModes and WeatherTypes. --- .../worldedit/bukkit/WorldEditPlugin.java | 5 ++++ .../worldedit/world/block/BlockTypes.java | 3 ++- .../worldedit/world/gamemode/GameModes.java | 2 +- .../worldedit/world/weather/WeatherTypes.java | 26 ++++++++++--------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index f53223a53..ff0b03a21 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -44,8 +44,10 @@ 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.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemCategory; import com.sk89q.worldedit.world.item.ItemType; +import com.sk89q.worldedit.world.weather.WeatherTypes; import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -173,6 +175,9 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { EntityType.REGISTRY.register("minecraft:" + lowerCaseMcId, new EntityType("minecraft:" + lowerCaseMcId)); } } + // ... :| + GameModes.get(""); + WeatherTypes.get(""); } private void setupTags() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index 2d9f1a4ba..1b8b44bcc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -628,7 +628,8 @@ public final class BlockTypes { private BlockTypes() { } - public static @Nullable BlockType get(final String id) { + @Nullable + public static BlockType get(final String id) { return BlockType.REGISTRY.get(id); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/gamemode/GameModes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/gamemode/GameModes.java index 0e5673221..f3a0fc4b2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/gamemode/GameModes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/gamemode/GameModes.java @@ -21,7 +21,7 @@ package com.sk89q.worldedit.world.gamemode; import javax.annotation.Nullable; -public class GameModes { +public final class GameModes { public static final GameMode SURVIVAL = register("survival"); public static final GameMode CREATIVE = register("creative"); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java index d7450610d..dd0f07e27 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/weather/WeatherTypes.java @@ -21,23 +21,25 @@ package com.sk89q.worldedit.world.weather; import javax.annotation.Nullable; -public class WeatherTypes { +public final class WeatherTypes { - static { - // This isn't really a proper registry - so inject these before they're obtained. - 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"); + public static final WeatherType CLEAR = register("clear"); + public static final WeatherType RAIN = register("rain"); + public static final WeatherType THUNDER_STORM = register("thunder_storm"); private WeatherTypes() { } - public static @Nullable WeatherType get(final String id) { + private static WeatherType register(String id) { + return register(new WeatherType(id)); + } + + public static WeatherType register(WeatherType weather) { + return WeatherType.REGISTRY.register(weather.getId(), weather); + } + + @Nullable + public static WeatherType get(final String id) { return WeatherType.REGISTRY.get(id); } }