71 lines
2.0 KiB
Java
71 lines
2.0 KiB
Java
package eu.univento.core.commands;
|
|
|
|
import eu.univento.core.Core;
|
|
import eu.univento.core.api.AutoCommand;
|
|
import eu.univento.core.api.languages.Messages;
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* fixes players
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
public class Fix extends AutoCommand<Core>{
|
|
|
|
/**
|
|
* @param plugin main class
|
|
* @param command command to execute
|
|
* @param description describes the command
|
|
* @param aliases aliases of command
|
|
*/
|
|
public Fix(Core 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(args.length == 0) {
|
|
for(Player player : Bukkit.getOnlinePlayers()) {
|
|
player.hidePlayer(p);
|
|
player.showPlayer(p);
|
|
}
|
|
p.teleport(p.getLocation());
|
|
p.sendMessage(msgs.PREFIX() + msgs.Core_FIX_OWN());
|
|
}
|
|
if(args.length == 1) {
|
|
if(Bukkit.getPlayer(args[0]) != null) {
|
|
CustomPlayer t = CustomPlayer.getPlayer(Bukkit.getPlayer(args[0]).getName());
|
|
Messages tMsgs = new Messages(t);
|
|
if(t != p) {
|
|
p.hidePlayer(t);
|
|
p.showPlayer(t);
|
|
p.teleport(p.getLocation());
|
|
p.sendMessage(msgs.Core_FIX_OTHER(t));
|
|
t.sendMessage(tMsgs.Core_FIX_BY_OTHER(p));
|
|
}else {
|
|
p.chat("/fix");
|
|
}
|
|
}else {
|
|
p.sendMessage(msgs.NOT_ONLINE(args[0]));
|
|
}
|
|
}
|
|
}else {
|
|
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
|
return Core.getOnlinePlayers().stream().map(CustomPlayer::getDisplayName).collect(Collectors.toList());
|
|
}
|
|
} |