Spawning Entities?

Discussion in 'Plugin Development' started by Monckey100, Dec 11, 2013.

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

    Monckey100

    Code:java
    1.  
    2. public final class Test extends JavaPlugin {
    3. public static Test plugin;
    4. @Override
    5. public void onEnable(){
    6. getLogger().info("Test has been enabled!");
    7. PluginManager serversets = getServer().getPluginManager();
    8. playerListener = new PlayerListeners(this);
    9. serversets.registerEvents(this.playerListener, this);
    10. // TODO Insert logic to be performed when the plugin is enabled
    11. }
    12.  
    13. @Override
    14. public void onDisable() {
    15. getLogger().info("Test has been disabled!");
    16. // TODO Insert logic to be performed when the plugin is disabled
    17. }
    18.  
    19. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    20. Player player = (Player) sender;
    21. if(cmd.getName().equalsIgnoreCase("SpawnPlayer")){
    22. if(player.isOp() == true){
    23. if (args.length == 1) { //if longer than 1 length
    24. if (args[0].equalsIgnoreCase("0")) {
    25. org.bukkit.Location loc = player.getLocation();
    26. //event.getEntity().remove();
    27. World w = loc.getWorld();
    28. w.spawnEntity(loc, org.bukkit.entity.EntityType.PLAYER);
    29. }
    30. return true;
    31. }
    32. }
    33. }
    34.  
    35. return false; // If this hasn't happened the a value of false will be returned.
    36. }
    37. //public final PlayerListeners playerListener = new PlayerListeners();
    38. public PlayerListeners playerListener ;
    39.  
    40. }
    41.  


    I tried to spawn a player, just good ole steve but this isn't working, it's mixing my java libraries with bukkit and then the server it's self is just throwing up at my code and I need help @_@

    Related edit: I wanted to make aggressive steves (towards players )with armor and if need be, change his skin..I figured something to do with using the zombie as a base and making a custom entity but I'm sort of hoping there's an easier way


    Code:java
    1. [00:21:27 INFO]: CONSOLE: Reload complete.
    2. [00:21:30 INFO]: Monckey100 issued server command: /spawnplayer 0
    3. [00:21:30 ERROR]: null
    4. org.bukkit.command.CommandException: Unhandled exception executing command 'spaw
    5. nplayer' in plugin TEST v1.0
    6. at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[cra
    7. ftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    8. at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:19
    9. 2) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    10. at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServe
    11. r.java:542) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    12. at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerCon
    13. nection.java:925) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    14. at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    15. :805) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    16. at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java
    17. :28) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    18. at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat
    19. .java:47) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    20. at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    21. ) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    22. at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    23. tbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    24. at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    25. 51) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    26. at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    27. 50) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    28. at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    29. 41) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    30. at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    31. :453) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    32. at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    33. 17) [craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    34. Caused by: java.lang.IllegalArgumentException: Cannot spawn an entity for org.bu
    35. kkit.entity.Player
    36. at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawn(CraftWorld.java:1033)
    37. ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    38. at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawn(CraftWorld.java:798)
    39. ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    40. at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawnEntity(CraftWorld.java
    41. :338) ~[craftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    42. at pack.Test.Test.onCommand(Test.java:198) ~[?:?]
    43. at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cra
    44. ftbukkit.jar:git-Bukkit-1.6.4-R2.0-23-ge8eb325-b2941jnks]
    45. ... 13 more
    46. [00:55:17 INFO]: Monckey100 lost connection: Internal Exception: net.minecraft.u
    47. til.io.netty.handler.timeout.ReadTimeoutException
    48. [00:55:17 INFO]: Monckey100 has left!
    49. [00:55:18 INFO]: Monckey100 left the game.
    50. >


    Bump :x

    Edit: Okay give me a second, I need to filter out the other stuff, this is just me messing with entities and yes it was asking for javas class instead of bukkits and I felt that was strange that I had to specify it's origins..

    Bump added the full trace and rest of the code

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 4, 2018
  2. Offline

    NinjaWAffles

    I'm not sure what "it's mixing my java libraries with bukkit" means. When it asks you import a class, always pick Bukkit unless you're intentionally using a Java or other plugin's class, or simply know what you're doing. As far as the rest of your question goes, can you please post your full class, as well as your full stack trace?
     
  3. Offline

    L33m4n123

    you try to spawn a Player. you cannot spawn a player
    Code:
    Caused by: java.lang.IllegalArgumentException: Cannot spawn an entity for org.bu
    kkit.entity.Player
     
  4. Offline

    Monckey100

    Is there a method TO spawning players or at least player dummies? I see certain mods utilize it:
    http://dev.bukkit.org/bukkit-plugins/statues/

    but I want to get into making them aggressive towards players

    Edit: Well problem solved, changing it to zombies did infact fix it but now comes the issue that I tackled the problem completely wrong, any idea as to how they achieve these player statues?
     
  5. Offline

    L33m4n123

    They use a method far more complicated than just "spawnEntity". they used packages and what not. If you want to know exactly ask for the source / decompile it and look at the source
     
  6. Offline

    Developing

  7. Offline

    Garris0n

    packets
     
  8. Offline

    L33m4n123

    yeah my bad. Wanted to write packets and what not^^
     
  9. Offline

    Monckey100

    Ah I see done with packets, so would I be able to make them zombie like these packet spawned players?
     
Thread Status:
Not open for further replies.

Share This Page