summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsk89q <the.sk89q@gmail.com>2011-02-16 21:46:01 -0800
committersk89q <the.sk89q@gmail.com>2011-02-16 21:47:01 -0800
commit5f940cf764a32cc1933634ca57501a6e5e4f7f77 (patch)
treeb26fb7e62fc4d9500c713eb863cf98b352947173 /src/main
parent03c118f343f8e559c0573589f4f89e4e2b3d10ad (diff)
downloadcraftbukkit-5f940cf764a32cc1933634ca57501a6e5e4f7f77.tar
craftbukkit-5f940cf764a32cc1933634ca57501a6e5e4f7f77.tar.gz
craftbukkit-5f940cf764a32cc1933634ca57501a6e5e4f7f77.tar.lz
craftbukkit-5f940cf764a32cc1933634ca57501a6e5e4f7f77.tar.xz
craftbukkit-5f940cf764a32cc1933634ca57501a6e5e4f7f77.zip
Added Player.chat().
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/net/minecraft/server/NetServerHandler.java50
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java4
2 files changed, 35 insertions, 19 deletions
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java
index c733545d..c73e75a2 100644
--- a/src/main/java/net/minecraft/server/NetServerHandler.java
+++ b/src/main/java/net/minecraft/server/NetServerHandler.java
@@ -585,38 +585,50 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
}
- if (s.startsWith("/")) {
- this.c(s);
- } else {
- // CraftBukkit start
- Player player = getPlayer();
- PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_CHAT, player, s);
- server.getPluginManager().callEvent(event);
- s = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
- if (event.isCancelled()) {
- return;
- }
- // CraftBukkit end
-
- a.info(s);
- this.d.f.a((Packet) (new Packet3Chat(s)));
+ // CraftBukkit start
+ chat(s);
+ // CraftBukkit end
+ }
+ }
+
+ // CraftBukkit start
+ public boolean chat(String msg) {
+ if (msg.startsWith("/")) {
+ this.c(msg);
+ return true;
+ } else {
+ // CraftBukkit start
+ Player player = getPlayer();
+ PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_CHAT, player, msg);
+ server.getPluginManager().callEvent(event);
+ msg = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage());
+ if (event.isCancelled()) {
+ return true;
}
+ // CraftBukkit end
+
+ a.info(msg);
+ this.d.f.a((Packet) (new Packet3Chat(msg)));
}
+
+ return false;
}
+ // CraftBukkit end
private void c(String s) {
// CraftBukkit start
CraftPlayer player = getPlayer();
- boolean targetPluginFound = server.dispatchCommand(player, s.substring(1));
- if (targetPluginFound) {
- return;
- }
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_COMMAND, player, s);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
+
+ boolean targetPluginFound = server.dispatchCommand(player, s.substring(1));
+ if (targetPluginFound) {
+ return;
+ }
s = event.getMessage();
player = (CraftPlayer) event.getPlayer();
EntityPlayer e = player.getHandle();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 7871480a..3faa3e32 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -110,6 +110,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
entity.a.b(((Packet) (new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))));
}
+ public void chat(String msg) {
+ entity.a.chat(msg);
+ }
+
public boolean performCommand(String command) {
return server.dispatchCommand(this, command);
}