@Override public void run(Client client, Message msg) { // Lookup client Client other = Server.getServer().getClient(msg.getParam(0)); if (other == null) { // No such nickname client.send( client .newNickMessage("401") .appendParam(msg.getParam(0)) .appendParam("No such nick / channel")); } else { // Must have kill rights if (client.hasPermission(Permissions.kill)) { // Kill them logger.warn( client.id.toString() + " killed " + other.id.toString() + " (" + msg.getParam(1) + ")"); other.close("Killed by " + client.id.nick + " (" + msg.getParam(1) + ")"); } else { // Permission denied logger.warn( client.id.toString() + " attempted to kill " + other.id.toString() + " but was denied"); client.send(client.newNickMessage("481").appendParam("KILL: Permission Denied")); } } }
@Override public void run(Client client, Message msg) { char statsCmd; // Perform requested operation if (msg.paramCount() > 0 && msg.getParam(0).length() == 1) { statsCmd = Character.toLowerCase(msg.getParam(0).charAt(0)); // Only very basic stuff here i'm afraid switch (statsCmd) { case 'm': // Get command statistics Map<String, ModuleManager.CommandInfo> commands = Server.getServer().getModuleManager().getCommands(); // Generate messages in sorted order TreeMap<String, Message> messages = new TreeMap<String, Message>(); for (Entry<String, ModuleManager.CommandInfo> entry : commands.entrySet()) { if (entry.getValue().getTimesRun() > 0) { // Add to messages messages.put( entry.getKey(), client .newNickMessage("212") .appendParam(entry.getKey()) .appendParam(Integer.toString(entry.getValue().getTimesRun()))); } } // Send messages for (Message outMsg : messages.values()) { client.send(outMsg); } break; case 'u': // Get uptime int upTime = (int) ((System.currentTimeMillis() - Server.getServer().creationTime.getTime()) / 1000); int secs = upTime % 60; int mins = (upTime / 60) % 60; int hours = (upTime / 3600) % 24; int days = upTime / (24 * 3600); client.send( client .newNickMessage("242") .appendParam( String.format( "Server Up %d day%s %d:%d:%d", days, days != 1 ? "s" : "", hours, mins, secs))); break; } } else { statsCmd = '*'; } // End of /STATS client.send( client .newNickMessage("219") .appendParam(Character.toString(statsCmd)) .appendParam("End of /STATS report")); }