-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateGame.java
58 lines (52 loc) · 2.45 KB
/
CreateGame.java
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
package com.krisapps.biamine.biamine;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.io.IOException;
public class CreateGame implements CommandExecutor {
BiaMine main;
public CreateGame(BiaMine main) {
this.main = main;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//Syntax: /creategame <id> <countdown> <training_time> <display_name>
if (args.length > 0) {
if (args.length >= 4) {
String display_name = "";
for (int i = 3; i != args.length; i++) {
display_name += args[i] + " ";
}
main.games.set(args[0] + ".id", args[0]);
main.games.set(args[0] + ".display_name", display_name);
main.games.set(args[0] + ".countdown", args[1]);
main.games.set(args[0] + ".training_time", args[2]);
main.games.set("activeGame", args[0]);
try {
main.games.save(main.gameConfigfile);
} catch (IOException e) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.localization.getString(main.config.getString("lang") + ".creategame.err-save")));
try {
main.log("Failed to save 'games.yml': File not found.");
} catch (IOException ex) {
ex.printStackTrace();
}
e.printStackTrace();
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.localization.getString(main.config.getString("lang") + ".creategame.msg-gameready").replace("$id", args[0])));
try {
main.log("Game created: " + args[0]);
} catch (IOException e) {
e.printStackTrace();
}
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.localization.getString(main.config.getString("lang") + ".creategame.insuff")));
return false;
}
} else {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', main.localization.getString(main.config.getString("lang") + ".creategame.err-insuff")));
}
return true;
}
}