mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-12-30 06:06:55 +00:00
Merge pull request 'refactor: mixin renaming' (#20) from amy/chipmunkmod:1.21.11 into 1.21.11
Reviewed-on: https://code.chipmunk.land/ChomeNS/chipmunkmod/pulls/20
This commit is contained in:
commit
7b8be20373
9 changed files with 28 additions and 26 deletions
|
|
@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(AbstractDebugChart.class)
|
||||
public interface DebugChartAccessor {
|
||||
public interface AbstractDebugChartAccessor {
|
||||
@Accessor(value = "sampleStorage")
|
||||
SampleStorage getSampleStorage ();
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ import java.net.URL;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(value = ChatScreen.class)
|
||||
@Mixin(ChatScreen.class)
|
||||
public abstract class ChatScreenMixin {
|
||||
@Shadow
|
||||
protected EditBox input;
|
||||
|
|
@ -38,15 +38,15 @@ public abstract class ChatScreenMixin {
|
|||
}
|
||||
|
||||
@Inject(method = "handleChatInput", at = @At("HEAD"), cancellable = true)
|
||||
private void sendMessage (final String chatText, final boolean addToHistory, final CallbackInfo ci) {
|
||||
private void handleChatInput (final String msg, final boolean addToRecent, final CallbackInfo ci) {
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
|
||||
if (addToHistory) {
|
||||
client.gui.getChat().addRecentChat(chatText);
|
||||
if (addToRecent) {
|
||||
client.gui.getChat().addRecentChat(msg);
|
||||
}
|
||||
|
||||
if (ChipmunkMod.CONFIG.bots.testbot.webhookUrl != null && chatText.startsWith(ChipmunkMod.CONFIG.bots.testbot.prefix)) {
|
||||
if (ChipmunkMod.CONFIG.bots.testbot.webhookUrl != null && msg.startsWith(ChipmunkMod.CONFIG.bots.testbot.prefix)) {
|
||||
ChipmunkMod.executorService.submit(() -> {
|
||||
try {
|
||||
final URL url = new URI(ChipmunkMod.CONFIG.bots.testbot.webhookUrl).toURL();
|
||||
|
|
@ -73,7 +73,7 @@ public abstract class ChatScreenMixin {
|
|||
ChipmunkMod.LOGGER.error("Error while trying to request TestBot webhook", e);
|
||||
}
|
||||
});
|
||||
} else if (chatText.startsWith(ChipmunkMod.CONFIG.bots.chomens.prefix)) {
|
||||
} else if (msg.startsWith(ChipmunkMod.CONFIG.bots.chomens.prefix)) {
|
||||
final List<ChomeNSBotCommand> commands = ChomeNSBotCommandSuggestions.INSTANCE.commands;
|
||||
|
||||
final List<String> moreOrTrustedCommands = new ArrayList<>();
|
||||
|
|
@ -91,7 +91,7 @@ public abstract class ChatScreenMixin {
|
|||
aliases.addAll(command.aliases());
|
||||
}
|
||||
|
||||
final String chatCommand = chatText.toLowerCase().split("\\s")[0];
|
||||
final String chatCommand = msg.toLowerCase().split("\\s")[0];
|
||||
|
||||
final int prefixLength = ChipmunkMod.CONFIG.bots.chomens.prefix.length();
|
||||
|
||||
|
|
@ -105,24 +105,24 @@ public abstract class ChatScreenMixin {
|
|||
)
|
||||
) {
|
||||
try {
|
||||
BotValidationUtilities.chomens(chatText.substring(prefixLength));
|
||||
BotValidationUtilities.chomens(msg.substring(prefixLength));
|
||||
ci.cancel();
|
||||
return;
|
||||
} catch (final Exception ignored) {
|
||||
}
|
||||
}
|
||||
} else if (chatText.startsWith(commandManager.prefix)) {
|
||||
commandManager.executeCommand(chatText.substring(commandManager.prefix.length()));
|
||||
} else if (msg.startsWith(commandManager.prefix)) {
|
||||
commandManager.executeCommand(msg.substring(commandManager.prefix.length()));
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (client.player == null) return;
|
||||
|
||||
if (chatText.startsWith("/")) {
|
||||
client.player.connection.sendCommand(chatText.substring(1));
|
||||
if (msg.startsWith("/")) {
|
||||
client.player.connection.sendCommand(msg.substring(1));
|
||||
} else {
|
||||
client.player.connection.sendChat(chatText);
|
||||
client.player.connection.sendChat(msg);
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
|
|
|
|||
|
|
@ -117,12 +117,12 @@ public abstract class ClientPacketListenerMixin {
|
|||
target = "Lnet/minecraft/client/gui/Gui;setOverlayMessage(Lnet/minecraft/network/chat/Component;Z)V"
|
||||
)
|
||||
)
|
||||
private void setOverlayMessage (final Gui instance, final Component message, final boolean tinted, final Operation<Void> original) {
|
||||
private void setOverlayMessage (final Gui instance, final Component message, final boolean animate, final Operation<Void> original) {
|
||||
for (final Listener listener : ListenerManager.listeners) {
|
||||
listener.overlayMessageReceived(message);
|
||||
}
|
||||
|
||||
original.call(instance, message, tinted);
|
||||
original.call(instance, message, animate);
|
||||
|
||||
// checking for the ChomeNS Bot selector message doesn't really
|
||||
// do much here since the message is just an empty string
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
|
|||
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.CommandSuggestions;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
|
|
@ -25,7 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.components.CommandSuggestions.class)
|
||||
@Mixin(CommandSuggestions.class)
|
||||
public class CommandSuggestionsMixin {
|
||||
@Mutable
|
||||
@Final
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
|||
import land.chipmunk.chipmunkmod.modules.SelfCare;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.DisconnectionDetails;
|
||||
import net.minecraft.network.PacketListener;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
|
|
@ -28,7 +29,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Mixin(net.minecraft.network.Connection.class)
|
||||
@Mixin(Connection.class)
|
||||
public class ConnectionMixin {
|
||||
@Unique
|
||||
private static final double MAX_PARTICLES_PER_PACKET = 1000;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(DebugScreenOverlay.class)
|
||||
public interface DebugHudAccessor {
|
||||
public interface DebugScreenOverlayAccessor {
|
||||
@Accessor(value = "pingChart")
|
||||
PingDebugChart getPingChart ();
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
@Mixin(StringUtil.class)
|
||||
public class StringUtilMixin {
|
||||
@Inject(method = "isAllowedChatCharacter", at = @At("RETURN"), cancellable = true)
|
||||
private static void isAllowedChatCharacter (final int c, final CallbackInfoReturnable<Boolean> cir) {
|
||||
private static void isAllowedChatCharacter (final int ch, final CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!CustomChat.SHOULD_IGNORE_INVALID_CHAR.get()) {
|
||||
CustomChat.SHOULD_IGNORE_INVALID_CHAR.set(true);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import land.chipmunk.chipmunkmod.ChipmunkMod;
|
|||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import land.chipmunk.chipmunkmod.mixin.ClientLevelAccessor;
|
||||
import land.chipmunk.chipmunkmod.mixin.DebugChartAccessor;
|
||||
import land.chipmunk.chipmunkmod.mixin.DebugHudAccessor;
|
||||
import land.chipmunk.chipmunkmod.mixin.AbstractDebugChartAccessor;
|
||||
import land.chipmunk.chipmunkmod.mixin.DebugScreenOverlayAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.debugchart.PingDebugChart;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
|
|
@ -596,8 +596,8 @@ public class CommandCore implements Listener {
|
|||
}
|
||||
|
||||
private int getNextTickWaitTime () {
|
||||
final PingDebugChart pingChart = ((DebugHudAccessor) client.getDebugOverlay()).getPingChart();
|
||||
final SampleStorage log = ((DebugChartAccessor) pingChart).getSampleStorage();
|
||||
final PingDebugChart pingChart = ((DebugScreenOverlayAccessor) client.getDebugOverlay()).getPingChart();
|
||||
final SampleStorage log = ((AbstractDebugChartAccessor) pingChart).getSampleStorage();
|
||||
|
||||
long sum = 0L;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
"LocalPlayerMixin",
|
||||
"ClientPacketListenerMixin",
|
||||
"ClientLevelAccessor",
|
||||
"DebugChartAccessor",
|
||||
"DebugHudAccessor",
|
||||
"AbstractDebugChartAccessor",
|
||||
"DebugScreenOverlayAccessor",
|
||||
"MinecraftAccessor",
|
||||
"StringUtilMixin",
|
||||
"ElderGuardianParticleProviderMixin",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue