From 4cf560fe276f9e809af7977341bc00b5e21b3663 Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Sun, 18 Mar 2018 14:23:46 -0700 Subject: [PATCH] Coleaders --- .../java/com/massivecraft/factions/Conf.java | 5 +++-- .../com/massivecraft/factions/cmd/CmdKick.java | 11 +++++++++-- .../com/massivecraft/factions/struct/Role.java | 16 +++++++++++++++- .../factions/zcore/persist/MemoryFaction.java | 8 ++++++-- .../com/massivecraft/factions/zcore/util/TL.java | 1 + src/main/resources/config.yml | 10 ++++++---- 6 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/Conf.java b/src/main/java/com/massivecraft/factions/Conf.java index 48bf1603..4c56c0c5 100644 --- a/src/main/java/com/massivecraft/factions/Conf.java +++ b/src/main/java/com/massivecraft/factions/Conf.java @@ -34,10 +34,11 @@ public class Conf { public static double powerOfflineLossLimit = 0.0; // players will no longer lose power from being offline once their power drops to this amount or less public static double powerFactionMax = 0.0; // if greater than 0, the cap on how much power a faction can have (additional power from players beyond that will act as a "buffer" of sorts) - public static String prefixAdmin = "**"; + public static String prefixAdmin = "***"; + public static String prefixColeader = "**"; public static String prefixMod = "*"; - public static String prefixRecruit = "-"; public static String prefixNormal = "+"; + public static String prefixRecruit = "-"; public static int factionTagLengthMin = 3; public static int factionTagLengthMax = 10; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java index 6f242bcc..6a01fa14 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java @@ -41,11 +41,19 @@ public class CmdKick extends FCommand { String s = player.getName(); msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); } - if (fme.getRole() == Role.ADMIN) { + if (fme.getRole().isAtLeast(Role.COLEADER)) { + // For both coleader and admin, add mods. for (FPlayer player : myFaction.getFPlayersWhereRole(Role.MODERATOR)) { 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) { + // Only add coleader to this for the leader. + for (FPlayer player : myFaction.getFPlayersWhereRole(Role.COLEADER)) { + String s = player.getName(); + msg.then(s + " ").color(ChatColor.RED).tooltip(TL.COMMAND_KICK_CLICKTOKICK.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " kick " + s); + } + } } sendFancyMessage(msg); @@ -115,7 +123,6 @@ public class CmdKick extends FCommand { } if (Conf.logFactionKick) { - //TODO:TL P.p.log((senderIsConsole ? "A console command" : fme.getName()) + " kicked " + toKick.getName() + " from the faction: " + toKickFaction.getTag()); } diff --git a/src/main/java/com/massivecraft/factions/struct/Role.java b/src/main/java/com/massivecraft/factions/struct/Role.java index 00fc0078..0c7c967a 100644 --- a/src/main/java/com/massivecraft/factions/struct/Role.java +++ b/src/main/java/com/massivecraft/factions/struct/Role.java @@ -7,6 +7,7 @@ import com.massivecraft.factions.zcore.util.TL; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -14,7 +15,8 @@ import java.util.ArrayList; import java.util.List; public enum Role implements Permissable { - ADMIN(3, TL.ROLE_ADMIN), + ADMIN(4, TL.ROLE_ADMIN), + COLEADER(3, TL.ROLE_COLEADER), MODERATOR(2, TL.ROLE_MODERATOR), NORMAL(1, TL.ROLE_NORMAL), RECRUIT(0, TL.ROLE_RECRUIT); @@ -51,6 +53,8 @@ public enum Role implements Permissable { case 2: return MODERATOR; case 3: + return COLEADER; + case 4 : return ADMIN; } @@ -61,6 +65,9 @@ public enum Role implements Permissable { switch (check.toLowerCase()) { case "admin": return ADMIN; + case "coleader": + case "coowner": + return COLEADER; case "mod": case "moderator": return MODERATOR; @@ -89,6 +96,10 @@ public enum Role implements Permissable { return Conf.prefixAdmin; } + if (this == Role.COLEADER) { + return Conf.prefixColeader; + } + if (this == Role.MODERATOR) { return Conf.prefixMod; } @@ -126,6 +137,9 @@ public enum Role implements Permissable { itemMeta.setDisplayName(displayName); itemMeta.setLore(lore); + + itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); + item.setItemMeta(itemMeta); return item; 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 066ef12b..a024adc3 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -803,8 +803,12 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { FPlayer oldLeader = this.getFPlayerAdmin(); - // get list of moderators, or list of normal members if there are no moderators - ArrayList replacements = this.getFPlayersWhereRole(Role.MODERATOR); + // get list of coleaders, or mods, or list of normal members if there are no moderators + ArrayList replacements = this.getFPlayersWhereRole(Role.COLEADER); + if (replacements == null || replacements.isEmpty()) { + replacements = this.getFPlayersWhereRole(Role.MODERATOR); + } + if (replacements == null || replacements.isEmpty()) { replacements = this.getFPlayersWhereRole(Role.NORMAL); } 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 058d3fc7..ed7cd847 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -706,6 +706,7 @@ public enum TL { * Roles */ ROLE_ADMIN("admin"), + ROLE_COLEADER("coleader"), ROLE_MODERATOR("moderator"), ROLE_NORMAL("normal member"), ROLE_RECRUIT("recruit"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f692c110..1ae335e7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -399,15 +399,17 @@ fperm-gui: recruit: 10 normal: 11 moderator: 12 - truce: 13 - ally: 14 - enemy: 15 - neutral: 16 + coleader: 13 + truce: 14 + ally: 15 + enemy: 16 + neutral: 17 # Material to be displayed materials: recruit: WOOD_SWORD normal: STONE_SWORD moderator: IRON_SWORD + coleader: SPONGE truce: IRON_AXE ally: DIAMOND_SWORD enemy: DIAMOND_AXE