diff --git a/pom.xml b/pom.xml
index 8460e24..dd90068 100644
--- a/pom.xml
+++ b/pom.xml
@@ -111,5 +111,11 @@
jar
1.0
+
+ cn.citycraft
+ AuthMe
+ jar
+ 6.1
+
\ No newline at end of file
diff --git a/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java b/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java
new file mode 100644
index 0000000..2148656
--- /dev/null
+++ b/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java
@@ -0,0 +1,21 @@
+package pw.yumc.MiaoLobby;
+
+import org.bukkit.Bukkit;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+
+import fr.xephi.authme.events.LoginEvent;
+import pw.yumc.YumCore.bukkit.P;
+
+public class AuthMeHook implements Listener {
+ MiaoLobby plugin = P.getPlugin();
+
+ public AuthMeHook() {
+ Bukkit.getPluginManager().registerEvents(this, P.instance);
+ }
+
+ @EventHandler
+ public void onLogin(final LoginEvent e) {
+ plugin.random(e.getPlayer());
+ }
+}
diff --git a/src/main/java/pw/yumc/MiaoLobby/Config.java b/src/main/java/pw/yumc/MiaoLobby/Config.java
index 39f2b68..146bef9 100644
--- a/src/main/java/pw/yumc/MiaoLobby/Config.java
+++ b/src/main/java/pw/yumc/MiaoLobby/Config.java
@@ -16,4 +16,5 @@ public class Config extends InjectConfig {
public String Message;
public String TimeOut;
public String Unavailable;
+ public Boolean AuthMeAutoTP;
}
diff --git a/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java b/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java
index 8fd864e..2a98211 100644
--- a/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java
+++ b/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java
@@ -19,6 +19,7 @@ import pw.yumc.YumCore.commands.CommandArgument;
import pw.yumc.YumCore.commands.CommandExecutor;
import pw.yumc.YumCore.commands.CommandManager;
import pw.yumc.YumCore.commands.annotation.Cmd;
+import pw.yumc.YumCore.commands.annotation.Cmd.Executor;
import pw.yumc.YumCore.commands.annotation.Help;
public class MiaoLobby extends JavaPlugin implements CommandExecutor {
@@ -35,10 +36,33 @@ public class MiaoLobby extends JavaPlugin implements CommandExecutor {
p.sendPluginMessage(this, "BungeeCord", out.toByteArray());
}
- @Cmd(permission = "MiaoLobby.default")
+ @Cmd(permission = "MiaoLobby.default", executor = Executor.PLAYER)
@Help("进行随机服务器传送")
public boolean def(final CommandArgument e) {
- final Player player = (Player) e.getSender();
+ random((Player) e.getSender());
+ return true;
+ }
+
+ @Override
+ public FileConfiguration getConfig() {
+ return config.getConfig();
+ }
+
+ @Override
+ public void onEnable() {
+ new CommandManager("MiaoLobby", this);
+ Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
+ if (config.AuthMeAutoTP && Bukkit.getPluginManager().isPluginEnabled("AuthMe")) {
+ new AuthMeHook();
+ }
+ }
+
+ @Override
+ public void onLoad() {
+ config = new Config();
+ }
+
+ public void random(final Player player) {
new BukkitRunnable() {
List servers = new ArrayList<>(config.Servers);
int i = 0;
@@ -58,23 +82,6 @@ public class MiaoLobby extends JavaPlugin implements CommandExecutor {
cancel();
}
}.runTaskTimerAsynchronously(this, 0, config.WaitTime);
- return true;
- }
-
- @Override
- public FileConfiguration getConfig() {
- return config.getConfig();
- }
-
- @Override
- public void onEnable() {
- new CommandManager("MiaoLobby", this);
- Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
- }
-
- @Override
- public void onLoad() {
- config = new Config();
}
@Cmd(permission = "MiaoLobby.reload")
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index bf614d4..e21bfd8 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -7,6 +7,8 @@ Servers:
- lobby2
#传送超时时间(单位: Tick)
WaitTime: 20
+#AuthMe自动传送
+AuthMeAutoTP: true
#传送提示
Message: '&a请稍候 正在传送至服务器 %s ...'
TimeOut: '&c传送超时 正在切换到服务器 %s ...'
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index b48fa7e..d1975c8 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -4,6 +4,8 @@ main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}-git-${env.GIT_COMMIT}
author: 喵♂呜
website: ${ciManagement.url}
+softdepend:
+- AuthMe
commands:
${project.artifactId}:
description: ${project.artifactId} - ${project.description}