Remote entities api not working propaly

Discussion in 'Plugin Development' started by JD_Guy17, Mar 7, 2014.

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

    JD_Guy17

    I am having trouble getting RemoteEntites api working in my plugin:
    heres the stack trace:
    Code:
    [21:35:19 ERROR]: Error occurred while enabling Guns v1.0 (Is it up to date?)
    de.kumpelblase2.remoteentities.exceptions.PluginNotEnabledException: RemoteEntit
    ies needs to be enable in order to use this operation
            at de.kumpelblase2.remoteentities.RemoteEntities.createManager(RemoteEnt
    ities.java:159) ~[?:?]
            at me.jdguy17.war.war.onEnable(war.java:63) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:250) ~[c
    raftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:350) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:389) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugin(CraftServer.jav
    a:439) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.enablePlugins(CraftServer.
    java:375) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.reload(CraftServer.java:77
    3) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.Bukkit.reload(Bukkit.java:279) [craftbukkit.jar:git-Bukkit
    -1.7.2-R0.3-b3020jnks]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:
    23) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:17
    5) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServe
    r.java:683) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchServerCommand(Craf
    tServer.java:670) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.aw(DedicatedServer.java:
    286) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    51) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    [21:35:19 INFO]: [RemoteEntities] Enabling RemoteEntities v1.8-SNAPSHOT
    Here is the main class:

    Code:java
    1. private EntityManager manager;
    2.  
    3. private static war instance;
    4.  
    5. public static war getInstance() {
    6. return instance;
    7. }
    8.  
    9. SettingsManager settings = SettingsManager.getInstance();
    10.  
    11. public void onEnable() {
    12.  
    13. CommandManager cm = new CommandManager();
    14. cm.setup();
    15. getCommand("jd-craft").setExecutor(cm);
    16.  
    17. instance = this;
    18. Bukkit.getServer().getPluginManager().registerEvents(new TestGun(), this);
    19. Bukkit.getServer().getPluginManager().registerEvents(new Knife(), this);
    20. Bukkit.getServer().getPluginManager().registerEvents(new Grenade(), this);
    21. Bukkit.getServer().getPluginManager().registerEvents(new GrappleHook(), this);
    22. getLogger().info("Guns enabled!");
    23. manager = RemoteEntities.createManager(this);
    24. spawnNPC(SettingsManager.getInstance().getConfig().getString("guns.name"), (Location) SettingsManager.getInstance().getConfig().get("guns.loc"));
    25.  
    26. SettingsManager.getInstance().setup(this);
    27. settings.setup(this);
    28. }
    29.  
    30. public void spawnNPC(String name, Location loc) {
    31. CreateEntityContext c = manager
    32. .prepareEntity(RemoteEntityType.Human)
    33. .asPushable(false)
    34. .asStationary(true)
    35. .atLocation(loc)
    36. .withName(name);
    37.  
    38. RemoteEntity re = c.create();
    39. }


    Thanks in advance,
    - JD
     
  2. Offline

    Buizelfan2

  3. Offline

    JD_Guy17

    Buizelfan2 I already had that installed and I don't know very much
     
  4. Offline

    Heirteir

    JD_Guy17
    Alright here is a link to latest remote entities package i use this myself and it works fine let me know if this doesn't work also another problem is that your plugin.yml my not depend on remoteentities so you need to put in your plugin.yml
    make you format like this:
    Code:
    name: <name>
    version: <version>
    main: <path to main class>
    depend: [RemoteEntities]
    etc....
    This will make remote entities load before you plugin loads so the task can be completed.

    Make sure you include the brackets!!!

    I hope this helped you out.
    --Heirteir
     
  5. Offline

    JD_Guy17

    Heirteir I got it to spawn a npc. But can you help me to create a command to spawn a npc where the player is standing with a specified name in the command.
    note: in another class.
    this is my spawn npc method:
    Code:java
    1. public void spawnNPC(String name, Location loc) {
    2. CreateEntityContext c = manager
    3. .prepareEntity(RemoteEntityType.Human)
    4. .asPushable(false)
    5. .asStationary(true)
    6. .atLocation(loc)
    7. .withName(name);
    8.  
    9. RemoteEntity re = c.create();
    10. }
     
  6. Offline

    Heirteir

    JD_Guy17
    All you need to do is that but just add a few checks here is an example
    Code:java
    1. package help;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.Location;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. import de.kumpelblase2.remoteentities.CreateEntityContext;
    11. import de.kumpelblase2.remoteentities.EntityManager;
    12. import de.kumpelblase2.remoteentities.api.RemoteEntity;
    13. import de.kumpelblase2.remoteentities.api.RemoteEntityType;
    14.  
    15. public class Main
    16. extends JavaPlugin{
    17.  
    18. public EntityManager manager;
    19.  
    20. @SuppressWarnings("deprecation")
    21. public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String [] args){
    22.  
    23. if (!(sender instanceof Player)){
    24. sender.sendMessage("All Players Can Execute This Command");
    25. return true;
    26. }
    27. Player p = (Player) sender;
    28. if (cmd.getName().equalsIgnoreCase("mylocnpc")){
    29. if (args.length == 0){
    30. p.sendMessage(ChatColor.RED + "Usage is: /mylocnpc <npcname>");
    31. return true;
    32. }
    33. if (args.length <= 2){
    34. p.sendMessage(ChatColor.RED + "Usage is: /mylocnpc <npcname>");
    35. return true;
    36. }
    37. spawnNPC(args[0].toString(), p.getLocation());
    38. }
    39.  
    40. return true;
    41. }
    42.  
    43. public void spawnNPC(String name, Location loc) {
    44. CreateEntityContext c = manager
    45. .prepareEntity(RemoteEntityType.Human)
    46. .asPushable(false)
    47. .asStationary(true)
    48. .atLocation(loc)
    49. .withName(name);
    50.  
    51. RemoteEntity re = c.create();
    52. }
    53. }


    Hope this helped you man!
    Heirteir
     
  7. Offline

    JD_Guy17

    Heirteir On reload the npc disappears is there a way to fix this?
     
  8. Offline

    Heirteir

    JD_Guy17
    Sadly there isn't with this really the only thing you should need to do is have stationary mobs i don't know of a way to keep them from despawning since the plugin itself is hosting these entities. Sorry I don't know.
     
  9. Offline

    JD_Guy17

    Any one else have a idea?
     
Thread Status:
Not open for further replies.

Share This Page