Skip to content

Commit

Permalink
Merge pull request #1886 from DenizenScript/dev
Browse files Browse the repository at this point in the history
PR for very busy 3 days
  • Loading branch information
mcmonkey4eva committed Jan 18, 2019
2 parents 67585ac + 86614c0 commit 975e9db
Show file tree
Hide file tree
Showing 186 changed files with 1,571 additions and 778 deletions.
Expand Up @@ -2,6 +2,7 @@

import net.aufdemrand.denizen.nms.util.BoundingBox;
import net.aufdemrand.denizen.nms.util.jnbt.CompoundTag;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
Expand All @@ -18,6 +19,14 @@

public interface EntityHelper {

default void setRiptide(Entity entity, boolean state) {
dB.echoError("Riptide control not available on this server version.");
}

int getBodyArrows(Entity entity);

void setBodyArrows(Entity entity, int numArrows);

Entity getFishHook(PlayerFishEvent event);

void forceInteraction(Player player, Location location);
Expand Down
11 changes: 11 additions & 0 deletions plugin/src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -600,6 +600,9 @@ public void onEnable() {
ScriptEvent.registerScriptEvent(new ChunkUnloadScriptEvent());
ScriptEvent.registerScriptEvent(new CreeperPoweredScriptEvent());
ScriptEvent.registerScriptEvent(new EntityBreaksHangingScriptEvent());
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_10_R1)) {
ScriptEvent.registerScriptEvent(new EntityBreedScriptEvent());
}
ScriptEvent.registerScriptEvent(new EntityChangesBlockScriptEvent());
ScriptEvent.registerScriptEvent(new EntityCombustsScriptEvent());
ScriptEvent.registerScriptEvent(new EntityCreatePortalScriptEvent());
Expand All @@ -624,6 +627,7 @@ public void onEnable() {
ScriptEvent.registerScriptEvent(new EntityResurrectScriptEvent());
}
ScriptEvent.registerScriptEvent(new EntityShootsBowEvent());
ScriptEvent.registerScriptEvent(new EntitySpawnerSpawnScriptEvent());
ScriptEvent.registerScriptEvent(new EntitySpawnScriptEvent());
ScriptEvent.registerScriptEvent(new EntityTamesScriptEvent());
ScriptEvent.registerScriptEvent(new EntityTargetsScriptEvent());
Expand Down Expand Up @@ -698,6 +702,9 @@ public void onEnable() {
ScriptEvent.registerScriptEvent(new PlayerPreparesAnvilCraftScriptEvent());
}
ScriptEvent.registerScriptEvent(new PlayerQuitsScriptEvent());
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_13_R2)) {
ScriptEvent.registerScriptEvent(new PlayerReceivesCommandsScriptEvent());
}
ScriptEvent.registerScriptEvent(new PlayerReceivesMessageScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerRespawnsScriptEvent());
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_9_R2)) {
Expand Down Expand Up @@ -821,6 +828,7 @@ public Property get(dObject o) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_9_R2)) {
PropertyParser.registerProperty(EntityBeamTarget.class, dEntity.class);
}
PropertyParser.registerProperty(EntityBodyArrows.class, dEntity.class);
PropertyParser.registerProperty(EntityBoundingBox.class, dEntity.class);
PropertyParser.registerProperty(EntityChestCarrier.class, dEntity.class);
PropertyParser.registerProperty(EntityColor.class, dEntity.class);
Expand All @@ -847,6 +855,9 @@ public Property get(dObject o) {
PropertyParser.registerProperty(EntityPotion.class, dEntity.class);
PropertyParser.registerProperty(EntityPowered.class, dEntity.class);
PropertyParser.registerProperty(EntityProfession.class, dEntity.class);
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_13_R2)) {
PropertyParser.registerProperty(EntityRiptide.class, dEntity.class);
}
PropertyParser.registerProperty(EntityRotation.class, dEntity.class);
PropertyParser.registerProperty(EntitySmall.class, dEntity.class);
PropertyParser.registerProperty(EntitySilent.class, dEntity.class);
Expand Down
@@ -1,51 +1,59 @@
package net.aufdemrand.denizen.events;

import net.aufdemrand.denizen.objects.*;
import net.aufdemrand.denizen.tags.BukkitTagContext;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.events.ScriptEvent;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.tags.TagContext;
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;
import java.util.regex.Pattern;

