TheRecovery

Untitled

Mar 2nd, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. public void stopLag(CommandContext args, CommandSender sender) throws CommandException
  2. {
  3. ConfigurationManager configManager = plugin.getGlobalStateManager();
  4.  
  5. configManager.activityHaltToggle = (!args.hasFlag('c'));
  6.  
  7. if (configManager.activityHaltToggle) {
  8. if (!(sender instanceof Player)) {
  9. sender.sendMessage(ChatColor.YELLOW + "ALL intensive server activity halted.");
  10. }
  11.  
  12. plugin.getServer().broadcastMessage(ChatColor.YELLOW + "ALL intensive server activity halted by " + plugin.toName(sender) + ".");
  13.  
  14. for (World world : plugin.getServer().getWorlds()) {
  15. int removed = 0;
  16.  
  17. for (Entity entity : world.getEntities()) {
  18. if (BukkitUtil.isIntensiveEntity(entity)) {
  19. entity.remove();
  20. removed++;
  21. }
  22. }
  23.  
  24. if (removed > 10) {
  25. sender.sendMessage("" + removed + " entities (>10) auto-removed from " + world.getName());
  26. }
  27. }
  28. }
  29. else
  30. {
  31. if (!(sender instanceof Player)) {
  32. sender.sendMessage(ChatColor.YELLOW + "ALL intensive server activity no longer halted.");
  33. }
  34.  
  35. plugin.getServer().broadcastMessage(ChatColor.YELLOW + "ALL intensive server activity is now allowed.");
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment