9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-30 04:19:30 +00:00

Remove, and opt config and config command

This commit is contained in:
violetc
2025-08-16 22:06:59 +08:00
parent 0ee8078482
commit a30c9abbc4
78 changed files with 64 additions and 97 deletions

View File

@@ -1,6 +1,5 @@
package org.leavesmc.leaves;
import com.destroystokyo.paper.util.SneakyThrow;
import io.papermc.paper.adventure.PaperAdventure;
import io.papermc.paper.configuration.GlobalConfiguration;
import net.kyori.adventure.text.Component;
@@ -86,7 +85,6 @@ public final class LeavesConfig {
config.load(file);
} catch (final Exception ex) {
LeavesLogger.LOGGER.severe("Failure to load leaves config", ex);
SneakyThrow.sneaky(ex);
throw new RuntimeException(ex);
}
}
@@ -107,7 +105,6 @@ public final class LeavesConfig {
config.load(LeavesConfig.configFile);
} catch (final Exception ex) {
LeavesLogger.LOGGER.severe("Failure to reload leaves config", ex);
SneakyThrow.sneaky(ex);
throw new RuntimeException(ex);
}
@@ -430,7 +427,7 @@ public final class LeavesConfig {
@TransferConfig("redstone-shears-wrench")
@GlobalConfig("redstone-shears-wrench")
public boolean redstoneShearsWrench = true;
public boolean redstoneShearsWrench = false;
@TransferConfig("budding-amethyst-can-push-by-piston")
@TransferConfig("modify.budding-amethyst-can-push-by-piston")
@@ -819,9 +816,6 @@ public final class LeavesConfig {
@GlobalConfig("skip-negligible-planar-movement-multiplication")
public boolean skipNegligiblePlanarMovementMultiplication = true;
@GlobalConfig("fix-villagers-dont-release-memory")
public boolean villagersDontReleaseMemoryFix = false;
@GlobalConfig(value = "sleeping-block-entity", lock = true)
public boolean sleepingBlockEntity = false;
}
@@ -1155,7 +1149,7 @@ public final class LeavesConfig {
public boolean forceMinecraftCommand = false;
@GlobalConfig("leaves-packet-event")
public boolean leavesPacketEvent = true;
public boolean leavesPacketEvent = false;
@GlobalConfig("chat-command-max-length")
public int chatCommandMaxLength = 32767;
@@ -1238,7 +1232,7 @@ public final class LeavesConfig {
}
@GlobalConfig("vanilla-portal-handle")
public boolean vanillaPortalHandle = false;
public boolean vanillaPortalHandle = true;
@GlobalConfig("vanilla-fluid-pushing")
public boolean vanillaFluidPushing = true;

View File

@@ -3,6 +3,7 @@ package org.leavesmc.leaves.command.subcommands;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
@@ -13,21 +14,23 @@ import org.leavesmc.leaves.command.LeavesSuggestionBuilder;
import org.leavesmc.leaves.config.GlobalConfigManager;
import org.leavesmc.leaves.config.VerifiedConfig;
import static net.kyori.adventure.text.Component.text;
public class ConfigCommand implements LeavesSubcommand {
@Override
public void execute(CommandSender sender, String subCommand, String[] args) {
if (args.length < 1) {
sender.sendMessage(Component.text("Leaves Config", NamedTextColor.GRAY));
sender.sendMessage(text("Leaves Config", NamedTextColor.GRAY));
return;
}
VerifiedConfig verifiedConfig = GlobalConfigManager.getVerifiedConfig(args[0]);
if (verifiedConfig == null) {
sender.sendMessage(Component.join(JoinConfiguration.noSeparators(),
Component.text("Config ", NamedTextColor.GRAY),
Component.text(args[0], NamedTextColor.RED),
Component.text(" is Not Found.", NamedTextColor.GRAY)
sender.sendMessage(Component.join(JoinConfiguration.spaces(),
text("Config", NamedTextColor.GRAY),
text(args[0], NamedTextColor.RED),
text("is Not Found.", NamedTextColor.GRAY)
));
return;
}
@@ -35,26 +38,35 @@ public class ConfigCommand implements LeavesSubcommand {
if (args.length > 1) {
try {
verifiedConfig.set(args[1]);
sender.sendMessage(Component.join(JoinConfiguration.noSeparators(),
Component.text("Config ", NamedTextColor.GRAY),
Component.text(args[0], NamedTextColor.AQUA),
Component.text(" changed to ", NamedTextColor.GRAY),
Component.text(verifiedConfig.getString(), NamedTextColor.AQUA)
sender.sendMessage(Component.join(JoinConfiguration.spaces(),
text("Config", NamedTextColor.GRAY),
text(args[0], NamedTextColor.AQUA),
text("changed to", NamedTextColor.GRAY),
text(verifiedConfig.getString(), NamedTextColor.AQUA)
));
Bukkit.getOnlinePlayers().stream().filter(player -> player.hasPermission("leaves.command.config.notify") && player != sender).forEach(
player -> player.sendMessage(Component.join(JoinConfiguration.spaces(),
text(sender.getName() + ":", NamedTextColor.GRAY),
text("Config", NamedTextColor.GRAY),
text(args[0], NamedTextColor.AQUA),
text("changed to", NamedTextColor.GRAY),
text(verifiedConfig.getString(), NamedTextColor.AQUA)
))
);
} catch (IllegalArgumentException exception) {
sender.sendMessage(Component.join(JoinConfiguration.noSeparators(),
Component.text("Config ", NamedTextColor.GRAY),
Component.text(args[0], NamedTextColor.RED),
Component.text(" modify error by ", NamedTextColor.GRAY),
Component.text(exception.getMessage(), NamedTextColor.RED)
sender.sendMessage(Component.join(JoinConfiguration.spaces(),
text("Config", NamedTextColor.GRAY),
text(args[0], NamedTextColor.RED),
text("modify error by", NamedTextColor.GRAY),
text(exception.getMessage(), NamedTextColor.RED)
));
}
} else {
sender.sendMessage(Component.join(JoinConfiguration.noSeparators(),
Component.text("Config ", NamedTextColor.GRAY),
Component.text(args[0], NamedTextColor.AQUA),
Component.text(" value is ", NamedTextColor.GRAY),
Component.text(verifiedConfig.getString(), NamedTextColor.AQUA)
sender.sendMessage(Component.join(JoinConfiguration.spaces(),
text("Config", NamedTextColor.GRAY),
text(args[0], NamedTextColor.AQUA),
text("value is", NamedTextColor.GRAY),
text(verifiedConfig.getString(), NamedTextColor.AQUA)
));
}
}

View File

@@ -1,5 +1,6 @@
package org.leavesmc.leaves.command.subcommands;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.leavesmc.leaves.LeavesConfig;
import org.leavesmc.leaves.command.LeavesSubcommand;
@@ -12,5 +13,8 @@ public class ReloadCommand implements LeavesSubcommand {
public void execute(CommandSender sender, String subCommand, String[] args) {
LeavesConfig.reload();
sender.sendMessage(text("Leaves config reload complete.", GREEN));
Bukkit.getOnlinePlayers().stream().filter(player -> player.hasPermission("leaves.command.config.notify") && player != sender).forEach(
player -> player.sendMessage(text("Leaves config reload complete.", GREEN))
);
}
}

View File

@@ -1,7 +1,7 @@
package org.leavesmc.leaves.config.annotations;
import org.leavesmc.leaves.config.api.impl.AutoConfigValidator;
import org.leavesmc.leaves.config.api.ConfigValidator;
import org.leavesmc.leaves.config.api.impl.AutoConfigValidator;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View File

@@ -1,7 +1,7 @@
package org.leavesmc.leaves.config.annotations;
import org.leavesmc.leaves.config.api.impl.AutoConfigTransformer;
import org.leavesmc.leaves.config.api.ConfigTransformer;
import org.leavesmc.leaves.config.api.impl.AutoConfigTransformer;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;