[1.8] Help with packet Packet205ClientCommand

Discussion in 'Spigot Plugin Help' started by MusicalCreeper01, May 25, 2015.

  1. Hey everyone,

    So I'm programming a plugin that has an auto respawn after death, but the usual used packet for this stuff, Packet205ClientCommand does not exist in spigot 1.8. Does anyone know what it has been changed to/what to use instead?

    For reference, my code is:

    Code (Text):

    @EventHandler
       public void onPlayerDeath(final PlayerDeathEvent e) {
         if (worlds.contains(e.getEntity().getWorld().getName())) {
           e.getEntity().setBedSpawnLocation(
               e.getEntity().getWorld().getSpawnLocation(), true);

           BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
           scheduler.scheduleSyncDelayedTask(this, new Runnable() {
             @Override
             public void run() {
               String tv = Bukkit.getVersion();
               int index = tv.indexOf("(MC: ") + 5;
               int end = tv.indexOf(")", index);
               //String version = tv.substring(index, end);
               try {
                 Class<?> packet = Class.forName("net.minecraft.server."
                     + nmsver
                     + ".Packet205ClientCommand");
                 Object name = packet.getConstructor(new Class[0])
                     .newInstance(new Object[0]);
                 Field a = packet.getDeclaredField("a");
                 a.setAccessible(true);
                 a.set(name, 1);
                 Object nmsPlayer = Class
                     .forName(
                         "org.bukkit.craftbukkit."
                             + nmsver
                             + ".entity.CraftPlayer")
                     .getMethod("getHandle", new Class[0])
                     .invoke(e.getEntity(), new Object[0]);
                 Field con = Class.forName(
                     "net.minecraft.server."
                         +nmsver
                         + ".EntityPlayer").getDeclaredField(
                     "playerConnection");
                 con.setAccessible(true);
                 Object handle = con.get(nmsPlayer);
                 packet.getDeclaredMethod(
                     "handle",
                     Class.forName("net.minecraft.server."
                         + nmsver
                         + ".Connection")).invoke(name, handle);
               } catch (Exception ex) {
                 ex.printStackTrace();
               }
             }
           }, 20L);
         }
       }
     
     
  2. Code (Text):
    player.spigot().respawn();
     
    #2 Coltll, May 25, 2015
    Last edited: May 25, 2015
    • Winner Winner x 2
  3. Oh, wow, I can't believe I didn't find that xD Thanks!
     
    • Like Like x 1
  4. We really need a guide or something for those little neat things.
     
    • Agree Agree x 1
    • Funny Funny x 1
    • Useful Useful x 1
    • Agree Agree x 1