Extract method

This commit is contained in:
dordsor21 2023-10-03 10:15:56 +01:00
parent 1e9a27ccea
commit ffebffec77
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -397,7 +397,20 @@ public abstract class PlotArea implements ComponentLike {
this.spawnCustom = config.getBoolean("event.spawn.custom");
this.spawnBreeding = config.getBoolean("event.spawn.breeding");
Runnable loadFlags = () -> {
if (PlotSquared.get().isWeInitialised()) {
loadFlags(config);
} else {
ConsolePlayer.getConsole().sendMessage(
TranslatableCaption.of("flags.delaying_loading_area_flags"),
TagResolver.resolver("area", Tag.inserting(Component.text(this.id == null ? this.worldName : this.id)))
);
TaskManager.runTaskLater(() -> loadFlags(config), TaskTime.ticks(1));
}
loadConfiguration(config);
}
private void loadFlags(ConfigurationSection config) {
ConsolePlayer.getConsole().sendMessage(
TranslatableCaption.of("flags.loading_area_flags"),
TagResolver.resolver("area", Tag.inserting(Component.text(this.id == null ? this.worldName : this.id)))
@ -433,24 +446,12 @@ public abstract class PlotArea implements ComponentLike {
}
}
}
this.roadFlags = roadflags.size() > 0;
this.roadFlags = !roadflags.isEmpty();
parseFlags(this.getRoadFlagContainer(), roadflags);
ConsolePlayer.getConsole().sendMessage(
TranslatableCaption.of("flags.road_flags"),
TagResolver.resolver("flags", Tag.inserting(Component.text(roadflags.toString())))
);
};
if (PlotSquared.get().isWeInitialised()) {
loadFlags.run();
} else {
ConsolePlayer.getConsole().sendMessage(
TranslatableCaption.of("flags.delaying_loading_area_flags"),
TagResolver.resolver("area", Tag.inserting(Component.text(this.id == null ? this.worldName : this.id)))
);
TaskManager.runTaskLater(loadFlags, TaskTime.ticks(1));
}
loadConfiguration(config);
}
public abstract void loadConfiguration(ConfigurationSection config);