From 90e57740a24c6679d17ee4e227cc1d10af373f3e Mon Sep 17 00:00:00 2001 From: Byteflux Date: Tue, 21 Oct 2014 18:08:26 -0700 Subject: [PATCH] Allow default prefix customization from lang file --- .../com/massivecraft/factions/scoreboards/FScoreboard.java | 6 ++++-- src/main/java/com/massivecraft/factions/zcore/util/TL.java | 3 ++- src/main/resources/lang.yml | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java b/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java index 55105f9f..25a09e1b 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/FScoreboard.java @@ -1,8 +1,8 @@ package com.massivecraft.factions.scoreboards; import com.massivecraft.factions.*; +import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -166,7 +166,9 @@ public class FScoreboard { // Update faction prefix if(P.p.getConfig().getBoolean("scoreboard.default-prefixes", false)) { - String prefix = faction.getRelationTo(this.fplayer).getColor() + "[" + faction.getTag().substring(0, Math.min(9, faction.getTag().length())) + "] " + ChatColor.RESET; + String prefix = TL.DEFAULT_PREFIX.toString(); + prefix = prefix.replace("{relationcolor}", faction.getRelationTo(this.fplayer).getColor().toString()); + prefix = prefix.replace("{faction}", faction.getTag().substring(0, Math.min("{faction}".length() + 16 - prefix.length(), faction.getTag().length()))); if (team.getPrefix() == null || !team.getPrefix().equals(prefix)) { team.setPrefix(prefix); } 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 4d345374..8f8825d0 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TL.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TL.java @@ -30,7 +30,8 @@ public enum TL { WARZONE_DESCRIPTION("warzone-description", "Not the safest place to be."), SAFEZONE("safezone", "&6Safezone"), SAFEZONE_DESCRIPTION("safezone-description", "Free from pvp and monsters."), - TOGGLE_SB("toggle-sb", "You now have scoreboards set to {value}"); + TOGGLE_SB("toggle-sb", "You now have scoreboards set to {value}"), + DEFAULT_PREFIX("default-prefix", "{relationcolor}[{faction}] &r"); private String path; private String def; diff --git a/src/main/resources/lang.yml b/src/main/resources/lang.yml index 8fa0cda5..e55daca1 100644 --- a/src/main/resources/lang.yml +++ b/src/main/resources/lang.yml @@ -9,4 +9,5 @@ warzone: "&4Warzone" warzone-description: "Not the safest place to be." safezone: "&6Safezone" safezone-description: "Free from pvp and monsters." -toggle-sb: "You now have scoreboards set to {value}" \ No newline at end of file +toggle-sb: "You now have scoreboards set to {value}" +default-prefix: "{relationcolor}[{faction}] &r" \ No newline at end of file