Skip to content

Commit

Permalink
Merge branch '1.19.x/dev' into 1.19.x/stable
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed Dec 9, 2022
2 parents 02c9a2f + f8fb4f1 commit 5d10022
Show file tree
Hide file tree
Showing 25 changed files with 303 additions and 159 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Upload assets to GitHub
run: ./gradlew build
run: ./gradlew build publishAllPublicationsToFlashyReeseReleasesRepository
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
BUILD_RELEASE: ${{ github.event.prerelease == false }}
- name: Publish to Modrinth & CurseForge
uses: Kir-Antipov/[email protected]
Expand Down
19 changes: 10 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'maven-publish'
id 'io.github.juuxel.loom-quiltflower' version '1.7.2'
}
Expand Down Expand Up @@ -34,7 +34,7 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Permissions API
include(modImplementation("me.lucko:fabric-permissions-api:0.1-SNAPSHOT"))
include(modImplementation("me.lucko:fabric-permissions-api:0.2-SNAPSHOT"))

// LevelDB
include(implementation("org.iq80.leveldb:leveldb:0.12"))
Expand All @@ -48,18 +48,18 @@ dependencies {
include(implementation("org.apache.commons:commons-pool2:2.11.1"))

// Parsing Libraries
include(implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-toml:2.13.3"))
include(implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.13.3"))
include(implementation("com.fasterxml.jackson.core:jackson-core:2.13.3"))
include(implementation("com.fasterxml.jackson.core:jackson-databind:2.13.3"))
include(implementation("com.fasterxml.jackson.core:jackson-annotations:2.13.3"))
include(implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-toml:2.14.0"))
include(implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.14.0"))
include(implementation("com.fasterxml.jackson.core:jackson-core:2.14.0"))
include(implementation("com.fasterxml.jackson.core:jackson-databind:2.14.0"))
include(implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.0"))

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

modRuntimeOnly "maven.modrinth:lazydfu:0.1.3"
//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:lithium:mc1.19-0.8.0"
//modRuntimeOnly "maven.modrinth:phosphor:mc1.19.x-0.8.1"
}

Expand Down Expand Up @@ -91,6 +91,7 @@ jar {
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19
yarn_mappings=1.19+build.4
loader_version=0.14.8
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.14.10

# Mod Properties
mod_version = 1.0.0
maven_group = me.flashyreese
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.57.0+1.19
fabric_version=0.67.0+1.19.2
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 11 additions & 5 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
Expand Down Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Permissions {
* Creates a predicate which returns the result of performing a permission check,
* falling back to the {@code defaultValue} if the resultant state is {@link TriState#DEFAULT}.
*
* @param permission the permission to check
* @param permission the permission to check
* @param defaultValue the default value to use if nothing has been set
* @return a predicate that will perform the permission check
*/
Expand All @@ -28,7 +28,7 @@ public class Permissions {
* falling back to requiring the {@code defaultRequiredLevel} if the resultant state is
* {@link TriState#DEFAULT}.
*
* @param permission the permission to check
* @param permission the permission to check
* @param defaultRequiredLevel the required permission level to check for as a fallback
* @return a predicate that will perform the permission check
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Scheduler {
private final Queue<Event> events = new PriorityQueue<>(Comparator.comparingLong(Event::getTriggerTime));

public void processEvents() {
while(true) {
while (true) {
Event event = this.events.peek();
if (event == null || event.triggerTime > System.currentTimeMillis()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.mojang.brigadier.tree.CommandNode;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import me.flashyreese.mods.commandaliases.CommandAliasesMod;
import me.flashyreese.mods.commandaliases.command.CommandType;
import me.flashyreese.mods.commandaliases.command.Permissions;
import me.flashyreese.mods.commandaliases.command.Scheduler;
import me.flashyreese.mods.commandaliases.command.builder.CommandBuilderDelegate;
Expand Down Expand Up @@ -42,18 +43,23 @@
* @since 0.4.0
*/
public abstract class AbstractCustomCommandBuilder<S extends CommandSource> implements CommandBuilderDelegate<S> {

protected final String filePath;
protected final CustomCommand commandAliasParent;
protected final CommandType commandType;

protected final ArgumentTypeMapper argumentTypeMapper;
protected final FunctionProcessor<S> functionProcessor;
protected final InputMapper<S> inputMapper;

protected final AbstractCommandAliasesProvider<S> abstractCommandAliasesProvider;

public AbstractCustomCommandBuilder(CustomCommand commandAliasParent, AbstractCommandAliasesProvider<S> abstractCommandAliasesProvider, CommandRegistryAccess registryAccess) {
public AbstractCustomCommandBuilder(String filePath, CustomCommand commandAliasParent, AbstractCommandAliasesProvider<S> abstractCommandAliasesProvider, CommandRegistryAccess registryAccess, CommandType commandType) {
this.filePath = filePath;
this.argumentTypeMapper = new ArgumentTypeMapper(registryAccess);
this.commandAliasParent = commandAliasParent;
this.abstractCommandAliasesProvider = abstractCommandAliasesProvider;
this.commandType = commandType;
this.functionProcessor = new FunctionProcessor<>(abstractCommandAliasesProvider);
this.inputMapper = new InputMapper<>();
}
Expand Down Expand Up @@ -109,14 +115,25 @@ protected LiteralArgumentBuilder<S> buildCommandParent(CommandDispatcher<S> disp
*/
protected ArgumentBuilder<S, ?> buildCommandChild(CustomCommandChild child, CommandDispatcher<S> dispatcher, List<String> inputs, String permission) {
ArgumentBuilder<S, ?> argumentBuilder = null;

if (child.getChild() == null || child.getChild().isEmpty()) {
CommandAliasesMod.logger().warn("[{}] {} - Missing Command Child Node Name: {}", this.commandType, this.commandAliasParent.getCommandMode(), this.filePath);
return null;
}

if (child.getType() == null || child.getType().isEmpty()) {
CommandAliasesMod.logger().warn("[{}] {} - Missing Command Child Node Type of \"{}\": {}", this.commandType, this.commandAliasParent.getCommandMode(), child.getChild(), this.filePath);
return null;
}

if (child.getType().equals("literal")) {
argumentBuilder = this.literal(child.getChild());
} else if (child.getType().equals("argument")) {
if (this.argumentTypeMapper.getArgumentMap().containsKey(child.getArgumentType())) {
argumentBuilder = this.argument(child.getChild(), this.argumentTypeMapper.getArgumentMap().get(child.getArgumentType()));
inputs.add(child.getChild());
} else {
CommandAliasesMod.logger().error("Invalid Argument Type: {}", child.getArgumentType());
CommandAliasesMod.logger().error("[{}] {} - Invalid Argument Type of \"{}\": {}", this.commandType, this.commandAliasParent.getCommandMode(), child.getArgumentType(), this.filePath);
}
}
if (argumentBuilder != null) {
Expand Down Expand Up @@ -183,25 +200,24 @@ protected int executeCommand(List<CustomCommandAction> actions, String message,
*/
@SuppressWarnings("unchecked")
public ArgumentBuilder<S, ?> buildCommandChildSuggestion(CommandDispatcher<S> dispatcher, ArgumentBuilder<S, ?> argumentBuilder, CustomCommandChild child, List<String> inputs) {
if (!(argumentBuilder instanceof RequiredArgumentBuilder))
return argumentBuilder;
if (!(argumentBuilder instanceof RequiredArgumentBuilder)) return argumentBuilder;

SuggestionProvider<S> SUGGESTION_PROVIDER;

CustomCommandSuggestionProvider suggestionProvider = child.getSuggestionProvider();

if (suggestionProvider.getSuggestionMode() == null) {
CommandAliasesMod.logger().warn("Missing suggestion mode in \"{}\"", child.getChild());
CommandAliasesMod.logger().warn("[{}] {} - Missing suggestion mode: {}", this.commandType, this.commandAliasParent.getCommandMode(), this.filePath);
return argumentBuilder;
}

if (suggestionProvider.getSuggestion() == null || suggestionProvider.getSuggestion().isEmpty()) {
CommandAliasesMod.logger().warn("Missing suggestion in \"{}\"", child.getChild());
CommandAliasesMod.logger().warn("[{}] {} - Missing suggestion: {}", this.commandType, this.commandAliasParent.getCommandMode(), this.filePath);
return argumentBuilder;
}

if (Arrays.stream(CustomCommandSuggestionMode.values()).filter(value -> suggestionProvider.getSuggestionMode() == value).count() != 1) {
CommandAliasesMod.logger().error("Invalid suggestion mode \"{}\"", suggestionProvider.getSuggestionMode());
CommandAliasesMod.logger().error("[{}] {} - Invalid suggestion mode \"{}\": {}", this.commandType, this.commandAliasParent.getCommandMode(), suggestionProvider.getSuggestionMode(), this.filePath);
return argumentBuilder;
}

Expand All @@ -210,7 +226,7 @@ protected int executeCommand(List<CustomCommandAction> actions, String message,
if (redirect != null && redirect.createBuilder() instanceof RequiredArgumentBuilder requiredArgumentBuilder) {
SUGGESTION_PROVIDER = requiredArgumentBuilder.getSuggestionsProvider();
} else {
CommandAliasesMod.logger().error("Invalid suggestion \"{}\"", suggestionProvider.getSuggestion());
CommandAliasesMod.logger().error("[{}] {} - Invalid suggestion \"{}\": {}", this.commandType, this.commandAliasParent.getCommandMode(), suggestionProvider.getSuggestion(), this.filePath);
return argumentBuilder;
}
} else if (suggestionProvider.getSuggestionMode() == CustomCommandSuggestionMode.JSON_LIST) {
Expand All @@ -222,11 +238,10 @@ protected int executeCommand(List<CustomCommandAction> actions, String message,
long end = System.nanoTime();
if (CommandAliasesMod.options().debugSettings.showProcessingTime) {
CommandAliasesMod.logger().info("""
\n\t======================================================
\tSuggestion Provider: {}
\tProcessing time: {}ms
\t======================================================""",
formattedSuggestion, (end - start) / 1000000.0);
\n\t======================================================
\tSuggestion Provider: {}
\tProcessing time: {}ms
\t======================================================""", formattedSuggestion, (end - start) / 1000000.0);
}
return CommandSource.suggestMatching(suggestions.stream().map(StringArgumentType::escapeIfRequired), builder);
};
Expand All @@ -236,21 +251,18 @@ protected int executeCommand(List<CustomCommandAction> actions, String message,
long start = System.nanoTime();
String formattedSuggestion = this.formatString(context, inputs, suggestionProvider.getSuggestion());
this.abstractCommandAliasesProvider.getDatabase().map().forEach((key, value) -> {
if (!(suggestionProvider.getSuggestionMode() == CustomCommandSuggestionMode.DATABASE_STARTS_WITH && key.startsWith(formattedSuggestion)) &&
!(suggestionProvider.getSuggestionMode() == CustomCommandSuggestionMode.DATABASE_ENDS_WITH && key.endsWith(formattedSuggestion)) &&
!(suggestionProvider.getSuggestionMode() == CustomCommandSuggestionMode.DATABASE_CONTAINS && key.contains(formattedSuggestion)))
if (!(suggestionProvider.getSuggestionMode() == CustomCommandSuggestionMode.DATABASE_STARTS_WITH && key.startsWith(formattedSuggestion)) && !(suggestionProvider.getSuggestionMode() == CustomCommandSuggestionMode.DATABASE_ENDS_WITH && key.endsWith(formattedSuggestion)) && !(suggestionProvider.getSuggestionMode() == CustomCommandSuggestionMode.DATABASE_CONTAINS && key.contains(formattedSuggestion)))
return;

suggestions.add(value);
});
long end = System.nanoTime();
if (CommandAliasesMod.options().debugSettings.showProcessingTime) {
CommandAliasesMod.logger().info("""
\n\t======================================================
\tSuggestion Provider: {}
\t"Processing time: {}ms
\t======================================================""",
formattedSuggestion, (end - start) / 1000000.0);
\n\t======================================================
\tSuggestion Provider: {}
\t"Processing time: {}ms
\t======================================================""", formattedSuggestion, (end - start) / 1000000.0);
}
return CommandSource.suggestMatching(suggestions.stream().map(StringArgumentType::escapeIfRequired), builder);
};
Expand Down Expand Up @@ -287,8 +299,7 @@ protected int performActions(List<CustomCommandAction> actions, CommandDispatche
*/
private int scheduleAction(Queue<CustomCommandAction> customCommandActionQueue, long triggerTime, CommandDispatcher<S> dispatcher, CommandContext<S> context, List<String> currentInputList) {
AtomicInteger state = new AtomicInteger();
if (customCommandActionQueue.isEmpty())
return Command.SINGLE_SUCCESS;
if (customCommandActionQueue.isEmpty()) return Command.SINGLE_SUCCESS;

CustomCommandAction action = customCommandActionQueue.poll();
String eventName = "generic";
Expand Down Expand Up @@ -324,14 +335,13 @@ private int scheduleAction(Queue<CustomCommandAction> customCommandActionQueue,
long endExecution = System.nanoTime();
if (CommandAliasesMod.options().debugSettings.showProcessingTime) {
CommandAliasesMod.logger().info("""
\n\t======================================================
\tOriginal Action Command: {}
\tOriginal Action Command Type: {}
\tPost Processed Action Command: {}
\tFormatting time: {}ms
\tExecuting time: {}ms
\t======================================================""",
action.getCommand(), action.getCommandType(), actionCommand, (endFormat - startFormat) / 1000000.0, (endExecution - endFormat) / 1000000.0);
\n\t======================================================
\tOriginal Action Command: {}
\tOriginal Action Command Type: {}
\tPost Processed Action Command: {}
\tFormatting time: {}ms
\tExecuting time: {}ms
\t======================================================""", action.getCommand(), action.getCommandType(), actionCommand, (endFormat - startFormat) / 1000000.0, (endExecution - endFormat) / 1000000.0);
}
if (state.get() != Command.SINGLE_SUCCESS) {
if (action.getMessageIfUnsuccessful() != null) {
Expand Down
Loading

0 comments on commit 5d10022

Please sign in to comment.