Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paper support #5

Merged
merged 38 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0e14855
[TODO] Paper support
xpple Jul 18, 2023
8baba7d
Merge remote-tracking branch 'origin/master' into multi-platform
xpple Jul 19, 2023
31c5779
Thank you @DJtheRedstoner
xpple Jul 19, 2023
458e17f
Fix entrypoint for Paper
xpple Jul 20, 2023
ee371c3
Fix command registration + feedback
xpple Jul 22, 2023
c0da376
Add test plugin
xpple Jul 23, 2023
5d5bd4f
Update README
xpple Jul 23, 2023
72d4f0e
Fix run configurations for Fabric
xpple Jul 23, 2023
699f3d9
Update README
xpple Jul 23, 2023
faa693f
Merge remote-tracking branch 'origin/master' into multi-platform
xpple Jul 24, 2023
f070a96
Merge remote-tracking branch 'origin/master' into multi-platform
xpple Aug 18, 2023
e8ad1b6
Merge remote-tracking branch 'origin/master' into multi-platform
xpple Aug 18, 2023
a158565
Merge remote-tracking branch 'origin/master' into multi-platform
xpple Aug 19, 2023
dced79e
Merge remote-tracking branch 'origin/master' into multi-platform
xpple Aug 19, 2023
2f391e9
Add platform service + fix bug in production
xpple Aug 19, 2023
9d00171
Merge remote-tracking branch 'origin/master' into multi-platform
xpple Aug 25, 2023
97c99dd
Rename config field
xpple Aug 25, 2023
3f4e01c
Merge remote-tracking branch 'origin/master' into multi-platform
xpple Oct 5, 2023
b94c956
Merge remote-tracking branch 'origin/master' into multi-platform
xpple Feb 21, 2024
8aa1571
Update to 1.20.4
xpple Feb 21, 2024
80a8979
Port to mojmap + add custom argument type example
xpple Feb 23, 2024
bc9139f
Add wrapped argument types for Fabric servers
xpple Feb 24, 2024
e3377dd
Remove suggestors in favour of wrapped argument types
xpple Feb 28, 2024
2f5fb0a
Clean up command building
xpple Apr 22, 2024
c09ea1c
Delete Pair class
xpple Apr 22, 2024
9ebaa8f
Delete leftover material suggestion provider class
xpple Apr 22, 2024
230de00
Update to Minecraft 1.20.6
xpple May 15, 2024
41a24e5
Update workflows
xpple May 15, 2024
4658514
Use deep copied value when resetting config
xpple May 15, 2024
ec5e753
Merge remote-tracking branch 'refs/remotes/origin/master' into multi-…
xpple Jun 14, 2024
86065ed
What was I thinking???
xpple Aug 5, 2024
7f57c61
Update Gradle
xpple Aug 5, 2024
46d2445
Use minecraft_version property
xpple Aug 5, 2024
f023414
base_version -> version
xpple Aug 5, 2024
8517aad
Remove sources jar
xpple Aug 5, 2024
c32b07c
Update README
xpple Aug 5, 2024
6d04c4f
Reset version
xpple Aug 5, 2024
7e3952e
version -> mod_version
xpple Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 43 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,47 @@ public class Configs {
public static String exampleString = "default";
}
```
Finally, in your mod's `onInitialize(Client)` method, register the `Configs` class. Replace `<mod id>` with your mod's
id.
```java
new ModConfigBuilder(<mod id>, Configs.class).build();
```
That's it! Now you can access `exampleString` through `Configs.exampleString`. You can edit `exampleString` by executing
the following command.
```
/(c)config <mod id> exampleString set <string>
```
Finally, register your `Configs` class.
- For Fabric users, register the `Configs` class in your mod's `onInitialize(Client)` method. Replace `<mod id>` with your
mod's id. Sometimes you may omit the generics and just do `<>` instead.
- On clients:
```java
new ModConfigBuilder<FabricClientCommandSource, CommandBuildContext>(<mod id>, Configs.class).build();
```
- On servers:
```java
new ModConfigBuilder<CommandSourceStack, CommandBuildContext>(<mod id>, Configs.class).build();
```
- For Paper users, register the `Configs` class in your plugin's `onEnable` method. Replace `<plugin name>` with your
plugin's name.
```java
new ModConfigBuilder<>(<plugin name>, Configs.class).build();
```
That's it! Now you can access `exampleString` through `Configs.exampleString`. You can edit `exampleString` by using the
config command.
- On Fabric there are different commands for the client and server. For both, replace `<mod id>` with your mod's id.
- On clients, execute `/cconfig <mod id> exampleString set <string>`.
- On servers, execute `/config <mod id> exampleString set <string>`.
- On Paper servers, execute `/config <plugin name> exampleString set <string>`. Replace `<plugin name>` with your
plugin's name.

## That's not all!
This mod also supports the use of `Collection`s and `Map`s as variable types. These configurations will have the options
`add`, `put` and `remove` available. Moreover, you can define your own (de)serialisers to create configurations with
arbitrary types. To do this, all you have to do is register the (de)serialiser when you build your config. For instance,
to create a variable with type `Block` you can do
This mod also natively supports the use of `Collection`s and `Map`s as variable types. These configurations will have
the options `add`, `put` and `remove` available. Moreover, you can define your own (de)serialisers to create
configurations with arbitrary types. To do this, all you have to do is register the (de)serialiser when you build your
config. For instance, to create configurations with type `Block` you can do
```java
new ModConfigBuilder(<mod id>, Configs.class)
new ModConfigBuilder<>(<mod id>, Configs.class)
.registerTypeHierarchy(Block.class, new BlockAdapter(), BlockArgumentType::block)
.build();
```
where `BlockAdapter` extends `TypeAdapter<Block>` and `BlockArgumentType` implements `ArgumentType<Block>`. See
[these tests](src/testmod/java/dev/xpple/betterconfig) for a complete picture.
where `BlockAdapter` extends `TypeAdapter<Block>` and `BlockArgumentType` implements `ArgumentType<Block>`. See
[these tests](fabric/src/testmod/java/dev/xpple/betterconfig) for a complete picture. An identical setup for Paper can
be found [here](paper/src/testplugin/java/dev/xpple/betterconfig).

Furthermore, you can completely change the behaviour of updating your config values by creating your own methods. Simply
add one or more of `setter`, `adder`, `putter` or `remover` as attribute to your `@Config` annotation. A great use for
this would be adding key-pair entries to a `Map` based on a single value. Consider the following configuration.
this would be adding key-value entries to a `Map` based on a single value. Consider the following configuration.
```java
@Config(putter = @Config.Putter("none"), adder = @Config.Adder("customMapAdder"))
public static Map<String, String> exampleMapAdder = new HashMap<>(Map.of("a", "A", "b", "B"));
Expand All @@ -48,7 +62,7 @@ public static void customMapAdder(String string) {
```
The value of `"none"` for the putter indicates that no putter will be available. This way, you can use this `Map` in your
code like usual, and add values to it using `/(c)config <mod id> exampleMapAdder add <string>`. For more details, see
[the JavaDocs for `@Config`](src/main/java/dev/xpple/betterconfig/api/Config.java).
[the JavaDocs for `@Config`](common/src/main/java/dev/xpple/betterconfig/api/Config.java).

The parameters of the update method can also be customised.
```java
Expand All @@ -60,8 +74,13 @@ public static void customTypeAdder(int codepoint) {
```
For putters, there are separate key and value type attributes.

And many more things! For some illustrative examples, see the `Configs` class for both
[Fabric](fabric/src/testmod/java/dev/xpple/betterconfig/Configs.java) and
[Paper](paper/src/testplugin/java/dev/xpple/betterconfig/Configs.java).

## Installation
Replace `${version}` with the artifact version.
Replace `${version}` with the artifact version. Append `-fabric` for Fabric and `-paper` for Paper to the base artifact
name.

You may choose between my own maven repository and GitHub's package repository.
### My own
Expand All @@ -87,6 +106,9 @@ repositories {
Import it:
```gradle
dependencies {
include modImplementation('dev.xpple:betterconfig:${betterconfig_version}')
// Fabric
include modImplementation('dev.xpple:betterconfig-fabric:${betterconfig-version}')
// Paper (also include the JAR in the plugins folder)
compileOnly 'dev.xpple:betterconfig-paper:${betterconfig_version}'
}
```
132 changes: 0 additions & 132 deletions build.gradle

This file was deleted.

40 changes: 40 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
plugins {
id 'fabric-loom' version '1.7-SNAPSHOT'
}

base {
archivesName = project.archives_base_name
version = project.mod_version
group = project.maven_group
}

repositories {
maven {
url = 'https://maven.parchmentmc.org'
}
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.layered {
officialMojangMappings {
nameSyntheticMembers = true
}
parchment "org.parchmentmc.data:${project.parchment_mappings}"
}
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 21
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
from("LICENSE") {
rename {"${it}_${project.base.archivesName.get()}"}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.xpple.betterconfig;

import org.jetbrains.annotations.ApiStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ApiStatus.Internal
public class BetterConfigCommon {
public static final String MOD_ID = "betterconfig";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import dev.xpple.betterconfig.impl.BetterConfigImpl;

public interface BetterConfigAPI {

static BetterConfigAPI getInstance() {
return BetterConfigImpl.INSTANCE;
}
Expand Down
Loading
Loading