From 3f1edf10964f83be0f0b97b1f4655b3a7a10f405 Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Thu, 15 Feb 2018 18:02:59 -0800 Subject: [PATCH] Allow players to set titles with colors. Adds #1036. factions.title.color permission which is included in factions.fullplayer permission subset. --- src/main/java/com/massivecraft/factions/FPlayer.java | 3 ++- src/main/java/com/massivecraft/factions/cmd/CmdTitle.java | 2 +- .../java/com/massivecraft/factions/struct/Permission.java | 1 + .../factions/zcore/persist/MemoryFPlayer.java | 8 +++++++- src/main/resources/plugin.yml | 7 +++++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index 3f0b77f9..b6a7d20b 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -9,6 +9,7 @@ import com.massivecraft.factions.util.WarmUpUtil; import mkremins.fanciful.FancyMessage; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.List; @@ -115,7 +116,7 @@ public interface FPlayer extends EconomyParticipator { public String getTitle(); - public void setTitle(String title); + public void setTitle(CommandSender sender, String title); public String getName(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java index 02b8da62..3bd1fb25 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java @@ -42,7 +42,7 @@ public class CmdTitle extends FCommand { return; } - you.setTitle(title); + you.setTitle(sender, title); // Inform myFaction.msg(TL.COMMAND_TITLE_CHANGED, fme.describeTo(myFaction, true), you.describeTo(myFaction, true)); diff --git a/src/main/java/com/massivecraft/factions/struct/Permission.java b/src/main/java/com/massivecraft/factions/struct/Permission.java index 3c324798..022af7ff 100644 --- a/src/main/java/com/massivecraft/factions/struct/Permission.java +++ b/src/main/java/com/massivecraft/factions/struct/Permission.java @@ -75,6 +75,7 @@ public enum Permission { STUCK("stuck"), TAG("tag"), TITLE("title"), + TITLE_COLOR("title.color"), TOGGLE_ALLIANCE_CHAT("togglealliancechat"), UNCLAIM("unclaim"), UNCLAIM_ALL("unclaimall"), 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 fdfa70dd..41c7c79d 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -19,6 +19,7 @@ import com.massivecraft.factions.util.WarmUpUtil; import com.massivecraft.factions.zcore.util.TL; import mkremins.fanciful.FancyMessage; import org.bukkit.*; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.HashSet; @@ -351,7 +352,12 @@ public abstract class MemoryFPlayer implements FPlayer { return this.hasFaction() ? title : TL.NOFACTION_PREFIX.toString(); } - public void setTitle(String title) { + public void setTitle(CommandSender sender, String title) { + // Check if the setter has it. + if (sender.hasPermission(Permission.TITLE_COLOR.node)) { + title = ChatColor.translateAlternateColorCodes('&', title); + } + this.title = title; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 55821901..592aefc5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -51,10 +51,11 @@ permissions: factions.show.bypassexempt: true factions.kit.fullplayer: default: true - description: Can also create new factions. + description: Can also create new factions and use title colors. children: factions.kit.halfplayer: true factions.create: true + factions.title.color: true factions.kit.halfplayer: description: Can do all but create factions. children: @@ -239,6 +240,8 @@ permissions: description: change the faction tag factions.title: description: set or remove a players title + factions.title.color: + description: set yours or other player's titles to be colored. factions.version: description: see the version of the plugin factions.unclaim: @@ -276,4 +279,4 @@ permissions: factions.setmaxvault: description: Set a faction's max vaults. factions.mapheight: - description: Set your /f map height. \ No newline at end of file + description: Set your /f map height.