diff --git a/pom.xml b/pom.xml index fb66e06f35..f85b372450 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ UTF-8 - 1.8.7-R0.1-SNAPSHOT + 1.8.8-R0.1-SNAPSHOT 20090211 2.0.16-SNAPSHOT Unknown diff --git a/src/main/java/net/aufdemrand/denizen/Denizen.java b/src/main/java/net/aufdemrand/denizen/Denizen.java index d5c9b453cc..3dfdba2cc7 100644 --- a/src/main/java/net/aufdemrand/denizen/Denizen.java +++ b/src/main/java/net/aufdemrand/denizen/Denizen.java @@ -661,7 +661,7 @@ public void onEnable() { ScriptEvent.registerScriptEvent(new PlayerJoinsScriptEvent()); ScriptEvent.registerScriptEvent(new PlayerJumpScriptEvent()); ScriptEvent.registerScriptEvent(new PlayerKickedScriptEvent()); - ScriptEvent.registerScriptEvent(new PlayerLeashesScriptEvent()); + ScriptEvent.registerScriptEvent(new PlayerLeashesEntityScriptEvent()); ScriptEvent.registerScriptEvent(new PlayerLeavesBedScriptEvent()); ScriptEvent.registerScriptEvent(new PlayerLevelsScriptEvent()); ScriptEvent.registerScriptEvent(new PlayerLoginScriptEvent()); @@ -779,6 +779,7 @@ public void onEnable() { propertyParser.registerProperty(EntityPowered.class, dEntity.class); propertyParser.registerProperty(EntityProfession.class, dEntity.class); propertyParser.registerProperty(EntityRotation.class, dEntity.class); + propertyParser.registerProperty(EntitySmall.class, dEntity.class); propertyParser.registerProperty(EntitySilent.class, dEntity.class); propertyParser.registerProperty(EntitySitting.class, dEntity.class); propertyParser.registerProperty(EntitySize.class, dEntity.class); diff --git a/src/main/java/net/aufdemrand/denizen/events/BukkitScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/BukkitScriptEvent.java index f9788ddd21..1a3e62a08c 100644 --- a/src/main/java/net/aufdemrand/denizen/events/BukkitScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/BukkitScriptEvent.java @@ -6,6 +6,10 @@ import net.aufdemrand.denizencore.scripts.containers.ScriptContainer; import net.aufdemrand.denizencore.utilities.CoreUtilities; import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Hanging; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Vehicle; import java.util.List; @@ -30,13 +34,13 @@ public boolean runInCheck(ScriptContainer scriptContainer, String s, String lowe return true; } - String it = CoreUtilities.getXthArg(index + 1, s); - if (it.equalsIgnoreCase("notable")) { + String it = CoreUtilities.getXthArg(index + 1, lower); + if (it.equals("notable")) { String subit = CoreUtilities.getXthArg(index + 2, lower); - if (subit.equalsIgnoreCase("cuboid")) { + if (subit.equals("cuboid")) { return dCuboid.getNotableCuboidsContaining(location).size() > 0; } - else if (subit.equalsIgnoreCase("ellipsoid")) { + else if (subit.equals("ellipsoid")) { return dEllipsoid.getNotableEllipsoidsContaining(location).size() > 0; } else { @@ -45,7 +49,7 @@ else if (subit.equalsIgnoreCase("ellipsoid")) { } } else if (dWorld.matches(it)) { - return location.getWorld().getName().equalsIgnoreCase(it); + return CoreUtilities.toLowerCase(location.getWorld().getName()).equals(it); } else if (dCuboid.matches(it)) { dCuboid cuboid = dCuboid.valueOf(it); @@ -79,9 +83,9 @@ public boolean tryLocation(dLocation location, String comparedto) { } public boolean runWithCheck(ScriptContainer scriptContainer, String s, String lower, dItem held) { - String with = getSwitch(s, "with"); + String with = getSwitch(lower, "with"); if (with != null) { - if (with.equalsIgnoreCase("item")) { + if (with.equals("item")) { return true; } dItem it = dItem.valueOf(with); @@ -97,71 +101,80 @@ public boolean runWithCheck(ScriptContainer scriptContainer, String s, String lo } public boolean tryItem(dItem item, String comparedto) { - if (comparedto.equalsIgnoreCase("item")) { - return true; - } - if (comparedto.length() == 0) { - dB.echoError("tryItem missing item value when compared to " + item.identifyNoIdentifier()); + if (comparedto == null || comparedto.isEmpty() || item == null) { return false; } - item = new dItem(item.getItemStack().clone()); - item.setAmount(1); - if (item.identifyNoIdentifier().equalsIgnoreCase(comparedto)) { + comparedto = CoreUtilities.toLowerCase(comparedto); + if (comparedto.equals("item")) { return true; } - if (item.identifyMaterialNoIdentifier().equalsIgnoreCase(comparedto)) { + item = new dItem(item.getItemStack().clone()); + item.setAmount(1); + ; + if (CoreUtilities.toLowerCase(item.identifyNoIdentifier()).equals(comparedto)) { return true; } - if (item.identifySimpleNoIdentifier().equalsIgnoreCase(comparedto)) { + else if (CoreUtilities.toLowerCase(item.identifyMaterialNoIdentifier()).equals(comparedto)) { return true; } - item.setDurability((short) 0); - if (item.identifyNoIdentifier().equalsIgnoreCase(comparedto)) { + else if (CoreUtilities.toLowerCase(item.identifySimpleNoIdentifier()).equals(comparedto)) { return true; } - if (item.identifyMaterialNoIdentifier().equalsIgnoreCase(comparedto)) { + else if (CoreUtilities.toLowerCase(item.identifyNoIdentifier()).equals(comparedto)) { return true; } - return false; + item.setDurability((short) 0); + return CoreUtilities.toLowerCase(item.identifyMaterialNoIdentifier()).equals(comparedto); } public boolean tryMaterial(dMaterial mat, String comparedto) { - if (comparedto == null || comparedto.length() == 0) { + if (comparedto == null || comparedto.isEmpty() || mat == null) { return false; } - if (comparedto.equalsIgnoreCase("block") || comparedto.equalsIgnoreCase("material")) { + comparedto = CoreUtilities.toLowerCase(comparedto); + if (comparedto.equals("block") || comparedto.equals("material")) { return true; } - if (mat.identifyNoIdentifier().equalsIgnoreCase(comparedto)) { + else if (CoreUtilities.toLowerCase(mat.identifyNoIdentifier()).equals(comparedto)) { return true; } - if (mat.identifySimpleNoIdentifier().equalsIgnoreCase(comparedto)) { + else if (CoreUtilities.toLowerCase(mat.identifySimpleNoIdentifier()).equals(comparedto)) { return true; } - if (mat.identifyFullNoIdentifier().equalsIgnoreCase(comparedto)) { + else if (CoreUtilities.toLowerCase(mat.identifyFullNoIdentifier()).equals(comparedto)) { return true; } return false; } public boolean tryEntity(dEntity entity, String comparedto) { - if (comparedto == null || comparedto.length() == 0 || entity == null) { + if (comparedto == null || comparedto.isEmpty() || entity == null) { return false; } + Entity bEntity = entity.getBukkitEntity(); comparedto = CoreUtilities.toLowerCase(comparedto); if (comparedto.equals("entity")) { return true; } - if (comparedto.equals("npc")) { + else if (comparedto.equals("npc")) { return entity.isCitizensNPC(); } - if (comparedto.equals("player")) { + else if (comparedto.equals("player")) { return entity.isPlayer(); } - if (entity.getEntityScript() != null && comparedto.equals(CoreUtilities.toLowerCase(entity.getEntityScript()))) { + else if (comparedto.equals("vehicle")) { + return bEntity instanceof Vehicle; + } + else if (comparedto.equals("projectile")) { + return bEntity instanceof Projectile; + } + else if (comparedto.equals("hanging")) { + return bEntity instanceof Hanging; + } + else if (entity.getEntityScript() != null && comparedto.equals(CoreUtilities.toLowerCase(entity.getEntityScript()))) { return true; } - if (comparedto.equals(entity.getEntityType().getLowercaseName())) { + else if (comparedto.equals(entity.getEntityType().getLowercaseName())) { return true; } return false; diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/CreeperPoweredScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/CreeperPoweredScriptEvent.java index d65eca0af4..06dd45bf31 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/CreeperPoweredScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/CreeperPoweredScriptEvent.java @@ -50,13 +50,17 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - String reason = CoreUtilities.getXthArg(3, lower); if (CoreUtilities.getXthArg(2, lower).equals("because") - && !reason.equals(CoreUtilities.toLowerCase(cause.toString()))) { + && !CoreUtilities.xthArgEquals(3, lower, CoreUtilities.toLowerCase(cause.toString()))) { return false; } - return runInCheck(scriptContainer, s, lower, event.getEntity().getLocation()); + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityBreaksHangingScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityBreaksHangingScriptEvent.java index a906eeb248..b50cba0886 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityBreaksHangingScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityBreaksHangingScriptEvent.java @@ -69,21 +69,23 @@ public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String entName = CoreUtilities.getXthArg(0, lower); String hang = CoreUtilities.getXthArg(2, lower); - if (!breaker.matchesEntity(entName)) { + + if (!tryEntity(breaker, entName)) { return false; } - if (!hang.equals("hanging") && !hanging.matchesEntity(hang)) { + + if (!hang.equals("hanging") && !tryEntity(hanging, hang)) { return false; } + if (!runInCheck(scriptContainer, s, lower, location)) { return false; } - if (CoreUtilities.xthArgEquals(3, lower, "because")) { - if (!CoreUtilities.getXthArg(4, lower).equals(CoreUtilities.toLowerCase(cause.asString()))) { - return false; - } + if (CoreUtilities.xthArgEquals(3, lower, "because") && !CoreUtilities.getXthArg(4, lower).equals(CoreUtilities.toLowerCase(cause.asString()))) { + return false; } + return true; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityChangesBlockScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityChangesBlockScriptEvent.java index de4f645f6f..165ddd2631 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityChangesBlockScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityChangesBlockScriptEvent.java @@ -66,18 +66,18 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String entName = CoreUtilities.getXthArg(0, lower); - if (!entity.matchesEntity(entName)) { + + if (!tryEntity(entity, entName)) { return false; } - String mat1 = CoreUtilities.getXthArg(2, lower); - if (!tryMaterial(old_material, mat1)) { + if (!tryMaterial(old_material, CoreUtilities.getXthArg(2, lower))) { return false; } if (CoreUtilities.xthArgEquals(3, lower, "into")) { String mat2 = CoreUtilities.getXthArg(4, lower); - if (mat2.length() == 0) { + if (mat2.isEmpty()) { dB.echoError("Invalid event material [" + getName() + "]: '" + s + "' for " + scriptContainer.getName()); return false; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityCombustsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityCombustsScriptEvent.java index af5c9d22ec..268e64b91c 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityCombustsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityCombustsScriptEvent.java @@ -58,8 +58,16 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - return entity.matchesEntity(CoreUtilities.getXthArg(0, lower)) - && runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityCreatePortalScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityCreatePortalScriptEvent.java index 4ec81c41a9..0eb45d3e20 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityCreatePortalScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityCreatePortalScriptEvent.java @@ -53,7 +53,8 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - if (!entity.matchesEntity(CoreUtilities.getXthArg(0, lower))) { + + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { return false; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityDamagedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityDamagedScriptEvent.java index 2534d724d7..c7a71a4be7 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityDamagedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityDamagedScriptEvent.java @@ -94,13 +94,9 @@ public boolean matches(ScriptContainer scriptContainer, String s) { CoreUtilities.getXthArg(2, lower).equals("by") ? CoreUtilities.getXthArg(3, lower) : ""; String target = cmd.equals("damages") ? CoreUtilities.getXthArg(2, lower) : CoreUtilities.getXthArg(0, lower); - if (attacker.length() > 0) { + if (!attacker.isEmpty()) { if (damager != null) { - boolean projectileMatched = false; - if (projectile != null) { - projectileMatched = projectile.matchesEntity(attacker); - } - if (!projectileMatched && !damager.matchesEntity(attacker) && !cause.asString().equals(attacker)) { + if (!cause.asString().equals(attacker) && !tryEntity(projectile, attacker) && !tryEntity(damager, attacker)) { return false; } } @@ -110,10 +106,9 @@ public boolean matches(ScriptContainer scriptContainer, String s) { } } } - if (target.length() > 0) { - if (!entity.matchesEntity(target)) { - return false; - } + + if (!tryEntity(entity, target)) { + return false; } if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityDeathScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityDeathScriptEvent.java index 0b41ac4266..6b798d9efe 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityDeathScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityDeathScriptEvent.java @@ -84,7 +84,16 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String target = CoreUtilities.getXthArg(0, lower); - return entity.matchesEntity(target) && runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!tryEntity(entity, target)) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityDespawnScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityDespawnScriptEvent.java index 583faef892..0ea55d9cf8 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityDespawnScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityDespawnScriptEvent.java @@ -50,9 +50,20 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String target = CoreUtilities.getXthArg(0, lower); - return entity.matchesEntity(target) - && checkSwitch(lower, "cause", CoreUtilities.toLowerCase(cause.asString())) - && runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!tryEntity(entity, target)) { + return false; + } + + if (!checkSwitch(lower, "cause", CoreUtilities.toLowerCase(cause.asString()))) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityEntersPortalScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityEntersPortalScriptEvent.java index 10619a5ad0..0b7c12c2ad 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityEntersPortalScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityEntersPortalScriptEvent.java @@ -55,7 +55,16 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String target = CoreUtilities.getXthArg(0, lower); - return entity.matchesEntity(target) && runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!tryEntity(entity, target)) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityEntersVehicleScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityEntersVehicleScriptEvent.java index 8abb085e0a..55294ab54a 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityEntersVehicleScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityEntersVehicleScriptEvent.java @@ -55,13 +55,17 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - if (!entity.matchesEntity(CoreUtilities.getXthArg(0, lower))) { + + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower)) + || !tryEntity(vehicle, CoreUtilities.getXthArg(2, lower))) { return false; } - if (!vehicle.matchesEntity(CoreUtilities.getXthArg(2, lower))) { + + if (!runInCheck(scriptContainer, s, lower, vehicle.getLocation())) { return false; } - return runInCheck(scriptContainer, s, lower, vehicle.getLocation()); + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityExitsPortalScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityExitsPortalScriptEvent.java index 79b1fa94f7..06d0f01f4a 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityExitsPortalScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityExitsPortalScriptEvent.java @@ -55,7 +55,16 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String target = CoreUtilities.getXthArg(0, lower); - return entity.matchesEntity(target) && runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!tryEntity(entity, target)) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityExitsVehicleScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityExitsVehicleScriptEvent.java index f0d1a89709..d2e42374b2 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityExitsVehicleScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityExitsVehicleScriptEvent.java @@ -55,13 +55,17 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - if (!entity.matchesEntity(CoreUtilities.getXthArg(0, lower))) { + + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower)) + || !tryEntity(vehicle, CoreUtilities.getXthArg(2, lower))) { return false; } - if (!vehicle.matchesEntity(CoreUtilities.getXthArg(2, lower))) { + + if (!runInCheck(scriptContainer, s, lower, vehicle.getLocation())) { return false; } - return runInCheck(scriptContainer, s, lower, vehicle.getLocation()); + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityExplodesScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityExplodesScriptEvent.java index 6006914f79..1222951b09 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityExplodesScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityExplodesScriptEvent.java @@ -65,7 +65,16 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String target = CoreUtilities.getXthArg(0, lower); - return entity.matchesEntity(target) && runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!tryEntity(entity, target)) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityExplosionPrimesScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityExplosionPrimesScriptEvent.java index b3a87f6867..d02d2059bf 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityExplosionPrimesScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityExplosionPrimesScriptEvent.java @@ -50,7 +50,16 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - return entity.matchesEntity(CoreUtilities.getXthArg(0, lower)) && runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityFoodLevelChangeScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityFoodLevelChangeScriptEvent.java index a06107799f..8180a9d06b 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityFoodLevelChangeScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityFoodLevelChangeScriptEvent.java @@ -59,7 +59,16 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String target = CoreUtilities.getXthArg(0, lower); - return entity.matchesEntity(target) && runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!tryEntity(entity, target)) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityFormsBlockScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityFormsBlockScriptEvent.java index 58100a41ef..32aacb9a65 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityFormsBlockScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityFormsBlockScriptEvent.java @@ -58,12 +58,11 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - if (!entity.matchesEntity(CoreUtilities.getXthArg(0, lower))) { + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { return false; } - String mat = CoreUtilities.getXthArg(2, lower); - if (!tryMaterial(material, mat)) { + if (!tryMaterial(material, CoreUtilities.getXthArg(2, lower))) { return false; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityHealsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityHealsScriptEvent.java index 90433b19cb..1d4ab42bb2 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityHealsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityHealsScriptEvent.java @@ -61,14 +61,21 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - if (!entity.matchesEntity(CoreUtilities.getXthArg(0, lower))) { + + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { return false; } - String cause = CoreUtilities.getXthArg(3, lower); - if (cause.length() > 0 && !cause.equals(CoreUtilities.toLowerCase(reason.toString()))) { + + if (CoreUtilities.getXthArg(2, lower).equals("because") && + !CoreUtilities.getXthArg(3, lower).equals(CoreUtilities.toLowerCase(reason.toString()))) { return false; } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityInteractScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityInteractScriptEvent.java index 29c10464fe..e861c35c6f 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityInteractScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityInteractScriptEvent.java @@ -47,6 +47,7 @@ public EntityInteractScriptEvent() { public dEntity entity; public dLocation location; private dMaterial material; + private dList cuboids; public EntityInteractEvent event; @Override @@ -58,12 +59,12 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - if (!entity.matchesEntity(CoreUtilities.getXthArg(0, lower))) { + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { return false; } String mat = CoreUtilities.getXthArg(3, lower); - if (!tryMaterial(material, mat)) { + if (!tryMaterial(material, CoreUtilities.getXthArg(2, lower))) { return false; } @@ -123,6 +124,10 @@ public void onEntityInteract(EntityInteractEvent event) { entity = new dEntity(event.getEntity()); location = new dLocation(event.getBlock().getLocation()); material = dMaterial.getMaterialFrom(event.getBlock().getType(), event.getBlock().getData()); + cuboids = new dList(); + for (dCuboid cuboid : dCuboid.getNotableCuboidsContaining(location)) { + cuboids.add(cuboid.identifySimple()); + } cancelled = event.isCancelled(); this.event = event; fire(); diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityKilledScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityKilledScriptEvent.java index cdb34b040c..34e927d0cd 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityKilledScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityKilledScriptEvent.java @@ -87,9 +87,11 @@ public boolean matches(ScriptContainer scriptContainer, String s) { String arg3 = CoreUtilities.getXthArg(3, lower); String attacker = cmd.equals("kills") ? arg0 : arg2.equals("by") ? arg3 : ""; String target = cmd.equals("kills") ? arg2 : arg0; - if (attacker.length() > 0) { + + if (!attacker.isEmpty()) { if (damager != null) { - if (!damager.matchesEntity(attacker) && !cause.asString().equals(attacker)) { + if (!cause.asString().equals(attacker) && + !tryEntity(projectile, attacker) && !tryEntity(damager, attacker)) { return false; } } @@ -97,11 +99,16 @@ else if (!cause.asString().equals(attacker)) { return false; } } - if (!entity.matchesEntity(target)) { + + if (!tryEntity(entity, target)) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { return false; } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityShootsBowEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityShootsBowEvent.java index a80ac9a633..8b3ce0f2f1 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityShootsBowEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityShootsBowEvent.java @@ -75,7 +75,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) { String attacker = CoreUtilities.getXthArg(0, lower); String item = CoreUtilities.getXthArg(2, lower); - if (!entity.matchesEntity(attacker)) { + if (!tryEntity(entity, attacker)) { return false; } @@ -83,7 +83,12 @@ public boolean matches(ScriptContainer scriptContainer, String s) { return false; } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; + } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntitySpawnScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntitySpawnScriptEvent.java index 5f1b4617b3..781e028300 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntitySpawnScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntitySpawnScriptEvent.java @@ -65,17 +65,19 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - if (!entity.matchesEntity(CoreUtilities.getXthArg(0, lower))) { + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { return false; } - if (!runInCheck(scriptContainer, s, lower, location)) { + if (CoreUtilities.xthArgEquals(2, lower, "because") + && !CoreUtilities.getXthArg(3, lower).equalsIgnoreCase(reason.toString())) { return false; } - if (CoreUtilities.xthArgEquals(2, lower, "because")) { - return CoreUtilities.getXthArg(3, lower).equalsIgnoreCase(reason.toString()); + if (!runInCheck(scriptContainer, s, lower, location)) { + return false; } + return true; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityTamesScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityTamesScriptEvent.java index 5eb5411d25..e9f687b10c 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityTamesScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityTamesScriptEvent.java @@ -59,19 +59,16 @@ public boolean matches(ScriptContainer scriptContainer, String s) { String cmd = CoreUtilities.getXthArg(1, lower); String ownerTest = cmd.equals("tames") ? CoreUtilities.getXthArg(0, lower) : CoreUtilities.getXthArg(2, lower); String tamed = cmd.equals("tamed") ? CoreUtilities.getXthArg(0, lower) : CoreUtilities.getXthArg(2, lower); - if (ownerTest.length() > 0) { - if (owner != null) { - if (!owner.matchesEntity(ownerTest)) { - return false; - } - } + + if (!tryEntity(owner, ownerTest) || !!tryEntity(entity, tamed)) { + return false; } - if (tamed.length() > 0) { - if (!entity.matchesEntity(tamed)) { - return false; - } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityTargetsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityTargetsScriptEvent.java index 63b329c78e..423ff23812 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityTargetsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityTargetsScriptEvent.java @@ -64,14 +64,13 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - if (!entity.matchesEntity(CoreUtilities.getXthArg(0, lower))) { + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { return false; } + String victim = CoreUtilities.getXthArg(2, lower); - if (!victim.equals("in") && !victim.equals("because") && target != null && victim.length() > 0) { - if (!target.matchesEntity(victim)) { - return false; - } + if (!victim.equals("in") && !victim.equals("because") && !tryEntity(target, victim)) { + return false; } if (!runInCheck(scriptContainer, s, lower, location)) { @@ -85,6 +84,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) { return false; } } + return true; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityTeleportScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityTeleportScriptEvent.java index 058523b162..1561e6bc35 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityTeleportScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityTeleportScriptEvent.java @@ -66,8 +66,17 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { - return entity.matchesEntity(CoreUtilities.getXthArg(0, CoreUtilities.toLowerCase(s))) - && runInCheck(scriptContainer, s, CoreUtilities.toLowerCase(s), from); + String lower = CoreUtilities.toLowerCase(s); + + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, from)) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityUnleashedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityUnleashedScriptEvent.java index a63ae01e74..5d0bd3da21 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityUnleashedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityUnleashedScriptEvent.java @@ -54,17 +54,19 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - if (!entity.matchesEntity(CoreUtilities.getXthArg(0, lower))) { + if (!tryEntity(entity, CoreUtilities.getXthArg(0, lower))) { return false; } - if (lower.contains("because")) { - if (!CoreUtilities.getXthArg(3, lower).equals(CoreUtilities.toLowerCase(reason.toString()))) { - return false; - } + if (lower.contains("because") && !CoreUtilities.xthArgEquals(3, lower, CoreUtilities.toLowerCase(reason.asString()))) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/FireworkBurstsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/FireworkBurstsScriptEvent.java index e6bf2f765b..9e768d5b90 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/FireworkBurstsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/FireworkBurstsScriptEvent.java @@ -51,7 +51,10 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/HangingBreaksScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/HangingBreaksScriptEvent.java index 1501af4bd6..41feaf5c51 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/HangingBreaksScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/HangingBreaksScriptEvent.java @@ -65,15 +65,13 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String hangCheck = CoreUtilities.getXthArg(0, lower); - if (!hangCheck.equals("hanging") - && !hanging.matchesEntity(hangCheck)) { + + if (!tryEntity(hanging, hangCheck)) { return false; } - if (CoreUtilities.xthArgEquals(2, lower, "because")) { - if (!CoreUtilities.getXthArg(3, lower).equals(CoreUtilities.toLowerCase(cause.asString()))) { - return false; - } + if (CoreUtilities.xthArgEquals(2, lower, "because") && !CoreUtilities.xthArgEquals(3, lower, CoreUtilities.toLowerCase(cause.asString()))) { + return false; } if (!runInCheck(scriptContainer, s, lower, location)) { diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/HorseJumpsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/HorseJumpsScriptEvent.java index b61bc69aab..aa090160b5 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/HorseJumpsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/HorseJumpsScriptEvent.java @@ -62,17 +62,19 @@ public boolean matches(ScriptContainer scriptContainer, String s) { String arg2 = CoreUtilities.getXthArg(1, lower); String tamed = arg2.equals("jumps") ? arg1 : arg2; - if (!entity.matchesEntity(tamed) || !tamed.equals(CoreUtilities.toLowerCase(variant.toString()))) { + if (!tryEntity(entity, tamed) || !tamed.equals(CoreUtilities.toLowerCase(variant.toString()))) { return false; } - if (CoreUtilities.getXthArg(2, lower).equals("jumps")) { - if (!arg1.equals(CoreUtilities.toLowerCase(color.toString()))) { - return false; - } + if (CoreUtilities.getXthArg(2, lower).equals("jumps") && !arg1.equals(CoreUtilities.toLowerCase(color.toString()))) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/ItemEnchantedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/ItemEnchantedScriptEvent.java index 3376687d62..4bb81ed7ea 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/ItemEnchantedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/ItemEnchantedScriptEvent.java @@ -68,6 +68,7 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String itemTest = CoreUtilities.getXthArg(0, lower); + if (!itemTest.equals("item") && !tryItem(item, itemTest)) { return false; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/ItemMergesScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/ItemMergesScriptEvent.java index c424a8ae82..f63d6802af 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/ItemMergesScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/ItemMergesScriptEvent.java @@ -61,8 +61,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String item_test = CoreUtilities.getXthArg(0, lower); - if (!item_test.equals("item") - && !item_test.equals(item.identifyNoIdentifier()) && !item_test.equals(item.identifySimpleNoIdentifier())) { + if (!tryItem(item, item_test)) { return false; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/ItemSpawnsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/ItemSpawnsScriptEvent.java index 4eefb43484..30f7cfa889 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/ItemSpawnsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/ItemSpawnsScriptEvent.java @@ -59,7 +59,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String item_test = CoreUtilities.getXthArg(0, lower); - if (!item_test.equals("item") && !tryItem(item, item_test)) { + if (!tryItem(item, item_test)) { return false; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/PigZappedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/PigZappedScriptEvent.java index 34f2e07b0e..4e20107fdc 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/PigZappedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/PigZappedScriptEvent.java @@ -49,7 +49,10 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { - return runInCheck(scriptContainer, s, CoreUtilities.toLowerCase(s), pig.getLocation()); + if (!runInCheck(scriptContainer, s, CoreUtilities.toLowerCase(s), pig.getLocation())) { + return false; + } + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/ProjectileHitsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/ProjectileHitsScriptEvent.java index 95344515c5..760eee0592 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/ProjectileHitsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/ProjectileHitsScriptEvent.java @@ -10,6 +10,7 @@ import net.aufdemrand.denizencore.scripts.ScriptEntryData; import net.aufdemrand.denizencore.scripts.containers.ScriptContainer; import net.aufdemrand.denizencore.utilities.CoreUtilities; +import net.aufdemrand.denizencore.utilities.debugging.dB; import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; @@ -75,24 +76,27 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String cmd = CoreUtilities.getXthArg(1, lower); - String pTest = cmd.equals("hits") ? CoreUtilities.getXthArg(0, lower) : - CoreUtilities.getXthArg(3, lower).equals("with") ? CoreUtilities.getXthArg(4, lower) : ""; + String pTest = ""; - if (pTest.length() > 0 && !projectile.matchesEntity(pTest)) { + if (cmd.equals("hits")) { + pTest = CoreUtilities.getXthArg(0, lower); + } + else if (cmd.equals("shoots") && CoreUtilities.xthArgEquals(3, lower, "with")) { + pTest = CoreUtilities.getXthArg(4, lower); + } + if (!pTest.isEmpty() && !pTest.equals("projectile") && !tryEntity(projectile, pTest)) { return false; } - String mat = CoreUtilities.getXthArg(2, lower); - if (!tryMaterial(material, mat)) { + if (!tryMaterial(material, CoreUtilities.getXthArg(2, lower))) { return false; } - String sTest = cmd.equals("shoots") ? CoreUtilities.getXthArg(0, lower) : ""; - if (shooter != null && sTest.length() > 0 && !shooter.matchesEntity(sTest)) { + if (!runInCheck(scriptContainer, s, lower, location)) { return false; } + return true; - return runInCheck(scriptContainer, s, lower, location); } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/ProjectileLaunchedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/ProjectileLaunchedScriptEvent.java index 63dba9102d..4e53c7b776 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/ProjectileLaunchedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/ProjectileLaunchedScriptEvent.java @@ -36,7 +36,7 @@ public ProjectileLaunchedScriptEvent() { } public static ProjectileLaunchedScriptEvent instance; - public dEntity entity; + public dEntity projectile; private dLocation location; public ProjectileLaunchEvent event; @@ -51,7 +51,8 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String projTest = CoreUtilities.getXthArg(0, lower); - if (!projTest.equals("projectile") && !entity.matchesEntity(projTest)) { + + if (!projTest.equals("projectile") && !tryEntity(projectile, projTest)) { return false; } @@ -85,7 +86,7 @@ public boolean applyDetermination(ScriptContainer container, String determinatio @Override public dObject getContext(String name) { if (name.equals("entity")) { - return entity; + return projectile; } return super.getContext(name); } @@ -94,7 +95,7 @@ public dObject getContext(String name) { public void onProjectileLaunched(ProjectileLaunchEvent event) { Entity projectile = event.getEntity(); dEntity.rememberEntity(projectile); - entity = new dEntity(projectile); + this.projectile = new dEntity(projectile); location = new dLocation(event.getEntity().getLocation()); cancelled = event.isCancelled(); this.event = event; diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/SheepDyedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/SheepDyedScriptEvent.java index 9e59ccefe1..6db5cb7440 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/SheepDyedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/SheepDyedScriptEvent.java @@ -53,27 +53,24 @@ public SheepDyedScriptEvent() { @Override public boolean couldMatch(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - String cmd = CoreUtilities.getXthArg(1, lower); - return (cmd.equals("dyed") || cmd.equals("dyes")); + return lower.startsWith("sheep dyed") || lower.startsWith("player dyes sheep"); } @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String cmd = CoreUtilities.getXthArg(1, lower); - String sheep = cmd.equals("dyed") ? CoreUtilities.getXthArg(0, lower) : CoreUtilities.getXthArg(3, lower); - if (!entity.matchesEntity(sheep)) { + + String new_color = cmd.equals("dyes") ? CoreUtilities.getXthArg(3, lower) : CoreUtilities.getXthArg(2, lower); + if (!new_color.isEmpty() && !new_color.equals(CoreUtilities.toLowerCase(color.toString()))) { return false; } - String new_color = cmd.equals("dyes") ? CoreUtilities.getXthArg(3, lower) : CoreUtilities.getXthArg(2, lower); - if (new_color.length() > 0) { - if (!new_color.equals(CoreUtilities.toLowerCase(color.toString()))) { - return false; - } + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/SheepRegrowsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/SheepRegrowsScriptEvent.java index 188a5b1513..439768b82c 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/SheepRegrowsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/SheepRegrowsScriptEvent.java @@ -48,7 +48,11 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - return runInCheck(scriptContainer, s, lower, location); + if (!runInCheck(scriptContainer, s, lower, location)) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/SlimeSplitsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/SlimeSplitsScriptEvent.java index fd34eb8619..b6eabab354 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/SlimeSplitsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/SlimeSplitsScriptEvent.java @@ -54,7 +54,8 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String counts = CoreUtilities.getXthArg(3, lower); - if (CoreUtilities.getXthArg(2, lower).equals("into") && counts.length() > 0) { + + if (CoreUtilities.xthArgEquals(2, lower, "into") && !counts.isEmpty()) { try { if (Integer.parseInt(counts) != count) { return false; @@ -64,7 +65,12 @@ public boolean matches(ScriptContainer scriptContainer, String s) { return false; } } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCollidesBlockScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCollidesBlockScriptEvent.java index 2d728b4597..4b088537c0 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCollidesBlockScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCollidesBlockScriptEvent.java @@ -53,17 +53,20 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - String ent = CoreUtilities.getXthArg(0, lower); - if (!vehicle.matchesEntity(ent)) { + + if (!tryEntity(vehicle, CoreUtilities.getXthArg(0, lower))) { + return false; + } + + if (!tryMaterial(material, CoreUtilities.getXthArg(3, lower))) { return false; } - String mat = CoreUtilities.getXthArg(3, lower); - if (!tryMaterial(material, mat)) { + if (!runInCheck(scriptContainer, s, lower, location)) { return false; } - return runInCheck(scriptContainer, s, lower, location); + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCollidesEntityScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCollidesEntityScriptEvent.java index d692675f2b..4c5b560cf0 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCollidesEntityScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCollidesEntityScriptEvent.java @@ -65,17 +65,19 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - String veh = CoreUtilities.getXthArg(0, lower); - if (!vehicle.matchesEntity(veh)) { + if (!tryEntity(vehicle, CoreUtilities.getXthArg(0, lower))) { return false; } - String ent = CoreUtilities.getXthArg(3, lower); - if (!entity.matchesEntity(ent)) { + if (!tryEntity(entity, CoreUtilities.getXthArg(3, lower))) { return false; } - return runInCheck(scriptContainer, s, lower, vehicle.getLocation()); + if (!runInCheck(scriptContainer, s, lower, vehicle.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCreatedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCreatedScriptEvent.java index e5add30ce6..d07a93f1d9 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCreatedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleCreatedScriptEvent.java @@ -47,8 +47,8 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - String veh = CoreUtilities.getXthArg(0, lower); - if (!vehicle.matchesEntity(veh)) { + + if (!tryEntity(vehicle, CoreUtilities.getXthArg(0, lower))) { return false; } diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleDamagedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleDamagedScriptEvent.java index e6d7e1b8cb..da43bd4019 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleDamagedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleDamagedScriptEvent.java @@ -67,15 +67,19 @@ public boolean matches(ScriptContainer scriptContainer, String s) { String cmd = CoreUtilities.getXthArg(1, lower); String veh = cmd.equals("damaged") ? CoreUtilities.getXthArg(0, lower) : CoreUtilities.getXthArg(2, lower); String ent = cmd.equals("damages") ? CoreUtilities.getXthArg(0, lower) : ""; - if (!vehicle.matchesEntity(veh)) { + + if (!tryEntity(vehicle, veh)) { + return false; + } + if (!ent.isEmpty() && entity != null && !tryEntity(entity, ent)) { return false; } - if (ent.length() > 0) { - if (entity == null || !entity.matchesEntity(ent)) { - return false; - } + + if (!runInCheck(scriptContainer, s, lower, vehicle.getLocation())) { + return false; } - return runInCheck(scriptContainer, s, lower, vehicle.getLocation()); + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleDestroyedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleDestroyedScriptEvent.java index a5d94a84a6..6d143a7912 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleDestroyedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleDestroyedScriptEvent.java @@ -62,15 +62,20 @@ public boolean matches(ScriptContainer scriptContainer, String s) { String cmd = CoreUtilities.getXthArg(1, lower); String veh = cmd.equals("destroyed") ? CoreUtilities.getXthArg(0, lower) : CoreUtilities.getXthArg(2, lower); String ent = cmd.equals("destroys") ? CoreUtilities.getXthArg(0, lower) : ""; - if (!vehicle.matchesEntity(veh)) { + + if (!tryEntity(vehicle, veh)) { return false; } - if (ent.length() > 0) { - if (entity == null || !entity.matchesEntity(ent)) { - return false; - } + + if (ent.length() > 0 && (entity == null || !tryEntity(entity, ent))) { + return false; } - return runInCheck(scriptContainer, s, lower, vehicle.getLocation()); + + if (!runInCheck(scriptContainer, s, lower, vehicle.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleMoveScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleMoveScriptEvent.java index 53731ed131..e26909e072 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/VehicleMoveScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/VehicleMoveScriptEvent.java @@ -51,8 +51,8 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - String veh = CoreUtilities.getXthArg(0, lower); - if (!vehicle.matchesEntity(veh)) { + + if (!tryEntity(vehicle, CoreUtilities.getXthArg(0, lower))) { return false; } diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerBreaksBlockScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerBreaksBlockScriptEvent.java index 352c8e335d..a565888043 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerBreaksBlockScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerBreaksBlockScriptEvent.java @@ -68,26 +68,21 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - String mat = CoreUtilities.getXthArg(2, lower); if (!tryMaterial(material, mat)) { return false; } - if (!runInCheck(scriptContainer, s, lower, location)) { return false; } - if (!runWithCheck(scriptContainer, s, lower, new dItem(event.getPlayer().getItemInHand()))) { return false; } // Deprecated in favor of with: format - if (CoreUtilities.xthArgEquals(3, lower, "with")) { - if (!tryItem(new dItem(event.getPlayer().getItemInHand()), CoreUtilities.getXthArg(4, lower))) { - return false; - } + if (CoreUtilities.xthArgEquals(3, lower, "with") + && !tryItem(new dItem(event.getPlayer().getItemInHand()), CoreUtilities.getXthArg(4, lower))) { + return false; } - return true; } diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerDragsInInvScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerDragsInInvScriptEvent.java index 19b7a25bc1..fadf6ebd87 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerDragsInInvScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerDragsInInvScriptEvent.java @@ -18,7 +18,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryDragEvent; -import org.bukkit.inventory.*; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; import org.bukkit.scheduler.BukkitRunnable; public class PlayerDragsInInvScriptEvent extends BukkitScriptEvent implements Listener { diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerDropsItemScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerDropsItemScriptEvent.java index f68413207b..2d329c138d 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerDropsItemScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerDropsItemScriptEvent.java @@ -11,7 +11,6 @@ import net.aufdemrand.denizencore.scripts.containers.ScriptContainer; import net.aufdemrand.denizencore.utilities.CoreUtilities; import org.bukkit.Bukkit; -import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerFishesScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerFishesScriptEvent.java index 36969b36cd..a8d696a0ba 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerFishesScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerFishesScriptEvent.java @@ -59,22 +59,22 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String fish = CoreUtilities.getXthArg(2, lower); - if (entity != null && fish.length() > 0) { - if (!entity.matchesEntity(fish)) { - return false; - } + + if (entity != null && !fish.isEmpty() && !tryEntity(entity, fish)) { + return false; } + List data = CoreUtilities.split(lower, ' '); for (int index = 0; index < data.size(); index++) { - if (data.get(index).equals("while")) { - if (!data.get(index + 1).equalsIgnoreCase(state.asString())) { - return false; - } + if (data.get(index).equals("while") && !data.get(index + 1).equalsIgnoreCase(state.asString())) { + return false; } } + if (!runInCheck(scriptContainer, s, lower, hook.getLocation())) { return false; } + return true; } diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerItemTakesDamageScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerItemTakesDamageScriptEvent.java index 82a2651ea9..040e191246 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerItemTakesDamageScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerItemTakesDamageScriptEvent.java @@ -13,6 +13,7 @@ import net.aufdemrand.denizencore.scripts.containers.ScriptContainer; import net.aufdemrand.denizencore.utilities.CoreUtilities; import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerItemDamageEvent; @@ -125,5 +126,14 @@ public void onPlayerItemTakesDamage(PlayerItemDamageEvent event) { fire(); event.setCancelled(cancelled); event.setDamage(damage.asInt()); + final Player p = event.getPlayer(); + if (cancelled) { + Bukkit.getScheduler().scheduleSyncDelayedTask(DenizenAPI.getCurrentInstance(), new Runnable() { + @Override + public void run() { + p.updateInventory(); + } + }, 1); + } } } diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerLeashesScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerLeashesEntityScriptEvent.java similarity index 77% rename from src/main/java/net/aufdemrand/denizen/events/player/PlayerLeashesScriptEvent.java rename to src/main/java/net/aufdemrand/denizen/events/player/PlayerLeashesEntityScriptEvent.java index 2f4be29e84..0dca29bb91 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerLeashesScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerLeashesEntityScriptEvent.java @@ -3,6 +3,7 @@ import net.aufdemrand.denizen.BukkitScriptEntryData; import net.aufdemrand.denizen.events.BukkitScriptEvent; import net.aufdemrand.denizen.objects.dEntity; +import net.aufdemrand.denizen.objects.dPlayer; import net.aufdemrand.denizen.utilities.DenizenAPI; import net.aufdemrand.denizencore.objects.dObject; import net.aufdemrand.denizencore.scripts.ScriptEntryData; @@ -13,7 +14,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerLeashEntityEvent; -public class PlayerLeashesScriptEvent extends BukkitScriptEvent implements Listener { +public class PlayerLeashesEntityScriptEvent extends BukkitScriptEvent implements Listener { // <--[event] // @Events @@ -32,13 +33,13 @@ public class PlayerLeashesScriptEvent extends BukkitScriptEvent implements Liste // // --> - public PlayerLeashesScriptEvent() { + public PlayerLeashesEntityScriptEvent() { instance = this; } - public static PlayerLeashesScriptEvent instance; + public static PlayerLeashesEntityScriptEvent instance; public dEntity entity; - public dEntity holder; + public dPlayer holder; public PlayerLeashEntityEvent event; @Override @@ -49,18 +50,21 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - String target = CoreUtilities.getXthArg(2, lower); - if (target.length() > 0) { - if (!target.equals(CoreUtilities.toLowerCase(entity.getName()))) { - return false; - } + + if (!tryEntity(entity, CoreUtilities.getXthArg(2, lower))) { + return false; + } + + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + + return true; } @Override public String getName() { - return "PlayerLeashes"; + return "PlayerLeashesEntity"; } @Override @@ -80,7 +84,7 @@ public boolean applyDetermination(ScriptContainer container, String determinatio @Override public ScriptEntryData getScriptEntryData() { - return new BukkitScriptEntryData(holder.isPlayer() ? holder.getDenizenPlayer() : null, null); + return new BukkitScriptEntryData(holder, null); } @Override @@ -99,10 +103,10 @@ public void onPlayerLeashes(PlayerLeashEntityEvent event) { if (dEntity.isNPC(event.getPlayer())) { return; } - holder = new dEntity(event.getPlayer()); + holder = new dPlayer(event.getPlayer()); entity = new dEntity(event.getEntity()); - this.event = event; cancelled = event.isCancelled(); + this.event = event; fire(); event.setCancelled(cancelled); } diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerPlacesHangingScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerPlacesHangingScriptEvent.java index 6ee1aac1fe..e540306509 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerPlacesHangingScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerPlacesHangingScriptEvent.java @@ -59,7 +59,7 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); String hangCheck = CoreUtilities.getXthArg(2, lower); - if (!hanging.matchesEntity(hangCheck)) { + if (!tryEntity(hanging, hangCheck)) { return false; } diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerShearsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerShearsScriptEvent.java index 07b355cf80..07d50f98d1 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerShearsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerShearsScriptEvent.java @@ -49,17 +49,22 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) { @Override public boolean matches(ScriptContainer scriptContainer, String s) { String lower = CoreUtilities.toLowerCase(s); - String ent = CoreUtilities.getXthArg(3, lower).equals("sheep") ? "sheep" : CoreUtilities.getXthArg(2, lower); - if (!ent.equals("sheep") && !entity.matchesEntity(ent)) { + String ent = CoreUtilities.xthArgEquals(3, lower, "sheep") ? "sheep" : CoreUtilities.getXthArg(2, lower); + + if (!ent.equals("sheep") && !tryEntity(entity, ent)) { return false; } - String color = CoreUtilities.getXthArg(3, lower).equals("sheep") ? CoreUtilities.getXthArg(2, lower) : ""; + String color = CoreUtilities.xthArgEquals(3, lower, "sheep") ? CoreUtilities.getXthArg(2, lower) : ""; if (color.length() > 0 && !color.equals(CoreUtilities.toLowerCase(((Sheep) entity.getBukkitEntity()).getColor().name()))) { return false; } - return runInCheck(scriptContainer, s, lower, entity.getLocation()); + if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerSneakScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerSneakScriptEvent.java index 6abd6916b2..4a554b2a89 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerSneakScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerSneakScriptEvent.java @@ -43,7 +43,7 @@ public PlayerSneakScriptEvent() { @Override public boolean couldMatch(ScriptContainer scriptContainer, String s) { - return CoreUtilities.getXthArg(2, CoreUtilities.toLowerCase(s)).startsWith("sneak"); + return CoreUtilities.getXthArg(2, CoreUtilities.toLowerCase(s)).equals("sneaking"); } @Override @@ -57,7 +57,11 @@ public boolean matches(ScriptContainer scriptContainer, String s) { return false; } - return runInCheck(scriptContainer, s, lower, event.getPlayer().getLocation()); + if (!runInCheck(scriptContainer, s, lower, event.getPlayer().getLocation())) { + return false; + } + + return true; } @Override diff --git a/src/main/java/net/aufdemrand/denizen/events/player/PlayerStatisticIncrementsScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/player/PlayerStatisticIncrementsScriptEvent.java index ee7f7508a2..511e4bf66c 100644 --- a/src/main/java/net/aufdemrand/denizen/events/player/PlayerStatisticIncrementsScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/player/PlayerStatisticIncrementsScriptEvent.java @@ -2,7 +2,9 @@ import net.aufdemrand.denizen.BukkitScriptEntryData; import net.aufdemrand.denizen.events.BukkitScriptEvent; -import net.aufdemrand.denizen.objects.*; +import net.aufdemrand.denizen.objects.dEntity; +import net.aufdemrand.denizen.objects.dMaterial; +import net.aufdemrand.denizen.objects.dPlayer; import net.aufdemrand.denizen.utilities.DenizenAPI; import net.aufdemrand.denizen.utilities.entity.DenizenEntityType; import net.aufdemrand.denizencore.objects.Element; diff --git a/src/main/java/net/aufdemrand/denizen/objects/dChunk.java b/src/main/java/net/aufdemrand/denizen/objects/dChunk.java index d5e1fa5ed0..6ef7239c63 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dChunk.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dChunk.java @@ -172,7 +172,7 @@ public static void registerTags() { // @attribute ,<#>]> // @returns dChunk // @description - // returns the chunk with the specified coordinates added to it. + // Returns the chunk with the specified coordinates added to it. // --> registerTag("add", new TagRunnable() { @Override @@ -199,7 +199,7 @@ public String run(Attribute attribute, dObject object) { // @attribute ,<#>]> // @returns dChunk // @description - // returns the chunk with the specified coordinates subtracted from it. + // Returns the chunk with the specified coordinates subtracted from it. // --> registerTag("sub", new TagRunnable() { @Override @@ -226,7 +226,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element(Boolean) // @description - // returns true if the chunk is currently loaded into memory. + // Returns true if the chunk is currently loaded into memory. // --> registerTag("is_loaded", new TagRunnable() { @Override @@ -239,7 +239,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element(Number) // @description - // returns the x coordinate of the chunk. + // Returns the x coordinate of the chunk. // --> registerTag("x", new TagRunnable() { @Override @@ -252,7 +252,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element(Number) // @description - // returns the z coordinate of the chunk. + // Returns the z coordinate of the chunk. // --> registerTag("z", new TagRunnable() { @Override @@ -265,7 +265,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns dWorld // @description - // returns the world associated with the chunk. + // Returns the world associated with the chunk. // --> registerTag("world", new TagRunnable() { @Override @@ -278,7 +278,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns dCuboid // @description - // returns a cuboid of this chunk. + // Returns a cuboid of this chunk. // --> registerTag("cuboid", new TagRunnable() { @Override @@ -294,7 +294,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns dList(dEntity) // @description - // returns a list of entities in the chunk. + // Returns a list of entities in the chunk. // --> registerTag("entities", new TagRunnable() { @Override @@ -312,7 +312,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns dList(dEntity) // @description - // returns a list of living entities in the chunk. This includes Players, mobs, NPCs, etc., but excludes + // Returns a list of living entities in the chunk. This includes Players, mobs, NPCs, etc., but excludes // dropped items, experience orbs, etc. // --> registerTag("living_entities", new TagRunnable() { @@ -333,7 +333,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns dList(dPlayer) // @description - // returns a list of players in the chunk. + // Returns a list of players in the chunk. // --> registerTag("players", new TagRunnable() { @Override @@ -353,7 +353,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns dList(Element) // @description - // returns a list of the height of each block in the chunk. + // Returns a list of the height of each block in the chunk. // --> registerTag("height_map", new TagRunnable() { @Override @@ -370,7 +370,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element(Decimal) // @description - // returns the average height of the blocks in the chunk. + // Returns the average height of the blocks in the chunk. // --> registerTag("average_height", new TagRunnable() { @Override @@ -411,7 +411,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns dList(dLocation) // @description - // returns a list of the highest non-air surface blocks in the chunk. + // Returns a list of the highest non-air surface blocks in the chunk. // --> registerTag("surface_blocks", new TagRunnable() { @Override @@ -432,7 +432,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns dList(dLocation) // @description - // returns whether the chunk is a specially located 'slime spawner' chunk. + // Returns whether the chunk is a specially located 'slime spawner' chunk. // --> registerTag("spawn_slimes", new TagRunnable() { @Override diff --git a/src/main/java/net/aufdemrand/denizen/objects/dColor.java b/src/main/java/net/aufdemrand/denizen/objects/dColor.java index d00cbb1bd5..ffa4e93b14 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dColor.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dColor.java @@ -203,7 +203,7 @@ public static void registerTags() { // @attribute // @returns Element(Number) // @description - // returns the red value of this color. + // Returns the red value of this color. // --> registerTag("red", new TagRunnable() { @Override @@ -216,7 +216,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element(Number) // @description - // returns the green value of this color. + // Returns the green value of this color. // --> registerTag("green", new TagRunnable() { @Override @@ -229,7 +229,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element(Number) // @description - // returns the blue value of this color. + // Returns the blue value of this color. // --> registerTag("blue", new TagRunnable() { @Override @@ -242,7 +242,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element // @description - // returns the RGB value of this color. + // Returns the RGB value of this color. // EG, 255,0,255 // --> registerTag("rgb", new TagRunnable() { @@ -257,7 +257,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element(Number) // @description - // returns the hue value of this color. + // Returns the hue value of this color. // --> registerTag("hue", new TagRunnable() { @Override @@ -270,7 +270,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element(Number) // @description - // returns the saturation value of this color. + // Returns the saturation value of this color. // --> registerTag("saturation", new TagRunnable() { @Override @@ -283,7 +283,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element(Number) // @description - // returns the brightness value of this color. + // Returns the brightness value of this color. // --> registerTag("brightness", new TagRunnable() { @Override @@ -296,7 +296,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element // @description - // returns the HSV value of this color. + // Returns the HSV value of this color. // EG, 100,100,255 // --> registerTag("hsv", new TagRunnable() { @@ -311,7 +311,7 @@ public String run(Attribute attribute, dObject object) { // @attribute // @returns Element // @description - // returns the name of this color (or red,green,blue if none). + // Returns the name of this color (or red,green,blue if none). // --> registerTag("name", new TagRunnable() { @Override @@ -324,7 +324,7 @@ public String run(Attribute attribute, dObject object) { // @attribute ]> // @returns dColor // @description - // returns the color that results if you mix this color with another. + // Returns the color that results if you mix this color with another. // --> registerTag("mix", new TagRunnable() { @Override diff --git a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java index 16f23d264d..2de0c0f796 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java @@ -1181,6 +1181,26 @@ public int comparesTo(dEntity entity) { return 0; } + public boolean comparedTo(String compare) { + compare = CoreUtilities.toLowerCase(compare); + if (compare.equals("entity")) { + return true; + } + else if (compare.equals("player")) { + return isPlayer(); + } + else if (compare.equals("npc")) { + return isCitizensNPC() || isNPC(); + } + else if (getEntityScript() != null && compare.equals(CoreUtilities.toLowerCase(getEntityScript()))) { + return true; + } + else if (compare.equals(getEntityType().getLowercaseName())) { + return true; + } + return false; + } + ///////////////////// // dObject Methods @@ -1318,12 +1338,12 @@ public boolean isUnique() { } public boolean matchesEntity(String ent) { - if (ent.equalsIgnoreCase("npc")) { - return this.isCitizensNPC(); - } if (ent.equalsIgnoreCase("entity")) { return true; } + if (ent.equalsIgnoreCase("npc")) { + return this.isCitizensNPC(); + } if (ent.equalsIgnoreCase("player")) { return this.isPlayer(); } @@ -1498,7 +1518,7 @@ public String getAttribute(Attribute attribute) { // @attribute ]> // @returns Element(Boolean) // @description - // returns true if the entity has the specified flag, otherwise returns false. + // Returns true if the entity has the specified flag, otherwise returns false. // --> if (attribute.startsWith("has_flag")) { String flag_name; @@ -1519,7 +1539,7 @@ public String getAttribute(Attribute attribute) { // @attribute ]> // @returns Flag dList // @description - // returns the specified flag from the entity. + // Returns the specified flag from the entity. // --> if (attribute.startsWith("flag")) { String flag_name; @@ -1708,7 +1728,7 @@ else if (getLivingEntity().getType() == EntityType.PIG) { // @returns dLocation // @group location // @description - // returns a 2D location indicating where on the map the entity's looking at. + // Returns a 2D location indicating where on the map the entity's looking at. // Each coordinate is in the range of 0 to 128. // --> if (attribute.startsWith("map_trace")) { @@ -1757,7 +1777,7 @@ else if (mtr.angle == BlockFace.EAST) { // @returns dLocation // @group location // @description - // returns the location of the entity's eyes. + // Returns the location of the entity's eyes. // --> if (attribute.startsWith("eye_location")) { return new dLocation(getEyeLocation()) diff --git a/src/main/java/net/aufdemrand/denizen/objects/dInventory.java b/src/main/java/net/aufdemrand/denizen/objects/dInventory.java index 26a34347f1..9966297ed5 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dInventory.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dInventory.java @@ -1763,7 +1763,7 @@ else if (item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName // @returns Element(Number) // @description // Returns the combined quantity of itemstacks that match an item if - // one if specified, or the combined quantity of all itemstacks + // one is specified, or the combined quantity of all itemstacks // if one is not. // --> if ((attribute.startsWith("quantity") || attribute.startsWith("qty")) diff --git a/src/main/java/net/aufdemrand/denizen/objects/dLocation.java b/src/main/java/net/aufdemrand/denizen/objects/dLocation.java index 2d047bb1e7..8a70cf782e 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dLocation.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dLocation.java @@ -35,10 +35,9 @@ import org.bukkit.material.Button; import org.bukkit.material.Lever; import org.bukkit.material.MaterialData; -import org.bukkit.util.*; +import org.bukkit.util.BlockIterator; import java.util.*; -import java.util.Vector; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -1289,11 +1288,7 @@ else if (attribute.startsWith("entities") && attribute.hasContext(2)) { dList ent_list = new dList(); if (attribute.hasContext(1)) { - for (String ent : dList.valueOf(attribute.getContext(1))) { - if (dEntity.matches(ent)) { - ent_list.add(ent.toUpperCase()); - } - } + ent_list = dList.valueOf(attribute.getContext(1)); } ArrayList found = new ArrayList(); double radius = aH.matchesDouble(attribute.getContext(2)) ? attribute.getDoubleContext(2) : 10; @@ -1302,10 +1297,8 @@ else if (attribute.startsWith("entities") if (Utilities.checkLocation(this, entity.getLocation(), radius)) { dEntity current = new dEntity(entity); if (!ent_list.isEmpty()) { - String type = current.getEntityType().getName(); for (String ent : ent_list) { - if ((type.equals(ent) || - current.identify().equalsIgnoreCase(ent)) && entity.isValid()) { + if (current.comparedTo(ent)) { found.add(current); break; } @@ -1372,7 +1365,7 @@ public int compare(dEntity ent1, dEntity ent2) { } List locs = PathFinder.getPath(this, two); dList list = new dList(); - for (dLocation loc: locs) { + for (dLocation loc : locs) { list.add(loc.identify()); } return list.getAttribute(attribute.fulfill(1)); @@ -1412,7 +1405,7 @@ public int compare(dEntity ent1, dEntity ent2) { // @attribute // @returns dChunk // @description - // returns the chunk that this location belongs to. + // Returns the chunk that this location belongs to. // --> if (attribute.startsWith("chunk") || attribute.startsWith("get_chunk")) { @@ -1423,7 +1416,7 @@ public int compare(dEntity ent1, dEntity ent2) { // @attribute // @returns dLocation // @description - // returns the raw representation of this location, + // Returns the raw representation of this location, // ignoring any notables it might match. // --> if (attribute.startsWith("raw")) { @@ -1899,10 +1892,10 @@ && getBlock().getType() == Material.COMMAND) { BlockFace face = BlockFace.SELF; MaterialData data = getBlock().getState().getData(); if (data instanceof Lever) { - face = ((Lever)data).getAttachedFace(); + face = ((Lever) data).getAttachedFace(); } else if (data instanceof Button) { - face = ((Button)data).getAttachedFace(); + face = ((Button) data).getAttachedFace(); } if (face != BlockFace.SELF) { return new dLocation(getBlock().getRelative(face).getLocation()).getAttribute(attribute.fulfill(1)); diff --git a/src/main/java/net/aufdemrand/denizen/objects/dNPC.java b/src/main/java/net/aufdemrand/denizen/objects/dNPC.java index 39af1e7a80..dc69aa63e3 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dNPC.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dNPC.java @@ -483,7 +483,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns Element // @description - // returns the NPC's display name. + // Returns the NPC's display name. // --> if (attribute.startsWith("name.nickname")) { return new Element(getCitizen().hasTrait(NicknameTrait.class) ? getCitizen().getTrait(NicknameTrait.class) @@ -494,7 +494,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns Element // @description - // returns the name of the NPC. + // Returns the name of the NPC. // --> if (attribute.startsWith("name")) { return new Element(getName()) @@ -531,6 +531,16 @@ public String getAttribute(Attribute attribute) { } } + // <--[tag] + // @attribute + // @returns Element(Boolean) + // @description + // Returns whether the NPC is pushable. + // --> + if (attribute.startsWith("pushable") || attribute.startsWith("is_pushable")) { + return new Element(getPushableTrait().isPushable()).getAttribute(attribute.fulfill(1)); + } + // <--[tag] // @attribute ]> // @returns Element(Boolean) @@ -551,7 +561,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns dList // @description - // returns a list of anchor names currently assigned to the NPC. + // Returns a list of anchor names currently assigned to the NPC. // --> if (attribute.startsWith("anchor.list") || attribute.startsWith("anchors.list")) { @@ -566,7 +576,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns Element(Boolean) // @description - // returns whether the NPC has anchors assigned. + // Returns whether the NPC has anchors assigned. // --> if (attribute.startsWith("has_anchors")) { return (new Element(getCitizen().getTrait(Anchors.class).getAnchors().size() > 0)) @@ -577,7 +587,7 @@ public String getAttribute(Attribute attribute) { // @attribute ]> // @returns dLocation // @description - // returns the location associated with the specified anchor, or null if it doesn't exist. + // Returns the location associated with the specified anchor, or null if it doesn't exist. // --> if (attribute.startsWith("anchor")) { if (attribute.hasContext(1) @@ -592,7 +602,7 @@ && getCitizen().getTrait(Anchors.class).getAnchor(attribute.getContext(1)) != nu // @attribute ]> // @returns Element(Boolean) // @description - // returns true if the NPC has the specified flag, otherwise returns false. + // Returns true if the NPC has the specified flag, otherwise returns false. // --> if (attribute.startsWith("has_flag")) { String flag_name; @@ -609,7 +619,7 @@ && getCitizen().getTrait(Anchors.class).getAnchor(attribute.getContext(1)) != nu // @attribute ]> // @returns Flag dList // @description - // returns the specified flag from the NPC. + // Returns the specified flag from the NPC. // --> if (attribute.startsWith("flag")) { String flag_name; @@ -679,7 +689,7 @@ && getCitizen().getTrait(Anchors.class).getAnchor(attribute.getContext(1)) != nu // @attribute ]> // @returns Element // @description - // returns the specified constant from the NPC. + // Returns the specified constant from the NPC. // --> if (attribute.startsWith("constant")) { if (attribute.hasContext(1)) { @@ -732,7 +742,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Boolean) // @description - // returns whether the NPC is currently engaged. + // Returns whether the NPC is currently engaged. // See <@link command engage> // --> if (attribute.startsWith("engaged") || attribute.startsWith("is_engaged")) { @@ -743,7 +753,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Boolean) // @description - // returns whether the NPC is currently invulnerable. + // Returns whether the NPC is currently invulnerable. // See <@link command vulnerable> // --> if (attribute.startsWith("invulnerable") || attribute.startsWith("vulnerable")) { @@ -754,7 +764,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Number) // @description - // returns the NPC's ID number. + // Returns the NPC's ID number. // --> if (attribute.startsWith("id")) { return new Element(getId()).getAttribute(attribute.fulfill(1)); @@ -764,7 +774,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns dPlayer/Element // @description - // returns the owner of the NPC as a dPlayer if it's a player, otherwise as just the name. + // Returns the owner of the NPC as a dPlayer if it's a player, otherwise as just the name. // --> if (attribute.startsWith("owner")) { String owner = getOwner(); @@ -784,7 +794,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element // @description - // returns whether the NPC has a custom skinskin. + // Returns whether the NPC has a custom skinskin. // --> if (attribute.startsWith("has_skin")) { return new Element(getCitizen().data().has(NPC.PLAYER_SKIN_UUID_METADATA)).getAttribute(attribute.fulfill(1)); @@ -794,7 +804,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element // @description - // returns the NPC's custom skin blob, if any. + // Returns the NPC's custom skin blob, if any. // --> if (attribute.startsWith("skin_blob")) { if (getCitizen().data().has(NPC.PLAYER_SKIN_TEXTURE_PROPERTIES_METADATA)) { @@ -806,7 +816,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element // @description - // returns the NPC's custom skin, if any. + // Returns the NPC's custom skin, if any. // --> if (attribute.startsWith("skin")) { if (getCitizen().data().has(NPC.PLAYER_SKIN_UUID_METADATA)) { @@ -828,7 +838,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Boolean) // @description - // returns whether the NPC is spawned. + // Returns whether the NPC is spawned. // --> if (attribute.startsWith("is_spawned")) { return new Element(isSpawned()).getAttribute(attribute.fulfill(1)); @@ -866,7 +876,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns dLocation // @description - // returns the NPC's previous navigated location. + // Returns the NPC's previous navigated location. // --> if (attribute.startsWith("location.previous_location")) { return (NPCTags.previousLocations.containsKey(getId()) @@ -879,7 +889,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @returns dLocation // @mechanism dNPC.teleport_on_stuck // @description - // returns whether the NPC teleports when it is stuck. + // Returns whether the NPC teleports when it is stuck. // --> if (attribute.startsWith("teleport_on_stuck")) { return new Element(getNavigator().getDefaultParameters().stuckAction() == TeleportStuckAction.INSTANCE) @@ -902,7 +912,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns dScript // @description - // returns the NPC's assigned script. + // Returns the NPC's assigned script. // --> if (attribute.startsWith("script")) { NPC citizen = getCitizen(); @@ -919,7 +929,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Boolean) // @description - // returns whether the NPC is currently navigating. + // Returns whether the NPC is currently navigating. // --> if (attribute.startsWith("navigator.is_navigating")) { return new Element(getNavigator().isNavigating()).getAttribute(attribute.fulfill(2)); @@ -929,7 +939,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Number) // @description - // returns the current speed of the NPC. + // Returns the current speed of the NPC. // --> if (attribute.startsWith("navigator.speed")) { return new Element(getNavigator().getLocalParameters().speed()) @@ -940,7 +950,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Number) // @description - // returns the maximum pathfinding range. + // Returns the maximum pathfinding range. // --> if (attribute.startsWith("navigator.range")) { return new Element(getNavigator().getLocalParameters().range()) @@ -951,7 +961,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Number) // @description - // returns the maximum attack range. + // Returns the maximum attack range. // --> if (attribute.startsWith("navigator.attack_range")) { return new Element(getNavigator().getLocalParameters().attackRange()) @@ -962,7 +972,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element // @description - // returns the NPC's attack strategy. + // Returns the NPC's attack strategy. // --> if (attribute.startsWith("navigator.attack_strategy")) { return new Element(getNavigator().getLocalParameters().attackStrategy().toString()) @@ -973,7 +983,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Number) // @description - // returns the NPC movement speed modifier. + // Returns the NPC movement speed modifier. // --> if (attribute.startsWith("navigator.speed_modifier")) { return new Element(getNavigator().getLocalParameters().speedModifier()) @@ -984,7 +994,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Number) // @description - // returns the base navigation speed. + // Returns the base navigation speed. // --> if (attribute.startsWith("navigator.base_speed")) { return new Element(getNavigator().getLocalParameters().baseSpeed()) @@ -995,7 +1005,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Boolean) // @description - // returns whether the NPC will avoid water. + // Returns whether the NPC will avoid water. // --> if (attribute.startsWith("navigator.avoid_water")) { return new Element(getNavigator().getLocalParameters().avoidWater()) @@ -1006,7 +1016,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns dLocation // @description - // returns the location the NPC is curently navigating towards. + // Returns the location the NPC is curently navigating towards. // --> if (attribute.startsWith("navigator.target_location")) { return (getNavigator().getTargetAsLocation() != null @@ -1018,7 +1028,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element(Boolean) // @description - // returns whether the NPC is in combat. + // Returns whether the NPC is in combat. // --> if (attribute.startsWith("navigator.is_fighting")) { return new Element(getNavigator().getEntityTarget() != null && getNavigator().getEntityTarget().isAggressive()) @@ -1029,7 +1039,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns Element // @description - // returns the entity type of the target. + // Returns the entity type of the target. // --> if (attribute.startsWith("navigator.target_type")) // TODO: IMPROVE @@ -1043,7 +1053,7 @@ && getCitizen().getTrait(ConstantsTrait.class).getConstant(attribute.getContext( // @attribute // @returns dEntity // @description - // returns the entity being targeted. + // Returns the entity being targeted. // --> if (attribute.startsWith("navigator.target_entity")) { return (getNavigator().getEntityTarget() != null && getNavigator().getEntityTarget().getTarget() != null diff --git a/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java b/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java index bb61660ab9..8481682e75 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dPlayer.java @@ -680,7 +680,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns Element // @description - // returns the last thing the player said. + // Returns the last thing the player said. // If a number is specified, returns an earlier thing the player said. // Works with offline players. // --> @@ -705,7 +705,7 @@ public String getAttribute(Attribute attribute) { // @attribute ]> // @returns Flag dList // @description - // returns the specified flag from the player. + // Returns the specified flag from the player. // Works with offline players. // --> if (attribute.startsWith("flag") && attribute.hasContext(1)) { @@ -731,7 +731,7 @@ public String getAttribute(Attribute attribute) { // @attribute ]> // @returns Element(Boolean) // @description - // returns true if the Player has the specified flag, otherwise returns false. + // Returns true if the Player has the specified flag, otherwise returns false. // Works with offline players. // --> if (attribute.startsWith("has_flag") && attribute.hasContext(1)) { @@ -803,7 +803,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns Element(Decimal) // @description - // returns the amount of money the player has with the registered Economy system. + // Returns the amount of money the player has with the registered Economy system. // May work offline depending on economy plugin. // --> @@ -814,7 +814,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns Element // @description - // returns the name of a single piece of currency - EG: Dollar + // Returns the name of a single piece of currency - EG: Dollar // (Only if supported by the registered Economy system.) // --> if (attribute.startsWith("money.currency_singular")) { @@ -826,7 +826,7 @@ public String getAttribute(Attribute attribute) { // @attribute // @returns Element // @description - // returns the name of multiple pieces of currency - EG: Dollars + // Returns the name of multiple pieces of currency - EG: Dollars // (Only if supported by the registered Economy system.) // --> if (attribute.startsWith("money.currency")) { @@ -1031,7 +1031,7 @@ else if (attribute.startsWith("uuid") && !isOnline()) // @attribute // @returns Element // @description - // returns the ID used to save the player in Denizen's saves.yml file. + // Returns the ID used to save the player in Denizen's saves.yml file. // Works with offline players. // --> if (attribute.startsWith("save_name")) { @@ -1075,7 +1075,7 @@ else if (attribute.startsWith("uuid") && !isOnline()) // @attribute // @returns Duration // @description - // returns the millisecond time of when the player first logged on to this server. + // Returns the millisecond time of when the player first logged on to this server. // Works with offline players. // --> if (attribute.startsWith("first_played")) { @@ -1092,7 +1092,7 @@ else if (attribute.startsWith("uuid") && !isOnline()) // @attribute // @returns Element(Boolean) // @description - // returns whether the player has played before. + // Returns whether the player has played before. // Works with offline players. // Note: This will just always return true. // --> @@ -1105,7 +1105,7 @@ else if (attribute.startsWith("uuid") && !isOnline()) // @attribute // @returns Element(Boolean) // @description - // returns whether the player's health bar is currently being scaled. + // Returns whether the player's health bar is currently being scaled. // --> if (attribute.startsWith("health.is_scaled")) { return new Element(getPlayerEntity().isHealthScaled()) @@ -1116,7 +1116,7 @@ else if (attribute.startsWith("uuid") && !isOnline()) // @attribute // @returns Element(Decimal) // @description - // returns the current scale for the player's health bar + // Returns the current scale for the player's health bar // --> if (attribute.startsWith("health.scale")) { return new Element(getPlayerEntity().getHealthScale()) @@ -1145,7 +1145,7 @@ else if (attribute.startsWith("uuid") && !isOnline()) // @attribute // @returns Element(Boolean) // @description - // returns whether the player is banned. + // Returns whether the player is banned. // --> if (attribute.startsWith("is_banned")) { BanEntry ban = Bukkit.getBanList(BanList.Type.NAME).getBanEntry(getName()); @@ -1162,7 +1162,7 @@ else if (ban.getExpiration() == null) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player is currently online. + // Returns whether the player is currently online. // Works with offline players (returns false in that case). // --> if (attribute.startsWith("is_online")) { @@ -1173,7 +1173,7 @@ else if (ban.getExpiration() == null) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player is a full server operator. + // Returns whether the player is a full server operator. // Works with offline players. // --> if (attribute.startsWith("is_op")) { @@ -1185,7 +1185,7 @@ else if (ban.getExpiration() == null) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player is whitelisted. + // Returns whether the player is whitelisted. // Works with offline players. // --> if (attribute.startsWith("is_whitelisted")) { @@ -1197,7 +1197,7 @@ else if (ban.getExpiration() == null) { // @attribute // @returns Duration // @description - // returns the datestamp of when the player was last seen in duration. + // Returns the datestamp of when the player was last seen in duration. // Works with offline players. // --> if (attribute.startsWith("last_played")) { @@ -1222,7 +1222,7 @@ else if (ban.getExpiration() == null) { // @attribute // @returns dList // @description - // returns a list of all groups the player is in. + // Returns a list of all groups the player is in. // May work with offline players, depending on permission plugin. // --> if (attribute.startsWith("groups")) { @@ -1255,7 +1255,7 @@ else if (ban.getExpiration().before(new Date())) { // @attribute // @returns Duration // @description - // returns the expiration of the player's ban, if they are banned. + // Returns the expiration of the player's ban, if they are banned. // --> if (attribute.startsWith("expiration")) { return new Duration(ban.getExpiration().getTime() / 50) @@ -1265,7 +1265,7 @@ else if (ban.getExpiration().before(new Date())) { // @attribute // @returns Element // @description - // returns the reason for the player's ban, if they are banned. + // Returns the reason for the player's ban, if they are banned. // --> else if (attribute.startsWith("reason")) { return new Element(ban.getReason()) @@ -1275,7 +1275,7 @@ else if (attribute.startsWith("reason")) { // @attribute // @returns Duration // @description - // returns when the player's ban was created, if they are banned. + // Returns when the player's ban was created, if they are banned. // --> else if (attribute.startsWith("created")) { return new Duration(ban.getCreated().getTime() / 50) @@ -1288,7 +1288,7 @@ else if (attribute.startsWith("created")) { // @attribute ]> // @returns Element(Boolean) // @description - // returns whether the player is in the specified group (requires the player to be online) + // Returns whether the player is in the specified group (requires the player to be online) // --> if (attribute.startsWith("in_group")) { if (Depends.permissions == null) { @@ -1304,7 +1304,7 @@ else if (attribute.startsWith("created")) { // @attribute ].global> // @returns Element(Boolean) // @description - // returns whether the player has the group with no regard to the + // Returns whether the player has the group with no regard to the // player's current world. // (Works with offline players) // (Note: This may or may not be functional with your permissions system.) @@ -1320,7 +1320,7 @@ else if (attribute.startsWith("created")) { // @attribute ].world> // @returns Element(Boolean) // @description - // returns whether the player has the group in regards to the + // Returns whether the player has the group in regards to the // player's current world. // (Works with offline players) // (Note: This may or may not be functional with your permissions system.) @@ -1343,7 +1343,7 @@ else if (isOnline()) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player has the specified node. + // Returns whether the player has the specified node. // (Requires the player to be online) // --> if (attribute.startsWith("permission") @@ -1355,7 +1355,7 @@ else if (isOnline()) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player has the specified node, regardless of world. + // Returns whether the player has the specified node, regardless of world. // (Works with offline players) // (Note: this may or may not be functional with your permissions system.) // --> @@ -1377,7 +1377,7 @@ else if (isOnline()) { // @attribute ]> // @returns Element(Boolean) // @description - // returns whether the player has the specified node in regards to the + // Returns whether the player has the specified node in regards to the // specified world. // (Works with offline players) // (Note: This may or may not be functional with your permissions system.) @@ -1411,7 +1411,7 @@ else if (isOnline()) { // @attribute // @returns dInventory // @description - // returns a dInventory of the player's current inventory. + // Returns a dInventory of the player's current inventory. // Works with offline players. // --> if (attribute.startsWith("inventory")) { @@ -1467,7 +1467,7 @@ else if (isOnline()) { // @attribute // @returns Element(Number) // @description - // returns the slot location of the player's selected item. + // Returns the slot location of the player's selected item. // --> if (attribute.startsWith("item_in_hand.slot")) { return new Element(getPlayerEntity().getInventory().getHeldItemSlot() + 1) @@ -1558,7 +1558,7 @@ else if (isOnline()) { // @attribute // @returns dNPC // @description - // returns the dNPC that the player currently has selected with + // Returns the dNPC that the player currently has selected with // '/npc select', null if no player selected. // --> if (attribute.startsWith("selected_npc")) { @@ -1576,7 +1576,7 @@ else if (isOnline()) { // @attribute // @returns dEntity // @description - // returns the dEntity object of the player. + // Returns the dEntity object of the player. // (Note: This should never actually be needed. is considered a valid dEntity by script commands.) // --> if (attribute.startsWith("entity") && !attribute.startsWith("entity_")) { @@ -1593,7 +1593,7 @@ else if (isOnline()) { // @attribute // @returns Element // @description - // returns the player's IP address host name. + // Returns the player's IP address host name. // --> if (attribute.startsWith("ip") || attribute.startsWith("host_name")) { @@ -1603,7 +1603,7 @@ else if (isOnline()) { // @attribute // @returns Element // @description - // returns the player's IP address. + // Returns the player's IP address. // --> if (attribute.startsWith("address")) { return new Element(getPlayerEntity().getAddress().toString()) @@ -1618,7 +1618,7 @@ else if (isOnline()) { // @attribute // @returns Element // @description - // returns the display name of the player, which may contain + // Returns the display name of the player, which may contain // prefixes and suffixes, colors, etc. // --> if (attribute.startsWith("name.display")) { @@ -1630,7 +1630,7 @@ else if (isOnline()) { // @attribute // @returns Element // @description - // returns the name of the player as shown in the player list. + // Returns the name of the player as shown in the player list. // --> if (attribute.startsWith("name.list")) { return new Element(getPlayerEntity().getPlayerListName()) @@ -1652,7 +1652,7 @@ else if (isOnline()) { // @attribute // @returns Element // @description - // returns the name of the player. + // Returns the name of the player. // --> if (attribute.startsWith("name")) { return new Element(getName()).getAttribute(attribute.fulfill(1)); @@ -1662,7 +1662,7 @@ else if (isOnline()) { // @attribute ]> // @returns Element(Boolean) // @description - // returns whether the player has finished the specified script. + // Returns whether the player has finished the specified script. // --> if (attribute.startsWith("has_finished")) { dScript script = dScript.valueOf(attribute.getContext(1)); @@ -1678,7 +1678,7 @@ else if (isOnline()) { // @attribute ]> // @returns Element(Boolean) // @description - // returns whether the player has failed the specified script. + // Returns whether the player has failed the specified script. // --> if (attribute.startsWith("has_failed")) { dScript script = dScript.valueOf(attribute.getContext(1)); @@ -1698,7 +1698,7 @@ else if (isOnline()) { // @attribute // @returns dLocation // @description - // returns the location of the player's compass target. + // Returns the location of the player's compass target. // --> if (attribute.startsWith("compass_target")) { Location target = getPlayerEntity().getCompassTarget(); @@ -1730,7 +1730,7 @@ else if (isOnline()) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player is allowed to fly. + // Returns whether the player is allowed to fly. // @mechanism dPlayer.can_fly // --> if (attribute.startsWith("can_fly") || attribute.startsWith("allowed_flight")) { @@ -1742,7 +1742,7 @@ else if (isOnline()) { // @attribute // @returns Element(Decimal) // @description - // returns the speed the player can fly at. + // Returns the speed the player can fly at. // --> if (attribute.startsWith("fly_speed")) { return new Element(getPlayerEntity().getFlySpeed()) @@ -1753,7 +1753,7 @@ else if (isOnline()) { // @attribute // @returns Element // @description - // returns a 'formatted' value of the player's current food level. + // Returns a 'formatted' value of the player's current food level. // May be 'starving', 'famished', 'parched, 'hungry' or 'healthy'. // --> if (attribute.startsWith("food_level.formatted")) { @@ -1783,7 +1783,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element(Decimal) // @description - // returns the current saturation of the player. + // Returns the current saturation of the player. // --> if (attribute.startsWith("saturation")) { return new Element(getPlayerEntity().getSaturation()) @@ -1794,7 +1794,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element(Number) // @description - // returns the current food level of the player. + // Returns the current food level of the player. // --> if (attribute.startsWith("food_level")) { return new Element(getPlayerEntity().getFoodLevel()) @@ -1805,7 +1805,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element // @description - // returns the name of the gamemode the player is currently set to. + // Returns the name of the gamemode the player is currently set to. // --> if (attribute.startsWith("gamemode")) { attribute = attribute.fulfill(1); @@ -1813,7 +1813,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element(Number) // @description - // returns the gamemode ID of the player. 0 = survival, 1 = creative, 2 = adventure, 3 = spectator + // Returns the gamemode ID of the player. 0 = survival, 1 = creative, 2 = adventure, 3 = spectator // --> if (attribute.startsWith("id")) { return new Element(getPlayerEntity().getGameMode().getValue()) @@ -1827,7 +1827,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player is currently blocking. + // Returns whether the player is currently blocking. // --> if (attribute.startsWith("is_blocking")) { return new Element(getPlayerEntity().isBlocking()) @@ -1838,7 +1838,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element(Number) // @description - // returns the player's current ping. + // Returns the player's current ping. // --> if (attribute.startsWith("ping")) { return new Element(((CraftPlayer) getPlayerEntity()).getHandle().ping) @@ -1849,7 +1849,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player is currently flying. + // Returns whether the player is currently flying. // --> if (attribute.startsWith("is_flying")) { return new Element(getPlayerEntity().isFlying()) @@ -1860,7 +1860,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player is currently sleeping. + // Returns whether the player is currently sleeping. // --> if (attribute.startsWith("is_sleeping")) { return new Element(getPlayerEntity().isSleeping()) @@ -1871,7 +1871,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player is currently sneaking. + // Returns whether the player is currently sneaking. // --> if (attribute.startsWith("is_sneaking")) { return new Element(getPlayerEntity().isSneaking()) @@ -1882,7 +1882,7 @@ else if (getPlayerEntity().getFoodLevel() / maxHunger < 1) { // @attribute // @returns Element(Boolean) // @description - // returns whether the player is currently sprinting. + // Returns whether the player is currently sprinting. // --> if (attribute.startsWith("is_sprinting")) { return new Element(getPlayerEntity().isSprinting()) @@ -1941,7 +1941,7 @@ else if (obj instanceof dEntity) { // @attribute // @returns Duration // @description - // returns the time the player has been asleep. + // Returns the time the player has been asleep. // --> if (attribute.startsWith("time_asleep")) { return new Duration(getPlayerEntity().getSleepTicks() / 20) @@ -1952,7 +1952,7 @@ else if (obj instanceof dEntity) { // @attribute // @returns Element(Number) // @description - // returns the time the player is currently experiencing. This time could differ from + // Returns the time the player is currently experiencing. This time could differ from // the time that the rest of the world is currently experiencing if a 'time' or 'freeze_time' // mechanism is being used on the player. // --> @@ -1965,7 +1965,7 @@ else if (obj instanceof dEntity) { // @attribute // @returns Element(Decimal) // @description - // returns the speed the player can walk at. + // Returns the speed the player can walk at. // --> if (attribute.startsWith("walk_speed")) { return new Element(getPlayerEntity().getWalkSpeed()) @@ -1976,7 +1976,7 @@ else if (obj instanceof dEntity) { // @attribute // @returns Element // @description - // returns the type of weather the player is experiencing. This will be different + // Returns the type of weather the player is experiencing. This will be different // from the weather currently in the world that the player is residing in if // the weather is currently being forced onto the player. // Returns null if the player does not currently have any forced weather. @@ -1995,7 +1995,7 @@ else if (obj instanceof dEntity) { // @attribute // @returns Element(Number) // @description - // returns the number of XP levels the player has. + // Returns the number of XP levels the player has. // --> if (attribute.startsWith("xp.level")) { return new Element(getPlayerEntity().getLevel()) @@ -2006,7 +2006,7 @@ else if (obj instanceof dEntity) { // @attribute // @returns Element(Number) // @description - // returns the amount of XP needed to get to the next level. + // Returns the amount of XP needed to get to the next level. // --> if (attribute.startsWith("xp.to_next_level")) { return new Element(getPlayerEntity().getExpToLevel()) @@ -2017,7 +2017,7 @@ else if (obj instanceof dEntity) { // @attribute // @returns Element(Number) // @description - // returns the total amount of experience points. + // Returns the total amount of experience points. // --> if (attribute.startsWith("xp.total")) { return new Element(getPlayerEntity().getTotalExperience()) @@ -2028,7 +2028,7 @@ else if (obj instanceof dEntity) { // @attribute // @returns Element(Decimal) // @description - // returns the percentage of experience points to the next level. + // Returns the percentage of experience points to the next level. // --> if (attribute.startsWith("xp")) { return new Element(getPlayerEntity().getExp() * 100) @@ -2485,7 +2485,7 @@ public void adjust(Mechanism mechanism) { // None // --> if (mechanism.matches("show_boss_bar")) { - if (value.asString().length() > 0) { + if (!value.asString().isEmpty()) { String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 2); if (split.length == 2 && new Element(split[0]).isInt()) { BossHealthBar.displayTextBar(split[1], getPlayerEntity(), new Element(split[0]).asInt()); @@ -2513,7 +2513,7 @@ public void adjust(Mechanism mechanism) { // None // --> if (mechanism.matches("fake_experience")) { - if (value.asString().length() > 0) { + if (!value.asString().isEmpty()) { String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 2); if (split.length > 0 && new Element(split[0]).isFloat()) { if (split.length > 1 && new Element(split[1]).isInt()) { @@ -2551,7 +2551,7 @@ public void adjust(Mechanism mechanism) { // None // --> if (mechanism.matches("fake_health")) { - if (value.asString().length() > 0) { + if (!value.asString().isEmpty()) { String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 3); if (split.length > 0 && new Element(split[0]).isFloat()) { if (split.length > 1 && new Element(split[1]).isInt()) { @@ -2592,7 +2592,7 @@ public void adjust(Mechanism mechanism) { // - adjust fake_equipment:|head|i@jack_o_lantern // --> if (mechanism.matches("fake_equipment")) { - if (value.asString().length() > 0) { + if (!value.asString().isEmpty()) { String[] split = value.asString().split("[\\|" + dList.internal_escape + "]", 3); if (split.length > 0 && new Element(split[0]).matchesType(dEntity.class)) { if (split.length > 1 && new Element(split[1]).matchesEnum(EntityEquipment.EquipmentSlots.values())) { @@ -2694,7 +2694,7 @@ else if (split.length > 1) { // - adjust tab_list_info:
|