1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

lets support multiple command lines one level up

This commit is contained in:
Zrips 2018-05-20 14:28:08 +03:00
parent 297c68f91d
commit b5dad11233
4 changed files with 47 additions and 22 deletions

View File

@ -649,7 +649,7 @@ public class PlayerManager {
return;
for (JobCommands command : job.getCommands()) {
if (newLevel >= command.getLevelFrom() && newLevel <= command.getLevelUntil()) {
String commandString = command.getCommand();
for (String commandString : new ArrayList<String>(command.getCommands())) {
commandString = commandString.replace("[player]", player.getName());
commandString = commandString.replace("[oldlevel]", String.valueOf(oldLevel));
commandString = commandString.replace("[newlevel]", String.valueOf(newLevel));
@ -658,6 +658,7 @@ public class PlayerManager {
}
}
}
}
/**
* Get max jobs

View File

@ -618,10 +618,14 @@ public class ConfigManager {
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid command key" + commandKey + "!");
continue;
}
String command = commandSection.getString("command");
List<String> commands = new ArrayList<String>();
if (commandSection.isString("command"))
commands.add(commandSection.getString("command"));
else if (commandSection.isList("command"))
commands.addAll(commandSection.getStringList("command"));
int levelFrom = commandSection.getInt("levelFrom");
int levelUntil = commandSection.getInt("levelUntil");
jobCommand.add(new JobCommands(node, command, levelFrom, levelUntil));
jobCommand.add(new JobCommands(node, commands, levelFrom, levelUntil));
}
}

View File

@ -18,14 +18,26 @@
package com.gamingmesh.jobs.container;
import java.util.ArrayList;
import java.util.List;
public class JobCommands {
private String node;
private String command;
private List<String> commands = new ArrayList<String>();
private int levelFrom;
private int levelUntil;
@Deprecated
public JobCommands(String node, String command, int levelFrom, int levelUntil) {
this.node = node;
this.command = command;
this.commands.add(command);
this.levelFrom = levelFrom;
this.levelUntil = levelUntil;
}
public JobCommands(String node, List<String> commands, int levelFrom, int levelUntil) {
this.node = node;
this.commands.addAll(commands);
this.levelFrom = levelFrom;
this.levelUntil = levelUntil;
}
@ -34,8 +46,13 @@ public class JobCommands {
return node;
}
@Deprecated
public String getCommand() {
return command;
return commands.isEmpty() ? "" : commands.get(0);
}
public List<String> getCommands() {
return commands;
}
public int getLevelFrom() {

View File

@ -454,6 +454,7 @@ Jobs:
fly:
# Command its self, this will be executed from console, so all commands should work
# Possible variables are: [player] [jobname] [oldlevel] [newlevel]
# can be one or multiple lines
command: manuaddp [player] essentials.fly
# When to execute this command first time
levelFrom: 100
@ -461,7 +462,9 @@ Jobs:
# This can be set to same level as levelFrom, so this command will be executed only once
levelUntil: 100
kit:
command: manuaddp [player] essentials.kits.woodcutter
command:
- manuaddp [player] essentials.kits.woodcutter
- manuaddp [player] essentials.fly
levelFrom: 150
levelUntil: 150
# Getting more money when equiped with specific weapon/tool ar wearing armor