Skip to content

Commit

Permalink
minor additional improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 4, 2020
1 parent 277afad commit 214b5aa
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/**
* ScriptEntry contain information about a single entry from a dScript. It is used
* by the CommandExecuter, among other parts of Denizen.
* by the CommandExecutor, among other parts of Denizen.
*/
public class ScriptEntry implements Cloneable, Debuggable {

Expand Down Expand Up @@ -369,7 +369,7 @@ public List<String> getArguments() {
/**
* Gets the original, pre-tagged arguments, as constructed. This is simply a copy of
* the original arguments, immune from any changes that may be made (such as tag filling)
* by the CommandExecuter.
* by the CommandExecutor.
*
* @return unmodified arguments from entry creation
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void onEnable() {
* Typically []'s represent required arguments and ()'s represent optional arguments.
* Example from SWITCH command: [LOCATION:x,y,z,world] (STATE:ON|OFF|TOGGLE) (DURATION:#)
* @param numberOfRequiredArgs The minimum number of required arguments needed to ensure proper functionality. The
* Executer will not parseArgs() for this command if this number is not met.
* Executor will not parseArgs() for this command if this number is not met.
* @return The newly created CommandOptions object for the possibility of setting other
* criteria, though currently none exists.
*/
Expand All @@ -148,9 +148,9 @@ public CommandOptions withOptions(String usageHint, int numberOfRequiredArgs) {
public abstract void execute(ScriptEntry scriptEntry);

/**
* Called by the CommandExecuter before the execute() method is called. Arguments
* Called by the CommandExecutor before the execute() method is called. Arguments
* should be iterated through and checked before continuing to execute(). Note that
* PLAYER:<player> and NPC:<npc> arguments are parsed automatically by the Executer
* PLAYER:<player> and NPC:<npc> arguments are parsed automatically by the Executor
* and should not be handled by this Command otherwise. Their output is stored in the
* attached {@link ScriptEntry} and can be retrieved with ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer(),
* scriptEntry.getOfflinePlayer() (if the player specified is not online), and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void execute(ScriptEntry scriptEntry) {
for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("foreach") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("FOREACH") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
hasnext = true;
break;
}
Expand All @@ -127,7 +127,7 @@ public void execute(ScriptEntry scriptEntry) {
while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("foreach") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("FOREACH") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
scriptEntry.getResidingQueue().removeEntry(0);
break;
}
Expand All @@ -148,7 +148,7 @@ else if (next != null && next.asBoolean()) {
for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("foreach") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("FOREACH") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
hasnext = true;
break;
}
Expand All @@ -157,7 +157,7 @@ else if (next != null && next.asBoolean()) {
while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("foreach") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("FOREACH") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
break;
}
scriptEntry.getResidingQueue().removeEntry(0);
Expand All @@ -169,7 +169,7 @@ else if (next != null && next.asBoolean()) {
return;
}
else if (callback != null && callback.asBoolean()) {
if (scriptEntry.getOwner() != null && (scriptEntry.getOwner().getCommandName().equalsIgnoreCase("foreach") ||
if (scriptEntry.getOwner() != null && (scriptEntry.getOwner().getCommandName().equals("FOREACH") ||
scriptEntry.getOwner().getBracedSet() == null || scriptEntry.getOwner().getBracedSet().isEmpty() ||
scriptEntry.getBracedSet().get(0).value.get(scriptEntry.getBracedSet().get(0).value.size() - 1) != scriptEntry)) {
ForeachData data = (ForeachData) scriptEntry.getOwner().getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void execute(ScriptEntry scriptEntry) {
for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("repeat") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("REPEAT") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
hasnext = true;
break;
}
Expand All @@ -120,7 +120,7 @@ public void execute(ScriptEntry scriptEntry) {
while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("repeat") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("REPEAT") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
scriptEntry.getResidingQueue().removeEntry(0);
break;
}
Expand All @@ -141,7 +141,7 @@ else if (next != null && next.asBoolean()) {
for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("repeat") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("REPEAT") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
hasnext = true;
break;
}
Expand All @@ -150,7 +150,7 @@ else if (next != null && next.asBoolean()) {
while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("repeat") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("REPEAT") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
break;
}
scriptEntry.getResidingQueue().removeEntry(0);
Expand All @@ -162,7 +162,7 @@ else if (next != null && next.asBoolean()) {
return;
}
else if (callback != null && callback.asBoolean()) {
if (scriptEntry.getOwner() != null && (scriptEntry.getOwner().getCommandName().equalsIgnoreCase("repeat") ||
if (scriptEntry.getOwner() != null && (scriptEntry.getOwner().getCommandName().equals("REPEAT") ||
scriptEntry.getOwner().getBracedSet() == null || scriptEntry.getOwner().getBracedSet().isEmpty() ||
scriptEntry.getBracedSet().get(0).value.get(scriptEntry.getBracedSet().get(0).value.size() - 1) != scriptEntry)) {
RepeatData data = (RepeatData) scriptEntry.getOwner().getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void execute(ScriptEntry scriptEntry) {
for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("while") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("WHILE") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
hasnext = true;
break;
}
Expand All @@ -105,7 +105,7 @@ public void execute(ScriptEntry scriptEntry) {
while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("while") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("WHILE") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
scriptEntry.getResidingQueue().removeEntry(0);
break;
}
Expand All @@ -126,7 +126,7 @@ else if (next != null && next.asBoolean()) {
for (int i = 0; i < scriptEntry.getResidingQueue().getQueueSize(); i++) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(i);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("while") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("WHILE") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
hasnext = true;
break;
}
Expand All @@ -135,7 +135,7 @@ else if (next != null && next.asBoolean()) {
while (scriptEntry.getResidingQueue().getQueueSize() > 0) {
ScriptEntry entry = scriptEntry.getResidingQueue().getEntry(0);
List<String> args = entry.getOriginalArguments();
if (entry.getCommandName().equalsIgnoreCase("while") && args.size() > 0 && args.get(0).equalsIgnoreCase("\0CALLBACK")) {
if (entry.getCommandName().equals("WHILE") && args.size() > 0 && args.get(0).equals("\0CALLBACK")) {
break;
}
scriptEntry.getResidingQueue().removeEntry(0);
Expand All @@ -147,7 +147,7 @@ else if (next != null && next.asBoolean()) {
return;
}
else if (callback != null && callback.asBoolean()) {
if (scriptEntry.getOwner() != null && (scriptEntry.getOwner().getCommandName().equalsIgnoreCase("while") ||
if (scriptEntry.getOwner() != null && (scriptEntry.getOwner().getCommandName().equals("WHILE") ||
scriptEntry.getOwner().getBracedSet() == null || scriptEntry.getOwner().getBracedSet().isEmpty() ||
scriptEntry.getBracedSet().get(0).value.get(scriptEntry.getBracedSet().get(0).value.size() - 1) != scriptEntry)) {
WhileData data = (WhileData) scriptEntry.getOwner().getData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

public class ScriptEngine {

public final CommandExecutor commandExecuter;
public final CommandExecutor commandExecutor;

public ScriptEngine() {
commandExecuter = new CommandExecutor();
commandExecutor = new CommandExecutor();
}

boolean shouldHold(ScriptQueue scriptQueue) {
Expand All @@ -35,7 +35,7 @@ public void revolveOnceForce(ScriptQueue scriptQueue) {
scriptEntry.setSendingQueue(scriptQueue);
scriptQueue.setLastEntryExecuted(scriptEntry);
try {
commandExecuter.execute(scriptEntry);
commandExecutor.execute(scriptEntry);
}
catch (Throwable e) {
Debug.echoError(scriptEntry.getResidingQueue(), "An exception has been called with this command (while revolving the queue forcefully)!");
Expand All @@ -51,7 +51,7 @@ public void revolve(ScriptQueue scriptQueue) {
while (scriptEntry != null) {
scriptEntry.setSendingQueue(scriptQueue);
scriptQueue.setLastEntryExecuted(scriptEntry);
commandExecuter.execute(scriptEntry);
commandExecutor.execute(scriptEntry);
if (scriptQueue instanceof Delayable) {
Delayable delayedQueue = (Delayable) scriptQueue;
if (delayedQueue.isDelayed() || delayedQueue.isPaused()) {
Expand Down

0 comments on commit 214b5aa

Please sign in to comment.