Class ExplosionEvent

java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.world.ExplosionEvent
All Implemented Interfaces:
Cancellable

public final class ExplosionEvent extends Event implements Cancellable
Called when an explosion is triggered (e.g caused by tnt).
Example: Prevent explosion from causing any damage (but it's still visible)
1@EventMethod
2public void onExplosion(ExplosionEvent event){
3 //set damage for players to 0
4 event.setPlayerDamage((short)0);
5
6 //set damage for npcs to 0
7 event.setNpcDamage((short)0);
8
9 //set damage for buildings/plants/world to 0
10 event.setWorldDamage((short)0);
11}

Example: Suppress explosion, so it neither causes damage nor is visible at all
1@EventMethod
2public void onExplosion(ExplosionEvent event){
3 //just cancel the event
4 event.setCancelled(true);
5}
  • Field Summary

    Fields inherited from class net.risingworld.api.events.Event

    cancelled, pointer
  • Method Summary

    Modifier and Type
    Method
    Description
    short
    Sets the amount of damage this explosion deals for npcs (e.g animals).
    short
    Gets the amount of damage this explosion deals for players.
    Gets the global world position of the explosion.
    Gets the related item which caused this explosion (e.g tnt).
    Gets the player who is responsible for this explosion.
    short
    Sets the amount of damage this explosion deals for world structures (i.e buildings), objects and vegetations.
    boolean
    Determines if the event is cancelled.
    boolean
    Gets whether or not other explosives will be triggered by this explosion.
    void
    setCancelled(boolean cancel)
    Cancels this event.
    void
    setNpcDamage(short damage)
    Sets the amount of damage this explosion deals for npcs (e.g animals).
    void
    setPlayerDamage(short damage)
    Sets the amount of damage this explosion deals for players.
    void
    setPosition(float x, float y, float z)
    Changes the global world position of the explosion.
    void
    Changes the global world position of the explosion.
    void
    setTriggerExplosives(boolean set)
    Sets whether or not this explosion should trigger other explosives.
    void
    setWorldDamage(short damage)
    Sets the amount of damage this explosion deals for world structures (i.e buildings), objects and vegetations.

    Methods inherited from class net.risingworld.api.events.Event

    equals, hashCode, isValid

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getPosition

      public Vector3f getPosition()
      Gets the global world position of the explosion.
      Returns:
      the global position, as a Vector3f
    • setPosition

      public void setPosition(Vector3f position)
      Changes the global world position of the explosion.
      Parameters:
      position - the new position.
    • setPosition

      public void setPosition(float x, float y, float z)
      Changes the global world position of the explosion.
      Parameters:
      x - the new x position.
      y - the new y position.
      z - the new z position.
    • getRelatedItem

      public WorldItem getRelatedItem()
      Gets the related item which caused this explosion (e.g tnt). If this explosion wasn't caused by an item, this function returns null.
      Returns:
      the item which caused this explosion, or null if there is no related item.
    • setPlayerDamage

      public void setPlayerDamage(short damage)
      Sets the amount of damage this explosion deals for players. Set to 0 to prevent this explosion from harming players.
      Parameters:
      damage - the amount of damage (players).
    • getPlayerDamage

      public short getPlayerDamage()
      Gets the amount of damage this explosion deals for players.
      Returns:
      the amount of damage (players).
    • setNpcDamage

      public void setNpcDamage(short damage)
      Sets the amount of damage this explosion deals for npcs (e.g animals). Set to 0 to prevent this explosion from harming npcs.
      Parameters:
      damage - the amount of damage (npcs).
    • getNpcDamage

      public short getNpcDamage()
      Sets the amount of damage this explosion deals for npcs (e.g animals).
      Returns:
      the amount of damage (npcs).
    • setWorldDamage

      public void setWorldDamage(short damage)
      Sets the amount of damage this explosion deals for world structures (i.e buildings), objects and vegetations. Set to 0 to prevent this explosion from causing any damage to the world.
      Parameters:
      damage - the amount of damage (world).
    • getWorldDamage

      public short getWorldDamage()
      Sets the amount of damage this explosion deals for world structures (i.e buildings), objects and vegetations.
      Returns:
      the amount of damage (world).
    • setTriggerExplosives

      public void setTriggerExplosives(boolean set)
      Sets whether or not this explosion should trigger other explosives.
      Parameters:
      set - true to trigger other explosives which are in proximity, false to prevent this behaviour.
    • isTriggerExplosivesEnabled

      public boolean isTriggerExplosivesEnabled()
      Gets whether or not other explosives will be triggered by this explosion.
      Returns:
      true if other explosives in proximity get triggered by this explosion, false if not.
    • getRelatedPlayer

      public Player getRelatedPlayer()
      Gets the player who is responsible for this explosion. Returns null if this explosion is not caused by a player.
      Returns:
      the player who triggered this explosion, or null if this explosion wasn't caused by a player.
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: Cancellable
      Determines if the event is cancelled. If an event is cancelled, it will no longer be executed, but other plugins will still receive the event.

      Please note: If the event is threaded, cancellation has no effect, i.e the event will still be executed.
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if the event is cancelled, or false if not.
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: Cancellable
      Cancels this event. This means it will no longer be executed, but other plugins will still receive the event.

      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      cancel - set to true if you want to cancel this event.
      Example: Cancel "PlayerEnterAreaEvent", i.e prevent player from entering an area
      1//Listener class
      2public class PlayerListener implements Listener{
      3 @EventMethod
      4 public void onEnterArea(PlayerEnterAreaEvent evt){
      5 //Now the player will not be able to enter the area, i.e.
      6 //he will be teleported back to his old position (outside the area)
      7 evt.setCancelled(true);
      8 }
      9}