Revert PlayerListener changes

Former-commit-id: 53c4a999fce41d39821744b2eb9576628c30e488 [formerly 000854db620bbb7a5c92165ee0653818b7ae9712]
Former-commit-id: 722536a3677952f9fb030ebfcaf94341592e8b09
This commit is contained in:
Ghost_chu committed 2019-06-28 22:17:06 +08:00
1 parent 05f483f721
commit 65b3a6cef2
1 file changed
+13 -45
@@ -52,7 +52,6 @@ public class PlayerListener implements Listener {
if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
Block b = e.getClickedBlock();
if (!Util.canBeShop(b) && !Util.isWallSign(b.getType())) {
Util.debugLog(b.getType().name() + " can't be shop.");
return;
}
Player p = e.getPlayer();
@@ -83,10 +82,8 @@ public class PlayerListener implements Listener {
}
// Purchase handling
if (shop != null && p.hasPermission("quickshop.use")) {
if (plugin.getConfig().getBoolean("shop.sneak-to-trade") && !p.isSneaking()) {
Util.debugLog("Player not in sneaking.");
if (plugin.getConfig().getBoolean("shop.sneak-to-trade") && !p.isSneaking())
return;
}
shop.onClick();
if (plugin.getConfig().getBoolean("effect.sound.onclick")) {
e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.BLOCK_DISPENSER_FAIL, 80.f, 1.0f);
@@ -105,42 +102,19 @@ public class PlayerListener implements Listener {
Info info = new Info(shop.getLocation(), ShopAction.BUY, null, null, shop);
actions.put(p.getUniqueId(), info);
return;
} else {
// Handles creating shops
if (e.useInteractedBlock() != Result.ALLOW) {
Util.debugLog("Interact action was canncelled: " + e.useInteractedBlock().name());
}
// Handles creating shops
else if (e.useInteractedBlock() == Result.ALLOW && shop == null && item != null && item.getType() != Material.AIR
&& p.hasPermission("quickshop.create.sell") && p.getGameMode() != GameMode.CREATIVE) {
if (e.useInteractedBlock() == Result.DENY)
return;
}
if (shop != null) {
Util.debugLog("Target block is a shop.");
if (plugin.getConfig().getBoolean("shop.sneak-to-create") && !p.isSneaking())
return;
}
if (item == null) {
Util.debugLog("Item can't be null");
return;
}
if (item.getType() == Material.AIR) {
Util.debugLog("Item can't be AIR");
return;
}
if (!p.hasPermission("quickshop.create.sell")) {
Util.debugLog("Player " + p.getName() + " no enough permission.");
return;
}
if (p.getGameMode() != GameMode.SURVIVAL) {
Util.debugLog("Only " + GameMode.SURVIVAL.name() + " can create the shop, " + p
.getName() + "'s gamemode is " + p.getGameMode().name());
return;
}
if (plugin.getConfig().getBoolean("shop.sneak-to-create") && !p.isSneaking()) {
Util.debugLog("Must sneak to create the shop.");
return;
}
if (!plugin.getShopManager().canBuildShop(p, b, e.getBlockFace())) {
// As of the new checking system, most plugins will tell the
// player why they can't create a shop there.
// So telling them a message would cause spam etc.
Util.debugLog(b.getType().name() + " can't be shop.");
return;
}
if (Util.getSecondHalf(b) != null && !p.hasPermission("quickshop.create.double")) {
@@ -153,8 +127,9 @@ public class PlayerListener implements Listener {
return;
}
if (b.getType() == Material.ENDER_CHEST) {
if (!p.hasPermission("quickshop.create.enderchest"))
if (!p.hasPermission("quickshop.create.enderchest")) {
return;
}
}
// if (!Util.canBeShop(b)) {
// Util.debugLog("Can be shop check failed.");
@@ -183,15 +158,8 @@ public class PlayerListener implements Listener {
p.sendMessage(
MsgUtil.getMessage("how-much-to-trade-for", Util.getItemStackName(e.getItem())));
}
} else {
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
Util.debugLog("Not right click the block");
return;
}
if (!Util.isWallSign(e.getClickedBlock().getType())) {
Util.debugLog(e.getClickedBlock().getType().name() + " not a wall sign.");
return;
}
} else if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)
&& Util.isWallSign(e.getClickedBlock().getType())) {
Block block;
if (Util.isWallSign(e.getClickedBlock().getType())) {
block = Util.getAttached(e.getClickedBlock());
@@ -286,4 +254,4 @@ public class PlayerListener implements Listener {
}
}
}
}