From 4e17d43c910a8c975b023bfaeecad3bcf24258bb Mon Sep 17 00:00:00 2001 From: Nick Porillo Date: Tue, 12 May 2015 23:25:28 -0400 Subject: [PATCH] Add configurable faction enter/leave message --- .../java/com/massivecraft/factions/FPlayer.java | 2 +- .../factions/listeners/FactionsPlayerListener.java | 2 +- .../factions/zcore/persist/MemoryFPlayer.java | 14 ++++++-------- .../com/massivecraft/factions/zcore/util/TL.java | 1 + src/main/resources/config.yml | 2 ++ 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index d59e6c2c..e6277ffc 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -191,7 +191,7 @@ public interface FPlayer extends EconomyParticipator { public boolean isInEnemyTerritory(); - public void sendFactionHereMessage(); + public void sendFactionHereMessage(Faction from); /** * Check if the scoreboard should be shown. Simple method to be used by above method. diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 4524259f..34c4ff60 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -166,7 +166,7 @@ public class FactionsPlayerListener implements Listener { String ownersTo = myFaction.getOwnerListString(to); if (changedFaction) { - me.sendFactionHereMessage(); + me.sendFactionHereMessage(factionFrom); if (Conf.ownedAreasEnabled && Conf.ownedMessageOnBorder && myFaction == factionTo && !ownersTo.isEmpty()) { me.sendMessage(TL.GENERIC_OWNERS.format(ownersTo)); } 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 8bddbe81..7431bfd0 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -559,17 +559,15 @@ public abstract class MemoryFPlayer implements FPlayer { return Board.getInstance().getFactionAt(new FLocation(this)).getRelationTo(this).isEnemy(); } - public void sendFactionHereMessage() { + public void sendFactionHereMessage(Faction from) { Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt()); + boolean showChat = true; if (shouldShowScoreboard(toShow)) { - // Shows them the scoreboard instead of sending a message in chat. Will disappear after a few seconds. FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow)); - } else { - String msg = toShow.getTag(this); - if (toShow.getDescription().length() > 0) { - msg += " - " + toShow.getDescription(); - } - this.sendMessage(msg); + showChat = P.p.getConfig().getBoolean("scoreboard.also-send-chat", true); + } + if (showChat) { + this.sendMessage(P.p.txt.parse(TL.FACTION_LEAVE.format(from.getTag(this), toShow.getTag(this)))); } } 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 1caafb10..454357dc 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -694,6 +694,7 @@ public enum TL { SAFEZONE("safezone", "&6Safezone"), SAFEZONE_DESCRIPTION("safezone-description", "Free from pvp and monsters."), TOGGLE_SB("toggle-sb", "You now have scoreboards set to {value}"), + FACTION_LEAVE("faction-leave", "Leaving %1$s, Entering %2$s"), DEFAULT_PREFIX("default-prefix", "{relationcolor}[{faction}] &r"), FACTION_LOGIN("faction-login", "&e%1$s &9logged in."), FACTION_LOGOUT("faction-logout", "&e%1$s &9logged out.."), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e1a1490a..a2eaee49 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -96,6 +96,8 @@ tooltips: # Use &0-9a-f for colors and include messages in "quotes" scoreboard: +# send faction change message as well when scoreboard is up? + also-send-chat: true # How long do we want scoreboards to stay if set temporarily. expiration: 7