Merge the duplicate configuration items (#151)
* do not release & push repo before finished * langs update * updateSuppression config moved up * redirect tick command option to carpet config system * optimizedDragonRespawn * diff in files * counter rules transformed * oops! * some fakeplayer options moved up * simplify * creative no clip moved * pre remove core module * pre update luminol to further fix a bug that config not saved to real file * fix up transform * fix up transform * fix up * fix up some problem in PR * redirect forgotten moved config * fix bugs in PR * refix * switch for final merge
This commit is contained in:
@@ -1,19 +1,10 @@
|
||||
package fun.bm.lophine.carpet;
|
||||
|
||||
import fun.bm.lophine.carpet.config.modules.CoreConfig;
|
||||
import fun.bm.lophine.carpet.config.modules.CounterCompatConfig;
|
||||
import fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig;
|
||||
import fun.bm.lophine.carpet.config.modules.GeneralCompatConfig;
|
||||
import fun.bm.lophine.config.modules.experiment.RedStoneConfig;
|
||||
import fun.bm.lophine.config.modules.fixes.UpdateSuppressionCrashFixConfig;
|
||||
import fun.bm.lophine.config.modules.function.CreativeFlyNoClipConfig;
|
||||
import fun.bm.lophine.carpet.config.modules.WoolHopperCounterConfig;
|
||||
import fun.bm.lophine.config.modules.function.FakeplayerConfig;
|
||||
import fun.bm.lophine.config.modules.function.LanguageConfig;
|
||||
import fun.bm.lophine.config.modules.function.WoolHopperCounterConfig;
|
||||
import fun.bm.lophine.protocol.CarpetLoggerProtocol;
|
||||
import me.earthme.luminol.config.modules.experiment.CommandConfig;
|
||||
import me.earthme.luminol.config.modules.optimizations.OptimizedDragonRespawnConfig;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.protocol.CarpetServerProtocol;
|
||||
|
||||
import java.util.List;
|
||||
@@ -23,42 +14,11 @@ public final class CarpetCompatSync {
|
||||
private static boolean init = false;
|
||||
|
||||
public static void apply() {
|
||||
if (init) return;
|
||||
if (CoreConfig.enabled) {
|
||||
applyGeneralRules();
|
||||
applyFakePlayerRules();
|
||||
applyCounterRules();
|
||||
}
|
||||
CarpetLoggerProtocol.refreshConfiguredDefaults(!init);
|
||||
registerProtocolRules();
|
||||
init = true;
|
||||
}
|
||||
|
||||
private static void applyGeneralRules() {
|
||||
LanguageConfig.lang = GeneralCompatConfig.language;
|
||||
UpdateSuppressionCrashFixConfig.enabled = GeneralCompatConfig.amsUpdateSuppressionCrashFix || GeneralCompatConfig.yeetUpdateSuppressionCrash;
|
||||
RedStoneConfig.redstoneIgnoreUpwardsUpdate = GeneralCompatConfig.dustTrapdoorReintroduced;
|
||||
RedStoneConfig.cce = GeneralCompatConfig.shulkerBoxCCEReintroduced;
|
||||
RedStoneConfig.instantBlockUpdater = GeneralCompatConfig.instantBlockUpdaterReintroduced;
|
||||
CommandConfig.tick = GeneralCompatConfig.commandTick;
|
||||
CreativeFlyNoClipConfig.enabled = GeneralCompatConfig.creativeNoClip;
|
||||
OptimizedDragonRespawnConfig.optimizedRespawn = GeneralCompatConfig.optimizedDragonRespawn;
|
||||
}
|
||||
|
||||
private static void applyFakePlayerRules() {
|
||||
FakeplayerConfig.enable = FakePlayerCompatConfig.commandBot || FakePlayerCompatConfig.commandPlayer;
|
||||
FakeplayerConfig.canResident = FakePlayerCompatConfig.fakePlayerResident;
|
||||
FakeplayerConfig.canOpenInventory = FakePlayerCompatConfig.openFakePlayerInventory;
|
||||
FakeplayerConfig.tickType = FakePlayerCompatConfig.fakePlayerTicksLikeRealPlayer
|
||||
? ServerBot.TickType.NETWORK
|
||||
: ServerBot.TickType.ENTITY_LIST;
|
||||
}
|
||||
|
||||
private static void applyCounterRules() {
|
||||
WoolHopperCounterConfig.enabled = CounterCompatConfig.hopperCounters;
|
||||
WoolHopperCounterConfig.unlimitedSpeed = CounterCompatConfig.hopperCountersUnlimitedSpeed;
|
||||
}
|
||||
|
||||
private static List<String> sanitizeDefaultLoggers(List<String> configuredLoggers) {
|
||||
return configuredLoggers == null ? List.of() : List.copyOf(configuredLoggers);
|
||||
}
|
||||
@@ -119,7 +79,7 @@ public final class CarpetCompatSync {
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "tntFuseDuration", GeneralCompatConfig.normalizedTntFuseDuration()));
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "defaultLoggers", CarpetLoggerProtocol.serializeConfiguredDefaults(sanitizeDefaultLoggers(GeneralCompatConfig.defaultLoggers))));
|
||||
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "commandBot", FakePlayerCompatConfig.commandBot));
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "commandBot", FakeplayerConfig.enable));
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "commandPlayer", FakePlayerCompatConfig.commandPlayer));
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "fakePlayerResident", FakePlayerCompatConfig.fakePlayerResident));
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "openFakePlayerInventory", FakePlayerCompatConfig.openFakePlayerInventory));
|
||||
@@ -132,7 +92,7 @@ public final class CarpetCompatSync {
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "fakePlayerAutoFish", FakePlayerCompatConfig.fakePlayerAutoFish));
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("lophine", "fakePlayerReloadAction", FakePlayerCompatConfig.fakePlayerReloadAction));
|
||||
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "hopperCounters", CounterCompatConfig.hopperCounters));
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "hopperCountersUnlimitedSpeed", CounterCompatConfig.hopperCountersUnlimitedSpeed));
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "hopperCounters", WoolHopperCounterConfig.hopperCounters));
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpettisaddition", "hopperCountersUnlimitedSpeed", WoolHopperCounterConfig.hopperCountersUnlimitedSpeed));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
package fun.bm.lophine.carpet;
|
||||
|
||||
import fun.bm.lophine.carpet.config.modules.GeneralCompatConfig;
|
||||
import fun.bm.lophine.carpet.config.modules.WoolHopperCounterConfig;
|
||||
import fun.bm.lophine.config.modules.function.FakeplayerConfig;
|
||||
import me.earthme.luminol.config.ConfigManager;
|
||||
import me.earthme.luminol.config.ConfigsInstance;
|
||||
|
||||
public class RedirectedConfigs {
|
||||
public static void redirect() {
|
||||
updateSuppressionCrashFix();
|
||||
commandTick();
|
||||
optimizedDragonRespawn();
|
||||
woolHopperCounter();
|
||||
fakeplayer();
|
||||
creativeFlyNoClip();
|
||||
redstoneChanges();
|
||||
}
|
||||
|
||||
private static void updateSuppressionCrashFix() {
|
||||
ConfigsInstance config = ConfigManager.getConfigs("lophine");
|
||||
try {
|
||||
boolean updateSuppressionCrashFixEnabled = config.getConfigOrigin("fixes.update-suppression-crash-fix.enabled");
|
||||
if (updateSuppressionCrashFixEnabled) {
|
||||
ConfigsInstance carpetConfig = ConfigManager.getConfigs("lophine_carpet");
|
||||
GeneralCompatConfig.amsUpdateSuppressionCrashFix = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "general", "amsUpdateSuppressionCrashFix"}, true);
|
||||
GeneralCompatConfig.yeetUpdateSuppressionCrash = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "general", "yeetUpdateSuppressionCrash"}, true);
|
||||
}
|
||||
config.removeConfig(new String[]{"fixes", "update-suppression-crash-fix", "enabled"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void commandTick() {
|
||||
try {
|
||||
boolean shouldEnabled = false;
|
||||
// first check lophine
|
||||
try {
|
||||
ConfigsInstance config = ConfigManager.getConfigs("lophine");
|
||||
shouldEnabled = config.getConfigOrigin("experiment.command.tick_command_enabled");
|
||||
config.removeConfig(new String[]{"experiment", "command", "tick_command_enabled"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
// then check luminol
|
||||
try {
|
||||
ConfigsInstance config = ConfigManager.getConfigs("luminol");
|
||||
shouldEnabled = shouldEnabled || (boolean) config.getConfigOrigin("experiment.command.enable_tick_command");
|
||||
config.removeConfig(new String[]{"experiment", "command", "enable_tick_command"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
if (shouldEnabled) {
|
||||
ConfigsInstance carpetConfig = ConfigManager.getConfigs("lophine_carpet");
|
||||
GeneralCompatConfig.commandTick = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "general", "commandTick"}, true);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void optimizedDragonRespawn() {
|
||||
ConfigsInstance config = ConfigManager.getConfigs("luminol");
|
||||
try {
|
||||
boolean optimizedDragonRespawnEnabled = config.getConfigOrigin("optimizations.end_dragon.optimized_dragon_respawn");
|
||||
if (optimizedDragonRespawnEnabled) {
|
||||
ConfigsInstance carpetConfig = ConfigManager.getConfigs("lophine_carpet");
|
||||
GeneralCompatConfig.optimizedDragonRespawn = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "general", "optimizedDragonRespawn"}, true);
|
||||
}
|
||||
config.removeConfig(new String[]{"optimizations", "end_dragon", "optimized_dragon_respawn"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void woolHopperCounter() {
|
||||
ConfigsInstance config = ConfigManager.getConfigs("lophine");
|
||||
ConfigsInstance carpetConfig = ConfigManager.getConfigs("lophine_carpet");
|
||||
try {
|
||||
boolean woolHopperCounterEnabled = config.getConfigOrigin("function.wool-hopper-counter.enabled");
|
||||
if (woolHopperCounterEnabled) {
|
||||
WoolHopperCounterConfig.hopperCounters = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "hopper_counter", "hopperCounters"}, true);
|
||||
}
|
||||
config.removeConfig(new String[]{"function", "wool-hopper-counter", "enabled"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
boolean woolHopperCounterUnlimitedSpeed = config.getConfigOrigin("function.wool-hopper-counter.unlimited-speed");
|
||||
if (woolHopperCounterUnlimitedSpeed) {
|
||||
WoolHopperCounterConfig.hopperCountersUnlimitedSpeed = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "hopper_counter", "hopperCountersUnlimitedSpeed"}, true);
|
||||
}
|
||||
config.removeConfig(new String[]{"function", "wool-hopper-counter", "unlimited-speed"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void fakeplayer() {
|
||||
ConfigsInstance carpetConfig = ConfigManager.getConfigs("lophine_carpet");
|
||||
try {
|
||||
boolean bot = carpetConfig.getConfigOrigin("carpet.fakeplayer.commandBot");
|
||||
if (bot) {
|
||||
try {
|
||||
ConfigsInstance lophineConfig = ConfigManager.getConfigs("lophine");
|
||||
FakeplayerConfig.enable = true;
|
||||
lophineConfig.setConfig(new String[]{"function", "fakeplayer", "enable"}, true);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
carpetConfig.removeConfig(new String[]{"carpet", "fakeplayer", "commandBot"});
|
||||
}
|
||||
|
||||
private static void creativeFlyNoClip() {
|
||||
ConfigsInstance config = ConfigManager.getConfigs("lophine");
|
||||
try {
|
||||
boolean creativeFlyNoClipEnabled = config.getConfigOrigin("function.creative_fly_no_clip.enabled");
|
||||
if (creativeFlyNoClipEnabled) {
|
||||
ConfigsInstance carpetConfig = ConfigManager.getConfigs("lophine_carpet");
|
||||
GeneralCompatConfig.creativeNoClip = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "general", "creativeNoClip"}, true);
|
||||
}
|
||||
config.removeConfig(new String[]{"function", "creative_fly_no_clip", "enabled"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private static void redstoneChanges() {
|
||||
ConfigsInstance config = ConfigManager.getConfigs("lophine");
|
||||
ConfigsInstance carpetConfig = ConfigManager.getConfigs("lophine_carpet");
|
||||
try {
|
||||
boolean dustTrapdoorReintroduced = config.getConfigOrigin("experiment.redstone.redstone-ignore-upwards-update");
|
||||
if (dustTrapdoorReintroduced) {
|
||||
GeneralCompatConfig.dustTrapdoorReintroduced = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "general", "dustTrapdoorReintroduced"}, true);
|
||||
}
|
||||
config.removeConfig(new String[]{"experiment", "redstone", "redstone-ignore-upwards-update"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
boolean shulkerBoxCCEReintroduced = config.getConfigOrigin("experiment.redstone.cce-update-suppression");
|
||||
if (shulkerBoxCCEReintroduced) {
|
||||
GeneralCompatConfig.shulkerBoxCCEReintroduced = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "general", "shulkerBoxCCEReintroduced"}, true);
|
||||
}
|
||||
config.removeConfig(new String[]{"experiment", "redstone", "cce-update-suppression"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
try {
|
||||
boolean instantBlockUpdaterReintroduced = config.getConfigOrigin("experiment.redstone.instant-block-updater");
|
||||
if (instantBlockUpdaterReintroduced) {
|
||||
GeneralCompatConfig.instantBlockUpdaterReintroduced = true;
|
||||
carpetConfig.setConfig(new String[]{"carpet", "general", "instantBlockUpdaterReintroduced"}, true);
|
||||
}
|
||||
config.removeConfig(new String[]{"experiment", "redstone", "instant-block-updater"});
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package fun.bm.lophine.carpet.config.modules;
|
||||
|
||||
import fun.bm.lophine.carpet.CarpetCompatSync;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
|
||||
@ConfigClassInfo(
|
||||
category = EnumConfigCategory.ROOT,
|
||||
name = "core",
|
||||
directory = {"carpet"}
|
||||
)
|
||||
public class CoreConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enabled", comments = """
|
||||
Enable carpet features.
|
||||
If you want to use some function from Carpet modifier,
|
||||
you need to enable it.
|
||||
(some function is not managed by this option)
|
||||
|
||||
ONLY GENERAL DIRECTORY WAS CONTROLLED BY THIS OPTION.
|
||||
WARNING: IF YOU ENABLED IT, ORIGINAL CONFIG IN LOPHINE CONFIG WILL BE OVERWRITTEN.""")
|
||||
public static boolean enabled = false;
|
||||
|
||||
@Override
|
||||
public void beforeFinalLoad() {
|
||||
CarpetCompatSync.apply();
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package fun.bm.lophine.carpet.config.modules;
|
||||
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
|
||||
@ConfigClassInfo(
|
||||
category = EnumConfigCategory.ROOT,
|
||||
name = "hopper_counter",
|
||||
directory = {"carpet"},
|
||||
comments = """
|
||||
Hopper counter compatibility mapped onto Lophine's wool hopper counter implementation."""
|
||||
)
|
||||
public class CounterCompatConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "hopperCounters", comments = """
|
||||
Enable the existing wool hopper counter implementation.""")
|
||||
public static boolean hopperCounters = false;
|
||||
|
||||
@ConfigInfo(name = "hopperCountersUnlimitedSpeed", comments = """
|
||||
Remove the hopper transfer speed limit for counters.
|
||||
Only effective when hopperCounters is enabled.""")
|
||||
public static boolean hopperCountersUnlimitedSpeed = false;
|
||||
}
|
||||
+27
-5
@@ -1,9 +1,15 @@
|
||||
package fun.bm.lophine.carpet.config.modules;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.config.flags.DoNotLoad;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.command.bot.BotCommand;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ConfigClassInfo(
|
||||
category = EnumConfigCategory.ROOT,
|
||||
@@ -14,12 +20,9 @@ import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
commandPlayer is currently backed by Lophine's /bot command surface."""
|
||||
)
|
||||
public class FakePlayerCompatConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "commandBot", comments = """
|
||||
Enable Lophine's /bot command.""")
|
||||
public static boolean commandBot = false;
|
||||
|
||||
@ConfigInfo(name = "commandPlayer", comments = """
|
||||
Map Carpet's commandPlayer rule to the same fakeplayer command surface used by /bot.""")
|
||||
Enable /player command.(not remapped)
|
||||
If you want to enable bot command, please see lophine global config.""")
|
||||
public static boolean commandPlayer = false;
|
||||
|
||||
@ConfigInfo(name = "fakePlayerResident", comments = """
|
||||
@@ -61,4 +64,23 @@ public class FakePlayerCompatConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "fakePlayerReloadAction", comments = """
|
||||
Persist queued fakeplayer actions across save and reload.""")
|
||||
public static boolean fakePlayerReloadAction = false;
|
||||
|
||||
@DoNotLoad
|
||||
private BotCommand command = null;
|
||||
|
||||
@Override
|
||||
public void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> exs) {
|
||||
if (commandPlayer) {
|
||||
command = new BotCommand("player");
|
||||
command.register();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnloaded(CommentedFileConfig configInstance) {
|
||||
if (command != null) {
|
||||
command.unregister();
|
||||
command = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+32
-9
@@ -1,8 +1,11 @@
|
||||
package fun.bm.lophine.carpet.config.modules;
|
||||
|
||||
import fun.bm.lophine.carpet.CarpetCompatSync;
|
||||
import fun.bm.lophine.carpet.RedirectedConfigs;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.config.flags.TransformedConfig;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,40 +19,47 @@ import java.util.List;
|
||||
Only rules that already have a working server-side implementation are exposed here."""
|
||||
)
|
||||
public class GeneralCompatConfig implements IConfigModule {
|
||||
@TransformedConfig(name = "language", directory = {"carpet", "general"}, transformComments = false)
|
||||
@ConfigInfo(name = "language", comments = """
|
||||
Carpet language value forwarded to lophine.function.language.lang.""")
|
||||
Carpet language value.
|
||||
ATTENTION: This config will not update in Lophine global now!""")
|
||||
public static String language = "en_us";
|
||||
|
||||
@ConfigInfo(name = "amsUpdateSuppressionCrashFix", comments = """
|
||||
Map AMS update suppression crash protection to Lophine's existing crash fix.""")
|
||||
Update suppression crash protection.""")
|
||||
public static boolean amsUpdateSuppressionCrashFix = false;
|
||||
|
||||
@ConfigInfo(name = "yeetUpdateSuppressionCrash", comments = """
|
||||
Map TIS update suppression crash yeeting to the same Lophine crash fix.""")
|
||||
Update suppression crash yeeting.""")
|
||||
public static boolean yeetUpdateSuppressionCrash = false;
|
||||
|
||||
@ConfigInfo(name = "dustTrapdoorReintroduced", comments = """
|
||||
Map dust-on-open-trapdoor behavior to Lophine's redstone-ignore-upwards-update option.""")
|
||||
Should the pre-1.20 mechanism be reintroduced:
|
||||
Redstone dust does not connect to adjacent redstone dust on trapdoors that are open
|
||||
Pre-1.20.2 mechanism: Redstone dust, redstone repeaters,
|
||||
and redstone comparators do not check for attachment when receiving status updates from below.""")
|
||||
public static boolean dustTrapdoorReintroduced = false;
|
||||
|
||||
@ConfigInfo(name = "shulkerBoxCCEReintroduced", comments = """
|
||||
Map shulker-box CCE update suppression to Lophine's cce-update-suppression option.""")
|
||||
Use ClassCastException for update suppression.""")
|
||||
public static boolean shulkerBoxCCEReintroduced = false;
|
||||
|
||||
@ConfigInfo(name = "instantBlockUpdaterReintroduced", comments = """
|
||||
Enable the existing instant block updater patch already carried by Lophine.""")
|
||||
Instant block updater.""")
|
||||
public static boolean instantBlockUpdaterReintroduced = false;
|
||||
|
||||
@ConfigInfo(name = "commandTick", comments = """
|
||||
Enable the tick command support already patched into Lophine.""")
|
||||
Enable the tick command support.""")
|
||||
public static boolean commandTick = false;
|
||||
|
||||
@ConfigInfo(name = "creativeNoClip", comments = """
|
||||
Enable the existing creative fly no clip implementation.""")
|
||||
Whether to enable creative fly no clip.
|
||||
When enabled, players in creative mode will not collide with blocks while flying.
|
||||
This allows them to pass through blocks without obstruction.""")
|
||||
public static boolean creativeNoClip = false;
|
||||
|
||||
@ConfigInfo(name = "optimizedDragonRespawn", comments = """
|
||||
Enable the existing optimized dragon respawn implementation from Luminol.""")
|
||||
Enable optimized dragon respawn.""")
|
||||
public static boolean optimizedDragonRespawn = false;
|
||||
|
||||
@ConfigInfo(name = "antiSpamDisabled", comments = """
|
||||
@@ -245,6 +255,10 @@ public class GeneralCompatConfig implements IConfigModule {
|
||||
Examples: ["tps", "mob_caps", "counter white"]""")
|
||||
public static List<String> defaultLoggers = List.of();
|
||||
|
||||
public static boolean mergedUpdateSuppressionCrashEnabled() {
|
||||
return amsUpdateSuppressionCrashFix || yeetUpdateSuppressionCrash;
|
||||
}
|
||||
|
||||
public static int normalizedTntFuseDuration() {
|
||||
return Math.clamp(tntFuseDuration, 0, Short.MAX_VALUE);
|
||||
}
|
||||
@@ -252,4 +266,13 @@ public class GeneralCompatConfig implements IConfigModule {
|
||||
public static int normalizedTickCommandPermission() {
|
||||
return Math.clamp(tickCommandPermission, 0, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeFinalLoad() {
|
||||
// Should remove in next Minecraft version update
|
||||
RedirectedConfigs.redirect();
|
||||
|
||||
// after all config updated, send changes to client
|
||||
CarpetCompatSync.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package fun.bm.lophine.carpet.config.modules;
|
||||
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.config.flags.TransformedConfig;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
|
||||
@ConfigClassInfo(category = EnumConfigCategory.REMOVED, name = "removed_config")
|
||||
public class RemovedConfig implements IConfigModule {
|
||||
@TransformedConfig(name = "enabled", directory = {"carpet", "core"})
|
||||
@ConfigInfo(name = "removed", comments =
|
||||
"""
|
||||
RemovedConfig redirect to here, no any function.""")
|
||||
public static boolean enabled = true;
|
||||
}
|
||||
+16
-7
@@ -1,4 +1,4 @@
|
||||
package fun.bm.lophine.config.modules.function;
|
||||
package fun.bm.lophine.carpet.config.modules;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import fun.bm.lophine.command.counter.CounterCommand;
|
||||
@@ -11,20 +11,29 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ConfigClassInfo(category = EnumConfigCategory.FUNCTION, name = "wool-hopper-counter")
|
||||
@ConfigClassInfo(
|
||||
category = EnumConfigCategory.ROOT,
|
||||
name = "hopper_counter",
|
||||
directory = {"carpet"},
|
||||
comments = """
|
||||
Hopper counter functions."""
|
||||
)
|
||||
public class WoolHopperCounterConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enabled")
|
||||
public static boolean enabled = false;
|
||||
@ConfigInfo(name = "hopperCounters", comments = """
|
||||
Enable the existing wool hopper counter implementation.""")
|
||||
public static boolean hopperCounters = false;
|
||||
|
||||
@ConfigInfo(name = "unlimited-speed")
|
||||
public static boolean unlimitedSpeed = false;
|
||||
@ConfigInfo(name = "hopperCountersUnlimitedSpeed", comments = """
|
||||
Remove the hopper transfer speed limit for counters.
|
||||
Only effective when hopperCounters is enabled.""")
|
||||
public static boolean hopperCountersUnlimitedSpeed = false;
|
||||
|
||||
@DoNotLoad
|
||||
private static CounterCommand counterCommand = null;
|
||||
|
||||
@Override
|
||||
public void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> exs) {
|
||||
if (enabled) {
|
||||
if (hopperCounters) {
|
||||
if (counterCommand == null) {
|
||||
counterCommand = new CounterCommand();
|
||||
}
|
||||
-14
@@ -3,7 +3,6 @@ package fun.bm.lophine.config.modules.experiment;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.config.flags.HotReloadUnsupported;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
|
||||
/*
|
||||
@@ -12,19 +11,6 @@ import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
*/
|
||||
@ConfigClassInfo(category = EnumConfigCategory.EXPERIMENT, name = "redstone")
|
||||
public class RedStoneConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "redstone-ignore-upwards-update", comments = """
|
||||
Should the pre-1.20 mechanism be reintroduced:
|
||||
Redstone dust does not connect to adjacent redstone dust on trapdoors that are open
|
||||
Pre-1.20.2 mechanism: Redstone dust, redstone repeaters, and redstone comparators do not check for attachment when receiving status updates from below""")
|
||||
public static boolean redstoneIgnoreUpwardsUpdate = false;
|
||||
|
||||
@ConfigInfo(name = "cce-update-suppression", comments = """
|
||||
Is it permissible to use ClassCastException for update suppression?""")
|
||||
public static boolean cce = false;
|
||||
|
||||
@HotReloadUnsupported
|
||||
@ConfigInfo(name = "instant-block-updater")
|
||||
public static boolean instantBlockUpdater = false;
|
||||
|
||||
@ConfigInfo(name = "old-block-remove-behaviour")
|
||||
public static boolean oldBlockRemoveBehaviour = false;
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package fun.bm.lophine.config.modules.function;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.protocol.CarpetServerProtocol;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ConfigClassInfo(name = "creative_fly_no_clip", category = EnumConfigCategory.FUNCTION)
|
||||
public class CreativeFlyNoClipConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enabled", comments = """
|
||||
Whether to enable creative fly no clip.
|
||||
When enabled, players in creative mode will not collide with blocks while flying.
|
||||
This allows them to pass through blocks without obstruction.""")
|
||||
public static boolean enabled = false;
|
||||
|
||||
@Override
|
||||
public void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> e) {
|
||||
CarpetServerProtocol.CarpetRules.register(CarpetServerProtocol.CarpetRule.of("carpet", "creativeNoClip", enabled));
|
||||
}
|
||||
}
|
||||
+16
-15
@@ -1,9 +1,11 @@
|
||||
package fun.bm.lophine.config.modules.function;
|
||||
|
||||
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
import fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig;
|
||||
import me.earthme.luminol.config.IConfigModule;
|
||||
import me.earthme.luminol.config.flags.ConfigClassInfo;
|
||||
import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
import me.earthme.luminol.config.flags.DoNotLoad;
|
||||
import me.earthme.luminol.enums.EnumConfigCategory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
@@ -15,7 +17,7 @@ import java.util.Set;
|
||||
@ConfigClassInfo(category = EnumConfigCategory.FUNCTION, name = "fakeplayer")
|
||||
public class FakeplayerConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enable", comments = """
|
||||
Enable fakeplayer functionality""")
|
||||
Enable fakeplayer functionality (/bot command)""")
|
||||
public static boolean enable = true;
|
||||
|
||||
@ConfigInfo(name = "unable-fakeplayer-names", comments = """
|
||||
@@ -38,14 +40,6 @@ public class FakeplayerConfig implements IConfigModule {
|
||||
Regeneration amount for fakeplayers""")
|
||||
public static double regenAmount = 0.0;
|
||||
|
||||
@ConfigInfo(name = "resident-fakeplayer", comments = """
|
||||
Allow fakeplayers to be resident""")
|
||||
public static boolean canResident = false;
|
||||
|
||||
@ConfigInfo(name = "open-fakeplayer-inventory", comments = """
|
||||
Allow opening fakeplayer inventory""")
|
||||
public static boolean canOpenInventory = false;
|
||||
|
||||
@ConfigInfo(name = "use-action", comments = """
|
||||
Allow fakeplayers to use actions""")
|
||||
public static boolean canUseAction = true;
|
||||
@@ -81,28 +75,35 @@ public class FakeplayerConfig implements IConfigModule {
|
||||
@ConfigInfo(name = "enable-locator-bar", comments = """
|
||||
Enable locator bar for fakeplayers""")
|
||||
public static boolean enableLocatorBar = false;
|
||||
public static ServerBot.TickType tickType = ServerBot.TickType.ENTITY_LIST;
|
||||
|
||||
@DoNotLoad
|
||||
private BotCommand command = null;
|
||||
|
||||
private boolean registered = false;
|
||||
|
||||
public static int getSimulationDistance(ServerBot bot) {
|
||||
return simulationDistance == -1 ? bot.getBukkitEntity().getSimulationDistance() : simulationDistance;
|
||||
}
|
||||
|
||||
public static ServerBot.TickType tickType() {
|
||||
return FakePlayerCompatConfig.fakePlayerTicksLikeRealPlayer
|
||||
? ServerBot.TickType.NETWORK
|
||||
: ServerBot.TickType.ENTITY_LIST;
|
||||
}
|
||||
|
||||
public static boolean checkEnabled() {
|
||||
return enable || FakePlayerCompatConfig.commandPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaded(CommentedFileConfig configInstance, @Nullable Set<Exception> exs) {
|
||||
if (enable) {
|
||||
command = new BotCommand();
|
||||
command = new BotCommand("bot");
|
||||
command.register();
|
||||
registered = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnloaded(CommentedFileConfig configInstance) {
|
||||
if (registered) {
|
||||
if (command != null) {
|
||||
command.unregister();
|
||||
command = null;
|
||||
}
|
||||
|
||||
+3
-1
@@ -11,7 +11,9 @@ public class LanguageConfig implements IConfigModule {
|
||||
@HotReloadUnsupported
|
||||
@ConfigInfo(name = "lang", comments = """
|
||||
Please use the key from https://minecraft.wiki/w/Language
|
||||
Sample of format: en_us zh_cn zh_hk zh_tw""")
|
||||
Sample of format: en_us zh_cn zh_hk zh_tw
|
||||
ATTENTION: If you want to edit language for carpet ststem,
|
||||
please edit it in carpet config file.""")
|
||||
public static String lang = "en_us";
|
||||
|
||||
@ConfigInfo(name = "full_blocking_load", comments = """
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import fun.bm.lophine.carpet.config.modules.FakePlayerCompatConfig;
|
||||
import fun.bm.lophine.config.modules.function.FakeplayerConfig;
|
||||
import fun.bm.lophine.config.modules.function.OldFeatureConfig;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
@@ -102,7 +103,7 @@ public class BotList {
|
||||
}
|
||||
|
||||
public void saveAllResumeBots() {
|
||||
if (!FakeplayerConfig.enable || !FakeplayerConfig.canResident) {
|
||||
if (!FakeplayerConfig.checkEnabled() || !FakePlayerCompatConfig.fakePlayerResident) {
|
||||
return;
|
||||
}
|
||||
for (ServerBot bot : this.bots) {
|
||||
@@ -353,7 +354,7 @@ public class BotList {
|
||||
for (String fullName : this.botsNameByWorldUuid.getOrDefault(worldUuid, new HashSet<>())) {
|
||||
ServerBot bot = this.getBotByName(fullName);
|
||||
if (bot != null) {
|
||||
this.removeBot(bot, BotRemoveEvent.RemoveReason.INTERNAL, null, FakeplayerConfig.canResident, FakeplayerConfig.canResident);
|
||||
this.removeBot(bot, BotRemoveEvent.RemoveReason.INTERNAL, null, FakePlayerCompatConfig.fakePlayerResident, FakePlayerCompatConfig.fakePlayerResident);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,9 +364,9 @@ public class BotList {
|
||||
AtomicInteger check = new AtomicInteger();
|
||||
AtomicInteger received = new AtomicInteger();
|
||||
for (ServerBot bot : this.bots) {
|
||||
bot.resume = FakeplayerConfig.canResident;
|
||||
bot.resume = FakePlayerCompatConfig.fakePlayerResident;
|
||||
if (TickThread.isTickThreadFor(bot.level(), bot.getX(), bot.getZ())) {
|
||||
this.removeBot(bot, BotRemoveEvent.RemoveReason.INTERNAL, null, FakeplayerConfig.canResident, FakeplayerConfig.canResident);
|
||||
this.removeBot(bot, BotRemoveEvent.RemoveReason.INTERNAL, null, FakePlayerCompatConfig.fakePlayerResident, FakePlayerCompatConfig.fakePlayerResident);
|
||||
} else {
|
||||
finished = false;
|
||||
check.getAndIncrement();
|
||||
@@ -382,7 +383,7 @@ public class BotList {
|
||||
}
|
||||
counter.getAndIncrement();
|
||||
try {
|
||||
this.removeBot(bot, BotRemoveEvent.RemoveReason.INTERNAL, null, FakeplayerConfig.canResident, FakeplayerConfig.canResident);
|
||||
this.removeBot(bot, BotRemoveEvent.RemoveReason.INTERNAL, null, FakePlayerCompatConfig.fakePlayerResident, FakePlayerCompatConfig.fakePlayerResident);
|
||||
received.getAndIncrement();
|
||||
} catch (Exception e) {
|
||||
this.removeBot(bot, check, received, counter);
|
||||
@@ -395,7 +396,7 @@ public class BotList {
|
||||
}
|
||||
|
||||
public void loadResumeBotInfo() {
|
||||
if (!FakeplayerConfig.enable || !FakeplayerConfig.canResident) {
|
||||
if (!FakeplayerConfig.checkEnabled() || !FakePlayerCompatConfig.fakePlayerResident) {
|
||||
return;
|
||||
}
|
||||
CompoundTag savedBotList = this.getResumeBotList().copy();
|
||||
@@ -431,7 +432,7 @@ public class BotList {
|
||||
}
|
||||
|
||||
public void loadResume(String worldUuid) {
|
||||
if (!FakeplayerConfig.enable || !FakeplayerConfig.canResident) {
|
||||
if (!FakeplayerConfig.checkEnabled() || !FakePlayerCompatConfig.fakePlayerResident) {
|
||||
return;
|
||||
}
|
||||
new HashSet<>(this.botsNameByWorldUuid.getOrDefault(worldUuid, new HashSet<>())).forEach(this::loadNewResumeBot);
|
||||
|
||||
@@ -358,7 +358,7 @@ public class ServerBot extends ServerPlayer {
|
||||
|
||||
@Override
|
||||
public @NotNull InteractionResult interact(@NotNull Player player, @NotNull InteractionHand hand, @NotNull net.minecraft.world.phys.Vec3 location) { // Leaves - Paper 26.1: Entity#interact now takes Vec3
|
||||
if (FakeplayerConfig.canOpenInventory) {
|
||||
if (FakePlayerCompatConfig.openFakePlayerInventory) {
|
||||
if (player instanceof ServerPlayer player1 && player.getMainHandItem().isEmpty()) {
|
||||
BotInventoryOpenEvent event = new BotInventoryOpenEvent(this.getBukkitEntity(), player1.getBukkitEntity());
|
||||
getServer().server.getPluginManager().callEvent(event);
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ public class TickTypeConfig extends AbstractBotConfig<ServerBot.TickType, TickTy
|
||||
|
||||
public TickTypeConfig() {
|
||||
super("tick_type", EnumArgumentType.fromEnum(ServerBot.TickType.class), TickTypeConfig::new);
|
||||
this.value = FakeplayerConfig.tickType;
|
||||
this.value = FakeplayerConfig.tickType();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +59,7 @@ public class TickTypeConfig extends AbstractBotConfig<ServerBot.TickType, TickTy
|
||||
|
||||
@Override
|
||||
public void load(@NotNull CompoundTag nbt) {
|
||||
String raw = nbt.getStringOr(getName(), FakeplayerConfig.tickType.name());
|
||||
String raw = nbt.getStringOr(getName(), FakeplayerConfig.tickType().name());
|
||||
this.setValue(switch (raw.toLowerCase(Locale.ROOT)) {
|
||||
case "network" -> ServerBot.TickType.NETWORK;
|
||||
case "entity_list" -> ServerBot.TickType.ENTITY_LIST;
|
||||
|
||||
@@ -29,8 +29,8 @@ import static org.leavesmc.leaves.command.CommandUtils.registerPermissions;
|
||||
public class BotCommand extends RootNode {
|
||||
private static final String PERM_BASE = "bukkit.command.bot";
|
||||
|
||||
public BotCommand() {
|
||||
super("bot", PERM_BASE);
|
||||
public BotCommand(String key) {
|
||||
super(key, PERM_BASE);
|
||||
this.children(
|
||||
ListCommand::new,
|
||||
ConfigCommand::new,
|
||||
|
||||
-1
@@ -20,7 +20,6 @@ package org.leavesmc.leaves.protocol.servux.litematics.container;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class LitematicaBitArray {
|
||||
/**
|
||||
|
||||
+4
-1
@@ -42,7 +42,10 @@ import org.leavesmc.leaves.protocol.servux.litematics.selection.Box;
|
||||
import org.leavesmc.leaves.protocol.servux.litematics.utils.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package org.leavesmc.leaves.util;
|
||||
|
||||
import fun.bm.lophine.config.modules.function.WoolHopperCounterConfig;
|
||||
import fun.bm.lophine.carpet.config.modules.WoolHopperCounterConfig;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -351,6 +351,6 @@ public class HopperCounter {
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return WoolHopperCounterConfig.enabled && enabled;
|
||||
return WoolHopperCounterConfig.hopperCounters && enabled;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user