From dcbe4f706aca443c3f2ff2c9fe3e0884cb1ba7f4 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Tue, 14 Jul 2020 08:56:13 +0200 Subject: [PATCH] Jobs commands now works when level from or level until not specified Closes #826 --- .../jobs/Placeholders/Placeholder.java | 2 +- .../com/gamingmesh/jobs/PlayerManager.java | 3 ++- .../gamingmesh/jobs/config/ConfigManager.java | 15 +++++------ src/main/resources/jobConfig.yml | 25 +++++++++---------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index d30e6c45..7eff85b1 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -485,7 +485,7 @@ public class Placeholder { return j == null ? "" : j.getJob().getName(); case user_title_$1: if (j == null) - return ""; + return ""; Title title = Jobs.gettitleManager().getTitle(j.getLevel(), j.getJob().getName()); return title == null ? "" : title.getChatColor() + title.getName(); diff --git a/src/main/java/com/gamingmesh/jobs/PlayerManager.java b/src/main/java/com/gamingmesh/jobs/PlayerManager.java index 3370a980..3a390195 100644 --- a/src/main/java/com/gamingmesh/jobs/PlayerManager.java +++ b/src/main/java/com/gamingmesh/jobs/PlayerManager.java @@ -781,7 +781,8 @@ public class PlayerManager { return; for (JobCommands command : job.getCommands()) { - if (newLevel >= command.getLevelFrom() && newLevel <= command.getLevelUntil()) { + if ((command.getLevelFrom() == 0 && command.getLevelUntil() == 0) || newLevel >= command.getLevelFrom() + && newLevel <= command.getLevelUntil()) { for (String commandString : new ArrayList(command.getCommands())) { commandString = commandString.replace("[player]", player.getName()); commandString = commandString.replace("[oldlevel]", String.valueOf(oldLevel)); diff --git a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java index c383ea72..cdf60336 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ConfigManager.java @@ -160,17 +160,18 @@ public class ConfigManager { cfg.get(pt + ".rejoinCooldown", 10); cfg.addComment(pt + ".Gui", "GUI icon information when using GUI function"); - cfg.addComment(pt + ".Gui.Item", "Name of the material"); + cfg.addComment(pt + ".Gui.Item", "You can use the custom player head:", + "Item: player_head", + " CustomSkull: Notch", + "", + "Name of the material"); cfg.get(pt + ".Gui.Item", "LOG:2"); cfg.addComment(pt + ".Gui.slot", "Slot number to show the item in the specified row"); cfg.get(pt + ".Gui.slot", 5); cfg.addComment(pt + ".Gui.Enchantments", "Enchants of the item"); cfg.get(pt + ".Gui.Enchantments", Arrays.asList("DURABILITY:1")); - cfg.addComment(pt + ".maxDailyQuests", "You can use the custom player head:", - "Item: player_head", - " CustomSkull: Notch", - "", + cfg.addComment(pt + ".maxDailyQuests", "Defines maximum amount of daily quests player can have from THIS job", "This will not have effect on overall quest amount player will have"); cfg.get(pt + ".maxDailyQuests", 3); @@ -963,8 +964,8 @@ public class ConfigManager { else if (commandSection.isList("command")) commands.addAll(commandSection.getStringList("command")); - int levelFrom = commandSection.getInt("levelFrom"); - int levelUntil = commandSection.getInt("levelUntil"); + int levelFrom = commandSection.getInt("levelFrom", 0); + int levelUntil = commandSection.getInt("levelUntil", maxLevel); jobCommand.add(new JobCommands(commandKey.toLowerCase(), commands, levelFrom, levelUntil)); } } diff --git a/src/main/resources/jobConfig.yml b/src/main/resources/jobConfig.yml index caad842f..d397415f 100644 --- a/src/main/resources/jobConfig.yml +++ b/src/main/resources/jobConfig.yml @@ -81,19 +81,21 @@ Jobs: rejoinCooldown: 10 # GUI icon information when using GUI function Gui: - # name of the block + # name of the material + # You can use the custom player head: + # Item: player_head + # CustomSkull: Notch Item: LOG:2 - # If you want to use this instead of Item name. - # id of block - # Id: 17 - # data of block, usually its 0, but in example Diorite will have id of 1 and data of 3 - # Data: 2 - # enchants in the item + + # If you want to use ID instead of material names. + # id of block + # Id: 17 + # data of block, usually its 0, but in example Diorite will have id of 1 and data of 3 + # Data: 2 + + # enchants in the item Enchantments: - 'DURABILITY:1' - # You can use the custom player head: - # Item: player_head - # CustomSkull: Notch # Defines maximum amount of daily quests player can have from THIS job # This will not have effect on overall quest amount player will have maxDailyQuests: 3 @@ -2242,9 +2244,6 @@ Jobs: income: 5.0 points: 5 experience: 5.0 - PIG_ZOMBIE: - income: 5.0 - points: 5 experience: 5.0 SILVERFISH: income: 3.0