Question

I'm trying to set up this API so that I can update player scoreboards and things when they buy items.

The plugin I'm using is called SignShop and can be found here:

http://dev.bukkit.org/bukkit-plugins/signshop/pages/sign-shop-api/

That's not my issue though, the issue is that none of the events are firing from the looks of it.

Here is my class where I was trying some debugging.

package me.galaxywarrior6.minecraftgta.events;

import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.wargamer2010.signshop.events.SSMoneyTransactionEvent;
import org.wargamer2010.signshop.events.SSPostTransactionEvent;
import org.wargamer2010.signshop.events.SSPreTransactionEvent;
import org.wargamer2010.signshop.events.SSTouchShopEvent;

public class SignBuyEvent implements Listener{

    public void onSignBuy(SSMoneyTransactionEvent event){
        Bukkit.getServer().broadcastMessage("one!");
    }
    public void onSignBuy(SSPreTransactionEvent event){
        Bukkit.getServer().broadcastMessage("two!");
    }
    public void onSignBuy(SSPostTransactionEvent event){
        Bukkit.getServer().broadcastMessage("three!");
    }
    public void onSignBuy(SSTouchShopEvent event){
        Bukkit.getServer().broadcastMessage("four!");
    }
}

Can someone please help me in implementing this API, I haven't done anything besides set up the events because that's all it really tells you to do.

Was it helpful?

Solution

That's because you need @EventHandler right above all of your events:

@EventHandler //this must be before ALL events
public void onSignBuy(SSMoneyTransactionEvent event){
    Bukkit.getServer().broadcastMessage("one!");
}

also, you may not be registering events. In your main file (the one that extends JavaPlugin), make sure you have this in your onEnable():

this.getServer().getPluginManager().registerEvents(new SignBuyEvent(), this);

So, your SignBuyEvent class should look like this:

public class SignBuyEvent implements Listener{
  @EventHandler
  public void onSignBuy(SSMoneyTransactionEvent event){
    Bukkit.getServer().broadcastMessage("one!");
  }

  @EventHandler
  public void onSignBuy(SSPreTransactionEvent event){
    Bukkit.getServer().broadcastMessage("two!");
  }

  @EventHandler
  public void onSignBuy(SSPostTransactionEvent event){
    Bukkit.getServer().broadcastMessage("three!");
  }

  @EventHandler
  public void onSignBuy(SSTouchShopEvent event){
    Bukkit.getServer().broadcastMessage("four!");
  }
}

and your onEnable() method in your Main class should look like this:

@Override
public void onEnable(){
  this.getServer().getPluginManager().registerEvents(new SignBuyEvent(), this);

  //other things that you have in your onEnable here
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top