Add nullcheck

This commit is contained in:
samczsun 2016-05-19 21:33:40 -04:00 committed by Sam Sun
parent d8b5dba3fc
commit 63e3cc8e12

View File

@ -269,26 +269,33 @@ public class ClanMainPage extends ClanPageBase
{
String enemyName = clanWar.getClanA().equals(clan.getName()) ? clanWar.getClanB() : clanWar.getClanA();
final ClanInfo enemy = getPlugin().getClan(enemyName);
String itemName = enemyName;
Material material = USE_RESOURCE_ICONS ? ClanIcon.WAR.getMaterial() : Material.DIAMOND_SWORD;
byte data = USE_RESOURCE_ICONS ? ClanIcon.WAR.getData() : 0;
int warPoints = clanWar.getPoints(clan.getName());
ArrayList<String> lore = new ArrayList<String>(5);
lore.add(" ");
lore.add(C.Reset + C.cYellow + "War Points " + clan.getFormattedWarPoints(enemy));
lore.add(" ");
lore.add(ChatColor.RESET + C.cGray + "Left Click " + C.cWhite + "Clan Info");
ShopItem shopItem = new ShopItem(material, data, itemName, lore.toArray(new String[0]), 0, false, false);
addButtonFakeCount(slot, shopItem, new IButton()
if (enemy != null)
{
@Override
public void onClick(Player player, ClickType clickType)
String itemName = enemyName;
Material material = USE_RESOURCE_ICONS ? ClanIcon.WAR.getMaterial() : Material.DIAMOND_SWORD;
byte data = USE_RESOURCE_ICONS ? ClanIcon.WAR.getData() : 0;
int warPoints = clanWar.getPoints(clan.getName());
ArrayList<String> lore = new ArrayList<String>(5);
lore.add(" ");
lore.add(C.Reset + C.cYellow + "War Points " + clan.getFormattedWarPoints(enemy));
lore.add(" ");
lore.add(ChatColor.RESET + C.cGray + "Left Click " + C.cWhite + "Clan Info");
ShopItem shopItem = new ShopItem(material, data, itemName, lore.toArray(new String[0]), 0, false, false);
addButtonFakeCount(slot, shopItem, new IButton()
{
getShop().openPageForPlayer(player, new ClanWhoPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player, enemy, true));
}
}, warPoints);
@Override
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(player, new ClanWhoPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player, enemy, true));
}
}, warPoints);
}
else
{
System.err.println("Could not find enemy clan: " + enemyName);
}
}
private void addAllyButton(int slot, final ClanInfo ally)