Moved from jd-gui to jad

This commit is contained in:
Erik Broes 2010-12-28 20:52:24 +01:00
parent 656f8a8e40
commit c49239fa8c
2 changed files with 511 additions and 474 deletions

View file

@ -1,6 +1,6 @@
package net.minecraft.server; package net.minecraft.server;
import java.awt.GraphicsEnvironment;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
@ -9,83 +9,84 @@ import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
public class MinecraftServer public class MinecraftServer
implements ICommandListener, Runnable { implements ICommandListener, Runnable {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
public static HashMap<String, Integer> b = new HashMap<String, Integer>(); public static HashMap b = new HashMap();
public NetworkListenThread c; public NetworkListenThread c;
public PropertyManager d; public PropertyManager d;
public WorldServer e; public WorldServer e;
public ServerConfigurationManager f; public ServerConfigurationManager f;
private boolean o = true; private boolean o;
public boolean g = false; public boolean g;
int h = 0; int h;
public String i; public String i;
public int j; public int j;
private List p = new ArrayList(); private List p;
private List q = Collections.synchronizedList(new ArrayList()); private List q;
public EntityTracker k; public EntityTracker k;
public boolean l; public boolean l;
public boolean m; public boolean m;
public boolean n; public boolean n;
public CraftServer server; // CraftBukkit public CraftServer server; // CraftBukkit
public MinecraftServer() { public MinecraftServer() {
o = true;
g = false;
h = 0;
p = new ArrayList();
q = Collections.synchronizedList(new ArrayList());
new ThreadSleepForever(this); new ThreadSleepForever(this);
} }
// CraftBukkit: Decompiler might miss this method, your IDE won't complain but you // CraftBukkit: added throws UnknownHostException
// can't run without it!
public static boolean a(MinecraftServer minecraftserver)
{
return minecraftserver.o;
}
private boolean d() throws UnknownHostException { private boolean d() throws UnknownHostException {
ThreadCommandReader localThreadCommandReader = new ThreadCommandReader(this); ThreadCommandReader threadcommandreader = new ThreadCommandReader(this);
localThreadCommandReader.setDaemon(true);
localThreadCommandReader.start();
threadcommandreader.setDaemon(true);
threadcommandreader.start();
ConsoleLogManager.a(); ConsoleLogManager.a();
a.info("Starting minecraft server version Beta 1.1_02"); a.info("Starting minecraft server version Beta 1.1_02");
if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) {
a.warning("**** NOT ENOUGH RAM!"); a.warning("**** NOT ENOUGH RAM!");
a.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); a.warning("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\"");
} }
a.info("Loading properties"); a.info("Loading properties");
this.d = new PropertyManager(new File("server.properties")); d = new PropertyManager(new File("server.properties"));
String str1 = this.d.a("server-ip", ""); String s = d.a("server-ip", "");
this.l = this.d.a("online-mode", true); l = d.a("online-mode", true);
this.m = this.d.a("spawn-animals", true); m = d.a("spawn-animals", true);
this.n = this.d.a("pvp", true); n = d.a("pvp", true);
InetAddress inetaddress = null;
InetAddress localInetAddress = null; if (s.length() > 0) {
if (str1.length() > 0) { inetaddress = InetAddress.getByName(s);
localInetAddress = InetAddress.getByName(str1);
} }
int i1 = this.d.a("server-port", 25565); int i1 = d.a("server-port", 25565);
a.info("Starting Minecraft server on " + (str1.length() == 0 ? "*" : str1) + ":" + i1); a.info((new StringBuilder()).append("Starting Minecraft server on ").append(s.length() != 0 ? s : "*").append(":").append(i1).toString());
try { try {
this.c = new NetworkListenThread(this, localInetAddress, i1); c = new NetworkListenThread(this, inetaddress, i1);
} catch (Throwable localIOException) { // CraftBukkit: Be more generic; IOException -> Throwable
} catch (Throwable ioexception) {
a.warning("**** FAILED TO BIND TO PORT!"); a.warning("**** FAILED TO BIND TO PORT!");
a.log(Level.WARNING, "The exception was: " + localIOException.toString()); a.log(Level.WARNING, (new StringBuilder()).append("The exception was: ").append(ioexception.toString()).toString());
a.warning("Perhaps a server is already running on that port?"); a.warning("Perhaps a server is already running on that port?");
return false; return false;
} }
if (!l) {
if (!this.l) {
a.warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); a.warning("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!");
a.warning("The server will make no attempt to authenticate usernames. Beware."); a.warning("The server will make no attempt to authenticate usernames. Beware.");
a.warning("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); a.warning("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.");
@ -94,64 +95,66 @@ public class MinecraftServer
server = new CraftServer(this, "1.1"); // CraftBukkit server = new CraftServer(this, "1.1"); // CraftBukkit
this.f = new ServerConfigurationManager(this); f = new ServerConfigurationManager(this);
this.k = new EntityTracker(this); k = new EntityTracker(this);
String s1 = d.a("level-name", "world");
String str2 = this.d.a("level-name", "world"); a.info((new StringBuilder()).append("Preparing level \"").append(s1).append("\"").toString());
a.info("Preparing level \"" + str2 + "\""); c(s1);
c(str2);
a.info("Done! For help, type \"help\" or \"?\""); a.info("Done! For help, type \"help\" or \"?\"");
return true; return true;
} }
private void c(String paramString) { private void c(String s) {
a.info("Preparing start region"); a.info("Preparing start region");
this.e = new WorldServer(this, new File("."), paramString, this.d.a("hellworld", false) ? -1 : 0); e = new WorldServer(this, new File("."), s, d.a("hellworld", false) ? -1 : 0);
this.e.a(new WorldManager(this)); e.a(new WorldManager(this));
this.e.k = (this.d.a("spawn-monsters", true) ? 1 : 0); e.k = d.a("spawn-monsters", true) ? 1 : 0;
this.f.a(this.e); f.a(e);
int i1 = 10; byte byte0 = 10;
for (int i2 = -i1; i2 <= i1; i2++) {
a("Preparing spawn area", (i2 + i1) * 100 / (i1 + i1 + 1)); for (int i1 = -byte0; i1 <= byte0; i1++) {
for (int i3 = -i1; i3 <= i1; i3++) { a("Preparing spawn area", ((i1 + byte0) * 100) / (byte0 + byte0 + 1));
if (!this.o) { for (int j1 = -byte0; j1 <= byte0; j1++) {
if (!o) {
return; return;
} }
this.e.A.d((this.e.m >> 4) + i2, (this.e.o >> 4) + i3); e.A.d((e.m >> 4) + i1, (e.o >> 4) + j1);
} }
} }
e(); e();
} }
private void a(String paramString, int paramInt) { private void a(String s, int i1) {
this.i = paramString; i = s;
this.j = paramInt; j = i1;
System.out.println(paramString + ": " + paramInt + "%"); System.out.println((new StringBuilder()).append(s).append(": ").append(i1).append("%").toString());
} }
private void e() { private void e() {
this.i = null; i = null;
this.j = 0; j = 0;
} }
private void f() { private void f() {
a.info("Saving chunks"); a.info("Saving chunks");
this.e.a(true, null); e.a(true, null);
} }
private void g() { private void g() {
a.info("Stopping server"); a.info("Stopping server");
if (this.f != null) { if (f != null) {
this.f.d(); f.d();
} }
if (this.e != null) { if (e != null) {
f(); f();
} }
} }
public void a() { public void a() {
this.o = false; o = false;
} }
public void run() { public void run() {
@ -159,9 +162,11 @@ public class MinecraftServer
if (d()) { if (d()) {
long l1 = System.currentTimeMillis(); long l1 = System.currentTimeMillis();
long l2 = 0L; long l2 = 0L;
while (this.o) {
while (o) {
long l3 = System.currentTimeMillis(); long l3 = System.currentTimeMillis();
long l4 = l3 - l1; long l4 = l3 - l1;
if (l4 > 2000L) { if (l4 > 2000L) {
a.warning("Can't keep up! Did the system time change, or is the server overloaded?"); a.warning("Can't keep up! Did the system time change, or is the server overloaded?");
l4 = 2000L; l4 = 2000L;
@ -172,300 +177,311 @@ public class MinecraftServer
} }
l2 += l4; l2 += l4;
l1 = l3; l1 = l3;
while (l2 > 50L) { while (l2 > 50L) {
l2 -= 50L; l2 -= 50L;
h(); h();
} }
Thread.sleep(1L); Thread.sleep(1L);
} }
} else { } else {
while (this.o) { while (o) {
b(); b();
try { try {
Thread.sleep(10L); Thread.sleep(10L);
} catch (InterruptedException localInterruptedException1) { } catch (InterruptedException interruptedexception) {
localInterruptedException1.printStackTrace(); interruptedexception.printStackTrace();
} }
} }
} }
} catch (Exception localException) { } catch (Exception exception) {
localException.printStackTrace(); exception.printStackTrace();
a.log(Level.SEVERE, "Unexpected exception", localException); a.log(Level.SEVERE, "Unexpected exception", exception);
while (this.o) { while (o) {
b(); b();
try { try {
Thread.sleep(10L); Thread.sleep(10L);
} catch (InterruptedException localInterruptedException2) { } catch (InterruptedException interruptedexception1) {
localInterruptedException2.printStackTrace(); interruptedexception1.printStackTrace();
} }
} }
} finally { } finally {
g(); g();
this.g = true; g = true;
System.exit(0); System.exit(0);
} }
} }
private void h() { private void h() {
ArrayList localArrayList = new ArrayList(); ArrayList arraylist = new ArrayList();
for (String str : b.keySet()) {
int i2 = ((Integer) b.get(str)).intValue(); for (Iterator iterator = b.keySet().iterator(); iterator.hasNext();) {
if (i2 > 0) { String s = (String) iterator.next();
b.put(str, Integer.valueOf(i2 - 1)); int k1 = ((Integer) b.get(s)).intValue();
if (k1 > 0) {
b.put(s, Integer.valueOf(k1 - 1));
} else { } else {
localArrayList.add(str); arraylist.add(s);
} }
} }
for (int i1 = 0; i1 < localArrayList.size(); i1++) {
b.remove(localArrayList.get(i1)); for (int i1 = 0; i1 < arraylist.size(); i1++) {
b.remove(arraylist.get(i1));
} }
AxisAlignedBB.a(); AxisAlignedBB.a();
Vec3D.a(); Vec3D.a();
this.h += 1; h++;
if (h % 20 == 0) {
if (this.h % 20 == 0) { f.a(new Packet4UpdateTime(e.e));
this.f.a(new Packet4UpdateTime(this.e.e)); }
e.f();
while (e.d()) {
;
}
e.c();
c.a();
f.b();
k.a();
for (int j1 = 0; j1 < p.size(); j1++) {
((IUpdatePlayerListBox) p.get(j1)).a();
} }
this.e.f();
while (this.e.d());
this.e.c();
this.c.a();
this.f.b();
this.k.a();
for (int i1 = 0; i1 < this.p.size(); i1++) {
((IUpdatePlayerListBox) this.p.get(i1)).a();
}
try { try {
b(); b();
} catch (Exception localException) { } catch (Exception exception) {
a.log(Level.WARNING, "Unexpected exception while parsing console command", localException); a.log(Level.WARNING, "Unexpected exception while parsing console command", exception);
} }
} }
public void a(String paramString, ICommandListener paramICommandListener) { public void a(String s, ICommandListener icommandlistener) {
this.q.add(new ServerCommand(paramString, paramICommandListener)); q.add(new ServerCommand(s, icommandlistener));
} }
public void b() { public void b() {
while (this.q.size() > 0) { do {
ServerCommand localServerCommand = (ServerCommand) this.q.remove(0); if (q.size() <= 0) {
String str1 = localServerCommand.a; break;
ICommandListener localICommandListener = localServerCommand.b;
String str2 = localICommandListener.c();
if ((str1.toLowerCase().startsWith("help")) || (str1.toLowerCase().startsWith("?"))) {
localICommandListener.b("To run the server without a gui, start it like this:");
localICommandListener.b(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui");
localICommandListener.b("Console commands:");
localICommandListener.b(" help or ? shows this message");
localICommandListener.b(" kick <player> removes a player from the server");
localICommandListener.b(" ban <player> bans a player from the server");
localICommandListener.b(" pardon <player> pardons a banned player so that they can connect again");
localICommandListener.b(" ban-ip <ip> bans an IP address from the server");
localICommandListener.b(" pardon-ip <ip> pardons a banned IP address so that they can connect again");
localICommandListener.b(" op <player> turns a player into an op");
localICommandListener.b(" deop <player> removes op status from a player");
localICommandListener.b(" tp <player1> <player2> moves one player to the same location as another player");
localICommandListener.b(" give <player> <id> [num] gives a player a resource");
localICommandListener.b(" tell <player> <message> sends a private message to a player");
localICommandListener.b(" stop gracefully stops the server");
localICommandListener.b(" save-all forces a server-wide level save");
localICommandListener.b(" save-off disables terrain saving (useful for backup scripts)");
localICommandListener.b(" save-on re-enables terrain saving");
localICommandListener.b(" list lists all currently connected players");
localICommandListener.b(" say <message> broadcasts a message to all players");
} else if (str1.toLowerCase().startsWith("list")) {
localICommandListener.b("Connected players: " + this.f.c());
} else if (str1.toLowerCase().startsWith("stop")) {
a(str2, "Stopping the server..");
this.o = false;
} else if (str1.toLowerCase().startsWith("save-all")) {
a(str2, "Forcing save..");
this.e.a(true, null);
a(str2, "Save complete.");
} else if (str1.toLowerCase().startsWith("save-off")) {
a(str2, "Disabling level saving..");
this.e.C = true;
} else if (str1.toLowerCase().startsWith("save-on")) {
a(str2, "Enabling level saving..");
this.e.C = false;
} else {
Object localObject1;
if (str1.toLowerCase().startsWith("op ")) {
localObject1 = str1.substring(str1.indexOf(" ")).trim();
this.f.e((String) localObject1);
a(str2, "Opping " + (String) localObject1);
this.f.a((String) localObject1, "§eYou are now op!");
} else if (str1.toLowerCase().startsWith("deop ")) {
localObject1 = str1.substring(str1.indexOf(" ")).trim();
this.f.f((String) localObject1);
this.f.a((String) localObject1, "§eYou are no longer op!");
a(str2, "De-opping " + (String) localObject1);
} else if (str1.toLowerCase().startsWith("ban-ip ")) {
localObject1 = str1.substring(str1.indexOf(" ")).trim();
this.f.c((String) localObject1);
a(str2, "Banning ip " + (String) localObject1);
} else if (str1.toLowerCase().startsWith("pardon-ip ")) {
localObject1 = str1.substring(str1.indexOf(" ")).trim();
this.f.d((String) localObject1);
a(str2, "Pardoning ip " + (String) localObject1);
} else {
Object localObject2;
if (str1.toLowerCase().startsWith("ban ")) {
localObject1 = str1.substring(str1.indexOf(" ")).trim();
this.f.a((String) localObject1);
a(str2, "Banning " + (String) localObject1);
localObject2 = this.f.h((String) localObject1);
if (localObject2 != null) {
((EntityPlayerMP) localObject2).a.a("Banned by admin");
} }
ServerCommand servercommand = (ServerCommand) q.remove(0);
String s = servercommand.a;
ICommandListener icommandlistener = servercommand.b;
String s1 = icommandlistener.c();
} else if (str1.toLowerCase().startsWith("pardon ")) { if (s.toLowerCase().startsWith("help") || s.toLowerCase().startsWith("?")) {
localObject1 = str1.substring(str1.indexOf(" ")).trim(); icommandlistener.b("To run the server without a gui, start it like this:");
this.f.b((String) localObject1); icommandlistener.b(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui");
a(str2, "Pardoning " + (String) localObject1); icommandlistener.b("Console commands:");
} else if (str1.toLowerCase().startsWith("kick ")) { icommandlistener.b(" help or ? shows this message");
localObject1 = str1.substring(str1.indexOf(" ")).trim(); icommandlistener.b(" kick <player> removes a player from the server");
localObject2 = null; icommandlistener.b(" ban <player> bans a player from the server");
for (int i1 = 0; i1 < this.f.b.size(); i1++) { icommandlistener.b(" pardon <player> pardons a banned player so that they can connect again");
EntityPlayerMP localEntityPlayerMP2 = (EntityPlayerMP) this.f.b.get(i1); icommandlistener.b(" ban-ip <ip> bans an IP address from the server");
if (localEntityPlayerMP2.aw.equalsIgnoreCase((String) localObject1)) { icommandlistener.b(" pardon-ip <ip> pardons a banned IP address so that they can connect again");
localObject2 = localEntityPlayerMP2; icommandlistener.b(" op <player> turns a player into an op");
icommandlistener.b(" deop <player> removes op status from a player");
icommandlistener.b(" tp <player1> <player2> moves one player to the same location as another player");
icommandlistener.b(" give <player> <id> [num] gives a player a resource");
icommandlistener.b(" tell <player> <message> sends a private message to a player");
icommandlistener.b(" stop gracefully stops the server");
icommandlistener.b(" save-all forces a server-wide level save");
icommandlistener.b(" save-off disables terrain saving (useful for backup scripts)");
icommandlistener.b(" save-on re-enables terrain saving");
icommandlistener.b(" list lists all currently connected players");
icommandlistener.b(" say <message> broadcasts a message to all players");
} else if (s.toLowerCase().startsWith("list")) {
icommandlistener.b((new StringBuilder()).append("Connected players: ").append(f.c()).toString());
} else if (s.toLowerCase().startsWith("stop")) {
a(s1, "Stopping the server..");
o = false;
} else if (s.toLowerCase().startsWith("save-all")) {
a(s1, "Forcing save..");
e.a(true, null);
a(s1, "Save complete.");
} else if (s.toLowerCase().startsWith("save-off")) {
a(s1, "Disabling level saving..");
e.C = true;
} else if (s.toLowerCase().startsWith("save-on")) {
a(s1, "Enabling level saving..");
e.C = false;
} else if (s.toLowerCase().startsWith("op ")) {
String s2 = s.substring(s.indexOf(" ")).trim();
f.e(s2);
a(s1, (new StringBuilder()).append("Opping ").append(s2).toString());
f.a(s2, "\247eYou are now op!");
} else if (s.toLowerCase().startsWith("deop ")) {
String s3 = s.substring(s.indexOf(" ")).trim();
f.f(s3);
f.a(s3, "\247eYou are no longer op!");
a(s1, (new StringBuilder()).append("De-opping ").append(s3).toString());
} else if (s.toLowerCase().startsWith("ban-ip ")) {
String s4 = s.substring(s.indexOf(" ")).trim();
f.c(s4);
a(s1, (new StringBuilder()).append("Banning ip ").append(s4).toString());
} else if (s.toLowerCase().startsWith("pardon-ip ")) {
String s5 = s.substring(s.indexOf(" ")).trim();
f.d(s5);
a(s1, (new StringBuilder()).append("Pardoning ip ").append(s5).toString());
} else if (s.toLowerCase().startsWith("ban ")) {
String s6 = s.substring(s.indexOf(" ")).trim();
f.a(s6);
a(s1, (new StringBuilder()).append("Banning ").append(s6).toString());
EntityPlayerMP entityplayermp = f.h(s6);
if (entityplayermp != null) {
entityplayermp.a.a("Banned by admin");
}
} else if (s.toLowerCase().startsWith("pardon ")) {
String s7 = s.substring(s.indexOf(" ")).trim();
f.b(s7);
a(s1, (new StringBuilder()).append("Pardoning ").append(s7).toString());
} else if (s.toLowerCase().startsWith("kick ")) {
String s8 = s.substring(s.indexOf(" ")).trim();
EntityPlayerMP entityplayermp1 = null;
for (int i1 = 0; i1 < f.b.size(); i1++) {
EntityPlayerMP entityplayermp5 = (EntityPlayerMP) f.b.get(i1);
if (entityplayermp5.aw.equalsIgnoreCase(s8)) {
entityplayermp1 = entityplayermp5;
} }
} }
if (localObject2 != null) { if (entityplayermp1 != null) {
((EntityPlayerMP) localObject2).a.a("Kicked by admin"); entityplayermp1.a.a("Kicked by admin");
a(str2, "Kicking " + ((EntityPlayerMP) localObject2).aw); a(s1, (new StringBuilder()).append("Kicking ").append(entityplayermp1.aw).toString());
} else { } else {
localICommandListener.b("Can't find user " + (String) localObject1 + ". No kick."); icommandlistener.b((new StringBuilder()).append("Can't find user ").append(s8).append(". No kick.").toString());
} }
} else { } else if (s.toLowerCase().startsWith("tp ")) {
EntityPlayerMP localEntityPlayerMP1; String as[] = s.split(" ");
if (str1.toLowerCase().startsWith("tp ")) {
String[] split = str1.split(" ");
if (split.length == 3) {
localObject2 = this.f.h(split[1]);
localEntityPlayerMP1 = this.f.h(split[2]);
if (localObject2 == null) { if (as.length == 3) {
localICommandListener.b("Can't find user " + split[1] + ". No tp."); EntityPlayerMP entityplayermp2 = f.h(as[1]);
} else if (localEntityPlayerMP1 == null) { EntityPlayerMP entityplayermp3 = f.h(as[2]);
localICommandListener.b("Can't find user " + split[2] + ". No tp.");
if (entityplayermp2 == null) {
icommandlistener.b((new StringBuilder()).append("Can't find user ").append(as[1]).append(". No tp.").toString());
} else if (entityplayermp3 == null) {
icommandlistener.b((new StringBuilder()).append("Can't find user ").append(as[2]).append(". No tp.").toString());
} else { } else {
((EntityPlayerMP) localObject2).a.a(localEntityPlayerMP1.p, localEntityPlayerMP1.q, localEntityPlayerMP1.r, localEntityPlayerMP1.v, localEntityPlayerMP1.w); entityplayermp2.a.a(entityplayermp3.p, entityplayermp3.q, entityplayermp3.r, entityplayermp3.v, entityplayermp3.w);
a(str2, "Teleporting " + split[1] + " to " + split[2] + "."); a(s1, (new StringBuilder()).append("Teleporting ").append(as[1]).append(" to ").append(as[2]).append(".").toString());
} }
} else { } else {
localICommandListener.b("Syntax error, please provice a source and a target."); icommandlistener.b("Syntax error, please provice a source and a target.");
} }
} else if (str1.toLowerCase().startsWith("give ")) { } else if (s.toLowerCase().startsWith("give ")) {
String[] split = str1.split(" "); String as1[] = s.split(" ");
if ((split.length != 3) && (split.length != 4)) {
if (as1.length != 3 && as1.length != 4) {
return; return;
} }
String s9 = as1[1];
EntityPlayerMP entityplayermp4 = f.h(s9);
localObject2 = split[1]; if (entityplayermp4 != null) {
localEntityPlayerMP1 = this.f.h((String) localObject2);
if (localEntityPlayerMP1 != null) {
try { try {
int i2 = Integer.parseInt(split[2]); int j1 = Integer.parseInt(as1[2]);
if (Item.c[i2] != null) {
a(str2, "Giving " + localEntityPlayerMP1.aw + " some " + i2);
int i3 = 1;
if (split.length > 3) {
i3 = b(split[3], 1);
}
if (i3 < 1) {
i3 = 1;
}
if (i3 > 64) {
i3 = 64;
}
localEntityPlayerMP1.b(new ItemStack(i2, i3));
} else {
localICommandListener.b("There's no item with id " + i2);
}
} catch (NumberFormatException localNumberFormatException) {
localICommandListener.b("There's no item with id " + split[2]);
}
} else {
localICommandListener.b("Can't find user " + (String) localObject2);
}
} else if (str1.toLowerCase().startsWith("say ")) {
str1 = str1.substring(str1.indexOf(" ")).trim();
a.info("[" + str2 + "] " + str1);
this.f.a(new Packet3Chat("§d[Server] " + str1));
} else if (str1.toLowerCase().startsWith("tell ")) {
String[] split = str1.split(" ");
if (split.length >= 3) {
str1 = str1.substring(str1.indexOf(" ")).trim();
str1 = str1.substring(str1.indexOf(" ")).trim();
a.info("[" + str2 + "->" + split[1] + "] " + str1); if (Item.c[j1] != null) {
str1 = "§7" + str2 + " whispers " + str1; a(s1, (new StringBuilder()).append("Giving ").append(entityplayermp4.aw).append(" some ").append(j1).toString());
a.info(str1); int k1 = 1;
if (!this.f.a(split[1], new Packet3Chat(str1))) {
localICommandListener.b("There's no player by that name online."); if (as1.length > 3) {
k1 = b(as1[3], 1);
}
if (k1 < 1) {
k1 = 1;
}
if (k1 > 64) {
k1 = 64;
}
entityplayermp4.b(new ItemStack(j1, k1));
} else {
icommandlistener.b((new StringBuilder()).append("There's no item with id ").append(j1).toString());
}
} catch (NumberFormatException numberformatexception) {
icommandlistener.b((new StringBuilder()).append("There's no item with id ").append(as1[2]).toString());
}
} else {
icommandlistener.b((new StringBuilder()).append("Can't find user ").append(s9).toString());
}
} else if (s.toLowerCase().startsWith("say ")) {
s = s.substring(s.indexOf(" ")).trim();
a.info((new StringBuilder()).append("[").append(s1).append("] ").append(s).toString());
f.a(new Packet3Chat((new StringBuilder()).append("\247d[Server] ").append(s).toString()));
} else if (s.toLowerCase().startsWith("tell ")) {
String as2[] = s.split(" ");
if (as2.length >= 3) {
s = s.substring(s.indexOf(" ")).trim();
s = s.substring(s.indexOf(" ")).trim();
a.info((new StringBuilder()).append("[").append(s1).append("->").append(as2[1]).append("] ").append(s).toString());
s = (new StringBuilder()).append("\2477").append(s1).append(" whispers ").append(s).toString();
a.info(s);
if (!f.a(as2[1], new Packet3Chat(s))) {
icommandlistener.b("There's no player by that name online.");
} }
} }
} else { } else {
a.info("Unknown console command. Type \"help\" for help."); a.info("Unknown console command. Type \"help\" for help.");
} }
} } while (true);
}
}
}
} }
private void a(String paramString1, String paramString2) { private void a(String s, String s1) {
String str = paramString1 + ": " + paramString2; String s2 = (new StringBuilder()).append(s).append(": ").append(s1).toString();
this.f.i("§7(" + str + ")");
a.info(str); f.i((new StringBuilder()).append("\2477(").append(s2).append(")").toString());
a.info(s2);
} }
private int b(String paramString, int paramInt) { private int b(String s, int i1) {
try { try {
return Integer.parseInt(paramString); return Integer.parseInt(s);
} catch (NumberFormatException localNumberFormatException) { } catch (NumberFormatException numberformatexception) {
return i1;
} }
return paramInt;
} }
public void a(IUpdatePlayerListBox paramIUpdatePlayerListBox) { public void a(IUpdatePlayerListBox iupdateplayerlistbox) {
this.p.add(paramIUpdatePlayerListBox); p.add(iupdateplayerlistbox);
} }
public static void main(String[] paramArrayOfString) { public static void main(String args[]) {
try { try {
MinecraftServer localMinecraftServer = new MinecraftServer(); MinecraftServer minecraftserver = new MinecraftServer();
if ((!GraphicsEnvironment.isHeadless()) && ((paramArrayOfString.length <= 0) || (!paramArrayOfString[0].equals("nogui")))) { if (!java.awt.GraphicsEnvironment.isHeadless() && (args.length <= 0 || !args[0].equals("nogui"))) {
ServerGUI.a(localMinecraftServer); ServerGUI.a(minecraftserver);
} }
(new ThreadServerApplication("Server thread", minecraftserver)).start();
new ThreadServerApplication("Server thread", localMinecraftServer).start(); } catch (Exception exception) {
} catch (Exception localException) { a.log(Level.SEVERE, "Failed to start the minecraft server", exception);
a.log(Level.SEVERE, "Failed to start the minecraft server", localException);
} }
} }
public File a(String paramString) { public File a(String s) {
return new File(paramString); return new File(s);
} }
public void b(String paramString) { public void b(String s) {
a.info(paramString); a.info(s);
} }
public String c() { public String c() {
return "CONSOLE"; return "CONSOLE";
} }
public static boolean a(MinecraftServer minecraftserver) {
return minecraftserver.o;
}
} }

