Disable Creeper Spawning at daytime

Discussion in 'Plugin Development' started by ZderKi, Jun 14, 2019 at 8:52 AM.

  1. Offline

    ZderKi

    So i tried doing this multiple ways... either of them didnt work, any help please?

    Code:
    long time = getServer().getWorld("world").getTime();
     
     
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onCreatureSpawn(CreatureSpawnEvent event) {
         
            Entity entity = event.getEntity();
         
            if(event.getEntityType().equals(EntityType.CREEPER) && time <= 13000) {         
            
                     event.setCancelled(true);
    
            } 
        }
    
    this is what i've got so far...
     
  2. @ZderKi
    The issue is that "time" is only set once, outside of the method you are using. Instead, move time into the onCreatureSpawnEvent.
     
  3. Offline

    ZderKi

    @Zombie_Striker
    tried that... they still will spawn after some time

    nvm i wasnt registering events in onEnable

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2019 at 9:50 AM

Share This Page