onPlayerRespawn

Discussion in 'Plugin Development' started by TECGaming360, Dec 10, 2014.

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

    TECGaming360

    Trying to get a Assigned "Item 1" to respawn a item every time player comes back and will go in 37 block (as shown in image) of hotbar!
    [​IMG]

    Here is my code so far!
    Code:
    @EventHandler
        public void onPlayerRespawn(PlayerRespawnEvent event){
        event.getPlayer().getInventory().getItem() == Material.getMaterial(KeepthatItem.plugin.getConfig().getString("Item 1").toUpperCase()));
        }
    getItem() <- Is coming up error
     
  2. Offline

    Skionz

    @TECGaming360 Not to offend but that is completely wrong. '==' is used to compare objects mainly in control statements. You should be using Inventory#setItem() instead.
     
  3. Offline

    TECGaming360

    @Skionz
    Still Does not work changing setItem. Because the Config files has the user type in compass or what ever they want!

    So it wouldn't be a number, it would be a Item name.

    Code:
    @EventHandler
        public void onPlayerRespawn(PlayerRespawnEvent event){
        event.getPlayer().getInventory().getItem(Material.getMaterial(KeepthatItem.plugin.getConfig().getString("Item 1").toUpperCase()));
        }
     
  4. Offline

    Skionz

    @TECGaming360 Create a new ItemStack instance from the Material in the config. Then use the setItem method correctly and it will work.
     
  5. Offline

    TECGaming360

    @Skionz
    How would you get it to force slot 1?

    / sot 37 using image
     
    Last edited by a moderator: Dec 10, 2014
  6. Offline

    Tehmaker

  7. Offline

    Skionz

    @TECGaming360 The first parameter takes an integer. I suggest taking a look at the Javadocs before asking.
     
Thread Status:
Not open for further replies.

Share This Page