mirror of
https://github.com/Freezy-Studios/BlazeSMP.git
synced 2025-04-21 19:44:05 +02:00
fixed homes
This commit is contained in:
parent
088ce798c6
commit
916881e628
4 changed files with 14 additions and 11 deletions
|
@ -8,7 +8,6 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,7 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class VanishCommand extends SimpleCommand {
|
public class VanishCommand extends SimpleCommand {
|
||||||
private final Map<UUID, Boolean> vanishedPlayers = new HashMap();
|
private final Map<UUID, Boolean> vanishedPlayers = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public VanishCommand() {
|
public VanishCommand() {
|
||||||
|
|
|
@ -43,7 +43,8 @@ public class Homes {
|
||||||
}
|
}
|
||||||
try (FileReader reader = new FileReader(file)) {
|
try (FileReader reader = new FileReader(file)) {
|
||||||
// Use a TypeToken to handle the Map<String, LocationJson> structure
|
// Use a TypeToken to handle the Map<String, LocationJson> structure
|
||||||
Type type = new TypeToken<Map<String, LocationJson>>() {}.getType();
|
Type type = new TypeToken<Map<String, LocationJson>>() {
|
||||||
|
}.getType();
|
||||||
Map<String, LocationJson> jsonMap = GSON.fromJson(reader, type);
|
Map<String, LocationJson> jsonMap = GSON.fromJson(reader, type);
|
||||||
if (jsonMap == null) {
|
if (jsonMap == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -58,17 +59,19 @@ public class Homes {
|
||||||
}
|
}
|
||||||
LocationJson locJson = entry.getValue();
|
LocationJson locJson = entry.getValue();
|
||||||
// Assume the default world "world" for homes
|
// Assume the default world "world" for homes
|
||||||
World world = Bukkit.getWorld("world");
|
|
||||||
if (world == null) {
|
|
||||||
LOGGER.warning("Default world 'world' not found. Skipping home for " + uuid);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
double x = Double.parseDouble(locJson.x);
|
double x = Double.parseDouble(locJson.x);
|
||||||
double y = Double.parseDouble(locJson.y);
|
double y = Double.parseDouble(locJson.y);
|
||||||
double z = Double.parseDouble(locJson.z);
|
double z = Double.parseDouble(locJson.z);
|
||||||
float yaw = Float.parseFloat(locJson.yaw);
|
float yaw = Float.parseFloat(locJson.yaw);
|
||||||
float pitch = Float.parseFloat(locJson.pitch);
|
float pitch = Float.parseFloat(locJson.pitch);
|
||||||
|
String worldName = locJson.world;
|
||||||
|
World world = Bukkit.getWorld(worldName);
|
||||||
|
if (world == null) {
|
||||||
|
LOGGER.warning("World '%s' not found. Skipping home for %s".formatted(worldName, uuid));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Location location = new Location(world, x, y, z, yaw, pitch);
|
Location location = new Location(world, x, y, z, yaw, pitch);
|
||||||
homes.put(uuid, location);
|
homes.put(uuid, location);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
|
@ -94,6 +97,7 @@ public class Homes {
|
||||||
locJson.z = String.valueOf(location.getZ());
|
locJson.z = String.valueOf(location.getZ());
|
||||||
locJson.yaw = String.valueOf(location.getYaw());
|
locJson.yaw = String.valueOf(location.getYaw());
|
||||||
locJson.pitch = String.valueOf(location.getPitch());
|
locJson.pitch = String.valueOf(location.getPitch());
|
||||||
|
locJson.world = location.getWorld().getName();
|
||||||
jsonMap.put(entry.getKey().toString(), locJson);
|
jsonMap.put(entry.getKey().toString(), locJson);
|
||||||
}
|
}
|
||||||
File file = new File(FILE_PATH);
|
File file = new File(FILE_PATH);
|
||||||
|
@ -138,5 +142,6 @@ public class Homes {
|
||||||
String z;
|
String z;
|
||||||
String yaw;
|
String yaw;
|
||||||
String pitch;
|
String pitch;
|
||||||
|
String world;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"y": "",
|
"y": "",
|
||||||
"z": "",
|
"z": "",
|
||||||
"yaw": "",
|
"yaw": "",
|
||||||
"pitch": ""
|
"pitch": "",
|
||||||
|
"world": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue