mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Bump Configurate
This commit is contained in:
1 parent
4a36172cdb
commit
96385ae889
8 files changed
+34
-35
No files matched your search
+4
-4
@@ -7,8 +7,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -26,16 +26,16 @@ public class CommandSettingsRegistry implements Registry<String, CommandSettings
|
||||
static {
|
||||
try {
|
||||
MAPPER = ObjectMapper.factory().get(CommandSettingsRegistry.class);
|
||||
} catch (final ObjectMappingException e) {
|
||||
} catch (final SerializationException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static CommandSettingsRegistry loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public static CommandSettingsRegistry loadFrom(final CommentedConfigurationNode node) throws SerializationException {
|
||||
return MAPPER.load(node);
|
||||
}
|
||||
|
||||
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
|
||||
MAPPER.save(this, node);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -24,16 +24,16 @@ public final class CarbonSettings {
|
||||
static {
|
||||
try {
|
||||
MAPPER = ObjectMapper.factory().get(CarbonSettings.class);
|
||||
} catch (final ObjectMappingException e) {
|
||||
} catch (final SerializationException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static CarbonSettings loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public static CarbonSettings loadFrom(final CommentedConfigurationNode node) throws SerializationException {
|
||||
return MAPPER.load(node);
|
||||
}
|
||||
|
||||
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
|
||||
MAPPER.save(this, node);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package net.draycia.carbon.api.config;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
@ConfigSerializable
|
||||
public final class CarbonTranslations {
|
||||
@@ -14,16 +14,16 @@ public final class CarbonTranslations {
|
||||
static {
|
||||
try {
|
||||
MAPPER = ObjectMapper.factory().get(CarbonTranslations.class);
|
||||
} catch (final ObjectMappingException e) {
|
||||
} catch (final SerializationException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static CarbonTranslations loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public static CarbonTranslations loadFrom(final CommentedConfigurationNode node) throws SerializationException {
|
||||
return MAPPER.load(node);
|
||||
}
|
||||
|
||||
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
|
||||
MAPPER.save(this, node);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package net.draycia.carbon.api.config;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
@@ -18,16 +18,16 @@ public final class ChannelSettings {
|
||||
static {
|
||||
try {
|
||||
MAPPER = ObjectMapper.factory().get(ChannelSettings.class);
|
||||
} catch (final ObjectMappingException e) {
|
||||
} catch (final SerializationException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static ChannelSettings loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public static ChannelSettings loadFrom(final CommentedConfigurationNode node) throws SerializationException {
|
||||
return MAPPER.load(node);
|
||||
}
|
||||
|
||||
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
|
||||
MAPPER.save(this, node);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package net.draycia.carbon.api.config;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -21,16 +21,16 @@ public final class ModerationSettings {
|
||||
static {
|
||||
try {
|
||||
MAPPER = ObjectMapper.factory().get(ModerationSettings.class);
|
||||
} catch (final ObjectMappingException e) {
|
||||
} catch (final SerializationException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static ModerationSettings loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public static ModerationSettings loadFrom(final CommentedConfigurationNode node) throws SerializationException {
|
||||
return MAPPER.load(node);
|
||||
}
|
||||
|
||||
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException {
|
||||
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
|
||||
MAPPER.save(this, node);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,11 +74,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -260,7 +259,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
|
||||
this.carbonSettings = CarbonSettings.loadFrom(node);
|
||||
loader.save(node);
|
||||
} catch (final ObjectMappingException | IOException exception) {
|
||||
} catch (final ConfigurateException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -273,7 +272,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
|
||||
this.translations = CarbonTranslations.loadFrom(node);
|
||||
loader.save(node);
|
||||
} catch (final ObjectMappingException | IOException exception) {
|
||||
} catch (final ConfigurateException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -286,7 +285,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
|
||||
this.moderationSettings = ModerationSettings.loadFrom(node);
|
||||
loader.save(node);
|
||||
} catch (final ObjectMappingException | IOException exception) {
|
||||
} catch (final ConfigurateException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -299,7 +298,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
|
||||
this.commandSettings = CommandSettingsRegistry.loadFrom(node);
|
||||
loader.save(node);
|
||||
} catch (final ObjectMappingException | IOException exception) {
|
||||
} catch (final ConfigurateException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -312,7 +311,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
|
||||
this.channelSettings = ChannelSettings.loadFrom(node);
|
||||
loader.save(node);
|
||||
} catch (final ObjectMappingException | IOException exception) {
|
||||
} catch (final ConfigurateException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.lang.reflect.Type;
|
||||
import java.util.function.Predicate;
|
||||
import net.kyori.adventure.key.InvalidKeyException;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
import org.spongepowered.configurate.serialize.ScalarSerializer;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
public final class KeySerializer extends ScalarSerializer<Key> {
|
||||
public static final KeySerializer INSTANCE = new KeySerializer();
|
||||
@@ -38,15 +38,15 @@ public final class KeySerializer extends ScalarSerializer<Key> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key deserialize(final Type type, final Object obj) throws ObjectMappingException {
|
||||
public Key deserialize(final Type type, final Object obj) throws SerializationException {
|
||||
if (!(obj instanceof CharSequence)) {
|
||||
throw new ObjectMappingException("Invalid type presented to serializer: " + type);
|
||||
throw new SerializationException("Invalid type presented to serializer: " + type);
|
||||
}
|
||||
|
||||
try {
|
||||
return Key.key(obj.toString());
|
||||
} catch(final InvalidKeyException ex) {
|
||||
throw new ObjectMappingException(ex);
|
||||
throw new SerializationException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ import net.kyori.adventure.sound.Sound;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.serialize.TypeSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@@ -49,7 +49,7 @@ public final class SoundSerializer implements TypeSerializer<Sound> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Sound deserialize(@NonNull final Type type, @NonNull final ConfigurationNode value) throws ObjectMappingException {
|
||||
public @Nullable Sound deserialize(@NonNull final Type type, @NonNull final ConfigurationNode value) throws SerializationException {
|
||||
if (value.empty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -60,14 +60,14 @@ public final class SoundSerializer implements TypeSerializer<Sound> {
|
||||
final float pitch = value.node(PITCH).getFloat(1.0f);
|
||||
|
||||
if (name == null || source == null) {
|
||||
throw new ObjectMappingException("A name and source are required to deserialize a Sound");
|
||||
throw new SerializationException("A name and source are required to deserialize a Sound");
|
||||
}
|
||||
|
||||
return Sound.sound(name, source, volume, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NonNull final Type type, @Nullable final Sound obj, @NonNull final ConfigurationNode value) throws ObjectMappingException {
|
||||
public void serialize(@NonNull final Type type, @Nullable final Sound obj, @NonNull final ConfigurationNode value) throws SerializationException {
|
||||
if (obj == null) {
|
||||
value.set(null);
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user