forked from ChomeNS/chipmunkmod
Compare commits
121 commits
Author | SHA1 | Date | |
---|---|---|---|
bf46a9ef4f | |||
23c4b60f00 | |||
98ec1f7741 | |||
9260fb46b2 | |||
8b6b7b71fc | |||
4dbf7925cc | |||
dcfbdfc544 | |||
9e6b14de91 | |||
5416cbf6f9 | |||
deeb89bb45 | |||
de55b8208e | |||
9d9283c70b | |||
fa7a41cecd | |||
2dd7443d4c | |||
|
951d4e35c1 | ||
|
fef81cc15f | ||
245c625b4c | |||
42ec7a2698 | |||
31f49729fd | |||
d72b215fe4 | |||
5f00a1925b | |||
f3a259384c | |||
16472506c2 | |||
63967e407d | |||
08c3773660 | |||
c04380b420 | |||
43939452fc | |||
ee5b2a0892 | |||
e15953918d | |||
d931a8abd1 | |||
bc738a6f25 | |||
1604b0a996 | |||
e0c7804aa7 | |||
c2170ddfcd | |||
706fff00d4 | |||
78689abe93 | |||
8fce7f0ee6 | |||
fedd15b946 | |||
b5ba97afaf | |||
11dbc4665a | |||
72bec0fbbf | |||
44dffc37a2 | |||
ec6a142b73 | |||
a794ebd7d3 | |||
d194d6baa2 | |||
5cf5163d75 | |||
80d67f17f8 | |||
b231e5e3d6 | |||
e1bbd2fa08 | |||
4c1ff7a0aa | |||
bb30748a00 | |||
40c9f94293 | |||
e4b1f66bb3 | |||
a153b0befb | |||
9d7d16c643 | |||
198ec68b43 | |||
bc35032c02 | |||
6a26456bc1 | |||
d987be251f | |||
4e07c1083a | |||
f75dbac63a | |||
9ebd9154d9 | |||
6ea08ab4dc | |||
994cbba173 | |||
82b5259b44 | |||
64fd0d1ad4 | |||
5ec6250570 | |||
e61407fa22 | |||
2feee9503d | |||
ce49c7238c | |||
701ad44325 | |||
e578d45490 | |||
306319e6a1 | |||
5ca7f086cf | |||
2a101f1576 | |||
10dca6c786 | |||
a9972c323c | |||
2081ed9423 | |||
1b7ace7aa8 | |||
0aedbff525 | |||
9a92ccbfec | |||
2452f555ef | |||
143a47162d | |||
49327ce22e | |||
0af580f804 | |||
03478b3133 | |||
e55b9e51b4 | |||
5a68eb0848 | |||
2d4e319c93 | |||
|
ffa8145854 | ||
1547326a54 | |||
402ddef938 | |||
3328fa4ff1 | |||
7afcc606fe | |||
02488b4289 | |||
bf7fd7df93 | |||
efe2e56cb5 | |||
9c99b9edcf | |||
535154a1a0 | |||
b86e6d649e | |||
99d37d33f9 | |||
a2b2de94f9 | |||
d286767f7a | |||
fd6dd2593b | |||
7e232a4115 | |||
b2d9d994fe | |||
3810b4e611 | |||
29ef3324fc | |||
e51eae558c | |||
7bf9886cb1 | |||
7206ef4629 | |||
3eac1f2c73 | |||
753c096308 | |||
2bcded3997 | |||
6a06c8589d | |||
b3dcef2232 | |||
914c9d9075 | |||
09749e3725 | |||
1b671635ce | |||
2d60606de3 | |||
3530238408 |
137 changed files with 3236 additions and 1974 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -38,3 +38,4 @@ hs_err_*.log
|
|||
replay_*.log
|
||||
*.hprof
|
||||
*.jfr
|
||||
/buildAndSend.sh
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
# ChipmunkMod
|
||||
My fork of [Chipmunk Sex Mod](https://code.chipmunk.land/ChipmunkMC/chipmunkmod)
|
||||
My fork of [chipmunkmod (chayapak fork)](https://code.chipmunk.land/ChomeNS/chipmunkmod)
|
||||
|
||||
ignore messy code pls,. .,,.,...,.,.,
|
||||
## alexa how to install
|
||||
go to [releases](https://code.chipmunk.land/Blackilykat/chipmunkmod/releases) then on the latest one click `chipmunkmod-x.x.x.jar` to download then get [fabricmc](https://fabricmc.net/use/installer/) if you dont have it and then put the downloaded file in your `.minecraft/mods/` folder
|
||||
|
||||
if thats not clear enough ask your search engine how to install a fabric mod
|
||||
|
||||
if it pops up with errors you dont understand [create an issue](https://code.chipmunk.land/Blackilykat/chipmunkmod/issues/new) about it
|
39
build.gradle
39
build.gradle
|
@ -1,10 +1,14 @@
|
|||
plugins {
|
||||
id 'fabric-loom' version '1.0-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/chipmunkmod.accesswidener")
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
version = project.mod_version
|
||||
|
@ -20,7 +24,16 @@ repositories {
|
|||
mavenCentral()
|
||||
}
|
||||
|
||||
// https://github.com/MeteorDevelopment/meteor-client/blob/master/build.gradle#L46
|
||||
configurations {
|
||||
implementation.extendsFrom(library)
|
||||
shadow.extendsFrom(library)
|
||||
include.extendsFrom(library)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.apache.commons:commons-text:1.10.0' // Use the version that best suits your project
|
||||
|
||||
// To change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
|
@ -29,22 +42,24 @@ dependencies {
|
|||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
modImplementation include("net.kyori:adventure-platform-fabric:5.8.0") // for Minecraft 1.19.4
|
||||
library "net.kyori:adventure-platform-fabric:5.14.1" // for Minecraft 1.21-1.21.1
|
||||
|
||||
modImplementation include("net.kyori:adventure-text-serializer-legacy:4.13.1")
|
||||
library "net.kyori:adventure-text-serializer-gson:4.17.0"
|
||||
|
||||
modImplementation include("org.luaj:luaj-jse:3.0.1")
|
||||
library "net.kyori:adventure-text-serializer-legacy:4.17.0"
|
||||
|
||||
// Uncomment the following line to enable the deprecated Fabric API modules.
|
||||
library "org.luaj:luaj-jse:3.0.1"
|
||||
|
||||
// Uncomment the following line to enable the deprecated Fabric API modules.
|
||||
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
|
||||
|
||||
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
||||
|
||||
compileOnly 'org.projectlombok:lombok:1.18.24'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||
compileOnly 'org.projectlombok:lombok:1.18.34'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.34'
|
||||
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.24'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.34'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -57,7 +72,7 @@ processResources {
|
|||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
||||
it.options.release = 17
|
||||
it.options.release = 21
|
||||
}
|
||||
|
||||
java {
|
||||
|
|
|
@ -4,15 +4,15 @@ org.gradle.parallel=true
|
|||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.19.4
|
||||
yarn_mappings=1.19.4+build.2
|
||||
loader_version=0.14.19
|
||||
minecraft_version=1.21.1
|
||||
yarn_mappings=1.21.1+build.3
|
||||
loader_version=0.16.5
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0.0
|
||||
mod_version = 1.0.1
|
||||
maven_group = land.chipmunk.chipmunkmod
|
||||
archives_base_name = chipmunkmod
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.81.1+1.19.4
|
||||
fabric_version=0.105.0+1.21.1
|
||||
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
17
gradlew
vendored
17
gradlew
vendored
|
@ -85,9 +85,6 @@ done
|
|||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
|
@ -125,6 +122,7 @@ if [ -n "$JAVA_HOME" ] ; then
|
|||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
JAVACMD=/usr/bin/java
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
|
@ -133,10 +131,13 @@ location of your Java installation."
|
|||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
|
@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
|
@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then
|
|||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
config.stopBubbling = true
|
||||
lombok.accessors.fluent = true
|
|
@ -1,7 +1,15 @@
|
|||
package land.chipmunk.chipmunkmod;
|
||||
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import land.chipmunk.chipmunkmod.memory.ModuleMemory;
|
||||
import land.chipmunk.chipmunkmod.util.Keybinds;
|
||||
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;
|
||||
|
@ -12,33 +20,60 @@ import java.io.BufferedWriter;
|
|||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
// what the fuck is this indentation who is responsible for this nightmare
|
||||
public class ChipmunkMod implements ModInitializer {
|
||||
// This logger is used to write text to the console and the log file.
|
||||
// It is considered best practice to use your mod id as the logger's name.
|
||||
// That way, it's clear which mod wrote info, warnings, and errors.
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("chipmunkmod");
|
||||
public static Configuration CONFIG;
|
||||
private static File CONFIG_DIR = new File("config");
|
||||
private static File CONFIG_FILE = new File(CONFIG_DIR, "chipmunkmod.json");
|
||||
public static Configuration CONFIG = new Configuration();
|
||||
public static final File CONFIG_DIR = new File("config");
|
||||
private static final File CONFIG_FILE = new File(CONFIG_DIR, "chipmunkmod.json");
|
||||
|
||||
public static ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
||||
|
||||
public static final ModuleMemory MEMORY = new ModuleMemory();
|
||||
|
||||
@Override
|
||||
public void onInitialize () {
|
||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||
// However, some things (like resources) may still be uninitialized.
|
||||
// Proceed with mild caution.
|
||||
|
||||
try {
|
||||
CONFIG = loadConfig();
|
||||
} catch (IOException exception) {
|
||||
throw new RuntimeException("Could not load the config", exception);
|
||||
}
|
||||
Keybinds.registerOpenGui();
|
||||
TickRunnableHandler.registerTickEndRunnables();
|
||||
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 -> {
|
||||
ModuleMemory.save();
|
||||
try {
|
||||
saveConfig();
|
||||
} catch (IOException e) {
|
||||
LOGGER.error("Failed to save config. Printing stacktrace.");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
LOGGER.info("Saved config!");
|
||||
});
|
||||
|
||||
LOGGER.info("Loaded ChipmunkMod (Blackilykat's fork)");
|
||||
}
|
||||
|
||||
|
@ -47,28 +82,43 @@ public class ChipmunkMod implements ModInitializer {
|
|||
|
||||
final Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(BlockPos.class, new BlockPosTypeAdapter())
|
||||
.serializeNulls()
|
||||
.create();
|
||||
final File file = CONFIG_FILE;
|
||||
|
||||
if (!file.exists()) {
|
||||
InputStream is = ChipmunkMod.class.getClassLoader().getResourceAsStream("assets/chipmunkmod/default_config.json");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
while (reader.ready()) sb.append((char) reader.read());
|
||||
final String defaultConfig = sb.toString();
|
||||
|
||||
// Write the default config
|
||||
BufferedWriter configWriter = new BufferedWriter(new FileWriter(file));
|
||||
configWriter.write(defaultConfig);
|
||||
configWriter.close();
|
||||
|
||||
return gson.fromJson(defaultConfig, Configuration.class);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
InputStream is = new FileInputStream(file);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
return gson.fromJson(reader, Configuration.class);
|
||||
Configuration configuration = gson.fromJson(reader, Configuration.class);
|
||||
if(configuration.bots.testbot.webhookUrl == null && configuration.testbotWebhook != null) {
|
||||
LOGGER.info("Updating testbot auth url location in config!");
|
||||
configuration.bots.testbot.webhookUrl = configuration.testbotWebhook;
|
||||
configuration.testbotWebhook = null;
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public static void saveConfig() throws IOException {
|
||||
// to migrate old configs and avoid confusion on which field to use. Exclusion strategy should be removed once no one has the old auth location
|
||||
// in their configs anymore
|
||||
Gson otherGson = new GsonBuilder().serializeNulls().setLenient().setPrettyPrinting().addSerializationExclusionStrategy(new ExclusionStrategy() {
|
||||
@Override
|
||||
public boolean shouldSkipField(FieldAttributes f) {
|
||||
return f.getName().equals("testbotWebhook");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSkipClass(Class<?> clazz) {
|
||||
return false;
|
||||
}
|
||||
}).create();
|
||||
String defaultConfig = otherGson.toJson(CONFIG);
|
||||
BufferedWriter configWriter = new BufferedWriter(new FileWriter(CONFIG_FILE));
|
||||
configWriter.write(defaultConfig);
|
||||
configWriter.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +1,96 @@
|
|||
package land.chipmunk.chipmunkmod;
|
||||
|
||||
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;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
public class Configuration {
|
||||
public CommandManager commands = new CommandManager();
|
||||
public CommandCore core = new CommandCore();
|
||||
public Bots bots = new Bots();
|
||||
public CustomChat customChat = new CustomChat();
|
||||
public boolean fullbright = true; // should this be false?
|
||||
public AntiSpam antiSpam = new AntiSpam();
|
||||
public String autoSkinUsername = "off";
|
||||
// here so old configs can be migrated
|
||||
public String testbotWebhook = null;
|
||||
public String defaultUsername = null;
|
||||
public Memory memory = new Memory();
|
||||
|
||||
public static class CommandManager {
|
||||
public String prefix = ".";
|
||||
}
|
||||
|
||||
public static class CommandCore {
|
||||
public BlockArea relativeArea = new BlockArea(new BlockPos(0, 0, 0), new BlockPos(15, 0, 15));
|
||||
}
|
||||
|
||||
public static class Bots {
|
||||
public BotInfo hbot = new BotInfo("#", null);
|
||||
public BotInfo sbot = new BotInfo(":", null);
|
||||
public BotInfo chipmunk = new BotInfo("'", null);
|
||||
public BotInfo chomens = new BotInfo("*", null);
|
||||
public ChomeNSBotInfo chomens = new ChomeNSBotInfo("*", null, null, null);
|
||||
public BotInfo fnfboyfriend = new BotInfo("~", null);
|
||||
public BotInfo nbot = new BotInfo("?", null);
|
||||
public BotInfo kittycorp = new BotInfo("^", null);
|
||||
public BotInfo testbot = new BotInfo("-", null);
|
||||
public TestBotInfo testbot = new TestBotInfo("-", null);
|
||||
}
|
||||
|
||||
public static class ChomeNSBotInfo {
|
||||
public String prefix;
|
||||
public String key;
|
||||
public String authKey;
|
||||
public String formatKey;
|
||||
|
||||
public ChomeNSBotInfo (String prefix, String key, String authKey, String formatKey) {
|
||||
this.prefix = prefix;
|
||||
this.key = key;
|
||||
this.authKey = authKey;
|
||||
this.formatKey = formatKey;
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
public JsonObject format;
|
||||
public JsonObject format = new Gson().fromJson("""
|
||||
{
|
||||
"translate": "chat.type.text",
|
||||
"with": [
|
||||
{
|
||||
"selector": "USERNAME"
|
||||
},
|
||||
{
|
||||
"text": "MESSAGE"
|
||||
}
|
||||
]
|
||||
}
|
||||
""", JsonObject.class);
|
||||
}
|
||||
|
||||
public static class AntiSpam {
|
||||
public int matchingMessagesToBeSpam = 20;
|
||||
public int messageTimeInTicks = 100;
|
||||
public int minimumLevenshteinDistanceToBeSpam = 20;
|
||||
}
|
||||
|
||||
public static class Memory {
|
||||
public HashMap<String, Boolean> categories = new HashMap<>();
|
||||
public HashMap<String, Boolean> modules = new HashMap<>();
|
||||
public HashMap<String, String> options = new HashMap<>(); // will convert all values to their type according to the method specified in the option type thing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.mojang.brigadier.arguments.ArgumentType;
|
|||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.Texts;
|
||||
|
@ -33,15 +32,14 @@ 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);
|
||||
AutoDeopCommand.register(this.dispatcher);
|
||||
DebugCommand.register(this.dispatcher);
|
||||
SelfCareCommand.register(this.dispatcher);
|
||||
ClearAntiChatSpamQueueCommand.register(this.dispatcher);
|
||||
}
|
||||
|
||||
public void executeCommand (String command) {
|
||||
|
@ -55,9 +53,7 @@ public class CommandManager {
|
|||
commandSource.sendError(Texts.toText(e.getRawMessage()));
|
||||
final Text context = getContext(e);
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.commands;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoDeopModule;
|
||||
import land.chipmunk.chipmunkmod.util.Chat;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.string;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
|
||||
public class AutoDeopCommand {
|
||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
final AutoDeopCommand instance = new AutoDeopCommand();
|
||||
dispatcher.register(
|
||||
literal("autodeop")
|
||||
.then(
|
||||
literal("add")
|
||||
.then(argument("username", string()).executes(instance::add))
|
||||
)
|
||||
.then(
|
||||
literal("remove")
|
||||
.then(argument("username", string()).executes(instance::remove))
|
||||
)
|
||||
.then(
|
||||
literal("list").executes(instance::list)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public int add(CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
String username = getString(context, "username");
|
||||
if(AutoDeopModule.players.contains(username)) {
|
||||
throw new SimpleCommandExceptionType(Text.translatable("That player is already in the AutoDeop list!")).create();
|
||||
}
|
||||
AutoDeopModule.players.add(username);
|
||||
Chat.sendGreen("Added " + username + " to the AutoDeop list!");
|
||||
return 1;
|
||||
}
|
||||
public int remove(CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
String username = getString(context, "username");
|
||||
if(!AutoDeopModule.players.contains(username)) {
|
||||
throw new SimpleCommandExceptionType(Text.translatable("That player is not in the AutoDeop list!")).create();
|
||||
}
|
||||
AutoDeopModule.players.remove(username);
|
||||
Chat.sendGreen("Removed " + username + " to the AutoDeop list!");
|
||||
return 1;
|
||||
}
|
||||
public int list(CommandContext<FabricClientCommandSource> context) {
|
||||
Chat.sendGold("AutoDeop player list:");
|
||||
for (String player : AutoDeopModule.players) {
|
||||
Chat.send(" - " + player);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package land.chipmunk.chipmunkmod.commands;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import land.chipmunk.chipmunkmod.util.Chat;
|
||||
import land.chipmunk.chipmunkmod.util.Executor;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
|
||||
public class ClearAntiChatSpamQueueCommand {
|
||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
final ClearAntiChatSpamQueueCommand instance = new ClearAntiChatSpamQueueCommand();
|
||||
dispatcher.register(
|
||||
literal("clearantichatspamqueue")
|
||||
.executes(instance::run)
|
||||
);
|
||||
}
|
||||
|
||||
public int run(CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
List<Runnable> runnables = Executor.antiChatSpamService.shutdownNow();
|
||||
Executor.antiChatSpamService = Executors.newFixedThreadPool(1);
|
||||
Chat.sendGreen("Stopped " + runnables.size() + " chat messages from getting recieved!");
|
||||
return 1;
|
||||
}
|
||||
}
|
|
@ -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++;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
package land.chipmunk.chipmunkmod.commands;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
|
||||
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 land.chipmunk.chipmunkmod.util.TextUtilities;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
@ -35,6 +41,14 @@ public class CoreCommand {
|
|||
|
||||
.then(literal("refill").executes(c -> refill(c)))
|
||||
.then(literal("move").executes(c -> move(c)))
|
||||
|
||||
.then(
|
||||
literal("runFillCommand")
|
||||
.then(
|
||||
argument("enabled", bool())
|
||||
.executes(c -> runFillCommand(c))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -53,8 +67,9 @@ public class CoreCommand {
|
|||
future.thenApply(tag -> {
|
||||
try {
|
||||
final String output = tag.getString("LastOutput");
|
||||
if (output != null) source.sendFeedback(Text.Serializer.fromJson(output));
|
||||
} catch (Exception ignored) {
|
||||
if (output != null) source.sendFeedback(TextUtilities.fromJson(output));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return tag;
|
||||
|
@ -76,4 +91,16 @@ public class CoreCommand {
|
|||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int runFillCommand(CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
|
||||
final boolean bool = getBool(context, "enabled");
|
||||
|
||||
CommandCore.INSTANCE.runFillCommand = bool;
|
||||
|
||||
source.sendFeedback(Text.literal("Running fill commands are now " + (bool ? "enabled" : "disabled")));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.brigadier.Command;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import land.chipmunk.chipmunkmod.modules.CustomChat;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.fun.CustomChatModule;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
|
@ -38,7 +39,8 @@ 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;
|
||||
CustomChatModule.INSTANCE.isEnabled = bool;
|
||||
source.sendFeedback(Text.literal("Custom chat is now " + (bool ? "on" : "off")));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
@ -47,7 +49,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;
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package land.chipmunk.chipmunkmod.commands;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
import land.chipmunk.chipmunkmod.util.Debug;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.string;
|
||||
|
||||
public class DebugCommand {
|
||||
public static SuggestionProvider<FabricClientCommandSource> knownSuggestions = (context, builder) -> {
|
||||
Debug.known.stream()
|
||||
.filter(option -> option.startsWith(builder.getRemaining().toLowerCase()))
|
||||
.forEach(builder::suggest);
|
||||
return builder.buildFuture();
|
||||
};
|
||||
public static SuggestionProvider<FabricClientCommandSource> selectedSuggestions = (context, builder) -> {
|
||||
Debug.selected.stream()
|
||||
.filter(option -> option.startsWith(builder.getRemaining().toLowerCase()))
|
||||
.forEach(builder::suggest);
|
||||
return builder.buildFuture();
|
||||
};
|
||||
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
dispatcher.register(
|
||||
literal("debug")
|
||||
.then(literal("add")
|
||||
.then(argument("caller", string())
|
||||
.suggests(knownSuggestions)
|
||||
.executes(DebugCommand::add)))
|
||||
.then(literal("remove")
|
||||
.then(argument("caller", string())
|
||||
.suggests(selectedSuggestions)
|
||||
.executes(DebugCommand::remove)))
|
||||
.then(literal("clear")
|
||||
.executes(DebugCommand::clear))
|
||||
);
|
||||
}
|
||||
|
||||
public static int add(CommandContext<FabricClientCommandSource> context) {
|
||||
String caller = context.getArgument("caller", String.class);
|
||||
Debug.selected.add(caller);
|
||||
context.getSource().sendFeedback(Text.literal("Added ").append(Text.literal(caller).formatted(Formatting.YELLOW)).append(Text.literal(" to the debug list!")));
|
||||
return 0;
|
||||
}
|
||||
public static int remove(CommandContext<FabricClientCommandSource> context) {
|
||||
String caller = context.getArgument("caller", String.class);
|
||||
Debug.selected.remove(caller);
|
||||
context.getSource().sendFeedback(Text.literal("Removed ").append(Text.literal(caller).formatted(Formatting.YELLOW)).append(Text.literal(" from the debug list!")));
|
||||
return 0;
|
||||
}
|
||||
public static int clear(CommandContext<FabricClientCommandSource> context) {
|
||||
Debug.selected = new ArrayList<>();
|
||||
context.getSource().sendFeedback(Text.literal("Cleared the debug list!"));
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ 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.util.Eval;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -21,14 +22,22 @@ public class EvalCommand {
|
|||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
dispatcher.register(
|
||||
literal("eval")
|
||||
.then(
|
||||
argument("code", greedyString())
|
||||
.executes(EvalCommand::eval)
|
||||
.then(literal("java")
|
||||
.then(
|
||||
argument("code", greedyString())
|
||||
.executes(EvalCommand::evalJava)
|
||||
)
|
||||
)
|
||||
.then(literal("lua")
|
||||
.then(
|
||||
argument("code", greedyString())
|
||||
.executes(EvalCommand::evalLua)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static int eval (CommandContext<FabricClientCommandSource> context) {
|
||||
public static int evalLua(CommandContext<FabricClientCommandSource> context) {
|
||||
final String code = getString(context, "code");
|
||||
|
||||
try {
|
||||
|
@ -45,6 +54,13 @@ public class EvalCommand {
|
|||
context.getSource().sendError(Text.literal(e.toString()));
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
public static int evalJava(CommandContext<FabricClientCommandSource> context) {
|
||||
final String code = getString(context, "code");
|
||||
|
||||
Eval.shell(code);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import land.chipmunk.chipmunkmod.command.CommandManager;
|
|||
import land.chipmunk.chipmunkmod.modules.SongPlayer;
|
||||
import land.chipmunk.chipmunkmod.song.Song;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.JoinConfiguration;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
@ -24,6 +25,8 @@ import java.util.List;
|
|||
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
|
||||
import static com.mojang.brigadier.arguments.FloatArgumentType.floatArg;
|
||||
import static com.mojang.brigadier.arguments.FloatArgumentType.getFloat;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
|
||||
import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
|
||||
import static com.mojang.brigadier.arguments.LongArgumentType.getLong;
|
||||
|
@ -58,10 +61,10 @@ public class MusicCommand {
|
|||
|
||||
.then(
|
||||
literal("list")
|
||||
.executes(c -> instance.list(c, root))
|
||||
.executes(c -> instance.list(root))
|
||||
.then(
|
||||
argument("location", filepath(root))
|
||||
.executes(c -> instance.list(c, getPath(c, "location")))
|
||||
.executes(c -> instance.list(getPath(c, "location")))
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -81,6 +84,7 @@ public class MusicCommand {
|
|||
.executes(instance::gotoCommand)
|
||||
)
|
||||
)
|
||||
|
||||
.then(
|
||||
literal("useCore")
|
||||
.then(
|
||||
|
@ -88,6 +92,22 @@ public class MusicCommand {
|
|||
.executes(instance::useCore)
|
||||
)
|
||||
)
|
||||
|
||||
.then(
|
||||
literal("actionbar")
|
||||
.then(
|
||||
argument("boolean", bool())
|
||||
.executes(instance::actionbar)
|
||||
)
|
||||
)
|
||||
|
||||
.then(
|
||||
literal("pitch")
|
||||
.then(
|
||||
argument("pitch", floatArg())
|
||||
.executes(instance::pitch)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -106,10 +126,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;
|
||||
|
@ -119,7 +139,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));
|
||||
|
@ -130,7 +150,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();
|
||||
|
||||
|
@ -145,9 +165,7 @@ public class MusicCommand {
|
|||
return 1;
|
||||
}
|
||||
|
||||
public int list (CommandContext<FabricClientCommandSource> context, Path path) throws CommandSyntaxException {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
|
||||
public int list (Path path) throws CommandSyntaxException {
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
|
||||
final String prefix = commandManager.prefix;
|
||||
|
@ -202,7 +220,7 @@ public class MusicCommand {
|
|||
mergedList.addAll(files);
|
||||
final Component component = Component.translatable("Songs - %s", Component.join(JoinConfiguration.separator(Component.space()), mergedList)).color(NamedTextColor.GREEN);
|
||||
|
||||
MinecraftClient.getInstance().player.sendMessage(component);
|
||||
((Audience) MinecraftClient.getInstance().player).sendMessage(component);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -223,7 +241,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();
|
||||
|
||||
|
@ -238,7 +256,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();
|
||||
|
@ -254,7 +272,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();
|
||||
|
@ -273,10 +291,39 @@ 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")));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int actionbar (CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
|
||||
final boolean enabled = getBool(context, "boolean");
|
||||
|
||||
SongPlayer.INSTANCE.actionbar = enabled;
|
||||
|
||||
source.sendFeedback(Text.literal("Showing actionbar is now " + (enabled ? "enabled" : "disabled")));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int pitch (CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
|
||||
final float pitch = getFloat(context, "pitch");
|
||||
|
||||
SongPlayer.INSTANCE.pitch = pitch;
|
||||
|
||||
source.sendFeedback(
|
||||
Text.translatable(
|
||||
"Set the pitch to: %s",
|
||||
Text.literal(String.valueOf(pitch))
|
||||
).formatted(Formatting.GREEN)
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.brigadier.Command;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.modules.CommandCore;
|
||||
import land.chipmunk.chipmunkmod.modules.CustomChat;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -27,6 +28,7 @@ public class ReloadConfigCommand {
|
|||
ChipmunkMod.CONFIG = ChipmunkMod.loadConfig();
|
||||
|
||||
CustomChat.INSTANCE.reloadFormat();
|
||||
CommandCore.INSTANCE.reloadRelativeArea();
|
||||
|
||||
source.sendFeedback(Text.literal("Successfully reloaded the config"));
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -3,12 +3,13 @@ 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 land.chipmunk.chipmunkmod.modules.Chat;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
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;
|
||||
|
||||
public class SayCommand {
|
||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
|
@ -22,8 +23,7 @@ public class SayCommand {
|
|||
}
|
||||
|
||||
public static int say (CommandContext<FabricClientCommandSource> context) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
source.getClient().getNetworkHandler().sendChatMessage(getString(context, "message"));
|
||||
Chat.sendChatMessage(getString(context, "message"), true);
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -2,10 +2,21 @@ package land.chipmunk.chipmunkmod.commands;
|
|||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.modules.SelfCare;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.SelfCareModule;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.text.Text;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
|
||||
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
|
||||
|
@ -13,6 +24,8 @@ import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
|||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
|
||||
public class SelfCareCommand {
|
||||
private static final Logger log = LoggerFactory.getLogger(SelfCareCommand.class);
|
||||
|
||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
dispatcher.register(
|
||||
literal("selfcare")
|
||||
|
@ -37,6 +50,64 @@ public class SelfCareCommand {
|
|||
.executes(m -> setSelfCare(m, "cspy"))
|
||||
)
|
||||
)
|
||||
.then(
|
||||
literal("icu")
|
||||
.then(
|
||||
argument("boolean", bool())
|
||||
.executes(m -> setSelfCare(m, "icu"))
|
||||
)
|
||||
)
|
||||
.then(
|
||||
literal("skin")
|
||||
.then(
|
||||
argument("skin", StringArgumentType.string())
|
||||
.executes(context -> {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
final String skin = StringArgumentType.getString(context, "skin");
|
||||
|
||||
SelfCare.INSTANCE.hasSkin = false;
|
||||
SelfCare.INSTANCE.skin = skin;
|
||||
if(skin.equals("off")) {
|
||||
SelfCareModule.INSTANCE.skinOption.setOptionValue(false);
|
||||
source.sendFeedback(Text.literal("Disabled skin self care"));
|
||||
} else {
|
||||
SelfCareModule.INSTANCE.skinOption.setOptionValue(true);
|
||||
SelfCareModule.INSTANCE.skinUsernameOption.setOptionValue(skin);
|
||||
source.sendFeedback(Text.literal("Skin self care enabled for " + skin + "'s skin"));
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
})
|
||||
.suggests((context, builder) -> {
|
||||
List<String> possibilities = new ArrayList<>();
|
||||
possibilities.add("off");
|
||||
|
||||
String currentContext;
|
||||
try {
|
||||
currentContext = StringArgumentType.getString(context, "skin");
|
||||
} catch(IllegalArgumentException e) {
|
||||
currentContext = "";
|
||||
}
|
||||
ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
|
||||
if(networkHandler == null) {
|
||||
// probably impossible, but can't hurt having this
|
||||
possibilities.add(ChipmunkMod.CONFIG.defaultUsername);
|
||||
} else {
|
||||
for(PlayerListEntry player : networkHandler.getPlayerList()) {
|
||||
log.info("Found possibility {}", player.getProfile().getName());
|
||||
possibilities.add(player.getProfile().getName());
|
||||
}
|
||||
}
|
||||
|
||||
for(String possibility : possibilities) {
|
||||
if(possibility.toLowerCase().startsWith(currentContext.toLowerCase())) {
|
||||
builder.suggest(possibility);
|
||||
}
|
||||
}
|
||||
return builder.buildFuture();
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -47,17 +118,25 @@ public class SelfCareCommand {
|
|||
|
||||
switch (type) {
|
||||
case "op" -> {
|
||||
SelfCare.INSTANCE.opEnabled(bool);
|
||||
SelfCare.INSTANCE.opEnabled = bool;
|
||||
SelfCareModule.INSTANCE.opOption.setOptionValue(bool);
|
||||
source.sendFeedback(Text.literal("The op self care is now " + (bool ? "enabled" : "disabled")));
|
||||
}
|
||||
case "gamemode" -> {
|
||||
SelfCare.INSTANCE.gamemodeEnabled(bool);
|
||||
SelfCare.INSTANCE.gamemodeEnabled = bool;
|
||||
SelfCareModule.INSTANCE.gmcOption.setOptionValue(bool);
|
||||
source.sendFeedback(Text.literal("The gamemode self care is now " + (bool ? "enabled" : "disabled")));
|
||||
}
|
||||
case "cspy" -> {
|
||||
SelfCare.INSTANCE.cspyEnabled(bool);
|
||||
SelfCare.INSTANCE.cspyEnabled = bool;
|
||||
SelfCareModule.INSTANCE.cspyOption.setOptionValue(bool);
|
||||
source.sendFeedback(Text.literal("The CommandSpy self care is now " + (bool ? "enabled" : "disabled")));
|
||||
}
|
||||
case "icu" -> {
|
||||
SelfCare.INSTANCE.icuEnabled = bool;
|
||||
SelfCareModule.INSTANCE.icuOption.setOptionValue(bool);
|
||||
source.sendFeedback(Text.literal("The iControlU self care is now " + (bool ? "enabled" : "disabled")));
|
||||
}
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
|
|
@ -8,15 +8,15 @@ import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
|||
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.util.SharedVariables;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ConnectScreen;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import net.minecraft.client.network.ServerAddress;
|
||||
import net.minecraft.client.util.Session;
|
||||
import net.minecraft.client.session.Session;
|
||||
import net.minecraft.text.Text;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
|
@ -24,7 +24,6 @@ import java.util.Optional;
|
|||
import land.chipmunk.chipmunkmod.mixin.MinecraftClientAccessor;
|
||||
|
||||
public class UsernameCommand {
|
||||
private static final Session ORIGINAL_SESSION = ((MinecraftClientAccessor) MinecraftClient.getInstance()).session();
|
||||
private static final SimpleCommandExceptionType USERNAME_TOO_LONG = new SimpleCommandExceptionType(Text.translatable("The specified username is longer than 16 characters"));
|
||||
|
||||
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
|
||||
|
@ -34,7 +33,7 @@ public class UsernameCommand {
|
|||
literal("set")
|
||||
.then(
|
||||
argument("username", greedyString())
|
||||
.executes(UsernameCommand::updateUsername)
|
||||
.executes(c -> updateUsername(c))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -51,12 +50,13 @@ public class UsernameCommand {
|
|||
|
||||
final MinecraftClient client = source.getClient();
|
||||
|
||||
SharedVariables.username = username;
|
||||
ChipmunkMod.CONFIG.defaultUsername = username;
|
||||
|
||||
// TODO: Put this in a separate class
|
||||
final ServerInfo info = client.getCurrentServerEntry();
|
||||
client.world.disconnect();
|
||||
client.disconnect();
|
||||
ConnectScreen.connect(new MultiplayerScreen(new TitleScreen()), client, ServerAddress.parse(info.address), info);
|
||||
ConnectScreen.connect(new TitleScreen(), client, ServerAddress.parse(info.address), info, false, null);
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,141 +1,30 @@
|
|||
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. Please use the completions from typing the bot's prefix."));
|
||||
|
||||
return chomens(getString(c, "command"));
|
||||
})))
|
||||
.then(literal("fnfboyfriend").then(argument("command", greedyString()).executes(c -> fnfboyfriend(getString(c, "command")))))
|
||||
.then(literal("nbot").then(argument("command", greedyString()).executes(c -> nbot(getString(c, "command")))))
|
||||
.then(literal("kittycorp").then(argument("command", greedyString()).executes(c -> kittycorp(getString(c, "command")))))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public static int hbot (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.hbot;
|
||||
final String command = getString(context, "command");
|
||||
final MinecraftClient client = context.getSource().getClient();
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw UNSPECIFIED_KEY.create();
|
||||
|
||||
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) {
|
||||
throw new SimpleCommandExceptionType(Text.literal(e.getMessage())).create();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int sbot (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.sbot;
|
||||
final String command = getString(context, "command");
|
||||
final MinecraftClient client = context.getSource().getClient();
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw UNSPECIFIED_KEY.create();
|
||||
|
||||
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) {
|
||||
throw new SimpleCommandExceptionType(Text.literal(e.getMessage())).create();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int chomens (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.chomens;
|
||||
final String command = getString(context, "command");
|
||||
final ClientPlayNetworkHandler networkHandler = context.getSource().getClient().getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw UNSPECIFIED_KEY.create();
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 10000);
|
||||
String input = time + key;
|
||||
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
String stringHash = Hexadecimal.encode(hash).substring(0, 16);
|
||||
|
||||
String[] arguments = command.split(" ");
|
||||
networkHandler.sendChatMessage(prefix + arguments[0] + " " + stringHash + " " + String.join(" ", Arrays.copyOfRange(arguments, 1, arguments.length)));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new SimpleCommandExceptionType(Text.literal(e.getMessage())).create();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
public static int kittycorp (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.kittycorp;
|
||||
final String command = getString(context, "command");
|
||||
final ClientPlayNetworkHandler networkHandler = context.getSource().getClient().getNetworkHandler();
|
||||
|
||||
final String prefix = info.prefix;
|
||||
final String key = info.key;
|
||||
if (key == null) throw UNSPECIFIED_KEY.create();
|
||||
|
||||
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) {
|
||||
throw new SimpleCommandExceptionType(Text.literal(e.getMessage())).create();
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,24 @@
|
|||
package land.chipmunk.chipmunkmod.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChomeNSBotCommand {
|
||||
public final String name;
|
||||
public final TrustLevel trustLevel;
|
||||
public final List<String> aliases = new ArrayList<>();
|
||||
|
||||
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());
|
||||
|
|
|
@ -6,7 +6,11 @@ import net.minecraft.text.Text;
|
|||
public class Listener {
|
||||
public void chatMessageReceived (Text message) {}
|
||||
|
||||
public void packetReceived (Packet packet) {}
|
||||
public void packetReceived (Packet<?> packet) {}
|
||||
|
||||
public void packetSent (Packet packet) {}
|
||||
public void packetSent (Packet<?> packet) {}
|
||||
|
||||
public void coreReady () {}
|
||||
|
||||
public void coreMoved () {}
|
||||
}
|
||||
|
|
127
src/main/java/land/chipmunk/chipmunkmod/memory/ModuleMemory.java
Normal file
127
src/main/java/land/chipmunk/chipmunkmod/memory/ModuleMemory.java
Normal file
|
@ -0,0 +1,127 @@
|
|||
package land.chipmunk.chipmunkmod.memory;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.Configuration;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Category;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import static land.chipmunk.chipmunkmod.ChipmunkMod.LOGGER;
|
||||
|
||||
// i have realised this can also be used to save profiles
|
||||
// like it would be so simple to implement that feature
|
||||
// not 1.1.0 tho it's taking too long
|
||||
// whyt he fuck is this here lmao i have a working config jsut use that ??1'11'!?
|
||||
public class ModuleMemory {
|
||||
|
||||
public static class Module {
|
||||
public final String name;
|
||||
public boolean enabled;
|
||||
public ArrayList<Option<?>> options = new ArrayList<>();
|
||||
public Module(String name, boolean enabled) {
|
||||
this.name = name;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Option<T extends Object> {
|
||||
public final String name;
|
||||
public T value;
|
||||
public Option(String name, T value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
public Class<T> getType() {return (Class<T>) value.getClass();} // ignore warning cause intellij has the stupid
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
for (Map.Entry<String, Boolean> categoryInMemory : ChipmunkMod.CONFIG.memory.categories.entrySet()) {
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
|
||||
if(categoryInMemory.getKey().equals(categoryInGui.getMessage().getString())) {
|
||||
categoryInGui.isExtended = categoryInMemory.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Boolean> moduleInMemory : ChipmunkMod.CONFIG.memory.modules.entrySet()) {
|
||||
|
||||
String[] split = moduleInMemory.getKey().split("\\.");
|
||||
String category = split[0];
|
||||
String module = split[1];
|
||||
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
|
||||
if(!categoryInGui.getMessage().getString().equals(category)) continue;
|
||||
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Module moduleInGui : categoryInGui.moduleList) {
|
||||
if(module.equals(moduleInGui.getMessage().getString())) {
|
||||
moduleInGui.isEnabled = moduleInMemory.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Boolean> moduleInMemory : ChipmunkMod.CONFIG.memory.modules.entrySet()) {
|
||||
|
||||
String[] split = moduleInMemory.getKey().split("\\.");
|
||||
String category = split[0];
|
||||
String module = split[1];
|
||||
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
|
||||
if(!categoryInGui.getMessage().getString().equals(category)) continue;
|
||||
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Module moduleInGui : categoryInGui.moduleList) {
|
||||
if(module.equals(moduleInGui.getMessage().getString())) {
|
||||
moduleInGui.isEnabled = moduleInMemory.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, String> optionInMemory : ChipmunkMod.CONFIG.memory.options.entrySet()) {
|
||||
|
||||
String[] split = optionInMemory.getKey().split("\\.");
|
||||
String category = split[0];
|
||||
String module = split[1];
|
||||
String option = split[2];
|
||||
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
|
||||
if(!categoryInGui.getMessage().getString().equals(category)) continue;
|
||||
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Module moduleInGui : categoryInGui.moduleList) {
|
||||
if(!module.equals(moduleInGui.getMessage().getString())) continue;
|
||||
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Option<?> optionInGui : moduleInGui.optionList) {
|
||||
if(option.equals(optionInGui.name)) {
|
||||
optionInGui.setValueFromString(optionInMemory.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.info("Loaded module memory!");
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
|
||||
String categoryKey = categoryInGui.getMessage().getString();
|
||||
ChipmunkMod.CONFIG.memory.categories.put(categoryKey, categoryInGui.isExtended);
|
||||
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Module moduleInGui : categoryInGui.moduleList) {
|
||||
String moduleKey = categoryKey + "." + moduleInGui.getMessage().getString();
|
||||
ChipmunkMod.CONFIG.memory.modules.put(moduleKey, moduleInGui.isEnabled);
|
||||
|
||||
for (land.chipmunk.chipmunkmod.testclient.gui.components.Option<?> optionInGui : moduleInGui.optionList) {
|
||||
String key = moduleKey + "." + optionInGui.name;
|
||||
ChipmunkMod.CONFIG.memory.options.put(key, optionInGui.getValueAsString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package land.chipmunk.chipmunkmod.memory;
|
||||
|
||||
public class UnknownOptionTypeException extends RuntimeException { //runtime exception because i dont wanna catch this i just want it to crash me when something goes wrong
|
||||
public UnknownOptionTypeException(Class<?> type) {
|
||||
super(String.format("An option with type %s is not handled by ModuleMemory.", type.getTypeName()));
|
||||
}
|
||||
}
|
|
@ -3,37 +3,84 @@ package land.chipmunk.chipmunkmod.mixin;
|
|||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import land.chipmunk.chipmunkmod.modules.RainbowName;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoDeopModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.AntiChatSpamModule;
|
||||
import land.chipmunk.chipmunkmod.util.Debug;
|
||||
import land.chipmunk.chipmunkmod.util.Executor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
||||
import net.minecraft.network.message.MessageSignatureData;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableTextContent;
|
||||
import net.minecraft.util.Nullables;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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 java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.hud.ChatHud.class)
|
||||
public class ChatHudMixin {
|
||||
public abstract class ChatHudMixin {
|
||||
|
||||
@Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At("TAIL"))
|
||||
private void testclient$autoDeopListener(Text message, MessageSignatureData signature, MessageIndicator indicator, CallbackInfo ci) {
|
||||
String pattern = "\\[(.*?)\\: Made (.*?) a server operator\\]";
|
||||
@Shadow
|
||||
public abstract void addMessage(Text message, @Nullable MessageSignatureData signature, @Nullable MessageIndicator indicator);
|
||||
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
@Shadow @Final private static Logger LOGGER;
|
||||
|
||||
Matcher matcher = Pattern.compile(pattern).matcher(message.getString());
|
||||
@Shadow protected abstract void logChatMessage(ChatHudLine message);
|
||||
@Shadow protected abstract void addVisibleMessage(ChatHudLine message);
|
||||
@Shadow protected abstract void addMessage(ChatHudLine message);
|
||||
|
||||
if (matcher.find()) {
|
||||
AutoDeopModule.execute(matcher.group(1), matcher.group(2));
|
||||
/*
|
||||
@Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;logChatMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void chipmunkmod$preventDoubleMessageLogging(Text message, MessageSignatureData signatureData, MessageIndicator indicator, CallbackInfo ci, ChatHudLine chatHudLine) {
|
||||
// addMessage(message, signature, client.inGameHud.getTicks(), indicator, false);
|
||||
//addVisibleMessage(chatHudLine);
|
||||
//addMessage(chatHudLine);
|
||||
|
||||
//ci.cancel();
|
||||
new Throwable().printStackTrace();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// super jank
|
||||
|
||||
@Inject(method = "logChatMessage", at = @At("HEAD"), cancellable = true)
|
||||
public void chipmunkmod$temp(ChatHudLine message, CallbackInfo ci) {
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void customLogChatMessage(ChatHudLine message) {
|
||||
String string = message.content().getString().replaceAll("\r", "\\\\r").replaceAll("\n", "\\\\n");
|
||||
String string2 = Nullables.map(message.indicator(), MessageIndicator::loggedName);
|
||||
if (string2 != null) {
|
||||
LOGGER.info("[{}] [CHAT] {}", string2, string);
|
||||
} else {
|
||||
LOGGER.info("[CHAT] {}", string);
|
||||
}
|
||||
}
|
||||
@Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", cancellable = true)
|
||||
public void addMessage(Text message, MessageSignatureData signature, int ticks, MessageIndicator indicator, boolean refresh, CallbackInfo ci) {
|
||||
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", cancellable = true)
|
||||
public void chipmunkmod$generalAddMessageMixin(Text message, MessageSignatureData signatureData, MessageIndicator indicator, CallbackInfo ci) {
|
||||
ChatHudLine chatHudLine = new ChatHudLine(this.client.inGameHud.getTicks(), message, signatureData, indicator);
|
||||
if(AntiChatSpamModule.INSTANCE.isEnabled && message.equals(AntiChatSpamModule.latestPassedThroughMessage)) {
|
||||
AntiChatSpamModule.latestPassedThroughMessage = Text.empty();
|
||||
customLogChatMessage(chatHudLine);
|
||||
addVisibleMessage(chatHudLine);
|
||||
addMessage(chatHudLine);
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (RainbowName.INSTANCE.enabled()) {
|
||||
if (RainbowName.INSTANCE.enabled) {
|
||||
if (message.getString().contains("Your nickname is now ") || message.getString().contains("Nickname changed.")) {
|
||||
ci.cancel();
|
||||
return;
|
||||
|
@ -49,6 +96,32 @@ public class ChatHudMixin {
|
|||
for (Listener listener : ListenerManager.listeners) {
|
||||
listener.chatMessageReceived(message);
|
||||
}
|
||||
|
||||
// for (AntiChatSpamModule.BlockedPattern pattern : AntiChatSpamModule.instance.patterns) {
|
||||
// if(pattern.pattern().matcher(message.getString()).matches()) ci.cancel();
|
||||
// }
|
||||
// ChipmunkMod.LOGGER.info("gex3");
|
||||
if(AntiChatSpamModule.INSTANCE.isEnabled) {
|
||||
Executor.antiChatSpamService.submit(() -> {
|
||||
try {
|
||||
Debug.debug("started a run or wahever", "AntiChatSpam.addMessage.future");
|
||||
AntiChatSpamModule.ChatMessage cmessage = new AntiChatSpamModule.ChatMessage(message.getString());
|
||||
Debug.debug("hidden: " + cmessage.hidden, "AntiChatSpam.addMessage.future");
|
||||
if (cmessage.hidden) return;
|
||||
AntiChatSpamModule.latestPassedThroughMessage = message;
|
||||
Debug.debug("changed variable in module class", "AntiChatSpam.addMessage.future");
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(message, signatureData, indicator);
|
||||
Debug.debug("ended a run or wahever", "AntiChatSpam.addMessage.future");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
customLogChatMessage(chatHudLine);
|
||||
addVisibleMessage(chatHudLine);
|
||||
addMessage(chatHudLine);
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.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.ClientPlayNetworkHandler;
|
||||
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)
|
||||
|
@ -22,13 +29,14 @@ public class ChatInputSuggestorMixin {
|
|||
@Shadow
|
||||
private CompletableFuture<Suggestions> pendingSuggestions;
|
||||
|
||||
@Final
|
||||
@Shadow
|
||||
private boolean slashOptional;
|
||||
|
||||
@Shadow
|
||||
public void show (boolean narrateFirstSuggestion) {}
|
||||
|
||||
@Shadow
|
||||
private static int getStartOfCurrentWord (String input) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Mutable
|
||||
@Final
|
||||
@Shadow
|
||||
|
@ -40,23 +48,51 @@ public class ChatInputSuggestorMixin {
|
|||
|
||||
@Inject(at = @At("TAIL"), method = "refresh()V")
|
||||
public void refresh (CallbackInfo ci) {
|
||||
if (slashOptional) return;
|
||||
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
|
||||
final String text = this.textField.getText();
|
||||
final int cursor = this.textField.getCursor();
|
||||
|
||||
if (cursor < commandManager.prefix.length() || !text.startsWith(commandManager.prefix)) return;
|
||||
final ClientPlayerEntity player = MinecraftClient.getInstance().player;
|
||||
|
||||
final StringReader reader = new StringReader(text);
|
||||
reader.setCursor(commandManager.prefix.length()); // Skip the prefix
|
||||
final String chomeNSPrefix = ChipmunkMod.CONFIG.bots.chomens.prefix;
|
||||
|
||||
final CommandDispatcher<FabricClientCommandSource> dispatcher = commandManager.dispatcher;
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
final FabricClientCommandSource commandSource = (FabricClientCommandSource) client.getNetworkHandler().getCommandSource();
|
||||
if (!text.contains(" ") && text.startsWith(chomeNSPrefix) && player != null) {
|
||||
final String textUpToCursor = text.substring(0, cursor);
|
||||
|
||||
pendingSuggestions = dispatcher.getCompletionSuggestions(dispatcher.parse(reader, commandSource), cursor);
|
||||
show(true);
|
||||
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);
|
||||
});
|
||||
} else if (cursor > commandManager.prefix.length() && text.startsWith(commandManager.prefix)) {
|
||||
final StringReader reader = new StringReader(text);
|
||||
reader.setCursor(commandManager.prefix.length()); // Skip the prefix
|
||||
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null) return;
|
||||
|
||||
final CommandDispatcher<FabricClientCommandSource> dispatcher = commandManager.dispatcher;
|
||||
final FabricClientCommandSource commandSource = (FabricClientCommandSource) networkHandler.getCommandSource();
|
||||
|
||||
pendingSuggestions = dispatcher.getCompletionSuggestions(dispatcher.parse(reader, commandSource), cursor);
|
||||
show(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,64 +1,127 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.modules.CustomChat;
|
||||
import land.chipmunk.chipmunkmod.util.SharedVariables;
|
||||
import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
|
||||
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
|
||||
import land.chipmunk.chipmunkmod.util.BotValidationUtilities;
|
||||
import land.chipmunk.chipmunkmod.util.Executor;
|
||||
import land.chipmunk.chipmunkmod.util.Webhook;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ChatInputSuggestor;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
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.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.ChatScreen.class)
|
||||
public class ChatScreenMixin {
|
||||
@Mixin(value = net.minecraft.client.gui.screen.ChatScreen.class)
|
||||
public class ChatScreenMixin extends Screen {
|
||||
@Shadow protected TextFieldWidget chatField;
|
||||
@Shadow private String originalChatText;
|
||||
@Shadow ChatInputSuggestor chatInputSuggestor;
|
||||
@Shadow private int messageHistoryIndex = -1;
|
||||
|
||||
public ChatScreenMixin(String originalChatText) {
|
||||
super(Text.translatable("chat_screen.title"));
|
||||
this.originalChatText = originalChatText;
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "init", cancellable = true)
|
||||
public void init (CallbackInfo ci) {
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
this.messageHistoryIndex = client.inGameHud.getChatHud().getMessageHistory().size();
|
||||
this.chatField = new TextFieldWidget(client.advanceValidatingTextRenderer, 4, this.height - 12, this.width - 4, 12, Text.translatable("chat.editBox")) {
|
||||
protected MutableText getNarrationMessage() {
|
||||
return super.getNarrationMessage().append(ChatScreenMixin.this.chatInputSuggestor.getNarration());
|
||||
}
|
||||
};
|
||||
this.chatField.setMaxLength(Integer.MAX_VALUE);
|
||||
this.chatField.setDrawsBackground(false);
|
||||
this.chatField.setText(this.originalChatText);
|
||||
this.chatField.setChangedListener(this::onChatFieldUpdate);
|
||||
this.chatField.setFocusUnlocked(false);
|
||||
this.addSelectableChild(this.chatField);
|
||||
this.chatInputSuggestor = new ChatInputSuggestor(this.client, this, this.chatField, this.textRenderer, false, false, 1, 10, true, -805306368);
|
||||
this.chatInputSuggestor.refresh();
|
||||
this.setInitialFocus(this.chatField);
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "sendMessage", cancellable = true)
|
||||
public void sendMessage(String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) {
|
||||
if(ChipmunkMod.CONFIG.testbotWebhook != null && chatText.startsWith("-")) {
|
||||
new Thread(() -> {
|
||||
Webhook webhook = new Webhook(ChipmunkMod.CONFIG.testbotWebhook);
|
||||
webhook.setUsername("ChipmunkMod");
|
||||
webhook.setContent(SharedVariables.username);
|
||||
public void sendMessage(String chatText, boolean addToHistory, CallbackInfo ci) {
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
if (addToHistory) {
|
||||
client.inGameHud.getChatHud().addToMessageHistory(chatText);
|
||||
}
|
||||
if(ChipmunkMod.CONFIG.bots.testbot.webhookUrl != null && chatText.startsWith("-")) {
|
||||
Executor.service.submit(() -> {
|
||||
try {
|
||||
webhook.execute();
|
||||
Webhook.send(ChipmunkMod.CONFIG.bots.testbot.webhookUrl, ChipmunkMod.CONFIG.defaultUsername);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
ChipmunkMod.LOGGER.error("fard webhook url !!!t");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
} 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();
|
||||
|
||||
final List<String> aliases = new ArrayList<>();
|
||||
for (ChomeNSBotCommand command : commands) {
|
||||
if (command.trustLevel == ChomeNSBotCommand.TrustLevel.PUBLIC) continue;
|
||||
|
||||
aliases.addAll(command.aliases);
|
||||
}
|
||||
|
||||
final String chatCommand = chatText.toLowerCase().split("\\s")[0];
|
||||
|
||||
final int prefixLength = ChipmunkMod.CONFIG.bots.chomens.prefix.length();
|
||||
|
||||
if (
|
||||
moreOrTrustedCommands.contains(chatCommand) ||
|
||||
aliases.contains(chatCommand.substring(prefixLength))
|
||||
) {
|
||||
try {
|
||||
BotValidationUtilities.chomens(chatText.substring(prefixLength));
|
||||
|
||||
ci.cancel();
|
||||
|
||||
return;
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
|
||||
if (chatText.startsWith(commandManager.prefix)) {
|
||||
commandManager.executeCommand(chatText.substring(commandManager.prefix.length()));
|
||||
if (client == null) return;
|
||||
|
||||
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);
|
||||
if (chatText.startsWith("/")) {
|
||||
client.player.networkHandler.sendChatCommand(chatText.substring(1));
|
||||
} else {
|
||||
client.player.networkHandler.sendChatMessage(chatText);
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;setMaxLength(I)V"), method = "init")
|
||||
public void init (CallbackInfo ci) {
|
||||
chatField.setMaxLength(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@ModifyArg(method = "normalize", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/StringHelper;truncateChat(Ljava/lang/String;)Ljava/lang/String;"))
|
||||
private String normalize (String text) {
|
||||
return text;
|
||||
@Unique
|
||||
private void onChatFieldUpdate(String chatText) {
|
||||
String string = this.chatField.getText();
|
||||
this.chatInputSuggestor.setWindowActive(!string.equals(this.originalChatText));
|
||||
this.chatInputSuggestor.refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public interface ClientConnectionAccessor {
|
||||
@Accessor("packetListener")
|
||||
PacketListener packetListener ();
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
public interface ClientConnectionInvoker {
|
||||
@Invoker("handlePacket")
|
||||
static <T extends PacketListener> void handlePacket (Packet<T> packet, PacketListener listener) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
|
@ -1,27 +1,35 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.antip2w.DelayPacketsModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.utility.AntiParticleKickModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiParticleKickModule;
|
||||
import land.chipmunk.chipmunkmod.util.Chat;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket;
|
||||
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.text.Text;
|
||||
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.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Mixin(net.minecraft.network.ClientConnection.class)
|
||||
public class ClientConnectionMixin {
|
||||
@Inject(at = @At("HEAD"), method = "disconnect", cancellable = true)
|
||||
@Unique
|
||||
private static final Pattern CUSTOM_PITCH_PATTERN = Pattern.compile(".*\\.pitch\\.(.*)");
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "disconnect(Lnet/minecraft/text/Text;)V", cancellable = true)
|
||||
public void disconnect (Text disconnectReason, CallbackInfo ci) {
|
||||
if (disconnectReason == ClientPlayNetworkHandlerAccessor.chatValidationFailedText()) {
|
||||
ci.cancel();
|
||||
|
@ -30,34 +38,63 @@ public class ClientConnectionMixin {
|
|||
|
||||
@Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true)
|
||||
private void exceptionCaught (ChannelHandlerContext context, Throwable ex, CallbackInfo ci) {
|
||||
if (ex instanceof DecoderException) {
|
||||
Chat.sendGold("ChipmunkMod caught an exception in ClientConnection.");
|
||||
ci.cancel();
|
||||
ex.printStackTrace();
|
||||
}
|
||||
Chat.sendGold("ChipmunkMod caught an exception in ClientConnection.");
|
||||
ci.cancel();
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@Inject(method = "handlePacket", at = @At("HEAD"), cancellable = true)
|
||||
private static void handlePacket (Packet<?> packet, PacketListener _listener, CallbackInfo ci) {
|
||||
for (Listener listener : ListenerManager.listeners) {
|
||||
listener.packetReceived(packet);
|
||||
}
|
||||
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
// please don't skid this.,.
|
||||
// mabe mabe mabe
|
||||
// lol i had my own im just gonna cop ypaste that :D
|
||||
if(packet instanceof ParticleS2CPacket) {
|
||||
if(AntiParticleKickModule.instance.isEnabled && ((ParticleS2CPacket) packet).getCount()>1000) {
|
||||
if(AntiParticleKickModule.INSTANCE.isEnabled && ((ParticleS2CPacket) packet).getCount()>1000) {
|
||||
if(((ParticleS2CPacket) packet).getCount()>1000) Chat.sendGold("ChipmunkMod prevented a particle kick!");
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
} else if (packet instanceof PlaySoundS2CPacket t_packet) {
|
||||
final SoundEvent soundEvent = t_packet.getSound().value();
|
||||
|
||||
for (Listener listener : ListenerManager.listeners) {
|
||||
listener.packetReceived(packet);
|
||||
final Identifier sound = soundEvent.getId();
|
||||
|
||||
final Matcher matcher = CUSTOM_PITCH_PATTERN.matcher(sound.getPath());
|
||||
|
||||
if (!matcher.find()) return;
|
||||
|
||||
try {
|
||||
final String stringPitch = matcher.group(1);
|
||||
|
||||
final float pitch = Float.parseFloat(stringPitch);
|
||||
|
||||
final ClientWorld world = client.world;
|
||||
|
||||
if (world == null) return;
|
||||
|
||||
// huge mess
|
||||
final SoundEvent newSound = SoundEvent.of(Identifier.of(sound.getNamespace(), sound.getPath().substring(0, sound.getPath().length() - (".pitch." + stringPitch).length())));
|
||||
|
||||
client.executeSync(() -> world.playSound(client.player, t_packet.getX(), t_packet.getY(), t_packet.getZ(), newSound, t_packet.getCategory(), t_packet.getVolume(), pitch, 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) { // o thanks fancy
|
||||
if (t_packet.getPartialCommand().length() > 2048) { // why was this comment here
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -67,20 +104,4 @@ public class ClientConnectionMixin {
|
|||
listener.packetSent(packet);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true)
|
||||
private void testclient$delayPackets(Packet<?> packet, CallbackInfo ci) {
|
||||
if(DelayPacketsModule.instance.isEnabled) {
|
||||
DelayPacketsModule.packetsToSend.add(packet);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "disconnect", at = @At("TAIL"))
|
||||
private void testclient$disablePacketDelayerOnDisconnect(Text disconnectReason, CallbackInfo ci) {
|
||||
DelayPacketsModule.instance.isEnabled = false;
|
||||
DelayPacketsModule.packetsToSend = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
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;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(net.minecraft.client.network.ClientPlayNetworkHandler.class)
|
||||
public interface ClientPlayNetworkHandlerAccessor {
|
||||
@Accessor("CHAT_VALIDATION_FAILED_TEXT")
|
||||
public static Text chatValidationFailedText () { throw new AssertionError(); }
|
||||
static Text chatValidationFailedText () { throw new AssertionError(); }
|
||||
|
||||
@Accessor("playerListEntries")
|
||||
Map<UUID, PlayerListEntry> playerListEntries();
|
||||
|
||||
@Accessor("listedPlayerListEntries")
|
||||
Set<PlayerListEntry> listedPlayerListEntries();
|
||||
}
|
||||
|
|
|
@ -1,37 +1,125 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
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.platform.fabric.FabricAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.network.encryption.NetworkEncryptionUtils;
|
||||
import net.minecraft.network.message.LastSeenMessagesCollector;
|
||||
import net.minecraft.network.message.MessageBody;
|
||||
import net.minecraft.network.message.MessageChain;
|
||||
import net.minecraft.network.message.MessageSignatureData;
|
||||
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
|
||||
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.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;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||
import net.minecraft.registry.CombinedDynamicRegistries;
|
||||
import net.minecraft.client.network.ClientDynamicRegistryType;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||
|
||||
@Mixin(net.minecraft.client.network.ClientPlayNetworkHandler.class)
|
||||
import java.time.Instant;
|
||||
|
||||
@Mixin(value = net.minecraft.client.network.ClientPlayNetworkHandler.class, priority = 1001)
|
||||
public class ClientPlayNetworkHandlerMixin {
|
||||
@Final
|
||||
@Shadow private FeatureSet enabledFeatures;
|
||||
@Shadow private CombinedDynamicRegistries<ClientDynamicRegistryType> combinedDynamicRegistries;
|
||||
@Final
|
||||
@Shadow private DynamicRegistryManager.Immutable combinedDynamicRegistries;
|
||||
@Shadow private LastSeenMessagesCollector lastSeenMessagesCollector;
|
||||
@Shadow private MessageChain.Packer messagePacker;
|
||||
|
||||
@Inject(method = "onGameJoin", at = @At("TAIL"))
|
||||
private void onGameJoin (GameJoinS2CPacket packet, CallbackInfo ci) {
|
||||
final CommandRegistryAccess commandRegistryAccess = CommandRegistryAccess.of(this.combinedDynamicRegistries.getCombinedRegistryManager(), this.enabledFeatures);
|
||||
final CommandRegistryAccess commandRegistryAccess = CommandRegistryAccess.of(this.combinedDynamicRegistries, 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();
|
||||
ChomeNSAuth.INSTANCE.init();
|
||||
CustomChat.INSTANCE.init();
|
||||
}
|
||||
|
||||
@Inject(method = "onGameJoin", at = @At("HEAD"))
|
||||
private void onGameJoinHead (GameJoinS2CPacket packet, CallbackInfo ci) {
|
||||
Players.INSTANCE.init();
|
||||
@Inject(method = "onPlayerRemove", at = @At("HEAD"), cancellable = true)
|
||||
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 {
|
||||
final String suggestionId = message.getSiblings().getFirst().getString();
|
||||
final String authId = ((PlainTextContent) message.getContent()).string();
|
||||
|
||||
if (suggestionId.equals(ChomeNSBotCommandSuggestions.ID) || authId.equals(ChomeNSAuth.INSTANCE.id)) {
|
||||
ci.cancel();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
|
||||
private void sendChatMessage (String chatText, CallbackInfo ci) {
|
||||
final CommandManager commandManager = CommandManager.INSTANCE;
|
||||
|
||||
final String secret = String.valueOf(Chat.secret);
|
||||
|
||||
if (chatText.startsWith(commandManager.prefix)) {
|
||||
commandManager.executeCommand(chatText.substring(commandManager.prefix.length()));
|
||||
|
||||
ci.cancel();
|
||||
} else if (!chatText.startsWith("/") && !chatText.startsWith(secret)) {
|
||||
CustomChat.INSTANCE.chat(chatText);
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
if (chatText.startsWith(secret)) {
|
||||
final String content = chatText.substring(secret.length());
|
||||
|
||||
Instant instant = Instant.now();
|
||||
long l = NetworkEncryptionUtils.SecureRandomUtil.nextLong();
|
||||
LastSeenMessagesCollector.LastSeenMessages lastSeenMessages = this.lastSeenMessagesCollector.collect();
|
||||
MessageSignatureData messageSignatureData = this.messagePacker.pack(new MessageBody(content, instant, l, lastSeenMessages.lastSeen()));
|
||||
MinecraftClient.getInstance().getNetworkHandler().sendPacket(new ChatMessageC2SPacket(content, instant, l, messageSignatureData, lastSeenMessages.update()));
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package land.chipmunk.chipmunkmod.mixin;
|
|||
|
||||
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;
|
||||
|
@ -16,7 +17,7 @@ import land.chipmunk.chipmunkmod.modules.CommandCore;
|
|||
|
||||
@Mixin(ClientPlayerEntity.class)
|
||||
public class ClientPlayerEntityMixin {
|
||||
private static MinecraftClient CLIENT = MinecraftClient.getInstance();
|
||||
@Unique private static MinecraftClient CLIENT = MinecraftClient.getInstance();
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "move")
|
||||
public void move (MovementType type, Vec3d relPos, CallbackInfo ci) {
|
||||
|
@ -26,9 +27,12 @@ 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);
|
||||
if (distance > world.getSimulationDistance()) {
|
||||
CommandCore.INSTANCE.clientPlayerEntityFilled = true;
|
||||
CommandCore.INSTANCE.move(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.ParseResults;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.context.CommandContextBuilder;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
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(CommandDispatcher.class)
|
||||
public class CommandDispatcherMixin<S> {
|
||||
@Inject(method = "parseNodes", at = @At("HEAD"), cancellable = true, /* important --> */ remap = false)
|
||||
private void parseNodes (CommandNode<S> node, StringReader originalReader, CommandContextBuilder<S> contextSoFar, CallbackInfoReturnable<ParseResults<S>> cir) {
|
||||
// correct way to patch this?
|
||||
// if (node.getRelevantNodes(originalReader).size() > 127) {
|
||||
// cir.setReturnValue(new ParseResults<>(contextSoFar));
|
||||
//
|
||||
// cir.cancel();
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.network.*;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.util.profiling.jfr.FlightProfiler;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
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 static land.chipmunk.chipmunkmod.ChipmunkMod.LOGGER;
|
||||
|
||||
@Mixin(DecoderHandler.class)
|
||||
public class DecoderHandlerMixin {
|
||||
@Final @Mutable @Shadow private final NetworkSide side;
|
||||
|
||||
public DecoderHandlerMixin(NetworkSide side) {
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@Inject(method = "decode", at = @At("HEAD"), cancellable = true)
|
||||
private void decode (ChannelHandlerContext ctx, ByteBuf buf, List<Object> objects, CallbackInfo ci) {
|
||||
int i = buf.readableBytes();
|
||||
if (i != 0) {
|
||||
PacketByteBuf packetByteBuf = new PacketByteBuf(buf);
|
||||
int j = packetByteBuf.readVarInt();
|
||||
Packet<?> packet = ctx.channel().attr(ClientConnection.PROTOCOL_ATTRIBUTE_KEY).get().getPacketHandler(this.side, j, packetByteBuf);
|
||||
if (packet != null) {
|
||||
int k = ctx.channel().attr(ClientConnection.PROTOCOL_ATTRIBUTE_KEY).get().getId();
|
||||
FlightProfiler.INSTANCE.onPacketReceived(k, j, ctx.channel().remoteAddress(), i);
|
||||
objects.add(packet);
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug(ClientConnection.PACKET_RECEIVED_MARKER, " IN: [{}:{}] {}", ctx.channel().attr(ClientConnection.PROTOCOL_ATTRIBUTE_KEY).get(), j, packet.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.utility.BlockGuardianParticlesModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.BlockGuardianParticlesModule;
|
||||
import land.chipmunk.chipmunkmod.util.SharedVariables;
|
||||
import net.minecraft.client.particle.ElderGuardianAppearanceParticle;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
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;
|
||||
|
@ -13,10 +13,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
|
||||
@Mixin(ElderGuardianAppearanceParticle.Factory.class)
|
||||
public class ElderGuardianAppearanceParticleMixin {
|
||||
@Inject(method = "createParticle(Lnet/minecraft/particle/DefaultParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"))
|
||||
private void testClient$limitGuardianParticles(DefaultParticleType defaultParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
|
||||
if(BlockGuardianParticlesModule.instance.isEnabled) cir.cancel();
|
||||
if(SharedVariables.elderGuardianParticleTimer > 0) cir.cancel();
|
||||
@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 testClient$limitGuardianParticles(SimpleParticleType defaultParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
|
||||
if(BlockGuardianParticlesModule.INSTANCE.isEnabled || SharedVariables.elderGuardianParticleTimer > 0) {
|
||||
cir.setReturnValue(null);
|
||||
cir.cancel();
|
||||
}
|
||||
SharedVariables.elderGuardianParticleTimer = 200;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiTextObfuscationLagModule;
|
||||
import net.minecraft.client.font.FontStorage;
|
||||
import net.minecraft.client.font.Glyph;
|
||||
import net.minecraft.client.font.GlyphRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@Mixin(FontStorage.class)
|
||||
public class FontStorageMixin {
|
||||
@Shadow private GlyphRenderer blankGlyphRenderer;
|
||||
|
||||
@Inject(method = "getObfuscatedGlyphRenderer", at = @At("HEAD"), cancellable = true)
|
||||
private void chipmunkmod$preventObfuscatedGlyphLag(Glyph glyph, CallbackInfoReturnable<GlyphRenderer> cir) {
|
||||
if(!AntiTextObfuscationLagModule.INSTANCE.isEnabled) return;
|
||||
if(AntiTextObfuscationLagModule.INSTANCE.exceededLimitThisTick || Instant.now().toEpochMilli() - AntiTextObfuscationLagModule.INSTANCE.renderTimeStart.toEpochMilli() > 18) {
|
||||
AntiTextObfuscationLagModule.INSTANCE.exceededLimitThisTick = true;
|
||||
cir.setReturnValue(blankGlyphRenderer);
|
||||
}
|
||||
// Debug.debug("Render time: "+(Instant.now().toEpochMilli() - AntiTextObfuscationLagModule.instance.renderTimeStart.toEpochMilli()), "AntiTextObfuscationLag.mixin");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
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(Identifier.class)
|
||||
public class IdentifierMixin {
|
||||
@Inject(method = "isNamespaceCharacterValid", at = @At("HEAD"), cancellable = true)
|
||||
private static void isNamespaceCharacterValid (char character, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(true);
|
||||
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "isNamespaceValid", at = @At("HEAD"), cancellable = true)
|
||||
private static void isNamespaceValid (String namespace, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(true);
|
||||
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@Inject(method = "validateNamespace", at = @At("HEAD"), cancellable = true)
|
||||
private static void validateNamespace(String namespace, String path, CallbackInfoReturnable<String> cir) {
|
||||
cir.setReturnValue(namespace);
|
||||
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.modules.LoopCrouch;
|
||||
import net.minecraft.client.input.Input;
|
||||
import net.minecraft.client.input.KeyboardInput;
|
||||
import net.minecraft.client.option.GameOptions;
|
||||
|
@ -8,6 +7,7 @@ import org.spongepowered.asm.mixin.Final;
|
|||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
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;
|
||||
|
@ -33,11 +33,11 @@ public class KeyboardInputMixin extends Input {
|
|||
this.movementSideways = getMovementMultiplier(this.pressingLeft, this.pressingRight);
|
||||
this.jumping = this.settings.jumpKey.isPressed();
|
||||
|
||||
// ohio code
|
||||
this.sneaking = LoopCrouch.INSTANCE.enabled() ?
|
||||
!LoopCrouch.INSTANCE.sneaking() :
|
||||
this.settings.sneakKey.isPressed();
|
||||
LoopCrouch.INSTANCE.sneaking(!LoopCrouch.INSTANCE.sneaking());
|
||||
// wtf loopcrougchs gone??????????????
|
||||
// this.sneaking = LoopCrouch.INSTANCE.enabled() ?
|
||||
// !LoopCrouch.INSTANCE.sneaking() :
|
||||
// this.settings.sneakKey.isPressed();
|
||||
// LoopCrouch.INSTANCE.sneaking(!LoopCrouch.INSTANCE.sneaking());
|
||||
|
||||
if (slowDown) {
|
||||
this.movementSideways *= f;
|
||||
|
@ -45,7 +45,8 @@ public class KeyboardInputMixin extends Input {
|
|||
}
|
||||
}
|
||||
|
||||
private float getMovementMultiplier(boolean positive, boolean negative) {
|
||||
@Unique
|
||||
private static float getMovementMultiplier(boolean positive, boolean negative) {
|
||||
if (positive == negative) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,29 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.antip2w.DelayPacketsModule;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
public class KeyboardMixin {
|
||||
@Inject(method = "onKey", at = @At("HEAD"), cancellable = true)
|
||||
private void testclient$keyBindsOverrides(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
|
||||
if(key == GLFW.GLFW_KEY_KP_0 && action == 1) {
|
||||
DelayPacketsModule.instance.isEnabled = !DelayPacketsModule.instance.isEnabled;
|
||||
if(!DelayPacketsModule.instance.isEnabled) {
|
||||
DelayPacketsModule.instance.deactivateRunnable.run();
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
// Don't @ me. It half-works
|
||||
// LUNA WHAT THE FUCK IS THIS MIXIN AM I SUPPOSED TO UNDERSTAND THIS
|
||||
// lol
|
||||
@Redirect(method = "onKey(JIIII)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", opcode = Opcodes.GETFIELD) )
|
||||
private Screen currentScreen(MinecraftClient instance) {
|
||||
// if (GuiMoveModule.instance.isEnabled) {
|
||||
// return null;
|
||||
// } else {
|
||||
return instance.currentScreen;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.client.session.Session;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import net.minecraft.client.util.Session;
|
||||
|
||||
@Mixin(net.minecraft.client.MinecraftClient.class)
|
||||
public interface MinecraftClientAccessor {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.util.SharedVariables;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
|
@ -23,9 +24,9 @@ public class MultiplayerScreenMixin extends Screen{
|
|||
@Inject(method="init", at = @At("TAIL"))
|
||||
private void testclient$addUsernameField(CallbackInfo ci) {
|
||||
TextFieldWidget usernameField = new TextFieldWidget(textRenderer, buttonEdit.getX()-130, buttonEdit.getY(), 120, 20, Text.literal("Username"));;
|
||||
usernameField.setText(SharedVariables.username);
|
||||
usernameField.setText(ChipmunkMod.CONFIG.defaultUsername);
|
||||
usernameField.setChangedListener(text -> {
|
||||
SharedVariables.username = text;
|
||||
ChipmunkMod.CONFIG.defaultUsername = text;
|
||||
});
|
||||
usernameField.setMaxLength(16);
|
||||
addDrawableChild(usernameField);
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.NbtTagSizeTracker;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import java.io.DataInput;
|
||||
|
||||
@Mixin(NbtIo.class)
|
||||
public interface NbtIoInvoker {
|
||||
@Invoker(value = "read")
|
||||
static NbtElement readInvoker(DataInput input, int depth, NbtTagSizeTracker tracker) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.util.Chat;
|
||||
import net.minecraft.nbt.*;
|
||||
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;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
|
||||
@Mixin(NbtIo.class)
|
||||
public class NbtIoMixin {
|
||||
|
||||
@Inject(method = "read(Ljava/io/DataInput;ILnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtElement;",at = @At("HEAD"), cancellable = true)
|
||||
private static void testclient$preventNbtKick(DataInput input, int depth, NbtTagSizeTracker tracker, CallbackInfoReturnable<NbtElement> cir) throws IOException {
|
||||
byte b = input.readByte();
|
||||
if (b == 0) {
|
||||
cir.setReturnValue(NbtEnd.INSTANCE);
|
||||
} else {
|
||||
NbtString.skip(input);
|
||||
|
||||
try {
|
||||
cir.setReturnValue(NbtTypes.byId(b).read(input, depth, tracker));
|
||||
} catch (Exception var7) {
|
||||
Chat.sendGold("ChipmunkMod prevented an NBT kick!");
|
||||
cir.setReturnValue(NbtEnd.INSTANCE); // i don't fucking know i just copied
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read(Ljava/io/DataInput;Lnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtCompound;", at = @At("HEAD"), cancellable = true)
|
||||
private static void testclient$antiNbtKickPreventLag(DataInput input, NbtTagSizeTracker tracker, CallbackInfoReturnable<NbtCompound> cir) {
|
||||
NbtElement nbtElement = NbtIoInvoker.readInvoker(input, 0, tracker);
|
||||
if (nbtElement instanceof NbtCompound) {
|
||||
cir.setReturnValue((NbtCompound)nbtElement);
|
||||
} else {
|
||||
ChipmunkMod.LOGGER.warn("ChipmunkMod hopefully prevented lag lol idk");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.movement.SlipperyWorldModule;
|
||||
import net.minecraft.block.Block;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -9,10 +7,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||
|
||||
@Mixin(Block.class)
|
||||
public class PlayerEntityMixin {
|
||||
@Inject(method = "getSlipperiness", at = @At("HEAD"), cancellable = true)
|
||||
private void testclient$slipperyWorld(CallbackInfoReturnable<Float> cir) {
|
||||
if(SlipperyWorldModule.instance.isEnabled) {
|
||||
cir.setReturnValue(((Double) SlipperyWorldModule.instance.optionList.get(0).optionValue).floatValue());
|
||||
}
|
||||
}
|
||||
//slippery world was here
|
||||
//TODO: remove
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
|
||||
import land.chipmunk.chipmunkmod.util.SharedVariables;
|
||||
import net.minecraft.client.util.Session;
|
||||
import net.minecraft.client.session.Session;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -16,6 +17,6 @@ public abstract class SessionMixin {
|
|||
@Inject(method = "getUsername", at=@At("RETURN"), cancellable = true)
|
||||
void testclient$overrideUsernameGetter(CallbackInfoReturnable<String> cir) {
|
||||
// only overrides when gui has been initialized cause issues
|
||||
if(Gui.gui != null) cir.setReturnValue(SharedVariables.username);
|
||||
if(Gui.gui != null) cir.setReturnValue(ChipmunkMod.CONFIG.defaultUsername);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
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());
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
|
@ -11,10 +11,18 @@ 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();
|
||||
}
|
||||
|
||||
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
|
||||
private static void isValidChar (char chr, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(chr >= ' ' && chr != '\u007f');
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(TextFieldWidget.class)
|
||||
public class TextFieldWidgetMixin {
|
||||
@Shadow private int maxLength;
|
||||
|
||||
@Inject(method = "setMaxLength", at = @At("HEAD"), cancellable = true)
|
||||
private void setMaxLength (int length, CallbackInfo ci) {
|
||||
this.maxLength = Integer.MAX_VALUE;
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
|
@ -1,22 +1,25 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.StringVisitable;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(Text.Serializer.class)
|
||||
public class TextMixin {
|
||||
@Inject(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/text/MutableText;", at = @At("HEAD"), cancellable = true)
|
||||
private void testclient$preventChatOverflowExploit(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext, CallbackInfoReturnable<MutableText> cir) {
|
||||
Throwable throwable = new Throwable();
|
||||
if(throwable.getStackTrace().length >= 1000 && throwable.getStackTrace()[999].getMethodName().equals("deserialize")) cir.setReturnValue(Text.literal("TestClient prevented a text overflow exploit i think ("+throwable.getStackTrace().length+")").formatted(Formatting.GOLD));
|
||||
}
|
||||
@Mixin(Text.class)
|
||||
public interface TextMixin {
|
||||
@Inject(method = "visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text;visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
|
||||
private <T> void testclient$preventVisitMethodCrash(StringVisitable.Visitor<T> visitor, CallbackInfoReturnable<Optional<T>> cir, Optional optional, Iterator var3, Text text) {
|
||||
if(text == null) cir.setReturnValue(Optional.empty());
|
||||
}
|
||||
@Inject(method = "visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text;visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
|
||||
private <T> void testclient$preventVisitMethodCrash2(StringVisitable.StyledVisitor<T> styledVisitor, Style style, CallbackInfoReturnable<Optional<T>> cir, Style style2, Optional optional, Iterator var5, Text text) {
|
||||
if(text == null) cir.setReturnValue(Optional.empty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@Mixin(Text.Serializer.class)
|
||||
public class TextSerializerMixin {
|
||||
@Unique private static final int LIMIT = 128;
|
||||
|
||||
@Unique private int i;
|
||||
|
||||
@Unique
|
||||
private boolean checkDepth (JsonElement element) {
|
||||
if (element.isJsonPrimitive()) return false;
|
||||
else if (i >= LIMIT) return true;
|
||||
|
||||
if (element.isJsonArray()) {
|
||||
i++;
|
||||
|
||||
for (JsonElement item : element.getAsJsonArray()) if (checkDepth(item)) return true;
|
||||
} else if (element.isJsonObject()) {
|
||||
final JsonObject object = element.getAsJsonObject();
|
||||
|
||||
JsonArray array;
|
||||
|
||||
if (object.has("extra")) array = object.get("extra").getAsJsonArray();
|
||||
else if (object.has("with")) array = object.get("with").getAsJsonArray();
|
||||
else return false;
|
||||
|
||||
i++;
|
||||
|
||||
for (JsonElement member : array) if (checkDepth(member)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Inject(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/text/MutableText;", at = @At("HEAD"), cancellable = true)
|
||||
private void deserialize (JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext, CallbackInfoReturnable<MutableText> cir) {
|
||||
i = 0; // better way to do this?
|
||||
|
||||
final boolean overLimit = checkDepth(jsonElement);
|
||||
|
||||
if (!overLimit) return;
|
||||
|
||||
cir.setReturnValue(Text.empty()); // just ignores it
|
||||
|
||||
cir.cancel();
|
||||
}
|
||||
@Inject(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/text/MutableText;", at = @At("HEAD"), cancellable = true)
|
||||
private void testclient$preventChatOverflowExploit(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext, CallbackInfoReturnable<MutableText> cir) {
|
||||
Throwable throwable = new Throwable();
|
||||
if(throwable.getStackTrace().length >= 700) cir.setReturnValue(Text.literal("TestClient prevented a text overflow exploit i think ("+throwable.getStackTrace().length+")").formatted(Formatting.GOLD));
|
||||
}
|
||||
}
|
|
@ -1,25 +1,36 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.memory.ModuleMemory;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
|
||||
import net.minecraft.client.gui.screen.SplashTextRenderer;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public class TitleScreenMixin {
|
||||
@Shadow @Nullable private String splashText;
|
||||
@Shadow
|
||||
private SplashTextRenderer splashText;
|
||||
|
||||
@Inject(method = "init", at = @At("HEAD"))
|
||||
void testclient$initializeGui(CallbackInfo ci) {
|
||||
splashText = "owo";
|
||||
splashText = new SplashTextRenderer("uwu");
|
||||
if(Gui.gui == null){
|
||||
Gui.initAutoRefresher();
|
||||
Gui.addComponents();
|
||||
Gui.gui = new Gui();
|
||||
ModuleMemory.load();
|
||||
ChipmunkMod.LOGGER.info("Initialised gui!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiTextObfuscationLagModule;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
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.CallbackInfo;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public class WorldRendererMixin {
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
private void chipmunkmod$saveRenderStartTime(CallbackInfo ci) {
|
||||
AntiTextObfuscationLagModule.INSTANCE.renderTimeStart = Instant.now();
|
||||
AntiTextObfuscationLagModule.INSTANCE.exceededLimitThisTick = false;
|
||||
}
|
||||
}
|
18
src/main/java/land/chipmunk/chipmunkmod/modules/Chat.java
Normal file
18
src/main/java/land/chipmunk/chipmunkmod/modules/Chat.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
|
||||
public class Chat {
|
||||
public static double secret = Math.random();
|
||||
|
||||
public static void sendChatMessage (String message) { sendChatMessage(message, false); }
|
||||
public static void sendChatMessage (String message, boolean usePlayerChat) {
|
||||
if (message == null) return;
|
||||
|
||||
final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
|
||||
|
||||
if (usePlayerChat) networkHandler.sendChatMessage(secret + message);
|
||||
else networkHandler.sendChatMessage(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.text.PlainTextContent;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TextContent;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
public class ChomeNSAuth extends Listener {
|
||||
public static final ChomeNSAuth INSTANCE = new ChomeNSAuth();
|
||||
|
||||
public final String id = "chomens_bot_verify";
|
||||
|
||||
public ChomeNSAuth () {
|
||||
ListenerManager.addListener(this);
|
||||
}
|
||||
|
||||
public void init () {}
|
||||
|
||||
@Override
|
||||
public void chatMessageReceived(Text text) {
|
||||
final String authKey = ChipmunkMod.CONFIG.bots.chomens.authKey;
|
||||
|
||||
if (authKey == null) return;
|
||||
|
||||
final TextContent message = text.getContent();
|
||||
|
||||
if (!(message instanceof PlainTextContent)) return;
|
||||
|
||||
final String id = ((PlainTextContent) message).string();
|
||||
|
||||
if (!id.equals(this.id)) return;
|
||||
|
||||
final List<Text> children = text.getSiblings();
|
||||
|
||||
if (children.size() != 2) return;
|
||||
|
||||
if (!(children.getFirst().getContent() instanceof PlainTextContent)) return;
|
||||
|
||||
final String hash = ((PlainTextContent) children.getFirst().getContent()).string();
|
||||
|
||||
final long time = System.currentTimeMillis() / 10_000;
|
||||
|
||||
final String actual = Hashing.sha256()
|
||||
// very pro hash input
|
||||
.hashString(authKey + time, StandardCharsets.UTF_8)
|
||||
.toString()
|
||||
.substring(0, 8);
|
||||
|
||||
if (!hash.equals(actual)) return;
|
||||
|
||||
if (!(children.get(1).getContent() instanceof PlainTextContent)) return;
|
||||
|
||||
final String selector = ((PlainTextContent) children.get(1).getContent()).string();
|
||||
|
||||
final String toSendHash = Hashing.sha256()
|
||||
// very pro hash input
|
||||
.hashString(authKey + authKey + time + time, StandardCharsets.UTF_8)
|
||||
.toString()
|
||||
.substring(0, 8);
|
||||
|
||||
final Component toSend = Component.text(id)
|
||||
.append(Component.text(toSendHash));
|
||||
|
||||
final String toSendString = GsonComponentSerializer.gson().serialize(toSend);
|
||||
|
||||
System.out.println("Sending " + toSendString + " to " + selector);
|
||||
|
||||
CommandCore.INSTANCE.run("tellraw " + selector + " " + toSendString);
|
||||
|
||||
CustomChat.INSTANCE.resetTotal();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
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.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.text.PlainTextContent;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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 List<Text> children = message.getSiblings();
|
||||
|
||||
if (children.isEmpty()) return;
|
||||
|
||||
final Text textComponent = children.getFirst();
|
||||
|
||||
if (!textComponent.getString().equals(ID)) return;
|
||||
|
||||
commands = children.subList(1, children.size())
|
||||
.stream()
|
||||
.map(
|
||||
(eachComponent) -> {
|
||||
final ChomeNSBotCommand command = new ChomeNSBotCommand(
|
||||
ChipmunkMod.CONFIG.bots.chomens.prefix + ((PlainTextContent) eachComponent.getContent()).string(),
|
||||
ChomeNSBotCommand.TrustLevel.valueOf(eachComponent.getSiblings().getFirst().getString())
|
||||
);
|
||||
|
||||
if (!Boolean.parseBoolean(eachComponent.getSiblings().get(1).getString())) return command;
|
||||
|
||||
final List<Text> subList = eachComponent.getSiblings().subList(2, eachComponent.getSiblings().size());
|
||||
|
||||
for (Text aliasComponent : subList) {
|
||||
final String alias = aliasComponent.getString();
|
||||
|
||||
command.aliases.add(alias);
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
)
|
||||
.toList();
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
|
@ -2,15 +2,22 @@ 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 land.chipmunk.chipmunkmod.testclient.modules.other.CommandCoreModule;
|
||||
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.CommandBlock;
|
||||
import net.minecraft.block.entity.CommandBlockBlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
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 net.minecraft.world.dimension.DimensionType;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
@ -18,60 +25,181 @@ 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 final BlockArea relativeArea;
|
||||
@Getter @Setter private BlockPos currentBlockRelative;
|
||||
public boolean ready = false;
|
||||
public BlockPos origin;
|
||||
public BlockArea noPos;
|
||||
public BlockPos block;
|
||||
public BlockArea withPos;
|
||||
|
||||
public static CommandCore INSTANCE = new CommandCore(MinecraftClient.getInstance(), ChipmunkMod.CONFIG.core.relativeArea);
|
||||
private Timer timer;
|
||||
|
||||
public CommandCore (MinecraftClient client, BlockArea relativeArea) {
|
||||
private boolean shouldRefill = false;
|
||||
|
||||
public boolean runFillCommand = true;
|
||||
|
||||
public boolean clientPlayerEntityFilled = false;
|
||||
|
||||
public static CommandCore INSTANCE = new CommandCore(MinecraftClient.getInstance());
|
||||
|
||||
public CommandCore (MinecraftClient client) {
|
||||
this.client = client;
|
||||
this.relativeArea = relativeArea;
|
||||
reloadRelativeArea();
|
||||
}
|
||||
|
||||
public void init () {
|
||||
if (timer != null) cleanup();
|
||||
|
||||
final TimerTask task = new TimerTask() {
|
||||
public void run () {
|
||||
if(!CommandCoreModule.INSTANCE.isEnabled) return;
|
||||
tick();
|
||||
}
|
||||
};
|
||||
|
||||
final TimerTask refillTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(!CommandCoreModule.INSTANCE.isEnabled) return;
|
||||
if (clientPlayerEntityFilled) {
|
||||
clientPlayerEntityFilled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
check();
|
||||
|
||||
if (!shouldRefill) return;
|
||||
|
||||
refill();
|
||||
|
||||
shouldRefill = false;
|
||||
}
|
||||
};
|
||||
|
||||
timer = new Timer();
|
||||
|
||||
timer.schedule(task, 50, 50);
|
||||
|
||||
timer.schedule(refillTask, 50, 1000);
|
||||
|
||||
move(client.player.getPos());
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null) {
|
||||
cleanup();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
reloadRelativeArea();
|
||||
}
|
||||
|
||||
public void reloadRelativeArea () {
|
||||
noPos = new BlockArea(new BlockPos(0, 0, 0),
|
||||
new BlockPos(CommandCoreModule.INSTANCE.coreSizeX.optionValue-1,
|
||||
CommandCoreModule.INSTANCE.coreSizeY.optionValue-1,
|
||||
CommandCoreModule.INSTANCE.coreSizeZ.optionValue-1));
|
||||
}
|
||||
|
||||
public void check () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null || withPos == null || !ready) return;
|
||||
|
||||
try {
|
||||
for (int x = withPos.start.getX(); x <= withPos.end.getX(); x++) {
|
||||
for (int y = withPos.start.getY(); y <= withPos.end.getY(); y++) {
|
||||
for (int z = withPos.start.getZ(); z <= withPos.end.getZ(); z++) {
|
||||
final BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
final ClientWorld world = client.world;
|
||||
|
||||
if (world == null) return;
|
||||
|
||||
final Block block = world.getBlockState(pos).getBlock();
|
||||
|
||||
if (block instanceof CommandBlock) continue;
|
||||
|
||||
shouldRefill = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void move (Vec3d position) {
|
||||
if (!ready) {
|
||||
ready = true;
|
||||
// for (Listener listener : listeners) listener.ready();
|
||||
}
|
||||
final ClientWorld world = client.world;
|
||||
|
||||
if (world == null || noPos == null) return;
|
||||
|
||||
final DimensionType dimension = world.getDimension();
|
||||
|
||||
origin = new BlockPos(
|
||||
((int) position.getX() / 16) * 16,
|
||||
0, // TODO: Use the actual bottom of the world instead of hardcoding to 0
|
||||
(int) MathUtilities.clamp(noPos.start.getY(), dimension.minY(), dimension.height()),
|
||||
((int) position.getZ() / 16) * 16
|
||||
);
|
||||
|
||||
if (currentBlockRelative == null) currentBlockRelative = new BlockPos(relativeArea.start());
|
||||
withPos = new BlockArea(
|
||||
new BlockPos(
|
||||
noPos.start.getX() + origin.getX(),
|
||||
(int) MathUtilities.clamp(noPos.start.getY(), dimension.minY(), dimension.height()),
|
||||
noPos.start.getZ() + origin.getZ()
|
||||
),
|
||||
new BlockPos(
|
||||
noPos.end.getX() + origin.getX(),
|
||||
(int) MathUtilities.clamp(noPos.end.getY(), dimension.minY(), dimension.height()),
|
||||
noPos.end.getZ() + origin.getZ()
|
||||
)
|
||||
);
|
||||
|
||||
block = new BlockPos(withPos.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();
|
||||
if (!runFillCommand || withPos == null) return;
|
||||
|
||||
final String command = String.format(
|
||||
"fill %s %s %s %s %s %s command_block",
|
||||
relStart.getX() + origin.getX(),
|
||||
relStart.getY() + origin.getY(),
|
||||
relStart.getZ() + origin.getZ(),
|
||||
KaboomCheck.INSTANCE.isKaboom ?
|
||||
"fill %s %s %s %s %s %s repeating_command_block replace" :
|
||||
"fill %s %s %s %s %s %s command_block",
|
||||
withPos.start.getX(),
|
||||
withPos.start.getY(),
|
||||
withPos.start.getZ(),
|
||||
|
||||
relEnd.getX() + origin.getX(),
|
||||
relEnd.getY() + origin.getY(),
|
||||
relEnd.getZ() + origin.getZ()
|
||||
withPos.end.getX(),
|
||||
withPos.end.getY(),
|
||||
withPos.end.getZ()
|
||||
);
|
||||
|
||||
client.getNetworkHandler().sendChatCommand(command);
|
||||
}
|
||||
|
||||
public void incrementCurrentBlock () {
|
||||
final BlockPos start = relativeArea.start();
|
||||
final BlockPos end = relativeArea.end();
|
||||
if (withPos == null) return;
|
||||
|
||||
int x = currentBlockRelative.getX();
|
||||
int y = currentBlockRelative.getY();
|
||||
int z = currentBlockRelative.getZ();
|
||||
final BlockPos start = withPos.start;
|
||||
final BlockPos end = withPos.end;
|
||||
|
||||
if (start == null || end == null) return;
|
||||
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
|
||||
x++;
|
||||
|
||||
|
@ -91,31 +219,94 @@ public class CommandCore {
|
|||
z = start.getZ();
|
||||
}
|
||||
|
||||
currentBlockRelative = new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
public BlockPos currentBlockAbsolute () {
|
||||
return currentBlockRelative.add(origin);
|
||||
block = new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
public void run (String command) {
|
||||
// should probably throw an illegalstateexception but i dont feel like handling it everywhere
|
||||
if(!CommandCoreModule.INSTANCE.isEnabled) return;
|
||||
final ClientConnection connection = client.getNetworkHandler().getConnection();
|
||||
final BlockPos currentBlock = currentBlockAbsolute();
|
||||
|
||||
// TODO: Support using repeating command blocks (on kaboom-like servers) (because less packets)
|
||||
connection.send(new UpdateCommandBlockC2SPacket(currentBlock, "", CommandBlockBlockEntity.Type.REDSTONE, false, false, false));
|
||||
connection.send(new UpdateCommandBlockC2SPacket(currentBlock, command, CommandBlockBlockEntity.Type.REDSTONE, false, false, true));
|
||||
if (block == null) return;
|
||||
|
||||
if (KaboomCheck.INSTANCE.isKaboom) {
|
||||
connection.send(
|
||||
new UpdateCommandBlockC2SPacket(
|
||||
block,
|
||||
command,
|
||||
CommandBlockBlockEntity.Type.AUTO,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
)
|
||||
);
|
||||
} else {
|
||||
connection.send(
|
||||
new UpdateCommandBlockC2SPacket(
|
||||
block,
|
||||
"",
|
||||
CommandBlockBlockEntity.Type.REDSTONE,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
connection.send(
|
||||
new UpdateCommandBlockC2SPacket(
|
||||
block,
|
||||
command,
|
||||
CommandBlockBlockEntity.Type.REDSTONE,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
incrementCurrentBlock();
|
||||
}
|
||||
|
||||
public CompletableFuture<NbtCompound> runTracked (String command) {
|
||||
if(!CommandCoreModule.INSTANCE.isEnabled) return CompletableFuture.failedFuture(new IllegalStateException("The core is disabled!"));
|
||||
final ClientConnection connection = client.getNetworkHandler().getConnection();
|
||||
final BlockPos currentBlock = currentBlockAbsolute();
|
||||
|
||||
// TODO: Support using repeating command blocks (on kaboom-like servers) (because less packets)
|
||||
connection.send(new UpdateCommandBlockC2SPacket(currentBlock, "", CommandBlockBlockEntity.Type.SEQUENCE, false, false, false));
|
||||
connection.send(new UpdateCommandBlockC2SPacket(currentBlock, command, CommandBlockBlockEntity.Type.REDSTONE, true, false, true));
|
||||
if (block == null) return new CompletableFuture<>();
|
||||
|
||||
if (KaboomCheck.INSTANCE.isKaboom) {
|
||||
connection.send(
|
||||
new UpdateCommandBlockC2SPacket(
|
||||
block,
|
||||
command,
|
||||
CommandBlockBlockEntity.Type.AUTO,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
)
|
||||
);
|
||||
} else {
|
||||
connection.send(
|
||||
new UpdateCommandBlockC2SPacket(
|
||||
block,
|
||||
"",
|
||||
CommandBlockBlockEntity.Type.REDSTONE,
|
||||
true,
|
||||
false,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
connection.send(
|
||||
new UpdateCommandBlockC2SPacket(
|
||||
block,
|
||||
command,
|
||||
CommandBlockBlockEntity.Type.REDSTONE,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
incrementCurrentBlock();
|
||||
|
||||
|
@ -125,8 +316,7 @@ public class CommandCore {
|
|||
|
||||
final TimerTask queryTask = new TimerTask() {
|
||||
public void run () {
|
||||
client.getNetworkHandler().getDataQueryHandler().queryBlockNbt(currentBlock,
|
||||
future::complete);
|
||||
client.getNetworkHandler().getDataQueryHandler().queryBlockNbt(block, future::complete);
|
||||
|
||||
timer.cancel(); // ? Is this necesary?
|
||||
timer.purge();
|
||||
|
@ -139,8 +329,13 @@ public class CommandCore {
|
|||
}
|
||||
|
||||
public void cleanup () {
|
||||
origin = null;
|
||||
currentBlockRelative = null;
|
||||
if (timer == null) return;
|
||||
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
|
||||
withPos = null;
|
||||
block = 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) {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.gson.JsonElement;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
@ -11,15 +13,28 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class CustomChat {
|
||||
private final MinecraftClient client;
|
||||
|
||||
public static final CustomChat INSTANCE = new CustomChat(MinecraftClient.getInstance());
|
||||
|
||||
@Getter @Setter private boolean enabled = true;
|
||||
public static final Pattern RACIST_PATTERN = Pattern.compile("nigga|nigger|i hate black", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
@Getter @Setter private String format;
|
||||
public boolean enabled = true;
|
||||
|
||||
public String format;
|
||||
|
||||
private Timer timer;
|
||||
|
||||
private int total = 0;
|
||||
|
||||
public CustomChat (MinecraftClient client) {
|
||||
this.client = client;
|
||||
|
@ -27,6 +42,39 @@ public class CustomChat {
|
|||
reloadFormat();
|
||||
}
|
||||
|
||||
public void init () {
|
||||
final TimerTask task = new TimerTask() {
|
||||
public void run () {
|
||||
tick();
|
||||
}
|
||||
};
|
||||
|
||||
resetTotal();
|
||||
|
||||
timer = new Timer();
|
||||
timer.schedule(task, 0, 50);
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler != null) return;
|
||||
|
||||
resetTotal();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
public void resetTotal() {
|
||||
total = 0;
|
||||
}
|
||||
|
||||
private void cleanup () {
|
||||
if (timer == null) return;
|
||||
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
}
|
||||
|
||||
public void reloadFormat () {
|
||||
final JsonElement formatString = ChipmunkMod.CONFIG.customChat.format;
|
||||
|
||||
|
@ -36,9 +84,20 @@ public class CustomChat {
|
|||
|
||||
public void chat (String message) {
|
||||
final ClientPlayerEntity player = client.player;
|
||||
|
||||
try {
|
||||
final Matcher racistMatcher = RACIST_PATTERN.matcher(message);
|
||||
if (racistMatcher.matches()) {
|
||||
player.sendMessage(Text.literal("racism bad"));
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
networkHandler.sendChatMessage(message);
|
||||
Chat.sendChatMessage(message, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -55,6 +114,17 @@ public class CustomChat {
|
|||
final Component deserialized = serializer.deserialize(message);
|
||||
final String messageWithColor = GsonComponentSerializer.gson().serialize(deserialized).replace("MESSAGE", randomized);
|
||||
|
||||
final String key = ChipmunkMod.CONFIG.bots.chomens.formatKey;
|
||||
|
||||
final String hash = key != null ?
|
||||
Hashing.sha256()
|
||||
.hashString(key + total, StandardCharsets.UTF_8)
|
||||
.toString()
|
||||
.substring(0, 8) :
|
||||
"";
|
||||
|
||||
total++;
|
||||
|
||||
try {
|
||||
// final MutablePlayerListEntry entry = Players.INSTANCE.getEntry(client.getNetworkHandler().getProfile().getId());
|
||||
|
||||
|
@ -68,15 +138,16 @@ public class CustomChat {
|
|||
// .replace("\"PREFIX\"", prefix)
|
||||
// .replace("\"DISPLAYNAME\"", displayName)
|
||||
.replace("USERNAME", username)
|
||||
.replace("HASH", hash)
|
||||
.replace("{\"text\":\"MESSAGE\"}", messageWithColor)
|
||||
.replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":")
|
||||
.replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")) // TODO: make this not use regex
|
||||
.replace("MESSAGE", sanitizedMessage.replaceAll("&.", ""))
|
||||
.replace(randomized, "MESSAGE"); // ohio ohio
|
||||
|
||||
CommandCore.INSTANCE.run("minecraft:tellraw @a " + sanitizedFormat);
|
||||
CommandCore.INSTANCE.run((KaboomCheck.INSTANCE.isKaboom ? "minecraft:tellraw @a " : "tellraw @a ") + sanitizedFormat);
|
||||
} catch (Exception e) {
|
||||
if (client.player == null) return;
|
||||
client.player.sendMessage(Component.text(e.toString()).color(NamedTextColor.RED));
|
||||
((Audience) client.player).sendMessage(Component.text(e.toString()).color(NamedTextColor.RED));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import com.mojang.brigadier.suggestion.Suggestion;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.packet.s2c.play.CommandSuggestionsS2CPacket;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class KaboomCheck extends Listener {
|
||||
public boolean isKaboom = false;
|
||||
|
||||
private Timer timer = null;
|
||||
|
||||
private final MinecraftClient client;
|
||||
|
||||
public static final KaboomCheck INSTANCE = new KaboomCheck(MinecraftClient.getInstance());
|
||||
|
||||
public KaboomCheck (MinecraftClient client) {
|
||||
this.client = client;
|
||||
|
||||
ListenerManager.addListener(this);
|
||||
}
|
||||
|
||||
public void init () {}
|
||||
|
||||
public void onJoin () {
|
||||
final TimerTask task = new TimerTask() {
|
||||
public void run () {
|
||||
tick();
|
||||
}
|
||||
};
|
||||
|
||||
if (timer != null) cleanup();
|
||||
|
||||
timer = new Timer();
|
||||
|
||||
timer.schedule(task, 50, 50);
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null) cleanup();
|
||||
}
|
||||
|
||||
private void check () {
|
||||
final CompletableFuture<CommandSuggestionsS2CPacket> future = TabComplete.INSTANCE.complete("/ver ");
|
||||
|
||||
future.thenApply((packet) -> {
|
||||
final Suggestions suggestions = packet.getSuggestions();
|
||||
|
||||
for (int i = 0; i < suggestions.getList().size(); i++) {
|
||||
final Suggestion suggestion = suggestions.getList().get(i);
|
||||
|
||||
if (suggestion.getText().equals("Extras")) {
|
||||
isKaboom = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void cleanup () {
|
||||
if (timer == null) return;
|
||||
|
||||
isKaboom = false;
|
||||
|
||||
timer.purge();
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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 () {}
|
||||
}
|
|
@ -6,24 +6,28 @@ import com.mojang.brigadier.suggestion.Suggestions;
|
|||
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.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.PlayerListEntry;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.CommandSuggestionsS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerListS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static land.chipmunk.chipmunkmod.util.ServerUtilities.serverHasCommand;
|
||||
|
||||
public class Players extends Listener {
|
||||
public List<MutablePlayerListEntry> list = new ArrayList<>();
|
||||
|
||||
public static Players INSTANCE = new Players(MinecraftClient.getInstance());
|
||||
|
||||
private Timer timer;
|
||||
|
||||
private final MinecraftClient client;
|
||||
|
||||
public Players (MinecraftClient client) {
|
||||
|
@ -33,37 +37,10 @@ public class Players extends Listener {
|
|||
TabComplete.INSTANCE.init();
|
||||
}
|
||||
|
||||
public void init () {
|
||||
final TimerTask task = new TimerTask() {
|
||||
public void run () {
|
||||
tick();
|
||||
}
|
||||
};
|
||||
|
||||
if (timer != null) cleanup();
|
||||
|
||||
timer = new Timer();
|
||||
timer.schedule(task, 0, 50);
|
||||
}
|
||||
|
||||
public void cleanup () {
|
||||
list.clear();
|
||||
|
||||
if (timer == null) return;
|
||||
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
timer = null;
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null) cleanup();
|
||||
}
|
||||
public void init () {}
|
||||
|
||||
@Override
|
||||
public void packetReceived (Packet packet) {
|
||||
public void packetReceived (Packet<?> packet) {
|
||||
if (packet instanceof PlayerListS2CPacket) packetReceived((PlayerListS2CPacket) packet);
|
||||
else if (packet instanceof PlayerRemoveS2CPacket) packetReceived((PlayerRemoveS2CPacket) packet);
|
||||
}
|
||||
|
@ -98,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;
|
||||
}
|
||||
}
|
||||
|
@ -111,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;
|
||||
}
|
||||
}
|
||||
|
@ -121,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;
|
||||
}
|
||||
}
|
||||
|
@ -130,15 +107,20 @@ public class Players extends Listener {
|
|||
}
|
||||
|
||||
private MutablePlayerListEntry getEntry (PlayerListS2CPacket.Entry other) {
|
||||
return getEntry(other.profile().getId());
|
||||
return getEntry(other.profileId());
|
||||
}
|
||||
|
||||
private void addPlayer (PlayerListS2CPacket.Entry newEntry) {
|
||||
try {
|
||||
final MutablePlayerListEntry duplicate = getEntry(newEntry);
|
||||
if (duplicate != null) list.remove(duplicate);
|
||||
if (duplicate != null) {
|
||||
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();
|
||||
}
|
||||
|
@ -149,7 +131,17 @@ 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.profileId());
|
||||
|
||||
if(entryAccessor != null) {
|
||||
entryAccessor.setGameMode(newEntry.gameMode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -159,14 +151,33 @@ 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.profileId());
|
||||
|
||||
if(entryAccessor == null) return;
|
||||
|
||||
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;
|
||||
|
||||
PlayerListEntry oldEntry = accessor.playerListEntries().get(newEntry.profileId());
|
||||
if(oldEntry != null) {
|
||||
oldEntry.setDisplayName(newEntry.displayName());
|
||||
}
|
||||
}
|
||||
|
||||
private void removePlayer (UUID uuid) {
|
||||
|
@ -174,27 +185,68 @@ public class Players extends Listener {
|
|||
final MutablePlayerListEntry target = getEntry(uuid);
|
||||
if (target == null) return;
|
||||
|
||||
if (!serverHasCommand("scoreboard")) {
|
||||
removeFromPlayerList(uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
final CompletableFuture<CommandSuggestionsS2CPacket> future = TabComplete.INSTANCE.complete("/scoreboard players add ");
|
||||
|
||||
if (future == null) return;
|
||||
|
||||
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);
|
||||
|
||||
final Message tooltip = suggestion.getTooltip();
|
||||
if (tooltip != null || !suggestion.getText().equals(username)) continue;
|
||||
return packet;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
list.remove(target);
|
||||
return packet;
|
||||
|
||||
removeFromPlayerList(uuid);
|
||||
|
||||
for (MutablePlayerListEntry entry : list) {
|
||||
if (!entry.profile.getId().equals(uuid)) continue;
|
||||
|
||||
addToPlayerList(new PlayerListEntry(entry.profile, false));
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
final ClientPlayNetworkHandlerAccessor accessor = ((ClientPlayNetworkHandlerAccessor) MinecraftClient.getInstance().getNetworkHandler());
|
||||
|
||||
if (accessor == null) return;
|
||||
|
||||
final PlayerListEntry playerListEntry = accessor.playerListEntries().remove(uuid);
|
||||
|
||||
if (playerListEntry != null) {
|
||||
accessor.listedPlayerListEntries().remove(playerListEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.fun.RainbowNameModule;
|
||||
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;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.TextWidget;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TextContent;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
|
@ -23,13 +29,15 @@ public class RainbowName {
|
|||
|
||||
private Timer timer = null;
|
||||
|
||||
@Getter @Setter private boolean enabled = false;
|
||||
public boolean enabled = false;
|
||||
|
||||
private String[] team;
|
||||
|
||||
@Getter @Setter private String displayName;
|
||||
public String displayName;
|
||||
|
||||
private int startHue = 0;
|
||||
public double speed = 1;
|
||||
public int saturation = 255;
|
||||
public int value = 255;
|
||||
|
||||
public void init () {
|
||||
final TimerTask task = new TimerTask() {
|
||||
|
@ -41,7 +49,7 @@ public class RainbowName {
|
|||
if (timer != null) cleanup();
|
||||
|
||||
timer = new Timer();
|
||||
timer.schedule(task, 0, 75);
|
||||
timer.schedule(task, 0, 50);
|
||||
}
|
||||
|
||||
private String[] generateColorCodes(int length) {
|
||||
|
@ -90,24 +98,11 @@ public class RainbowName {
|
|||
}
|
||||
|
||||
public void enable () {
|
||||
final String[] colorCodes = generateColorCodes(8);
|
||||
client.getNetworkHandler().sendChatCommand("extras:username " + generateUsername(colorCodes));
|
||||
|
||||
team = generateTeamName();
|
||||
|
||||
CommandCore.INSTANCE.run("minecraft:team add " + String.join("", team));
|
||||
|
||||
CommandCore.INSTANCE.run("minecraft:execute as " + client.getNetworkHandler().getProfile().getId() + " run team join " + String.join("", team));
|
||||
|
||||
enabled = true;
|
||||
this.displayName = ChipmunkMod.CONFIG.defaultUsername;
|
||||
}
|
||||
|
||||
public void disable () {
|
||||
client.getNetworkHandler().sendChatCommand("extras:username " + client.getSession().getUsername());
|
||||
|
||||
CommandCore.INSTANCE.run("minecraft:team remove " + String.join("", team));
|
||||
team = null;
|
||||
|
||||
CommandCore.INSTANCE.run("essentials:nick " + client.getSession().getUsername() + " off");
|
||||
|
||||
enabled = false;
|
||||
|
@ -115,7 +110,7 @@ public class RainbowName {
|
|||
|
||||
public RainbowName (MinecraftClient client) {
|
||||
this.client = client;
|
||||
this.displayName = client.getSession().getUsername();
|
||||
this.displayName = ChipmunkMod.CONFIG.defaultUsername;
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
|
@ -128,22 +123,25 @@ public class RainbowName {
|
|||
}
|
||||
|
||||
if (!enabled) return;
|
||||
|
||||
int hue = startHue;
|
||||
int increment = (int) (360.0 / Math.max(displayName.length(), 20));
|
||||
int increment = (int) (360.0 / Math.max(displayName.length(), 20) * speed);
|
||||
|
||||
Component component = Component.empty();
|
||||
StringBuilder essentialsNickname = new StringBuilder();
|
||||
MutableText preview = Text.empty();
|
||||
|
||||
for (char character : displayName.toCharArray()) {
|
||||
String color = String.format("%06x", ColorUtilities.hsvToRgb(hue, 100, 100));
|
||||
int colorRaw = ColorUtilities.hsvToRgb(hue, saturation, value);
|
||||
String color = String.format("%06x", colorRaw);
|
||||
component = component.append(Component.text(character).color(TextColor.fromHexString("#" + color)));
|
||||
essentialsNickname.append("\u00a7#").append(color).append(character != ' ' ? character : '_');
|
||||
preview.append(Text.of(character+"").copy().withColor(colorRaw));
|
||||
hue = (hue + increment) % 360;
|
||||
}
|
||||
|
||||
CommandCore.INSTANCE.run("minecraft:team modify " + String.join("", team) + " prefix " + GsonComponentSerializer.gson().serialize(component));
|
||||
CommandCore.INSTANCE.run("essentials:nick " + client.getSession().getUsername() + " " + essentialsNickname);
|
||||
CommandCore.INSTANCE.run("essentials:nick " + ChipmunkMod.CONFIG.defaultUsername + " " + essentialsNickname);
|
||||
|
||||
((RainbowNameModule.MutableTextWidget)RainbowNameModule.preview.widget).setText(preview);
|
||||
|
||||
startHue = (startHue + increment) % 360;
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -3,34 +3,42 @@ 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 land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.SelfCareModule;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
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.network.packet.s2c.play.PlayerPositionLookS2CPacket;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
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;
|
||||
public boolean icuEnabled = true;
|
||||
|
||||
@Getter @Setter private String skin;
|
||||
private int gameMode;
|
||||
|
||||
public String skin;
|
||||
|
||||
private Timer timer;
|
||||
private Timer chatTimer;
|
||||
|
||||
private boolean cspy = false;
|
||||
@Getter @Setter private boolean hasSkin = false;
|
||||
public boolean hasSkin = false;
|
||||
|
||||
private Timer timer = null;
|
||||
private Timer chatTimer = null;
|
||||
private int positionPacketsPerSecond = 0;
|
||||
|
||||
public static final SelfCare INSTANCE = new SelfCare(MinecraftClient.getInstance(), 70L, 500L); // make the intervals in config?
|
||||
|
||||
|
@ -44,7 +52,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 +67,6 @@ public class SelfCare extends Listener {
|
|||
}
|
||||
};
|
||||
|
||||
if (timer != null || chatTimer != null) cleanup();
|
||||
|
||||
timer = new Timer();
|
||||
chatTimer = new Timer();
|
||||
|
||||
|
@ -71,14 +79,16 @@ public class SelfCare extends Listener {
|
|||
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
timer = null;
|
||||
|
||||
chatTimer.cancel();
|
||||
chatTimer.purge();
|
||||
chatTimer = null;
|
||||
|
||||
gameMode = -1;
|
||||
|
||||
hasSkin = false;
|
||||
cspy = false;
|
||||
// cspy too mabe?
|
||||
// why was cspy not here lol
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,37 +106,59 @@ public class SelfCare extends Listener {
|
|||
}
|
||||
|
||||
public void tick () {
|
||||
final ClientPlayerEntity player = client.player;
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null) {
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
if(!SelfCareModule.INSTANCE.isEnabled) return;
|
||||
|
||||
final ClientPlayerEntity player = client.player;
|
||||
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");
|
||||
else if (positionPacketsPerSecond >= 10 && icuEnabled) CommandCore.INSTANCE.run("sudo * icu stop");
|
||||
}
|
||||
|
||||
public void chatTick () {
|
||||
if(!SelfCareModule.INSTANCE.isEnabled) return;
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (!cspy && cspyEnabled) { if (serverHasCommand("c")) networkHandler.sendChatCommand("c on"); }
|
||||
else if (!hasSkin && !skin.equals("off")) { if (serverHasCommand("skin")) networkHandler.sendChatCommand("skin " + skin); }
|
||||
}
|
||||
|
||||
// TODO: Move this into a separate class related to server info gathering (and yes, I plan on making this d y n a m i c and require little to no configuration for most servers)
|
||||
private boolean serverHasCommand (String name) {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
@Override
|
||||
public void packetReceived(Packet<?> packet) {
|
||||
if (packet instanceof GameJoinS2CPacket) packetReceived((GameJoinS2CPacket) packet);
|
||||
else if (packet instanceof GameStateChangeS2CPacket) packetReceived((GameStateChangeS2CPacket) packet);
|
||||
else if (packet instanceof PlayerPositionLookS2CPacket) packetReceived((PlayerPositionLookS2CPacket) packet);
|
||||
}
|
||||
|
||||
if (networkHandler == null) return false;
|
||||
public void packetReceived(GameJoinS2CPacket packet) {
|
||||
gameMode = packet.commonPlayerSpawnInfo().gameMode().getId();
|
||||
}
|
||||
|
||||
for (CommandNode node : networkHandler.getCommandDispatcher().getRoot().getChildren()) {
|
||||
if (!(node instanceof LiteralCommandNode literal)) continue;
|
||||
public void packetReceived(GameStateChangeS2CPacket packet) {
|
||||
if (packet.getReason() != GameStateChangeS2CPacket.GAME_MODE_CHANGED) return;
|
||||
|
||||
if (literal.getLiteral().equals(name)) return true;
|
||||
gameMode = (int) packet.getValue();
|
||||
}
|
||||
|
||||
public void packetReceived(PlayerPositionLookS2CPacket packet) {
|
||||
if (timer == null) return;
|
||||
|
||||
try {
|
||||
positionPacketsPerSecond++;
|
||||
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
positionPacketsPerSecond--;
|
||||
}
|
||||
}, 1000);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import land.chipmunk.chipmunkmod.song.Note;
|
|||
import land.chipmunk.chipmunkmod.song.Song;
|
||||
import land.chipmunk.chipmunkmod.song.SongLoaderException;
|
||||
import land.chipmunk.chipmunkmod.song.SongLoaderThread;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
@ -14,12 +14,12 @@ import net.minecraft.client.network.ClientPlayNetworkHandler;
|
|||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
@ -35,13 +35,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;
|
||||
public boolean useCore = true;
|
||||
public boolean actionbar = true;
|
||||
|
||||
public float pitch = 0;
|
||||
|
||||
private final MinecraftClient client;
|
||||
|
||||
|
@ -53,34 +56,34 @@ public class SongPlayer {
|
|||
|
||||
public void loadSong (Path location) {
|
||||
if (loaderThread != null) {
|
||||
client.player.sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
|
||||
client.player.sendMessage(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
_loaderThread.start();
|
||||
loaderThread = _loaderThread;
|
||||
} catch (SongLoaderException e) {
|
||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message()).color(NamedTextColor.RED));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Failed to load song: %s", e.message.getString()).color(NamedTextColor.RED));
|
||||
loaderThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void loadSong (URL location) {
|
||||
if (loaderThread != null) {
|
||||
client.player.sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
|
||||
client.player.sendMessage(Component.translatable("Loading %s", Component.text(location.toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Loading %s", Component.text(location.toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
_loaderThread.start();
|
||||
loaderThread = _loaderThread;
|
||||
} catch (SongLoaderException e) {
|
||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message()).color(NamedTextColor.RED));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Failed to load song: %s", e.message.getString()).color(NamedTextColor.RED));
|
||||
loaderThread = null;
|
||||
}
|
||||
}
|
||||
|
@ -100,19 +103,19 @@ 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));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Failed to load song: %s", loaderThread.exception.message.getString()).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));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
}
|
||||
loaderThread = null;
|
||||
}
|
||||
|
||||
if (currentSong == null) {
|
||||
if (songQueue.size() == 0) return;
|
||||
if (songQueue.isEmpty()) return;
|
||||
|
||||
currentSong = songQueue.poll();
|
||||
client.player.sendMessage(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
currentSong.play();
|
||||
}
|
||||
|
||||
|
@ -120,8 +123,8 @@ public class SongPlayer {
|
|||
else ticksUntilPausedActionbar = 20;
|
||||
|
||||
try {
|
||||
if (!useCore) client.player.sendActionBar(generateActionbar());
|
||||
else CommandCore.INSTANCE.run("title " + SELECTOR + " actionbar " + GsonComponentSerializer.gson().serialize(generateActionbar()));
|
||||
if (!useCore && actionbar && client.player != null) ((Audience) client.player).sendActionBar(generateActionbar());
|
||||
else if (actionbar) CommandCore.INSTANCE.run("title " + SELECTOR + " actionbar " + GsonComponentSerializer.gson().serialize(generateActionbar()));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -131,13 +134,13 @@ public class SongPlayer {
|
|||
handlePlaying();
|
||||
|
||||
if (currentSong.finished()) {
|
||||
client.player.sendMessage(Component.translatable("Finished playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
((Audience) client.player).sendMessage(Component.translatable("Finished playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||
currentSong = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
playTimer.schedule(playTask, 50, 50);
|
||||
playTimer.schedule(playTask, 60, 50);
|
||||
|
||||
if (currentSong != null) currentSong.play();
|
||||
}
|
||||
|
@ -146,7 +149,7 @@ public class SongPlayer {
|
|||
final ClientPlayerEntity player = client.player;
|
||||
|
||||
Component component = Component.empty()
|
||||
.append(Component.translatable("%s", player.getName()).color(NamedTextColor.GREEN))
|
||||
.append(Component.translatable("%s", player.getName().getString()).color(NamedTextColor.GREEN))
|
||||
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
|
||||
.append(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN))
|
||||
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
|
||||
|
@ -204,18 +207,29 @@ public class SongPlayer {
|
|||
while (currentSong.reachedNextNote()) {
|
||||
final Note note = currentSong.getNextNote();
|
||||
|
||||
final float floatingPitch = (float) Math.pow(2, (note.pitch - 12) / 12.0);
|
||||
|
||||
try {
|
||||
if (!useCore) {
|
||||
if (floatingPitch < 0 || floatingPitch > 2) return;
|
||||
if (!useCore && client.player != null) {
|
||||
final float floatingPitch = (float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12))));
|
||||
|
||||
final String[] thing = note.instrument.sound.split(":");
|
||||
|
||||
if (thing[1] == null) return; // idk if this can be null but ill just protect it for now i guess
|
||||
|
||||
client.player.playSound(SoundEvent.of(Identifier.of(thing[0], thing[1])), SoundCategory.RECORDS, note.volume, floatingPitch);
|
||||
} else CommandCore.INSTANCE.run("execute as " + SELECTOR + " at @s run playsound " + note.instrument.sound + " record @s ~ ~ ~ " + note.volume + " " + floatingPitch);
|
||||
client.submit(() -> client.world.playSound(
|
||||
client.player.getX(),
|
||||
client.player.getY(),
|
||||
client.player.getZ(),
|
||||
SoundEvent.of(Identifier.of(thing[0], thing[1])),
|
||||
SoundCategory.RECORDS,
|
||||
note.volume,
|
||||
floatingPitch,
|
||||
true
|
||||
));
|
||||
} else {
|
||||
final float floatingPitch = MathUtilities.clamp((float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12)))), 0F, 2F);
|
||||
|
||||
CommandCore.INSTANCE.run("execute as " + SELECTOR + " at @s run playsound " + note.instrument.sound + " record @s ~ ~ ~ " + note.volume + " " + floatingPitch);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ 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.ClientConnection;
|
||||
|
@ -17,13 +16,10 @@ 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());
|
||||
|
||||
@Getter private boolean loggedIn = false;
|
||||
|
||||
public TabComplete (MinecraftClient client) {
|
||||
this.client = client;
|
||||
ListenerManager.addListener(this);
|
||||
|
@ -40,8 +36,7 @@ public class TabComplete extends Listener {
|
|||
|
||||
if (connection == null) return null;
|
||||
|
||||
final int transactionId = nextTransactionId++;
|
||||
if (nextTransactionId > Integer.MAX_VALUE) nextTransactionId = 0; // ? Can and should I use negative numbers too?
|
||||
final int transactionId = TransactionManager.INSTANCE.nextTransactionId();
|
||||
connection.send(new RequestCommandCompletionsC2SPacket(transactionId, command));
|
||||
|
||||
final CompletableFuture<CommandSuggestionsS2CPacket> future = new CompletableFuture<>();
|
||||
|
@ -50,12 +45,12 @@ public class TabComplete extends Listener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void packetReceived (Packet packet) {
|
||||
public void packetReceived (Packet<?> packet) {
|
||||
if (packet instanceof CommandSuggestionsS2CPacket) packetReceived((CommandSuggestionsS2CPacket) packet);
|
||||
}
|
||||
|
||||
public void packetReceived (CommandSuggestionsS2CPacket packet) {
|
||||
final CompletableFuture<CommandSuggestionsS2CPacket> future = transactions.get(packet.getCompletionId());
|
||||
final CompletableFuture<CommandSuggestionsS2CPacket> future = transactions.get(packet.id());
|
||||
|
||||
if (future == null) return;
|
||||
future.complete(packet);
|
||||
|
|
|
@ -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++; }
|
||||
}
|
|
@ -27,7 +27,7 @@ public class Instrument {
|
|||
this.id = id;
|
||||
this.name = name;
|
||||
this.offset = offset;
|
||||
this.sound = name;
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
private Instrument (int id, String name, int offset) {
|
||||
|
|
|
@ -19,7 +19,7 @@ public class MidiConverter {
|
|||
public static final int NOTE_OFF = 0x80;
|
||||
|
||||
public static Song getSongFromUrl(URL url) throws IOException, InvalidMidiDataException, URISyntaxException, NoSuchAlgorithmException, KeyManagementException {
|
||||
Sequence sequence = MidiSystem.getSequence(DownloadUtilities.DownloadToInputStream(url, 5*1024*1024));
|
||||
Sequence sequence = MidiSystem.getSequence(DownloadUtilities.DownloadToInputStream(url));
|
||||
return getSong(sequence, Paths.get(url.toURI().getPath()).getFileName().toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -164,11 +164,7 @@ public class NBSConverter {
|
|||
if (index >= customInstruments.size()) continue;
|
||||
NBSCustomInstrument customInstrument = customInstruments.get(index);
|
||||
instrument = Instrument.of(customInstrument.name);
|
||||
// key += customInstrument.pitch;
|
||||
}
|
||||
|
||||
if (key < 33 || key > 57) {
|
||||
continue;
|
||||
key += customInstrument.pitch;
|
||||
}
|
||||
|
||||
byte layerVolume = 100;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -17,7 +17,7 @@ public class SongLoaderThread extends Thread {
|
|||
public SongLoaderException exception;
|
||||
public Song song;
|
||||
|
||||
private boolean isUrl = false;
|
||||
private boolean isUrl;
|
||||
|
||||
public SongLoaderThread (URL location) throws SongLoaderException {
|
||||
isUrl = true;
|
||||
|
@ -34,7 +34,7 @@ public class SongLoaderThread extends Thread {
|
|||
String name;
|
||||
try {
|
||||
if (isUrl) {
|
||||
bytes = DownloadUtilities.DownloadToByteArray(songUrl, 10*1024*1024);
|
||||
bytes = DownloadUtilities.DownloadToByteArray(songUrl);
|
||||
name = Paths.get(songUrl.toURI().getPath()).getFileName().toString();
|
||||
} else {
|
||||
bytes = Files.readAllBytes(songPath.toPath());
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.gui;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Category;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.antip2w.DelayPacketsModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.combat.KillAuraModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.movement.*;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.op.AntiTeleportModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoDeopModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoOpModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoSudoKickModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.utility.AutoToolsModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.utility.BlockGuardianParticlesModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.utility.GuiMoveModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.AntiChatSpamModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.SelfCareModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.fun.CustomChatModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.fun.RainbowNameModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiParticleKickModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiTextObfuscationLagModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.BlockGuardianParticlesModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.AntiTeleportModule;
|
||||
import land.chipmunk.chipmunkmod.testclient.modules.other.CommandCoreModule;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.Drawable;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.Selectable;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
||||
public class Gui extends Screen{
|
||||
public class
|
||||
Gui extends Screen{
|
||||
|
||||
public static ArrayList<Category> categoryList = new ArrayList<>();
|
||||
|
||||
|
@ -78,10 +77,10 @@ public class Gui extends Screen{
|
|||
});
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
|
||||
// this.renderBackground(matrices);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
public static void open() {
|
||||
|
@ -161,35 +160,24 @@ public class Gui extends Screen{
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void addComponents() {
|
||||
new Category("Movement")
|
||||
.withModule(new FlightModule())
|
||||
.withModule(new SpeedModule())
|
||||
.withModule(new FreezeModule())
|
||||
.withModule(new AirJumpModule())
|
||||
.withModule(new JesusModule())
|
||||
.withModule(SlipperyWorldModule.instance)
|
||||
new Category("Lag prevention")
|
||||
.withModule(AntiParticleKickModule.INSTANCE)
|
||||
.withModule(BlockGuardianParticlesModule.INSTANCE)
|
||||
.withModule(AntiTextObfuscationLagModule.INSTANCE)
|
||||
.register();
|
||||
new Category("Combat")
|
||||
.withModule(new KillAuraModule())
|
||||
.withModule(new Module("Reach"))
|
||||
.withModule(new Module("Bow Aimbot"))
|
||||
.register();
|
||||
new Category("Utility")
|
||||
.withModule(AutoToolsModule.instance)
|
||||
.withModule(AntiVoidModule.instance)
|
||||
.withModule(BlockGuardianParticlesModule.instance)
|
||||
.withModule(new GuiMoveModule())
|
||||
.register();
|
||||
new Category("OP")
|
||||
new Category("Anti annoyances")
|
||||
.withModule(AntiChatSpamModule.INSTANCE)
|
||||
.withModule(new AntiTeleportModule())
|
||||
.withModule(AutoDeopModule.instance)
|
||||
.withModule(AutoOpModule.instance)
|
||||
.withModule(AutoSudoKickModule.instance)
|
||||
.withModule(SelfCareModule.INSTANCE)
|
||||
.register();
|
||||
new Category("p2w")
|
||||
.withModule(DelayPacketsModule.instance)
|
||||
new Category("Fun")
|
||||
.withModule(RainbowNameModule.INSTANCE)
|
||||
.withModule(CustomChatModule.INSTANCE)
|
||||
.register();
|
||||
new Category("Other")
|
||||
.withModule(CommandCoreModule.INSTANCE)
|
||||
.register();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.Drawable;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
|
@ -21,24 +24,27 @@ public class OptionsScreen extends Screen {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
fill(matrices, 40, 40, width-40, height-40, backgroundColor);
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
renderBackground(context, mouseX, mouseY, delta);
|
||||
context.fill(40, 40, width-40, height-40, backgroundColor);
|
||||
int textWidth = MinecraftClient.getInstance().textRenderer.getWidth(getTitle());
|
||||
AtomicInteger lineY = new AtomicInteger(70);
|
||||
AtomicInteger textY = new AtomicInteger(50);
|
||||
|
||||
drawTextWithShadow(matrices, MinecraftClient.getInstance().textRenderer, getTitle(), width/2 - textWidth/2, 50, 0xFFFFFFFF);
|
||||
fill(matrices, 45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
|
||||
|
||||
context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, getTitle(), width/2 - textWidth/2, 50, 0xFFFFFFFF);
|
||||
context.fill(45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
|
||||
|
||||
for (Option<?> option : optionList) {
|
||||
lineY.addAndGet(30);
|
||||
drawTextWithShadow(matrices, MinecraftClient.getInstance().textRenderer, option.name, 50, textY.addAndGet(30), 0xFFFFFFFF);
|
||||
fill(matrices, 45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
|
||||
context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, option.name, 50, textY.addAndGet(30), 0xFFFFFFFF);
|
||||
context.fill(45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
|
||||
// drawHorizontalLine(matrices, 45, width-45, lineY.addAndGet(30), 0x33FFFFFF);
|
||||
option.widget.setX(width - 50 - option.widget.getWidth());
|
||||
option.widget.setY(textY.get() - ((option.widget.getHeight()-9)/2));
|
||||
}
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
|
||||
// had to use access widener cause minecraft is silly and wont lemme separate background and foreground manually
|
||||
for (Drawable drawable : this.drawables) {
|
||||
drawable.render(context, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.gui.components;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
|
||||
import land.chipmunk.chipmunkmod.util.Chat;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -13,7 +15,6 @@ import java.util.ArrayList;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Category extends ButtonWidget {
|
||||
|
||||
public ArrayList<Module> moduleList = new ArrayList<>();
|
||||
public boolean isExtended;
|
||||
private int fullHeight;
|
||||
|
@ -99,10 +100,10 @@ public class Category extends ButtonWidget {
|
|||
// }
|
||||
|
||||
@Override
|
||||
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY());
|
||||
MinecraftClient minecraftClient = MinecraftClient.getInstance();
|
||||
fill(matrices, getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
|
||||
this.drawMessage(matrices, minecraftClient.textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24);
|
||||
context.fill(getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
|
||||
this.drawMessage(context, minecraftClient.textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.gui.components;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.OptionsScreen;
|
||||
import land.chipmunk.chipmunkmod.util.TickRunnableHandler;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -11,7 +13,6 @@ import net.minecraft.util.math.MathHelper;
|
|||
import java.util.ArrayList;
|
||||
|
||||
public class Module extends ButtonWidget {
|
||||
|
||||
public Runnable activateRunnable;
|
||||
public Runnable deactivateRunnable;
|
||||
public Runnable endTickRunnable;
|
||||
|
@ -111,11 +112,11 @@ public class Module extends ButtonWidget {
|
|||
// }
|
||||
// }
|
||||
|
||||
public Module atActivate(Runnable runnable) {
|
||||
public Module onActivate(Runnable runnable) {
|
||||
activateRunnable = runnable;
|
||||
return this;
|
||||
}
|
||||
public Module atDeactivate(Runnable runnable) {
|
||||
public Module onDeactivate(Runnable runnable) {
|
||||
deactivateRunnable = runnable;
|
||||
return this;
|
||||
}
|
||||
|
@ -124,14 +125,12 @@ public class Module extends ButtonWidget {
|
|||
return this;
|
||||
}
|
||||
|
||||
private Module getThis() {return this;}
|
||||
|
||||
@Override
|
||||
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY());
|
||||
fill(matrices, getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
|
||||
fill(matrices, getX(), getY(), getX()+2, getY()+getHeight(), isEnabled ? enabledBarColor : disabledBarColor);
|
||||
drawMessage(matrices, MinecraftClient.getInstance().textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24);
|
||||
context.fill(getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
|
||||
context.fill(getX(), getY(), getX()+2, getY()+getHeight(), isEnabled ? enabledBarColor : disabledBarColor);
|
||||
drawMessage(context, MinecraftClient.getInstance().textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24);
|
||||
}
|
||||
|
||||
// public static class OptionsButton extends WButton {
|
||||
|
@ -185,4 +184,4 @@ TODO:
|
|||
- translate categories from WButton to vanilla ButtonWidget
|
||||
- make everything work with vanilla stuff
|
||||
The goal is to stop struggling with screen size. It's so annoying with LibGui.
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.gui.components;
|
||||
|
||||
|
||||
import land.chipmunk.chipmunkmod.memory.ModuleMemory;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
|
||||
public abstract class Option<ValueType> {
|
||||
|
@ -11,5 +12,12 @@ public abstract class Option<ValueType> {
|
|||
this.name = name;
|
||||
optionValue = defaultValue;
|
||||
}
|
||||
|
||||
|
||||
public Class<ValueType> getType() {return (Class<ValueType>) optionValue.getClass();} // ignore this error intellij has the stupid
|
||||
|
||||
// these two should match perfectly, meaning that setValueFromString(getValueAsString()); should do nothing
|
||||
public abstract void setValueFromString(String string);
|
||||
public abstract String getValueAsString();
|
||||
|
||||
public abstract void setOptionValue(ValueType optionValue);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.gui.components.options;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.CheckboxWidget;
|
||||
import net.minecraft.client.gui.widget.SliderWidget;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class BooleanCheckboxOption extends Option<Boolean> {
|
||||
private RunnableWithParameter<Boolean> onPress = value -> {};
|
||||
|
||||
CheckboxWidget checkboxWidget = CheckboxWidget.builder(Text.empty(), MinecraftClient.getInstance().textRenderer)
|
||||
.pos(0, 0)
|
||||
.maxWidth(20)
|
||||
.checked(optionValue)
|
||||
.callback((checkbox, checked) -> {
|
||||
optionValue = !optionValue;
|
||||
onPress.run(optionValue);
|
||||
|
||||
checkbox.checked = optionValue;
|
||||
})
|
||||
.build();
|
||||
|
||||
public BooleanCheckboxOption(String name, boolean defaultValue) {
|
||||
super(name, defaultValue);
|
||||
optionValue = defaultValue;
|
||||
widget = checkboxWidget;
|
||||
}
|
||||
public BooleanCheckboxOption(String name, boolean defaultValue, RunnableWithParameter<Boolean> onPress) {
|
||||
super(name, defaultValue);
|
||||
optionValue = defaultValue;
|
||||
widget = checkboxWidget;
|
||||
this.onPress = onPress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromString(String string) {
|
||||
setOptionValue(Boolean.valueOf(string));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValueAsString() {
|
||||
return Boolean.toString(optionValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionValue(Boolean optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
this.checkboxWidget.checked = optionValue;
|
||||
}
|
||||
|
||||
public interface RunnableWithParameter<T> {
|
||||
void run(T value);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,13 +10,14 @@ public class DoubleSliderOption extends Option<Double> {
|
|||
int roundTo = 4;
|
||||
SliderWidget sliderWidget = new SliderWidget(0, 0, 100, 20, Text.literal("text ig"), 0.0) {
|
||||
@Override
|
||||
protected void updateMessage() {
|
||||
public void updateMessage() {
|
||||
setMessage(Text.literal(round((value * (maxValue - minValue) + minValue), roundTo)+""));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyValue() {
|
||||
optionValue = round((value * (maxValue - minValue) + minValue), roundTo);
|
||||
System.out.println("Saving value " + optionValue + " from " + value);
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
|
@ -53,4 +54,19 @@ public class DoubleSliderOption extends Option<Double> {
|
|||
long tmp = Math.round(value);
|
||||
return (double) tmp / factor;
|
||||
}
|
||||
|
||||
public void setValueFromString(String string) {
|
||||
setOptionValue(Double.valueOf(string));
|
||||
}
|
||||
|
||||
public String getValueAsString() {
|
||||
return Double.toString(optionValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionValue(Double optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
sliderWidget.value = (optionValue - minValue) / (maxValue - minValue);
|
||||
sliderWidget.updateMessage();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ public class IntSliderOption extends Option<Integer> {
|
|||
public int minValue = 0;
|
||||
SliderWidget sliderWidget = new SliderWidget(0, 0, 100, 20, Text.literal("text ig"), 0.0) {
|
||||
@Override
|
||||
protected void updateMessage() {
|
||||
public void updateMessage() {
|
||||
setMessage(Text.literal(((int) (value * (maxValue - minValue) + minValue))+""));
|
||||
}
|
||||
|
||||
|
@ -35,4 +35,21 @@ public class IntSliderOption extends Option<Integer> {
|
|||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromString(String string) {
|
||||
this.setOptionValue(Integer.valueOf(string));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionValue(Integer optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
sliderWidget.value = (double) (optionValue - minValue) / (maxValue - minValue);
|
||||
sliderWidget.updateMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValueAsString() {
|
||||
return Integer.toString(optionValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.gui.components.options;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class IntTextFieldOption extends Option<Integer> {
|
||||
TextFieldWidget textFieldWidget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 200, 20, Text.empty());
|
||||
|
||||
public IntTextFieldOption(String name, Integer defaultValue) {
|
||||
super(name, defaultValue);
|
||||
textFieldWidget.setText(defaultValue.toString());
|
||||
textFieldWidget.setChangedListener(text -> {
|
||||
try {
|
||||
IntTextFieldOption.this.optionValue = Integer.valueOf(text);
|
||||
} catch(NumberFormatException ignored) {
|
||||
}
|
||||
});
|
||||
this.widget = textFieldWidget;
|
||||
}
|
||||
|
||||
public IntTextFieldOption(String name, Integer defaultValue, Consumer<Integer> onChanged) {
|
||||
super(name, defaultValue);
|
||||
textFieldWidget.setText(defaultValue.toString());
|
||||
textFieldWidget.setChangedListener(text -> {
|
||||
try {
|
||||
int i = Integer.parseInt(text);
|
||||
IntTextFieldOption.this.optionValue = i;
|
||||
onChanged.accept(i);
|
||||
} catch(NumberFormatException ignored) {
|
||||
}
|
||||
});
|
||||
this.widget = textFieldWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromString(String string) {
|
||||
setOptionValue(Integer.valueOf(string));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValueAsString() {
|
||||
return optionValue.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionValue(Integer optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
textFieldWidget.setText(optionValue.toString());
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class StringOption extends Option<String> {
|
||||
TextFieldWidget textFieldWidget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 0, 0, 200, 20, Text.empty());
|
||||
public StringOption(String name, String defaultValue) {
|
||||
|
@ -15,5 +17,31 @@ public class StringOption extends Option<String> {
|
|||
});
|
||||
widget = textFieldWidget;
|
||||
}
|
||||
|
||||
public StringOption(String name, String defaultValue, Consumer<String> onChanged) {
|
||||
super(name, defaultValue);
|
||||
textFieldWidget.setText(defaultValue);
|
||||
textFieldWidget.setChangedListener(text -> {
|
||||
optionValue = text;
|
||||
onChanged.accept(text);
|
||||
});
|
||||
widget = textFieldWidget;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromString(String string) {
|
||||
setOptionValue(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOptionValue(String optionValue) {
|
||||
this.optionValue = optionValue;
|
||||
textFieldWidget.setText(optionValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValueAsString() {
|
||||
return optionValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
|
||||
import land.chipmunk.chipmunkmod.util.Debug;
|
||||
import lombok.Getter;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.minecraft.text.Text;
|
||||
import org.apache.commons.text.similarity.LevenshteinDistance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AntiChatSpamModule extends Module {
|
||||
public static final AntiChatSpamModule INSTANCE = new AntiChatSpamModule();
|
||||
private static final String debugCallerPrefix = "AntiChatSpam.";
|
||||
private static final String debugTickedCaller = debugCallerPrefix + "tick";
|
||||
private static final String debugLevenshteinDistanceCaller = debugCallerPrefix + "levenshtein_distance";
|
||||
private static final String debugLevenshteinDistanceCallerSpamless = debugCallerPrefix + "levenshtein_distance_spamless";
|
||||
private static final String debugLevenshteinDistanceCallerSpamful = debugCallerPrefix + "levenshtein_distance_spamful";
|
||||
public static Text latestPassedThroughMessage = Text.empty();
|
||||
public ArrayList<ChatMessage> messages = new ArrayList<>();
|
||||
|
||||
public AntiChatSpamModule() {
|
||||
super("Anti chat spam");
|
||||
isEnabled = true;
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
// ChipmunkMod.LOGGER.info("gex");
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
if(messages.get(i) == null) continue;
|
||||
Debug.debug("Ticked message: " + messages.get(i).content, debugTickedCaller);
|
||||
messages.get(i).tick();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static class ChatMessage {
|
||||
private @Getter final String content;
|
||||
public boolean hidden = false;
|
||||
public int timer = ChipmunkMod.CONFIG.antiSpam.messageTimeInTicks;
|
||||
|
||||
public ChatMessage(String content) {
|
||||
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
|
||||
this.content = content;
|
||||
|
||||
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
|
||||
ArrayList<ChatMessage> chatMessages = INSTANCE.messages;
|
||||
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
|
||||
int similarMessages = 0;
|
||||
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
|
||||
LevenshteinDistance ld = new LevenshteinDistance(); // thanks maniaplay fo r teaching me about levenshtein distance
|
||||
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
|
||||
for (int i = 0; i < chatMessages.size(); i++) {
|
||||
Debug.debug("BBBBB1", debugLevenshteinDistanceCallerSpamful);
|
||||
ChatMessage message = chatMessages.get(i);
|
||||
Debug.debug("BBBBB2", debugLevenshteinDistanceCallerSpamful);
|
||||
if(message == null) continue;
|
||||
Debug.debug("BBBBB3", debugLevenshteinDistanceCallerSpamful);
|
||||
int distance = ld.apply(content, message.content);
|
||||
Debug.debug("BBBBB4", debugLevenshteinDistanceCallerSpamful);
|
||||
Debug.debug("Distance: " + distance, debugLevenshteinDistanceCaller);
|
||||
Debug.debug("BBBBB5", debugLevenshteinDistanceCallerSpamful);
|
||||
if (distance <= ChipmunkMod.CONFIG.antiSpam.minimumLevenshteinDistanceToBeSpam) similarMessages++;
|
||||
Debug.debug("BBBBB6", debugLevenshteinDistanceCallerSpamful);
|
||||
// Pattern pattern = getPattern(new ComparableString(this.content()), new ComparableString(message.content()));
|
||||
// int matching = 0;
|
||||
// ArrayList<ChatMessage> chatMessageArrayList = instance.messages;
|
||||
// for (int j = 0; j < chatMessageArrayList.size(); j++) {
|
||||
// ChatMessage message1 = chatMessageArrayList.get(j);
|
||||
// if (pattern.matcher(message1.content()).matches()) matching++;
|
||||
// }
|
||||
// if (matching >= ChipmunkMod.CONFIG.antiSpam.matchingMessagesToBeSpam) {
|
||||
// instance.patterns.add(new BlockedPattern(pattern));
|
||||
// }
|
||||
}
|
||||
Debug.debug("CCCC", debugLevenshteinDistanceCallerSpamful);
|
||||
Debug.debug("Similar messages: " + similarMessages, debugLevenshteinDistanceCaller);
|
||||
Debug.debug("Similar messages: " + similarMessages, debugLevenshteinDistanceCallerSpamless);
|
||||
if (similarMessages >= ChipmunkMod.CONFIG.antiSpam.matchingMessagesToBeSpam) hidden = true;
|
||||
Debug.debug("CCCC", debugLevenshteinDistanceCallerSpamful);
|
||||
Debug.debug("Hidden: " + hidden, debugLevenshteinDistanceCaller);
|
||||
Debug.debug("Hidden: " + hidden, debugLevenshteinDistanceCallerSpamless);
|
||||
INSTANCE.messages.add(this);
|
||||
Debug.debug("CCCC", debugLevenshteinDistanceCallerSpamful);
|
||||
// threadQueue.add(() -> {
|
||||
// // code above used to be here but i cant decide if i should show it or not depending on the thread cuz i cant make it wait
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
timer--;
|
||||
if (timer <= 0) INSTANCE.messages.remove(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.modules.op;
|
||||
package land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
|
||||
import land.chipmunk.chipmunkmod.util.Chat;
|
|
@ -0,0 +1,62 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.modules.SelfCare;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.options.BooleanCheckboxOption;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.options.StringOption;
|
||||
|
||||
public class SelfCareModule extends Module {
|
||||
public static final SelfCareModule INSTANCE = new SelfCareModule();
|
||||
public BooleanCheckboxOption opOption = new BooleanCheckboxOption(
|
||||
"OP",
|
||||
SelfCare.INSTANCE.opEnabled,
|
||||
value -> SelfCare.INSTANCE.opEnabled = value
|
||||
);
|
||||
public BooleanCheckboxOption gmcOption = new BooleanCheckboxOption(
|
||||
"Creative mode",
|
||||
SelfCare.INSTANCE.gamemodeEnabled,
|
||||
value -> SelfCare.INSTANCE.gamemodeEnabled = value
|
||||
);
|
||||
public BooleanCheckboxOption cspyOption = new BooleanCheckboxOption(
|
||||
"Command spy",
|
||||
SelfCare.INSTANCE.cspyEnabled,
|
||||
value -> SelfCare.INSTANCE.cspyEnabled = value
|
||||
);
|
||||
public BooleanCheckboxOption icuOption = new BooleanCheckboxOption(
|
||||
"ICU",
|
||||
SelfCare.INSTANCE.icuEnabled,
|
||||
value -> SelfCare.INSTANCE.icuEnabled = value
|
||||
);
|
||||
// split because skinUsernameOption and skinOption need to reference each other in their onChanged
|
||||
public StringOption skinUsernameOption;
|
||||
public BooleanCheckboxOption skinOption = new BooleanCheckboxOption(
|
||||
"Skin",
|
||||
SelfCare.INSTANCE.skin.equals("off"),
|
||||
value -> {
|
||||
SelfCare.INSTANCE.skin = value ? skinUsernameOption.optionValue : "off";
|
||||
}
|
||||
);
|
||||
|
||||
public SelfCareModule() {
|
||||
super("Self care");
|
||||
skinUsernameOption = new StringOption(
|
||||
"Skin's username",
|
||||
ChipmunkMod.CONFIG.defaultUsername,
|
||||
s -> {
|
||||
SelfCare.INSTANCE.hasSkin = false;
|
||||
SelfCare.INSTANCE.skin = skinOption.optionValue ? s : "off";
|
||||
}
|
||||
);
|
||||
withOption(opOption);
|
||||
withOption(gmcOption);
|
||||
withOption(cspyOption);
|
||||
withOption(icuOption);
|
||||
withOption(skinOption);
|
||||
withOption(skinUsernameOption);
|
||||
/*endTickRunnable = () -> {
|
||||
// make it update the skin self acre username
|
||||
SelfCare.INSTANCE.skin = skinOption.optionValue ? skinUsernameOption.optionValue : "off";
|
||||
};*/
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue