@Override public boolean run( CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (args.length != 1) { return false; } OfflinePlayer player = null; for (Player onlinePlayer : server.getOnlinePlayers()) { if (args[0].equalsIgnoreCase(onlinePlayer.getName())) { player = onlinePlayer; } } // if the player is not online if (player == null) { player = TFM_DepreciationAggregator.getOfflinePlayer(server, args[0]); } TFM_Util.adminAction(sender.getName(), "De-opping " + player.getName(), false); player.setOp(false); return true; }
@Override public boolean run( CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (args.length != 1) { return false; } if (args[0].equalsIgnoreCase("all") || args[0].equalsIgnoreCase("everyone")) { playerMsg("Correct usage: /opall"); return true; } OfflinePlayer player = null; for (Player onlinePlayer : server.getOnlinePlayers()) { if (args[0].equalsIgnoreCase(onlinePlayer.getName())) { player = onlinePlayer; } } // if the player is not online if (player == null) { if (TFM_AdminList.isSuperAdmin(sender) || senderIsConsole) { player = TFM_DepreciationAggregator.getOfflinePlayer(server, args[0]); } else { playerMsg("That player is not online."); playerMsg("You don't have permissions to OP offline players.", ChatColor.YELLOW); return true; } } TFM_Util.adminAction(sender.getName(), "Opping " + player.getName(), false); player.setOp(true); return true; }
@EventHandler(priority = EventPriority.HIGH) public void onPlayerInteract(PlayerInteractEvent event) { final Player player = event.getPlayer(); final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); switch (event.getAction()) { case RIGHT_CLICK_AIR: case RIGHT_CLICK_BLOCK: { switch (event.getMaterial()) { case WATER_BUCKET: { if (TFM_AdminList.isSuperAdmin(player) || TFM_ConfigEntry.ALLOW_WATER_PLACE.getBoolean()) { break; } player .getInventory() .setItem( player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled."); event.setCancelled(true); break; } case LAVA_BUCKET: { if (TFM_AdminList.isSuperAdmin(player) || TFM_ConfigEntry.ALLOW_LAVA_PLACE.getBoolean()) { break; } player .getInventory() .setItem( player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1)); player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled."); event.setCancelled(true); break; } case EXPLOSIVE_MINECART: { if (TFM_ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean()) { break; } player.getInventory().clear(player.getInventory().getHeldItemSlot()); player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled."); event.setCancelled(true); break; } } break; } case LEFT_CLICK_AIR: case LEFT_CLICK_BLOCK: { switch (event.getMaterial()) { case STICK: { if (!TFM_AdminList.isSuperAdmin(player)) { break; } event.setCancelled(true); final Location location = TFM_DepreciationAggregator.getTargetBlock(player, null, 5).getLocation(); final List<RollbackEntry> entries = TFM_RollbackManager.getEntriesAtLocation(location); if (entries.isEmpty()) { TFM_Util.playerMsg(player, "No block edits at that location."); break; } TFM_Util.playerMsg( player, "Block edits at (" + ChatColor.WHITE + "x" + location.getBlockX() + ", y" + location.getBlockY() + ", z" + location.getBlockZ() + ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE); for (RollbackEntry entry : entries) { TFM_Util.playerMsg( player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " " + StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == 0 ? "" : ":" + entry.data)); } break; } case BONE: { if (!playerdata.mobThrowerEnabled()) { break; } Location player_pos = player.getLocation(); Vector direction = player_pos.getDirection().normalize(); LivingEntity rezzed_mob = (LivingEntity) player .getWorld() .spawnEntity( player_pos.add(direction.multiply(2.0)), playerdata.mobThrowerCreature()); rezzed_mob.setVelocity(direction.multiply(playerdata.mobThrowerSpeed())); playerdata.enqueueMob(rezzed_mob); event.setCancelled(true); break; } case SULPHUR: { if (!playerdata.isMP44Armed()) { break; } event.setCancelled(true); if (playerdata.toggleMP44Firing()) { playerdata.startArrowShooter(TotalFreedomMod.plugin); } else { playerdata.stopArrowShooter(); } break; } case BLAZE_ROD: { if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) { break; } if (!TFM_AdminList.isSeniorAdmin(player, true)) { break; } event.setCancelled(true); Block targetBlock; if (event.getAction().equals(Action.LEFT_CLICK_AIR)) { targetBlock = TFM_DepreciationAggregator.getTargetBlock(player, null, 120); } else { targetBlock = event.getClickedBlock(); } if (targetBlock == null) { player.sendMessage("Can't resolve target block."); break; } player.getWorld().createExplosion(targetBlock.getLocation(), 4F, true); player.getWorld().strikeLightning(targetBlock.getLocation()); break; } case CARROT: { if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) { break; } if (!TFM_AdminList.isSeniorAdmin(player, true)) { break; } Location location = player.getLocation().clone(); Vector playerPostion = location.toVector().add(new Vector(0.0, 1.65, 0.0)); Vector playerDirection = location.getDirection().normalize(); double distance = 150.0; Block targetBlock = TFM_DepreciationAggregator.getTargetBlock( player, null, Math.round((float) distance)); if (targetBlock != null) { distance = location.distance(targetBlock.getLocation()); } final List<Block> affected = new ArrayList<Block>(); Block lastBlock = null; for (double offset = 0.0; offset <= distance; offset += (distance / 25.0)) { Block block = playerPostion .clone() .add(playerDirection.clone().multiply(offset)) .toLocation(player.getWorld()) .getBlock(); if (!block.equals(lastBlock)) { if (block.isEmpty()) { affected.add(block); block.setType(Material.TNT); } else { break; } } lastBlock = block; } new BukkitRunnable() { @Override public void run() { for (Block tntBlock : affected) { TNTPrimed tnt = tntBlock.getWorld().spawn(tntBlock.getLocation(), TNTPrimed.class); tnt.setFuseTicks(5); tntBlock.setType(Material.AIR); } } }.runTaskLater(TotalFreedomMod.plugin, 30L); event.setCancelled(true); break; } case RAW_FISH: { final int RADIUS_HIT = 5; final int STRENGTH = 4; // Clownfish if (TFM_DepreciationAggregator.getData_MaterialData(event.getItem().getData()) == 2) { if (TFM_AdminList.isSeniorAdmin(player, true) || TFM_AdminList.isTelnetAdmin(player, true)) { boolean didHit = false; final Location playerLoc = player.getLocation(); final Vector playerLocVec = playerLoc.toVector(); final List<Player> players = player.getWorld().getPlayers(); for (final Player target : players) { if (target == player) { continue; } final Location targetPos = target.getLocation(); final Vector targetPosVec = targetPos.toVector(); try { if (targetPosVec.distanceSquared(playerLocVec) < (RADIUS_HIT * RADIUS_HIT)) { TFM_Util.setFlying(player, false); target.setVelocity( targetPosVec.subtract(playerLocVec).normalize().multiply(STRENGTH)); didHit = true; } } catch (IllegalArgumentException ex) { } } if (didHit) { final Sound[] sounds = Sound.values(); for (Sound sound : sounds) { if (sound.toString().contains("HIT")) { playerLoc .getWorld() .playSound( randomOffset(playerLoc, 5.0), sound, 100.0f, randomDoubleRange(0.5, 2.0).floatValue()); } } } } else { final StringBuilder msg = new StringBuilder(); final char[] chars = (player.getName() + " is a clown.").toCharArray(); for (char c : chars) { msg.append(TFM_Util.randomChatColor()).append(c); } TFM_Util.bcastMsg(msg.toString()); player.getInventory().getItemInHand().setType(Material.POTATO_ITEM); } event.setCancelled(true); break; } } } break; } } }
/* */ public boolean run( CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) /* */ { /* 19 */ if (args.length < 1) { /* 21 */ return false; /* */ } /* 25 */ if (args[0].equalsIgnoreCase("list")) /* */ { /* 27 */ playerMsg( "Whitelisted players: " + TFM_Util.playerListToNames(server.getWhitelistedPlayers())); /* 28 */ return true; /* */ } /* 32 */ if (args[0].equalsIgnoreCase("count")) /* */ { /* 34 */ int onlineWPs = 0; /* 35 */ int offlineWPs = 0; /* 36 */ int totalWPs = 0; /* 38 */ for (OfflinePlayer player : server.getWhitelistedPlayers()) /* */ { /* 40 */ if (player.isOnline()) { /* 42 */ onlineWPs++; /* */ } else { /* 46 */ offlineWPs++; /* */ } /* 48 */ totalWPs++; /* */ } /* 51 */ playerMsg("Online whitelisted players: " + onlineWPs); /* 52 */ playerMsg("Offline whitelisted players: " + offlineWPs); /* 53 */ playerMsg("Total whitelisted players: " + totalWPs); /* */ /* 55 */ return true; /* */ } /* 59 */ if ((!senderIsConsole) && (!TFM_AdminList.isSuperAdmin(sender))) /* */ { /* 61 */ sender.sendMessage(TFM_Command.MSG_NO_PERMS); /* 62 */ return true; /* */ } /* 66 */ if (args[0].equalsIgnoreCase("on")) /* */ { /* 68 */ TFM_Util.adminAction(sender.getName(), "Turning the whitelist on.", true); /* 69 */ server.setWhitelist(true); /* 70 */ return true; /* */ } /* 74 */ if (args[0].equalsIgnoreCase("off")) /* */ { /* 76 */ TFM_Util.adminAction(sender.getName(), "Turning the whitelist off.", true); /* 77 */ server.setWhitelist(false); /* 78 */ return true; /* */ } /* 82 */ if (args[0].equalsIgnoreCase("add")) /* */ { /* 84 */ if (args.length < 2) { /* 86 */ return false; /* */ } /* 89 */ String search_name = args[1].trim().toLowerCase(); /* */ /* 91 */ OfflinePlayer player = getPlayer(search_name); /* 93 */ if (player == null) { /* 95 */ player = TFM_DepreciationAggregator.getOfflinePlayer(server, search_name); /* */ } /* 98 */ TFM_Util.adminAction( sender.getName(), "Adding " + player.getName() + " to the whitelist.", false); /* 99 */ player.setWhitelisted(true); /* 100 */ return true; /* */ } /* 104 */ if ("remove".equals(args[0])) /* */ { /* 106 */ if (args.length < 2) { /* 108 */ return false; /* */ } /* 111 */ String search_name = args[1].trim().toLowerCase(); /* */ /* 113 */ OfflinePlayer player = getPlayer(search_name); /* 115 */ if (player == null) { /* 117 */ player = TFM_DepreciationAggregator.getOfflinePlayer(server, search_name); /* */ } /* 120 */ if (player.isWhitelisted()) /* */ { /* 122 */ TFM_Util.adminAction( sender.getName(), "Removing " + player.getName() + " from the whitelist.", false); /* 123 */ player.setWhitelisted(false); /* 124 */ return true; /* */ } /* 128 */ playerMsg("That player is not whitelisted"); /* 129 */ return true; /* */ } /* 135 */ if (args[0].equalsIgnoreCase("addall")) /* */ { /* 137 */ TFM_Util.adminAction( sender.getName(), "Adding all online players to the whitelist.", false); /* 138 */ int counter = 0; /* 139 */ for (Player player : server.getOnlinePlayers()) { /* 141 */ if (!player.isWhitelisted()) /* */ { /* 143 */ player.setWhitelisted(true); /* 144 */ counter++; /* */ } /* */ } /* 148 */ playerMsg("Whitelisted " + counter + " players."); /* 149 */ return true; /* */ } /* 153 */ if (!senderIsConsole) /* */ { /* 155 */ sender.sendMessage(TFM_Command.MSG_NO_PERMS); /* 156 */ return true; /* */ } /* 160 */ if (args[0].equalsIgnoreCase("purge")) /* */ { /* 162 */ TFM_Util.adminAction( sender.getName(), "Removing all players from the whitelist.", false); /* 163 */ playerMsg( "Removed " + TFM_ServerInterface.purgeWhitelist() + " players from the whitelist."); /* */ /* 165 */ return true; /* */ } /* 169 */ return false; /* */ }