Skip to content

Commit

Permalink
use EntityMountEvent and EntityDismountEvent for vehicle events
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 22, 2020
1 parent d8f2120 commit b4b7c61
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Expand Up @@ -7,7 +7,7 @@
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.spigotmc.event.entity.EntityMountEvent;

import java.util.Arrays;
import java.util.HashSet;
Expand All @@ -29,15 +29,15 @@ public class EntityEntersVehicleScriptEvent extends BukkitScriptEvent implements
//
// @Cancellable true
//
// @Triggers when an entity enters a vehicle.
// @Triggers when an entity mounts another entity.
//
// @Context
// <context.vehicle> returns the EntityTag of the vehicle.
// <context.vehicle> returns the EntityTag of the mounted vehicle.
// <context.entity> returns the EntityTag of the entering entity.
//
// @Player when the entity that entered the vehicle is a player.
// @Player when the entity that mounted the vehicle is a player.
//
// @NPC when the entity that entered the vehicle is an NPC.
// @NPC when the entity that mounted the vehicle is an NPC.
//
// -->

Expand All @@ -48,7 +48,7 @@ public EntityEntersVehicleScriptEvent() {
public static EntityEntersVehicleScriptEvent instance;
public EntityTag vehicle;
public EntityTag entity;
public VehicleEnterEvent event;
public EntityMountEvent event;

public static HashSet<String> notRelevantEnterables = new HashSet<>(Arrays.asList("notable", "cuboid", "biome", "bed", "portal"));

Expand All @@ -63,7 +63,7 @@ public boolean couldMatch(ScriptPath path) {
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
if (!couldMatchVehicle(path.eventArgLowerAt(2))) {
if (!couldMatchEntity(path.eventArgLowerAt(2))) {
return false;
}
return true;
Expand Down Expand Up @@ -103,9 +103,9 @@ else if (name.equals("entity")) {
}

@EventHandler
public void onEntityEntersVehicle(VehicleEnterEvent event) {
vehicle = new EntityTag(event.getVehicle());
entity = new EntityTag(event.getEntered());
public void onEntityEntersVehicle(EntityMountEvent event) {
vehicle = new EntityTag(event.getMount());
entity = new EntityTag(event.getEntity());
this.event = event;
fire(event);
}
Expand Down
Expand Up @@ -7,7 +7,7 @@
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.spigotmc.event.entity.EntityDismountEvent;

public class EntityExitsVehicleScriptEvent extends BukkitScriptEvent implements Listener {

Expand All @@ -26,15 +26,15 @@ public class EntityExitsVehicleScriptEvent extends BukkitScriptEvent implements
//
// @Cancellable true
//
// @Triggers when an entity exits a vehicle.
// @Triggers when an entity dismounts from another entity.
//
// @Context
// <context.vehicle> returns the EntityTag of the vehicle.
// <context.vehicle> returns the EntityTag of the mount vehicle.
// <context.entity> returns the EntityTag of the exiting entity.
//
// @Player when the entity that exits the vehicle is a player.
// @Player when the entity that dismounts the vehicle is a player.
//
// @NPC when the entity that exists the vehicle is an NPC.
// @NPC when the entity that dismounts the vehicle is an NPC.
//
// -->

Expand All @@ -45,7 +45,7 @@ public EntityExitsVehicleScriptEvent() {
public static EntityExitsVehicleScriptEvent instance;
public EntityTag vehicle;
public EntityTag entity;
public VehicleExitEvent event;
public EntityDismountEvent event;

@Override
public boolean couldMatch(ScriptPath path) {
Expand All @@ -55,7 +55,7 @@ public boolean couldMatch(ScriptPath path) {
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
if (!couldMatchVehicle(path.eventArgLowerAt(2))) {
if (!couldMatchEntity(path.eventArgLowerAt(2))) {
return false;
}
return true;
Expand Down Expand Up @@ -95,9 +95,9 @@ else if (name.equals("entity")) {
}

@EventHandler
public void onEntityExitsVehicle(VehicleExitEvent event) {
vehicle = new EntityTag(event.getVehicle());
entity = new EntityTag(event.getExited());
public void onEntityExitsVehicle(EntityDismountEvent event) {
vehicle = new EntityTag(event.getDismounted());
entity = new EntityTag(event.getEntity());
this.event = event;
fire(event);
}
Expand Down

0 comments on commit b4b7c61

Please sign in to comment.