Ir para conteúdo
  • 0

Ajuda com plugin


Lucasrocha

Pergunta

Olá,

Alguém poderia me ajudar falando como que eu faço para quando o player der o comando "/fight [nick de sua dupla]" e o outro player der o mesmo comando com o nick do primeiro os dois são teletransportados e é salvo uma lista que é possível visualizar com o comando "/fight participantes" ?

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0
Guest Fusquete

Eu fiz um código, tá bem extenso e completo para o seu plugin. Mas eu fiz correndo, então se tiver algum erro, falha ou bug. Me avisa aqui no tópico que eu mando a solução ^^


Senta aquele LIKE + RESOLVIDO


 


Somente crie um arquivo de config.yml para salvar os dados da localização! No caso eu usei no meu código a classe "comando" mas você pode colocar o nome da sua classe! hehe. Lembrando que eu não coloquei mensagem em todos os erros como "falta de argumentos" por que ia demorar muito, isso você mesmo faz


 


Hastebin: http://hastebin.com/aqelapopiz.avrasm


 


Código abaixo [Meio Grandinho]




import java.util.ArrayList;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class comando extends JavaPlugin implements CommandExecutor {

public void onEnable() {
saveDefaultConfig();
saveConfig();
getCommand("dupla").setExecutor(this);
getCommand("fight").setExecutor(this);
}

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

Player player = (Player) sender;
ArrayList<Player> duplas = new ArrayList<Player>();
ArrayList<Player> terminado = new ArrayList<Player>();
ArrayList<Player> pedindo = new ArrayList<Player>();
if (command.getName().equalsIgnoreCase("dupla")) {
if (sender instanceof Player) {
if (player.hasPermission("duplas")) {
if (args.length < 0) {
player.sendMessage(
"§cErro!" + player.getName() + "§cdigite o nome de sua dupla ex: /dupla teste");
if (args.length == 0) {
if (sender instanceof Player) {
if (player.hasPermission("duplas")) {
Player target = Bukkit.getServer().getPlayer(args[0]);
if (!duplas.contains(target)) {
if (terminado.isEmpty()) {
if (target instanceof Player) {
player.sendMessage("§ePedido de §ldupla §eenviado para o jogador§f"
+ target.getName() + "§8: §eAguarde...");
target.sendMessage("§aO jogador" + sender.getName()
+ "§aesta te convidando para ser sua dupla");
target.sendMessage("§aUse /dupla aceitar" + " §f" + player.getName()
+ "§apara §laceitar");
target.sendMessage("§cUse /dupla recusar" + " §f" + player.getName()
+ "§apara §lrecusar");
pedindo.add((Player) sender);
pedindo.add((Player) target);
if (args[0] == "aceitar") {
Player target1 = Bukkit.getServer().getPlayer(args[1]);
if (target1 instanceof Player) {
if (!duplas.contains(target1)) {
if (pedindo.contains(target1)) {
if (pedindo.contains(sender)) {
if (terminado.isEmpty()) {
duplas.add(target1);
terminado.add(target1);
player.sendMessage("§aO jogador§f"
+ target1.getName()
+ "§aAceitou seu pedido de dupla!");
target1.sendMessage(
"§aVocê aceitou o pedido de dupla feito por §f"
+ player.getName() + "§a!");
pedindo.remove(target1);
pedindo.remove(sender);
if (args[0] == "recusar") {
if (target1 instanceof Player) {
if (!duplas.contains(target1)) {
if (terminado.isEmpty()) {
pedindo.remove(target1);
pedindo.remove(sender);
player.sendMessage(
"§cO jogador§f"
+ target1
.getName()
+ "§cRecusou seu pedido de dupla!");
target1.sendMessage(
"§cVocê recusou o pedido de dupla feito por §f"
+ player.getName()
+ "§c!");
ArrayList<Player> osdoisaceitaram = new ArrayList<Player>();
if (command.getName()
.equalsIgnoreCase(
"fight")) {
if (sender instanceof Player) {
if (player
.hasPermission(
"fight")) {
if (args.length < 0) {
if (terminado
.isEmpty()) {
player.sendMessage(
"§CVocê não possui uma dupla, chame alguem com /dupla <nick>");
} else {
if (osdoisaceitaram
.isEmpty()) {
osdoisaceitaram
.add((Player) sender);
player.sendMessage(
"§cAguarde a resposta do outro participante...");
target.sendMessage(
"§cVocê foi solicitado no fight, utilize /fight §f"
+ sender.getName()
+ "§c, para ir com seu amigo");
}
ArrayList<Player> fightsetado = new ArrayList<Player>();
if (command
.getName()
.equalsIgnoreCase(
"setfight")) {
if (sender instanceof Player) {
if (player
.hasPermission(
"fight")) {
if (args.length < 0) {
if (fightsetado
.isEmpty()) {
getConfig()
.set("Fight",
"world");
getConfig()
.set("Fight",
"x");
getConfig()
.set("Fight",
"y");
getConfig()
.set("Fight",
"z");
getConfig()
.set("Fight.world",
player.getLocation()
.getWorld()
.getName());
getConfig()
.set("Fight.x",
player.getLocation()
.getX());
getConfig()
.set("Fight.y",
player.getLocation()
.getY());
getConfig()
.set("Fight.z",
player.getLocation()
.getZ());
saveConfig();
sender.sendMessage(
"§aFight setado");
fightsetado
.add((Player) sender);
}
}
}
}
if (args.length >= 0) {
if (osdoisaceitaram
.contains(
sender)) {
if (sender instanceof Player) {
if (player
.hasPermission(
"fight")) {
player.sendMessage(
"§cUtilize apenas o comando /fight para entrar!");
ArrayList<Player> participantes = new ArrayList<Player>();
if (args.length == 0) {
if (osdoisaceitaram
.contains(
target)) {
if (sender instanceof Player) {
if (player
.hasPermission(
"fight")) {
World w = Bukkit
.getServer()
.getWorld(
getConfig()
.getString(
"Fight.world"));
double x = getConfig()
.getDouble(
"spawn.x");
double y = getConfig()
.getDouble(
"spawn.y");
double z = getConfig()
.getDouble(
"spawn.z");
player.teleport(
new Location(
w,
x,
y,
z));
osdoisaceitaram
.add((Player) sender);
target.teleport(
new Location(
w,
x,
y,
z));
target.sendMessage(
"§aPoof, teleportado");
((Player) sender)
.teleport(
target);
sender.sendMessage(
"§aPoof, teleportado");
participantes
.add((Player) sender);
participantes
.add(target);
if (args[0] == "participantes") {
player.sendMessage(
"§aParticipantes do evento: \nl"
+ "§f"
+ participantes);
if (args[0] == "sair") {
if (participantes
.contains(
sender)) {
participantes
.remove(sender);
sender.sendMessage(
"§cVocê saiu do fight... Teleportando para o spawn");
((Player) sender)
.performCommand(
"spawn");
} else {
sender.sendMessage(
"§cVocê não está no fight");
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}

}

}
}
return false;
}
}
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...