Skip to content

Commit

Permalink
Merged branch master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Feb 4, 2016
2 parents bdbcab1 + 23dc1d4 commit 211a108
Show file tree
Hide file tree
Showing 75 changed files with 916 additions and 414 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -13,7 +13,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<craftbukkit.version>1.8.7-R0.1-SNAPSHOT</craftbukkit.version>
<craftbukkit.version>1.8.8-R0.1-SNAPSHOT</craftbukkit.version>
<json.version>20090211</json.version>
<citizens.version>2.0.16-SNAPSHOT</citizens.version>
<build.number>Unknown</build.number>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down
75 changes: 44 additions & 31 deletions src/main/java/net/aufdemrand/denizen/events/BukkitScriptEvent.java
Expand Up @@ -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;

Expand All @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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;
}

Expand Down
Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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;
}

Expand Down
Expand Up @@ -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;
}
}
Expand All @@ -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())) {
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit 211a108

Please sign in to comment.