Actually initialize GameModes and WeatherTypes.

This commit is contained in:
wizjany 2019-05-02 00:08:19 -04:00
parent 5e81dd1c4c
commit 57c161a602
4 changed files with 22 additions and 14 deletions

View File

@ -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() {

View File

@ -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);
}
}

View File

@ -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");

View File

@ -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);
}
}