mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-18 05:11:32 +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;
|
return;
|
||||||
for (JobCommands command : job.getCommands()) {
|
for (JobCommands command : job.getCommands()) {
|
||||||
if (newLevel >= command.getLevelFrom() && newLevel <= command.getLevelUntil()) {
|
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("[player]", player.getName());
|
||||||
commandString = commandString.replace("[oldlevel]", String.valueOf(oldLevel));
|
commandString = commandString.replace("[oldlevel]", String.valueOf(oldLevel));
|
||||||
commandString = commandString.replace("[newlevel]", String.valueOf(newLevel));
|
commandString = commandString.replace("[newlevel]", String.valueOf(newLevel));
|
||||||
commandString = commandString.replace("[jobname]", job.getName());
|
commandString = commandString.replace("[jobname]", job.getName());
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandString);
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,10 +618,14 @@ public class ConfigManager {
|
|||||||
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid command key" + commandKey + "!");
|
Jobs.getPluginLogger().warning("Job " + jobKey + " has an invalid command key" + commandKey + "!");
|
||||||
continue;
|
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 levelFrom = commandSection.getInt("levelFrom");
|
||||||
int levelUntil = commandSection.getInt("levelUntil");
|
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;
|
package com.gamingmesh.jobs.container;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class JobCommands {
|
public class JobCommands {
|
||||||
private String node;
|
private String node;
|
||||||
private String command;
|
private List<String> commands = new ArrayList<String>();
|
||||||
private int levelFrom;
|
private int levelFrom;
|
||||||
private int levelUntil;
|
private int levelUntil;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public JobCommands(String node, String command, int levelFrom, int levelUntil) {
|
public JobCommands(String node, String command, int levelFrom, int levelUntil) {
|
||||||
this.node = node;
|
this.node = node;
|
||||||
this.command = command;
|
this.commands.add(command);
|
||||||
this.levelFrom = levelFrom;
|
this.levelFrom = levelFrom;
|
||||||
this.levelUntil = levelUntil;
|
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() {
|
public String getNode() {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String getCommand() {
|
public String getCommand() {
|
||||||
return command;
|
return commands.isEmpty() ? "" : commands.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getCommands() {
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
public int getLevelFrom() {
|
public int getLevelFrom() {
|
||||||
return levelFrom;
|
return levelFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLevelUntil() {
|
public int getLevelUntil() {
|
||||||
return levelUntil;
|
return levelUntil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,6 +454,7 @@ Jobs:
|
|||||||
fly:
|
fly:
|
||||||
# Command its self, this will be executed from console, so all commands should work
|
# Command its self, this will be executed from console, so all commands should work
|
||||||
# Possible variables are: [player] [jobname] [oldlevel] [newlevel]
|
# Possible variables are: [player] [jobname] [oldlevel] [newlevel]
|
||||||
|
# can be one or multiple lines
|
||||||
command: manuaddp [player] essentials.fly
|
command: manuaddp [player] essentials.fly
|
||||||
# When to execute this command first time
|
# When to execute this command first time
|
||||||
levelFrom: 100
|
levelFrom: 100
|
||||||
@ -461,7 +462,9 @@ Jobs:
|
|||||||
# This can be set to same level as levelFrom, so this command will be executed only once
|
# This can be set to same level as levelFrom, so this command will be executed only once
|
||||||
levelUntil: 100
|
levelUntil: 100
|
||||||
kit:
|
kit:
|
||||||
command: manuaddp [player] essentials.kits.woodcutter
|
command:
|
||||||
|
- manuaddp [player] essentials.kits.woodcutter
|
||||||
|
- manuaddp [player] essentials.fly
|
||||||
levelFrom: 150
|
levelFrom: 150
|
||||||
levelUntil: 150
|
levelUntil: 150
|
||||||
# Getting more money when equiped with specific weapon/tool ar wearing armor
|
# Getting more money when equiped with specific weapon/tool ar wearing armor
|
||||||
|
Loading…
Reference in New Issue
Block a user