CreatureType asking to be initialized as a null?

Discussion in 'Plugin Development' started by Monckey100, Mar 29, 2011.

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

    Monckey100

    well that doesn't exactly work as it would crash the plugin so how exactly do i get it to work.
    CreatureType Zombie = null; (i figured shouldn't exactly work)
    so what do i set it as. it's inside of the onBlockBreak and for a reason, also if possible it would be nice if you can provide what you did to find out what it should equal to. (so i don't have to continuously stumble across this problem)

    anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  2. Offline

    Edward Hand

    Not entirely sure I understand what you're asking.
    Could you post your code?
     
  3. Offline

    Monckey100

    yes of course my good man. not exactly my entire code but a clean snippet. I'm basically asking how people figure out what should equal for Creature creaturetype...cause...
    public void onBlockBreak(BlockBreakEvent event) {
    CreatureType Zombie;
    plugin.SpawnCreature(player.getLocation(), Zombie);
    }

    says CreatureType Zombie needs to have a variable and the default null just won't cut it for bukkit.. I encountered this problem before with
    World world; and to fix it a plugin dev told me to use this.getServer().getWorld("World"); since it was in the main plugin area and I was wondering.
    1) how did he figure out what to put in there
    2) where does it say in the documentation to make[cause I wouldn't have guessed the world should equal a get world function of inside the plugin, I'd assume it was from the world listener]
    World world = this.getServer().getWorld("World");
     
  4. Offline

    nickguletskii

    CreatureType is an enum.
     
  5. Offline

    Monckey100

    CreatureType Zombie = new CreatureType;
    meep, that doesn't work X_X I'm abit new to java and bukkit; so as a dev coming from C++ this gets rather complicated for me to understand
     
  6. Offline

    AOD_Batman

    CreatureType is not a class, but is an enum and it's values should be accessed like so:

    Code:
    CreatureType.ZOMBIE
    So for example you would do:

    Code:
    plugin.SpawnCreature(player.getLocation(), CreatureType.ZOMBIE);
    When in doubt look at JavaDoc.
     
  7. Offline

    Monckey100

    ah thank you so much /bow T_T so much help from these forums. I must contribute my plugins!!
     
Thread Status:
Not open for further replies.

Share This Page