Archiviert
1
0

Merge branch 'modblocker' of SteamWar/BungeeCore into master

Dieser Commit ist enthalten in:
Lixfel 2019-12-31 08:43:22 +01:00 committet von Gitea
Commit fcd09fb3b3
2 geänderte Dateien mit 25 neuen und 299 gelöschten Zeilen

Datei anzeigen

@ -6,6 +6,7 @@ import de.steamwar.bungeecore.sql.Mod;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator; import io.netty.buffer.UnpooledByteBufAllocator;
import javafx.util.Pair; import javafx.util.Pair;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.Connection; import net.md_5.bungee.api.connection.Connection;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
@ -13,18 +14,15 @@ import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.*;
import java.util.LinkedList; import java.util.concurrent.TimeUnit;
import java.util.List;
public class Forge extends BasicListener { public class Forge extends BasicListener {
private static final String FMLHS = "FML|HS"; private static final String FMLHS = "FML|HS";
private static final byte[] REGISTER; private static final byte[] REGISTER;
private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0}; private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0};
//Packet 2, ein Mod, minecraft 1.12.2 private static final Set<UUID> unlocked = new HashSet<>();
private static final byte[] MODS = new byte[]{2, 1, 9, 109, 105, 110, 101, 99, 114, 97, 102, 116, 6, 49, 46, 49, 50, 46, 50};
private static final byte[] REGISTRY;
private static boolean enabled = false; private static boolean enabled = false;
public static void toggleEnabled(){ public static void toggleEnabled(){
@ -37,272 +35,6 @@ public class Forge extends BasicListener {
buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8); buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8);
REGISTER = new byte[buf.readableBytes()]; REGISTER = new byte[buf.readableBytes()];
buf.readBytes(REGISTER); buf.readBytes(REGISTER);
buf.clear();
buf = UnpooledByteBufAllocator.DEFAULT.directBuffer(100);
buf.writeByte(3); // Packet 3
buf.writeByte(0); // Boolean no following packet 3
buf.writeByte(9); // Stringlength 9 (namespace minecraft)
buf.writeCharSequence("minecraft", StandardCharsets.UTF_8);
buf.writeByte(253); // VarInt 253, Missing: 36, 253, 254
buf.writeByte(1); // VarInt +128
registerId(buf, 0, "air");
registerId(buf, 1, "stone");
registerId(buf, 2, "grass");
registerId(buf, 3, "dirt");
registerId(buf, 4, "cobblestone");
registerId(buf, 5, "planks");
registerId(buf, 6, "sapling");
registerId(buf, 7, "bedrock");
registerId(buf, 8, "flowing_water");
registerId(buf, 9, "water");
registerId(buf, 10, "flowing_lava");
registerId(buf, 11, "lava");
registerId(buf, 12, "sand");
registerId(buf, 13, "gravel");
registerId(buf, 14, "gold_ore");
registerId(buf, 15, "iron_ore");
registerId(buf, 16, "coal_ore");
registerId(buf, 17, "log");
registerId(buf, 18, "leaves");
registerId(buf, 19, "sponge");
registerId(buf, 20, "glass");
registerId(buf, 21, "lapis_ore");
registerId(buf, 22, "lapis_block");
registerId(buf, 23, "dispenser");
registerId(buf, 24, "sandstone");
registerId(buf, 25, "noteblock");
registerId(buf, 26, "bed");
registerId(buf, 27, "golden_rail");
registerId(buf, 28, "detector_rail");
registerId(buf, 29, "sticky_piston");
registerId(buf, 30, "web");
registerId(buf, 31, "tallgrass");
registerId(buf, 32, "deadbush");
registerId(buf, 33, "piston");
registerId(buf, 34, "piston_head");
registerId(buf, 35, "wool");
registerId(buf, 37, "yellow_flower");
registerId(buf, 38, "red_flower");
registerId(buf, 39, "brown_mushroom");
registerId(buf, 40, "red_mushroom");
registerId(buf, 41, "gold_block");
registerId(buf, 42, "iron_block");
registerId(buf, 43, "double_stone_slab");
registerId(buf, 44, "stone_slab");
registerId(buf, 45, "brick_block");
registerId(buf, 46, "tnt");
registerId(buf, 47, "bookshelf");
registerId(buf, 48, "mossy_cobblestone");
registerId(buf, 49, "obsidian");
registerId(buf, 50, "torch");
registerId(buf, 51, "fire");
registerId(buf, 52, "mob_spawner");
registerId(buf, 53, "oak_stairs");
registerId(buf, 54, "chest");
registerId(buf, 55, "redstone_wire");
registerId(buf, 56, "diamond_ore");
registerId(buf, 57, "diamond_block");
registerId(buf, 58, "crafting_table");
registerId(buf, 59, "wheat");
registerId(buf, 60, "farmland");
registerId(buf, 61, "furnace");
registerId(buf, 62, "lit_furnace");
registerId(buf, 63, "standing_sign");
registerId(buf, 64, "wooden_door");
registerId(buf, 65, "ladder");
registerId(buf, 66, "rail");
registerId(buf, 67, "stone_stairs");
registerId(buf, 68, "wall_sign");
registerId(buf, 69, "lever");
registerId(buf, 70, "stone_pressure_plate");
registerId(buf, 71, "iron_door");
registerId(buf, 72, "wooden_pressure_plate");
registerId(buf, 73, "redstone_ore");
registerId(buf, 74, "lit_redstone_ore");
registerId(buf, 75, "unlit_redstone_torch");
registerId(buf, 76, "redstone_torch");
registerId(buf, 77, "stone_button");
registerId(buf, 78, "snow_layer");
registerId(buf, 79, "ice");
registerId(buf, 80, "snow");
registerId(buf, 81, "cactus");
registerId(buf, 82, "clay");
registerId(buf, 83, "reeds");
registerId(buf, 84, "jukebox");
registerId(buf, 85, "fence");
registerId(buf, 86, "pumpkin");
registerId(buf, 87, "netherrack");
registerId(buf, 88, "soul_sand");
registerId(buf, 89, "glowstone");
registerId(buf, 90, "portal");
registerId(buf, 91, "lit_pumpkin");
registerId(buf, 92, "cake");
registerId(buf, 93, "unpowered_repeater");
registerId(buf, 94, "powered_repeater");
registerId(buf, 95, "stained_glass");
registerId(buf, 96, "trapdoor");
registerId(buf, 97, "monster_egg");
registerId(buf, 98, "stonebrick");
registerId(buf, 99, "brown_mushroom_block");
registerId(buf, 100, "red_mushroom_block");
registerId(buf, 101, "iron_bars");
registerId(buf, 102, "glass_pane");
registerId(buf, 103, "melon_block");
registerId(buf, 104, "pumpkin_stem");
registerId(buf, 105, "melon_stem");
registerId(buf, 106, "vine");
registerId(buf, 107, "fence_gate");
registerId(buf, 108, "brick_stairs");
registerId(buf, 109, "stone_brick_stairs");
registerId(buf, 110, "mycelium");
registerId(buf, 111, "waterlily");
registerId(buf, 112, "nether_brick");
registerId(buf, 113, "nether_brick_fence");
registerId(buf, 114, "nether_brick_stairs");
registerId(buf, 115, "nether_wart");
registerId(buf, 116, "enchanting_table");
registerId(buf, 117, "brewing_stand");
registerId(buf, 118, "cauldron");
registerId(buf, 119, "end_portal");
registerId(buf, 120, "end_portal_frame");
registerId(buf, 121, "end_stone");
registerId(buf, 122, "dragon_egg");
registerId(buf, 123, "redstone_lamp");
registerId(buf, 124, "lit_redstone_lamp");
registerId(buf, 125, "double_wooden_slab");
registerId(buf, 126, "wooden_slab");
registerId(buf, 127, "cocoa");
registerId(buf, 128, "sandstone_stairs");
registerId(buf, 129, "emerald_ore");
registerId(buf, 130, "ender_chest");
registerId(buf, 131, "tripwire_hook");
registerId(buf, 132, "tripwire");
registerId(buf, 133, "emerald_block");
registerId(buf, 134, "spruce_stairs");
registerId(buf, 135, "birch_stairs");
registerId(buf, 136, "jungle_stairs");
registerId(buf, 137, "command_block");
registerId(buf, 138, "beacon");
registerId(buf, 139, "cobblestone_wall");
registerId(buf, 140, "flower_pot");
registerId(buf, 141, "carrots");
registerId(buf, 142, "potatoes");
registerId(buf, 143, "wooden_button");
registerId(buf, 144, "skull");
registerId(buf, 145, "anvil");
registerId(buf, 146, "trapped_chest");
registerId(buf, 147, "light_weighted_pressure_plate");
registerId(buf, 148, "heavy_weighted_pressure_plate");
registerId(buf, 149, "unpowered_comparator");
registerId(buf, 150, "powered_comparator");
registerId(buf, 151, "daylight_detector");
registerId(buf, 152, "redstone_block");
registerId(buf, 153, "quartz_ore");
registerId(buf, 154, "hopper");
registerId(buf, 155, "quartz_block");
registerId(buf, 156, "quartz_stairs");
registerId(buf, 157, "activator_rail");
registerId(buf, 158, "dropper");
registerId(buf, 159, "stained_hardened_clay");
registerId(buf, 160, "stained_glass_pane");
registerId(buf, 161, "leaves2");
registerId(buf, 162, "log2");
registerId(buf, 163, "acacia_stairs");
registerId(buf, 164, "dark_oak_stairs");
registerId(buf, 165, "slime");
registerId(buf, 166, "barrier");
registerId(buf, 167, "iron_trapdoor");
registerId(buf, 168, "prismarine");
registerId(buf, 169, "sea_lantern");
registerId(buf, 170, "hay_block");
registerId(buf, 171, "carpet");
registerId(buf, 172, "hardened_clay");
registerId(buf, 173, "coal_block");
registerId(buf, 174, "packed_ice");
registerId(buf, 175, "double_plant");
registerId(buf, 176, "standing_banner");
registerId(buf, 177, "wall_banner");
registerId(buf, 178, "daylight_detector_inverted");
registerId(buf, 179, "red_sandstone");
registerId(buf, 180, "red_sandstone_stairs");
registerId(buf, 181, "double_stone_slab2");
registerId(buf, 182, "stone_slab2");
registerId(buf, 183, "spruce_fence_gate");
registerId(buf, 184, "birch_fence_gate");
registerId(buf, 185, "jungle_fence_gate");
registerId(buf, 186, "dark_oak_fence_gate");
registerId(buf, 187, "acacia_fence_gate");
registerId(buf, 188, "spruce_fence");
registerId(buf, 189, "birch_fence");
registerId(buf, 190, "jungle_fence");
registerId(buf, 191, "dark_oak_fence");
registerId(buf, 192, "acacia_fence");
registerId(buf, 193, "spruce_door");
registerId(buf, 194, "birch_door");
registerId(buf, 195, "jungle_door");
registerId(buf, 196, "acacia_door");
registerId(buf, 197, "dark_oak_door");
registerId(buf, 198, "end_rod");
registerId(buf, 199, "chorus_plant");
registerId(buf, 200, "chorus_flower");
registerId(buf, 201, "purpur_block");
registerId(buf, 202, "purpur_pillar");
registerId(buf, 203, "purpur_stairs");
registerId(buf, 204, "purpur_double_slab");
registerId(buf, 205, "purpur_slab");
registerId(buf, 206, "end_bricks");
registerId(buf, 207, "beetroots");
registerId(buf, 208, "grass_path");
registerId(buf, 209, "end_gateway");
registerId(buf, 210, "repeating_command_block");
registerId(buf, 211, "chain_command_block");
registerId(buf, 212, "frosted_ice");
registerId(buf, 213, "magma");
registerId(buf, 214, "nether_wart_block");
registerId(buf, 215, "red_nether_brick");
registerId(buf, 216, "bone_block");
registerId(buf, 217, "structure_void");
registerId(buf, 218, "observer");
registerId(buf, 219, "white_shulker_box");
registerId(buf, 220, "orange_shulker_box");
registerId(buf, 221, "magenta_shulker_box");
registerId(buf, 222, "light_blue_shulker_box");
registerId(buf, 223, "yellow_shulker_box");
registerId(buf, 224, "lime_shulker_box");
registerId(buf, 225, "pink_shulker_box");
registerId(buf, 226, "gray_shulker_box");
registerId(buf, 227, "silver_shulker_box");
registerId(buf, 228, "cyan_shulker_box");
registerId(buf, 229, "purple_shulker_box");
registerId(buf, 230, "blue_shulker_box");
registerId(buf, 231, "brown_shulker_box");
registerId(buf, 232, "green_shulker_box");
registerId(buf, 233, "red_shulker_box");
registerId(buf, 234, "black_shulker_box");
registerId(buf, 235, "white_glazed_terracotta");
registerId(buf, 236, "orange_glazed_terracotta");
registerId(buf, 237, "magenta_glazed_terracotta");
registerId(buf, 238, "light_blue_glazed_terracotta");
registerId(buf, 239, "yellow_glazed_terracotta");
registerId(buf, 240, "lime_glazed_terracotta");
registerId(buf, 241, "pink_glazed_terracotta");
registerId(buf, 242, "gray_glazed_terracotta");
registerId(buf, 243, "light_gray_glazed_terracotta");
registerId(buf, 244, "cyan_glazed_terracotta");
registerId(buf, 245, "purple_glazed_terracotta");
registerId(buf, 246, "blue_glazed_terracotta");
registerId(buf, 247, "brown_glazed_terracotta");
registerId(buf, 248, "green_glazed_terracotta");
registerId(buf, 249, "red_glazed_terracotta");
registerId(buf, 250, "black_glazed_terracotta");
registerId(buf, 251, "concrete");
registerId(buf, 252, "concrete_powder");
registerId(buf, 255, "structure_block");
buf.writeByte(0); // 0 Dummys
buf.writeByte(0); // 0 Subsitutions
REGISTRY = new byte[buf.readableBytes()];
buf.readBytes(REGISTRY);
} }
@EventHandler @EventHandler
@ -312,6 +44,13 @@ public class Forge extends BasicListener {
if(!enabled) if(!enabled)
return; return;
synchronized (unlocked) {
if(unlocked.contains(player.getUniqueId())){
unlocked.remove(player.getUniqueId());
return;
}
}
if(player.getPendingConnection().getVersion() > 340) if(player.getPendingConnection().getVersion() > 340)
player.sendData("minecraft:register", REGISTER); //1.13+ player.sendData("minecraft:register", REGISTER); //1.13+
else else
@ -354,35 +93,20 @@ public class Forge extends BasicListener {
BungeeCore.log(new String(name) + " " + new String(version)); BungeeCore.log(new String(name) + " " + new String(version));
} }
Utils.handleMods(p, mods); if(Utils.handleMods(p, mods)){
p.sendData(FMLHS, MODS); synchronized (unlocked){
break; unlocked.add(p.getUniqueId());
case -1: }
switch(data[1]){ p.disconnect(BungeeCore.stringToText("§7Deine installierten Mods wurden überprüft\n\n§aDu kannst nun §eSteam§8War §abetreten"));
case 2: ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
p.sendData(FMLHS, REGISTRY); synchronized (unlocked) {
break; unlocked.remove(p.getUniqueId());
case 3: }
p.sendData(FMLHS, new byte[]{-1, 2}); }, 30, TimeUnit.SECONDS);
break; }
case 4:
p.sendData(FMLHS, new byte[]{-1, 3});
break; break;
default: default:
break; break;
} }
break;
case 1:
default:
break;
}
}
private static void registerId(ByteBuf bb, int id, String name){
bb.writeByte(name.length());
bb.writeCharSequence(name, StandardCharsets.UTF_8);
bb.writeByte(id);
if(id > 127)
bb.writeByte(1);
} }
} }

