mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-17 16:15:32 +01:00
SchedulerManager console output + Added a simple ShutdownCommand
This commit is contained in:
parent
4ad4054fce
commit
56010e27e6
@ -36,6 +36,7 @@ public class Main {
|
||||
commandManager.register(new SimpleCommand());
|
||||
commandManager.register(new GamemodeCommand());
|
||||
commandManager.register(new DimensionCommand());
|
||||
commandManager.register(new ShutdownCommand());
|
||||
|
||||
/*RecipeManager recipeManager = MinecraftServer.getRecipeManager();
|
||||
ShapelessRecipe shapelessRecipe = new ShapelessRecipe("test", "groupname") {
|
||||
|
33
src/main/java/fr/themode/demo/commands/ShutdownCommand.java
Normal file
33
src/main/java/fr/themode/demo/commands/ShutdownCommand.java
Normal file
@ -0,0 +1,33 @@
|
||||
package fr.themode.demo.commands;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.command.CommandProcessor;
|
||||
import net.minestom.server.command.CommandSender;
|
||||
import net.minestom.server.entity.Player;
|
||||
|
||||
/**
|
||||
* A simple shutdown command
|
||||
*/
|
||||
public class ShutdownCommand implements CommandProcessor {
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "shutdown";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(CommandSender sender, String command, String[] args) {
|
||||
MinecraftServer.stopCleanly();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccess(Player player) {
|
||||
return player.getPermissionLevel() >= 4;
|
||||
}
|
||||
}
|
@ -80,10 +80,13 @@ public class SchedulerManager {
|
||||
* Shutdowns all normal tasks and call the registered shutdown tasks
|
||||
*/
|
||||
public void shutdown() {
|
||||
for (Task shutdownTask : this.getShutdownTasks()) {
|
||||
shutdownTask.schedule();
|
||||
MinecraftServer.getLOGGER().info("Executing all shutdown tasks..");
|
||||
for (Task task : this.getShutdownTasks()) {
|
||||
task.schedule();
|
||||
}
|
||||
batchesPool.shutdown();
|
||||
MinecraftServer.getLOGGER().info("Shutting down the scheduled execution service and batches pool.");
|
||||
this.timerExecutionService.shutdown();
|
||||
this.batchesPool.shutdown();
|
||||
try {
|
||||
batchesPool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user