Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.github.optijava.opt_carpet_addition.logger.LoggerRegister;
import io.github.optijava.opt_carpet_addition.utils.CommandLogger;
import io.github.optijava.opt_carpet_addition.utils.ConfigUtil;
import io.github.optijava.opt_carpet_addition.utils.RuleTranslator;
import io.github.optijava.opt_carpet_addition.utils.TpLimit;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
Expand All @@ -24,6 +25,7 @@
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.util.Map;
import java.util.Objects;

public class OptCarpetAddition implements CarpetExtension, ModInitializer {
Expand Down Expand Up @@ -174,4 +176,9 @@ public void onPlayerLoggedOut(ServerPlayerEntity player) {
public void registerLoggers() {
LoggerRegister.registry();
}

@Override
public Map<String, String> canHasTranslations(String lang) {
return RuleTranslator.getTranslationFromResourcePath(lang);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package io.github.optijava.opt_carpet_addition;

//#if MC >= 11900
//$$ import carpet.api.settings.RuleCategory;
//#else

import carpet.settings.RuleCategory;
//#if MC >= 12001
import carpet.api.settings.RuleCategory;
//#endif
////#else
////$$
////$$ import carpet.settings.RuleCategory;
////#endif
//import carpet.settings.Rule;
//#if MC < 12001
//$$ import carpet.settings.Rule;
//$$ import carpet.settings.RuleCategory;
//#endif
//#if MC >= 12001
import carpet.api.settings.Rule;
//#endif
import carpet.settings.Rule;

import io.github.optijava.opt_carpet_addition.utils.config_bean.CommandLoggerConfigBean;
import io.github.optijava.opt_carpet_addition.utils.config_bean.TpLimitConfigBean;
import io.github.optijava.opt_carpet_addition.utils.validator.CustomItemDiscardTimeValidator;
Expand All @@ -18,7 +25,7 @@
import java.nio.file.Path;

//#if MC >= 11900
//$$ @SuppressWarnings("all")
@SuppressWarnings("all")
//#endif
public class OptCarpetSettings {
public static final String OCA = "OCA";
Expand All @@ -27,46 +34,36 @@ public class OptCarpetSettings {

// Tp command rules =======================================================================

@Rule(
desc = "Enables [/player xxx tp] to teleport to fake player",
category = {RuleCategory.COMMAND,OCA},
options = {"true", "false", "ops"}
)
@Rule(categories = {RuleCategory.COMMAND,OCA})
public static String commandTpToFakePlayer = FALSE;

@Rule(
desc = "Enables [/player xxx tp] to teleport to real player",
category = {RuleCategory.COMMAND,OCA},
@Rule(categories = {RuleCategory.COMMAND,OCA},
options = {"true", "false", "ops"}
)
public static String allowTpToRealPlayer = FALSE;

@Rule(
desc = "Enables [/player xxx tp] to teleport to fake player",
category = {RuleCategory.COMMAND,OCA},
categories = {RuleCategory.COMMAND,OCA},
options = {"true", "false", "ops"}
)
public static String commandTpHereFakePlayer = FALSE;

@Rule(
desc = "Enables [/player xxx tp] to teleport to real player",
category = {RuleCategory.COMMAND,OCA},
categories = {RuleCategory.COMMAND,OCA},
options = {"true", "false", "ops"}
)
public static String allowTpHereRealPlayer = FALSE;

// Force fake player gamemode rule =========================================================
@Rule(
desc = "Force fake player gamemode",
category = {RuleCategory.FEATURE,OCA},
categories = {RuleCategory.FEATURE,OCA},
options = {"survival", "creative", "adventure", "false"}
)
public static String forceFakePlayerGameMode = FALSE;

// Fix bugs ================================================================================
@Rule(
desc = "Refresh xp level when player change world",
category = {RuleCategory.BUGFIX,OCA}
categories = {RuleCategory.BUGFIX,OCA}
)
public static boolean fixXpLevelBug = false;

Expand All @@ -77,196 +74,167 @@ public class OptCarpetSettings {
public static CommandLoggerConfigBean commandLoggerConfigBean;

@Rule(
desc = "Enable tp prefix blacklist",
category = {RuleCategory.FEATURE,OCA}
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean enableTpPrefixBlacklist = false;

@Rule(
desc = "Enable tp prefix whitelist",
category = {RuleCategory.FEATURE,OCA}
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean enableTpPrefixWhitelist = false;

@Rule(
desc = "Enable tp here prefix blacklist",
category = {RuleCategory.FEATURE,OCA}
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean enableTpHerePrefixBlacklist = false;

@Rule(
desc = "Enable tp here prefix whitelist",
category = {RuleCategory.FEATURE,OCA}
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean enableTpHerePrefixWhitelist = false;

@Rule(
desc = "Disable chicken lays eggs",
category = {RuleCategory.FEATURE,OCA}
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean disabledLayEggs = false;

@Rule(
desc = "Disable enderman pickup block goal",
category = {RuleCategory.FEATURE,OCA}
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean disabledEnderManPickupGoal = false;

@Rule(
desc = "Disable enderman place block goal",
category = {RuleCategory.FEATURE,OCA}
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean disabledEnderManPlaceBlockGoal = false;

@Rule(
desc = "Disable zombified piglin spawn in nether portal",
category = {RuleCategory.OPTIMIZATION, RuleCategory.FEATURE,OCA}
categories = {RuleCategory.OPTIMIZATION, RuleCategory.FEATURE,OCA}
)
public static boolean disabledNetherPortalSpawn = false;

@Rule(
desc = "Disable entity tick(contains all entity and BlockEntity)",
category = {RuleCategory.EXPERIMENTAL,OCA}
categories = {RuleCategory.EXPERIMENTAL,OCA}
)
public static boolean disabledEntityTick = false;

//#if MC < 11900
@Rule(
desc = "Disable error stack when update suppression.",
category = {RuleCategory.BUGFIX,OCA}
)
public static boolean disabledUpdateSuppressionErrorStackTrace = false;
//$$ @Rule(
//$$ desc = "Disable error stack when update suppression.",
//$$ category = {RuleCategory.BUGFIX,OCA}
//$$ )
//$$ public static boolean disabledUpdateSuppressionErrorStackTrace = false;
//#endif

@Rule(
desc = "Unescape chat message. \\u4e2d -> 中",
category = {RuleCategory.FEATURE, RuleCategory.CLIENT,OCA}
categories = {RuleCategory.FEATURE, RuleCategory.CLIENT,OCA}
)
public static boolean unescapeChatMessage = false;

//#if MC < 11900
@Rule(
desc = "Handle player connect in a new thread to reduce the lag.",
category = {RuleCategory.OPTIMIZATION, RuleCategory.EXPERIMENTAL,OCA}
)
public static boolean optimizePlayerConnect = false;
//$$ @Rule(
//$$ desc = "Handle player connect in a new thread to reduce the lag.",
//$$ category = {RuleCategory.OPTIMIZATION, RuleCategory.EXPERIMENTAL,OCA}
//$$ )
//$$ public static boolean optimizePlayerConnect = false;
//#endif

//#if MC < 11900
@Rule(
desc = "Handle player teleport in a new thread to reduce the lag.",
category = {RuleCategory.OPTIMIZATION, RuleCategory.EXPERIMENTAL,OCA}
)
public static boolean optimizeTeleport = false;
//$$ @Rule(
//$$ desc = "Handle player teleport in a new thread to reduce the lag.",
//$$ category = {RuleCategory.OPTIMIZATION, RuleCategory.EXPERIMENTAL,OCA}
//$$ )
//$$ public static boolean optimizeTeleport = false;
//#endif

@Rule(
desc = "Print info log when players submit command",
category = {RuleCategory.COMMAND, RuleCategory.FEATURE,OCA}
categories = {RuleCategory.COMMAND, RuleCategory.FEATURE,OCA}
)
public static boolean commandLogger = false;

//#if MC < 11900
@Rule(
desc = "Dropper crash fix",
category = {RuleCategory.BUGFIX,OCA}
)
public static boolean dropperCrashFix = false;
//$$ @Rule(
//$$ desc = "Dropper crash fix",
//$$ category = {RuleCategory.BUGFIX,OCA}
//$$ )
//$$ public static boolean dropperCrashFix = false;
//#endif

@Rule(
desc = "Always spawn offline fake player to reduce lagging",
category = {RuleCategory.OPTIMIZATION,OCA}
categories = {RuleCategory.OPTIMIZATION,OCA}
)
public static boolean optimizeFakePlayerSpawn = false;

//#if MC < 12100
@Rule(
desc = "Fix CCE Suppression crashes",
category = {RuleCategory.BUGFIX, RuleCategory.EXPERIMENTAL,OCA}
)
public static boolean cceSuppressionCrashFix = false;
//$$ @Rule(
//$$
//$$ categories = {RuleCategory.BUGFIX, RuleCategory.EXPERIMENTAL,OCA}
//$$ )
//$$ public static boolean cceSuppressionCrashFix = false;
//#endif

@Rule(
desc = "Remove every armour which has `curse of binding` enchantment when player dead in wall (keepInventory must be true).",
category = {RuleCategory.FEATURE,OCA}
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean removeAllCurseOfBindingArmorWhenPlayerDeadInWall = false;

@Rule(
desc = "Modify item disappeared time, default value -1 (unit: tick)",
category = {RuleCategory.FEATURE,OCA},
categories = {RuleCategory.FEATURE,OCA},
options = {"-1", "6000"},
strict = false,
validate = CustomItemDiscardTimeValidator.class
validators = CustomItemDiscardTimeValidator.class
)
public static int customItemDiscardTime = -1;

//#if MC >= 12000
//$$ @Rule(
//$$ desc = "Disallow redstone wire connects to open trapdoor(in version >= 1.20)",
//$$ category = {RuleCategory.FEATURE,OCA}
//$$ )
//$$ public static boolean disallowRedstoneWireConnectsToOpenTrapdoor = false;
@Rule(
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean disallowRedstoneWireConnectsToOpenTrapdoor = false;
//#endif

@Rule(
desc = "Don't enable this rule unless you need blockUpdate logger! Enabling this rule may cause performance issues, so this rule was false by default. Before you set this rule to true, everyone can not use blockUpdate logger.",
category = {RuleCategory.FEATURE, RuleCategory.OPTIMIZATION,OCA}
categories = {RuleCategory.FEATURE, RuleCategory.OPTIMIZATION,OCA}
)
public static boolean allowBlockUpdateLogger = false;

@Rule(
desc = "Don't spawn bats!",
category = {RuleCategory.FEATURE,OCA}
categories = {RuleCategory.FEATURE,OCA}
)
public static boolean removeBats = false;

@Rule(
desc = "The rate limit of `/player xxx tp` command. Default: permit 1 request per 2 seconds per player.",
category = {RuleCategory.FEATURE, RuleCategory.COMMAND,OCA},
validate = PlayerTpRateLimitTimeValidator.class,
categories = {RuleCategory.FEATURE, RuleCategory.COMMAND,OCA},
validators = PlayerTpRateLimitTimeValidator.class,
strict = false,
options = {"2"}
)
public static int playerTpRateLimitTime = 2;

@Rule(
desc = "If enabled, command logger will broadcast commands to those players.",
category = {RuleCategory.COMMAND, RuleCategory.FEATURE,OCA},
categories = {RuleCategory.COMMAND, RuleCategory.FEATURE,OCA},
options = {"true", "false", "ops"}
)
public static String commandLoggerBroadcastToPlayer = FALSE;

@Rule(
desc = "allow spectator tp to any player!",
category = {RuleCategory.FEATURE, RuleCategory.COMMAND,OCA},
categories = {RuleCategory.FEATURE, RuleCategory.COMMAND,OCA},
options = {"true", "false"}
)
public static boolean allowSpectatorTpToAnyPlayer = false;

@Rule(
desc = "enableLoggerCommand",
category = {RuleCategory.COMMAND , OCA}
)
public static boolean enableLoggerCommand = true;

@Rule(
desc = "enableCrashCommand",
category = {RuleCategory.COMMAND , OCA}
categories = {RuleCategory.COMMAND , OCA}
)
public static boolean enableCrashCommand = true;

@Rule(
desc = "enableListAdvanceCommand",
category = {RuleCategory.COMMAND , OCA}
categories = {RuleCategory.COMMAND , OCA}
)
public static boolean enableListAdvanceCommand = true;

@Rule(
desc = "enableTpmanagerCommand",
category = {RuleCategory.COMMAND , OCA}
categories = {RuleCategory.COMMAND , OCA}
)
public static boolean enableTpmanagerCommand = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import io.github.optijava.opt_carpet_addition.utils.CommandLogger;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import static io.github.optijava.opt_carpet_addition.OptCarpetSettings.enableLoggerCommand;
import static io.github.optijava.opt_carpet_addition.OptCarpetSettings.commandLogger;

public class CommandLoggerCommand {
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
LiteralArgumentBuilder<ServerCommandSource> argumentBuilder = CommandManager.literal("commandlogger")
//#if MC < 12004
//$$.requires((player) -> carpet.settings.SettingsManager.canUseCommand(source, enableLoggerCommand))
//$$.requires((player) -> carpet.settings.SettingsManager.canUseCommand(source, commandLogger))
//#else
//$$.requires((player) -> carpet.utils.CommandHelper.canUseCommand(player, enableLoggerCommand))
//$$.requires((player) -> carpet.utils.CommandHelper.canUseCommand(player, commandLogger))
//#endif
.then(
CommandManager.literal("reload")
Expand Down
Loading
Loading