Skip to content

Commit

Permalink
Skip upgrading random teleport config when tpr.yml isn't initialized …
Browse files Browse the repository at this point in the history
…yet (#6003)

If there's no tpr.yml, upgrading the random teleport config will fail
and the plugin cannot be loaded.
  • Loading branch information
henningrck authored and mdcfe committed Jan 1, 2025
1 parent 8e53214 commit 667b0f7
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,26 +164,28 @@ public void updateRandomTeleport() {

final EssentialsConfiguration config = ess.getRandomTeleport().getConfig();

final LazyLocation center = config.getLocation("center");
final Location centerLoc = center != null ? center.location() : null;
if (center != null && centerLoc != null) {
final double minRange = config.getDouble("min-range", Double.MIN_VALUE);
final double maxRange = config.getDouble("max-range", Double.MIN_VALUE);
for (final World world : ess.getServer().getWorlds()) {
final String propPrefix = "locations." + world.getName() + ".";
config.setProperty(propPrefix + "center", centerLoc);

if (minRange != Double.MIN_VALUE) {
config.setProperty(propPrefix + "min-range", minRange);
}
if (maxRange != Double.MIN_VALUE) {
config.setProperty(propPrefix + "max-range", maxRange);
if (config.getRootNode() != null) {
final LazyLocation center = config.getLocation("center");
final Location centerLoc = center != null ? center.location() : null;
if (center != null && centerLoc != null) {
final double minRange = config.getDouble("min-range", Double.MIN_VALUE);
final double maxRange = config.getDouble("max-range", Double.MIN_VALUE);
for (final World world : ess.getServer().getWorlds()) {
final String propPrefix = "locations." + world.getName() + ".";
config.setProperty(propPrefix + "center", centerLoc);

if (minRange != Double.MIN_VALUE) {
config.setProperty(propPrefix + "min-range", minRange);
}
if (maxRange != Double.MIN_VALUE) {
config.setProperty(propPrefix + "max-range", maxRange);
}
}
}
}
config.removeProperty("center");
config.removeProperty("center");

config.blockingSave();
config.blockingSave();
}

doneFile.setProperty("updateRandomTeleport", true);
doneFile.save();
Expand Down

0 comments on commit 667b0f7

Please sign in to comment.