[SOLVED] Disguise as a Creeper

Discussion in 'Plugin Development' started by SnowGears, Aug 2, 2012.

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

    CorrieKay

    use "depends" if you require another plugin to be INSTALLED, not to use the api of it. You can use the api without depends.
     
    ZeusAllMighty11 likes this.
  2. Offline

    SnowGears

    ohhhhhhhhh.... wow that makes sense. They need to put that in the documentation of their API page then because they said its required to use the API

    Idk about that. Now I get this when I start my plugin.

    Code:
    java.lang.NoClassDefFoundError: pgDev/bukkit/DisguiseCraft/DisguiseCraft
    at com.pluggertech.armorabilities.ArmorAbilities.onEnable(ArmorAbilities.java:66)
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337)
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
    at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:257)
    at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:239)
    at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:373)
    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:360)
    at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:189)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:424)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
    Caused by: java.lang.ClassNotFoundException: pgDev.bukkit.DisguiseCraft.DisguiseCraft
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:41)
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 11 more
    
    ZeusAllMighty11
    Do you know how to fix this?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  3. Offline

    r0306

    Tooner101
    Add that to your onEnable(). Not all servers will run DisguiseCraft. Without checking if the plugin is installed, the server will throw a nasty error.
    Code:
    public static DisguiseCraftAPI api;
     
    public void onEnable()
    {
    if (getServer().getPluginManager().getPlugin("DisguiseCraft") != null)
      api = DisguiseCraft.getAPI();
    }
    }
     
  4. Offline

    SnowGears

    So if the server does not have disguiseCraft installed how do I use the API ?
     
  5. Offline

    r0306

    Tooner101
    You can't. An API is merely an interface for controlling the DisguiseCraft plugin. If DisguiseCraft is not installed, it becomes useless and you won't be able to disguise as mobs. That's why I integrated a simpler version of the disguise system into my plugin.
     
  6. Offline

    SnowGears

    Okay. I know I'm asking for a lot but can you help me more in depth with using the API if its detected and if its not using your code you posted earlier?

    EDIT: because if I import disguiseCraft at the top of my class and they don't have it installed on the server it will throw errors
     
  7. Offline

    r0306

    Tooner101
    Nothing happens. That code I posted only intervenes by preventing the server from trying to retrieve the API when DisguiseCraft is not detected. Otherwise, it would throw a nullpointerexception and a plugin not found exception like you posted earlier.
     
    Tooner101 likes this.
  8. Offline

    SnowGears

    Okay cool I got it. I think I will just disguise player if disguisecraft is installed and if not I won't. that will make my life easier. Can you help me with one more thing really quick?

    I need to add world support because my plugin does not work in the nether or the end and I can't figure out what to do. It only works in the default world. Here is my code.

    My listener class - http://pastebin.com/ckSfBpvn
    My main class - http://pastebin.com/gdG3YW3W

    EDIT: as I said before I think I need to do something like getWorld().getPlayer() but im not sure
     
  9. Offline

    r0306

    Tooner101
    Hmm. That's odd. Even the commands don't work at all?
     
  10. Offline

    SnowGears

    Yep. It says "Unknown Command" when I try to type any command related to my plugin when I'm in the nether or the end
     
  11. Offline

    r0306

    Tooner101
    Got any world related plugins?
     
  12. Offline

    SnowGears

    All I have installed is my plugin and essentials. I guess I can try disabling essentials...

    r0306
    Hmm works fine without essentials... Alright. well thanks for all your help. You really helped me with so many bugs I can't thank you enough. The bukkit community is lucky to have you.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  13. Offline

    r0306

    Np.
     
    Tooner101 likes this.
  14. Offline

    CorrieKay

    I'd just like to point out that this isnt universally true.
     
  15. Offline

    r0306

  16. Okay I think I have better news there is a new error
     
  17. Offline

    r0306

    iKeirNez
    Great. :) Can you post the error?
     
  18. Oops, thought I had pasted it
    http://pastie.org/4389984

    r0306 Also why are we using reflection here

    Code:
    Field metadata = packet.getClass().getDeclaredField("i");
    metadata.setAccessible(true);
    metadata.set(packet, field);
    When i is already accessible?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  19. Offline

    CorrieKay

    It is not required to have a plugin installed to use its API, unless the developer of the plugin makes that a requirement.
     
  20. @ro306 Sorry to spam you but after looking at the CraftBukkit files I changed

    Field metadata = packet.getClass().getDeclaredField("i");
    metadata.setAccessible(true);
    metadata.set(packet, field);

    to

    Field metadata = packet.getClass().getDeclaredField("s");
    metadata.setAccessible(true);
    metadata.set(packet, field);

    But now everyone except the player being disguised crashes, any ideas?

    Thanks

    r0306 Ignore all my other posts, I have sort of got it to work, spent hours looking at the minecraft source code and I think I am almost there. I may do a written and video tutorial of it later.

    r0306 I sort of have it working, you can disguise as a creeper and move around and also move your head. The only problem is though is that the maths is slightly off for the head rotation. Would it be possible if I added you on Skype if you have it?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  21. Offline

    The_Coder

  22. Its not complete yet, I will post it though when I have finished it and it works
     
  23. Offline

    Limeth

    This part doesn't work for me at all:
    Code:java
    1. public DataWatcher field;
    2. public Packet24MobSpawn spawnMob(Location location, int id) throws FieldNotFoundException
    3.  
    4. Packet24MobSpawn packet = new Packet24MobSpawn()
    5. {
    6. packet.a = id; //Entity UDID
    7. packet.b = 50; //id for creeper
    8. packet.c = Math.floor(loc.getX() * 32d);
    9. packet.d = Math.floor(loc.getY() * 32d);
    10. packet.e = Math.floor(loc.getZ() * 32d);
    11. packet.f = (byte) loc.getYaw();
    12. packet.g = (byte) loc.getPitch();
    13. packet.h = packet.f;
    14.  
    15. Field metadata = packet.getClass().getDeclaredField("i");
    16. metadata.setAccessible(true);
    17. metadata.set(packet, field);
    18.  
    19. return packet;
    20. }


    Anyone help, please? :(
     
  24. Offline

    CorrieKay

    every time minecraft releases a new version, those field name changes.

    you'll need to figure out which one is which now.
     
Thread Status:
Not open for further replies.

Share This Page