Skip to content

Commit

Permalink
Add UUID Fixer Module
Browse files Browse the repository at this point in the history
  • Loading branch information
Satxm committed Aug 18, 2024
1 parent 7cb45e6 commit a3625a4
Show file tree
Hide file tree
Showing 29 changed files with 1,479 additions and 1,134 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[3]: https://img.shields.io/curseforge/dt/450250?label=CurseForge%0aDownloads&logo=curseforge&style=flat&color=E36639&labelcolor=2D2D2D
[4]: https://www.curseforge.com/minecraft/mc-mods/mcwifipnp

[5]: https://img.shields.io/badge/Available%20for-%201.15%20to%201.20-47376F?logo=files&color=377BCB&labelcolor=2D2D2D
[5]: https://img.shields.io/badge/Available%20for-%201.15%20to%201.21-47376F?logo=files&color=377BCB&labelcolor=2D2D2D
[6]: https://modrinth.com/mod/mcwifipnp/versions

[7]: https://img.shields.io/github/license/Satxm/mcwifipnp?label=License&logo=github&style=flat&color=E51050&labelcolor=2D2D2D
Expand Down Expand Up @@ -58,6 +58,18 @@ Modified from [TheGlitch76/mcpnp](https://github.com/TheGlitch76/mcpnp) project

## What Can It Do - 它的作用

Added UUID Fixer module, which allows offline players to obtain a unique UUID from the Mojang server, keeping the UUID fixed and not changing due to client changes.

添加了 UUID 修复模块,对于离线玩家,可以使离线玩家从 Mojang 服务器获取唯一的 UUID,使 UUID 固定,不会因为客户端变化而变化。

Added a new command `/forceoffline` to control whether players are forced into offline mode without obtaining UUIDs from Mojang servers. `/forceoffline list` command can list players who in the force offline list, `/forceoffline add` command can add players to the force offline list, `/forceoffline remove` command can remove players from the force offline list.

添加了一个新指令 `/forceoffline` 以便于控制玩家是否强制玩家为离线模式,不从 Mojang 服务器获取 UUID。`/forceoffline list` 指令可以查看列表中玩家,`/forceoffline add` 指令可以添加玩家到列表,`/forceoffline remove` 指令可以从列表中移除玩家。

For the `Oline Mode` button, there are now three options: 'Enable': enable genuine verification, which will verify login information against the Mojang server database, only allowing players who login with a Microsoft account to join, `Disable`: not verify login information, allows offline players to join, `Disable + UUID Fixer`: Attempt to match the Mojang server user name with the player name for offline mode players to obtain a unique UUID, Meanwhile, UUIDs are retained for users logging in with Microsoft accounts, It can also prevent the loss of backpack and inventory items.

对于`正版验证`按钮,现在有三个选项:`启用`:启用正版验证,将会比对Mojang服务器数据库验证登录信息,即只允许使用微软帐户登录的玩家加入;`禁用`:即不验证登录信息,允许使用离线模式登录的玩家加入;`禁用 + 修复UUID`:尝试使用离线模式登录的玩家名匹配Mojang服务器用户名称以获取唯一UUID,同时为使用微软帐户登录的用户保留UUID,它也可以防止背包和物品栏内容丢失。

Allows you to change the port number of the LAN world and choose whether to map this port to the public network using UPnP (if your router supports UPnP).

允许你修改局域网世界的端口号,并选择是否映射这个端口使用UPnP映射到公网(如果你的路由器支持UPnP)。
Expand Down
44 changes: 22 additions & 22 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '0.12-SNAPSHOT'
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_16
Expand All @@ -9,43 +9,43 @@ version = project.mod_version + "-" + project.minecraft_version + "-fabric"
group = project.maven_group

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "com.google.code.findbugs:jsr305:3.0.2"
}

