private Object[] say(Object[] args) throws Exception { if (args.length != 1) throw new Exception("Expected 1 argument, got " + args.length); else if (!(args[0] instanceof String)) throw new Exception("Bad argument #1: expected string"); if (count++ > Settings.chatSayRate) throw new Exception("too many messages (max " + Settings.chatSayRate + " per second)"); String[] playersToSend; if (Settings.chatRangeSay >= 0) playersToSend = getPlayerNames(); else playersToSend = MinecraftServer.getServer().getConfigurationManager().getAllUsernames(); Helpers.sendChatToPlayer(playersToSend, buildMessage((String) args[0], false)); return new Object[] {true}; }
private Object[] tell(Object[] args) throws Exception { if (args.length != 2) throw new Exception("Expected 2 argument, got " + args.length); else if (!(args[0] instanceof String)) throw new Exception("Bad argument #1: expected string"); else if (!(args[1] instanceof String)) throw new Exception("Bad argument #2: expected string"); if (count++ > Settings.chatSayRate) throw new Exception("too many messages (max " + Settings.chatSayRate + " per second)"); String username = (String) args[0]; // Check Euclidean distance to player if (Settings.chatRangeSay >= 0) if (entityInRange( MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(username), Settings.chatRangeSay)) return new Object[] {false}; Helpers.sendChatToPlayer(username, buildMessage((String) args[1], true)); return new Object[] {true}; }