mirror of
https://github.com/CarmJos/MoeTeleport.git
synced 2026-06-04 16:46:10 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4393cc9ce2 | |||
| 8c1a4530c0 | |||
| 21e3fc1674 | |||
| b35ac8e4c4 | |||
| 0d1fdccb79 | |||
| f728d1f7e6 | |||
| cb76e86b80 |
+155
@@ -0,0 +1,155 @@
|
||||
```text
|
||||
__ ___ ______ __ __
|
||||
/ |/ /__ __/_ __/__ / /__ ___ ___ ____/ /_
|
||||
/ /|_/ / _ \/ -_) / / -_) / -_) _ \/ _ \/ __/ __/
|
||||
/_/ /_/\___/\__/_/ \__/_/\__/ .__/\___/_/ \__/
|
||||
/_/
|
||||
```
|
||||
README LANGUAGES [ [中文](README.md) | [**English**](README-EN.md) ]
|
||||
|
||||
# MoeTeleport
|
||||
|
||||
[](https://www.codefactor.io/repository/github/CarmJos/MoeTeleport)
|
||||

|
||||
[](https://github.com/CarmJos/MoeTeleport/releases)
|
||||
[](https://github.com/CarmJos/MoeTeleport/actions/workflows/maven.yml)
|
||||

|
||||

|
||||
|
||||
MoeTeleport is an open source delivery plugin that contains several features and will be always updated to add new features based on users' requirements.
|
||||
|
||||
The project code conforms to the development specifications and is suitable for new developers to learn Bukkit and make their own plugins.
|
||||
|
||||
## Functions and advantages
|
||||
|
||||
### Current functions
|
||||
|
||||
- Multiple storage formats, select on demand.
|
||||
- Support YAML, JSON and MySQL/MariaDB storage
|
||||
- Support direct call [EssentialsX] (https://github.com/EssentialsX/Essentials)/CMI data, Seamless switching
|
||||
- Clickable messages (such as "Click-Agree")
|
||||
- Based on the MineDown syntax, Customizable configuration
|
||||
- Teleport requests between players
|
||||
- Support to specify handling a player's request
|
||||
- Set warp locations
|
||||
- Support to set a different number of warp locations as VIP add-on content based on permissions
|
||||
- Set home locations (understood as private warps)
|
||||
- Support setting different number of homes according to permissions as VIP add-on content
|
||||
- Return to the place of death and the last location
|
||||
|
||||
### Advantages
|
||||
|
||||
- ** Lightweight plugin. ** Suitable for small servers, simple and convenient configuration.
|
||||
- ** Specification development. ** Plugin architecture conforms to development specifications, suitable for new developers to learn.
|
||||
- EasyPlugin has been used since [3.0.0]() and may be somewhat different from other mainstream plugin structures.
|
||||
- ** Continuous maintenance. ** All new functional requirements can be submitted, which is likely to be supported in the subsequent development.
|
||||
- Functional requirements please [submit Issues] (HTTP: / / https://github.com/CarmJos/MoeTeleport/issues/new?assignees=&labels=enhancement&template=feature issues.md&title=), do not submit in the post!
|
||||
- Submitting requests associated with "teleport" will most likely be updated and supported.
|
||||
|
||||
## [Dependencies](https://github.com/CarmJos/MoeTeleport/network/dependencies)
|
||||
|
||||
- **[Necessary]** The plugin is based on [Spigot-API](https://hub.spigotmc.org/stash/projects/SPIGOT) 、[BukkitAPI](http://bukkit.org/).
|
||||
- **[Included]** Message format is based on [MineDown](https://github.com/Phoenix616/MineDown).
|
||||
- All messages.yml support MineDown syntax。
|
||||
- **[Recommended]** The variable part is based on [PlaceholderAPI](https://www.spigotmc.org/resources/6245/).
|
||||
|
||||
Read this if you need more details. [Dependencies](https://github.com/CarmJos/MoeTeleport/network/dependencies).
|
||||
|
||||
## [Commands](src/main/resources/plugin.yml)
|
||||
|
||||
The main command is `/MoeTeleport` or `/mt`.
|
||||
|
||||
All commands in this plugin support configuration of "simplified commands",
|
||||
such as allowing the player to directly input '/back' and execute '/MoeTeleport back', see [configuration](#Config) related content.
|
||||
|
||||
- Required parameter '< Parameter >'
|
||||
- Optional parameter '[parameter]'
|
||||
|
||||
```text
|
||||
# reload
|
||||
@ Admin command (MoeTeleport.admin)
|
||||
- Reload the plugin configuration file.
|
||||
|
||||
# back
|
||||
- Return to the last location.
|
||||
|
||||
----- [Teleport commands] -----
|
||||
|
||||
# teleport to <target player>
|
||||
- Request to teleport to target player's location.
|
||||
|
||||
# teleport here <target player>
|
||||
- Request the target player to teleport to their location.
|
||||
|
||||
# teleport accept [target player]
|
||||
- Grant a teleport request (player requests can be specified).
|
||||
|
||||
# teleport deny [target player].
|
||||
- Reject a teleport request (player requests can be specified).
|
||||
|
||||
----- [Home commands] -----
|
||||
|
||||
# home to [home name]
|
||||
- Send to the specified home.
|
||||
- If you do not fill in the specific home, return to the first set of home.
|
||||
- If there is a home named "home", return to "home" preferentially.
|
||||
|
||||
# home list
|
||||
- List all the home names.
|
||||
|
||||
# home set [home name]
|
||||
- Set a home location.
|
||||
- If you do not specify the name of home, the default value is "home".
|
||||
|
||||
# home delete [home name]
|
||||
-Delete a home location
|
||||
|
||||
|
||||
----- [Warp commands] -----
|
||||
|
||||
# warp to <warp name>
|
||||
- Teleport to the specified location.
|
||||
|
||||
# warp list
|
||||
- List all current warp locations.
|
||||
|
||||
# warp set <warp name>
|
||||
- Set a warp location.
|
||||
- If the warp already exists and you are the owner (or the server administrator) of the warp,
|
||||
- the old warp point will be overwritten.
|
||||
|
||||
# warp delete <Warp name>
|
||||
- Delete one of your own warps
|
||||
|
||||
```
|
||||
|
||||
## Config
|
||||
|
||||
### Plugin configuration file ([config.yml]())
|
||||
|
||||
Read source file for more details.
|
||||
|
||||
### Message configuration file ([messages.yml]())
|
||||
|
||||
Support [MineDown syntax](https://wiki.phoenix616.dev/library:minedown:syntax)
|
||||
|
||||
Read source file for more details.
|
||||
|
||||
## Usage statistics
|
||||
|
||||
[](https://bstats.org/plugin/bukkit/MoeTeleport/14459)
|
||||
|
||||
## Support and donate
|
||||
|
||||
If you find this plugin helps, you can donate to support me. Thank you for being a supporter of this open source project!
|
||||
|
||||
Sincere thanks to the following friends who support the development of this project:
|
||||
- This plugin is entrusted by [**璎珞 **](https://www.yingluo.world/) server , authorized already.
|
||||
- Thank you to [**XingMC**(MagicMC server developer)](https://www.mcbbs.net/?4816320) for funding the subsequent development of this plugin.
|
||||
|
||||
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
|
||||
[](https://www.jetbrains.com/?from=https://github.com/CarmJos/UserPrefix)
|
||||
|
||||
## Open source agreement
|
||||
|
||||
The source code of this project uses [GNU General Public License v3.0](https://opensource.org/licenses/GPL-3.0) License.
|
||||
@@ -5,13 +5,14 @@
|
||||
/_/ /_/\___/\__/_/ \__/_/\__/ .__/\___/_/ \__/
|
||||
/_/
|
||||
```
|
||||
README LANGUAGES [ [**中文**](README.md) | [English](README-EN.md) ]
|
||||
|
||||
# MoeTeleport 喵喵传送
|
||||
|
||||
[](https://www.codefactor.io/repository/github/carm-outsource/MoeTeleport)
|
||||

|
||||
[](https://github.com/carm-outsource/MoeTeleport/releases)
|
||||
[](https://github.com/carm-outsource/MoeTeleport/actions/workflows/maven.yml)
|
||||
[](https://www.codefactor.io/repository/github/CarmJos/MoeTeleport)
|
||||

|
||||
[](https://github.com/CarmJos/MoeTeleport/releases)
|
||||
[](https://github.com/CarmJos/MoeTeleport/actions/workflows/maven.yml)
|
||||

|
||||

|
||||
|
||||
@@ -124,11 +125,11 @@
|
||||
|
||||
## 配置
|
||||
|
||||
### 插件配置文件 ([config.yml](src/main/resources/config.yml))
|
||||
### 插件配置文件 ([config.yml]())
|
||||
|
||||
详见源文件。
|
||||
|
||||
### 消息配置文件 ([messages.yml](src/main/resources/messages.yml))
|
||||
### 消息配置文件 ([messages.yml]())
|
||||
|
||||
支持 [MineDown 语法](https://wiki.phoenix616.dev/library:minedown:syntax),详见源文件。
|
||||
|
||||
@@ -144,6 +145,9 @@
|
||||
- 本插件由 [**璎珞**服务器](https://www.yingluo.world/) 委托本人开发,经过授权后开源。
|
||||
- 感谢 [**XingMC**(MagicMC服务器开发者)](https://www.mcbbs.net/?4816320) 为本插件提供后续开发的资金赞助。
|
||||
|
||||
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
|
||||
[](https://www.jetbrains.com/?from=https://github.com/CarmJos/UserPrefix)
|
||||
|
||||
## 开源协议
|
||||
|
||||
本项目源码采用 [GNU General Public License v3.0](https://opensource.org/licenses/GPL-3.0) 开源协议。
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
||||
|
||||
<deps.easyplugin.version>1.4.19</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.3.1</deps.mineconfig.version>
|
||||
<deps.mineconfig.version>2.5.0</deps.mineconfig.version>
|
||||
</properties>
|
||||
|
||||
<groupId>cc.carm.plugin</groupId>
|
||||
<artifactId>moeteleport</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<version>4.0.2</version>
|
||||
|
||||
<name>MoeTeleport</name>
|
||||
<description>喵喵传送,简单的传送、设置家的插件。</description>
|
||||
@@ -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>
|
||||
@@ -87,10 +80,11 @@
|
||||
</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>
|
||||
@@ -98,7 +92,7 @@
|
||||
<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>
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -2,6 +2,7 @@ package cc.carm.plugin.moeteleport;
|
||||
|
||||
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;
|
||||
@@ -15,6 +16,7 @@ import cc.carm.plugin.moeteleport.storage.StorageMethod;
|
||||
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 {
|
||||
@@ -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;
|
||||
@@ -85,15 +87,16 @@ public class Main extends EasyPlugin {
|
||||
log("注册指令...");
|
||||
registerCommand("MoeTeleport", new MainCommands(this));
|
||||
|
||||
try {
|
||||
this.commandManager = new CommandManager(this);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
if (PluginConfig.METRICS.getNotNull()) {
|
||||
log("启用统计数据...");
|
||||
@@ -116,8 +119,8 @@ public class Main extends EasyPlugin {
|
||||
|
||||
@Override
|
||||
protected void shutdown() {
|
||||
if (PluginConfig.COMMAND.ENABLE.getNotNull() && this.commandManager != null) {
|
||||
log("清空简化指令...");
|
||||
if (this.commandManager != null) {
|
||||
this.commandManager.unregisterAll();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cc.carm.plugin.moeteleport.command;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.CommandHandler;
|
||||
import cc.carm.plugin.moeteleport.command.parent.*;
|
||||
import cc.carm.plugin.moeteleport.command.sub.*;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package cc.carm.plugin.moeteleport.command.sub;
|
||||
package cc.carm.plugin.moeteleport.command.base;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.SubCommand;
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.storage.UserData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package cc.carm.plugin.moeteleport.command.sub;
|
||||
package cc.carm.plugin.moeteleport.command.base;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.SubCommand;
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.storage.UserData;
|
||||
import cc.carm.plugin.moeteleport.teleport.TeleportRequest;
|
||||
import org.bukkit.Bukkit;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package cc.carm.plugin.moeteleport.command.sub;
|
||||
package cc.carm.plugin.moeteleport.command.base;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.SubCommand;
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.manager.WarpManager;
|
||||
import cc.carm.plugin.moeteleport.model.WarpInfo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
+6
-1
@@ -1,4 +1,4 @@
|
||||
package cc.carm.plugin.moeteleport.command.parent;
|
||||
package cc.carm.plugin.moeteleport.command.sub;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.SubCommand;
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
@@ -39,4 +39,9 @@ public class BackCommand extends SubCommand<MainCommands> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.hasPermission("MoeTeleport.back");
|
||||
}
|
||||
|
||||
}
|
||||
+8
-5
@@ -1,11 +1,8 @@
|
||||
package cc.carm.plugin.moeteleport.command.parent;
|
||||
package cc.carm.plugin.moeteleport.command.sub;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.CommandHandler;
|
||||
import cc.carm.plugin.moeteleport.command.MainCommands;
|
||||
import cc.carm.plugin.moeteleport.command.home.HomeCreateCommand;
|
||||
import cc.carm.plugin.moeteleport.command.home.HomeDeleteCommand;
|
||||
import cc.carm.plugin.moeteleport.command.home.HomeListCommand;
|
||||
import cc.carm.plugin.moeteleport.command.home.HomeTeleportCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.home.*;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginConfig;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -26,6 +23,7 @@ public class HomeCommands extends CommandHandler {
|
||||
registerSubCommand(new HomeListCommand(this, "list", "ls"));
|
||||
registerSubCommand(new HomeCreateCommand(this, "set", "create"));
|
||||
registerSubCommand(new HomeDeleteCommand(this, "delete", "remove", "del"));
|
||||
registerSubCommand(new HomeRenameCommand(this, "rename", "rn"));
|
||||
}
|
||||
|
||||
|
||||
@@ -50,4 +48,9 @@ public class HomeCommands extends CommandHandler {
|
||||
return main.noPermission(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.hasPermission("MoeTeleport.home");
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package cc.carm.plugin.moeteleport.command.parent;
|
||||
package cc.carm.plugin.moeteleport.command.sub;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.SubCommand;
|
||||
import cc.carm.plugin.moeteleport.Main;
|
||||
@@ -35,7 +35,7 @@ public class ReloadCommand extends SubCommand<MainCommands> {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.hasPermission("moeteleport.reload");
|
||||
return sender.hasPermission("MoeTeleport.admin");
|
||||
}
|
||||
|
||||
}
|
||||
+10
-5
@@ -1,10 +1,10 @@
|
||||
package cc.carm.plugin.moeteleport.command.parent;
|
||||
package cc.carm.plugin.moeteleport.command.sub;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.CommandHandler;
|
||||
import cc.carm.plugin.moeteleport.command.MainCommands;
|
||||
import cc.carm.plugin.moeteleport.command.teleport.TeleportCancelCommand;
|
||||
import cc.carm.plugin.moeteleport.command.teleport.TeleportHandleCommand;
|
||||
import cc.carm.plugin.moeteleport.command.teleport.TeleportRequestCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.teleport.TeleportCancelCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.teleport.TeleportHandleCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.teleport.TeleportRequestCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.teleport.TeleportRequest;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -22,7 +22,7 @@ public class TeleportCommands extends CommandHandler {
|
||||
|
||||
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"));
|
||||
}
|
||||
@@ -38,4 +38,9 @@ public class TeleportCommands extends CommandHandler {
|
||||
return main.noPermission(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.hasPermission("MoeTeleport.teleport");
|
||||
}
|
||||
|
||||
}
|
||||
+9
-2
@@ -1,8 +1,8 @@
|
||||
package cc.carm.plugin.moeteleport.command.parent;
|
||||
package cc.carm.plugin.moeteleport.command.sub;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.CommandHandler;
|
||||
import cc.carm.plugin.moeteleport.command.MainCommands;
|
||||
import cc.carm.plugin.moeteleport.command.warp.*;
|
||||
import cc.carm.plugin.moeteleport.command.sub.warp.*;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginConfig;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -24,6 +24,7 @@ public class WarpCommands extends CommandHandler {
|
||||
registerSubCommand(new WarpInfoCommand(this, "info", "i"));
|
||||
registerSubCommand(new WarpCreateCommand(this, "set", "create"));
|
||||
registerSubCommand(new WarpDeleteCommand(this, "delete", "remove", "del"));
|
||||
registerSubCommand(new WarpRenameCommand(this, "rename", "rn"));
|
||||
|
||||
}
|
||||
|
||||
@@ -48,4 +49,10 @@ public class WarpCommands extends CommandHandler {
|
||||
return main.noPermission(sender);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.hasPermission("MoeTeleport.warp");
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package cc.carm.plugin.moeteleport.command.home;
|
||||
package cc.carm.plugin.moeteleport.command.sub.home;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.SimpleCompleter;
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.HomeSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.conf.location.DataLocation;
|
||||
import cc.carm.plugin.moeteleport.storage.UserData;
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cc.carm.plugin.moeteleport.command.home;
|
||||
package cc.carm.plugin.moeteleport.command.sub.home;
|
||||
|
||||
import cc.carm.plugin.moeteleport.command.parent.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.HomeSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.conf.location.DataLocation;
|
||||
import cc.carm.plugin.moeteleport.storage.UserData;
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cc.carm.plugin.moeteleport.command.home;
|
||||
package cc.carm.plugin.moeteleport.command.sub.home;
|
||||
|
||||
import cc.carm.plugin.moeteleport.command.parent.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.HomeSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.storage.UserData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -0,0 +1,71 @@
|
||||
package cc.carm.plugin.moeteleport.command.sub.home;
|
||||
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.HomeSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.conf.location.DataLocation;
|
||||
import cc.carm.plugin.moeteleport.storage.UserData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class HomeRenameCommand extends HomeSubCommand {
|
||||
|
||||
public HomeRenameCommand(@NotNull HomeCommands parent, String name, String... aliases) {
|
||||
super(parent, name, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) throws Exception {
|
||||
if (!(sender instanceof Player)) {
|
||||
PluginMessages.NOT_PLAYER.send(sender);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (args.length < 2) return getParent().noArgs(sender);
|
||||
|
||||
String homeName = args[0];
|
||||
String newName = args[1];
|
||||
|
||||
if (homeName.equals(newName)) return getParent().noArgs(sender);
|
||||
if (newName.length() > 32) { // 超过家的名字长度限定
|
||||
PluginMessages.HOME.NAME_TOO_LONG.send(sender);
|
||||
return null;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
UserData data = getData(player);
|
||||
|
||||
Map.Entry<String, DataLocation> locationInfo = data.getHomeLocation(homeName);
|
||||
if (locationInfo == null) {
|
||||
PluginMessages.HOME.NOT_FOUND.send(player);
|
||||
return null;
|
||||
}
|
||||
|
||||
Map.Entry<String, DataLocation> newInfo = data.getHomeLocation(newName);
|
||||
if (newInfo != null) {
|
||||
PluginMessages.HOME.ALREADY_EXITS.send(player);
|
||||
return null;
|
||||
}
|
||||
|
||||
PluginMessages.HOME.RENAMED.send(player, newName, locationInfo.getKey());
|
||||
|
||||
data.setHomeLocation(newName, locationInfo.getValue().getBukkitLocation());
|
||||
data.delHomeLocation(homeName);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(JavaPlugin plugin, CommandSender sender, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return listHomes(sender, args[args.length - 1]);
|
||||
} else return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package cc.carm.plugin.moeteleport.command.home;
|
||||
package cc.carm.plugin.moeteleport.command.sub.home;
|
||||
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.HomeCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.HomeSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.conf.location.DataLocation;
|
||||
import cc.carm.plugin.moeteleport.storage.UserData;
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package cc.carm.plugin.moeteleport.command.teleport;
|
||||
package cc.carm.plugin.moeteleport.command.sub.teleport;
|
||||
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.TeleportSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.TeleportSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.teleport.TeleportRequest;
|
||||
import org.bukkit.command.CommandSender;
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package cc.carm.plugin.moeteleport.command.teleport;
|
||||
package cc.carm.plugin.moeteleport.command.sub.teleport;
|
||||
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.TeleportSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.TeleportSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.storage.UserData;
|
||||
import cc.carm.plugin.moeteleport.teleport.TeleportRequest;
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cc.carm.plugin.moeteleport.command.teleport;
|
||||
package cc.carm.plugin.moeteleport.command.sub.teleport;
|
||||
|
||||
import cc.carm.plugin.moeteleport.command.parent.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.TeleportSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.TeleportSubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package cc.carm.plugin.moeteleport.command.teleport;
|
||||
package cc.carm.plugin.moeteleport.command.sub.teleport;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.SimpleCompleter;
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.TeleportSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.TeleportCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.TeleportSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.teleport.TeleportRequest;
|
||||
import org.bukkit.Bukkit;
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package cc.carm.plugin.moeteleport.command.warp;
|
||||
package cc.carm.plugin.moeteleport.command.sub.warp;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.SimpleCompleter;
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.model.WarpInfo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cc.carm.plugin.moeteleport.command.warp;
|
||||
package cc.carm.plugin.moeteleport.command.sub.warp;
|
||||
|
||||
import cc.carm.plugin.moeteleport.command.parent.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.model.WarpInfo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package cc.carm.plugin.moeteleport.command.warp;
|
||||
package cc.carm.plugin.moeteleport.command.sub.warp;
|
||||
|
||||
import cc.carm.plugin.moeteleport.command.parent.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.model.WarpInfo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package cc.carm.plugin.moeteleport.command.warp;
|
||||
package cc.carm.plugin.moeteleport.command.sub.warp;
|
||||
|
||||
import cc.carm.lib.easyplugin.command.SimpleCompleter;
|
||||
import cc.carm.plugin.moeteleport.command.parent.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.model.WarpInfo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -0,0 +1,71 @@
|
||||
package cc.carm.plugin.moeteleport.command.sub.warp;
|
||||
|
||||
import cc.carm.plugin.moeteleport.Main;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.model.WarpInfo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class WarpRenameCommand extends WarpSubCommand {
|
||||
|
||||
public WarpRenameCommand(@NotNull WarpCommands parent, String name, String... aliases) {
|
||||
super(parent, name, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) throws Exception {
|
||||
if (!(sender instanceof Player)) {
|
||||
PluginMessages.NOT_PLAYER.send(sender);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (args.length < 2) return getParent().noArgs(sender);
|
||||
|
||||
String oldName = args[0];
|
||||
String newName = args[1];
|
||||
|
||||
if (oldName.equals(newName)) return getParent().noArgs(sender);
|
||||
if (newName.length() > 16) { // 超过地标的名字长度限定
|
||||
PluginMessages.WARP.NAME_TOO_LONG.send(sender);
|
||||
return null;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
|
||||
WarpInfo info = getWarp(oldName);
|
||||
if (info == null) {
|
||||
PluginMessages.WARP.NOT_FOUND.send(player);
|
||||
return null;
|
||||
}
|
||||
|
||||
WarpInfo newInfo = getWarp(oldName);
|
||||
if (newInfo != null) {
|
||||
PluginMessages.WARP.ALREADY_EXITS.send(player);
|
||||
return null;
|
||||
}
|
||||
|
||||
PluginMessages.WARP.RENAMED.send(player, newName, info.getLocation());
|
||||
Main.getInstance().getScheduler().runAsync(() -> {
|
||||
getManager().setWarp(newName, player.getUniqueId(), info.getLocation());
|
||||
getManager().delWarp(oldName);
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(JavaPlugin plugin, CommandSender sender, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return listWarpNames(sender, args[args.length - 1], true);
|
||||
} else return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
+3
-4
@@ -1,10 +1,9 @@
|
||||
package cc.carm.plugin.moeteleport.command.warp;
|
||||
package cc.carm.plugin.moeteleport.command.sub.warp;
|
||||
|
||||
import cc.carm.plugin.moeteleport.MoeTeleport;
|
||||
import cc.carm.plugin.moeteleport.command.parent.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.command.sub.WarpCommands;
|
||||
import cc.carm.plugin.moeteleport.command.base.WarpSubCommand;
|
||||
import cc.carm.plugin.moeteleport.conf.PluginMessages;
|
||||
import cc.carm.plugin.moeteleport.manager.TeleportManager;
|
||||
import cc.carm.plugin.moeteleport.model.WarpInfo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -54,6 +54,7 @@ public class PluginConfig extends ConfigurationRoot {
|
||||
map.put("delHome", "home delete");
|
||||
map.put("listHomes", "home list");
|
||||
map.put("listHome", "home list");
|
||||
map.put("renameHome", "home rename");
|
||||
|
||||
map.put("warp", "warp to");
|
||||
map.put("setWarp", "warp set");
|
||||
@@ -61,6 +62,7 @@ public class PluginConfig extends ConfigurationRoot {
|
||||
map.put("warpInfo", "warp info");
|
||||
map.put("listWarps", "warp list");
|
||||
map.put("listWarp", "warp list");
|
||||
map.put("renameWarp", "warp rename");
|
||||
}).build();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package cc.carm.plugin.moeteleport.conf;
|
||||
|
||||
import cc.carm.lib.configuration.core.ConfigurationRoot;
|
||||
import cc.carm.lib.configuration.core.annotation.HeaderComment;
|
||||
import cc.carm.lib.easyplugin.utils.ColorParser;
|
||||
import cc.carm.lib.easyplugin.utils.MessageUtils;
|
||||
import cc.carm.lib.mineconfiguration.bukkit.builder.message.CraftMessageListBuilder;
|
||||
import cc.carm.lib.mineconfiguration.bukkit.builder.message.CraftMessageValueBuilder;
|
||||
import cc.carm.lib.mineconfiguration.bukkit.builder.title.TitleConfigBuilder;
|
||||
@@ -9,14 +11,19 @@ import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessage;
|
||||
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
|
||||
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredTitle;
|
||||
import de.themoep.minedown.MineDown;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
|
||||
@HeaderComment({
|
||||
"MoeTeleport 传送插件的消息配置文件",
|
||||
"如特定的消息不需要任何提示,可直接留下单行空内容消息。",
|
||||
"支持 支持 &+颜色代码(原版颜色)、§(#XXXXXX)(RGB颜色) 与 &<#XXXXXX>(前后标注RGB颜色渐变)。",
|
||||
" "
|
||||
})
|
||||
public class PluginMessages extends ConfigurationRoot {
|
||||
|
||||
public static @NotNull CraftMessageListBuilder<BaseComponent[]> list() {
|
||||
@@ -34,10 +41,7 @@ public class PluginMessages extends ConfigurationRoot {
|
||||
}
|
||||
|
||||
public static @NotNull BiFunction<CommandSender, String, BaseComponent[]> getParser() {
|
||||
return (sender, message) -> {
|
||||
if (sender instanceof Player) message = PlaceholderAPI.setPlaceholders((Player) sender, message);
|
||||
return MineDown.parse(ColorParser.parse(message));
|
||||
};
|
||||
return (sender, message) -> MineDown.parse(ColorParser.parse(MessageUtils.setPlaceholders(sender, message)));
|
||||
}
|
||||
|
||||
public static final ConfiguredMessageList<BaseComponent[]> NO_PERMISSION = list().defaults(
|
||||
@@ -95,7 +99,9 @@ public class PluginMessages extends ConfigurationRoot {
|
||||
"&8-&7&o 若地标点已存在,且您是地标点的设立者,",
|
||||
"&8-&7&o 则会覆盖原有的地标点位置。",
|
||||
"&8#&f warp delete &d[地标名]",
|
||||
"&8-&7 删除一个自己设立的地标点。"
|
||||
"&8-&7 删除一个自己设立的地标点。",
|
||||
"&8#&f warp rename &d<原地标名> &d<新地标名>",
|
||||
"&8-&7 重命名一个自己设立的地标点。"
|
||||
).build();
|
||||
|
||||
public static final ConfiguredMessageList<BaseComponent[]> HOMES = list().defaults(
|
||||
@@ -110,7 +116,9 @@ public class PluginMessages extends ConfigurationRoot {
|
||||
"&8-&7 设定一个家的位置。",
|
||||
"&8-&7&o 若不填写家的名称则默认为“home”",
|
||||
"&8#&f home delete &d[家名]",
|
||||
"&8-&7 删除一个家的位置。"
|
||||
"&8-&7 删除一个家的位置。",
|
||||
"&8#&f home rename &d<原家名> &d<新家名>",
|
||||
"&8-&7 重命名一个家传送点的名称。"
|
||||
).build();
|
||||
|
||||
}
|
||||
@@ -257,6 +265,11 @@ public class PluginMessages extends ConfigurationRoot {
|
||||
"&7或输入 &5/setHome <家名称> &7覆盖之前的家传送点。"
|
||||
).params("max").build();
|
||||
|
||||
public static final ConfiguredMessageList<BaseComponent[]> ALREADY_EXITS = list()
|
||||
.defaults("&f您已存在名为 &d%(name) &f的家传送点,换个名字叭~")
|
||||
.params("name")
|
||||
.build();
|
||||
|
||||
public static final ConfiguredMessageList<BaseComponent[]> NOT_FOUND = list()
|
||||
.defaults("&f您还没有设置这个家,请先输入 &5/setHome <家名称> &f设置一个吧!")
|
||||
.build();
|
||||
@@ -275,6 +288,10 @@ public class PluginMessages extends ConfigurationRoot {
|
||||
"&8原先位置为 &5%(location) &8。"
|
||||
).params("name", "location").build();
|
||||
|
||||
public static final ConfiguredMessageList<BaseComponent[]> RENAMED = list().defaults(
|
||||
"&f成功以 &d%(newName) 重命名原先的家传送点 &d&o%(oldName) &f。"
|
||||
).params("newName", "oldName").build();
|
||||
|
||||
public static class LIST extends ConfigurationRoot {
|
||||
|
||||
public static final ConfiguredMessageList<BaseComponent[]> HEADER = list().defaults(
|
||||
@@ -336,6 +353,14 @@ public class PluginMessages extends ConfigurationRoot {
|
||||
"&8原先位置为 &5%(location) &8。"
|
||||
).params("name", "location").build();
|
||||
|
||||
public static final ConfiguredMessageList<BaseComponent[]> ALREADY_EXITS = list()
|
||||
.defaults("&f已存在名为 &d%(name) &f的地标点,换个名字叭~")
|
||||
.params("name")
|
||||
.build();
|
||||
|
||||
public static final ConfiguredMessageList<BaseComponent[]> RENAMED = list().defaults(
|
||||
"&f成功以 &d%(newName) 重命名原先的地标点 &d&o%(oldName) &f。"
|
||||
).params("newName", "oldName").build();
|
||||
|
||||
public static class LIST extends ConfigurationRoot {
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package cc.carm.plugin.moeteleport.effect;
|
||||
|
||||
public class TeleportEffect {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
package cc.carm.plugin.moeteleport.manager;
|
||||
|
||||
import cc.carm.plugin.moeteleport.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.plugin.SimplePluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
public class CommandManager {
|
||||
|
||||
protected final JavaPlugin plugin;
|
||||
|
||||
protected final SimpleCommandMap commandMap;
|
||||
protected final Field knownCommandsFiled;
|
||||
|
||||
protected final Map<String, AliasCommand> registeredCommands = new HashMap<>();
|
||||
|
||||
public CommandManager(JavaPlugin plugin) throws Exception {
|
||||
this.plugin = plugin;
|
||||
|
||||
SimplePluginManager manager = (SimplePluginManager) Bukkit.getPluginManager();
|
||||
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||
commandMapField.setAccessible(true);
|
||||
this.commandMap = (SimpleCommandMap) commandMapField.get(manager);
|
||||
|
||||
this.knownCommandsFiled = SimpleCommandMap.class.getDeclaredField("knownCommands");
|
||||
this.knownCommandsFiled.setAccessible(true);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Map<String, Command> getKnownCommands() {
|
||||
try {
|
||||
return (Map<String, Command>) knownCommandsFiled.get(commandMap);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.plugin.getName().toLowerCase() + " ";
|
||||
}
|
||||
|
||||
protected SimpleCommandMap getCommandMap() {
|
||||
return commandMap;
|
||||
}
|
||||
|
||||
public void register(String alias, String target) {
|
||||
AliasCommand current = this.registeredCommands.get(alias);
|
||||
if (current != null) current.unregister(getCommandMap());
|
||||
|
||||
AliasCommand cmd = new AliasCommand(alias, this, getPrefix() + target);
|
||||
this.registeredCommands.put(alias, cmd);
|
||||
getCommandMap().register(Main.getInstance().getName(), cmd);
|
||||
}
|
||||
|
||||
public void unregister(String alias) {
|
||||
AliasCommand current = this.registeredCommands.remove(alias);
|
||||
if (current != null) {
|
||||
getKnownCommands().remove(alias);
|
||||
current.unregister(getCommandMap());
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterAll() {
|
||||
registeredCommands.forEach((k, v) -> {
|
||||
getKnownCommands().remove(k);
|
||||
v.unregister(getCommandMap());
|
||||
});
|
||||
registeredCommands.clear();
|
||||
}
|
||||
|
||||
public static class AliasCommand extends Command {
|
||||
|
||||
protected final CommandManager commandManager;
|
||||
protected final String targetCommand;
|
||||
|
||||
public AliasCommand(String name, CommandManager commandManager, String targetCommand) {
|
||||
super(name);
|
||||
this.commandManager = commandManager;
|
||||
this.targetCommand = targetCommand;
|
||||
}
|
||||
|
||||
protected SimpleCommandMap getCommandMap() {
|
||||
return this.commandManager.getCommandMap();
|
||||
}
|
||||
|
||||
protected String buildCommand(String[] args) {
|
||||
return this.targetCommand + " " + String.join(" ", args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
return getCommandMap().dispatch(sender, buildCommand(args));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias,
|
||||
@NotNull String[] args, @Nullable Location location) throws IllegalArgumentException {
|
||||
return Optional.ofNullable(getCommandMap().tabComplete(sender, buildCommand(args))).orElse(Collections.emptyList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
|
||||
return tabComplete(sender, alias, args, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user