@Override public void Write(IOClient p, Server server) { PacketPrepareEvent event = new PacketPrepareEvent(p, this, server); server.getEventSystem().callEvent(event); if (event.isCancelled()) return; Player player; if (p instanceof Player) { player = (Player) p; } else return; try { while (player.kickreason.length() < 64) { player.kickreason += " "; } byte[] temp = player.kickreason.getBytes("US-ASCII"); byte[] finals = new byte[1 + temp.length]; finals[0] = ID; System.arraycopy(temp, 0, finals, 1, temp.length); player.writeData(finals); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
@Override public void execute(CommandExecutor ce, String[] args) { Player who = null; String nick = ""; if (args.length == 0) { help(ce); return; } if (!(ce instanceof Player)) { if ((who = ce.getServer().findPlayer(args[0])) == null) { ce.sendMessage("Player not found.."); return; } if (args[1].equals("reset")) { who.resetCustomNick(); ce.sendMessage(who.getName() + " nick was reset."); return; } for (int i = 0; i < args.length; i++) { nick += args[i] + " "; } nick = nick.trim(); who.setCustomNick(nick); ce.getServer() .sendGlobalMessage( ce.getName() + ChatColor.White + " set " + who.getName() + "'s nick to " + who.getCustomName()); } else { Player p = (Player) ce; who = p; int startindex = 0; if (p.getServer().findPlayer(args[0]) != null) { who = p.getServer().findPlayer(args[0]); startindex++; } if (who == p && args[0].equals("reset")) { p.resetCustomNick(); p.sendMessage("Your nick was reset!"); return; } if (who != p && args[1].equals("reset")) { who.resetCustomNick(); p.sendMessage(who.getName() + "'s name was reset."); return; } for (int i = startindex; i < args.length; i++) { nick += args[i] + " "; } nick = nick.trim(); who.setCustomNick(nick); if (who != p) p.getServer() .sendGlobalMessage( p.getDisplayName() + ChatColor.White + " set " + who.getName() + "'s nick to " + who.getCustomName()); else p.getServer().sendGlobalMessage(p.getName() + " set their nick to " + p.getCustomName()); } }