Prevent mobs from spawning under certain conditions

Discussion in 'Plugin Development' started by Set3, Dec 19, 2015.

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

    Set3

    I'm trying to figure out how to prevent mobs from spawning under certain conditions (I'm very new to the whole bucket thing but i know enough java).

    Here is my code:

    Code:
    package com.gmail.Set3minecraft.ZombieSiege;
    
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.entity.CreatureSpawnEvent;
    import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
    
    
    public class ZombieSiege {
       
    
    
        @EventHandler
        public void onCreatureSpawn(CreatureSpawnEvent event) {
            if(event.getSpawnReason() == SpawnReason.SPAWNER_EGG){
                event.setCancelled(true);
            }
        }
    }
     
  2. Offline

    567legodude

  3. Offline

    Zombie_Striker

    You may not be new to Java, but you still might have not mastered the conventions. Package names should be lowercase, and the last section on the path will be duplicated ("ZombieSiege.ZombieSiege") But that doesn't matter right now.

    What you need to do is create a main class (Please don't name it "main.class"), and have that main class register this class. Then you let this class implement listener

    Since you said you are new to bukkit, please don't learn from Youtube. Instead, go here:https://bukkit.org/threads/plugin-dev-sticky-learning-java-where-to-learn.395662/
     
  4. Offline

    Set3

    ok I did what 567legodude said, but its still not working. Pretty sure its something in the .yml file.

    Heres the error i get:
    Code:
    19.12 23:55:48 [Server] ERROR Could not load 'plugins/AntiZombieSiege-0.0.2-SNAPSHOT.jar' in folder 'plugins'
    19.12 23:55:48 [Server] INFO org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.gmail.Set3minecraft.ZombieSiege.ZombieSiege.java'
    and heres my plugin.ml file:

    Code:
    name: AntiZombieSiege
    main: com.gmail.Set3minecraft.ZombieSiege.ZombieSiege.java
    version: 0.0.2
    pretty sure I'm making a silly mistake. Any help is appreciated :)
     
  5. Offline

    Zombie_Striker

    Remove this.
     
  6. Offline

    Set3

    I did that and same error
     
  7. Offline

    teej107

  8. Offline

    Nibbit

    Make sure that your main class is at that exact place, check for capitals.
     
Thread Status:
Not open for further replies.

Share This Page