mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +01:00
Teleport players to the positions where they were
This commit is contained in:
parent
ed838d01da
commit
4c159c79a4
@ -26,8 +26,10 @@ import de.erethon.dungeonsxl.api.world.EditWorld;
|
|||||||
import de.erethon.dungeonsxl.player.DEditPlayer;
|
import de.erethon.dungeonsxl.player.DEditPlayer;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -91,14 +93,23 @@ public class DEditWorld extends DInstanceWorld implements EditWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugin.setLoadingWorld(true);
|
plugin.setLoadingWorld(true);
|
||||||
List<Player> players = getWorld().getPlayers();
|
Map<Player, Double[]> players = new HashMap<>();
|
||||||
|
getWorld().getPlayers().forEach(p -> players.put(p,
|
||||||
|
new Double[]{
|
||||||
|
p.getLocation().getX(),
|
||||||
|
p.getLocation().getY(),
|
||||||
|
p.getLocation().getZ(),
|
||||||
|
new Double(p.getLocation().getYaw()),
|
||||||
|
new Double(p.getLocation().getPitch())
|
||||||
|
}
|
||||||
|
));
|
||||||
kickAllPlayers();
|
kickAllPlayers();
|
||||||
|
|
||||||
getResource().editWorld = null;
|
getResource().editWorld = null;
|
||||||
plugin.getInstanceCache().remove(this);
|
plugin.getInstanceCache().remove(this);
|
||||||
getResource().getSignData().serializeSigns(signs.values());
|
getResource().getSignData().serializeSigns(signs.values());
|
||||||
Bukkit.unloadWorld(getWorld(), true);
|
Bukkit.unloadWorld(getWorld(), true);
|
||||||
new ProgressBar(players, plugin.getMainConfig().getEditInstanceRemovalDelay()) {
|
new ProgressBar(players.keySet(), plugin.getMainConfig().getEditInstanceRemovalDelay()) {
|
||||||
@Override
|
@Override
|
||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
getResource().clearFolder();
|
getResource().clearFolder();
|
||||||
@ -108,9 +119,11 @@ public class DEditWorld extends DInstanceWorld implements EditWorld {
|
|||||||
|
|
||||||
plugin.setLoadingWorld(false);
|
plugin.setLoadingWorld(false);
|
||||||
EditWorld newEditWorld = getResource().getOrInstantiateEditWorld(true);
|
EditWorld newEditWorld = getResource().getOrInstantiateEditWorld(true);
|
||||||
players.forEach(p -> {
|
players.keySet().forEach(p -> {
|
||||||
if (p.isOnline()) {
|
if (p.isOnline()) {
|
||||||
new DEditPlayer(plugin, p, newEditWorld);
|
new DEditPlayer(plugin, p, newEditWorld);
|
||||||
|
Double[] coords = players.get(p);
|
||||||
|
p.teleport(new Location(newEditWorld.getWorld(), coords[0], coords[1], coords[2], coords[3].floatValue(), coords[4].floatValue()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user