Skip to content

Commit

Permalink
1.21 Add UUID Fix With issue:#16
Browse files Browse the repository at this point in the history
  • Loading branch information
Satxm committed Aug 17, 2024
1 parent 3953221 commit b1f3d54
Show file tree
Hide file tree
Showing 25 changed files with 448 additions and 142 deletions.
1 change: 1 addition & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "com.google.code.findbugs:jsr305:3.0.2"
}

sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.PauseScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.commands.BanIpCommands;
Expand All @@ -20,8 +19,6 @@
import net.minecraft.server.commands.DeOpCommands;
import net.minecraft.server.commands.OpCommand;
import net.minecraft.server.commands.WhitelistCommand;
import net.minecraft.server.players.PlayerList;
import io.github.satxm.mcwifipnp.mixin.PlayerListAccessor;

public class MCWiFiPnP implements ModInitializer {
public static final String MODID = "mcwifipnp";
Expand All @@ -39,6 +36,7 @@ public void onInitialize() {
BanIpCommands.register(dispatcher);
BanListCommands.register(dispatcher);
BanPlayerCommands.register(dispatcher);
OfflinePlayerCommand.register(dispatcher);
});
}

Expand All @@ -65,9 +63,4 @@ private void onServerStop(MinecraftServer server) {
MCWiFiPnPUnit.CloseUPnPPort(server);
}

public static void setMaxPlayers(IntegratedServer server, int num) {
PlayerList playerList = server.getPlayerList();
((PlayerListAccessor) playerList).setMaxPlayers(num);
}

}
14 changes: 12 additions & 2 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
id 'org.spongepowered.mixin' version '0.7.+'
}

