feat: 添加登录传送延时

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
2016-09-28 10:30:24 +08:00
parent a8b14469ce
commit fc02e2233b
4 changed files with 27 additions and 4 deletions

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -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已尝试所有可用服务器 传送失败!'