@Override public void processCommandPlayer(EntityPlayer sender, String[] args) { if (args.length >= 1) { if (!PermissionsAPI.checkPermAllowed( new PermQueryPlayer(sender, getCommandPerm() + ".others"))) { OutputHandler.chatError(sender, Localization.get(Localization.ERROR_NOPERMISSION)); return; } EntityPlayerMP player = FunctionHelper.getPlayerForName(args[0]); if (player != null) { PlayerInfo.getPlayerInfo(player.username).back = new WarpPoint(player); PropQueryPlayerZone query = new PropQueryPlayerZone( player, "ForgeEssentials.BasicCommands.spawnPoint", ZoneManager.getGLOBAL(), true); PermissionsAPI.getPermissionProp(query); String val = query.getStringValue(); String[] split = val.split("[;_]"); int dim = Integer.parseInt(split[0]); int x = Integer.parseInt(split[1]); int y = Integer.parseInt(split[2]); int z = Integer.parseInt(split[3]); WarpPoint point = new WarpPoint(dim, x + .5, y + 1, z + .5, player.cameraYaw, player.cameraPitch); // teleport FunctionHelper.setPlayer(player, point); player.sendChatToPlayer(Localization.get("command.spawn.done")); return; } else { OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NOPLAYER, args[0])); return; } } else if (args.length == 0) { PropQueryPlayerZone query = new PropQueryPlayerZone( sender, "ForgeEssentials.BasicCommands.spawnPoint", ZoneManager.getGLOBAL(), true); PermissionsAPI.getPermissionProp(query); String val = query.getStringValue(); String[] split = val.split("[;_]"); int dim = Integer.parseInt(split[0]); int x = Integer.parseInt(split[1]); int y = Integer.parseInt(split[2]); int z = Integer.parseInt(split[3]); WarpPoint spawn = new WarpPoint(dim, x + .5, y + 1, z + .5, sender.cameraYaw, sender.cameraPitch); PlayerInfo.getPlayerInfo(sender.username).back = new WarpPoint(sender); TeleportCenter.addToTpQue(spawn, sender); sender.sendChatToPlayer(Localization.get("command.spawn.done")); } }
/** * Prints an error message to the sender of the command. * * @param sender Object that issued the command * @param message Error message */ public void error(ICommandSender sender, String message) { if (sender instanceof EntityPlayer) { OutputHandler.chatError((EntityPlayer) sender, message); } else { sender.sendChatToPlayer(message); } }
@Override public void processCommandConsole(ICommandSender sender, String[] args) { if (args.length >= 1) { EntityPlayerMP player = FunctionHelper.getPlayerForName(args[0]); if (player != null) { PlayerInfo.getPlayerInfo(player.username).back = new WarpPoint(player); WarpPoint spawn; ChunkCoordinates point = FMLCommonHandler.instance() .getMinecraftServerInstance() .worldServers[0] .provider .getSpawnPoint(); spawn = new WarpPoint( 0, point.posX, point.posY, point.posZ, player.rotationPitch, player.rotationYaw); TeleportCenter.addToTpQue(spawn, player); player.sendChatToPlayer(Localization.get("command.spawn.done")); return; } else { OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NOPLAYER, args[0])); return; } } }
@Override public void processCommandConsole(ICommandSender sender, String[] args) { if (args.length == 2) { if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) { EntityPlayerMP player = FunctionHelper.getPlayerForName(sender, args[0]); if (player != null) { Warp warp = CommandDataManager.warps.get(args[1].toLowerCase()); PlayerInfo.getPlayerInfo(player.username).back = new WarpPoint(player); TeleportCenter.addToTpQue(warp.getPoint(), player); } else { OutputHandler.chatError( sender, Localization.format(Localization.ERROR_NOPLAYER, args[0])); } } else { OutputHandler.info("CommandBlock Error: " + Localization.get("command.warp.notfound")); } } }
public static void processCommandPlayer(EntityPlayer sender, String[] args) { sender.sendChatToPlayer("TEST! Promote parsing"); if (args.length == 0) // Not possible // OutputHandler.chatError(sender, // Localization.get(Localization.ERROR_BADSYNTAX) + ""); return; EntityPlayerMP player = FunctionHelper.getPlayerForName(args[0]); if (player == null) { // No such player! } if (args.length == 1) // default ladder return; if (!args[1].equalsIgnoreCase("from")) { // Ladder specified. // Ladder = arg 1 if (args.length >= 3) { if (args.length == 4) { // Zone set. // arg 3 = zone } } return; } if (args[1].equalsIgnoreCase("from")) { // Ladder specified. // Ladder = arg 1 if (args.length >= 3) { if (args.length == 4) { // Zone set. // arg 3 = zone } } return; } OutputHandler.chatError(sender, Localization.get(Localization.ERROR_BADSYNTAX) + ""); }
@Override public void processCommandPlayer(EntityPlayer sender, String[] args) { if (args.length == 0) { String msg = ""; for (String warp : CommandDataManager.warps.keySet()) { msg = warp + ", " + msg; } sender.sendChatToPlayer(msg); } else if (args.length == 1) { if (CommandDataManager.warps.containsKey(args[0].toLowerCase())) { if (PermissionsAPI.checkPermAllowed( new PermQueryPlayer(sender, getCommandPerm() + "." + args[0].toLowerCase()))) { Warp warp = CommandDataManager.warps.get(args[0].toLowerCase()); PlayerInfo playerInfo = PlayerInfo.getPlayerInfo(sender.username); playerInfo.back = new WarpPoint(sender); TeleportCenter.addToTpQue(warp.getPoint(), sender); } else { OutputHandler.chatError(sender, Localization.get(Localization.ERROR_PERMDENIED)); } } else { OutputHandler.chatError(sender, Localization.get("command.warp.notfound")); } } else if (args.length == 2) { if (PermissionsAPI.checkPermAllowed( new PermQueryPlayer(sender, getCommandPerm() + ".admin"))) { if (args[0].equalsIgnoreCase("set")) { if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) { OutputHandler.chatError(sender, Localization.get("command.warp.alreadyexists")); } else { CommandDataManager.addWarp(new Warp(args[1].toLowerCase(), new WarpPoint(sender))); OutputHandler.chatConfirmation(sender, Localization.get(Localization.DONE)); } } else if (args[0].equalsIgnoreCase("del")) { if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) { CommandDataManager.removeWarp(CommandDataManager.warps.get(args[1])); OutputHandler.chatConfirmation(sender, Localization.get(Localization.DONE)); } else { OutputHandler.chatError(sender, Localization.get("command.warp.notfound")); } } else { OutputHandler.chatError( sender, Localization.get(Localization.ERROR_BADSYNTAX) + getSyntaxPlayer(sender)); } } else { OutputHandler.chatError(sender, Localization.get(Localization.ERROR_PERMDENIED)); } } }
@Override public void processCommandConsole(ICommandSender sender, String[] args) { if (args.length == 0 || args.length == 1) { sender.sendChatToPlayer(Localization.ERROR_BADSYNTAX + getSyntaxConsole()); return; } if (args.length > 1) { EntityPlayerMP receiver = FunctionHelper.getPlayerForName(sender, args[0]); if (receiver == null) { OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NOPLAYER, args[0])); return; } else { clearReply(receiver.getCommandSenderName()); clearReply("server"); addReply(receiver.getCommandSenderName(), "server"); addReply("server", receiver.getCommandSenderName()); String senderMessage = "[ me -> " + receiver.getCommandSenderName() + "] "; String receiverMessage = FEChatFormatCodes.GOLD + "[" + FEChatFormatCodes.PURPLE + "Server" + FEChatFormatCodes.GOLD + " -> me ] " + FEChatFormatCodes.GREY; for (int i = 1; i < args.length; i++) { receiverMessage += args[i]; senderMessage += args[i]; if (i != args.length - 1) { receiverMessage += " "; senderMessage += " "; } } sender.sendChatToPlayer(senderMessage); receiver.sendChatToPlayer(receiverMessage); } } }
@Override public void processCommandPlayer(EntityPlayer sender, String[] args) { if (args.length > 1) { if (args[1].equals("remove")) { try { rules.remove(new Integer(args[0]) - 1); } catch (NumberFormatException e) { OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NAN, args[0])); } catch (IndexOutOfBoundsException e) { sender.sendChatToPlayer("That rule does not exist."); } } else { try { String newRule = ""; for (int i = 1; i < args.length; i++) newRule = newRule + args[i] + " "; rules.add(new Integer(args[0]) - 1, newRule); } catch (NumberFormatException e) { sender.sendChatToPlayer("Not a number. Try " + getSyntaxConsole()); } } saveRules(); } else for (String rule : rules) sender.sendChatToPlayer(rule); }
@Override public void processCommandPlayer(EntityPlayer sender, String[] args) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return; boolean set = ModuleWorldBorder.set; // Info if (args.length == 0) { sender.sendChatToPlayer(Localization.get(Localization.WB_STATUS_HEADER)); if (set) { sender.sendChatToPlayer( FEChatFormatCodes.GREEN + Localization.get(Localization.WB_STATUS_BORDERSET)); sender.sendChatToPlayer("Coordinates :"); if (ModuleWorldBorder.shape.equals(BorderShape.square)) { sender.sendChatToPlayer( "centerX:" + ModuleWorldBorder.X + " centerZ:" + ModuleWorldBorder.Z); sender.sendChatToPlayer("rad:" + ModuleWorldBorder.rad + " Shape: Square"); sender.sendChatToPlayer( "minX:" + ModuleWorldBorder.minX + " maxX:" + ModuleWorldBorder.maxX); sender.sendChatToPlayer( "minZ:" + ModuleWorldBorder.minZ + " maxZ:" + ModuleWorldBorder.maxZ); } if (ModuleWorldBorder.shape.equals(BorderShape.round)) { sender.sendChatToPlayer( "centerX:" + ModuleWorldBorder.X + " centerZ:" + ModuleWorldBorder.Z); sender.sendChatToPlayer("rad:" + ModuleWorldBorder.rad + " Shape: Round"); } } else { sender.sendChatToPlayer( FEChatFormatCodes.RED + Localization.get(Localization.WB_STATUS_BORDERNOTSET)); } return; } // Fill if (args[0].equalsIgnoreCase("fill")) { if (args.length == 1) { sender.sendChatToPlayer( FEChatFormatCodes.RED + Localization.get(Localization.WB_LAGWARING)); sender.sendChatToPlayer( FEChatFormatCodes.RED + Localization.get(Localization.WB_FILL_INFO)); sender.sendChatToPlayer(Localization.get(Localization.WB_FILL_CONFIRM)); return; } if (args[1].equalsIgnoreCase("start")) { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); WorldServer world = server.worldServers[sender.dimension]; if (taskGooing != null) { sender.sendChatToPlayer(Localization.get(Localization.WB_FILL_ONLYONCE)); } else { taskGooing = new TickTaskFill(world); } return; } if (args[1].equalsIgnoreCase("continue")) { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); WorldServer world = server.worldServerForDimension(sender.dimension); if (taskGooing != null) { sender.sendChatToPlayer(Localization.get(Localization.WB_FILL_ONLYONCE)); } else { taskGooing = new TickTaskFill(world); } return; } if (args[1].equalsIgnoreCase("cancel")) { taskGooing.stop(); return; } if (args[1].equalsIgnoreCase("message")) { if (args[2].equalsIgnoreCase("off") || args[2].equalsIgnoreCase("false")) { TickTaskFill.enablemsg = false; } else { TickTaskFill.enablemsg = true; } return; } } // Set if (args[0].equalsIgnoreCase("set") && args.length >= 3) { BorderShape shape = BorderShape.valueOf(args[1].toLowerCase()); int rad = parseIntWithMin(sender, args[2], 0); if (args.length == 3) { ModuleWorldBorder.setCenter(rad, (int) sender.posX, (int) sender.posZ, shape, true); sender.sendChatToPlayer( Localization.get(Localization.WB_SET) .replaceAll("%r", "" + rad) .replaceAll("%x", "" + (int) sender.posX) .replaceAll("%z", "" + (int) sender.posZ)); return; } if (args.length == 5) { int X = parseInt(sender, args[3]); int Z = parseInt(sender, args[4]); ModuleWorldBorder.setCenter(rad, X, Z, shape, true); sender.sendChatToPlayer( Localization.get(Localization.WB_SET) .replaceAll("%r", "" + rad) .replaceAll("%x", "" + X) .replaceAll("%z", "" + Z)); return; } } // Command unknown OutputHandler.chatError( sender, Localization.get(Localization.ERROR_BADSYNTAX) + getSyntaxPlayer(sender)); }
@Override public void processCommandPlayer(EntityPlayer sender, String[] args) { if (args.length == 0) throw new WrongUsageException("command.auth.usage"); boolean hasAdmin = APIRegistry.perms.checkPermAllowed( new PermQueryPlayer(sender, getCommandPerm() + ".admin")); // one arg? must be help. if (args.length == 1) { if (args[0].equalsIgnoreCase("help")) { OutputHandler.chatConfirmation(sender, " - /auth register <password>"); OutputHandler.chatConfirmation(sender, " - /auth login <password>"); OutputHandler.chatConfirmation( sender, " - /auth changepass <oldpass> <newpass> - changes your password"); if (!hasAdmin) return; OutputHandler.chatConfirmation( sender, " - /auth kick <player> - forces the player to login again"); OutputHandler.chatConfirmation( sender, " - /auth setpass <player> <password> - sets the players password"); OutputHandler.chatConfirmation( sender, " - /auth unregister <player> - forces the player to register again"); return; } else throw new WrongUsageException("command.auth.usage"); } // 2 args? seconds needs to be the player. if (args.length == 2) { // parse login if (args[0].equalsIgnoreCase("login")) { PlayerPassData data = PlayerPassData.getData(sender.username); if (data == null) { OutputHandler.chatError( sender, Localization.format("message.auth.error.notregisterred", sender.username)); return; } String pass = ModuleAuth.encrypt(args[1]); // login worked if (data.password.equals(pass)) { ModuleAuth.unLogged.remove(sender.username); OutputHandler.chatConfirmation(sender, Localization.get("command.auth.login.success")); } else { OutputHandler.chatError(sender, Localization.get("command.auth.login.fail")); } return; } // parse register else if (args[0].equalsIgnoreCase("register")) { if (PlayerPassData.getData(sender.username) != null) { OutputHandler.chatError( sender, Localization.format("message.auth.error.yesregisterred", sender.username)); return; } if (ModuleAuth.isEnabled() && !ModuleAuth.allowOfflineReg) { OutputHandler.chatError(sender, Localization.format("message.auth.error.disabledreg")); return; } String pass = ModuleAuth.encrypt(args[1]); PlayerPassData.registerData(sender.username, pass); ModuleAuth.unRegistered.remove(sender.username); OutputHandler.chatConfirmation(sender, Localization.get("command.auth.register.success")); return; } // stop if unlogged. if (ModuleAuth.unLogged.contains(sender.username)) { OutputHandler.chatError(sender, Localization.get("message.auth.needlogin")); return; } else if (ModuleAuth.unRegistered.contains(sender.username)) { OutputHandler.chatError(sender, Localization.get("message.auth.needregister")); return; } // check for players.. all the rest of these should be greated than 1. String name = args[1]; boolean isLogged = true; // check if the player is logged. EntityPlayerMP player = FunctionHelper.getPlayerForName(sender, name); if (player == null) { OutputHandler.chatWarning( sender, "A player of that name is not on the server. Doing the action anyways."); isLogged = false; } // parse ./auth kick if (args[0].equalsIgnoreCase("kick")) { if (!hasAdmin) throw new PermissionDeniedException(); else if (!isLogged) throw new PlayerNotFoundException(); else { ModuleAuth.unLogged.add(name); OutputHandler.chatConfirmation( sender, Localization.format("command.auth.kick.user", name)); OutputHandler.chatWarning(player, Localization.get("command.auth.kick.target")); return; } } // parse ./auth setpass else if (args[0].equalsIgnoreCase("setPass")) { if (!hasAdmin) throw new PermissionDeniedException(); throw new WrongUsageException("command.auth.usage.setpass"); } // parse ./auth unregister else if (args[0].equalsIgnoreCase("unregister")) { if (!hasAdmin) throw new PermissionDeniedException(); if (PlayerPassData.getData(name) == null) throw new WrongUsageException("message.auth.error.notregisterred", name); PlayerPassData.deleteData(name); OutputHandler.chatConfirmation( sender, Localization.format("command.auth.unregister", name)); return; } // ERROR! :D else throw new WrongUsageException("command.auth.usage"); } // 3 args? must be a comtmand - player - pass else if (args.length == 3) { if (ModuleAuth.unLogged.contains(sender.username)) { OutputHandler.chatError(sender, Localization.get("message.auth.needlogin")); return; } else if (ModuleAuth.unRegistered.contains(sender.username)) { OutputHandler.chatError(sender, Localization.get("message.auth.needregister")); return; } // parse changePass if (args[0].equalsIgnoreCase("changepass")) { PlayerPassData data = PlayerPassData.getData(sender.username); String oldpass = ModuleAuth.encrypt(args[1]); String newPass = ModuleAuth.encrypt(args[2]); if (args[1].equals(args[2])) { OutputHandler.chatConfirmation(sender, Localization.get("command.auth.change.same")); return; } if (!data.password.equals(oldpass)) { OutputHandler.chatConfirmation(sender, Localization.get("command.auth.change.wrongpass")); return; } data.password = newPass; data.save(); OutputHandler.chatConfirmation(sender, Localization.get("command.auth.change.success")); return; } // check for players.. all the rest of these should be greated than 1. String name = args[1]; // check if the player is logged. EntityPlayerMP player = FunctionHelper.getPlayerForName(sender, name); if (player == null) { OutputHandler.chatWarning( sender, "A player of that name is not on the server. Doing the action anyways."); } // pasre setPass if (args[0].equalsIgnoreCase("setPass")) { if (!hasAdmin) throw new PermissionDeniedException(); PlayerPassData data = PlayerPassData.getData(name); String encrypted = ModuleAuth.encrypt(args[2]); if (data == null) { PlayerPassData.registerData(name, encrypted); } else { data.password = encrypted; data.save(); } OutputHandler.chatConfirmation(sender, Localization.format("command.auth.setPass", name)); } } }
private void execute(ICommandSender sender, String[] args) { /* * No world, Status update. */ if (args.length == 0) { // Header String header = "--- Fillers active ---"; sender.sendChatToPlayer(header); // Actual info for (Integer world : map.keySet()) { sender.sendChatToPlayer(world + ": " + map.get(world).getStatus()); } // Footer StringBuilder footer = new StringBuilder(); for (int i = 3; i < header.length(); i++) { footer.append("-"); } sender.sendChatToPlayer(footer.toString()); return; } /* * Get the world */ WorldServer world = null; if (FunctionHelper.isNumeric(args[0])) { world = DimensionManager.getWorld(parseInt(sender, args[0])); } else if ((args[0].equalsIgnoreCase("here") || args[0].equalsIgnoreCase("world")) && sender instanceof EntityPlayer) { world = (WorldServer) ((EntityPlayer) sender).worldObj; } if (world == null) { OutputHandler.chatError(sender, args[0] + " is not an ID of a loaded world."); return; } if (args.length == 1) { if (map.containsKey(world.provider.dimensionId)) { OutputHandler.chatConfirmation(sender, map.get(world.provider.dimensionId).getStatus()); } else { OutputHandler.chatError(sender, "There is no filler running for that world."); } } else { if (args[1].equalsIgnoreCase("start")) { if (!map.containsKey(world.provider.dimensionId)) { map.put(world.provider.dimensionId, new TickTaskFill(world, sender, true)); } else { OutputHandler.chatError(sender, "Filler already running for that world!"); } } else if (args[1].equalsIgnoreCase("stop")) { if (!map.containsKey(world.provider.dimensionId)) { OutputHandler.chatError(sender, "There is no filler running for that world."); } else { map.get(world.provider.dimensionId).stop(); } } else if (args[1].equalsIgnoreCase("reset")) { if (!map.containsKey(world.provider.dimensionId)) { map.put(world.provider.dimensionId, new TickTaskFill(world, sender, false)); } else { OutputHandler.chatError(sender, "Filler already running for that world!"); } } else if (args[1].equalsIgnoreCase("speed")) { if (!map.containsKey(world.provider.dimensionId)) { OutputHandler.chatError(sender, "There is no filler running for that world."); } else { if (args.length != 3) { OutputHandler.chatConfirmation( sender, "Current speed: " + map.get(world.provider.dimensionId)); } else { map.get(world.provider.dimensionId).speed(parseIntWithMin(sender, args[2], 0)); if (map.get(world.provider.dimensionId).source != sender) { OutputHandler.chatError(sender, "Changed speed to " + args[2]); } } } } } }
@Override public void processCommandPlayer(EntityPlayer sender, String[] args) { if (args.length == 0 || args.length == 1) { OutputHandler.chatError( sender, Localization.get(Localization.ERROR_BADSYNTAX) + getSyntaxPlayer(sender)); return; } if (args.length > 1) { if (args[0].equalsIgnoreCase("server") || args[0].equalsIgnoreCase("console")) { clearReply(sender.getCommandSenderName()); clearReply("server"); addReply(sender.getCommandSenderName(), "server"); addReply("server", sender.getCommandSenderName()); String senderMessage = FEChatFormatCodes.GOLD + "[ me -> " + FEChatFormatCodes.PURPLE + "Server" + FEChatFormatCodes.GOLD + "] " + FEChatFormatCodes.GREY; String receiverMessage = FEChatFormatCodes.GOLD + "[" + FEChatFormatCodes.PURPLE + "Server" + FEChatFormatCodes.GOLD + " -> me ] "; for (int i = 0; i < args.length; i++) { receiverMessage += args[i]; senderMessage += args[i]; if (i != args.length - 1) { receiverMessage += " "; senderMessage += " "; } } MinecraftServer.getServer().sendChatToPlayer(receiverMessage); sender.sendChatToPlayer(senderMessage); } else { EntityPlayerMP receiver = FunctionHelper.getPlayerForName(sender, args[0]); if (receiver == null) { OutputHandler.chatError( sender, Localization.format(Localization.ERROR_NOPLAYER, args[0])); return; } clearReply(sender.getCommandSenderName()); clearReply(receiver.getCommandSenderName()); addReply(sender.getCommandSenderName(), receiver.getCommandSenderName()); addReply(receiver.getCommandSenderName(), sender.getCommandSenderName()); String senderMessage = FEChatFormatCodes.GOLD + "[ me -> " + FEChatFormatCodes.GREY + receiver.getCommandSenderName() + FEChatFormatCodes.GOLD + "] " + FEChatFormatCodes.WHITE; String receiverMessage = FEChatFormatCodes.GOLD + "[" + FEChatFormatCodes.GREY + sender.getCommandSenderName() + FEChatFormatCodes.GOLD + " -> me ] " + FEChatFormatCodes.WHITE; for (int i = 1; i < args.length; i++) { receiverMessage += args[i]; senderMessage += args[i]; if (i != args.length - 1) { receiverMessage += " "; senderMessage += " "; } } sender.sendChatToPlayer(senderMessage); receiver.sendChatToPlayer(receiverMessage); } } }