From 5612becd6fad25d0fba1d964273a82963ef60255 Mon Sep 17 00:00:00 2001 From: Zrips Date: Sat, 4 Feb 2017 16:53:39 +0200 Subject: [PATCH] new command to reset payment limit --- com/gamingmesh/jobs/commands/list/.gitignore | 1 + .../jobs/commands/list/resetlimit.java | 31 +++++++++++++++++++ .../jobs/config/LanguageManager.java | 6 ++++ com/gamingmesh/jobs/container/JobsPlayer.java | 9 ++++++ .../jobs/listeners/JobsPaymentListener.java | 7 +---- 5 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 com/gamingmesh/jobs/commands/list/resetlimit.java diff --git a/com/gamingmesh/jobs/commands/list/.gitignore b/com/gamingmesh/jobs/commands/list/.gitignore index 3c2b66a3..3dec0a50 100644 --- a/com/gamingmesh/jobs/commands/list/.gitignore +++ b/com/gamingmesh/jobs/commands/list/.gitignore @@ -55,3 +55,4 @@ /entitylist.class /iteminfo.class /area.class +/resetlimit.class diff --git a/com/gamingmesh/jobs/commands/list/resetlimit.java b/com/gamingmesh/jobs/commands/list/resetlimit.java new file mode 100644 index 00000000..3798301c --- /dev/null +++ b/com/gamingmesh/jobs/commands/list/resetlimit.java @@ -0,0 +1,31 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.JobsPlayer; + +public class resetlimit implements Cmd { + + @Override + @JobCommand(700) + public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) { + if (args.length != 1) { + Jobs.getCommandManager().sendUsage(sender, "resetlimit"); + return true; + } + + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]); + + if (jPlayer == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); + return true; + } + + jPlayer.resetPaymentLimit(); + sender.sendMessage(Jobs.getLanguage().getMessage("command.resetlimit.output.reseted", "%playername%", jPlayer.getUserName())); + + return true; + } +} diff --git a/com/gamingmesh/jobs/config/LanguageManager.java b/com/gamingmesh/jobs/config/LanguageManager.java index d7d96061..0fcad26e 100644 --- a/com/gamingmesh/jobs/config/LanguageManager.java +++ b/com/gamingmesh/jobs/config/LanguageManager.java @@ -141,7 +141,13 @@ public class LanguageManager { c.get("command.limit.output.reachedpointslimit", "&4You have reached exp limit in given time!"); c.get("command.limit.output.reachedpointslimit2", "&eYou can check your limit with &2/jobs limit &ecommand"); c.get("command.limit.output.notenabled", "&eMoney limit is not enabled"); + + c.get("command.resetlimit.help.info", "Resets players payment limits"); + c.get("command.resetlimit.help.args", "[playername]"); + c.get("command.resetlimit.output.reseted", "&ePayment limits have been reset for: &2%playername%"); + + c.get("command.help.output.info", "Type /jobs [cmd] ? for more information about a command."); c.get("command.help.output.usage", "Usage: %usage%"); c.get("command.help.output.title", "&e-------&e ======= &6Jobs &e======= &e-------"); diff --git a/com/gamingmesh/jobs/container/JobsPlayer.java b/com/gamingmesh/jobs/container/JobsPlayer.java index c5faef04..22eb8a81 100644 --- a/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/com/gamingmesh/jobs/container/JobsPlayer.java @@ -261,6 +261,7 @@ public class JobsPlayer { Parser eq = Jobs.getGCManager().currencyLimitUse.get(type).getMaxEquation(); eq.setVariable("totallevel", TotalLevel); limits.put(type, (int) eq.getValue()); + setSaved(false); } public void reloadLimits() { @@ -273,6 +274,14 @@ public class JobsPlayer { return this.limits.get(type); } + public void resetPaymentLimit() { + if (paymentLimits == null) + getPaymentLimit(); + if (paymentLimits != null) + paymentLimits.resetLimits(); + setSaved(false); + } + /** * Get the list of job progressions * @return the list of job progressions diff --git a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 23d51354..241e3f70 100644 --- a/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -150,7 +150,7 @@ public class JobsPaymentListener implements Listener { // check if in creative if (player.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative()) return; - + if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; @@ -267,16 +267,11 @@ public class JobsPaymentListener implements Listener { if (player.getGameMode() == GameMode.CREATIVE && !Jobs.getGCManager().payInCreative()) return; - long time = System.nanoTime(); if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName())) return; - Debug.D("time in " + (System.nanoTime() - time)); - - time = System.nanoTime(); if (!Jobs.getPermissionHandler().hasWorldPermission2(player, player.getLocation().getWorld().getName())) return; - Debug.D("time in " + (System.nanoTime() - time)); BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.BREAK); FastPayment fp = Jobs.FastPayment.get(player.getName());