1
mirror of https://github.com/CarmJos/MoeTeleport.git synced 2026-06-04 16:46:10 +08:00

6 Commits

30 changed files with 399 additions and 81 deletions
+155
View File
@@ -0,0 +1,155 @@
```text
__ ___ ______ __ __
/ |/ /__ __/_ __/__ / /__ ___ ___ ____/ /_
/ /|_/ / _ \/ -_) / / -_) / -_) _ \/ _ \/ __/ __/
/_/ /_/\___/\__/_/ \__/_/\__/ .__/\___/_/ \__/
/_/
```
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)
![Support](https://img.shields.io/badge/Minecraft-Java%201.13--Latest-blue)
![](https://visitor-badge.glitch.me/badge?page_id=moeteleport.readme)
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
[![bStats](https://bstats.org/signatures/bukkit/MoeTeleport.svg)](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://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](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.
+6 -2
View File
@@ -5,6 +5,7 @@
/_/ /_/\___/\__/_/ \__/_/\__/ .__/\___/_/ \__/
/_/
```
README LANGUAGES [ [**中文**](README.md) | [English](README-EN.md) ]
# MoeTeleport 喵喵传送
@@ -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://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/CarmJos/UserPrefix)
## 开源协议
本项目源码采用 [GNU General Public License v3.0](https://opensource.org/licenses/GPL-3.0) 开源协议。
+3 -3
View File
@@ -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.4</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.1</version>
<name>MoeTeleport</name>
<description>喵喵传送,简单的传送、设置家的插件。</description>
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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"));
}
@@ -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;
@@ -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;
@@ -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"));
}
@@ -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;
@@ -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;
@@ -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();
}
}
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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();
}
}
@@ -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 {
}