83 lines
2.3 KiB
Java
83 lines
2.3 KiB
Java
package eu.univento.lobby.commands;
|
|
|
|
import eu.univento.core.api.AutoCommand;
|
|
import eu.univento.core.api.CustomPlayer;
|
|
import eu.univento.core.api.Messages;
|
|
import eu.univento.core.api.Servers;
|
|
import eu.univento.core.api.Perms.Ranks;
|
|
import eu.univento.lobby.Lobby;
|
|
import eu.univento.lobby.utils.StatusSignUtil;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
|
|
import org.bukkit.Material;
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
/**
|
|
* sets status signs
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
public class StatusSign extends AutoCommand<Lobby> {
|
|
|
|
/**
|
|
* @param plugin main class
|
|
* @param command command to execute
|
|
* @param description describes the command
|
|
* @param aliases aliases of command
|
|
*/
|
|
public StatusSign(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());
|
|
if (p.isAllowed(Ranks.Admin)) {
|
|
if (args.length < 1) {
|
|
p.sendMessage("§4/statussign <Servername>");
|
|
return true;
|
|
}
|
|
String ip = Servers.getServerIP(args[0]);
|
|
|
|
int port = Servers.getServerPort(args[1]);
|
|
|
|
String name = args[0];
|
|
|
|
HashSet<Byte> hash = new HashSet<Byte>();
|
|
Block block = p.getTargetBlock(hash, 10);
|
|
if (block == null) {
|
|
p.sendMessage("§4Da ist ja gar kein Block :|:");
|
|
return true;
|
|
}
|
|
|
|
if ((block.getType() != Material.SIGN) && (block.getType() != Material.SIGN_POST) && (block.getType() != Material.WALL_SIGN)) {
|
|
p.sendMessage("§4Du musst schon auf ein Schild schauen");
|
|
return true;
|
|
}
|
|
|
|
StatusSignUtil statusSign = new StatusSignUtil(block.getLocation(), name, ip, port);
|
|
|
|
p.sendMessage("§aDu hast erfolgreich ein Status Schild erstellt");
|
|
|
|
Lobby.returnSigns().add(statusSign);
|
|
StatusSignUtil.save(statusSign);
|
|
}
|
|
p.sendMessage(Messages.NO_PERMS);
|
|
} else {
|
|
sender.sendMessage(Messages.NOT_A_PLAYER);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
|
return null;
|
|
}
|
|
} |