Klasse ExplosionEvent

java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.world.ExplosionEvent
Alle implementierten Schnittstellen:
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}
  • Feldübersicht

    Von Klasse geerbte Felder net.risingworld.api.events.Event

    cancelled, pointer
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    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.

    Von Klasse geerbte Methoden net.risingworld.api.events.Event

    equals, hashCode, isValid

    Von Klasse geerbte Methoden java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Methodendetails

    • getPosition

      public Vector3f getPosition()
      Gets the global world position of the explosion.
      Gibt zurück:
      the global position, as a Vector3f
    • setPosition

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

      public void setPosition(float x, float y, float z)
      Changes the global world position of the explosion.
      Parameter:
      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.
      Gibt zurück:
      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.
      Parameter:
      damage - the amount of damage (players).
    • getPlayerDamage

      public short getPlayerDamage()
      Gets the amount of damage this explosion deals for players.
      Gibt zurück:
      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.
      Parameter:
      damage - the amount of damage (npcs).
    • getNpcDamage

      public short getNpcDamage()
      Sets the amount of damage this explosion deals for npcs (e.g animals).
      Gibt zurück:
      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.
      Parameter:
      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.
      Gibt zurück:
      the amount of damage (world).
    • setTriggerExplosives

      public void setTriggerExplosives(boolean set)
      Sets whether or not this explosion should trigger other explosives.
      Parameter:
      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.
      Gibt zurück:
      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.
      Gibt zurück:
      the player who triggered this explosion, or null if this explosion wasn't caused by a player.
    • isCancelled

      public boolean isCancelled()
      Beschreibung aus Schnittstelle kopiert: 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.
      Angegeben von:
      isCancelled in Schnittstelle Cancellable
      Gibt zurück:
      true if the event is cancelled, or false if not.
    • setCancelled

      public void setCancelled(boolean cancel)
      Beschreibung aus Schnittstelle kopiert: Cancellable
      Cancels this event. This means it will no longer be executed, but other plugins will still receive the event.

      Angegeben von:
      setCancelled in Schnittstelle Cancellable
      Parameter:
      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}