sourceSets {
main {
java {
srcDir "../src/main/java"
}
resources {
srcDir "../src/main/resources"
}
main {
java {
srcDir "../src/main/java"
}
resources {
srcDir "../src/main/resources"
}
}
}

jar {
from("../LICENSE") {
}
from("../LICENSE") {
}
}

java {
withSourcesJar()
withSourcesJar()
}

processResources {
inputs.property "version", project.version
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.mod_version,'mc_version': project.fabric_minecraft_version_range, 'fabric_version': project.fabric_version_range, "loader_version": project.fabric_loader_version_range
}
filesMatching("fabric.mod.json") {
expand "version": project.mod_version,'mc_version': project.fabric_minecraft_version_range, 'fabric_version': project.fabric_version_range, "loader_version": project.fabric_loader_version_range
}
}

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 16
it.options.encoding = "UTF-8"
it.options.release = 16
}
78 changes: 35 additions & 43 deletions fabric/src/main/java/io/github/satxm/mcwifipnp/MCWiFiPnP.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.github.satxm.mcwifipnp;
import java.util.List;

import io.github.satxm.mcwifipnp.mixin.PlayerListAccessor;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.Screens;
Expand All @@ -12,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.TranslatableComponent;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.commands.BanIpCommands;
Expand All @@ -21,55 +19,49 @@
import net.minecraft.server.commands.DeOpCommands;
import net.minecraft.server.commands.OpCommand;
import net.minecraft.server.commands.WhitelistCommand;
import net.minecraft.server.players.PlayerList;

public class MCWiFiPnP implements ModInitializer {
public static final String MODID = "mcwifipnp";
public static final String MODID = "mcwifipnp";

@Override
public void onInitialize() {
ServerLifecycleEvents.SERVER_STARTING.register(this::onServerLoad);
ServerLifecycleEvents.SERVER_STOPPING.register(this::onServerStop);
ScreenEvents.AFTER_INIT.register(MCWiFiPnP::afterScreenInit);
@Override
public void onInitialize() {
ServerLifecycleEvents.SERVER_STARTING.register(this::onServerLoad);
ServerLifecycleEvents.SERVER_STOPPING.register(this::onServerStop);
ScreenEvents.AFTER_INIT.register(MCWiFiPnP::afterScreenInit);

CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
DeOpCommands.register(dispatcher);
OpCommand.register(dispatcher);
WhitelistCommand.register(dispatcher);
BanIpCommands.register(dispatcher);
BanListCommands.register(dispatcher);
BanPlayerCommands.register(dispatcher);
});
}
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
DeOpCommands.register(dispatcher);
OpCommand.register(dispatcher);
WhitelistCommand.register(dispatcher);
BanIpCommands.register(dispatcher);
BanListCommands.register(dispatcher);
BanPlayerCommands.register(dispatcher);
ForceOfflineCommand.register(dispatcher);
});
}

