fix: player invisible in some cases after join

This commit is contained in:
Simon Giesel 2020-05-27 11:30:04 +02:00
parent cd3b4db3f4
commit eb9bfc78d1
2 changed files with 20 additions and 8 deletions

View file

@ -46,7 +46,6 @@ public class PlayerJoinQuitListener implements Listener {
@EventHandler @EventHandler
public void onPlayerJoin(final PlayerJoinEvent e) { public void onPlayerJoin(final PlayerJoinEvent e) {
e.setJoinMessage(null); e.setJoinMessage(null);
this.plugin.getNPCManager().syncClones(e.getPlayer());
if (!this.plugin.getTeamManager().setTeam(e.getPlayer())) { if (!this.plugin.getTeamManager().setTeam(e.getPlayer())) {
e.getPlayer().kickPlayer(this.plugin.getLangUtils().get("Error.NoTeam")); e.getPlayer().kickPlayer(this.plugin.getLangUtils().get("Error.NoTeam"));

View file

@ -41,13 +41,17 @@ public class PlayerUtils {
this.plugin.getLangUtils().get("Service.LoadingSubTitle"), 20, (seconds - 2) * 20, 20); this.plugin.getLangUtils().get("Service.LoadingSubTitle"), 20, (seconds - 2) * 20, 20);
p.sendTitle(title); p.sendTitle(title);
p.removePotionEffect(PotionEffectType.BLINDNESS);
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, seconds * 20, 1, false, false)); p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, seconds * 20, 1, false, false));
final BukkitTask hidePlayersTask = new BukkitRunnable() { final BukkitTask hidePlayersTask = new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
for (final Player player : Bukkit.getOnlinePlayers()) for (final Player player : Bukkit.getOnlinePlayers()) {
p.hidePlayer(plugin, player); if (!p.equals(player)) {
player.hidePlayer(plugin, p);
}
}
} }
}.runTaskTimer(this.plugin, 0l, 1l); }.runTaskTimer(this.plugin, 0l, 1l);
@ -68,14 +72,23 @@ public class PlayerUtils {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { 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.setGameMode(GameMode.SURVIVAL);
p.setFlySpeed(0.1f); p.setFlySpeed(0.1f);
p.setFlying(false); p.setFlying(false);
p.teleport(plugin.getPlayerCache().getPlayerLocationCache(p.getUniqueId().toString().replace("-", ""))); new BukkitRunnable() {
hidePlayersTask.cancel(); @Override
for (final Player player : Bukkit.getOnlinePlayers()) public void run() {
p.removePotionEffect(PotionEffectType.INVISIBILITY);
for (final Player player : Bukkit.getOnlinePlayers()) {
p.showPlayer(plugin, player); p.showPlayer(plugin, player);
player.showPlayer(plugin, p);
}
plugin.getNPCManager().syncClones(p);
}
}.runTaskLater(plugin, 10);
} }
}.runTaskLater(this.plugin, seconds * 20); }.runTaskLater(this.plugin, seconds * 20);
} }