Skip to content

Commit

Permalink
update 'on command' to a script event finally
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 29, 2019
1 parent 251c69d commit 177cd5a
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 249 deletions.
3 changes: 1 addition & 2 deletions plugin/src/main/java/com/denizenscript/denizen/Denizen.java
Expand Up @@ -353,8 +353,7 @@ public void onEnable() {
CommonRegistries.registerMainTagHandlers();

eventManager = new OldEventManager();
// Register all the 'Core' SmartEvents.
OldEventManager.registerSmartEvent(new CommandSmartEvent());
// Register all the legacy 'Core' SmartEvents.
OldEventManager.registerSmartEvent(new CuboidEnterExitSmartEvent());
OldEventManager.registerSmartEvent(new FlagSmartEvent());
OldEventManager.registerSmartEvent(new NPCNavigationSmartEvent());
Expand Down
Expand Up @@ -203,24 +203,11 @@ public void initForPriority(EventPriority priority, Listener listener) {
}
}

@Deprecated
public boolean runInCheck(ScriptContainer scriptContainer, String s, String lower, Location location) {
return runInCheck(scriptContainer, s, lower, location, "in");
}

@Deprecated
public boolean runInCheck(ScriptContainer scriptContainer, String s, String lower, Location location, String innote) {
return runInCheck(new ScriptPath(scriptContainer, s), location, innote);
}

public boolean runInCheck(ScriptPath path, Location location) {
return runInCheck(path, location, "in");
}

public boolean runInCheck(ScriptPath path, Location location, String innote) {
if (location == null) {
return false;
}
String it = path.switches.get(innote);
if (it == null) {
int index;
Expand All @@ -233,6 +220,9 @@ public boolean runInCheck(ScriptPath path, Location location, String innote) {
// No 'in ...' specified
return true;
}
if (location == null) {
return false;
}
Deprecations.inAreaSwitchFormat.warn();
it = path.eventArgLowerAt(index + 1);
if (it.equals("notable")) {
Expand All @@ -249,6 +239,9 @@ else if (subit.equals("ellipsoid")) {
}
}
}
if (location == null) {
return false;
}
String lower = CoreUtilities.toLowerCase(it);
if (lower.equals("cuboid")) {
return CuboidTag.getNotableCuboidsContaining(location).size() > 0;
Expand Down Expand Up @@ -303,13 +296,11 @@ public boolean runWithCheck(ScriptContainer scriptContainer, String s, String lo
return runWithCheck(new ScriptPath(scriptContainer, s), held);
}

public static TagContext noDebugTagContext = new BukkitTagContext(null, null, false, null, false, null);

public boolean runGenericCheck(String inputValue, String trueValue) {
if (inputValue != null) {
trueValue = CoreUtilities.toLowerCase(trueValue);
inputValue = CoreUtilities.toLowerCase(inputValue);
if (inputValue.equalsIgnoreCase(trueValue)) {
if (inputValue.equals(trueValue)) {
return true;
}
Pattern regexd = regexHandle(inputValue);
Expand All @@ -325,7 +316,7 @@ public boolean runGenericSwitchCheck(ScriptPath path, String switchName, String
if (with != null) {
value = CoreUtilities.toLowerCase(value);
with = CoreUtilities.toLowerCase(with);
if (with.equalsIgnoreCase(value)) {
if (with.equals(value)) {
return true;
}
Pattern regexd = regexHandle(with);
Expand Down
Expand Up @@ -176,6 +176,7 @@ public static void registerMainEvents() {
// World events
ScriptEvent.registerScriptEvent(new ChunkLoadScriptEvent());
ScriptEvent.registerScriptEvent(new ChunkUnloadScriptEvent());
ScriptEvent.registerScriptEvent(new CommandScriptEvent());
ScriptEvent.registerScriptEvent(new InventoryPicksUpItemScriptEvent());
ScriptEvent.registerScriptEvent(new ItemMoveScriptEvent());
ScriptEvent.registerScriptEvent(new LightningStrikesScriptEvent());
Expand Down
Expand Up @@ -87,6 +87,7 @@ public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
if (lower.equals("buildable")) {
cancelled = false;
}
return true;
}
return super.applyDetermination(path, determinationObj);
}
Expand Down
Expand Up @@ -89,6 +89,7 @@ else if (LocationTag.matches(determination)) {
else {
event.setVelocity(vel.toVector());
}
return true;
}
else if (ItemTag.matches(determination)) {
ItemTag it = ItemTag.valueOf(determination, path.container);
Expand All @@ -99,6 +100,7 @@ else if (ItemTag.matches(determination)) {
item = it;
event.setItem(item.getItemStack());
}
return true;
}
return super.applyDetermination(path, determinationObj);
}
Expand Down

This file was deleted.

0 comments on commit 177cd5a

Please sign in to comment.