diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index 1dae6dd1..be44c4ac 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -42,6 +42,8 @@ public class Conf { public static String prefixNormal = "+"; public static String prefixRecruit = "-"; + public static boolean allowMultipleColeaders = false; + public static int factionTagLengthMin = 3; public static int factionTagLengthMax = 10; public static boolean factionTagForceUpperCase = false; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java new file mode 100644 index 00000000..c739f7f1 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdColeader.java @@ -0,0 +1,97 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.Conf; +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.zcore.util.TL; +import mkremins.fanciful.FancyMessage; +import org.bukkit.ChatColor; + +public class CmdColeader extends FCommand { + + public CmdColeader() { + super(); + this.aliases.add("coleader"); + this.aliases.add("setcoleader"); + this.aliases.add("cl"); + this.aliases.add("setcl"); + + this.optionalArgs.put("player name", "name"); + + this.permission = Permission.COLEADER.node; + this.disableOnLock = true; + + senderMustBePlayer = false; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = true; + } + + @Override + public void perform() { + FPlayer target = this.argAsBestFPlayerMatch(0); + if (target == null) { + FancyMessage msg = new FancyMessage(TL.COMMAND_COLEADER_CANDIDATES.toString()).color(ChatColor.GOLD); + for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { + String s = player.getName(); + + msg.then(s + " ").color(ChatColor.WHITE) + .tooltip(TL.COMMAND_COLEADER_CLICKTOPROMOTE.toString() + s) + .command("/" + Conf.baseCommandAliases.get(0) + " coleader " + s); + } + + sendFancyMessage(msg); + return; + } + + boolean permAny = Permission.COLEADER_ANY.has(sender, false); + Faction targetFaction = target.getFaction(); + + if (targetFaction != myFaction && !permAny) { + msg(TL.COMMAND_COLEADER_NOTMEMBER, target.describeTo(fme, true)); + return; + } + + if (fme != null && fme.getRole() != Role.ADMIN && !permAny) { + msg(TL.COMMAND_COLEADER_NOTADMIN); + return; + } + + if (target == fme && !permAny) { + msg(TL.COMMAND_COLEADER_SELF); + return; + } + + if (target.getRole() == Role.ADMIN) { + msg(TL.COMMAND_COLEADER_TARGETISADMIN); + return; + } + + if (target.getRole() == Role.COLEADER) { + // Revoke + target.setRole(Role.MODERATOR); + targetFaction.msg(TL.COMMAND_COLEADER_REVOKED, target.describeTo(targetFaction, true)); + msg(TL.COMMAND_COLEADER_REVOKES, target.describeTo(fme, true)); + return; + } + + // Check to see if we should allow multiple coleaders or not. + if (!Conf.allowMultipleColeaders && !targetFaction.getFPlayersWhereRole(Role.COLEADER).isEmpty()) { + msg(TL.COMMAND_COLEADER_ALREADY_COLEADER); + return; + } + + // Give + target.setRole(Role.COLEADER); + targetFaction.msg(TL.COMMAND_COLEADER_PROMOTED, target.describeTo(targetFaction, true)); + msg(TL.COMMAND_COLEADER_PROMOTES, target.describeTo(fme, true)); + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_COLEADER_DESCRIPTION; + } + +} diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index e4332263..156e6b17 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -82,6 +82,7 @@ public class FCmdRoot extends FCommand { public CmdBan cmdban = new CmdBan(); public CmdUnban cmdUnban = new CmdUnban(); public CmdBanlist cmdbanlist = new CmdBanlist(); + public CmdColeader cmdColeader = new CmdColeader(); public FCmdRoot() { super(); @@ -174,6 +175,7 @@ public class FCmdRoot extends FCommand { this.addSubCommand(this.cmdban); this.addSubCommand(this.cmdUnban); this.addSubCommand(this.cmdbanlist); + this.addSubCommand(this.cmdColeader); if (Bukkit.getServer().getPluginManager().isPluginEnabled("FactionsTop")) { P.p.log(Level.INFO, "Found FactionsTop plugin. Disabling our own /f top command."); } else { diff --git a/src/main/java/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FCommand.java index 57402426..8f524bfc 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCommand.java @@ -98,8 +98,9 @@ public abstract class FCommand extends MCommand

{ return false; } - if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.ADMIN)) { - sender.sendMessage(p.txt.parse("Only faction admins can %s.", this.getHelpShort())); + // FactionsUUID - allow coleaders to execute things. + if (this.senderMustBeAdmin && !fme.getRole().isAtLeast(Role.COLEADER)) { + sender.sendMessage(p.txt.parse("Only faction coleaders and admins can %s.", this.getHelpShort())); return false; } diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index 87c588cc..d76575e1 100644 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -21,6 +21,8 @@ public enum Permission { CLAIMAT("claimat"), CLAIM_LINE("claim.line"), CLAIM_RADIUS("claim.radius"), + COLEADER("coleader"), + COLEADER_ANY("coleader.any"), CONFIG("config"), CREATE("create"), DEFAULTRANK("defaultrank"), 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 fc496d6f..3db8aec2 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -956,7 +956,7 @@ public abstract class MemoryFPlayer implements FPlayer { // Admins can always fly in their territory. // admin bypass (ops) can fly as well. - if (isAdminBypassing || (faction == getFaction() && getRole() == Role.ADMIN)) { + if (isAdminBypassing || (faction == getFaction() && getRole().isAtLeast(Role.COLEADER))) { 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 c22e63ae..82182531 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -124,6 +124,19 @@ public enum TL { COMMAND_CLAIMLINE_ABOVEMAX("&cThe maximum limit for claim line is &c%s&c."), COMMAND_CLAIMLINE_NOTVALID("%s&c is not a cardinal direction. You may use &dnorth&c, &deast&c, &dsouth &cor &dwest&c."), + COMMAND_COLEADER_CANDIDATES("Players you can promote: "), + COMMAND_COLEADER_CLICKTOPROMOTE("Click to promote "), + COMMAND_COLEADER_NOTMEMBER("%1$s&c is not a member in your faction."), + COMMAND_COLEADER_NOTADMIN("&cYou are not the faction admin."), + COMMAND_COLEADER_SELF("&cThe target player musn't be yourself."), + COMMAND_COLEADER_TARGETISADMIN("&cThe target player is a faction admin. Demote them first."), + COMMAND_COLEADER_REVOKES("&eYou have removed coleader status from %1$s&e."), + COMMAND_COLEADER_REVOKED("%1$s&e is no longer coleader in your faction."), + COMMAND_COLEADER_PROMOTES("%1$s&e was promoted to coleader in your faction."), + COMMAND_COLEADER_PROMOTED("&eYou have promoted %1$s&e to coleader."), + COMMAND_COLEADER_DESCRIPTION("Give or revoke coleader rights"), + COMMAND_COLEADER_ALREADY_COLEADER("The faction already has a coleader. There can only be 1."), + COMMAND_CONFIG_NOEXIST("&cNo configuration setting \"&d%1$s&c\" exists."), COMMAND_CONFIG_SET_TRUE("\" option set to true (enabled)."), COMMAND_CONFIG_SET_FALSE("\" option set to false (disabled)."), @@ -417,7 +430,6 @@ public enum TL { COMMAND_NOACCESS("You don't have access to that."), COMMAND_PROMOTE_NOTTHATPLAYER("That player cannot be promoted."), - COMMAND_POWER_TOSHOW("to show player power info"), COMMAND_POWER_FORSHOW("for showing player power info"), COMMAND_POWER_POWER("%1$s&6 - Power / Maxpower: &e%2$d / %3$d %4$s"), diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index d3482df8..8248d255 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -103,6 +103,7 @@ permissions: factions.mapheight: true factions.ban: true factions.fly: true + factions.coleader: true factions.admin: description: hand over your admin rights factions.admin.any: @@ -286,3 +287,5 @@ permissions: description: Ban players from Factions factions.fly: description: Allow use of /f fly + factions.coleader: + description: Allow use of /f coleader