public static void afterScreenInit(Minecraft client, Screen screen, int i, int j) {
if (screen instanceof PauseScreen) {
final List<AbstractWidget> buttons = Screens.getButtons(screen);
for (int k = 0; k < buttons.size(); k++) {
AbstractWidget ShareToLanOld = buttons.get(k);
if (buttons.size() != 0 && ShareToLanOld.getMessage().getString()
.equals(new TranslatableComponent("menu.shareToLan").getString())) {
AbstractWidget ShareToLanNew = new Button(ShareToLanOld.x, ShareToLanOld.y, ShareToLanOld.getWidth(), ShareToLanOld.getHeight(),new TranslatableComponent("menu.shareToLan"),
(button) -> client.setScreen(new ShareToLanScreenNew(screen)));
ShareToLanNew.active = ShareToLanOld.active;
buttons.remove(ShareToLanOld);
buttons.add(ShareToLanNew);
}
}
public static void afterScreenInit(Minecraft client, Screen screen, int i, int j) {
if (screen instanceof PauseScreen) {
final List<AbstractWidget> buttons = Screens.getButtons(screen);
for (int k = 0; k < buttons.size(); k++) {
AbstractWidget ShareToLanOld = buttons.get(k);
if (buttons.size() != 0 && ShareToLanOld.getMessage().getString().equals(new TranslatableComponent("menu.shareToLan").getString())) {
AbstractWidget ShareToLanNew = new Button(ShareToLanOld.x, ShareToLanOld.y, ShareToLanOld.getWidth(), ShareToLanOld.getHeight(),new TranslatableComponent("menu.shareToLan"),
(button) -> client.setScreen(new ShareToLanScreenNew(screen)));
ShareToLanNew.active = ShareToLanOld.active;
buttons.remove(ShareToLanOld);
buttons.add(ShareToLanNew);
}
}
}
}

private void onServerLoad(MinecraftServer server) {
MCWiFiPnPUnit.ReadingConfig(server);
}
private void onServerLoad(MinecraftServer server) {
MCWiFiPnPUnit.ReadingConfig(server);
}

private void onServerStop(MinecraftServer server) {
MCWiFiPnPUnit.CloseUPnPPort(server);
}

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

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

This file was deleted.

117 changes: 65 additions & 52 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
plugins {
id 'eclipse'
id 'idea'
id 'net.minecraftforge.gradle' version '5.1+'
id 'eclipse'
id 'idea'
id 'net.minecraftforge.gradle' version '5.1+'
id 'org.spongepowered.mixin' version '0.7.+'
}

archivesBaseName = project.archives_base_name
Expand All @@ -13,86 +14,98 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(16)
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

minecraft {
mappings channel: 'official', version: project.minecraft_version
mappings channel: 'official', version: project.minecraft_version

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

runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'

mods {
mcwifipnp {
source sourceSets.main
}
}
mods {
mcwifipnp {
source sourceSets.main
}
}
}
}
}

dependencies {
minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}

afterEvaluate {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "2000"
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "2000"
}
}

sourceSets {
main {
java {
srcDir "../src/main/java"
}
resources {
srcDir "../src/main/resources"
}
main {
java {
srcDir "../src/main/java"
}
resources {
srcDir "../src/main/resources"
}
}
}


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

debug.verbose = true
debug.export = true
}

jar {
manifest {
attributes([
"Specification-Title": "LAN World Plug-n-Play",
"Specification-Vendor": "Satxm",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor": "Satxm",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
])
}
from("../LICENSE") {
}
manifest {
attributes([
"Specification-Title": "LAN World Plug-n-Play",
"Specification-Vendor": "Satxm",
"Specification-Version": "1",
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor": "Satxm",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs": "mcwifipnp.mixins.json"
])
}
from("../LICENSE") {
}
}

java {
withSourcesJar()
withSourcesJar()
}

def replaceResources = tasks.register("replaceResources", Copy) {
it.outputs.upToDateWhen { false }
it.from(sourceSets.main.resources) {
include "META-INF/mods.toml"
expand 'version': project.mod_version, 'mc_version': project.forge_minecraft_version_range, 'forge_version': project.forge_version_range, "loader_version": project.forge_version_range
}
it.into "$buildDir/resources/main/"
it.outputs.upToDateWhen { false }
it.from(sourceSets.main.resources) {
include "META-INF/mods.toml"
expand 'version': project.mod_version, 'mc_version': project.forge_minecraft_version_range, 'forge_version': project.forge_version_range, "loader_version": project.forge_version_range
}
it.into "$buildDir/resources/main/"
}

processResources {
duplicatesStrategy(DuplicatesStrategy.FAIL)
exclude('META-INF/mods.toml')
configure { finalizedBy(replaceResources) }
duplicatesStrategy(DuplicatesStrategy.FAIL)
exclude('META-INF/mods.toml')
configure { finalizedBy(replaceResources) }
}

classes.configure {
dependsOn(replaceResources)
dependsOn(replaceResources)
}

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 16
it.options.encoding = "UTF-8"
it.options.release = 16
}
Loading

0 comments on commit a3625a4

Please sign in to comment.