use of com.solinia.solinia.Interfaces.ISoliniaItem in project solinia3-core by mixxit.
the class Utils method checkArmourEquip.
public static void checkArmourEquip(ISoliniaPlayer solplayer, PlayerInteractEvent event) {
ItemStack itemstack = event.getItem();
if (itemstack == null)
return;
if (!(CraftItemStack.asNMSCopy(itemstack).getItem() instanceof net.minecraft.server.v1_12_R1.ItemArmor)) {
return;
}
if (Utils.IsSoliniaItem(itemstack) && !itemstack.getType().equals(Material.ENCHANTED_BOOK)) {
try {
ISoliniaItem soliniaitem = StateManager.getInstance().getConfigurationManager().getItem(itemstack);
if (soliniaitem.getAllowedClassNames().size() == 0)
return;
if (solplayer.getClassObj() == null) {
Utils.CancelEvent(event);
;
event.getPlayer().updateInventory();
event.getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
return;
}
if (!soliniaitem.getAllowedClassNames().contains(solplayer.getClassObj().getName())) {
Utils.CancelEvent(event);
;
event.getPlayer().updateInventory();
event.getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
return;
}
if (soliniaitem.getMinLevel() > solplayer.getLevel()) {
Utils.CancelEvent(event);
;
event.getPlayer().updateInventory();
event.getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
return;
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Aggregations