Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 08:30:12 +01:00
GeyserCustomSkullConfiguration uses Configurate
Dieser Commit ist enthalten in:
Ursprung
360350d44e
Commit
add02cadd7
@ -26,7 +26,10 @@ dependencies {
|
|||||||
|
|
||||||
compileOnlyApi(libs.viaversion)
|
compileOnlyApi(libs.viaversion)
|
||||||
|
|
||||||
implementation(libs.gson.record.factory) // For 1.16.5/1.17.1
|
// For 1.16.5/1.17.1
|
||||||
|
implementation(libs.gson.record.factory) {
|
||||||
|
isTransitive = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
platformRelocate("it.unimi.dsi.fastutil")
|
platformRelocate("it.unimi.dsi.fastutil")
|
||||||
|
@ -25,26 +25,21 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.configuration;
|
package org.geysermc.geyser.configuration;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@ConfigSerializable
|
||||||
@SuppressWarnings("FieldMayBeFinal") // Jackson requires that the fields are not final
|
@SuppressWarnings("FieldMayBeFinal") // Jackson requires that the fields are not final
|
||||||
public class GeyserCustomSkullConfiguration {
|
public class GeyserCustomSkullConfiguration {
|
||||||
@JsonProperty("player-usernames")
|
|
||||||
private List<String> playerUsernames;
|
private List<String> playerUsernames;
|
||||||
|
|
||||||
@JsonProperty("player-uuids")
|
|
||||||
private List<String> playerUUIDs;
|
private List<String> playerUUIDs;
|
||||||
|
|
||||||
@JsonProperty("player-profiles")
|
|
||||||
private List<String> playerProfiles;
|
private List<String> playerProfiles;
|
||||||
|
|
||||||
@JsonProperty("skin-hashes")
|
|
||||||
private List<String> skinHashes;
|
private List<String> skinHashes;
|
||||||
|
|
||||||
public List<String> getPlayerUsernames() {
|
public List<String> getPlayerUsernames() {
|
||||||
|
@ -64,7 +64,7 @@ public class CustomSkullRegistryPopulator {
|
|||||||
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();
|
GeyserBootstrap bootstrap = GeyserImpl.getInstance().getBootstrap();
|
||||||
Path skullConfigPath = bootstrap.getConfigFolder().resolve("custom-skulls.yml");
|
Path skullConfigPath = bootstrap.getConfigFolder().resolve("custom-skulls.yml");
|
||||||
File skullConfigFile = FileUtils.fileOrCopiedFromResource(skullConfigPath.toFile(), "custom-skulls.yml", Function.identity(), bootstrap);
|
File skullConfigFile = FileUtils.fileOrCopiedFromResource(skullConfigPath.toFile(), "custom-skulls.yml", Function.identity(), bootstrap);
|
||||||
skullConfig = FileUtils.loadConfig(skullConfigFile, GeyserCustomSkullConfiguration.class);
|
skullConfig = FileUtils.loadConfigNew(skullConfigFile, GeyserCustomSkullConfiguration.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
GeyserImpl.getInstance().getLogger().severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e);
|
GeyserImpl.getInstance().getLogger().severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e);
|
||||||
return;
|
return;
|
||||||
|
@ -32,6 +32,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||||
import org.geysermc.geyser.GeyserBootstrap;
|
import org.geysermc.geyser.GeyserBootstrap;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -68,6 +70,14 @@ public class FileUtils {
|
|||||||
return objectMapper.readValue(src, valueType);
|
return objectMapper.readValue(src, valueType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T loadConfigNew(File src, Class<T> valueType) throws IOException {
|
||||||
|
YamlConfigurationLoader loader = YamlConfigurationLoader.builder()
|
||||||
|
.file(src)
|
||||||
|
.build();
|
||||||
|
ConfigurationNode node = loader.load();
|
||||||
|
return node.get(valueType);
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> T loadJson(InputStream src, Class<T> valueType) {
|
public static <T> T loadJson(InputStream src, Class<T> valueType) {
|
||||||
// Read specifically with UTF-8 to allow any non-UTF-encoded JSON to read
|
// Read specifically with UTF-8 to allow any non-UTF-encoded JSON to read
|
||||||
return GeyserImpl.GSON.fromJson(new InputStreamReader(src, StandardCharsets.UTF_8), valueType);
|
return GeyserImpl.GSON.fromJson(new InputStreamReader(src, StandardCharsets.UTF_8), valueType);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren