-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport to 1.20.1 Fabric & Forge (#10)
* kill neoforge * update, fix gradle & dependencies * 1.20.1 backport first attempt * delete phases * add setflammable to forge accesstransformer.cfg * temporarily upload to jitpack * remove from jitpack * optimize imports * add ConfigSync (on fabric) * improve ConfigSync * Revert "remove from jitpack" temporary This reverts commit c290aca. * do not remap configsync * delete comments * add javadoc * some more fixes for config sync * Reapply temporary This reverts commit 109ca7e.
- Loading branch information
1 parent
580e0d9
commit 5609ec2
Showing
65 changed files
with
238 additions
and
1,384 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
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,44 +1,36 @@ | ||
/******************************************************************************* | ||
* Copyright 2023, the Glitchfiend Team. | ||
* All rights reserved. | ||
******************************************************************************/ | ||
package glitchcore.config; | ||
|
||
import glitchcore.network.SyncConfigPacket; | ||
import glitchcore.core.GlitchCore; | ||
import glitchcore.util.Environment; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
public class ConfigSync | ||
{ | ||
private static Map<String, Config> configs = new HashMap<>(); | ||
|
||
public static void register(Config config) | ||
{ | ||
String relative = Environment.getConfigPath().relativize(config.getPath()).toString(); | ||
configs.put(relative, config); | ||
} | ||
|
||
public static Stream<SyncConfigPacket> createPackets() | ||
{ | ||
return configs.entrySet().stream().map(e -> { | ||
var config = e.getValue(); | ||
|
||
// Reload the config from the filesystem, but do not save it | ||
config.read(); | ||
config.load(); | ||
|
||
return new SyncConfigPacket(e.getKey(), e.getValue().encode().getBytes(StandardCharsets.UTF_8)); | ||
}); | ||
} | ||
|
||
public static void reload(String path, String toml) | ||
{ | ||
var config = configs.get(path); | ||
config.parse(toml); | ||
config.load(); | ||
import net.minecraft.resources.ResourceLocation; | ||
|
||
public class ConfigSync { | ||
private static final ResourceLocation CONFIG_SYNC_CHANNEL = new ResourceLocation("glitchcorefabric", "config_sync"); | ||
private static final Map<String, Config> CONFIGS_BY_PATH = new HashMap<>(); | ||
private static boolean inited = false; | ||
/** | ||
* Enables sync between server and client for your config. | ||
* NOTE: This function works only on fabric, you need to implement it yourself | ||
* if you want to use it on forge | ||
* | ||
* @param config your config. | ||
*/ | ||
public static void register(Config config) { | ||
if (!inited) { | ||
initSyncs(); | ||
inited = true; | ||
} | ||
String relative = Environment.getConfigPath().relativize(config.getPath()).toString(); | ||
CONFIGS_BY_PATH.put(relative, config); | ||
} | ||
private static void initSyncs() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
private static void reload(String path, String toml) { | ||
var config = CONFIGS_BY_PATH.get(path); | ||
config.parse(toml); | ||
config.load(); | ||
} | ||
} |
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
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
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
44 changes: 0 additions & 44 deletions
44
common/src/main/java/glitchcore/mixin/MixinServerConfigurationPacketListenerImpl.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.