Send player data to fix the invisible bug

Discussion in 'Plugin Development' started by black_ixx, Sep 19, 2012.

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

    Currently, teleporting players at the same tick dont works without bugs. So I got the idea to avoid the bug with a plugin. Its possible to hide players and set them to visible back with a plugin. So it should also be possible to just set invisible players to visible. Is this possible? How?
    Maybe with sending the right data/packets (erm I didnt work with this before)?

    Help is welcome :D
     
  2. Offline

    SnowGears

    Run a loop through all online players and use this code
    (an online player).hidePlayer( player to hide )
    When you want to show them again, use same loop but this time do:
    (an online player).showPlayer( player to hide )
     
  3. Offline

    Infamous Jeezy

    Unfortunately the hide/show player command won't fix this bug.
    At least it didn't for me, maybe it was just a fluke...
     
  4. Offline

    iZanax

    I've found no solution to the problem.
    I tried 3 methodes to fix it, but it still appear time to time.
    • Reteleport them
    • Refresh the chunk
    • Hide/Show

    If u need the source, tell me ^^
     
  5. I already tried that... ( http://forums.bukkit.org/threads/teleport-bug.99398/#post-1342186 )
     
  6. Offline

    Comphenix

    Strange, I would think refreshChunk should do the trick.

    In any event, I might have found a different method of showing the player. When I wrote TagHelper (an API for changing the display tag of players, just like TagAPI) I modified EntityTracker instead of using the showPlayer()/hidePlayer() trick.

    I managed to reproduce the invisibility bug by teleporting "Player" around on my test server. When I called "/refresh Player" after teleporting, he reappeared on the screen.

    You can check if this works for you by downloading ProtocolLib, TagHelper and TagExample.
     
    black_ixx likes this.
  7. Offline

    xXSniperzzXx_SD

    I teleport all at different ticks, and refresh the chunk and i haven't had a problem yet!
     
  8. So you think teleporting and different ticks will work?

    I tried your plugins but they could not be started:
    Code:
    2012-09-20 21:09:42 [SEVERE] Could not load 'plugins\TagExample.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: com/comphenix/tagexample/TagExampleMod : Unsupported major.minor version 51.0
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:155)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:222)
        at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:565)
        at org.bukkit.Bukkit.reload(Bukkit.java:183)
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:21)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:492)
        at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:488)
        at net.minecraft.server.DedicatedServer.ah(DedicatedServer.java:248)
        at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:213)
        at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:474)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:406)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    Caused by: java.lang.UnsupportedClassVersionError: com/comphenix/tagexample/TagExampleMod : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:44)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:144)
        ... 14 more
    2012-09-20 21:09:42 [SEVERE] Could not load 'plugins\TagHelper.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: com/comphenix/taghelper/TagHelperMod : Unsupported major.minor version 51.0
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:155)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:222)
        at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:565)
        at org.bukkit.Bukkit.reload(Bukkit.java:183)
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:21)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:492)
        at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:488)
        at net.minecraft.server.DedicatedServer.ah(DedicatedServer.java:248)
        at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:213)
        at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:474)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:406)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    Caused by: java.lang.UnsupportedClassVersionError: com/comphenix/taghelper/TagHelperMod : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:44)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:144)
        ... 14 more

    I also got another idea:
    Code:
            for (Player pl : Bukkit.getOnlinePlayers()){
                for (Player player : Bukkit.getOnlinePlayers()) {
                        CraftPlayer p = (CraftPlayer) pl;
                        if (!pl.getName().equalsIgnoreCase(player.getName())){
                        ((CraftPlayer)player).getHandle().netServerHandler.sendPacket(new Packet20NamedEntitySpawn(p.getHandle()));}
                 
                }
            }
    But with this code, the other players wont be able to see the players armor and item in hand...



    Edit:

    New idea: Would it be possible to create a mod to just fix the bug?
     
  9. Offline

    Comphenix

    Oh, you're using Java 6.

    Try TagHelper 1.0.1 and TagExample 1.0.1 then. They should be compatible.

    Exactly. You'll need to send these (especially Packet5EntityEquipment) for your fix to properly correct the bug.

    But what ProtocolLib does is force Minecraft to re-send all the necessary packets. It may be a bit difficult to see how this is actually done due to all the reflection, but essentially I'm just removing the players I want to update from trackedPlayers before I call updatePlayers.
     
    black_ixx likes this.
  10. Offline

    xXSniperzzXx_SD

    Well i heard that this happens when you teleport multiple people in the same tick, so i assume that putting everyone at a different tick will fix it, and since i did that it hasn't happened yet
     
    black_ixx likes this.
  11. I think I fixed the bug now !
    It works (Ive tested it 5 times).
    Thanks :D
     
  12. Offline

    xXSniperzzXx_SD

    Lately i've been seeming to still get ateast 1/5 ppl invisible so now i do

    Code:
     plugin.queuedtp = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
                                                    World world = Bukkit.getServer().getWorld(plugin.getArenas().getString("Arenas."+plugin.playingin+".World"));
                                                    public void run() {
                                                      if(!(plugin.queued.size()==0)){
                                                          Player p = plugin.queued.get(0);
                                                       
                                                              p.teleport(new Location(world, plugin.getArenas().getInt("Arenas."+plugin.playingin+".X"), plugin.getArenas().getInt("Arenas."+plugin.playingin+".Y"), plugin.getArenas().getInt("Arenas."+plugin.playingin+".Z")));
                                                              p.getWorld().getChunkAt(new Location(world, plugin.getArenas().getInt("Arenas."+plugin.playingin+".X"), plugin.getArenas().getInt("Arenas."+plugin.playingin+".Y"), plugin.getArenas().getInt("Arenas."+plugin.playingin+".Z")));
                                                              plugin.queued.remove(p);
                                                   
                                                      }if(plugin.queued.size()==0){
                                                   
                                                          Bukkit.getScheduler().cancelTask(plugin.queuedtp);
                                                      }
                                                  }
                                              }, 0L, 1L);
    I know it may ask alot of the server cause it wants a chunk refresh on every tick, but it seems to do the trick so far
     
  13. Offline

    Lolmewn

    xXSniperzzXx_SD As far as I can tell, you're only getting the chunk variable with that, not reloading/refreshing it.
     
  14. Yeah.... 1/10 times of testing a player was invisible...
    Hopefully Mojang will fix that. Also, would it be possible to just fix it with a mod?
     
  15. Offline

    xXSniperzzXx_SD

    lol i forgot to add refresh chunk :p

    And the owner of the McInfected server says he's fixed this problem using a sneaky way, but he's refusing to tell me how...

    http://super-gaming.net/index.php?t...ublic-testing-on-s3-double-cookies-event.934/

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

    libraryaddict

Thread Status:
Not open for further replies.

Share This Page