Get client forge mod list?

Discussion in 'Spigot Plugin Development' started by Porama6400, May 14, 2017.

  1. Are there any way to get client forge mod list?
     
    • Agree Agree x 1
  2. I believe you'll have to use Sponge Powered for this.
     
  3. Take a look at this site.
    http://wiki.vg/Minecraft_Forge_Handshake
    I just skimmed the site quickly, however it seems that the client sends to the forge server a modlist so the server can check if the client is compatible.
    With this, you would need to make the forge client think that you're an forge server and get the modlist.

    Gesendet von meinem Nexus 5 mit Tapatalk
     
    • Agree Agree x 1
  4. I'v tried that but I somehow client won't ŕespond
     
  5. I know it's possible because BungeeCord try to communicate with forge client too
    But I don't know what did I do wrong

    Here's my code

    Code (Text):
    package me.Porama6400.AntiForge;

    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerLoginEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.plugin.messaging.PluginMessageListener;
    import org.bukkit.scheduler.BukkitRunnable;

    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.nio.ByteBuffer;

    /**
    * Created by Porama6400
    */
    public class AntiForge extends JavaPlugin implements Listener, PluginMessageListener {
        @Override
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
        }

        @EventHandler
        public void onJoin(PlayerJoinEvent e) throws IOException {
            new BukkitRunnable() {
                @Override
                public void run() {
                    try {
                        FMLHandshake(e);
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }.runTaskLaterAsynchronously(this, 5);
        }

        void FMLHandshake(PlayerJoinEvent e) throws IOException {
            try {
                Bukkit.getMessenger().registerIncomingPluginChannel(this, "FML|HS", this);
                Bukkit.getMessenger().registerOutgoingPluginChannel(this, "FML|HS");
                Bukkit.getMessenger().registerOutgoingPluginChannel(this, "FML");
                Bukkit.getMessenger().registerOutgoingPluginChannel(this, "FML|MP");
                Bukkit.getMessenger().registerOutgoingPluginChannel(this, "FORGE");
            } catch (Exception xxe) {
                xxe.printStackTrace();
            }

            ByteBuffer reset = ByteBuffer.allocate(32);
            reset.put((byte) 254);
            reset.compact();
            e.getPlayer().sendPluginMessage(this, "FML|HS", reset.array());
            reset.clear();
            ByteBuffer hello = ByteBuffer.allocate(32);
            hello.put((byte) 0);
            hello.put((byte) 1);
            //hello.putInt(0);
            reset.compact();
            e.getPlayer().sendPluginMessage(this, "FML|HS", hello.array());
            hello.clear();
        }

        @Override
        public void onPluginMessageReceived(String s, Player player, byte[] bytes) {
            System.out.println("MSG!");
            try {
                ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
                if (ois.readByte() != 2) {
                    ois.close();
                    return;
                }
                int count = Util.readVarInt(ois);
                for (int i = 0; i < count; i++) {
                    int stringASize = Util.readVarInt(ois);
                    String stringA = "";
                    for (int sai = 0; sai < stringASize; sai++) {
                        stringA += ois.readChar();
                    }
                    String stringB = "";
                    int stringBSize = Util.readVarInt(ois);
                    for (int sbi = 0; sbi < stringBSize; sbi++) {
                        stringB += ois.readChar();
                    }
                    System.out.println(stringA + " - " + stringB);
                }

            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
     

    Player can join but no handshake response received from client
     
  6. this is possible with a proxiedplayer on bungeecird
     
  7. Ahhh very true. A ProxiedPlayer (not the official docs, but at least it has proper documentation) can use .getModlist(); to get the player's mod list.
     
  8. it can't respond. it's upon loading the server list it sends the packet, and no packets are being received then, and that's the only chance you have to get the mod list.
     
  9. the handshake has already taken place on the PlayerJoinEvent
     
  10. I tried to do it on Spigot server not BungeeCord

    The first packet I it sent is HandshakeReset packet, which should restart the Forge handshake isn't it?
     
  11. no, like i said:
    you need to listen to packets at all times.
     
  12. P.s: ProtocolLib can help
     
  13. Use it for what?
     

  14. are you like fucking blind or just a moron
     
    • Optimistic Optimistic x 1
  15. I mean I know what should I do but I'm not sure how to do it

    I'm sorry, I'm not good with explanation in English

    English is not my native language, sorry :(
     
    • Friendly Friendly x 1
    • Optimistic Optimistic x 1