diff --git a/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java b/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java index 2148656..f7d7ee5 100644 --- a/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java +++ b/src/main/java/pw/yumc/MiaoLobby/AuthMeHook.java @@ -1,11 +1,14 @@ 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 { MiaoLobby plugin = P.getPlugin(); @@ -16,6 +19,21 @@ public class AuthMeHook implements Listener { @EventHandler public void onLogin(final LoginEvent e) { - plugin.random(e.getPlayer()); + 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)); + return; + } + plugin.random(player); + } + cancel(); + } + }.runTaskTimerAsynchronously(plugin, 0, 20); } } diff --git a/src/main/java/pw/yumc/MiaoLobby/Config.java b/src/main/java/pw/yumc/MiaoLobby/Config.java index 146bef9..bedc0e4 100644 --- a/src/main/java/pw/yumc/MiaoLobby/Config.java +++ b/src/main/java/pw/yumc/MiaoLobby/Config.java @@ -15,6 +15,8 @@ public class Config extends InjectConfig { public Integer WaitTime; public String Message; public String TimeOut; + public String TPDelay; public String Unavailable; public Boolean AuthMeAutoTP; + public Integer AutoTPDelay; } diff --git a/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java b/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java index 2a98211..ebbfb3e 100644 --- a/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java +++ b/src/main/java/pw/yumc/MiaoLobby/MiaoLobby.java @@ -23,8 +23,8 @@ import pw.yumc.YumCore.commands.annotation.Cmd.Executor; import pw.yumc.YumCore.commands.annotation.Help; public class MiaoLobby extends JavaPlugin implements CommandExecutor { + public Config config; private final SecureRandom random = new SecureRandom(); - private Config config; public void connect(final Player p, final String server) { final ByteArrayDataOutput out = ByteStreams.newDataOutput(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e21bfd8..a5506ed 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,15 +1,18 @@ #配置文件版本 请勿修改 -Version: 1.0 +Version: 1.1 #数据库信息 Servers: - lobby1 - lobby2 #传送超时时间(单位: Tick) -WaitTime: 20 +WaitTime: 35 #AuthMe自动传送 AuthMeAutoTP: true +#自动登录延时(单位: Tick) +AutoTPDelay: 10 #传送提示 Message: '&a请稍候 正在传送至服务器 %s ...' TimeOut: '&c传送超时 正在切换到服务器 %s ...' +TPDelay: '&a登陆成功 正在为您匹配服务器 剩余 %s 秒...' Unavailable: '&4已尝试所有可用服务器 传送失败!' \ No newline at end of file