fix: user can't tp next login

Signed-off-by: MiaoWoo <admin@yumc.pw>
master
MiaoWoo 2021-04-01 10:34:51 +00:00
parent 979ca55dfb
commit dd7e87d890
5 changed files with 18 additions and 9 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>MiaoLobby</artifactId>
<version>2.0</version>
<version>2.1</version>
<parent>
<groupId>pw.yumc</groupId>
@ -24,11 +24,12 @@
<properties>
<update.description>§a正式版本 §bv${project.version}</update.description>
<update.changes>
§621-04-01 §a新增: 重复传送限制 离线清理数据;
</update.changes>
<update.changelog>
§617-07-05 §a新增: 添加对MOD服和1.12的ActionBar支持;
§617-07-05 §a新增: 未混淆的API接口;
§617-07-03 §a新增: 传送前事件 PreLobbyTpEvent
</update.changes>
<update.changelog>
</update.changelog>
<env.GIT_COMMIT>DEV</env.GIT_COMMIT>
</properties>

View File

@ -30,7 +30,7 @@ public class MiaoLobby extends JavaPlugin implements Executor, Listener {
@Cmd(permission = "MiaoLobby.default", executor = Cmd.Executor.PLAYER)
@Help("进行随机服务器传送")
public boolean def(final Player player) {
Util.random(player);
Util.delayTp(player);
return true;
}

View File

@ -8,6 +8,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import pw.yumc.MiaoLobby.config.Config;
import pw.yumc.MiaoLobby.event.PreLobbyTpEvent;
import pw.yumc.YumCore.bukkit.Log;
import pw.yumc.YumCore.bukkit.P;
import pw.yumc.YumCore.bukkit.compatible.C;
@ -28,6 +29,10 @@ public class Util {
private static Map<String, BukkitTask> tasks = new HashMap<>();
public static void delayTp(final Player player) {
if (tasks.containsKey(player.getName())) {
Log.sender(player, config.TPing);
return;
}
tasks.put(player.getName(), new BukkitRunnable() {
int delay = config.AutoTPDelay;
@ -41,7 +46,7 @@ public class Util {
}
random(player);
}
cancel();
this.cancel();
}
}.runTaskTimerAsynchronously(plugin, 0, 20));
}
@ -56,7 +61,7 @@ public class Util {
public static void cancel(Player player) {
if (player != null) {
BukkitTask task = tasks.get(player.getName());
BukkitTask task = tasks.remove(player.getName());
if (task != null) {
task.cancel();
}
@ -94,7 +99,8 @@ public class Util {
i++;
return;
}
cancel();
Util.cancel(player);
this.cancel();
}
}.runTaskTimerAsynchronously(plugin, 0, config.WaitTime);
}

View File

@ -1,9 +1,9 @@
package pw.yumc.MiaoLobby.config;
import java.util.List;
import pw.yumc.YumCore.config.inject.InjectConfig;
import java.util.List;
/**
*
*
@ -16,6 +16,7 @@ public class Config extends InjectConfig {
public String Message;
public String TimeOut;
public String TPDelay;
public String TPing;
public String Unavailable;
public Boolean AutoTP;
public Boolean LoginAutoTP;

View File

@ -19,4 +19,5 @@ ReTry: true
Message: '&a请稍候 正在传送至服务器 %s ...'
TimeOut: '&c传送超时 正在切换到服务器 %s ...'
TPDelay: '&a登陆成功 正在为您匹配服务器 剩余 %s 秒...'
TPing: '&c正在为您选择可用大厅 请稍候重试!'
Unavailable: '&4已尝试所有可用服务器 传送失败!'