Skip to content

Commit

Permalink
Add permissions support
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaCartes committed Dec 30, 2021
1 parent a41696e commit c5545f9
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 10 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
### 1.0.0 Minecraft 1.18

Add permission for all commands

* `easywhitelist.commands.easywhitelist.root`
* `easywhitelist.commands.easywhitelist.add`
* `easywhitelist.commands.easywhitelist.remove`
* `easywhitelist.commands.easypardon`
* `easywhitelist.commands.easyop`
* `easywhitelist.commands.easydeop`
* `easywhitelist.commands.easyban`

### 0.2.0 Minecraft 1.17.1, 1.18

Add offline version of some commands:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ be use at offline mode.
}
```

5) List of permissions:
* `easywhitelist.commands.easywhitelist.root`
* `easywhitelist.commands.easywhitelist.add`
* `easywhitelist.commands.easywhitelist.remove`
* `easywhitelist.commands.easypardon`
* `easywhitelist.commands.easyop`
* `easywhitelist.commands.easydeop`
* `easywhitelist.commands.easyban`

[Discord](https://discord.gg/UY4nhvUzaK)

[CurseForge](https://www.curseforge.com/minecraft/mc-mods/easywhitelist), [Modrinth](https://modrinth.com/mod/easywhitelist)
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {

repositories {
maven { name 'Jitpack'; url 'https://jitpack.io' }
maven { name "Permission"; url "https://oss.sonatype.org/content/repositories/snapshots"}
}

archivesBaseName = "${project.mod_id}-mc${project.minecraft_version}"
Expand All @@ -22,6 +23,9 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Permissions
modImplementation include("me.lucko:fabric-permissions-api:${project.fabric_permissions_version}")

// Mods
modImplementation include(fabricApi.module("fabric-command-api-v1", project.fabric_version));
modImplementation include(fabricApi.module("fabric-api-base", project.fabric_version));
Expand Down
11 changes: 6 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Mod
mod_name = EasyWhitelist
mod_id = easywhitelist
mod_version = 0.2.0
mod_version = 1.0.0

# Fabric
minecraft_version=1.18
yarn_mappings=1.18+build.1
loader_version=0.12.6
fabric_version=0.43.1+1.18
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.12
loader_version=0.12.12
fabric_version=0.45.0+1.18

# Dependencies
lazydfu_version = 0.1.2
fabric_permissions_version=0.1-SNAPSHOT

# Other
org.gradle.jvmargs=-Xmx1G
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.ServerCommandSource;

import me.lucko.fabric.api.permissions.v0.Permissions;

import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static com.mojang.brigadier.arguments.StringArgumentType.word;
import static net.minecraft.command.argument.MessageArgumentType.getMessage;
Expand All @@ -16,7 +18,7 @@ public class EasyBanCommand {

public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(literal("easyban")
.requires(source -> source.hasPermissionLevel(3))
.requires(Permissions.require("easywhitelist.commands.easyban", 3))
.then((argument("targets", word())
.executes(ctx ->
ban(ctx.getSource(), getProfileFromNickname(getString(ctx, "targets")), null)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.ServerCommandSource;

import me.lucko.fabric.api.permissions.v0.Permissions;

import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static com.mojang.brigadier.arguments.StringArgumentType.word;
import static net.minecraft.server.command.CommandManager.argument;
Expand All @@ -14,7 +16,7 @@ public class EasyDeOpCommand {

public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(literal("easydeop")
.requires(source -> source.hasPermissionLevel(3))
.requires(Permissions.require("easywhitelist.commands.easydeop", 4))
.then(argument("targets", word())
.executes(ctx ->
deop(ctx.getSource(), getProfileFromNickname(getString(ctx, "targets"))))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.ServerCommandSource;

import me.lucko.fabric.api.permissions.v0.Permissions;

import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static com.mojang.brigadier.arguments.StringArgumentType.word;
import static net.minecraft.server.command.CommandManager.argument;
Expand All @@ -14,7 +16,7 @@ public class EasyOpCommand {

public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(literal("easyop")
.requires(source -> source.hasPermissionLevel(3))
.requires(Permissions.require("easywhitelist.commands.easyop", 4))
.then(argument("targets", word())
.executes(ctx ->
op(ctx.getSource(), getProfileFromNickname(getString(ctx, "targets"))))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.ServerCommandSource;

import me.lucko.fabric.api.permissions.v0.Permissions;

import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static com.mojang.brigadier.arguments.StringArgumentType.word;
import static net.minecraft.server.command.CommandManager.argument;
Expand All @@ -14,7 +16,7 @@ public class EasyPardonCommand {

public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(literal("easypardon")
.requires(source -> source.hasPermissionLevel(3))
.requires(Permissions.require("easywhitelist.commands.easypardon", 3))
.then(argument("targets", word())
.executes(ctx ->
pardon(ctx.getSource(), getProfileFromNickname(getString(ctx, "targets"))))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.ServerCommandSource;

import me.lucko.fabric.api.permissions.v0.Permissions;

import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static com.mojang.brigadier.arguments.StringArgumentType.word;
import static net.minecraft.server.command.CommandManager.argument;
Expand All @@ -15,15 +17,17 @@ public class EasyWhitelistCommand {

public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(literal("easywhitelist")
.requires(source -> source.hasPermissionLevel(3))
.requires(Permissions.require("easywhitelist.commands.easywhitelist.root", 3))
.then(literal("add")
.requires(Permissions.require("easywhitelist.commands.easywhitelist.add", 3))
.then(argument("targets", word())
.executes(ctx ->
executeAdd(ctx.getSource(), getProfileFromNickname(getString(ctx, "targets")))
)
)
)
.then(literal("remove")
.requires(Permissions.require("easywhitelist.commands.easywhitelist.remove", 3))
.then(argument("targets", word())
.executes(ctx ->
executeRemove(ctx.getSource(), getProfileFromNickname(getString(ctx, "targets"))))
Expand Down

0 comments on commit c5545f9

Please sign in to comment.