Solved EntityDamageEvent with Subclass does not fire.

Discussion in 'Plugin Development' started by marcelo.mb, Jan 10, 2021.

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

    marcelo.mb

    Hey,
    my EntityDamageEvent and my EntityDamageByEntityEvent does not fire anyway. In the following you see the important parts of code:

    MainClass
    Code:
    @Override
        public void onEnable() {
            //set listeners
            new PluginListeners(this);
        }
    PluginListeners
    Code:
    public class PluginListeners implements Listener {
        public MainClass plugin;
      
        public PluginListeners(MainClass plugin) {
              this.plugin = plugin;
              plugin.getServer().getPluginManager().registerEvents(this, plugin);
        }
      
        @EventHandler
        public void onBlockBreak(BlockBreakEvent e) {
            System.out.println("A block was broken. Help before the kingdom of Froozen collapses.");
        }
      
        @EventHandler
        public void onDamage(EntityDamageEvent e) {
            System.out.println("That's a lot of damage. 1");
        }
      
        @EventHandler
        public void onDamageByEntity(EntityDamageByEntityEvent e) {
            System.out.println("That's a lot of damage. 2");
        }
    }
    NOTE:
    EntityDamageEvent and EntityDamageByEntityEvent does not work. For testing, if Listener registered correctly there is also the BlockBreakEvent. And the BlockBreakEvent works the others dont.

    ADDITIONAL INF:
    • Yes, I registered the Listeners.
    • Yes, @EventHandler is before every Event
    • Yes, @Override is before onEnable()
    • No, there is no output in the console. Nothing except when I break a block.
    • Yes, PVP is enabled in the server.properties file.
    Hope someone can help me out of this. Found no solution. Thanks, buddies.
     
    Last edited: Jan 10, 2021
  2. Offline

    CraftCreeper6

    @marcelo.mb
    Since your first event is working and the others are not, it seems like the only plausible difference between them is that two have the same name. Since they both have differing parameters it shouldn't be a problem but it's worth changing one of them to try it out
     
    Last edited: Jan 10, 2021
    marcelo.mb likes this.
  3. Offline

    marcelo.mb

    @CraftCreeper6 Ok, actually, that's a really good and plausible argument. But unfortunately, it didn't work. I do not understand the world anymore.
     
  4. Offline

    CraftCreeper6

    @marcelo.mb
    Do you have any other plugins installed on the server?
     
  5. Offline

    marcelo.mb

    @CraftCreeper6 Yes, I have a few other plugins at my server. The good thing: They are all programmed by me so I know what they do. So I can say there is no plugin which uses EntityDamageEvent and/or EntityDamageByEntityEvent. Could there be another thing caused by another plugin?

    So, I tested it with only the current plugin with my problem. And it worked. If the plugin is alone in plugin folder it works. But how could this be? There is no other plugin which uses these events.
     
  6. Offline

    CraftCreeper6

    @marcelo.mb
    It doesn't really make sense. Do any other plugins use BlockBreakEvent and were producing a false positive for your debug?

    It seems like the plugin is in fact not loading.
     
  7. Offline

    marcelo.mb

    @CraftCreeper6 Ok. Yes, in other plugins there are BlockBreakEvents.

    I found another weird thing. If I apply a new update of one plugin and completely restart the server (just to go sure) it does not run the newest update.

    Example: I write "System.out.println("UPDATED");" in onEnable(). Then I compile the new update and make everything ready and start the server. The "UPDATED" is not going to be displayed in the console. If I remove all other plugins and only run the same updated version it works. In the console, I get an "UPDATED".

    So that is very weird and an interesting problem which I never had before. Could it be that if I often use same java class names they're causing any issues? Is this bug caused by Bukkit?

    NOTE:
    I know it sounds unbelievable, but it is that true. I also checked 12 times if I compile to the right path with all right settings and also restarted the server every time completely since there could be bugs within using reload command.
     
  8. Offline

    CraftCreeper6

    @marcelo.mb
    I honestly thought as much. I've had problems with this in the past where even after an update, exporting does absolutely nothing and does not update the jar at all.

    I don't think it's caused by Bukkit, are you using Eclipse?
     
  9. Offline

    marcelo.mb

    @CraftCreeper6 Yes, I am using Eclipse (Version: 2020-09 (4.17.0); 64 bit). How do you fix that in the past?
    So the weird thing is that the plugin works if he is alone without my other plugins as I already said. Probably he's ashamed. But anyway maybe there is a problem in Eclipse.[tnt]
     
  10. Offline

    CraftCreeper6

    @marcelo.mb
    I used to fix it by creating a new project and copying everything over to it. It's not great but it worked for me.
     
  11. Offline

    marcelo.mb

    @CraftCreeper6 So, unfortunately, it didn't work. But I am glad that somebody tries to help me out of this. Thanks.

    So just to check if it is caused by Eclipse or anything at the server:
    I compiled the new update of my plugin with eclipse and decompiled the jar with a decompiler. And it turns out it was the same code. So we can say that Eclipse works fine in my case and the update was successfully compiled.

    Check if it is caused by the plugin itself, combined with other plugins or caused by the server:
    I ran to servers. The one only with this one plugin I am currently developing at and the other server with all plugins inclusive the one I am working at installed. The result: The plugin I am currently developing at was working only on the server without the other plugins. Combined with other plugins the updated plugin dopes not work.

    Summary: It is not caused by Eclipse, also the failure is not caused by the server. The updated plugin works only alone without my other plugins and the plugin has no visible console errors. Also, the updated plugin is going to be enabled every time I restart the server and do not crash at any time.
    Conclusion: One of my other plugins has to do with the failure of the updated plugin I am currently working on.

    This problem drives me crazy.[flintnsteel]
     
  12. Offline

    CraftCreeper6

  13. Offline

    marcelo.mb

    @CraftCreeper6 Thanks for this tip. I also tested this and it didn't work.
    I think not that it is caused by any Eventpriorities, because in the updated plugin I put this "System.out.println("UPDATED");" into onEnable(). And even this does not appear in the console. But the plugin is enabled.

    @CraftCreeper6 Thanks for your help. I appreciate it.
    So finally I solved my problem. I can not tell you what I did. I just started the server for the 90 times and bam it just worked. Maybe lags caused by my computer? I am not sure. Anyway, the good thing is that everything works again.
    Thanks for your help.[diamond]
     
    Last edited: Jan 11, 2021
  14. Offline

    CraftCreeper6

    @marcelo.mb
    Who knows what the problem was. Very strange to say the least.
     
    marcelo.mb likes this.
Thread Status:
Not open for further replies.

Share This Page