Skip to content
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

将判断是否是op改为是否有对应的权限节点 #39

Merged
merged 4 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AddRouteSubCommand(String name) {

@Override
public boolean canUser(CommandSender sender) {
return sender.isPlayer() && sender.isOp();
return sender.isPlayer() && sender.hasPermission("RsNPC.admin.addroute");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public CreateSubCommand(String name) {

@Override
public boolean canUser(CommandSender sender) {
return sender.isPlayer() && sender.isOp();
return sender.isPlayer() && sender.hasPermission("RsNPC.admin.create");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public DeleteSubCommand(String name) {

@Override
public boolean canUser(CommandSender sender) {
return sender.isOp();
return sender.hasPermission("RsNPC.admin.delete");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ReloadSubCommand(String name) {

@Override
public boolean canUser(CommandSender sender) {
return sender.isOp();
return sender.hasPermission("RsNPC.admin.reload");
}

@Override
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/com/smallaswater/npc/utils/FormHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ public static void sendMain(@NotNull Player player) {
simple.setContent(getRandomMessage() + "\n\n");
}

simple.addButton(new ResponseElementButton(language.translateString("gui.main.button.createNPCText")).onClicked(FormHelper::sendCreateNpc));
simple.addButton(new ResponseElementButton(language.translateString("gui.main.button.adminNPCText")).onClicked(FormHelper::sendAdminNpcSelect));
simple.addButton(new ResponseElementButton(language.translateString("gui.main.button.reloadText"))
.onClicked(cp -> Server.getInstance().dispatchCommand(cp, "rsnpc reload"))
);
if (player.hasPermission("RsNPC.admin.create")) {
simple.addButton(new ResponseElementButton(language.translateString("gui.main.button.createNPCText")).onClicked(FormHelper::sendCreateNpc));
if (player.hasPermission("RsNPC.admin.delete")) {
simple.addButton(new ResponseElementButton(language.translateString("gui.main.button.adminNPCText")).onClicked(FormHelper::sendAdminNpcSelect));
}
}
if (player.hasPermission("RsNPC.admin.reload")) {
simple.addButton(new ResponseElementButton(language.translateString("gui.main.button.reloadText"))
.onClicked(cp -> Server.getInstance().dispatchCommand(cp, "rsnpc reload"))
);
}

player.showFormWindow(simple);
}
Expand Down
14 changes: 13 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@ softdepend:
permissions:
RsNPC.admin:
default: op
description: "RsNPC插件主命令"
description: "RsNPC 插件主命令"
RsNPC.admin.create:
default: op
description: "RsNPC 创建NPC命令"
RsNPC.admin.delete:
default: op
description: "RsNPC 删除NPC命令"
RsNPC.admin.reload:
default: op
description: "RsNPC 重载配置文件命令"
RsNPC.admin.addroute:
default: op
description: "RsNPC 添加NPC移动路径命令"
Loading