Skip to content

Commit

Permalink
Fix issue #1064 - challenge chests
Browse files Browse the repository at this point in the history
  • Loading branch information
rlf committed Jul 13, 2018
1 parent db0f6ee commit ea91d85
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import us.talabrek.ultimateskyblock.uSkyBlock;
Expand Down Expand Up @@ -41,7 +42,7 @@ public void onPlayerHitSign(PlayerInteractEvent e) {
|| (e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.LEFT_CLICK_BLOCK)
|| e.getClickedBlock() == null || e.getClickedBlock().getType() != Material.WALL_SIGN
|| !(e.getClickedBlock().getState() instanceof Sign)
|| !hasPermission(e.getPlayer(), "usb.island.signs.use")
|| !e.getPlayer().hasPermission("usb.island.signs.use")
|| e.getPlayer() == null || !plugin.isSkyAssociatedWorld(e.getPlayer().getWorld())
|| !(plugin.playerIsOnOwnIsland(e.getPlayer()))
) {
Expand Down Expand Up @@ -80,18 +81,31 @@ private boolean isChest(Block wallBlock) {
&& wallBlock.getState() instanceof Chest;
}

//@EventHandler(priority = EventPriority.MONITOR)
//public void onChestClosed(InventoryCloseEvent e) {
// if (e.getPlayer() == null || e.getPlayer().getLocation() == null
// || !plugin.isSkyAssociatedWorld(e.getPlayer().getLocation().getWorld())
// ) {
// return;
// }
// Location loc = ReflectionUtil.exec(e.getInventory(), "getLocation");
// if (loc != null) {
// logic.updateSignsOnContainer(loc);
// }
//}
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryMovedEvent(InventoryMoveItemEvent e) {
if (e.getDestination() == null || e.getDestination().getLocation() == null || !plugin.isSkyAssociatedWorld(e.getDestination().getLocation().getWorld())) {
return;
}
Location loc = e.getDestination().getLocation();
if (loc != null) {
logic.updateSignsOnContainer(loc);
}
loc = e.getSource().getLocation();
if (loc != null) {
logic.updateSignsOnContainer(loc);
}
}

@EventHandler(priority = EventPriority.MONITOR)
public void onChestClosed(InventoryCloseEvent e) {
if (e.getPlayer() == null || e.getPlayer().getLocation() == null || !plugin.isSkyAssociatedWorld(e.getPlayer().getLocation().getWorld())) {
return;
}
Location loc = e.getInventory().getLocation();
if (loc != null) {
logic.updateSignsOnContainer(loc);
}
}

@EventHandler(priority = EventPriority.MONITOR)
public void onSignOrChestBreak(BlockBreakEvent e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import us.talabrek.ultimateskyblock.Settings;
import us.talabrek.ultimateskyblock.api.async.Callback;

import java.util.Locale;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -46,9 +47,9 @@ public static String asString(Location loc) {
if (loc.getWorld() != null && loc.getWorld().getName() != null) {
s += loc.getWorld().getName() + ":";
}
s += String.format("%.2f,%.2f,%.2f", loc.getX(), loc.getY(), loc.getZ());
s += String.format(Locale.ENGLISH, "%.2f,%.2f,%.2f", loc.getX(), loc.getY(), loc.getZ());
if (loc.getYaw() != 0f || loc.getPitch() != 0f) {
s += String.format(":%.2f:%.2f", loc.getYaw(), loc.getPitch());
s += String.format(Locale.ENGLISH, ":%.2f:%.2f", loc.getYaw(), loc.getPitch());
}
return s;
}
Expand Down

0 comments on commit ea91d85

Please sign in to comment.