diff --git a/README.md b/README.md
index 94ea199..b0b350c 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,15 @@
## TpaForm Tpa Form支持
为Tpa相关命令添加Form菜单,基于命令监听实现
+## 使用方式
+指令/tform打开传送菜单,选择玩家后传送
+基岩版玩家在接收到传送请求后自动弹出菜单
+## 兼容的插件
+绝大部分非跨服, 以指令为基础的Tpa均可通过调整配置文件兼容
+目前已经测试的插件有:
+* [EssentialX](https://essentialsx.net/)
+* [CMI](https://www.spigotmc.org/resources/3742/)
+* [Sunlight](https://www.spigotmc.org/resources/67733/)
+* [HuskHomes](https://github.com/WiIIiam278/HuskHomes) (仅单端)
+* [TPAPro](https://www.mcbbs.net/thread-904737-1-1.html) (需要从 [此处](https://raw.githubusercontent.com/RenYuan-MC/TpaForm/master/extensions/TpaForm-TpaProSupport.jar) 下载扩展以兼容其黑名单功能)
## 前置
* Floodgate (2.2.0版本以上) - 用于基岩版菜单
diff --git a/extensions/TpaForm-TpaProSupport.jar b/extensions/TpaForm-TpaProSupport.jar
new file mode 100644
index 0000000..e31eedd
Binary files /dev/null and b/extensions/TpaForm-TpaProSupport.jar differ
diff --git a/pom.xml b/pom.xml
index bb92a09..bd6197a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
ltd.rymc
TpaForm
- 2.0.1
+ 2.1.0
jar
TpaForm
diff --git a/src/main/java/ltd/rymc/form/tpa/configs/LangConfig.java b/src/main/java/ltd/rymc/form/tpa/configs/LangConfig.java
index 68c346d..c8d082e 100644
--- a/src/main/java/ltd/rymc/form/tpa/configs/LangConfig.java
+++ b/src/main/java/ltd/rymc/form/tpa/configs/LangConfig.java
@@ -31,6 +31,7 @@ public interface LangConfig {
@ConfComments("\n# 传送选择菜单")
@AnnotationBasedSorter.Order(40)
String selectPlayers();
+
@ConfDefault.DefaultString("玩家列表")
@ConfKey("player-list")
@AnnotationBasedSorter.Order(50)
diff --git a/src/main/java/ltd/rymc/form/tpa/configs/TpaConfig.java b/src/main/java/ltd/rymc/form/tpa/configs/TpaConfig.java
index 6d0f290..f045e66 100644
--- a/src/main/java/ltd/rymc/form/tpa/configs/TpaConfig.java
+++ b/src/main/java/ltd/rymc/form/tpa/configs/TpaConfig.java
@@ -6,6 +6,8 @@
import space.arim.dazzleconf.annote.ConfKey;
import space.arim.dazzleconf.sorter.AnnotationBasedSorter;
+import java.util.List;
+
@SuppressWarnings("unused")
@ConfHeader("# 配置文件 TpaForm Config ver 2.0.0 by RENaa_FD")
public interface TpaConfig {
@@ -34,8 +36,8 @@ public interface TpaConfig {
@AnnotationBasedSorter.Order(20)
boolean enableTpaHere();
- @ConfDefault.DefaultString("tpa")
- @ConfKey("tpa-command")
+ @ConfDefault.DefaultStrings({"tpa"})
+ @ConfKey("tpa-commands")
@ConfComments({
"",
"# tpa相关的命令",
@@ -43,12 +45,12 @@ public interface TpaConfig {
"# 示例: tpaccept %s"
})
@AnnotationBasedSorter.Order(30)
- String tpaCommand();
+ List tpaCommands();
- @ConfDefault.DefaultString("tpahere")
- @ConfKey("tpa-here-command")
+ @ConfDefault.DefaultStrings({"tpahere"})
+ @ConfKey("tpa-here-commands")
@AnnotationBasedSorter.Order(40)
- String tpaHereCommand();
+ List tpaHereCommands();
@ConfDefault.DefaultString("tpaccept")
@ConfKey("tpa-accept-command")
diff --git a/src/main/java/ltd/rymc/form/tpa/forms/TpaSendForm.java b/src/main/java/ltd/rymc/form/tpa/forms/TpaSendForm.java
index c998e67..41e2bb0 100644
--- a/src/main/java/ltd/rymc/form/tpa/forms/TpaSendForm.java
+++ b/src/main/java/ltd/rymc/form/tpa/forms/TpaSendForm.java
@@ -34,7 +34,7 @@ private String[] getPlayerNameList(){
@Override
public void onValidResult(CustomForm form, CustomFormResponse response) {
- String command = (response.asToggle(2) ? TpaForm.config().tpaHereCommand() : TpaForm.config().tpaCommand()) + " ";
+ String command = (response.asToggle(2) ? TpaForm.config().tpaHereCommands().get(0) : TpaForm.config().tpaCommands().get(0)) + " ";
String input = response.asInput(1);
String playerName;
diff --git a/src/main/java/ltd/rymc/form/tpa/listener/TpaCommandListener.java b/src/main/java/ltd/rymc/form/tpa/listener/TpaCommandListener.java
index ae1a3c5..683ad6a 100644
--- a/src/main/java/ltd/rymc/form/tpa/listener/TpaCommandListener.java
+++ b/src/main/java/ltd/rymc/form/tpa/listener/TpaCommandListener.java
@@ -10,6 +10,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
+import java.util.List;
import java.util.Locale;
public class TpaCommandListener implements Listener {
@@ -21,25 +22,26 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event){
String message = event.getMessage().trim().toLowerCase(Locale.ROOT).substring(1);
// check tpa
- String command = TpaForm.config().tpaCommand();
- String playerName = processCommand(message, command);
+ List commands = TpaForm.config().tpaCommands();
+ TpaPlayer tpaPlayer = processCommand(message, commands);
TpaMode mode = TpaMode.TPA;
// check tpa here
- if (TpaForm.config().enableTpaHere() && (playerName == null || playerName.contains(" "))) {
- command = TpaForm.config().tpaHereCommand();
- playerName = processCommand(message, command);
+ if (TpaForm.config().enableTpaHere() && (tpaPlayer == null || tpaPlayer.checkPlayerName())) {
+ commands = TpaForm.config().tpaHereCommands();
+ tpaPlayer = processCommand(message, commands);
mode = TpaMode.TPAHERE;
}
// check player name
- if (playerName == null || playerName.contains(" ") || playerName.isEmpty()) return;
- if (event.getPlayer().getName().equalsIgnoreCase(playerName)) return;
+ if (tpaPlayer == null || tpaPlayer.checkPlayerName()) return;
+ if (event.getPlayer().getName().equalsIgnoreCase(tpaPlayer.playerName)) return;
+ String playerName = tpaPlayer.playerName;
// completion
if (TpaForm.config().completion()) {
playerName = PlayerUtils.completionPlayer(playerName);
- event.setMessage("/" + command + " " + playerName);
+ event.setMessage("/" + tpaPlayer.command + " " + playerName);
}
// get player
@@ -52,8 +54,26 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event){
- private String processCommand(String message,String command){
- if (!message.startsWith(command.toLowerCase(Locale.ROOT))) return null;
- return message.substring(command.length()).trim();
+ private TpaPlayer processCommand(String message, List commands){
+ for (String command : commands){
+ if (!message.startsWith(command.toLowerCase(Locale.ROOT))) continue;
+ return new TpaPlayer(message.substring(command.length()).trim(), command);
+ }
+ return null;
+ }
+
+ private static class TpaPlayer {
+
+ private final String playerName;
+ private final String command;
+
+ private TpaPlayer(String playerName, String command){
+ this.playerName = playerName;
+ this.command = command;
+ }
+
+ private boolean checkPlayerName(){
+ return playerName.contains(" ") || playerName.isEmpty();
+ }
}
-}
+}
\ No newline at end of file