9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2026-01-04 15:41:38 +00:00
This commit is contained in:
XiaoMoMi
2025-04-18 20:04:49 +08:00
parent bb3ced5881
commit efcb9e6418
17 changed files with 165 additions and 60 deletions

View File

@@ -16,6 +16,13 @@ reload:
- /craftengine reload
- /ce reload
upload:
enable: true
permission: ce.command.admin.upload
usage:
- /craftengine upload
- /ce upload
get_item:
enable: true
permission: ce.command.admin.get_item

View File

@@ -59,6 +59,8 @@ command.resource.enable.failure.unknown: "<red>Unknown resource <arg:0></red>"
command.resource.disable.success: "<white>Disabled resource <arg:0>. Run <click:run_command:/ce reload all><u>/ce reload all</u></click> to apply changes</white>"
command.resource.disable.failure.unknown: "<red>Unknown resource <arg:0></red>"
command.resource.list: "<white>Enabled resources(<arg:0>): <green><arg:1></green><newline>Disabled resources(<arg:2>): <red><arg:3></red></white>"
command.upload.failure.not_supported: "<red>Current hosting method '<arg:0>' doesn't support uploading resource packs.</red>"
command.upload.on_progress: "<white>Started uploading progress. Check the console for more information.</white>"
warning.config.image.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated image '<arg:1>'.</yellow>"
warning.config.image.lack_height: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is missing the required 'height' argument.</yellow>"
warning.config.image.height_smaller_than_ascent: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' violates the bitmap image rule: 'height' should be no lower than 'ascent'.</yellow>"

View File

@@ -59,6 +59,8 @@ command.resource.enable.failure.unknown: "<red>未知资源 <arg:0></red>"
command.resource.disable.success: "<white>已禁用 <arg:0>. 执行 <click:run_command:/ce reload all><u>/ce reload all</u></click> 以应用更改</white>"
command.resource.disable.failure.unknown: "<red>未知资源 <arg:0></red>"
command.resource.list: "<white>启用的资源(<arg:0>): <green><arg:1></green><newline>禁用的资源(<arg:2>): <red><arg:3></red></white>"
command.upload.failure.not_supported: "<red>当前托管模式 '<arg:0>' 不支持上传资源包.</red>"
command.upload.on_progress: "<white>已开始上传进程. 检查控制台以获取详细信息.</white>"
warning.config.image.duplicated: "<yellow>在文件 <arg:0> 中发现问题 - 图片 '<arg:1>' 重复定义</yellow>"
warning.config.image.lack_height: "<yellow>在文件 <arg:0> 中发现问题 - 图片 '<arg:1>' 缺少必要的 'height' 高度参数</yellow>"
warning.config.image.height_smaller_than_ascent: "<yellow>在文件 <arg:0> 中发现问题 - 图片 '<arg:1>' 违反位图规则:'height' 高度值不应小于 'ascent' 基准线高度</yellow>"

View File

@@ -49,7 +49,8 @@ public class BukkitCommandManager extends AbstractCommandManager<CommandSender>
new TotemAnimationCommand(this, plugin),
new EnableResourceCommand(this, plugin),
new DisableResourceCommand(this, plugin),
new ListResourceCommand(this, plugin)
new ListResourceCommand(this, plugin),
new UploadPackCommand(this, plugin)
));
final LegacyPaperCommandManager<CommandSender> manager = (LegacyPaperCommandManager<CommandSender>) getCommandManager();
manager.settings().set(ManagerSetting.ALLOW_UNSAFE_REGISTRATION, true);

View File

@@ -61,7 +61,6 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
plugin().logger().warn("Failed to reload config", e);
}
} else if (argument == ReloadArgument.PACK) {
RELOAD_PACK_FLAG = true;
plugin().scheduler().executeAsync(() -> {
try {
long time1 = System.currentTimeMillis();
@@ -73,8 +72,6 @@ public class ReloadCommand extends BukkitCommandFeature<CommandSender> {
} catch (Exception e) {
handleFeedback(context, MessageConstants.COMMAND_RELOAD_PACK_FAILURE);
plugin().logger().warn("Failed to generate resource pack", e);
} finally {
RELOAD_PACK_FLAG = false;
}
});
} else if (argument == ReloadArgument.ALL) {

View File

@@ -0,0 +1,37 @@
package net.momirealms.craftengine.bukkit.plugin.command.feature;
import net.kyori.adventure.text.Component;
import net.momirealms.craftengine.bukkit.plugin.command.BukkitCommandFeature;
import net.momirealms.craftengine.core.pack.host.ResourcePackHost;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.command.CraftEngineCommandManager;
import net.momirealms.craftengine.core.plugin.config.Config;
import net.momirealms.craftengine.core.plugin.locale.MessageConstants;
import org.bukkit.command.CommandSender;
import org.incendo.cloud.Command;
public class UploadPackCommand extends BukkitCommandFeature<CommandSender> {
public UploadPackCommand(CraftEngineCommandManager<CommandSender> commandManager, CraftEngine plugin) {
super(commandManager, plugin);
}
@Override
public Command.Builder<? extends CommandSender> assembleCommand(org.incendo.cloud.CommandManager<CommandSender> manager, Command.Builder<CommandSender> builder) {
return builder
.handler(context -> {
ResourcePackHost host = plugin().packManager().resourcePackHost();
if (host.canUpload()) {
handleFeedback(context, MessageConstants.COMMAND_UPLOAD_ON_PROGRESS);
host.upload(Config.fileToUpload());
} else {
handleFeedback(context, MessageConstants.COMMAND_UPLOAD_FAILURE_NOT_SUPPORTED, Component.text(host.type().value()));
}
});
}
@Override
public String getFeatureID() {
return "upload";
}
}