-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relocate and create Configurate API wrapper (#296)
- ConfigurationNode has been replaced with the ConfigNode wrapper class in api and api-bukkit - Configurate is no longer included in the api as a dependency
- Loading branch information
Showing
42 changed files
with
668 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
api/src/main/java/dev/aurelium/auraskills/api/config/ConfigNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package dev.aurelium.auraskills.api.config; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.lang.reflect.Type; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* An interface that copies the Configurate ConfigurationNode and is | ||
* implemented by it under the hood. This is used in the API to allow | ||
* AuraSkills to relocate Configurate packages while keeping API configuration | ||
* functionality. All methods work exactly like ConfigurationNode from Configurate, | ||
* though not all methods are available. | ||
*/ | ||
public interface ConfigNode { | ||
|
||
@Nullable Object key(); | ||
|
||
@Nullable ConfigNode parent(); | ||
|
||
ConfigNode node(Object... path); | ||
|
||
ConfigNode node(Iterable<?> path); | ||
|
||
boolean hasChild(Object... path); | ||
|
||
boolean hasChild(Iterable<?> path); | ||
|
||
boolean virtual(); | ||
|
||
boolean isNull(); | ||
|
||
boolean isList(); | ||
|
||
boolean isMap(); | ||
|
||
boolean empty(); | ||
|
||
List<? extends ConfigNode> childrenList(); | ||
|
||
Map<Object, ? extends ConfigNode> childrenMap(); | ||
|
||
<V> @Nullable V get(Class<V> type); | ||
|
||
<V> V get(Class<V> type, V def); | ||
|
||
<V> V get(Class<V> type, Supplier<V> defSupplier); | ||
|
||
@Nullable Object get(Type type); | ||
|
||
Object get(Type type, Object def); | ||
|
||
Object get(Type type, Supplier<?> defSupplier); | ||
|
||
<V> @Nullable List<V> getList(Class<V> type); | ||
|
||
<V> List<V> getList(Class<V> elementType, List<V> def); | ||
|
||
<V> List<V> getList(Class<V> elementType, Supplier<List<V>> defSupplier); | ||
|
||
@Nullable String getString(); | ||
|
||
String getString(String def); | ||
|
||
float getFloat(); | ||
|
||
float getFloat(float def); | ||
|
||
double getDouble(); | ||
|
||
double getDouble(double def); | ||
|
||
int getInt(); | ||
|
||
int getInt(int def); | ||
|
||
long getLong(); | ||
|
||
long getLong(long def); | ||
|
||
boolean getBoolean(); | ||
|
||
boolean getBoolean(boolean def); | ||
|
||
ConfigNode set(@Nullable Object value); | ||
|
||
<V> ConfigNode set(Class<V> type, @Nullable V value); | ||
|
||
ConfigNode set(Type type, @Nullable Object value); | ||
|
||
<V> ConfigNode setList(final Class<V> elementType, final @Nullable List<V> items); | ||
|
||
@Nullable Object raw(); | ||
|
||
ConfigNode raw(Object value); | ||
|
||
@Nullable Object rawScalar(); | ||
|
||
ConfigNode from(ConfigNode other); | ||
|
||
ConfigNode mergeFrom(ConfigNode other); | ||
|
||
boolean removeChild(Object key); | ||
|
||
ConfigNode appendListNode(); | ||
|
||
ConfigNode copy(); | ||
|
||
} |
5 changes: 2 additions & 3 deletions
5
api/src/main/java/dev/aurelium/auraskills/api/loot/LootParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package dev.aurelium.auraskills.api.loot; | ||
|
||
import org.spongepowered.configurate.ConfigurationNode; | ||
import org.spongepowered.configurate.serialize.SerializationException; | ||
import dev.aurelium.auraskills.api.config.ConfigNode; | ||
|
||
@FunctionalInterface | ||
public interface LootParser { | ||
|
||
Loot parse(LootParsingContext context, ConfigurationNode config) throws SerializationException; | ||
Loot parse(LootParsingContext context, ConfigNode config); | ||
|
||
} |
4 changes: 2 additions & 2 deletions
4
api/src/main/java/dev/aurelium/auraskills/api/loot/LootParsingContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package dev.aurelium.auraskills.api.loot; | ||
|
||
import org.spongepowered.configurate.ConfigurationNode; | ||
import dev.aurelium.auraskills.api.config.ConfigNode; | ||
|
||
public interface LootParsingContext { | ||
|
||
LootValues parseValues(ConfigurationNode config); | ||
LootValues parseValues(ConfigNode config); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
api/src/main/java/dev/aurelium/auraskills/api/source/UtilityParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package dev.aurelium.auraskills.api.source; | ||
|
||
import org.spongepowered.configurate.ConfigurationNode; | ||
import org.spongepowered.configurate.serialize.SerializationException; | ||
import dev.aurelium.auraskills.api.config.ConfigNode; | ||
|
||
@FunctionalInterface | ||
public interface UtilityParser<T> { | ||
|
||
T parse(ConfigurationNode source, BaseContext context) throws SerializationException; | ||
T parse(ConfigNode source, BaseContext context); | ||
|
||
} |
5 changes: 2 additions & 3 deletions
5
api/src/main/java/dev/aurelium/auraskills/api/source/XpSourceParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package dev.aurelium.auraskills.api.source; | ||
|
||
import org.spongepowered.configurate.ConfigurationNode; | ||
import org.spongepowered.configurate.serialize.SerializationException; | ||
import dev.aurelium.auraskills.api.config.ConfigNode; | ||
|
||
@FunctionalInterface | ||
public interface XpSourceParser<T> { | ||
|
||
T parse(ConfigurationNode source, SourceContext context) throws SerializationException; | ||
T parse(ConfigNode source, SourceContext context); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.