diff --git a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java index c8e49696..63c2f7f6 100644 --- a/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java +++ b/src/main/java/com/gamingmesh/jobs/Placeholders/Placeholder.java @@ -6,7 +6,6 @@ import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.gamingmesh.jobs.Jobs; diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/level.java b/src/main/java/com/gamingmesh/jobs/commands/list/level.java new file mode 100644 index 00000000..ae8dcf59 --- /dev/null +++ b/src/main/java/com/gamingmesh/jobs/commands/list/level.java @@ -0,0 +1,103 @@ +package com.gamingmesh.jobs.commands.list; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gamingmesh.jobs.Jobs; +import com.gamingmesh.jobs.commands.Cmd; +import com.gamingmesh.jobs.commands.JobCommand; +import com.gamingmesh.jobs.container.Job; +import com.gamingmesh.jobs.container.JobProgression; +import com.gamingmesh.jobs.container.JobsPlayer; + +public class level implements Cmd { + + private enum Action { + Set, Add, Take + } + + @Override + @JobCommand(1600) + public boolean perform(Jobs plugin, CommandSender sender, String[] args) { + if (args.length < 4) { + Jobs.getCommandManager().sendUsage(sender, "level"); + return true; + } + + Action action = Action.Add; + int amount = 0; + String playerName = null; + Job job = null; + + for (String one : args) { + switch (one.toLowerCase()) { + case "set": + action = Action.Set; + continue; + case "add": + action = Action.Add; + continue; + case "take": + action = Action.Take; + continue; + } + + try { + amount = Integer.parseInt(one); + continue; + } catch (NumberFormatException e) { + } + + if (job == null && Jobs.getJob(one) != null) { + job = Jobs.getJob(one); + continue; + } + playerName = one; + } + + if (playerName == null) + return false; + + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(playerName); + if (jPlayer == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.noinfoByPlayer", "%playername%", args[0])); + return true; + } + + if (!Jobs.hasPermission(jPlayer.getPlayer(), "jobs.command.level", true)) + return true; + + if (job == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); + return true; + } + + try { + // check if player already has the job + if (jPlayer.isInJob(job)) { + JobProgression prog = jPlayer.getJobProgression(job); + switch (action) { + case Set: + prog.setLevel(amount); + break; + case Add: + prog.setLevel(amount); + break; + case Take: + prog.setLevel(amount); + break; + } + + Player player = jPlayer.getPlayer(); + if (player != null) { + player.sendMessage(Jobs.getLanguage().getMessage("command.level.output.target", "%jobname%", job.getChatColor() + job.getName(), "%level%", prog.getLevel(), "%exp%", prog.getExperience())); + } + + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); + } + } catch (Exception e) { + sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.error")); + } + return true; + } +} diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java b/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java index 0a9c04a9..51be01c1 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/placeholders.java @@ -9,7 +9,6 @@ import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceHolders; import com.gamingmesh.jobs.Placeholders.Placeholder.JobsPlaceholderType; import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; -import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.PageInfo; public class placeholders implements Cmd { @@ -60,7 +59,7 @@ public class placeholders implements Cmd { if (player != null && !one.isComplex()) extra = plugin.getPlaceholderAPIManager().updatePlaceHolders(player, Jobs.getLanguage().getMessage("command.placeholders.output.outputResult", "[result]", Jobs.getInstance().getPlaceholderAPIManager().updatePlaceHolders(player, one.getFull()))); - + String place = one.getFull(); String hover = ""; if (plugin.isPlaceholderAPIEnabled()) { diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 4c5182f8..e2c23521 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -583,6 +583,11 @@ public class LanguageManager { Jobs.getGCManager().commandArgs.put("exp", Arrays.asList("[playername]", "[jobname]", "set%%add%%take")); c.get("command.exp.output.target", "&eYour exp was changed for %jobname% &eand now you at &6%level%lvl &eand with &6%exp%exp."); + c.get("command.level.help.info", "Change the player level for job."); + c.get("command.level.help.args", "[playername] [jobname] set/add/take [amount]"); + Jobs.getGCManager().commandArgs.put("level", Arrays.asList("[playername]", "[jobname]", "set%%add%%take")); + c.get("command.level.output.target", "&eYour level was changed for %jobname% &eand now you at &6%level%lvl &eand with &6%exp%exp."); + c.get("command.demote.help.info", "Demote the player X levels in a job."); c.get("command.demote.help.args", "[playername] [jobname] [levels]"); Jobs.getGCManager().commandArgs.put("demote", Arrays.asList("[playername]", "[jobname]", "[levels]")); diff --git a/src/main/resources/locale/messages_hu.yml b/src/main/resources/locale/messages_hu.yml index bfcea860..545de7cf 100644 --- a/src/main/resources/locale/messages_hu.yml +++ b/src/main/resources/locale/messages_hu.yml @@ -198,6 +198,14 @@ command: id: ' &eTárgy ID: &6%itemid%' data: ' &eTárgy adat: &6%itemdata%' usage: ' &eHasználat: &6%first% &evagy &6%second%' + placeholders: + help: + info: 'Listázza az összes helyőrzőt' + args: '(parse) (placeholder)' + output: + list: '&e[place]. &7[placeholder]' + outputResult: ' &eeredmény: &7[result]' + parse: '&6[placeholder] &b[source]-val/-vel &6eredmény &8|&f[result]&8|' entitylist: help: info: 'Megmutatja, hogy minden lehetséges entitás használható a pluginnal.' @@ -522,7 +530,13 @@ command: info: 'Módosítsa a játékos tapasztalat feladatát.' args: '[playername] [jobname] set/add/take [amount]' output: - target: '&eA tapasztalat változott %jobname%&e, most van &6%level%lvl &eés &6%exp%&eexp.' + target: '&eA tapasztalat megváltozott a(z) %jobname%&e munkában, most van &6%level%lvl &eés &6%exp%&eexp.' + level: + help: + info: 'Módosítsa a játékos szint feladatát.' + args: '[playername] [jobname] set/add/take [amount]' + output: + target: '&eA szint megváltozott a(z) %jobname%&e munkában, most van &6%level%lvl &eés &6%exp%&eexp.' demote: help: info: 'Eldobja a játékos X szintjét a munkában.'