Remove hit cooldown

Discussion in 'Spigot Plugin Development' started by Miike001, May 16, 2019.

  1. Hello. I'm tring to develop a plugin that removes the hit cooldown. Like before 1.9 update.

    This is my main class:
    Code (Text):
    package com.micaelpires.oldpvp;

    import org.bukkit.attribute.Attribute;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin {
       
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e){
            e.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(100D);
        }
       
    }
     
    Please don't tell me to just use a plugin that already exist.
    Can anyone help me understanding what can I do?
    (PS: I've started developing Minecraft plugins today, so sorry if the answere is very obvisous but I'm new in this things xD)
     
    • Like Like x 1
    • Funny Funny x 1
  2. Choco

    Junior Mod

    But... why not? There is already a rather popular one that will likely do a lot better what you, a beginner, are trying to accomplish. I don't understand why you would want to replicate something that exists already.
     
  3. The advantages are that he saves time and the hassle to do this.
     
  4. I understand it. But the objective of do the plugin myself is learn. My objective is not put the server online for everyone, I'm just doing it to learn.
     
    • Agree Agree x 1
  5. Choco

    Junior Mod

    lolwhat? You're telling me that rewriting a 200KB jar is going to take less time than downloading it from the internet? How poor is your internet connection?

    I'd advise you learn on a less complicated topic.
     
    • Like Like x 1
    • Funny Funny x 1
  6. How disrespectful! It took 15 minutes to post that comment.

    smh my head.
     
    • Optimistic Optimistic x 1
  7. Can you give me some ideas?
     
  8. Make a simple command.
     
  9. Honestly don't know why everyone is being so stupidly toxic. Saying "just use a pre-made solution" is in no way useful for the people trying to learn.

    You have the right idea you just need to tell spigot to call your event handler. Learn about events here. You're doing well no matter what other people are saying keep it up.
     
    • Like Like x 3
    • Agree Agree x 2
    • Friendly Friendly x 1
  10. Jared_P

    Jared_P Previously xHavock

    To addon to what @slack69 said, it's also sometimes helpful to look at how other people have done it to get a starting idea. When I was learning and trying to look at how people did certain things on github or decompiling stuff, but it was very complicated due to not knowing code layout and package structure. So I found this for you: attack cooldown

    To learn, try and go through this class line by line till you don't understand something. When you get to the line you don't understand, research and review resources online or books (JavaForDummies is great to get started with Java) about that topic. It will usually lead you to a new topic you don't understand and then you branch out from there.

    but please DO NOT just copy the code found there, understand it first, experiment with it, and build upon it.

    If you find yourself not understanding a lot of it, try and reach out to learning Java resources (the aforementioned book). Spigot is just an API built in Java, if you understand Java, Spigot becomes easy.
     
    #10 Jared_P, May 18, 2019
    Last edited: May 18, 2019
    • Agree Agree x 1
  11. i've seen a plugin which has set the attack speed of the items to its highest value, im not sure if this is the best way but it worked for my server
     
  12. The PlayerJoinEvent is a good way to start with, but I highly recommend to use a plugin because rewriting that is super complicated.
     
  13. The last sentence is stupidly toxic, I didn't just read that.
     

  14. Code (Text):
        @EventHandler
        public void onDamagee(EntityDamageEvent e) {

            if((e.getEntity() instanceof Player)) {
                Player p = (Player) e.getEntity();
                    e.setCancelled(true);
                    p.damage(e.getFinalDamage());
                }

        }
    I use this
     
    • Friendly Friendly x 1

Share This Page