From 4110fb2ef4c115e5f874cf0e6c985c85b5998d90 Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Thu, 4 Jan 2018 18:10:49 -0800 Subject: [PATCH] Fix up default role and promote commands --- .../java/com/massivecraft/factions/cmd/CmdJoin.java | 1 + .../massivecraft/factions/cmd/CmdSetDefaultRole.java | 1 - .../java/com/massivecraft/factions/cmd/CmdShow.java | 2 +- .../com/massivecraft/factions/cmd/FPromoteCommand.java | 10 +++++----- .../java/com/massivecraft/factions/util/MiscUtil.java | 6 ++++++ .../factions/zcore/persist/MemoryFaction.java | 9 ++------- .../java/com/massivecraft/factions/zcore/util/TL.java | 6 ++++-- 7 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java index 9de7bb55..b2de104f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java @@ -101,6 +101,7 @@ public class CmdJoin extends FCommand { fplayer.resetFactionData(); fplayer.setFaction(faction); faction.deinvite(fplayer); + fme.setRole(faction.getDefaultRole()); if (Conf.logFactionJoin) { if (samePlayer) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java index 3f319d1f..dbc79678 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdSetDefaultRole.java @@ -15,7 +15,6 @@ public class CmdSetDefaultRole extends FCommand { this.aliases.add("def"); this.requiredArgs.add("role"); - this.senderMustBeMember = true; this.senderMustBeAdmin = true; this.senderMustBePlayer = true; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index 6a292f6d..6ffbf326 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -54,7 +54,7 @@ public class CmdShow extends FCommand { return; } - if (!fme.getPlayer().hasPermission("factions.show.bypassexempt") + if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt") && P.p.getConfig().getStringList("show-exempt").contains(faction.getTag())) { msg(TL.COMMAND_SHOW_EXEMPT); return; diff --git a/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java b/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java index 1112b0ec..00e45a61 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FPromoteCommand.java @@ -14,8 +14,7 @@ public class FPromoteCommand extends FCommand { public FPromoteCommand() { super(); - this.optionalArgs.put("player name", "name"); - //this.optionalArgs.put("", ""); + this.requiredArgs.add("player"); this.permission = Permission.MOD.node; this.disableOnLock = true; @@ -44,7 +43,6 @@ public class FPromoteCommand extends FCommand { // Well this is messy. if (access == null || access == Access.UNDEFINED) { if (!assertMinRole(Role.MODERATOR)) { - msg(TL.COMMAND_NOACCESS); return; } } else if (access == Access.DENY) { @@ -59,13 +57,15 @@ public class FPromoteCommand extends FCommand { return; } + String action = relative > 0 ? TL.COMMAND_PROMOTE_PROMOTED.toString() : TL.COMMAND_PROMOTE_DEMOTED.toString(); + // Success! target.setRole(promotion); if (target.isOnline()) { - target.msg(TL.COMMAND_PROMOTE_TARGET, promotion.nicename); + target.msg(TL.COMMAND_PROMOTE_TARGET, action, promotion.nicename); } - target.msg(TL.COMMAND_PROMOTE_SUCCESS, target.getName(), promotion.nicename); + fme.msg(TL.COMMAND_PROMOTE_SUCCESS, action, target.getName(), promotion.nicename); } @Override diff --git a/src/main/java/com/massivecraft/factions/util/MiscUtil.java b/src/main/java/com/massivecraft/factions/util/MiscUtil.java index 7a300c4f..6697b3b1 100644 --- a/src/main/java/com/massivecraft/factions/util/MiscUtil.java +++ b/src/main/java/com/massivecraft/factions/util/MiscUtil.java @@ -85,6 +85,7 @@ public class MiscUtil { List admins = new ArrayList<>(); List moderators = new ArrayList<>(); List normal = new ArrayList<>(); + List recruit = new ArrayList<>(); for (FPlayer player : players) { switch (player.getRole()) { @@ -99,6 +100,10 @@ public class MiscUtil { case NORMAL: normal.add(player); break; + + case RECRUIT: + recruit.add(player); + break; } } @@ -106,6 +111,7 @@ public class MiscUtil { ret.addAll(admins); ret.addAll(moderators); ret.addAll(normal); + ret.addAll(recruit); return ret; } } 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 17fcf2cd..1a6ae601 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -47,8 +47,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { protected ConcurrentHashMap warpPasswords = new ConcurrentHashMap<>(); private long lastDeath; protected int maxVaults; - protected Map> permissions = new HashMap<>(); protected Role defaultRole; + protected Map> permissions = new HashMap<>(); public HashMap> getAnnouncements() { return this.announcements; @@ -579,12 +579,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { } public boolean addFPlayer(FPlayer fplayer) { - if (!this.isPlayerFreeType() && fplayers.add(fplayer)) { - fplayer.setRole(defaultRole); // set default role on join. - return true; - } - - return false; + return !this.isPlayerFreeType() && fplayers.add(fplayer); } public boolean removeFPlayer(FPlayer fplayer) { 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 cc2bd427..1ffe18a0 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -375,8 +375,10 @@ public enum TL { COMMAND_PERMANENT_REVOKE("removed permanent status from"), COMMAND_PERMANENT_YOURS("%1$s has %2$s your faction"), COMMAND_PERMANENT_OTHER("%s has %s the faction '%s'."), - COMMAND_PROMOTE_TARGET("You've been promoted to %1$s"), - COMMAND_PROMOTE_SUCCESS("You successfully promoted %1$s to %2$s"), + COMMAND_PROMOTE_TARGET("You've been %1$s to %2$s"), + COMMAND_PROMOTE_SUCCESS("You successfully %1$s %2$s to %3$s"), + COMMAND_PROMOTE_PROMOTED("promoted"), + COMMAND_PROMOTE_DEMOTED("demoted"), COMMAND_PERMANENTPOWER_DESCRIPTION("Toggle faction power permanence"), //TODO: This a real word? COMMAND_PERMANENTPOWER_GRANT("added permanentpower status to"),