Makes sure to check entrance blocks when, and only when, protectEntrance is enabled
This commit is contained in:
parent
1bf9914c39
commit
9efc960696
@ -88,7 +88,7 @@ public class BlockEventListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
if (event.isCancelled() || !Stargate.protectEntrance) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
@ -96,7 +96,7 @@ public class BlockEventListener implements Listener {
|
|||||||
|
|
||||||
//Decide if a portal is broken
|
//Decide if a portal is broken
|
||||||
Portal portal = PortalHandler.getByBlock(block);
|
Portal portal = PortalHandler.getByBlock(block);
|
||||||
if (portal == null) {
|
if (portal == null && Stargate.protectEntrance) {
|
||||||
portal = PortalHandler.getByEntrance(block);
|
portal = PortalHandler.getByEntrance(block);
|
||||||
}
|
}
|
||||||
if (portal == null) {
|
if (portal == null) {
|
||||||
@ -104,11 +104,11 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean deny = false;
|
boolean deny = false;
|
||||||
String denyMsg = "";
|
String denyMessage = "";
|
||||||
|
|
||||||
//Decide if the user can destroy the portal
|
//Decide if the user can destroy the portal
|
||||||
if (!PermissionHelper.canDestroyPortal(player, portal)) {
|
if (!PermissionHelper.canDestroyPortal(player, portal)) {
|
||||||
denyMsg = Stargate.getString("denyMsg");
|
denyMessage = Stargate.getString("denyMsg");
|
||||||
deny = true;
|
deny = true;
|
||||||
Stargate.logger.info(Stargate.getString("prefix") + player.getName() + " tried to destroy gate");
|
Stargate.logger.info(Stargate.getString("prefix") + player.getName() + " tried to destroy gate");
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ public class BlockEventListener implements Listener {
|
|||||||
int cost = EconomyHandler.getDestroyCost(player, portal.getGate());
|
int cost = EconomyHandler.getDestroyCost(player, portal.getGate());
|
||||||
|
|
||||||
//Create and call a StarGateDestroyEvent
|
//Create and call a StarGateDestroyEvent
|
||||||
StargateDestroyEvent destroyEvent = new StargateDestroyEvent(portal, player, deny, denyMsg, cost);
|
StargateDestroyEvent destroyEvent = new StargateDestroyEvent(portal, player, deny, denyMessage, cost);
|
||||||
Stargate.server.getPluginManager().callEvent(destroyEvent);
|
Stargate.server.getPluginManager().callEvent(destroyEvent);
|
||||||
if (destroyEvent.isCancelled()) {
|
if (destroyEvent.isCancelled()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user