mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 12:46:46 +01:00
Extract method
This commit is contained in:
parent
1e9a27ccea
commit
ffebffec77
@ -397,62 +397,63 @@ public abstract class PlotArea implements ComponentLike {
|
||||
this.spawnCustom = config.getBoolean("event.spawn.custom");
|
||||
this.spawnBreeding = config.getBoolean("event.spawn.breeding");
|
||||
|
||||
Runnable loadFlags = () -> {
|
||||
ConsolePlayer.getConsole().sendMessage(
|
||||
TranslatableCaption.of("flags.loading_area_flags"),
|
||||
TagResolver.resolver("area", Tag.inserting(Component.text(this.id == null ? this.worldName : this.id)))
|
||||
);
|
||||
List<String> flags = config.getStringList("flags.default");
|
||||
if (flags.isEmpty()) {
|
||||
flags = config.getStringList("flags");
|
||||
if (flags.isEmpty()) {
|
||||
flags = new ArrayList<>();
|
||||
ConfigurationSection section = config.getConfigurationSection("flags");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
for (String key : keys) {
|
||||
if (!"default".equals(key)) {
|
||||
flags.add(key + ';' + section.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
parseFlags(this.getFlagContainer(), flags);
|
||||
ConsolePlayer.getConsole().sendMessage(
|
||||
TranslatableCaption.of("flags.area_flags"),
|
||||
TagResolver.resolver("flags", Tag.inserting(Component.text(flags.toString())))
|
||||
);
|
||||
|
||||
List<String> roadflags = config.getStringList("road.flags");
|
||||
if (roadflags.isEmpty()) {
|
||||
roadflags = new ArrayList<>();
|
||||
ConfigurationSection section = config.getConfigurationSection("road.flags");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
for (String key : keys) {
|
||||
if (!"default".equals(key)) {
|
||||
roadflags.add(key + ';' + section.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.roadFlags = roadflags.size() > 0;
|
||||
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();
|
||||
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, TaskTime.ticks(1));
|
||||
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)))
|
||||
);
|
||||
List<String> flags = config.getStringList("flags.default");
|
||||
if (flags.isEmpty()) {
|
||||
flags = config.getStringList("flags");
|
||||
if (flags.isEmpty()) {
|
||||
flags = new ArrayList<>();
|
||||
ConfigurationSection section = config.getConfigurationSection("flags");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
for (String key : keys) {
|
||||
if (!"default".equals(key)) {
|
||||
flags.add(key + ';' + section.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
parseFlags(this.getFlagContainer(), flags);
|
||||
ConsolePlayer.getConsole().sendMessage(
|
||||
TranslatableCaption.of("flags.area_flags"),
|
||||
TagResolver.resolver("flags", Tag.inserting(Component.text(flags.toString())))
|
||||
);
|
||||
|
||||
List<String> roadflags = config.getStringList("road.flags");
|
||||
if (roadflags.isEmpty()) {
|
||||
roadflags = new ArrayList<>();
|
||||
ConfigurationSection section = config.getConfigurationSection("road.flags");
|
||||
Set<String> keys = section.getKeys(false);
|
||||
for (String key : keys) {
|
||||
if (!"default".equals(key)) {
|
||||
roadflags.add(key + ';' + section.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
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())))
|
||||
);
|
||||
}
|
||||
|
||||
public abstract void loadConfiguration(ConfigurationSection config);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user