diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java index 7c220eaf..7b58c80e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdChat.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdChat.java @@ -37,8 +37,12 @@ public class CmdChat extends FCommand { if (modeString != null) { modeString = modeString.toLowerCase(); - if (modeString.startsWith("m")) { + // Only allow Mods and higher rank to switch to this channel. + if (modeString.startsWith("m") && fme.getRole().isAtLeast(Role.MODERATOR)) { modeTarget = ChatMode.MOD; + } else if (modeString.startsWith("m") && !fme.getRole().isAtLeast(Role.MODERATOR)) { + msg(TL.COMMAND_CHAT_MOD_ONLY); + return; } else if (modeString.startsWith("p")) { modeTarget = ChatMode.PUBLIC; } else if (modeString.startsWith("a")) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java index f80e3a8a..924df7b5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java @@ -54,10 +54,16 @@ public class CmdFly extends FCommand { continue; } } + + if (FPlayers.getInstance().getByPlayer(player).isVanished()) { + // Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation. + // But we can keep it as a config. + if (P.p.getConfig().getBoolean("ffly.Particles.Enable-While-Vanished")) { + return; + } continue; } - if (P.p.useNonPacketParticles) { // 1.9+ based servers will use the built in particleAPI instead of packet based. // any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working. diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java index c024671d..2d6075e9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java @@ -48,36 +48,39 @@ public class CmdInvite extends FCommand { return; } - Access access = myFaction.getAccess(fme, PermissableAction.INVITE); - if (access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) { - fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "invite"); + if (!fme.isAdminBypassing()) { + Access access = myFaction.getAccess(fme, PermissableAction.INVITE); + if (access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) { + fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "invite"); + return; + } + } + if (myFaction.isInvited(target)) { + fme.msg(TL.COMMAND_INVITE_ALREADYINVITED, target.getName()); return; } - if (myFaction.isBanned(target)) { fme.msg(TL.COMMAND_INVITE_BANNED, target.getName()); return; } myFaction.invite(target); - if (!target.isOnline()) { - return; + // Send the invitation to the target player when online, otherwise just ignore + if (target.isOnline()) { + // Tooltips, colors, and commands only apply to the string immediately before it. + FancyMessage message = new FancyMessage(fme.describeTo(target, true)) + .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) + .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) + .then(TL.COMMAND_INVITE_INVITEDYOU.toString()) + .color(ChatColor.YELLOW) + .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) + .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) + .then(myFaction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) + .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()); + + message.send(target.getPlayer()); } - - // Tooltips, colors, and commands only apply to the string immediately before it. - FancyMessage message = new FancyMessage(fme.describeTo(target, true)) - .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) - .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) - .then(TL.COMMAND_INVITE_INVITEDYOU.toString()) - .color(ChatColor.YELLOW) - .tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) - .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()) - .then(myFaction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) - .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()); - - message.send(target.getPlayer()); - - //you.msg("%s invited you to %s", fme.describeTo(you, true), myFaction.describeTo(you)); + myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), target.describeTo(myFaction)); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java index 3d012d1f..13934a30 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdKick.java @@ -73,40 +73,31 @@ public class CmdKick extends FCommand { return; } - // players with admin-level "disband" permission can bypass these requirements - if (!Permission.KICK_ANY.has(sender)) { - + // This permission check has been cleaned to be more understandable and logical + // Unless is admin, + // - Check for the kick permission. + // - Make sure the player is in the faction. + // - Make sure the kicked player has lower rank than the kicker. + if (!fme.isAdminBypassing()) { Access access = myFaction.getAccess(fme, PermissableAction.KICK); - if (access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) { + if (access != Access.ALLOW && fme.getRole() != Role.ADMIN) { fme.msg(TL.GENERIC_NOPERMISSION, "kick"); return; } - if (toKickFaction != myFaction) { msg(TL.COMMAND_KICK_NOTMEMBER, toKick.describeTo(fme, true), myFaction.describeTo(fme)); return; } - - // Check for Access before we check for Role. - if (access != Access.ALLOW && toKick.getRole().value >= fme.getRole().value) { + if (toKick.getRole().value >= fme.getRole().value) { msg(TL.COMMAND_KICK_INSUFFICIENTRANK); return; } - if (!Conf.canLeaveWithNegativePower && toKick.getPower() < 0) { msg(TL.COMMAND_KICK_NEGATIVEPOWER); return; } } - Access access = myFaction.getAccess(fme, PermissableAction.KICK); - // This statement allows us to check if they've specifically denied it, or default to - // the old setting of allowing moderators to kick - if (access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) { - fme.msg(TL.GENERIC_NOPERMISSION, "kick"); - return; - } - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay if (!canAffordCommand(Conf.econCostKick, TL.COMMAND_KICK_TOKICK.toString())) { return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java b/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java index 1c6fc8a7..1d12faac 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdStealth.java @@ -21,20 +21,15 @@ public class CmdStealth extends FCommand { } public void perform() { - //Grabs Faction - Faction faction = fme.getFaction(); - - if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) { - //Grabs Boolean From FPlayer + if (myFaction != null && !myFaction.isWilderness() && !myFaction.isSafeZone() && !myFaction.isWarZone() && myFaction.isNormal()) { fme.setStealth(!fme.isStealthEnabled()); - //Sends Enable/Disable Message + // Sends Enable/Disable Message fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE); - } else { - //Send "Needed Faction" Message - fme.sendMessage(ChatColor.RED + "You must be in a faction to use this command"); + fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER); } } + @Override public TL getUsageTranslation() { return TL.COMMAND_STEALTH_DESCRIPTION; diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java index 2054164b..8f4b143c 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -63,8 +63,14 @@ public class FactionsChatListener implements Listener { fplayer.sendMessage("[MCspy]: " + message); } } + } else { + // Just in case player gets demoted while in faction chat. + me.msg(TL.COMMAND_CHAT_MOD_ONLY); + event.setCancelled(true); + return; } + Bukkit.getLogger().log(Level.INFO, ChatColor.stripColor("Mod Chat: " + message)); event.setCancelled(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 23fbab06..cbe4d82b 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -188,6 +188,7 @@ public enum TL { COMMAND_CHAT_MODE_TRUCE("&c&l[!] &5Truce &7only chat mode."), COMMAND_CHAT_MODE_FACTION("&c&l[!] &aFaction&7 only chat mode."), COMMAND_CHAT_MODE_MOD("&c&l[!] &dMod &7only chat mode."), + COMMAND_CHAT_MOD_ONLY("&c&l[!] &7Only Mods can talk through this chat mode."), COMMAND_CHATSPY_ENABLE("&c&l[!] &7You have &cenabled &7chat spying mode."), COMMAND_CHATSPY_ENABLELOG(" has ENABLED chat spying mode."), @@ -329,6 +330,7 @@ public enum TL { COMMAND_INVITE_INVITEDYOU("&chas invited you to join "), COMMAND_INVITE_INVITED("&c&l[!]&7 &c%1$s&7 invited &c%2$s&7 to your faction."), COMMAND_INVITE_ALREADYMEMBER("&c&l[!]&7 &c%1$s&7 is already a member of&c %2$s"), + COMMAND_INVITE_ALREADYINVITED("&c&l[!]&7 &c%1$s&7 has already been invited"), COMMAND_INVITE_DESCRIPTION("Invite a player to your faction"), COMMAND_INVITE_BANNED("&c&l[!]&7 &7%1$s &cis banned &7from your Faction. &cNot &7sending an invite."), @@ -635,6 +637,7 @@ public enum TL { COMMAND_STEALTH_DESCRIPTION("Enable and Disable Stealth Mode"), COMMAND_STEALTH_ENABLE( "&2Stealth &8» &7You will no longer disable nearby players fly."), COMMAND_STEALTH_DISABLE("&2Stealth &8» &7You will now disable other nearby players fly."), + COMMAND_STEALTH_MUSTBEMEMBER("&2Stealth &8» &4You must be in a faction to use this command"), COMMAND_STUCK_TIMEFORMAT("m 'minutes', s 'seconds.'"), COMMAND_STUCK_CANCELLED("Teleport cancelled because you were damaged"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index a1297935..d227629b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -65,6 +65,7 @@ enable-faction-flight: true ffly: Particles: Enabled: true + Enable-While-Vanished: true AutoEnable: true #If set to true, fly will automatically enable when walking into your own chunk.