Bump Configurate

This commit is contained in:
Draycia committed 2020-10-18 03:30:53 -07:00
1 parent 4a36172cdb
commit 96385ae889
8 files changed
+34 -35

No files matched your search

@@ -7,8 +7,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.ObjectMapper; import org.spongepowered.configurate.objectmapping.ObjectMapper;
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
import org.spongepowered.configurate.objectmapping.meta.Setting; import org.spongepowered.configurate.objectmapping.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@@ -26,16 +26,16 @@ public class CommandSettingsRegistry implements Registry<String, CommandSettings
static { static {
try { try {
MAPPER = ObjectMapper.factory().get(CommandSettingsRegistry.class); MAPPER = ObjectMapper.factory().get(CommandSettingsRegistry.class);
} catch (final ObjectMappingException e) { } catch (final SerializationException e) {
throw new ExceptionInInitializerError(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); return MAPPER.load(node);
} }
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node); MAPPER.save(this, node);
} }
@@ -6,9 +6,9 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.ObjectMapper; 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.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting; import org.spongepowered.configurate.objectmapping.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@@ -24,16 +24,16 @@ public final class CarbonSettings {
static { static {
try { try {
MAPPER = ObjectMapper.factory().get(CarbonSettings.class); MAPPER = ObjectMapper.factory().get(CarbonSettings.class);
} catch (final ObjectMappingException e) { } catch (final SerializationException e) {
throw new ExceptionInInitializerError(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); return MAPPER.load(node);
} }
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node); MAPPER.save(this, node);
} }
@@ -3,8 +3,8 @@ package net.draycia.carbon.api.config;
import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.ObjectMapper; import org.spongepowered.configurate.objectmapping.ObjectMapper;
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
import org.spongepowered.configurate.objectmapping.meta.Setting; import org.spongepowered.configurate.objectmapping.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
@ConfigSerializable @ConfigSerializable
public final class CarbonTranslations { public final class CarbonTranslations {
@@ -14,16 +14,16 @@ public final class CarbonTranslations {
static { static {
try { try {
MAPPER = ObjectMapper.factory().get(CarbonTranslations.class); MAPPER = ObjectMapper.factory().get(CarbonTranslations.class);
} catch (final ObjectMappingException e) { } catch (final SerializationException e) {
throw new ExceptionInInitializerError(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); return MAPPER.load(node);
} }
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node); MAPPER.save(this, node);
} }
@@ -3,9 +3,9 @@ package net.draycia.carbon.api.config;
import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.ObjectMapper; 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.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting; import org.spongepowered.configurate.objectmapping.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
@@ -18,16 +18,16 @@ public final class ChannelSettings {
static { static {
try { try {
MAPPER = ObjectMapper.factory().get(ChannelSettings.class); MAPPER = ObjectMapper.factory().get(ChannelSettings.class);
} catch (final ObjectMappingException e) { } catch (final SerializationException e) {
throw new ExceptionInInitializerError(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); return MAPPER.load(node);
} }
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node); MAPPER.save(this, node);
} }
@@ -3,9 +3,9 @@ package net.draycia.carbon.api.config;
import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.ObjectMapper; 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.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting; import org.spongepowered.configurate.objectmapping.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@@ -21,16 +21,16 @@ public final class ModerationSettings {
static { static {
try { try {
MAPPER = ObjectMapper.factory().get(ModerationSettings.class); MAPPER = ObjectMapper.factory().get(ModerationSettings.class);
} catch (final ObjectMappingException e) { } catch (final SerializationException e) {
throw new ExceptionInInitializerError(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); return MAPPER.load(node);
} }
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node); MAPPER.save(this, node);
} }
@@ -74,11 +74,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.hocon.HoconConfigurationLoader; import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -260,7 +259,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
this.carbonSettings = CarbonSettings.loadFrom(node); this.carbonSettings = CarbonSettings.loadFrom(node);
loader.save(node); loader.save(node);
} catch (final ObjectMappingException | IOException exception) { } catch (final ConfigurateException exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
} }
@@ -273,7 +272,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
this.translations = CarbonTranslations.loadFrom(node); this.translations = CarbonTranslations.loadFrom(node);
loader.save(node); loader.save(node);
} catch (final ObjectMappingException | IOException exception) { } catch (final ConfigurateException exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
} }
@@ -286,7 +285,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
this.moderationSettings = ModerationSettings.loadFrom(node); this.moderationSettings = ModerationSettings.loadFrom(node);
loader.save(node); loader.save(node);
} catch (final ObjectMappingException | IOException exception) { } catch (final ConfigurateException exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
} }
@@ -299,7 +298,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
this.commandSettings = CommandSettingsRegistry.loadFrom(node); this.commandSettings = CommandSettingsRegistry.loadFrom(node);
loader.save(node); loader.save(node);
} catch (final ObjectMappingException | IOException exception) { } catch (final ConfigurateException exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
} }
@@ -312,7 +311,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
this.channelSettings = ChannelSettings.loadFrom(node); this.channelSettings = ChannelSettings.loadFrom(node);
loader.save(node); loader.save(node);
} catch (final ObjectMappingException | IOException exception) { } catch (final ConfigurateException exception) {
exception.printStackTrace(); exception.printStackTrace();
} }
} }
@@ -27,8 +27,8 @@ import java.lang.reflect.Type;
import java.util.function.Predicate; import java.util.function.Predicate;
import net.kyori.adventure.key.InvalidKeyException; import net.kyori.adventure.key.InvalidKeyException;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
import org.spongepowered.configurate.serialize.ScalarSerializer; import org.spongepowered.configurate.serialize.ScalarSerializer;
import org.spongepowered.configurate.serialize.SerializationException;
public final class KeySerializer extends ScalarSerializer<Key> { public final class KeySerializer extends ScalarSerializer<Key> {
public static final KeySerializer INSTANCE = new KeySerializer(); public static final KeySerializer INSTANCE = new KeySerializer();
@@ -38,15 +38,15 @@ public final class KeySerializer extends ScalarSerializer<Key> {
} }
@Override @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)) { if (!(obj instanceof CharSequence)) {
throw new ObjectMappingException("Invalid type presented to serializer: " + type); throw new SerializationException("Invalid type presented to serializer: " + type);
} }
try { try {
return Key.key(obj.toString()); return Key.key(obj.toString());
} catch(final InvalidKeyException ex) { } catch(final InvalidKeyException ex) {
throw new ObjectMappingException(ex); throw new SerializationException(ex);
} }
} }
@@ -29,7 +29,7 @@ import net.kyori.adventure.sound.Sound;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.objectmapping.ObjectMappingException; import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.serialize.TypeSerializer; import org.spongepowered.configurate.serialize.TypeSerializer;
import java.lang.reflect.Type; import java.lang.reflect.Type;
@@ -49,7 +49,7 @@ public final class SoundSerializer implements TypeSerializer<Sound> {
} }
@Override @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()) { if (value.empty()) {
return null; return null;
} }
@@ -60,14 +60,14 @@ public final class SoundSerializer implements TypeSerializer<Sound> {
final float pitch = value.node(PITCH).getFloat(1.0f); final float pitch = value.node(PITCH).getFloat(1.0f);
if (name == null || source == null) { 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); return Sound.sound(name, source, volume, pitch);
} }
@Override @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) { if (obj == null) {
value.set(null); value.set(null);
return; return;