mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 19:56:15 +00:00
refactor: remove imposter format in chomens (the HASH thing)
This commit is contained in:
parent
79589edc44
commit
ccf9600cf1
4 changed files with 24 additions and 39 deletions
|
|
@ -30,7 +30,7 @@ public class Configuration {
|
||||||
public BotInfo hbot = new BotInfo("#", null);
|
public BotInfo hbot = new BotInfo("#", null);
|
||||||
public BotInfo sbot = new BotInfo(":", null);
|
public BotInfo sbot = new BotInfo(":", null);
|
||||||
public BotInfo chipmunk = new BotInfo("'", null);
|
public BotInfo chipmunk = new BotInfo("'", null);
|
||||||
public ChomeNSBotInfo chomens = new ChomeNSBotInfo("*", null, null);
|
public BotInfo chomens = new BotInfo("*", null);
|
||||||
public BotInfo fnfboyfriend = new BotInfo("~", null);
|
public BotInfo fnfboyfriend = new BotInfo("~", null);
|
||||||
public BotInfo qilk = new BotInfo(">", null);
|
public BotInfo qilk = new BotInfo(">", null);
|
||||||
public BotInfo nbot = new BotInfo("?", null);
|
public BotInfo nbot = new BotInfo("?", null);
|
||||||
|
|
@ -38,22 +38,6 @@ public class Configuration {
|
||||||
public TestBotInfo testbot = new TestBotInfo("-", null);
|
public TestBotInfo testbot = new TestBotInfo("-", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigSerializable
|
|
||||||
public static class ChomeNSBotInfo {
|
|
||||||
public String prefix;
|
|
||||||
public @Nullable String key;
|
|
||||||
public @Nullable String formatKey;
|
|
||||||
|
|
||||||
public ChomeNSBotInfo() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChomeNSBotInfo(String prefix, @Nullable String key, @Nullable String formatKey) {
|
|
||||||
this.prefix = prefix;
|
|
||||||
this.key = key;
|
|
||||||
this.formatKey = formatKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfigSerializable
|
@ConfigSerializable
|
||||||
public static class TestBotInfo {
|
public static class TestBotInfo {
|
||||||
public String prefix;
|
public String prefix;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package land.chipmunk.chipmunkmod.config.migrations;
|
||||||
|
|
||||||
|
import land.chipmunk.chipmunkmod.config.migration.ConfigMigration;
|
||||||
|
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
||||||
|
import org.spongepowered.configurate.transformation.TransformAction;
|
||||||
|
|
||||||
|
import static org.spongepowered.configurate.NodePath.path;
|
||||||
|
|
||||||
|
public class MigrationV3 implements ConfigMigration {
|
||||||
|
@Override
|
||||||
|
public int version() {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigurationTransformation create() {
|
||||||
|
return ConfigurationTransformation.builder()
|
||||||
|
.addAction(path("bots", "chomens", "formatKey"), TransformAction.remove())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package land.chipmunk.chipmunkmod.modules.custom_chat;
|
package land.chipmunk.chipmunkmod.modules.custom_chat;
|
||||||
|
|
||||||
import com.google.common.hash.Hashing;
|
|
||||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||||
|
|
||||||
import land.chipmunk.chipmunkmod.modules.Chat;
|
import land.chipmunk.chipmunkmod.modules.Chat;
|
||||||
|
|
@ -17,7 +16,6 @@ import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
@ -66,8 +64,6 @@ public class CustomChat {
|
||||||
|
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
|
|
||||||
private int total = 0;
|
|
||||||
|
|
||||||
public CustomChat (MinecraftClient client) {
|
public CustomChat (MinecraftClient client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
@ -79,8 +75,6 @@ public class CustomChat {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
resetTotal();
|
|
||||||
|
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
timer.schedule(task, 0, 50);
|
timer.schedule(task, 0, 50);
|
||||||
}
|
}
|
||||||
|
|
@ -90,14 +84,9 @@ public class CustomChat {
|
||||||
|
|
||||||
if (networkHandler != null) return;
|
if (networkHandler != null) return;
|
||||||
|
|
||||||
resetTotal();
|
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetTotal() {
|
|
||||||
total = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanup () {
|
private void cleanup () {
|
||||||
if (timer == null) return;
|
if (timer == null) return;
|
||||||
|
|
||||||
|
|
@ -116,18 +105,9 @@ public class CustomChat {
|
||||||
final Component styledMessage = SERIALIZER.deserialize(message);
|
final Component styledMessage = SERIALIZER.deserialize(message);
|
||||||
|
|
||||||
final String username = MinecraftClient.getInstance().getSession().getUsername();
|
final String username = MinecraftClient.getInstance().getSession().getUsername();
|
||||||
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++;
|
|
||||||
|
|
||||||
final CustomChatContext context = new CustomChatContext(player.getUuidAsString(), styledMessage,
|
final CustomChatContext context = new CustomChatContext(player.getUuidAsString(), styledMessage,
|
||||||
Map.of("MESSAGE", message, "USERNAME", username, "HASH", hash));
|
Map.of("MESSAGE", message, "USERNAME", username));
|
||||||
final Component renderedFormat = RENDERER.render(ChipmunkMod.CONFIG.customChat.format, context)
|
final Component renderedFormat = RENDERER.render(ChipmunkMod.CONFIG.customChat.format, context)
|
||||||
.compact();
|
.compact();
|
||||||
final String json = GSON.serialize(renderedFormat);
|
final String json = GSON.serialize(renderedFormat);
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ public class BotValidationUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int chomens (String command) throws RuntimeException {
|
public static int chomens (String command) throws RuntimeException {
|
||||||
final Configuration.ChomeNSBotInfo info = ChipmunkMod.CONFIG.bots.chomens;
|
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.chomens;
|
||||||
|
|
||||||
final MinecraftClient client = MinecraftClient.getInstance();
|
final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue