fix: player invisible in some cases after join
This commit is contained in:
parent
cd3b4db3f4
commit
eb9bfc78d1
2 changed files with 20 additions and 8 deletions
|
@ -46,7 +46,6 @@ public class PlayerJoinQuitListener implements Listener {
|
|||
@EventHandler
|
||||
public void onPlayerJoin(final PlayerJoinEvent e) {
|
||||
e.setJoinMessage(null);
|
||||
this.plugin.getNPCManager().syncClones(e.getPlayer());
|
||||
|
||||
if (!this.plugin.getTeamManager().setTeam(e.getPlayer())) {
|
||||
e.getPlayer().kickPlayer(this.plugin.getLangUtils().get("Error.NoTeam"));
|
||||
|
|
|
@ -41,13 +41,17 @@ public class PlayerUtils {
|
|||
this.plugin.getLangUtils().get("Service.LoadingSubTitle"), 20, (seconds - 2) * 20, 20);
|
||||
p.sendTitle(title);
|
||||
|
||||
p.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, seconds * 20, 1, false, false));
|
||||
|
||||
final BukkitTask hidePlayersTask = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (final Player player : Bukkit.getOnlinePlayers())
|
||||
p.hidePlayer(plugin, player);
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!p.equals(player)) {
|
||||
player.hidePlayer(plugin, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(this.plugin, 0l, 1l);
|
||||
|
||||
|
@ -68,14 +72,23 @@ public class PlayerUtils {
|
|||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getNPCManager().removeClone(p);
|
||||
hidePlayersTask.cancel();
|
||||
plugin.getNPCManager().removeClone(p.getUniqueId());
|
||||
p.teleport(plugin.getPlayerCache().getPlayerLocationCache(p.getUniqueId().toString().replace("-", "")));
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
p.setFlySpeed(0.1f);
|
||||
p.setFlying(false);
|
||||
p.teleport(plugin.getPlayerCache().getPlayerLocationCache(p.getUniqueId().toString().replace("-", "")));
|
||||
hidePlayersTask.cancel();
|
||||
for (final Player player : Bukkit.getOnlinePlayers())
|
||||
p.showPlayer(plugin, player);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
p.removePotionEffect(PotionEffectType.INVISIBILITY);
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
p.showPlayer(plugin, player);
|
||||
player.showPlayer(plugin, p);
|
||||
}
|
||||
plugin.getNPCManager().syncClones(p);
|
||||
}
|
||||
}.runTaskLater(plugin, 10);
|
||||
}
|
||||
}.runTaskLater(this.plugin, seconds * 20);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue