Move MinecraftColor to core plugin
This commit is contained in:
@@ -12,7 +12,7 @@ import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import nl.interestingcorner.coordinates.db.Coordinate;
|
||||
import nl.interestingcorner.coordinates.db.CoordinatesDatabaseManager;
|
||||
import nl.interestingcorner.coordinates.db.MinecraftColor;
|
||||
import nl.interestingcorner.core.MinecraftColor;
|
||||
|
||||
public class AddCoordinateCommandHandler implements CoordinatesCommandHandler {
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package nl.interestingcorner.coordinates.db;
|
||||
|
||||
import nl.interestingcorner.core.MinecraftColor;
|
||||
|
||||
/**
|
||||
* +-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+------+-----+---------+----------------+
|
||||
* | Field | Type | Null | Key | Default | Extra |
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import nl.interestingcorner.core.MinecraftColor;
|
||||
|
||||
public enum CoordinatesDatabaseManager implements nl.interestingcorner.core.db.DatabaseInitializeListener{
|
||||
|
||||
INSTANCE;
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
package nl.interestingcorner.coordinates.db;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public enum MinecraftColor {
|
||||
DARK_RED("dark_red"),
|
||||
RED("red"),
|
||||
BLACK("black"),
|
||||
BLUE("blue"),
|
||||
AQUA("aqua"),
|
||||
DARK_AQUA("dark_aqua"),
|
||||
GREEN("green"),
|
||||
GOLD("gold"),
|
||||
DARK_PURPLE("dark_purple"),
|
||||
LIGHT_PURPLE("light_purple"),
|
||||
YELLOW("yellow"),
|
||||
DARK_GREEN("dark_green"),
|
||||
GRAY("gray"),
|
||||
DARK_GRAY("dark_gray"),
|
||||
WHITE("white"),
|
||||
DARK_BLUE("dark_blue");
|
||||
|
||||
private final String name;
|
||||
|
||||
private static final HashMap<MinecraftColor, Material> materialsMap = new HashMap<>() {{
|
||||
put(DARK_RED, Material.RED_WOOL);
|
||||
put(RED, Material.RED_WOOL);
|
||||
put(BLACK, Material.BLACK_WOOL);
|
||||
put(BLUE, Material.BLUE_WOOL);
|
||||
put(AQUA, Material.LIGHT_BLUE_WOOL);
|
||||
put(DARK_AQUA, Material.CYAN_WOOL);
|
||||
put(GREEN, Material.GREEN_WOOL);
|
||||
put(GOLD, Material.YELLOW_WOOL);
|
||||
put(DARK_PURPLE, Material.PURPLE_WOOL);
|
||||
put(LIGHT_PURPLE, Material.MAGENTA_WOOL);
|
||||
put(YELLOW, Material.YELLOW_WOOL);
|
||||
put(DARK_GREEN, Material.LIME_WOOL);
|
||||
put(GRAY, Material.LIGHT_GRAY_WOOL);
|
||||
put(DARK_GRAY, Material.GRAY_WOOL);
|
||||
put(WHITE, Material.WHITE_WOOL);
|
||||
put(DARK_BLUE, Material.BLUE_WOOL);
|
||||
}};
|
||||
|
||||
private static final HashMap<MinecraftColor, String> colorCodesMap = new HashMap<>() {{
|
||||
put(DARK_RED, "§4");
|
||||
put(RED, "§c");
|
||||
put(BLACK, "§0");
|
||||
put(BLUE, "§9");
|
||||
put(AQUA, "§b");
|
||||
put(DARK_AQUA, "§3");
|
||||
put(GREEN, "§a");
|
||||
put(GOLD, "§6");
|
||||
put(DARK_PURPLE, "§5");
|
||||
put(LIGHT_PURPLE, "§d");
|
||||
put(YELLOW, "§e");
|
||||
put(DARK_GREEN, "§2");
|
||||
put(GRAY, "§7");
|
||||
put(DARK_GRAY, "§8");
|
||||
put(WHITE, "§f");
|
||||
put(DARK_BLUE, "§1");
|
||||
}};
|
||||
|
||||
MinecraftColor(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean equalsName(String otherName) {
|
||||
return name.equalsIgnoreCase(otherName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a MinecraftColor from a string value
|
||||
*
|
||||
* @param name the name to find the MinecraftColor from
|
||||
* @return the MinecraftColor if found, null if not found.
|
||||
*/
|
||||
public static MinecraftColor fromString(String name) {
|
||||
if (name == null) {
|
||||
return WHITE;
|
||||
}
|
||||
|
||||
for (MinecraftColor color : MinecraftColor.values()) {
|
||||
if (color.equalsName(name)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
return WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given name is a valid color value.
|
||||
* @param name the name to check
|
||||
* @return true if it's a valid color value, false otherwise
|
||||
*/
|
||||
public static boolean isValidColor(String name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (MinecraftColor color : values()) {
|
||||
if (color.equalsName(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this MinecraftColor to a corresponding Material.
|
||||
*
|
||||
* @return the Material corresponding to this MinecraftColor
|
||||
*/
|
||||
public Material toMaterial() {
|
||||
return materialsMap.get(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this MinecraftColor to a corresponding Minecraft color code.
|
||||
* @return
|
||||
*/
|
||||
public String toColorCode() {
|
||||
return colorCodesMap.get(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import nl.interestingcorner.coordinates.db.Coordinate;
|
||||
import nl.interestingcorner.coordinates.db.MinecraftColor;
|
||||
import nl.interestingcorner.core.MinecraftColor;
|
||||
|
||||
public class CoordinatesGUI {
|
||||
public static void open(Player player, List<Coordinate> coordinates) {
|
||||
|
||||
Reference in New Issue
Block a user