PlayerJoinEvent not firing?

Discussion in 'Plugin Development' started by CandyCranium, Jul 2, 2014.

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

    CandyCranium

    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerJoin(PlayerJoinEvent e) {
    4. Player p = e.getPlayer();
    5. p.getInventory().addItem(new ItemStack(getCustomItem(GUI.gui)));
    6. p.updateInventory();
    7. }
    8.  

    PlayerJoinEvent, yuno work?
     
  2. Offline

    jthort

    Did you register your events
     
  3. Offline

    CandyCranium

  4. Offline

    jthort

    Does your class implement listener
     
  5. Offline

    CandyCranium

  6. Offline

    Rocoty

    jthort The fact that he has registered the events kinda implies that the class implements Listener...

    CandyCranium Why don't you post all your code?
     
  7. Offline

    CandyCranium

    Rocoty

    Well I wouldn't want to show everybody the plugin I'm working on ;) But I'll post the important parts:

    Code:java
    1.  
    2. public static ItemStack getCustomItem(GUI item) {
    3. ItemStack is = null;
    4.  
    5. switch (item) {
    6. case gui:
    7. is = new ItemStack(Material.DIAMOND, 1);
    8. ItemMeta in = is.getItemMeta();
    9. in.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "One vs One");
    10. ArrayList<String> lore = new ArrayList<String>();
    11. lore.add(ChatColor.AQUA + "Play a One vs One battle against another player!");
    12. in.setLore(lore);
    13. is.setItemMeta(in);
    14. }
    15. return is;
    16. }
    17.  
    18. // Skip a few...
    19.  
    20. @SuppressWarnings("deprecation")
    21. @EventHandler
    22. public void onPlayerJoin(PlayerJoinEvent e) {
    23. Player p = e.getPlayer();
    24. p.getInventory().addItem(new ItemStack(getCustomItem(GUI.gui)));
    25. p.updateInventory();
    26. }
    27.  
     
  8. Offline

    CandyCranium

    CapitanChewbacca
    Code:java
    1.  
    2. Bukkit.getServer().getPluginManager().registerEvents(new OneVsOneGUI(this), this);
    3.  
    4. That's all the code Imma give you in the onEnable()
     
  9. Offline

    Rocoty

    make a print statement at the top of the event handler method. I'm afraid there is not much we can do to help you when you're so reluctant to share your code.

    ProTip: No one will be interested in stealing your code. And those who might be probably don't know Java and won't be able to use it anyway.
     
    CapitanChewbacca likes this.
  10. Offline

    CandyCranium

    CapitanChewbacca

    Okay so I just tried it, and now it gives me 3 diamonds instead of one -.-
     
  11. Offline

    Rocoty

    CandyCranium Or...just a thought, but maybe the two other diamonds have been there all along, but didn't show for whatever reason. Worth looking into. Since inventories don't always update, how can you be sure that the event doesn't fire? When such a thing happens ALWAYS add print statements to be absolutely sure that is the problem. If nothing is printed then your concerns are confirmed. If something is printed, however, then you can be sure the event is firing.
     
  12. Offline

    hankered

    We can't really help you, again, if you don't show the code.
     
  13. Offline

    jthort

    Yah never know :)
     
  14. Offline

    Rocoty

    jthort You're right. This is the Bukkit Forums after all.
     
    jthort likes this.
Thread Status:
Not open for further replies.

Share This Page