Skip to content
Closed
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
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
group=com.legitimoose.legitslimepaper
version=1.21.4-R0.1-SNAPSHOT
mcVersion=1.21.4
version=1.21.6-R0.1-SNAPSHOT
mcVersion=1.21.6

#Update with ASP!! (also update gradle/libs.versions.toml)
aspRef=2b60acc0578293049d8837cd716ffd256f2e1090
apiVersion=4.0.0-SNAPSHOT
aspRef=0575f17f44a345d729fbe50c0d61fc4afeea7ac0
apiVersion=4.1.0-SNAPSHOT

org.gradle.caching=true
org.gradle.parallel=true
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
adventure = "4.17.0"
adventure = "4.21.0"
annotations = "26.0.1"
autoservice = "1.1.1"
blossom = "2.1.0"
Expand All @@ -15,7 +15,7 @@ lettuce = "6.5.1.RELEASE"
lombok = "1.18.36"
lombok-plugin = "8.11"
mongo = "5.2.1"
paperweight = "2.0.0-SNAPSHOT"
paperweight = "2.0.0-beta.17"
plugin-yml-paper = "0.6.0"
shadow = "8.3.5"
slf4j = "2.0.16"
Expand Down
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-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
4 changes: 2 additions & 2 deletions legitslimepaper-api/build.gradle.kts.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
--- a/aspaper-api/build.gradle.kts
+++ b/aspaper-api/build.gradle.kts
@@ -104,17 +_,21 @@
@@ -102,17 +_,21 @@
java {
srcDir(generatedApiPath)
srcDir(generatedDir)
srcDir(file("../paper-api/src/main/java"))
+ srcDir(file("../aspaper-api/src/main/java"))
}
Expand Down
14 changes: 7 additions & 7 deletions legitslimepaper-server/build.gradle.kts.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/aspaper-server/build.gradle.kts
+++ b/aspaper-server/build.gradle.kts
@@ -30,7 +_,22 @@
@@ -33,7 +_,22 @@
}
}

Expand All @@ -23,8 +23,8 @@
+ activeFork = legitslimepaper

spigot {
buildDataRef = "3edaf46ec1eed4115ce1b18d2846cded42577e42"
@@ -116,10 +_,14 @@
enabled = false
@@ -120,10 +_,14 @@
main {
java { srcDir("../paper-server/src/main/java") }
resources { srcDir("../paper-server/src/main/resources") }
Expand All @@ -38,17 +38,17 @@
+ resources { srcDir("../aspaper-server/src/test/resources") }
}
}

@@ -143,7 +_,7 @@
val log4jPlugins = sourceSets.create("log4jPlugins") {
@@ -150,7 +_,7 @@
}

dependencies {
- implementation(project(":aspaper-api")) //ASP
+ implementation(project(":legitslimepaper-api")) //ASP + Moose
implementation(project(":core")) //ASP
implementation("commons-io:commons-io:2.11.0")
implementation("ca.spottedleaf:concurrentutil:0.0.3")
@@ -215,14 +_,14 @@
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
@@ -227,14 +_,14 @@
val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim()
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
this.command = command;
@@ -102,6 +_,13 @@
@@ -92,6 +_,13 @@
}
} else {
children.put(node.getName(), node);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,67 @@
--- a/net/minecraft/commands/Commands.java
+++ b/net/minecraft/commands/Commands.java
@@ -1,6 +_,7 @@
@@ -1,5 +_,6 @@
package net.minecraft.commands;

import com.google.common.collect.Maps;
+import com.legitimoose.lsp.MooseConfig;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.StringReader;
@@ -38,7 +_,6 @@
@@ -7,18 +_,18 @@
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
+import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.context.CommandContextBuilder;
import com.mojang.brigadier.context.ContextChain;
+import com.mojang.brigadier.context.ParsedCommandNode;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import com.mojang.brigadier.tree.ArgumentCommandNode;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.RootCommandNode;
import com.mojang.logging.LogUtils;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
+
+import java.util.*;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
@@ -40,7 +_,6 @@
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.protocol.game.ClientboundCommandsPacket;
@@ -136,6 +_,7 @@
@@ -143,6 +_,7 @@
import net.minecraft.util.profiling.jfr.JvmProfiler;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.flag.FeatureFlags;
+import net.minecraft.world.level.BaseCommandBlock;
import net.minecraft.world.level.GameRules;
import org.slf4j.Logger;

@@ -148,6 +_,7 @@
public static final int LEVEL_ADMINS = 3;
public static final int LEVEL_OWNERS = 4;
@@ -174,6 +_,7 @@
}
};
private final CommandDispatcher<CommandSourceStack> dispatcher = new CommandDispatcher<>();
+ public static CommandDispatcher<CommandSourceStack> vanillaCommands = new CommandDispatcher<>(); // Moose

