Search in sources :

Example 71 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class BlockIgnitesScriptEvent method onBlockIgnites.

@EventHandler
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) {
        // TODO: Why would this be null?
        origin_location = new dLocation(event.getIgnitingBlock().getLocation());
    }
    cause = new Element(event.getCause().toString());
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Element(net.aufdemrand.denizencore.objects.Element) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) EventHandler(org.bukkit.event.EventHandler)

Example 72 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class CommandSmartEvent method playerCommandPreprocess.

// <--[event]
// @Events
// command
// <command_name>|... command (in <area>)
//
// @Regex ^on( [^\s]+)? command( in ((notable (cuboid|ellipsoid))|([^\s]+)))?$
//
// @Triggers when a player or console runs a Bukkit command. This happens before
// any code of established commands allowing scripters to 'override' existing commands.
// @Context
// <context.command> returns the command name as an Element.
// <context.raw_args> returns any args used as an Element.
// <context.args> returns a dList of the arguments.
// <context.server> returns true if the command was run from the console.
// <context.cuboids> DEPRECATED.
//
// @Determine
// "FULFILLED" to tell Bukkit the command was handled.
//
// -->
@EventHandler
public void playerCommandPreprocess(PlayerCommandPreprocessEvent event) {
    Map<String, dObject> context = new HashMap<String, dObject>();
    String message = event.getMessage();
    String command = message.split(" ")[0].replace("/", "").toUpperCase();
    List<String> events = new ArrayList<String>();
    events.add("command");
    events.add(command + " command");
    events.addAll(getAll(command));
    // Look for cuboids that contain the block's location
    List<dCuboid> cuboids = dCuboid.getNotableCuboidsContaining(event.getPlayer().getLocation());
    dList cuboid_context = new dList();
    List<String> cuboidEvents = new ArrayList<String>();
    for (dCuboid cuboid : cuboids) {
        for (String str : events) {
            cuboidEvents.add(str + " in " + cuboid.identifySimple());
        }
        cuboid_context.add(cuboid.identifySimple());
    }
    events.addAll(cuboidEvents);
    // Add in cuboids context, with either the cuboids or an empty list
    context.put("cuboids", cuboid_context);
    List<String> args = Arrays.asList(aH.buildArgs(message.split(" ").length > 1 ? message.split(" ", 2)[1] : ""));
    // Fill context
    context.put("args", new dList(args));
    context.put("parsed_args", new dList(args));
    context.put("command", new Element(command));
    context.put("raw_args", new Element((message.split(" ").length > 1 ? message.split(" ", 2)[1] : "")));
    context.put("server", Element.FALSE);
    String determination;
    // Run any event scripts and get the determination.
    determination = BukkitWorldScriptHelper.doEvents(events, null, dEntity.getPlayerFrom(event.getPlayer()), context).toUpperCase();
    // receive the default 'Invalid command' gibberish from bukkit.
    if (determination.equals("FULFILLED") || determination.equals("CANCELLED")) {
        event.setCancelled(true);
    }
}
Also used : net.aufdemrand.denizencore.objects.dObject(net.aufdemrand.denizencore.objects.dObject) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) Element(net.aufdemrand.denizencore.objects.Element) net.aufdemrand.denizen.objects.dCuboid(net.aufdemrand.denizen.objects.dCuboid) EventHandler(org.bukkit.event.EventHandler)

Example 73 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class CreeperPoweredScriptEvent method onCreeperPowered.

@EventHandler
public void onCreeperPowered(CreeperPowerEvent event) {
    lightning = new dEntity(event.getLightning());
    entity = new dEntity(event.getEntity());
    cause = new Element(event.getCause().name());
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Element(net.aufdemrand.denizencore.objects.Element) EventHandler(org.bukkit.event.EventHandler)

Example 74 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class EntityChangesBlockScriptEvent method onEntityChangesBlock.

@EventHandler
public void onEntityChangesBlock(EntityChangeBlockEvent event) {
    entity = new dEntity(event.getEntity());
    location = new dLocation(event.getBlock().getLocation());
    old_material = dMaterial.getMaterialFrom(location.getBlock().getType(), location.getBlock().getData());
    new_material = dMaterial.getMaterialFrom(event.getTo());
    cuboids = new dList();
    for (dCuboid cuboid : dCuboid.getNotableCuboidsContaining(location)) {
        cuboids.add(cuboid.identifySimple());
    }
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) net.aufdemrand.denizen.objects.dCuboid(net.aufdemrand.denizen.objects.dCuboid) EventHandler(org.bukkit.event.EventHandler)

Example 75 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class EntityCreatePortalScriptEvent method onEntityCreatesPortal.

@EventHandler
public void onEntityCreatesPortal(EntityCreatePortalEvent event) {
    entity = new dEntity(event.getEntity());
    portal_type = new Element(event.getPortalType().toString());
    /*
        blocks = new dList();
        for (int i=0; i < event.getBlocks().size(); i++) {
            dLocation tempLoc = new dLocation(event.getBlocks().get(i).getBlock().getLocation());
            blocks.add(tempLoc.identifySimple());
        }
*/
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Element(net.aufdemrand.denizencore.objects.Element) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EventHandler (org.bukkit.event.EventHandler)532 Player (org.bukkit.entity.Player)185 Entity (org.bukkit.entity.Entity)70 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)67 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)62 Block (org.bukkit.block.Block)62 ItemStack (org.bukkit.inventory.ItemStack)55 Location (org.bukkit.Location)54 Island (com.wasteofplastic.acidisland.Island)42 Element (net.aufdemrand.denizencore.objects.Element)38 LivingEntity (org.bukkit.entity.LivingEntity)37 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)31 Minigame (au.com.mineauz.minigames.minigame.Minigame)29 net.aufdemrand.denizen.objects.dItem (net.aufdemrand.denizen.objects.dItem)29 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)28 Projectile (org.bukkit.entity.Projectile)26 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)23 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)22 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)18 ArrayList (java.util.ArrayList)18