Untitled
unknown
plain_text
2 years ago
1.6 kB
5
Indexable
package org.lifestealsmp.itemmetasaver; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import shwendel.durabilityapi.DurabilityAPI; public class main extends JavaPlugin implements Listener { public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(this, this); this.getCommand("durabilitytest").setExecutor(new DurabilityTestCommand()); } private class DurabilityTestCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "This command can only be run by a player."); return true; } Player player = (Player) sender; ItemStack item = player.getInventory().getItemInMainHand(); if (item == null || item.getType().isAir()) { player.sendMessage(ChatColor.RED + "Please hold an item in your main hand."); return true; } // Set a custom max durability value for testing purposes int testMaxDurability = 363; DurabilityAPI.setItemMaxDurability(item, testMaxDurability); return true; } } }
Editor is loading...