java.toolchain.languageVersion = JavaLanguageVersion.of(21)
Expand All @@ -21,8 +22,6 @@ minecraft {

copyIdeResources = true

accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

runs {

configureEach {
Expand All @@ -48,7 +47,9 @@ minecraft {

dependencies {
minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
annotationProcessor "org.spongepowered:mixin:0.8.5:processor"
implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
implementation "com.google.code.findbugs:jsr305:3.0.2"
}

sourceSets {
Expand All @@ -63,6 +64,15 @@ sourceSets {
}
}

mixin {
// MixinGradle Settings
add sourceSets.main, 'mcwifipnp.refmap.json'
config 'mcwifipnp.mixins.json'

debug.verbose = true
debug.export = true
}

tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
mod_version : project.mod_version,
Expand Down
7 changes: 0 additions & 7 deletions forge/src/main/java/io/github/satxm/mcwifipnp/MCWiFiPnP.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.PauseScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.network.chat.Component;
import net.minecraft.server.commands.BanIpCommands;
import net.minecraft.server.commands.BanListCommands;
import net.minecraft.server.commands.BanPlayerCommands;
import net.minecraft.server.commands.DeOpCommands;
import net.minecraft.server.commands.OpCommand;
import net.minecraft.server.commands.WhitelistCommand;
import net.minecraft.server.players.PlayerList;
import net.minecraftforge.client.event.ScreenEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegisterCommandsEvent;
Expand Down Expand Up @@ -57,11 +55,6 @@ public void onServerStopping(ServerStoppingEvent event) {
MCWiFiPnPUnit.CloseUPnPPort(event.getServer());
}

public static void setMaxPlayers(IntegratedServer server, int num) {
PlayerList playerList = server.getPlayerList();
playerList.maxPlayers = num;
}

public static void onAfterInitScreen(Minecraft client, Screen screen, List<GuiEventListener> children,
Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove) {
if (screen instanceof PauseScreen pauseScreen && screen.getClass() == PauseScreen.class) {
Expand Down
5 changes: 1 addition & 4 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ repositories {
}

minecraft {
accessTransformers {
file('src/main/resources/META-INF/accesstransformer.cfg')
}

runs {
configureEach {
workingDirectory project.file('run')
Expand All @@ -43,6 +39,7 @@ minecraft {

dependencies {
implementation "net.neoforged:neoforge:${project.neo_version}"
implementation "com.google.code.findbugs:jsr305:3.0.2"
}

sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.PauseScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.network.chat.Component;
import net.minecraft.server.commands.BanIpCommands;
import net.minecraft.server.commands.BanListCommands;
import net.minecraft.server.commands.BanPlayerCommands;
import net.minecraft.server.commands.DeOpCommands;
import net.minecraft.server.commands.OpCommand;
import net.minecraft.server.commands.WhitelistCommand;
import net.minecraft.server.players.PlayerList;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
Expand Down Expand Up @@ -59,11 +57,6 @@ public void onServerStopping(ServerStoppingEvent event) {
MCWiFiPnPUnit.CloseUPnPPort(event.getServer());
}

public static void setMaxPlayers(IntegratedServer server, int num) {
PlayerList playerList = server.getPlayerList();
playerList.maxPlayers = num;
}

public static void onAfterInitScreen(Minecraft client, Screen screen, List<GuiEventListener> children,
Consumer<GuiEventListener> add, Consumer<GuiEventListener> remove) {
if (screen instanceof PauseScreen pauseScreen && screen.getClass() == PauseScreen.class) {
Expand Down
8 changes: 4 additions & 4 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ logoFile="mcwifipnp.png"
authors="Satxm"
description="A Minecraft LAN World Tool With WLAN UPnP."

#[[mixins]]
#config="mcwifipnp.mixins.json"
[[mixins]]
config="mcwifipnp.mixins.json"

[[accessTransformers]]
file="META-INF/accesstransformer.cfg"
#[[accessTransformers]]
#file="META-INF/accesstransformer.cfg"

[[dependencies.mcwifipnp]]
modId="neoforge"
Expand Down
3 changes: 1 addition & 2 deletions quilt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ dependencies {
officialMojangMappings()
}
modImplementation "org.quiltmc:quilt-loader:${project.quilt_loader_version}"

modImplementation "org.quiltmc:qsl:${project.qsl_version}"

modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${qfapi_version}"
modImplementation "com.google.code.findbugs:jsr305:3.0.2"
}

sourceSets {
Expand Down
8 changes: 0 additions & 8 deletions quilt/src/main/java/io/github/satxm/mcwifipnp/MCWiFiPnP.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.PauseScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.commands.BanIpCommands;
Expand All @@ -21,8 +20,6 @@
import net.minecraft.server.commands.DeOpCommands;
import net.minecraft.server.commands.OpCommand;
import net.minecraft.server.commands.WhitelistCommand;
import net.minecraft.server.players.PlayerList;
import io.github.satxm.mcwifipnp.mixin.PlayerListAccessor;

public class MCWiFiPnP implements ModInitializer {
public static final String MODID = "mcwifipnp";
Expand Down Expand Up @@ -66,9 +63,4 @@ private void onServerStop(MinecraftServer server) {
MCWiFiPnPUnit.CloseUPnPPort(server);
}

public static void setMaxPlayers(IntegratedServer server, int num) {
PlayerList playerList = server.getPlayerList();
((PlayerListAccessor) playerList).setMaxPlayers(num);
}

}

This file was deleted.

12 changes: 0 additions & 12 deletions quilt/src/main/resources/mcwifipnp.mixins.json

This file was deleted.

16 changes: 7 additions & 9 deletions src/main/java/io/github/satxm/mcwifipnp/MCWiFiPnPUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.WeakHashMap;
import java.util.*;

import io.github.satxm.mcwifipnp.mixin.PlayerListAccessor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -54,7 +49,6 @@ public class MCWiFiPnPUnit {
public static Config getConfig(MinecraftServer server) {
return Objects.requireNonNull(configMap.get(server), "no config for server???");
}


public static void OpenToLan() {
Minecraft client = Minecraft.getInstance();
Expand All @@ -67,13 +61,15 @@ public static void OpenToLan() {
? PublishCommand.getSuccessMessage(cfg.port)
: Component.translatable("commands.publish.failed");
client.gui.getChat().addMessage(component);
MCWiFiPnP.setMaxPlayers(server,cfg.maxPlayers);
((PlayerListAccessor) playerList).setMaxPlayers(cfg.maxPlayers);
server.setUsesAuthentication(cfg.OnlineMode);
server.setPvpAllowed(cfg.PvP);
server.setEnforceWhitelist(cfg.Whitelist);
playerList.setUsingWhiteList(cfg.Whitelist);
playerList.getOps().add(new ServerOpListEntry(server.getSingleplayerProfile(), 4, playerList.canBypassPlayerLimit(server.getSingleplayerProfile())));
playerList.setAllowCommandsForAllPlayers(cfg.AllPlayersCheats);
UUIDFixer.EnableUUIDFix = cfg.EnableUUIDFix;
UUIDFixer.alwaysOfflinePlayers = cfg.alwaysOfflinePlayers;

new Thread(() -> {
MCWiFiPnPUnit.UseUPnP(cfg, client);
Expand Down Expand Up @@ -196,6 +192,8 @@ public static class Config {
public boolean UseUPnP = true;
public boolean AllowCommands = false;
public boolean OnlineMode = true;
public boolean EnableUUIDFix = false;
public List<String> alwaysOfflinePlayers = Collections.emptyList();
public boolean PvP = true;
public boolean CopyToClipboard = true;
public transient Path location;
Expand Down
Loading

0 comments on commit b1f3d54

Please sign in to comment.