From 1e2a6b34b47491af88e6002cd851ee6120ad0c74 Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Fri, 16 Mar 2018 10:08:19 -0700 Subject: [PATCH] Send titles when entering faction territory. Allows users to pick which, if any, or all, ways of sending faction enter messages from: scoreboard, chat, and titles. Adds new config.yml options and lang messages. --- .../factions/zcore/persist/MemoryFPlayer.java | 17 +++++++++++++++++ .../massivecraft/factions/zcore/util/TL.java | 2 ++ src/main/resources/config.yml | 12 ++++++++++++ 3 files changed, 31 insertions(+) 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 46e8e481..1d15b7af 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -594,7 +594,24 @@ public abstract class MemoryFPlayer implements FPlayer { public void sendFactionHereMessage(Faction from) { Faction toShow = Board.getInstance().getFactionAt(getLastStoodAt()); + boolean showTitle = P.p.getConfig().getBoolean("enter-titles.enabled", true); boolean showChat = true; + Player player = getPlayer(); + + if (showTitle && player != null) { + int in = P.p.getConfig().getInt("enter-titles.fade-in", 10); + int stay = P.p.getConfig().getInt("enter-titles.stay", 70); + int out = P.p.getConfig().getInt("enter-titles.fade-out", 20); + String title = TL.FACTION_ENTER_TITLE.format(this); + String sub = TL.FACTION_ENTER_SUBTITLE.format(toShow.getTag(this)); + + // We send null instead of empty because Spigot won't touch the title if it's null, but clears if empty. + // We're just trying to be as unintrusive as possible. + player.sendTitle(title.isEmpty() ? null : title, sub.isEmpty() ? null : sub, in, stay, out); + + showChat = P.p.getConfig().getBoolean("enter-titles.also-show-chat", false); + } + if (showInfoBoard(toShow)) { FScoreboard.get(this).setTemporarySidebar(new FInfoSidebar(toShow)); showChat = P.p.getConfig().getBoolean("scoreboard.also-send-chat", 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 19017fb2..058d3fc7 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -772,6 +772,8 @@ public enum TL { 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"), + FACTION_ENTER_TITLE("faction-enter-title", ""), + FACTION_ENTER_SUBTITLE("faction-enter-subtitle", "%s"), FACTIONS_ANNOUNCEMENT_TOP("faction-announcement-top", "&d--Unread Faction Announcements--"), FACTIONS_ANNOUNCEMENT_BOTTOM("faction-announcement-bottom", "&d--Unread Faction Announcements--"), DEFAULT_PREFIX("default-prefix", "{relationcolor}[{faction}] &r"), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 48303d9f..4291cf59 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -72,6 +72,18 @@ fly-falldamage-cooldown: 3 # http://i.gyazo.com/6a1a31222e58a5d60ff341c13f6a8404.gif disable-pistons-in-territory: false +# Should we send titles when players enter Factions? +# This is the same as finfo.titles and can be shown in conjunction with scoreboard and chat if necessary. +# If you only want to show titles when entering territory, +# leave this true and set scoreboard.finfo.titles and scoreboard.alsosendchat to false. +enter-titles: + enabled: true + fade-in: 10 + stay: 70 + fade-out: 20 + also-show-chat: false + + # ToolTips # This section is to configure tooltips for things like /f list tooltips: