blob: c854b60701469b8c6ebc51ec3cbf9c1a5a4840e8 (
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
60
|
package net.tylermurphy.hideAndSeek.command;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import java.util.HashMap;
import java.util.Map;
import net.tylermurphy.hideAndSeek.game.Status;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.tylermurphy.hideAndSeek.Main;
import static net.tylermurphy.hideAndSeek.configuration.Config.addToConfig;
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
public class SetSpawnLocation implements ICommand {
public void execute(CommandSender sender, String[] args) {
if(Main.plugin.status != Status.STANDBY) {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
Vector newSpawnPosition = new Vector();
Player player = (Player) sender;
if(player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
sender.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
return;
}
newSpawnPosition.setX(player.getLocation().getBlockX());
newSpawnPosition.setY(player.getLocation().getBlockY());
newSpawnPosition.setZ(player.getLocation().getBlockZ());
if(worldborderEnabled && newSpawnPosition.distance(worldborderPosition) > 100) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
return;
}
spawnWorld = player.getLocation().getWorld().getName();
spawnPosition = newSpawnPosition;
sender.sendMessage(messagePrefix + message("GAME_SPAWN"));
addToConfig("spawns.game.x", spawnPosition.getX());
addToConfig("spawns.game.y", spawnPosition.getY());
addToConfig("spawns.game.z", spawnPosition.getZ());
addToConfig("spawns.game.world", player.getLocation().getWorld().getName());
saveConfig();
}
public String getLabel() {
return "setspawn";
}
public String getUsage() {
return "";
}
public String getDescription() {
return "Sets hide and seeks spawn location to current position";
}
}
|