CreatureSpawnEvent

Discussion in 'Plugin Development' started by KaaaaJ, Jan 19, 2021.

  1. Offline

    KaaaaJ

    i try logs on every line.
    its simple code but i dont know why it stops on the start of the event
    Code:
    package pl.KaJ.extremeMobs.Listeners;
    
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Creeper;
    import org.bukkit.entity.EntityType;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.CreatureSpawnEvent;
    
    import pl.KaJ.extremeMobs.Main;
    import pl.KaJ.extremeMobs.commands.turn;
    
    public class CreeperChange implements Listener {
       
        @SuppressWarnings("unused")
        private Main plugin;
    
        public CreeperChange(Main plugin) {    
            this.plugin = plugin;
        }
       
        @EventHandler
        public void onSpawn(CreatureSpawnEvent event) {
            plugin.getLogger().info("ExtremeMobs Is now enabled");
            if ((event.getEntityType() == EntityType.CREEPER) && (turn.ExtremeMobsEnabled == true)) {
                Creeper creeper = (Creeper) event.getEntity();
                creeper.setPowered(true);
                creeper.setMaxFuseTicks(10);
               
            }
        }
    }
    
    
    That is the class.
    btw sorry for my english :)
     
  2. Offline

    Legendary_zotar

    @KaaaaJ Where exactly does it stop? or does it not work at all?
    Have you registered you event in the main?
    Code:
    Bukkit.getPluginManager().registerEvents(new CreeperChange(this), this);
     
  3. Offline

    KaaaaJ

    @Legendary_zotar It stops on @EventHandler the plugin is loaded on my server but it stops i try logs and last was before @EventHandler :) and i registered it in main but little differrently
    Code:
            new pl.KaJ.extremeMobs.Listeners.CreeperChange(this);
     
  4. Offline

    timtower Administrator Administrator Moderator

    @KaaaaJ That does not register it as listener
    You need this piece regardless: Bukkit.getPluginManager().registerEvents
     
  5. Offline

    KaaaaJ

    Last edited: Jan 20, 2021

Share This Page