Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions commons/src/main/java/net/swofty/commons/ServerType.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public enum ServerType {
SKYBLOCK_GALATEA(true),
SKYBLOCK_BACKWATER_BAYOU(true),
SKYBLOCK_JERRYS_WORKSHOP(true),
SKYBLOCK_LOTUS_ATOLL(true),
SKYBLOCK_SAFARI(true),
PROTOTYPE_LOBBY(false),
BEDWARS_LOBBY(false),
BEDWARS_GAME(false),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package net.swofty.commons.config;

import de.exlll.configlib.NameFormatters;
import de.exlll.configlib.YamlConfigurationProperties;
import de.exlll.configlib.YamlConfigurations;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.AtomicMoveNotSupportedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

public final class YamlConfigLoader {
private static final YamlConfigurationProperties PROPERTIES = YamlConfigurationProperties.newBuilder()
.setNameFormatter(NameFormatters.IDENTITY)
.charset(StandardCharsets.UTF_8)
.build();

private YamlConfigLoader() {
}

public static <T> T load(Path location, Class<?> resourceOwner, String resource, Class<T> configurationType) {
try (InputStream source = openSource(location, resourceOwner, resource)) {
return YamlConfigurations.read(source, configurationType, PROPERTIES);
} catch (IOException exception) {
throw new IllegalStateException("Unable to read YAML configuration " + location, exception);
}
}

public static <T> void save(Path location, Class<T> configurationType, T configuration) {
Path target = location.toAbsolutePath();
Path temporary = null;
try {
Path directory = target.getParent();
Files.createDirectories(directory);
temporary = Files.createTempFile(directory, target.getFileName().toString(), ".tmp");
YamlConfigurations.save(temporary, configurationType, configuration, PROPERTIES);
try {
Files.move(temporary, target, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
} catch (AtomicMoveNotSupportedException exception) {
Files.move(temporary, target, StandardCopyOption.REPLACE_EXISTING);
}
temporary = null;
} catch (IOException exception) {
throw new IllegalStateException("Unable to write YAML configuration " + location, exception);
} finally {
if (temporary != null) {
try {
Files.deleteIfExists(temporary);
} catch (IOException ignored) {
}
}
}
}

private static InputStream openSource(Path location, Class<?> resourceOwner, String resource) throws IOException {
if (Files.isRegularFile(location)) {
return Files.newInputStream(location);
}

InputStream source = resourceOwner.getResourceAsStream(resource);
if (source == null) {
throw new FileNotFoundException(location.toString());
}
return source;
}
}
10 changes: 0 additions & 10 deletions configuration/mongo-init.sh

This file was deleted.

13 changes: 0 additions & 13 deletions configuration/skyblock/Minestom.crystals.csv

This file was deleted.

85 changes: 85 additions & 0 deletions configuration/skyblock/Minestom.crystals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
crystals:
- id: 1
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 43.13005921622691
y: 75.1118727240194
z: -122.24967766591506
serverType: HUB
itemType: WHEAT_CRYSTAL
- id: 2
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 28.31150256073339
y: 75.48551224990652
z: -140.6871747405607
serverType: HUB
itemType: WHEAT_CRYSTAL
- id: 3
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 63.414336674908704
y: 76.97180664240655
z: -134.42058576459584
serverType: HUB
itemType: WHEAT_CRYSTAL
- id: 4
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 73.69529306049547
y: 79.21654074104354
z: -160.75138423775255
serverType: HUB
itemType: WHEAT_CRYSTAL
- id: 5
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 59.50817153963336
y: 79.21654074104354
z: -182.6970617412972
serverType: HUB
itemType: WHEAT_CRYSTAL
- id: 6
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 23.69214972882618
y: 77.72147472159656
z: -178.00258311237133
serverType: HUB
itemType: WHEAT_CRYSTAL
- id: 7
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: -7.1
y: 78.1
z: -27.1
serverType: HUB
itemType: FLOWER_CRYSTAL
- id: 8
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 134.8683294293372
y: 78.83531391075113
z: -212.77871289031293
serverType: THE_FARMING_ISLANDS
itemType: WHEAT_CRYSTAL
- id: 9
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 118.09829197561052
y: 78.0854154409095
z: -221.89615973940928
serverType: THE_FARMING_ISLANDS
itemType: WHEAT_CRYSTAL
- id: 10
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 179.6704613500174
y: 82.90219669149552
z: -216.48506739711638
serverType: THE_FARMING_ISLANDS
itemType: PUMPKIN_AND_MELON_CRYSTAL
- id: 11
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 168.39194062684598
y: 90.78562053479897
z: -269.59782005232177
serverType: THE_FARMING_ISLANDS
itemType: POTATO_CRYSTAL
- id: 12
url: 9265f96f54b78885c46e7d2f86b1c1dbfe643c6060fc7fcc9834c3e3fd595135
x: 132.578203624726
y: 91.16748587959599
z: -284.62450974516634
serverType: THE_FARMING_ISLANDS
itemType: CARROT_CRYSTAL
Loading
Loading