Skip to content

Commit

Permalink
General event cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 12, 2015
1 parent 5cffab6 commit 76af9a4
Show file tree
Hide file tree
Showing 25 changed files with 57 additions and 17 deletions.
Expand Up @@ -42,7 +42,9 @@ public class BiomeEnterExitScriptEvent extends ScriptEvent implements Listener {
public BiomeEnterExitScriptEvent() {
instance = this;
}

public static BiomeEnterExitScriptEvent instance;

public dLocation from;
public dLocation to;
public Element old_biome;
Expand Down
Expand Up @@ -33,7 +33,9 @@ public class BlockFallsScriptEvent extends ScriptEvent implements Listener {
public BlockFallsScriptEvent() {
instance = this;
}

public static BlockFallsScriptEvent instance;

public dLocation location;
public EntityChangeBlockEvent event;

Expand Down
Expand Up @@ -43,6 +43,7 @@ public BlockPhysicsScriptEvent() {
}

public static BlockPhysicsScriptEvent instance;

public dLocation location;
public dMaterial new_material;
public dMaterial old_material;
Expand Down
Expand Up @@ -39,6 +39,7 @@ public BucketEmptyScriptEvent() {
}

public static BucketEmptyScriptEvent instance;

public dEntity entity;
public dItem item;
public dMaterial material;
Expand Down
Expand Up @@ -39,6 +39,7 @@ public BucketFillScriptEvent() {
}

public static BucketFillScriptEvent instance;

public dEntity entity;
public dItem item;
public dMaterial material;
Expand Down
Expand Up @@ -55,6 +55,7 @@ public ChatScriptEvent() {
}

public static ChatScriptEvent instance;

public PlayerChatEvent pcEvent;
public AsyncPlayerChatEvent apcEvent;
public Element message;
Expand Down
Expand Up @@ -33,9 +33,11 @@ public class ChunkLoadScriptEvent extends ScriptEvent implements Listener {
public ChunkLoadScriptEvent() {
instance = this;
}

public static ChunkLoadScriptEvent instance;

public dChunk chunk;
public dWorld world; // Deprecated in favor of context.chunk.world
public dWorld world;
public ChunkLoadEvent event;

@Override
Expand All @@ -48,7 +50,8 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
return lower.equals("chunk loads for the first time")
|| lower.equals("chunk loads for the first time in " + dWorld.mirrorBukkitWorld(event.getWorld()).getName().toLowerCase());
|| lower.equals("chunk loads for the first time in " +
CoreUtilities.toLowerCase(world.getName()));
}

@Override
Expand Down Expand Up @@ -82,7 +85,7 @@ public HashMap<String, dObject> getContext() {
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
chunk = new dChunk(event.getChunk());
world = new dWorld(event.getWorld()); // Deprecated in favor of context.chunk.world
world = new dWorld(event.getWorld());
this.event = event;
fire();
}
Expand Down
Expand Up @@ -35,9 +35,11 @@ public class ChunkUnloadScriptEvent extends ScriptEvent implements Listener {
public ChunkUnloadScriptEvent() {
instance = this;
}

public static ChunkUnloadScriptEvent instance;

public dChunk chunk;
public dWorld world; // Deprecated in favor of context.chunk.world
public dWorld world;
public ChunkUnloadEvent event;

@Override
Expand All @@ -50,7 +52,7 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
return lower.equals("chunk unloads")
|| lower.equals("chunk unloads in " + dWorld.mirrorBukkitWorld(event.getWorld()).getName().toLowerCase());
|| lower.equals("chunk unloads in " + CoreUtilities.toLowerCase(world.getName()));
}

@Override
Expand Down Expand Up @@ -84,7 +86,7 @@ public HashMap<String, dObject> getContext() {
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
chunk = new dChunk(event.getChunk());
world = new dWorld(event.getWorld()); // Deprecated in favor of context.chunk.world
world = new dWorld(event.getWorld());
cancelled = event.isCancelled();
this.event = event;
fire();
Expand Down
Expand Up @@ -35,7 +35,9 @@ public class EntityCombustsScriptEvent extends ScriptEvent implements Listener {
public EntityCombustsScriptEvent() {
instance = this;
}

public static EntityCombustsScriptEvent instance;

public dEntity entity;
public Element duration;
public EntityCombustEvent event;
Expand Down
Expand Up @@ -65,7 +65,9 @@ public class EntityDamagedScriptEvent extends ScriptEvent implements Listener {
public EntityDamagedScriptEvent() {
instance = this;
}

public static EntityDamagedScriptEvent instance;

public dEntity entity;
public Element cause;
public Element damage;
Expand Down
Expand Up @@ -34,9 +34,8 @@ public class EntityDeathScriptEvent extends ScriptEvent implements Listener {
// <context.damager> returns the dEntity damaging the other entity, if any.
// <context.message> returns an Element of a player's death message.
// <context.inventory> returns the dInventory of the entity if it was a player.
// <context.cause> returns an Element of the cause of the death.
// <context.cause> returns an Element of the cause of the death. See <@link language damage cause> for a list of possible damage causes.
// <context.drops> returns a dList of all pending item drops.
// Causes: <@link url https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityDamageEvent.DamageCause.html>
//
// @Determine
// Element(String) to change the death message.
Expand All @@ -50,7 +49,9 @@ public class EntityDeathScriptEvent extends ScriptEvent implements Listener {
public EntityDeathScriptEvent() {
instance = this;
}

public static EntityDeathScriptEvent instance;

public dEntity entity;
public dEntity damager;
public Element message;
Expand Down
Expand Up @@ -34,6 +34,7 @@ public EntityDespawnScriptEvent() {
}

public static EntityDespawnScriptEvent instance;

public dEntity entity;
public Element cause;

Expand Down
Expand Up @@ -51,7 +51,9 @@ public class EntityKilledScriptEvent extends ScriptEvent implements Listener {
public EntityKilledScriptEvent() {
instance = this;
}

public static EntityKilledScriptEvent instance;

public dEntity entity;
public Element cause;
public Element damage;
Expand Down
Expand Up @@ -158,8 +158,9 @@ public void onEntityTeleports(EntityTeleportEvent event) {
@EventHandler
public void onPlayerTeleports(PlayerTeleportEvent event) {

if (dEntity.isNPC(event.getPlayer()))
if (dEntity.isNPC(event.getPlayer())) {
return;
}

from = new dLocation(event.getFrom());
to = new dLocation(event.getTo());
Expand Down
Expand Up @@ -42,7 +42,9 @@ public class ItemMoveScriptEvent extends ScriptEvent implements Listener {
public ItemMoveScriptEvent() {
instance = this;
}

public static ItemMoveScriptEvent instance;

public dInventory origin;
public dInventory destination;
public dInventory initiator;
Expand Down
Expand Up @@ -34,7 +34,9 @@ public class ItemScrollScriptEvent extends ScriptEvent implements Listener {
public ItemScrollScriptEvent() {
instance = this;
}

public static ItemScrollScriptEvent instance;

public Element new_slot;
public Element previous_slot;
public PlayerItemHeldEvent event;
Expand Down
Expand Up @@ -38,6 +38,7 @@ public LiquidSpreadScriptEvent() {
}

public static LiquidSpreadScriptEvent instance;

public dMaterial material;
public dLocation from;
public dLocation to;
Expand Down
Expand Up @@ -38,7 +38,9 @@ public class ListPingScriptEvent extends ScriptEvent implements Listener {
public ListPingScriptEvent() {
instance = this;
}

public static ListPingScriptEvent instance;

public Element motd;
public Element max_players;
public Element num_players;
Expand Down
Expand Up @@ -29,7 +29,9 @@ public class PlayerJumpScriptEvent extends ScriptEvent implements Listener {
public PlayerJumpScriptEvent() {
instance = this;
}

public static PlayerJumpScriptEvent instance;

public dLocation location;
public PlayerMoveEvent event;

Expand Down Expand Up @@ -80,9 +82,7 @@ public HashMap<String, dObject> getContext() {
@EventHandler
public void onPlayerJumps(PlayerMoveEvent event) {
location = new dLocation(event.getFrom());
cancelled = event.isCancelled(); // Bukkit is broken, this doesn't work
this.event = event;
fire();
event.setCancelled(cancelled); // Bukkit is broken, this doesn't work
}
}
Expand Up @@ -35,7 +35,9 @@ public class PlayerWalkScriptEvent extends ScriptEvent implements Listener {
public PlayerWalkScriptEvent() {
instance = this;
}

public static PlayerWalkScriptEvent instance;

public dLocation old_location;
public dLocation new_location;
public PlayerMoveEvent event;
Expand Down
Expand Up @@ -37,7 +37,9 @@ public class RedstoneScriptEvent extends ScriptEvent implements Listener {
public RedstoneScriptEvent() {
instance = this;
}

public static RedstoneScriptEvent instance;

public dLocation location;
public Element old_current;
public Element new_current;
Expand Down
Expand Up @@ -17,8 +17,6 @@ public class ResourcePackStatusScriptEvent extends ScriptEvent {
// @Events
// resource pack status
//
// @Cancellable false
//
// @Triggers when a player accepts, denies, successfully loads, or fails to download a resource pack.
//
// @Context
Expand All @@ -32,6 +30,7 @@ public ResourcePackStatusScriptEvent() {
}

public static ResourcePackStatusScriptEvent instance;

public Element hash;
public Element status;
public dPlayer player;
Expand Down
Expand Up @@ -36,7 +36,9 @@ public class VehicleCollidesBlockScriptEvent extends ScriptEvent implements List
public VehicleCollidesBlockScriptEvent() {
instance = this;
}

public static VehicleCollidesBlockScriptEvent instance;

public dEntity vehicle;
public dLocation location;
public VehicleBlockCollisionEvent event;
Expand Down
Expand Up @@ -3,6 +3,8 @@
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizencore.events.ScriptEvent;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.aH;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
Expand Down Expand Up @@ -30,9 +32,11 @@ public class VehicleCollidesEntityScriptEvent extends ScriptEvent implements Lis
// @Context
// <context.vehicle> returns the dEntity of the vehicle.
// <context.entity> returns the dEntity of the entity the vehicle has collided with.
// <context.pickup> returns whether the vehicle can pick up the entity.
//
// @Determine
// "NOPICKUP" to stop the vehicle from picking up the entity.
// "PICKUP:TRUE" to allow the vehicle to pick up the entity.
// "PICKUP:FALSE" to stop the vehicle from picking up the entity.
//
// -->

Expand All @@ -41,6 +45,7 @@ public VehicleCollidesEntityScriptEvent() {
}

public static VehicleCollidesEntityScriptEvent instance;

public dEntity vehicle;
public dEntity entity;
public Boolean pickup_cancel;
Expand Down Expand Up @@ -91,8 +96,9 @@ public void destroy() {

@Override
public boolean applyDetermination(ScriptContainer container, String determination) {
if (determination.toLowerCase().equals("nopickup")) {
pickup_cancel = true;
aH.Argument arg = aH.Argument.valueOf(determination);
if (arg.matchesPrefix("pickup")) {
pickup_cancel = !arg.asElement().asBoolean();
return true;
}
return super.applyDetermination(container, determination);
Expand All @@ -103,6 +109,7 @@ public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("vehicle", vehicle);
context.put("entity", entity);
context.put("pickup", new Element(!pickup_cancel));
return context;
}

Expand Down
Expand Up @@ -22,7 +22,6 @@ public class VehicleMoveScriptEvent extends ScriptEvent implements Listener {
// <vehicle> moves
//
// @Warning This event fires very very rapidly!
// @Warning This is a listen-only event: it can't be stopped!
//
// @Triggers when a vehicle moves in the slightest.
// @Context
Expand Down

0 comments on commit 76af9a4

Please sign in to comment.