Search in sources :

Example 1 with VehicleEvent

use of org.bukkit.event.vehicle.VehicleEvent in project CommandHelper by EngineHub.

the class BukkitAbstractEventMixin method evaluate_helper.

@Override
public Map<String, Construct> evaluate_helper(BindableEvent event) throws EventException {
    Map<String, Construct> map = new HashMap<>();
    map.put("event_type", new CString(mySuper.getName(), Target.UNKNOWN));
    String macro;
    Object e = event._GetObject();
    if (e instanceof BlockEvent) {
        macro = "block";
    } else if (e instanceof EntityEvent) {
        macro = "entity";
        if (((EntityEvent) e).getEntity() instanceof Player) {
            Entity entity = ((EntityEvent) e).getEntity();
            map.put("player", new CString(entity.getName(), Target.UNKNOWN));
        }
    } else if (e instanceof HangingEvent) {
        macro = "entity";
    } else if (e instanceof InventoryEvent) {
        macro = "inventory";
    } else if (e instanceof PlayerEvent) {
        map.put("player", new CString(((PlayerEvent) e).getPlayer().getName(), Target.UNKNOWN));
        macro = "player";
    } else if (e instanceof ServerEvent) {
        macro = "server";
    } else if (e instanceof VehicleEvent) {
        macro = "vehicle";
    } else if (e instanceof WeatherEvent) {
        macro = "weather";
    } else if (e instanceof WorldEvent) {
        macro = "world";
    } else {
        macro = "custom";
    }
    map.put("macrotype", new CString(macro, Target.UNKNOWN));
    return map;
}
Also used : Entity(org.bukkit.entity.Entity) InventoryEvent(org.bukkit.event.inventory.InventoryEvent) Player(org.bukkit.entity.Player) HashMap(java.util.HashMap) PlayerEvent(org.bukkit.event.player.PlayerEvent) CString(com.laytonsmith.core.constructs.CString) WeatherEvent(org.bukkit.event.weather.WeatherEvent) CString(com.laytonsmith.core.constructs.CString) HangingEvent(org.bukkit.event.hanging.HangingEvent) VehicleEvent(org.bukkit.event.vehicle.VehicleEvent) ServerEvent(org.bukkit.event.server.ServerEvent) EntityEvent(org.bukkit.event.entity.EntityEvent) WorldEvent(org.bukkit.event.world.WorldEvent) Construct(com.laytonsmith.core.constructs.Construct) BlockEvent(org.bukkit.event.block.BlockEvent)

Aggregations

CString (com.laytonsmith.core.constructs.CString)1 Construct (com.laytonsmith.core.constructs.Construct)1 HashMap (java.util.HashMap)1 Entity (org.bukkit.entity.Entity)1 Player (org.bukkit.entity.Player)1 BlockEvent (org.bukkit.event.block.BlockEvent)1 EntityEvent (org.bukkit.event.entity.EntityEvent)1 HangingEvent (org.bukkit.event.hanging.HangingEvent)1 InventoryEvent (org.bukkit.event.inventory.InventoryEvent)1 PlayerEvent (org.bukkit.event.player.PlayerEvent)1 ServerEvent (org.bukkit.event.server.ServerEvent)1 VehicleEvent (org.bukkit.event.vehicle.VehicleEvent)1 WeatherEvent (org.bukkit.event.weather.WeatherEvent)1 WorldEvent (org.bukkit.event.world.WorldEvent)1