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

@@ -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";
}
}