mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 18:46:15 +00:00
refactor: use Wrap* for mixins
refactor: remove TransactionManager since it's unused refactor: fix some warnings about ClientPlayNetworkHandler being nullable and some more stuff i might have forgor to put here more stuff coming in the next commits !!!
This commit is contained in:
parent
bb8bb88489
commit
1afb5583b4
13 changed files with 158 additions and 125 deletions
|
|
@ -52,6 +52,8 @@ public class ChatInputSuggestorMixin {
|
|||
public void refresh(CallbackInfo ci) {
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
|
||||
if (this.textField == null) return;
|
||||
|
||||
final String text = this.textField.getText();
|
||||
final int cursor = this.textField.getCursor();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
|
||||
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
|
||||
|
|
@ -35,8 +37,8 @@ public abstract class ChatScreenMixin {
|
|||
chatField.setMaxLength(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true)
|
||||
private void sendMessage(String chatText, boolean addToHistory, CallbackInfo cir) {
|
||||
@WrapMethod(method = "sendMessage")
|
||||
private void sendMessage(final String chatText, final boolean addToHistory, final Operation<Void> original) {
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
if (addToHistory) {
|
||||
|
|
@ -67,7 +69,7 @@ public abstract class ChatScreenMixin {
|
|||
connection.getInputStream().close();
|
||||
connection.disconnect();
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
ChipmunkMod.LOGGER.error("Error while trying to request TestBot webhook", e);
|
||||
}
|
||||
});
|
||||
} else if (chatText.startsWith(ChipmunkMod.CONFIG.bots.chomens.prefix)) {
|
||||
|
|
@ -95,9 +97,6 @@ public abstract class ChatScreenMixin {
|
|||
) {
|
||||
try {
|
||||
BotValidationUtilities.chomens(chatText.substring(prefixLength));
|
||||
|
||||
cir.cancel();
|
||||
|
||||
return;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
|
@ -112,6 +111,6 @@ public abstract class ChatScreenMixin {
|
|||
client.player.networkHandler.sendChatMessage(chatText);
|
||||
}
|
||||
|
||||
cir.cancel();
|
||||
// :D
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.network.PacketCallbacks;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket;
|
||||
|
|
@ -14,9 +17,6 @@ import net.minecraft.sound.SoundEvent;
|
|||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
|
@ -28,26 +28,24 @@ public class ClientConnectionMixin {
|
|||
@Unique
|
||||
private static final Pattern CUSTOM_PITCH_PATTERN = Pattern.compile(".*\\.pitch\\.(.*)");
|
||||
|
||||
@Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true)
|
||||
private void exceptionCaught(ChannelHandlerContext context, Throwable ex, CallbackInfo ci) {
|
||||
ci.cancel();
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@Inject(method = "handlePacket", at = @At("HEAD"), cancellable = true)
|
||||
private static void handlePacket(Packet<?> packet, PacketListener _listener, CallbackInfo ci) {
|
||||
@WrapMethod(method = "handlePacket")
|
||||
private static <T extends PacketListener> void handlePacket(
|
||||
final Packet<T> packet,
|
||||
final PacketListener packetListener,
|
||||
final Operation<Void> original
|
||||
) {
|
||||
for (Listener listener : ListenerManager.listeners) {
|
||||
listener.packetReceived(packet);
|
||||
}
|
||||
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
// please don't skid this.,.
|
||||
// mabe mabe mabe
|
||||
if (packet instanceof ParticleS2CPacket t_packet) {
|
||||
if (t_packet.getCount() > MAX_PARTICLES_PER_PACKET) {
|
||||
ci.cancel();
|
||||
}
|
||||
// this check is very easy to bypass in 2025
|
||||
if (
|
||||
packet instanceof ParticleS2CPacket t_packet
|
||||
&& t_packet.getCount() > MAX_PARTICLES_PER_PACKET
|
||||
) {
|
||||
return;
|
||||
} else if (packet instanceof PlaySoundS2CPacket t_packet) {
|
||||
final SoundEvent soundEvent = t_packet.getSound().value();
|
||||
|
||||
|
|
@ -55,7 +53,10 @@ public class ClientConnectionMixin {
|
|||
|
||||
final Matcher matcher = CUSTOM_PITCH_PATTERN.matcher(sound.getPath());
|
||||
|
||||
if (!matcher.find()) return;
|
||||
if (!matcher.find()) {
|
||||
original.call(packet, packetListener);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final String stringPitch = matcher.group(1);
|
||||
|
|
@ -64,7 +65,10 @@ public class ClientConnectionMixin {
|
|||
|
||||
final ClientWorld world = client.world;
|
||||
|
||||
if (world == null) return;
|
||||
if (world == null) {
|
||||
original.call(packet, packetListener);
|
||||
return;
|
||||
}
|
||||
|
||||
final SoundEvent newSound = SoundEvent.of(
|
||||
Identifier.of(
|
||||
|
|
@ -89,26 +93,33 @@ public class ClientConnectionMixin {
|
|||
t_packet.getSeed()
|
||||
));
|
||||
|
||||
ci.cancel();
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (t_packet.getVolume() == 1 && sound.getPath().equals("entity.enderman.scream")) ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true)
|
||||
private void sendPacket(Packet<?> packet, CallbackInfo ci) {
|
||||
if (packet instanceof RequestCommandCompletionsC2SPacket t_packet) {
|
||||
if (t_packet.getPartialCommand().length() > 2048) {
|
||||
ci.cancel();
|
||||
return;
|
||||
} catch (NumberFormatException e) {
|
||||
ChipmunkMod.LOGGER.error("Failed to parse custom pitch", e);
|
||||
}
|
||||
|
||||
if (t_packet.getVolume() == 1 && sound.getPath().equals("entity.enderman.scream")) return;
|
||||
}
|
||||
|
||||
original.call(packet, packetListener);
|
||||
}
|
||||
|
||||
@WrapMethod(method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;Z)V")
|
||||
private void sendPacket(
|
||||
final Packet<?> packet,
|
||||
final PacketCallbacks callbacks,
|
||||
final boolean flush,
|
||||
final Operation<Void> original
|
||||
) {
|
||||
if (
|
||||
packet instanceof RequestCommandCompletionsC2SPacket t_packet
|
||||
&& t_packet.getPartialCommand().length() > 2048
|
||||
) return;
|
||||
|
||||
for (Listener listener : ListenerManager.listeners) {
|
||||
listener.packetSent(packet);
|
||||
}
|
||||
|
||||
original.call(packet, callbacks, flush);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||
|
|
@ -7,14 +10,16 @@ import land.chipmunk.chipmunkmod.listeners.Listener;
|
|||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import land.chipmunk.chipmunkmod.modules.*;
|
||||
import land.chipmunk.chipmunkmod.modules.custom_chat.CustomChat;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.message.MessageHandler;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket;
|
||||
import net.minecraft.registry.DynamicRegistryManager;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
import net.minecraft.text.PlainTextContent;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableTextContent;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
|
@ -24,7 +29,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = net.minecraft.client.network.ClientPlayNetworkHandler.class, priority = 1001)
|
||||
@Mixin(value = ClientPlayNetworkHandler.class, priority = 1001)
|
||||
public class ClientPlayNetworkHandlerMixin {
|
||||
@Final
|
||||
@Shadow
|
||||
|
|
@ -54,62 +59,73 @@ public class ClientPlayNetworkHandlerMixin {
|
|||
KaboomCheck.INSTANCE.onCommandTree(this.commandDispatcher);
|
||||
}
|
||||
|
||||
@Inject(method = "onGameMessage", at = @At("HEAD"), cancellable = true)
|
||||
private void onGameMessage(GameMessageS2CPacket packet, CallbackInfo ci) {
|
||||
final Text message = packet.content();
|
||||
|
||||
@WrapOperation(
|
||||
method = "onGameMessage",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/network/message/MessageHandler;onGameMessage(Lnet/minecraft/text/Text;Z)V"
|
||||
)
|
||||
)
|
||||
private void onGameMessage(MessageHandler instance, Text message, boolean overlay, Operation<Void> original) {
|
||||
try {
|
||||
if (
|
||||
(
|
||||
RainbowName.INSTANCE.enabled &&
|
||||
(
|
||||
message.getString().contains("Your nickname is now ") ||
|
||||
message.getString().contains("Nickname changed.")
|
||||
message.getString().startsWith("Your nickname is now ") ||
|
||||
message.getString().startsWith("Nickname changed.")
|
||||
)
|
||||
) {
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.getContent() instanceof TranslatableTextContent translatableTextContent) {
|
||||
final String key = translatableTextContent.getKey();
|
||||
|
||||
if (key.equals("advMode.setCommand.success") || key.equals("قيادة المجموعة: %s")) {
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
) ||
|
||||
(
|
||||
message.getContent() instanceof TranslatableTextContent translatableTextContent &&
|
||||
(
|
||||
translatableTextContent.getKey().equals("advMode.setCommand.success")
|
||||
|| translatableTextContent.getKey().equals("قيادة المجموعة: %s")
|
||||
)
|
||||
)
|
||||
) return;
|
||||
|
||||
for (Listener listener : ListenerManager.listeners) {
|
||||
listener.chatMessageReceived(message);
|
||||
}
|
||||
|
||||
if (message.getSiblings().size() > 1) {
|
||||
final String suggestionId = message.getSiblings().getFirst().getString();
|
||||
|
||||
if (suggestionId.equals(ChomeNSBotCommandSuggestions.REQUEST_SUGGESTIONS_ID)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
if (
|
||||
message.getSiblings().size() > 1
|
||||
&& message.getSiblings().getFirst().getContent() instanceof PlainTextContent textContent
|
||||
&& textContent.string().equals(ChomeNSBotCommandSuggestions.REQUEST_SUGGESTIONS_ID)
|
||||
) return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Inject(method = "onOverlayMessage", at = @At("TAIL"))
|
||||
private void onOverlayMessage(OverlayMessageS2CPacket packet, CallbackInfo ci) {
|
||||
original.call(instance, message, overlay);
|
||||
}
|
||||
|
||||
@WrapOperation(
|
||||
method = "onOverlayMessage",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/gui/hud/InGameHud;setOverlayMessage(Lnet/minecraft/text/Text;Z)V"
|
||||
)
|
||||
)
|
||||
private void onOverlayMessage(InGameHud instance, Text message, boolean tinted, Operation<Void> original) {
|
||||
for (Listener listener : ListenerManager.listeners) {
|
||||
listener.overlayMessageReceived(packet.text());
|
||||
listener.overlayMessageReceived(message);
|
||||
}
|
||||
|
||||
// checking for the bot selector message doesn't really
|
||||
// do much here since the message is just an empty string,
|
||||
original.call(instance, message, tinted);
|
||||
|
||||
// checking for the chomens bot selector message doesn't really
|
||||
// do much here since the message is just an empty string
|
||||
// that gets sent only when you join (or the bot restarts),
|
||||
// so I do not ignore them
|
||||
}
|
||||
|
||||
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
|
||||
private void sendChatMessage(String chatText, CallbackInfo ci) {
|
||||
@WrapMethod(method = "sendChatMessage")
|
||||
private void sendChatMessage(String content, Operation<Void> original) {
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
if (chatText.startsWith(commandManager.prefix)) {
|
||||
commandManager.executeCommand(chatText.substring(commandManager.prefix.length()));
|
||||
ci.cancel();
|
||||
if (content.startsWith(commandManager.prefix)) {
|
||||
commandManager.executeCommand(content.substring(commandManager.prefix.length()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +134,8 @@ public class ClientPlayNetworkHandlerMixin {
|
|||
return;
|
||||
}
|
||||
|
||||
CustomChat.INSTANCE.chat(chatText);
|
||||
ci.cancel();
|
||||
CustomChat.INSTANCE.chat(content);
|
||||
|
||||
// :D
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,30 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import net.minecraft.client.particle.ElderGuardianAppearanceParticle;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.SimpleParticleType;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ElderGuardianAppearanceParticle.Factory.class)
|
||||
public class ElderGuardianAppearanceParticleMixin {
|
||||
@Inject(
|
||||
method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private void createParticle(final CallbackInfoReturnable<Particle> cir) {
|
||||
cir.setReturnValue(null);
|
||||
@WrapMethod(
|
||||
method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;"
|
||||
)
|
||||
private Particle createParticle(
|
||||
final SimpleParticleType simpleParticleType,
|
||||
final ClientWorld clientWorld,
|
||||
final double d,
|
||||
final double e,
|
||||
final double f,
|
||||
final double g,
|
||||
final double h,
|
||||
final double i,
|
||||
final Operation<Particle> original
|
||||
) {
|
||||
// slash scare command
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import net.minecraft.client.sound.SoundInstance;
|
||||
import net.minecraft.client.sound.SoundSystem;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(SoundSystem.class)
|
||||
public class SoundSystemMixin {
|
||||
@Inject(method = "getAdjustedPitch", at = @At("HEAD"), cancellable = true)
|
||||
private void getAdjustedPitch (SoundInstance sound, CallbackInfoReturnable<Float> cir) {
|
||||
cir.setReturnValue(sound.getPitch());
|
||||
@WrapMethod(method = "getAdjustedPitch")
|
||||
private float getAdjustedPitch(final SoundInstance sound, final Operation<Float> original) {
|
||||
return sound.getPitch();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import net.minecraft.util.StringHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(StringHelper.class)
|
||||
public class StringHelperMixin {
|
||||
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
|
||||
private static void isValidChar (char chr, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(chr >= ' ' && chr != '\u007f');
|
||||
@WrapMethod(method = "isValidChar")
|
||||
private static boolean isValidChar (final char c, final Operation<Boolean> original) {
|
||||
// very legal [NUL] [LF] §
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public class Chat {
|
|||
if (usePlayerChat) NEXT_CHAT_PLAYER.set(true);
|
||||
|
||||
final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
|
||||
if (networkHandler == null) return;
|
||||
networkHandler.sendChatMessage(message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import net.minecraft.util.math.BlockBox;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
|
|
@ -19,7 +17,7 @@ public class CommandLoopManager {
|
|||
|
||||
public int loopCommand (String command, long interval) {
|
||||
final CommandLoop loop = new CommandLoop(this.core, command, interval);
|
||||
if (!commandLoops.add(loop)) return -1;
|
||||
commandLoops.add(loop);
|
||||
return commandLoops.size() - 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.util.ColorUtilities;
|
||||
|
||||
|
||||
import land.chipmunk.chipmunkmod.util.RandomUtilities;
|
||||
import land.chipmunk.chipmunkmod.util.UUIDUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
|
@ -45,6 +45,7 @@ public class RainbowName {
|
|||
|
||||
public void enable () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
if (networkHandler == null) return;
|
||||
final GameProfile profile = networkHandler.getProfile();
|
||||
|
||||
final String username = RandomUtilities.emptyUsername(random);
|
||||
|
|
@ -60,6 +61,10 @@ public class RainbowName {
|
|||
|
||||
public void disable () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
if (networkHandler == null) {
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
final GameProfile profile = networkHandler.getProfile();
|
||||
|
||||
CommandCore.INSTANCE.run("essentials:nick " + profile.getId() + " off");
|
||||
|
|
@ -94,7 +99,7 @@ public class RainbowName {
|
|||
for (char character : displayName.toCharArray()) {
|
||||
String color = String.format("%06x", ColorUtilities.hsvToRgb(hue, 100, 100));
|
||||
component = component.append(Component.text(character).color(TextColor.fromHexString("#" + color)));
|
||||
essentialsNickname.append("\u00a7#").append(color).append(character != ' ' ? character : '_');
|
||||
essentialsNickname.append("§#").append(color).append(character != ' ' ? character : '_');
|
||||
hue = (hue + increment) % 360;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +108,7 @@ public class RainbowName {
|
|||
|
||||
startHue = (startHue + increment) % 360;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ChipmunkMod.LOGGER.error("Error while ticking rainbow name", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ public class SelfCare implements Listener {
|
|||
public void chatTick() {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null) return;
|
||||
|
||||
if (!cspy && cspyEnabled) {
|
||||
if (serverHasCommand("c")) networkHandler.sendChatCommand("c on");
|
||||
} else if (!hasSkin && !skin.equals("off")) {
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
public class TransactionManager {
|
||||
public static final TransactionManager INSTANCE = new TransactionManager();
|
||||
|
||||
private int transactionId = 0;
|
||||
|
||||
public int transactionId () { return transactionId; }
|
||||
|
||||
public int nextTransactionId () { return transactionId++; }
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue