mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 13:07:06 +01:00
Added Player.chat().
This commit is contained in:
parent
03c118f343
commit
5f940cf764
2 changed files with 36 additions and 20 deletions
|
@ -585,38 +585,50 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.startsWith("/")) {
|
// CraftBukkit start
|
||||||
this.c(s);
|
chat(s);
|
||||||
} else {
|
// CraftBukkit end
|
||||||
// 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
|
||||||
|
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) {
|
private void c(String s) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
CraftPlayer player = getPlayer();
|
CraftPlayer player = getPlayer();
|
||||||
boolean targetPluginFound = server.dispatchCommand(player, s.substring(1));
|
|
||||||
if (targetPluginFound) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_COMMAND, player, s);
|
PlayerChatEvent event = new PlayerChatEvent(Type.PLAYER_COMMAND, player, s);
|
||||||
server.getPluginManager().callEvent(event);
|
server.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean targetPluginFound = server.dispatchCommand(player, s.substring(1));
|
||||||
|
if (targetPluginFound) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
s = event.getMessage();
|
s = event.getMessage();
|
||||||
player = (CraftPlayer) event.getPlayer();
|
player = (CraftPlayer) event.getPlayer();
|
||||||
EntityPlayer e = player.getHandle();
|
EntityPlayer e = player.getHandle();
|
||||||
|
|
|
@ -110,6 +110,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||||
entity.a.b(((Packet) (new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))));
|
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) {
|
public boolean performCommand(String command) {
|
||||||
return server.dispatchCommand(this, command);
|
return server.dispatchCommand(this, command);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue