Ir para conteúdo
  • 0

Como eu coloco uma permissao nesse código?


Lelfe

Pergunta

Como eu coloco uma permissão nesse código?


não estou conseguindo :/


 


quero colocar para pegar a permissao da config, igual as msg e os itens bloqueados que já estou pegando.


 


config: 



msg_ao_craftar: "§cO Craft desse item está bloqueado no nosso servidor."
permissao: 'craft.bypass'
itens_bloqueados:
- '276'
- '278'

Código:



@EventHandler
public void craftItem(PrepareItemCraftEvent e)
{
@SuppressWarnings("deprecation")
int itemType = e.getRecipe().getResult().getType().getId();
if (getConfig().getIntegerList("itens_bloqueados").contains(Integer.valueOf(itemType)))
{
e.getInventory().setResult(new ItemStack(Material.AIR));
for (HumanEntity he : e.getViewers()) {
if ((he instanceof Player)) {
((Player)he).sendMessage(getConfig().getString("msg_ao_craftar").replace("&", "§"));
}
((Player)he).closeInventory();
return;
}
}
}
}


(sou iniciante)


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

8 respostass a esta questão

Posts Recomendados


@EventHandler
@SuppressWarnings("deprecation") 
public void craftItem(PrepareItemCraftEvent e) {
int itemType = e.getRecipe().getResult().getType().getId();
if (getConfig().getIntegerList("itens_bloqueados").contains(Integer.valueOf(itemType))) {
e.getInventory().setResult(new ItemStack(Material.AIR));
for (HumanEntity he : e.getViewers()) {
if ((he instanceof Player)) {
if(player.hasPermission(getConfig().getString("permissao"))) {
((Player)he).sendMessage(getConfig().getString("msg_ao_craftar").replace("&", "§"));
} else {
e.setCancelled(true);
}
} else {
((Player)he).closeInventory();
return;
}
}
}
}
 

 

ae no eclipse da um ctrl + shift + f pra arruma o cod, esse fico assim pq arrumei no notpad '-'

 

valeeu :)

Link para o comentário
Compartilhar em outros sites

Sim, aí com um else você coloca e.setCancelled(true) pra quem não tiver a permissão...

eu não consegui, se não for muito abuso da minha parte poderia colocar no meu código por favor?

 

- ficou dando erro nos codigos

- não sei a linha certa para colocar

- sou burro

Link para o comentário
Compartilhar em outros sites


@EventHandler
@SuppressWarnings("deprecation") 
public void craftItem(PrepareItemCraftEvent e) {
int itemType = e.getRecipe().getResult().getType().getId();
if (getConfig().getIntegerList("itens_bloqueados").contains(Integer.valueOf(itemType))) {
e.getInventory().setResult(new ItemStack(Material.AIR));
for (HumanEntity he : e.getViewers()) {
if ((he instanceof Player)) {
if(player.hasPermission(getConfig().getString("permissao"))) {
((Player)he).sendMessage(getConfig().getString("msg_ao_craftar").replace("&", "§"));
} else {
e.setCancelled(true);
}
} else {
((Player)he).closeInventory();
return;
}
}
}
}
 

 

ae no eclipse da um ctrl + shift + f pra arruma o cod, esse fico assim pq arrumei no notpad '-'

Link para o comentário
Compartilhar em outros sites

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