Development Assistance Defining getPlugin()

Discussion in 'Plugin Help/Development/Requests' started by CactusComboPvP, Feb 19, 2015.

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

    CactusComboPvP

    So i'm using this Lib, https://bukkit.org/threads/npclib-create-fake-players-1-8-1-7-10-1-7-9.340234/

    It's to make custom npc's

    But I get an error on this line when spawning one:
    Code:
    NPCRegistry registry = NPCLib.getNPCRegistry("TacoRegistry", Bukkit.getServer().getPluginManager().getPlugin("npc"));
    Full class code:

    Code:
    import net.techcable.npclib.NPC;
    import net.techcable.npclib.NPCLib;
    import net.techcable.npclib.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;
    
    public class NPCSpawn implements CommandExecutor{
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("npc")) {
                NPCRegistry registry = NPCLib.getNPCRegistry("TacoRegistry", Bukkit.getServer().getPluginManager().getPlugin("npc"));
                NPC npc = registry. createNPC(EntityType.PLAYER, "TacoMan");
                npc.setProtected(true);
                npc.setSkin("Techcable");
                npc.spawn(Bukkit.getWorld("world").getSpawnLocation());
            }
            return true;
           
        }
    }
    Stack trace:

    Code:
    [16:52:28 INFO]: MineplexMOD issued server command: /npc
    [16:52:28 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'npc'
    in plugin npc v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[cra
    ftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:18
    1) ~[craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServe
    r.java:767) ~[craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.PlayerConnection.handleCommand(PlayerCon
    nection.java:1043) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java
    :880) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.PacketPlayInChat.a(PacketPlayInChat.java
    :28) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.PacketPlayInChat.handle(PacketPlayInChat
    .java:65) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:186
    ) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java
    :81) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:7
    34) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:2
    89) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:5
    84) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :490) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    Caused by: java.lang.NoClassDefFoundError: net/techcable/npclib/NPCLib
            at io.github.cactuscombo.NPCSpawn.onCommand(NPCSpawn.java:16) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cra
    ftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            ... 13 more
    Caused by: java.lang.ClassNotFoundException: net.techcable.npclib.NPCLib
            at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_25]
            at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.8.0_25]
            at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_
    25]
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_25]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:101) ~[craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:86) ~[craftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_25]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_25]
            at io.github.cactuscombo.NPCSpawn.onCommand(NPCSpawn.java:16) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cra
    ftbukkit.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
            ... 13 more
    >
     
  2. Offline

    1Rogue

    You either need to include the classes on the server in the form of a plugin or you need to shade the files into your own jar.
     
  3. Offline

    CactusComboPvP

    @1Rogue

    I did, this is my pom.xml but same error

    Code:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>io.github.cactuscombo</groupId>
        <artifactId>Heroes</artifactId>
        <version>0.1</version>
        <name>Heroes</name>
        <repositories>
            <repository>
                <id>techcable-repo</id>
                <url>http://repo.techcable.net/content/groups/public/</url>
            </repository>
        </repositories>
        <dependencies>
            <dependency>
                <groupId>net.techcable</groupId>
                <artifactId>npclib</artifactId>
                <version>
                    1.1.0-SNAPSHOT
                </version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>2.3</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <relocations>
                                    <relocation>
                                        <pattern>net.techcable.npclib</pattern>
                                        <shadedPattern>${project.groupId}.${project.artifactId}.libs.npclib</shadedPattern>
                                    </relocation>
                                </relocations>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
     
  4. Offline

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
     
  5. Offline

    1Rogue

  6. Offline

    CactusComboPvP

    @1Rogue
    Still same error, and I added what you told me to

    Code:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>io.github.cactuscombo</groupId>
        <artifactId>Heroes</artifactId>
        <version>0.1</version>
        <name>Heroes</name>
        <artifactSet>
            <includes>
                <include>org.apache.maven:*</include>
            </includes>
            <excludes>
                <exclude>*:maven-core</exclude>
            </excludes>
        </artifactSet>
        <repositories>
            <repository>
                <id>techcable-repo</id>
                <url>http://repo.techcable.net/content/groups/public/</url>
            </repository>
        </repositories>
        <dependencies>
            <dependency>
                <groupId>net.techcable</groupId>
                <artifactId>npclib</artifactId>
                <version>
                    1.1.0-SNAPSHOT
                </version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>2.3</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <relocations>
                                    <relocation>
                                        <pattern>net.techcable.npclib</pattern>
                                        <shadedPattern>${project.groupId}.${project.artifactId}.libs.npclib</shadedPattern>
                                    </relocation>
                                </relocations>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
     
  7. Offline

    1Rogue

    ...considering it's for the shade plugin, it goes under executions>execution>configuration, not in the scope of the whole project
     
Thread Status:
Not open for further replies.

Share This Page