Plugin category: PyroAxe Minecraft version: 1.8 Suggested name: pyroaxe What I want: I'd like to have a axe called pyroaxe witch have Sharp v Fire 2 and Mulltiple dmg : 3 when u hit someone Ideas for commands: /Pyroaxe Ideas for permissions: player.canuse When I'd like it by: in 2 hours or 4 hours pls can u pls finish this fast i need it EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Code: public class Pyroaxe extends JavaPlugin { private ItemStack pyroaxe; @Override public void onEnable() { this.loadPyroaxe(); this.loadCommands(); this.loadListeners(); } private void loadPyroaxe() { this.pyroaxe = new ItemStack(Material.DIAMOND_AXE, 1); ItemMeta meta = this.pyroaxe.getItemMeta(); meta.setDisplayName(this.color("&6❋&lPyroaxe&6❋")); meta.addEnchant(Enchantment.DAMAGE_ALL, 5, true); meta.addEnchant(Enchantment.FIRE_ASPECT, 2, true); this.pyroaxe.setItemMeta(meta); } private void loadCommands() { this.getCommand("pyroaxe").setExecutor(new PyroaxeCmd(this)); } private void loadListeners() { PluginManager pluginManager = this.getServer().getPluginManager(); pluginManager.registerEvents(new AttackE(this), this); } public void message(CommandSender user, String message) { user.sendMessage(this.color(message)); } private String color(String message) { return ChatColor.translateAlternateColorCodes('&', message); } public boolean isPyroaxe(ItemStack item) { if (item.getType() != this.getPyroaxe().getType()) return false; if (!this.getPyroaxe().getItemMeta().getDisplayName().equals(item.getItemMeta().getDisplayName())) return false; for (Enchantment enchantment : item.getItemMeta().getEnchants().keySet()) if (!this.getPyroaxe().getItemMeta().getEnchants().containsKey(enchantment)) return false; return true; } public ItemStack getPyroaxe() { return this.pyroaxe; } } Code: public class AttackE implements Listener { private Pyroaxe plugin; public AttackE(Pyroaxe plugin) { this.plugin = plugin; } @EventHandler public void onDamageE(EntityDamageByEntityEvent e) { if (!(e.getDamager() instanceof Player)) return; Player user = (Player) e.getDamager(); if (!this.plugin.isPyroaxe(user.getItemInHand())) return; e.setDamage(e.getDamage() * 3); } } Code: public class PyroaxeCmd implements CommandExecutor { private Pyroaxe plugin; public PyroaxeCmd(Pyroaxe plugin) { this.plugin = plugin; } @Override public boolean onCommand(CommandSender sender, Command cmd, String d, String[] args) { if (!(sender instanceof Player)) { this.plugin.message(sender, "&cThis command can only be used by players."); return true; } Player user = (Player) sender; if (!user.hasPermission("pyroaxe.get")) { this.plugin.message(user, "&cYou do not have permission to use this command."); return true; } user.getInventory().addItem(this.plugin.getPyroaxe()); this.plugin.message(user, this.plugin.getPyroaxe().getItemMeta().getDisplayName() + " &7was added to your inventory."); return true; } }
you should be careful with that. AFAIK it can lead to a NPE if the display name is null. I would swap the item with the pyroaxe here or test if the ItemMeta.hasDisplayName()
@timtower isn't there this problem with durabilities? so isSimilar() would still differenciate all 15~~ damaged version of diamond sword?
dude can pls fix this the axe should do x3 dmg not 3dmg so if the axe dose 6dmg it chould x it by 3 (18dmg) so can u pls fix it