Qballl

Untitled

Dec 2nd, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. package io.wildernesstp.hook;
  2.  
  3. import com.palmergames.bukkit.towny.TownyAPI;
  4.  
  5.  
  6. import io.wildernesstp.Main;
  7. import org.bukkit.Location;
  8. import org.bukkit.block.Block;
  9. import org.bukkit.util.Vector;
  10.  
  11. /**
  12. * MIT License
  13. * <p>
  14. * Copyright (c) 2019 Quintin VanBooven
  15. * <p>
  16. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17. * of this software and associated documentation files (the "Software"), to deal
  18. * in the Software without restriction, including without limitation the rights
  19. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20. * copies of the Software, and to permit persons to whom the Software is
  21. * furnished to do so, subject to the following conditions:
  22. * <p>
  23. * The above copyright notice and this permission notice shall be included in all
  24. * copies or substantial portions of the Software.
  25. * <p>
  26. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  27. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  28. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  29. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  30. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  31. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  32. * SOFTWARE.
  33. */
  34. public class TownyHook extends Hook {
  35.  
  36. private final Main main;
  37.  
  38. public TownyHook(Main main) {
  39. super("Towny");
  40. this.main = main;
  41. }
  42.  
  43. @Override
  44. public void enable() {
  45.  
  46. }
  47.  
  48. @Override
  49. public void disable() {
  50.  
  51. }
  52.  
  53. @Override
  54. public boolean isClaim(Location loc) {
  55. int distance = main.getConfig().getInt("Distance");
  56.  
  57. if (!TownyAPI.getInstance().isWilderness(loc.getBlock()))
  58. return true;
  59. Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
  60. Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
  61. for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
  62. for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
  63. Block block = new Location(loc.getWorld(), x, loc.getWorld().getHighestBlockYAt(x, z), z).getBlock();
  64. if (!TownyAPI.getInstance().isWilderness(block))
  65. return true;
  66. }
  67. }
  68. return false;
  69. }
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment