Changed the enum for Leader to actually be leader and not admin.

This commit is contained in:
ProSavage 2018-10-18 19:39:48 -05:00
parent 713aab8bfa
commit 80e66d7d6c
32 changed files with 181 additions and 182 deletions

View File

@ -45,7 +45,7 @@ public class CmdAdmin extends FCommand {
return; return;
} }
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) { if (fme != null && fme.getRole() != Role.LEADER && ! permAny) {
msg(TL.COMMAND_ADMIN_NOTADMIN); msg(TL.COMMAND_ADMIN_NOTADMIN);
return; return;
} }
@ -83,7 +83,7 @@ public class CmdAdmin extends FCommand {
if (admin != null) { if (admin != null) {
admin.setRole(Role.COLEADER); admin.setRole(Role.COLEADER);
} }
fyou.setRole(Role.ADMIN); fyou.setRole(Role.LEADER);
msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(fme, true)); msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(fme, true));
// Inform all players // Inform all players

View File

@ -37,7 +37,7 @@ public class CmdBan extends FCommand {
// Adds bypass to admins and clean permission check // Adds bypass to admins and clean permission check
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.BAN); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "ban");
return; return;
} }

View File

@ -35,7 +35,7 @@ public class CmdChest extends FCommand {
// This permission check is way too explicit but it's clean // This permission check is way too explicit but it's clean
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.CHEST); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "access chest");
return; return;
} }

View File

@ -39,7 +39,7 @@ public class CmdClaim extends FCommand {
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "change faction territory");
return; return;
} }

View File

@ -55,7 +55,7 @@ public class CmdColeader extends FCommand {
return; return;
} }
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) { if (fme != null && fme.getRole() != Role.LEADER && ! permAny) {
msg(TL.COMMAND_COLEADER_NOTADMIN); msg(TL.COMMAND_COLEADER_NOTADMIN);
return; return;
} }
@ -65,7 +65,7 @@ public class CmdColeader extends FCommand {
return; return;
} }
if (you.getRole() == Role.ADMIN) { if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_COLEADER_TARGETISADMIN); msg(TL.COMMAND_COLEADER_TARGETISADMIN);
return; return;
} }

View File

@ -89,7 +89,7 @@ public class CmdCreate extends FCommand {
// We should consider adding the role just AFTER joining the faction. // We should consider adding the role just AFTER joining the faction.
// That way we don't have to mess up deleting more stuff. // 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. // 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()) { for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower)); follower.msg(TL.COMMAND_CREATE_CREATED, fme.describeTo(follower, true), faction.getTag(follower));

View File

@ -36,7 +36,7 @@ public class CmdDeinvite extends FCommand {
FPlayer you = this.argAsBestFPlayerMatch(0); FPlayer you = this.argAsBestFPlayerMatch(0);
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.INVITE); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return; return;
} }

View File

@ -48,7 +48,7 @@ public class CmdDisband extends FCommand {
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = faction.getAccess(fme, PermissableAction.DISBAND); 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()); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "disband " + faction.getTag());
return; return;
} }

View File

@ -33,7 +33,7 @@ public class CmdFWarp extends FCommand {
//TODO: check if in combat. //TODO: check if in combat.
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.WARP); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use warps");
return; return;
} }

View File

@ -51,7 +51,7 @@ public class CmdHome extends FCommand {
} }
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.HOME); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "teleport home");
return; return;
} }

View File

@ -50,7 +50,7 @@ public class CmdInvite extends FCommand {
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.INVITE); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
return; return;
} }

View File

@ -47,7 +47,7 @@ public class CmdKick extends FCommand {
String s = player.getName(); String s = player.getName();
msg.then(s + " ").color(ChatColor.GRAY).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); 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. // Only add coleader to this for the leader.
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) { for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) {
String s = player.getName(); String s = player.getName();
@ -80,7 +80,7 @@ public class CmdKick extends FCommand {
// - Make sure the kicked player has lower rank than the kicker. // - Make sure the kicked player has lower rank than the kicker.
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.KICK); 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"); fme.msg(TL.GENERIC_NOPERMISSION, "kick");
return; return;
} }
@ -124,7 +124,7 @@ public class CmdKick extends FCommand {
if (Conf.logFactionKick) { if (Conf.logFactionKick) {
P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag()); 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.promoteNewLeader();
} }
toKickFaction.deinvite(toKick); toKickFaction.deinvite(toKick);

