diff --git a/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java b/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java
index c210912f..949823ea 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/CustomPacketHandler.java
@@ -1,43 +1,48 @@
+/*
+ This file is a part of the SteamWar software.
+
+ Copyright (C) 2020 SteamWar.de-Serverteam
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
package de.steamwar.bungeecore.listeners.mods;
import de.steamwar.bungeecore.BungeeCore;
-import de.steamwar.bungeecore.sql.Mod;
-import net.md_5.bungee.BungeeCord;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.LoginEvent;
-import net.md_5.bungee.api.event.PreLoginEvent;
-import net.md_5.bungee.api.plugin.Event;
-import net.md_5.bungee.netty.ChannelWrapper;
import net.md_5.bungee.netty.PacketHandler;
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
public class CustomPacketHandler extends PacketHandler {
- private LoginEvent event;
- private ChannelWrapper wrapper;
+ private LoginEvent event;
- public CustomPacketHandler(LoginEvent event, ChannelWrapper wrapper) {
+ public CustomPacketHandler(LoginEvent event) {
this.event = event;
- this.wrapper = wrapper;
}
- @Override public String toString() {
+ @Override
+ public String toString() {
return null;
}
public void handle(LoginPayloadResponse response){
if(response.getData() == null) {
- System.out.println("Data is null with id: " + response.getId() + " , which means Client has no installed mods!");
event.completeIntent(BungeeCore.get());
return;
}
-
+
+ byte[] data = response.getData();
event.completeIntent(BungeeCore.get());
}
diff --git a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java
index 73dba3d8..56edfc21 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/FMLPing.java
@@ -1,3 +1,21 @@
+/*
+ This file is a part of the SteamWar software.
+
+ Copyright (C) 2020 SteamWar.de-Serverteam
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
package de.steamwar.bungeecore.listeners.mods;
import net.md_5.bungee.api.ServerPing;
diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java
index 881e4d7c..64c1ce08 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java
@@ -19,6 +19,7 @@
package de.steamwar.bungeecore.listeners.mods;
+import com.google.common.collect.ImmutableMap;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.bungeecore.sql.Mod;
@@ -41,14 +42,13 @@ import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
public class Forge extends BasicListener {
private static final String FMLHS = "FML|HS";
- private static final String FMLHS13 = "fml:handshake";
private static final String WRAPPER = "fml:loginwrapper";
private static final byte[] REGISTER;
- private static final byte[] REGISTER13;
private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0};
private static final Set unlocked = new HashSet<>();
@@ -58,37 +58,28 @@ public class Forge extends BasicListener {
buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8);
REGISTER = new byte[buf.readableBytes()];
buf.readBytes(REGISTER);
-
- buf.clear();
- buf.writeByte(13);
- buf.writeCharSequence(FMLHS13, StandardCharsets.UTF_8);
- REGISTER13 = new byte[buf.readableBytes()];
- buf.readBytes(REGISTER13);
}
@EventHandler
public void onServerConnected(LoginEvent event){
- //Wir senden Packet ID 1
- //Wir wollen empfangen Packet ID 2
- //(FMLHS13, new byte[]{4, 1, 0, 0, 0});
- //13,102,109,108,58,104,97,110,100,115,104,97,107,101 = 13 + "fml:handshake"
+ if(event.getConnection().getVersion() < 340) return; //1.13+
event.getConnection().unsafe().sendPacket(new LoginPayloadRequest(1,WRAPPER, new byte[]{13,102,109,108,58,104,97,110,100,115,104,97,107,101,4,1,0,0,0}));
- event.registerIntent(BungeeCore.get());
-
InitialHandler handler = (InitialHandler) event.getConnection();
Field ch;
- ChannelWrapper wrapper = null;
+ ChannelWrapper wrapper;
try{
ch = handler.getClass().getDeclaredField("ch");
ch.setAccessible(true);
wrapper = (ChannelWrapper) ch.get(handler);
} catch (NoSuchFieldException | IllegalAccessException e) {
- e.printStackTrace();
+ BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get Channel", e);
+ return;
}
- wrapper.getHandle().pipeline().get(HandlerBoss.class).setHandler(new CustomPacketHandler(event, wrapper));
+ event.registerIntent(BungeeCore.get());
+ wrapper.getHandle().pipeline().get(HandlerBoss.class).setHandler(new CustomPacketHandler(event));
}
@EventHandler
@@ -107,10 +98,7 @@ public class Forge extends BasicListener {
}
}
- if(player.getPendingConnection().getVersion() > 340) {
- player.sendData("minecraft:register", REGISTER13); //1.13+
- player.sendData(FMLHS13, Forge.HELLO);
- }else{
+ if(player.getPendingConnection().getVersion() <= 340) {
player.sendData("REGISTER", REGISTER); //1.12-
player.sendData(FMLHS, Forge.HELLO);
}
@@ -118,7 +106,7 @@ public class Forge extends BasicListener {
@EventHandler
public void onPluginMessageEvent(PluginMessageEvent e){
- if(!e.getTag().equals(FMLHS) && !e.getTag().equals(FMLHS13))
+ if(!e.getTag().equals(FMLHS))
return;
e.setCancelled(true);
diff --git a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
index 281830cf..a4d54e6d 100644
--- a/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
+++ b/src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
@@ -56,26 +56,6 @@ public class ModLoaderBlocker extends BasicListener {
}
}
- @EventHandler
- public void onPluginMessage(PluginMessageEvent e){
- if(!e.getTag().equals("minecraft:register"))
- return;
-
- Connection sender = e.getSender();
- if(!(sender instanceof ProxiedPlayer))
- return;
- ProxiedPlayer p = (ProxiedPlayer) sender;
-
- if(p.getPendingConnection().getVersion() <= 340)
- return;
-
- String registered = new String(e.getData(), StandardCharsets.UTF_8);
- if(registered.contains("fml:loginwrapper") || registered.contains("fml:handshake") || registered.contains("fml:play")){
- Storage.fabricPlayers.add(p);
- Message.send("MODLOADER_INSTALLED", p, "Forge");
- }
- }
-
@EventHandler
public void onDisconnect(PlayerDisconnectEvent e){
Storage.fabricPlayers.remove(e.getPlayer());