added command source to rule validators and added WIP tag
This commit is contained in:
1 parent
acfa91d1e8
commit
7800daacb8
2 files changed
+113
-101
No files matched your search
@@ -10,6 +10,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -24,6 +25,8 @@ import java.io.FileNotFoundException;
|
|||||||
//import carpet.helpers.SpawnChunks;
|
//import carpet.helpers.SpawnChunks;
|
||||||
import carpet.fakes.MinecraftServer_motdInterface;
|
import carpet.fakes.MinecraftServer_motdInterface;
|
||||||
import carpet.utils.Messenger;
|
import carpet.utils.Messenger;
|
||||||
|
import net.minecraft.server.command.CommandSource;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.dedicated.DedicatedServer;
|
import net.minecraft.server.dedicated.DedicatedServer;
|
||||||
import net.minecraft.util.math.ChunkPos;
|
import net.minecraft.util.math.ChunkPos;
|
||||||
@@ -73,15 +76,15 @@ public class CarpetSettings
|
|||||||
{
|
{
|
||||||
CarpetSettingEntry[] RuleList = new CarpetSettingEntry[] {
|
CarpetSettingEntry[] RuleList = new CarpetSettingEntry[] {
|
||||||
rule("watchdogCrashFix", "fix", "Fixes server crashing supposedly on falling behind 60s in ONE tick, yeah bs.").
|
rule("watchdogCrashFix", "fix", "Fixes server crashing supposedly on falling behind 60s in ONE tick, yeah bs.").
|
||||||
extraInfo("Fixed 1.12 watchdog crash in 1.13 pre-releases, reintroduced with 1.13, GG."),
|
extraInfo("Fixed 1.12 watchdog crash in 1.13 pre-releases, reintroduced with 1.13, GG.").wip(),
|
||||||
rule("portalSuffocationFix", "fix", "Nether portals correctly place entities going through")
|
rule("portalSuffocationFix", "fix", "Nether portals correctly place entities going through")
|
||||||
.extraInfo("Entities shouldn't suffocate in obsidian"),
|
.extraInfo("Entities shouldn't suffocate in obsidian").wip(),
|
||||||
rule("superSecretSetting", "experimental","Gbhs sgnf sadsgras fhskdpri!"),
|
rule("superSecretSetting", "experimental","Gbhs sgnf sadsgras fhskdpri!"),
|
||||||
rule("invisibilityFix", "fix", "Guardians honor players' invisibility effect"),
|
rule("invisibilityFix", "fix", "Guardians honor players' invisibility effect").wip(),
|
||||||
rule("portalCreativeDelay", "creative", "Portals won't let a creative player go through instantly")
|
rule("portalCreativeDelay", "creative", "Portals won't let a creative player go through instantly")
|
||||||
.extraInfo("Holding obsidian in either hand won't let you through at all"),
|
.extraInfo("Holding obsidian in either hand won't let you through at all"),
|
||||||
rule("ctrlQCraftingFix", "fix survival", "Dropping entire stacks works also from on the crafting UI result slot"),
|
rule("ctrlQCraftingFix", "fix survival", "Dropping entire stacks works also from on the crafting UI result slot"),
|
||||||
rule("persistentParrots", "survival feature", "Parrots don't get of your shoulders until you receive damage"),
|
rule("persistentParrots", "survival feature", "Parrots don't get of your shoulders until you receive damage").wip(),
|
||||||
//!rule("growingUpWallJump", "fix", "Mobs growing up won't glitch into walls or go through fences"),
|
//!rule("growingUpWallJump", "fix", "Mobs growing up won't glitch into walls or go through fences"),
|
||||||
//!rule("reloadSuffocationFix", "fix experimental", "Won't let mobs glitch into blocks when reloaded.")
|
//!rule("reloadSuffocationFix", "fix experimental", "Won't let mobs glitch into blocks when reloaded.")
|
||||||
// .extraInfo("Can cause slight differences in mobs behaviour"),
|
// .extraInfo("Can cause slight differences in mobs behaviour"),
|
||||||
@@ -92,17 +95,17 @@ public class CarpetSettings
|
|||||||
rule("explosionNoBlockDamage", "tnt", "Explosions won't destroy blocks"),
|
rule("explosionNoBlockDamage", "tnt", "Explosions won't destroy blocks"),
|
||||||
rule("tntPrimerMomentumRemoved", "tnt", "Removes random TNT momentum when primed"),
|
rule("tntPrimerMomentumRemoved", "tnt", "Removes random TNT momentum when primed"),
|
||||||
rule("fastRedstoneDust", "experimental optimizations", "Lag optimizations for redstone dust")
|
rule("fastRedstoneDust", "experimental optimizations", "Lag optimizations for redstone dust")
|
||||||
.extraInfo("by Theosib").boolAccelerate().defaultFalse(),
|
.extraInfo("by Theosib").boolAccelerate().defaultFalse().wip(),
|
||||||
rule("huskSpawningInTemples", "experimental feature", "Only husks spawn in desert temples").boolAccelerate(),
|
rule("huskSpawningInTemples", "experimental feature", "Only husks spawn in desert temples").boolAccelerate().wip(),
|
||||||
rule("shulkerSpawningInEndCities", "feature experimental", "Shulkers will respawn in end cities").boolAccelerate(),
|
rule("shulkerSpawningInEndCities", "feature experimental", "Shulkers will respawn in end cities").boolAccelerate(),
|
||||||
rule("unloadedEntityFix", "experimental creative", "Entities pushed or moved into unloaded chunks no longer disappear"),
|
rule("unloadedEntityFix", "experimental creative", "Entities pushed or moved into unloaded chunks no longer disappear").wip(),
|
||||||
rule("TNTDoNotUpdate", "tnt", "TNT doesn't update when placed against a power source"),
|
rule("TNTDoNotUpdate", "tnt", "TNT doesn't update when placed against a power source"),
|
||||||
rule("antiCheatSpeed", "creative surival", "Prevents players from rubberbanding when moving too fast"),
|
rule("antiCheatSpeed", "creative surival", "Prevents players from rubberbanding when moving too fast").wip(),
|
||||||
rule("quasiConnectivity", "creative", "Pistons, droppers and dispensers react if block above them is powered")
|
rule("quasiConnectivity", "creative", "Pistons, droppers and dispensers react if block above them is powered")
|
||||||
.defaultTrue(),
|
.defaultTrue().wip(),
|
||||||
rule("flippinCactus", "creative survival", "Players can flip and rotate blocks when holding cactus")
|
rule("flippinCactus", "creative survival", "Players can flip and rotate blocks when holding cactus")
|
||||||
.extraInfo("Doesn't cause block updates when rotated/flipped",
|
.extraInfo("Doesn't cause block updates when rotated/flipped",
|
||||||
"Applies to pistons, observers, droppers, repeaters, stairs, glazed terracotta etc..."),
|
"Applies to pistons, observers, droppers, repeaters, stairs, glazed terracotta etc...").wip(),
|
||||||
rule("hopperCounters", "commands creative survival","hoppers pointing to wool will count items passing through them")
|
rule("hopperCounters", "commands creative survival","hoppers pointing to wool will count items passing through them")
|
||||||
.extraInfo("Enables /counter command, and actions while placing red and green carpets on wool blocks",
|
.extraInfo("Enables /counter command, and actions while placing red and green carpets on wool blocks",
|
||||||
"Use /counter <color?> reset to reset the counter, and /counter <color?> to query",
|
"Use /counter <color?> reset to reset the counter, and /counter <color?> to query",
|
||||||
@@ -110,14 +113,14 @@ public class CarpetSettings
|
|||||||
"Counters are global and shared between players, 16 channels available",
|
"Counters are global and shared between players, 16 channels available",
|
||||||
"Items counted are destroyed, count up to one stack per tick per hopper")
|
"Items counted are destroyed, count up to one stack per tick per hopper")
|
||||||
.isACommand().boolAccelerate().defaultFalse(),
|
.isACommand().boolAccelerate().defaultFalse(),
|
||||||
rule("renewableSponges", "experimental feature", "Guardians turn into Elder Guardian when struck by lightning"),
|
rule("renewableSponges", "experimental feature", "Guardians turn into Elder Guardian when struck by lightning").wip(),
|
||||||
rule("movableTileEntities", "experimental", "Pistons can push tile entities, like hoppers, chests etc.").boolAccelerate(),
|
rule("movableTileEntities", "experimental", "Pistons can push tile entities, like hoppers, chests etc.").boolAccelerate().wip(),
|
||||||
rule("desertShrubs", "feature", "Saplings turn into dead shrubs in hot climates and no water access when it attempts to grow into a tree"),
|
rule("desertShrubs", "feature", "Saplings turn into dead shrubs in hot climates and no water access when it attempts to grow into a tree").wip(),
|
||||||
rule("silverFishDropGravel", "experimental", "Silverfish drop a gravel item when breaking out of a block"),
|
rule("silverFishDropGravel", "experimental", "Silverfish drop a gravel item when breaking out of a block"),
|
||||||
rule("summonNaturalLightning","creative", "summoning a lightning bolt has all the side effects of natural lightning"),
|
rule("summonNaturalLightning","creative", "summoning a lightning bolt has all the side effects of natural lightning"),
|
||||||
rule("commandSpawn", "commands", "Enables /spawn command for spawn tracking").isACommand(),
|
rule("commandSpawn", "commands", "Enables /spawn command for spawn tracking").isACommand(),
|
||||||
rule("commandTick", "commands", "Enables /tick command to control game speed").isACommand(),
|
rule("commandTick", "commands", "Enables /tick command to control game speed").isACommand(),
|
||||||
rule("commandLog", "commands", "Enables /log command to monitor events in the game via chat and overlays").isACommand(),
|
rule("commandLog", "commands", "Enables /log command to monitor events in the game via chat and overlays").isACommand().wip(),
|
||||||
rule("commandDistance", "commands", "Enables /distance command to measure in game distance between points").isACommand()
|
rule("commandDistance", "commands", "Enables /distance command to measure in game distance between points").isACommand()
|
||||||
.extraInfo("Also enables brown carpet placement action if 'carpets' rule is turned on as well"),
|
.extraInfo("Also enables brown carpet placement action if 'carpets' rule is turned on as well"),
|
||||||
rule("commandInfo", "commands", "Enables /info command for blocks and entities").isACommand()
|
rule("commandInfo", "commands", "Enables /info command for blocks and entities").isACommand()
|
||||||
@@ -131,16 +134,16 @@ public class CarpetSettings
|
|||||||
.extraInfo("... allows for drawing simple shapes"),
|
.extraInfo("... allows for drawing simple shapes"),
|
||||||
rule("commandScript", "commands", "Enables /script command").isACommand()
|
rule("commandScript", "commands", "Enables /script command").isACommand()
|
||||||
.extraInfo("a powerful in-game scripting API"),
|
.extraInfo("a powerful in-game scripting API"),
|
||||||
rule("commandPlayer", "commands", "Enables /player command to control/spawn players").isACommand(),
|
rule("commandPlayer", "commands", "Enables /player command to control/spawn players").isACommand().wip(),
|
||||||
rule("carpets", "survival", "Placing carpets may issue carpet commands for non-op players"),
|
rule("carpets", "survival", "Placing carpets may issue carpet commands for non-op players"),
|
||||||
rule("missingTools", "survival", "Pistons, Glass and Sponge can be broken faster with their appropriate tools"),
|
rule("missingTools", "survival", "Pistons, Glass and Sponge can be broken faster with their appropriate tools").wip(),
|
||||||
rule("portalCaching", "survival experimental", "Alternative, persistent caching strategy for nether portals"),
|
rule("portalCaching", "survival experimental", "Alternative, persistent caching strategy for nether portals").wip(),
|
||||||
rule("calmNetherFires", "experimental", "Permanent fires don't schedule random updates"),
|
rule("calmNetherFires", "experimental", "Permanent fires don't schedule random updates").wip(),
|
||||||
rule("fillUpdates", "creative", "fill/clone/setblock and structure blocks cause block updates").defaultTrue().boolAccelerate(),
|
rule("fillUpdates", "creative", "fill/clone/setblock and structure blocks cause block updates").defaultTrue().boolAccelerate(),
|
||||||
rule("pushLimit", "creative","Customizable piston push limit")
|
rule("pushLimit", "creative","Customizable piston push limit")
|
||||||
.choices("12","10 12 14 100").setNotStrict().numAccelerate(),
|
.choices("12","10 12 14 100").setNotStrict().numAccelerate(),
|
||||||
rule("railPowerLimit", "creative", "Customizable powered rail power range")
|
rule("railPowerLimit", "creative", "Customizable powered rail power range")
|
||||||
.choices("9","9 15 30").setNotStrict().validate( (s) ->
|
.choices("9","9 15 30").setNotStrict().validate( (s, n) ->
|
||||||
railPowerLimitAdjusted = CarpetSettings.getInt("railPowerLimit") - 1),
|
railPowerLimitAdjusted = CarpetSettings.getInt("railPowerLimit") - 1),
|
||||||
rule("fillLimit", "creative","Customizable fill/clone volume limit")
|
rule("fillLimit", "creative","Customizable fill/clone volume limit")
|
||||||
.choices("32768","32768 250000 1000000").setNotStrict(),
|
.choices("32768","32768 250000 1000000").setNotStrict(),
|
||||||
@@ -155,15 +158,15 @@ public class CarpetSettings
|
|||||||
rule("onePlayerSleeping", "survival", "One player is required on the server to cause night to pass"),
|
rule("onePlayerSleeping", "survival", "One player is required on the server to cause night to pass"),
|
||||||
rule("customMOTD", "creative","Sets a different motd message on client trying to connect to the server")
|
rule("customMOTD", "creative","Sets a different motd message on client trying to connect to the server")
|
||||||
.extraInfo("use '_' to use the startup setting from server.properties")
|
.extraInfo("use '_' to use the startup setting from server.properties")
|
||||||
.choices("_","_").setNotStrict().validate((s) ->
|
.choices("_","_").setNotStrict().validate((s, n) ->
|
||||||
((MinecraftServer_motdInterface)CarpetServer.minecraft_server).checkMOTD()),
|
((MinecraftServer_motdInterface)CarpetServer.minecraft_server).checkMOTD()),
|
||||||
rule("rotatorBlock", "experimental", "Cactus in dispensers rotates blocks.")
|
rule("rotatorBlock", "experimental", "Cactus in dispensers rotates blocks.")
|
||||||
.extraInfo("Cactus in a dispenser gives the dispenser the ability to rotate the blocks " +
|
.extraInfo("Cactus in a dispenser gives the dispenser the ability to rotate the blocks " +
|
||||||
"that are in front of it anti-clockwise if possible."),
|
"that are in front of it anti-clockwise if possible.").wip(),
|
||||||
rule("viewDistance", "creative", "Changes the view distance of the server.")
|
rule("viewDistance", "creative", "Changes the view distance of the server.")
|
||||||
.extraInfo("Set to 0 to not override the value in server settings.")
|
.extraInfo("Set to 0 to not override the value in server settings.")
|
||||||
.choices("0", "0 12 16 32 64").setNotStrict()
|
.choices("0", "0 12 16 32 64").setNotStrict()
|
||||||
.validate( (s) -> {
|
.validate( (s, n) -> {
|
||||||
int viewDistance = getInt("viewDistance");
|
int viewDistance = getInt("viewDistance");
|
||||||
if (CarpetServer.minecraft_server.isDedicated())
|
if (CarpetServer.minecraft_server.isDedicated())
|
||||||
{
|
{
|
||||||
@@ -180,22 +183,23 @@ public class CarpetSettings
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CarpetSettings.get(s).setForce("0");
|
CarpetSettings.get(n).setForce("0");
|
||||||
Messenger.print_server_message(CarpetServer.minecraft_server, "view distance can only be changed on a server");
|
if (s != null)
|
||||||
|
Messenger.m(s, "w view distance can only be changed on a server");
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
rule("disableSpawnChunks", "creative", "Removes the spawn chunks.")
|
rule("disableSpawnChunks", "creative", "Removes the spawn chunks.")
|
||||||
.validate((s) -> {
|
.validate((s, n) -> {
|
||||||
if (!CarpetSettings.getBool("disableSpawnChunks"))
|
if (!CarpetSettings.getBool("disableSpawnChunks"))
|
||||||
if (CarpetServer.minecraft_server != null)
|
if (s != null)
|
||||||
Messenger.print_server_message(CarpetServer.minecraft_server, "Spawn chunks re-enabled. Visit spawn to load it.");
|
Messenger.m(s, "w Spawn chunks re-enabled. Visit spawn to load it.");
|
||||||
}).boolAccelerate(),
|
}).boolAccelerate().wip(),
|
||||||
rule("kelpGenerationGrowLimit", "feature", "limits growth limit of newly naturally generated kelp to this amount of blocks")
|
rule("kelpGenerationGrowLimit", "feature", "limits growth limit of newly naturally generated kelp to this amount of blocks")
|
||||||
.choices("25", "0 2 25").setNotStrict(),
|
.choices("25", "0 2 25").setNotStrict(),
|
||||||
rule("renewableCoral", "feature", "Coral structures will grow with bonemeal from coral plants"),
|
rule("renewableCoral", "feature", "Coral structures will grow with bonemeal from coral plants"),
|
||||||
rule("placementRotationFix", "fix", "fixes block placement rotation issue when player rotates quickly while placing blocks"),
|
rule("placementRotationFix", "fix", "fixes block placement rotation issue when player rotates quickly while placing blocks").wip(),
|
||||||
rule("leadFix", "fix", "Fixes leads breaking/becoming invisible in unloaded chunks")
|
rule("leadFix", "fix", "Fixes leads breaking/becoming invisible in unloaded chunks")
|
||||||
.extraInfo("You may still get visibly broken leash links on the client side, but server side the link is still there."),
|
.extraInfo("You may still get visibly broken leash links on the client side, but server side the link is still there.").wip(),
|
||||||
rule("lagFreeSpawning", "optimizations", "Spawning requires much less CPU and Memory").boolAccelerate()
|
rule("lagFreeSpawning", "optimizations", "Spawning requires much less CPU and Memory").boolAccelerate()
|
||||||
};
|
};
|
||||||
for (CarpetSettingEntry rule: RuleList)
|
for (CarpetSettingEntry rule: RuleList)
|
||||||
@@ -227,7 +231,7 @@ public class CarpetSettings
|
|||||||
}
|
}
|
||||||
for (String key: conf.keySet())
|
for (String key: conf.keySet())
|
||||||
{
|
{
|
||||||
set(key, conf.get(key));
|
set(server.getCommandSource(), key, conf.get(key));
|
||||||
LOG.info("[CM]: loaded setting "+key+" as "+conf.get(key)+" from carpet.conf");
|
LOG.info("[CM]: loaded setting "+key+" as "+conf.get(key)+" from carpet.conf");
|
||||||
}
|
}
|
||||||
locked = is_locked;
|
locked = is_locked;
|
||||||
@@ -310,41 +314,41 @@ public class CarpetSettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stores different defaults in the file
|
// stores different defaults in the file
|
||||||
public static boolean setDefaultRule(MinecraftServer server, String setting_name, String string_value)
|
public static boolean setDefaultRule(ServerCommandSource source, String setting_name, String string_value)
|
||||||
{
|
{
|
||||||
if (locked) return false;
|
if (locked) return false;
|
||||||
if (settings_store.containsKey(setting_name))
|
if (settings_store.containsKey(setting_name))
|
||||||
{
|
{
|
||||||
Map<String, String> conf = read_conf(server);
|
Map<String, String> conf = read_conf(source.getMinecraftServer());
|
||||||
conf.put(setting_name, string_value);
|
conf.put(setting_name, string_value);
|
||||||
write_conf(server, conf);
|
write_conf(source.getMinecraftServer(), conf);
|
||||||
set(setting_name,string_value);
|
set(source, setting_name,string_value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// removes overrides of the default values in the file
|
// removes overrides of the default values in the file
|
||||||
public static boolean removeDefaultRule(MinecraftServer server, String setting_name)
|
public static boolean removeDefaultRule(ServerCommandSource source, String setting_name)
|
||||||
{
|
{
|
||||||
if (locked) return false;
|
if (locked) return false;
|
||||||
if (settings_store.containsKey(setting_name))
|
if (settings_store.containsKey(setting_name))
|
||||||
{
|
{
|
||||||
Map<String, String> conf = read_conf(server);
|
Map<String, String> conf = read_conf(source.getMinecraftServer());
|
||||||
conf.remove(setting_name);
|
conf.remove(setting_name);
|
||||||
write_conf(server, conf);
|
write_conf(source.getMinecraftServer(), conf);
|
||||||
set(setting_name,get(setting_name).getDefault());
|
set(source, setting_name,get(setting_name).getDefault());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//changes setting temporarily
|
//changes setting temporarily
|
||||||
public static boolean set(String setting_name, String string_value)
|
public static boolean set(ServerCommandSource source, String setting_name, String string_value)
|
||||||
{
|
{
|
||||||
CarpetSettingEntry en = get(setting_name);
|
CarpetSettingEntry en = get(setting_name);
|
||||||
if (en != FalseEntry)
|
if (en != FalseEntry)
|
||||||
{
|
{
|
||||||
en.set(string_value);
|
en.set(source, string_value);
|
||||||
//reload_stat(setting_name);
|
//reload_stat(setting_name);
|
||||||
//CarpetClientRuleChanger.updateCarpetClientsRule(setting_name, string_value);
|
//CarpetClientRuleChanger.updateCarpetClientsRule(setting_name, string_value);
|
||||||
return true;
|
return true;
|
||||||
@@ -433,66 +437,66 @@ public class CarpetSettings
|
|||||||
return settings_store.get(rule);
|
return settings_store.get(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resetToVanilla()
|
public static void resetToVanilla(ServerCommandSource source)
|
||||||
{
|
{
|
||||||
for (String rule: settings_store.keySet())
|
for (String rule: settings_store.keySet())
|
||||||
{
|
{
|
||||||
get(rule).reset();
|
get(rule).reset(source);
|
||||||
//reload_stat(rule);
|
//reload_stat(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resetToUserDefaults(MinecraftServer server)
|
public static void resetToUserDefaults(ServerCommandSource source)
|
||||||
{
|
{
|
||||||
resetToVanilla();
|
resetToVanilla(source);
|
||||||
apply_settings_from_conf(server);
|
apply_settings_from_conf(source.getMinecraftServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resetToCreative()
|
public static void resetToCreative(ServerCommandSource source)
|
||||||
{
|
{
|
||||||
resetToBugFixes();
|
resetToBugFixes(source);
|
||||||
set("fillLimit","500000");
|
set(source, "fillLimit","500000");
|
||||||
set("fillUpdates","false");
|
set(source, "fillUpdates","false");
|
||||||
set("portalCreativeDelay","true");
|
set(source, "portalCreativeDelay","true");
|
||||||
set("portalCaching","true");
|
set(source, "portalCaching","true");
|
||||||
set("flippinCactus","true");
|
set(source, "flippinCactus","true");
|
||||||
set("hopperCounters","true");
|
set(source, "hopperCounters","true");
|
||||||
set("antiCheatSpeed","true");
|
set(source, "antiCheatSpeed","true");
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void resetToSurvival()
|
public static void resetToSurvival(ServerCommandSource source)
|
||||||
{
|
{
|
||||||
resetToBugFixes();
|
resetToBugFixes(source);
|
||||||
set("ctrlQCraftingFix","true");
|
set(source, "ctrlQCraftingFix","true");
|
||||||
set("persistentParrots", "true");
|
set(source, "persistentParrots", "true");
|
||||||
set("stackableEmptyShulkerBoxes","true");
|
set(source, "stackableEmptyShulkerBoxes","true");
|
||||||
set("flippinCactus","true");
|
set(source, "flippinCactus","true");
|
||||||
set("hopperCounters","true");
|
set(source, "hopperCounters","true");
|
||||||
set("carpets","true");
|
set(source, "carpets","true");
|
||||||
set("missingTools","true");
|
set(source, "missingTools","true");
|
||||||
set("portalCaching","true");
|
set(source, "portalCaching","true");
|
||||||
set("miningGhostBlocksFix","true");
|
set(source, "miningGhostBlocksFix","true");
|
||||||
}
|
}
|
||||||
public static void resetToBugFixes()
|
public static void resetToBugFixes(ServerCommandSource source)
|
||||||
{
|
{
|
||||||
resetToVanilla();
|
resetToVanilla(source);
|
||||||
set("portalSuffocationFix","true");
|
set(source, "portalSuffocationFix","true");
|
||||||
set("pistonGhostBlocksFix","serverOnly");
|
set(source, "pistonGhostBlocksFix","serverOnly");
|
||||||
set("portalTeleportationFix","true");
|
set(source, "portalTeleportationFix","true");
|
||||||
set("entityDuplicationFix","true");
|
set(source, "entityDuplicationFix","true");
|
||||||
set("inconsistentRedstoneTorchesFix","true");
|
set(source, "inconsistentRedstoneTorchesFix","true");
|
||||||
set("llamaOverfeedingFix","true");
|
set(source, "llamaOverfeedingFix","true");
|
||||||
set("invisibilityFix","true");
|
set(source, "invisibilityFix","true");
|
||||||
set("potionsDespawnFix","true");
|
set(source, "potionsDespawnFix","true");
|
||||||
set("liquidsNotRandom","true");
|
set(source, "liquidsNotRandom","true");
|
||||||
set("mobsDontControlMinecarts","true");
|
set(source, "mobsDontControlMinecarts","true");
|
||||||
set("breedingMountingDisabled","true");
|
set(source, "breedingMountingDisabled","true");
|
||||||
set("growingUpWallJump","true");
|
set(source, "growingUpWallJump","true");
|
||||||
set("reloadSuffocationFix","true");
|
set(source, "reloadSuffocationFix","true");
|
||||||
set("watchdogFix","true");
|
set(source, "watchdogFix","true");
|
||||||
set("unloadedEntityFix","true");
|
set(source, "unloadedEntityFix","true");
|
||||||
set("hopperDuplicationFix","true");
|
set(source, "hopperDuplicationFix","true");
|
||||||
set("calmNetherFires","true");
|
set(source, "calmNetherFires","true");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CarpetSettingEntry
|
public static class CarpetSettingEntry
|
||||||
@@ -509,7 +513,7 @@ public class CarpetSettings
|
|||||||
private String default_string_value;
|
private String default_string_value;
|
||||||
private boolean isFloat;
|
private boolean isFloat;
|
||||||
private boolean strict;
|
private boolean strict;
|
||||||
private List<Consumer<String>> validators;
|
private List<BiConsumer<ServerCommandSource, String>> validators;
|
||||||
|
|
||||||
//factory
|
//factory
|
||||||
public static CarpetSettingEntry create(String rule_name, String tags, String toast)
|
public static CarpetSettingEntry create(String rule_name, String tags, String toast)
|
||||||
@@ -518,7 +522,7 @@ public class CarpetSettings
|
|||||||
}
|
}
|
||||||
private CarpetSettingEntry(String rule_name, String tags_string, String toast_string)
|
private CarpetSettingEntry(String rule_name, String tags_string, String toast_string)
|
||||||
{
|
{
|
||||||
set("false");
|
set(null, "false");
|
||||||
rule = rule_name;
|
rule = rule_name;
|
||||||
default_string_value = string;
|
default_string_value = string;
|
||||||
tags = tags_string.split("\\s+"); // never empty
|
tags = tags_string.split("\\s+"); // never empty
|
||||||
@@ -531,12 +535,12 @@ public class CarpetSettings
|
|||||||
}
|
}
|
||||||
public CarpetSettingEntry defaultTrue()
|
public CarpetSettingEntry defaultTrue()
|
||||||
{
|
{
|
||||||
set("true");
|
set(null, "true");
|
||||||
default_string_value = string;
|
default_string_value = string;
|
||||||
options = "true false".split("\\s+");
|
options = "true false".split("\\s+");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
public CarpetSettingEntry validate(Consumer<String> method)
|
public CarpetSettingEntry validate(BiConsumer<ServerCommandSource, String> method)
|
||||||
{
|
{
|
||||||
if (validators == null)
|
if (validators == null)
|
||||||
{
|
{
|
||||||
@@ -547,7 +551,7 @@ public class CarpetSettings
|
|||||||
}
|
}
|
||||||
public CarpetSettingEntry boolAccelerate()
|
public CarpetSettingEntry boolAccelerate()
|
||||||
{
|
{
|
||||||
Consumer<String> validator = (name) -> {
|
BiConsumer<ServerCommandSource, String> validator = (source, name) -> {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Field f = CarpetSettings.class.getDeclaredField("b_"+name);
|
Field f = CarpetSettings.class.getDeclaredField("b_"+name);
|
||||||
@@ -566,7 +570,7 @@ public class CarpetSettings
|
|||||||
}
|
}
|
||||||
public CarpetSettingEntry numAccelerate()
|
public CarpetSettingEntry numAccelerate()
|
||||||
{
|
{
|
||||||
Consumer<String> validator = (name) -> {
|
BiConsumer<ServerCommandSource, String> validator = (source, name) -> {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Field f = CarpetSettings.class.getDeclaredField("n_"+name);
|
Field f = CarpetSettings.class.getDeclaredField("n_"+name);
|
||||||
@@ -594,12 +598,12 @@ public class CarpetSettings
|
|||||||
|
|
||||||
public CarpetSettingEntry isACommand()
|
public CarpetSettingEntry isACommand()
|
||||||
{
|
{
|
||||||
return this.defaultTrue().validate( (s) -> notifyPlayersCommandsChanged());
|
return this.defaultTrue().validate( (s, n) -> notifyPlayersCommandsChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CarpetSettingEntry defaultFalse()
|
public CarpetSettingEntry defaultFalse()
|
||||||
{
|
{
|
||||||
set("false");
|
set(null, "false");
|
||||||
default_string_value = string;
|
default_string_value = string;
|
||||||
options = "true false".split("\\s+");
|
options = "true false".split("\\s+");
|
||||||
return this;
|
return this;
|
||||||
@@ -607,7 +611,7 @@ public class CarpetSettings
|
|||||||
|
|
||||||
public CarpetSettingEntry choices(String defaults, String options_string)
|
public CarpetSettingEntry choices(String defaults, String options_string)
|
||||||
{
|
{
|
||||||
set(defaults);
|
set(null, defaults);
|
||||||
default_string_value = string;
|
default_string_value = string;
|
||||||
options = options_string.split("\\s+");
|
options = options_string.split("\\s+");
|
||||||
return this;
|
return this;
|
||||||
@@ -631,12 +635,12 @@ public class CarpetSettings
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void set(String unparsed)
|
private void set(ServerCommandSource source, String unparsed)
|
||||||
{
|
{
|
||||||
setForce(unparsed);
|
setForce(unparsed);
|
||||||
if (validators != null)
|
if (validators != null)
|
||||||
{
|
{
|
||||||
validators.forEach((r) -> r.accept(this.getName()));
|
validators.forEach((r) -> r.accept(source, this.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void setForce(String unparsed)
|
private void setForce(String unparsed)
|
||||||
@@ -677,9 +681,9 @@ public class CarpetSettings
|
|||||||
public boolean getIsFloat() { return isFloat;}
|
public boolean getIsFloat() { return isFloat;}
|
||||||
|
|
||||||
//actual stuff
|
//actual stuff
|
||||||
public void reset()
|
public void reset(ServerCommandSource s)
|
||||||
{
|
{
|
||||||
set(default_string_value);
|
set(s, default_string_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(String tag)
|
public boolean matches(String tag)
|
||||||
@@ -716,6 +720,14 @@ public class CarpetSettings
|
|||||||
{
|
{
|
||||||
return strict;
|
return strict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CarpetSettingEntry wip()
|
||||||
|
{
|
||||||
|
return validate( (s, n) -> {
|
||||||
|
if (s != null)
|
||||||
|
Messenger.m(s, "r Work in progress - limited or no functionality available for "+n);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ public class CarpetCommand
|
|||||||
|
|
||||||
private static int setRule(ServerCommandSource source, CarpetSettingEntry rule, String newValue)
|
private static int setRule(ServerCommandSource source, CarpetSettingEntry rule, String newValue)
|
||||||
{
|
{
|
||||||
CarpetSettings.set(rule.getName(), newValue);
|
CarpetSettings.set(source, rule.getName(), newValue);
|
||||||
Messenger.m(source, "w "+rule.toString()+", ", "c [change permanently?]",
|
Messenger.m(source, "w "+rule.toString()+", ", "c [change permanently?]",
|
||||||
"^w Click to keep the settings in carpet.conf to save across restarts",
|
"^w Click to keep the settings in carpet.conf to save across restarts",
|
||||||
"?/carpet setDefault "+rule.getName()+" "+rule.getStringValue());
|
"?/carpet setDefault "+rule.getName()+" "+rule.getStringValue());
|
||||||
@@ -121,13 +121,13 @@ public class CarpetCommand
|
|||||||
}
|
}
|
||||||
private static int setDefault(ServerCommandSource source, CarpetSettingEntry rule, String defaultValue)
|
private static int setDefault(ServerCommandSource source, CarpetSettingEntry rule, String defaultValue)
|
||||||
{
|
{
|
||||||
CarpetSettings.setDefaultRule(source.getMinecraftServer(), rule.getName(), defaultValue);
|
CarpetSettings.setDefaultRule(source, rule.getName(), defaultValue);
|
||||||
Messenger.m(source ,"gi rule "+ rule.getName()+" will now default to "+ defaultValue);
|
Messenger.m(source ,"gi rule "+ rule.getName()+" will now default to "+ defaultValue);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
private static int removeDefault(ServerCommandSource source, CarpetSettingEntry rule)
|
private static int removeDefault(ServerCommandSource source, CarpetSettingEntry rule)
|
||||||
{
|
{
|
||||||
CarpetSettings.removeDefaultRule(source.getMinecraftServer(), rule.getName());
|
CarpetSettings.removeDefaultRule(source, rule.getName());
|
||||||
Messenger.m(source ,"gi rule "+ rule.getName()+" defaults to Vanilla");
|
Messenger.m(source ,"gi rule "+ rule.getName()+" defaults to Vanilla");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user