Solved Spawn Command

Discussion in 'Plugin Help/Development/Requests' started by bubblefat_, Dec 30, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    bubblefat_

    So I created a spawn command. I want to save it in a config file so when we reload we don't have to reset it. Here is my code if you need it.

    Code:
            if (cmd.getName().equalsIgnoreCase("setspawn") && sender instanceof Player) {
                Player player = (Player) sender;
                if(!player.isOp()) {
                    player.sendMessage(ChatColor.GOLD + "Permissoins> " + ChatColor.GRAY + "Only " + ChatColor.RED + "Owners " + ChatColor.GRAY + "can use this command.");
                    return true;   
                }
                if(player.isOp()) {
                    Location location = player.getLocation();
                    teleportLocation = location;
                    player.sendMessage(ChatColor.GOLD + "Teleport> " + ChatColor.GRAY + "Sucessfully set spawn.");
                    return true;
            }
            }
            if (cmd.getName().equalsIgnoreCase("spawn") && sender instanceof Player) {
                Player player = (Player) sender;
                if(teleportLocation !=null) {
                        player.teleport(teleportLocation);
                        player.sendMessage(ChatColor.GOLD + "Teleport> " + ChatColor.GRAY + ChatColor.BOLD + "WOOOOSH! ยง7You have been teleported to spawn.");
                        player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1);
                        return true;
                    }
                    }else{
                        Player player = (Player) sender;
                        player.sendMessage(ChatColor.GOLD + "Teleport> " + ChatColor.RED + "Spawn has not been set. " + ChatColor.GRAY + "Please notify staff.");
                        return true;
                    }
     
  2. Offline

    HeadGam3z

    You could use getConfig().set(path, object) and then save the config.
     
Thread Status:
Not open for further replies.

Share This Page