3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-18 05:50:04 +01:00
Paper/src/main/java/net/minecraft/server/ServerConfigurationManager.java

653 Zeilen
23 KiB
Java

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
// CraftBukkit start
import org.bukkit.Location;
2010-12-26 03:20:29 +01:00
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.command.ColouredConsoleSender;
import org.bukkit.entity.Player;
2011-06-07 23:20:03 +02:00
import org.bukkit.event.player.PlayerPortalEvent;
2011-03-27 00:34:33 +01:00
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerJoinEvent;
2010-12-28 23:22:26 +01:00
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
2011-06-07 23:20:03 +02:00
import org.bukkit.Bukkit;
// 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");
public List players = new ArrayList();
2011-05-14 16:29:42 +02:00
public MinecraftServer server; // CraftBukkit - private -> public
// private PlayerManager[] d = new PlayerManager[2]; // Craftbukkit - removed
2011-05-14 16:29:42 +02:00
public int maxPlayers; // CraftBukkit - private -> public
private Set banByName = new HashSet();
private Set banByIP = new HashSet();
2011-01-29 22:50:29 +01:00
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-05-14 16:29:42 +02:00
public PlayerFileData playerFileData; // CraftBukkit - private - >public
2011-02-23 03:37:56 +01:00
private boolean o;
2010-12-26 03:20:29 +01:00
// CraftBukkit start
private CraftServer cserver;
public ServerConfigurationManager(MinecraftServer minecraftserver) {
2011-01-30 13:51:20 +01:00
minecraftserver.server = new CraftServer(minecraftserver, this);
minecraftserver.console = new ColouredConsoleSender(minecraftserver.server);
cserver = minecraftserver.server;
// CraftBukkit end
this.server = 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-05-26 14:48:22 +02:00
int i = minecraftserver.propertyManager.getInt("view-distance", 10);
// Craftbukkit - removed playermanagers
this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20);
this.o = minecraftserver.propertyManager.getBoolean("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
}
2011-05-26 14:48:22 +02:00
public void setPlayerFileData(WorldServer[] aworldserver) {
if (this.playerFileData != null) return; // CraftBukkit
2011-05-26 14:48:22 +02:00
this.playerFileData = aworldserver[0].p().d();
}
public void a(EntityPlayer entityplayer) {
// Craftbukkit - removed playermanagers
2011-05-28 22:50:08 +02:00
for(WorldServer world : this.server.worlds) {
if(world.manager.a.contains(entityplayer)) {
world.manager.removePlayer(entityplayer);
break;
}
}
2011-05-26 14:48:22 +02:00
this.a(entityplayer.dimension).addPlayer(entityplayer);
WorldServer worldserver = this.server.a(entityplayer.dimension);
worldserver.chunkProviderServer.getChunkAt((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
2010-12-26 03:20:29 +01:00
}
public int a() {
// Craftbukkit start
if (this.server.worlds.size() == 0) {
return this.server.propertyManager.getInt("view-distance", 10) * 16 - 16;
} else {
return this.server.worlds.get(0).manager.c();
}
// Craftbukkit end
2010-12-26 03:20:29 +01:00
}
2011-05-26 14:48:22 +02:00
private PlayerManager a(int i) {
return server.a(i).manager; // Craftbukkit
2011-05-26 14:48:22 +02:00
}
public void b(EntityPlayer entityplayer) {
this.playerFileData.b(entityplayer);
2011-05-26 14:48:22 +02:00
}
2011-05-26 14:48:22 +02:00
public void c(EntityPlayer entityplayer) {
this.players.add(entityplayer);
WorldServer worldserver = this.server.a(entityplayer.dimension);
worldserver.chunkProviderServer.getChunkAt((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
while (worldserver.getEntities(entityplayer, entityplayer.boundingBox).size() != 0) {
entityplayer.setPosition(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
2010-12-26 03:20:29 +01:00
}
2011-05-26 14:48:22 +02:00
// CraftBukkit start
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " joined the game.");
cserver.getPluginManager().callEvent(playerJoinEvent);
String joinMessage = playerJoinEvent.getJoinMessage();
if (joinMessage != null) {
this.server.serverConfigurationManager.sendAll(new Packet3Chat(joinMessage));
}
2011-02-23 13:56:36 +01:00
// CraftBukkit end
2011-05-26 14:48:22 +02:00
worldserver.addEntity(entityplayer);
this.a(entityplayer.dimension).addPlayer(entityplayer);
2010-12-26 03:20:29 +01:00
}
2011-05-26 14:48:22 +02:00
public void d(EntityPlayer entityplayer) {
this.a(entityplayer.dimension).movePlayer(entityplayer);
2010-12-26 03:20:29 +01:00
}
public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - changed return type
2011-01-29 22:50:29 +01:00
// CraftBukkit start
// Quitting must be before we do final save of data, in case plugins need to modify it
2011-05-26 14:48:22 +02:00
this.a(entityplayer.dimension).removePlayer(entityplayer);
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " left the game.");
cserver.getPluginManager().callEvent(playerQuitEvent);
2011-01-30 13:51:20 +01:00
// CraftBukkit end
this.playerFileData.a(entityplayer);
2011-05-26 14:48:22 +02:00
this.server.a(entityplayer.dimension).kill(entityplayer);
this.players.remove(entityplayer);
2011-05-26 14:48:22 +02:00
this.a(entityplayer.dimension).removePlayer(entityplayer);
return playerQuitEvent.getQuitMessage(); // CraftBukkit
2010-12-26 03:20:29 +01:00
}
2011-01-30 13:51:20 +01:00
2011-04-20 22:47:26 +02:00
public EntityPlayer a(NetLoginHandler netloginhandler, String s) {
// 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
// depending on the outcome. Also change any reference to this.e.c to entity.world
2011-05-26 14:48:22 +02:00
EntityPlayer entity = new EntityPlayer(this.server, this.server.a(0), s, new ItemInWorldManager(this.server.a(0)));
2011-01-29 22:50:29 +01:00
Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
PlayerLoginEvent event = new PlayerLoginEvent(player);
2011-05-26 14:48:22 +02:00
String s1 = netloginhandler.networkManager.getSocketAddress().toString();
2010-12-28 20:52:24 +01:00
2011-05-26 14:48:22 +02:00
s1 = s1.substring(s1.indexOf("/") + 1);
s1 = s1.substring(0, s1.indexOf(":"));
2010-12-28 23:22:26 +01:00
if (this.banByName.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-05-14 16:29:42 +02:00
// return null // CraftBukkit
} else if (!this.isWhitelisted(s)) {
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!");
2011-05-26 14:48:22 +02:00
} else if (this.banByIP.contains(s1)) {
2010-12-28 23:22:26 +01:00
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Your IP address is banned from this server!");
} else if (this.players.size() >= this.maxPlayers) {
2010-12-28 23:22:26 +01:00
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!");
} else {
2011-05-26 14:48:22 +02:00
event.disallow(PlayerLoginEvent.Result.ALLOWED, s1);
2010-12-26 03:20:29 +01:00
}
cserver.getPluginManager().callEvent(event);
2010-12-28 23:22:26 +01:00
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
netloginhandler.disconnect(event.getKickMessage());
2010-12-26 03:20:29 +01:00
return null;
}
2010-12-28 20:52:24 +01:00
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
2011-01-29 22:50:29 +01:00
if (entityplayer.name.equalsIgnoreCase(s)) {
entityplayer.netServerHandler.disconnect("You logged in from another location");
2010-12-26 03:20:29 +01:00
}
}
2011-06-08 19:40:40 +02:00
return entity;
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-05-28 22:50:08 +02:00
// CraftBukkit start
2011-05-26 14:48:22 +02:00
public EntityPlayer a(EntityPlayer entityplayer, int i) {
2011-06-08 19:40:40 +02:00
return a(entityplayer, i, null);
2011-05-28 22:50:08 +02:00
}
2011-06-08 19:40:40 +02:00
public EntityPlayer a(EntityPlayer entityplayer, int i, Location location) {
2011-05-26 14:48:22 +02:00
this.server.b(entityplayer.dimension).trackPlayer(entityplayer);
this.a(entityplayer.dimension).removePlayer(entityplayer);
this.players.remove(entityplayer);
2011-05-26 14:48:22 +02:00
this.server.a(entityplayer.dimension).removeEntity(entityplayer);
2011-06-08 19:40:40 +02:00
if (location == null) {
ChunkCoordinates chunkcoordinates = entityplayer.M();
CraftWorld cw = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld);
if(cw != null && chunkcoordinates != null) {
ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(cw.getHandle(), chunkcoordinates);
2011-05-28 22:50:08 +02:00
if (chunkcoordinates1 != null) {
2011-06-08 19:40:40 +02:00
location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
2011-05-28 22:50:08 +02:00
} else {
2011-06-08 19:40:40 +02:00
entityplayer.netServerHandler.sendPacket(new Packet70Bed(0));
2011-05-28 22:50:08 +02:00
}
2011-03-31 22:40:00 +02:00
}
2011-06-08 19:40:40 +02:00
if (location == null) {
cw = (CraftWorld) this.server.server.getWorlds().get(0);
chunkcoordinates = cw.getHandle().getSpawn();
location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
}
2011-06-01 02:10:21 +02:00
Player respawnPlayer = cserver.getPlayer(entityplayer);
2011-06-08 19:40:40 +02:00
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location);
2011-06-01 02:10:21 +02:00
cserver.getPluginManager().callEvent(respawnEvent);
2011-06-08 19:40:40 +02:00
location = respawnEvent.getRespawnLocation();
entityplayer.health = 20;
} else {
location.setWorld(this.server.a(i).getWorld());
2011-05-28 22:50:08 +02:00
}
2011-06-08 19:40:40 +02:00
WorldServer worldserver = ((CraftWorld)location.getWorld()).getHandle();
worldserver.chunkProviderServer.getChunkAt((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
2011-01-29 22:50:29 +01:00
2011-06-08 19:40:40 +02:00
while (worldserver.getEntities(entityplayer, entityplayer.boundingBox).size() != 0) {
entityplayer.setPosition(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
2011-05-26 14:48:22 +02:00
}
2011-05-28 22:50:08 +02:00
byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId());
2011-06-08 19:40:40 +02:00
entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) (actualDimension >= 0 ? -1 : 0)));
entityplayer.netServerHandler.sendPacket(new Packet9Respawn(actualDimension));
entityplayer.a(worldserver);
entityplayer.dead = false;
entityplayer.netServerHandler.teleport(location);
this.a(entityplayer, worldserver);
this.a(entityplayer.dimension).addPlayer(entityplayer);
worldserver.addEntity(entityplayer);
this.players.add(entityplayer);
this.g(entityplayer);
entityplayer.w();
return entityplayer;
2011-06-01 02:10:21 +02:00
// CraftBukkit end
2010-12-26 03:20:29 +01:00
}
2011-05-28 22:50:08 +02:00
// CraftBukkit - changed signature
public EntityPlayer f(EntityPlayer entityplayer) {
2011-05-26 14:48:22 +02:00
WorldServer worldserver = this.server.a(entityplayer.dimension);
boolean flag = false;
byte b0;
if (entityplayer.dimension == -1) {
b0 = 0;
} else {
b0 = -1;
}
2011-05-28 22:50:08 +02:00
// CraftBukkit start
2011-06-07 23:20:03 +02:00
CraftWorld oldCraftWorld = worldserver.getWorld();
CraftWorld newCraftWorld = this.server.a(b0).getWorld();
Location startLocation = new Location(oldCraftWorld, entityplayer.locX, entityplayer.locY, entityplayer.locZ);
Location endLocation;
if (b0 == -1) {
endLocation = new Location(newCraftWorld, entityplayer.locX / 8.0D, entityplayer.locY, entityplayer.locZ / 8.0D,entityplayer.yaw,entityplayer.pitch);
} else {
endLocation = new Location(newCraftWorld, entityplayer.locX * 8.0D, entityplayer.locY, entityplayer.locZ * 8.0D,entityplayer.yaw,entityplayer.pitch);
}
PlayerPortalEvent event = new PlayerPortalEvent((Player)entityplayer.getBukkitEntity(),startLocation,endLocation);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return entityplayer;
}
2011-05-28 22:50:08 +02:00
// entityplayer.dimension = b0;
WorldServer worldserver1 = this.server.a(b0);
2011-05-26 14:48:22 +02:00
2011-05-28 22:50:08 +02:00
// entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) ((WorldServer)entityplayer.world).getWorld().getEnvironment().getId()));
// Craftbukkit end
2011-05-26 14:48:22 +02:00
double d0 = entityplayer.locX;
double d1 = entityplayer.locZ;
double d2 = 8.0D;
2011-05-28 22:50:08 +02:00
if (b0 == -1) { // CraftBukkit
2011-05-26 14:48:22 +02:00
d0 /= d2;
d1 /= d2;
entityplayer.setPositionRotation(d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch);
2011-05-28 22:50:08 +02:00
if (entityplayer.S()) {
2011-05-26 14:48:22 +02:00
worldserver.entityJoinedWorld(entityplayer, false);
}
} else {
d0 *= d2;
d1 *= d2;
entityplayer.setPositionRotation(d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch);
2011-05-28 22:50:08 +02:00
if (entityplayer.S()) {
2011-05-26 14:48:22 +02:00
worldserver.entityJoinedWorld(entityplayer, false);
}
}
2011-05-28 22:50:08 +02:00
if (entityplayer.S()) {
// worldserver1.addEntity(entityplayer); // CraftBukkit
2011-05-26 14:48:22 +02:00
entityplayer.setPositionRotation(d0, entityplayer.locY, d1, entityplayer.yaw, entityplayer.pitch);
worldserver1.entityJoinedWorld(entityplayer, false);
2011-06-07 23:20:03 +02:00
// CraftBukkit start - added conditional
if (event.useTravelAgent()) {
worldserver1.chunkProviderServer.a = true;
(new PortalTravelAgent()).a(worldserver1, entityplayer);
worldserver1.chunkProviderServer.a = false;
} // CraftBukkit end
2011-05-26 14:48:22 +02:00
}
2011-05-28 22:50:08 +02:00
/* CraftBukkit start
2011-05-26 14:48:22 +02:00
this.a(entityplayer);
entityplayer.netServerHandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
entityplayer.a((World) worldserver1);
this.a(entityplayer, worldserver1);
2011-05-28 22:50:08 +02:00
this.g(entityplayer);
*/ // CraftBukkit end
2011-06-08 19:40:40 +02:00
// CraftBukkit - defer for actual teleportation
return a(entityplayer, b0, new Location(null, entityplayer.locX, entityplayer.locY, entityplayer.locZ));
2011-05-26 14:48:22 +02:00
}
2010-12-26 03:20:29 +01:00
public void b() {
// Craftbukkit start
for (int i = 0; i < this.server.worlds.size(); ++i) {
this.server.worlds.get(i).manager.flush();
2011-02-06 23:53:48 +01:00
}
// Craftbukkit end
2010-12-26 03:20:29 +01:00
}
2011-05-26 14:48:22 +02:00
public void flagDirty(int i, int j, int k, int l) {
this.a(l).flagDirty(i, j, k);
2010-12-26 03:20:29 +01:00
}
public void sendAll(Packet packet) {
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
2010-12-28 20:52:24 +01:00
entityplayer.netServerHandler.sendPacket(packet);
2010-12-26 03:20:29 +01:00
}
}
2011-05-26 14:48:22 +02:00
public void a(Packet packet, int i) {
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
if (entityplayer.dimension == i) {
entityplayer.netServerHandler.sendPacket(packet);
}
}
}
2010-12-26 03:20:29 +01:00
public String c() {
2010-12-28 20:52:24 +01:00
String s = "";
for (int i = 0; i < this.players.size(); ++i) {
2011-01-29 22:50:29 +01:00
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.players.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) {
this.banByName.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) {
this.banByName.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 {
this.banByName.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.banByName.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));
Iterator iterator = this.banByName.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) {
this.banByIP.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) {
this.banByIP.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 {
this.banByIP.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.banByIP.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));
Iterator iterator = this.banByIP.iterator();
2011-01-29 22:50:29 +01:00
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-05-14 16:29:42 +02:00
// CraftBukkit - corrected text
a.warning("Failed to load ops: " + exception);
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-05-14 16:29:42 +02:00
// CraftBukkit - corrected text
a.warning("Failed to save ops: " + exception);
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);
}
}
public boolean isWhitelisted(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 isOp(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) {
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.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.netServerHandler.sendPacket(new Packet3Chat(s1));
2010-12-26 03:20:29 +01:00
}
}
2011-05-26 14:48:22 +02:00
public void a(double d0, double d1, double d2, double d3, int i, Packet packet) {
this.a((EntityHuman) null, d0, d1, d2, d3, i, packet);
}
2010-12-28 20:52:24 +01:00
2011-05-26 14:48:22 +02:00
public void a(EntityHuman entityhuman, double d0, double d1, double d2, double d3, int i, Packet packet) {
for (int j = 0; j < this.players.size(); ++j) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(j);
if (entityplayer != entityhuman && entityplayer.dimension == i) {
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
double d6 = d2 - entityplayer.locZ;
if (d4 * d4 + d5 * d5 + d6 * d6 < d3 * d3) {
entityplayer.netServerHandler.sendPacket(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);
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
2010-12-28 20:52:24 +01:00
if (this.isOp(entityplayer.name)) {
entityplayer.netServerHandler.sendPacket(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.netServerHandler.sendPacket(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 savePlayers() {
for (int i = 0; i < this.players.size(); ++i) {
this.playerFileData.a((EntityHuman) this.players.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-05-26 14:48:22 +02:00
public void a(EntityPlayer entityplayer, WorldServer worldserver) {
2011-05-28 22:50:08 +02:00
entityplayer.netServerHandler.sendPacket(new Packet4UpdateTime(worldserver.getTime()));
2011-05-26 14:48:22 +02:00
if (worldserver.v()) {
entityplayer.netServerHandler.sendPacket(new Packet70Bed(1));
}
}
2011-05-28 22:50:08 +02:00
public void g(EntityPlayer entityplayer) {
entityplayer.a(entityplayer.defaultContainer);
entityplayer.B();
}
2011-02-23 13:56:36 +01:00
}