Update to CommandsXL 2.0

This commit is contained in:
Daniel Saukel 2015-12-29 20:42:11 +01:00
parent 41e5a05f93
commit 930045c263
2 changed files with 34 additions and 10 deletions

View File

@ -1,9 +1,11 @@
package io.github.dre2n.dungeonsxl.sign; package io.github.dre2n.dungeonsxl.sign;
import io.github.dre2n.commandsxl.CCommand; import io.github.dre2n.commandsxl.command.CCommand;
import io.github.dre2n.commandsxl.command.CCommandExecutorTask;
import io.github.dre2n.commandsxl.CommandsXL; import io.github.dre2n.commandsxl.CommandsXL;
import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld; import io.github.dre2n.dungeonsxl.dungeon.game.GameWorld;
import io.github.dre2n.dungeonsxl.trigger.InteractTrigger; import io.github.dre2n.dungeonsxl.trigger.InteractTrigger;
import io.github.dre2n.dungeonsxl.util.IntegerUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -17,6 +19,8 @@ public class CommandSign extends DSign {
// Variables // Variables
private CCommand cCommand; private CCommand cCommand;
private long delay;
private String command; private String command;
private String executor; private String executor;
private boolean initialized; private boolean initialized;
@ -27,14 +31,34 @@ public class CommandSign extends DSign {
@Override @Override
public boolean check() { public boolean check() {
return true; String lines[] = getSign().getLines();
if (lines[1].equals("") || lines[2].equals("")) {
return false;
}
if (lines[1] == null) {
return false;
}
String[] attributes = lines[2].split(",");
if (attributes.length == 2) {
return true;
} else {
return false;
}
} }
@Override @Override
public void onInit() { public void onInit() {
command = getSign().getLine(1); String[] lines = getSign().getLines();
executor = getSign().getLine(2); String[] attributes = lines[2].split(",");
cCommand = CommandsXL.getCCommands().getCCommand(command);
command = lines[1];
executor = attributes[0];
delay = IntegerUtil.parseInt(attributes[1]);
cCommand = CommandsXL.getPlugin().getCCommands().getCCommand(command);
if (getTriggers().isEmpty()) { if (getTriggers().isEmpty()) {
getSign().getBlock().setType(Material.AIR); getSign().getBlock().setType(Material.AIR);
@ -60,13 +84,13 @@ public class CommandSign extends DSign {
@Override @Override
public boolean onPlayerTrigger(Player player) { public boolean onPlayerTrigger(Player player) {
if (executor.equalsIgnoreCase("Console")) { if (executor.equalsIgnoreCase("Console")) {
cCommand.execute(player, Bukkit.getConsoleSender(), true); new CCommandExecutorTask(player, cCommand, Bukkit.getConsoleSender(), true).runTaskLater(plugin, delay);
} else if (executor.equalsIgnoreCase("OP")) { } else if (executor.equalsIgnoreCase("OP")) {
cCommand.execute(player, player, true); new CCommandExecutorTask(player, cCommand, player, true).runTaskLater(plugin, delay);
} else { } else {
cCommand.execute(player, player, false); new CCommandExecutorTask(player, cCommand, player, false).runTaskLater(plugin, delay);
} }
return true; return true;

View File

@ -43,8 +43,8 @@ public class MobSign extends DSign {
return false; return false;
} }
String[] atributes = lines[2].split(","); String[] attributes = lines[2].split(",");
if (atributes.length == 2) { if (attributes.length == 2) {
return true; return true;
} else { } else {