public static void useJailStick(Player player) { Boolean enabled = Jail.jailStickToggle.get(player); if (enabled == null || !enabled) return; if (!InputOutput.global.getBoolean(Setting.EnableJailStick.getString(), false) || !InputOutput.jailStickParameters.containsKey(player.getItemInHand().getTypeId())) return; if (!Util.permission( player, "jail.usejailstick." + String.valueOf(player.getItemInHand().getTypeId()), PermissionDefault.OP)) return; String[] param = InputOutput.jailStickParameters.get(player.getItemInHand().getTypeId()); List<Block> targets = player.getLineOfSight(null, Integer.parseInt(param[1])); for (Block b : targets) { for (Player p : Bukkit.getServer().getOnlinePlayers()) { if (p == player) continue; if ((b.getLocation().equals(p.getLocation().getBlock().getLocation()) || b.getLocation().equals(p.getEyeLocation().getBlock().getLocation())) && Util.permission(player, "jail.canbestickjailed", PermissionDefault.TRUE)) { String args[] = new String[4]; args[0] = p.getName(); args[1] = param[2]; args[2] = param[3]; args[3] = param[4]; PrisonerManager.PrepareJail((CommandSender) player, args); } } } }
public Boolean run(CommandSender sender, String[] args) { if (args.length < 1) { Util.Message("Usage: /jail [Name] (time) (j:Jail name) (c:Cell name) (r:Reason) (m)", sender); return true; } if (Jail.zones.size() < 1) { Util.Message(Settings.getGlobalString(Setting.MessageNoJail), sender); return true; } // Initialize defaults String playerName = args[0].toLowerCase(); int time = Settings.getGlobalInt(Setting.DefaultJailTime); String jailname = ""; String cellname = ""; String reason = ""; Boolean muted = Settings.getGlobalBoolean(Setting.AutomaticMute); // Parse command line for (int i = 1; i < args.length; i++) { String line = args[i]; if (Util.isInteger(line)) time = Integer.parseInt(line); else if (line.startsWith("j:")) jailname = line.substring(2); else if (line.startsWith("c:")) cellname = line.substring(2); else if (line.equals("m")) muted = !muted; else if (line.startsWith("r:")) { if (line.startsWith("r:\"")) { reason = line.substring(3); while (!line.endsWith("\"")) { i++; if (i >= args.length) { Util.Message( "Usage: /jail [Name] (t:time) (j:Jail name) (c:Cell name) (r:Reason) (m)", sender); return true; } line = args[i]; if (line.endsWith("\"")) reason += " " + line.substring(0, line.length() - 1); else reason += " " + line; } } else reason = line.substring(2); int maxReason = Settings.getGlobalInt(Setting.MaximumReasonLength); if (maxReason > 250) maxReason = 250; // DB Limit if (reason.length() > maxReason) { Util.Message(Settings.getGlobalString(Setting.MessageTooLongReason), sender); return true; } } } Player player = Util.getPlayer(playerName, true); if (player == null && !Util.playerExists(playerName)) { Util.Message( Settings.getGlobalString(Setting.MessageNeverOnThisServer) .replace("<Player>", playerName), sender); return true; } else if (player != null) playerName = player.getName().toLowerCase(); JailPrisoner prisoner = new JailPrisoner( playerName, time * 6, jailname, cellname, false, "", reason, muted, "", sender instanceof Player ? ((Player) sender).getName() : "console", ""); PrisonerManager.PrepareJail(prisoner, player); String message; if (player == null) message = Settings.getGlobalString(Setting.MessagePrisonerOffline); else message = Settings.getGlobalString(Setting.MessagePrisonerJailed); message = prisoner.parseTags(message); Util.Message(message, sender); return true; }