From f9031d41f91935a1f6eb428c4b778147a938c411 Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Fri, 9 Aug 2019 12:17:57 +0000 Subject: [PATCH] Expect multisell NPC id to be properly set. --- .../dist/game/data/multisell/900001.xml | 3 ++ .../dist/game/data/multisell/900002.xml | 3 ++ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../dist/game/data/multisell/900001.xml | 3 ++ .../dist/game/data/multisell/900002.xml | 3 ++ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../dist/game/data/multisell/900001.xml | 3 ++ .../dist/game/data/multisell/900002.xml | 3 ++ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../dist/game/data/multisell/900001.xml | 3 ++ .../dist/game/data/multisell/900002.xml | 3 ++ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../dist/game/data/multisell/900001.xml | 3 ++ .../dist/game/data/multisell/900002.xml | 3 ++ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../dist/game/data/multisell/900001.xml | 3 ++ .../dist/game/data/multisell/900002.xml | 3 ++ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../dist/game/data/multisell/900001.xml | 3 ++ .../dist/game/data/multisell/900002.xml | 3 ++ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../data/xml/impl/MultisellData.java | 16 +++++-- .../model/multisell/ListContainer.java | 7 +-- .../clientpackets/MultiSellChoose.java | 16 +++++-- .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ .../data/xml/impl/MultisellData.java | 19 ++++---- .../model/holders/MultisellListHolder.java | 7 +-- .../clientpackets/MultiSellChoose.java | 48 +++++++------------ 56 files changed, 459 insertions(+), 584 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/multisell/900001.xml b/L2J_Mobius_1.0_Ertheia/dist/game/data/multisell/900001.xml index 94daead217..4fb9977d64 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/multisell/900001.xml +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/multisell/900001.xml @@ -1,5 +1,8 @@ + + -1 + diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/multisell/900002.xml b/L2J_Mobius_1.0_Ertheia/dist/game/data/multisell/900002.xml index 6aa642331b..37549e1bd3 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/multisell/900002.xml +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/multisell/900002.xml @@ -1,6 +1,9 @@ + + -1 + diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index c8b2c52789..fec83da610 100644 --- a/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_1.0_Ertheia/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -113,13 +115,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -606,30 +620,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/multisell/900001.xml b/L2J_Mobius_2.5_Underground/dist/game/data/multisell/900001.xml index 94daead217..4fb9977d64 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/multisell/900001.xml +++ b/L2J_Mobius_2.5_Underground/dist/game/data/multisell/900001.xml @@ -1,5 +1,8 @@ + + -1 + diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/multisell/900002.xml b/L2J_Mobius_2.5_Underground/dist/game/data/multisell/900002.xml index 6aa642331b..37549e1bd3 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/multisell/900002.xml +++ b/L2J_Mobius_2.5_Underground/dist/game/data/multisell/900002.xml @@ -1,6 +1,9 @@ + + -1 + diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 63b796ea3c..233c3dfe73 100644 --- a/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_2.5_Underground/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/multisell/900001.xml b/L2J_Mobius_3.0_Helios/dist/game/data/multisell/900001.xml index 94daead217..4fb9977d64 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/multisell/900001.xml +++ b/L2J_Mobius_3.0_Helios/dist/game/data/multisell/900001.xml @@ -1,5 +1,8 @@ + + -1 + diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/multisell/900002.xml b/L2J_Mobius_3.0_Helios/dist/game/data/multisell/900002.xml index 6aa642331b..37549e1bd3 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/multisell/900002.xml +++ b/L2J_Mobius_3.0_Helios/dist/game/data/multisell/900002.xml @@ -1,6 +1,9 @@ + + -1 + diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 63b796ea3c..233c3dfe73 100644 --- a/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_3.0_Helios/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/multisell/900001.xml b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/multisell/900001.xml index 94daead217..4fb9977d64 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/multisell/900001.xml +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/multisell/900001.xml @@ -1,5 +1,8 @@ + + -1 + diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/multisell/900002.xml b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/multisell/900002.xml index 6aa642331b..37549e1bd3 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/multisell/900002.xml +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/multisell/900002.xml @@ -1,6 +1,9 @@ + + -1 + diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 63b796ea3c..233c3dfe73 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/multisell/900001.xml b/L2J_Mobius_5.0_Salvation/dist/game/data/multisell/900001.xml index c0d65ec4e8..5ebd367f02 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/multisell/900001.xml +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/multisell/900001.xml @@ -1,5 +1,8 @@ + + -1 + diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/multisell/900002.xml b/L2J_Mobius_5.0_Salvation/dist/game/data/multisell/900002.xml index 6aa642331b..37549e1bd3 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/multisell/900002.xml +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/multisell/900002.xml @@ -1,6 +1,9 @@ + + -1 + diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 189b8121f0..70539f4ce7 100644 --- a/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_5.0_Salvation/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/multisell/900001.xml b/L2J_Mobius_5.5_EtinasFate/dist/game/data/multisell/900001.xml index c0d65ec4e8..5ebd367f02 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/multisell/900001.xml +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/multisell/900001.xml @@ -1,5 +1,8 @@ + + -1 + diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/multisell/900002.xml b/L2J_Mobius_5.5_EtinasFate/dist/game/data/multisell/900002.xml index 6aa642331b..37549e1bd3 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/multisell/900002.xml +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/multisell/900002.xml @@ -1,6 +1,9 @@ + + -1 + diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 189b8121f0..70539f4ce7 100644 --- a/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_5.5_EtinasFate/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/multisell/900001.xml b/L2J_Mobius_6.0_Fafurion/dist/game/data/multisell/900001.xml index c0d65ec4e8..5ebd367f02 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/multisell/900001.xml +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/multisell/900001.xml @@ -1,5 +1,8 @@ + + -1 + diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/multisell/900002.xml b/L2J_Mobius_6.0_Fafurion/dist/game/data/multisell/900002.xml index 6aa642331b..37549e1bd3 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/multisell/900002.xml +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/multisell/900002.xml @@ -1,6 +1,9 @@ + + -1 + diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index ee511af3bb..48f7e18239 100644 --- a/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_6.0_Fafurion/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 794916ce8b..84a27dc39d 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -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); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/multisell/ListContainer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/multisell/ListContainer.java index 87abc66d23..b4988e8419 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/multisell/ListContainer.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/multisell/ListContainer.java @@ -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); } } \ No newline at end of file diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 92ad48ecf3..587caf2b2c 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -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)) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 48a6f7b889..3aa4a5b789 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 48a6f7b889..3aa4a5b789 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 48a6f7b889..3aa4a5b789 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 48a6f7b889..3aa4a5b789 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 48a6f7b889..3aa4a5b789 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java index 4d8bb5c1b2..7f96e8a59b 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/impl/MultisellData.java @@ -239,16 +239,19 @@ public class MultisellData implements IXmlReader return; } - if (!template.isNpcAllowed(-1) && (((npc != null) && !template.isNpcAllowed(npc.getId())) || ((npc == null) && template.isNpcOnly()))) + if (!template.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !template.isNpcAllowed(npc.getId())) { - 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; + 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; + } } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java index bc6f27d8cb..f4173594d1 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/MultisellListHolder.java @@ -102,11 +102,6 @@ public class MultisellListHolder implements IIdentifiable public boolean isNpcAllowed(int npcId) { - return (_npcsAllowed == null) || _npcsAllowed.contains(npcId); - } - - public boolean isNpcOnly() - { - return _npcsAllowed != null; + return (_npcsAllowed != null) && _npcsAllowed.contains(npcId); } } \ No newline at end of file diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java index 48a6f7b889..3aa4a5b789 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/MultiSellChoose.java @@ -16,6 +16,8 @@ */ package org.l2jmobius.gameserver.network.clientpackets; +import static org.l2jmobius.gameserver.model.actor.Npc.INTERACTION_DISTANCE; + import java.util.Collections; import java.util.List; import java.util.OptionalLong; @@ -130,13 +132,25 @@ public class MultiSellChoose implements IClientIncomingPacket } final Npc npc = player.getLastFolkNPC(); - if (!list.isNpcAllowed(-1) && !isAllowedToUse(player, npc, list)) + if (!list.isNpcAllowed(-1)) { - if (player.isGM()) + if ((npc == null) || !list.isNpcAllowed(npc.getId())) { - player.sendMessage("Multisell " + _listId + " is restricted. Under current conditions cannot be used. Only GMs are allowed to use it."); + 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; + } } - else + } + + if (!player.isGM() && (npc != null)) + { + if (!player.isInsideRadius3D(npc, INTERACTION_DISTANCE) || (player.getInstanceId() != npc.getInstanceId())) { player.setMultiSell(null); return; @@ -650,30 +664,4 @@ public class MultiSellChoose implements IClientIncomingPacket return true; } - - /** - * @param player - * @param npc - * @param list - * @return {@code true} if player can buy stuff from the multisell, {@code false} otherwise. - */ - private boolean isAllowedToUse(PlayerInstance player, Npc npc, PreparedMultisellListHolder list) - { - if (npc != null) - { - if (!list.isNpcAllowed(npc.getId())) - { - return false; - } - else if (list.isNpcOnly() && (!list.checkNpcObjectId(npc.getObjectId()) || (npc.getInstanceWorld() != player.getInstanceWorld()) || !player.isInsideRadius3D(npc, Npc.INTERACTION_DISTANCE))) - { - return false; - } - } - else if (list.isNpcOnly()) - { - return false; - } - return true; - } } \ No newline at end of file