From edb943be1144df6c1320f7a51bee57b72cef5d45 Mon Sep 17 00:00:00 2001 From: Zrips Date: Tue, 25 Dec 2018 12:52:38 +0200 Subject: [PATCH] Initial support for built in placeholders for PlaceHolderAPI Couple base placeholders --- pom.xml | 15 +- .../gamingmesh/jobs/CMILib/ItemManager.java | 8 +- src/main/java/com/gamingmesh/jobs/Jobs.java | 33 ++ .../jobs/Placeholders/ChatFilterRule.java | 125 +++++ .../jobs/Placeholders/Placeholder.java | 490 ++++++++++++++++++ .../jobs/Placeholders/PlaceholderAPIHook.java | 28 + .../java/com/gamingmesh/jobs/Signs/Sign.java | 122 ++--- .../jobs/config/LanguageManager.java | 2 + .../gamingmesh/jobs/container/JobsPlayer.java | 2 + src/main/resources/plugin.yml | 2 +- 10 files changed, 759 insertions(+), 68 deletions(-) create mode 100644 src/main/java/com/gamingmesh/jobs/Placeholders/ChatFilterRule.java create mode 100644 src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java create mode 100644 src/main/java/com/gamingmesh/jobs/Placeholders/PlaceholderAPIHook.java diff --git a/pom.xml b/pom.xml index 8998be96..00ecb5df 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 Jobs jobs - 4.9.4 + 4.9.5 Jobs http://maven.apache.org @@ -105,6 +105,12 @@ + + me.clip + placeholderapi + 2.0.6 + provided + @@ -131,7 +137,12 @@ papermc https://papermc.io/repo/repository/maven-public/ - + + + + placeholderapi + http://repo.extendedclip.com/content/repositories/placeholderapi/ + diff --git a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java index c24f5cf2..5fd5851d 100644 --- a/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java +++ b/src/main/java/com/gamingmesh/jobs/CMILib/ItemManager.java @@ -662,7 +662,7 @@ public class ItemManager { BLACK_CARPET(171, 15, 6056, "Black Carpet"), BLACK_CONCRETE(251, 15, 13338, "Black Concrete", "CONCRETE"), BLACK_CONCRETE_POWDER(252, 15, 16150, "Black Concrete Powder", "CONCRETE_POWDER"), - BLACK_DYE(351, -1, 26753, "Black Dye"), + BLACK_DYE(-1, -1, 26753, "Black Dye"), BLACK_GLAZED_TERRACOTTA(250, 0, 29678, "Black Glazed Terracotta"), BLACK_SHULKER_BOX(234, 0, 24076, "Black Shulker Box"), BLACK_STAINED_GLASS(95, 15, 13941, "Black Stained Glass"), @@ -678,7 +678,7 @@ public class ItemManager { BLUE_CARPET(171, 11, 13292, "Blue Carpet"), BLUE_CONCRETE(251, 11, 18756, "Blue Concrete"), BLUE_CONCRETE_POWDER(252, 11, 17773, "Blue Concrete Powder"), - BLUE_DYE(351, -1, 12344, "Blue Dye"), + BLUE_DYE(-1, -1, 12344, "Blue Dye"), BLUE_GLAZED_TERRACOTTA(246, 0, 23823, "Blue Glazed Terracotta"), BLUE_ICE(-1, -1, 22449, "Blue Ice"), BLUE_ORCHID(38, 1, 13432, "Blue Orchid"), @@ -710,7 +710,7 @@ public class ItemManager { BROWN_CARPET(171, 12, 23352, "Brown Carpet"), BROWN_CONCRETE(251, 12, 19006, "Brown Concrete"), BROWN_CONCRETE_POWDER(252, 12, 21485, "Brown Concrete Powder"), - BROWN_DYE(351, -1, 4237, "Brown Dye"), + BROWN_DYE(-1, -1, 4237, "Brown Dye"), BROWN_GLAZED_TERRACOTTA(247, 0, 5655, "Brown Glazed Terracotta"), BROWN_MUSHROOM(39, 0, 9665, "Brown Mushroom"), BROWN_MUSHROOM_BLOCK(99, 0, 6291, "Brown Mushroom Block", "HUGE_MUSHROOM_1"), @@ -1492,7 +1492,7 @@ public class ItemManager { WHITE_CARPET(171, 0, 15117, "White Carpet"), WHITE_CONCRETE(251, 0, 6281, "White Concrete"), WHITE_CONCRETE_POWDER(252, 0, 10363, "White Concrete Powder"), - WHITE_DYE(351, -1, 5276, "White Dye"), + WHITE_DYE(-1, -1, 5276, "White Dye"), WHITE_GLAZED_TERRACOTTA(235, 0, 11326, "White Glazed Terracotta"), WHITE_SHULKER_BOX(219, 0, 31750, "White Shulker Box"), WHITE_STAINED_GLASS(95, 0, 31190, "White Stained Glass"), diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index a0f637fb..c034ce0b 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -49,6 +49,8 @@ import com.gamingmesh.jobs.MyPet.MyPetManager; import com.gamingmesh.jobs.MythicMobs.MythicMobInterface; import com.gamingmesh.jobs.MythicMobs.MythicMobs2; import com.gamingmesh.jobs.MythicMobs.MythicMobs4; +import com.gamingmesh.jobs.Placeholders.Placeholder; +import com.gamingmesh.jobs.Placeholders.PlaceholderAPIHook; import com.gamingmesh.jobs.Signs.SignUtil; import com.gamingmesh.jobs.WorldGuard.WorldGuardManager; import com.gamingmesh.jobs.api.JobsExpGainEvent; @@ -190,6 +192,23 @@ public class Jobs extends JavaPlugin { return myPetManager; } + private Placeholder Placeholder; + private boolean PlaceholderAPIEnabled = false; + + public Placeholder getPlaceholderAPIManager() { + if (Placeholder == null) + Placeholder = new Placeholder(this); + return Placeholder; + } + + private boolean setupPlaceHolderAPI() { + if (!getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) + return false; + if ((new PlaceholderAPIHook(this)).hook()) + Bukkit.getConsoleSender().sendMessage("[Jobs] PlaceholderAPI hooked."); + return true; + } + public static WorldGuardManager getWorldGuardManager() { return worldGuardManager; } @@ -765,6 +784,16 @@ public class Jobs extends JavaPlugin { e.printStackTrace(); return; } + try { + if (setupPlaceHolderAPI()) { + consoleMsg("PlaceholderAPI was found - Enabling capabilities."); + PlaceholderAPIEnabled = true; + } else { + consoleMsg("PlaceholderAPI nope"); + } + } catch (Exception e) { + e.printStackTrace(); + } try { @@ -1330,4 +1359,8 @@ public class Jobs extends JavaPlugin { if (pageCount != 0) rm.show(sender); } + + public boolean isPlaceholderAPIEnabled() { + return PlaceholderAPIEnabled; + } } diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/ChatFilterRule.java b/src/main/java/com/gamingmesh/jobs/Placeholders/ChatFilterRule.java new file mode 100644 index 00000000..3017a373 --- /dev/null +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/ChatFilterRule.java @@ -0,0 +1,125 @@ +package com.gamingmesh.jobs.Placeholders; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ChatFilterRule { + public enum ChatFilterBlockType { + All(0), Others(1), None(2); + + private int id; + + ChatFilterBlockType(int id) { + this.id = id; + } + + public int getId() { + return id; + } + } + private String replaceWith; + private ChatFilterBlockType blockType; + private String ruleName; + private List pattern = new ArrayList(); + private String messageToStaff; + private List commands = new ArrayList(); + private String group; + + public ChatFilterRule(String ruleName, String group, List list, String replaceWith, ChatFilterBlockType blockType, String messageToStaff, List commands) { + this.group = group; + this.ruleName = ruleName; + this.commands = commands; + setPattern(list); + this.messageToStaff = messageToStaff; + this.replaceWith = replaceWith; + this.blockType = blockType; + } + + public ChatFilterRule(String ruleName, List list) { + this.ruleName = ruleName; + setPattern(list); + this.blockType = ChatFilterBlockType.None; + } + + public ChatFilterRule() { + } + + public List getPattern() { + return pattern; + } + + public ChatFilterRule setPattern(String list) { + setPattern(Arrays.asList(list)); + return this; + } + + public void setPattern(List list) { + pattern.clear(); + for (String one : list) { + pattern.add(Pattern.compile(one)); + } + } + + public String getReplaceWith() { + return replaceWith; + } + + public void setReplaceWith(String replaceWith) { + this.replaceWith = replaceWith; + } + + public ChatFilterBlockType getBlockType() { + return blockType; + } + + public void setBlockType(ChatFilterBlockType blockType) { + this.blockType = blockType; + } + + public String getRuleName() { + return ruleName; + } + + public void setRuleName(String ruleName) { + this.ruleName = ruleName; + } + + public Matcher getMatcher(String msg) { + Matcher matcher = null; + for (Pattern one : pattern) { + if (one.matcher(msg).find()) { + matcher = one.matcher(msg); + break; + } + } + return matcher; + } + + public String getMessageToStaff() { + return messageToStaff; + } + + public void setMessageToStaff(String messageToStaff) { + this.messageToStaff = messageToStaff; + } + + public List getCommands() { + return commands; + } + + public void setCommands(List commands) { + this.commands = commands; + } + + public String getGroup() { + return group; + } + + public void setGroup(String group) { + this.group = group; + } + +} diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java new file mode 100644 index 00000000..d129adc4 --- /dev/null +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -0,0 +1,490 @@ +package com.gamingmesh.jobs.Placeholders; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.container.CurrencyType; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobProgression; +import com.gamingmesh.jobs.container.JobsPlayer; + +public class Placeholder { + + private Jobs plugin; + Pattern placeholderPatern = Pattern.compile("(%)([^\"^%]*)(%)"); + + public Placeholder(Jobs plugin) { + this.plugin = plugin; + } + + static String pref = "jobsr"; + private static ChatFilterRule numericalRule = new ChatFilterRule().setPattern("(\\$\\d)"); + + public enum JobsPlaceHolders { + user_id, + user_bstandcount, + user_maxbstandcount, + user_furncount, + user_maxfurncount, + user_doneq, + user_totallevels, + user_displayhonorific, + user_joinedjobcount, + maxjobs, + name_$1("number/name"), + shortname_$1("number/name"), + chatcolor_$1("number/name"), + description_$1("number/name"), + maxdailyq_$1("number/name"), + maxlvl_$1("number/name"), + maxviplvl_$1("number/name"), + totalplayers_$1("number/name"), + maxslots_$1("number/name"), + user_boost_$1_$2("jobname/number", "money/exp/points"), + user_isin_$1("jobname/number"), + user_canjoin_$1("jobname/number"); + + private String[] vars; + private List groups = new ArrayList(); + private ChatFilterRule rule = null; + private boolean hidden = false; + + JobsPlaceHolders() { + } + + JobsPlaceHolders(String... vars) { + Matcher matcher = numericalRule.getMatcher(this.toString()); + if (matcher != null) { + rule = new ChatFilterRule(); + List ls = new ArrayList(); + ls.add("(%" + pref + "_)" + this.toString().replaceAll("\\$\\d", "([^\"^%]*)") + "(%)"); +// For MVdWPlaceholderAPI +// ls.add("(\\{" + pref + this.toString().replaceAll("\\$\\d", "([^\"^%]*)" + "(\\})")); + rule.setPattern(ls); + while (matcher.find()) { + try { + int id = Integer.parseInt(matcher.group(1).substring(1)); + groups.add(id); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + this.vars = vars; + this.hidden = false; + } + + public static JobsPlaceHolders getByName(String name) { + String original = name; +// name = name.replace("_", ""); + for (JobsPlaceHolders one : JobsPlaceHolders.values()) { + if (one.isComplex()) + continue; +// String n = one.name().replace("_", ""); + if (one.name().equalsIgnoreCase(name)) { + return one; + } + } + name = pref + name; + for (JobsPlaceHolders one : JobsPlaceHolders.values()) { + if (one.isComplex()) + continue; + String n = one.name(); + if (n.equalsIgnoreCase(name)) { + return one; + } + } + name = "%" + pref + "_" + original + "%"; + for (JobsPlaceHolders one : JobsPlaceHolders.values()) { + if (!one.isComplex()) + continue; + if (!one.getComplexRegexMatchers(name).isEmpty()) { + return one; + } + } +// For MVdWPlaceholderAPI +// if (Jobs.getInstance().isMVdWPlaceholderAPIEnabled() && original.startsWith(pref+"_")) { +// String t = "{" + original + "}"; +// for (JobsPlaceHolders one : JobsPlaceHolders.values()) { +// if (!one.isComplex()) +// continue; +// if (!one.getComplexRegexMatchers(t).isEmpty()) { +// return one; +// } +// } +// } + return null; + } + + public static JobsPlaceHolders getByNameExact(String name) { + name = name.toLowerCase(); + for (JobsPlaceHolders one : JobsPlaceHolders.values()) { + if (one.isComplex()) { + if (!one.getComplexRegexMatchers("%" + name + "%").isEmpty()) { + return one; + } + } else { + String n = one.name(); + if (n.equals(name)) + return one; + } + } + return null; + } + + public String getFull() { + if (this.isComplex()) { + String name = this.name(); + int i = 0; + for (String one : this.name().split("_")) { + if (!one.startsWith("$")) + continue; + if (vars.length >= i - 1) + name = name.replace(one, "[" + vars[i] + "]"); + i++; + } + + return "%" + name + "%"; + } + return "%" + this.name() + "%"; + } + + public String getMVdW() { + if (this.isComplex()) { + String name = this.name(); + int i = 0; + for (String one : this.name().split("_")) { + if (!one.startsWith("$")) + continue; + if (vars.length >= i - 1) + name = name.replace(one, "*"); + i++; + } + + return name; + } + return this.name(); + } + + public List getComplexRegexMatchers(String text) { + List lsInLs = new ArrayList(); + if (!this.isComplex()) + return lsInLs; + + Matcher matcher = this.getRule().getMatcher(text); + if (matcher == null) + return lsInLs; + while (matcher.find()) { + lsInLs.add(matcher.group()); + } + return lsInLs; + } + + public List getComplexValues(String text) { + + List lsInLs = new ArrayList(); + if (!this.isComplex() || text == null) + return lsInLs; + + Matcher matcher = this.getRule().getMatcher(text); + if (matcher == null) + return lsInLs; + while (matcher.find()) { + try { + for (Integer oneG : groups) { + lsInLs.add(matcher.group(oneG + 1)); + } + } catch (Exception e) { + } + break; + } + return lsInLs; + } + + public boolean isComplex() { + return rule != null; + } + + public ChatFilterRule getRule() { + return rule; + } + + public void setRule(ChatFilterRule rule) { + this.rule = rule; + } + + public boolean isHidden() { + return hidden; + } + } + + public List updatePlaceHolders(Player player, List messages) { + List ms = new ArrayList(messages); + for (int i = 0, l = messages.size(); i < l; ++i) { + ms.set(i, updatePlaceHolders(player, messages.get(i))); + } + return ms; + } + + public enum JobsPlaceholderType { + Jobs, PAPI, MVdW; + } + + public JobsPlaceholderType getPlaceHolderType(Player player, String placeholder) { + if (placeholder == null) + return null; + if (placeholder.contains("%")) { + if (!placeholder.equals(translateOwnPlaceHolder(player, placeholder))) + return JobsPlaceholderType.Jobs; + } + if (plugin.isPlaceholderAPIEnabled()) { + try { + if (placeholder.contains("%")) + if (!placeholder.equals(me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, placeholder))) + return JobsPlaceholderType.PAPI; + } catch (Exception e) { + + } + } +// For MVdWPlaceholderAPI +// if (plugin.isMVdWPlaceholderAPIEnabled()) { +// if (placeholder.contains("{")) +// if (!placeholder.equals(be.maximvdw.placeholderapi.PlaceholderAPI.replacePlaceholders(player, placeholder))) +// return CMIPlaceholderType.MVdW; +// } + return null; + } + + public String updatePlaceHolders(Player player, String message) { + + if (message == null) + return null; + if (message.contains("%")) + message = translateOwnPlaceHolder(player, message); + if (plugin.isPlaceholderAPIEnabled()) { + try { + if (message.contains("%")) + message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, message); + } catch (Exception e) { + + } + } +// For MVdWPlaceholderAPI +// if (plugin.isMVdWPlaceholderAPIEnabled()) { +// if (message.contains("{")) +// message = be.maximvdw.placeholderapi.PlaceholderAPI.replacePlaceholders(player, message); +// } + + return message; + } + + private String translateOwnPlaceHolder(Player player, String message) { + if (message == null) + return null; + + if (message.contains("%")) { + Matcher match = placeholderPatern.matcher(message); + while (match.find()) { + try { + String cmd = match.group(2); + if (!message.contains("%")) + break; + JobsPlaceHolders place = JobsPlaceHolders.getByNameExact(cmd); + if (place == null) + continue; + String group = match.group(); + String with = this.getValue(player, place, group); + if (with == null) + with = ""; + if (with.startsWith("$")) + with = "\\" + with; + message = message.replaceFirst(group, with); + } catch (Exception e) { +// e.printStackTrace(); + } + } + } + return message; + } + + public String getValue(Player player, JobsPlaceHolders placeHolder) { + return getValue(player, placeHolder, null); + + } + + public String getValue(Player player, JobsPlaceHolders placeHolder, String value) { + return getValue(player != null ? player.getUniqueId() : null, placeHolder, value); + } + + private static JobProgression getProgFromValue(JobsPlayer user, String value) { + JobProgression j = null; + try { + int id = Integer.parseInt(value); + if (id > 0) + j = user.getJobProgression().get(id - 1); + } catch (Exception e) { + Job job = Jobs.getJob(value); + if (job != null) + j = user.getJobProgression(job); + } + return j; + } + + private static Job getJobFromValue(String value) { + Job j = null; + try { + int id = Integer.parseInt(value); + if (id > 0) + j = Jobs.getJobs().get(id - 1); + } catch (Exception e) { + j = Jobs.getJob(value); + } + return j; + } + + private static String simplifyDouble(double value) { + return String.valueOf((int) (value * 100) / 100D); + } + + public String getValue(UUID uuid, JobsPlaceHolders placeHolder, String value) { + JobsPlayer user = Jobs.getPlayerManager().getJobsPlayer(uuid); + + if (placeHolder == null) + return null; + // Placeholders by JobsPLayer object + if (user != null) { + switch (placeHolder) { + case user_id: + return String.valueOf(user.getUserId()); + case user_bstandcount: + return String.valueOf(user.getBrewingStandCount()); + case user_maxbstandcount: + return String.valueOf(user.getMaxBrewingStandsAllowed()); + case user_furncount: + return String.valueOf(user.getFurnaceCount()); + case user_maxfurncount: + return String.valueOf(user.getMaxFurnacesAllowed()); + case user_doneq: + return String.valueOf(user.getDoneQuests()); + case user_totallevels: + return String.valueOf(user.getTotalLevels()); + case user_displayhonorific: + return String.valueOf(user.getDisplayHonorific()); + case user_joinedjobcount: + return String.valueOf(user.getJobProgression().size()); + case user_boost_$1_$2: + List values = placeHolder.getComplexValues(value); + if (values.size() < 2) + return ""; + JobProgression j = getProgFromValue(user, values.get(0)); + if (j == null) + return ""; + return simplifyDouble(user.getBoost(j.getJob().getName(), CurrencyType.getByName(values.get(1)))); + case user_isin_$1: + values = placeHolder.getComplexValues(value); + if (values.isEmpty()) + return ""; + Job job = getJobFromValue(values.get(0)); + if (job == null) + return ""; + return convert(user.isInJob(job)); + + default: + break; + } + } + + // Placeholders by player object + if (user != null && user.isOnline()) { + Player player = user.getPlayer(); + if (player != null) { + List values; + switch (placeHolder) { + + case user_canjoin_$1: + values = placeHolder.getComplexValues(value); + if (values.isEmpty()) + return ""; + + Job job = getJobFromValue(values.get(0)); + if (job == null) + return ""; + + if (!Jobs.getCommandManager().hasJobPermission(player, job)) { + return convert(false); + } + + if (user.isInJob(job)) { + return convert(false); + } + + if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { + return convert(false); + } + + int confMaxJobs = Jobs.getGCManager().getMaxJobs(); + short PlayerMaxJobs = (short) user.getJobProgression().size(); + if (confMaxJobs > 0 && PlayerMaxJobs >= confMaxJobs && !Jobs.getPlayerManager().getJobsLimit(user, PlayerMaxJobs)) { + return convert(false); + } + + return convert(true); + + default: + break; + } + } + } + + List values = new ArrayList(); + + if (placeHolder.isComplex()) { + values = placeHolder.getComplexValues(value); + if (values.isEmpty()) + return ""; + Job j = getJobFromValue(values.get(0)); + + // Global placeholders by jobname + switch (placeHolder) { + case name_$1: + return j == null ? "" : j.getName(); + case shortname_$1: + return j == null ? "" : j.getShortName(); + case chatcolor_$1: + return j == null ? "" : j.getChatColor().toString(); + case description_$1: + return j == null ? "" : j.getDescription(); + case maxdailyq_$1: + return j == null ? "" : String.valueOf(j.getMaxDailyQuests()); + case maxlvl_$1: + return j == null ? "" : String.valueOf(j.getMaxLevel()); + case maxviplvl_$1: + return j == null ? "" : String.valueOf(j.getVipMaxLevel()); + case totalplayers_$1: + return j == null ? "" : String.valueOf(j.getTotalPlayers()); + case maxslots_$1: + return j == null ? "" : String.valueOf(j.getMaxSlots()); + default: + break; + } + } + + // Global placeholders + switch (placeHolder) { + case maxjobs: + return String.valueOf(Jobs.getGCManager().getMaxJobs()); + } + + return null; + } + + private String convert(boolean state) { + return state ? Jobs.getLanguage().getMessage("general.info.true") : Jobs.getLanguage().getMessage("general.info.false"); + } +} diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/PlaceholderAPIHook.java b/src/main/java/com/gamingmesh/jobs/Placeholders/PlaceholderAPIHook.java new file mode 100644 index 00000000..4e7b28df --- /dev/null +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/PlaceholderAPIHook.java @@ -0,0 +1,28 @@ +package com.gamingmesh.jobs.Placeholders; + +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceHolders; + +import me.clip.placeholderapi.external.EZPlaceholderHook; + +public class PlaceholderAPIHook extends EZPlaceholderHook { + + private Jobs plugin; + + public PlaceholderAPIHook(Jobs plugin) { + super(plugin, Placeholder.pref); + this.plugin = plugin; + } + + @Override + public String onPlaceholderRequest(Player player, String identifier) { + JobsPlaceHolders placeHolder = JobsPlaceHolders.getByName(identifier); + if (placeHolder == null) { + return null; + } + return plugin.getPlaceholderAPIManager().getValue(player, placeHolder, "%" + Placeholder.pref + "_" + identifier + "%"); + } + +} diff --git a/src/main/java/com/gamingmesh/jobs/Signs/Sign.java b/src/main/java/com/gamingmesh/jobs/Signs/Sign.java index 49c3b01c..3829aa87 100644 --- a/src/main/java/com/gamingmesh/jobs/Signs/Sign.java +++ b/src/main/java/com/gamingmesh/jobs/Signs/Sign.java @@ -2,79 +2,79 @@ package com.gamingmesh.jobs.Signs; public class Sign { - private int Category = 0; - private String World = null; - private double x = 0.01; - private double y = 0.01; - private double z = 0.01; - private int Number = 0; - private String JobName = null; - private boolean special = false; + private int Category = 0; + private String World = null; + private double x = 0.01; + private double y = 0.01; + private double z = 0.01; + private int Number = 0; + private String JobName = null; + private boolean special = false; - public Sign() { - } - - public void setSpecial(boolean special) { - this.special = special; - } + public Sign() { + } - public boolean isSpecial() { - return special; - } - - public void setJobName(String JobName) { - this.JobName = JobName; - } + public void setSpecial(boolean special) { + this.special = special; + } - public String GetJobName() { - return JobName; - } - - public void setCategory(int Category) { - this.Category = Category; - } + public boolean isSpecial() { + return special; + } - public int GetCategory() { - return Category; - } + public void setJobName(String JobName) { + this.JobName = JobName; + } - public void setWorld(String World) { - this.World = World; - } + public String GetJobName() { + return JobName; + } - public String GetWorld() { - return World; - } + public void setCategory(int Category) { + this.Category = Category; + } - public void setX(double x) { - this.x = x; - } + public int GetCategory() { + return Category; + } - public double GetX() { - return x; - } + public void setWorld(String World) { + this.World = World; + } - public void setY(double y) { - this.y = y; - } + public String GetWorld() { + return World; + } - public double GetY() { - return y; - } + public void setX(double x) { + this.x = x; + } - public void setZ(double z) { - this.z = z; - } + public double GetX() { + return x; + } - public double GetZ() { - return z; - } + public void setY(double y) { + this.y = y; + } - public void setNumber(int Number) { - this.Number = Number; - } + public double GetY() { + return y; + } - public int GetNumber() { - return Number; - } + public void setZ(double z) { + this.z = z; + } + + public double GetZ() { + return z; + } + + public void setNumber(int Number) { + this.Number = Number; + } + + public int GetNumber() { + return Number; + } } diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 90c91fbc..3e8bf732 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -135,6 +135,8 @@ public class LanguageManager { c.get("general.info.time.mins", "&e%mins% &6min "); c.get("general.info.time.secs", "&e%secs% &6sec "); c.get("general.info.invalidPage", "&cInvalid page"); + c.get("general.info.true", "&2True"); + c.get("general.info.false", "&cFalse"); c.get("general.admin.error", "&cThere was an error in the command."); c.get("general.admin.success", "&eYour command has been performed."); c.get("general.error.noHelpPage", "&cThere is no help page by this number!"); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index cc4c3c25..0d5902bc 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -201,6 +201,8 @@ public class JobsPlayer { double Boost = 0D; if (!this.isOnline()) return Boost; + if (type == null) + return Boost; long time = System.currentTimeMillis(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 564a29b1..8eed147d 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,7 +5,7 @@ version: 4.9.4 api-version: 1.13 website: https://www.spigotmc.org/resources/4216/ author: phrstbrn -softdepend: [Vault, MythicMobs, McMMO, WorldGuard, MyPet] +softdepend: [Vault, MythicMobs, McMMO, WorldGuard, MyPet, PlaceholderAPI] commands: jobs: description: Jobs