Skip to content

Commit

Permalink
Add NeedPermissionAction
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Nov 23, 2024
1 parent 5201ab6 commit 78eaff0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package de.oliver.fancynpcs.api.actions.types;

import de.oliver.fancynpcs.api.actions.NpcAction;
import de.oliver.fancynpcs.api.actions.executor.ActionExecutionContext;

public class NeedPermissionAction extends NpcAction {

public NeedPermissionAction() {
super("need_permission", true);
}

@Override
public void execute(ActionExecutionContext context, String value) {
if (value == null || value.isEmpty()) {
return;
}

if (context.getPlayer() == null) {
return;
}

if (!context.getPlayer().hasPermission(value)) {
context.terminate();
}
}
}
1 change: 1 addition & 0 deletions src/main/java/de/oliver/fancynpcs/FancyNpcs.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public void onEnable() {
actionManager.registerAction(new WaitAction());
actionManager.registerAction(new ExecuteRandomActionAction());
actionManager.registerAction(new BlockUntilDoneAction());
actionManager.registerAction(new NeedPermissionAction());

skinCache = new SkinCacheYaml();
skinCache.loadAndInsertToSkinFetcher();
Expand Down

0 comments on commit 78eaff0

Please sign in to comment.