Hey im trying to use Citizens API so when a player does /clone, it spawns a clone of the player where they are standing. This is also my first time using an API. I can't figure out why it won't work. there are no errors in console. Code: public void onEnable() { Bukkit.getServer().getPluginManager().registerEvents(this, this); if(getServer().getPluginManager().getPlugin("Citizens") == null || getServer().getPluginManager().getPlugin("Citizens").isEnabled() == false) { getLogger().log(Level.SEVERE, "Citizens 2.0 not found or not enabled"); getServer().getPluginManager().disablePlugin(this); return; } } Code: if(cmd.getName().equalsIgnoreCase("clone")){ Player player = (Player) sender; NPCRegistry registry = CitizensAPI.getNPCRegistry(); NPC npc = registry.createNPC(EntityType.PLAYER, player.getName()); npc.spawn(Bukkit.getWorlds().get(0).getSpawnLocation()); } Code: name: EasyRPG author: reecehunter version: 0.1 description: Rpg plugin main: me.reece.EasyRPG.Main softdepend: [Citizens] commands: clone: description: Creates a clone of you.
Don't blindly cast the sender to a player. You have to make sure sender is actually a player before casting it. What if another plugin sends the command, or what if the console sends a command? Even if you think/know they will never send the message, why would you not want to check? Neither can we. We don't know what is wrong.
@rhunter You do know that you are spawning the NPC at spawn of the first world? Why not spawn on the location of the player as you want?