Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
.idea/
.vscode/
*.iml
*.ipr
*.iws
lib/
run/
out/
bin/
build/
.gradle/
classes/
lombok.config
src/main/resources/english.zip
extra.properties
33 changes: 21 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
id "io.freefair.lombok" version "6.0.0-m2"
id "fabric-loom" version "1.11-SNAPSHOT"
id "maven-publish"
id "io.freefair.lombok" version "8.10"
}

apply from: 'https://raw.githubusercontent.com/DarkKronicle/GradleScripts/main/gradle/publish.gradle'
// apply from: 'https://raw.githubusercontent.com/DarkKronicle/GradleScripts/main/gradle/publish.gradle'

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = "${project.minecraft_version}-${project.mod_version}"
Expand All @@ -24,10 +24,14 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modImplementation "fi.dy.masa.malilib:malilib-fabric-1.20.2:${project.malilib_version}"
//modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.advancedchat_version}"
modImplementation "io.github.darkkronicle:AdvancedChatCore:1.20.4-1.5.10" // only used to build the mod locally
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "com.github.sakura-ryoko:malilib:${project.malilib_version}"
//modImplementation "com.github.DarkKronicle:AdvancedChatCore:${project.mod_version}"
modImplementation "io.github.darkkronicle:AdvancedChatCore:${project.minecraft_version}-${project.mod_version}"
// modImplementation files("libs/AdvancedChatCore-${project.mod_version}.jar")

implementation "org.mariuszgromada.math:MathParser.org-mXparser:${project.mxparser_version}"
include "org.mariuszgromada.math:MathParser.org-mXparser:${project.mxparser_version}"

implementation "org.languagetool:language-en:5.5"
// Transitive
Expand Down Expand Up @@ -62,10 +66,14 @@ processResources {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 16
it.options.release = 21
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}

withSourcesJar()
}

Expand All @@ -89,6 +97,7 @@ publishing {

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {

// uncomment to publish to the local maven
mavenLocal()
}
}
22 changes: 13 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.3
fabric_api_version=0.92.0+1.20.4
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

mod_version=1.1.6
minecraft_version=1.21.8
yarn_mappings=1.21.8+build.1
loader_version=0.17.2
loom_version=1.11-SNAPSHOT

fabric_version=0.132.0+1.21.8

mod_version=1.8.0
maven_group=io.github.darkkronicle
archives_base_name=AdvancedChatBox
malilib_version = 0.17.0
advancedchat_version=1.5.7

malilib_version=1.21.8-0.25.5-sakura.4
mxparser_version=4.4.2
org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# Uploading data
curseforge_slug=advancedchatbox
Expand All @@ -26,4 +30,4 @@ project_logo=https://raw.githubusercontent.com/DarkKronicle/AdvancedChatBox/main
project_color=0x4480ad
changelog_hide_unimportant_commits=true
changelog_max_commit_search=200
discord_webhook_changelog_line_limit=10
discord_webhook_changelog_line_limit=10
6 changes: 4 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.network.ClientCommandSource;
import net.minecraft.command.CommandSource;