public Commands(Commands.CommandSelection selection, CommandBuildContext context) {
// Paper start - Brigadier API - modern minecraft overloads that do not use redirects but are copies instead
@@ -256,6 +_,25 @@
@@ -285,6 +_,25 @@
PublishCommand.register(this.dispatcher);
}

+ // Moose start - Special boolean to track command block allowed commands (allowed to be ran by command blocks and click events).
+ for (CommandNode<CommandSourceStack> node : this.dispatcher.getRoot().getChildren()) {
+ String cmd = node.getName();
+ if (!MooseConfig.blacklistedVanillaCommands.contains(cmd)) {
+ if (!com.legitimoose.lsp.MooseConfig.blacklistedVanillaCommands.contains(cmd)) {
+ node.commandBlockAllowed = true;
+ }
+ //this.vanillaCommandNodes.add(node);
Expand All @@ -58,13 +80,14 @@
// Paper start - Vanilla command permission fixes
for (final CommandNode<CommandSourceStack> node : this.dispatcher.getRoot().getChildren()) {
if (node.getRequirement() == com.mojang.brigadier.builder.ArgumentBuilder.<CommandSourceStack>defaultRequirement()) {
@@ -353,6 +_,14 @@
@@ -388,6 +_,15 @@
ContextChain contextChain = this.finishParsing(parseResults, command, commandSourceStack, label); // CraftBukkit // Paper - Add UnknownCommandEvent

try {
+ // Moose start - Command block whitelist
+ if (parseResults.getContext().getSource().source instanceof BaseCommandBlock) {
+ if (!parseResults.getContext().getNodes().get(0).getNode().commandBlockAllowed) {
+ List<ParsedCommandNode<CommandSourceStack>> context = parseResults.getContext().getNodes();
+ if (!context.isEmpty() && !context.getFirst().getNode().commandBlockAllowed) {
+ throw new Exception("Non-vanilla commands cannot be executed in command blocks.");
+ }
+ }
Expand All @@ -73,7 +96,7 @@
if (contextChain != null) {
executeCommandInContext(
commandSourceStack,
@@ -362,7 +_,7 @@
@@ -397,7 +_,7 @@
);
}
} catch (Exception var12) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.commands.ExecutionCommandSource;
import net.minecraft.commands.FunctionInstantiationException;
import net.minecraft.commands.execution.UnboundEntryAction;
@@ -50,6 +_,7 @@
@@ -51,6 +_,7 @@

@Override
public InstantiatedFunction<T> instantiate(@Nullable CompoundTag arguments, CommandDispatcher<T> dispatcher) throws FunctionInstantiationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
- this.clickEvent = clickEvent;
+ // Moose start
+ boolean blackListedCommand = false;
+ if (clickEvent != null && clickEvent.getAction() == ClickEvent.Action.RUN_COMMAND) {
+ String cmd = clickEvent.getValue();
+ if (clickEvent != null && clickEvent.action() == ClickEvent.Action.RUN_COMMAND) {
+ String cmd = ((ClickEvent.RunCommand) clickEvent).command();
+ cmd = cmd.startsWith("/") ? cmd.substring(1) : cmd;
+ cmd = cmd.split(" ", 2)[0];
+ String finalCmd = cmd;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--- a/net/minecraft/resources/RegistryDataLoader.java
+++ b/net/minecraft/resources/RegistryDataLoader.java
@@ -166,11 +_,12 @@
map.put(registry.key(), new IllegalStateException("Registry must be non-empty"));
@@ -193,11 +_,12 @@
map.put(registry.key(), new IllegalStateException("Registry must be non-empty: " + registry.key().location()));
}
});
+ // Moose start - Don't throw an exception on invalid registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@
import net.minecraft.SharedConstants;
import net.minecraft.SuppressForbidden;
import net.minecraft.Util;
@@ -57,7 +_,6 @@
import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.LevelSummary;
import net.minecraft.world.level.storage.PrimaryLevelData;
@@ -54,11 +_,7 @@
import net.minecraft.world.level.levelgen.WorldDimensions;
import net.minecraft.world.level.levelgen.WorldOptions;
import net.minecraft.world.level.levelgen.presets.WorldPresets;
-import net.minecraft.world.level.storage.LevelDataAndDimensions;
-import net.minecraft.world.level.storage.LevelStorageSource;
-import net.minecraft.world.level.storage.LevelSummary;
-import net.minecraft.world.level.storage.PrimaryLevelData;
-import net.minecraft.world.level.storage.WorldData;
+import net.minecraft.world.level.storage.*;
import org.slf4j.Logger;

public class Main {
@@ -139,6 +_,8 @@
@@ -140,6 +_,8 @@
LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath());
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
--- a/net/minecraft/server/commands/ExecuteCommand.java
+++ b/net/minecraft/server/commands/ExecuteCommand.java
@@ -146,7 +_,7 @@
@@ -142,7 +_,7 @@
dispatcher.register(
Commands.literal("execute")
.requires(source -> source.hasPermission(2))
.requires(Commands.hasPermission(2))
- .then(Commands.literal("run").redirect(dispatcher.getRoot()))
+ .then(Commands.literal("run").redirect(Commands.vanillaCommands.getRoot())) // Moose - Only run vanilla commands
.then(addConditionals(literalCommandNode, Commands.literal("if"), true, context))
.then(addConditionals(literalCommandNode, Commands.literal("unless"), false, context))
.then(Commands.literal("as").then(Commands.argument("targets", EntityArgument.entities()).fork(literalCommandNode, context1 -> {
.then(addConditionals(literalCommandNode, Commands.literal("if"), true, buildContext))
.then(addConditionals(literalCommandNode, Commands.literal("unless"), false, buildContext))
.then(Commands.literal("as").then(Commands.argument("targets", EntityArgument.entities()).fork(literalCommandNode, commandContext -> {
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
--- a/net/minecraft/server/commands/ReturnCommand.java
+++ b/net/minecraft/server/commands/ReturnCommand.java
@@ -6,6 +_,9 @@
@@ -6,6 +_,8 @@
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.context.ContextChain;
import java.util.List;
+
+import com.mojang.brigadier.tree.CommandNode;
+import net.minecraft.commands.Commands;
import net.minecraft.commands.Commands;
import net.minecraft.commands.ExecutionCommandSource;
import net.minecraft.commands.execution.ChainModifiers;
import net.minecraft.commands.execution.CustomCommandExecutor;
@@ -25,7 +_,7 @@
@@ -26,7 +_,7 @@
.executes(new ReturnCommand.ReturnValueCustomExecutor<>())
)
.then(LiteralArgumentBuilder.<T>literal("fail").executes(new ReturnCommand.ReturnFailCustomExecutor<>()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
dispatcher.register(
Commands.literal("tick")
- .requires(commandSourceStack -> commandSourceStack.hasPermission(3))
+ .requires(commandSourceStack -> commandSourceStack.hasPermission(2))
- .requires(Commands.hasPermission(3))
+ .requires(Commands.hasPermission(2))
.then(Commands.literal("query").executes(commandContext -> tickQuery(commandContext.getSource())))
.then(
Commands.literal("rate")
Loading