From 8087628ad163b67ccd12807134e59a124664f65e Mon Sep 17 00:00:00 2001 From: Jim Drey Date: Tue, 4 Sep 2012 09:33:22 -0400 Subject: [PATCH 1/3] Update for 1.3.1+. Resolve compile warnings. --- com/aranai/crafty/Crafty.java | 24 +++++++++++------------ com/aranai/crafty/PerformanceMonitor.java | 4 +--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/com/aranai/crafty/Crafty.java b/com/aranai/crafty/Crafty.java index f8de232..dc3e372 100644 --- a/com/aranai/crafty/Crafty.java +++ b/com/aranai/crafty/Crafty.java @@ -63,7 +63,7 @@ import org.bukkit.craftbukkit.Main; import org.bukkit.entity.Player; -import net.minecraft.server.MinecraftServer; +import net.minecraft.server.DedicatedServer; import net.minecraft.server.PropertyManager; import net.minecraft.server.StatisticList; import net.minecraft.server.ThreadServerApplication; @@ -109,8 +109,8 @@ public static final class UserActions { protected JLabel statusMsg; protected JLabel activeUserLabel; - protected JList activeUserList; - protected DefaultListModel activeUserListModel; + protected JList activeUserList; + protected DefaultListModel activeUserListModel; protected JScrollPane activeUserScroller; protected JPopupMenu activeUserPopup; @@ -143,7 +143,7 @@ public static final class UserActions { protected PerformanceMonitor pf; protected OutputStream out; protected ByteArrayInputStream in; - protected MinecraftServer ms; + protected DedicatedServer ms; protected static Logger logger; private ThreadServerApplication tsa; private CraftyExceptionHandler eh; @@ -274,8 +274,8 @@ public void actionPerformed(ActionEvent e) activeUserLabel.setPreferredSize(new Dimension(190, 24)); commandPanel.add(activeUserLabel); - activeUserListModel = new DefaultListModel(); - activeUserList = new JList(activeUserListModel); + activeUserListModel = new DefaultListModel(); + activeUserList = new JList(activeUserListModel); activeUserListModel.addElement("Nobody"); activeUserList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); activeUserList.setLayoutOrientation(JList.VERTICAL); @@ -750,7 +750,7 @@ public void startServer() StatisticList.a(); // Create the Minecraft server - ms = new MinecraftServer(options); + ms = new DedicatedServer(options); // Override the default ConsoleReader with our own bizarro version // Ours sits around for a bit and then returns null @@ -765,7 +765,7 @@ public String readLine() throws IOException }; // Create our own ThreadServerApplication - tsa = new ThreadServerApplication("Server thread", ms); + tsa = new ThreadServerApplication(ms, "Server thread"); // Catch exceptions from the TSA ourselves (mainly used to catch system.exit() events) tsa.setUncaughtExceptionHandler(eh); @@ -775,7 +775,7 @@ public String readLine() throws IOException logger = Logger.getLogger("Minecraft"); } catch (Exception exception) { - MinecraftServer.log.log(Level.SEVERE, "Failed to start the minecraft server", exception); + DedicatedServer.log.log(Level.SEVERE, "Failed to start the minecraft server", exception); } } } @@ -962,10 +962,10 @@ public static void queueConsoleCommand(String cmd) { logger.info("SecurityException"); return; } - MinecraftServer ms; + DedicatedServer ms; try { f.setAccessible(true); - ms = (MinecraftServer) f.get(cs); + ms = (DedicatedServer) f.get(cs); } catch (IllegalArgumentException ex) { logger.info("IllegalArgumentException"); return; @@ -974,7 +974,7 @@ public static void queueConsoleCommand(String cmd) { return; } - if ((!ms.isStopped) && (MinecraftServer.isRunning(ms))) { + if ((!ms.isStopped()) && (ms.isRunning())) { ms.issueCommand(cmd, ms); } } diff --git a/com/aranai/crafty/PerformanceMonitor.java b/com/aranai/crafty/PerformanceMonitor.java index 6197ada..9728f3b 100644 --- a/com/aranai/crafty/PerformanceMonitor.java +++ b/com/aranai/crafty/PerformanceMonitor.java @@ -13,8 +13,7 @@ public class PerformanceMonitor { static final Runtime runtime = Runtime.getRuntime (); - @SuppressWarnings("restriction") - public synchronized double getCpuUsage() + public synchronized double getCpuUsage() { if ( lastSystemTime == 0 ) { @@ -46,7 +45,6 @@ public synchronized double getCpuUsage() return (cpuUsage / availableProcessors) * 100.0; } - @SuppressWarnings("restriction") private void baselineCounters() { lastSystemTime = System.nanoTime(); From be7772555321de72e17434f39cb15e077b53bd49 Mon Sep 17 00:00:00 2001 From: Jim Drey Date: Wed, 3 Oct 2012 15:12:07 -0400 Subject: [PATCH 2/3] Moving folders to standard structure. --- .../aranai/crafty/ActiveUserActionListener.java | 0 .../com}/aranai/crafty/ActiveUserPopupListener.java | 0 {com => src/com}/aranai/crafty/CommandManager.java | 0 {com => src/com}/aranai/crafty/Crafty.java | 5 ++++- .../com}/aranai/crafty/CraftyExceptionHandler.java | 0 .../crafty/CraftyThreadServerApplication.java | 0 .../com}/aranai/crafty/CraftyWindowListener.java | 0 .../com}/aranai/crafty/ExitTrappedException.java | 0 .../com}/aranai/crafty/PerformanceMonitor.java | 0 {com => src/com}/aranai/crafty/StatusBar.java | 0 {com => src/com}/aranai/crafty/Theme.java | 0 {com => src/com}/aranai/crafty/ThemeBuilder.java | 0 {com => src/com}/aranai/crafty/ThemeManager.java | 0 {com => src/com}/aranai/crafty/resources/ban.png | Bin {com => src/com}/aranai/crafty/resources/deop.png | Bin {com => src/com}/aranai/crafty/resources/getip.png | Bin {com => src/com}/aranai/crafty/resources/icon.png | Bin {com => src/com}/aranai/crafty/resources/kick.png | Bin {com => src/com}/aranai/crafty/resources/op.png | Bin .../com}/aranai/crafty/resources/shutdown.png | Bin 20 files changed, 4 insertions(+), 1 deletion(-) rename {com => src/com}/aranai/crafty/ActiveUserActionListener.java (100%) rename {com => src/com}/aranai/crafty/ActiveUserPopupListener.java (100%) rename {com => src/com}/aranai/crafty/CommandManager.java (100%) rename {com => src/com}/aranai/crafty/Crafty.java (99%) rename {com => src/com}/aranai/crafty/CraftyExceptionHandler.java (100%) rename {com => src/com}/aranai/crafty/CraftyThreadServerApplication.java (100%) rename {com => src/com}/aranai/crafty/CraftyWindowListener.java (100%) rename {com => src/com}/aranai/crafty/ExitTrappedException.java (100%) rename {com => src/com}/aranai/crafty/PerformanceMonitor.java (100%) rename {com => src/com}/aranai/crafty/StatusBar.java (100%) rename {com => src/com}/aranai/crafty/Theme.java (100%) rename {com => src/com}/aranai/crafty/ThemeBuilder.java (100%) rename {com => src/com}/aranai/crafty/ThemeManager.java (100%) rename {com => src/com}/aranai/crafty/resources/ban.png (100%) rename {com => src/com}/aranai/crafty/resources/deop.png (100%) rename {com => src/com}/aranai/crafty/resources/getip.png (100%) rename {com => src/com}/aranai/crafty/resources/icon.png (100%) rename {com => src/com}/aranai/crafty/resources/kick.png (100%) rename {com => src/com}/aranai/crafty/resources/op.png (100%) rename {com => src/com}/aranai/crafty/resources/shutdown.png (100%) diff --git a/com/aranai/crafty/ActiveUserActionListener.java b/src/com/aranai/crafty/ActiveUserActionListener.java similarity index 100% rename from com/aranai/crafty/ActiveUserActionListener.java rename to src/com/aranai/crafty/ActiveUserActionListener.java diff --git a/com/aranai/crafty/ActiveUserPopupListener.java b/src/com/aranai/crafty/ActiveUserPopupListener.java similarity index 100% rename from com/aranai/crafty/ActiveUserPopupListener.java rename to src/com/aranai/crafty/ActiveUserPopupListener.java diff --git a/com/aranai/crafty/CommandManager.java b/src/com/aranai/crafty/CommandManager.java similarity index 100% rename from com/aranai/crafty/CommandManager.java rename to src/com/aranai/crafty/CommandManager.java diff --git a/com/aranai/crafty/Crafty.java b/src/com/aranai/crafty/Crafty.java similarity index 99% rename from com/aranai/crafty/Crafty.java rename to src/com/aranai/crafty/Crafty.java index dc3e372..9284538 100644 --- a/com/aranai/crafty/Crafty.java +++ b/src/com/aranai/crafty/Crafty.java @@ -1062,6 +1062,7 @@ public void prepAndPrintText(String text) int len = doc.getLength(); doc.insertString(len, text, tm.getCurrentTheme().getAttributeSet(Theme.TEXT_BASE)); + doc.insertString(len, "", tm.getCurrentTheme().getAttributeSet(Theme.TEXT_BASE)); //TODO test: this should prevent any lines that drop a reset code from bleeding into the rest of the console. // Style bracketed log indicators int at = text.indexOf("[INFO]"); @@ -1072,7 +1073,9 @@ public void prepAndPrintText(String text) if(at >= 0) { doc.setCharacterAttributes(len+at, 8, tm.getCurrentTheme().getAttributeSet(Theme.SYNTAX_SEVERE), false); } at = text.indexOf("[CRAFTY]"); if(at >= 0) { doc.setCharacterAttributes(len+at, 8, tm.getCurrentTheme().getAttributeSet(Theme.SYNTAX_CRAFTY), false); } - + + //TODO color codes here + // Style timestamp if(timestamp.length() > 0) { diff --git a/com/aranai/crafty/CraftyExceptionHandler.java b/src/com/aranai/crafty/CraftyExceptionHandler.java similarity index 100% rename from com/aranai/crafty/CraftyExceptionHandler.java rename to src/com/aranai/crafty/CraftyExceptionHandler.java diff --git a/com/aranai/crafty/CraftyThreadServerApplication.java b/src/com/aranai/crafty/CraftyThreadServerApplication.java similarity index 100% rename from com/aranai/crafty/CraftyThreadServerApplication.java rename to src/com/aranai/crafty/CraftyThreadServerApplication.java diff --git a/com/aranai/crafty/CraftyWindowListener.java b/src/com/aranai/crafty/CraftyWindowListener.java similarity index 100% rename from com/aranai/crafty/CraftyWindowListener.java rename to src/com/aranai/crafty/CraftyWindowListener.java diff --git a/com/aranai/crafty/ExitTrappedException.java b/src/com/aranai/crafty/ExitTrappedException.java similarity index 100% rename from com/aranai/crafty/ExitTrappedException.java rename to src/com/aranai/crafty/ExitTrappedException.java diff --git a/com/aranai/crafty/PerformanceMonitor.java b/src/com/aranai/crafty/PerformanceMonitor.java similarity index 100% rename from com/aranai/crafty/PerformanceMonitor.java rename to src/com/aranai/crafty/PerformanceMonitor.java diff --git a/com/aranai/crafty/StatusBar.java b/src/com/aranai/crafty/StatusBar.java similarity index 100% rename from com/aranai/crafty/StatusBar.java rename to src/com/aranai/crafty/StatusBar.java diff --git a/com/aranai/crafty/Theme.java b/src/com/aranai/crafty/Theme.java similarity index 100% rename from com/aranai/crafty/Theme.java rename to src/com/aranai/crafty/Theme.java diff --git a/com/aranai/crafty/ThemeBuilder.java b/src/com/aranai/crafty/ThemeBuilder.java similarity index 100% rename from com/aranai/crafty/ThemeBuilder.java rename to src/com/aranai/crafty/ThemeBuilder.java diff --git a/com/aranai/crafty/ThemeManager.java b/src/com/aranai/crafty/ThemeManager.java similarity index 100% rename from com/aranai/crafty/ThemeManager.java rename to src/com/aranai/crafty/ThemeManager.java diff --git a/com/aranai/crafty/resources/ban.png b/src/com/aranai/crafty/resources/ban.png similarity index 100% rename from com/aranai/crafty/resources/ban.png rename to src/com/aranai/crafty/resources/ban.png diff --git a/com/aranai/crafty/resources/deop.png b/src/com/aranai/crafty/resources/deop.png similarity index 100% rename from com/aranai/crafty/resources/deop.png rename to src/com/aranai/crafty/resources/deop.png diff --git a/com/aranai/crafty/resources/getip.png b/src/com/aranai/crafty/resources/getip.png similarity index 100% rename from com/aranai/crafty/resources/getip.png rename to src/com/aranai/crafty/resources/getip.png diff --git a/com/aranai/crafty/resources/icon.png b/src/com/aranai/crafty/resources/icon.png similarity index 100% rename from com/aranai/crafty/resources/icon.png rename to src/com/aranai/crafty/resources/icon.png diff --git a/com/aranai/crafty/resources/kick.png b/src/com/aranai/crafty/resources/kick.png similarity index 100% rename from com/aranai/crafty/resources/kick.png rename to src/com/aranai/crafty/resources/kick.png diff --git a/com/aranai/crafty/resources/op.png b/src/com/aranai/crafty/resources/op.png similarity index 100% rename from com/aranai/crafty/resources/op.png rename to src/com/aranai/crafty/resources/op.png diff --git a/com/aranai/crafty/resources/shutdown.png b/src/com/aranai/crafty/resources/shutdown.png similarity index 100% rename from com/aranai/crafty/resources/shutdown.png rename to src/com/aranai/crafty/resources/shutdown.png From 660f7729eec8725a3354d55935b4a5bf380dd28e Mon Sep 17 00:00:00 2001 From: Jim Drey Date: Wed, 3 Oct 2012 15:12:56 -0400 Subject: [PATCH 3/3] Update for 1.3.2. --- src/com/aranai/crafty/Crafty.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/aranai/crafty/Crafty.java b/src/com/aranai/crafty/Crafty.java index 9284538..3a355ae 100644 --- a/src/com/aranai/crafty/Crafty.java +++ b/src/com/aranai/crafty/Crafty.java @@ -55,9 +55,10 @@ import javax.swing.text.DefaultCaret; import javax.swing.text.StyledDocument; -import jline.console.ConsoleReader; -import joptsimple.OptionParser; -import joptsimple.OptionSet; +import org.bukkit.craftbukkit.libs.jline.console.ConsoleReader; +import org.bukkit.craftbukkit.libs.joptsimple.OptionException; +import org.bukkit.craftbukkit.libs.joptsimple.OptionParser; +import org.bukkit.craftbukkit.libs.joptsimple.OptionSet; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.Main; @@ -681,7 +682,7 @@ public void startServer() { this.cLog.log(Level.ALL, "Arg: "+s); } - } catch (joptsimple.OptionException ex) { + } catch (OptionException ex) { this.cLog.log(Level.SEVERE, ex.getLocalizedMessage()); }