Merge remote-tracking branch 'upstream/1.20.1' into 1.20.1
This commit is contained in:
commit
ce49c7238c
48 changed files with 692 additions and 310 deletions
|
@ -4,9 +4,9 @@ org.gradle.parallel=true
|
|||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.20.1
|
||||
yarn_mappings=1.20.1+build.9
|
||||
loader_version=0.14.21
|
||||
minecraft_version=1.20.1
|
||||
yarn_mappings=1.20.1+build.9
|
||||
loader_version=0.14.21
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.1
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
config.stopBubbling = true
|
||||
lombok.accessors.fluent = true
|
|
@ -7,6 +7,7 @@ import land.chipmunk.chipmunkmod.util.SharedVariables;
|
|||
import land.chipmunk.chipmunkmod.util.TickRunnableHandler;
|
||||
import land.chipmunk.chipmunkmod.modules.KaboomCheck;
|
||||
import land.chipmunk.chipmunkmod.modules.Players;
|
||||
import land.chipmunk.chipmunkmod.modules.SelfCare;
|
||||
import land.chipmunk.chipmunkmod.util.gson.BlockPosTypeAdapter;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import java.io.InputStream;
|
||||
|
@ -55,6 +56,7 @@ public class ChipmunkMod implements ModInitializer {
|
|||
if(CONFIG.defaultUsername == null) CONFIG.defaultUsername = MinecraftClient.getInstance().getSession().getUsername(); // testclient gui is not loaded yet so getUsername will not retunr the fake
|
||||
Players.INSTANCE.init();
|
||||
KaboomCheck.INSTANCE.init();
|
||||
SelfCare.INSTANCE.init();
|
||||
|
||||
//save on quit owo
|
||||
ClientLifecycleEvents.CLIENT_STOPPING.register(client -> {
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.JsonObject;
|
||||
import land.chipmunk.chipmunkmod.data.BlockArea;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
|
||||
public class Configuration {
|
||||
public CommandManager commands = new CommandManager();
|
||||
|
@ -34,16 +34,24 @@ public class Configuration {
|
|||
public TestBotInfo testbot = new TestBotInfo("-", null);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class TestBotInfo {
|
||||
public String prefix;
|
||||
public String webhookUrl;
|
||||
|
||||
public TestBotInfo (String prefix, String webhookUrl) {
|
||||
this.prefix = prefix;
|
||||
this.webhookUrl = webhookUrl;
|
||||
}
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class BotInfo {
|
||||
public String prefix;
|
||||
public String key;
|
||||
|
||||
public BotInfo (String prefix, String key) {
|
||||
this.prefix = prefix;
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomChat {
|
||||
|
|
|
@ -33,11 +33,9 @@ public class CommandManager {
|
|||
ItemCommand.register(this.dispatcher, commandRegistryAccess);
|
||||
CustomChatCommand.register(this.dispatcher);
|
||||
EvalCommand.register(this.dispatcher);
|
||||
FullBrightCommand.register(this.dispatcher);
|
||||
MusicCommand.register(this.dispatcher);
|
||||
RainbowNameCommand.register(this.dispatcher);
|
||||
SayCommand.register(this.dispatcher);
|
||||
SelfCareCommand.register(this.dispatcher);
|
||||
AutoSkinCommand.register(this.dispatcher);
|
||||
ReloadConfigCommand.register(this.dispatcher);
|
||||
LoopCrouchCommand.register(this.dispatcher);
|
||||
|
@ -59,7 +57,7 @@ public class CommandManager {
|
|||
if (context != null) commandSource.sendError(context);
|
||||
} catch (CommandException e) {
|
||||
commandSource.sendError(e.getTextMessage());
|
||||
} catch (RuntimeException e) {
|
||||
} catch (Exception e) {
|
||||
commandSource.sendError(Text.of(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ public class AutoSkinCommand {
|
|||
|
||||
final String username = getString(context, "username");
|
||||
|
||||
SelfCare.INSTANCE.skin(username);
|
||||
SelfCare.INSTANCE.skin = username;
|
||||
|
||||
if (username.equals("off")) source.sendFeedback(Text.literal("Successfully disabled auto skin"));
|
||||
else {
|
||||
SelfCare.INSTANCE.hasSkin(false);
|
||||
SelfCare.INSTANCE.hasSkin = false;
|
||||
source.sendFeedback(Text.literal("Set your auto skin username to: " + username));
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class CloopCommand {
|
|||
final CommandLoopManager manager = CommandLoopManager.INSTANCE;
|
||||
final int id = getInteger(context, "id");
|
||||
|
||||
if (id < 0 || id >= manager.commandLoops().size()) throw INVALID_CLOOP_ID_EXCEPTION.create(id);
|
||||
if (id < 0 || id >= manager.commandLoops.size()) throw INVALID_CLOOP_ID_EXCEPTION.create(id);
|
||||
|
||||
manager.removeAndStop(id);
|
||||
|
||||
|
@ -88,11 +88,11 @@ public class CloopCommand {
|
|||
|
||||
public static int listCloops (CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
final List<CommandLoopManager.CommandLoop> loops = CommandLoopManager.INSTANCE.commandLoops();
|
||||
final List<CommandLoopManager.CommandLoop> loops = CommandLoopManager.INSTANCE.commandLoops;
|
||||
|
||||
int id = 0;
|
||||
for (CommandLoopManager.CommandLoop loop : loops) {
|
||||
source.sendFeedback(Text.translatable("%s: %s (%s)", Text.literal(String.valueOf(id)), Text.literal(loop.command()), Text.literal(String.valueOf(loop.interval()))));
|
||||
source.sendFeedback(Text.translatable("%s: %s (%s)", Text.literal(String.valueOf(id)), Text.literal(loop.command), Text.literal(String.valueOf(loop.interval))));
|
||||
id++;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class CustomChatCommand {
|
|||
public static int enabled (CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
final boolean bool = getBool(context, "boolean");
|
||||
CustomChat.INSTANCE.enabled(bool);
|
||||
CustomChat.INSTANCE.enabled = bool;
|
||||
source.sendFeedback(Text.literal("Custom chat is now " + (bool ? "on" : "off")));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
@ -47,7 +47,7 @@ public class CustomChatCommand {
|
|||
public static int setFormat (CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
final String format = getString(context, "format");
|
||||
CustomChat.INSTANCE.format(format);
|
||||
CustomChat.INSTANCE.format = format;
|
||||
source.sendFeedback(Text.literal("Set the custom chat format to: " + format));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.commands;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import land.chipmunk.chipmunkmod.modules.FullBright;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
|
||||
public class FullBrightCommand {
|
||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
dispatcher.register(
|
||||
literal("fullbright")
|
||||
.then(
|
||||
argument("boolean", bool())
|
||||
.executes(FullBrightCommand::set)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int set (CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
|
||||
final boolean bool = getBool(context, "boolean");
|
||||
|
||||
FullBright.enabled(bool);
|
||||
|
||||
source.sendFeedback(Text.literal("Fullbright is now " + (bool ? "enabled" : "disabled")));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.commands;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import land.chipmunk.chipmunkmod.modules.LoopCrouch;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
|
||||
public class LoopCrouchCommand {
|
||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
dispatcher.register(
|
||||
literal("loopcrouch")
|
||||
.then(
|
||||
argument("enabled", bool())
|
||||
.executes(LoopCrouchCommand::run)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int run (CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
|
||||
final boolean enabled = getBool(context, "enabled");
|
||||
|
||||
LoopCrouch.INSTANCE.enabled(enabled);
|
||||
|
||||
source.sendFeedback(Text.literal("Loop crouch is now " + (enabled ? "enabled" : "disabled")));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
|
@ -125,10 +125,10 @@ public class MusicCommand {
|
|||
final FabricClientCommandSource source = context.getSource();
|
||||
final SongPlayer songPlayer = SongPlayer.INSTANCE;
|
||||
|
||||
if (songPlayer.currentSong() == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
|
||||
if (songPlayer.currentSong == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
|
||||
|
||||
songPlayer.stopPlaying();
|
||||
songPlayer.songQueue().clear();
|
||||
songPlayer.songQueue.clear();
|
||||
source.sendFeedback(Text.literal("Stopped music playback").formatted(Formatting.GREEN));
|
||||
|
||||
return 1;
|
||||
|
@ -138,7 +138,7 @@ public class MusicCommand {
|
|||
final FabricClientCommandSource source = context.getSource();
|
||||
final SongPlayer songPlayer = SongPlayer.INSTANCE;
|
||||
|
||||
if (songPlayer.currentSong() == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
|
||||
if (songPlayer.currentSong == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
|
||||
|
||||
songPlayer.stopPlaying();
|
||||
source.sendFeedback(Text.literal("Skipped the current song").formatted(Formatting.GREEN));
|
||||
|
@ -149,7 +149,7 @@ public class MusicCommand {
|
|||
public int pause (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
final SongPlayer songPlayer = SongPlayer.INSTANCE;
|
||||
final Song currentSong = songPlayer.currentSong();
|
||||
final Song currentSong = songPlayer.currentSong;
|
||||
|
||||
if (currentSong == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
|
||||
|
||||
|
@ -240,7 +240,7 @@ public class MusicCommand {
|
|||
public int toggleLoop (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
final SongPlayer songPlayer = SongPlayer.INSTANCE;
|
||||
final Song currentSong = songPlayer.currentSong();
|
||||
final Song currentSong = songPlayer.currentSong;
|
||||
|
||||
if (currentSong == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
|
||||
|
||||
|
@ -255,7 +255,7 @@ public class MusicCommand {
|
|||
public int loop (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
final SongPlayer songPlayer = SongPlayer.INSTANCE;
|
||||
final Song currentSong = songPlayer.currentSong();
|
||||
final Song currentSong = songPlayer.currentSong;
|
||||
final int count = getInteger(context, "count");
|
||||
|
||||
if (currentSong == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
|
||||
|
@ -271,7 +271,7 @@ public class MusicCommand {
|
|||
public int gotoCommand (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
final SongPlayer songPlayer = SongPlayer.INSTANCE;
|
||||
final Song currentSong = songPlayer.currentSong();
|
||||
final Song currentSong = songPlayer.currentSong;
|
||||
final long millis = getLong(context, "timestamp");
|
||||
|
||||
if (currentSong == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
|
||||
|
@ -290,7 +290,7 @@ public class MusicCommand {
|
|||
|
||||
final boolean enabled = getBool(context, "boolean");
|
||||
|
||||
SongPlayer.INSTANCE.useCore(enabled);
|
||||
SongPlayer.INSTANCE.useCore = enabled;
|
||||
|
||||
source.sendFeedback(Text.literal("Playing music using core is now " + (enabled ? "enabled" : "disabled")));
|
||||
|
||||
|
@ -302,7 +302,7 @@ public class MusicCommand {
|
|||
|
||||
final boolean enabled = getBool(context, "boolean");
|
||||
|
||||
SongPlayer.INSTANCE.actionbar(enabled);
|
||||
SongPlayer.INSTANCE.actionbar = enabled;
|
||||
|
||||
source.sendFeedback(Text.literal("Showing actionbar is now " + (enabled ? "enabled" : "disabled")));
|
||||
|
||||
|
@ -314,7 +314,7 @@ public class MusicCommand {
|
|||
|
||||
final float pitch = getFloat(context, "pitch");
|
||||
|
||||
SongPlayer.INSTANCE.pitch(pitch);
|
||||
SongPlayer.INSTANCE.pitch = pitch;
|
||||
|
||||
source.sendFeedback(
|
||||
Text.translatable(
|
||||
|
|
|
@ -56,7 +56,7 @@ public class RainbowNameCommand {
|
|||
|
||||
final String name = getString(context, "name");
|
||||
|
||||
RainbowName.INSTANCE.displayName(name);
|
||||
RainbowName.INSTANCE.displayName = name;
|
||||
|
||||
source.sendFeedback(Text.literal("Set the display name to: " + name));
|
||||
|
||||
|
|
|
@ -47,15 +47,15 @@ public class SelfCareCommand {
|
|||
|
||||
switch (type) {
|
||||
case "op" -> {
|
||||
SelfCare.INSTANCE.opEnabled(bool);
|
||||
SelfCare.INSTANCE.opEnabled = bool;
|
||||
source.sendFeedback(Text.literal("The op self care is now " + (bool ? "enabled" : "disabled")));
|
||||
}
|
||||
case "gamemode" -> {
|
||||
SelfCare.INSTANCE.gamemodeEnabled(bool);
|
||||
SelfCare.INSTANCE.gamemodeEnabled = bool;
|
||||
source.sendFeedback(Text.literal("The gamemode self care is now " + (bool ? "enabled" : "disabled")));
|
||||
}
|
||||
case "cspy" -> {
|
||||
SelfCare.INSTANCE.cspyEnabled(bool);
|
||||
SelfCare.INSTANCE.cspyEnabled = bool;
|
||||
source.sendFeedback(Text.literal("The CommandSpy self care is now " + (bool ? "enabled" : "disabled")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +1,28 @@
|
|||
package land.chipmunk.chipmunkmod.commands;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import java.util.Arrays;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.Configuration;
|
||||
import land.chipmunk.chipmunkmod.util.Hexadecimal;
|
||||
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
import static land.chipmunk.chipmunkmod.util.BotValidationUtilities.*;
|
||||
|
||||
public class ValidateCommand {
|
||||
private static final SimpleCommandExceptionType UNSPECIFIED_KEY = new SimpleCommandExceptionType(Text.literal("The key of the bot is unspecified (null), did you incorrectly add it to your config?"));
|
||||
|
||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
dispatcher.register(
|
||||
literal("validate")
|
||||
.then(literal("hbot").then(argument("command", greedyString()).executes(c -> hbot(c))))
|
||||
.then(literal("sbot").then(argument("command", greedyString()).executes(c -> sbot(c))))
|
||||
// .then(literal("chipmunk").then(argument("command", greedyString()).executes(c -> chipmunk(c))))
|
||||
.then(literal("chomens").then(argument("command", greedyString()).executes(c -> chomens(c))))
|
||||
.then(literal("kittycorp").then(argument("command", greedyString()).executes(c -> kittycorp(c))))
|
||||
.then(literal("hbot").then(argument("command", greedyString()).executes(c -> hbot(getString(c, "command")))))
|
||||
.then(literal("sbot").then(argument("command", greedyString()).executes(c -> sbot(getString(c, "command")))))
|
||||
// .then(literal("chipmunk").then(argument("command", greedyString()).executes(c -> chipmunk(getString(c, "command")))))
|
||||
.then(literal("chomens").then(argument("command", greedyString()).executes(c -> {
|
||||
c.getSource().sendFeedback(Text.literal("Warning: Manual ChomeNS Bot validation is deprecated"));
|
||||
|
||||
return chomens(getString(c, "command"));
|
||||
})))
|
||||
.then(literal("kittycorp").then(argument("command", greedyString()).executes(c -> kittycorp(getString(c, "command")))))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package land.chipmunk.chipmunkmod.data;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
// ? Am I reinventing the wheel here?
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class BlockArea {
|
||||
private BlockPos start;
|
||||
private BlockPos end;
|
||||
public BlockPos start;
|
||||
public BlockPos end;
|
||||
|
||||
public BlockArea (BlockPos start, BlockPos end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package land.chipmunk.chipmunkmod.data;
|
||||
|
||||
public class ChomeNSBotCommand {
|
||||
public final String name;
|
||||
public final TrustLevel trustLevel;
|
||||
|
||||
public ChomeNSBotCommand (
|
||||
String name,
|
||||
TrustLevel trustLevel
|
||||
) {
|
||||
this.name = name;
|
||||
this.trustLevel = trustLevel;
|
||||
}
|
||||
|
||||
public enum TrustLevel {
|
||||
PUBLIC,
|
||||
TRUSTED,
|
||||
OWNER
|
||||
}
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.data;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class CommandLoop {
|
||||
@Getter
|
||||
private String command;
|
||||
@Getter
|
||||
private long interval;
|
||||
|
||||
public CommandLoop (String command, long interval) {
|
||||
this.command = command;
|
||||
this.interval = interval;
|
||||
}
|
||||
}
|
|
@ -1,19 +1,22 @@
|
|||
package land.chipmunk.chipmunkmod.data;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.world.GameMode;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MutablePlayerListEntry {
|
||||
private GameProfile profile;
|
||||
private GameMode gamemode;
|
||||
private int latency;
|
||||
private Text displayName;
|
||||
public GameProfile profile;
|
||||
public GameMode gamemode;
|
||||
public int latency;
|
||||
public Text displayName;
|
||||
|
||||
public MutablePlayerListEntry(GameProfile profile, GameMode gamemode, int latency, Text displayName) {
|
||||
this.profile = profile;
|
||||
this.gamemode = gamemode;
|
||||
this.latency = latency;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public MutablePlayerListEntry (PlayerListS2CPacket.Entry entry) {
|
||||
this(entry.profile(), entry.gameMode(), entry.latency(), entry.displayName());
|
||||
|
|
|
@ -9,4 +9,8 @@ public class Listener {
|
|||
public void packetReceived (Packet<?> packet) {}
|
||||
|
||||
public void packetSent (Packet<?> packet) {}
|
||||
|
||||
public void coreReady () {}
|
||||
|
||||
public void coreMoved () {}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,16 @@ package land.chipmunk.chipmunkmod.mixin;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||
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.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
|
@ -15,6 +21,7 @@ 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.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.ChatInputSuggestor.class)
|
||||
|
@ -29,6 +36,11 @@ public class ChatInputSuggestorMixin {
|
|||
@Shadow
|
||||
public void show (boolean narrateFirstSuggestion) {}
|
||||
|
||||
@Shadow
|
||||
private static int getStartOfCurrentWord (String input) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Mutable
|
||||
@Final
|
||||
@Shadow
|
||||
|
@ -47,6 +59,35 @@ public class ChatInputSuggestorMixin {
|
|||
final String text = this.textField.getText();
|
||||
final int cursor = this.textField.getCursor();
|
||||
|
||||
final ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||
|
||||
final String chomeNSPrefix = ChipmunkMod.CONFIG.bots.chomens.prefix;
|
||||
|
||||
if (!text.contains(" ") && text.startsWith(chomeNSPrefix) && player != null) {
|
||||
final String textUpToCursor = text.substring(0, cursor);
|
||||
|
||||
final List<String> commands = ChomeNSBotCommandSuggestions.INSTANCE.commands
|
||||
.stream()
|
||||
.map((command) -> command.name)
|
||||
.toList();
|
||||
|
||||
pendingSuggestions = CommandSource.suggestMatching(
|
||||
commands,
|
||||
new SuggestionsBuilder(
|
||||
textUpToCursor,
|
||||
getStartOfCurrentWord(textUpToCursor)
|
||||
)
|
||||
);
|
||||
|
||||
pendingSuggestions.thenRun(() -> {
|
||||
if (!pendingSuggestions.isDone()) return;
|
||||
|
||||
show(true);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (cursor < commandManager.prefix.length() || !text.startsWith(commandManager.prefix)) return;
|
||||
|
||||
final StringReader reader = new StringReader(text);
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||
import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
|
||||
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
|
||||
import land.chipmunk.chipmunkmod.modules.CustomChat;
|
||||
import land.chipmunk.chipmunkmod.util.Webhook;
|
||||
import land.chipmunk.chipmunkmod.util.BotValidationUtilities;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ChatInputSuggestor;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
@ -13,12 +16,17 @@ import net.minecraft.text.MutableText;
|
|||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.ChatScreen.class)
|
||||
public class ChatScreenMixin extends Screen {
|
||||
|
@ -43,30 +51,59 @@ public class ChatScreenMixin extends Screen {
|
|||
}
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
|
||||
if (ChipmunkMod.CONFIG.bots.testbot.webhookUrl != null) {
|
||||
if (ChipmunkMod.CONFIG.bots.testbot.webhookUrl != null && chatText.startsWith(ChipmunkMod.CONFIG.bots.testbot.prefix)) {
|
||||
ChipmunkMod.executorService.submit(() -> {
|
||||
final Webhook webhook = new Webhook(ChipmunkMod.CONFIG.bots.testbot.webhookUrl);
|
||||
webhook.setUsername("ChipmunkMod");
|
||||
webhook.setContent(MinecraftClient.getInstance().getSession().getUsername());
|
||||
try {
|
||||
webhook.execute();
|
||||
final URL url = new URL(ChipmunkMod.CONFIG.bots.testbot.webhookUrl);
|
||||
|
||||
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.addRequestProperty("Content-Type", "application/json");
|
||||
connection.addRequestProperty("User-Agent", "ChipmunkMod");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
|
||||
final JsonObject jsonObject = new JsonObject();
|
||||
|
||||
jsonObject.addProperty("username", "ChipmunkMod UwU");
|
||||
jsonObject.addProperty("content", MinecraftClient.getInstance().getSession().getUsername());
|
||||
|
||||
final OutputStream stream = connection.getOutputStream();
|
||||
stream.write(jsonObject.toString().getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
|
||||
connection.getInputStream().close();
|
||||
connection.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
} else if (chatText.startsWith(ChipmunkMod.CONFIG.bots.chomens.prefix)) {
|
||||
final List<ChomeNSBotCommand> commands = ChomeNSBotCommandSuggestions.INSTANCE.commands;
|
||||
|
||||
final List<String> moreOrTrustedCommands = commands.stream()
|
||||
.filter((command) -> command.trustLevel != ChomeNSBotCommand.TrustLevel.PUBLIC)
|
||||
.map((command) -> command.name.toLowerCase())
|
||||
.toList();
|
||||
|
||||
if (moreOrTrustedCommands.contains(chatText.toLowerCase().split("\\s")[0])) {
|
||||
try {
|
||||
BotValidationUtilities.chomens(chatText.substring(ChipmunkMod.CONFIG.bots.chomens.prefix.length()));
|
||||
|
||||
cir.setReturnValue(true);
|
||||
|
||||
return;
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
if (chatText.startsWith(commandManager.prefix)) {
|
||||
commandManager.executeCommand(chatText.substring(commandManager.prefix.length()));
|
||||
|
||||
if (addToHistory) MinecraftClient.getInstance().inGameHud.getChatHud().addToMessageHistory(chatText);
|
||||
|
||||
cir.setReturnValue(true);
|
||||
} else if (!chatText.startsWith("/")) {
|
||||
CustomChat.INSTANCE.chat(chatText);
|
||||
|
||||
if (addToHistory) MinecraftClient.getInstance().inGameHud.getChatHud().addToMessageHistory(chatText);
|
||||
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +136,7 @@ public class ChatScreenMixin extends Screen {
|
|||
ci.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void onChatFieldUpdate(String chatText) {
|
||||
String string = this.chatField.getText();
|
||||
this.chatInputSuggestor.setWindowActive(!string.equals(this.originalChatText));
|
||||
|
|
|
@ -2,6 +2,7 @@ package land.chipmunk.chipmunkmod.mixin;
|
|||
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import net.minecraft.text.Text;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
public interface ClientPlayNetworkHandlerInvoker {
|
||||
}
|
|
@ -1,14 +1,26 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import land.chipmunk.chipmunkmod.modules.*;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.network.ClientDynamicRegistryType;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.client.util.telemetry.WorldSession;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket;
|
||||
import net.minecraft.registry.CombinedDynamicRegistries;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableTextContent;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -20,20 +32,58 @@ public class ClientPlayNetworkHandlerMixin {
|
|||
@Shadow private FeatureSet enabledFeatures;
|
||||
@Shadow private CombinedDynamicRegistries<ClientDynamicRegistryType> combinedDynamicRegistries;
|
||||
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void init (MinecraftClient client, Screen screen, ClientConnection connection, ServerInfo serverInfo, GameProfile profile, WorldSession worldSession, CallbackInfo ci) {
|
||||
|
||||
}
|
||||
|
||||
@Inject(method = "onGameJoin", at = @At("TAIL"))
|
||||
private void onGameJoin (GameJoinS2CPacket packet, CallbackInfo ci) {
|
||||
final CommandRegistryAccess commandRegistryAccess = CommandRegistryAccess.of(this.combinedDynamicRegistries.getCombinedRegistryManager(), this.enabledFeatures);
|
||||
|
||||
KaboomCheck.INSTANCE.onJoin();
|
||||
CommandManager.INSTANCE = new CommandManager(ChipmunkMod.CONFIG.commands.prefix, commandRegistryAccess);
|
||||
SelfCare.INSTANCE.init();
|
||||
LoopCrouch.INSTANCE.init();
|
||||
SelfCare.INSTANCE.onJoin();
|
||||
CommandCore.INSTANCE.init();
|
||||
SongPlayer.INSTANCE.coreReady();
|
||||
RainbowName.INSTANCE.init();
|
||||
ChomeNSBotCommandSuggestions.INSTANCE.init();
|
||||
}
|
||||
|
||||
@Inject(method = "onPlayerRemove", at = @At("HEAD"), cancellable = true)
|
||||
private void onPlayerRemove (PlayerRemoveS2CPacket packet, CallbackInfo ci) {
|
||||
ci.cancel();
|
||||
private void onPlayerRemove (PlayerRemoveS2CPacket packet, CallbackInfo ci) { ci.cancel(); }
|
||||
|
||||
|
||||
@Inject(method = "onGameMessage", at = @At("HEAD"), cancellable = true)
|
||||
private void onGameMessage (GameMessageS2CPacket packet, CallbackInfo ci) {
|
||||
final Text message = packet.content();
|
||||
|
||||
try {
|
||||
if (RainbowName.INSTANCE.enabled) {
|
||||
if (message.getString().contains("Your nickname is now ") || message.getString().contains("Nickname changed.")) {
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (((TranslatableTextContent) message.getContent()).getKey().equals("advMode.setCommand.success")) {
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
} catch (ClassCastException ignored) {}
|
||||
|
||||
for (Listener listener : ListenerManager.listeners) {
|
||||
listener.chatMessageReceived(message);
|
||||
}
|
||||
|
||||
try {
|
||||
if (((TextComponent) message.asComponent().children().get(0)).content().equals(ChomeNSBotCommandSuggestions.ID)) {
|
||||
ci.cancel();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class ClientPlayerEntityMixin {
|
|||
|
||||
final ClientWorld world = CLIENT.getNetworkHandler().getWorld();
|
||||
|
||||
final BlockPos origin = CommandCore.INSTANCE.origin();
|
||||
final BlockPos origin = CommandCore.INSTANCE.origin;
|
||||
if (origin == null) { CommandCore.INSTANCE.move(position); return; }
|
||||
final int distance = (int) Math.sqrt(new Vec2f(origin.getX() / 16, origin.getZ() / 16).distanceSquared(new Vec2f((int) position.getX() / 16, (int) position.getZ() / 16)));
|
||||
if (distance > world.getSimulationDistance()) CommandCore.INSTANCE.move(position);
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.modules.FullBright;
|
||||
import net.minecraft.client.render.LightmapTextureManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArgs;
|
||||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
|
||||
|
||||
@Mixin(LightmapTextureManager.class)
|
||||
public class LightmapTextureManagerMixin {
|
||||
@ModifyArgs(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/NativeImage;setColor(III)V"))
|
||||
private void update (Args args) {
|
||||
if (FullBright.enabled()) args.set(2, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.world.GameMode;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(PlayerListEntry.class)
|
||||
public interface PlayerListEntryAccessor {
|
||||
@Accessor("gameMode")
|
||||
void setGameMode (GameMode gameMode);
|
||||
|
||||
@Accessor("latency")
|
||||
void setLatency (int latency);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.SharedConstants;
|
||||
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(SharedConstants.class)
|
||||
public class SharedConstantsMixin {
|
||||
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
|
||||
private static void isValidChar (char chr, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(chr >= ' ' && chr != '\u007f');
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
|
@ -11,10 +11,12 @@ public class StringHelperMixin {
|
|||
@Inject(method = "truncateChat", at = @At("HEAD"), cancellable = true)
|
||||
private static void truncateChat (String text, CallbackInfoReturnable<String> cir) {
|
||||
cir.setReturnValue(text);
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "stripTextFormat", at = @At("HEAD"), cancellable = true)
|
||||
private static void stripTextFormat(String text, CallbackInfoReturnable<String> cir) {
|
||||
cir.setReturnValue(text);
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import land.chipmunk.chipmunkmod.util.UUIDUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ChomeNSBotCommandSuggestions extends Listener {
|
||||
public static final String ID = "chomens_bot_request_command_suggestion";
|
||||
|
||||
public static ChomeNSBotCommandSuggestions INSTANCE = new ChomeNSBotCommandSuggestions(MinecraftClient.getInstance());
|
||||
|
||||
private final MinecraftClient client;
|
||||
|
||||
public List<ChomeNSBotCommand> commands = new ArrayList<>();
|
||||
|
||||
public ChomeNSBotCommandSuggestions (MinecraftClient client) {
|
||||
this.client = client;
|
||||
|
||||
ListenerManager.addListener(this);
|
||||
}
|
||||
|
||||
public void init () {}
|
||||
|
||||
@Override
|
||||
public void coreMoved () { forceRequest(); }
|
||||
|
||||
public void forceRequest () {
|
||||
final ClientPlayerEntity player = client.player;
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
final String selector = UUIDUtilities.selector(player.getUuid());
|
||||
|
||||
final Component component = Component
|
||||
.text(ID)
|
||||
.append(Component.text(selector));
|
||||
|
||||
final String serialized = GsonComponentSerializer.gson().serialize(component);
|
||||
|
||||
CommandCore.INSTANCE.run("tellraw @a[tag=chomens_bot] " + serialized);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chatMessageReceived(Text message) {
|
||||
try {
|
||||
final Component component = message.asComponent();
|
||||
|
||||
final List<Component> children = component.children();
|
||||
|
||||
if (children.size() == 0) return;
|
||||
|
||||
final TextComponent textComponent = (TextComponent) children.get(0);
|
||||
|
||||
if (!textComponent.content().equals(ID)) return;
|
||||
|
||||
commands = children.subList(1, children.size())
|
||||
.stream()
|
||||
.map(
|
||||
(eachCum) -> new ChomeNSBotCommand(
|
||||
ChipmunkMod.CONFIG.bots.chomens.prefix + ((TextComponent) eachCum).content(),
|
||||
ChomeNSBotCommand.TrustLevel.valueOf(((TextComponent) eachCum.children().get(0)).content())
|
||||
)
|
||||
)
|
||||
.toList();
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
|
@ -2,26 +2,32 @@ package land.chipmunk.chipmunkmod.modules;
|
|||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.data.BlockArea;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import net.minecraft.block.entity.CommandBlockBlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.packet.c2s.play.UpdateCommandBlockC2SPacket;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class CommandCore {
|
||||
private final MinecraftClient client;
|
||||
@Getter @Setter private boolean ready = false;
|
||||
@Getter @Setter private BlockPos origin;
|
||||
@Getter private BlockArea relativeArea;
|
||||
@Getter @Setter private BlockPos currentBlockRelative;
|
||||
public boolean ready = false;
|
||||
public BlockPos origin;
|
||||
public BlockArea relativeArea;
|
||||
public BlockPos currentBlockRelative;
|
||||
|
||||
private Timer timer;
|
||||
|
||||
public static CommandCore INSTANCE = new CommandCore(MinecraftClient.getInstance(), ChipmunkMod.CONFIG.core.relativeArea);
|
||||
|
||||
|
@ -30,33 +36,58 @@ public class CommandCore {
|
|||
this.relativeArea = relativeArea;
|
||||
}
|
||||
|
||||
public void init () {
|
||||
if (timer != null) {
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
final TimerTask task = new TimerTask() {
|
||||
public void run () {
|
||||
tick();
|
||||
}
|
||||
};
|
||||
|
||||
timer = new Timer();
|
||||
|
||||
timer.schedule(task, 50, 50);
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null) cleanup();
|
||||
}
|
||||
|
||||
public void reloadRelativeArea () {
|
||||
relativeArea = ChipmunkMod.CONFIG.core.relativeArea;
|
||||
}
|
||||
|
||||
public void move (Vec3d position) {
|
||||
if (!ready) {
|
||||
ready = true;
|
||||
// for (Listener listener : listeners) listener.ready();
|
||||
}
|
||||
|
||||
origin = new BlockPos(
|
||||
((int) position.getX() / 16) * 16,
|
||||
0, // TODO: Use the actual bottom of the world instead of hardcoding to 0
|
||||
((int) position.getZ() / 16) * 16
|
||||
);
|
||||
|
||||
if (currentBlockRelative == null) currentBlockRelative = new BlockPos(relativeArea.start());
|
||||
if (currentBlockRelative == null) currentBlockRelative = new BlockPos(relativeArea.start);
|
||||
refill();
|
||||
|
||||
for (Listener listener : ListenerManager.listeners) listener.coreMoved();
|
||||
if (!ready) {
|
||||
ready = true;
|
||||
|
||||
for (Listener listener : ListenerManager.listeners) listener.coreReady();
|
||||
}
|
||||
}
|
||||
|
||||
public void refill () {
|
||||
// final PositionManager position = client.position();
|
||||
final BlockPos relStart = relativeArea.start();
|
||||
final BlockPos relEnd = relativeArea.end();
|
||||
final BlockPos relStart = relativeArea.start;
|
||||
final BlockPos relEnd = relativeArea.end;
|
||||
|
||||
final String command = String.format(
|
||||
KaboomCheck.INSTANCE.isKaboom() ?
|
||||
KaboomCheck.INSTANCE.isKaboom ?
|
||||
"fill %s %s %s %s %s %s repeating_command_block replace" :
|
||||
"fill %s %s %s %s %s %s command_block",
|
||||
relStart.getX() + origin.getX(),
|
||||
|
@ -72,8 +103,8 @@ public class CommandCore {
|
|||
}
|
||||
|
||||
public void incrementCurrentBlock () {
|
||||
final BlockPos start = relativeArea.start();
|
||||
final BlockPos end = relativeArea.end();
|
||||
final BlockPos start = relativeArea.start;
|
||||
final BlockPos end = relativeArea.end;
|
||||
|
||||
int x = currentBlockRelative.getX();
|
||||
int y = currentBlockRelative.getY();
|
||||
|
@ -131,8 +162,7 @@ public class CommandCore {
|
|||
|
||||
final TimerTask queryTask = new TimerTask() {
|
||||
public void run () {
|
||||
client.getNetworkHandler().getDataQueryHandler().queryBlockNbt(currentBlock,
|
||||
future::complete);
|
||||
client.getNetworkHandler().getDataQueryHandler().queryBlockNbt(currentBlock, future::complete);
|
||||
|
||||
timer.cancel(); // ? Is this necesary?
|
||||
timer.purge();
|
||||
|
@ -145,6 +175,11 @@ public class CommandCore {
|
|||
}
|
||||
|
||||
public void cleanup () {
|
||||
if (timer == null) return;
|
||||
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
|
||||
origin = null;
|
||||
currentBlockRelative = null;
|
||||
ready = false;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
|
@ -9,7 +9,7 @@ import java.util.TimerTask;
|
|||
|
||||
public class CommandLoopManager {
|
||||
private final CommandCore core;
|
||||
@Getter @Setter private List<CommandLoop> commandLoops = new ArrayList<>();
|
||||
public List<CommandLoop> commandLoops = new ArrayList<>();
|
||||
|
||||
public CommandLoopManager (CommandCore core) {
|
||||
this.core = core;
|
||||
|
@ -40,9 +40,9 @@ public class CommandLoopManager {
|
|||
public void cleanup () { this.clearLoops(); }
|
||||
|
||||
public static class CommandLoop {
|
||||
@Getter @Setter private CommandCore core;
|
||||
@Getter @Setter private String command;
|
||||
@Getter private long interval;
|
||||
public CommandCore core;
|
||||
public String command;
|
||||
public long interval;
|
||||
private Timer timer;
|
||||
|
||||
public CommandLoop (CommandCore core, String command, long interval) {
|
||||
|
|
|
@ -2,8 +2,8 @@ package land.chipmunk.chipmunkmod.modules;
|
|||
|
||||
import com.google.gson.JsonElement;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
@ -17,9 +17,9 @@ public class CustomChat {
|
|||
|
||||
public static final CustomChat INSTANCE = new CustomChat(MinecraftClient.getInstance());
|
||||
|
||||
@Getter @Setter private boolean enabled = true;
|
||||
public boolean enabled = true;
|
||||
|
||||
@Getter @Setter private String format;
|
||||
public String format;
|
||||
|
||||
public CustomChat (MinecraftClient client) {
|
||||
this.client = client;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class FullBright {
|
||||
@Getter @Setter private static boolean enabled = ChipmunkMod.CONFIG.fullbright;
|
||||
}
|
|
@ -2,7 +2,7 @@ package land.chipmunk.chipmunkmod.modules;
|
|||
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import lombok.Getter;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
|
@ -18,7 +18,7 @@ public class KaboomCheck extends Listener {
|
|||
|
||||
public static final String SUBTITLE_START_TEXT = "Free OP";
|
||||
|
||||
@Getter private boolean isKaboom = false;
|
||||
public boolean isKaboom = false;
|
||||
|
||||
private boolean hasKaboomTitle = false;
|
||||
private boolean hasKaboomSubtitle = false;
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class LoopCrouch {
|
||||
public static final LoopCrouch INSTANCE = new LoopCrouch();
|
||||
|
||||
@Getter @Setter private boolean enabled = false;
|
||||
|
||||
@Getter @Setter private boolean sneaking = false;
|
||||
|
||||
public LoopCrouch () {
|
||||
}
|
||||
|
||||
public void init () {}
|
||||
}
|
|
@ -3,11 +3,11 @@ package land.chipmunk.chipmunkmod.modules;
|
|||
import com.mojang.brigadier.Message;
|
||||
import com.mojang.brigadier.suggestion.Suggestion;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.data.MutablePlayerListEntry;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import land.chipmunk.chipmunkmod.mixin.ClientPlayNetworkHandlerAccessor;
|
||||
import land.chipmunk.chipmunkmod.mixin.PlayerListEntryAccessor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
|
@ -75,7 +75,7 @@ public class Players extends Listener {
|
|||
public final MutablePlayerListEntry getEntry (UUID uuid) {
|
||||
try {
|
||||
for (MutablePlayerListEntry candidate : list) {
|
||||
if (candidate.profile().getId().equals(uuid)) {
|
||||
if (candidate.profile.getId().equals(uuid)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class Players extends Listener {
|
|||
|
||||
public final MutablePlayerListEntry getEntry (String username) {
|
||||
for (MutablePlayerListEntry candidate : list) {
|
||||
if (candidate.profile().getName().equals(username)) {
|
||||
if (candidate.profile.getName().equals(username)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public class Players extends Listener {
|
|||
|
||||
public final MutablePlayerListEntry getEntry (Text displayName) {
|
||||
for (MutablePlayerListEntry candidate : list) {
|
||||
if (candidate.displayName() != null && candidate.displayName().equals(displayName)) {
|
||||
if (candidate.displayName != null && candidate.displayName.equals(displayName)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
@ -114,11 +114,13 @@ public class Players extends Listener {
|
|||
try {
|
||||
final MutablePlayerListEntry duplicate = getEntry(newEntry);
|
||||
if (duplicate != null) {
|
||||
removeFromPlayerList(duplicate.profile().getId());
|
||||
removeFromPlayerList(duplicate.profile.getId());
|
||||
list.remove(duplicate);
|
||||
}
|
||||
|
||||
list.add(new MutablePlayerListEntry(newEntry));
|
||||
final MutablePlayerListEntry entry = new MutablePlayerListEntry(newEntry);
|
||||
|
||||
list.add(entry);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -129,7 +131,15 @@ public class Players extends Listener {
|
|||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
target.gamemode(newEntry.gameMode());
|
||||
target.gamemode = newEntry.gameMode();
|
||||
|
||||
final ClientPlayNetworkHandlerAccessor accessor = ((ClientPlayNetworkHandlerAccessor) MinecraftClient.getInstance().getNetworkHandler());
|
||||
|
||||
if (accessor == null) return;
|
||||
|
||||
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profile().getId());
|
||||
|
||||
entryAccessor.setGameMode(newEntry.gameMode());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -139,14 +149,28 @@ public class Players extends Listener {
|
|||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
target.latency(newEntry.latency());
|
||||
target.latency = newEntry.latency();
|
||||
|
||||
final ClientPlayNetworkHandlerAccessor accessor = ((ClientPlayNetworkHandlerAccessor) MinecraftClient.getInstance().getNetworkHandler());
|
||||
|
||||
if (accessor == null) return;
|
||||
|
||||
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profile().getId());
|
||||
|
||||
entryAccessor.setLatency(newEntry.latency());
|
||||
}
|
||||
|
||||
private void updateDisplayName (PlayerListS2CPacket.Entry newEntry) {
|
||||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
target.displayName(newEntry.displayName());
|
||||
target.displayName = newEntry.displayName();
|
||||
|
||||
final ClientPlayNetworkHandlerAccessor accessor = ((ClientPlayNetworkHandlerAccessor) MinecraftClient.getInstance().getNetworkHandler());
|
||||
|
||||
if (accessor == null) return;
|
||||
|
||||
accessor.playerListEntries().get(newEntry.profile().getId()).setDisplayName(newEntry.displayName());
|
||||
}
|
||||
|
||||
private void removePlayer (UUID uuid) {
|
||||
|
@ -155,7 +179,6 @@ public class Players extends Listener {
|
|||
if (target == null) return;
|
||||
|
||||
if (!serverHasCommand("scoreboard")) {
|
||||
ChipmunkMod.LOGGER.warn("Server doesn't have /scoreboard, so not showing vanished players.");
|
||||
removeFromPlayerList(uuid);
|
||||
return;
|
||||
}
|
||||
|
@ -166,7 +189,7 @@ public class Players extends Listener {
|
|||
|
||||
future.thenApply(packet -> {
|
||||
final Suggestions matches = packet.getSuggestions();
|
||||
final String username = target.profile().getName();
|
||||
final String username = target.profile.getName();
|
||||
|
||||
for (int i = 0; i < matches.getList().size(); i++) {
|
||||
final Suggestion suggestion = matches.getList().get(i);
|
||||
|
@ -179,9 +202,14 @@ public class Players extends Listener {
|
|||
|
||||
list.remove(target);
|
||||
|
||||
// TODO: fix players using /username gone from the player list, the cause is exactly at the next line and it's because uuid i guess
|
||||
removeFromPlayerList(uuid);
|
||||
|
||||
for (MutablePlayerListEntry entry : list) {
|
||||
if (!entry.profile.getId().equals(uuid)) continue;
|
||||
|
||||
addToPlayerList(new PlayerListEntry(entry.profile, false));
|
||||
}
|
||||
|
||||
return packet;
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
@ -189,6 +217,18 @@ public class Players extends Listener {
|
|||
}
|
||||
}
|
||||
|
||||
public void addToPlayerList (PlayerListEntry entry) {
|
||||
client.getSocialInteractionsManager().setPlayerOnline(entry);
|
||||
|
||||
final ClientPlayNetworkHandlerAccessor accessor = ((ClientPlayNetworkHandlerAccessor) MinecraftClient.getInstance().getNetworkHandler());
|
||||
|
||||
if (accessor == null) return;
|
||||
|
||||
accessor.playerListEntries().put(entry.getProfile().getId(), entry);
|
||||
|
||||
accessor.listedPlayerListEntries().add(entry);
|
||||
}
|
||||
|
||||
private void removeFromPlayerList (UUID uuid) {
|
||||
client.getSocialInteractionsManager().setPlayerOffline(uuid);
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import land.chipmunk.chipmunkmod.util.ColorUtilities;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
@ -23,10 +23,10 @@ public class RainbowName {
|
|||
|
||||
private Timer timer = null;
|
||||
|
||||
@Getter @Setter private boolean enabled = false;
|
||||
public boolean enabled = false;
|
||||
|
||||
|
||||
@Getter @Setter private String displayName;
|
||||
public String displayName;
|
||||
|
||||
private int startHue = 0;
|
||||
|
||||
|
|
|
@ -3,11 +3,12 @@ package land.chipmunk.chipmunkmod.modules;
|
|||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Timer;
|
||||
|
@ -17,21 +18,23 @@ import static land.chipmunk.chipmunkmod.util.ServerUtilities.serverHasCommand;
|
|||
|
||||
public class SelfCare extends Listener {
|
||||
private final MinecraftClient client;
|
||||
@Getter private final long interval;
|
||||
@Getter private final long chatInterval;
|
||||
public final long interval;
|
||||
public final long chatInterval;
|
||||
|
||||
@Getter @Setter private boolean opEnabled = true;
|
||||
@Getter @Setter private boolean gamemodeEnabled = true;
|
||||
@Getter @Setter private boolean cspyEnabled = true;
|
||||
public boolean opEnabled = true;
|
||||
public boolean gamemodeEnabled = true;
|
||||
public boolean cspyEnabled = true;
|
||||
|
||||
@Getter @Setter private String skin;
|
||||
private int gameMode;
|
||||
|
||||
private boolean cspy = false;
|
||||
@Getter @Setter private boolean hasSkin = false;
|
||||
public String skin;
|
||||
|
||||
private Timer timer = null;
|
||||
private Timer chatTimer = null;
|
||||
|
||||
private boolean cspy = false;
|
||||
public boolean hasSkin = false;
|
||||
|
||||
public static final SelfCare INSTANCE = new SelfCare(MinecraftClient.getInstance(), 70L, 500L); // make the intervals in config?
|
||||
|
||||
public SelfCare (MinecraftClient client, long interval, long chatInterval) {
|
||||
|
@ -44,7 +47,9 @@ public class SelfCare extends Listener {
|
|||
ListenerManager.addListener(this);
|
||||
}
|
||||
|
||||
public void init () {
|
||||
public void init () {}
|
||||
|
||||
public void onJoin () {
|
||||
final TimerTask task = new TimerTask() {
|
||||
public void run () {
|
||||
tick();
|
||||
|
@ -57,8 +62,6 @@ public class SelfCare extends Listener {
|
|||
}
|
||||
};
|
||||
|
||||
if (timer != null || chatTimer != null) cleanup();
|
||||
|
||||
timer = new Timer();
|
||||
chatTimer = new Timer();
|
||||
|
||||
|
@ -71,11 +74,11 @@ public class SelfCare extends Listener {
|
|||
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
timer = null;
|
||||
|
||||
chatTimer.cancel();
|
||||
chatTimer.purge();
|
||||
chatTimer = null;
|
||||
|
||||
gameMode = -1;
|
||||
|
||||
hasSkin = false;
|
||||
// cspy too mabe?
|
||||
|
@ -105,7 +108,7 @@ public class SelfCare extends Listener {
|
|||
}
|
||||
|
||||
if (player != null && !player.hasPermissionLevel(2) && opEnabled) { if (serverHasCommand("op")) networkHandler.sendChatCommand("op @s[type=player]"); }
|
||||
else if (client.player != null && !client.player.isCreative() && gamemodeEnabled) networkHandler.sendChatCommand("gamemode creative");
|
||||
else if (gameMode != 1 && gamemodeEnabled) networkHandler.sendChatCommand("gamemode creative");
|
||||
}
|
||||
|
||||
public void chatTick () {
|
||||
|
@ -114,4 +117,20 @@ public class SelfCare extends Listener {
|
|||
if (!cspy && cspyEnabled) { if (serverHasCommand("c")) networkHandler.sendChatCommand("c on"); }
|
||||
else if (!hasSkin && !skin.equals("off")) { if (serverHasCommand("skin")) networkHandler.sendChatCommand("skin " + skin); }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetReceived(Packet<?> packet) {
|
||||
if (packet instanceof GameJoinS2CPacket) packetReceived((GameJoinS2CPacket) packet);
|
||||
else if (packet instanceof GameStateChangeS2CPacket) packetReceived((GameStateChangeS2CPacket) packet);
|
||||
}
|
||||
|
||||
public void packetReceived(GameJoinS2CPacket packet) {
|
||||
gameMode = packet.gameMode().getId();
|
||||
}
|
||||
|
||||
public void packetReceived(GameStateChangeS2CPacket packet) {
|
||||
if (packet.getReason() != GameStateChangeS2CPacket.GAME_MODE_CHANGED) return;
|
||||
|
||||
gameMode = (int) packet.getValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import land.chipmunk.chipmunkmod.song.Song;
|
|||
import land.chipmunk.chipmunkmod.song.SongLoaderException;
|
||||
import land.chipmunk.chipmunkmod.song.SongLoaderThread;
|
||||
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
@ -42,16 +42,16 @@ public class SongPlayer {
|
|||
|
||||
public static final SongPlayer INSTANCE = new SongPlayer(MinecraftClient.getInstance());
|
||||
|
||||
@Getter @Setter private Song currentSong;
|
||||
@Getter @Setter private LinkedList<Song> songQueue = new LinkedList<>();
|
||||
@Getter @Setter private Timer playTimer;
|
||||
@Getter @Setter private SongLoaderThread loaderThread;
|
||||
public Song currentSong;
|
||||
public LinkedList<Song> songQueue = new LinkedList<>();
|
||||
public Timer playTimer;
|
||||
public SongLoaderThread loaderThread;
|
||||
private int ticksUntilPausedActionbar = 20;
|
||||
|
||||
@Getter @Setter private boolean useCore = true;
|
||||
@Getter @Setter private boolean actionbar = true;
|
||||
public boolean useCore = true;
|
||||
public boolean actionbar = true;
|
||||
|
||||
@Getter @Setter private float pitch = 0;
|
||||
public float pitch = 0;
|
||||
|
||||
private final MinecraftClient client;
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class SongPlayer {
|
|||
_loaderThread.start();
|
||||
loaderThread = _loaderThread;
|
||||
} catch (SongLoaderException e) {
|
||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message()).color(NamedTextColor.RED));
|
||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message).color(NamedTextColor.RED));
|
||||
loaderThread = null;
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class SongPlayer {
|
|||
_loaderThread.start();
|
||||
loaderThread = _loaderThread;
|
||||
} catch (SongLoaderException e) {
|
||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message()).color(NamedTextColor.RED));
|
||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message).color(NamedTextColor.RED));
|
||||
loaderThread = null;
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class SongPlayer {
|
|||
|
||||
if (loaderThread != null && !loaderThread.isAlive()) {
|
||||
if (loaderThread.exception != null) {
|
||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", loaderThread.exception.message()).color(NamedTextColor.RED));
|
||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", loaderThread.exception.message).color(NamedTextColor.RED));
|
||||
} else {
|
||||
songQueue.add(loaderThread.song);
|
||||
client.player.sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.util.concurrent.CompletableFuture;
|
|||
public class TabComplete extends Listener {
|
||||
private final MinecraftClient client;
|
||||
|
||||
private int nextTransactionId = 0;
|
||||
private final Map<Integer, CompletableFuture<CommandSuggestionsS2CPacket>> transactions = new HashMap<>();
|
||||
|
||||
public static TabComplete INSTANCE = new TabComplete(MinecraftClient.getInstance());
|
||||
|
@ -37,7 +36,7 @@ public class TabComplete extends Listener {
|
|||
|
||||
if (connection == null) return null;
|
||||
|
||||
final int transactionId = nextTransactionId++;
|
||||
final int transactionId = TransactionManager.INSTANCE.nextTransactionId();
|
||||
connection.send(new RequestCommandCompletionsC2SPacket(transactionId, command));
|
||||
|
||||
final CompletableFuture<CommandSuggestionsS2CPacket> future = new CompletableFuture<>();
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
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++; }
|
||||
}
|
|
@ -1,14 +1,19 @@
|
|||
package land.chipmunk.chipmunkmod.song;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class Note implements Comparable<Note> {
|
||||
public Instrument instrument;
|
||||
public int pitch;
|
||||
public float volume;
|
||||
public long time;
|
||||
|
||||
public Note (Instrument instrument, int pitch, float volume, long time) {
|
||||
this.instrument = instrument;
|
||||
this.pitch = pitch;
|
||||
this.volume = volume;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Note other) {
|
||||
if (time < other.time) {
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package land.chipmunk.chipmunkmod.song;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class SongLoaderException extends Exception {
|
||||
@Getter private final Text message;
|
||||
public final Text message;
|
||||
|
||||
public SongLoaderException (Text message) {
|
||||
super();
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
package land.chipmunk.chipmunkmod.util;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.Configuration;
|
||||
import land.chipmunk.chipmunkmod.modules.CustomChat;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BotValidationUtilities {
|
||||
public static int hbot (String command) throws RuntimeException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.hbot;
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw new RuntimeException("The key of the bot is unspecified (null), did you incorrectly add it to your config?");
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 10000);
|
||||
String input = command.replaceAll("&[0-9a-fklmnor]", "") + ";" + client.player.getUuidAsString() + ";" + time + ";" + key;
|
||||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
||||
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
||||
|
||||
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int sbot (String command) throws RuntimeException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.sbot;
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw new RuntimeException("The key of the bot is unspecified (null), did you incorrectly add it to your config?");
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 20000);
|
||||
String input = prefix + command.replaceAll("&[0-9a-fklmnorx]", "") + ";" + client.player.getName() + ";" + time + ";" + key;
|
||||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
||||
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
||||
|
||||
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int chomens (String command) throws RuntimeException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.chomens;
|
||||
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw new RuntimeException("The key of the bot is unspecified (null), did you incorrectly add it to your config?");
|
||||
|
||||
try {
|
||||
String[] arguments = command.split(" ");
|
||||
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 5_000);
|
||||
String input = client.player.getUuidAsString() + arguments[0] + time + key;
|
||||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
String stringHash = Hexadecimal.encode(hash).substring(0, 16);
|
||||
|
||||
final String toSend = prefix + arguments[0] + " " + stringHash + " " + String.join(" ", Arrays.copyOfRange(arguments, 1, arguments.length));
|
||||
|
||||
CustomChat.INSTANCE.chat(toSend);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int kittycorp (String command) throws RuntimeException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.kittycorp;
|
||||
final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw new RuntimeException("The key of the bot is unspecified (null), did you incorrectly add it to your config?");
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 10000);
|
||||
String input = prefix + command.replaceAll("&[0-9a-fklmnorx]", "") + ";" + time + ";" + key;
|
||||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
|
||||
String stringHash = bigInt.toString(Character.MAX_RADIX);
|
||||
|
||||
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package land.chipmunk.chipmunkmod.util;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UUIDUtilities {
|
||||
public static int[] intArray (UUID uuid) {
|
||||
final ByteBuffer buffer = ByteBuffer.wrap(new byte[16]);
|
||||
buffer.putLong(0, uuid.getMostSignificantBits());
|
||||
buffer.putLong(8, uuid.getLeastSignificantBits());
|
||||
|
||||
final int[] intArray = new int[4];
|
||||
for (int i = 0; i < intArray.length; i++) intArray[i] = buffer.getInt();
|
||||
|
||||
return intArray;
|
||||
}
|
||||
|
||||
public static String snbt (UUID uuid) {
|
||||
int[] array = intArray(uuid);
|
||||
return "[I;" + array[0] + "," + array[1] + "," + array[2] + "," + array[3] + "]"; // TODO: improve lol
|
||||
}
|
||||
|
||||
public static String selector (UUID uuid) { return "@a[limit=1,nbt={UUID:" + snbt(uuid) + "}]"; }
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
"package": "land.chipmunk.chipmunkmod.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"ChatHudMixin",
|
||||
"ChatInputSuggestorMixin",
|
||||
"ChatScreenMixin",
|
||||
"ClientConnectionAccessor",
|
||||
|
@ -14,7 +13,10 @@
|
|||
"ClientPlayNetworkHandlerAccessor",
|
||||
"ClientPlayNetworkHandlerInvoker",
|
||||
"ClientPlayNetworkHandlerMixin",
|
||||
"MinecraftClientAccessor",
|
||||
"DecoderHandlerMixin",
|
||||
"StringHelperMixin",
|
||||
"NbtIoMixin",
|
||||
"DecoratedPotBlockEntitySherdsMixin",
|
||||
"ElderGuardianAppearanceParticleMixin",
|
||||
"FontStorageMixin",
|
||||
|
@ -29,7 +31,10 @@
|
|||
"SessionMixin",
|
||||
"StringHelperMixin",
|
||||
"TextMixin",
|
||||
"TitleScreenMixin"
|
||||
"ClientConnectionInvoker",
|
||||
"TitleScreenMixin",
|
||||
"PlayerListEntryAccessor",
|
||||
"SharedConstantsMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"depends": {
|
||||
"fabricloader": ">=0.14.21",
|
||||
"fabric-api": "*",
|
||||
"minecraft": "~1.20.1",
|
||||
"minecraft": ">1.20",
|
||||
"java": ">=17"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue