Swingspeed

Discussion in 'Plugin Requests' started by Jamesol1, Sep 3, 2017.

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

    Jamesol1

    1.12

    Swingspeed

    A plugin that can reduce the swing speed of axes. I have a plugin that can edit the damage of axes... so it will make a sort of secondary weapon option. Add in shields and axes will be easier to block but will do alot more damage.
    Is this do-able? If not let me know.

    Thanks
     
  2. Offline

    MightyOne

    I guess it is possible. Could you describe more clearly which functions this plugin should have?
     
  3. Offline

    MasterDoctor

    Okay I'm unable to finish this but here's what I have so far if anyone wants to continue this:
    Code:
        @EventHandler
        public void onSlotChange(PlayerItemHeldEvent event){
            if(inConfig(event.getPlayer().getInventory().getItem(event.getNewSlot()).getType())){
                //TODO: Check here to see if the item has already been updated
                ItemStack item = event.getPlayer().getInventory().getItem(event.getNewSlot());
                net.minecraft.server.v1_9_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
                NBTTagCompound compound = (nmsItem.hasTag()) ? nmsItem.getTag() : new NBTTagCompound();
                NBTTagList modifiers = new NBTTagList();
             
                NBTTagCompound attackSpeed = new NBTTagCompound();
                attackSpeed.set("AttributeName", new NBTTagString("generic.attackSpeed"));
                attackSpeed.set("Name", new NBTTagString("generic.attackSpeed"));
                attackSpeed.set("Amount", new NBTTagInt(getConfigValue(item.getType())));
                attackSpeed.set("Operation", new NBTTagInt(0));
                attackSpeed.set("UUIDLeast", new NBTTagInt(894654));
                attackSpeed.set("UUIDMost", new NBTTagInt(2872));
                attackSpeed.set("Slot", new NBTTagString("mainhand"));
                modifiers.add(attackSpeed);
                compound.set("AttributeModifiers", modifiers);
                nmsItem.setTag(compound);
                event.getPlayer().getInventory().setItem(event.getNewSlot(), CraftItemStack.asBukkitCopy(nmsItem));
            }
        }
    
    I realized that the best way to go about this is probably to mess with the NBT (you might want to see if the API for this has been written into the version that the OP is using.)

    I've been using this for reference: https://bukkit.org/threads/1-11-the-complete-guide-to-item-nbttags-attributes.411448/
     
    Last edited: Sep 5, 2017
  4. Offline

    nahkd123

    Enable command block in your server then give mining fatigue effect when player holding item so you don't need plugins anymore.
     
  5. Offline

    MightyOne

    @MasterDoctor dude this already works xD. I mean it would not be a big thing to... replace every axe ingame? maybe it would. anyway thx for the tutorial. I'l see what i can do for this plugin

    aaaaaaand its too difficult
     
    Last edited: Sep 17, 2017
    MasterDoctor likes this.
Thread Status:
Not open for further replies.

Share This Page