From abf7f8581ee366c5951f230f4c44849ecfe7b472 Mon Sep 17 00:00:00 2001 From: Raphfrk Date: Sat, 26 Mar 2011 11:31:48 +0000 Subject: Added ability to disable the join/leave notices by setting the message to null in the event. The join message is moved to the onJoinEvent rather than during login --- src/main/java/net/minecraft/server/NetLoginHandler.java | 2 +- src/main/java/net/minecraft/server/NetServerHandler.java | 5 ++++- .../java/net/minecraft/server/ServerConfigurationManager.java | 11 ++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src/main/java/net/minecraft') diff --git a/src/main/java/net/minecraft/server/NetLoginHandler.java b/src/main/java/net/minecraft/server/NetLoginHandler.java index bdd85f19..a2dcf2eb 100644 --- a/src/main/java/net/minecraft/server/NetLoginHandler.java +++ b/src/main/java/net/minecraft/server/NetLoginHandler.java @@ -83,7 +83,7 @@ public class NetLoginHandler extends NetHandler { ChunkCoordinates chunkcoordinates = entityplayer.world.l(); netserverhandler.b((Packet) (new Packet1Login("", "", entityplayer.id, entityplayer.world.j(), (byte) entityplayer.world.m.g))); netserverhandler.b((Packet) (new Packet6SpawnPosition(chunkcoordinates.a, chunkcoordinates.b, chunkcoordinates.c))); - this.e.f.a((Packet) (new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game."))); + // this.e.f.a((Packet) (new Packet3Chat("\u00A7e" + entityplayer.name + " joined the game."))); // CraftBukkit - message moved to join event this.e.f.a(entityplayer); netserverhandler.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); this.e.c.a(netserverhandler); diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java index 1ea515cc..ba060ff8 100644 --- a/src/main/java/net/minecraft/server/NetServerHandler.java +++ b/src/main/java/net/minecraft/server/NetServerHandler.java @@ -90,7 +90,10 @@ public class NetServerHandler extends NetHandler implements ICommandListener { // Send the possibly modified leave message this.b.a((Packet) (new Packet255KickDisconnect( event.getReason() ))); this.b.c(); - this.d.f.a((Packet) (new Packet3Chat( event.getLeaveMessage() ))); + leaveMessage = event.getLeaveMessage(); + if (leaveMessage != null) { + this.d.f.a((Packet) (new Packet3Chat(leaveMessage))); + } // CraftBukkit end this.d.f.c(this.e); diff --git a/src/main/java/net/minecraft/server/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/ServerConfigurationManager.java index 34ac6497..d028298a 100644 --- a/src/main/java/net/minecraft/server/ServerConfigurationManager.java +++ b/src/main/java/net/minecraft/server/ServerConfigurationManager.java @@ -21,6 +21,7 @@ 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.PlayerJoinEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerRespawnEvent; // CraftBukkit end @@ -94,7 +95,15 @@ public class ServerConfigurationManager { entityplayer.world.a(entityplayer); - server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayer))); + PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " joined the game."); + + server.getPluginManager().callEvent(playerJoinEvent); + + String joinMessage = playerJoinEvent.getJoinMessage(); + + if (joinMessage != null) { + this.c.f.a((Packet) (new Packet3Chat(joinMessage))); + } ((WorldServer) entityplayer.world).manager.a(entityplayer); // CraftBukkit end -- cgit v1.2.3