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
21 changes: 7 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'fabric-loom' version '1.11-SNAPSHOT'
id 'net.fabricmc.fabric-loom' version '1.16-SNAPSHOT'
id 'maven-publish'
}

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

Expand Down Expand Up @@ -37,17 +37,16 @@ repositories {

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Permissions API
include(modImplementation("me.lucko:fabric-permissions-api:0.5.0"))
include(implementation("me.lucko:fabric-permissions-api:0.7.0"))

// Placeholders API
modImplementation include("eu.pb4:placeholder-api:2.8.0+1.21.9")
implementation include("eu.pb4:placeholder-api:3.0.0+26.1")

// LevelDB
include(implementation("org.iq80.leveldb:leveldb:0.12"))
Expand All @@ -70,11 +69,6 @@ dependencies {

// Math Evaluator
include(implementation("com.fathzer:javaluator:3.0.6"))

//modRuntimeOnly "maven.modrinth:lazydfu:0.1.3"
//modRuntimeOnly "maven.modrinth:sodium:mc1.19-0.4.2"
//modRuntimeOnly "maven.modrinth:lithium:mc1.19-0.8.0"
//modRuntimeOnly "maven.modrinth:phosphor:mc1.19.x-0.8.1"
}

processResources {
Expand All @@ -86,8 +80,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 21
it.options.release = 25
}

java {
Expand Down
13 changes: 7 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
org.gradle.configuration-cache=false

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.21.9
yarn_mappings=1.21.9+build.1
loader_version=0.17.2
# check these on https://fabricmc.net/develop
minecraft_version=26.1.2
loader_version=0.19.2

# Mod Properties
mod_version = 1.0.3
mod_version = 1.0.4
maven_group = me.flashyreese.mods
archives_base_name = commandaliases

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.134.0+1.21.9
fabric_version=0.146.0+26.1.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ pluginManagement {
gradlePluginPortal()
}
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.flashyreese.mods.commandaliases.command;

import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.command.CommandManager;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.Commands;

/**
* Accessor for CommandManager
Expand All @@ -11,7 +11,7 @@
* @since 0.7.0
*/
public interface CommandManagerExtended {
CommandManager.RegistrationEnvironment getEnvironment();
Commands.CommandSelection getEnvironment();

CommandRegistryAccess getCommandRegistryAccess();
CommandBuildContext getCommandRegistryAccess();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.flashyreese.mods.commandaliases.command;

import net.fabricmc.fabric.api.util.TriState;
import net.minecraft.command.CommandSource;
import net.minecraft.commands.SharedSuggestionProvider;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;
Expand All @@ -18,7 +18,7 @@ public class Permissions {
* @param defaultValue the default value to use if nothing has been set
* @return a predicate that will perform the permission check
*/
public static <S extends CommandSource> @NotNull Predicate<S> require(@NotNull String permission, boolean defaultValue) {
public static <S extends SharedSuggestionProvider> @NotNull Predicate<S> require(@NotNull String permission, boolean defaultValue) {
Objects.requireNonNull(permission, "permission");
return player -> check(player, permission, defaultValue);
}
Expand All @@ -32,7 +32,7 @@ public class Permissions {
* @param defaultRequiredLevel the required permission level to check for as a fallback
* @return a predicate that will perform the permission check
*/
public static <S extends CommandSource> @NotNull Predicate<S> require(@NotNull String permission, int defaultRequiredLevel) {
public static <S extends SharedSuggestionProvider> @NotNull Predicate<S> require(@NotNull String permission, int defaultRequiredLevel) {
Objects.requireNonNull(permission, "permission");
return player -> check(player, permission, defaultRequiredLevel);
}
Expand All @@ -44,7 +44,7 @@ public class Permissions {
* @param permission the permission to check
* @return a predicate that will perform the permission check
*/
public static <S extends CommandSource> @NotNull Predicate<S> require(@NotNull String permission) {
public static <S extends SharedSuggestionProvider> @NotNull Predicate<S> require(@NotNull String permission) {
Objects.requireNonNull(permission, "permission");
return player -> check(player, permission);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import net.minecraft.command.CommandSource;
import net.minecraft.commands.SharedSuggestionProvider;

/**
* Represents a command builder
Expand All @@ -13,7 +13,7 @@
* @version 0.5.0
* @since 0.5.0
*/
public interface CommandBuilderDelegate<S extends CommandSource> {
public interface CommandBuilderDelegate<S extends SharedSuggestionProvider> {
LiteralArgumentBuilder<S> buildCommand(CommandDispatcher<S> dispatcher);

default LiteralArgumentBuilder<S> literal(String literal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import me.flashyreese.mods.commandaliases.command.impl.FunctionProcessor;
import me.flashyreese.mods.commandaliases.command.impl.InputMapper;
import me.flashyreese.mods.commandaliases.command.loader.AbstractCommandAliasesProvider;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.CommandSource;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.SharedSuggestionProvider;

import java.util.Arrays;
import java.util.LinkedList;
Expand All @@ -42,7 +42,7 @@
* @version 1.0.0
* @since 0.4.0
*/
public abstract class AbstractCustomCommandBuilder<S extends CommandSource> implements CommandBuilderDelegate<S> {
public abstract class AbstractCustomCommandBuilder<S extends SharedSuggestionProvider> implements CommandBuilderDelegate<S> {

protected final String filePath;
protected final CustomCommand commandAliasParent;
Expand All @@ -54,7 +54,7 @@ public abstract class AbstractCustomCommandBuilder<S extends CommandSource> impl

protected final AbstractCommandAliasesProvider<S> abstractCommandAliasesProvider;

public AbstractCustomCommandBuilder(String filePath, CustomCommand commandAliasParent, AbstractCommandAliasesProvider<S> abstractCommandAliasesProvider, CommandRegistryAccess registryAccess, CommandType commandType) {
public AbstractCustomCommandBuilder(String filePath, CustomCommand commandAliasParent, AbstractCommandAliasesProvider<S> abstractCommandAliasesProvider, CommandBuildContext registryAccess, CommandType commandType) {
this.filePath = filePath;
this.argumentTypeMapper = new ArgumentTypeMapper(registryAccess);
this.commandAliasParent = commandAliasParent;
Expand Down Expand Up @@ -243,7 +243,7 @@ protected int executeCommand(List<CustomCommandAction> actions, String message,
\tProcessing time: {}ms
\t======================================================""", formattedSuggestion, (end - start) / 1000000.0);
}
return CommandSource.suggestMatching(suggestions.stream().map(StringArgumentType::escapeIfRequired), builder);
return SharedSuggestionProvider.suggest(suggestions.stream().map(StringArgumentType::escapeIfRequired), builder);
};
} else {
SUGGESTION_PROVIDER = (context, builder) -> {
Expand All @@ -264,7 +264,7 @@ protected int executeCommand(List<CustomCommandAction> actions, String message,
\t"Processing time: {}ms
\t======================================================""", formattedSuggestion, (end - start) / 1000000.0);
}
return CommandSource.suggestMatching(suggestions.stream().map(StringArgumentType::escapeIfRequired), builder);
return SharedSuggestionProvider.suggest(suggestions.stream().map(StringArgumentType::escapeIfRequired), builder);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import me.flashyreese.mods.commandaliases.command.builder.custom.format.CustomCommandAction;
import me.flashyreese.mods.commandaliases.command.loader.AbstractCommandAliasesProvider;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.text.Text;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.network.chat.Component;

/**
* Represents the Client Custom Command Builder
Expand All @@ -22,7 +22,7 @@
* @since 0.5.0
*/
public class ClientCustomCommandBuilder extends AbstractCustomCommandBuilder<FabricClientCommandSource> {
public ClientCustomCommandBuilder(String filePath, CustomCommand commandAliasParent, AbstractCommandAliasesProvider<FabricClientCommandSource> abstractCommandAliasesProvider, CommandRegistryAccess registryAccess) {
public ClientCustomCommandBuilder(String filePath, CustomCommand commandAliasParent, AbstractCommandAliasesProvider<FabricClientCommandSource> abstractCommandAliasesProvider, CommandBuildContext registryAccess) {
super(filePath, commandAliasParent, abstractCommandAliasesProvider, registryAccess, CommandType.CLIENT);
}

Expand All @@ -32,14 +32,14 @@ protected int dispatcherExecute(CustomCommandAction action, CommandDispatcher<Fa
if (action.getCommandType() == CommandType.CLIENT) {
state = dispatcher.execute(actionCommand, context.getSource());
} else if (action.getCommandType() == CommandType.SERVER) {
context.getSource().getPlayer().networkHandler.sendChatCommand(actionCommand); // Todo: Dangerous might cause abuse by spammers
context.getSource().getPlayer().connection.sendCommand(actionCommand); // Todo: Dangerous might cause abuse by spammers
state = Command.SINGLE_SUCCESS;
}
return state;
}

@Override
protected void sendFeedback(CommandContext<FabricClientCommandSource> context, String message) {
context.getSource().sendFeedback(Text.literal(message));
context.getSource().sendFeedback(Component.literal(message));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import eu.pb4.placeholders.api.PlaceholderContext;
import eu.pb4.placeholders.api.Placeholders;
import eu.pb4.placeholders.api.ServerPlaceholderContext;
import me.flashyreese.mods.commandaliases.CommandAliasesMod;
import me.flashyreese.mods.commandaliases.command.CommandType;
import me.flashyreese.mods.commandaliases.command.builder.custom.format.CustomCommand;
import me.flashyreese.mods.commandaliases.command.builder.custom.format.CustomCommandAction;
import me.flashyreese.mods.commandaliases.command.loader.AbstractCommandAliasesProvider;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.commands.CommandBuildContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;

import java.util.List;

Expand All @@ -25,34 +25,34 @@
* @version 1.0.0
* @since 0.5.0
*/
public class ServerCustomCommandBuilder extends AbstractCustomCommandBuilder<ServerCommandSource> {
public ServerCustomCommandBuilder(String filePath, CustomCommand commandAliasParent, AbstractCommandAliasesProvider<ServerCommandSource> abstractCommandAliasesProvider, CommandRegistryAccess registryAccess) {
public class ServerCustomCommandBuilder extends AbstractCustomCommandBuilder<CommandSourceStack> {
public ServerCustomCommandBuilder(String filePath, CustomCommand commandAliasParent, AbstractCommandAliasesProvider<CommandSourceStack> abstractCommandAliasesProvider, CommandBuildContext registryAccess) {
super(filePath, commandAliasParent, abstractCommandAliasesProvider, registryAccess, CommandType.SERVER);
}

@Override
protected String formatString(CommandContext<ServerCommandSource> context, List<String> currentInputList, String string) {
protected String formatString(CommandContext<CommandSourceStack> context, List<String> currentInputList, String string) {
string = super.formatString(context, currentInputList, string);

// Placeholder API processor
string = Placeholders.parseText(Text.literal(string), PlaceholderContext.of(context.getSource())).getString();
string = Placeholders.SERVER_PLACEHOLDER_PARSER.parseComponent(string, ServerPlaceholderContext.of(context.getSource()).asParserContext()).getString();

return string;
}

@Override
protected int dispatcherExecute(CustomCommandAction action, CommandDispatcher<ServerCommandSource> dispatcher, CommandContext<ServerCommandSource> context, String actionCommand) throws CommandSyntaxException {
protected int dispatcherExecute(CustomCommandAction action, CommandDispatcher<CommandSourceStack> dispatcher, CommandContext<CommandSourceStack> context, String actionCommand) throws CommandSyntaxException {
int state = 0;
if (action.getCommandType() == CommandType.CLIENT) {
state = dispatcher.execute(actionCommand, context.getSource());
} else if (action.getCommandType() == CommandType.SERVER) {
state = dispatcher.execute(actionCommand, context.getSource().getServer().getCommandSource());
state = dispatcher.execute(actionCommand, context.getSource().getServer().createCommandSourceStack());
}
return state;
}

@Override
protected void sendFeedback(CommandContext<ServerCommandSource> context, String message) {
context.getSource().sendFeedback(() -> Text.literal(message), CommandAliasesMod.options().debugSettings.broadcastToOps);
protected void sendFeedback(CommandContext<CommandSourceStack> context, String message) {
context.getSource().sendSuccess(() -> Component.literal(message), CommandAliasesMod.options().debugSettings.broadcastToOps);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import me.flashyreese.mods.commandaliases.command.CommandType;
import me.flashyreese.mods.commandaliases.command.builder.CommandBuilderDelegate;
import me.flashyreese.mods.commandaliases.command.builder.reassign.format.ReassignCommand;
import net.minecraft.command.CommandSource;
import net.minecraft.commands.SharedSuggestionProvider;

import java.lang.reflect.Field;
import java.util.List;
Expand All @@ -22,7 +22,7 @@
* @version 1.0.0
* @since 0.3.0
*/
public class ReassignCommandBuilder<S extends CommandSource> implements CommandBuilderDelegate<S> {
public class ReassignCommandBuilder<S extends SharedSuggestionProvider> implements CommandBuilderDelegate<S> {
protected final String filePath;
protected final ReassignCommand command;
protected final Map<String, String> reassignCommandMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import me.flashyreese.mods.commandaliases.command.CommandType;
import me.flashyreese.mods.commandaliases.command.builder.CommandBuilderDelegate;
import me.flashyreese.mods.commandaliases.command.builder.redirect.format.RedirectCommand;
import net.minecraft.command.CommandSource;
import net.minecraft.commands.SharedSuggestionProvider;

import java.util.Arrays;
import java.util.Collections;
Expand All @@ -25,7 +25,7 @@
* @version 0.5.0
* @since 0.3.0
*/
public class CommandRedirectBuilder<S extends CommandSource> implements CommandBuilderDelegate<S> {
public class CommandRedirectBuilder<S extends SharedSuggestionProvider> implements CommandBuilderDelegate<S> {
private final String filePath;
private final RedirectCommand command;
private final CommandType commandType;
Expand Down
Loading