diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java
index 6edffb2f..265c9b91 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdAdmin.java
@@ -45,7 +45,7 @@ public class CmdAdmin extends FCommand {
return;
}
- if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
+ if (fme != null && fme.getRole() != Role.LEADER && ! permAny) {
msg(TL.COMMAND_ADMIN_NOTADMIN);
return;
}
@@ -83,7 +83,7 @@ public class CmdAdmin extends FCommand {
if (admin != null) {
admin.setRole(Role.COLEADER);
}
- fyou.setRole(Role.ADMIN);
+ fyou.setRole(Role.LEADER);
msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(fme, true));
// Inform all players
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBan.java b/src/main/java/com/massivecraft/factions/cmd/CmdBan.java
index c899812d..15b36b86 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdBan.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdBan.java
@@ -37,7 +37,7 @@ public class CmdBan extends FCommand {
// Adds bypass to admins and clean permission check
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.BAN);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "ban");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChest.java b/src/main/java/com/massivecraft/factions/cmd/CmdChest.java
index c9c17b67..f517f7e9 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdChest.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdChest.java
@@ -35,7 +35,7 @@ public class CmdChest extends FCommand {
// This permission check is way too explicit but it's clean
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.CHEST);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "access chest");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java
index fe605796..2ef27129 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdClaim.java
@@ -39,7 +39,7 @@ public class CmdClaim extends FCommand {
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "change faction territory");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java
index 552b4dc7..0e846973 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java
@@ -55,7 +55,7 @@ public class CmdColeader extends FCommand {
return;
}
- if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
+ if (fme != null && fme.getRole() != Role.LEADER && ! permAny) {
msg(TL.COMMAND_COLEADER_NOTADMIN);
return;
}
@@ -65,7 +65,7 @@ public class CmdColeader extends FCommand {
return;
}
- if (you.getRole() == Role.ADMIN) {
+ if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_COLEADER_TARGETISADMIN);
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java b/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java
index e9a5b83e..7ef50ef5 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdCreate.java
@@ -89,7 +89,7 @@ public class CmdCreate extends FCommand {
// We should consider adding the role just AFTER joining the faction.
// That way we don't have to mess up deleting more stuff.
// And prevent the user from being returned to NORMAL after deleting his old faction.
- fme.setRole(Role.ADMIN);
+ fme.setRole(Role.LEADER);
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower));
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java
index 540140f0..a7a2b7cc 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdDeinvite.java
@@ -36,7 +36,7 @@ public class CmdDeinvite extends FCommand {
FPlayer you = this.argAsBestFPlayerMatch(0);
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.INVITE);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java
index f5252329..bf98c5c0 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java
@@ -48,7 +48,7 @@ public class CmdDisband extends FCommand {
if (!fme.isAdminBypassing()) {
Access access = faction.getAccess(fme, PermissableAction.DISBAND);
- if (access != Access.ALLOW || fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW || fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java
index 95654ab6..94e380c7 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java
@@ -33,7 +33,7 @@ public class CmdFWarp extends FCommand {
//TODO: check if in combat.
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.WARP);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use warps");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java
index 04026809..31aec298 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdHome.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdHome.java
@@ -51,7 +51,7 @@ public class CmdHome extends FCommand {
}
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.HOME);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java
index 3e913c51..69aa7dc6 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java
@@ -50,7 +50,7 @@ public class CmdInvite extends FCommand {
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.INVITE);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java
index 13934a30..2ac73fe3 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java
@@ -47,7 +47,7 @@ public class CmdKick extends FCommand {
String s = player.getName();
msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s);
}
- if (fme.getRole() == Role.ADMIN) {
+ if (fme.getRole() == Role.LEADER) {
// Only add coleader to this for the leader.
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) {
String s = player.getName();
@@ -80,7 +80,7 @@ public class CmdKick extends FCommand {
// - Make sure the kicked player has lower rank than the kicker.
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.KICK);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_NOPERMISSION, "kick");
return;
}
@@ -124,7 +124,7 @@ public class CmdKick extends FCommand {
if (Conf.logFactionKick) {
P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag());
}
- if (toKick.getRole() == Role.ADMIN) {
+ if (toKick.getRole() == Role.LEADER) {
toKickFaction.promoteNewLeader();
}
toKickFaction.deinvite(toKick);
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java
index f3221358..b9d904b2 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdMod.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdMod.java
@@ -52,7 +52,7 @@ public class CmdMod extends FCommand {
return;
}
- if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
+ if (fme != null && fme.getRole() != Role.LEADER && ! permAny) {
msg(TL.COMMAND_MOD_NOTADMIN);
return;
}
@@ -62,7 +62,7 @@ public class CmdMod extends FCommand {
return;
}
- if (you.getRole() == Role.ADMIN) {
+ if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_MOD_TARGETISADMIN);
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java
index 35038a13..6398ae62 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java
@@ -45,7 +45,7 @@ public class CmdOwner extends FCommand {
return;
}
- if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN)) {
+ if (! hasBypass && ! assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) {
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java
index df878ce9..718ae332 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java
@@ -30,7 +30,7 @@ public class CmdSetDefaultRole extends FCommand {
return;
}
- if (target == Role.ADMIN) {
+ if (target == Role.LEADER) {
msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, argAsString(0));
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java
index c0984d4e..ee682452 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java
@@ -39,7 +39,7 @@ public class CmdSetFWarp extends FCommand {
// the old setting of allowing moderators to set warps.
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.SETWARP);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set warps");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java b/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java
index 6ad7ecfb..6246fd11 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdSethome.java
@@ -42,7 +42,7 @@ public class CmdSethome extends FCommand {
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.SETHOME);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN && !Permission.SETHOME_ANY.has(sender, true)) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER && ! Permission.SETHOME_ANY.has(sender, true)) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set home");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java b/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java
index 399f4835..758eb811 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdTnt.java
@@ -38,7 +38,7 @@ public class CmdTnt extends FCommand {
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TNTBANK);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use tnt bank");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java b/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java
index 8e652b7b..9289fc19 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdTntFill.java
@@ -36,7 +36,7 @@ public class CmdTntFill extends FCommand {
public void perform() {
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TNTFILL);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use tnt fill");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java
index 2af076ac..0b91f001 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java
@@ -28,7 +28,7 @@ public class CmdUnban extends FCommand {
public void perform() {
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.BAN);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN && !Permission.BAN.has(sender, true)) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER && ! Permission.BAN.has(sender, true)) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage bans");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java
index 74e6669e..9a6148a7 100644
--- a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java
+++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java
@@ -37,7 +37,7 @@ public class CmdUnclaim extends FCommand {
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage faction territory");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FCommand.java
index 46e41bd3..52fed408 100644
--- a/src/main/java/com/massivecraft/factions/cmd/FCommand.java
+++ b/src/main/java/com/massivecraft/factions/cmd/FCommand.java
@@ -105,7 +105,7 @@ public abstract class FCommand extends MCommand
{
return false;
}
- if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.ADMIN)) {
+ if (this.senderMustBeAdmin && ! fme.getRole().isAtLeast(Role.LEADER)) {
sender.sendMessage(p.txt.parse("Only faction admins can %s.", this.getHelpShort()));
return false;
}
@@ -261,11 +261,11 @@ public abstract class FCommand extends MCommand
{
return false;
}
- if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.ADMIN)) {
+ if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.LEADER)) {
return true;
}
- if (you.getRole().equals(Role.ADMIN)) {
+ if (you.getRole().equals(Role.LEADER)) {
i.sendMessage(p.txt.parse("Only the faction admin can do that."));
} else if ((you.getRole().equals(Role.COLEADER))) {
diff --git a/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java b/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java
index 8ff7a3ff..895d771f 100644
--- a/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java
+++ b/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java
@@ -44,7 +44,7 @@ public class FPromoteCommand extends FCommand {
// Now it ain't that messy
if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.PROMOTE);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_NOPERMISSION, "manage ranks");
return;
}
diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java
index 5dc9d7ab..34203740 100644
--- a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java
+++ b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java
@@ -669,7 +669,7 @@ public class EngineDynmap {
FPlayer playersLeaderObject = faction.getFPlayerAdmin();
String playersLeader = getHtmlPlayerName(playersLeaderObject);
- ArrayList playersAdminsList = faction.getFPlayersWhereRole(Role.ADMIN);
+ ArrayList playersAdminsList = faction.getFPlayersWhereRole(Role.LEADER);
String playersAdminsCount = String.valueOf(playersAdminsList.size());
String playersAdmins = getHtmlPlayerString(playersAdminsList);
diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java
index 8ae67aa5..0e277d35 100644
--- a/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java
+++ b/src/main/java/com/massivecraft/factions/listeners/FactionsBlockListener.java
@@ -68,25 +68,125 @@ public class FactionsBlockListener implements Listener {
}
}
- @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
- public void onBlockBreak(BlockBreakEvent event) {
- if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
- event.setCancelled(true);
- return;
+ public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
+ String name = player.getName();
+ if (Conf.playersWhoBypassAllProtection.contains(name)) {
+ return true;
+ }
+
+ FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
+ if (me.isAdminBypassing()) {
+ return true;
+ }
+
+ FLocation loc = new FLocation(location);
+ Faction otherFaction = Board.getInstance().getFactionAt(loc);
+
+ if (otherFaction.isWilderness()) {
+ if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) {
+ return true;
+ }
+
+ if (! Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) {
+ return true; // This is not faction territory. Use whatever you like here.
+ }
+
+ if (! justCheck) {
+ me.msg("You can't " + action + " in the wilderness.");
+ }
+
+ return false;
+ } else if (otherFaction.isSafeZone()) {
+ if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) {
+ return true;
+ }
+
+ if (! Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) {
+ return true;
+ }
+
+ if (! justCheck) {
+ me.msg("You can't " + action + " in a safe zone.");
+ }
+
+ return false;
+ } else if (otherFaction.isWarZone()) {
+ if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) {
+ return true;
+ }
+
+ if (! Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) {
+ return true;
+ }
+
+ if (! justCheck) {
+ me.msg("You can't " + action + " in a war zone.");
+ }
+
+ return false;
+ }
+ if (P.p.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() >= otherFaction.getPowerRounded()) {
+ return true;
+ }
+
+ Faction myFaction = me.getFaction();
+ Relation rel = myFaction.getRelationTo(otherFaction);
+ boolean online = otherFaction.hasPlayersOnline();
+ boolean pain = ! justCheck && rel.confPainBuild(online);
+ boolean deny = rel.confDenyBuild(online);
+
+ Access access = otherFaction.getAccess(me, PermissableAction.fromString(action));
+ if (access == Access.ALLOW && ((rel == Relation.ALLY) || (rel == Relation.ENEMY) || (rel == Relation.NEUTRAL) || (rel == Relation.TRUCE))) {
+ deny = false;
+ }
+ // hurt the player for building/destroying in other territory?
+ if (pain) {
+ player.damage(Conf.actionDeniedPainAmount);
+
+ if (! deny) {
+ me.msg("It is painful to try to " + action + " in the territory of " + otherFaction.getTag(myFaction));
+ }
+ }
+
+
+ // cancel building/destroying in other territory?
+ if (deny) {
+ if (! justCheck) {
+ me.msg("You can't " + action + " in the territory of " + otherFaction.getTag(myFaction));
+ }
+
+ return false;
}
- FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
- if (!fme.hasFaction()) {
- return;
- }
- if (event.getBlock().getType() == P.p.MOB_SPANWER) {
- if (!fme.isAdminBypassing()) {
- Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
- if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
- fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
- return;
+
+ // Also cancel and/or cause pain if player doesn't have ownership rights for this claim
+ if (Conf.ownedAreasEnabled && (Conf.ownedAreaDenyBuild || Conf.ownedAreaPainBuild) && ! otherFaction.playerHasOwnershipRights(me, loc)) {
+ if (! pain && Conf.ownedAreaPainBuild && ! justCheck) {
+ player.damage(Conf.actionDeniedPainAmount);
+ if (! Conf.ownedAreaDenyBuild) {
+ me.msg("It is painful to try to " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
}
}
+ if (Conf.ownedAreaDenyBuild) {
+ if (! justCheck) {
+ me.msg("You can't " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
+ return false;
}
+ }
+ }
+
+ // Check the permission just after making sure the land isn't owned by someone else to avoid bypass.
+
+ if (access != Access.ALLOW && me.getRole() != Role.LEADER) {
+ // TODO: Update this once new access values are added other than just allow / deny.
+ if (access == Access.DENY) {
+ me.msg(TL.GENERIC_NOPERMISSION, action);
+ return false;
+ } else if (myFaction.getOwnerListString(loc) != null && ! myFaction.getOwnerListString(loc).isEmpty() && ! myFaction.getOwnerListString(loc).contains(player.getName())) {
+ me.msg("You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc));
+ return false;
+ }
+ }
+ return true;
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@@ -277,124 +377,24 @@ public class FactionsBlockListener implements Listener {
return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
}
- public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
- String name = player.getName();
- if (Conf.playersWhoBypassAllProtection.contains(name)) {
- return true;
- }
-
- FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
- if (me.isAdminBypassing()) {
- return true;
- }
-
- FLocation loc = new FLocation(location);
- Faction otherFaction = Board.getInstance().getFactionAt(loc);
-
- if (otherFaction.isWilderness()) {
- if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) {
- return true;
- }
-
- if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) {
- return true; // This is not faction territory. Use whatever you like here.
- }
-
- if (!justCheck) {
- me.msg("You can't " + action + " in the wilderness.");
- }
-
- return false;
- } else if (otherFaction.isSafeZone()) {
- if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) {
- return true;
- }
-
- if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) {
- return true;
- }
-
- if (!justCheck) {
- me.msg("You can't " + action + " in a safe zone.");
- }
-
- return false;
- } else if (otherFaction.isWarZone()) {
- if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) {
- return true;
- }
-
- if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) {
- return true;
- }
-
- if (!justCheck) {
- me.msg("You can't " + action + " in a war zone.");
- }
-
- return false;
- }
- if (P.p.getConfig().getBoolean("hcf.raidable", false) && otherFaction.getLandRounded() >= otherFaction.getPowerRounded()) {
- return true;
- }
-
- Faction myFaction = me.getFaction();
- Relation rel = myFaction.getRelationTo(otherFaction);
- boolean online = otherFaction.hasPlayersOnline();
- boolean pain = !justCheck && rel.confPainBuild(online);
- boolean deny = rel.confDenyBuild(online);
-
- Access access = otherFaction.getAccess(me, PermissableAction.fromString(action));
- if (access == Access.ALLOW && ((rel == Relation.ALLY) || (rel == Relation.ENEMY) || (rel == Relation.NEUTRAL) || (rel == Relation.TRUCE))) {
- deny = false;
- }
- // hurt the player for building/destroying in other territory?
- if (pain) {
- player.damage(Conf.actionDeniedPainAmount);
-
- if (!deny) {
- me.msg("It is painful to try to " + action + " in the territory of " + otherFaction.getTag(myFaction));
- }
- }
-
-
- // cancel building/destroying in other territory?
- if (deny) {
- if (!justCheck) {
- me.msg("You can't " + action + " in the territory of " + otherFaction.getTag(myFaction));
- }
-
- return false;
- }
-
- // Also cancel and/or cause pain if player doesn't have ownership rights for this claim
- if (Conf.ownedAreasEnabled && (Conf.ownedAreaDenyBuild || Conf.ownedAreaPainBuild) && !otherFaction.playerHasOwnershipRights(me, loc)) {
- if (!pain && Conf.ownedAreaPainBuild && !justCheck) {
- player.damage(Conf.actionDeniedPainAmount);
- if (!Conf.ownedAreaDenyBuild) {
- me.msg("It is painful to try to " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
- }
- }
- if (Conf.ownedAreaDenyBuild) {
- if (!justCheck) {
- me.msg("You can't " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
- return false;
- }
- }
- }
-
- // Check the permission just after making sure the land isn't owned by someone else to avoid bypass.
-
- if (access != Access.ALLOW && me.getRole() != Role.ADMIN) {
- // TODO: Update this once new access values are added other than just allow / deny.
- if (access == Access.DENY) {
- me.msg(TL.GENERIC_NOPERMISSION, action);
- return false;
- } else if (myFaction.getOwnerListString(loc) != null && !myFaction.getOwnerListString(loc).isEmpty() && !myFaction.getOwnerListString(loc).contains(player.getName())) {
- me.msg("You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc));
- return false;
- }
- }
- return true;
+ @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
+ public void onBlockBreak(BlockBreakEvent event) {
+ if (! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
+ event.setCancelled(true);
+ return;
}
+ FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
+ if (! fme.hasFaction()) {
+ return;
+ }
+ if (event.getBlock().getType() == P.p.MOB_SPANWER) {
+ if (! fme.isAdminBypassing()) {
+ Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
+ if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
+ fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
+ return;
+ }
+ }
+ }
+ }
}
diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java
index 09f5c1e7..6188f6ca 100644
--- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java
+++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java
@@ -326,7 +326,7 @@ public class FactionsPlayerListener implements Listener {
}
- if (access != Access.ALLOW && me.getRole() != Role.ADMIN) {
+ if (access != Access.ALLOW && me.getRole() != Role.LEADER) {
// TODO: Update this once new access values are added other than just allow / deny.
if ((myFaction.getOwnerListString(loc) != null && ! myFaction.getOwnerListString(loc).isEmpty() && myFaction.getOwnerListString(loc).contains(player.getName()))) {
return true;
@@ -1004,7 +1004,7 @@ public class FactionsPlayerListener implements Listener {
// if player was banned (not just kicked), get rid of their stored info
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) {
- if (badGuy.getRole() == Role.ADMIN) {
+ if (badGuy.getRole() == Role.LEADER) {
badGuy.getFaction().promoteNewLeader();
}
diff --git a/src/main/java/com/massivecraft/factions/struct/Role.java b/src/main/java/com/massivecraft/factions/struct/Role.java
index eb7b3322..4810e489 100644
--- a/src/main/java/com/massivecraft/factions/struct/Role.java
+++ b/src/main/java/com/massivecraft/factions/struct/Role.java
@@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.List;
public enum Role implements Permissable {
- ADMIN(4, TL.ROLE_ADMIN),
+ LEADER(4, TL.ROLE_LEADER),
COLEADER(3, TL.ROLE_COLEADER),
MODERATOR(2, TL.ROLE_MODERATOR),
NORMAL(1, TL.ROLE_NORMAL),
@@ -47,7 +47,7 @@ public enum Role implements Permissable {
case 3:
return COLEADER;
case 4:
- return ADMIN;
+ return LEADER;
}
return null;
@@ -56,7 +56,7 @@ public enum Role implements Permissable {
public static Role fromString(String check) {
switch (check.toLowerCase()) {
case "admin":
- return ADMIN;
+ return LEADER;
case "coleader":
return COLEADER;
case "mod":
@@ -91,7 +91,7 @@ public enum Role implements Permissable {
}
public String getPrefix() {
- if (this == Role.ADMIN) {
+ if (this == Role.LEADER) {
return Conf.prefixAdmin;
}
if (this == Role.COLEADER) {
diff --git a/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java b/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java
index 26e656b7..d0e84d96 100644
--- a/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java
+++ b/src/main/java/com/massivecraft/factions/util/AutoLeaveProcessTask.java
@@ -60,7 +60,7 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
}
// if player is faction admin, sort out the faction since he's going away
- if (fplayer.getRole() == Role.ADMIN) {
+ if (fplayer.getRole() == Role.LEADER) {
Faction faction = fplayer.getFaction();
if (faction != null) {
fplayer.getFaction().promoteNewLeader();
diff --git a/src/main/java/com/massivecraft/factions/util/MiscUtil.java b/src/main/java/com/massivecraft/factions/util/MiscUtil.java
index be517150..7a813618 100644
--- a/src/main/java/com/massivecraft/factions/util/MiscUtil.java
+++ b/src/main/java/com/massivecraft/factions/util/MiscUtil.java
@@ -99,7 +99,7 @@ public class MiscUtil {
}
switch (player.getRole()) {
- case ADMIN:
+ case LEADER:
admins.add(player);
break;
diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java
index 19fabbbe..6e16d1ab 100644
--- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java
+++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java
@@ -653,7 +653,7 @@ public abstract class MemoryFPlayer implements FPlayer {
boolean perm = myFaction.isPermanent();
- if (!perm && this.getRole() == Role.ADMIN && myFaction.getFPlayers().size() > 1) {
+ if (! perm && this.getRole() == Role.LEADER && myFaction.getFPlayers().size() > 1) {
msg(TL.LEAVE_PASSADMIN);
return;
}
@@ -894,7 +894,7 @@ public abstract class MemoryFPlayer implements FPlayer {
public boolean canFlyAtLocation(FLocation location) {
Faction faction = Board.getInstance().getFactionAt(location);
- if ((faction == getFaction() && getRole() == Role.ADMIN) || isAdminBypassing) {
+ if ((faction == getFaction() && getRole() == Role.LEADER) || isAdminBypassing) {
return true;
}
@@ -1196,7 +1196,7 @@ public abstract class MemoryFPlayer implements FPlayer {
if (getRole() == Role.COLEADER) {
return Conf.prefixCoLeader;
}
- if (getRole() == Role.ADMIN) {
+ if (getRole() == Role.LEADER) {
return Conf.prefixAdmin;
}
return null;
diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java
index c72d6b39..29814d8b 100644
--- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java
+++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java
@@ -11,7 +11,6 @@ import com.massivecraft.factions.struct.BanInfo;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
-import com.massivecraft.factions.util.InventoryUtil;
import com.massivecraft.factions.util.LazyLocation;
import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.util.RelationUtil;
@@ -657,7 +656,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
// And each role.
for (Role role : Role.values()) {
- if (role != Role.ADMIN) {
+ if (role != Role.LEADER) {
permissions.put(role, new HashMap<>(freshMap));
}
}
@@ -910,7 +909,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
}
for (FPlayer fplayer : fplayers) {
- if (fplayer.getRole() == Role.ADMIN) {
+ if (fplayer.getRole() == Role.LEADER) {
return fplayer;
}
}
@@ -1014,7 +1013,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
if (oldLeader != null) {
oldLeader.setRole(Role.NORMAL);
}
- replacements.get(0).setRole(Role.ADMIN);
+ replacements.get(0).setRole(Role.LEADER);
//TODO:TL
this.msg("Faction admin %s has been removed. %s has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName());
P.p.log("Faction " + this.getTag() + " (" + this.getId() + ") admin was removed. Replacement admin: " + replacements.get(0).getName());
@@ -1156,7 +1155,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) {
// in own faction, with sufficient role or permission to bypass
// ownership?
- if (fplayer.getFaction() == this && (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN) || Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) {
+ if (fplayer.getFaction() == this && (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.LEADER) || Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()))) {
return true;
}
diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TL.java b/src/main/java/com/massivecraft/factions/zcore/util/TL.java
index 9ea28149..385ca916 100644
--- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java
+++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java
@@ -880,7 +880,7 @@ public enum TL {
/**
* Roles
*/
- ROLE_ADMIN("admin"),
+ ROLE_LEADER("admin"),
ROLE_COLEADER("coleader"),
ROLE_MODERATOR("moderator"),
ROLE_NORMAL("normal member"),