diff options
author | Forsaken <darkmaster87@gmx.de> | 2011-02-04 16:04:28 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-02-06 12:38:38 +0100 |
commit | 002b5ebefc2802104fa9ffafbb0095ecb62873e6 (patch) | |
tree | 2a8fcafdf15ac2261a67c5e9b2494f7d4a65952d /src/main/java/net/minecraft | |
parent | 228b5e7ccdeef71e16958e014fb99c640f84a7a9 (diff) | |
download | craftbukkit-002b5ebefc2802104fa9ffafbb0095ecb62873e6.tar craftbukkit-002b5ebefc2802104fa9ffafbb0095ecb62873e6.tar.gz craftbukkit-002b5ebefc2802104fa9ffafbb0095ecb62873e6.tar.lz craftbukkit-002b5ebefc2802104fa9ffafbb0095ecb62873e6.tar.xz craftbukkit-002b5ebefc2802104fa9ffafbb0095ecb62873e6.zip |
Added PlayerKick (setReason, setLeaveMessage, setCancelled) and PlayerRespawn (setLocation)
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r-- | src/main/java/net/minecraft/server/NetServerHandler.java | 19 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/ServerConfigurationManager.java | 35 |
2 files changed, 39 insertions, 15 deletions
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index f0815a03..af94bad0 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -22,6 +22,7 @@ import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerItemHeldEvent; +import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.plugin.Plugin; // CraftBukkit end @@ -66,7 +67,6 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } // CraftBukkit end - public void a() { this.b.a(); if (this.f++ % 20 == 0) { @@ -75,10 +75,21 @@ public class NetServerHandler extends NetHandler implements ICommandListener { } public void a(String s) { - this.b.a((Packet) (new Packet255KickDisconnect(s))); - this.b.c(); - this.d.f.a((Packet) (new Packet3Chat("§e" + this.e.name + " left the game."))); + // CraftBukkit start + String leaveMessage = "§e" + this.e.name + " left the game."; + PlayerKickEvent kickEvent = new PlayerKickEvent(org.bukkit.event.Event.Type.PLAYER_KICK, server.getPlayer(this.e), s, leaveMessage); + server.getPluginManager().callEvent(kickEvent); + if (kickEvent.isCancelled()) { + // Do not kick the player + return; + } + // Send the possibly modified leave message + this.d.f.a((Packet) (new Packet3Chat( kickEvent.getLeaveMessage() ))); this.d.f.c(this.e); + this.b.a((Packet) (new Packet255KickDisconnect( kickEvent.getReason() ))); + // CraftBukkit end + + this.b.c(); this.c = true; } diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index 7fce5e72..a8ef81a2 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -13,12 +13,14 @@ import java.util.Set; import java.util.logging.Logger; // CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.Location; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Player; +import org.bukkit.event.Event; import org.bukkit.event.Event.Type; import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerRespawnEvent; // CraftBukkit end public class ServerConfigurationManager { @@ -36,12 +38,18 @@ public class ServerConfigurationManager { private File k; private PlayerNBTManager l; - private CraftServer server; // CraftBukkit + // CraftBukkit start + private CraftServer server; + + public int getMaxPlayers() { + return this.e; + } public ServerConfigurationManager(MinecraftServer minecraftserver) { - // CraftBukkit 2 lines! minecraftserver.server = new CraftServer(minecraftserver, this); server = minecraftserver.server; + // CraftBukkit end + this.c = minecraftserver; this.i = minecraftserver.a("banned-players.txt"); this.j = minecraftserver.a("banned-ips.txt"); @@ -56,12 +64,6 @@ public class ServerConfigurationManager { this.j(); } - // CraftBukkit start - public int getMaxPlayers() { - return this.e; - } - // CraftBukkit end - public void a(WorldServer worldserver) { this.l = new PlayerNBTManager(new File(worldserver.t, "players")); } @@ -101,13 +103,12 @@ public class ServerConfigurationManager { // CraftBukkit end } - public EntityPlayer a(NetLoginHandler netloginhandler, String s, String s1) { // CraftBukkit start - note: this entire method needs to be changed // 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. - EntityPlayer entity = new EntityPlayer(c, ((World) (c.e)), s, new ItemInWorldManager(((World) (c.e)))); + EntityPlayer entity = new EntityPlayer(c, (World) c.e, s, new ItemInWorldManager((World) c.e)); Player player = (entity == null) ? null : (Player) entity.getBukkitEntity(); PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, player); @@ -158,6 +159,18 @@ public class ServerConfigurationManager { entityplayer1.a(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ); } + // CraftBukkit start + Player respawnPlayer = server.getPlayer(entityplayer); + Location respawnLocation = new Location(respawnPlayer.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); + PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(Event.Type.PLAYER_RESPAWN, respawnPlayer, respawnLocation ); + server.getPluginManager().callEvent(respawnEvent); + 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(); + // CraftBukkit end + entityplayer1.a.b((Packet) (new Packet9Respawn())); entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch); this.d.a(entityplayer1); |