View File

@ -52,7 +52,7 @@ public class CmdMod extends FCommand {
return; return;
} }
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) { if (fme != null && fme.getRole() != Role.LEADER && ! permAny) {
msg(TL.COMMAND_MOD_NOTADMIN); msg(TL.COMMAND_MOD_NOTADMIN);
return; return;
} }
@ -62,7 +62,7 @@ public class CmdMod extends FCommand {
return; return;
} }
if (you.getRole() == Role.ADMIN) { if (you.getRole() == Role.LEADER) {
msg(TL.COMMAND_MOD_TARGETISADMIN); msg(TL.COMMAND_MOD_TARGETISADMIN);
return; return;
} }

View File

@ -45,7 +45,7 @@ public class CmdOwner extends FCommand {
return; return;
} }
if (!hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN)) { if (! hasBypass && ! assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.LEADER)) {
return; return;
} }

View File

@ -30,7 +30,7 @@ public class CmdSetDefaultRole extends FCommand {
return; return;
} }
if (target == Role.ADMIN) { if (target == Role.LEADER) {
msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, argAsString(0)); msg(TL.COMMAND_SETDEFAULTROLE_NOTTHATROLE, argAsString(0));
return; return;
} }

View File

@ -39,7 +39,7 @@ public class CmdSetFWarp extends FCommand {
// the old setting of allowing moderators to set warps. // the old setting of allowing moderators to set warps.
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.SETWARP); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set warps");
return; return;
} }

View File

@ -42,7 +42,7 @@ public class CmdSethome extends FCommand {
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.SETHOME); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "set home");
return; return;
} }

View File

@ -38,7 +38,7 @@ public class CmdTnt extends FCommand {
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TNTBANK); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use tnt bank");
return; return;
} }

View File

@ -36,7 +36,7 @@ public class CmdTntFill extends FCommand {
public void perform() { public void perform() {
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TNTFILL); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "use tnt fill");
return; return;
} }

View File

@ -28,7 +28,7 @@ public class CmdUnban extends FCommand {
public void perform() { public void perform() {
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.BAN); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage bans");
return; return;
} }

View File

@ -37,7 +37,7 @@ public class CmdUnclaim extends FCommand {
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY); 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"); fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage faction territory");
return; return;
} }

View File

