Ir para conteúdo
  • 0

[Entregue] Inventário full '-'


Guest » MickCraft » xKizame »

Pergunta

10 respostass a esta questão

Posts Recomendados

public boolean inventarioVazio(Player p){
if ((p.getInventory().getContents() == null) && (p.getInventory().getArmorContents() == null)){
	return true;
	}else{
	return false;
    }
}

Como usar:

if (inventarioVazio(p) == true){
	p.sendMessage("Você está com o inventário vazio!");
	}else{
	p.sendMessage("Você tem itens no inventário!");
}

Vai checar se não tem itens no inventário, e se não tem armadura.

Link para o comentário
Compartilhar em outros sites

boolean isEmpty = false;

          for(int is=0; is<36; is++) {

                    if(p.getInventory().getItem(is) == null){

                     continue;

        }else{

         isEmpty = true;

         break;

         }

    }

    if(isEmpty == true){

     p.sendMessage("§cEsvazie seu inventário para entrar");

    }

Link para o comentário
Compartilhar em outros sites

 

boolean isEmpty = false;
          for(int is=0; is<36; is++) {
                    if(p.getInventory().getItem(is) == null){
                     continue;
        }else{
         isEmpty = true;
         break;
         }
    }
    if(isEmpty == true){
     p.sendMessage("§cEsvazie seu inventário para entrar");
    }

 

Aí so pega o inventario , e não a armadura.

Link para o comentário
Compartilhar em outros sites

como ele vai guardar itens na armadura? '-'


Como eu faço para saber se o inventário do jogador ta full e mandar uma mensagem tipo.. "inventario lotado"

 

Posso saber melhor o por que você quer saber isso?

 

Posso fazer um sistema que retorna uma map, com um Material e um Integer de quantos itens ainda cabe... (para caso todo os slots estiverem cheio, no entanto ter stacks incompletas)

Link para o comentário
Compartilhar em outros sites


public static boolean isInventoryEmpty(Player p)

{

for(ItemStack item : p.getInventory().getContents()){

if(item != null && item.getType()!=Material.AIR)

return false;

}

for(ItemStack item : p.getInventory().getArmorContents()){

if(item != null && item.getType()!=Material.AIR)

return false;

}

return true;

}

Link para o comentário
Compartilhar em outros sites

public static boolean isInventoryEmpty(Player p)
		{
		    for(ItemStack item : p.getInventory().getContents()){
		     if(item != null && item.getType()!=Material.AIR)
		      return false;
		    }
		    for(ItemStack item : p.getInventory().getArmorContents()){
		     if(item != null && item.getType()!=Material.AIR)
		      return false;
		    }
		    return true;
		}

"if" não funciona não? ;-;

Editado por zMathi
Link para o comentário
Compartilhar em outros sites

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