If player close custom inventory, re-open this

Discussion in 'Plugin Development' started by alexisngo1605, May 5, 2015.

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

    alexisngo1605

    Hi everyone ! I'm making a plugin that open an inventory when you join server and you cannot close it before 5 seconds. I tried this code but when you close the inventory, there is a bug that disconnect you ?

    Code:
    @EventHandler
    public void Close(InventoryCloseEvent e) {
    Player p = (Player) e.getPlayer();
    if(!e.getInventory().getName().equalsIgnoreCase(DayGift.getName() || cooldownTime.get(p) > 0)) return;
           p.openInventory(DayGift);
    Thanks for help :) !
     
    Last edited: May 5, 2015
  2. @alexisngo1605 Try checking the timer, if it is greater than 0 then cancel.
     
    alexisngo1605 likes this.
  3. Offline

    alexisngo1605

    Code:
    @EventHandler
    public void Close(InventoryCloseEvent e) {
    Player p = (Player) e.getPlayer();
    if(!e.getInventory().getName().equalsIgnoreCase(DayGift.getName() || cooldownTime.get(p) > 0)) return;
    p.openInventory(DayGift);
    }else{
    if(!e.getInventory().getName().equalsIgnoreCase(DayGift.getName() || cooldownTime.get(p) == 0)) {
    p.closeInventory();
    cancel();
    }
    No mistakes for the code but there is always the bug that disconnect you on close inventory, I tried this without cooldown and the bug is always here.

    Code:
    @EventHandler
    public void Close(InventoryCloseEvent e) {
    Player p = (Player) e.getPlayer();
    if(!e.getInventory().getName().equalsIgnoreCase(DayGift.getName())) return;
    p.openInventory(DayGift);
    }
    But thank you after all ^^
     
  4. Does it throw an error in the console? If so send it
     
    alexisngo1605 likes this.
  5. Offline

    alexisngo1605

    Thank you, I'm going to try this

    The code:
    Code:
    Player megamichiel = Bukkit.getPlayer("megamichiel")
    is yellow

    And the code:
    Code:
    if(!megamichiel.isOwner()) {
    had a mistake​

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: May 7, 2015
  6. Offline

    Msrules123

    That's his signature... Lol.

    In your console, is your plugin throwing errors?
     
  7. Offline

    Ambamore2000

    This part made me laugh...
    OnTopic:
    What is the error...
     
  8. Offline

    alexisngo1605

    Oh, I saw that x) ! I'm so confused, I was wondering what's that code !

    Yeah it's throwing error, and the player is disconnected 30 seconds after

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: May 7, 2015
Thread Status:
Not open for further replies.

Share This Page