ServerPlugin CitizensAPI 2 Probelm

Dieses Thema im Forum "Programmierung" wurde erstellt von ThePowerPlay, 14. Juli 2014.

  1. ThePowerPlay
    Offline

    ThePowerPlay

    Registriert seit:
    1. Oktober 2012
    Beiträge:
    78
    Hallo, ich möchte ein Plugin machen das man einen NPC Spawnen Kann, jedoch will das nich so wie ich >.< Vielleich kann mir jemand helfen.
    ich weiß das es irgendwas mit implemention ist.

    ERROR:

    [13:13:12] [Server thread/ERROR]: Could not load 'plugins/test.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalStateException: no implementation set
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[craftbukkit.jar:git-Spigot-1551]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[craftbukkit.jar:git-Spigot-1551]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit.jar:git-Spigot-1551]
    at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugins(CraftServer.java:369) [craftbukkit.jar:git-Spigot-1551]
    at org.bukkit.craftbukkit.v1_7_R4.CraftServer.reload(CraftServer.java:864) [craftbukkit.jar:git-Spigot-1551]
    at org.bukkit.Bukkit.reload(Bukkit.java:301) [craftbukkit.jar:git-Spigot-1551]
    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit.jar:git-Spigot-1551]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) [craftbukkit.jar:git-Spigot-1551]
    at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:767) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.PlayerConnection.handleCommand(PlayerConnection.java:1016) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:846) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.PacketPlayInChat.handle(PacketPlayInChat.java:65) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:184) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:731) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [craftbukkit.jar:git-Spigot-1551]
    at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Spigot-1551]
    Caused by: java.lang.IllegalStateException: no implementation set
    at net.citizensnpcs.api.CitizensAPI.getImplementation(CitizensAPI.java:70) ~[?:?]
    at net.citizensnpcs.api.CitizensAPI.getNPCRegistry(CitizensAPI.java:103) ~[?:?]
    at de.thepowerplay.hubplayer.Main.<init>(Main.java:17) ~[?:?]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_60]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[?:1.7.0_60]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.7.0_60]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[?:1.7.0_60]
    at java.lang.Class.newInstance(Class.java:374) ~[?:1.7.0_60]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit.jar:git-Spigot-1551]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[craftbukkit.jar:git-Spigot-1551]
    ... 19 more


    PLUGIN:


    package de.thepowerplay.hubplayer;

    import net.citizensnpcs.api.CitizensAPI;
    import net.citizensnpcs.api.npc.NPC;
    import net.citizensnpcs.api.npc.NPCRegistry;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
    import org.bukkit.plugin.java.JavaPlugin;


    public class Main extends JavaPlugin implements CommandExecutor , Listener {

    NPCRegistry registry = CitizensAPI.getNPCRegistry();
    NPC bot = null;

    public void onEnable() {
    getCommand("spawnbot").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if(args.length == 0) {
    if(sender instanceof Player) {
    Player p = (Player) sender;
    if(p.isOp()) {
    if(bot == null) {
    bot = registry.createNPC(EntityType.PLAYER, "Steve");
    bot.spawn(p.getLocation());
    p.sendMessage("§2Steve:§7 Hallo mein Meister!");
    } else {
    p.sendMessage("§2Steve: §7Ich lebe doch schon! C:");
    bot.teleport(p.getLocation(), TeleportCause.COMMAND);
    }
    } else {
    p.sendMessage("§2>> §7Nur ThePowerPlay darf den Bot spawnen. Wenn er nicht da ist dann ist es schade :c. Schreibe das am besten einem Admin.");
    }
    }
    }
    return false;
    }

    }


    LG ThePowerPlay

    - - - Aktualisiert - - -

    SOLVED



    Lösung:

    NPCRegistry null setzen und beim spawnen als CitizensAPI.getNPCRegistry() definieren

    C:

    NEUER CODE FÜR DIE LEUTE DIE IHN BRAUCHEN:
    package de.thepowerplay.hubplayer;

    import net.citizensnpcs.api.CitizensAPI;
    import net.citizensnpcs.api.npc.NPC;
    import net.citizensnpcs.api.npc.NPCRegistry;

    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerCommandPreprocessEvent;
    import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
    import org.bukkit.plugin.java.JavaPlugin;


    public class Main extends JavaPlugin implements CommandExecutor , Listener {

    NPCRegistry registry = null;
    NPC bot = null;

    public void onEnable() {
    getCommand("spawnbot").setExecutor(this);
    getCommand("despawnbot").setExecutor(this);
    Bukkit.getPluginManager().registerEvents(this, this);
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "reloadchat");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if(cmd.getName().equals("despawnbot")) {
    if(args.length == 0) {
    if(sender instanceof Player) {
    Player p = (Player) sender;
    if(p.isOp()) {
    if(bot == null) {
    p.sendMessage("§2Steve:§7 Ich bin schon Tot :c");
    } else {
    p.sendMessage("§2Steve: §7AUA! DAS TAT WEH ;(");
    bot.destroy();
    }
    } else {
    p.sendMessage("§2>> §7Nur ThePowerPlay darf den Bot spawnen. Wenn er nicht da ist dann ist es schade :c. Schreibe das am besten einem Admin.");
    }
    } else {
    if(sender.isOp()) {
    if(bot == null) {
    } else {
    bot.destroy();
    }
    }
    }
    }
    }
    if(cmd.getName().equals("spawnbot")) {
    if(args.length == 0) {
    if(sender instanceof Player) {
    Player p = (Player) sender;
    if(p.isOp()) {
    if(bot == null) {
    registry = CitizensAPI.getNPCRegistry();
    bot = registry.createNPC(EntityType.PLAYER, "Steve");
    bot.spawn(p.getLocation());
    p.sendMessage("§2Steve:§7 Hallo mein Meister!");
    } else {
    p.sendMessage("§2Steve: §7Ich lebe doch schon! Hier bin ich.");
    bot.teleport(p.getLocation(), TeleportCause.COMMAND);
    }
    } else {
    p.sendMessage("§2>> §7Nur ThePowerPlay darf den Bot spawnen. Wenn er nicht da ist dann ist es schade :c. Schreibe das am besten einem Admin.");
    }
    }
    }
    }
    return false;
    }

    @EventHandler
    public void RunCommand(PlayerCommandPreprocessEvent e) {
    String cmd = e.getMessage();
    if(e.getPlayer().isOp()) {
    if(cmd.equalsIgnoreCase("reload")) {
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "despawnbot");
    }
    }

    }

    }
     
    #1