/** A maintainer of suggestions to suggest to the player. */
Expand All @@ -42,7 +43,7 @@ public class ChatSuggestor {

/** Parsed command results */
@Getter
private ParseResults<CommandSource> parse;
private ParseResults<ClientCommandSource> parse;

/** Suggestions to complete */
@Getter
Expand Down Expand Up @@ -100,7 +101,7 @@ public void updateCommandSuggestions() {
*/
public void updateCommandSuggestions(Runnable after) {
allSuggestions = null;
CommandDispatcher<CommandSource> commandDispatcher = client.player.networkHandler.getCommandDispatcher();
CommandDispatcher<ClientCommandSource> commandDispatcher = client.player.networkHandler.getCommandDispatcher();
pendingSuggestions = commandDispatcher.getCompletionSuggestions(this.parse, getCursorIndex())
.thenApplyAsync(AdvancedSuggestions::fromSuggestions);
if (after != null) {
Expand All @@ -114,7 +115,7 @@ public void updateCommandSuggestions(Runnable after) {
* @param stringReader StringReader which contains reading string
*/
public void updateParse(StringReader stringReader) {
CommandDispatcher<CommandSource> commandDispatcher = client.player.networkHandler.getCommandDispatcher();
CommandDispatcher<ClientCommandSource> commandDispatcher = client.player.networkHandler.getCommandDispatcher();
if (parse == null) {
parse = commandDispatcher.parse(stringReader, client.player.networkHandler.getCommandSource());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.network.ClientCommandSource;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Rect2i;
Expand Down Expand Up @@ -180,8 +181,10 @@ private void showIfActive() {
if (this.suggestor.getSuggestions().isEmpty() && !this.suggestor.getParse().getExceptions().isEmpty()) {
int builtInExceptions = 0;

for (Map.Entry<CommandNode<CommandSource>, CommandSyntaxException> commandNodeCommandSyntaxExceptionEntry : this.suggestor
.getParse().getExceptions().entrySet()) {
for (
Map.Entry<CommandNode<ClientCommandSource>, CommandSyntaxException> commandNodeCommandSyntaxExceptionEntry :
this.suggestor.getParse().getExceptions().entrySet()
) {
CommandSyntaxException commandSyntaxException = commandNodeCommandSyntaxExceptionEntry.getValue();
if (commandSyntaxException.getType() == CommandSyntaxException.BUILT_IN_EXCEPTIONS
.literalIncorrect()) {
Expand Down Expand Up @@ -211,16 +214,16 @@ private void showIfActive() {
}

private void showUsages(Formatting formatting) {
CommandContextBuilder<CommandSource> commandContextBuilder = this.suggestor.getParse().getContext();
SuggestionContext<CommandSource> suggestionContext =
CommandContextBuilder<ClientCommandSource> commandContextBuilder = this.suggestor.getParse().getContext();
SuggestionContext<ClientCommandSource> suggestionContext =
commandContextBuilder.findSuggestionContext(this.textField.getCursor());
Map<CommandNode<CommandSource>, String> map = this.client.player.networkHandler.getCommandDispatcher()
Map<CommandNode<ClientCommandSource>, String> map = this.client.player.networkHandler.getCommandDispatcher()
.getSmartUsage(suggestionContext.parent, this.client.player.networkHandler.getCommandSource());
List<OrderedText> list = new ArrayList<>();
int i = 0;
Style style = Style.EMPTY.withColor(formatting);

for (Map.Entry<CommandNode<CommandSource>, String> commandNodeStringEntry : map.entrySet()) {
for (Map.Entry<CommandNode<ClientCommandSource>, String> commandNodeStringEntry : map.entrySet()) {
if (!(commandNodeStringEntry.getKey() instanceof LiteralCommandNode)) {
list.add(OrderedText.styledForwardsVisitedString(commandNodeStringEntry.getValue(), style));
i = Math.max(i, this.textRenderer.getWidth(commandNodeStringEntry.getValue()));
Expand Down Expand Up @@ -451,7 +454,8 @@ public void select(int index) {
ChatSuggestorGui.this.textField.setSuggestion(ChatSuggestorGui
.getSuggestionSuffix(ChatSuggestorGui.this.textField.getText(), suggestion.apply(this.typedText)));
if (client.getNarratorManager().isActive() && this.lastNarrationIndex != this.selection) {
client.getNarratorManager().narrate(this.getNarration());
Text narrationText = Text.literal(this.getNarration());
client.getNarratorManager().narrate(narrationText);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static String translate(String key) {
.fromConfig("availableSuggestionColor", new ConfigColor(translate("availablesuggestioncolor"),
new Color(150, 150, 150, 255), translate("info.availablesuggestioncolor")));

public static final ImmutableList<SaveableConfig<? extends IConfigBase>> OPTIONS =
public static final List<SaveableConfig<?>> OPTIONS =
ImmutableList.of(HIGHLIGHT_COLOR, UNHIGHLIGHT_COLOR, BACKGROUND_COLOR, SUGGESTION_SIZE,
REMOVE_IDENTIFIER, PRUNE_PLAYER_SUGGESTIONS, AVAILABLE_SUGGESTION_COLOR);
}
Expand All @@ -90,7 +90,7 @@ public static String translate(String key) {
// )
// );

public static final ImmutableList<SaveableConfig<? extends IConfigBase>> OPTIONS = ImmutableList.of(HOVER_TEXT
public static final List<SaveableConfig<?>> OPTIONS = ImmutableList.of(HOVER_TEXT
// SUGGEST_CAPITAL
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.command.CommandSource;
import net.minecraft.client.network.ClientCommandSource;
import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
Expand All @@ -26,7 +26,7 @@
public class ColorCodeFormatter implements IMessageFormatter {

@Override
public Optional<Text> format(Text text, @Nullable ParseResults<CommandSource> parse) {
public Optional<Text> format(Text text, @Nullable ParseResults<ClientCommandSource> parse) {
if (parse != null) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.network.ClientCommandSource;
import net.minecraft.command.CommandSource;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
Expand All @@ -57,14 +58,14 @@ private CommandColorer() {
}

@Override
public Optional<Text> format(Text text, @Nullable ParseResults<CommandSource> parse) {
public Optional<Text> format(Text text, @Nullable ParseResults<ClientCommandSource> parse) {
if (parse == null) {
if (text.getString().charAt(0) == '/') {
return Optional.of(Text.literal(text.getString()).fillStyle(Style.EMPTY.withColor(CommandColorerStorage.ERROR_COLOR.config.get().color())));
}
return Optional.empty();
}
CommandContextBuilder<CommandSource> commandContextBuilder = parse.getContext().getLastChild();
CommandContextBuilder<ClientCommandSource> commandContextBuilder = parse.getContext().getLastChild();
HashMap<StringMatch, StringInsert> replace = new HashMap<>();
int lowest = -1;
int max = 0;
Expand Down Expand Up @@ -118,39 +119,39 @@ public Optional<Text> format(Text text, @Nullable ParseResults<CommandSource> pa
return Optional.of(text);
}

private List<CommandSection<?>> compileObjects(ParseResults<CommandSource> parse, String input) {
CommandContextBuilder<CommandSource> commandContextBuilder = parse.getContext();
private List<CommandSection<?>> compileObjects(ParseResults<ClientCommandSource> parse, String input) {
CommandContextBuilder<ClientCommandSource> commandContextBuilder = parse.getContext();
List<CommandSection<?>> sections = new ArrayList<>();
for (CommandContextBuilder<CommandSource> child : getAllChildren(commandContextBuilder)) {
for (CommandContextBuilder<ClientCommandSource> child : getAllChildren(commandContextBuilder)) {
sections.addAll(addSubs(child, input));
sections.addAll(addArgs(child, input));
}
return sections;
}

private List<CommandSection<ParsedCommandNode<CommandSource>>> addSubs(CommandContextBuilder<CommandSource> context,
private List<CommandSection<ParsedCommandNode<ClientCommandSource>>> addSubs(CommandContextBuilder<ClientCommandSource> context,
String input) {
List<CommandSection<ParsedCommandNode<CommandSource>>> nodes = new ArrayList<>();
for (ParsedCommandNode<CommandSource> node : context.getNodes()) {
List<CommandSection<ParsedCommandNode<ClientCommandSource>>> nodes = new ArrayList<>();
for (ParsedCommandNode<ClientCommandSource> node : context.getNodes()) {
nodes.add(new CommandSection<>(node, fromRange(node.getRange(), input), CommandSection.Section.COMMAND));
}
return nodes;
}

private List<CommandSection<ParsedArgument<CommandSource, ?>>> addArgs(CommandContextBuilder<CommandSource> context,
private List<CommandSection<ParsedArgument<ClientCommandSource, ?>>> addArgs(CommandContextBuilder<ClientCommandSource> context,
String input) {
List<CommandSection<ParsedArgument<CommandSource, ?>>> nodes = new ArrayList<>();
List<CommandSection<ParsedArgument<ClientCommandSource, ?>>> nodes = new ArrayList<>();
if (context.getArguments() == null) {
return nodes;
}
for (ParsedArgument<CommandSource, ?> node : context.getArguments().values()) {
for (ParsedArgument<ClientCommandSource, ?> node : context.getArguments().values()) {
nodes.add(new CommandSection<>(node, fromRange(node.getRange(), input), CommandSection.Section.ARGUMENT));
}
return nodes;
}

private List<CommandContextBuilder<CommandSource>> getAllChildren(CommandContextBuilder<CommandSource> context) {
List<CommandContextBuilder<CommandSource>> children = new ArrayList<>();
private List<CommandContextBuilder<ClientCommandSource>> getAllChildren(CommandContextBuilder<ClientCommandSource> context) {
List<CommandContextBuilder<ClientCommandSource>> children = new ArrayList<>();
while (context != null) {
children.add(context);
context = context.getChild();
Expand All @@ -169,24 +170,24 @@ private static StringMatch fromRange(StringRange range, String input) {
return new StringMatch(range.get(input), range.getStart(), range.getEnd());
}

@SuppressWarnings("unchecked") // Compiler and LSP are disagreeing :(
@Override
public JsonObject save() {
JsonObject obj = new JsonObject();
// Compiler is weird and casting is required
ConfigStorage.writeOptions(obj, CommandColorerStorage.NAME,
(List<SaveableConfig<?>>) CommandColorerStorage.OPTIONS);
(List<SaveableConfig<?>>) (List<?>) CommandColorerStorage.OPTIONS);
return obj;
}

@SuppressWarnings("unchecked") // Compiler and LSP are disagreeing :(
@Override
public void load(JsonElement element) {
if (!element.isJsonObject()) {
return;
}
JsonObject obj = element.getAsJsonObject();
// Compiler is weird and casting is required
ConfigStorage.readOptions(obj, CommandColorerStorage.NAME,
(List<SaveableConfig<?>>) CommandColorerStorage.OPTIONS);
(List<SaveableConfig<?>>) (List<?>) CommandColorerStorage.OPTIONS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import lombok.Value;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.command.CommandSource;
import net.minecraft.client.network.ClientCommandSource;
import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -61,7 +61,7 @@ public static class JSONToken {
}

@Override
public Optional<Text> format(Text text, @Nullable ParseResults<CommandSource> parse) {
public Optional<Text> format(Text text, @Nullable ParseResults<ClientCommandSource> parse) {
String content = text.getString();
Optional<List<StringMatch>> omatches = SearchUtils.findMatches(content, "\\{.+\\}", FindType.REGEX);
if (!omatches.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import com.mojang.brigadier.ParseResults;
import java.util.Optional;
import javax.annotation.Nullable;
import net.minecraft.command.CommandSource;

import net.minecraft.client.network.ClientCommandSource;
import net.minecraft.text.Text;

/** An interface for formatting the chat text box on the chat screen. */
Expand All @@ -22,5 +23,5 @@ public interface IMessageFormatter {
* @param parse Current commands that have been parsed
* @return Text that should render on the chat text bar. If empty it won't modify.
*/
Optional<Text> format(Text text, @Nullable ParseResults<CommandSource> parse);
Optional<Text> format(Text text, @Nullable ParseResults<ClientCommandSource> parse);
}
Loading