saving the player location when disconnecting for the next server join
parent
4df911eb0a
commit
319407ecc5
|
@ -34,11 +34,5 @@ public class PlayerJoinListener implements Listener {
|
|||
RMap<String, String> map = ProxySystem.getInstance().getRedisManager()
|
||||
.getRedissonClient()
|
||||
.getMap("player:" + uuid); */
|
||||
player.sendMessage(player.getLocation().getX() + " " + player.getLocation().getY() + " " + player.getLocation().getZ());
|
||||
player.sendMessage(round(player.getLocation().getX()) + " " + round(player.getLocation().getY()) + " " + round(player.getLocation().getZ()));
|
||||
}
|
||||
|
||||
public double round(double location) {
|
||||
return Math.round(location * 100.0) / 100.0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package net.krakatoaapi.listener;
|
||||
|
||||
import de.dytanic.cloudnet.driver.CloudNetDriver;
|
||||
import net.krakatoaapi.KrakatoaAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PlayerQuitListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
|
@ -13,6 +18,22 @@ public class PlayerQuitListener implements Listener {
|
|||
|
||||
event.setQuitMessage(null);
|
||||
|
||||
String uuid = KrakatoaAPI.getInstance().getFormatter().formatUuid(Objects.requireNonNull(player.getPlayer()).getUniqueId());
|
||||
|
||||
/*
|
||||
* Saving the player location when disconnecting for the next server join
|
||||
*/
|
||||
if (!CloudNetDriver.getInstance().getComponentName().startsWith("Lobby")) {
|
||||
Map<Object, Object> map = KrakatoaAPI.getInstance().getRedisManager().getPlayer(uuid);
|
||||
|
||||
if (!map.isEmpty()) {
|
||||
map.put("lastLocation", round(player.getLocation().getX()) + " " + round(player.getLocation().getY()) + " " + round(player.getLocation().getZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double round(double location) {
|
||||
return Math.round(location * 100.0) / 100.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue