Null warnings should never be suppressed.

This commit is contained in:
MobiusDevelopment
2022-08-26 00:13:15 +00:00
parent 03a61c2c3a
commit 635271c89a
6 changed files with 230 additions and 182 deletions

View File

@@ -62,7 +62,6 @@ public class AdminSiege implements IAdminCommandHandler
"admin_clanhallteleportself"
};
@SuppressWarnings("null")
@Override
public boolean useAdminCommand(String commandValue, Player activeChar)
{
@@ -105,7 +104,7 @@ public class AdminSiege implements IAdminCommandHandler
if (command.equalsIgnoreCase("admin_add_attacker"))
{
if (player == null)
if ((player == null) || (castle == null))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
}
@@ -120,7 +119,7 @@ public class AdminSiege implements IAdminCommandHandler
}
else if (command.equalsIgnoreCase("admin_add_defender"))
{
if (player == null)
if ((player == null) || (castle == null))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
}
@@ -130,6 +129,8 @@ public class AdminSiege implements IAdminCommandHandler
}
}
else if (command.equalsIgnoreCase("admin_add_guard"))
{
if (castle != null)
{
try
{
@@ -141,18 +142,27 @@ public class AdminSiege implements IAdminCommandHandler
BuilderUtil.sendSysMessage(activeChar, "Usage: //add_guard npcId");
}
}
}
else if (command.equalsIgnoreCase("admin_clear_siege_list"))
{
if (castle != null)
{
castle.getSiege().clearSiegeClan();
}
}
else if (command.equalsIgnoreCase("admin_endsiege"))
{
if (castle != null)
{
castle.getSiege().endSiege();
}
}
else if (command.equalsIgnoreCase("admin_list_siege_clans"))
{
if (castle != null)
{
castle.getSiege().listRegisterClan(activeChar);
}
return true;
}
else if (command.equalsIgnoreCase("admin_move_defenders"))
@@ -165,12 +175,14 @@ public class AdminSiege implements IAdminCommandHandler
{
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
}
else
else if (castle != null)
{
castle.setOwner(player.getClan());
}
}
else if (command.equalsIgnoreCase("admin_removecastle"))
{
if (castle != null)
{
final Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
if (clan != null)
@@ -182,9 +194,10 @@ public class AdminSiege implements IAdminCommandHandler
BuilderUtil.sendSysMessage(activeChar, "Unable to remove castle");
}
}
}
else if (command.equalsIgnoreCase("admin_clanhallset"))
{
if ((player == null) || (player.getClan() == null))
if ((player == null) || (player.getClan() == null) || (clanhall == null))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
}
@@ -207,7 +220,7 @@ public class AdminSiege implements IAdminCommandHandler
}
else if (command.equalsIgnoreCase("admin_clanhalldel"))
{
if (!ClanHallTable.getInstance().isFree(clanhall.getId()))
if ((clanhall != null) && !ClanHallTable.getInstance().isFree(clanhall.getId()))
{
ClanHallTable.getInstance().setFree(clanhall.getId());
AuctionManager.getInstance().initNPC(clanhall.getId());
@@ -218,14 +231,22 @@ public class AdminSiege implements IAdminCommandHandler
}
}
else if (command.equalsIgnoreCase("admin_clanhallopendoors"))
{
if (clanhall != null)
{
clanhall.openCloseDoors(true);
}
}
else if (command.equalsIgnoreCase("admin_clanhallclosedoors"))
{
if (clanhall != null)
{
clanhall.openCloseDoors(false);
}
}
else if (command.equalsIgnoreCase("admin_clanhallteleportself"))
{
if (clanhall != null)
{
final ClanHallZone zone = clanhall.getZone();
if (zone != null)
@@ -233,20 +254,27 @@ public class AdminSiege implements IAdminCommandHandler
activeChar.teleToLocation(zone.getSpawnLoc(), true);
}
}
}
else if (command.equalsIgnoreCase("admin_spawn_doors"))
{
if (castle != null)
{
castle.spawnDoor();
}
}
else if (command.equalsIgnoreCase("admin_startsiege"))
{
if (castle != null)
{
castle.getSiege().startSiege();
}
}
if (clanhall != null)
{
showClanHallPage(activeChar, clanhall);
}
else
else if (castle != null)
{
showSiegePage(activeChar, castle.getName());
}

View File

