Library NPCLib - Create Fake Players [1.7.9 till 1.8.3]

Discussion in 'Resources' started by Techcable, Feb 4, 2015.

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

    Techcable

    NPCLib is a library that allows you to spawn human npcs easily.

    Why choose NPCLib?
    • Doesn't require an external plugin
    • Supports multiple versions
    • Supports fake 1.8
    • Supports skins
    • If you have citizens installed, that is used for npc spawning (so if they update first the new version is supported)
    Maven Setup
    This is designed to be shaded into your plugin, so users don't have to download it.
    Code:
    <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</arifactId>
        <version>1.1.1-SNAPSHOT</version>
      </dependency>
    </dependencies>
    
    Plugin Setup
    This library is also available as a plugin if you don't want to use maven.
    This has the disadvantage of requiring your users to update whenever a new release comes out.

    Download Page


    Examples
    To create a invincible npc named "TacoMan" with a troll skin at spawn:
    Code:
    NPCRegistry registry = NPCLib. getNPCRegistry("TacoRegistry", TacoPlugin.getInstance());
    NPC npc = registry. createNPC(EntityType.PLAYER, "TacoMan");
    npc.setProtected(true);
    npc.setSkin("Techcable");
    npc.spawn(Bukkit.getWorlds().get(0).getSpawnLocation());
    Plugins Using It

    Links
    Javadocs --- Documentation
    Github --- Source Code
    Github Issues --- Issues
    Jenkins --- Developer Builds
     
    Last edited: Mar 2, 2015
    ChipDev, Shawckz and GrandmaJam like this.
  2. Offline

    ProStriker123

    GrandmaJam, Techcable and ChipDev like this.
  3. Offline

    Techcable

    Also this is used in my plugin combat tag reloaded so it should receive constant updates and bug fixes.
     
  4. Offline

    000nick

    All I needed were NPC's with skins, and this should do the job! Thank you. :)
     
    GrandmaJam likes this.
  5. Offline

    Techcable

    For what plugin?
     
  6. Offline

    dori99xd

    @Techable Nice Libary. May adding a function that makes the npc lying?
     
  7. Offline

    Techcable

    I'm working on that and animations (crouching, eating, damage animations).
     
    Last edited: Feb 6, 2015
  8. Offline

    GriffinPvP

    Ok I didn't really use Maven until now, and I wanted to know how to shade this.
     
  9. Offline

    Techcable

    Put this in your pom.xml:
    Code:
    <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>
    
    Feel free to replace ${project.groupId}.${project.artifactId} with your plugin's package.
     
  10. Offline

    Shawckz

    Amazing library!
     
    GrandmaJam likes this.
  11. Offline

    GrandmaJam

    Awesome Library dude
     
  12. Offline

    Techcable

    Scheduled for the 1.2.0 release.
     
  13. Offline

    Shawckz

    Is it possible to make the NPC visible to only a specific player?
     
  14. Offline

    Skionz

    You can do that yourself. Listen for outgoing PacketPlayOutNamedEntitySpawn packets and cancel it when necessary.
     
  15. Offline

    Techcable

    That would require a nms or protocollib dependency.
    You should call Player.hidePlayer on the NPC object.
     
  16. Offline

    CactusComboPvP

    Getting an error on this line

    Code:
    NPCRegistry registry = NPCLib. getNPCRegistry("TacoRegistry", Main.getInstance());
     
  17. Offline

    ChipDev

    What.. is. .the.. error??
     
  18. Offline

    CactusComboPvP

    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
    >
    @ChipDev
     
  19. Offline

    ChipDev

    Do you even have the lib installed in your plugin libraries?
     
  20. Offline

    CactusComboPvP

    @ChipDev

    I'm using Maven and I have all the repositories and dependencies and I get no error in the code, I only get it when I do the command.

    Does this work for you?
     
  21. Offline

    Techcable

    Do you have NPCLib as <scope>compile</scope> in your pom.xml?
     
  22. Offline

    CactusComboPvP

    @Techcable
    No, i'm new to maven, please tell me how i can do that.
    can you give me an example of how my pom.xml should look like?
     
    Last edited: Feb 19, 2015
  23. Offline

    Techcable

    What is your current pom?
     
  24. Offline

    CactusComboPvP

    @Techcable

    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>
    </project>
     
  25. Offline

    viper_monster

    @CactusComboPvP you need to either shade it using maven or install the plugin on your server.
     
  26. Offline

    ChipDev

    I have the same problem ;(

    @viper_monster
     
  27. Offline

    viper_monster

    Last edited: Feb 22, 2015
    ChipDev likes this.
  28. Offline

    _Filip

  29. Offline

    ChipDev

    Please quote what message you mean.
     
  30. Offline

    Techcable

    I'm Baffled, This shouldn't cause a no class found exception.

    @viper_monster
    This isn't designed to be used as a plugin, just shaded in to the plugin.
    Does bukkit load jars into the classpath even if no plugin.yml is found? If the awnser is no, putting it in the plugin folder won't work because there is no plugin.yml to make it load.
     
Thread Status:
Not open for further replies.

Share This Page