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-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;
|
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;
|
2012-02-15 20:59:17 +01:00
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
2011-06-07 23:20:03 +02:00
|
|
|
import org.bukkit.Bukkit;
|
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-04-20 19:05:14 +02:00
|
|
|
public List players = new ArrayList();
|
2011-05-14 16:29:42 +02:00
|
|
|
public MinecraftServer server; // CraftBukkit - private -> public
|
2011-11-20 09:01:14 +01:00
|
|
|
// private PlayerManager[] d = new PlayerManager[3]; // CraftBukkit - removed
|
2011-05-14 16:29:42 +02:00
|
|
|
public int maxPlayers; // CraftBukkit - private -> public
|
2011-09-03 03:13:07 +02:00
|
|
|
public Set banByName = new HashSet(); // CraftBukkit - private -> public
|
2011-09-03 02:59:28 +02:00
|
|
|
public Set banByIP = new HashSet(); // CraftBukkit - private -> public
|
2011-09-25 04:28:00 +02:00
|
|
|
public Set operators = new HashSet(); // CraftBukkit - private -> public
|
2011-09-24 23:03:31 +02:00
|
|
|
private Set whitelist = 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
|
2012-01-12 12:02:39 +01:00
|
|
|
public boolean hasWhitelist; // CraftBukkit - private -> public
|
2011-09-15 02:23:52 +02:00
|
|
|
private int p = 0;
|
2010-12-26 03:20:29 +01:00
|
|
|
|
2011-02-04 16:04:28 +01:00
|
|
|
// CraftBukkit start
|
2011-04-20 19:05:14 +02:00
|
|
|
private CraftServer cserver;
|
2011-09-30 20:38:46 +02:00
|
|
|
|
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-09-25 00:14:13 +02:00
|
|
|
minecraftserver.console = ColouredConsoleSender.getInstance();
|
2011-06-27 00:25:01 +02:00
|
|
|
this.cserver = minecraftserver.server;
|
2011-02-04 16:04:28 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
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-08-15 20:27:02 +02:00
|
|
|
int i = minecraftserver.propertyManager.getInt("view-distance", 10);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit - removed playermanagers
|
2011-04-20 19:05:14 +02:00
|
|
|
this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20);
|
2011-09-24 23:03:31 +02:00
|
|
|
this.hasWhitelist = minecraftserver.propertyManager.getBoolean("white-list", false);
|
2011-02-23 03:37:56 +01:00
|
|
|
this.l();
|
|
|
|
this.n();
|
2011-09-15 02:23:52 +02:00
|
|
|
this.p();
|
2011-11-20 09:01:14 +01:00
|
|
|
this.r();
|
|
|
|
this.m();
|
|
|
|
this.o();
|
|
|
|
this.q();
|
|
|
|
this.s();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public void setPlayerFileData(WorldServer[] aworldserver) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.playerFileData != null) return; // CraftBukkit
|
2011-11-30 00:17:43 +01:00
|
|
|
this.playerFileData = aworldserver[0].getDataManager().getPlayerFileData();
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(EntityPlayer entityplayer) {
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit - removed playermanagers
|
|
|
|
for (WorldServer world : this.server.worlds) {
|
2011-06-27 00:25:01 +02:00
|
|
|
if (world.manager.managedPlayers.contains(entityplayer)) {
|
2011-05-28 22:50:08 +02:00
|
|
|
world.manager.removePlayer(entityplayer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getPlayerManager(entityplayer.dimension).addPlayer(entityplayer);
|
|
|
|
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
|
|
|
worldserver.chunkProviderServer.getChunkAt((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int a() {
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit start
|
2011-05-26 23:15:27 +02:00
|
|
|
if (this.server.worlds.size() == 0) {
|
2011-08-15 20:27:02 +02:00
|
|
|
return this.server.propertyManager.getInt("view-distance", 10) * 16 - 16;
|
2011-05-26 23:15:27 +02:00
|
|
|
}
|
2011-06-27 00:25:01 +02:00
|
|
|
return this.server.worlds.get(0).manager.getFurthestViewableBlock();
|
2011-06-12 00:02:58 +02:00
|
|
|
// CraftBukkit end
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
private PlayerManager getPlayerManager(int i) {
|
|
|
|
return this.server.getWorldServer(i).manager; // CraftBukkit
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void b(EntityPlayer entityplayer) {
|
2012-01-12 16:27:39 +01:00
|
|
|
this.playerFileData.load(entityplayer);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
2011-02-05 19:15:04 +01:00
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public void c(EntityPlayer entityplayer) {
|
2012-01-31 20:54:15 +01:00
|
|
|
cserver.detectListNameConflict(entityplayer); // CraftBukkit
|
|
|
|
//this.sendAll(new Packet201PlayerInfo(entityplayer.name, true, 1000)); // CraftBukkit - replaced with loop below
|
2011-05-26 14:48:22 +02:00
|
|
|
this.players.add(entityplayer);
|
2011-06-27 00:25:01 +02:00
|
|
|
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
|
2011-05-26 14:48:22 +02:00
|
|
|
|
|
|
|
worldserver.chunkProviderServer.getChunkAt((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
|
|
|
|
|
2012-01-29 12:36:43 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
if (!cserver.useExactLoginLocation()) {
|
2012-02-29 22:31:04 +01:00
|
|
|
while (worldserver.getCubes(entityplayer, entityplayer.boundingBox).size() != 0) {
|
2012-01-29 12:36:43 +01:00
|
|
|
entityplayer.setPosition(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
entityplayer.setPosition(entityplayer.locX, entityplayer.locY + entityplayer.getBukkitEntity().getEyeHeight(), entityplayer.locZ);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " joined the game.");
|
|
|
|
this.cserver.getPluginManager().callEvent(playerJoinEvent);
|
2011-03-26 12:31:48 +01:00
|
|
|
|
|
|
|
String joinMessage = playerJoinEvent.getJoinMessage();
|
|
|
|
|
2011-11-28 07:21:35 +01:00
|
|
|
if ((joinMessage != null) && (joinMessage.length() > 0)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.server.serverConfigurationManager.sendAll(new Packet3Chat(joinMessage));
|
2011-03-26 12:31:48 +01:00
|
|
|
}
|
2012-02-16 23:31:40 +01:00
|
|
|
this.cserver.onPlayerJoin(playerJoinEvent.getPlayer());
|
2011-02-23 13:56:36 +01:00
|
|
|
// CraftBukkit end
|
2011-05-26 14:48:22 +02:00
|
|
|
|
|
|
|
worldserver.addEntity(entityplayer);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getPlayerManager(entityplayer.dimension).addPlayer(entityplayer);
|
2012-03-30 23:33:51 +02:00
|
|
|
this.u();
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-01-31 20:54:15 +01:00
|
|
|
// CraftBukkit start - sendAll above replaced with this loop
|
|
|
|
Packet201PlayerInfo packet = new Packet201PlayerInfo(entityplayer.listName, true, 1000);
|
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
|
|
|
|
|
|
|
|
if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
|
|
|
|
entityplayer1.netServerHandler.sendPacket(packet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
|
|
|
|
|
2011-09-27 00:10:35 +02:00
|
|
|
// CraftBukkit start - .name -> .listName
|
2012-01-31 20:54:15 +01:00
|
|
|
if (entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) {
|
|
|
|
entityplayer.netServerHandler.sendPacket(new Packet201PlayerInfo(entityplayer1.listName, true, entityplayer1.ping));
|
|
|
|
}
|
2011-09-27 00:10:35 +02:00
|
|
|
// CraftBukkit end
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-05-26 14:48:22 +02:00
|
|
|
public void d(EntityPlayer entityplayer) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getPlayerManager(entityplayer.dimension).movePlayer(entityplayer);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - changed return type
|
2011-12-01 23:35:19 +01:00
|
|
|
if (entityplayer.netServerHandler.disconnected) return null; // CraftBukkit - exploitsies fix
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit start
|
2011-04-03 19:02:35 +02:00
|
|
|
// Quitting must be before we do final save of data, in case plugins need to modify it
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getPlayerManager(entityplayer.dimension).removePlayer(entityplayer);
|
|
|
|
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " left the game.");
|
|
|
|
this.cserver.getPluginManager().callEvent(playerQuitEvent);
|
2011-01-30 13:51:20 +01:00
|
|
|
// CraftBukkit end
|
2011-04-03 19:02:35 +02:00
|
|
|
|
2012-01-12 16:27:39 +01:00
|
|
|
this.playerFileData.save(entityplayer);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.server.getWorldServer(entityplayer.dimension).kill(entityplayer);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.players.remove(entityplayer);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getPlayerManager(entityplayer.dimension).removePlayer(entityplayer);
|
2012-01-31 20:54:15 +01:00
|
|
|
// CraftBukkit start - .name -> .listName, replace sendAll with loop
|
|
|
|
Packet201PlayerInfo packet = new Packet201PlayerInfo(entityplayer.listName, false, 9999);
|
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
|
|
|
|
|
|
|
|
if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
|
|
|
|
entityplayer1.netServerHandler.sendPacket(packet);
|
|
|
|
}
|
|
|
|
}
|
2011-09-27 00:10:35 +02:00
|
|
|
// CraftBukkit end
|
2011-04-03 19:02:35 +02:00
|
|
|
|
|
|
|
return playerQuitEvent.getQuitMessage(); // CraftBukkit
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2011-01-30 13:51:20 +01:00
|
|
|
|
2012-03-03 19:38:36 +01:00
|
|
|
public EntityPlayer attemptLogin(NetLoginHandler netloginhandler, String s, String hostname) { // CraftBukkit - add hostname parameter
|
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
|
2011-06-27 00:25:01 +02:00
|
|
|
EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), s, new ItemInWorldManager(this.server.getWorldServer(0)));
|
2012-04-04 00:04:28 +02:00
|
|
|
Player player = entity.getBukkitEntity();
|
|
|
|
PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, netloginhandler.getSocket().getInetAddress());
|
2011-01-11 09:25:13 +01:00
|
|
|
|
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
|
|
|
|
2011-04-20 19:05:14 +02: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-04-20 19:05:14 +02:00
|
|
|
} else if (!this.isWhitelisted(s)) {
|
2011-03-20 07:08:00 +01:00
|
|
|
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!");
|
2011-04-20 19:05:14 +02:00
|
|
|
} 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!");
|
2011-03-18 08:03:03 +01:00
|
|
|
} else {
|
2011-05-26 14:48:22 +02:00
|
|
|
event.disallow(PlayerLoginEvent.Result.ALLOWED, s1);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
2011-01-01 14:06:04 +01:00
|
|
|
|
2012-04-18 19:28:50 +02:00
|
|
|
this.b(entity);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.cserver.getPluginManager().callEvent(event);
|
2010-12-28 23:22:26 +01:00
|
|
|
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
|
2011-04-20 19:05:14 +02:00
|
|
|
netloginhandler.disconnect(event.getKickMessage());
|
2010-12-26 03:20:29 +01:00
|
|
|
return null;
|
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-04-20 19:05:14 +02: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)) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entityplayer.netServerHandler.disconnect("You logged in from another location");
|
2012-04-18 19:28:50 +02:00
|
|
|
this.b(entity);
|
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-11-20 09:01:14 +01:00
|
|
|
public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag) {
|
2011-11-24 19:48:01 +01:00
|
|
|
return this.moveToWorld(entityplayer, i, flag, null);
|
2011-05-28 22:50:08 +02:00
|
|
|
}
|
|
|
|
|
2011-11-24 19:48:01 +01:00
|
|
|
public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location) {
|
2012-01-12 19:43:34 +01:00
|
|
|
// CraftBukkit end
|
2011-06-27 00:25:01 +02:00
|
|
|
this.server.getTracker(entityplayer.dimension).untrackPlayer(entityplayer);
|
|
|
|
// this.server.getTracker(entityplayer.dimension).untrackEntity(entityplayer); // CraftBukkit
|
|
|
|
this.getPlayerManager(entityplayer.dimension).removePlayer(entityplayer);
|
2011-04-20 19:05:14 +02:00
|
|
|
this.players.remove(entityplayer);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer);
|
|
|
|
ChunkCoordinates chunkcoordinates = entityplayer.getBed();
|
2011-06-09 20:24:21 +02:00
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
EntityPlayer entityplayer1 = entityplayer;
|
2011-09-30 20:38:46 +02:00
|
|
|
org.bukkit.World fromWorld = entityplayer1.getBukkitEntity().getWorld();
|
2011-06-10 09:50:04 +02:00
|
|
|
|
2011-11-24 19:48:01 +01:00
|
|
|
if (flag) {
|
|
|
|
entityplayer1.copyTo(entityplayer);
|
|
|
|
}
|
|
|
|
|
2011-06-08 19:40:40 +02:00
|
|
|
if (location == null) {
|
2011-06-21 05:33:29 +02:00
|
|
|
boolean isBedSpawn = false;
|
2011-06-27 00:25:01 +02:00
|
|
|
CraftWorld cworld = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld);
|
|
|
|
if (cworld != null && chunkcoordinates != null) {
|
|
|
|
ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(cworld.getHandle(), chunkcoordinates);
|
2011-05-28 22:50:08 +02:00
|
|
|
if (chunkcoordinates1 != null) {
|
2011-06-21 05:33:29 +02:00
|
|
|
isBedSpawn = true;
|
2011-06-27 00:25:01 +02:00
|
|
|
location = new Location(cworld, chunkcoordinates1.x + 0.5, chunkcoordinates1.y, chunkcoordinates1.z + 0.5);
|
2011-05-28 22:50:08 +02:00
|
|
|
} else {
|
2011-09-15 02:23:52 +02:00
|
|
|
entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0, 0));
|
2011-05-28 22:50:08 +02:00
|
|
|
}
|
2011-03-31 22:40:00 +02:00
|
|
|
}
|
2011-06-12 00:02:58 +02:00
|
|
|
|
2011-06-08 19:40:40 +02:00
|
|
|
if (location == null) {
|
2011-06-27 00:25:01 +02:00
|
|
|
cworld = (CraftWorld) this.server.server.getWorlds().get(0);
|
|
|
|
chunkcoordinates = cworld.getHandle().getSpawn();
|
|
|
|
location = new Location(cworld, chunkcoordinates.x + 0.5, chunkcoordinates.y, chunkcoordinates.z + 0.5);
|
2011-06-08 19:40:40 +02:00
|
|
|
}
|
2011-06-12 00:02:58 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
Player respawnPlayer = this.cserver.getPlayer(entityplayer);
|
2011-06-21 05:33:29 +02:00
|
|
|
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.cserver.getPluginManager().callEvent(respawnEvent);
|
2011-06-12 00:02:58 +02:00
|
|
|
|
2011-06-08 19:40:40 +02:00
|
|
|
location = respawnEvent.getRespawnLocation();
|
2011-12-04 13:10:02 +01:00
|
|
|
entityplayer.reset();
|
2011-06-08 19:40:40 +02:00
|
|
|
} else {
|
2011-06-27 00:25:01 +02:00
|
|
|
location.setWorld(this.server.getWorldServer(i).getWorld());
|
2011-05-28 22:50:08 +02:00
|
|
|
}
|
2011-06-12 00:02:58 +02:00
|
|
|
WorldServer worldserver = ((CraftWorld) location.getWorld()).getHandle();
|
2011-06-09 20:24:21 +02:00
|
|
|
entityplayer1.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
|
|
|
// CraftBukkit end
|
2011-06-10 09:50:04 +02:00
|
|
|
|
2011-06-09 20:24:21 +02:00
|
|
|
worldserver.chunkProviderServer.getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
while (worldserver.getCubes(entityplayer1, entityplayer1.boundingBox).size() != 0) {
|
2011-06-09 20:24:21 +02:00
|
|
|
entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
2011-06-10 09:50:04 +02:00
|
|
|
|
2011-06-09 20:24:21 +02:00
|
|
|
// CraftBukkit start
|
2011-05-28 22:50:08 +02:00
|
|
|
byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId());
|
2012-03-06 04:44:29 +01:00
|
|
|
// Force the client to refresh their chunk cache.
|
|
|
|
entityplayer1.netServerHandler.sendPacket(new Packet9Respawn((byte) (actualDimension >= 0 ? -1 : 0), (byte) worldserver.difficulty, worldserver.getWorldData().getType(), worldserver.getHeight(), entityplayer.itemInWorldManager.getGameMode()));
|
2012-03-01 11:49:23 +01:00
|
|
|
entityplayer1.netServerHandler.sendPacket(new Packet9Respawn(actualDimension, (byte) worldserver.difficulty, worldserver.getWorldData().getType(), worldserver.getHeight(), entityplayer.itemInWorldManager.getGameMode()));
|
2011-06-27 00:25:01 +02:00
|
|
|
entityplayer1.spawnIn(worldserver);
|
2011-06-09 20:24:21 +02:00
|
|
|
entityplayer1.dead = false;
|
2011-06-11 04:59:54 +02:00
|
|
|
entityplayer1.netServerHandler.teleport(new Location(worldserver.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch));
|
2011-06-01 02:10:21 +02:00
|
|
|
// CraftBukkit end
|
2011-06-09 20:24:21 +02:00
|
|
|
this.a(entityplayer1, worldserver);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getPlayerManager(entityplayer1.dimension).addPlayer(entityplayer1);
|
2011-06-09 20:24:21 +02:00
|
|
|
worldserver.addEntity(entityplayer1);
|
|
|
|
this.players.add(entityplayer1);
|
2011-06-27 00:25:01 +02:00
|
|
|
this.updateClient(entityplayer1); // CraftBukkit
|
2012-03-01 11:49:23 +01:00
|
|
|
entityplayer1.E();
|
2011-10-02 20:30:05 +02:00
|
|
|
// CraftBukkit start - don't fire on respawn
|
|
|
|
if (fromWorld != location.getWorld()) {
|
|
|
|
org.bukkit.event.player.PlayerChangedWorldEvent event = new org.bukkit.event.player.PlayerChangedWorldEvent((Player) entityplayer1.getBukkitEntity(), fromWorld);
|
|
|
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2012-03-07 01:59:15 +01:00
|
|
|
|
2011-06-09 20:24:21 +02:00
|
|
|
return entityplayer1;
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void changeDimension(EntityPlayer entityplayer, int i) {
|
2011-06-20 07:34:17 +02:00
|
|
|
// CraftBukkit start -- Replaced the standard handling of portals with a more customised method.
|
2011-11-24 21:00:55 +01:00
|
|
|
int dimension = i;
|
2011-11-25 21:05:51 +01:00
|
|
|
WorldServer fromWorld = this.server.getWorldServer(entityplayer.dimension);
|
2011-07-26 22:14:52 +02:00
|
|
|
WorldServer toWorld = null;
|
2011-11-25 22:10:16 +01:00
|
|
|
if (entityplayer.dimension < 10) {
|
2011-07-26 22:14:52 +02:00
|
|
|
for (WorldServer world : this.server.worlds) {
|
2011-11-25 21:05:51 +01:00
|
|
|
if (world.dimension == dimension) {
|
2011-07-26 22:14:52 +02:00
|
|
|
toWorld = world;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-05-26 14:48:22 +02:00
|
|
|
|
2011-06-20 07:34:17 +02:00
|
|
|
Location fromLocation = new Location(fromWorld.getWorld(), entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
|
2011-11-24 21:00:55 +01:00
|
|
|
Location toLocation = null;
|
|
|
|
|
|
|
|
if (toWorld != null) {
|
2011-11-25 21:54:29 +01:00
|
|
|
if (((dimension == -1) || (dimension == 0)) && ((entityplayer.dimension == -1) || (entityplayer.dimension == 0))) {
|
2011-11-24 21:00:55 +01:00
|
|
|
double blockRatio = dimension == 0 ? 8 : 0.125;
|
|
|
|
|
|
|
|
toLocation = toWorld == null ? null : new Location(toWorld.getWorld(), (entityplayer.locX * blockRatio), entityplayer.locY, (entityplayer.locZ * blockRatio), entityplayer.yaw, entityplayer.pitch);
|
|
|
|
} else {
|
2012-01-14 21:03:48 +01:00
|
|
|
ChunkCoordinates coords = toWorld.getDimensionSpawn();
|
2011-12-09 18:09:21 +01:00
|
|
|
if (coords != null) {
|
|
|
|
toLocation = new Location(toWorld.getWorld(), coords.x, coords.y, coords.z, 90, 0);
|
|
|
|
}
|
2011-11-24 21:00:55 +01:00
|
|
|
}
|
|
|
|
}
|
2011-06-11 04:59:54 +02:00
|
|
|
|
2012-02-15 20:59:17 +01:00
|
|
|
TeleportCause cause = TeleportCause.UNKNOWN;
|
|
|
|
int playerEnvironmentId = entityplayer.getBukkitEntity().getWorld().getEnvironment().getId();
|
|
|
|
switch (dimension) {
|
|
|
|
case -1:
|
|
|
|
cause = TeleportCause.NETHER_PORTAL;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
if (playerEnvironmentId == -1) {
|
|
|
|
cause = TeleportCause.NETHER_PORTAL;
|
|
|
|
} else if (playerEnvironmentId == 1) {
|
|
|
|
cause = TeleportCause.END_PORTAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
cause = TeleportCause.END_PORTAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-06-20 07:34:17 +02:00
|
|
|
org.bukkit.craftbukkit.PortalTravelAgent pta = new org.bukkit.craftbukkit.PortalTravelAgent();
|
2012-02-15 20:59:17 +01:00
|
|
|
PlayerPortalEvent event = new PlayerPortalEvent((Player) entityplayer.getBukkitEntity(), fromLocation, toLocation, pta, cause);
|
2011-11-24 21:00:55 +01:00
|
|
|
|
|
|
|
if (entityplayer.dimension == 1) {
|
|
|
|
event.useTravelAgent(false);
|
|
|
|
}
|
|
|
|
|
2011-06-11 04:59:54 +02:00
|
|
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
2011-07-26 22:14:52 +02:00
|
|
|
if (event.isCancelled() || event.getTo() == null) {
|
2011-06-11 04:59:54 +02:00
|
|
|
return;
|
|
|
|
}
|
2011-06-27 00:25:01 +02:00
|
|
|
|
2011-06-20 07:34:17 +02:00
|
|
|
Location finalLocation = event.getTo();
|
2011-06-27 00:25:01 +02:00
|
|
|
if (event.useTravelAgent()) {
|
2011-08-27 06:46:37 +02:00
|
|
|
finalLocation = event.getPortalTravelAgent().findOrCreate(finalLocation);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
2011-06-20 07:34:17 +02:00
|
|
|
toWorld = ((CraftWorld) finalLocation.getWorld()).getHandle();
|
2011-11-24 19:48:01 +01:00
|
|
|
this.moveToWorld(entityplayer, toWorld.dimension, true, finalLocation);
|
2011-06-11 04:59:54 +02:00
|
|
|
// CraftBukkit end
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public void tick() {
|
2011-11-20 09:01:14 +01:00
|
|
|
if (++this.p > 200) {
|
|
|
|
this.p = 0;
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-09-18 13:11:17 +02:00
|
|
|
/* CraftBukkit start -- remove updating of lag to players -- it spams way to much on big servers.
|
2011-11-20 09:01:14 +01:00
|
|
|
if (this.p < this.players.size()) {
|
|
|
|
EntityPlayer entityplayer = (EntityPlayer) this.players.get(this.p);
|
2011-09-17 02:57:43 +02:00
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
this.sendAll(new Packet201PlayerInfo(entityplayer.name, true, entityplayer.ping));
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
2011-09-30 20:38:46 +02:00
|
|
|
*/
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
for (int i = 0; i < this.server.worlds.size(); ++i) {
|
2011-09-18 13:11:17 +02:00
|
|
|
this.server.worlds.get(i).manager.flush();
|
|
|
|
// CraftBukkit end
|
2011-02-06 23:53:48 +01:00
|
|
|
}
|
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) {
|
2011-06-27 00:25:01 +02:00
|
|
|
this.getPlayerManager(l).flagDirty(i, j, k);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02: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
|
|
|
|
2011-04-20 19:05:14 +02: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 = "";
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
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
|
|
|
|
2011-04-20 19:05:14 +02: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
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public String[] d() {
|
|
|
|
String[] astring = new String[this.players.size()];
|
|
|
|
|
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
|
|
|
astring[i] = ((EntityPlayer) this.players.get(i)).name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return astring;
|
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void addUserBan(String s) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.banByName.add(s.toLowerCase());
|
2011-11-20 09:01:14 +01:00
|
|
|
this.m();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void removeUserBan(String s) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.banByName.remove(s.toLowerCase());
|
2011-11-20 09:01:14 +01:00
|
|
|
this.m();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
private void l() {
|
2010-12-26 03:20:29 +01:00
|
|
|
try {
|
2011-04-20 19:05:14 +02:00
|
|
|
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) {
|
2011-04-20 19:05:14 +02:00
|
|
|
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-11-20 09:01:14 +01:00
|
|
|
private void m() {
|
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-04-20 19:05:14 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public Set getBannedPlayers() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return this.banByName;
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public Set getBannedAddresses() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return this.banByIP;
|
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void addIpBan(String s) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.banByIP.add(s.toLowerCase());
|
2011-11-20 09:01:14 +01:00
|
|
|
this.o();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void removeIpBan(String s) {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.banByIP.remove(s.toLowerCase());
|
2011-11-20 09:01:14 +01:00
|
|
|
this.o();
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
private void n() {
|
2010-12-26 03:20:29 +01:00
|
|
|
try {
|
2011-04-20 19:05:14 +02:00
|
|
|
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) {
|
2011-04-20 19:05:14 +02:00
|
|
|
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-11-20 09:01:14 +01:00
|
|
|
private void o() {
|
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-04-20 19:05:14 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void addOp(String s) {
|
|
|
|
this.operators.add(s.toLowerCase());
|
2011-11-20 09:01:14 +01:00
|
|
|
this.q();
|
2011-07-17 18:19:41 +02:00
|
|
|
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit start
|
2011-07-17 18:19:41 +02:00
|
|
|
Player player = server.server.getPlayer(s);
|
|
|
|
if (player != null) {
|
|
|
|
player.recalculatePermissions();
|
|
|
|
}
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit end
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void removeOp(String s) {
|
|
|
|
this.operators.remove(s.toLowerCase());
|
2011-11-20 09:01:14 +01:00
|
|
|
this.q();
|
2011-07-17 18:19:41 +02:00
|
|
|
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit start
|
2011-07-17 18:19:41 +02:00
|
|
|
Player player = server.server.getPlayer(s);
|
|
|
|
if (player != null) {
|
|
|
|
player.recalculatePermissions();
|
|
|
|
}
|
2012-01-12 12:02:39 +01:00
|
|
|
// CraftBukkit end
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
private void p() {
|
2010-12-26 03:20:29 +01:00
|
|
|
try {
|
2011-09-24 23:03:31 +02:00
|
|
|
this.operators.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) {
|
2011-09-24 23:03:31 +02:00
|
|
|
this.operators.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-11-20 09:01:14 +01:00
|
|
|
a.warning("Failed to load operators list: " + exception);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
private void q() {
|
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-09-24 23:03:31 +02:00
|
|
|
Iterator iterator = this.operators.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-11-20 09:01:14 +01:00
|
|
|
a.warning("Failed to save operators list: " + exception);
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
private void r() {
|
2011-02-23 03:37:56 +01:00
|
|
|
try {
|
2011-09-24 23:03:31 +02:00
|
|
|
this.whitelist.clear();
|
2011-02-23 03:37:56 +01:00
|
|
|
BufferedReader bufferedreader = new BufferedReader(new FileReader(this.m));
|
|
|
|
String s = "";
|
|
|
|
|
|
|
|
while ((s = bufferedreader.readLine()) != null) {
|
2011-09-24 23:03:31 +02:00
|
|
|
this.whitelist.add(s.trim().toLowerCase());
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bufferedreader.close();
|
|
|
|
} catch (Exception exception) {
|
|
|
|
a.warning("Failed to load white-list: " + exception);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
private void s() {
|
2011-02-23 03:37:56 +01:00
|
|
|
try {
|
|
|
|
PrintWriter printwriter = new PrintWriter(new FileWriter(this.m, false));
|
2011-09-24 23:03:31 +02:00
|
|
|
Iterator iterator = this.whitelist.iterator();
|
2011-02-23 03:37:56 +01:00
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
String s = (String) iterator.next();
|
|
|
|
|
|
|
|
printwriter.println(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
printwriter.close();
|
|
|
|
} catch (Exception exception) {
|
|
|
|
a.warning("Failed to save white-list: " + exception);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isWhitelisted(String s) {
|
2011-02-23 03:37:56 +01:00
|
|
|
s = s.trim().toLowerCase();
|
2011-09-24 23:03:31 +02:00
|
|
|
return !this.hasWhitelist || this.operators.contains(s) || this.whitelist.contains(s);
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public boolean isOp(String s) {
|
2011-09-24 23:03:31 +02:00
|
|
|
return this.operators.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-04-20 19:05:14 +02:00
|
|
|
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) {
|
2011-04-20 19:05:14 +02:00
|
|
|
entityplayer.netServerHandler.sendPacket(new Packet3Chat(s1));
|
2010-12-26 03:20:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public void sendPacketNearby(double d0, double d1, double d2, double d3, int i, Packet packet) {
|
|
|
|
this.sendPacketNearby((EntityHuman) null, d0, d1, d2, d3, i, packet);
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
2010-12-28 20:52:24 +01:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public void sendPacketNearby(EntityHuman entityhuman, double d0, double d1, double d2, double d3, int i, Packet packet) {
|
2011-05-26 14:48:22 +02:00
|
|
|
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);
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
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-04-20 19:05:14 +02: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) {
|
2011-04-20 19:05:14 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void savePlayers() {
|
|
|
|
for (int i = 0; i < this.players.size(); ++i) {
|
2012-01-12 16:27:39 +01:00
|
|
|
this.playerFileData.save((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
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void addWhitelist(String s) {
|
|
|
|
this.whitelist.add(s);
|
2011-11-20 09:01:14 +01:00
|
|
|
this.s();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void removeWhitelist(String s) {
|
|
|
|
this.whitelist.remove(s);
|
2011-11-20 09:01:14 +01:00
|
|
|
this.s();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public Set getWhitelisted() {
|
|
|
|
return this.whitelist;
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:03:31 +02:00
|
|
|
public void reloadWhitelist() {
|
2011-11-20 09:01:14 +01:00
|
|
|
this.r();
|
2011-02-23 03:37:56 +01:00
|
|
|
}
|
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()));
|
2012-03-01 11:49:23 +01:00
|
|
|
if (worldserver.x()) {
|
2011-09-15 02:23:52 +02:00
|
|
|
entityplayer.netServerHandler.sendPacket(new Packet70Bed(1, 0));
|
2011-05-26 14:48:22 +02:00
|
|
|
}
|
|
|
|
}
|
2011-05-28 22:50:08 +02:00
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public void updateClient(EntityPlayer entityplayer) {
|
|
|
|
entityplayer.updateInventory(entityplayer.defaultContainer);
|
2012-03-22 21:39:39 +01:00
|
|
|
entityplayer.D_();
|
2012-01-12 16:27:39 +01:00
|
|
|
entityplayer.lastSentExp = -1; // CraftBukkit
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public int getPlayerCount() {
|
2011-09-15 02:23:52 +02:00
|
|
|
return this.players.size();
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
public int getMaxPlayers() {
|
2011-09-15 02:23:52 +02:00
|
|
|
return this.maxPlayers;
|
2011-05-28 22:50:08 +02:00
|
|
|
}
|
2012-03-30 23:33:51 +02:00
|
|
|
|
|
|
|
public String[] getSeenPlayers() {
|
|
|
|
return this.server.worlds.get(0).getDataManager().getPlayerFileData().getSeenPlayers(); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
private void u() {
|
|
|
|
MojangStatisticsGenerator mojangstatisticsgenerator = new MojangStatisticsGenerator("server");
|
|
|
|
|
|
|
|
mojangstatisticsgenerator.a("version", this.server.getVersion());
|
|
|
|
mojangstatisticsgenerator.a("os_name", System.getProperty("os.name"));
|
|
|
|
mojangstatisticsgenerator.a("os_version", System.getProperty("os.version"));
|
|
|
|
mojangstatisticsgenerator.a("os_architecture", System.getProperty("os.arch"));
|
|
|
|
mojangstatisticsgenerator.a("memory_total", Long.valueOf(Runtime.getRuntime().totalMemory()));
|
|
|
|
mojangstatisticsgenerator.a("memory_max", Long.valueOf(Runtime.getRuntime().maxMemory()));
|
|
|
|
mojangstatisticsgenerator.a("memory_free", Long.valueOf(Runtime.getRuntime().freeMemory()));
|
|
|
|
mojangstatisticsgenerator.a("java_version", System.getProperty("java.version"));
|
|
|
|
mojangstatisticsgenerator.a("cpu_cores", Integer.valueOf(Runtime.getRuntime().availableProcessors()));
|
|
|
|
mojangstatisticsgenerator.a("players_current", Integer.valueOf(this.getPlayerCount()));
|
|
|
|
mojangstatisticsgenerator.a("players_max", Integer.valueOf(this.getMaxPlayers()));
|
|
|
|
mojangstatisticsgenerator.a("players_seen", Integer.valueOf(this.getSeenPlayers().length));
|
|
|
|
mojangstatisticsgenerator.a("uses_auth", Boolean.valueOf(this.server.onlineMode));
|
|
|
|
mojangstatisticsgenerator.a("server_brand", this.server.getServerModName());
|
|
|
|
mojangstatisticsgenerator.a();
|
|
|
|
}
|
2011-02-23 13:56:36 +01:00
|
|
|
}
|