HookPlotSquared.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package xyz.spaceio.hooks;
  2. import java.util.Optional;
  3. import java.util.UUID;
  4. import org.bukkit.Location;
  5. import org.bukkit.block.Block;
  6. import com.github.intellectualsites.plotsquared.api.PlotAPI;
  7. public class HookPlotSquared implements SkyblockAPIHook {
  8. private PlotAPI api;
  9. public HookPlotSquared() {
  10. api = new PlotAPI();
  11. }
  12. @Override
  13. public int getIslandLevel(UUID uuid, String world) {
  14. return 0;
  15. }
  16. @Override
  17. public Optional<UUID> getIslandOwner(Location loc) {
  18. Optional<UUID> optional = Optional.empty();
  19. if(api.getPlotSquared().getApplicablePlotArea(getPSLocation(loc)).getPlotCount() > 0) {
  20. UUID owner = api.getPlotSquared().getApplicablePlotArea(getPSLocation(loc)).getPlots().iterator().next().getOwner();
  21. optional = Optional.of(owner);
  22. }
  23. return optional;
  24. }
  25. @Override
  26. public String[] getSkyBlockWorldNames() {
  27. return api.getPlotSquared().worlds.getConfigurationSection("worlds").getKeys(false).stream().toArray(String[]::new);
  28. }
  29. private com.github.intellectualsites.plotsquared.plot.object.Location getPSLocation(Location bukkitLoc) {
  30. com.github.intellectualsites.plotsquared.plot.object.Location loc = new com.github.intellectualsites.plotsquared.plot.object.Location(bukkitLoc.getWorld().getName(), bukkitLoc.getBlockX(), bukkitLoc.getBlockY(), bukkitLoc.getBlockZ());
  31. return loc;
  32. }
  33. @Override
  34. public void sendBlockAcknowledge(Block block) {
  35. // TODO Auto-generated method stub
  36. }
  37. }