From 2215c57791293328106cdf412d08c6b8bbbe7aea Mon Sep 17 00:00:00 2001 From: montlikadani Date: Mon, 7 Jan 2019 18:06:02 +0100 Subject: [PATCH] Added player argument to /job limit command - Fix sheep color not work properly --- .../gamingmesh/jobs/commands/list/limit.java | 37 +++++++++++-------- .../jobs/config/GeneralConfigManager.java | 2 +- .../jobs/config/LanguageManager.java | 2 +- .../gamingmesh/jobs/container/JobsPlayer.java | 2 +- .../com/gamingmesh/jobs/nmsUtil/v1_10.java | 2 - src/main/resources/jobConfig.yml | 8 ++-- src/main/resources/locale/messages_hu.yml | 4 +- 7 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/limit.java b/src/main/java/com/gamingmesh/jobs/commands/list/limit.java index b27d21bd..ccd23400 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/limit.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/limit.java @@ -16,46 +16,53 @@ public class limit implements Cmd { @Override @JobCommand(700) public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { - if (args.length > 0) { + if (args.length != 0 && args.length != 1) { Jobs.getCommandManager().sendUsage(sender, "limit"); return true; } - if (!(sender instanceof Player)) { - sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame")); - return false; - } + JobsPlayer JPlayer = null; + if (args.length >= 1) + JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); + else if (sender instanceof Player) + JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender); - Player player = (Player) sender; boolean disabled = true; for (CurrencyType type : CurrencyType.values()) { - if (Jobs.getGCManager().currencyLimitUse.get(type).isEnabled()) { + if (Jobs.getGCManager().getLimit(type).isEnabled()) { disabled = false; break; } } if (disabled) { - player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.notenabled")); + sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.notenabled")); + return true; + } + + if (JPlayer == null) { + if (args.length >= 1) + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfo")); + else if (!(sender instanceof Player)) + Jobs.getCommandManager().sendUsage(sender, "limit"); return true; } - JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player); for (CurrencyType type : CurrencyType.values()) { - if (!Jobs.getGCManager().currencyLimitUse.get(type).isEnabled()) + if (!Jobs.getGCManager().getLimit(type).isEnabled()) continue; PaymentData limit = JPlayer.getPaymentLimit(); if (limit == null) { - int lefttime1 = Jobs.getGCManager().currencyLimitUse.get(type).getTimeLimit() * 1000; - player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort((long) lefttime1))); - player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit", + int lefttime1 = Jobs.getGCManager().getLimit(type).getTimeLimit() * 1000; + sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort((long) lefttime1))); + sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit", "%current%", "0.0", "%total%", JPlayer.getLimit(type))); continue; } if (limit.GetLeftTime(type) > 0) { - player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort(limit.GetLeftTime(type)))); - player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit", + sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort(limit.GetLeftTime(type)))); + sender.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "Limit", "%current%", (int) (limit.GetAmount(type) * 100) / 100D, "%total%", JPlayer.getLimit(type))); } diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 34038fd8..0e497bd9 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -76,7 +76,7 @@ public class GeneralConfigManager { private int ResetTimeMinute; // Limits - public HashMap currencyLimitUse = new HashMap<>(); + private HashMap currencyLimitUse = new HashMap<>(); public boolean PayForRenaming, PayForEachCraft, SignsEnabled, SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index a98c9726..d7a154a2 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -231,7 +231,7 @@ public class LanguageManager { c.get("command.convert.help.args", ""); c.get("command.limit.help.info", "Shows payment limits for jobs"); - c.get("command.limit.help.args", ""); + c.get("command.limit.help.args", "[playername]"); c.get("command.limit.output.moneytime", "&eTime left until money limit resets: &2%time%"); c.get("command.limit.output.moneyLimit", "&eMoney limit: &2%current%&e/&2%total%"); c.get("command.limit.output.exptime", "&eTime left until Exp limit resets: &2%time%"); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 10cf42c7..7c1dd99c 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -291,7 +291,7 @@ public class JobsPlayer { for (JobProgression prog : progression) { TotalLevel += prog.getLevel(); } - Parser eq = Jobs.getGCManager().currencyLimitUse.get(type).getMaxEquation(); + Parser eq = Jobs.getGCManager().getLimit(type).getMaxEquation(); eq.setVariable("totallevel", TotalLevel); limits.put(type, (int) eq.getValue()); setSaved(false); diff --git a/src/main/java/com/gamingmesh/jobs/nmsUtil/v1_10.java b/src/main/java/com/gamingmesh/jobs/nmsUtil/v1_10.java index 00542fc9..228f47e4 100644 --- a/src/main/java/com/gamingmesh/jobs/nmsUtil/v1_10.java +++ b/src/main/java/com/gamingmesh/jobs/nmsUtil/v1_10.java @@ -2,9 +2,7 @@ package com.gamingmesh.jobs.nmsUtil; import java.util.ArrayList; import java.util.List; -import java.util.Set; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.Guardian; diff --git a/src/main/resources/jobConfig.yml b/src/main/resources/jobConfig.yml index e3c74e9b..e6871821 100644 --- a/src/main/resources/jobConfig.yml +++ b/src/main/resources/jobConfig.yml @@ -345,7 +345,7 @@ Jobs: Green: income: 2.0 experience: 5.0 - Navy: + Light_Blue: income: 2.0 experience: 5.0 Lime: @@ -366,7 +366,7 @@ Jobs: Red: income: 2.0 experience: 5.0 - Silver: + Light_Gray: income: 2.0 experience: 5.0 White: @@ -1749,7 +1749,7 @@ Jobs: income: 4.0 points: 4.0 experience: 5.0 - Navy: + Light_Blue: income: 4.0 points: 4.0 experience: 5.0 @@ -1765,7 +1765,7 @@ Jobs: income: 4.0 points: 4.0 experience: 5.0 - Silver: + Light_Gray: income: 4.0 points: 4.0 experience: 5.0 diff --git a/src/main/resources/locale/messages_hu.yml b/src/main/resources/locale/messages_hu.yml index 4eb2db00..4407cff8 100644 --- a/src/main/resources/locale/messages_hu.yml +++ b/src/main/resources/locale/messages_hu.yml @@ -108,9 +108,9 @@ command: limit: help: info: 'Megmutatja a fizetési határértékeket a munkahelyekért.' - args: '' + args: '[playername]' output: - moneytime: '&eAz idő marad, amíg a pénzkorlát visszaáll: &2%time%' + moneytime: '&eIdő maradt, míg a pénzkorlát visszaáll: &2%time%' moneyLimit: '&ePénzkorlát: &2%current%&e/&2%total%' exptime: '&eAz exp limitig hátralévő idő marad vissza: &2%time%' expLimit: '&eExp limit: &2%current%&e/&2%total%'