Skip to content

Commit

Permalink
spreads events: add a type matcher to allow distinguishing intended e…
Browse files Browse the repository at this point in the history
…vent with dynamic matchers
  • Loading branch information
mcmonkey4eva committed Jun 15, 2021
1 parent 431469f commit 8abeb03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -17,6 +17,8 @@ public class BlockSpreadsScriptEvent extends BukkitScriptEvent implements Listen
//
// @Regex ^on [^\s]+ spreads$
//
// @Switch type:<material> to only run if the block spreading matches the material input.
//
// @Group Block
//
// @Location true
Expand Down Expand Up @@ -57,13 +59,15 @@ public boolean couldMatch(ScriptPath path) {

@Override
public boolean matches(ScriptPath path) {

if (!runInCheck(path, location)) {
return false;
}
if (!tryMaterial(material, path.eventArgLowerAt(0))) {
return false;
}
if (path.switches.containsKey("type") && !tryMaterial(material, path.switches.get("type"))) {
return false;
}
return super.matches(path);

}
Expand Down
Expand Up @@ -19,6 +19,8 @@ public class LiquidSpreadScriptEvent extends BukkitScriptEvent implements Listen
//
// @Regex ^on [^\s]+ spreads$
//
// @Switch type:<material> to only run if the block spreading matches the material input.
//
// @Group Block
//
// @Location true
Expand Down Expand Up @@ -74,6 +76,9 @@ public boolean matches(ScriptPath path) {
return false;
}
}
if (path.switches.containsKey("type") && !tryMaterial(material, path.switches.get("type"))) {
return false;
}
if (!runInCheck(path, location) && !runInCheck(path, destination)) {
return false;
}
Expand Down

0 comments on commit 8abeb03

Please sign in to comment.