Skip to content

Commit

Permalink
advanced matches coreification
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Apr 29, 2022
1 parent b6c40ff commit 973feed
Show file tree
Hide file tree
Showing 149 changed files with 591 additions and 779 deletions.
Expand Up @@ -42,7 +42,7 @@ public EntityAddToWorldScriptEvent() {

@Override
public boolean matches(ScriptPath path) {
if (!tryEntity(entity, path.eventArgLowerAt(0))) {
if (!entity.tryAdvancedMatcher(path.eventArgLowerAt(0))) {
return false;
}
if (!runInCheck(path, location)) {
Expand Down
Expand Up @@ -60,7 +60,7 @@ public EntityKnocksbackEntityScriptEvent() {
public boolean matches(ScriptPath path) {
String attacker = path.eventArgLowerAt(0);
String target = path.eventArgLowerAt(3);
if (!tryEntity(hitBy, attacker) || (!tryEntity(entity, target))) {
if (!hitBy.tryAdvancedMatcher(attacker) || (!entity.tryAdvancedMatcher(target))) {
return false;
}
if (!runInCheck(path, entity.getLocation())) {
Expand Down
Expand Up @@ -58,7 +58,7 @@ public EntityLoadCrossbowScriptEvent() {

@Override
public boolean matches(ScriptPath path) {
if (!tryEntity(entity, path.eventArgLowerAt(0))) {
if (!entity.tryAdvancedMatcher(path.eventArgLowerAt(0))) {
return false;
}
if (!runWithCheck(path, new ItemTag(event.getCrossbow()), "crossbow")) {
Expand Down
Expand Up @@ -54,7 +54,7 @@ public EntityPathfindScriptEvent() {

@Override
public boolean matches(ScriptPath path) {
if (!tryEntity(entity, path.eventArgLowerAt(0))) {
if (!entity.tryAdvancedMatcher(path.eventArgLowerAt(0))) {
return false;
}
if (!runInCheck(path, entity.getLocation())) {
Expand All @@ -64,7 +64,7 @@ public boolean matches(ScriptPath path) {
return false;
}
String at = path.switches.get("at");
if (at != null && !tryEntity(target, at)) {
if (at != null && (target == null || !target.tryAdvancedMatcher(at))) {
return false;
}
return super.matches(path);
Expand Down
Expand Up @@ -64,7 +64,7 @@ public boolean matches(ScriptPath path) {
return false;
}
if (path.switches.containsKey("elytra")
&& !tryItem(new ItemTag(player.getPlayerEntity().getEquipment().getChestplate()), path.switches.get("elytra"))) {
&& !new ItemTag(player.getPlayerEntity().getEquipment().getChestplate()).tryAdvancedMatcher(path.switches.get("elytra"))) {
return false;
}
return super.matches(path);
Expand Down
Expand Up @@ -69,19 +69,17 @@ public PlayerEquipsArmorScriptEvent() {
public boolean matches(ScriptPath path) {
String type = path.eventArgLowerAt(1);
String itemCompare = path.eventArgLowerAt(2);

PlayerArmorChangeEvent.SlotType slotType = slotsByName.get(itemCompare);
if (slotType != null && slot != slotType) {
return false;
}

if (type.equals("equips")) {
if (slotType != null) {
if (newItem.getMaterial().getMaterial() == Material.AIR) {
return false;
}
}
else if (!itemCompare.equals("armor") && !tryItem(newItem, itemCompare)) {
else if (!itemCompare.equals("armor") && !newItem.tryAdvancedMatcher(itemCompare)) {
return false;
}
}
Expand All @@ -91,11 +89,10 @@ else if (!itemCompare.equals("armor") && !tryItem(newItem, itemCompare)) {
return false;
}
}
else if (!itemCompare.equals("armor") && !tryItem(oldItem, itemCompare)) {
else if (!itemCompare.equals("armor") && !oldItem.tryAdvancedMatcher(itemCompare)) {
return false;
}
}

return super.matches(path);
}

Expand Down
Expand Up @@ -43,7 +43,7 @@ public PlayerSpectatesEntityScriptEvent() {

@Override
public boolean matches(ScriptPath path) {
if (!tryEntity(new EntityTag(event.getNewSpectatorTarget()), path.eventArgLowerAt(2))) {
if (!new EntityTag(event.getNewSpectatorTarget()).tryAdvancedMatcher(path.eventArgLowerAt(2))) {
return false;
}
if (!runInCheck(path, event.getPlayer().getLocation())) {
Expand Down
Expand Up @@ -42,7 +42,7 @@ public PlayerStopsSpectatingScriptEvent() {

@Override
public boolean matches(ScriptPath path) {
if (path.eventArgLowerAt(3).length() > 0 && !tryEntity(new EntityTag(event.getSpectatorTarget()), path.eventArgLowerAt(3))) {
if (path.eventArgLowerAt(3).length() > 0 && !new EntityTag(event.getSpectatorTarget()).tryAdvancedMatcher(path.eventArgLowerAt(3))) {
return false;
}
if (!runInCheck(path, event.getPlayer().getLocation())) {
Expand Down
Expand Up @@ -56,7 +56,7 @@ public boolean matches(ScriptPath path) {
if (!runInCheck(path, event.getPlayer().getLocation())) {
return false;
}
if (path.switches.containsKey("result") && !tryItem(new ItemTag(event.getTrade().getResult()), path.switches.get("result"))) {
if (path.switches.containsKey("result") && !new ItemTag(event.getTrade().getResult()).tryAdvancedMatcher(path.switches.get("result"))) {
return false;
}
return super.matches(path);
Expand Down
Expand Up @@ -51,7 +51,7 @@ public PreEntitySpawnScriptEvent() {

@Override
public boolean matches(ScriptPath path) {
if (!tryEntity(entity, path.eventArgLowerAt(0))) {
if (!entity.tryAdvancedMatcher(path.eventArgLowerAt(0))) {
return false;
}
if (path.eventArgLowerAt(2).equals("because")
Expand Down
Expand Up @@ -49,10 +49,10 @@ public boolean matches(ScriptPath path) {
if (!runInCheck(path, event.getEntity().getLocation())) {
return false;
}
if (!tryEntity(projectile, path.eventArgLowerAt(0))) {
if (!projectile.tryAdvancedMatcher(path.eventArgLowerAt(0))) {
return false;
}
if (!tryEntity(collidedWith, path.eventArgLowerAt(3))) {
if (!collidedWith.tryAdvancedMatcher(path.eventArgLowerAt(3))) {
return false;
}
return super.matches(path);
Expand Down

0 comments on commit 973feed

Please sign in to comment.