@@ -38,10 +38,10 @@ public class OfflineShop implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
"offline",
"offline_shop"
};
@SuppressWarnings("null")
@Override
public boolean useVoicedCommand(String command, Player player, String target)
{
@@ -66,7 +66,7 @@ public class OfflineShop implements IVoicedCommandHandler
}
final TradeList storeListBuy = player.getBuyList();
if ((storeListBuy == null) && (storeListBuy.getItemCount() == 0))
if ((storeListBuy == null) || (storeListBuy.getItemCount() == 0))
{
player.sendMessage("Your buy list is empty.");
player.sendPacket(ActionFailed.STATIC_PACKET);
@@ -74,7 +74,7 @@ public class OfflineShop implements IVoicedCommandHandler
}
final TradeList storeListSell = player.getSellList();
if ((storeListSell == null) && (storeListSell.getItemCount() == 0))
if ((storeListSell == null) || (storeListSell.getItemCount() == 0))
{
player.sendMessage("Your sell list is empty.");
player.sendPacket(ActionFailed.STATIC_PACKET);
@@ -143,7 +143,6 @@ public class OfflineShop implements IVoicedCommandHandler
player.sendMessage("Your private store has succesfully been flagged as an offline shop and will remain active for ever.");
player.logout();
return true;
}

View File

@@ -85,21 +85,13 @@ public class hitConditionBonus
factory.setIgnoringElementContentWhitespace(true);
factory.setIgnoringComments(true);
final File file = new File(Config.DATAPACK_ROOT, "data/stats/hitConditionBonus.xml");
Document doc = null;
if (file.exists())
{
try
{
doc = factory.newDocumentBuilder().parse(file);
}
catch (Exception e)
{
LOGGER.warning("[hitConditionBonus] Could not parse file: " + e.getMessage());
}
String name;
for (@SuppressWarnings("null")
Node list = doc.getFirstChild(); list != null; list = list.getNextSibling())
final Document doc = factory.newDocumentBuilder().parse(file);
for (Node list = doc.getFirstChild(); list != null; list = list.getNextSibling())
{
if ("hitConditionBonus".equalsIgnoreCase(list.getNodeName()) || "list".equalsIgnoreCase(list.getNodeName()))
{
@@ -158,6 +150,11 @@ public class hitConditionBonus
}
}
}
catch (Exception e)
{
LOGGER.warning("[hitConditionBonus] Could not parse file: " + e.getMessage());
}
}
else
{
throw new Error("[hitConditionBonus] File not found: " + file.getName());

View File

@@ -62,7 +62,6 @@ public class AdminSiege implements IAdminCommandHandler
"admin_clanhallteleportself"
};
@SuppressWarnings("null")
@Override
public boolean useAdminCommand(String commandValue, Player activeChar)
{
@@ -105,7 +104,7 @@ public class AdminSiege implements IAdminCommandHandler
if (command.equalsIgnoreCase("admin_add_attacker"))
{
if (player == null)
if ((player == null) || (castle == null))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
}
@@ -120,7 +119,7 @@ public class AdminSiege implements IAdminCommandHandler
}
else if (command.equalsIgnoreCase("admin_add_defender"))
{
if (player == null)
if ((player == null) || (castle == null))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
}
@@ -130,6 +129,8 @@ public class AdminSiege implements IAdminCommandHandler
}
}
else if (command.equalsIgnoreCase("admin_add_guard"))
{
if (castle != null)
{
try
{
@@ -141,18 +142,27 @@ public class AdminSiege implements IAdminCommandHandler
BuilderUtil.sendSysMessage(activeChar, "Usage: //add_guard npcId");
}
}
}
else if (command.equalsIgnoreCase("admin_clear_siege_list"))
{
if (castle != null)
{
castle.getSiege().clearSiegeClan();
}
}
else if (command.equalsIgnoreCase("admin_endsiege"))
{
if (castle != null)
{
castle.getSiege().endSiege();
}
}
else if (command.equalsIgnoreCase("admin_list_siege_clans"))
{
if (castle != null)
{
castle.getSiege().listRegisterClan(activeChar);
}
return true;
}
else if (command.equalsIgnoreCase("admin_move_defenders"))
@@ -165,12 +175,14 @@ public class AdminSiege implements IAdminCommandHandler
{
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
}
else
else if (castle != null)
{
castle.setOwner(player.getClan());
}
}
else if (command.equalsIgnoreCase("admin_removecastle"))
{
if (castle != null)
{
final Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
if (clan != null)
@@ -182,9 +194,10 @@ public class AdminSiege implements IAdminCommandHandler
BuilderUtil.sendSysMessage(activeChar, "Unable to remove castle");
}
}
}
else if (command.equalsIgnoreCase("admin_clanhallset"))
{
if ((player == null) || (player.getClan() == null))
if ((player == null) || (player.getClan() == null) || (clanhall == null))
{
activeChar.sendPacket(SystemMessageId.THAT_IS_THE_INCORRECT_TARGET);
}
@@ -207,7 +220,7 @@ public class AdminSiege implements IAdminCommandHandler
}
else if (command.equalsIgnoreCase("admin_clanhalldel"))
{
if (!ClanHallTable.getInstance().isFree(clanhall.getId()))
if ((clanhall != null) && !ClanHallTable.getInstance().isFree(clanhall.getId()))
{
ClanHallTable.getInstance().setFree(clanhall.getId());
AuctionManager.getInstance().initNPC(clanhall.getId());
@@ -218,14 +231,22 @@ public class AdminSiege implements IAdminCommandHandler
}
}
else if (command.equalsIgnoreCase("admin_clanhallopendoors"))
{
if (clanhall != null)
{
clanhall.openCloseDoors(true);
}
}
else if (command.equalsIgnoreCase("admin_clanhallclosedoors"))
{
if (clanhall != null)
{
clanhall.openCloseDoors(false);
}
}
else if (command.equalsIgnoreCase("admin_clanhallteleportself"))
{
if (clanhall != null)
{
final ClanHallZone zone = clanhall.getZone();
if (zone != null)
@@ -233,20 +254,27 @@ public class AdminSiege implements IAdminCommandHandler
activeChar.teleToLocation(zone.getSpawnLoc(), true);
}
}
}
else if (command.equalsIgnoreCase("admin_spawn_doors"))
{
if (castle != null)
{
castle.spawnDoor();
}
}
else if (command.equalsIgnoreCase("admin_startsiege"))
{
if (castle != null)
{
castle.getSiege().startSiege();
}
}
if (clanhall != null)
{
showClanHallPage(activeChar, clanhall);
}
else
else if (castle != null)
{
showSiegePage(activeChar, castle.getName());
}

