Advertisement
Guest User

World Guard

a guest
Jul 22nd, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. @EventHandler
  2. public void preProcessCommand(PlayerCommandPreprocessEvent e)
  3. {
  4. if (e.getMessage().equalsIgnoreCase("classes"))
  5. {
  6. Player wgplayer = e.getPlayer();
  7. LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(wgplayer);
  8. World world = localPlayer.getWorld();
  9. Location loc = new Location(world, localPlayer.getLocation().getX(), localPlayer.getLocation().getY(), localPlayer.getLocation().getZ());
  10. RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
  11. RegionQuery query = container.createQuery();
  12. ApplicableRegionSet set = query.getApplicableRegions(loc);
  13.  
  14. List<ProtectedRegion> regions = Lists.newArrayList(set);
  15. for (ProtectedRegion region : set)
  16. {
  17. if (!region.getId().equalsIgnoreCase("spawn"))
  18. {
  19. wgplayer.sendMessage("You are not allowed to do that!");
  20. e.setCancelled(true);
  21. }
  22. return;
  23. }
  24. }
  25. return;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement