mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-03 14:26:27 +00:00
bukkit commandregistrationevent
This commit is contained in:
@@ -5,6 +5,6 @@ dependencies {
|
||||
|
||||
"shadedApi"("net.jafama:jafama:2.3.2")
|
||||
|
||||
implementation("cloud.commandframework", "cloud-core", "1.5.0")
|
||||
"compileOnly"("cloud.commandframework", "cloud-core", "1.5.0")
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ dependencies {
|
||||
"compileOnly"("com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT")
|
||||
|
||||
"shadedApi"("com.google.guava:guava:30.0-jre")
|
||||
|
||||
"shadedApi"("cloud.commandframework", "cloud-bukkit", "1.5.0")
|
||||
}
|
||||
|
||||
val jvmFlags = listOf(
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
package com.dfsek.terra.bukkit;
|
||||
|
||||
import cloud.commandframework.bukkit.BukkitCommandManager;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
|
||||
import com.dfsek.terra.api.entity.CommandSender;
|
||||
import com.dfsek.terra.api.event.events.platform.CommandRegistrationEvent;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -43,9 +50,25 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
private final TerraPluginImpl terraPlugin = new TerraPluginImpl(this);
|
||||
|
||||
private final cloud.commandframework.CommandManager<CommandSender> commandManager;
|
||||
|
||||
private final Map<String, com.dfsek.terra.api.world.generator.ChunkGenerator> generatorMap = new HashMap<>();
|
||||
private final Map<String, ConfigPack> worlds = new HashMap<>();
|
||||
|
||||
public TerraBukkitPlugin() {
|
||||
try {
|
||||
commandManager = new BukkitCommandManager<>(
|
||||
this,
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
BukkitAdapter::adapt,
|
||||
BukkitAdapter::adapt
|
||||
);
|
||||
} catch(Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
BukkitChunkGeneratorWrapper.saveAll();
|
||||
@@ -62,27 +85,7 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
||||
|
||||
new Metrics(this, 9017); // Set up bStats.
|
||||
|
||||
PluginCommand c = Objects.requireNonNull(getCommand("terra"));
|
||||
|
||||
CommandManager manager = new TerraCommandManager(terraPlugin);
|
||||
|
||||
|
||||
try {
|
||||
CommandUtil.registerAll(manager);
|
||||
manager.register("save-data", SaveDataCommand.class);
|
||||
manager.register("fix-chunk", FixChunkCommand.class);
|
||||
} catch(MalformedCommandException e) { // This should never happen.
|
||||
terraPlugin.logger().severe("Errors occurred while registering commands.");
|
||||
e.printStackTrace();
|
||||
terraPlugin.logger().severe("Please report this to Terra.");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitCommandAdapter command = new BukkitCommandAdapter(manager);
|
||||
|
||||
c.setExecutor(command);
|
||||
c.setTabCompleter(command);
|
||||
terraPlugin.getEventManager().callEvent(new CommandRegistrationEvent(commandManager)); // Register commands
|
||||
|
||||
|
||||
long save = terraPlugin.getTerraConfig().getDataSaveInterval();
|
||||
|
||||
Reference in New Issue
Block a user