mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-03 06:40:19 +08:00
Call hooks, update to new code
This commit is contained in:
parent
2798e5b84f
commit
01a0562cab
@ -15,14 +15,14 @@ import java.util.logging.Logger;
|
|||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
|
||||||
public class MinecraftServer
|
public class MinecraftServer
|
||||||
implements fn, 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<String, Integer> b = new HashMap<String, Integer>();
|
||||||
public eh c;
|
public NetworkListenThread c;
|
||||||
public dt d;
|
public PropertyManager d;
|
||||||
public fm e;
|
public WorldServer e;
|
||||||
public hl f;
|
public ServerConfigurationManager f;
|
||||||
private boolean o = true;
|
private boolean o = true;
|
||||||
public boolean g = false;
|
public boolean g = false;
|
||||||
int h = 0;
|
int h = 0;
|
||||||
@ -30,14 +30,14 @@ public class MinecraftServer
|
|||||||
public int j;
|
public int j;
|
||||||
private List p = new ArrayList();
|
private List p = new ArrayList();
|
||||||
private List q = Collections.synchronizedList(new ArrayList());
|
private List q = Collections.synchronizedList(new ArrayList());
|
||||||
public hp 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() {
|
||||||
new cn(this);
|
new ThreadSleepForever(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit: Decompiler might miss this method, your IDE won't complain but you
|
// CraftBukkit: Decompiler might miss this method, your IDE won't complain but you
|
||||||
@ -47,14 +47,14 @@ public class MinecraftServer
|
|||||||
return minecraftserver.o;
|
return minecraftserver.o;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean d() {
|
private boolean d() throws UnknownHostException {
|
||||||
cl localcl = new cl(this);
|
ThreadCommandReader localThreadCommandReader = new ThreadCommandReader(this);
|
||||||
|
|
||||||
localcl.setDaemon(true);
|
localThreadCommandReader.setDaemon(true);
|
||||||
localcl.start();
|
localThreadCommandReader.start();
|
||||||
|
|
||||||
hb.a();
|
ConsoleLogManager.a();
|
||||||
a.info("Starting minecraft server version Beta 1.1");
|
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!");
|
||||||
@ -62,7 +62,7 @@ public class MinecraftServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
a.info("Loading properties");
|
a.info("Loading properties");
|
||||||
this.d = new dt(new File("server.properties"));
|
this.d = new PropertyManager(new File("server.properties"));
|
||||||
String str1 = this.d.a("server-ip", "");
|
String str1 = this.d.a("server-ip", "");
|
||||||
|
|
||||||
this.l = this.d.a("online-mode", true);
|
this.l = this.d.a("online-mode", true);
|
||||||
@ -71,17 +71,13 @@ public class MinecraftServer
|
|||||||
|
|
||||||
InetAddress localInetAddress = null;
|
InetAddress localInetAddress = null;
|
||||||
if (str1.length() > 0) {
|
if (str1.length() > 0) {
|
||||||
try {
|
localInetAddress = InetAddress.getByName(str1);
|
||||||
localInetAddress = InetAddress.getByName(str1);
|
|
||||||
} catch (UnknownHostException ex) {
|
|
||||||
Logger.getLogger(MinecraftServer.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int i1 = this.d.a("server-port", 25565);
|
int i1 = this.d.a("server-port", 25565);
|
||||||
|
|
||||||
a.info("Starting Minecraft server on " + (str1.length() == 0 ? "*" : str1) + ":" + i1);
|
a.info("Starting Minecraft server on " + (str1.length() == 0 ? "*" : str1) + ":" + i1);
|
||||||
try {
|
try {
|
||||||
this.c = new eh(this, localInetAddress, i1);
|
this.c = new NetworkListenThread(this, localInetAddress, i1);
|
||||||
} catch (Throwable localIOException) {
|
} catch (Throwable localIOException) {
|
||||||
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, "The exception was: " + localIOException.toString());
|
||||||
@ -96,11 +92,11 @@ public class MinecraftServer
|
|||||||
a.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file.");
|
a.warning("To change this, set \"online-mode\" to \"true\" in the server.settings file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.f = new hl(this);
|
|
||||||
this.k = new hp(this);
|
|
||||||
|
|
||||||
server = new CraftServer(this, "1.1"); // CraftBukkit
|
server = new CraftServer(this, "1.1"); // CraftBukkit
|
||||||
|
|
||||||
|
this.f = new ServerConfigurationManager(this);
|
||||||
|
this.k = new EntityTracker(this);
|
||||||
|
|
||||||
String str2 = this.d.a("level-name", "world");
|
String str2 = this.d.a("level-name", "world");
|
||||||
a.info("Preparing level \"" + str2 + "\"");
|
a.info("Preparing level \"" + str2 + "\"");
|
||||||
c(str2);
|
c(str2);
|
||||||
@ -111,8 +107,8 @@ public class MinecraftServer
|
|||||||
|
|
||||||
private void c(String paramString) {
|
private void c(String paramString) {
|
||||||
a.info("Preparing start region");
|
a.info("Preparing start region");
|
||||||
this.e = new fm(this, new File("."), paramString, this.d.a("hellworld", false) ? -1 : 0);
|
this.e = new WorldServer(this, new File("."), paramString, this.d.a("hellworld", false) ? -1 : 0);
|
||||||
this.e.a(new fj(this));
|
this.e.a(new WorldManager(this));
|
||||||
this.e.k = (this.d.a("spawn-monsters", true) ? 1 : 0);
|
this.e.k = (this.d.a("spawn-monsters", true) ? 1 : 0);
|
||||||
this.f.a(this.e);
|
this.f.a(this.e);
|
||||||
int i1 = 10;
|
int i1 = 10;
|
||||||
@ -226,12 +222,12 @@ public class MinecraftServer
|
|||||||
b.remove(localArrayList.get(i1));
|
b.remove(localArrayList.get(i1));
|
||||||
}
|
}
|
||||||
|
|
||||||
el.a();
|
AxisAlignedBB.a();
|
||||||
bn.a();
|
Vec3D.a();
|
||||||
this.h += 1;
|
this.h += 1;
|
||||||
|
|
||||||
if (this.h % 20 == 0) {
|
if (this.h % 20 == 0) {
|
||||||
this.f.a(new hc(this.e.e));
|
this.f.a(new Packet4UpdateTime(this.e.e));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.e.f();
|
this.e.f();
|
||||||
@ -242,7 +238,7 @@ public class MinecraftServer
|
|||||||
this.k.a();
|
this.k.a();
|
||||||
|
|
||||||
for (int i1 = 0; i1 < this.p.size(); i1++) {
|
for (int i1 = 0; i1 < this.p.size(); i1++) {
|
||||||
((fc) this.p.get(i1)).a();
|
((IUpdatePlayerListBox) this.p.get(i1)).a();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
b();
|
b();
|
||||||
@ -251,39 +247,39 @@ public class MinecraftServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(String paramString, fn paramfn) {
|
public void a(String paramString, ICommandListener paramICommandListener) {
|
||||||
this.q.add(new at(paramString, paramfn));
|
this.q.add(new ServerCommand(paramString, paramICommandListener));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void b() {
|
public void b() {
|
||||||
while (this.q.size() > 0) {
|
while (this.q.size() > 0) {
|
||||||
at localat = (at) this.q.remove(0);
|
ServerCommand localServerCommand = (ServerCommand) this.q.remove(0);
|
||||||
String str1 = localat.a;
|
String str1 = localServerCommand.a;
|
||||||
fn localfn = localat.b;
|
ICommandListener localICommandListener = localServerCommand.b;
|
||||||
String str2 = localfn.c();
|
String str2 = localICommandListener.c();
|
||||||
if ((str1.toLowerCase().startsWith("help")) || (str1.toLowerCase().startsWith("?"))) {
|
if ((str1.toLowerCase().startsWith("help")) || (str1.toLowerCase().startsWith("?"))) {
|
||||||
localfn.b("To run the server without a gui, start it like this:");
|
localICommandListener.b("To run the server without a gui, start it like this:");
|
||||||
localfn.b(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui");
|
localICommandListener.b(" java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui");
|
||||||
localfn.b("Console commands:");
|
localICommandListener.b("Console commands:");
|
||||||
localfn.b(" help or ? shows this message");
|
localICommandListener.b(" help or ? shows this message");
|
||||||
localfn.b(" kick <player> removes a player from the server");
|
localICommandListener.b(" kick <player> removes a player from the server");
|
||||||
localfn.b(" ban <player> bans a player from the server");
|
localICommandListener.b(" ban <player> bans a player from the server");
|
||||||
localfn.b(" pardon <player> pardons a banned player so that they can connect again");
|
localICommandListener.b(" pardon <player> pardons a banned player so that they can connect again");
|
||||||
localfn.b(" ban-ip <ip> bans an IP address from the server");
|
localICommandListener.b(" ban-ip <ip> bans an IP address from the server");
|
||||||
localfn.b(" pardon-ip <ip> pardons a banned IP address so that they can connect again");
|
localICommandListener.b(" pardon-ip <ip> pardons a banned IP address so that they can connect again");
|
||||||
localfn.b(" op <player> turns a player into an op");
|
localICommandListener.b(" op <player> turns a player into an op");
|
||||||
localfn.b(" deop <player> removes op status from a player");
|
localICommandListener.b(" deop <player> removes op status from a player");
|
||||||
localfn.b(" tp <player1> <player2> moves one player to the same location as another player");
|
localICommandListener.b(" tp <player1> <player2> moves one player to the same location as another player");
|
||||||
localfn.b(" give <player> <id> [num] gives a player a resource");
|
localICommandListener.b(" give <player> <id> [num] gives a player a resource");
|
||||||
localfn.b(" tell <player> <message> sends a private message to a player");
|
localICommandListener.b(" tell <player> <message> sends a private message to a player");
|
||||||
localfn.b(" stop gracefully stops the server");
|
localICommandListener.b(" stop gracefully stops the server");
|
||||||
localfn.b(" save-all forces a server-wide level save");
|
localICommandListener.b(" save-all forces a server-wide level save");
|
||||||
localfn.b(" save-off disables terrain saving (useful for backup scripts)");
|
localICommandListener.b(" save-off disables terrain saving (useful for backup scripts)");
|
||||||
localfn.b(" save-on re-enables terrain saving");
|
localICommandListener.b(" save-on re-enables terrain saving");
|
||||||
localfn.b(" list lists all currently connected players");
|
localICommandListener.b(" list lists all currently connected players");
|
||||||
localfn.b(" say <message> broadcasts a message to all players");
|
localICommandListener.b(" say <message> broadcasts a message to all players");
|
||||||
} else if (str1.toLowerCase().startsWith("list")) {
|
} else if (str1.toLowerCase().startsWith("list")) {
|
||||||
localfn.b("Connected players: " + this.f.c());
|
localICommandListener.b("Connected players: " + this.f.c());
|
||||||
} else if (str1.toLowerCase().startsWith("stop")) {
|
} else if (str1.toLowerCase().startsWith("stop")) {
|
||||||
a(str2, "Stopping the server..");
|
a(str2, "Stopping the server..");
|
||||||
this.o = false;
|
this.o = false;
|
||||||
@ -327,7 +323,7 @@ public class MinecraftServer
|
|||||||
localObject2 = this.f.h((String) localObject1);
|
localObject2 = this.f.h((String) localObject1);
|
||||||
|
|
||||||
if (localObject2 != null) {
|
if (localObject2 != null) {
|
||||||
((fi) localObject2).a.a("Banned by admin");
|
((EntityPlayerMP) localObject2).a.a("Banned by admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (str1.toLowerCase().startsWith("pardon ")) {
|
} else if (str1.toLowerCase().startsWith("pardon ")) {
|
||||||
@ -338,36 +334,36 @@ public class MinecraftServer
|
|||||||
localObject1 = str1.substring(str1.indexOf(" ")).trim();
|
localObject1 = str1.substring(str1.indexOf(" ")).trim();
|
||||||
localObject2 = null;
|
localObject2 = null;
|
||||||
for (int i1 = 0; i1 < this.f.b.size(); i1++) {
|
for (int i1 = 0; i1 < this.f.b.size(); i1++) {
|
||||||
fi localfi2 = (fi) this.f.b.get(i1);
|
EntityPlayerMP localEntityPlayerMP2 = (EntityPlayerMP) this.f.b.get(i1);
|
||||||
if (localfi2.aw.equalsIgnoreCase((String) localObject1)) {
|
if (localEntityPlayerMP2.aw.equalsIgnoreCase((String) localObject1)) {
|
||||||
localObject2 = localfi2;
|
localObject2 = localEntityPlayerMP2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localObject2 != null) {
|
if (localObject2 != null) {
|
||||||
((fi) localObject2).a.a("Kicked by admin");
|
((EntityPlayerMP) localObject2).a.a("Kicked by admin");
|
||||||
a(str2, "Kicking " + ((fi) localObject2).aw);
|
a(str2, "Kicking " + ((EntityPlayerMP) localObject2).aw);
|
||||||
} else {
|
} else {
|
||||||
localfn.b("Can't find user " + (String) localObject1 + ". No kick.");
|
localICommandListener.b("Can't find user " + (String) localObject1 + ". No kick.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fi localfi1;
|
EntityPlayerMP localEntityPlayerMP1;
|
||||||
if (str1.toLowerCase().startsWith("tp ")) {
|
if (str1.toLowerCase().startsWith("tp ")) {
|
||||||
String[] split = str1.split(" ");
|
String[] split = str1.split(" ");
|
||||||
if (split.length == 3) {
|
if (split.length == 3) {
|
||||||
localObject2 = this.f.h(split[1]);
|
localObject2 = this.f.h(split[1]);
|
||||||
localfi1 = this.f.h(split[2]);
|
localEntityPlayerMP1 = this.f.h(split[2]);
|
||||||
|
|
||||||
if (localObject2 == null) {
|
if (localObject2 == null) {
|
||||||
localfn.b("Can't find user " + split[1] + ". No tp.");
|
localICommandListener.b("Can't find user " + split[1] + ". No tp.");
|
||||||
} else if (localfi1 == null) {
|
} else if (localEntityPlayerMP1 == null) {
|
||||||
localfn.b("Can't find user " + split[2] + ". No tp.");
|
localICommandListener.b("Can't find user " + split[2] + ". No tp.");
|
||||||
} else {
|
} else {
|
||||||
((fi) localObject2).a.a(localfi1.p, localfi1.q, localfi1.r, localfi1.v, localfi1.w);
|
((EntityPlayerMP) localObject2).a.a(localEntityPlayerMP1.p, localEntityPlayerMP1.q, localEntityPlayerMP1.r, localEntityPlayerMP1.v, localEntityPlayerMP1.w);
|
||||||
a(str2, "Teleporting " + split[1] + " to " + split[2] + ".");
|
a(str2, "Teleporting " + split[1] + " to " + split[2] + ".");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
localfn.b("Syntax error, please provice a source and a target.");
|
localICommandListener.b("Syntax error, please provice a source and a target.");
|
||||||
}
|
}
|
||||||
} else if (str1.toLowerCase().startsWith("give ")) {
|
} else if (str1.toLowerCase().startsWith("give ")) {
|
||||||
String[] split = str1.split(" ");
|
String[] split = str1.split(" ");
|
||||||
@ -376,13 +372,13 @@ public class MinecraftServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
localObject2 = split[1];
|
localObject2 = split[1];
|
||||||
localfi1 = this.f.h((String) localObject2);
|
localEntityPlayerMP1 = this.f.h((String) localObject2);
|
||||||
|
|
||||||
if (localfi1 != null) {
|
if (localEntityPlayerMP1 != null) {
|
||||||
try {
|
try {
|
||||||
int i2 = Integer.parseInt(split[2]);
|
int i2 = Integer.parseInt(split[2]);
|
||||||
if (gm.c[i2] != null) {
|
if (Item.c[i2] != null) {
|
||||||
a(str2, "Giving " + localfi1.aw + " some " + i2);
|
a(str2, "Giving " + localEntityPlayerMP1.aw + " some " + i2);
|
||||||
int i3 = 1;
|
int i3 = 1;
|
||||||
if (split.length > 3) {
|
if (split.length > 3) {
|
||||||
i3 = b(split[3], 1);
|
i3 = b(split[3], 1);
|
||||||
@ -393,20 +389,20 @@ public class MinecraftServer
|
|||||||
if (i3 > 64) {
|
if (i3 > 64) {
|
||||||
i3 = 64;
|
i3 = 64;
|
||||||
}
|
}
|
||||||
localfi1.b(new il(i2, i3));
|
localEntityPlayerMP1.b(new ItemStack(i2, i3));
|
||||||
} else {
|
} else {
|
||||||
localfn.b("There's no item with id " + i2);
|
localICommandListener.b("There's no item with id " + i2);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException localNumberFormatException) {
|
} catch (NumberFormatException localNumberFormatException) {
|
||||||
localfn.b("There's no item with id " + split[2]);
|
localICommandListener.b("There's no item with id " + split[2]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
localfn.b("Can't find user " + (String) localObject2);
|
localICommandListener.b("Can't find user " + (String) localObject2);
|
||||||
}
|
}
|
||||||
} else if (str1.toLowerCase().startsWith("say ")) {
|
} else if (str1.toLowerCase().startsWith("say ")) {
|
||||||
str1 = str1.substring(str1.indexOf(" ")).trim();
|
str1 = str1.substring(str1.indexOf(" ")).trim();
|
||||||
a.info("[" + str2 + "] " + str1);
|
a.info("[" + str2 + "] " + str1);
|
||||||
this.f.a(new br("§d[Server] " + str1));
|
this.f.a(new Packet3Chat("§d[Server] " + str1));
|
||||||
} else if (str1.toLowerCase().startsWith("tell ")) {
|
} else if (str1.toLowerCase().startsWith("tell ")) {
|
||||||
String[] split = str1.split(" ");
|
String[] split = str1.split(" ");
|
||||||
if (split.length >= 3) {
|
if (split.length >= 3) {
|
||||||
@ -416,8 +412,8 @@ public class MinecraftServer
|
|||||||
a.info("[" + str2 + "->" + split[1] + "] " + str1);
|
a.info("[" + str2 + "->" + split[1] + "] " + str1);
|
||||||
str1 = "§7" + str2 + " whispers " + str1;
|
str1 = "§7" + str2 + " whispers " + str1;
|
||||||
a.info(str1);
|
a.info(str1);
|
||||||
if (!this.f.a(split[1], new br(str1))) {
|
if (!this.f.a(split[1], new Packet3Chat(str1))) {
|
||||||
localfn.b("There's no player by that name online.");
|
localICommandListener.b("There's no player by that name online.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -443,8 +439,8 @@ public class MinecraftServer
|
|||||||
return paramInt;
|
return paramInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void a(fc paramfc) {
|
public void a(IUpdatePlayerListBox paramIUpdatePlayerListBox) {
|
||||||
this.p.add(paramfc);
|
this.p.add(paramIUpdatePlayerListBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] paramArrayOfString) {
|
public static void main(String[] paramArrayOfString) {
|
||||||
@ -452,10 +448,10 @@ public class MinecraftServer
|
|||||||
MinecraftServer localMinecraftServer = new MinecraftServer();
|
MinecraftServer localMinecraftServer = new MinecraftServer();
|
||||||
|
|
||||||
if ((!GraphicsEnvironment.isHeadless()) && ((paramArrayOfString.length <= 0) || (!paramArrayOfString[0].equals("nogui")))) {
|
if ((!GraphicsEnvironment.isHeadless()) && ((paramArrayOfString.length <= 0) || (!paramArrayOfString[0].equals("nogui")))) {
|
||||||
hg.a(localMinecraftServer);
|
ServerGUI.a(localMinecraftServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
new cj("Server thread", localMinecraftServer).start();
|
new ThreadServerApplication("Server thread", localMinecraftServer).start();
|
||||||
} catch (Exception localException) {
|
} catch (Exception localException) {
|
||||||
a.log(Level.SEVERE, "Failed to start the minecraft server", localException);
|
a.log(Level.SEVERE, "Failed to start the minecraft server", localException);
|
||||||
}
|
}
|
||||||
|
337
src/net/minecraft/server/ServerConfigurationManager.java
Normal file
337
src/net/minecraft/server/ServerConfigurationManager.java
Normal file
@ -0,0 +1,337 @@
|
|||||||
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
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 org.bukkit.Server;
|
||||||
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.bukkit.event.player.PlayerEvent.EventType;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class ServerConfigurationManager {
|
||||||
|
|
||||||
|
public static Logger a = Logger.getLogger("Minecraft");
|
||||||
|
public List b = new ArrayList();
|
||||||
|
private MinecraftServer c;
|
||||||
|
private PlayerManager d;
|
||||||
|
private int e;
|
||||||
|
private Set<String> f = new HashSet<String>();
|
||||||
|
private Set<String> g = new HashSet<String>();
|
||||||
|
private Set<String> h = new HashSet<String>();
|
||||||
|
private File i;
|
||||||
|
private File j;
|
||||||
|
private File k;
|
||||||
|
private PlayerNBTManager l;
|
||||||
|
private CraftServer server; // Craftbukkit
|
||||||
|
|
||||||
|
public ServerConfigurationManager(MinecraftServer paramMinecraftServer) {
|
||||||
|
server = paramMinecraftServer.server; // Craftbukkit
|
||||||
|
|
||||||
|
this.c = paramMinecraftServer;
|
||||||
|
this.i = paramMinecraftServer.a("banned-players.txt");
|
||||||
|
this.j = paramMinecraftServer.a("banned-ips.txt");
|
||||||
|
this.k = paramMinecraftServer.a("ops.txt");
|
||||||
|
this.d = new PlayerManager(paramMinecraftServer);
|
||||||
|
this.e = paramMinecraftServer.d.a("max-players", 20);
|
||||||
|
e();
|
||||||
|
g();
|
||||||
|
i();
|
||||||
|
f();
|
||||||
|
h();
|
||||||
|
j();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(WorldServer paramWorldServer) {
|
||||||
|
this.l = new PlayerNBTManager(new File(paramWorldServer.t, "players"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int a() {
|
||||||
|
return this.d.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(EntityPlayerMP paramEntityPlayerMP) {
|
||||||
|
this.b.add(paramEntityPlayerMP);
|
||||||
|
this.l.b(paramEntityPlayerMP);
|
||||||
|
|
||||||
|
this.c.e.A.d((int) paramEntityPlayerMP.p >> 4, (int) paramEntityPlayerMP.r >> 4);
|
||||||
|
|
||||||
|
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);
|
||||||
|
this.d.a(paramEntityPlayerMP);
|
||||||
|
|
||||||
|
// Craftbukkit
|
||||||
|
server.getPluginManager().callEvent(EventType.Join, new PlayerEvent(server, server.getPlayer(paramEntityPlayerMP)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void b(EntityPlayerMP paramEntityPlayerMP) {
|
||||||
|
this.d.c(paramEntityPlayerMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void c(EntityPlayerMP paramEntityPlayerMP) {
|
||||||
|
this.l.a(paramEntityPlayerMP);
|
||||||
|
this.c.e.d(paramEntityPlayerMP);
|
||||||
|
this.b.remove(paramEntityPlayerMP);
|
||||||
|
this.d.b(paramEntityPlayerMP);
|
||||||
|
|
||||||
|
// Craftbukkit
|
||||||
|
server.getPluginManager().callEvent(EventType.Quit, new PlayerQuitEvent(server, server.getPlayer(paramEntityPlayerMP), PlayerQuitEvent.PlayerQuitReason.Disconnected));
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityPlayerMP a(NetLoginHandler paramNetLoginHandler, String paramString1, String paramString2) {
|
||||||
|
if (this.f.contains(paramString1.trim().toLowerCase())) {
|
||||||
|
paramNetLoginHandler.a("You are banned from this server!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String str = paramNetLoginHandler.b.b().toString();
|
||||||
|
str = str.substring(str.indexOf("/") + 1);
|
||||||
|
str = str.substring(0, str.indexOf(":"));
|
||||||
|
if (this.g.contains(str)) {
|
||||||
|
paramNetLoginHandler.a("Your IP address is banned from this server!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (this.b.size() >= this.e) {
|
||||||
|
paramNetLoginHandler.a("The server is full!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (int m = 0; m < this.b.size(); m++) {
|
||||||
|
EntityPlayerMP localEntityPlayerMP = (EntityPlayerMP) this.b.get(m);
|
||||||
|
if (localEntityPlayerMP.aw.equalsIgnoreCase(paramString1)) {
|
||||||
|
localEntityPlayerMP.a.a("You logged in from another location");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new EntityPlayerMP(this.c, this.c.e, paramString1, new ItemInWorldManager(this.c.e));
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityPlayerMP d(EntityPlayerMP paramEntityPlayerMP) {
|
||||||
|
this.c.k.a(paramEntityPlayerMP);
|
||||||
|
this.c.k.b(paramEntityPlayerMP);
|
||||||
|
this.d.b(paramEntityPlayerMP);
|
||||||
|
this.b.remove(paramEntityPlayerMP);
|
||||||
|
this.c.e.e(paramEntityPlayerMP);
|
||||||
|
|
||||||
|
EntityPlayerMP localEntityPlayerMP = new EntityPlayerMP(this.c, this.c.e, paramEntityPlayerMP.aw, new ItemInWorldManager(this.c.e));
|
||||||
|
localEntityPlayerMP.g = paramEntityPlayerMP.g;
|
||||||
|
localEntityPlayerMP.a = paramEntityPlayerMP.a;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
localEntityPlayerMP.a.b(new Packet9());
|
||||||
|
localEntityPlayerMP.a.a(localEntityPlayerMP.p, localEntityPlayerMP.q, localEntityPlayerMP.r, localEntityPlayerMP.v, localEntityPlayerMP.w);
|
||||||
|
|
||||||
|
this.d.a(localEntityPlayerMP);
|
||||||
|
this.c.e.a(localEntityPlayerMP);
|
||||||
|
this.b.add(localEntityPlayerMP);
|
||||||
|
|
||||||
|
localEntityPlayerMP.k();
|
||||||
|
return localEntityPlayerMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void b() {
|
||||||
|
this.d.a();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(int paramInt1, int paramInt2, int paramInt3) {
|
||||||
|
this.d.a(paramInt1, paramInt2, paramInt3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(Packet paramPacket) {
|
||||||
|
for (int m = 0; m < this.b.size(); m++) {
|
||||||
|
EntityPlayerMP localEntityPlayerMP = (EntityPlayerMP) this.b.get(m);
|
||||||
|
localEntityPlayerMP.a.b(paramPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String c() {
|
||||||
|
String str = "";
|
||||||
|
for (int m = 0; m < this.b.size(); m++) {
|
||||||
|
if (m > 0) {
|
||||||
|
str = str + ", ";
|
||||||
|
}
|
||||||
|
str = str + ((EntityPlayerMP) this.b.get(m)).aw;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(String paramString) {
|
||||||
|
this.f.add(paramString.toLowerCase());
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void b(String paramString) {
|
||||||
|
this.f.remove(paramString.toLowerCase());
|
||||||
|
f();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void e() {
|
||||||
|
try {
|
||||||
|
this.f.clear();
|
||||||
|
BufferedReader localBufferedReader = new BufferedReader(new FileReader(this.i));
|
||||||
|
String str = "";
|
||||||
|
while ((str = localBufferedReader.readLine()) != null) {
|
||||||
|
this.f.add(str.trim().toLowerCase());
|
||||||
|
}
|
||||||
|
localBufferedReader.close();
|
||||||
|
} catch (Exception localException) {
|
||||||
|
a.warning("Failed to load ban list: " + localException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void f() {
|
||||||
|
try {
|
||||||
|
PrintWriter localPrintWriter = new PrintWriter(new FileWriter(this.i, false));
|
||||||
|
for (String str : this.f) {
|
||||||
|
localPrintWriter.println(str);
|
||||||
|
}
|
||||||
|
localPrintWriter.close();
|
||||||
|
} catch (Exception localException) {
|
||||||
|
a.warning("Failed to save ban list: " + localException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void c(String paramString) {
|
||||||
|
this.g.add(paramString.toLowerCase());
|
||||||
|
h();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void d(String paramString) {
|
||||||
|
this.g.remove(paramString.toLowerCase());
|
||||||
|
h();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void g() {
|
||||||
|
try {
|
||||||
|
this.g.clear();
|
||||||
|
BufferedReader localBufferedReader = new BufferedReader(new FileReader(this.j));
|
||||||
|
String str = "";
|
||||||
|
while ((str = localBufferedReader.readLine()) != null) {
|
||||||
|
this.g.add(str.trim().toLowerCase());
|
||||||
|
}
|
||||||
|
localBufferedReader.close();
|
||||||
|
} catch (Exception localException) {
|
||||||
|
a.warning("Failed to load ip ban list: " + localException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void h() {
|
||||||
|
try {
|
||||||
|
PrintWriter localPrintWriter = new PrintWriter(new FileWriter(this.j, false));
|
||||||
|
for (String str : this.g) {
|
||||||
|
localPrintWriter.println(str);
|
||||||
|
}
|
||||||
|
localPrintWriter.close();
|
||||||
|
} catch (Exception localException) {
|
||||||
|
a.warning("Failed to save ip ban list: " + localException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void e(String paramString) {
|
||||||
|
this.h.add(paramString.toLowerCase());
|
||||||
|
j();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void f(String paramString) {
|
||||||
|
this.h.remove(paramString.toLowerCase());
|
||||||
|
j();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void i() {
|
||||||
|
try {
|
||||||
|
this.h.clear();
|
||||||
|
BufferedReader localBufferedReader = new BufferedReader(new FileReader(this.k));
|
||||||
|
String str = "";
|
||||||
|
while ((str = localBufferedReader.readLine()) != null) {
|
||||||
|
this.h.add(str.trim().toLowerCase());
|
||||||
|
}
|
||||||
|
localBufferedReader.close();
|
||||||
|
} catch (Exception localException) {
|
||||||
|
a.warning("Failed to load ip ban list: " + localException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void j() {
|
||||||
|
try {
|
||||||
|
PrintWriter localPrintWriter = new PrintWriter(new FileWriter(this.k, false));
|
||||||
|
for (String str : this.h) {
|
||||||
|
localPrintWriter.println(str);
|
||||||
|
}
|
||||||
|
localPrintWriter.close();
|
||||||
|
} catch (Exception localException) {
|
||||||
|
a.warning("Failed to save ip ban list: " + localException);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean g(String paramString) {
|
||||||
|
return this.h.contains(paramString.trim().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityPlayerMP h(String paramString) {
|
||||||
|
for (int m = 0; m < this.b.size(); m++) {
|
||||||
|
EntityPlayerMP localEntityPlayerMP = (EntityPlayerMP) this.b.get(m);
|
||||||
|
if (localEntityPlayerMP.aw.equalsIgnoreCase(paramString)) {
|
||||||
|
return localEntityPlayerMP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(String paramString1, String paramString2) {
|
||||||
|
EntityPlayerMP localEntityPlayerMP = h(paramString1);
|
||||||
|
if (localEntityPlayerMP != null) {
|
||||||
|
localEntityPlayerMP.a.b(new Packet3Chat(paramString2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4, Packet paramPacket) {
|
||||||
|
for (int m = 0; m < this.b.size(); m++) {
|
||||||
|
EntityPlayerMP localEntityPlayerMP = (EntityPlayerMP) this.b.get(m);
|
||||||
|
double d1 = paramDouble1 - localEntityPlayerMP.p;
|
||||||
|
double d2 = paramDouble2 - localEntityPlayerMP.q;
|
||||||
|
double d3 = paramDouble3 - localEntityPlayerMP.r;
|
||||||
|
if (d1 * d1 + d2 * d2 + d3 * d3 < paramDouble4 * paramDouble4) {
|
||||||
|
localEntityPlayerMP.a.b(paramPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 boolean a(String paramString, Packet paramPacket) {
|
||||||
|
EntityPlayerMP localEntityPlayerMP = h(paramString);
|
||||||
|
if (localEntityPlayerMP != null) {
|
||||||
|
localEntityPlayerMP.a.b(paramPacket);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void d() {
|
||||||
|
for (int m = 0; m < this.b.size(); m++) {
|
||||||
|
this.l.a((EntityPlayerMP) this.b.get(m));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(int paramInt1, int paramInt2, int paramInt3, TileEntity paramTileEntity) {
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,15 @@
|
|||||||
|
|
||||||
package org.bukkit.craftbukkit;
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
import net.minecraft.server.fi;
|
import net.minecraft.server.EntityPlayerMP;
|
||||||
import org.bukkit.Player;
|
import org.bukkit.Player;
|
||||||
|
|
||||||
public class CraftPlayer implements Player {
|
public class CraftPlayer implements Player {
|
||||||
private fi player;
|
private EntityPlayerMP player;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final CraftServer server;
|
private final CraftServer server;
|
||||||
|
|
||||||
public CraftPlayer(CraftServer serv, fi handle) {
|
public CraftPlayer(CraftServer serv, EntityPlayerMP handle) {
|
||||||
player = handle;
|
player = handle;
|
||||||
name = player.aw;
|
name = player.aw;
|
||||||
server = serv;
|
server = serv;
|
||||||
|
@ -8,6 +8,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import net.minecraft.server.*;
|
import net.minecraft.server.*;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.SimplePluginManager;
|
import org.bukkit.plugin.SimplePluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||||
@ -19,7 +20,7 @@ public final class CraftServer implements Server {
|
|||||||
private final PluginManager pluginManager = new SimplePluginManager(this);
|
private final PluginManager pluginManager = new SimplePluginManager(this);
|
||||||
|
|
||||||
protected final MinecraftServer console;
|
protected final MinecraftServer console;
|
||||||
protected final hl server;
|
protected final ServerConfigurationManager server;
|
||||||
|
|
||||||
public CraftServer(MinecraftServer instance, String ver) {
|
public CraftServer(MinecraftServer instance, String ver) {
|
||||||
serverVersion = ver;
|
serverVersion = ver;
|
||||||
@ -50,7 +51,7 @@ public final class CraftServer implements Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Player[] getOnlinePlayers() {
|
public Player[] getOnlinePlayers() {
|
||||||
List<fi> online = server.b;
|
List<EntityPlayerMP> online = server.b;
|
||||||
Player[] players = new Player[online.size()];
|
Player[] players = new Player[online.size()];
|
||||||
|
|
||||||
for (int i = 0; i < players.length; i++) {
|
for (int i = 0; i < players.length; i++) {
|
||||||
@ -67,6 +68,17 @@ public final class CraftServer implements Server {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Player getPlayer(EntityPlayerMP entity) {
|
||||||
|
Player result = playerCache.get(entity.aw);
|
||||||
|
|
||||||
|
if (result == null) {
|
||||||
|
result = new CraftPlayer(this, entity);
|
||||||
|
playerCache.put(entity.aw, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public PluginManager getPluginManager() {
|
public PluginManager getPluginManager() {
|
||||||
return pluginManager;
|
return pluginManager;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user