From 990d3e1add1f181e6dff4389d84b6a82fca589cd Mon Sep 17 00:00:00 2001 From: Alex 'mcmonkey' Goodwin Date: Sun, 3 Jan 2021 01:02:34 -0800 Subject: [PATCH] less bork with vehicle exit for non-vanilla-vehicles --- README.md | 2 +- .../denizen/events/BukkitScriptEvent.java | 10 ++++++++++ .../events/entity/EntityExitsVehicleScriptEvent.java | 6 ++++-- .../events/player/AreaEnterExitScriptEvent.java | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 90d511e748..070d72b0bc 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Copyright (C) 2013-2019 The Denizen Script Team, All Rights Reserved. The MIT License (MIT) -Copyright (c) 2019-2020 The Denizen Script Team +Copyright (c) 2019-2021 The Denizen Script Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/BukkitScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/BukkitScriptEvent.java index cde2f24605..8e98466b94 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/BukkitScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/BukkitScriptEvent.java @@ -116,6 +116,16 @@ public boolean couldMatchEntity(String text) { return genericCouldMatchChecks(text, this::couldMatchEntity); } + public boolean exactMatchEntity(String text) { + if (specialEntityMatchables.contains(text)) { + return true; + } + if (EntityTag.matches(text)) { + return true; + } + return false; + } + public boolean exactMatchesVehicle(String text) { if (text.equals("vehicle")) { return true; diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityExitsVehicleScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityExitsVehicleScriptEvent.java index ba39c53b86..07ae5fd5a0 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityExitsVehicleScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/entity/EntityExitsVehicleScriptEvent.java @@ -63,8 +63,10 @@ public boolean couldMatch(ScriptPath path) { @Override public boolean matches(ScriptPath path) { - if (!tryEntity(entity, path.eventArgLowerAt(0)) - || !tryEntity(vehicle, path.eventArgLowerAt(2))) { + if (!tryEntity(entity, path.eventArgLowerAt(0))) { + return false; + } + if (!path.eventArgLowerAt(2).equals("vehicle") && !tryEntity(vehicle, path.eventArgLowerAt(2))) { return false; } if (!runInCheck(path, vehicle.getLocation())) { diff --git a/plugin/src/main/java/com/denizenscript/denizen/events/player/AreaEnterExitScriptEvent.java b/plugin/src/main/java/com/denizenscript/denizen/events/player/AreaEnterExitScriptEvent.java index 17cd24ac7b..8b6e67c593 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/events/player/AreaEnterExitScriptEvent.java +++ b/plugin/src/main/java/com/denizenscript/denizen/events/player/AreaEnterExitScriptEvent.java @@ -70,7 +70,7 @@ public boolean couldMatch(ScriptPath path) { if (path.eventArgLowerAt(2).equals("biome") || exactMatchesEnum(path.eventArgLowerAt(2), Biome.values())) { return false; } - if (exactMatchesVehicle(path.eventArgLowerAt(2))) { + if (exactMatchEntity(path.eventArgLowerAt(2))) { return false; } if (path.eventArgLowerAt(2).equals("bed") || path.eventArgLowerAt(2).equals("portal")) {