From 7b049fe6707e086dc5842bbfe00cd204dbaf23cc Mon Sep 17 00:00:00 2001 From: Zrips Date: Mon, 11 Jan 2016 17:48:56 +0200 Subject: [PATCH] title prefix/suffix/seperator --- .../jobs/config/JobsConfiguration.java | 29 +++++++++++++++++-- com/gamingmesh/jobs/container/JobsPlayer.java | 4 ++- .../jobs/listeners/JobsListener.java | 2 +- plugin.yml | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/com/gamingmesh/jobs/config/JobsConfiguration.java b/com/gamingmesh/jobs/config/JobsConfiguration.java index 5fb42d2f..b67b2bb7 100644 --- a/com/gamingmesh/jobs/config/JobsConfiguration.java +++ b/com/gamingmesh/jobs/config/JobsConfiguration.java @@ -68,6 +68,9 @@ public class JobsConfiguration { protected int maxJobs; protected boolean payNearSpawner; protected boolean modifyChat; + public String modifyChatPrefix; + public String modifyChatSuffix; + public String modifyChatSeparator; protected int economyBatchDelay; protected boolean saveOnDisconnect; public boolean LocalOfflinePlayersData; @@ -138,7 +141,7 @@ public class JobsConfiguration { public boolean isUseBreederFinder() { return this.useBreederFinder; } - + public void setTntFinder(boolean state) { this.useTnTFinder = state; } @@ -146,7 +149,7 @@ public class JobsConfiguration { public boolean isUseTntFinder() { return this.useTnTFinder; } - + /** * Get how often in minutes to save job information * @return how often in minutes to save job information @@ -267,6 +270,18 @@ public class JobsConfiguration { return modifyChat; } + public String getModifyChatPrefix() { + return modifyChatPrefix; + } + + public String getModifyChatSuffix() { + return modifyChatSuffix; + } + + public String getModifyChatSeparator() { + return modifyChatSeparator; + } + public synchronized int getEconomyBatchDelay() { return economyBatchDelay; } @@ -453,6 +468,10 @@ public class JobsConfiguration { "Modifys chat to add chat titles. If you're using a chat manager, you may add the tag {jobs} to your chat format and disable this."); modifyChat = getBoolean("modify-chat", true, config, writer); + modifyChatPrefix = getString("modify-chat-prefix", "&c[", config, writer, true); + modifyChatSuffix = getString("modify-chat-suffix", "&c]", config, writer, true); + modifyChatSeparator = getString("modify-chat-seperator", " ", config, writer, true); + writer.addComment("UseCustomNames", "Do you want to use custom item/block/mob/enchant/color names", "With this set to true names like Stone:1 will be translated to Granite", "Name list is in ItemList.yml file"); UseCustomNames = getBoolean("UseCustomNames", true, config, writer); @@ -1124,6 +1143,12 @@ public class JobsConfiguration { return config.getString(path); } + private String getString(String path, String boo, YamlConfiguration config, CommentedYamlConfiguration writer, boolean colorize) { + config.addDefault(path, boo); + copySetting(config, writer, path); + return org.bukkit.ChatColor.translateAlternateColorCodes('&', config.getString(path)); + } + private Double getDouble(String path, Double boo, YamlConfiguration config, CommentedYamlConfiguration writer) { config.addDefault(path, boo); copySetting(config, writer, path); diff --git a/com/gamingmesh/jobs/container/JobsPlayer.java b/com/gamingmesh/jobs/container/JobsPlayer.java index ea93e815..801542b7 100644 --- a/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/com/gamingmesh/jobs/container/JobsPlayer.java @@ -444,7 +444,7 @@ public class JobsPlayer { if (method.equals(DisplayMethod.NONE)) continue; if (gotTitle) { - builder.append(" "); + builder.append(ConfigManager.getJobsConfiguration().getModifyChatSeparator()); gotTitle = false; } Title title = ConfigManager.getJobsConfiguration().getTitleForLevel(prog.getLevel(), prog.getJob().getName()); @@ -513,6 +513,8 @@ public class JobsPlayer { } honorific = builder.toString().trim(); + honorific = ConfigManager.getJobsConfiguration().getModifyChatPrefix() + honorific + ConfigManager.getJobsConfiguration().getModifyChatSuffix(); + } /** diff --git a/com/gamingmesh/jobs/listeners/JobsListener.java b/com/gamingmesh/jobs/listeners/JobsListener.java index c2662f5f..574ce4af 100644 --- a/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/com/gamingmesh/jobs/listeners/JobsListener.java @@ -406,7 +406,7 @@ public class JobsListener implements Listener { Player player = event.getPlayer(); JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); - String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : ""; + String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : ""; if (honorific.equalsIgnoreCase(" ")) honorific = ""; diff --git a/plugin.yml b/plugin.yml index f27ead8c..43db4b2f 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: Jobs description: Jobs Plugin for the BukkitAPI main: com.gamingmesh.jobs.JobsPlugin -version: 2.59.1 +version: 2.60.0 author: phrstbrn softdepend: [Vault, CoreProtect, MythicMobs, McMMO] commands: