Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud for commands #3808

Merged
merged 129 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 113 commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
db5ccff
Initial start on cloud
Konicai Jun 1, 2023
8d7e789
Compiling and working on spigot
Konicai Jun 2, 2023
9da3345
paper-mojangapi is no longer required
Konicai Jun 2, 2023
37797d7
Be more lenient with backwardsCommandSenderMappers
Konicai Jun 2, 2023
8e6d7d3
Cleanup the last commit
Konicai Jun 3, 2023
e2f71af
Fix small mistakes
Konicai Jun 3, 2023
411c289
Refactor CommandSourceConverter
Konicai Jun 20, 2023
2435a33
Merge remote-tracking branch 'upstream/master' into feature/cloud
Konicai Jun 20, 2023
e3532fa
Initial start on permissions
Konicai Jun 20, 2023
5b3226b
Fix GeyserSession#hasPermission, remove WorldManager#hasPermission, docs
Konicai Jun 25, 2023
f553e83
Merge remote-tracking branch 'upstream/master' into feature/cloud
Konicai Jun 26, 2023
a830fb7
permissions.yml and compiling
Konicai Jun 26, 2023
049e29e
Make commands fully use cloud, command api deprecations
Konicai Jun 27, 2023
42ada0b
Merge remote-tracking branch 'upstream/master' into feature/cloud
Konicai Aug 30, 2023
6c932ec
Handle exceptions on standalone, class renaming and moving
Konicai Aug 31, 2023
47031ce
misc changes for reviews
Konicai Sep 1, 2023
cddc34a
Cleanup builtin and extension command implementations
Konicai Sep 2, 2023
aea2a18
CommandBuilder -> ExtensionCommandBuilder
Konicai Sep 2, 2023
7ee26fb
Attempt at permission defaults for spigot
Konicai Sep 2, 2023
94d3f62
Define default permissions of builtin commands
Konicai Sep 2, 2023
4b893e6
Undo some changes, some legacy compat for suggestedOpOnly
Konicai Sep 2, 2023
54b2597
Merge branch 'master' into feature/cloud
Konicai Sep 2, 2023
2ab03e7
Allow commands without aliases to have their permissions registered
Konicai Sep 2, 2023
887509b
Don't force perm registration of perms used by commands
Konicai Sep 2, 2023
a640e1a
Merge remote-tracking branch 'origin/feature/cloud' into feature/cloud
Konicai Sep 2, 2023
1eba87d
fix commands on fabric
Konicai Sep 3, 2023
c7826b5
Move command registry creation to mod init on fabric
Konicai Sep 4, 2023
1c45bb4
Temporary warning if command source converter receives atypical argument
Konicai Sep 4, 2023
26f53d2
Make extension command builder an inner class of ExtensionCommand
Konicai Sep 4, 2023
065abb0
Bootstrap consistency: register commands after PreInitEvent, before P…
Konicai Sep 4, 2023
acd53a4
Refactor command abstraction and implement `/geyser` as help
Konicai Sep 5, 2023
12928f1
Missing Override annotation for version command
Konicai Sep 5, 2023
bdbef04
Customize exception handlers on all platforms
Konicai Sep 5, 2023
cdf06ce
Don't suggest opts that have already been added for dump command
Konicai Sep 5, 2023
821ce46
Update translations
Konicai Sep 6, 2023
14e1c04
Target languages PR
Konicai Sep 7, 2023
f1e9869
Merge upstream
Konicai Sep 7, 2023
55e50fe
Remove trailing whitespace on Standalone GUI
Konicai Sep 7, 2023
3ec2125
Stop Bedrock commands from appearing in Java players' brig suggestions
Konicai Sep 8, 2023
6e4f718
Merge remote-tracking branch 'upstream/master' into feature/cloud
Konicai Sep 11, 2023
e9140c5
Reimplement command descriptions
Konicai Sep 13, 2023
c40cfd6
Merge branch 'master' into feature/cloud
Konicai Sep 13, 2023
2aa2621
javadocs
Konicai Sep 14, 2023
6b22cf7
cloud 1.8.4
Konicai Sep 15, 2023
5314004
Strip trailing whitespace for cloud on Standalone as well
Konicai Sep 19, 2023
df15625
Fix usage of HelpCommand for extensions
Konicai Sep 19, 2023
7580b8b
address some simple reviews
Konicai Sep 19, 2023
e9d4802
2.2.0 -> 2.3.0
Konicai Sep 29, 2023
6f06ff6
Merge remote-tracking branch 'upstream/master' into feature/cloud
Konicai Sep 29, 2023
d97ed14
Don't explicitly clear the CommandRegistry
Konicai Sep 29, 2023
c715c86
Move warning to debug
Konicai Sep 29, 2023
799972d
Reverse nullability changes for `Command.Builder#description/permissi…
Konicai Sep 29, 2023
24323d4
Cleanup nullabilities relating to extension commands
Konicai Sep 30, 2023
215f1fe
some misc changes
Konicai Sep 30, 2023
0fedd8b
Simplify alias setting for extension commands
Konicai Sep 30, 2023
c73b9de
Merge remote-tracking branch 'upstream/master' into feature/cloud
Konicai Oct 1, 2023
3a1797f
Update lang keys for root command descriptions
Konicai Oct 1, 2023
8d708b6
Update languages
Konicai Oct 1, 2023
7c083f0
better javadocs on Command.Builder#permission
Konicai Oct 1, 2023
1cf6d97
remove some outdated todos
Konicai Oct 1, 2023
f5b2457
don't block standalone terminal with commands
Konicai Oct 2, 2023
0cfee52
don't let (unexpected) exceptions thrown while handling command excep…
Konicai Oct 2, 2023
956d607
Don't use Optional for CommandSource#playerUuid/connection
Konicai Oct 2, 2023
37807a5
hnnnng
Konicai Oct 2, 2023
35e08cc
Improve permission messages, deprecate executableOnConsole for player…
Konicai Oct 6, 2023
b8b30d3
Merge remote-tracking branch 'upstream/master' into feature/cloud
Konicai Oct 6, 2023
f1ad466
loom is the bane of my existence
Konicai Oct 6, 2023
bfc5b7f
Revert "loom is the bane of my existence"
Konicai Oct 6, 2023
aeca04a
update gradle, lombok, loom
Konicai Oct 17, 2023
4bd9bfc
Merge remote-tracking branch 'upstream/master' into feature/cloud
onebeastchris Oct 18, 2023
c7aa3fa
Merge remote-tracking branch 'upstream/master' into feature/cloud-upd…
onebeastchris Jan 9, 2024
f1906f5
javadocs fixes
Konicai Feb 28, 2024
f6b0f36
Merge remote-tracking branch 'upstream/master' into feature/cloud-upd…
onebeastchris Mar 5, 2024
c867b54
attempt at updating the cloud pr; todo neoforge or even general testing
onebeastchris Mar 7, 2024
666c23f
some more merge issues
onebeastchris Mar 7, 2024
dc1826c
Start on cloud 2.0 changes
onebeastchris Mar 7, 2024
f2a3fea
2.0 command arguments
onebeastchris Mar 7, 2024
677f79d
- removed fabric permission api, done by cloud now
onebeastchris Mar 8, 2024
ba3bd43
revert attempts related to exception handling
onebeastchris Mar 8, 2024
98856a9
Merge remote-tracking branch 'upstream/master' into feature/cloud-upd…
onebeastchris Apr 13, 2024
6911105
yeet paper mojang api depend
onebeastchris Apr 13, 2024
5079ce5
maybe the dump command works?
onebeastchris Apr 13, 2024
dea6c2f
Merge remote-tracking branch 'upstream/master' into feature/cloud-upd…
onebeastchris Apr 14, 2024
ad546b6
it builds!
onebeastchris Apr 14, 2024
e017532
- Don't throw when a throwable has been handled
onebeastchris Apr 14, 2024
542fb88
Merge remote-tracking branch 'konica/feature/cloud' into feature/clou…
onebeastchris Apr 14, 2024
8341480
add comment on paper command manager
onebeastchris Apr 14, 2024
f261137
- yeet application plugin from mod/plugin build scripts, set main cla…
onebeastchris Apr 15, 2024
9aa6553
help command changes to ensure root command does require the help com…
onebeastchris Apr 15, 2024
aa3d875
Merge remote-tracking branch 'upstream/master' into feature/cloud-upd…
onebeastchris Apr 19, 2024
8245b0f
don't jij cloud stuff, cloud-platform does that already
onebeastchris Apr 19, 2024
55ebb95
Revert add entity translator shenanigans, re-add viaproxy console com…
onebeastchris Apr 20, 2024
27a086e
- add permission (+default) for base `/geyser` command
onebeastchris Apr 21, 2024
7456ed3
- add default handlers for neoforge
onebeastchris Apr 21, 2024
c98d090
Merge remote-tracking branch 'refs/remotes/upstream/master' into feat…
Konicai May 5, 2024
d1af3ff
Fix merge mistake
Konicai May 6, 2024
bc1a740
Don't invoke a permission check a second time if it fails
Konicai May 6, 2024
bdc2d07
cleanup CommandRegistry
Konicai May 6, 2024
5105132
misc
Konicai May 7, 2024
1140306
address some reviews, update cloud, separate exception handling
Konicai May 8, 2024
83c131e
Update GeyserNeoForgeCommandRegistry#hasPermission exception handling
Konicai May 8, 2024
6f6be87
CommandSource#connection should return GeyserConnection instead of Co…
Konicai May 9, 2024
b5f6ddd
NeoForge: Mixin for new PermissionNode instead of reflection
Konicai May 13, 2024
348ee4f
CommandRegistry: Don't expose the CommandManager
Konicai May 14, 2024
70edacc
Merge branch 'refs/heads/master' into feature/cloud
Konicai Jun 2, 2024
30aa88e
misc cleanup
Konicai Jun 2, 2024
cc94227
Only initialize commands once on Geyser-Standalone
Konicai Jun 1, 2024
c92ae75
delegate CommandSource#playerUuid impl in GeyserSession
Konicai Jun 3, 2024
db399cb
discard root command permission for now, move root->help delegate out…
Konicai Jun 3, 2024
c672d62
add back root command permission optionally, to avoid Spigot regression
Konicai Jun 7, 2024
d1abeee
Permissions class for general perms, GeyserImpl is responsible for th…
Konicai Jun 9, 2024
5ad0da1
Cleanup command constructors, reference GeyserCommand more
Konicai Jun 9, 2024
4c00b11
register all permissions on NeoForge
Konicai Jun 10, 2024
3f90320
check more parameters
Konicai Jun 10, 2024
c3d5219
only one permissions.yml file, in core
Konicai Jun 10, 2024
ffb8256
update to cloud rc.2
Konicai Jun 10, 2024
6159799
some review
Konicai Jun 11, 2024
20d91cc
some more review
Konicai Jun 17, 2024
667486b
Mark Command.Builder#permission(String, TriState) as experimental.
Konicai Jun 18, 2024
1863f5a
Merge remote-tracking branch 'refs/remotes/upstream/master' into feat…
Konicai Jun 18, 2024
628000b
Support Spigot 1.21, further decrease priority of Forge undefined perms
Konicai Jun 18, 2024
f680a72
Merge remote-tracking branch 'refs/remotes/upstream/master' into feat…
onebeastchris Jul 1, 2024
5ee0d41
Merge upstream, update languages module
onebeastchris Jul 1, 2024
b2a2250
Handle blank permissions properly
onebeastchris Jul 6, 2024
b891023
Merge remote-tracking branch 'refs/remotes/upstream/master' into feat…
Konicai Jul 8, 2024
568cbc8
Some more blank permission handling/comments
Konicai Jul 8, 2024
5feccb8
Probably fix permission checking on ViaProxy
Konicai Jul 8, 2024
71b14eb
bump cloud-minecraft to 2.0.0-beta.9
Konicai Jul 8, 2024
d49617d
Relocate geantyref (provided by cloud yippee)
Konicai Jul 10, 2024
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
113 changes: 75 additions & 38 deletions api/src/main/java/org/geysermc/geyser/api/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.GeyserApi;
import org.geysermc.geyser.api.connection.GeyserConnection;
import org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionsEvent;
import org.geysermc.geyser.api.extension.Extension;
import org.geysermc.geyser.api.util.TriState;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -58,15 +60,15 @@ public interface Command {
* Gets the permission node associated with
* this command.
*
* @return the permission node for this command
* @return the permission node for this command if defined, otherwise an empty string
*/
@NonNull
String permission();

/**
* Gets the aliases for this command.
* Gets the aliases for this command, as an unmodifiable list
*
* @return the aliases for this command
* @return the aliases for this command as an unmodifiable list
*/
@NonNull
List<String> aliases();
Expand All @@ -75,35 +77,39 @@ public interface Command {
* Gets if this command is designed to be used only by server operators.
*
* @return if this command is designated to be used only by server operators.
* @deprecated this method is not guaranteed to provide meaningful or expected results.
*/
boolean isSuggestedOpOnly();
@Deprecated(forRemoval = true)
default boolean isSuggestedOpOnly() {
return false;
}

/**
* Gets if this command is executable on console.
*
* @return if this command is executable on console
* @return true if this command is executable on console
* @deprecated use {@link #isPlayerOnly()} instead (inverted)
*/
boolean isExecutableOnConsole();
@Deprecated(forRemoval = true)
default boolean isExecutableOnConsole() {
return !isPlayerOnly();
}

/**
* Gets the subcommands associated with this
* command. Mainly used within the Geyser Standalone
* GUI to know what subcommands are supported.
*
* @return the subcommands associated with this command
* @return true if this command can only be used by players
*/
@NonNull
default List<String> subCommands() {
return Collections.emptyList();
}
boolean isPlayerOnly();

/**
* Used to send a deny message to Java players if this command can only be used by Bedrock players.
*
* @return true if this command can only be used by Bedrock players.
* @return true if this command can only be used by Bedrock players
*/
default boolean isBedrockOnly() {
return false;
boolean isBedrockOnly();

/**
* @deprecated this method will always return an empty immutable list
*/
@Deprecated(forRemoval = true)
@NonNull
default List<String> subCommands() {
return Collections.emptyList();
}

/**
Expand All @@ -128,86 +134,117 @@ interface Builder<T extends CommandSource> {
* is an instance of this source.
*
* @param sourceType the source type
* @return the builder
* @return this builder
*/
Builder<T> source(@NonNull Class<? extends T> sourceType);

/**
* Sets the command name.
*
* @param name the command name
* @return the builder
* @return this builder
*/
Builder<T> name(@NonNull String name);

/**
* Sets the command description.
*
* @param description the command description
* @return the builder
* @return this builder
*/
Builder<T> description(@NonNull String description);

/**
* Sets the permission node.
* Sets the permission node required to run this command. <br>
* It will not be registered with any permission registries, such as an underlying server,
* or a permissions Extension (unlike {@link #permission(String, TriState)}).
*
* @param permission the permission node
* @return the builder
* @return this builder
*/
Builder<T> permission(@NonNull String permission);

/**
* Sets the permission node and its default value. The usage of the default value is platform dependant
* and may or may not be used. For example, it may be registered to an underlying server.
<p>
* Extensions may instead listen for {@link GeyserRegisterPermissionsEvent} to register permissions, which
* should be used if the same permission is required by multiple commands.
*
* @param permission the permission node
* @param defaultValue the node's default value
* @return this builder
*/
Builder<T> permission(@NonNull String permission, @NonNull TriState defaultValue);

/**
* Sets the aliases.
*
* @param aliases the aliases
* @return the builder
* @return this builder
*/
Builder<T> aliases(@NonNull List<String> aliases);

/**
* Sets if this command is designed to be used only by server operators.
*
* @param suggestedOpOnly if this command is designed to be used only by server operators
* @return the builder
* @return this builder
* @deprecated this method is not guaranteed to produce meaningful or expected results
*/
@Deprecated(forRemoval = true)
Builder<T> suggestedOpOnly(boolean suggestedOpOnly);

/**
* Sets if this command is executable on console.
*
* @param executableOnConsole if this command is executable on console
* @return the builder
* @return this builder
* @deprecated use {@link #isPlayerOnly()} instead (inverted)
*/
@Deprecated(forRemoval = true)
Builder<T> executableOnConsole(boolean executableOnConsole);

/**
* Sets the subcommands.
* Sets if this command can only be executed by players.
*
* @param subCommands the subcommands
* @return the builder
* @param playerOnly if this command is player only
* @return this builder
*/
Builder<T> subCommands(@NonNull List<String> subCommands);
Builder<T> playerOnly(boolean playerOnly);

/**
* Sets if this command is bedrock only.
* Sets if this command can only be executed by bedrock players.
*
* @param bedrockOnly if this command is bedrock only
* @return the builder
* @return this builder
*/
Builder<T> bedrockOnly(boolean bedrockOnly);

/**
* Sets the subcommands.
*
* @param subCommands the subcommands
* @return this builder
* @deprecated this method has no effect
*/
@Deprecated(forRemoval = true)
default Builder<T> subCommands(@NonNull List<String> subCommands) {
return this;
}

/**
* Sets the {@link CommandExecutor} for this command.
*
* @param executor the command executor
* @return the builder
* @return this builder
*/
Builder<T> executor(@NonNull CommandExecutor<T> executor);

/**
* Builds the command.
*
* @return the command
* @return a new command from this builder
*/
@NonNull
Command build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
package org.geysermc.geyser.api.command;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.geyser.api.connection.GeyserConnection;

import java.util.UUID;

/**
* Represents an instance capable of sending commands.
Expand Down Expand Up @@ -64,6 +68,18 @@ default void sendMessage(String[] messages) {
*/
boolean isConsole();

/**
* @return a Java UUID if this source represents a player, otherwise null
*/
@Nullable UUID playerUuid();
Konicai marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return a GeyserConnection if this source represents a Bedrock player that is connected
* to this Geyser instance, otherwise null
*/
@Nullable
GeyserConnection connection();

/**
* Returns the locale of the command source.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public interface GeyserDefineCommandsEvent extends Event {
/**
* Gets all the registered built-in {@link Command}s.
*
* @return all the registered built-in commands
* @return all the registered built-in commands as an unmodifiable map
*/
@NonNull
Map<String, Command> commands();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.api.event.lifecycle;

import org.geysermc.event.Event;
import org.geysermc.event.PostOrder;
import org.geysermc.geyser.api.permission.PermissionChecker;

/**
* Fired by any permission manager implementations that wish to add support for custom permission checking.
* This event is not guaranteed to be fired - it is currently only fired on Geyser-Standalone and ViaProxy.
* <p>
* Subscribing to this event with an earlier {@link PostOrder} and registering a {@link PermissionChecker}
* will result in that checker having a higher priority than others.
*/
public interface GeyserRegisterPermissionCheckersEvent extends Event {

void register(PermissionChecker checker);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/

package org.geysermc.geyser.api.event.lifecycle;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.event.Event;
import org.geysermc.geyser.api.util.TriState;

/**
* Fired by anything that wishes to gather permission nodes and defaults.
* <p>
* This event is not guaranteed to be fired, as certain Geyser platforms do not have a native permission system.
Konicai marked this conversation as resolved.
Show resolved Hide resolved
* It can be expected to fire on Geyser-Spigot, Geyser-NeoForge and Geyser-Standalone.
* It may still be fired on other platforms due to a 3rd party.
*/
public interface GeyserRegisterPermissionsEvent extends Event {

/**
* Registers a permission node and its default value with the firer.
*
* @param permission the permission node to register
* @param defaultValue the default value of the node
*/
void register(@NonNull String permission, @NonNull TriState defaultValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ default ExtensionDescription description() {
return this.extensionLoader().description(this);
}

/**
* @return the root command that all of this extension's commands will stem from.
* By default, this is the extension's id.
*/
@NonNull
default String rootCommand() {
return this.description().id();
}

/**
* Gets the extension's logger
*
Expand Down
Loading