60 lines
2 KiB
Java
60 lines
2 KiB
Java
package net.minecraft.client.multiplayer.chat.report;
|
|
|
|
import com.mojang.authlib.yggdrasil.request.AbuseReportRequest.ClientInfo;
|
|
import com.mojang.authlib.yggdrasil.request.AbuseReportRequest.RealmInfo;
|
|
import com.mojang.authlib.yggdrasil.request.AbuseReportRequest.ThirdPartyServerInfo;
|
|
import com.mojang.realmsclient.dto.RealmsServer;
|
|
import java.util.Locale;
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.multiplayer.chat.report.ReportEnvironment.Server.Realm;
|
|
import net.minecraft.client.multiplayer.chat.report.ReportEnvironment.Server.ThirdParty;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public record ReportEnvironment(String clientVersion, @Nullable ReportEnvironment.Server server) {
|
|
public static ReportEnvironment local() {
|
|
return create(null);
|
|
}
|
|
|
|
public static ReportEnvironment thirdParty(String ip) {
|
|
return create(new ThirdParty(ip));
|
|
}
|
|
|
|
public static ReportEnvironment realm(RealmsServer realmsServer) {
|
|
return create(new Realm(realmsServer));
|
|
}
|
|
|
|
public static ReportEnvironment create(@Nullable ReportEnvironment.Server server) {
|
|
return new ReportEnvironment(getClientVersion(), server);
|
|
}
|
|
|
|
public ClientInfo clientInfo() {
|
|
return new ClientInfo(this.clientVersion, Locale.getDefault().toLanguageTag());
|
|
}
|
|
|
|
@Nullable
|
|
public ThirdPartyServerInfo thirdPartyServerInfo() {
|
|
return this.server instanceof ThirdParty thirdParty ? new ThirdPartyServerInfo(thirdParty.ip) : null;
|
|
}
|
|
|
|
@Nullable
|
|
public RealmInfo realmInfo() {
|
|
return this.server instanceof Realm realm ? new RealmInfo(String.valueOf(realm.realmId()), realm.slotId()) : null;
|
|
}
|
|
|
|
private static String getClientVersion() {
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
stringBuilder.append("1.21.5");
|
|
if (Minecraft.checkModStatus().shouldReportAsModified()) {
|
|
stringBuilder.append(" (modded)");
|
|
}
|
|
|
|
return stringBuilder.toString();
|
|
}
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public interface Server {
|
|
}
|
|
}
|