Solved Unbreakable items?

Discussion in 'Spigot Plugin Development' started by teeter11, Jul 12, 2015.

Thread Status:
Not open for further replies.
  1. Is there a way to make an item never loose durability?
     
  2. A runnable for all player, set item in hand max durability?
     
  3. No i want it so you can type /unbreakable and that item your holding will never loose any durability.
     
  4. Humm... I think there is a "NBTTag" for do this, but i don't know what's it :(
     
  5. konsolas

    Supporter

    ItemStack.spigot().setUnbreakable(true);
     
    • Useful Useful x 3
    • Winner Winner x 2
  6. I must be doing this wrong because it underlines red on setUnbreakable(true);

    It says : The method setUnbreakable(boolean) is undefined for the type ItemStack

    My code :



    package me.Teeter.BearUnbreaking2;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.*;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Unbreaking2Main extends JavaPlugin {

    public void onEnable(){

    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd,String label, String[] args){
    if (cmd.getName().equalsIgnoreCase("unbreakable")){
    if (!(sender instanceof Player)) {

    return true;
    }
    Player s = (Player) sender;

    ItemStack unbreakable = new ItemStack(s.getItemInHand());
    unbreakable.setUnbreakable(true);

    }
    return false;
    }


    }
     
  7. item.spigot().setUnbreakable(boolean);
     
    • Agree Agree x 1
  8. I get a red underline and it says : The method spigot() is undefined for the type ItemStack
     
    • Funny Funny x 1
  9. What's the API you imported?
     
  10. I first used craftbukkit-1.8.7.jar
    then tried the spigot.jar

    neither worked

    @RolynDev
     
  11. It is normal that its not working: here we speak of a function Spigot and you have Bukkit ...
     
    • Agree Agree x 2
  12. would this be correct? even if i had the correct spigot

    s.getItemInHand().spigot().setUnbreakable(true);
     
    #12 teeter11, Jul 12, 2015
    Last edited: Jul 12, 2015
  13. There's an unbreakable nbt tag for items. Do you know how to set nbt tags for items?
     

  14. only if its a normal minecraft command

    is there a way to set an NBTTag in spigot?
     
    #14 teeter11, Jul 12, 2015
    Last edited: Jul 12, 2015
  15. Yes
     
  16. Import the spigot.jar and use item.spigot().setUnbreakable(boolean);
     
    • Friendly Friendly x 1
  17. ItemStack.spigot().setUnbreakable(true);
     
    • Friendly Friendly x 1
  18. This thread is just too funny.
     
    • Agree Agree x 10
    • Optimistic Optimistic x 2
    • Funny Funny x 1
  19. Command:

    /give @p minecraft:diamond_sword 1 0 {Unbreakable:1,display:{Name:"Name",Lore:[Lore]}}
     
    • Funny Funny x 6
    • Useful Useful x 3
Thread Status:
Not open for further replies.