Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/mcmonkey4eva/Denizen
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphan1 committed Jun 24, 2015
2 parents 41fa075 + 38d0eda commit f79cc85
Show file tree
Hide file tree
Showing 39 changed files with 2,261 additions and 1,037 deletions.
20 changes: 19 additions & 1 deletion src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -597,43 +597,61 @@ public void onEnable() {
ScriptEvent.registerScriptEvent(new CreeperPoweredScriptEvent());
ScriptEvent.registerScriptEvent(new EntityBreaksHangingScriptEvent());
ScriptEvent.registerScriptEvent(new EntityChangesBlockScriptEvent());
ScriptEvent.registerScriptEvent(new EntityCreatePortalScriptEvent());
ScriptEvent.registerScriptEvent(new EntityCombustsScriptEvent());
ScriptEvent.registerScriptEvent(new EntityDamagedScriptEvent());
ScriptEvent.registerScriptEvent(new EntityDeathScriptEvent());
ScriptEvent.registerScriptEvent(new EntityDespawnScriptEvent());
ScriptEvent.registerScriptEvent(new EntityEntersPortalScriptEvent());
ScriptEvent.registerScriptEvent(new EntityExitsPortalScriptEvent());
ScriptEvent.registerScriptEvent(new EntityExplodesScriptEvent());
ScriptEvent.registerScriptEvent(new EntityFormsBlock());
ScriptEvent.registerScriptEvent(new EntityExplosionPrimesScriptEvent());
ScriptEvent.registerScriptEvent(new EntityFoodLevelChangeScriptEvent());
ScriptEvent.registerScriptEvent(new EntityFormsBlockScriptEvent());
ScriptEvent.registerScriptEvent(new EntityHealsScriptEvent());
ScriptEvent.registerScriptEvent(new EntityInteractScriptEvent());
ScriptEvent.registerScriptEvent(new EntityKilledScriptEvent());
ScriptEvent.registerScriptEvent(new EntityShootsBowEvent());
ScriptEvent.registerScriptEvent(new EntitySpawnScriptEvent());
ScriptEvent.registerScriptEvent(new EntityTamesScriptEvent());
ScriptEvent.registerScriptEvent(new EntityTargetsScriptEvent());
ScriptEvent.registerScriptEvent(new EntityTeleportScriptEvent());
ScriptEvent.registerScriptEvent(new EntityUnleashedScriptEvent());
ScriptEvent.registerScriptEvent(new FurnaceBurnsItemScriptEvent());
ScriptEvent.registerScriptEvent(new FurnaceSmeltsItemScriptEvent());
ScriptEvent.registerScriptEvent(new HangingBreaksScriptEvent());
ScriptEvent.registerScriptEvent(new HorseJumpsScriptEvent());
ScriptEvent.registerScriptEvent(new InvPicksUpItemScriptEvent());
ScriptEvent.registerScriptEvent(new ItemDespawnsScriptEvent());
ScriptEvent.registerScriptEvent(new ItemEnchantedScriptEvent());
ScriptEvent.registerScriptEvent(new ItemMoveScriptEvent());
ScriptEvent.registerScriptEvent(new ItemScrollScriptEvent());
ScriptEvent.registerScriptEvent(new ItemSpawnsScriptEvent());
ScriptEvent.registerScriptEvent(new LeafDecaysScriptEvent());
ScriptEvent.registerScriptEvent(new LiquidSpreadScriptEvent());
ScriptEvent.registerScriptEvent(new ListPingScriptEvent());
ScriptEvent.registerScriptEvent(new PigZappedScriptEvent());
ScriptEvent.registerScriptEvent(new PistonExtendsScriptEvent());
ScriptEvent.registerScriptEvent(new PistonRetractsScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerBreaksBlockScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerChangesSignScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerClosesInvScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerDamagesBlockScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerJumpScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerOpensInvScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerPlacesBlockScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerPlacesHangingScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerStepsOnScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerTakesFromFurnaceScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerUsesPortalScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerWalkScriptEvent());
ScriptEvent.registerScriptEvent(new ProjectileLaunchedScriptEvent());
ScriptEvent.registerScriptEvent(new PotionSplashScriptEvent());
ScriptEvent.registerScriptEvent(new RedstoneScriptEvent());
ScriptEvent.registerScriptEvent(new ResourcePackStatusScriptEvent());
ScriptEvent.registerScriptEvent(new SheepDyedScriptEvent());
ScriptEvent.registerScriptEvent(new SheepRegrowsScriptEvent());
ScriptEvent.registerScriptEvent(new SlimeSplitsScriptEvent());
ScriptEvent.registerScriptEvent(new VehicleCollidesBlockScriptEvent());
ScriptEvent.registerScriptEvent(new VehicleCollidesEntityScriptEvent());
ScriptEvent.registerScriptEvent(new VehicleMoveScriptEvent());
Expand Down
Expand Up @@ -102,9 +102,11 @@ public HashMap<String, dObject> getContext() {
public void onBlockIgnites(BlockIgniteEvent event) {
location = new dLocation(event.getBlock().getLocation());
material = dMaterial.getMaterialFrom(event.getBlock().getType(), event.getBlock().getData());
entity = null;
if (event.getIgnitingEntity() != null) {
entity = new dEntity(event.getIgnitingEntity());
}
origin_location = null;
if (event.getIgnitingBlock() != null) {
origin_location = new dLocation(event.getIgnitingBlock().getLocation());
}
Expand Down
@@ -1,12 +1,10 @@
package net.aufdemrand.denizen.events.block;

import net.aufdemrand.denizen.objects.dCuboid;
import net.aufdemrand.denizen.objects.dEllipsoid;
import net.aufdemrand.denizen.events.BukkitScriptEvent;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dMaterial;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.events.ScriptEvent;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
Expand All @@ -18,12 +16,12 @@

import java.util.HashMap;

public class BlockPhysicsScriptEvent extends ScriptEvent implements Listener {
public class BlockPhysicsScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
// @Events
// block physics (in <notable cuboid>)
// <material> physics (in <notable cuboid>)
// block physics (in <area>)
// <material> physics (in <area>)
//
// @Warning This event may fire very rapidly.
//
Expand Down Expand Up @@ -64,33 +62,13 @@ public boolean matches(ScriptContainer scriptContainer, String s) {

if (!lower.startsWith("block")) {
dMaterial mat = dMaterial.valueOf(CoreUtilities.getXthArg(0, lower));
if (mat == null) {
dB.echoError("Invalid event material [BlockPhysics]: '" + s + "' for " + scriptContainer.getName());
return false;
}
if (!old_material.matchesMaterialData(mat.getMaterialData())) {
return false;
}
}

if (CoreUtilities.xthArgEquals(2, lower, "in")) {
String it = CoreUtilities.getXthArg(3, lower);
if (dCuboid.matches(it)) {
dCuboid cuboid = dCuboid.valueOf(it);
if (!cuboid.isInsideCuboid(location)) {
return false;
}
}
else if (dEllipsoid.matches(it)) {
dEllipsoid ellipsoid = dEllipsoid.valueOf(it);
if (!ellipsoid.contains(location)) {
return false;
}
}
else {
dB.echoError("Invalid event 'IN ...' check [BlockPhysics]: '" + s + "' for " + scriptContainer.getName());
return false;
}
if (!runInCheck(scriptContainer, s, lower, location)) {
return false;
}

return true;
Expand Down
Expand Up @@ -155,7 +155,7 @@ private List<String> getAll(String cmd) {
// <--[event]
// @Events
// command
// <command_name>|... command (in <notable cuboid>)
// <command_name>|... command (in <area>)
//
// @Regex on [^\s]+ command(in \w+)?
//
Expand Down
@@ -1,13 +1,11 @@
package net.aufdemrand.denizen.events.entity;

import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.events.BukkitScriptEvent;
import net.aufdemrand.denizen.objects.dCuboid;
import net.aufdemrand.denizen.objects.dEllipsoid;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.events.ScriptEvent;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.objects.dObject;
Expand All @@ -23,14 +21,14 @@
import java.util.HashMap;
import java.util.List;

public class EntityBreaksHangingScriptEvent extends ScriptEvent implements Listener {
public class EntityBreaksHangingScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
// @Events
// entity breaks hanging (in <notable cuboid>)
// entity breaks hanging because <cause> (in <notable cuboid>)
// <entity> breaks hanging (in <notable cuboid>)
// <entity> breaks hanging because <cause> (in <notable cuboid>)
// entity breaks hanging (in <area>)
// entity breaks hanging because <cause> (in <area>)
// <entity> breaks hanging (in <area>)
// <entity> breaks hanging because <cause> (in <area>)
//
// @Cancellable true
//
Expand Down Expand Up @@ -74,30 +72,8 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
return false;
}

String notable = null;
if (CoreUtilities.xthArgEquals(3, lower, "in")) {
notable = CoreUtilities.getXthArg(4, lower);
}
else if (CoreUtilities.xthArgEquals(5, lower, "in")) {
notable = CoreUtilities.getXthArg(6, lower);
}
if (notable != null) {
if (dCuboid.matches(notable)) {
dCuboid cuboid = dCuboid.valueOf(notable);
if (!cuboid.isInsideCuboid(location)) {
return false;
}
}
else if (dEllipsoid.matches(notable)) {
dEllipsoid ellipsoid = dEllipsoid.valueOf(notable);
if (!ellipsoid.contains(location)) {
return false;
}
}
else {
dB.echoError("Invalid event 'IN ...' check [" + getName() + "]: '" + s + "' for " + scriptContainer.getName());
return false;
}
if (!runInCheck(scriptContainer, s, lower, location)) {
return false;
}

if (CoreUtilities.xthArgEquals(3, lower, "because")){
Expand Down
@@ -1,10 +1,10 @@
package net.aufdemrand.denizen.events.entity;

import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.events.BukkitScriptEvent;
import net.aufdemrand.denizen.objects.*;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.events.ScriptEvent;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.ScriptEntryData;
Expand All @@ -19,15 +19,15 @@
import java.util.HashMap;
import java.util.List;

public class EntityChangesBlockScriptEvent extends ScriptEvent implements Listener {
public class EntityChangesBlockScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
// @Events
// entity changes block
// entity changes block (into <material>) (in <notable cuboid>)
// entity changes <material> (into <material>) (in <notable cuboid>)
// <entity> changes block (into <material>) (in <notable cuboid>)
// <entity> changes <material> (into <material>) (in <notable cuboid>)
// entity changes block (into <material>) (in <area>)
// entity changes <material> (into <material>) (in <area>)
// <entity> changes block (into <material>) (in <area>)
// <entity> changes <material> (into <material>) (in <area>)
//
// @Cancellable true
//
Expand Down Expand Up @@ -71,38 +71,27 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
return false;
}

String notable = null;
if (CoreUtilities.xthArgEquals(3, lower, "in")) {
notable = CoreUtilities.getXthArg(4, lower);
}
else if (CoreUtilities.xthArgEquals(5, lower, "in")) {
notable = CoreUtilities.getXthArg(6, lower);
String mat = CoreUtilities.getXthArg(1, lower);
if (!mat.equals("block")
&& !mat.equals(old_material.identifySimpleNoIdentifier()) && !mat.equals(old_material.identifyFullNoIdentifier())) {
return false;
}
if (notable != null) {
if (dCuboid.matches(notable)) {
dCuboid cuboid = dCuboid.valueOf(notable);
if (!cuboid.isInsideCuboid(location)) {
return false;
}
}
else if (dEllipsoid.matches(notable)) {
dEllipsoid ellipsoid = dEllipsoid.valueOf(notable);
if (!ellipsoid.contains(location)) {
return false;
}

if (CoreUtilities.xthArgEquals(3, lower, "into")) {
mat = CoreUtilities.getXthArg(4, lower);
if (mat.length() == 0) {
dB.echoError("Invalid event material [" + getName() + "]: '" + s + "' for " + scriptContainer.getName());
return false;
}
else {
dB.echoError("Invalid event 'IN ...' check [" + getName() + "]: '" + s + "' for " + scriptContainer.getName());
else if (!mat.equals("block") && !mat.equals(new_material.identifySimpleNoIdentifier())) {
return false;
}
}

if (CoreUtilities.xthArgEquals(3, lower, "into")) {
String mat = CoreUtilities.getXthArg(4, lower);
if (!mat.equals("block") && !mat.equals(new_material.identifyFullNoIdentifier())) {
return false;
}
if (!runInCheck(scriptContainer, s, lower, location)) {
return false;
}

return true;
}

Expand Down

0 comments on commit f79cc85

Please sign in to comment.