Solved TinyProtocol -> don't work

Discussion in 'Plugin Development' started by Smerfa, Oct 2, 2014.

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

    Smerfa

    Hi, I have problem with TinyProtocol
    https://github.com/aadnk/ProtocolLi.../com/comphenix/tinyprotocol/TinyProtocol.java

    So... after some tests, I see that
    Code:
    private static final MethodInvoker getNetworkMarkers = Reflection.getTypedMethod(serverConnectionClass, null, List.class, serverConnectionClass);
    is giving error (when it's used at 177 line) , because there is no method like that in most of build of CraftBukkit, I found it only in some Spigot builds.
    Code:
     static List a(ServerConnection serverconnection)
      {
        return serverconnection.f;
      }
    So, how to fix that?

    Comphenix

    bump

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

    fireblast709

    Smerfa the method exists, even in CB. However, it seems he is trying to invoke it with a MinecraftServer instance instead of a ServerConnection instance.
     
  3. Offline

    Smerfa

    o.o I check CraftBukkit R1, R2, R3, R4 and I don't see that method...
    R1 from jd-Gui
    Show Spoiler

    Code:java
    1. package net.minecraft.server.v1_7_R1;
    2.  
    3. import java.net.InetAddress;
    4. import java.util.ArrayList;
    5. import java.util.Collections;
    6. import java.util.Iterator;
    7. import java.util.List;
    8. import net.minecraft.util.com.google.common.util.concurrent.ThreadFactoryBuilder;
    9. import net.minecraft.util.io.netty.bootstrap.ServerBootstrap;
    10. import net.minecraft.util.io.netty.channel.Channel;
    11. import net.minecraft.util.io.netty.channel.ChannelFuture;
    12. import net.minecraft.util.io.netty.channel.nio.NioEventLoopGroup;
    13. import net.minecraft.util.io.netty.channel.socket.nio.NioServerSocketChannel;
    14. import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
    15. import org.apache.logging.log4j.LogManager;
    16. import org.apache.logging.log4j.Logger;
    17.  
    18. public class ServerConnection
    19. {
    20. private static final Logger b = ;
    21. private static final NioEventLoopGroup c = new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty IO #%d").setDaemon(true).build());
    22. private final MinecraftServer d;
    23. public volatile boolean a;
    24. private final List e = Collections.synchronizedList(new ArrayList());
    25. private final List f = Collections.synchronizedList(new ArrayList());
    26.  
    27. public ServerConnection(MinecraftServer paramMinecraftServer)
    28. {
    29. this.d = paramMinecraftServer;
    30. this.a = true;
    31. }
    32.  
    33. public void a(InetAddress paramInetAddress, int paramInt)
    34. {
    35. synchronized (this.e)
    36. {
    37. this.e.add(((ServerBootstrap)((ServerBootstrap)new ServerBootstrap().channel(NioServerSocketChannel.class)).childHandler(new ServerConnectionChannel(this)).group(c).localAddress(paramInetAddress, paramInt)).bind().syncUninterruptibly());
    38. }
    39. }
    40.  
    41. public void b()
    42. {
    43. this.a = false;
    44. for (ChannelFuture localChannelFuture : this.e) {
    45. localChannelFuture.channel().close().syncUninterruptibly();
    46. }
    47. }
    48.  
    49. public void c()
    50. {
    51. synchronized (this.f)
    52. {
    53. Iterator localIterator = this.f.iterator();
    54. while (localIterator.hasNext())
    55. {
    56. NetworkManager localNetworkManager = (NetworkManager)localIterator.next();
    57. if (!localNetworkManager.d())
    58. {
    59. localIterator.remove();
    60. if (localNetworkManager.f() != null) {
    61. localNetworkManager.getPacketListener().a(localNetworkManager.f());
    62. } else if (localNetworkManager.getPacketListener() != null) {
    63. localNetworkManager.getPacketListener().a(new ChatComponentText("Disconnected"));
    64. }
    65. }
    66. else
    67. {
    68. try
    69. {
    70. localNetworkManager.a();
    71. }
    72. catch (Exception localException)
    73. {
    74. if (localNetworkManager.c())
    75. {
    76. localObject1 = CrashReport.a(localException, "Ticking memory connection");
    77. CrashReportSystemDetails localCrashReportSystemDetails = ((CrashReport)localObject1).a("Ticking connection");
    78.  
    79. localCrashReportSystemDetails.a("Connection", new CrashReportServerConnection(this, localNetworkManager));
    80.  
    81.  
    82.  
    83.  
    84.  
    85.  
    86. throw new ReportedException((CrashReport)localObject1);
    87. }
    88. b.warn("Failed to handle packet for " + localNetworkManager.getSocketAddress(), localException);
    89. Object localObject1 = new ChatComponentText("Internal server error");
    90. localNetworkManager.handle(new PacketPlayOutKickDisconnect((IChatBaseComponent)localObject1), new GenericFutureListener[] { new ServerConnectionFuture(this, localNetworkManager, (ChatComponentText)localObject1) });
    91.  
    92.  
    93.  
    94.  
    95.  
    96. localNetworkManager.g();
    97. }
    98. }
    99. }
    100. }
    101. }
    102.  
    103. public MinecraftServer d()
    104. {
    105. return this.d;
    106. }
    107. }
    108.  



    I try another decompiler...
    from another one:
    Show Spoiler

    Code:java
    1. package net.minecraft.server.v1_7_R1;
    2.  
    3.  
    4.  
    5. import net.minecraft.util.io.netty.bootstrap.AbstractBootstrap;
    6.  
    7. import net.minecraft.util.com.google.common.util.concurrent.ThreadFactoryBuilder;
    8.  
    9. import org.apache.logging.log4j.LogManager;
    10.  
    11. import net.minecraft.util.io.netty.util.concurrent.GenericFutureListener;
    12.  
    13. import java.util.concurrent.Callable;
    14.  
    15. import java.util.Iterator;
    16.  
    17. import net.minecraft.util.io.netty.channel.ChannelFuture;
    18.  
    19. import net.minecraft.util.io.netty.channel.EventLoopGroup;
    20.  
    21. import net.minecraft.util.io.netty.channel.ChannelHandler;
    22.  
    23. import net.minecraft.util.io.netty.channel.Channel;
    24.  
    25. import net.minecraft.util.io.netty.channel.socket.nio.NioServerSocketChannel;
    26.  
    27. import net.minecraft.util.io.netty.bootstrap.ServerBootstrap;
    28.  
    29. import java.net.InetAddress;
    30.  
    31. import java.util.Collections;
    32.  
    33. import java.util.ArrayList;
    34.  
    35. import java.util.List;
    36.  
    37. import net.minecraft.util.io.netty.channel.nio.NioEventLoopGroup;
    38.  
    39. import org.apache.logging.log4j.Logger;
    40.  
    41.  
    42.  
    43. public class ServerConnection
    44.  
    45. {
    46.  
    47. private static final Logger b;
    48.  
    49. private static final NioEventLoopGroup c;
    50.  
    51. private final MinecraftServer d;
    52.  
    53. public volatile boolean a;
    54.  
    55. private final List e;
    56.  
    57. private final List f;
    58.  
    59.  
    60.  
    61. public ServerConnection(final MinecraftServer d) {
    62.  
    63. super();
    64.  
    65. this.e = Collections.synchronizedList(new ArrayList<Object>());
    66.  
    67. this.f = Collections.synchronizedList(new ArrayList<Object>());
    68.  
    69. this.d = d;
    70.  
    71. this.a = true;
    72.  
    73. }
    74.  
    75.  
    76.  
    77. public void a(final InetAddress inetHost, final int inetPort) {
    78.  
    79. synchronized (this.e) {
    80.  
    81. this.e.add(((AbstractBootstrap<ServerBootstrap, C>)((AbstractBootstrap<ServerBootstrap, Channel>)new ServerBootstrap()).channel(NioServerSocketChannel.class).childHandler(new ServerConnectionChannel(this)).group(ServerConnection.c)).localAddress(inetHost, inetPort).bind().syncUninterruptibly());
    82.  
    83. }
    84.  
    85. }
    86.  
    87.  
    88.  
    89. public void b() {
    90.  
    91. this.a = false;
    92.  
    93. final Iterator<ChannelFuture> iterator = this.e.iterator();
    94.  
    95. while (iterator.hasNext()) {
    96.  
    97. iterator.next().channel().close().syncUninterruptibly();
    98.  
    99. }
    100.  
    101. }
    102.  
    103.  
    104.  
    105. public void c() {
    106.  
    107. synchronized (this.f) {
    108.  
    109. final Iterator<NetworkManager> iterator = (Iterator<NetworkManager>)this.f.iterator();
    110.  
    111. while (iterator.hasNext()) {
    112.  
    113. final NetworkManager networkManager = iterator.next();
    114.  
    115. if (!networkManager.d()) {
    116.  
    117. iterator.remove();
    118.  
    119. if (networkManager.f() != null) {
    120.  
    121. networkManager.getPacketListener().a(networkManager.f());
    122.  
    123. }
    124.  
    125. else {
    126.  
    127. if (networkManager.getPacketListener() == null) {
    128.  
    129. continue;
    130.  
    131. }
    132.  
    133. networkManager.getPacketListener().a(new ChatComponentText("Disconnected"));
    134.  
    135. }
    136.  
    137. }
    138.  
    139. else {
    140.  
    141. try {
    142.  
    143. networkManager.a();
    144.  
    145. }
    146.  
    147. catch (Exception throwable) {
    148.  
    149. if (networkManager.c()) {
    150.  
    151. final CrashReport a = CrashReport.a(throwable, "Ticking memory connection");
    152.  
    153. a.a("Ticking connection").a("Connection", new CrashReportServerConnection(this, networkManager));
    154.  
    155. throw new ReportedException(a);
    156.  
    157. }
    158.  
    159. ServerConnection.b.warn("Failed to handle packet for " + networkManager.getSocketAddress(), throwable);
    160.  
    161. final ChatComponentText chatComponentText = new ChatComponentText("Internal server error");
    162.  
    163. networkManager.handle(new PacketPlayOutKickDisconnect(chatComponentText), new ServerConnectionFuture(this, networkManager, chatComponentText));
    164.  
    165. networkManager.g();
    166.  
    167. }
    168.  
    169. }
    170.  
    171. }
    172.  
    173. }
    174.  
    175. }
    176.  
    177.  
    178.  
    179. public MinecraftServer d() {
    180.  
    181. return this.d;
    182.  
    183. }
    184.  
    185.  
    186.  
    187. static {
    188.  
    189. b = LogManager.getLogger();
    190.  
    191. c = new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty IO #%d").setDaemon(true).build());
    192.  
    193. }
    194.  
    195. }



    so... :D where?
     
  4. Offline

    fireblast709

  5. Offline

    Smerfa

    bump
    Comphenix are you alive? :(


    EDIT: fixed by changing method of getting Networks list, and delay TinyProtocol start.
     
Thread Status:
Not open for further replies.

Share This Page