Skip to content
This repository was archived by the owner on Dec 9, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions com/aranai/crafty/Crafty.java → src/com/aranai/crafty/Crafty.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@
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;
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;
Expand Down Expand Up @@ -109,8 +110,8 @@ public static final class UserActions {
protected JLabel statusMsg;

protected JLabel activeUserLabel;
protected JList activeUserList;
protected DefaultListModel activeUserListModel;
protected JList<String> activeUserList;
protected DefaultListModel<String> activeUserListModel;
protected JScrollPane activeUserScroller;
protected JPopupMenu activeUserPopup;

Expand Down Expand Up @@ -143,7 +144,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;
Expand Down Expand Up @@ -274,8 +275,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<String>();
activeUserList = new JList<String>(activeUserListModel);
activeUserListModel.addElement("Nobody");
activeUserList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
activeUserList.setLayoutOrientation(JList.VERTICAL);
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -750,7 +751,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
Expand All @@ -765,7 +766,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);
Expand All @@ -775,7 +776,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);
}
}
}
Expand Down Expand Up @@ -962,10 +963,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;
Expand All @@ -974,7 +975,7 @@ public static void queueConsoleCommand(String cmd) {
return;
}

if ((!ms.isStopped) && (MinecraftServer.isRunning(ms))) {
if ((!ms.isStopped()) && (ms.isRunning())) {
ms.issueCommand(cmd, ms);
}
}
Expand Down Expand Up @@ -1062,6 +1063,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]");
Expand All @@ -1072,7 +1074,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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down Expand Up @@ -46,7 +45,6 @@ public synchronized double getCpuUsage()
return (cpuUsage / availableProcessors) * 100.0;
}

@SuppressWarnings("restriction")
private void baselineCounters()
{
lastSystemTime = System.nanoTime();
Expand Down