Solved Events not working...?!

Discussion in 'Plugin Development' started by 4thegame3, Nov 2, 2014.

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

    4thegame3

    I did all the necessary but they are not working, i also tried a debug with System.out after each event but nothing...

    Code:java
    1. package me.TheGame.giftChest;
    2.  
    3. import java.util.List;
    4.  
    5. import org.bukkit.Material;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.EventPriority;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.block.Action;
    11. import org.bukkit.event.entity.ItemDespawnEvent;
    12. import org.bukkit.event.inventory.InventoryCloseEvent;
    13. import org.bukkit.event.player.PlayerInteractEvent;
    14. import org.bukkit.event.player.PlayerJoinEvent;
    15. import org.bukkit.inventory.Inventory;
    16. import org.bukkit.plugin.java.JavaPlugin;
    17.  
    18.  
    19. public class event implements Listener {
    20. JavaPlugin plugin;
    21. manageConfig mC;
    22.  
    23. public event(JavaPlugin plugin) {
    24. this.plugin = plugin;
    25. mC = new manageConfig(plugin);
    26. }
    27.  
    28. @EventHandler(priority = EventPriority.LOWEST)
    29. public void onJoin(PlayerJoinEvent e) {
    30. if (!e.getPlayer().hasPlayedBefore()) {
    31. util util = new util(plugin);
    32. util.Gift(e.getPlayer());
    33.  
    34. }
    35. }
    36.  
    37. @EventHandler(priority = EventPriority.LOWEST)
    38. public void onClick(PlayerInteractEvent e) {
    39. Player p = e.getPlayer();
    40. if (e.getAction() == Action.RIGHT_CLICK_AIR
    41. || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    42. if (p.getItemInHand().getType().equals(Material.CHEST)
    43. && p.getItemInHand().getItemMeta().getDisplayName()
    44. .equals("§6Gift Chest")) {
    45. p.openInventory((Inventory) util.inv.get(
    46. p.getItemInHand().getItemMeta().getLore()).get(0));
    47. }
    48. }
    49. }
    50.  
    51. @EventHandler(priority = EventPriority.LOWEST)
    52. public void onClose(InventoryCloseEvent e) {
    53.  
    54. Player p = (Player) e.getPlayer();
    55. for (List<Object> list : util.inv.values()) {
    56. if (list.contains(e.getInventory())) {
    57. for (List<String> key : util.inv.keySet())
    58. mC.setInventory(key, ((Inventory) util.inv.get(key).get(0)));
    59. }
    60. if (util.isEmpty(e.getInventory())) {
    61. mC.delKey(p.getItemInHand().getItemMeta().getLore().get(0));
    62. util.inv.remove(p.getItemInHand().getItemMeta().getLore().get(0));
    63. p.getInventory().remove(p.getItemInHand());
    64.  
    65. }
    66. }
    67. }
    68.  
    69. @EventHandler(priority = EventPriority.LOWEST)
    70. public void onDespawn(ItemDespawnEvent e) {
    71. if (e.getEntity().getItemStack().getItemMeta().getLore() != null) {
    72. String lore = e.getEntity().getItemStack().getItemMeta().getLore()
    73. .get(0);
    74. if (util.inv.keySet().contains(lore)) {
    75. mC.delKey(lore);
    76. }
    77. }
    78. }
    79.  
    80. }
    81.  
    82.  
    83.  
    84.  


    Code:java
    1. public void onEnable() {
    2. util = new util(this);
    3. getServer().getPluginManager().registerEvents(new events(this), this);
    4. getLogger().info("Enabled!");
    5. }
     
  2. Offline

    JordyPwner

    Any errors?
     
  3. Offline

    Monkey_Swag

    not too sure what's wrong. It may be the following but idk: Rename your class 'events' to 'Events'. Classes must start with a Capital letter.
     
  4. Offline

    4thegame3

    JordyPwner not even one

    Monkey_Swag tried, still nothing.

    EDIT: nvm got it work, I dont know how :eek:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  5. Offline

    Tecno_Wizard

Thread Status:
Not open for further replies.

Share This Page