mirror of
https://github.com/Aizistral-Studios/No-Chat-Restrictions.git
synced 2026-02-04 05:38:24 +00:00
Update mixins and code for 1.18.2
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
package com.aizistral.nochatrestrictions.core;
|
||||
|
||||
import java.util.UUID;
|
||||
import com.mojang.authlib.minecraft.SocialInteractionsService;
|
||||
|
||||
public class WrappedSocialInteractionsService implements SocialInteractionsService {
|
||||
private final SocialInteractionsService service;
|
||||
|
||||
public WrappedSocialInteractionsService(SocialInteractionsService service) {
|
||||
if (service == null)
|
||||
throw new NullPointerException("'service' argument cannot be null!");
|
||||
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean serversAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean realmsAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chatAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean telemetryAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockedPlayer(UUID playerID) {
|
||||
return this.service.isBlockedPlayer(playerID);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.aizistral.nochatrestrictions.core;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.authlib.minecraft.TelemetrySession;
|
||||
import com.mojang.authlib.minecraft.UserApiService;
|
||||
|
||||
public class WrappedUserApiService implements UserApiService {
|
||||
private static final UserProperties FORCED_PROPERTIES;
|
||||
|
||||
static {
|
||||
ImmutableSet.Builder<UserFlag> flags = ImmutableSet.builder();
|
||||
|
||||
flags.add(UserFlag.CHAT_ALLOWED); // always let the player access chat
|
||||
flags.add(UserFlag.SERVERS_ALLOWED); // always let the player open multiplayer menu
|
||||
flags.add(UserFlag.REALMS_ALLOWED); // always let the player open Realms menu
|
||||
// flags.add(UserFlag.TELEMETRY_ENABLED); // not adding this for obvious reasons
|
||||
// flags.add(UserFlag.PROFANITY_FILTER_ENABLED) // not adding this one either
|
||||
|
||||
FORCED_PROPERTIES = new UserProperties(flags.build());
|
||||
}
|
||||
|
||||
private final UserApiService service;
|
||||
|
||||
public WrappedUserApiService(UserApiService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProperties properties() {
|
||||
return FORCED_PROPERTIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockedPlayer(UUID playerID) {
|
||||
return this.service.isBlockedPlayer(playerID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshBlockList() {
|
||||
this.service.refreshBlockList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TelemetrySession newTelemetrySession(Executor executor) {
|
||||
return TelemetrySession.DISABLED;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.aizistral.nochatrestrictions.core.NCRCore;
|
||||
import com.aizistral.nochatrestrictions.core.WrappedSocialInteractionsService;
|
||||
import com.mojang.authlib.minecraft.SocialInteractionsService;
|
||||
import com.aizistral.nochatrestrictions.core.WrappedUserApiService;
|
||||
import com.mojang.authlib.minecraft.UserApiService;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -16,14 +16,14 @@ import net.minecraft.client.main.GameConfig;
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft {
|
||||
|
||||
@Inject(method = { "func_244735_a", "createSocialInteractions" }, at = @At("RETURN"), cancellable = true)
|
||||
public void onCreateSocialInteractions(YggdrasilAuthenticationService authService, GameConfig gameConfig,
|
||||
CallbackInfoReturnable<SocialInteractionsService> info) {
|
||||
SocialInteractionsService returnedService = info.getReturnValue();
|
||||
@Inject(method = { "m_193585_", "createUserApiService" }, at = @At("RETURN"), cancellable = true)
|
||||
public void onCreateUserApi(YggdrasilAuthenticationService authService, GameConfig gameConfig,
|
||||
CallbackInfoReturnable<UserApiService> info) {
|
||||
UserApiService returnedService = info.getReturnValue();
|
||||
assert returnedService != null;
|
||||
info.setReturnValue(new WrappedSocialInteractionsService(returnedService));
|
||||
info.setReturnValue(new WrappedUserApiService(returnedService));
|
||||
|
||||
NCRCore.LOGGER.info("Successfully supplanted SocialInteractionsService with a wrapped version.");
|
||||
NCRCore.LOGGER.info("Successfully supplanted UserApiService with a wrapped version.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.aizistral.nochatrestrictions.core;
|
||||
|
||||
import java.util.UUID;
|
||||
import com.mojang.authlib.minecraft.SocialInteractionsService;
|
||||
|
||||
public class WrappedSocialInteractionsService implements SocialInteractionsService {
|
||||
private final SocialInteractionsService service;
|
||||
|
||||
public WrappedSocialInteractionsService(SocialInteractionsService service) {
|
||||
if (service == null)
|
||||
throw new NullPointerException("'service' argument cannot be null!");
|
||||
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean serversAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean realmsAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean chatAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean telemetryAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockedPlayer(UUID playerID) {
|
||||
return this.service.isBlockedPlayer(playerID);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.aizistral.nochatrestrictions.core;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.authlib.minecraft.TelemetrySession;
|
||||
import com.mojang.authlib.minecraft.UserApiService;
|
||||
|
||||
public class WrappedUserApiService implements UserApiService {
|
||||
private static final UserProperties FORCED_PROPERTIES;
|
||||
|
||||
static {
|
||||
ImmutableSet.Builder<UserFlag> flags = ImmutableSet.builder();
|
||||
|
||||
flags.add(UserFlag.CHAT_ALLOWED); // always let the player access chat
|
||||
flags.add(UserFlag.SERVERS_ALLOWED); // always let the player open multiplayer menu
|
||||
flags.add(UserFlag.REALMS_ALLOWED); // always let the player open Realms menu
|
||||
// flags.add(UserFlag.TELEMETRY_ENABLED); // not adding this for obvious reasons
|
||||
// flags.add(UserFlag.PROFANITY_FILTER_ENABLED) // not adding this one either
|
||||
|
||||
FORCED_PROPERTIES = new UserProperties(flags.build());
|
||||
}
|
||||
|
||||
private final UserApiService service;
|
||||
|
||||
public WrappedUserApiService(UserApiService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProperties properties() {
|
||||
return FORCED_PROPERTIES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockedPlayer(UUID playerID) {
|
||||
return this.service.isBlockedPlayer(playerID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshBlockList() {
|
||||
this.service.refreshBlockList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TelemetrySession newTelemetrySession(Executor executor) {
|
||||
return TelemetrySession.DISABLED;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.aizistral.nochatrestrictions.core.NCRCore;
|
||||
import com.aizistral.nochatrestrictions.core.WrappedSocialInteractionsService;
|
||||
import com.mojang.authlib.minecraft.SocialInteractionsService;
|
||||
import com.aizistral.nochatrestrictions.core.WrappedUserApiService;
|
||||
import com.mojang.authlib.minecraft.UserApiService;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -16,14 +16,14 @@ import net.minecraft.client.main.GameConfig;
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft {
|
||||
|
||||
@Inject(method = { "func_244735_a", "createSocialInteractions" }, at = @At("RETURN"), cancellable = true)
|
||||
public void onCreateSocialInteractions(YggdrasilAuthenticationService authService, GameConfig gameConfig,
|
||||
CallbackInfoReturnable<SocialInteractionsService> info) {
|
||||
SocialInteractionsService returnedService = info.getReturnValue();
|
||||
@Inject(method = { "m_193585_", "createUserApiService" }, at = @At("RETURN"), cancellable = true)
|
||||
public void onCreateUserApi(YggdrasilAuthenticationService authService, GameConfig gameConfig,
|
||||
CallbackInfoReturnable<UserApiService> info) {
|
||||
UserApiService returnedService = info.getReturnValue();
|
||||
assert returnedService != null;
|
||||
info.setReturnValue(new WrappedSocialInteractionsService(returnedService));
|
||||
info.setReturnValue(new WrappedUserApiService(returnedService));
|
||||
|
||||
NCRCore.LOGGER.info("Successfully supplanted SocialInteractionsService with a wrapped version.");
|
||||
NCRCore.LOGGER.info("Successfully supplanted UserApiService with a wrapped version.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user