Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package busstation.busstation.commands;
- import busstation.busstation.BusStation;
- import busstation.busstation.util.ConfigUtilities;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- public class addBus implements CommandExecutor {
- private BusStation plugin;
- public addBus(BusStation pl) {
- plugin = pl;
- }
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- ConfigUtilities config = new ConfigUtilities(plugin, "coords.yml");
- Player player = (Player) sender;
- Location loc = player.getLocation();
- String world = player.getWorld().getName();
- if (sender instanceof Player) {
- if (args.length == 2) {
- boolean addstop = false;
- if (!(config.getConfig().getConfigurationSection("stops." + args[0]) == null)) {
- sender.sendMessage(ChatColor.RED + "That location name is already used on the server.");
- return false;
- } // location isn't already in coords.yml
- else {
- for (String key : config.getConfig().getConfigurationSection("stops").getKeys(false)) {
- String cworld = config.getConfig().getString("stops." + key + ".Location.world");
- if (world.equalsIgnoreCase(config.getConfig().getString("stops." + key + ".Location.world"))) {
- Location locb = (Location) config.getConfig().getLocation("stops." + key + ".Location");
- int mindis = plugin.getConfig().getInt("minStopDist");
- if (loc.distance(locb) < mindis) {
- addstop = true;
- } // minimum distance
- }// if world equals world.
- } // end string loop.
- } // end else location not in config.
- if (addstop) {
- sender.sendMessage("Not Adding Location");
- } else {
- sender.sendMessage("Adding location");
- }
- return true;
- } // args length
- } // instance of player
- return true;
- } // methods
- } // class
Advertisement
Add Comment
Please, Sign In to add comment