-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0abb6b
commit ff5fb2b
Showing
6 changed files
with
51 additions
and
3 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
10 changes: 10 additions & 0 deletions
10
src/main/java/net/zepalesque/redux/config/enums/AACompatType.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,10 @@ | ||
package net.zepalesque.redux.config.enums; | ||
|
||
public enum AACompatType implements NamedConfig { | ||
TRUE, FALSE, WITHOUT_AA; | ||
|
||
@Override | ||
public String serialize() { | ||
return this.name().toLowerCase(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/net/zepalesque/redux/config/enums/NamedConfig.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,6 @@ | ||
package net.zepalesque.redux.config.enums; | ||
|
||
public interface NamedConfig { | ||
|
||
public String serialize(); | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/net/zepalesque/redux/mixin/mixins/common/ValueWriterMixin.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,30 @@ | ||
package net.zepalesque.redux.mixin.mixins.common; | ||
|
||
import com.electronwill.nightconfig.core.io.CharacterOutput; | ||
import com.electronwill.nightconfig.toml.TomlWriter; | ||
import net.zepalesque.redux.config.enums.NamedConfig; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
// TODO: FIND A BETTER WAY PLEASE GOD | ||
// TODO: FIND A BETTER WAY PLEASE GOD | ||
// TODO: FIND A BETTER WAY PLEASE GOD | ||
// TODO: FIND A BETTER WAY PLEASE GOD | ||
// TODO: FIND A BETTER WAY PLEASE GOD | ||
// TODO: FIND A BETTER WAY PLEASE GOD | ||
@Mixin(targets = "com.electronwill.nightconfig.toml.ValueWriter") | ||
public abstract class ValueWriterMixin { | ||
@Shadow | ||
private static void writeString(String string, CharacterOutput output, TomlWriter writer) {} | ||
|
||
@Inject(method = "write", at = @At("HEAD"), cancellable = true) | ||
private static void redux$write(Object value, CharacterOutput output, TomlWriter writer, CallbackInfo ci) { | ||
if (value instanceof NamedConfig config) { | ||
writeString(config.serialize(), output, writer); | ||
ci.cancel(); | ||
} | ||
} | ||
} |
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