Lobby/src/main/java/eu/univento/lobby/commands/Setloc.java

66 lines
1.9 KiB
Java

package eu.univento.lobby.commands;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.Config;
import eu.univento.core.api.languages.Messages;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.core.api.player.Rank;
import eu.univento.lobby.Lobby;
/**
* sets teleport locations
* @author joethei
* @version 1.0
*/
public class Setloc extends AutoCommand<Lobby>{
/**
* @param plugin main class
* @param command command to execute
* @param description describes the command
* @param aliases aliases of command
*/
public Setloc(Lobby plugin, String command, String description, String... aliases) {
super(plugin, command, description, aliases);
}
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if(sender instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
Messages msgs = new Messages(p);
if(p.isAllowed(Rank.SrDeveloper)) {
if(args.length == 1) {
Config.write("Lobby.Locs." + args[0], p.getLocation());
p.sendMessage(msgs.PREFIX() + msgs.Lobby_SET_LOCATION());
}else {
p.sendMessage(msgs.PREFIX() + msgs.Lobby_SET_LOCATION_USAGE());
}
}else {
p.sendMessage(msgs.NO_PERMS());
}
}else {
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
}
return false;
}
@Override
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
ArrayList<String> list = new ArrayList<>();
list.add("Spawn");
list.add("Maya");
list.add("WoolGet");
list.add("PremiumHub");
return list;
}
}