kenshinshideandseek/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java

53 lines
1.4 KiB
Java
Raw Normal View History

2021-09-01 01:55:27 +00:00
package net.tylermurphy.hideAndSeek.command;
2021-08-27 21:20:07 +00:00
2021-10-23 00:03:15 +00:00
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
2021-08-27 21:20:07 +00:00
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
2021-08-28 00:32:50 +00:00
import org.bukkit.scheduler.BukkitRunnable;
2021-08-27 21:20:07 +00:00
import net.tylermurphy.hideAndSeek.Main;
2021-10-23 00:03:15 +00:00
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
2021-08-27 21:20:07 +00:00
public class SaveMap implements ICommand {
2021-10-21 00:14:01 +00:00
public static boolean runningBackup = false;
2021-08-27 21:20:07 +00:00
public void execute(CommandSender sender, String[] args) {
2021-10-21 00:14:01 +00:00
if(!Main.plugin.status.equals("Standby")) {
2021-10-23 00:03:15 +00:00
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
2021-10-11 15:52:56 +00:00
return;
}
2021-08-27 21:20:07 +00:00
if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
2021-10-23 00:03:15 +00:00
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
2021-08-27 21:20:07 +00:00
return;
}
2021-10-23 00:03:15 +00:00
sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
2021-08-27 21:20:07 +00:00
Bukkit.getServer().getWorld(spawnWorld).save();
2021-08-28 00:32:50 +00:00
BukkitRunnable runnable = new BukkitRunnable() {
public void run() {
2021-10-27 23:57:44 +00:00
sender.sendMessage(
Main.plugin.worldLoader.save()
);
runningBackup = false;
2021-08-27 21:20:07 +00:00
}
2021-08-28 00:32:50 +00:00
};
runnable.runTaskAsynchronously(Main.plugin);
runningBackup = true;
}
2021-08-27 21:20:07 +00:00
public String getLabel() {
return "saveMap";
}
public String getUsage() {
return "";
}
public String getDescription() {
return "Saves current map for the game. May lag server.";
}
}