Fixed Spawner Mining Error
This commit is contained in:
parent
bcc04e6174
commit
0fc3e47289
@ -162,18 +162,20 @@ public class FactionsBlockListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
|
|
||||||
|
|
||||||
if (!event.canBuild()) return;
|
if (!event.canBuild()) return;
|
||||||
if (event.getBlockPlaced().getType() == Material.FIRE) return;
|
if (event.getBlockPlaced().getType() == Material.FIRE) return;
|
||||||
|
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()) && Conf.spawnerLock) {
|
|
||||||
event.setCancelled(true);
|
if (isSpawner) {
|
||||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
if (Conf.spawnerLock) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,12 +496,24 @@ public class FactionsBlockListener implements Listener {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
|
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
|
||||||
boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial();
|
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) {
|
|
||||||
|
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (block != null && isSpawner) {
|
|
||||||
|
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||||
|
if (fme == null || !fme.hasFaction()) return;
|
||||||
|
|
||||||
|
if (isSpawner) {
|
||||||
|
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
||||||
|
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
||||||
|
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSpawner && !fme.isAdminBypassing()) {
|
||||||
ItemStack item = new ItemStack(block.getType(), 1, block.getData());
|
ItemStack item = new ItemStack(block.getType(), 1, block.getData());
|
||||||
if (at != null && at.isNormal()) {
|
if (at != null && at.isNormal()) {
|
||||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||||
|
@ -925,16 +925,17 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLogoutMove(PlayerMoveEvent e) {
|
public void onLogoutMove(PlayerMoveEvent e) {
|
||||||
LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName());
|
LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName());
|
||||||
|
|
||||||
|
if (Objects.requireNonNull(e.getTo()).getBlockX() == e.getFrom().getBlockX() &&
|
||||||
|
e.getTo().getBlockY() == e.getFrom().getBlockY() &&
|
||||||
|
e.getTo().getBlockZ() == e.getFrom().getBlockZ())
|
||||||
|
return;
|
||||||
|
|
||||||
if (handler.isLogoutActive(e.getPlayer())) {
|
if (handler.isLogoutActive(e.getPlayer())) {
|
||||||
handler.cancelLogout(e.getPlayer());
|
handler.cancelLogout(e.getPlayer());
|
||||||
e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED));
|
e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getTo().getBlockX() == e.getFrom().getBlockX() &&
|
|
||||||
e.getTo().getBlockY() == e.getFrom().getBlockY() &&
|
|
||||||
e.getTo().getBlockZ() == e.getFrom().getBlockZ())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) {
|
if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) {
|
||||||
CmdWild.waitingTeleport.remove(e.getPlayer());
|
CmdWild.waitingTeleport.remove(e.getPlayer());
|
||||||
FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED);
|
FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED);
|
||||||
|
Loading…
Reference in New Issue
Block a user