Skip to content

Commit

Permalink
Some work towards move ScriptEntry to the core
Browse files Browse the repository at this point in the history
Yay corework
  • Loading branch information
mcmonkey4eva committed Jan 11, 2015
1 parent ce2eaf0 commit 37187e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
15 changes: 7 additions & 8 deletions src/main/java/net/aufdemrand/denizen/scripts/ScriptEntry.java
Expand Up @@ -8,15 +8,14 @@
import net.aufdemrand.denizen.objects.Element;
import net.aufdemrand.denizen.objects.dObject;
import net.aufdemrand.denizen.objects.dScript;
import net.aufdemrand.denizen.scripts.commands.AbstractCommand;
import net.aufdemrand.denizen.scripts.commands.BracedCommand;
import net.aufdemrand.denizencore.scripts.ScriptEntryData;
import net.aufdemrand.denizencore.scripts.commands.BaseAbstractCommand;
import net.aufdemrand.denizencore.scripts.commands.Holdable;
import net.aufdemrand.denizen.scripts.containers.ScriptContainer;
import net.aufdemrand.denizen.scripts.queues.ScriptQueue;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizencore.utilities.debugging.Debuggable;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.utilities.debugging.dB;


/**
Expand All @@ -31,7 +30,7 @@ public class ScriptEntry implements Cloneable, Debuggable {

// The name of the command that will be executed
private String command;
private AbstractCommand actualCommand;
private BaseAbstractCommand actualCommand;

// Command Arguments
private List<String> args;
Expand Down Expand Up @@ -105,15 +104,15 @@ public ScriptEntry(String command, String[] arguments, ScriptContainer script) t
else if (command.charAt(0) == '~') {
this.command = command.substring(1).toUpperCase();
// Make sure this command can be 'waited for'
if (DenizenAPI.getCurrentInstance().getCommandRegistry().get(this.command)
if (DenizenCore.getCommandRegistry().get(this.command)
instanceof Holdable) {
waitfor = true;
}
else {
dB.echoError(null, "The command '" + this.command + "' cannot be waited for!");
dB.echoError("The command '" + this.command + "' cannot be waited for!");
}
}
actualCommand = (AbstractCommand)DenizenAPI.getCurrentInstance().getCommandRegistry().get(this.command);
actualCommand = DenizenCore.getCommandRegistry().get(this.command);
}
else {
actualCommand = null;
Expand Down Expand Up @@ -221,7 +220,7 @@ public String getCommandName() {
return command;
}

public AbstractCommand getCommand() {
public BaseAbstractCommand getCommand() {
return actualCommand;
}

Expand Down
Expand Up @@ -18,6 +18,7 @@
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizen.utilities.debugging.dB.DebugElement;

import net.aufdemrand.denizencore.scripts.commands.BaseAbstractCommand;
import org.bukkit.ChatColor;

public class CommandExecuter {
Expand Down Expand Up @@ -66,9 +67,9 @@ public boolean execute(ScriptEntry scriptEntry) {
}

// Get the command instance ready for the execution of the scriptEntry
AbstractCommand command = scriptEntry.getCommand();
BaseAbstractCommand command = scriptEntry.getCommand();
if (command == null) {
command = (AbstractCommand)DenizenAPI.getCurrentInstance().getCommandRegistry().get(scriptEntry.getCommandName());
command = DenizenAPI.getCurrentInstance().getCommandRegistry().get(scriptEntry.getCommandName());
}

if (command == null) {
Expand Down Expand Up @@ -215,7 +216,7 @@ else if (arg.matchesPrefix("save") && !if_ignore) {
))); // Replace tags

// Parse the rest of the arguments for execution.
command.parseArgs(scriptEntry);
((AbstractCommand)command).parseArgs(scriptEntry);

} catch (InvalidArgumentsException e) {

Expand All @@ -241,7 +242,7 @@ else if (arg.matchesPrefix("save") && !if_ignore) {
if (keepGoing)
try {
// Run the execute method in the command
command.execute(scriptEntry);
((AbstractCommand)command).execute(scriptEntry);
} catch (Exception e) {
dB.echoError(scriptEntry.getResidingQueue(), "Woah!! An exception has been called with this command!");
dB.echoError(scriptEntry.getResidingQueue(), e);
Expand Down

0 comments on commit 37187e8

Please sign in to comment.