This as reflection

Discussion in 'Plugin Development' started by Seadragon91, Jul 24, 2014.

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

    Seadragon91

    Hello!

    Can anyone write that code as reflection code? I found a bug in bukkit and haven't found any solution as bukkit code. Only this nms code fix that problem...

    Code:
    Chunk chunk = chunk1; // this line is bukkit code
     
    net.minecraft.server.v1_7_R1.World nmsWorld = ((org.bukkit.craftbukkit.v1_7_R1.CraftChunk) chunk).getHandle().world;
    for (net.minecraft.server.v1_7_R1.EntityPlayer ep : (List<net.minecraft.server.v1_7_R1.EntityPlayer>) nmsWorld.players) {
        ep.chunkCoordIntPairQueue.add(new net.minecraft.server.v1_7_R1.ChunkCoordIntPair(chunk.getX(), chunk.getZ()));
    }
    
     
  2. Offline

    mythbusterma

  3. Offline

    Seadragon91

  4. Offline

    _Filip

    Java docs.
     
  5. Offline

    Seadragon91

    Very stupid answer, I tried everything with bukkit code for chunks, nothing works. ONLY this nms code fix that problem.
     
  6. Offline

    _Filip

  7. Offline

    xTrollxDudex

    Seadragon91
    Never use reflection if you don't absolutely have to. A relavent usage for reflection is accessing private API or internals, not so you can be lazy and not have to update every release.

    Use it like it is, you don't need to use reflection. In fact, you shouldn't use reflection.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  8. Offline

    Seadragon91


    I need to use reflection, If I use the plugin for different versions...
     
  9. Offline

    xTrollxDudex

    Compile for different versions
     
  10. Offline

    mythbusterma

    Honestly I would use reflection, if only because server owners are too stupid to figure out which version they need and will complain to me, accessing two methods via reflection doesn't seem like that egregious an offence.

    And TheSpherret showed you exactly how to do it, http://docs.oracle.com/javase/tutorial/reflect/
     
Thread Status:
Not open for further replies.

Share This Page