View file

@ -1,44 +1,42 @@
package net.minecraft.server; package net.minecraft.server;
import java.io.BufferedReader; import java.io.*;
import java.io.File; import java.util.*;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
public class ServerConfigurationManager { public class ServerConfigurationManager {
public static Logger a = Logger.getLogger("Minecraft"); public static Logger a = Logger.getLogger("Minecraft");
public List b = new ArrayList(); public List b;
private MinecraftServer c; private MinecraftServer c;
private PlayerManager d; private PlayerManager d;
private int e; private int e;
private Set<String> f = new HashSet<String>(); private Set f;
private Set<String> g = new HashSet<String>(); private Set g;
private Set<String> h = new HashSet<String>(); private Set h;
private File i; private File i;
private File j; private File j;
private File k; private File k;
private PlayerNBTManager l; private PlayerNBTManager l;
private CraftServer server; // Craftbukkit private CraftServer server; // Craftbukkit
public ServerConfigurationManager(MinecraftServer paramMinecraftServer) { public ServerConfigurationManager(MinecraftServer minecraftserver) {
server = paramMinecraftServer.server; // Craftbukkit server = minecraftserver.server; // Craftbukkit
this.c = paramMinecraftServer; b = new ArrayList();
this.i = paramMinecraftServer.a("banned-players.txt"); f = new HashSet();
this.j = paramMinecraftServer.a("banned-ips.txt"); g = new HashSet();
this.k = paramMinecraftServer.a("ops.txt"); h = new HashSet();
this.d = new PlayerManager(paramMinecraftServer); c = minecraftserver;
this.e = paramMinecraftServer.d.a("max-players", 20); i = minecraftserver.a("banned-players.txt");
j = minecraftserver.a("banned-ips.txt");
k = minecraftserver.a("ops.txt");
d = new PlayerManager(minecraftserver);
e = minecraftserver.d.a("max-players", 20);
e(); e();
g(); g();
i(); i();
@ -47,289 +45,312 @@ public class ServerConfigurationManager {
j(); j();
} }
public void a(WorldServer paramWorldServer) { public void a(WorldServer worldserver) {
this.l = new PlayerNBTManager(new File(paramWorldServer.t, "players")); l = new PlayerNBTManager(new File(worldserver.t, "players"));
} }
public int a() { public int a() {
return this.d.b(); return d.b();
} }
public void a(EntityPlayerMP paramEntityPlayerMP) { public void a(EntityPlayerMP entityplayermp) {
this.b.add(paramEntityPlayerMP); b.add(entityplayermp);
this.l.b(paramEntityPlayerMP); l.b(entityplayermp);
c.e.A.d((int) entityplayermp.p >> 4, (int) entityplayermp.r >> 4);
this.c.e.A.d((int) paramEntityPlayerMP.p >> 4, (int) paramEntityPlayerMP.r >> 4); for (; c.e.a(entityplayermp, entityplayermp.z).size() != 0; entityplayermp.a(entityplayermp.p, entityplayermp.q + 1.0D, entityplayermp.r)) {
;
while (this.c.e.a(paramEntityPlayerMP, paramEntityPlayerMP.z).size() != 0) {
paramEntityPlayerMP.a(paramEntityPlayerMP.p, paramEntityPlayerMP.q + 1.0D, paramEntityPlayerMP.r);
} }
this.c.e.a(paramEntityPlayerMP); c.e.a(entityplayermp);
this.d.a(paramEntityPlayerMP); d.a(entityplayermp);
// Craftbukkit // Craftbukkit
server.getPluginManager().callEvent(new PlayerEvent(Type.PLAYER_JOIN, server.getPlayer(paramEntityPlayerMP))); server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayermp)));
} }
public void b(EntityPlayerMP paramEntityPlayerMP) { public void b(EntityPlayerMP entityplayermp) {
this.d.c(paramEntityPlayerMP); d.c(entityplayermp);
} }
public void c(EntityPlayerMP paramEntityPlayerMP) { public void c(EntityPlayerMP entityplayermp) {
this.l.a(paramEntityPlayerMP); l.a(entityplayermp);
this.c.e.d(paramEntityPlayerMP); c.e.d(entityplayermp);
this.b.remove(paramEntityPlayerMP); b.remove(entityplayermp);
this.d.b(paramEntityPlayerMP); d.b(entityplayermp);
// Craftbukkit // Craftbukkit
server.getPluginManager().callEvent(new PlayerEvent(Type.PLAYER_QUIT, server.getPlayer(paramEntityPlayerMP))); server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_QUIT, server.getPlayer(entityplayermp)));
} }
public EntityPlayerMP a(NetLoginHandler paramNetLoginHandler, String paramString1, String paramString2) { public EntityPlayerMP a(NetLoginHandler netloginhandler, String s, String s1) {
if (this.f.contains(paramString1.trim().toLowerCase())) { if (f.contains(s.trim().toLowerCase())) {
paramNetLoginHandler.a("You are banned from this server!"); netloginhandler.a("You are banned from this server!");
return null; return null;
} }
String str = paramNetLoginHandler.b.b().toString(); String s2 = netloginhandler.b.b().toString();
str = str.substring(str.indexOf("/") + 1);
str = str.substring(0, str.indexOf(":")); s2 = s2.substring(s2.indexOf("/") + 1);
if (this.g.contains(str)) { s2 = s2.substring(0, s2.indexOf(":"));
paramNetLoginHandler.a("Your IP address is banned from this server!"); if (g.contains(s2)) {
netloginhandler.a("Your IP address is banned from this server!");
return null; return null;
} }
if (this.b.size() >= this.e) { if (b.size() >= e) {
paramNetLoginHandler.a("The server is full!"); netloginhandler.a("The server is full!");
return null; return null;
} }
for (int m = 0; m < this.b.size(); m++) { for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP localEntityPlayerMP = (EntityPlayerMP) this.b.get(m); EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
if (localEntityPlayerMP.aw.equalsIgnoreCase(paramString1)) {
localEntityPlayerMP.a.a("You logged in from another location"); if (entityplayermp.aw.equalsIgnoreCase(s)) {
entityplayermp.a.a("You logged in from another location");
} }
} }
return new EntityPlayerMP(this.c, this.c.e, paramString1, new ItemInWorldManager(this.c.e));
return new EntityPlayerMP(c, c.e, s, new ItemInWorldManager(c.e));
} }
public EntityPlayerMP d(EntityPlayerMP paramEntityPlayerMP) { public EntityPlayerMP d(EntityPlayerMP entityplayermp) {
this.c.k.a(paramEntityPlayerMP); c.k.a(entityplayermp);
this.c.k.b(paramEntityPlayerMP); c.k.b(entityplayermp);
this.d.b(paramEntityPlayerMP); d.b(entityplayermp);
this.b.remove(paramEntityPlayerMP); b.remove(entityplayermp);
this.c.e.e(paramEntityPlayerMP); c.e.e(entityplayermp);
EntityPlayerMP entityplayermp1 = new EntityPlayerMP(c, c.e, entityplayermp.aw, new ItemInWorldManager(c.e));
EntityPlayerMP localEntityPlayerMP = new EntityPlayerMP(this.c, this.c.e, paramEntityPlayerMP.aw, new ItemInWorldManager(this.c.e)); entityplayermp1.g = entityplayermp.g;
localEntityPlayerMP.g = paramEntityPlayerMP.g; entityplayermp1.a = entityplayermp.a;
localEntityPlayerMP.a = paramEntityPlayerMP.a; c.e.A.d((int) entityplayermp1.p >> 4, (int) entityplayermp1.r >> 4);
for (; c.e.a(entityplayermp1, entityplayermp1.z).size() != 0; entityplayermp1.a(entityplayermp1.p, entityplayermp1.q + 1.0D, entityplayermp1.r)) {
this.c.e.A.d((int) localEntityPlayerMP.p >> 4, (int) localEntityPlayerMP.r >> 4); ;
while (this.c.e.a(localEntityPlayerMP, localEntityPlayerMP.z).size() != 0) {
localEntityPlayerMP.a(localEntityPlayerMP.p, localEntityPlayerMP.q + 1.0D, localEntityPlayerMP.r);
} }
entityplayermp1.a.b(new Packet9());
localEntityPlayerMP.a.b(new Packet9()); entityplayermp1.a.a(entityplayermp1.p, entityplayermp1.q, entityplayermp1.r, entityplayermp1.v, entityplayermp1.w);
localEntityPlayerMP.a.a(localEntityPlayerMP.p, localEntityPlayerMP.q, localEntityPlayerMP.r, localEntityPlayerMP.v, localEntityPlayerMP.w); d.a(entityplayermp1);
c.e.a(entityplayermp1);
this.d.a(localEntityPlayerMP); b.add(entityplayermp1);
this.c.e.a(localEntityPlayerMP); entityplayermp1.k();
this.b.add(localEntityPlayerMP); return entityplayermp1;
localEntityPlayerMP.k();
return localEntityPlayerMP;
} }
public void b() { public void b() {
this.d.a(); d.a();
} }
public void a(int paramInt1, int paramInt2, int paramInt3) { public void a(int i1, int j1, int k1) {
this.d.a(paramInt1, paramInt2, paramInt3); d.a(i1, j1, k1);
} }
public void a(Packet paramPacket) { public void a(Packet packet) {
for (int m = 0; m < this.b.size(); m++) { for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP localEntityPlayerMP = (EntityPlayerMP) this.b.get(m); EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
localEntityPlayerMP.a.b(paramPacket);
entityplayermp.a.b(packet);
} }
} }
public String c() { public String c() {
String str = ""; String s = "";
for (int m = 0; m < this.b.size(); m++) {
if (m > 0) { for (int i1 = 0; i1 < b.size(); i1++) {
str = str + ", "; if (i1 > 0) {
s = (new StringBuilder()).append(s).append(", ").toString();
} }
str = str + ((EntityPlayerMP) this.b.get(m)).aw; s = (new StringBuilder()).append(s).append(((EntityPlayerMP) b.get(i1)).aw).toString();
}
return str;
} }
public void a(String paramString) { return s;
this.f.add(paramString.toLowerCase()); }
public void a(String s) {
f.add(s.toLowerCase());
f(); f();
} }
public void b(String paramString) { public void b(String s) {
this.f.remove(paramString.toLowerCase()); f.remove(s.toLowerCase());
f(); f();
} }
private void e() { private void e() {
try { try {
this.f.clear(); f.clear();
BufferedReader localBufferedReader = new BufferedReader(new FileReader(this.i)); BufferedReader bufferedreader = new BufferedReader(new FileReader(i));
String str = "";
while ((str = localBufferedReader.readLine()) != null) { for (String s = ""; (s = bufferedreader.readLine()) != null;) {
this.f.add(str.trim().toLowerCase()); f.add(s.trim().toLowerCase());
} }
localBufferedReader.close();
} catch (Exception localException) { bufferedreader.close();
a.warning("Failed to load ban list: " + localException); } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to load ban list: ").append(exception).toString());
} }
} }
private void f() { private void f() {
try { try {
PrintWriter localPrintWriter = new PrintWriter(new FileWriter(this.i, false)); PrintWriter printwriter = new PrintWriter(new FileWriter(i, false));
for (String str : this.f) { String s;
localPrintWriter.println(str);
for (Iterator iterator = f.iterator(); iterator.hasNext(); printwriter.println(s)) {
s = (String) iterator.next();
} }
localPrintWriter.close();
} catch (Exception localException) { printwriter.close();
a.warning("Failed to save ban list: " + localException); } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to save ban list: ").append(exception).toString());
} }
} }
public void c(String paramString) { public void c(String s) {
this.g.add(paramString.toLowerCase()); g.add(s.toLowerCase());
h(); h();
} }
public void d(String paramString) { public void d(String s) {
this.g.remove(paramString.toLowerCase()); g.remove(s.toLowerCase());
h(); h();
} }
private void g() { private void g() {
try { try {
this.g.clear(); g.clear();
BufferedReader localBufferedReader = new BufferedReader(new FileReader(this.j)); BufferedReader bufferedreader = new BufferedReader(new FileReader(j));
String str = "";
while ((str = localBufferedReader.readLine()) != null) { for (String s = ""; (s = bufferedreader.readLine()) != null;) {
this.g.add(str.trim().toLowerCase()); g.add(s.trim().toLowerCase());
} }
localBufferedReader.close();
} catch (Exception localException) { bufferedreader.close();
a.warning("Failed to load ip ban list: " + localException); } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to load ip ban list: ").append(exception).toString());
} }
} }
private void h() { private void h() {
try { try {
PrintWriter localPrintWriter = new PrintWriter(new FileWriter(this.j, false)); PrintWriter printwriter = new PrintWriter(new FileWriter(j, false));
for (String str : this.g) { String s;
localPrintWriter.println(str);
for (Iterator iterator = g.iterator(); iterator.hasNext(); printwriter.println(s)) {
s = (String) iterator.next();
} }
localPrintWriter.close();
} catch (Exception localException) { printwriter.close();
a.warning("Failed to save ip ban list: " + localException); } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to save ip ban list: ").append(exception).toString());
} }
} }
public void e(String paramString) { public void e(String s) {
this.h.add(paramString.toLowerCase()); h.add(s.toLowerCase());
j(); j();
} }
public void f(String paramString) { public void f(String s) {
this.h.remove(paramString.toLowerCase()); h.remove(s.toLowerCase());
j(); j();
} }
private void i() { private void i() {
try { try {
this.h.clear(); h.clear();
BufferedReader localBufferedReader = new BufferedReader(new FileReader(this.k)); BufferedReader bufferedreader = new BufferedReader(new FileReader(k));
String str = "";
while ((str = localBufferedReader.readLine()) != null) { for (String s = ""; (s = bufferedreader.readLine()) != null;) {
this.h.add(str.trim().toLowerCase()); h.add(s.trim().toLowerCase());
} }
localBufferedReader.close();
} catch (Exception localException) { bufferedreader.close();
a.warning("Failed to load ip ban list: " + localException); } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to load ip ban list: ").append(exception).toString());
} }
} }
private void j() { private void j() {
try { try {
PrintWriter localPrintWriter = new PrintWriter(new FileWriter(this.k, false)); PrintWriter printwriter = new PrintWriter(new FileWriter(k, false));
for (String str : this.h) { String s;
localPrintWriter.println(str);
for (Iterator iterator = h.iterator(); iterator.hasNext(); printwriter.println(s)) {
s = (String) iterator.next();
} }
localPrintWriter.close();
} catch (Exception localException) { printwriter.close();
a.warning("Failed to save ip ban list: " + localException); } catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to save ip ban list: ").append(exception).toString());
} }
} }
public boolean g(String paramString) { public boolean g(String s) {
return this.h.contains(paramString.trim().toLowerCase()); return h.contains(s.trim().toLowerCase());
} }
public EntityPlayerMP h(String paramString) { public EntityPlayerMP h(String s) {
for (int m = 0; m < this.b.size(); m++) { for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP localEntityPlayerMP = (EntityPlayerMP) this.b.get(m); EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
if (localEntityPlayerMP.aw.equalsIgnoreCase(paramString)) {
return localEntityPlayerMP; if (entityplayermp.aw.equalsIgnoreCase(s)) {
return entityplayermp;
} }
} }
return null; return null;
} }
public void a(String paramString1, String paramString2) { public void a(String s, String s1) {
EntityPlayerMP localEntityPlayerMP = h(paramString1); EntityPlayerMP entityplayermp = h(s);
if (localEntityPlayerMP != null) {
localEntityPlayerMP.a.b(new Packet3Chat(paramString2)); if (entityplayermp != null) {
entityplayermp.a.b(new Packet3Chat(s1));
} }
} }
public void a(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4, Packet paramPacket) { public void a(double d1, double d2, double d3, double d4, Packet packet) {
for (int m = 0; m < this.b.size(); m++) { for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP localEntityPlayerMP = (EntityPlayerMP) this.b.get(m); EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
double d1 = paramDouble1 - localEntityPlayerMP.p; double d5 = d1 - entityplayermp.p;
double d2 = paramDouble2 - localEntityPlayerMP.q; double d6 = d2 - entityplayermp.q;
double d3 = paramDouble3 - localEntityPlayerMP.r; double d7 = d3 - entityplayermp.r;
if (d1 * d1 + d2 * d2 + d3 * d3 < paramDouble4 * paramDouble4) {
localEntityPlayerMP.a.b(paramPacket); if (d5 * d5 + d6 * d6 + d7 * d7 < d4 * d4) {
} entityplayermp.a.b(packet);
} }
} }
public void i(String paramString) {
Packet3Chat localPacket3Chat = new Packet3Chat(paramString);
for (int m = 0; m < this.b.size(); m++) {
EntityPlayerMP localEntityPlayerMP = (EntityPlayerMP) this.b.get(m);
if (g(localEntityPlayerMP.aw)) {
localEntityPlayerMP.a.b(localPacket3Chat);
} }
public void i(String s) {
Packet3Chat packet3chat = new Packet3Chat(s);
for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
if (g(entityplayermp.aw)) {
entityplayermp.a.b(packet3chat);
} }
} }
public boolean a(String paramString, Packet paramPacket) { }
EntityPlayerMP localEntityPlayerMP = h(paramString);
if (localEntityPlayerMP != null) { public boolean a(String s, Packet packet) {
localEntityPlayerMP.a.b(paramPacket); EntityPlayerMP entityplayermp = h(s);
if (entityplayermp != null) {
entityplayermp.a.b(packet);
return true; return true;
} } else {
return false; return false;
} }
}
public void d() { public void d() {
for (int m = 0; m < this.b.size(); m++) { for (int i1 = 0; i1 < b.size(); i1++) {
this.l.a((EntityPlayerMP) this.b.get(m)); l.a((EntityPlayerMP) b.get(i1));
}
} }
public void a(int paramInt1, int paramInt2, int paramInt3, TileEntity paramTileEntity) {
} }
public void a(int i1, int j1, int k1, TileEntity tileentity) {}
} }