-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement custom chat representations for configs (#16)
* Implement custom chat representations for configs * Make JavaDoc clearer * Implement Component type in both fabric and paper modules to avoid accidental mistakes * Actually implement platform-specific API interface * Make string argument nullable for stringToComponent * Tighten type bound * Use correct Nullable type
- Loading branch information
Showing
28 changed files
with
334 additions
and
101 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
common/src/main/java/dev/xpple/betterconfig/api/AbstractBetterConfigAPI.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,17 @@ | ||
package dev.xpple.betterconfig.api; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
/** | ||
* @param <P> the chat component type: {@link net.minecraft.network.chat.Component} on Fabric | ||
* and {@link net.kyori.adventure.text.Component} on Paper | ||
*/ | ||
@ApiStatus.Internal | ||
public interface AbstractBetterConfigAPI<P> { | ||
/** | ||
* Get the configurations for the specified mod. | ||
* @param modId the mod's identifier | ||
* @return the configurations for the specified mod | ||
*/ | ||
ModConfig<P> getModConfig(String modId); | ||
} |
16 changes: 0 additions & 16 deletions
16
common/src/main/java/dev/xpple/betterconfig/api/BetterConfigAPI.java
This file was deleted.
Oops, something went wrong.
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
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
26 changes: 26 additions & 0 deletions
26
common/src/main/java/dev/xpple/betterconfig/impl/AbstractBetterConfigImpl.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,26 @@ | ||
package dev.xpple.betterconfig.impl; | ||
|
||
import dev.xpple.betterconfig.api.AbstractBetterConfigAPI; | ||
import dev.xpple.betterconfig.api.ModConfig; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public abstract class AbstractBetterConfigImpl<P> implements AbstractBetterConfigAPI<P> { | ||
|
||
private static final Map<String, ModConfigImpl<?, ?, ?>> modConfigs = new HashMap<>(); | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public ModConfig<P> getModConfig(String modId) { | ||
ModConfig<P> modConfig = (ModConfig<P>) modConfigs.get(modId); | ||
if (modConfig == null) { | ||
throw new IllegalArgumentException(modId); | ||
} | ||
return modConfig; | ||
} | ||
|
||
public static Map<String, ModConfigImpl<?, ?, ?>> getModConfigs() { | ||
return modConfigs; | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
common/src/main/java/dev/xpple/betterconfig/impl/BetterConfigImpl.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.