Solved Prevent event happening.

Discussion in 'Plugin Development' started by PreFixLT, Apr 30, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    PreFixLT

    Hello, I need some help, I want to prevent xp gaining event:

    @EventHandler
    public void onPlayerXpChange(PlayerExpChangeEvent e)
    {
    TPlayer tPlayer = Terasology.getTPlayer(e.getPlayer());
    tPlayer.addProgress(e.getAmount());

    }

    I want to do custom levels and so I worked with sourcepawn language there are "return Plugin_Handled;" but I think there aren't such things or maybe is?
     
  2. Offline

    ferrybig

    e.setCancelled(true)
     
  3. Offline

    PreFixLT

    The method setCancelled(boolean) is undefined for the type PlayerExpChangeEvent
     
  4. Offline

    Tzeentchful

    It's not an event event you can cancel. You will either have to do your XP calculations in the event set set the amount to your custom value. Or set the amount of XP they gain to 0 to stop the event having any effect.
    Code:java
    1. e.setAmount(0);// essentially cancels the event
    2. // Or
    3. int customValue = ...// Do a calculation
    4. e.setAmount(customValue);// Sets the custom value
    5.  
     
  5. Offline

    PreFixLT

    Thanks for you, but I solved it, found some solutions in other threads :O
     
Thread Status:
Not open for further replies.

Share This Page