mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-09-27 15:22:37 +02:00
Fix remaining uses of Location over LazyLocation (#4206)
This commit is contained in:
parent
300daea4f9
commit
3d09ea386b
@ -40,7 +40,7 @@ public class RandomTeleport implements IConf {
|
|||||||
|
|
||||||
public Location getCenter() {
|
public Location getCenter() {
|
||||||
try {
|
try {
|
||||||
final Location center = config.getLocation("center");
|
final Location center = config.getLocation("center").location();
|
||||||
if (center != null) {
|
if (center != null) {
|
||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,12 @@ public class Warps implements IConf, net.ess3.api.IWarps {
|
|||||||
if (conf == null) {
|
if (conf == null) {
|
||||||
throw new WarpNotFoundException();
|
throw new WarpNotFoundException();
|
||||||
}
|
}
|
||||||
return conf.getLocation(null);
|
|
||||||
|
final Location loc = conf.getLocation(null).location();
|
||||||
|
if (loc == null) {
|
||||||
|
throw new WarpNotFoundException();
|
||||||
|
}
|
||||||
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,26 +103,26 @@ public class EssentialsConfiguration {
|
|||||||
setInternal(path, location);
|
setInternal(path, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getLocation(final String path) throws InvalidWorldException {
|
public LazyLocation getLocation(final String path) throws InvalidWorldException {
|
||||||
final CommentedConfigurationNode node = path == null ? getRootNode() : getSection(path);
|
final CommentedConfigurationNode node = path == null ? getRootNode() : getSection(path);
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return node.get(Location.class);
|
return node.get(LazyLocation.class);
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Location> getLocationSectionMap(final String path) {
|
public Map<String, LazyLocation> getLocationSectionMap(final String path) {
|
||||||
final CommentedConfigurationNode node = getSection(path);
|
final CommentedConfigurationNode node = getSection(path);
|
||||||
final Map<String, Location> result = new HashMap<>();
|
final Map<String, LazyLocation> result = new HashMap<>();
|
||||||
for (final Map.Entry<String, CommentedConfigurationNode> entry : ConfigurateUtil.getMap(node).entrySet()) {
|
for (final Map.Entry<String, CommentedConfigurationNode> entry : ConfigurateUtil.getMap(node).entrySet()) {
|
||||||
final CommentedConfigurationNode jailNode = entry.getValue();
|
final CommentedConfigurationNode jailNode = entry.getValue();
|
||||||
try {
|
try {
|
||||||
result.put(entry.getKey().toLowerCase(Locale.ENGLISH), jailNode.get(Location.class));
|
result.put(entry.getKey().toLowerCase(Locale.ENGLISH), jailNode.get(LazyLocation.class));
|
||||||
} catch (SerializationException e) {
|
} catch (SerializationException e) {
|
||||||
LOGGER.log(Level.WARNING, "Error serializing key " + entry.getKey(), e);
|
LOGGER.log(Level.WARNING, "Error serializing key " + entry.getKey(), e);
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,9 @@ public class Commandspawn extends EssentialsCommand {
|
|||||||
|
|
||||||
private void respawn(final CommandSource sender, final User teleportOwner, final User teleportee, final Trade charge, final String commandLabel, final CompletableFuture<Boolean> future) throws Exception {
|
private void respawn(final CommandSource sender, final User teleportOwner, final User teleportee, final Trade charge, final String commandLabel, final CompletableFuture<Boolean> future) throws Exception {
|
||||||
final Location spawn = ((SpawnStorage) this.module).getSpawn(teleportee.getGroup());
|
final Location spawn = ((SpawnStorage) this.module).getSpawn(teleportee.getGroup());
|
||||||
|
if (spawn == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
sender.sendMessage(tl("teleporting", spawn.getWorld().getName(), spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()));
|
sender.sendMessage(tl("teleporting", spawn.getWorld().getName(), spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ()));
|
||||||
future.exceptionally(e -> {
|
future.exceptionally(e -> {
|
||||||
showError(sender.getSender(), e, commandLabel);
|
showError(sender.getSender(), e, commandLabel);
|
||||||
|
@ -85,6 +85,9 @@ class EssentialsSpawnPlayerListener implements Listener {
|
|||||||
if (ess.getSettings().isUserInSpawnOnJoinGroup(user) && !user.isAuthorized("essentials.spawn-on-join.exempt")) {
|
if (ess.getSettings().isUserInSpawnOnJoinGroup(user) && !user.isAuthorized("essentials.spawn-on-join.exempt")) {
|
||||||
ess.scheduleSyncDelayedTask(() -> {
|
ess.scheduleSyncDelayedTask(() -> {
|
||||||
final Location spawn = spawns.getSpawn(user.getGroup());
|
final Location spawn = spawns.getSpawn(user.getGroup());
|
||||||
|
if (spawn == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
final CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||||
future.exceptionally(e -> {
|
future.exceptionally(e -> {
|
||||||
ess.showError(user.getSource(), e, "spawn-on-join");
|
ess.showError(user.getSource(), e, "spawn-on-join");
|
||||||
|
@ -3,6 +3,7 @@ package com.earth2me.essentials.spawn;
|
|||||||
import com.earth2me.essentials.IConf;
|
import com.earth2me.essentials.IConf;
|
||||||
import com.earth2me.essentials.IEssentialsModule;
|
import com.earth2me.essentials.IEssentialsModule;
|
||||||
import com.earth2me.essentials.config.EssentialsConfiguration;
|
import com.earth2me.essentials.config.EssentialsConfiguration;
|
||||||
|
import com.earth2me.essentials.config.entities.LazyLocation;
|
||||||
import net.ess3.api.IEssentials;
|
import net.ess3.api.IEssentials;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -15,7 +16,7 @@ import java.util.Map;
|
|||||||
public class SpawnStorage implements IEssentialsModule, IConf {
|
public class SpawnStorage implements IEssentialsModule, IConf {
|
||||||
private final IEssentials ess;
|
private final IEssentials ess;
|
||||||
private final EssentialsConfiguration config;
|
private final EssentialsConfiguration config;
|
||||||
private final Map<String, Location> spawns = new HashMap<>();
|
private final Map<String, LazyLocation> spawns = new HashMap<>();
|
||||||
|
|
||||||
SpawnStorage(final IEssentials ess) {
|
SpawnStorage(final IEssentials ess) {
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
@ -36,7 +37,7 @@ public class SpawnStorage implements IEssentialsModule, IConf {
|
|||||||
void setSpawn(final Location loc, String group) {
|
void setSpawn(final Location loc, String group) {
|
||||||
group = group.toLowerCase(Locale.ENGLISH);
|
group = group.toLowerCase(Locale.ENGLISH);
|
||||||
synchronized (spawns) {
|
synchronized (spawns) {
|
||||||
spawns.put(group, loc);
|
spawns.put(group, LazyLocation.fromLocation(loc));
|
||||||
config.setProperty("spawns." + group, loc);
|
config.setProperty("spawns." + group, loc);
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
@ -52,7 +53,7 @@ public class SpawnStorage implements IEssentialsModule, IConf {
|
|||||||
if (!spawns.containsKey(group)) {
|
if (!spawns.containsKey(group)) {
|
||||||
return getWorldSpawn();
|
return getWorldSpawn();
|
||||||
}
|
}
|
||||||
return spawns.get(group);
|
return spawns.get(group).location();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user