diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 90260667a..ec162ab84 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,8 +5,12 @@ + + + + @@ -44,7 +48,7 @@ - + @@ -54,7 +58,7 @@ - + @@ -64,12 +68,9 @@ - - - - - - + + + @@ -77,8 +78,8 @@ - - + + @@ -86,10 +87,20 @@ + + + + + + + + + + - + @@ -99,7 +110,7 @@ - + @@ -124,6 +135,7 @@ @@ -160,6 +172,21 @@ + + + + + + + + + + + @@ -234,21 +261,6 @@ - - - - - - - - - - - @@ -419,7 +431,8 @@ 1411382235722 - + + 1411382351159 @@ -445,15 +458,19 @@ 1411386181908 1411386181908 - - - + @@ -466,17 +483,17 @@ - - + + @@ -508,6 +525,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -552,7 +635,6 @@ - @@ -577,12 +659,9 @@ - - - - - - + + + @@ -602,10 +681,26 @@ + + + + + + + + + + + + + + + + - - + + diff --git a/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java b/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java new file mode 100644 index 000000000..d299992bf --- /dev/null +++ b/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java @@ -0,0 +1,88 @@ +package com.intellectualcrafters.plot; + +import org.bukkit.ChatColor; + +/** + * Created by Citymonstret on 2014-09-22. + */ +public class ConsoleColors { + + public static final String ANSI_RESET = "\u001B[0m"; + public static final String ANSI_BLACK = "\u001B[30m"; + public static final String ANSI_RED = "\u001B[31m"; + public static final String ANSI_GREEN = "\u001B[32m"; + public static final String ANSI_YELLOW = "\u001B[33m"; + public static final String ANSI_BLUE = "\u001B[34m"; + public static final String ANSI_PURPLE = "\u001B[35m"; + public static final String ANSI_CYAN = "\u001B[36m"; + public static final String ANSI_WHITE = "\u001B[37m"; + public static final String ANSI_BOLD = "\033[1m"; + public static final String ANSI_UNDERLINE = "\033[0m"; + public static final String ANSI_ITALIC = "\033[3m]"; + + public static String fromString(String input) { + input = input + .replaceAll("&0", fromChatColor(ChatColor.BLACK)) + .replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE)) + .replaceAll("&2", fromChatColor(ChatColor.DARK_GREEN)) + .replaceAll("&3", fromChatColor(ChatColor.DARK_AQUA)) + .replaceAll("&4", fromChatColor(ChatColor.DARK_RED)) + .replaceAll("&5", fromChatColor(ChatColor.DARK_PURPLE)) + .replaceAll("&6", fromChatColor(ChatColor.GOLD)) + .replaceAll("&7", fromChatColor(ChatColor.GRAY)) + .replaceAll("&8", fromChatColor(ChatColor.DARK_GRAY)) + .replaceAll("&9", fromChatColor(ChatColor.BLUE)) + .replaceAll("&a", fromChatColor(ChatColor.GREEN)) + .replaceAll("&b", fromChatColor(ChatColor.AQUA)) + .replaceAll("&c", fromChatColor(ChatColor.RED)) + .replaceAll("&d", fromChatColor(ChatColor.LIGHT_PURPLE)) + .replaceAll("&e", fromChatColor(ChatColor.YELLOW)) + .replaceAll("&f", fromChatColor(ChatColor.WHITE)) + .replaceAll("&k", fromChatColor(ChatColor.MAGIC)) + .replaceAll("&l", fromChatColor(ChatColor.BOLD)) + .replaceAll("&m", fromChatColor(ChatColor.STRIKETHROUGH)) + .replaceAll("&n", fromChatColor(ChatColor.UNDERLINE)) + .replaceAll("&o", fromChatColor(ChatColor.ITALIC)) + .replaceAll("&r", fromChatColor(ChatColor.RESET)) + ; + return input + ANSI_RESET; + } + + public static String fromChatColor(ChatColor color) { + switch(color) { + case RESET: + return ANSI_RESET; + case GRAY: + case DARK_GRAY: + return ANSI_WHITE; + case BLACK: + return ANSI_BLACK; + case DARK_RED: + case RED: + return ANSI_RED; + case GOLD: + case YELLOW: + return ANSI_YELLOW; + case DARK_GREEN: + case GREEN: + return ANSI_GREEN; + case AQUA: + case DARK_AQUA: + return ANSI_CYAN; + case LIGHT_PURPLE: + case DARK_PURPLE: + return ANSI_PURPLE; + case BLUE: + case DARK_BLUE: + return ANSI_BLUE; + case UNDERLINE: + return ANSI_UNDERLINE; + case ITALIC: + return ANSI_ITALIC; + case BOLD: + return ANSI_BOLD; + default: + return ""; + } + } +} diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index 7cc51bb9e..bd9161ef0 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -248,6 +248,27 @@ public class PlotMain extends JavaPlugin { } } + + private void setupLogger() { + File log = new File(getMain().getDataFolder() + File.separator + "logs" + File.separator + "plots.log"); + if (!log.exists()) { + try { + if (!new File(getMain().getDataFolder() + File.separator + "logs").mkdirs()) { + sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create logs folder. Do it manually."); + } + if (log.createNewFile()) { + FileWriter writer = new FileWriter(log); + writer.write("Created at: " + new Date().toString() + "\n\n\n"); + writer.close(); + } + } catch (IOException e) { + + e.printStackTrace(); + } + } + Logger.setup(log); + Logger.add(LogLevel.GENERAL, "Logger enabled"); + } /** * On Load. * TODO: Load updates async @@ -255,26 +276,8 @@ public class PlotMain extends JavaPlugin { @Override @SuppressWarnings("deprecation") public void onEnable() { - { - File log = new File(getMain().getDataFolder() + File.separator + "logs" + File.separator + "plots.log"); - if (!log.exists()) { - try { - if (!new File(getMain().getDataFolder() + File.separator + "logs").mkdirs()) { - sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create logs folder. Do it manually."); - } - if (log.createNewFile()) { - FileWriter writer = new FileWriter(log); - writer.write("Created at: " + new Date().toString() + "\n\n\n"); - writer.close(); - } - } catch (IOException e) { + setupLogger(); - e.printStackTrace(); - } - } - Logger.setup(log); - Logger.add(LogLevel.GENERAL, "Logger enabled"); - } configs(); // TODO make this configurable @@ -388,10 +391,15 @@ public class PlotMain extends JavaPlugin { 100L, 1L); if(Web.ENABLED) { - sendConsoleSenderMessage("This is not yet implemented..."); + sendConsoleSenderMessage(C.PREFIX.s() + "This is not yet implemented..."); } } + + private void options(boolean verbose) { + + } + /** * Get MySQL Connection * @@ -432,7 +440,11 @@ public class PlotMain extends JavaPlugin { * @param string message */ public static void sendConsoleSenderMessage(String string) { - getMain().getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', string)); + if(getMain().getServer().getConsoleSender() == null) { + System.out.println(ChatColor.stripColor(ConsoleColors.fromString(string))); + } else { + getMain().getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', string)); + } } public static boolean teleportPlayer(Player player, Location from, Plot plot) { @@ -589,7 +601,7 @@ public class PlotMain extends JavaPlugin { World world = Bukkit.getWorld(w); try { if(world.getLoadedChunks().length < 1) { - return; + continue; } for (Chunk chunk : world.getLoadedChunks()) { for (Entity entity : chunk.getEntities()){