Skip to content

Commit

Permalink
Issue #782: Double chests and completion only on right-click
Browse files Browse the repository at this point in the history
  • Loading branch information
rlf committed Jul 6, 2016
1 parent a1baeeb commit 80aa542
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public SignEvents(uSkyBlock plugin, SignLogic logic) {
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerHitSign(PlayerInteractEvent e) {
if (e.isCancelled()
|| (e.getAction() != Action.LEFT_CLICK_BLOCK && e.getAction() != Action.RIGHT_CLICK_BLOCK)
|| e.getAction() != Action.RIGHT_CLICK_BLOCK
|| e.getClickedBlock() == null || e.getClickedBlock().getType() != Material.WALL_SIGN
|| !(e.getClickedBlock().getState() instanceof Sign)
|| !hasPermission(e.getPlayer(), "usb.island.signs.use")
Expand Down Expand Up @@ -95,7 +95,7 @@ public void onChestClosed(InventoryCloseEvent e) {
}

@EventHandler(priority = EventPriority.MONITOR)
public void onSignBreak(BlockBreakEvent e) {
public void onSignOrChestBreak(BlockBreakEvent e) {
if (e.isCancelled()
|| e.getBlock() == null
|| (e.getBlock().getType() != Material.WALL_SIGN && e.getBlock().getType() != Material.CHEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,29 @@ public void updateSigns(final Location... containerLocations) {
@Override
public void run() {
for (Location loc : containerLocations) {
updateSignAsync(loc);
long x1 = (long) Math.floor(loc.getX());
long x2 = Math.round(loc.getX());
long z1 = (long) Math.floor(loc.getZ());
long z2 = Math.round(loc.getZ());
if (x1 != x2) {
// Double Chest!
Location loc1 = loc.clone();
loc1.setX(x1);
Location loc2 = loc.clone();
loc2.setX(x2);
updateSignAsync(loc1);
updateSignAsync(loc2);
} else if (z1 != z2) {
// Double Chest!
Location loc1 = loc.clone();
loc1.setZ(z1);
Location loc2 = loc.clone();
loc2.setZ(z2);
updateSignAsync(loc1);
updateSignAsync(loc2);
} else {
updateSignAsync(loc);
}
}
}
});
Expand Down

0 comments on commit 80aa542

Please sign in to comment.