summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/commands/EnableBorder.java
blob: 4aa44ad2b2e95e5bf997a9d535f4359d0e812045 (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
package net.tylermurphy.hideAndSeek.commands;

import org.bukkit.command.CommandSender;

import net.tylermurphy.hideAndSeek.ICommand;
import net.tylermurphy.hideAndSeek.manager.WorldborderManager;

import static net.tylermurphy.hideAndSeek.Store.*;

public class EnableBorder implements ICommand {

	public void execute(CommandSender sender, String[] args) {
		if(worldborderPosition == null) {
			sender.sendMessage(errorPrefix + "Please setup worldborder info before enabling");
			return;
		}
		boolean bool;
		try { bool = Boolean.parseBoolean(args[0]); } catch (Exception e) {
			sender.sendMessage(errorPrefix + "Please enter true or false");
			return;
		}
		if(spawnPosition != null && worldborderPosition != null && spawnPosition.distance(worldborderPosition) > 100) {
			sender.sendMessage(errorPrefix + "Cannot enable worldborder, spawn position is outside 100 blocks from worldborder");
			return;
		}
		sender.sendMessage(messagePrefix + "Set worldborder to "+args[0]);
		getConfig().set("borderEnabled", bool);
		worldborderEnabled = bool;
		saveConfig();
		WorldborderManager.reset();
	}

	public String getLabel() {
		return "enableBorder";
	}
	
	public String getUsage() {
		return "<true/false>";
	}

	public String getDescription() {
		return "Enables or disables worldborder";
	}

}