diff --git a/pom.xml b/pom.xml
index 3be4798..6cc87f3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
pw.yumc
MiaoLobby
- 1.2
+ 1.3
${project.name}
diff --git a/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java b/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java
index ff366f7..c4e5a51 100644
--- a/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java
+++ b/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java
@@ -1,14 +1,11 @@
package pw.yumc.MiaoLobby;
import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
-import org.bukkit.scheduler.BukkitRunnable;
import fr.xephi.authme.events.LoginEvent;
import pw.yumc.YumCore.bukkit.P;
-import pw.yumc.YumCore.bukkit.compatible.C;
public class AuthMeHook implements Listener {
private MiaoLobby plugin = P.getPlugin();
@@ -19,22 +16,6 @@ public class AuthMeHook implements Listener {
@EventHandler
public void onLogin(final LoginEvent e) {
- new BukkitRunnable() {
- Player player = e.getPlayer();
- int delay = plugin.config.AutoTPDelay;
-
- @Override
- public void run() {
- if (player.isOnline()) {
- if (delay > 0) {
- C.ActionBar.send(player, String.format(plugin.config.TPDelay, delay));
- delay--;
- return;
- }
- plugin.random(player);
- }
- cancel();
- }
- }.runTaskTimerAsynchronously(plugin, 0, 20);
+ plugin.delayTP(e.getPlayer());
}
}
diff --git a/src/main/java/pw/yumc/MiaoLobby/Config.java b/src/main/java/pw/yumc/MiaoLobby/Config.java
index ba7d7fe..d876355 100644
--- a/src/main/java/pw/yumc/MiaoLobby/Config.java
+++ b/src/main/java/pw/yumc/MiaoLobby/Config.java
@@ -17,6 +17,7 @@ public class Config extends InjectConfig {
public String TimeOut;
public String TPDelay;
public String Unavailable;
+ public Boolean AutoTP;
public Boolean AuthMeAutoTP;
public Integer AutoTPDelay;
public Boolean ReTry;
diff --git a/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java b/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java
index bd50c94..2a26787 100644
--- a/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java
+++ b/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java
@@ -7,6 +7,9 @@ import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
@@ -22,22 +25,11 @@ import pw.yumc.YumCore.commands.annotation.Cmd;
import pw.yumc.YumCore.commands.annotation.Cmd.Executor;
import pw.yumc.YumCore.commands.annotation.Help;
import pw.yumc.YumCore.statistic.Statistics;
-import pw.yumc.YumCore.update.SubscribeTask;
-public class MiaoLobby extends JavaPlugin implements CommandExecutor {
+public class MiaoLobby extends JavaPlugin implements CommandExecutor, Listener {
Config config;
private final SecureRandom random = new SecureRandom();
- private void connect(final Player p, final String server) {
- final ByteArrayDataOutput out = ByteStreams.newDataOutput();
- try {
- out.writeUTF("Connect");
- out.writeUTF(server);
- } catch (final Exception ignored) {
- }
- p.sendPluginMessage(this, "BungeeCord", out.toByteArray());
- }
-
@Cmd(permission = "MiaoLobby.default", executor = Executor.PLAYER)
@Help("进行随机服务器传送")
public boolean def(final CommandArgument e) {
@@ -45,6 +37,25 @@ public class MiaoLobby extends JavaPlugin implements CommandExecutor {
return true;
}
+ public void delayTP(final Player player) {
+ new BukkitRunnable() {
+ int delay = config.AutoTPDelay;
+
+ @Override
+ public void run() {
+ if (player.isOnline()) {
+ if (delay > 0) {
+ C.ActionBar.send(player, String.format(config.TPDelay, delay));
+ delay--;
+ return;
+ }
+ random(player);
+ }
+ cancel();
+ }
+ }.runTaskTimerAsynchronously(this, 0, 20);
+ }
+
@Override
public FileConfiguration getConfig() {
return config.getConfig();
@@ -54,18 +65,44 @@ public class MiaoLobby extends JavaPlugin implements CommandExecutor {
public void onEnable() {
new CommandManager("MiaoLobby", this);
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
- if (config.AuthMeAutoTP && Bukkit.getPluginManager().isPluginEnabled("AuthMe")) {
+ if (config.AutoTP) {
+ Bukkit.getPluginManager().registerEvents(this, this);
+ } else if (config.AuthMeAutoTP && Bukkit.getPluginManager().isPluginEnabled("AuthMe")) {
new AuthMeHook();
}
new Statistics();
// new SubscribeTask(true, true);
}
+ @EventHandler
+ public void onJoin(PlayerJoinEvent e) {
+ if (config.AutoTP) {
+ delayTP(e.getPlayer());
+ }
+ }
+
@Override
public void onLoad() {
config = new Config();
}
+ @Cmd(permission = "MiaoLobby.reload")
+ @Help("重载配置文件")
+ public void reload(final CommandArgument e) {
+ config.reload();
+ Log.toSender(e.getSender(), "§a配置文件已重载!");
+ }
+
+ private void connect(final Player p, final String server) {
+ final ByteArrayDataOutput out = ByteStreams.newDataOutput();
+ try {
+ out.writeUTF("Connect");
+ out.writeUTF(server);
+ } catch (final Exception ignored) {
+ }
+ p.sendPluginMessage(this, "BungeeCord", out.toByteArray());
+ }
+
void random(final Player player) {
new BukkitRunnable() {
List servers = new ArrayList<>(config.Servers);
@@ -91,11 +128,4 @@ public class MiaoLobby extends JavaPlugin implements CommandExecutor {
}
}.runTaskTimerAsynchronously(this, 0, config.WaitTime);
}
-
- @Cmd(permission = "MiaoLobby.reload")
- @Help("重载配置文件")
- public void reload(final CommandArgument e) {
- config.reload();
- Log.toSender(e.getSender(), "§a配置文件已重载!");
- }
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index e0475b4..10f662d 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,5 +1,5 @@
#配置文件版本 请勿修改
-Version: 1.2
+Version: 1.3
#数据库信息
Servers:
@@ -7,9 +7,11 @@ Servers:
- lobby2
#传送超时时间(单位: Tick)
WaitTime: 35
+#自带传送(如果开启 则AuthMe自动传送失效)
+AutoTP: false
#AuthMe自动传送
AuthMeAutoTP: true
-#自动登录延时(单位: 秒)
+#自动传送延时(单位: 秒)
AutoTPDelay: 10
#尝试完毕后是否继续重试
ReTry: true