From 151d38fd7bb26b61f80eabfd254386d9c934da33 Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Wed, 28 Feb 2018 20:23:37 -0800 Subject: [PATCH] Faction Bans Adds /f ban, /f unban, and /f banlist Permission: factions.ban - included with factions.kithalfplayer Also added as a /f perm that can be granted. Otherwise, defaults to faction mods. Number of bans now shows up in f show Banning a player will notify your faction and target player. It'll also kick the player from your faction if they are currently in it. TODO: make /f banlist prettier --- .../com/massivecraft/factions/Faction.java | 9 ++ .../com/massivecraft/factions/cmd/CmdBan.java | 88 +++++++++++++++++++ .../massivecraft/factions/cmd/CmdBanlist.java | 67 ++++++++++++++ .../massivecraft/factions/cmd/CmdInvite.java | 27 +++--- .../massivecraft/factions/cmd/CmdJoin.java | 6 ++ .../massivecraft/factions/cmd/CmdUnban.java | 69 +++++++++++++++ .../massivecraft/factions/cmd/FCmdRoot.java | 6 ++ .../factions/event/FPlayerLeaveEvent.java | 2 +- .../massivecraft/factions/struct/BanInfo.java | 42 +++++++++ .../factions/struct/Permission.java | 1 + .../zcore/fperms/PermissableAction.java | 1 + .../factions/zcore/persist/MemoryFaction.java | 30 +++++++ .../massivecraft/factions/zcore/util/TL.java | 16 ++++ .../factions/zcore/util/TagReplacer.java | 3 + src/main/resources/config.yml | 2 + src/main/resources/plugin.yml | 3 + 16 files changed, 360 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdBan.java create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdBanlist.java create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdUnban.java create mode 100644 src/main/java/com/massivecraft/factions/struct/BanInfo.java diff --git a/src/main/java/com/massivecraft/factions/Faction.java b/src/main/java/com/massivecraft/factions/Faction.java index d10c6fd0..d466cf5c 100644 --- a/src/main/java/com/massivecraft/factions/Faction.java +++ b/src/main/java/com/massivecraft/factions/Faction.java @@ -2,6 +2,7 @@ package com.massivecraft.factions; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.iface.RelationParticipator; +import com.massivecraft.factions.struct.BanInfo; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.util.LazyLocation; @@ -56,6 +57,14 @@ public interface Faction extends EconomyParticipator { public boolean isInvited(FPlayer fplayer); + public void ban(FPlayer target, FPlayer banner); + + public void unban(FPlayer player); + + public boolean isBanned(FPlayer player); + + public Set getBannedPlayers(); + public boolean getOpen(); public void setOpen(boolean isOpen); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBan.java b/src/main/java/com/massivecraft/factions/cmd/CmdBan.java new file mode 100644 index 00000000..c0970e24 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBan.java @@ -0,0 +1,88 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.P; +import com.massivecraft.factions.event.FPlayerLeaveEvent; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.zcore.fperms.Access; +import com.massivecraft.factions.zcore.fperms.PermissableAction; +import com.massivecraft.factions.zcore.util.TL; +import org.bukkit.Bukkit; + +import java.util.logging.Level; + +public class CmdBan extends FCommand { + + public CmdBan() { + super(); + this.aliases.add("ban"); + + this.requiredArgs.add("target"); + + this.permission = Permission.BAN.node; + this.disableOnLock = true; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } + + @Override + public void perform() { + Access access = myFaction.getAccess(fme, PermissableAction.BAN); + if (access == Access.DENY) { + fme.msg(TL.GENERIC_NOPERMISSION, "ban"); + return; + } + + // Can the player set the home for this faction? + // Check for ALLOW access as well before we check for role. + if (access != Access.ALLOW) { + if (!Permission.BAN.has(sender) && !(assertMinRole(Role.MODERATOR))) { + return; + } + } else { + if (!Permission.BAN.has(sender, true)) { + return; + } + } + + // Good on permission checks. Now lets just ban the player. + FPlayer target = argAsFPlayer(0); + if (target == null) { + return; // the above method sends a message if fails to find someone. + } + + // Ban the user. + myFaction.ban(target, fme); + myFaction.deinvite(target); // can't hurt + + // If in same Faction, lets make sure to kick them and throw an event. + if (target.getFaction() == myFaction) { + + FPlayerLeaveEvent event = new FPlayerLeaveEvent(target, myFaction, FPlayerLeaveEvent.PlayerLeaveReason.BANNED); + Bukkit.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + // if someone cancels a ban, we'll get people complaining here. So lets log it. + P.p.log(Level.WARNING, "Attempted to ban {0} but someone cancelled the kick event. This isn't good.", target.getName()); + return; + } + + // Didn't get cancelled so remove them and reset their invite. + myFaction.removeFPlayer(target); + target.resetFactionData(); + } + + // Lets inform the people! + target.msg(TL.COMMAND_BAN_TARGET, myFaction.getTag(target.getFaction())); + myFaction.msg(TL.COMMAND_BAN_BANNED, fme.getName(), target.getName()); + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_BAN_DESCRIPTION; + } +} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdBanlist.java b/src/main/java/com/massivecraft/factions/cmd/CmdBanlist.java new file mode 100644 index 00000000..cef2d57f --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdBanlist.java @@ -0,0 +1,67 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.FPlayers; +import com.massivecraft.factions.Faction; +import com.massivecraft.factions.Factions; +import com.massivecraft.factions.struct.BanInfo; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TL; + +import java.util.ArrayList; +import java.util.List; + +public class CmdBanlist extends FCommand { + + public CmdBanlist() { + super(); + this.aliases.add("banlist"); + this.aliases.add("bans"); + this.aliases.add("banl"); + + this.optionalArgs.put("faction", "faction"); + + this.permission = Permission.BAN.node; + this.disableOnLock = true; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } + + @Override + public void perform() { + Faction target = myFaction; + if (!args.isEmpty()) { + target = argAsFaction(0); + } + + if (target == Factions.getInstance().getWilderness()) { + sender.sendMessage(TL.COMMAND_BANLIST_NOFACTION.toString()); + return; + } + + List lines = new ArrayList<>(); + lines.add(TL.COMMAND_BANLIST_HEADER.format(target.getBannedPlayers().size(), target.getTag(myFaction))); + int i = 1; + + for (BanInfo info : target.getBannedPlayers()) { + FPlayer banned = FPlayers.getInstance().getById(info.getBanned()); + FPlayer banner = FPlayers.getInstance().getById(info.getBanner()); + String timestamp = TL.sdf.format(info.getTime()); + + lines.add(TL.COMMAND_BANLIST_ENTRY.format(i, banned.getName(), banner.getName(), timestamp)); + i++; + } + + for (String s : lines) { + fme.sendMessage(s); + } + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_BANLIST_DESCRIPTION; + } +} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java index 0326d2bd..f28c4c45 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdInvite.java @@ -31,13 +31,13 @@ public class CmdInvite extends FCommand { @Override public void perform() { - FPlayer you = this.argAsBestFPlayerMatch(0); - if (you == null) { + FPlayer target = this.argAsBestFPlayerMatch(0); + if (target == null) { return; } - if (you.getFaction() == myFaction) { - msg(TL.COMMAND_INVITE_ALREADYMEMBER, you.getName(), myFaction.getTag()); + if (target.getFaction() == myFaction) { + msg(TL.COMMAND_INVITE_ALREADYMEMBER, target.getName(), myFaction.getTag()); msg(TL.GENERIC_YOUMAYWANT.toString() + p.cmdBase.cmdKick.getUseageTemplate(false)); return; } @@ -47,32 +47,37 @@ public class CmdInvite extends FCommand { return; } - Access access = myFaction.getAccess(you, PermissableAction.INVITE); + Access access = myFaction.getAccess(target, PermissableAction.INVITE); if (access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) { fme.msg(TL.GENERIC_NOPERMISSION, "invite"); return; } - myFaction.invite(you); - if (!you.isOnline()) { + if (myFaction.isBanned(target)) { + fme.msg(TL.COMMAND_INVITE_BANNED, target.getName()); + return; + } + + myFaction.invite(target); + if (!target.isOnline()) { return; } // Tooltips, colors, and commands only apply to the string immediately before it. - FancyMessage message = new FancyMessage(fme.describeTo(you, true)) + 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(you)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) + .then(myFaction.describeTo(target)).tooltip(TL.COMMAND_INVITE_CLICKTOJOIN.toString()) .command("/" + Conf.baseCommandAliases.get(0) + " join " + myFaction.getTag()); - message.send(you.getPlayer()); + 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), you.describeTo(myFaction)); + myFaction.msg(TL.COMMAND_INVITE_INVITED, fme.describeTo(myFaction, true), target.describeTo(myFaction)); } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java index b2de104f..5d492084 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdJoin.java @@ -79,6 +79,12 @@ public class CmdJoin extends FCommand { return; } + // Check for ban + if (!fme.isAdminBypassing() && faction.isBanned(fme)) { + fme.msg(TL.COMMAND_JOIN_BANNED, faction.getTag(fme)); + return; + } + // trigger the join event (cancellable) FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayers.getInstance().getByPlayer(me), faction, FPlayerJoinEvent.PlayerJoinReason.COMMAND); Bukkit.getServer().getPluginManager().callEvent(joinEvent); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java new file mode 100644 index 00000000..2060a43b --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnban.java @@ -0,0 +1,69 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.FPlayer; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.zcore.fperms.Access; +import com.massivecraft.factions.zcore.fperms.PermissableAction; +import com.massivecraft.factions.zcore.util.TL; + +public class CmdUnban extends FCommand { + + public CmdUnban() { + super(); + this.aliases.add("unban"); + + this.requiredArgs.add("target"); + + this.permission = Permission.BAN.node; + this.disableOnLock = true; + + senderMustBePlayer = true; + senderMustBeMember = false; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } + + @Override + public void perform() { + Access access = myFaction.getAccess(fme, PermissableAction.BAN); + if (access == Access.DENY) { + fme.msg(TL.GENERIC_NOPERMISSION, "ban"); + return; + } + + // Can the player set the home for this faction? + // Check for ALLOW access as well before we check for role. + // TODO: no more duplicate code :( + if (access != Access.ALLOW) { + if (!Permission.BAN.has(sender) && !(assertMinRole(Role.MODERATOR))) { + return; + } + } else { + if (!Permission.BAN.has(sender, true)) { + return; + } + } + + // Good on permission checks. Now lets just ban the player. + FPlayer target = argAsFPlayer(0); + if (target == null) { + return; // the above method sends a message if fails to find someone. + } + + if (!myFaction.isBanned(target)) { + fme.msg(TL.COMMAND_UNBAN_NOTBANNED, target.getName()); + return; + } + + myFaction.unban(target); + + myFaction.msg(TL.COMMAND_UNBAN_UNBANNED, fme.getName(), target.getName()); + target.msg(TL.COMMAND_UNBAN_TARGET, myFaction.getTag(target)); + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_UNBAN_DESCRIPTION; + } +} diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index f2985886..b1bc8c2e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -76,6 +76,9 @@ public class FCmdRoot extends FCommand { public CmdSetDefaultRole cmdSetDefaultRole = new CmdSetDefaultRole(); public CmdMapHeight cmdMapHeight = new CmdMapHeight(); public CmdClaimAt cmdClaimAt = new CmdClaimAt(); + public CmdBan cmdban = new CmdBan(); + public CmdUnban cmdUnban = new CmdUnban(); + public CmdBanlist cmdbanlist = new CmdBanlist(); public FCmdRoot() { super(); @@ -166,6 +169,9 @@ public class FCmdRoot extends FCommand { this.addSubCommand(this.cmdSetDefaultRole); this.addSubCommand(this.cmdMapHeight); this.addSubCommand(this.cmdClaimAt); + this.addSubCommand(this.cmdban); + this.addSubCommand(this.cmdUnban); + this.addSubCommand(this.cmdbanlist); if (P.p.isHookedPlayervaults()) { P.p.log("Found playervaults hook, adding /f vault and /f setmaxvault commands."); this.addSubCommand(new CmdSetMaxVaults()); diff --git a/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java b/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java index b3b9e474..a080a6a6 100644 --- a/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java +++ b/src/main/java/com/massivecraft/factions/event/FPlayerLeaveEvent.java @@ -10,7 +10,7 @@ public class FPlayerLeaveEvent extends FactionPlayerEvent implements Cancellable boolean cancelled = false; public enum PlayerLeaveReason { - KICKED, DISBAND, RESET, JOINOTHER, LEAVE + KICKED, DISBAND, RESET, JOINOTHER, LEAVE, BANNED } public FPlayerLeaveEvent(FPlayer p, Faction f, PlayerLeaveReason r) { diff --git a/src/main/java/com/massivecraft/factions/struct/BanInfo.java b/src/main/java/com/massivecraft/factions/struct/BanInfo.java new file mode 100644 index 00000000..365d7a31 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/struct/BanInfo.java @@ -0,0 +1,42 @@ +package com.massivecraft.factions.struct; + +public class BanInfo { + + // FPlayer IDs + private final String banner; + private final String banned; + private final long time; + + public BanInfo(String banner, String banned, long time) { + this.banner = banner; + this.banned = banned; + this.time = time; + } + + /** + * Get the FPlayer ID of the player who issued the ban. + * + * @return FPlayer ID. + */ + public String getBanner() { + return this.banner; + } + + /** + * Get the FPlayer ID of the player who got banned. + * + * @return FPlayer ID. + */ + public String getBanned() { + return banned; + } + + /** + * Get the server time when the ban was issued. + * + * @return system timestamp. + */ + public long getTime() { + return time; + } +} diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index 022af7ff..ee30e0fd 100644 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -13,6 +13,7 @@ public enum Permission { ANNOUNCE("announce"), AUTOCLAIM("autoclaim"), AUTO_LEAVE_BYPASS("autoleavebypass"), + BAN("ban"), BYPASS("bypass"), CHAT("chat"), CHATSPY("chatspy"), diff --git a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java index 9717fae6..7c3f357c 100644 --- a/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java +++ b/src/main/java/com/massivecraft/factions/zcore/fperms/PermissableAction.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.zcore.fperms; public enum PermissableAction { + BAN("ban"), BUILD("build"), DESTROY("destroy"), FROST_WALK("frostwalk"), 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 7993dcfa..5c105d00 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -4,6 +4,7 @@ import com.massivecraft.factions.*; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.iface.RelationParticipator; import com.massivecraft.factions.integration.Econ; +import com.massivecraft.factions.struct.BanInfo; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; @@ -50,6 +51,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { protected int maxVaults; protected Role defaultRole; protected Map> permissions = new HashMap<>(); + protected Set bans = new HashSet<>(); public HashMap> getAnnouncements() { return this.announcements; @@ -147,6 +149,34 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { return this.invites.contains(fplayer.getId()); } + public void ban(FPlayer target, FPlayer banner) { + BanInfo info = new BanInfo(banner.getId(), target.getId(), System.currentTimeMillis()); + this.bans.add(info); + } + + public void unban(FPlayer player) { + Iterator iter = bans.iterator(); + while (iter.hasNext()) { + if (iter.next().getBanned().equalsIgnoreCase(player.getId())) { + iter.remove(); + } + } + } + + public boolean isBanned(FPlayer player) { + for (BanInfo info : bans) { + if (info.getBanned().equalsIgnoreCase(player.getId())) { + return true; + } + } + + return false; + } + + public Set getBannedPlayers() { + return this.bans; + } + public boolean getOpen() { return open; } 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 2a373ee7..d673d0cc 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -75,6 +75,15 @@ public enum TL { COMMAND_AUTOHELP_HELPFOR("Help for command \""), + COMMAND_BAN_DESCRIPTION("Ban players from joining your Faction."), + COMMAND_BAN_TARGET("&cYou were banned from &7%1$s"), // banned player perspective + COMMAND_BAN_BANNED("&e%1$s &cbanned &7%2$s"), + + COMMAND_BANLIST_DESCRIPTION("View a Faction's ban list"), + COMMAND_BANLIST_HEADER("&6There are &c%d&6 bans for %s"), + COMMAND_BANLIST_ENTRY("&7%d. &c%s &r- &a%s &r- &e%s"), + COMMAND_BANLIST_NOFACTION("&4You are not in a Faction."), + COMMAND_BOOM_PEACEFULONLY("This command is only usable by factions which are specifically designated as peaceful."), COMMAND_BOOM_TOTOGGLE("to toggle explosions"), COMMAND_BOOM_FORTOGGLE("for toggling explosions"), @@ -244,6 +253,7 @@ public enum TL { COMMAND_INVITE_INVITED("%1$s invited %2$s to your faction."), COMMAND_INVITE_ALREADYMEMBER("%1$s is already a member of %2$s"), COMMAND_INVITE_DESCRIPTION("Invite a player to your faction"), + COMMAND_INVITE_BANNED("&7%1$s &cis banned from your Faction. Not sending an invite."), COMMAND_JOIN_CANNOTFORCE("You do not have permission to move other players into a faction."), COMMAND_JOIN_SYSTEMFACTION("Players may only join normal factions. This is a system faction."), @@ -261,6 +271,7 @@ public enum TL { COMMAND_JOIN_JOINEDLOG("%1$s joined the faction %2$s."), COMMAND_JOIN_MOVEDLOG("%1$s moved the player %2$s into the faction %3$s."), COMMAND_JOIN_DESCRIPTION("Join a faction"), + COMMAND_JOIN_BANNED("&cYou are banned from %1$s &c:("), COMMAND_KICK_CANDIDATES("Players you can kick: "), COMMAND_KICK_CLICKTOKICK("Click to kick "), @@ -534,6 +545,11 @@ public enum TL { COMMAND_TOP_LINE("%d. &6%s: &c%s"), // Rank. Faction: Value COMMAND_TOP_INVALID("Could not sort by %s. Try balance, online, members, power or land."), + COMMAND_UNBAN_DESCRIPTION("Unban someone from your Faction"), + COMMAND_UNBAN_NOTBANNED("&7%s &cisn't banned. Not doing anything."), + COMMAND_UNBAN_UNBANNED("&e%1$s &cunbanned &7%2$s"), + COMMAND_UNBAN_TARGET("&aYou were unbanned from &r%s"), + COMMAND_UNCLAIM_SAFEZONE_SUCCESS("Safe zone was unclaimed."), COMMAND_UNCLAIM_SAFEZONE_NOPERM("This is a safe zone. You lack permissions to unclaim."), COMMAND_UNCLAIM_WARZONE_SUCCESS("War zone was unclaimed."), diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java b/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java index 1fbdca43..c3a32269 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TagReplacer.java @@ -71,6 +71,7 @@ public enum TagReplacer { FACTION_SIZE(TagType.FACTION, "{members}"), FACTION_KILLS(TagType.FACTION, "{faction-kills}"), FACTION_DEATHS(TagType.FACTION, "{faction-deaths}"), + FACTION_BANCOUNT(TagType.FACTION, "{faction-bancount}"), /** * General variables, require no faction or player @@ -233,6 +234,8 @@ public enum TagReplacer { return String.valueOf(fac.getKills()); case FACTION_DEATHS: return String.valueOf(fac.getDeaths()); + case FACTION_BANCOUNT: + return String.valueOf(fac.getBannedPlayers().size()); } return null; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bc56e012..49e41974 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -244,6 +244,7 @@ show: - 'This faction is permanent, remaining even with no members.' # only shows if faction is permanent - 'Land value: {land-value} {land-refund}' - 'Balance: {balance}' + - 'Bans: {faction-bancount}' - 'Allies({allies}/{max-allies}): {allies-list} ' - 'Online: ({online}/{members}): {online-list}' - 'Offline: ({offline}/{members}): {offline-list}' @@ -372,6 +373,7 @@ help: # - {world}, {x}, {y}, {z} : Faction home variables. You don't need to use them all. # - {faction-kills} : # of kills the faction has # - {faction-deaths}: # of deaths the faction has +# - {faction-bancount} : # of bans the faction has # General variables. Can be used anywhere. # - {total-online} : Total # of players on the server # - {max-warps} : Max # of warps a faction can set diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 592aefc5..9875ed9a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -101,6 +101,7 @@ permissions: factions.togglealliancechat: true factions.vault: true factions.mapheight: true + factions.ban: true factions.admin: description: hand over your admin rights factions.admin.any: @@ -280,3 +281,5 @@ permissions: description: Set a faction's max vaults. factions.mapheight: description: Set your /f map height. + factions.ban: + description: Ban players from Factions \ No newline at end of file