Solved How to access DedicatedPlayerList

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

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

    Zen3515

    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 :
    Code:java
    1. public static void sendParticlesPacket(Location loc, String effectname, float xOffset, float yOffset, float zOffset, float effectSpeed, int amount)
    2. {
    3.  
    4. DedicatedPlayerList Plist = ???????//Here how to do this
    5.  
    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.
    Code:java
    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

    RawCode

    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

    Zen3515

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

    SuperOmegaCow

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

    jrneulight

    Code:java
    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

    RawCode

    Zen3515
    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