Required method for deserialization @param args map to deserialize @return deserialized location @throws IllegalArgumentException if the world don't exists @see ConfigurationSerializable
(@NotNull Map<String, Object> args)
| 1212 | * @see ConfigurationSerializable |
| 1213 | */ |
| 1214 | @NotNull |
| 1215 | public static Location deserialize(@NotNull Map<String, Object> args) { |
| 1216 | World world = null; |
| 1217 | boolean requiresWorld = false; |
| 1218 | if (args.containsKey("world")) { |
| 1219 | world = Bukkit.getWorld((String) args.get("world")); |
| 1220 | requiresWorld = true; |
| 1221 | } |
| 1222 | if (args.containsKey("world_key")) { |
| 1223 | NamespacedKey key = NamespacedKey.fromString((String) args.get("world_key")); |
| 1224 | world = key == null ? null : Bukkit.getWorld(key); |
| 1225 | requiresWorld = true; |
| 1226 | } |
| 1227 | |
| 1228 | if (requiresWorld && world == null) { |
| 1229 | throw new IllegalArgumentException("unknown world"); |
| 1230 | } |
| 1231 | |
| 1232 | return new Location(world, NumberConversions.toDouble(args.get("x")), NumberConversions.toDouble(args.get("y")), NumberConversions.toDouble(args.get("z")), NumberConversions.toFloat(args.get("yaw")), NumberConversions.toFloat(args.get("pitch"))); |
| 1233 | } |
| 1234 | |
| 1235 | /** |
| 1236 | * Normalizes the given yaw angle to a value between <code>+/-180</code> |
nothing calls this directly
no test coverage detected