Console Colour Support

This commit is contained in:
Sauilitired 2014-09-22 14:35:46 +02:00
parent e4e9b80c02
commit ca858ff88e
3 changed files with 259 additions and 64 deletions

View File

@ -5,8 +5,12 @@
<artifact name="plotsquared" />
</artifacts-to-build>
</component>
<component name="BookmarkManager">
<bookmark url="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java" line="37" mnemonic="2" />
</component>
<component name="ChangeListManager">
<list default="true" id="f6aaf715-4424-4f9e-96dc-b47edea10520" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java" afterPath="$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
</list>
@ -44,7 +48,7 @@
<file leaf-file-name="encodings.xml" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/.idea/encodings.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="187">
<state vertical-scroll-proportion="0.0" vertical-offset="85" max-vertical-offset="187">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</state>
@ -54,7 +58,7 @@
<file leaf-file-name="PlotId.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotId.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="629">
<state vertical-scroll-proportion="0.0" vertical-offset="68" max-vertical-offset="629">
<caret line="4" column="13" selection-start-line="4" selection-start-column="13" selection-end-line="4" selection-end-column="13" />
<folding />
</state>
@ -64,12 +68,9 @@
<file leaf-file-name="Plot.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/Plot.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="1900" max-vertical-offset="3757">
<caret line="173" column="43" selection-start-line="173" selection-start-column="43" selection-end-line="173" selection-end-column="43" />
<folding>
<element signature="e#4212#4213#0" expanded="true" />
<element signature="e#4262#4263#0" expanded="true" />
</folding>
<state vertical-scroll-proportion="0.0" vertical-offset="2941" max-vertical-offset="4182">
<caret line="173" column="29" selection-start-line="173" selection-start-column="29" selection-end-line="173" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
@ -77,8 +78,8 @@
<file leaf-file-name="PlotMain.java" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="2.3176856" vertical-offset="9148" max-vertical-offset="11611">
<caret line="694" column="10" selection-start-line="694" selection-start-column="10" selection-end-line="694" selection-end-column="10" />
<state vertical-scroll-proportion="0.4268559" vertical-offset="7089" max-vertical-offset="11798">
<caret line="465" column="7" selection-start-line="465" selection-start-column="7" selection-end-line="465" selection-end-column="7" />
<folding>
<element signature="imports" expanded="true" />
</folding>
@ -86,10 +87,20 @@
</provider>
</entry>
</file>
<file leaf-file-name="ConsoleColors.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="136" max-vertical-offset="1598">
<caret line="42" column="40" selection-start-line="42" selection-start-column="40" selection-end-line="42" selection-end-column="40" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="plotsquared.xml" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/plotsquared.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="2856">
<state vertical-scroll-proportion="0.0" vertical-offset="408" max-vertical-offset="2856">
<caret line="24" column="30" selection-start-line="24" selection-start-column="30" selection-end-line="24" selection-end-column="30" />
<folding />
</state>
@ -99,7 +110,7 @@
<file leaf-file-name="Settings.java" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/Settings.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="1071">
<state vertical-scroll-proportion="0.0" vertical-offset="374" max-vertical-offset="1241">
<caret line="22" column="13" selection-start-line="22" selection-start-column="13" selection-end-line="22" selection-end-column="13" />
<folding />
</state>
@ -124,6 +135,7 @@
<option value="$PROJECT_DIR$/src/com/intellectualcrafters/plot/database/PlotMeConverter.java" />
<option value="$PROJECT_DIR$/src/com/intellectualcrafters/plot/PlotMain.java" />
<option value="$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/Plot.java" />
<option value="$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java" />
<option value="$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java" />
</list>
</option>
@ -160,6 +172,21 @@
<sortByType />
</navigator>
<panes>
<pane id="PackagesPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="plot_news" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="plot_news1" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewModuleNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<PATH>
@ -234,21 +261,6 @@
</PATH>
</subPane>
</pane>
<pane id="PackagesPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="plot_news" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="plot_news1" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewModuleNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
@ -419,7 +431,8 @@
<updated>1411382235722</updated>
<workItem from="1411382238709" duration="182000" />
<workItem from="1411382421959" duration="656000" />
<workItem from="1411383098267" duration="2536000" />
<workItem from="1411383098267" duration="5030000" />
<workItem from="1411389312646" duration="17000" />
</task>
<task id="LOCAL-00001" summary="First Commit">
<created>1411382351159</created>
@ -445,15 +458,19 @@
<created>1411386181908</created>
<updated>1411386181908</updated>
</task>
<option name="localTasksCounter" value="7" />
<task id="LOCAL-00007" summary="Removed web stuff (caused crash)">
<created>1411386295962</created>
<updated>1411386295962</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="3374000" />
<option name="totallyTimeSpent" value="5885000" />
</component>
<component name="ToolWindowManager">
<frame x="-6" y="-6" width="1932" height="1062" extended-state="6" />
<editor active="true" />
<editor active="false" />
<layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@ -466,17 +483,17 @@
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3291536" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3291536" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
@ -508,6 +525,72 @@
<breakpoint-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/.idea/compiler.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="493">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.idea/encodings.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="85" max-vertical-offset="187">
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotId.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="68" max-vertical-offset="629">
<caret line="4" column="13" selection-start-line="4" selection-start-column="13" selection-end-line="4" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/Plot.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="2941" max-vertical-offset="4182">
<caret line="173" column="29" selection-start-line="173" selection-start-column="29" selection-end-line="173" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="7089" max-vertical-offset="11798">
<caret line="442" column="0" selection-start-line="442" selection-start-column="0" selection-end-line="448" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="136" max-vertical-offset="1598">
<caret line="42" column="40" selection-start-line="42" selection-start-column="40" selection-end-line="42" selection-end-column="40" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/plotsquared.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="408" max-vertical-offset="2856">
<caret line="24" column="30" selection-start-line="24" selection-start-column="30" selection-end-line="24" selection-end-column="30" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/Settings.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="374" max-vertical-offset="1241">
<caret line="22" column="13" selection-start-line="22" selection-start-column="13" selection-end-line="22" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.idea/compiler.xml">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="493">
@ -552,7 +635,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.05654102" vertical-offset="0" max-vertical-offset="902">
<caret line="3" column="0" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
<folding />
</state>
</provider>
<provider editor-type-id="MarkdownPreviewEditor">
@ -577,12 +659,9 @@
</entry>
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/Plot.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="1900" max-vertical-offset="3757">
<caret line="173" column="43" selection-start-line="173" selection-start-column="43" selection-end-line="173" selection-end-column="43" />
<folding>
<element signature="e#4212#4213#0" expanded="true" />
<element signature="e#4262#4263#0" expanded="true" />
</folding>
<state vertical-scroll-proportion="0.0" vertical-offset="2941" max-vertical-offset="4182">
<caret line="173" column="29" selection-start-line="173" selection-start-column="29" selection-end-line="173" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
@ -602,10 +681,26 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="136" max-vertical-offset="1598">
<caret line="42" column="40" selection-start-line="42" selection-start-column="40" selection-end-line="42" selection-end-column="40" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/plotsquared.properties">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="929">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="2.3176856" vertical-offset="9148" max-vertical-offset="11611">
<caret line="694" column="10" selection-start-line="694" selection-start-column="10" selection-end-line="694" selection-end-column="10" />
<state vertical-scroll-proportion="0.4268559" vertical-offset="7089" max-vertical-offset="11798">
<caret line="465" column="7" selection-start-line="465" selection-start-column="7" selection-end-line="465" selection-end-column="7" />
<folding>
<element signature="imports" expanded="true" />
</folding>

View File

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

View File

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