blob: c5b753f3092da87cb07dae7ed42e64c1c748e525 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package net.tylermurphy.hideAndSeek.commands;
import static net.tylermurphy.hideAndSeek.Store.*;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import net.tylermurphy.hideAndSeek.Main;
import net.tylermurphy.hideAndSeek.util.Functions;
import net.tylermurphy.hideAndSeek.util.ICommand;
public class SaveMap implements ICommand {
public void execute(CommandSender sender, String[] args) {
if(spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
sender.sendMessage(errorPrefix + "Please set spawn location first");
return;
}
sender.sendMessage(warningPrefix + "This command may lag the server");
Bukkit.getServer().getWorld(spawnWorld).save();
File current = new File(Main.root+File.separator+spawnWorld);
if(current.exists()) {
File destenation = new File(Main.root+File.separator+"hideandseek_"+spawnWorld);
if(destenation.exists()) {
deleteDirectory(destenation);
destenation.mkdir();
}
Functions.copyFileStructure(current, destenation);
sender.sendMessage(messagePrefix + "Map save complete");
} else {
sender.sendMessage(errorPrefix + "Coudnt find current map");
}
}
boolean deleteDirectory(File directoryToBeDeleted) {
File[] allContents = directoryToBeDeleted.listFiles();
if (allContents != null) {
for (File file : allContents) {
deleteDirectory(file);
}
}
return directoryToBeDeleted.delete();
}
public String getLabel() {
return "saveMap";
}
public String getUsage() {
return "";
}
public String getDescription() {
return "Saves current map for the game. May lag server.";
}
}
|