Solved How to access DedicatedPlayerList

Discussion in 'Plugin Development' started by Zen3515, Mar 15, 2014.

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


    I want to create Particles effect so I have created PacketPlayOutWorldParticles to send, but how can I access DedicatedPlayerList.sendPacketNearby(.........);
    Do I have to new this object or there have any method can return this ?

    My source code :
    1. public static void sendParticlesPacket(Location loc, String effectname, float xOffset, float yOffset, float zOffset, float effectSpeed, int amount)
    2. {
    4. DedicatedPlayerList Plist = ???????//Here how to do this
    6. PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(effectname,(float)loc.getX(),(float)loc.getY(),(float)loc.getZ(),xOffset,yOffset,zOffset,effectSpeed,amount);
    7. Plist.sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64, ((CraftWorld) loc.getWorld()).getHandle().dimension, packet);
    8. }

    Please anyone help me.
    If you don't understand, ask me, I bad at English language.

    UPDATE: I've found new way but It was confusing :( if anyone know how to access DedicatedPlayerList please tell me.
    1. try {
    2. DedicatedPlayerList = Class.forName("net.minecraft.server.v1_7_R1.DedicatedPlayerList");
    3. sendPacketNearby = DedicatedPlayerList.getMethod("sendPacketNearby", double.class, double.class, double.class, double.class, int.class, Class.forName("net.minecraft.server.v1_7_R1.Packet"));
    4. PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(effectname,(float)loc.getX(),(float)loc.getY(),(float)loc.getZ(),xOffset,yOffset,zOffset,effectSpeed,amount);
    5. sendPacketNearby.invoke(((CraftServer)Bukkit.getServer()).getHandle(), loc.getX(), loc.getY(), loc.getZ(),64,((CraftWorld) loc.getWorld()).getHandle().dimension,packet);
    6. } catch (Exception e) {
    7. e.printStackTrace();
    8. }

    UPDATE2: Solved
  2. Offline


    download mc-dev and craftbukkit source code
    merge with cb priority over mc-dev
    run notepad++
    start search in files by keyword DedicatedPlayerList
    discover all cases of DedicatedPlayerList usage in code
    discover class-field that stored native DedicatedPlayerList instance
    reflectfetch that instance
    do what you want

    protip - you can't invoke nonstatic methods without valid instance.
  3. Offline


    That look really hard, I believed someone should already known it.
  4. Offline


    Could you not just use the api to get nearby entities and send the packet to them?
  5. Offline


    1. CraftServer craftServer = (CraftServer) getServer();
    2. DedicatedPlayerList DPL = craftServer.getHandle();

    Like that. You need to use the CraftBukkit jar, as it uses NMS code.
    Zen3515 likes this.
  6. Offline


    It does not matter is anyone already know solution (i know), this is development forum, i explained how you can get this self.
    Zen3515 likes this.
Thread Status:
Not open for further replies.

Share This Page