Datei anzeigen

@ -34,7 +34,7 @@ class Utils {
return new Pair<>(numRead, result); return new Pair<>(numRead, result);
} }
static void handleMods(ProxiedPlayer player, List<Mod> mods){ static boolean handleMods(ProxiedPlayer player, List<Mod> mods){
ModType max = ModType.YELLOW; ModType max = ModType.YELLOW;
Iterator<Mod> it = mods.iterator(); Iterator<Mod> it = mods.iterator();
while(it.hasNext()){ while(it.hasNext()){
@ -46,7 +46,7 @@ class Utils {
} }
if(mods.isEmpty()) if(mods.isEmpty())
return; return true;
if(mods.size() == 1){ if(mods.size() == 1){
if(max == ModType.YELLOW) if(max == ModType.YELLOW)
@ -62,5 +62,7 @@ class Utils {
else else
SteamwarUser.get(player.getUniqueId()).ban(Timestamp.from(Instant.now().plus(1, ChronoUnit.DAYS)), "Versuchte Benutzung der Mods\n" + sb.toString()); SteamwarUser.get(player.getUniqueId()).ban(Timestamp.from(Instant.now().plus(1, ChronoUnit.DAYS)), "Versuchte Benutzung der Mods\n" + sb.toString());
} }
return false;
} }
} }