PyroAxe

Discussion in 'Plugin Requests' started by Karanveer00, Jun 3, 2018.

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

    Karanveer00

    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.
     
    Last edited by a moderator: Jun 3, 2018
  2. Offline

    SavageAvocado

  3. Offline

    Karanveer00

    thx dude can u send me the coding for it pls
     
  4. Offline

    SavageAvocado

    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;
        }
    }
     
    Last edited: Jun 4, 2018
  5. Offline

    MightyOne

    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()
     
  6. Offline

    timtower Administrator Administrator Moderator

  7. Offline

    MightyOne

    @timtower isn't there this problem with durabilities? so isSimilar() would still differenciate all 15~~ damaged version of diamond sword?
     
  8. Offline

    timtower Administrator Administrator Moderator

  9. Offline

    Karanveer00

    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
     
  10. Offline

    SavageAvocado

    @MightyOne I didn't think about that. Thanks for pointing it out.
     
  11. Offline

    Karanveer00

    pls fix it thx
     
  12. Offline

    SavageAvocado

  13. Offline

    Karanveer00

    one last time can u make it so it dose 36.75 dmg pls
    @SavageAvocado
     
  14. Offline

    MightyOne

    your special wishes are unmatchable
     
  15. Offline

    Karanveer00

  16. Offline

    SavageAvocado

    @Karanveer00 36.75 damage every hit? Okay, I updated it.
     
Thread Status:
Not open for further replies.

Share This Page