-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
base: master
Are you sure you want to change the base?
Cloud for commands #3808
Conversation
at least right now lol
bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java
Outdated
Show resolved
Hide resolved
...ocity/src/main/java/org/geysermc/geyser/platform/velocity/command/VelocityCommandSource.java
Show resolved
Hide resolved
any GeyserCommandSource should be valid to use in any CommandManager as long as one of the following is satisfied 1. it is a platform implementation 2. isConsole() returns true 2. playerUuid() returns a valid uuid and the player lookup succeeds
# Conflicts: # bootstrap/bungeecord/build.gradle.kts # bootstrap/spigot/build.gradle.kts # core/src/main/java/org/geysermc/geyser/command/GeyserCommandManager.java # core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockCommandRequestTranslator.java
# Conflicts: # bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/gui/GeyserStandaloneGUI.java
# Conflicts: # bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/GeyserFabricMod.java # bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/command/FabricCommandSource.java # bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/command/GeyserFabricCommandExecutor.java # bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java # core/src/main/java/org/geysermc/geyser/command/defaults/HelpCommand.java # core/src/main/java/org/geysermc/geyser/command/defaults/VersionCommand.java # core/src/main/resources/languages # gradle/libs.versions.toml
api/src/main/java/org/geysermc/geyser/api/permission/PermissionChecker.java
Show resolved
Hide resolved
core/src/main/java/org/geysermc/geyser/command/defaults/AdvancedTooltipsCommand.java
Outdated
Show resolved
Hide resolved
feeling kinda icky but idk
- create cloud earlier - trigger resource reload after geyser registers commands to cloud so that cloud registers them to the server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some thoughts that came to mind, looks good otherwise (skipped the NeoForge permission stuff, since well, that's known)
api/src/main/java/org/geysermc/geyser/api/event/lifecycle/GeyserRegisterPermissionsEvent.java
Outdated
Show resolved
Hide resolved
...forge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoForgeCommandRegistry.java
Outdated
Show resolved
Hide resolved
...ndalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneBootstrap.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/geysermc/geyser/command/CommandRegistry.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/geysermc/geyser/command/CommandRegistry.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/geysermc/geyser/command/defaults/DumpCommand.java
Show resolved
Hide resolved
core/src/main/java/org/geysermc/geyser/extension/command/GeyserExtensionCommand.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/geysermc/geyser/session/GeyserSession.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/geysermc/geyser/session/GeyserSession.java
Outdated
Show resolved
Hide resolved
# Conflicts: # bootstrap/mod/neoforge/src/main/java/org/geysermc/geyser/platform/neoforge/GeyserNeoForgeBootstrap.java # bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java # bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java # core/src/main/java/org/geysermc/geyser/session/GeyserSession.java # core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/BedrockCommandRequestTranslator.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nitpick; also the @NonNull
nature of the permission/permission default on the permission registration event doesn't seem to be enforced at the moment
core/src/main/java/org/geysermc/geyser/command/CommandRegistry.java
Outdated
Show resolved
Hide resolved
@@ -213,6 +218,7 @@ public void onGeyserEnable() { | |||
|
|||
GeyserImpl.start(); | |||
|
|||
|
|||
if (geyserConfig.isLegacyPingPassthrough()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove diff
VersionCheckUtils.checkForGeyserUpdate(() -> new ModCommandSender(stack)); | ||
ModCommandSource source = new ModCommandSource(player.createCommandSourceStack()); | ||
if (source.hasPermission(Permissions.CHECK_UPDATE)) { | ||
VersionCheckUtils.checkForGeyserUpdate(() -> source); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert but use source.getServer().getOperatorUserPermissionLevel()
instead of 2
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo
|
||
private final CommandSourceStack source; | ||
|
||
public ModCommandSender(CommandSourceStack source) { | ||
public ModCommandSource(CommandSourceStack source) { | ||
this.source = source; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
load geyser locale like other CommandSource implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the CommandSourceStack
doesn't expose a locale - Floodgate-Fabric for example always fallbacks to en_US as of now: https://github.com/GeyserMC/Floodgate-Fabric/blob/master/src/main/java/org/geysermc/floodgate/util/FabricCommandUtil.java#L43
public @NonNull S reverse(GeyserCommandSource source) throws IllegalArgumentException { | ||
Object handle = source.handle(); | ||
if (senderType.isInstance(handle)) { | ||
return senderType.cast(source); // one of the server platform implementations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handle not source, recent regression
bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java
Outdated
Show resolved
Hide resolved
|
||
private final CommandSourceStack source; | ||
|
||
public ModCommandSender(CommandSourceStack source) { | ||
public ModCommandSource(CommandSourceStack source) { | ||
this.source = source; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, the CommandSourceStack
doesn't expose a locale - Floodgate-Fabric for example always fallbacks to en_US as of now: https://github.com/GeyserMC/Floodgate-Fabric/blob/master/src/main/java/org/geysermc/floodgate/util/FabricCommandUtil.java#L43
* it yet to platforms like Velocity where we cannot natively specify a permission default. Doing so will | ||
* break setups as players would suddenly not have the required permission to execute any Geyser commands. | ||
*/ | ||
protected boolean applyRootPermission() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also be overridden on Standalone/ViaProxy/NeoForge
core/src/main/java/org/geysermc/geyser/command/GeyserCommand.java
Outdated
Show resolved
Hide resolved
}); | ||
this.commands.stream() | ||
.distinct() // remove aliases | ||
.filter(cmd -> !cmd.isBedrockOnly() || bedrockPlayer) // remove bedrock only commands if not a bedrock player |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small, unimportant nitpick: this might be a bit better as .filter(bedrockPlayer ? Predicates.alwaysTrue() : cmd -> !cmd.isBedrockOnly())
.
public abstract void execute(@Nullable GeyserSession session, GeyserCommandSource sender, String[] args); | ||
/** | ||
* The default value of the permission node. | ||
* A null value indicates that the permission node should not be registered whatsoever. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we document what each of the values means here, or link to another Javadoc where they are explained?
changes
GeyserCommandManager
has been renamed toCommandRegistry
GeyserCommandExecutor
and all subclasses have been removed in favour of Cloud.WorldManager#hasPermission
has been removed in favour of Cloud.permission node for the root command of Geyser and extensions, that is required to use any child commands
Spigot
GeyserBrigadierSupport
has been removed in favour of Cloud.Standalone/ViaProxy:
permissions.yml
has been added, a list of default permissions available to all players.Velocity/BungeeCord/Fabric/Standalone: commands are now registered before
GeyserPostInitializeEvent
, for consistency with Spigot, and to allow valid registration on Fabric.api changes:
deprecations
Command#isSuggestedOpOnly
and the relevant builder method have been deprecated for removalCommand#subCommands
has been deprecated for removal and will always returnCollections.emptyList()
Command#isExecutableOnConsole()
has been deprecated & replaced with#isPlayerOnly()
changes
Command#aliases()
now always returns an immutable listadditions
Command.Builder#permission(String, Tristate)
- register the permission and its default value to the server implementation if possible.CommandSource#playerUuid
- return a uuid if the source represents a player.CommandSource#connection
- return a Connection if the source represents a bedrock player managed by the current Geyser instance.GeyserRegisterPermissionCheckersEvent
- only used by Geyser-Standalone/ViaProxy. Fired when the command manager is created. Allows registeringPermissionChecker
s to the manager. Event listeners with a higher listener priority will register PermissionCheckers as having a higher priority.PermissionChecker
- api interface that is responsible for resolving a CommandSource and a permission node to a Tristate.GeyserRegisterPermissionsEvent
- fired by a server platform, or extension, or anything, when it is the proper time for permissions to be registered to the event caller. This event will be called by Geyser-Spigot/Standalone/Forge. An extension may also fire the event in order to register permissions to LuckPerms for Geyser-Velocity/BungeeCord/Fabric. Geyser's CommandRegistry will listen for this event, but api users may as well.future and separate PRs
todo:
permissions.yml
file for standalone/viaproxyisSuggestedOpOnly
is kind of problematic imo, in regards to its wording and the way it is used. it can probably just be deprecated in favour of optional permission registrationisExecutableOnConsole
orisBedrockOnly
with descriptive messages/geyser
is suppose to send help?handleNoPermission
command.failed
lang might be broken