From 4484eae5b825f00e71fcb760c02fce41d9f57cc1 Mon Sep 17 00:00:00 2001 From: vemacs Date: Wed, 25 Feb 2015 07:38:03 -0700 Subject: [PATCH 1/3] add API to ignore alliance chat --- src/main/java/com/massivecraft/factions/FPlayer.java | 4 ++++ .../factions/listeners/FactionsChatListener.java | 2 +- .../factions/zcore/persist/MemoryFPlayer.java | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index 83b58c86..d59e6c2c 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -66,6 +66,10 @@ public interface FPlayer extends EconomyParticipator { public ChatMode getChatMode(); + public void setIgnoreAllianceChat(boolean ignore); + + public boolean isIgnoreAllianceChat(); + public void setSpyingChat(boolean chatSpying); public boolean isSpyingChat(); diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java index 029deaff..bb1ea025 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -58,7 +58,7 @@ public class FactionsChatListener implements Listener { //Send to all our allies for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) { - if (myFaction.getRelationTo(fplayer) == Relation.ALLY) { + if (myFaction.getRelationTo(fplayer) == Relation.ALLY && !fplayer.isIgnoreAllianceChat()) { fplayer.sendMessage(message); } 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 40f69858..b8b5cd74 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -64,6 +64,9 @@ public abstract class MemoryFPlayer implements FPlayer { // FIELD: chatMode protected ChatMode chatMode; + // FIELD: ignoreAllianceChat + protected boolean ignoreAllianceChat = false; + protected String id; protected String name; @@ -199,6 +202,14 @@ public abstract class MemoryFPlayer implements FPlayer { return chatMode; } + public void setIgnoreAllianceChat(boolean ignore) { + this.ignoreAllianceChat = ignore; + } + + public boolean isIgnoreAllianceChat() { + return ignoreAllianceChat; + } + public void setSpyingChat(boolean chatSpying) { this.spyingChat = chatSpying; } From 7fd590fc753948cf561b053900eaa102b2078510 Mon Sep 17 00:00:00 2001 From: vemacs Date: Wed, 4 Mar 2015 23:55:46 -0500 Subject: [PATCH 2/3] Add ToggleAllianceChat command (sorry I couldn't think of a shorter name, but this is extremely useful for YouTubers) --- .../massivecraft/factions/cmd/CmdHelp.java | 1 + .../factions/cmd/CmdToggleAllianceChat.java | 46 +++++++++++++++++++ .../massivecraft/factions/cmd/FCmdRoot.java | 2 + .../factions/struct/Permission.java | 1 + .../massivecraft/factions/zcore/util/TL.java | 6 ++- 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java index 6a2f5f2b..cc888100 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdHelp.java @@ -66,6 +66,7 @@ public class CmdHelp extends FCommand { pageLines.add(p.cmdBase.cmdJoin.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdLeave.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdChat.getUseageTemplate(true)); + pageLines.add(p.cmdBase.cmdToggleAllianceChat.getUseageTemplate(true)); pageLines.add(p.cmdBase.cmdHome.getUseageTemplate(true)); pageLines.add(p.txt.parse(TL.COMMAND_HELP_NEXTCREATE.toString())); helpPages.add(pageLines); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java b/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java new file mode 100644 index 00000000..a242448d --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdToggleAllianceChat.java @@ -0,0 +1,46 @@ +package com.massivecraft.factions.cmd; + +import com.massivecraft.factions.Conf; +import com.massivecraft.factions.struct.Permission; +import com.massivecraft.factions.zcore.util.TL; + +public class CmdToggleAllianceChat extends FCommand { + public CmdToggleAllianceChat() { + super(); + this.aliases.add("tac"); + this.aliases.add("togglealliancechat"); + + this.disableOnLock = false; + + this.permission = Permission.TOGGLE_ALLIANCE_CHAT.node; + this.disableOnLock = false; + + senderMustBePlayer = true; + senderMustBeMember = true; + senderMustBeModerator = false; + senderMustBeAdmin = false; + } + + @Override + public TL getUsageTranslation() { + return TL.COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION; + } + + @Override + public void perform() { + if (!Conf.factionOnlyChat) { + msg(TL.COMMAND_CHAT_DISABLED.toString()); + return; + } + + boolean ignoreAllianceChat = fme.isIgnoreAllianceChat(); + + if (ignoreAllianceChat) { + msg(TL.COMMAND_TOGGLEALLIANCECHAT_UNIGNORE); + fme.setIgnoreAllianceChat(false); + } else { + msg(TL.COMMAND_TOGGLEALLIANCECHAT_IGNORE); + fme.setIgnoreAllianceChat(true); + } + } +} diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index a16c4863..3f118ec1 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -49,6 +49,7 @@ public class FCmdRoot extends FCommand { public CmdStatus cmdStatus = new CmdStatus(); public CmdTag cmdTag = new CmdTag(); public CmdTitle cmdTitle = new CmdTitle(); + public CmdToggleAllianceChat cmdToggleAllianceChat = new CmdToggleAllianceChat(); public CmdUnclaim cmdUnclaim = new CmdUnclaim(); public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall(); public CmdVersion cmdVersion = new CmdVersion(); @@ -92,6 +93,7 @@ public class FCmdRoot extends FCommand { this.addSubCommand(this.cmdBoom); this.addSubCommand(this.cmdBypass); this.addSubCommand(this.cmdChat); + this.addSubCommand(this.cmdToggleAllianceChat); this.addSubCommand(this.cmdChatSpy); this.addSubCommand(this.cmdClaim); this.addSubCommand(this.cmdConfig); diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index 2b87b515..297c2a73 100644 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -67,6 +67,7 @@ public enum Permission { STATUS("status"), TAG("tag"), TITLE("title"), + TOGGLE_ALLIANCE_CHAT("togglealliancechat"), UNCLAIM("unclaim"), UNCLAIM_ALL("unclaimall"), VERSION("version"), 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 a0627b64..6c8b24cc 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -79,7 +79,7 @@ public enum TL { COMMAND_BYPASS_DISABLELOG(" has DISABLED admin bypass mode."), COMMAND_BYPASS_DESCRIPTION("Enable admin bypass mode"), - COMMAND_CHAT_DISABLED("The built in chat chat channels are disabled on this server."), + COMMAND_CHAT_DISABLED("The built in chat channels are disabled on this server."), COMMAND_CHAT_INVALIDMODE("Unrecognised chat mode. Please enter either 'a','f' or 'p'"), COMMAND_CHAT_DESCRIPTION("Change chat mode"), @@ -469,6 +469,10 @@ public enum TL { COMMAND_TITLE_CHANGED("%1$s changed a title: %2$s"), COMMAND_TITLE_DESCRIPTION("Set or remove a players title"), + COMMAND_TOGGLEALLIANCECHAT_DESCRIPTION("Toggles whether or not you will see alliance chat"), + COMMAND_TOGGLEALLIANCECHAT_IGNORE("Alliance chat is now ignored"), + COMMAND_TOGGLEALLIANCECHAT_UNIGNORE("Alliance chat is no longer ignored"), + COMMAND_TOP_DESCRIPTION("Sort Factions to see the top of some criteria."), COMMAND_TOP_TOP("Top Factions by %s. Page %d/%d"), COMMAND_TOP_LINE("%d. &6%s: &c%s"), // Rank. Faction: Value From 1ea6dbe12d6df047ba7cd09ecad4e9c4d8ea7be5 Mon Sep 17 00:00:00 2001 From: vemacs Date: Thu, 5 Mar 2015 00:16:57 -0500 Subject: [PATCH 3/3] Fix one type checking warning --- src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java index 3f118ec1..8d4b68a9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCmdRoot.java @@ -70,7 +70,7 @@ public class FCmdRoot extends FCommand { public FCmdRoot() { super(); this.aliases.addAll(Conf.baseCommandAliases); - this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas + this.aliases.removeAll(Collections.singletonList(null)); // remove any nulls from extra commas this.allowNoSlashAccess = Conf.allowNoSlashCommand; //this.requiredArgs.add("");