@ -105,7 +105,7 @@ public abstract class FCommand extends MCommand<P> {
return false; return false;
} }
if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.ADMIN)) { if (this.senderMustBeAdmin && ! fme.getRole().isAtLeast(Role.LEADER)) {
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort())); sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
return false; return false;
} }
@ -261,11 +261,11 @@ public abstract class FCommand extends MCommand<P> {
return false; 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; return true;
} }
if (you.getRole().equals(Role.ADMIN)) { if (you.getRole().equals(Role.LEADER)) {
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that.")); i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
} else if ((you.getRole().equals(Role.COLEADER))) { } else if ((you.getRole().equals(Role.COLEADER))) {

View File

@ -44,7 +44,7 @@ public class FPromoteCommand extends FCommand {
// Now it ain't that messy // Now it ain't that messy
if (!fme.isAdminBypassing()) { if (!fme.isAdminBypassing()) {
Access access = myFaction.getAccess(fme, PermissableAction.PROMOTE); 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"); fme.msg(TL.GENERIC_NOPERMISSION, "manage ranks");
return; return;
} }

View File

@ -669,7 +669,7 @@ public class EngineDynmap {
FPlayer playersLeaderObject = faction.getFPlayerAdmin(); FPlayer playersLeaderObject = faction.getFPlayerAdmin();
String playersLeader = getHtmlPlayerName(playersLeaderObject); String playersLeader = getHtmlPlayerName(playersLeaderObject);
ArrayList<FPlayer> playersAdminsList = faction.getFPlayersWhereRole(Role.ADMIN); ArrayList<FPlayer> playersAdminsList = faction.getFPlayersWhereRole(Role.LEADER);
String playersAdminsCount = String.valueOf(playersAdminsList.size()); String playersAdminsCount = String.valueOf(playersAdminsList.size());
String playersAdmins = getHtmlPlayerString(playersAdminsList); String playersAdmins = getHtmlPlayerString(playersAdminsList);

View File

@ -68,25 +68,125 @@ public class FactionsBlockListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) {
public void onBlockBreak(BlockBreakEvent event) { String name = player.getName();
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) { if (Conf.playersWhoBypassAllProtection.contains(name)) {
event.setCancelled(true); return true;
return;
} }
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (!fme.hasFaction()) { FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString());
return; if (me.isAdminBypassing()) {
return true;
} }
if (event.getBlock().getType() == P.p.MOB_SPANWER) {
if (!fme.isAdminBypassing()) { FLocation loc = new FLocation(location);
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER); Faction otherFaction = Board.getInstance().getFactionAt(loc);
if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners"); if (otherFaction.isWilderness()) {
return; 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("<b>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("<b>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("<b>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("<b>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("<b>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("<b>It is painful to try to " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
}
}
if (Conf.ownedAreaDenyBuild) {
if (! justCheck) {
me.msg("<b>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("<b>You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc));
return false;
}
}
return true;
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -277,124 +377,24 @@ public class FactionsBlockListener implements Listener {
return !rel.confDenyBuild(otherFaction.hasPlayersOnline()); return !rel.confDenyBuild(otherFaction.hasPlayersOnline());
} }
public static boolean playerCanBuildDestroyBlock(Player player, Location location, String action, boolean justCheck) { @EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
String name = player.getName(); public void onBlockBreak(BlockBreakEvent event) {
if (Conf.playersWhoBypassAllProtection.contains(name)) { if (! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
return true; event.setCancelled(true);
return;
} }
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
FPlayer me = FPlayers.getInstance().getById(player.getUniqueId().toString()); if (! fme.hasFaction()) {
if (me.isAdminBypassing()) { return;
return true;
} }
if (event.getBlock().getType() == P.p.MOB_SPANWER) {
FLocation loc = new FLocation(location); if (! fme.isAdminBypassing()) {
Faction otherFaction = Board.getInstance().getFactionAt(loc); Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
if (otherFaction.isWilderness()) { fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
if (Conf.worldGuardBuildPriority && Worldguard.playerCanBuild(player, location)) { return;
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("<b>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("<b>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("<b>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("<b>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("<b>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("<b>It is painful to try to " + action + " in this territory, it is owned by: " + otherFaction.getOwnerListString(loc));
}
}
if (Conf.ownedAreaDenyBuild) {
if (!justCheck) {
me.msg("<b>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("<b>You can't " + action + " in this territory, it is owned by: " + myFaction.getOwnerListString(loc));
return false;
}
}
return true;
} }
} }

View File

@ -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. // 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()))) { if ((myFaction.getOwnerListString(loc) != null && ! myFaction.getOwnerListString(loc).isEmpty() && myFaction.getOwnerListString(loc).contains(player.getName()))) {
return true; 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 player was banned (not just kicked), get rid of their stored info
if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) { if (Conf.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin.")) {
if (badGuy.getRole() == Role.ADMIN) { if (badGuy.getRole() == Role.LEADER) {
badGuy.getFaction().promoteNewLeader(); badGuy.getFaction().promoteNewLeader();
} }

View File

@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public enum Role implements Permissable { public enum Role implements Permissable {
ADMIN(4, TL.ROLE_ADMIN), LEADER(4, TL.ROLE_LEADER),
COLEADER(3, TL.ROLE_COLEADER), COLEADER(3, TL.ROLE_COLEADER),
MODERATOR(2, TL.ROLE_MODERATOR), MODERATOR(2, TL.ROLE_MODERATOR),
NORMAL(1, TL.ROLE_NORMAL), NORMAL(1, TL.ROLE_NORMAL),
@ -47,7 +47,7 @@ public enum Role implements Permissable {
case 3: case 3:
return COLEADER; return COLEADER;
case 4: case 4:
return ADMIN; return LEADER;
} }
return null; return null;
@ -56,7 +56,7 @@ public enum Role implements Permissable {
public static Role fromString(String check) { public static Role fromString(String check) {
switch (check.toLowerCase()) { switch (check.toLowerCase()) {
case "admin": case "admin":
return ADMIN; return LEADER;
case "coleader": case "coleader":
return COLEADER; return COLEADER;
case "mod": case "mod":
@ -91,7 +91,7 @@ public enum Role implements Permissable {
} }
public String getPrefix() { public String getPrefix() {
if (this == Role.ADMIN) { if (this == Role.LEADER) {
return Conf.prefixAdmin; return Conf.prefixAdmin;
} }
if (this == Role.COLEADER) { if (this == Role.COLEADER) {

View File

@ -60,7 +60,7 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
} }
// if player is faction admin, sort out the faction since he's going away // 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(); Faction faction = fplayer.getFaction();
if (faction != null) { if (faction != null) {
fplayer.getFaction().promoteNewLeader(); fplayer.getFaction().promoteNewLeader();

View File

@ -99,7 +99,7 @@ public class MiscUtil {
} }
switch (player.getRole()) { switch (player.getRole()) {
case ADMIN: case LEADER:
admins.add(player); admins.add(player);
break; break;

View File

@ -653,7 +653,7 @@ public abstract class MemoryFPlayer implements FPlayer {
boolean perm = myFaction.isPermanent(); 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); msg(TL.LEAVE_PASSADMIN);
return; return;
} }
@ -894,7 +894,7 @@ public abstract class MemoryFPlayer implements FPlayer {
public boolean canFlyAtLocation(FLocation location) { public boolean canFlyAtLocation(FLocation location) {
Faction faction = Board.getInstance().getFactionAt(location); Faction faction = Board.getInstance().getFactionAt(location);
if ((faction == getFaction() && getRole() == Role.ADMIN) || isAdminBypassing) { if ((faction == getFaction() && getRole() == Role.LEADER) || isAdminBypassing) {
return true; return true;
} }
@ -1196,7 +1196,7 @@ public abstract class MemoryFPlayer implements FPlayer {
if (getRole() == Role.COLEADER) { if (getRole() == Role.COLEADER) {
return Conf.prefixCoLeader; return Conf.prefixCoLeader;
} }
if (getRole() == Role.ADMIN) { if (getRole() == Role.LEADER) {
return Conf.prefixAdmin; return Conf.prefixAdmin;
} }
return null; return null;

View File

@ -11,7 +11,6 @@ import com.massivecraft.factions.struct.BanInfo;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.InventoryUtil;
import com.massivecraft.factions.util.LazyLocation; import com.massivecraft.factions.util.LazyLocation;
import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.factions.util.RelationUtil;
@ -657,7 +656,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
// And each role. // And each role.
for (Role role : Role.values()) { for (Role role : Role.values()) {
if (role != Role.ADMIN) { if (role != Role.LEADER) {
permissions.put(role, new HashMap<>(freshMap)); permissions.put(role, new HashMap<>(freshMap));
} }
} }
@ -910,7 +909,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
} }
for (FPlayer fplayer : fplayers) { for (FPlayer fplayer : fplayers) {
if (fplayer.getRole() == Role.ADMIN) { if (fplayer.getRole() == Role.LEADER) {
return fplayer; return fplayer;
} }
} }
@ -1014,7 +1013,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
if (oldLeader != null) { if (oldLeader != null) {
oldLeader.setRole(Role.NORMAL); oldLeader.setRole(Role.NORMAL);
} }
replacements.get(0).setRole(Role.ADMIN); replacements.get(0).setRole(Role.LEADER);
//TODO:TL //TODO:TL
this.msg("<i>Faction admin <h>%s<i> has been removed. %s<i> has been promoted as the new faction admin.", oldLeader == null ? "" : oldLeader.getName(), replacements.get(0).getName()); this.msg("<i>Faction admin <h>%s<i> has been removed. %s<i> 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()); 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) { public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) {
// in own faction, with sufficient role or permission to bypass // in own faction, with sufficient role or permission to bypass
// ownership? // 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; return true;
} }

View File

@ -880,7 +880,7 @@ public enum TL {
/** /**
* Roles * Roles
*/ */
ROLE_ADMIN("admin"), ROLE_LEADER("admin"),
ROLE_COLEADER("coleader"), ROLE_COLEADER("coleader"),
ROLE_MODERATOR("moderator"), ROLE_MODERATOR("moderator"),
ROLE_NORMAL("normal member"), ROLE_NORMAL("normal member"),