From 417b6f70f9c3597b9cfc71b92fc979331f474acc Mon Sep 17 00:00:00 2001 From: montlikadani Date: Wed, 6 Mar 2019 17:51:35 +0100 Subject: [PATCH] Option to broadcast skill message when a player reach level, #171 - Modify-chat set to default false, to ignore user-friendly posts. - DBManager registering fix at startup, #377 --- src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java | 2 +- src/main/java/com/gamingmesh/jobs/Jobs.java | 7 +++++-- src/main/java/com/gamingmesh/jobs/PlayerManager.java | 1 + .../com/gamingmesh/jobs/config/GeneralConfigManager.java | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index 9a2a926c..47a69042 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -364,7 +364,7 @@ public class ItemManager { public enum CMIPotionType { Awkward(373, 16, "Awkard Potion"), Fire_Resistance_1(373, 8195, "Fire Resistance Potion"), - Fire_Resistance_2(373, 8259, "Fire Resistance potion 2"), + Fire_Resistance_2(373, 8259, "Fire Resistance Potion 2"), Harming_1(373, 8204, "Harming Potion"), Harming_2(373, 8236, "Harming Potion 2"), Healing_1(373, 8197, "Healing Potion"), diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 83b72803..00d4707d 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -280,9 +280,11 @@ public class Jobs extends JavaPlugin { return reflections; } + public static void setDBManager() { + DBManager = new JobsManager(instance); + } + public static JobsManager getDBManager() { - if (DBManager == null) - DBManager = new JobsManager(instance); return DBManager; } @@ -834,6 +836,7 @@ public class Jobs extends JavaPlugin { setPermissionHandler(new PermissionHandler(this)); setPluginLogger(getLogger()); setJobsClassloader(); + setDBManager(); setLanguage(); setGUIManager(); setExplore(); diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index c24f5dfc..ca04cbd9 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -603,6 +603,7 @@ public class PlayerManager { message = message.replace("%jobname%", job.getChatColor() + job.getName()); for (String line : message.split("\n")) { if (Jobs.getGCManager().isBroadcastingSkillups()) + if (Jobs.getGCManager().BroadcastingSkillUpLevels.contains(oldLevel + 1) || Jobs.getGCManager().BroadcastingSkillUpLevels.contains(0)) Bukkit.getServer().broadcastMessage(line); else if (player != null) { if (Jobs.getGCManager().TitleChangeActionBar) diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index ca49697f..aa11ef8d 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -42,6 +42,7 @@ import com.gamingmesh.jobs.resources.jfep.Parser; public class GeneralConfigManager { private Jobs plugin; public List BroadcastingLevelUpLevels = new ArrayList<>(); + public List BroadcastingSkillUpLevels = new ArrayList<>(); protected Locale locale; protected int savePeriod; protected boolean economyAsync; @@ -486,6 +487,8 @@ public class GeneralConfigManager { c.addComment("broadcast.on-skill-up.use", "Do all players get a message when someone goes up a skill level?"); isBroadcastingSkillups = c.get("broadcast.on-skill-up.use", false); + c.addComment("broadcast.on-skill-up.levels", "For what skill levels you want to broadcast message? Keep it at 0 if you want for all of them"); + BroadcastingSkillUpLevels = c.getIntList("broadcast.on-skill-up.levels", Arrays.asList(0)); c.addComment("broadcast.on-level-up.use", "Do all players get a message when someone goes up a level?"); isBroadcastingLevelups = c.get("broadcast.on-level-up.use", false); @@ -530,7 +533,7 @@ public class GeneralConfigManager { payItemDurabilityLoss = c.get("enable-pay-when-item-durability-loss", true); c.addComment("modify-chat", "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 = c.get("modify-chat.use", true); + modifyChat = c.get("modify-chat.use", false); modifyChatPrefix = c.get("modify-chat.prefix", "&c["); modifyChatSuffix = c.get("modify-chat.suffix", "&c]&r "); modifyChatSeparator = c.get("modify-chat.separator", " ");