Skip to content

Commit

Permalink
feat(command): 为各个指令的功能添加单独权限,修复接受指令错误的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Mar 17, 2023
1 parent 8c1a453 commit 4393cc9
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 160 deletions.
8 changes: 4 additions & 4 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ README LANGUAGES [ [中文](README.md) | [**English**](README-EN.md) ]

# MoeTeleport

[![CodeFactor](https://www.codefactor.io/repository/github/carm-outsource/MoeTeleport/badge?s=b76fec1f64726b5f19989aace6adb5f85fdab840)](https://www.codefactor.io/repository/github/carm-outsource/MoeTeleport)
![CodeSize](https://img.shields.io/github/languages/code-size/carm-outsource/MoeTeleport)
[![Download](https://img.shields.io/github/downloads/carm-outsource/MoeTeleport/total)](https://github.com/carm-outsource/MoeTeleport/releases)
[![Java CI with Maven](https://github.com/carm-outsource/MoeTeleport/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/carm-outsource/MoeTeleport/actions/workflows/maven.yml)
[![CodeFactor](https://www.codefactor.io/repository/github/CarmJos/MoeTeleport/badge?s=b76fec1f64726b5f19989aace6adb5f85fdab840)](https://www.codefactor.io/repository/github/CarmJos/MoeTeleport)
![CodeSize](https://img.shields.io/github/languages/code-size/CarmJos/MoeTeleport)
[![Download](https://img.shields.io/github/downloads/CarmJos/MoeTeleport/total)](https://github.com/CarmJos/MoeTeleport/releases)
[![Java CI with Maven](https://github.com/CarmJos/MoeTeleport/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/CarmJos/MoeTeleport/actions/workflows/maven.yml)
![Support](https://img.shields.io/badge/Minecraft-Java%201.13--Latest-blue)
![](https://visitor-badge.glitch.me/badge?page_id=moeteleport.readme)

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ README LANGUAGES [ [**中文**](README.md) | [English](README-EN.md) ]

# MoeTeleport 喵喵传送

[![CodeFactor](https://www.codefactor.io/repository/github/carm-outsource/MoeTeleport/badge?s=b76fec1f64726b5f19989aace6adb5f85fdab840)](https://www.codefactor.io/repository/github/carm-outsource/MoeTeleport)
![CodeSize](https://img.shields.io/github/languages/code-size/carm-outsource/MoeTeleport)
[![Download](https://img.shields.io/github/downloads/carm-outsource/MoeTeleport/total)](https://github.com/carm-outsource/MoeTeleport/releases)
[![Java CI with Maven](https://github.com/carm-outsource/MoeTeleport/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/carm-outsource/MoeTeleport/actions/workflows/maven.yml)
[![CodeFactor](https://www.codefactor.io/repository/github/CarmJos/MoeTeleport/badge?s=b76fec1f64726b5f19989aace6adb5f85fdab840)](https://www.codefactor.io/repository/github/CarmJos/MoeTeleport)
![CodeSize](https://img.shields.io/github/languages/code-size/CarmJos/MoeTeleport)
[![Download](https://img.shields.io/github/downloads/CarmJos/MoeTeleport/total)](https://github.com/CarmJos/MoeTeleport/releases)
[![Java CI with Maven](https://github.com/CarmJos/MoeTeleport/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/CarmJos/MoeTeleport/actions/workflows/maven.yml)
![Support](https://img.shields.io/badge/Minecraft-Java%201.13--Latest-blue)
![](https://visitor-badge.glitch.me/badge?page_id=moeteleport.readme)

Expand Down
30 changes: 16 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>

<deps.easyplugin.version>1.5.4</deps.easyplugin.version>
<deps.easyplugin.version>1.5.5</deps.easyplugin.version>
<deps.easysql.version>0.4.6</deps.easysql.version>
<deps.mineconfig.version>2.5.0</deps.mineconfig.version>
</properties>

<groupId>cc.carm.plugin</groupId>
<artifactId>moeteleport</artifactId>
<version>4.0.1</version>
<version>4.0.2</version>

<name>MoeTeleport</name>
<description>喵喵传送,简单的传送、设置家的插件。</description>
Expand All @@ -44,13 +44,6 @@
</developers>

<repositories>

<repository>
<id>carm-repo</id>
<name>Carm's Repo</name>
<url>https://repo.carm.cc/repository/maven-public/</url>
</repository>

<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
Expand Down Expand Up @@ -87,18 +80,19 @@
</repository>

<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/${project.name}</url>
<id>carm-repo</id>
<name>Carm's Repo</name>
<url>https://repo.carm.cc/repository/maven-public/</url>
</repository>

</repositories>

<distributionManagement>
<downloadUrl>https://github.com/CarmJos/MoeTeleport/releases</downloadUrl>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/${project.name}</url>
<url>https://maven.pkg.github.com/CarmJos/MoeTeleport</url>
</repository>
</distributionManagement>

Expand Down Expand Up @@ -128,6 +122,14 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-command-alias</artifactId>
<version>${deps.easyplugin.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-githubchecker</artifactId>
Expand Down Expand Up @@ -295,7 +297,7 @@
</execution>
</executions>
<configuration>
<finalName>${project.name}-${project.version}</finalName>
<finalName>MoeTeleport-${project.version}</finalName>
<outputDirectory>${project.basedir}/asset/</outputDirectory>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/cc/carm/plugin/moeteleport/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.easyplugin.EasyPlugin;
import cc.carm.lib.easyplugin.command.alias.AliasCommandManager;
import cc.carm.lib.easyplugin.updatechecker.GHUpdateChecker;
import cc.carm.lib.mineconfiguration.bukkit.MineConfiguration;
import cc.carm.plugin.moeteleport.command.MainCommands;
Expand All @@ -15,6 +16,7 @@
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
import xyz.xenondevs.particle.utils.ReflectionUtils;

public class Main extends EasyPlugin {
Expand All @@ -28,7 +30,7 @@ public class Main extends EasyPlugin {
protected UserManager userManager;
protected RequestManager requestManager;
protected TeleportManager teleportManager;
protected CommandManager commandManager;
protected AliasCommandManager commandManager;

public Main() {
instance = this;
Expand Down Expand Up @@ -85,14 +87,15 @@ protected boolean initialize() {
log("注册指令...");
registerCommand("MoeTeleport", new MainCommands(this));

try {
this.commandManager = new CommandManager(this);
if (PluginConfig.COMMAND.ENABLE.getNotNull()) {
if (PluginConfig.COMMAND.ENABLE.getNotNull()) {
log("注册简化指令映射...");
try {
this.commandManager = new AliasCommandManager(this);
PluginConfig.COMMAND.ALIAS.getNotNull().forEach(commandManager::register);
} catch (Exception e) {
log("注册简化指令失败: " + e.getMessage());
e.printStackTrace();
}
} catch (Exception e) {
log("注册简化指令失败: " + e.getMessage());
e.printStackTrace();
}

if (PluginConfig.METRICS.getNotNull()) {
Expand All @@ -116,8 +119,8 @@ protected boolean initialize() {

@Override
protected void shutdown() {
log("清空简化指令...");
if (this.commandManager != null) {
if (PluginConfig.COMMAND.ENABLE.getNotNull() && this.commandManager != null) {
log("清空简化指令...");
this.commandManager.unregisterAll();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) {
return null;
}

@Override
public boolean hasPermission(CommandSender sender) {
return sender.hasPermission("MoeTeleport.back");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ public Void noPermission(CommandSender sender) {
return main.noPermission(sender);
}

@Override
public boolean hasPermission(CommandSender sender) {
return sender.hasPermission("MoeTeleport.home");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) {

@Override
public boolean hasPermission(CommandSender sender) {
return sender.hasPermission("moeteleport.reload");
return sender.hasPermission("MoeTeleport.admin");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public TeleportCommands(@NotNull JavaPlugin plugin, @NotNull MainCommands main,

registerSubCommand(new TeleportRequestCommand(this, TeleportRequest.Type.TPA_TO, "to"));
registerSubCommand(new TeleportRequestCommand(this, TeleportRequest.Type.TPA_HERE, "here"));
registerSubCommand(new TeleportHandleCommand(this, true, "cancel"));
registerSubCommand(new TeleportHandleCommand(this, true, "accept", "agree"));
registerSubCommand(new TeleportHandleCommand(this, false, "deny", "refuse"));
registerSubCommand(new TeleportCancelCommand(this, "cancel"));
}
Expand All @@ -38,4 +38,9 @@ public Void noPermission(CommandSender sender) {
return main.noPermission(sender);
}

@Override
public boolean hasPermission(CommandSender sender) {
return sender.hasPermission("MoeTeleport.teleport");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ public Void noPermission(CommandSender sender) {
return main.noPermission(sender);
}


@Override
public boolean hasPermission(CommandSender sender) {
return sender.hasPermission("MoeTeleport.warp");
}

}
122 changes: 0 additions & 122 deletions src/main/java/cc/carm/plugin/moeteleport/manager/CommandManager.java

This file was deleted.

22 changes: 17 additions & 5 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,30 @@ softdepend:
- CMI

permissions:
"MoeTeleport":
description: "插件的主权限节点"
default: false

"MoeTeleport.admin":
description: "插件的管理员权限节点"
default: op

"MoeTeleport.teleport":
description: "使用传送请求相关指令的权限。"
default: true

"MoeTeleport.home":
description: "使用家相关指令的权限。"
default: true

"MoeTeleport.warp":
description: "使用传送请求相关指令的权限。"
default: true

"MoeTeleport.back":
description: "使用返回相关指令的权限。"
default: true

commands:
"MoeTeleport":
description: "插件的主命令,用于重载插件或查看插件信息。"
permission: "MoeTeleport.admin"
usage: "/MoeTeleport reload"
usage: "您可以输入 /MoeTeleport help 查看插件的相关帮助。"
aliases:
- mt

0 comments on commit 4393cc9

Please sign in to comment.