mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
lets support multiple command lines one level up
This commit is contained in:
parent
297c68f91d
commit
b5dad11233
@ -649,12 +649,13 @@ public class PlayerManager {
|
||||
return;
|
||||
for (JobCommands command : job.getCommands()) {
|
||||
if (newLevel >= command.getLevelFrom() && newLevel <= command.getLevelUntil()) {
|
||||
String commandString = command.getCommand();
|
||||
commandString = commandString.replace("[player]", player.getName());
|
||||
commandString = commandString.replace("[oldlevel]", String.valueOf(oldLevel));
|
||||
commandString = commandString.replace("[newlevel]", String.valueOf(newLevel));
|
||||
commandString = commandString.replace("[jobname]", job.getName());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandString);
|
||||
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));
|
||||
commandString = commandString.replace("[jobname]", job.getName());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,31 +18,48 @@
|
||||
|
||||
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.levelFrom = levelFrom;
|
||||
this.levelUntil = levelUntil;
|
||||
this.node = node;
|
||||
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;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return node;
|
||||
return node;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getCommand() {
|
||||
return command;
|
||||
return commands.isEmpty() ? "" : commands.get(0);
|
||||
}
|
||||
|
||||
public List<String> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public int getLevelFrom() {
|
||||
return levelFrom;
|
||||
return levelFrom;
|
||||
}
|
||||
|
||||
public int getLevelUntil() {
|
||||
return levelUntil;
|
||||
return levelUntil;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user