Skip to content

Commit

Permalink
Added endPortalPick setting (#722)
Browse files Browse the repository at this point in the history
* Added endPortalPick setting

- added endPortalPick configuration setting to allow the end portal frames to be picked up and placed again, as they are indestructable blocks (right click with wooden pickaxe, consumes pickaxe)
- restructured PlayerInteractListener to accommodate multiple listening targets

* Update PlayerInteractListener.java

* Update PlayerInteractListener.java
  • Loading branch information
sh0inx authored Sep 23, 2023
1 parent d8ffaaf commit 0afae52
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public Configuration() {


public boolean obsidianBucket = true;
public boolean endPortalPick = true;
public boolean removeIslandBlocksOnDelete = false;
public boolean clearInventoryOnRegen = false;
public boolean clearEnderChestOnRegen = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ public void onClick(PlayerInteractEvent event) {
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
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;
}

Optional<Island> island = IridiumSkyblock.getInstance().getTeamManager().getTeamViaLocation(event.getClickedBlock().getLocation());
if (!island.isPresent()) return;
if (!IridiumSkyblock.getInstance().getTeamManager().getTeamPermission(island.get(), user, PermissionType.BLOCK_BREAK)) {
Expand All @@ -39,15 +32,32 @@ public void onClick(PlayerInteractEvent event) {
return;
}

event.getClickedBlock().setType(Material.AIR);
if (itemInHand.getAmount() > 1) {
itemInHand.setAmount(itemInHand.getAmount() - 1);
player.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET)).values().forEach(itemStack ->
player.getWorld().dropItem(player.getLocation(), itemStack)
);
} else {
itemInHand.setType(Material.LAVA_BUCKET);
if(IridiumSkyblock.getInstance().getConfiguration().obsidianBucket
&& event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
&& event.getClickedBlock().getType().equals(Material.OBSIDIAN)
&& itemInHand.getType().equals(Material.BUCKET)) {

event.getClickedBlock().setType(Material.AIR);

if (itemInHand.getAmount() > 1) {
itemInHand.setAmount(itemInHand.getAmount() - 1);
player.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET)).values().forEach(itemStack ->
player.getWorld().dropItem(player.getLocation(), itemStack)
);
} else {
itemInHand.setType(Material.LAVA_BUCKET);
}
}
}

if(IridiumSkyblock.getInstance().getConfiguration().endPortalPick
&& (event.getAction().equals(Action.LEFT_CLICK_BLOCK) && player.isSneaking())
&& event.getClickedBlock().getType().equals(Material.END_PORTAL_FRAME)
&& (itemInHand.getType().name().contains("PICKAXE"))) {

event.getClickedBlock().breakNaturally();

player.getInventory().addItem(new ItemStack(Material.END_PORTAL_FRAME)).values().forEach(itemStack ->
player.getWorld().dropItem(player.getLocation(), itemStack));
}
}
}

0 comments on commit 0afae52

Please sign in to comment.