From 5e944cd92003755c8686731724a61dfbb7fa69b6 Mon Sep 17 00:00:00 2001 From: Daniel Saukel Date: Thu, 25 Jan 2018 00:46:18 +0100 Subject: [PATCH] #333 1.13 preparation fixes --- .../github/dre2n/dungeonsxl/util/DColor.java | 41 +++++++++++-------- .../dre2n/dungeonsxl/util/LegacyUtil.java | 4 +- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/java/io/github/dre2n/dungeonsxl/util/DColor.java b/src/main/java/io/github/dre2n/dungeonsxl/util/DColor.java index 1b0ce900..51e9e5dc 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/util/DColor.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/util/DColor.java @@ -16,6 +16,7 @@ */ package io.github.dre2n.dungeonsxl.util; +import io.github.dre2n.commons.misc.EnumUtil; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; @@ -27,31 +28,35 @@ import org.bukkit.Material; */ public enum DColor { - BLACK(ChatColor.BLACK, DyeColor.BLACK, Material.valueOf("BLACK_WOOL")), - DARK_GRAY(ChatColor.DARK_GRAY, DyeColor.GRAY, Material.valueOf("GRAY_WOOL")), - LIGHT_GRAY(ChatColor.GRAY, DyeColor.SILVER, Material.valueOf("LIGHT_GRAY_WOOL")), - WHITE(ChatColor.WHITE, DyeColor.WHITE, Material.valueOf("WHITE_WOOL")), - DARK_GREEN(ChatColor.DARK_GREEN, DyeColor.GREEN, Material.valueOf("GREEN_WOOL")), - LIGHT_GREEN(ChatColor.GREEN, DyeColor.LIME, Material.valueOf("LIME_WOOL")), - CYAN(ChatColor.DARK_AQUA, DyeColor.CYAN, Material.valueOf("CYAN_WOOL")), - DARK_BLUE(ChatColor.DARK_BLUE, DyeColor.BLUE, Material.valueOf("BLUE_WOOL")), - LIGHT_BLUE(ChatColor.AQUA, DyeColor.LIGHT_BLUE, Material.valueOf("LIGHT_BLUE_WOOL")), - PURPLE(ChatColor.DARK_PURPLE, DyeColor.PURPLE, Material.valueOf("PURPLE_WOOL")), - MAGENTA(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA, Material.valueOf("MAGENTA_WOOL")), - DARK_RED(ChatColor.DARK_RED, DyeColor.BROWN, Material.valueOf("BROWN_WOOL")), - LIGHT_RED(ChatColor.RED, DyeColor.RED, Material.valueOf("RED_WOOL")), - ORANGE(ChatColor.GOLD, DyeColor.ORANGE, Material.valueOf("ORANGE_WOOL")), - YELLOW(ChatColor.YELLOW, DyeColor.YELLOW, Material.valueOf("YELLOW_WOOL")), - DEFAULT(ChatColor.BLUE, DyeColor.PINK, Material.valueOf("PINK_WOOL")); + BLACK(ChatColor.BLACK, DyeColor.BLACK, "BLACK_WOOL"), + DARK_GRAY(ChatColor.DARK_GRAY, DyeColor.GRAY, "GRAY_WOOL"), + LIGHT_GRAY(ChatColor.GRAY, DyeColor.SILVER, "LIGHT_GRAY_WOOL"), + WHITE(ChatColor.WHITE, DyeColor.WHITE, "WHITE_WOOL"), + DARK_GREEN(ChatColor.DARK_GREEN, DyeColor.GREEN, "GREEN_WOOL"), + LIGHT_GREEN(ChatColor.GREEN, DyeColor.LIME, "LIME_WOOL"), + CYAN(ChatColor.DARK_AQUA, DyeColor.CYAN, "CYAN_WOOL"), + DARK_BLUE(ChatColor.DARK_BLUE, DyeColor.BLUE, "BLUE_WOOL"), + LIGHT_BLUE(ChatColor.AQUA, DyeColor.LIGHT_BLUE, "LIGHT_BLUE_WOOL"), + PURPLE(ChatColor.DARK_PURPLE, DyeColor.PURPLE, "PURPLE_WOOL"), + MAGENTA(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA, "MAGENTA_WOOL"), + DARK_RED(ChatColor.DARK_RED, DyeColor.BROWN, "BROWN_WOOL"), + LIGHT_RED(ChatColor.RED, DyeColor.RED, "RED_WOOL"), + ORANGE(ChatColor.GOLD, DyeColor.ORANGE, "ORANGE_WOOL"), + YELLOW(ChatColor.YELLOW, DyeColor.YELLOW, "YELLOW_WOOL"), + DEFAULT(ChatColor.BLUE, DyeColor.PINK, "PINK_WOOL"); private ChatColor chat; private DyeColor dye; private Material woolMaterial; - DColor(ChatColor chat, DyeColor dye, Material woolMaterial) { + DColor(ChatColor chat, DyeColor dye, String woolMaterial) { this.chat = chat; this.dye = dye; - this.woolMaterial = woolMaterial; + if (EnumUtil.isValidEnum(Material.class, woolMaterial)) { + this.woolMaterial = Material.valueOf(woolMaterial); + } else { + this.woolMaterial = LegacyUtil.LEGACY_WOOL; + } } /** diff --git a/src/main/java/io/github/dre2n/dungeonsxl/util/LegacyUtil.java b/src/main/java/io/github/dre2n/dungeonsxl/util/LegacyUtil.java index f6fa03d9..a22f2335 100644 --- a/src/main/java/io/github/dre2n/dungeonsxl/util/LegacyUtil.java +++ b/src/main/java/io/github/dre2n/dungeonsxl/util/LegacyUtil.java @@ -39,8 +39,8 @@ public class LegacyUtil { public static Material GOLDEN_LEGGINGS = is1_13 ? Material.valueOf("GOLDEN_LEGGINGS") : Material.valueOf("GOLD_LEGGINGS"); public static Material GOLDEN_BOOTS = is1_13 ? Material.valueOf("GOLDEN_BOOTS") : Material.valueOf("GOLD_BOOTS"); public static Material WRITABLE_BOOK = is1_13 ? Material.valueOf("WRITABLE_BOOK") : Material.valueOf("BOOK_AND_QUILL"); - private static Material LEGACY_WOOL = Material.valueOf("WOOL"); - private static Material LEGACY_SIGN_POST = Material.valueOf("SIGN_POST"); + public static Material LEGACY_WOOL = Material.valueOf("WOOL"); + public static Material LEGACY_SIGN_POST = Material.valueOf("SIGN_POST"); public static ItemStack RAW_PLACEHOLDER = is1_13 ? new ItemStack(Material.valueOf("BLACK_STAINED_GLASS_PANE")) : new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 15); public static ItemStack RAW_PLAYER_HEAD = is1_13 ? new ItemStack(Material.valueOf("PLAYER_HEAD")) : new ItemStack(Material.valueOf("SKULL"), 1, (short) 3);