View File

@@ -38,10 +38,10 @@ public class OfflineShop implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
"offline",
"offline_shop"
};
@SuppressWarnings("null")
@Override
public boolean useVoicedCommand(String command, Player player, String target)
{
@@ -66,7 +66,7 @@ public class OfflineShop implements IVoicedCommandHandler
}
final TradeList storeListBuy = player.getBuyList();
if ((storeListBuy == null) && (storeListBuy.getItemCount() == 0))
if ((storeListBuy == null) || (storeListBuy.getItemCount() == 0))
{
player.sendMessage("Your buy list is empty.");
player.sendPacket(ActionFailed.STATIC_PACKET);
@@ -74,7 +74,7 @@ public class OfflineShop implements IVoicedCommandHandler
}
final TradeList storeListSell = player.getSellList();
if ((storeListSell == null) && (storeListSell.getItemCount() == 0))
if ((storeListSell == null) || (storeListSell.getItemCount() == 0))
{
player.sendMessage("Your sell list is empty.");
player.sendPacket(ActionFailed.STATIC_PACKET);
@@ -143,7 +143,6 @@ public class OfflineShop implements IVoicedCommandHandler
player.sendMessage("Your private store has succesfully been flagged as an offline shop and will remain active for ever.");
player.logout();
return true;
}

View File

@@ -85,21 +85,13 @@ public class hitConditionBonus
factory.setIgnoringElementContentWhitespace(true);
factory.setIgnoringComments(true);
final File file = new File(Config.DATAPACK_ROOT, "data/stats/hitConditionBonus.xml");
Document doc = null;
if (file.exists())
{
try
{
doc = factory.newDocumentBuilder().parse(file);
}
catch (Exception e)
{
LOGGER.warning("[hitConditionBonus] Could not parse file: " + e.getMessage());
}
String name;
for (@SuppressWarnings("null")
Node list = doc.getFirstChild(); list != null; list = list.getNextSibling())
final Document doc = factory.newDocumentBuilder().parse(file);
for (Node list = doc.getFirstChild(); list != null; list = list.getNextSibling())
{
if ("hitConditionBonus".equalsIgnoreCase(list.getNodeName()) || "list".equalsIgnoreCase(list.getNodeName()))
{
@@ -158,6 +150,11 @@ public class hitConditionBonus
}
}
}
catch (Exception e)
{
LOGGER.warning("[hitConditionBonus] Could not parse file: " + e.getMessage());
}
}
else
{
throw new Error("[hitConditionBonus] File not found: " + file.getName());