-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
157 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
repositories { | ||
mavenCentral() | ||
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' } | ||
maven { url = 'https://oss.sonatype.org/content/repositories/central' } | ||
maven { | ||
url = "https://repo.papermc.io/repository/maven-public/" | ||
} | ||
maven { | ||
url = "https://libraries.minecraft.net" | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly("com.mojang:brigadier:1.0.18") | ||
compileOnlyApi("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT") | ||
} | ||
|
||
processTestResources { | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
} | ||
|
||
java { | ||
toolchain.languageVersion.set(JavaLanguageVersion.of(17)) | ||
} |
41 changes: 41 additions & 0 deletions
41
...r/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendCommandsEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.destroystokyo.paper.event.brigadier; | ||
|
||
import com.mojang.brigadier.tree.RootCommandNode; | ||
import io.papermc.paper.command.brigadier.CommandSourceStack; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.player.PlayerEvent; | ||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class AsyncPlayerSendCommandsEvent<S extends CommandSourceStack> extends PlayerEvent { | ||
|
||
private static final HandlerList HANDLER_LIST = new HandlerList(); | ||
private final RootCommandNode<S> node; | ||
private final boolean hasFiredAsync; | ||
|
||
@ApiStatus.Internal | ||
public AsyncPlayerSendCommandsEvent(Player player, RootCommandNode<S> node, boolean hasFiredAsync) { | ||
super(player, !Bukkit.isPrimaryThread()); | ||
this.node = node; | ||
this.hasFiredAsync = hasFiredAsync; | ||
} | ||
|
||
public RootCommandNode<S> getCommandNode() { | ||
return this.node; | ||
} | ||
|
||
public boolean hasFiredAsync() { | ||
return this.hasFiredAsync; | ||
} | ||
|
||
public @NotNull HandlerList getHandlers() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
paper/src/main/java/io/papermc/paper/command/brigadier/CommandSourceStack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.papermc.paper.command.brigadier; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Entity; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface CommandSourceStack { | ||
Location getLocation(); | ||
|
||
CommandSender getSender(); | ||
|
||
@Nullable | ||
Entity getExecutor(); | ||
} |
45 changes: 45 additions & 0 deletions
45
paper/src/main/java/io/papermc/paper/command/brigadier/Commands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.papermc.paper.command.brigadier; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.arguments.ArgumentType; | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import com.mojang.brigadier.builder.RequiredArgumentBuilder; | ||
import com.mojang.brigadier.tree.LiteralCommandNode; | ||
import io.papermc.paper.plugin.configuration.PluginMeta; | ||
import io.papermc.paper.plugin.lifecycle.event.registrar.Registrar; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.jetbrains.annotations.Unmodifiable; | ||
|
||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
public interface Commands extends Registrar { | ||
|
||
static LiteralArgumentBuilder<CommandSourceStack> literal(String literal) { | ||
return LiteralArgumentBuilder.literal(literal); | ||
} | ||
|
||
static <T> RequiredArgumentBuilder<CommandSourceStack, T> argument(String name, ArgumentType<T> argumentType) { | ||
return RequiredArgumentBuilder.argument(name, argumentType); | ||
} | ||
|
||
CommandDispatcher<CommandSourceStack> getDispatcher(); | ||
|
||
default @Unmodifiable Set<String> register(LiteralCommandNode<CommandSourceStack> node) { | ||
return null; | ||
} | ||
|
||
default @Unmodifiable Set<String> register(LiteralCommandNode<CommandSourceStack> node, @Nullable String description) { | ||
return null; | ||
} | ||
|
||
default @Unmodifiable Set<String> register(LiteralCommandNode<CommandSourceStack> node, Collection<String> aliases) { | ||
return null; | ||
} | ||
|
||
@Unmodifiable | ||
Set<String> register(LiteralCommandNode<CommandSourceStack> var1, @Nullable String var2, Collection<String> var3); | ||
|
||
@Unmodifiable Set<String> register(PluginMeta var1, LiteralCommandNode<CommandSourceStack> var2, @Nullable String var3, Collection<String> var4); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters