Expect multisell NPC id to be properly set.

This commit is contained in:
MobiusDevelopment
2019-08-09 12:17:57 +00:00
parent efbbe7a3b7
commit f9031d41f9
56 changed files with 459 additions and 584 deletions

View File

@@ -241,10 +241,20 @@ public class MultisellData implements IXmlReader
return;
}
if (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))
if (!template.isNpcAllowed(-1))
{
LOGGER.warning(getClass().getSimpleName() + ": player " + player + " attempted to open multisell " + listId + " from npc " + npc + " which is not allowed!");
return;
if ((npc == null) || !template.isNpcAllowed(npc.getId()))
{
if (player.isGM())
{
player.sendMessage("Multisell " + listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it.");
}
else
{
LOGGER.warning(getClass().getSimpleName() + ": Player " + player + " attempted to open multisell " + listId + " from npc " + npc + " which is not allowed!");
return;
}
}
}
final PreparedListContainer list = new PreparedListContainer(template, inventoryOnly, player, npc);

View File

@@ -95,11 +95,6 @@ public class ListContainer
public boolean isNpcAllowed(int npcId)
{
return (_npcsAllowed == null) || _npcsAllowed.contains(npcId);
}
public boolean isNpcOnly()
{
return _npcsAllowed != null;
return (_npcsAllowed != null) && _npcsAllowed.contains(npcId);
}
}

View File

@@ -119,10 +119,20 @@ public class MultiSellChoose implements IClientIncomingPacket
}
final Npc npc = player.getLastFolkNPC();
if (((npc != null) && !list.isNpcAllowed(npc.getId())) || ((npc == null) && list.isNpcOnly()))
if (!list.isNpcAllowed(-1))
{
player.setMultiSell(null);
return;
if ((npc == null) || !list.isNpcAllowed(npc.getId()))
{
if (player.isGM())
{
player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it.");
}
else
{
player.setMultiSell(null);
return;
}
}
}
if (!player.isGM() && (npc != null))