use of com.iridium.iridiumskyblock.database.Island in project IridiumSkyblock by Iridium-Development.
the class BucketListener method onClick.
@EventHandler(ignoreCancelled = true)
public void onClick(PlayerInteractEvent event) {
if (!IridiumSkyblockAPI.getInstance().isIslandWorld(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer();
ItemStack itemInHand = player.getInventory().getItemInMainHand();
if (!(IridiumSkyblock.getInstance().getConfiguration().obsidianBucket && event.getAction().equals(Action.RIGHT_CLICK_BLOCK) && event.getClickedBlock().getType().equals(Material.OBSIDIAN) && itemInHand.getType().equals(Material.BUCKET))) {
return;
}
Location location = event.getClickedBlock().getLocation();
Optional<Island> island = IridiumSkyblock.getInstance().getIslandManager().getIslandViaLocation(location);
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
if (island.isPresent()) {
if (IridiumSkyblock.getInstance().getIslandManager().getIslandPermission(island.get(), user, PermissionType.BUCKET)) {
event.getClickedBlock().setType(Material.AIR);
if (itemInHand.getAmount() > 1) {
itemInHand.setAmount(itemInHand.getAmount() - 1);
if (InventoryUtils.hasEmptySlot(player.getInventory())) {
event.getPlayer().getInventory().addItem(new ItemStack(Material.LAVA_BUCKET));
} else {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().inventoryFull));
player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.LAVA_BUCKET));
}
} else {
itemInHand.setType(Material.LAVA_BUCKET);
}
} else {
player.sendMessage(StringUtils.color(IridiumSkyblock.getInstance().getMessages().noPermission.replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix)));
}
}
}
use of com.iridium.iridiumskyblock.database.Island in project IridiumSkyblock by Iridium-Development.
the class EntityPickupItemListener method onEntityPickupItem.
@EventHandler(ignoreCancelled = true)
@SuppressWarnings("deprecation")
public void onEntityPickupItem(EntityPickupItemEvent event) {
if (!(event.getEntity() instanceof Player))
return;
Player player = (Player) event.getEntity();
Optional<Island> island = IridiumSkyblock.getInstance().getIslandManager().getIslandViaLocation(event.getItem().getLocation());
if (!island.isPresent())
return;
if (!IridiumSkyblock.getInstance().getIslandManager().getIslandPermission(island.get(), IridiumSkyblock.getInstance().getUserManager().getUser(player), PermissionType.PICKUP_ITEMS)) {
event.setCancelled(true);
}
}
use of com.iridium.iridiumskyblock.database.Island in project IridiumSkyblock by Iridium-Development.
the class IslandTopGUI method addContent.
@Override
public void addContent(Inventory inventory) {
List<Island> islands = IridiumSkyblock.getInstance().getIslandManager().getIslands(IslandManager.SortType.VALUE);
islandSlots.clear();
inventory.clear();
InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().islandTopGUI.background);
for (int rank : IridiumSkyblock.getInstance().getConfiguration().islandTopSlots.keySet()) {
int slot = IridiumSkyblock.getInstance().getConfiguration().islandTopSlots.get(rank);
if (islands.size() >= rank) {
Island island = islands.get(rank - 1);
islandSlots.put(slot, island);
inventory.setItem(slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().islandTopGUI.item, new PlaceholderBuilder().applyIslandPlaceholders(island).build()));
} else {
inventory.setItem(slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().islandTopGUI.filler));
}
}
if (IridiumSkyblock.getInstance().getConfiguration().backButtons && getPreviousInventory() != null) {
inventory.setItem(inventory.getSize() + IridiumSkyblock.getInstance().getInventories().backButton.slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().backButton));
}
}
use of com.iridium.iridiumskyblock.database.Island in project IridiumSkyblock by Iridium-Development.
the class IslandTopGUI method onInventoryClick.
/**
* Called when there is a click in this GUI.
* Cancelled automatically.
*
* @param event The InventoryClickEvent provided by Bukkit
*/
@Override
public void onInventoryClick(InventoryClickEvent event) {
if (!islandSlots.containsKey(event.getSlot()))
return;
Island island = islandSlots.get(event.getSlot());
IridiumSkyblock.getInstance().getCommands().visitCommand.execute(event.getWhoClicked(), new String[] { "", island.getOwner().getName() });
}
use of com.iridium.iridiumskyblock.database.Island in project IridiumSkyblock by Iridium-Development.
the class IslandVisitorsGUI method addContent.
@Override
public void addContent(Inventory inventory) {
inventory.clear();
InventoryUtils.fillInventory(inventory, getNoItemGUI().background);
inventory.setItem(inventory.getSize() - 3, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().nextPage));
inventory.setItem(inventory.getSize() - 7, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().previousPage));
final long elementsPerPage = inventory.getSize() - 9;
AtomicInteger slot = new AtomicInteger(0);
IridiumSkyblock.getInstance().getIslandManager().getPlayersOnIsland(getIsland()).stream().filter(user -> user.getIsland().map(Island::getId).orElse(0) != getIsland().getId()).skip((page - 1) * elementsPerPage).limit(elementsPerPage).forEachOrdered(user -> {
visitors.add(user);
List<Placeholder> placeholderList = new PlaceholderBuilder().applyPlayerPlaceholders(user).applyIslandPlaceholders(getIsland()).build();
inventory.setItem(slot.getAndIncrement(), ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().visitorsGUI.item, placeholderList));
});
}
Aggregations