Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. package me.rockindavies21.bteamfix;
  2.  
  3. import com.massivecraft.factions.entity.BoardColls;
  4. import com.massivecraft.factions.entity.Faction;
  5. import com.massivecraft.mcore.ps.PS;
  6. import java.util.Iterator;
  7. import java.util.List;
  8. import org.bukkit.Bukkit;
  9. import org.bukkit.Location;
  10. import org.bukkit.World;
  11. import org.bukkit.command.Command;
  12. import org.bukkit.command.CommandSender;
  13. import org.bukkit.entity.Entity;
  14. import org.bukkit.entity.EntityType;
  15. import org.bukkit.entity.Player;
  16. import org.bukkit.event.EventHandler;
  17. import org.bukkit.event.Listener;
  18. import org.bukkit.event.entity.EntitySpawnEvent;
  19. import org.bukkit.plugin.java.JavaPlugin;
  20.  
  21. public class BTeamFix
  22. extends JavaPlugin
  23. implements Listener
  24. {
  25. public void onEnable() {}
  26.  
  27. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
  28. {
  29. if (cmd.getName().equalsIgnoreCase("despawn"))
  30. {
  31. sender.sendMessage("All minions have been despawned!");
  32. onMove();
  33. }
  34. return false;
  35. }
  36.  
  37. @EventHandler
  38. public void onSpawn(EntitySpawnEvent e)
  39. {
  40. Entity entity = e.getEntity();
  41. Location loc = entity.getLocation();
  42. if (!(entity instanceof Player))
  43. {
  44. EntityType[] arrayOfEntityType;
  45. int j = (arrayOfEntityType = EntityType.values()).length;
  46. for (int i = 0; i < j; i++)
  47. {
  48. EntityType type = arrayOfEntityType[i];
  49. if (type.name().equals("Minion"))
  50. {
  51. String name = BoardColls.get().getFactionAt(PS.valueOf(loc)).getName();
  52. if (!name.contains("Wilderness")) {
  53. e.setCancelled(true);
  54. }
  55. }
  56. }
  57. }
  58. }
  59.  
  60. public void onMove()
  61. {
  62. Iterator localIterator2;
  63. for (Iterator localIterator1 = Bukkit.getWorlds().iterator(); localIterator1.hasNext(); localIterator2.hasNext())
  64. {
  65. World world = (World)localIterator1.next();
  66. localIterator2 = world.getEntities().iterator(); continue;Entity entity = (Entity)localIterator2.next();
  67. if (!(entity instanceof Player))
  68. {
  69. EntityType[] arrayOfEntityType;
  70. int j = (arrayOfEntityType = EntityType.values()).length;
  71. for (int i = 0; i < j; i++)
  72. {
  73. EntityType type = arrayOfEntityType[i];
  74. if (type.name().equals("Minion"))
  75. {
  76. Location location = entity.getLocation();
  77. String name = BoardColls.get().getFactionAt(PS.valueOf(location)).getName();
  78. if (!name.contains("Wilderness")) {
  79. entity.remove();
  80. }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement