This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
generated from MinestomPlugins/minestom-library-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit b05d770.
- Loading branch information
Window5
authored and
Window5
committed
Jan 19, 2023
1 parent
b05d770
commit be39400
Showing
36 changed files
with
745 additions
and
803 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
rootProject.name = 'HypeStom' | ||
rootProject.name = 'HypeLib' | ||
|
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,63 @@ | ||
package org.hypejet.hype.command; | ||
|
||
import org.hypejet.hype.permission.PermissionProvider; | ||
import org.hypejet.hype.permission.SubPermission; | ||
import net.minestom.server.command.CommandSender; | ||
import net.minestom.server.command.ConsoleSender; | ||
import net.minestom.server.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Normal Command witch also uses extra permission features. | ||
*/ | ||
public class Command extends net.minestom.server.command.builder.Command { | ||
|
||
/** | ||
* The permission provider for this command | ||
* @see SubPermission | ||
*/ | ||
protected SubPermission provider; | ||
|
||
/** | ||
* Creates a new command. | ||
* Default permissions the extension's permissions with the command name as a subpermission. | ||
* | ||
* @param provider PermissionsProvider, automatically set in the Extension class. | ||
* @param name Name of the command SubPermission will be automatically created with this name. | ||
* @param aliases Nullable, aliases to the command that the CommandSenders can also run to execute the command. | ||
*<br> | ||
* <br> | ||
* See also:<br> | ||
* {@link Command#setPermission(String)} | ||
*/ | ||
public Command(@NotNull PermissionProvider provider, @NotNull String name, @Nullable String... aliases) { | ||
super(name, aliases); | ||
this.provider = new SubPermission(provider, name); | ||
setPermission(name); | ||
setCondition(this::defaultCondition); | ||
} | ||
|
||
/** | ||
* Sets the subcommand permission. | ||
* @param permission The permission to be used | ||
*/ | ||
public void setPermission(String permission) { | ||
provider.updatePermissions(permission); | ||
} | ||
|
||
/** | ||
* Set the required permissions level required for bypassing permissions. | ||
* @param level The new op level | ||
*/ | ||
public void setPermissionLevel(int level) { | ||
provider.setOpLevel(level); | ||
} | ||
|
||
/** | ||
* Gives the sender access if it is either a console or if it has the command permission. | ||
*/ | ||
protected boolean defaultCondition(CommandSender sender, String command) { | ||
return sender instanceof ConsoleSender || provider.hasPermission((Player) sender); | ||
} | ||
} |
Oops, something went wrong.