-
Notifications
You must be signed in to change notification settings - Fork 40
Vanilla Commands Rework and Additions #65
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
Open
wi1helm
wants to merge
7
commits into
Minestom:master
Choose a base branch
from
wi1helm:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cec0598
Added/Reworked Vanilla Commands (Begining)
wi1helm f8a7893
Vanilla Commands Rework #2
wi1helm adee5de
Vanilla Commands Rework (#3)
wi1helm 2896960
Msg, tell, w commands and java doc
wi1helm 8d26658
Made @a selector work for msg command
wi1helm e59b697
Removed world:)
wi1helm b91ec02
Translation Key update
wi1helm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
51 changes: 0 additions & 51 deletions
51
commands/src/main/java/net/minestom/vanilla/commands/DifficultyCommand.java
This file was deleted.
Oops, something went wrong.
128 changes: 0 additions & 128 deletions
128
commands/src/main/java/net/minestom/vanilla/commands/GamemodeCommand.java
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
commands/src/main/java/net/minestom/vanilla/commands/HelpCommand.java
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
commands/src/main/java/net/minestom/vanilla/commands/SaveAllCommand.java
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
commands/src/main/java/net/minestom/vanilla/commands/StopCommand.java
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
commands/src/main/java/net/minestom/vanilla/commands/VanillaCommand.java
This file contains hidden or 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,68 @@ | ||
| package net.minestom.vanilla.commands; | ||
|
|
||
| import net.kyori.adventure.text.Component; | ||
| import net.minestom.server.command.CommandSender; | ||
| import net.minestom.server.command.ConsoleSender; | ||
| import net.minestom.server.command.builder.Command; | ||
| import net.minestom.server.command.builder.CommandContext; | ||
| import net.minestom.server.command.builder.condition.CommandCondition; | ||
| import net.minestom.server.entity.Player; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** | ||
| * Abstract base class for Vanilla commands. | ||
| * Includes permission level handling and shared utility methods. | ||
| */ | ||
| public abstract class VanillaCommand extends Command { | ||
|
|
||
| public final int LEVEL_ALL = 0; | ||
| public final int LEVEL_MODERATOR = 1; | ||
| public final int LEVEL_GAMEMASTER = 2; | ||
| public final int LEVEL_ADMIN = 3; | ||
| public final int LEVEL_OWNER = 4; | ||
|
|
||
| public VanillaCommand(@NotNull String name, @Nullable String... aliases) { | ||
| super(name, aliases); | ||
| } | ||
|
|
||
| public VanillaCommand(@NotNull String name) { | ||
| super(name); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the usage message for this command, required and used for /help command. | ||
| * | ||
| * @param sender the command sender | ||
| * @param context the command context | ||
| * @return the usage message as a Component | ||
| */ | ||
| public abstract Component usage(CommandSender sender, CommandContext context); | ||
|
|
||
| protected abstract void defaultor(CommandSender sender, CommandContext context); | ||
|
|
||
| /** | ||
| * Creates a command condition that checks if the sender has the required permission level. | ||
| * Console senders are always allowed. | ||
| * | ||
| * @param level the required permission level | ||
| * @return the command condition | ||
| */ | ||
| public CommandCondition permission(int level) { | ||
| return (sender, commandName) -> { | ||
| if (sender instanceof ConsoleSender) return true; | ||
| if (sender instanceof Player player) return player.getPermissionLevel() >= level; | ||
| return false; | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Checks whether the command was invoked without any arguments. | ||
| * | ||
| * @param context the command context | ||
| * @return true if no arguments were given, false otherwise | ||
| */ | ||
| public boolean hasNoArguments(CommandContext context) { | ||
| return context.getCommandName().equals(context.getInput()); | ||
| } | ||
| } | ||
40 changes: 0 additions & 40 deletions
40
commands/src/main/java/net/minestom/vanilla/commands/VanillaCommands.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this should be a static constant