2010-12-26 03:20:29 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
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.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
2010-12-26 03:20:29 +01:00
|
|
|
import java.util.logging.Logger;
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start
|
2011-02-04 16:04:28 +01:00
|
|
|
import org.bukkit.Location;
|
2010-12-26 03:20:29 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftServer;
|
2011-02-22 19:02:06 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftWorld;
|
2011-02-25 17:12:38 +01:00
|
|
|
import org.bukkit.craftbukkit.command.ColouredConsoleSender;
|
2011-01-23 13:23:13 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2011-03-27 00:34:33 +01:00
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
2011-03-26 12:31:48 +01:00
|
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
2010-12-28 23:22:26 +01:00
|
|
|
import org.bukkit.event.player.PlayerLoginEvent;
|
2011-02-04 16:04:28 +01:00
|
|
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit end
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2010-12-26 03:20:29 +01:00
|
|
|
public class ServerConfigurationManager {
|
|
|
|
|
|
|
|
public static Logger a = Logger.getLogger("Minecraft");
|
2011-01-29 22:50:29 +01:00
|
|
|
public List b = new ArrayList();
|
2011-02-23 13:56:36 +01:00
|
|
|
public MinecraftServer c; // CraftBukkit - private->public
|
|
|
|
// public PlayerManager d; // CraftBukkit - removed!
|
|
|
|
public int e; // CraftBukkit - private->public
|
2011-01-29 22:50:29 +01:00
|
|
|
private Set f = new HashSet();
|
|
|
|
private Set g = new HashSet();
|
|
|
|
private Set h = new HashSet();
|
2011-02-23 03:37:56 +01:00
|
|
|
private Set i = new HashSet();
|
2010-12-26 03:20:29 +01:00
|
|
|
private File j;
|
|
|
|
private File k;
|
2011-02-23 03:37:56 +01:00
|
|
|
private File l;
|
|
|
|
private File m;
|
2011-04-03 17:40:08 +02:00
|
|
|
public PlayerFileData n; // CraftBukkit - private->public
|
2011-02-23 03:37:56 +01:00
|
|
|
private boolean o;
|
2010-12-26 03:20:29 +01:00
|
|
|
|
2011-02-04 16:04:28 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
private CraftServer server;
|
|
|
|
|
2011-01-11 09:25:13 +01:00
|
|
|
public ServerConfigurationManager(MinecraftServer minecraftserver) {
|
2011-01-30 13:51:20 +01:00
|
|
|
minecraftserver.server = new CraftServer(minecraftserver, this);
|
2011-02-25 17:12:38 +01:00
|
|
|
minecraftserver.console = new ColouredConsoleSender(minecraftserver.server);
|
2011-01-30 13:51:20 +01:00
|
|
|
server = minecraftserver.server;
|
2011-02-04 16:04:28 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.c = minecraftserver;
|
2011-02-23 03:37:56 +01:00
|
|
|
this.j = minecraftserver.a("banned-players.txt");
|
|
|
|
this.k = minecraftserver.a("banned-ips.txt");
|
|
|
|
this.l = minecraftserver.a("ops.txt");
|
|
|
|
this.m = minecraftserver.a("white-list.txt");
|
2011-02-23 13:56:36 +01:00
|
|
|
// this.d = new PlayerManager(minecraftserver); // CraftBukkit - removed!
|
2011-01-29 22:50:29 +01:00
|
|
|
this.e = minecraftserver.d.a("max-players", 20);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.o = minecraftserver.d.a("white-list", false);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.g();
|
|
|
|
this.i();
|
2011-02-23 03:37:56 +01:00
|
|
|
this.k();
|
|
|
|
this.m();
|
2011-01-29 22:50:29 +01:00
|
|
|
this.h();
|
|
|
|
this.j();
|
2011-02-23 03:37:56 +01:00
|
|
|
this.l();
|
|
|
|
this.n();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public void a(WorldServer worldserver) {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.n == null) {
|
2011-03-31 22:40:00 +02:00
|
|
|
this.n = worldserver.o().d();
|
2011-02-07 02:10:55 +01:00
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int a() {
|
2011-02-23 13:56:36 +01:00
|
|
|
return 144; // CraftBukkit - magic number from PlayerManager.b() (??)
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(EntityPlayer entityplayer) {
|
|
|
|
this.b.add(entityplayer);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.n.b(entityplayer);
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2011-03-31 22:40:00 +02:00
|
|
|
((WorldServer) entityplayer.world).u.c((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
|
2011-02-05 19:15:04 +01:00
|
|
|
|
|
|
|
while (entityplayer.world.a(entityplayer, entityplayer.boundingBox).size() != 0) {
|
2011-01-29 22:50:29 +01:00
|
|
|
entityplayer.a(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-05 19:15:04 +01:00
|
|
|
entityplayer.world.a(entityplayer);
|
2011-01-30 20:42:39 +01:00
|
|
|
|
2011-03-26 22:32:56 +01:00
|
|
|
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(server.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " joined the game.");
|
2011-03-26 12:31:48 +01:00
|
|
|
|
|
|
|
server.getPluginManager().callEvent(playerJoinEvent);
|
|
|
|
|
|
|
|
String joinMessage = playerJoinEvent.getJoinMessage();
|
|
|
|
|
|
|
|
if (joinMessage != null) {
|
|
|
|
this.c.f.a((Packet) (new Packet3Chat(joinMessage)));
|
|
|
|
}
|
2011-02-06 23:53:48 +01:00
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
((WorldServer) entityplayer.world).manager.a(entityplayer);
|
|
|
|
// CraftBukkit end
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void b(EntityPlayer entityplayer) {
|
2011-02-23 13:56:36 +01:00
|
|
|
((WorldServer) entityplayer.world).manager.c(entityplayer); // CraftBukkit
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-02 16:42:11 +02:00
|
|
|
public String c(EntityPlayer entityplayer) { // CraftBukkit - changed return type
|
2011-02-23 03:37:56 +01:00
|
|
|
this.n.a(entityplayer);
|
2011-02-23 13:56:36 +01:00
|
|
|
entityplayer.world.d(entityplayer); // CraftBukkit
|
2011-01-29 22:50:29 +01:00
|
|
|
this.b.remove(entityplayer);
|
2010-12-26 03:20:29 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit start
|
2011-02-23 13:56:36 +01:00
|
|
|
((WorldServer) entityplayer.world).manager.b(entityplayer);
|
2011-04-02 16:42:11 +02:00
|
|
|
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(server.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " left the game.");
|
|
|
|
server.getPluginManager().callEvent(playerQuitEvent);
|
|
|
|
return playerQuitEvent.getQuitMessage();
|
2011-01-30 13:51:20 +01:00
|
|
|
// CraftBukkit end
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2011-01-30 13:51:20 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public EntityPlayer a(NetLoginHandler netloginhandler, String s, String s1) {
|
2011-01-11 09:25:13 +01:00
|
|
|
// CraftBukkit start - note: this entire method needs to be changed
|
2010-12-28 23:22:26 +01:00
|
|
|
// Instead of kicking then returning, we need to store the kick reason
|
|
|
|
// in the event, check with plugins to see if it's ok, and THEN kick
|
2011-02-05 19:15:04 +01:00
|
|
|
// depending on the outcome. Also change any reference to this.e.c to entity.world
|
|
|
|
EntityPlayer entity = new EntityPlayer(c, c.worlds.get(0), s, new ItemInWorldManager(c.worlds.get(0)));
|
2011-01-29 22:50:29 +01:00
|
|
|
Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
|
2011-03-26 22:32:56 +01:00
|
|
|
PlayerLoginEvent event = new PlayerLoginEvent(player);
|
2011-01-11 09:25:13 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
String s2 = netloginhandler.b.b().toString();
|
2010-12-28 20:52:24 +01:00
|
|
|
|
|
|
|
s2 = s2.substring(s2.indexOf("/") + 1);
|
|
|
|
s2 = s2.substring(0, s2.indexOf(":"));
|
2010-12-28 23:22:26 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (this.f.contains(s.trim().toLowerCase())) {
|
2010-12-28 23:22:26 +01:00
|
|
|
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You are banned from this server!");
|
2011-02-23 03:37:56 +01:00
|
|
|
} else if (!this.g(s)) {
|
2011-03-20 07:08:00 +01:00
|
|
|
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!");
|
2011-01-29 22:50:29 +01:00
|
|
|
} else if (this.g.contains(s2)) {
|
2010-12-28 23:22:26 +01:00
|
|
|
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Your IP address is banned from this server!");
|
2011-01-29 22:50:29 +01:00
|
|
|
} else if (this.b.size() >= this.e) {
|
2010-12-28 23:22:26 +01:00
|
|
|
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!");
|
2011-03-18 08:03:03 +01:00
|
|
|
} else {
|
|
|
|
event.disallow(PlayerLoginEvent.Result.ALLOWED, s2);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2011-01-01 14:06:04 +01:00
|
|
|
|
2010-12-28 23:22:26 +01:00
|
|
|
server.getPluginManager().callEvent(event);
|
|
|
|
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
|
|
|
|
netloginhandler.a(event.getKickMessage());
|
2010-12-26 03:20:29 +01:00
|
|
|
return null;
|
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < this.b.size(); ++i) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
|
|
|
|
|
|
|
|
if (entityplayer.name.equalsIgnoreCase(s)) {
|
|
|
|
entityplayer.a.a("You logged in from another location");
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-05 19:15:04 +01:00
|
|
|
return new EntityPlayer(this.c, entity.world, s, new ItemInWorldManager(entity.world));
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
2010-12-28 20:52:24 +01:00
|
|
|
}
|
2010-12-26 03:20:29 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public EntityPlayer d(EntityPlayer entityplayer) {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start - every reference to this.c.e should be entityplayer.world
|
2011-01-29 22:50:29 +01:00
|
|
|
this.c.k.a(entityplayer);
|
|
|
|
this.c.k.b(entityplayer);
|
2011-02-23 13:56:36 +01:00
|
|
|
((WorldServer) entityplayer.world).manager.b(entityplayer);
|
2011-01-29 22:50:29 +01:00
|
|
|
this.b.remove(entityplayer);
|
2011-02-05 19:15:04 +01:00
|
|
|
entityplayer.world.e(entityplayer);
|
2011-03-31 22:40:00 +02:00
|
|
|
ChunkCoordinates chunkcoordinates = entityplayer.H();
|
2011-02-05 19:15:04 +01:00
|
|
|
EntityPlayer entityplayer1 = new EntityPlayer(this.c, entityplayer.world, entityplayer.name, new ItemInWorldManager(entityplayer.world));
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
entityplayer1.id = entityplayer.id;
|
|
|
|
entityplayer1.a = entityplayer.a;
|
2011-03-13 13:29:52 +01:00
|
|
|
entityplayer1.displayName = entityplayer.displayName; // CraftBukkit
|
2011-03-25 21:22:03 +01:00
|
|
|
entityplayer1.compassTarget = entityplayer.compassTarget; // CraftBukkit
|
2011-03-31 22:40:00 +02:00
|
|
|
|
|
|
|
if (chunkcoordinates != null) {
|
|
|
|
ChunkCoordinates chunkcoordinates1 = EntityHuman.a(entityplayer.world, chunkcoordinates);
|
|
|
|
|
|
|
|
if (chunkcoordinates1 != null) {
|
|
|
|
entityplayer1.c((double) ((float) chunkcoordinates1.a + 0.5F), (double) ((float) chunkcoordinates1.b + 0.1F), (double) ((float) chunkcoordinates1.c + 0.5F), 0.0F, 0.0F);
|
|
|
|
entityplayer1.a(chunkcoordinates);
|
|
|
|
} else {
|
|
|
|
entityplayer1.a.b((Packet) (new Packet70Bed(0)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
((WorldServer) entityplayer.world).u.d((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-05 19:15:04 +01:00
|
|
|
while (entityplayer.world.a(entityplayer1, entityplayer1.boundingBox).size() != 0) {
|
2011-01-29 22:50:29 +01:00
|
|
|
entityplayer1.a(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2011-02-04 16:04:28 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
Player respawnPlayer = server.getPlayer(entityplayer);
|
|
|
|
Location respawnLocation = new Location(respawnPlayer.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
2011-03-26 22:32:56 +01:00
|
|
|
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, respawnLocation );
|
2011-02-04 16:04:28 +01:00
|
|
|
server.getPluginManager().callEvent(respawnEvent);
|
2011-02-23 13:56:36 +01:00
|
|
|
|
|
|
|
entityplayer1.world = ((CraftWorld) respawnEvent.getRespawnLocation().getWorld()).getHandle();
|
2011-02-04 16:04:28 +01:00
|
|
|
entityplayer1.locX = respawnEvent.getRespawnLocation().getX();
|
|
|
|
entityplayer1.locY = respawnEvent.getRespawnLocation().getY();
|
|
|
|
entityplayer1.locZ = respawnEvent.getRespawnLocation().getZ();
|
|
|
|
entityplayer1.yaw = respawnEvent.getRespawnLocation().getYaw();
|
|
|
|
entityplayer1.pitch = respawnEvent.getRespawnLocation().getPitch();
|
2011-02-23 13:56:36 +01:00
|
|
|
entityplayer1.c = new ItemInWorldManager(((CraftWorld) respawnEvent.getRespawnLocation().getWorld()).getHandle());
|
2011-02-22 19:02:06 +01:00
|
|
|
entityplayer1.c.a = entityplayer1;
|
2011-02-23 13:56:36 +01:00
|
|
|
((WorldServer) entityplayer1.world).u.d((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
|
2011-02-04 16:04:28 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
entityplayer1.a.b((Packet) (new Packet9Respawn()));
|
|
|
|
entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
2011-02-05 19:15:04 +01:00
|
|
|
entityplayer.world.a(entityplayer1);
|
2011-03-31 22:40:00 +02:00
|
|
|
((WorldServer) entityplayer1.world).manager.a(entityplayer1);
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-01-29 22:50:29 +01:00
|
|
|
this.b.add(entityplayer1);
|
2011-03-31 22:40:00 +02:00
|
|
|
entityplayer1.m();
|
|
|
|
entityplayer1.t();
|
2011-01-29 22:50:29 +01:00
|
|
|
return entityplayer1;
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b() {
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
for (WorldServer world: c.worlds) {
|
2011-02-06 23:53:48 +01:00
|
|
|
world.manager.a();
|
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit start - changed signature
|
2011-02-05 19:15:04 +01:00
|
|
|
public void a(int i, int j, int k, WorldServer world) {
|
2011-02-23 03:37:56 +01:00
|
|
|
world.manager.a(i, j, k);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2010-12-26 03:20:29 +01:00
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public void a(Packet packet) {
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < this.b.size(); ++i) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
entityplayer.a.b(packet);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String c() {
|
2010-12-28 20:52:24 +01:00
|
|
|
String s = "";
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < this.b.size(); ++i) {
|
|
|
|
if (i > 0) {
|
|
|
|
s = s + ", ";
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
s = s + ((EntityPlayer) this.b.get(i)).name;
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
|
|
|
return s;
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public void a(String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.f.add(s.toLowerCase());
|
2011-02-23 03:37:56 +01:00
|
|
|
this.h();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public void b(String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.f.remove(s.toLowerCase());
|
2011-02-23 03:37:56 +01:00
|
|
|
this.h();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void g() {
|
2010-12-26 03:20:29 +01:00
|
|
|
try {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.f.clear();
|
2011-02-23 03:37:56 +01:00
|
|
|
BufferedReader bufferedreader = new BufferedReader(new FileReader(this.j));
|
2011-01-29 22:50:29 +01:00
|
|
|
String s = "";
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
while ((s = bufferedreader.readLine()) != null) {
|
|
|
|
this.f.add(s.trim().toLowerCase());
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
|
|
|
bufferedreader.close();
|
|
|
|
} catch (Exception exception) {
|
2011-01-29 22:50:29 +01:00
|
|
|
a.warning("Failed to load ban list: " + exception);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void h() {
|
2010-12-26 03:20:29 +01:00
|
|
|
try {
|
2011-02-23 03:37:56 +01:00
|
|
|
PrintWriter printwriter = new PrintWriter(new FileWriter(this.j, false));
|
2011-01-29 22:50:29 +01:00
|
|
|
Iterator iterator = this.f.iterator();
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
while (iterator.hasNext()) {
|
|
|
|
String s = (String) iterator.next();
|
|
|
|
|
|
|
|
printwriter.println(s);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
|
|
|
printwriter.close();
|
|
|
|
} catch (Exception exception) {
|
2011-01-29 22:50:29 +01:00
|
|
|
a.warning("Failed to save ban list: " + exception);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public void c(String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.g.add(s.toLowerCase());
|
2011-02-23 03:37:56 +01:00
|
|
|
this.j();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public void d(String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.g.remove(s.toLowerCase());
|
2011-02-23 03:37:56 +01:00
|
|
|
this.j();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void i() {
|
2010-12-26 03:20:29 +01:00
|
|
|
try {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.g.clear();
|
2011-02-23 03:37:56 +01:00
|
|
|
BufferedReader bufferedreader = new BufferedReader(new FileReader(this.k));
|
2011-01-29 22:50:29 +01:00
|
|
|
String s = "";
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
while ((s = bufferedreader.readLine()) != null) {
|
|
|
|
this.g.add(s.trim().toLowerCase());
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
|
|
|
bufferedreader.close();
|
|
|
|
} catch (Exception exception) {
|
2011-01-29 22:50:29 +01:00
|
|
|
a.warning("Failed to load ip ban list: " + exception);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void j() {
|
2010-12-26 03:20:29 +01:00
|
|
|
try {
|
2011-02-23 03:37:56 +01:00
|
|
|
PrintWriter printwriter = new PrintWriter(new FileWriter(this.k, false));
|
2011-01-29 22:50:29 +01:00
|
|
|
Iterator iterator = this.g.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
String s = (String) iterator.next();
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
printwriter.println(s);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
|
|
|
printwriter.close();
|
|
|
|
} catch (Exception exception) {
|
2011-01-29 22:50:29 +01:00
|
|
|
a.warning("Failed to save ip ban list: " + exception);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public void e(String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.h.add(s.toLowerCase());
|
2011-02-23 03:37:56 +01:00
|
|
|
this.l();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public void f(String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.h.remove(s.toLowerCase());
|
2011-02-23 03:37:56 +01:00
|
|
|
this.l();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void k() {
|
2010-12-26 03:20:29 +01:00
|
|
|
try {
|
2011-01-29 22:50:29 +01:00
|
|
|
this.h.clear();
|
2011-02-23 03:37:56 +01:00
|
|
|
BufferedReader bufferedreader = new BufferedReader(new FileReader(this.l));
|
2011-01-29 22:50:29 +01:00
|
|
|
String s = "";
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
while ((s = bufferedreader.readLine()) != null) {
|
|
|
|
this.h.add(s.trim().toLowerCase());
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
|
|
|
bufferedreader.close();
|
|
|
|
} catch (Exception exception) {
|
2011-02-24 02:18:23 +01:00
|
|
|
a.warning("Failed to load ops: " + exception); // CraftBukkit corrected text
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void l() {
|
2010-12-26 03:20:29 +01:00
|
|
|
try {
|
2011-02-23 03:37:56 +01:00
|
|
|
PrintWriter printwriter = new PrintWriter(new FileWriter(this.l, false));
|
2011-01-29 22:50:29 +01:00
|
|
|
Iterator iterator = this.h.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
String s = (String) iterator.next();
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
printwriter.println(s);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
|
|
|
printwriter.close();
|
|
|
|
} catch (Exception exception) {
|
2011-02-24 02:18:23 +01:00
|
|
|
a.warning("Failed to save ops: " + exception); // CraftBukkit corrected text
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
private void m() {
|
|
|
|
try {
|
|
|
|
this.i.clear();
|
|
|
|
BufferedReader bufferedreader = new BufferedReader(new FileReader(this.m));
|
|
|
|
String s = "";
|
|
|
|
|
|
|
|
while ((s = bufferedreader.readLine()) != null) {
|
|
|
|
this.i.add(s.trim().toLowerCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
bufferedreader.close();
|
|
|
|
} catch (Exception exception) {
|
|
|
|
a.warning("Failed to load white-list: " + exception);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void n() {
|
|
|
|
try {
|
|
|
|
PrintWriter printwriter = new PrintWriter(new FileWriter(this.m, false));
|
|
|
|
Iterator iterator = this.i.iterator();
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
String s = (String) iterator.next();
|
|
|
|
|
|
|
|
printwriter.println(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
printwriter.close();
|
|
|
|
} catch (Exception exception) {
|
|
|
|
a.warning("Failed to save white-list: " + exception);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public boolean g(String s) {
|
2011-02-23 03:37:56 +01:00
|
|
|
s = s.trim().toLowerCase();
|
|
|
|
return !this.o || this.h.contains(s) || this.i.contains(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean h(String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return this.h.contains(s.trim().toLowerCase());
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public EntityPlayer i(String s) {
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < this.b.size(); ++i) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entityplayer.name.equalsIgnoreCase(s)) {
|
|
|
|
return entityplayer;
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2010-12-26 03:20:29 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public void a(String s, String s1) {
|
2011-02-23 03:37:56 +01:00
|
|
|
EntityPlayer entityplayer = this.i(s);
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entityplayer != null) {
|
|
|
|
entityplayer.a.b((Packet) (new Packet3Chat(s1)));
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(double d0, double d1, double d2, double d3, Packet packet) {
|
|
|
|
for (int i = 0; i < this.b.size(); ++i) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
|
|
|
|
double d4 = d0 - entityplayer.locX;
|
|
|
|
double d5 = d1 - entityplayer.locY;
|
|
|
|
double d6 = d2 - entityplayer.locZ;
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (d4 * d4 + d5 * d5 + d6 * d6 < d3 * d3) {
|
|
|
|
entityplayer.a.b(packet);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public void j(String s) {
|
2010-12-28 20:52:24 +01:00
|
|
|
Packet3Chat packet3chat = new Packet3Chat(s);
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < this.b.size(); ++i) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) this.b.get(i);
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
if (this.h(entityplayer.name)) {
|
2011-01-29 22:50:29 +01:00
|
|
|
entityplayer.a.b((Packet) packet3chat);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-28 20:52:24 +01:00
|
|
|
public boolean a(String s, Packet packet) {
|
2011-02-23 03:37:56 +01:00
|
|
|
EntityPlayer entityplayer = this.i(s);
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
if (entityplayer != null) {
|
|
|
|
entityplayer.a.b(packet);
|
2010-12-26 03:20:29 +01:00
|
|
|
return true;
|
2010-12-28 20:52:24 +01:00
|
|
|
} else {
|
|
|
|
return false;
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void d() {
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < this.b.size(); ++i) {
|
2011-02-23 03:37:56 +01:00
|
|
|
this.n.a((EntityHuman) this.b.get(i));
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public void a(int i, int j, int k, TileEntity tileentity) {}
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
public void k(String s) {
|
|
|
|
this.i.add(s);
|
|
|
|
this.n();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void l(String s) {
|
|
|
|
this.i.remove(s);
|
|
|
|
this.n();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set e() {
|
|
|
|
return this.i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void f() {
|
|
|
|
this.m();
|
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
}
|