Solved Need Help with ExpBottle stuff

Discussion in 'Plugin Development' started by DogeGamingPRO, Nov 18, 2015.

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

    DogeGamingPRO

    So basically, Im working on this project/plugin where if users do /xpwithdraw <amount> and it will add a nbt-tagged(I am using https://www.spigotmc.org/resources/item-nbt-api.7939/ for it to work) expbottle to the user's inventory(All the xp are scaled properly thanks to ExperienceManager). The part that i need help on is the listener part where it listens for the user to throw an exp bottle and fetches its nbt tag(again, using https://www.spigotmc.org/resources/item-nbt-api.7939/), and gives the user the appropiate amount of xp. I've tried the ThrownExpBottle event, ExpBottleEvent and ProjectileLaunchEvent but nothing seems to work.You can try editing this
    Code:
        @EventHandler(priority=EventPriority.HIGH)
        public void onPlayerUse(PlayerInteractEvent event){
            Player p = event.getPlayer();
            ExperienceManager expman = new ExperienceManager(p);
            NBTItem nbti = new NBTItem(event.getItem());
                if(nbti.hasKey("XpContained")){
                    expman.setTotalExperience(expman.getTotalExperience()+nbti.getInteger("XpContained"));
                    p.sendMessage(ChatColor.YELLOW+"+"+nbti.getInteger("XpContained")+"XP");
            
            
        
    
                }
            else return;
        }
    
    (Sorry if the error is obvious because I'm a starter)
     
    Last edited: Nov 18, 2015
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    DogeGamingPRO

    @timtower Yes I did

    It seems like the nbt tag api is not working, i gave myself an ordinary xpbottle ingame and it stacks with the bottle spawned in by the plugin.

    EDIT: It doesnt stack, because it has a custom name, but I think the nbt tag api is not working

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.

    EDIT2: I changed the code a little bit and somehow got it to work, thanks anyways:)
     
    Last edited: Nov 18, 2015
  4. Offline

    Scimiguy

    @DogeGamingPRO
    Edit the title of this thread and add a solved marker then please
     
Thread Status:
Not open for further replies.

Share This Page