public abstract class BukkitScriptEvent extends ScriptEvent {

@Deprecated
public boolean runInCheck(ScriptContainer scriptContainer, String s, String lower, Location location) {
return runInCheck(scriptContainer, s, lower, location, "in");
}

@Deprecated
public boolean runInCheck(ScriptContainer scriptContainer, String s, String lower, Location location, String innote) {
List<String> data = CoreUtilities.split(lower, ' ');
return runInCheck(new ScriptPath(scriptContainer, s), location, innote);
}

int index;
public boolean runInCheck(ScriptPath path, Location location) {
return runInCheck(path, location, "in");
}

for (index = 0; index < data.size(); index++) {
if (data.get(index).equals(innote)) {
public boolean runInCheck(ScriptPath path, Location location, String innote) {
int index;
for (index = 0; index < path.eventArgsLower.length; index++) {
if (path.eventArgsLower[index].equals(innote)) {
break;
}
}
if (index >= data.size()) {
if (index >= path.eventArgsLower.length) {
// No 'in ...' specified
return true;
}

String it = CoreUtilities.getXthArg(index + 1, lower);
String it = path.eventArgsLower[index + 1];
if (it.equals("notable")) {
String subit = CoreUtilities.getXthArg(index + 2, lower);
String subit = path.eventArgsLower[index + 2];
if (subit.equals("cuboid")) {
return dCuboid.getNotableCuboidsContaining(location).size() > 0;
}
else if (subit.equals("ellipsoid")) {
return dEllipsoid.getNotableEllipsoidsContaining(location).size() > 0;
}
else {
dB.echoError("Invalid event 'IN ...' check [" + getName() + "] ('in notable ???'): '" + s + "' for " + scriptContainer.getName());
dB.echoError("Invalid event 'IN ...' check [" + getName() + "] ('in notable ???'): '" + path.event + "' for " + path.container.getName());
return false;
}
}
Expand All @@ -61,7 +69,7 @@ else if (dEllipsoid.matches(it)) {
return ellipsoid.contains(location);
}
else {
dB.echoError("Invalid event 'IN ...' check [" + getName() + "] ('in ???'): '" + s + "' for " + scriptContainer.getName());
dB.echoError("Invalid event 'IN ...' check [" + getName() + "] ('in ???'): '" + path.event + "' for " + path.container.getName());
return false;
}
}
Expand All @@ -83,15 +91,22 @@ public boolean tryLocation(dLocation location, String comparedto) {
return loc.getBlock().equals(location.getBlock());
}

@Deprecated
public boolean runWithCheck(ScriptContainer scriptContainer, String s, String lower, dItem held) {
String with = getSwitch(lower, "with");
return runWithCheck(new ScriptPath(scriptContainer, s), held);
}

public static TagContext noDebugTagContext = new BukkitTagContext(null, null, false, null, false, null);

public boolean runWithCheck(ScriptPath path, dItem held) {
String with = path.switches.get("with");
if (with != null) {
if (with.equals("item")) {
return true;
}
dItem it = dItem.valueOf(with);
dItem it = dItem.valueOf(with, noDebugTagContext);
if (it == null) {
dB.echoError("Invalid WITH item in " + getName() + " for '" + s + "' in " + scriptContainer.getName());
dB.echoError("Invalid WITH item in " + getName() + " for '" + path.event + "' in " + path.container.getName());
return false;
}
if (held == null || !tryItem(held, with)) {
Expand Down
Expand Up @@ -52,10 +52,11 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;

if (!runInCheck(scriptContainer, s, lower, location)) {
if (!runInCheck(path, location)) {
return false;
}

Expand Down
Expand Up @@ -48,10 +48,11 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;

if (!runInCheck(scriptContainer, s, lower, location)) {
if (!runInCheck(path, location)) {
return false;
}

Expand Down
Expand Up @@ -62,9 +62,10 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
if (!runInCheck(scriptContainer, s, lower, location)) {
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;
if (!runInCheck(path, location)) {
return false;
}

Expand Down
Expand Up @@ -48,9 +48,10 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
if (!runInCheck(scriptContainer, s, lower, location)) {
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;
if (!runInCheck(path, location)) {
return false;
}

Expand Down
Expand Up @@ -51,9 +51,10 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
if (!runInCheck(scriptContainer, s, lower, location)) {
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;
if (!runInCheck(path, location)) {
return false;
}

Expand Down
Expand Up @@ -48,9 +48,10 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
if (!runInCheck(scriptContainer, s, lower, location)) {
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;
if (!runInCheck(path, location)) {
return false;
}

Expand Down
Expand Up @@ -50,16 +50,17 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;
String mat = CoreUtilities.getXthArg(0, lower);
if (!tryMaterial(material, mat)) {
return false;
}
if (material.isStructure()) {
return false;
}
return runInCheck(scriptContainer, s, lower, location);
return runInCheck(path, location);
}

@Override
Expand Down
Expand Up @@ -56,9 +56,10 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
if (!runInCheck(scriptContainer, s, lower, location)) {
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;
if (!runInCheck(path, location)) {
return false;
}

Expand Down
Expand Up @@ -54,10 +54,11 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;

if (!runInCheck(scriptContainer, s, lower, location)) {
if (!runInCheck(path, location)) {
return false;
}

Expand Down
Expand Up @@ -50,10 +50,11 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;

if (!runInCheck(scriptContainer, s, lower, location)) {
if (!runInCheck(path, location)) {
return false;
}

Expand Down
Expand Up @@ -48,15 +48,16 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;

if (CoreUtilities.getXthArg(2, lower).equals("because")
&& !CoreUtilities.xthArgEquals(3, lower, CoreUtilities.toLowerCase(cause.toString()))) {
return false;
}

if (!runInCheck(scriptContainer, s, lower, entity.getLocation())) {
if (!runInCheck(path, entity.getLocation())) {
return false;
}

Expand Down
Expand Up @@ -65,8 +65,9 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
public boolean matches(ScriptPath path) {
String s = path.event;
String lower = path.eventLower;
String entName = CoreUtilities.getXthArg(0, lower);
String hang = CoreUtilities.getXthArg(2, lower);

Expand All @@ -78,7 +79,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
return false;
}

if (!runInCheck(scriptContainer, s, lower, location)) {
if (!runInCheck(path, location)) {
return false;
}

Expand Down

0 comments on commit 975e9db

Please sign in to comment.