Solved CreatureSpawnEvent SpawnReason

Discussion in 'Plugin Development' started by GamingChrisYT, Apr 17, 2017.

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

    GamingChrisYT

    Hey, I write a lobby plugin and i have a problem. Nobody can spawn mobs on the Server but, i want if a admin wite a command that you can but only with commands and Spawn_Eggs. I write it with spawnreasons but it don't work! I know i use a ArrayList for the boolean, but it's bot importen because i debug it and the mistake is in the line : 11! And the Value in the ArrayList is true! The sysout.println("2") is for debuging. Here the code:
    Code:
    @EventHandler
        public void SpawnEntity(CreatureSpawnEvent e) {
    
            EntityType et = e.getEntityType();
            if (e.getEntity() instanceof Animals || e.getEntity() instanceof Monster) {
               
               
    
                if(plugin.spawnEntity.get(0)==true){
                   
                    if (e.getSpawnReason().equals(SpawnReason.SPAWNER_EGG)||e.getSpawnReason().equals(SpawnReason.CUSTOM)||e.getSpawnReason().equals(SpawnReason.DISPENSE_EGG)){
                        System.out.println("2");
                    } else {
                        e.setCancelled(true);
                    }
                } else {
                    e.setCancelled(true);
                }
               
            }
        }
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    GamingChrisYT

    Ok know it work, but what is spawnreason for the command /summon?
     
  4. Offline

    Mahtaran

    What's at line 11? Also, does it throw an error? If so, which?
     
  5. Offline

    GamingChrisYT

    Thank you for your help, but i found the mistake.
     
  6. Offline

    Mahtaran

    What was it?
     
  7. Offline

    Zombie_Striker

    @GamingChrisYT
    If your problem has been solved, mark this thread as solved.

    Also, please post what was the mistake. Threads like these may be able to help other users with similar problems.
     
Thread Status:
Not open for further replies.

Share This Page