Browse Source

Refactored to static methods.

master
MagicBot 2 years ago
parent
commit
4adfbc0723
  1. 543
      src/engine/net/client/handlers/OrderNPCMsgHandler.java
  2. 75
      src/engine/objects/Mob.java
  3. 24
      src/engine/objects/NPC.java

543
src/engine/net/client/handlers/OrderNPCMsgHandler.java

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
package engine.net.client.handlers;
import engine.Enum;
import engine.Enum.DispatchChannel;
import engine.Enum.GameObjectType;
import engine.Enum.ProfitType;
@ -36,242 +37,65 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { @@ -36,242 +37,65 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
super(OrderNPCMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
// Member variable declarations
public static void processRedeedMob(Mob mob, Building building, ClientConnection origin) {
PlayerCharacter player;
NPC npc;
Mob mob;
Building building;
OrderNPCMsg orderNPCMsg;
ManageCityAssetsMsg outMsg;
// Member variable assignment
orderNPCMsg = (OrderNPCMsg) baseMsg;
if (origin.ordernpcspam > System.currentTimeMillis())
return true;
origin.ordernpcspam = System.currentTimeMillis() + 500;
Contract contract;
CharacterItemManager itemMan;
ItemBase itemBase;
Item item;
player = SessionManager.getPlayerCharacter(origin);
itemMan = player.getCharItemManager();
if (player == null)
return true;
contract = mob.getContract();
if (orderNPCMsg.getActionType() == 28) {
OrderNPCMsgHandler.handleCityCommand(orderNPCMsg, player);
return true;
if (!player.getCharItemManager().hasRoomInventory((short) 1)) {
ErrorPopupMsg.sendErrorPopup(player, 21);
return;
}
if (orderNPCMsg.getObjectType() == GameObjectType.NPC.ordinal()) {
npc = NPC.getFromCache(orderNPCMsg.getNpcUUID());
if (npc == null)
return true;
building = BuildingManager.getBuildingFromCache(orderNPCMsg.getBuildingUUID());
if (building == null)
return true;
if (building.getHirelings().containsKey(npc) == false)
return true;
if (player.getCharItemManager().getTradingWith() != null) {
ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings.");
return true;
}
player.lastBuildingAccessed = building.getObjectUUID();
switch (orderNPCMsg.getActionType()) {
case 2:
player = SessionManager.getPlayerCharacter(origin);
if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false)
return true;
if (building.getHirelings().containsKey(npc) == false)
return true;
if (npc.remove() == false) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
return true;
}
ManageCityAssetsMsg manageCityAssetsMsg = new ManageCityAssetsMsg();
manageCityAssetsMsg.actionType = SVR_CLOSE_WINDOW;
manageCityAssetsMsg.setTargetType(building.getObjectType().ordinal());
manageCityAssetsMsg.setTargetID(building.getObjectUUID());
Dispatch dispatch = Dispatch.borrow(player, manageCityAssetsMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
case CLIENT_UPGRADE_REQUEST:
if (BuildingManager.playerCanManage(player, building) == false)
return true;
processUpgradeNPC(player, npc);
outMsg = new ManageCityAssetsMsg(player, building);
// Action TYPE
outMsg.actionType = 3;
outMsg.setTargetType(building.getObjectType().ordinal());
outMsg.setTargetID(building.getObjectUUID());
outMsg.setTargetType3(building.getObjectType().ordinal());
outMsg.setTargetID3(building.getObjectUUID());
outMsg.setAssetName1(building.getName());
outMsg.setUnknown54(1);
dispatch = Dispatch.borrow(player, outMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
break;
case CLIENT_REDEED_REQUEST:
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
processRedeedNPC(npc, building, origin);
return true;
//MB TODO HANDLE all profits.
case 7:
case 8:
case 9:
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
modifySellProfit(orderNPCMsg, origin);
dispatch = Dispatch.borrow(player, orderNPCMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
case 10:
case 11:
case 12:
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
modifyBuyProfit(orderNPCMsg, origin);
dispatch = Dispatch.borrow(player, orderNPCMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
}
// Validation check Owner or IC or friends
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
if (BuildingManager.playerCanManage(player, building) == false)
return true;
ManageNPCMsg manageNPCMsg = new ManageNPCMsg(npc);
Dispatch dispatch = Dispatch.borrow(player, manageNPCMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
} else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) {
mob = Mob.getFromCacheDBID(orderNPCMsg.getNpcUUID());
if (mob == null)
return true;
building = BuildingManager.getBuildingFromCache(orderNPCMsg.getBuildingUUID());
if (building == null)
return true;
if (!building.getHirelings().containsKey(mob))
return true;
if (player.getCharItemManager().getTradingWith() != null) {
ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings.");
return true;
}
player.lastBuildingAccessed = building.getObjectUUID();
switch (orderNPCMsg.getActionType()) {
case 2:
if (BuildingManager.playerCanManage(player, building) == false)
return true;
if (building.getHirelings().containsKey(mob) == false)
return true;
if (NPCManager.removeMobileFromBuilding(mob, building) == false) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
return true;
}
if (!building.getHirelings().containsKey(mob))
return;
ManageCityAssetsMsg manageCityAssetsMsg = new ManageCityAssetsMsg();
manageCityAssetsMsg.actionType = SVR_CLOSE_WINDOW;
manageCityAssetsMsg.setTargetType(building.getObjectType().ordinal());
manageCityAssetsMsg.setTargetID(building.getObjectUUID());
Dispatch dispatch = Dispatch.borrow(player, manageCityAssetsMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
break;
case 3:
if (!NPCManager.removeMobileFromBuilding(mob, building)) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
return;
}
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
building.getHirelings().remove(mob);
processUpgradeNPC(player, mob);
itemBase = ItemBase.getItemBase(contract.getContractID());
outMsg = new ManageCityAssetsMsg(player, building);
if (itemBase == null) {
Logger.error("Could not find Contract for npc: " + mob.getObjectUUID());
return;
}
// Action TYPE
outMsg.actionType = 3;
outMsg.setTargetType(building.getObjectType().ordinal());
outMsg.setTargetID(building.getObjectUUID());
outMsg.setTargetType3(building.getObjectType().ordinal());
outMsg.setTargetID3(building.getObjectUUID());
outMsg.setAssetName1(building.getName());
outMsg.setUnknown54(1);
boolean itemWorked = false;
dispatch = Dispatch.borrow(player, outMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
break;
case 6:
item = new Item(itemBase, player.getObjectUUID(), Enum.OwnerType.PlayerCharacter, (byte) ((byte) mob.getRank() - 1), (byte) ((byte) mob.getRank() - 1), (short) 1, (short) 1, true, false, Enum.ItemContainerType.INVENTORY, (byte) 0, new ArrayList<>(), "");
item.setNumOfItems(1);
item.containerType = Enum.ItemContainerType.INVENTORY;
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
itemWorked = true;
} catch (Exception e) {
Logger.error(e);
}
processRedeedNPC(mob, building, origin);
return true;
//MB TODO HANDLE all profits.
case 7:
case 8:
case 9:
break;
case 10:
case 11:
case 12:
break;
}
if (itemWorked) {
itemMan.addItemToInventory(item);
itemMan.updateInventory();
}
// Validation check Owner or IC
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
if (BuildingManager.playerCanManage(player, building) == false)
return true;
ManageCityAssetsMsg mca = new ManageCityAssetsMsg();
mca.actionType = NPC.SVR_CLOSE_WINDOW;
mca.setTargetType(building.getObjectType().ordinal());
mca.setTargetID(building.getObjectUUID());
origin.sendMsg(mca);
ManageNPCMsg manageNPCMsg = new ManageNPCMsg(mob);
Dispatch dispatch = Dispatch.borrow(player, manageNPCMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
}
return true;
}
private static void modifyBuyProfit(OrderNPCMsg msg, ClientConnection origin) {
@ -383,10 +207,10 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { @@ -383,10 +207,10 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
if (orderNpcMsg.getPatrolPoints() != null) {
if ( !AddPatrolPoints(building.getObjectUUID(), orderNpcMsg.getPatrolPoints())){
ErrorPopupMsg.sendErrorMsg(player, "Patrol Points must be placed on city zone.");
return;
}
if (!AddPatrolPoints(building.getObjectUUID(), orderNpcMsg.getPatrolPoints())) {
ErrorPopupMsg.sendErrorMsg(player, "Patrol Points must be placed on city zone.");
return;
}
for (AbstractCharacter guard : building.getHirelings().keySet()) {
if (guard.getObjectType() == GameObjectType.Mob)
@ -466,7 +290,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { @@ -466,7 +290,7 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
}
}
private synchronized void processRedeedNPC(AbstractCharacter abstractCharacter, Building building, ClientConnection origin) {
private static synchronized void processRedeedNPC(AbstractCharacter abstractCharacter, Building building, ClientConnection origin) {
// Member variable declaration
@ -479,11 +303,11 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { @@ -479,11 +303,11 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
if (cityBuilding == null)
return;
npc.processRedeedNPC(origin);
NPC.processRedeedNPC(npc, npc.building, origin);
break;
case Mob:
Mob mob = (Mob) abstractCharacter;
mob.processRedeedMob(origin);
processRedeedMob(mob, mob.building, origin);
break;
}
}
@ -494,36 +318,35 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { @@ -494,36 +318,35 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
if (building == null)
return false;
Zone zone = building.getParentZone();
if (zone == null)
return false;
return false;
if (zone.getPlayerCityUUID() == 0)
return false;
return false;
City city = building.getCity();
if (city == null)
return false;
return false;
//clear first.
for (Vector3fImmutable point : patrolPoints) {
if (city.isLocationOnCityZone(point) == false){
return false;
}
if (city.isLocationOnCityZone(point) == false) {
return false;
}
}
DbManager.BuildingQueries.CLEAR_PATROL(buildingID);
for (Vector3fImmutable point : patrolPoints) {
if (!DbManager.BuildingQueries.ADD_TO_PATROL(buildingID, point))
return false;
}
@ -573,4 +396,242 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler { @@ -573,4 +396,242 @@ public class OrderNPCMsgHandler extends AbstractClientMsgHandler {
return true;
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
// Member variable declarations
PlayerCharacter player;
NPC npc;
Mob mob;
Building building;
OrderNPCMsg orderNPCMsg;
ManageCityAssetsMsg outMsg;
// Member variable assignment
orderNPCMsg = (OrderNPCMsg) baseMsg;
if (origin.ordernpcspam > System.currentTimeMillis())
return true;
origin.ordernpcspam = System.currentTimeMillis() + 500;
player = SessionManager.getPlayerCharacter(origin);
if (player == null)
return true;
if (orderNPCMsg.getActionType() == 28) {
OrderNPCMsgHandler.handleCityCommand(orderNPCMsg, player);
return true;
}
if (orderNPCMsg.getObjectType() == GameObjectType.NPC.ordinal()) {
npc = NPC.getFromCache(orderNPCMsg.getNpcUUID());
if (npc == null)
return true;
building = BuildingManager.getBuildingFromCache(orderNPCMsg.getBuildingUUID());
if (building == null)
return true;
if (building.getHirelings().containsKey(npc) == false)
return true;
if (player.getCharItemManager().getTradingWith() != null) {
ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings.");
return true;
}
player.lastBuildingAccessed = building.getObjectUUID();
switch (orderNPCMsg.getActionType()) {
case 2:
player = SessionManager.getPlayerCharacter(origin);
if (ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building) == false)
return true;
if (building.getHirelings().containsKey(npc) == false)
return true;
if (npc.remove() == false) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
return true;
}
ManageCityAssetsMsg manageCityAssetsMsg = new ManageCityAssetsMsg();
manageCityAssetsMsg.actionType = SVR_CLOSE_WINDOW;
manageCityAssetsMsg.setTargetType(building.getObjectType().ordinal());
manageCityAssetsMsg.setTargetID(building.getObjectUUID());
Dispatch dispatch = Dispatch.borrow(player, manageCityAssetsMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
case CLIENT_UPGRADE_REQUEST:
if (BuildingManager.playerCanManage(player, building) == false)
return true;
processUpgradeNPC(player, npc);
outMsg = new ManageCityAssetsMsg(player, building);
// Action TYPE
outMsg.actionType = 3;
outMsg.setTargetType(building.getObjectType().ordinal());
outMsg.setTargetID(building.getObjectUUID());
outMsg.setTargetType3(building.getObjectType().ordinal());
outMsg.setTargetID3(building.getObjectUUID());
outMsg.setAssetName1(building.getName());
outMsg.setUnknown54(1);
dispatch = Dispatch.borrow(player, outMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
break;
case CLIENT_REDEED_REQUEST:
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
processRedeedNPC(npc, building, origin);
return true;
//MB TODO HANDLE all profits.
case 7:
case 8:
case 9:
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
modifySellProfit(orderNPCMsg, origin);
dispatch = Dispatch.borrow(player, orderNPCMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
case 10:
case 11:
case 12:
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
modifyBuyProfit(orderNPCMsg, origin);
dispatch = Dispatch.borrow(player, orderNPCMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
}
// Validation check Owner or IC or friends
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
if (BuildingManager.playerCanManage(player, building) == false)
return true;
ManageNPCMsg manageNPCMsg = new ManageNPCMsg(npc);
Dispatch dispatch = Dispatch.borrow(player, manageNPCMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
} else if (orderNPCMsg.getObjectType() == GameObjectType.Mob.ordinal()) {
mob = Mob.getFromCacheDBID(orderNPCMsg.getNpcUUID());
if (mob == null)
return true;
building = BuildingManager.getBuildingFromCache(orderNPCMsg.getBuildingUUID());
if (building == null)
return true;
if (!building.getHirelings().containsKey(mob))
return true;
if (player.getCharItemManager().getTradingWith() != null) {
ErrorPopupMsg.sendErrorMsg(player, "Cannot barter and trade with same timings.");
return true;
}
player.lastBuildingAccessed = building.getObjectUUID();
switch (orderNPCMsg.getActionType()) {
case 2:
if (BuildingManager.playerCanManage(player, building) == false)
return true;
if (building.getHirelings().containsKey(mob) == false)
return true;
if (NPCManager.removeMobileFromBuilding(mob, building) == false) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
return true;
}
ManageCityAssetsMsg manageCityAssetsMsg = new ManageCityAssetsMsg();
manageCityAssetsMsg.actionType = SVR_CLOSE_WINDOW;
manageCityAssetsMsg.setTargetType(building.getObjectType().ordinal());
manageCityAssetsMsg.setTargetID(building.getObjectUUID());
Dispatch dispatch = Dispatch.borrow(player, manageCityAssetsMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
break;
case 3:
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
processUpgradeNPC(player, mob);
outMsg = new ManageCityAssetsMsg(player, building);
// Action TYPE
outMsg.actionType = 3;
outMsg.setTargetType(building.getObjectType().ordinal());
outMsg.setTargetID(building.getObjectUUID());
outMsg.setTargetType3(building.getObjectType().ordinal());
outMsg.setTargetID3(building.getObjectUUID());
outMsg.setAssetName1(building.getName());
outMsg.setUnknown54(1);
dispatch = Dispatch.borrow(player, outMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
break;
case 6:
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
return true;
processRedeedNPC(mob, building, origin);
return true;
//MB TODO HANDLE all profits.
case 7:
case 8:
case 9:
break;
case 10:
case 11:
case 12:
break;
}
// Validation check Owner or IC
if (BuildingManager.PlayerCanControlNotOwner(building, player) == false)
if (BuildingManager.playerCanManage(player, building) == false)
return true;
ManageNPCMsg manageNPCMsg = new ManageNPCMsg(mob);
Dispatch dispatch = Dispatch.borrow(player, manageNPCMsg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
return true;
}
return true;
}
}

75
src/engine/objects/Mob.java

@ -24,9 +24,6 @@ import engine.math.Vector3fImmutable; @@ -24,9 +24,6 @@ import engine.math.Vector3fImmutable;
import engine.net.ByteBufferWriter;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.ManageCityAssetsMsg;
import engine.net.client.msg.PetMsg;
import engine.net.client.msg.PlaceAssetMsg;
import engine.powers.EffectsBase;
@ -53,7 +50,7 @@ public class Mob extends AbstractIntelligenceAgent { @@ -53,7 +50,7 @@ public class Mob extends AbstractIntelligenceAgent {
//mob specific
public final ConcurrentHashMap<Integer, Boolean> playerAgroMap = new ConcurrentHashMap<>();
public final ConcurrentHashMap<Mob, Integer> siegeMinionMap = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
public final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
public long nextCastTime = 0;
public long nextCallForHelp = 0;
public ReentrantReadWriteLock minionLock = new ReentrantReadWriteLock();
@ -2145,76 +2142,6 @@ public class Mob extends AbstractIntelligenceAgent { @@ -2145,76 +2142,6 @@ public class Mob extends AbstractIntelligenceAgent {
}
}
public void processRedeedMob(ClientConnection origin) {
PlayerCharacter player;
Contract contract;
CharacterItemManager itemMan;
ItemBase itemBase;
Item item;
this.lock.writeLock().lock();
try {
player = SessionManager.getPlayerCharacter(origin);
itemMan = player.getCharItemManager();
contract = this.getContract();
if (!player.getCharItemManager().hasRoomInventory((short) 1)) {
ErrorPopupMsg.sendErrorPopup(player, 21);
return;
}
if (!building.getHirelings().containsKey(this))
return;
if (!NPCManager.removeMobileFromBuilding(this, building)) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
return;
}
building.getHirelings().remove(this);
itemBase = ItemBase.getItemBase(contract.getContractID());
if (itemBase == null) {
Logger.error("Could not find Contract for npc: " + this.getObjectUUID());
return;
}
boolean itemWorked = false;
item = new Item(itemBase, player.getObjectUUID(), OwnerType.PlayerCharacter, (byte) ((byte) this.getRank() - 1), (byte) ((byte) this.getRank() - 1), (short) 1, (short) 1, true, false, Enum.ItemContainerType.INVENTORY, (byte) 0, new ArrayList<>(), "");
item.setNumOfItems(1);
item.containerType = Enum.ItemContainerType.INVENTORY;
try {
item = DbManager.ItemQueries.ADD_ITEM(item);
itemWorked = true;
} catch (Exception e) {
Logger.error(e);
}
if (itemWorked) {
itemMan.addItemToInventory(item);
itemMan.updateInventory();
}
ManageCityAssetsMsg mca = new ManageCityAssetsMsg();
mca.actionType = NPC.SVR_CLOSE_WINDOW;
mca.setTargetType(building.getObjectType().ordinal());
mca.setTargetID(building.getObjectUUID());
origin.sendMsg(mca);
} catch (Exception e) {
Logger.error(e);
} finally {
this.lock.writeLock().unlock();
}
}
public void dismiss() {
if (this.isPet()) {

24
src/engine/objects/NPC.java

@ -53,7 +53,7 @@ public class NPC extends AbstractCharacter { @@ -53,7 +53,7 @@ public class NPC extends AbstractCharacter {
protected boolean isMob;
protected MobBase mobBase;
protected String name;
protected Building building;
public Building building;
protected Contract contract;
protected int dbID;
protected int currentID;
@ -99,10 +99,6 @@ public class NPC extends AbstractCharacter { @@ -99,10 +99,6 @@ public class NPC extends AbstractCharacter {
public Vector3fImmutable inBuildingLoc = Vector3fImmutable.ZERO;
private int repairCost = 5;
public int classID = 0;
public int professionID = 0;
public int extraRune = 0;
public int extraRune2 = 0;
@ -1716,7 +1712,7 @@ public class NPC extends AbstractCharacter { @@ -1716,7 +1712,7 @@ public class NPC extends AbstractCharacter {
}
}
public void processRedeedNPC( ClientConnection origin) {
public static void processRedeedNPC(NPC npc, Building building, ClientConnection origin) {
// Member variable declaration
PlayerCharacter player;
@ -1725,7 +1721,7 @@ public class NPC extends AbstractCharacter { @@ -1725,7 +1721,7 @@ public class NPC extends AbstractCharacter {
ItemBase itemBase;
Item item;
this.lock.writeLock().lock();
npc.lock.writeLock().lock();
try{
@ -1735,7 +1731,7 @@ public class NPC extends AbstractCharacter { @@ -1735,7 +1731,7 @@ public class NPC extends AbstractCharacter {
player = SessionManager.getPlayerCharacter(origin);
itemMan = player.getCharItemManager();
contract = this.getContract();
contract = npc.getContract();
if (!player.getCharItemManager().hasRoomInventory((short)1)){
ErrorPopupMsg.sendErrorPopup(player, 21);
@ -1743,26 +1739,26 @@ public class NPC extends AbstractCharacter { @@ -1743,26 +1739,26 @@ public class NPC extends AbstractCharacter {
}
if (!building.getHirelings().containsKey(this))
if (!building.getHirelings().containsKey(npc))
return;
if (!this.remove()) {
if (!npc.remove()) {
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
return;
}
building.getHirelings().remove(this);
building.getHirelings().remove(npc);
itemBase = ItemBase.getItemBase(contract.getContractID());
if (itemBase == null) {
Logger.error("Could not find Contract for npc: " + this.getObjectUUID());
Logger.error("Could not find Contract for npc: " + npc.getObjectUUID());
return;
}
boolean itemWorked = false;
item = new Item( itemBase, player.getObjectUUID(), OwnerType.PlayerCharacter, (byte) ((byte) this.getRank() - 1), (byte) ((byte) this.getRank() - 1),
item = new Item( itemBase, player.getObjectUUID(), OwnerType.PlayerCharacter, (byte) ((byte) npc.getRank() - 1), (byte) ((byte) npc.getRank() - 1),
(short) 1, (short) 1, true, false, Enum.ItemContainerType.INVENTORY, (byte) 0,
new ArrayList<>(),"");
item.setNumOfItems(1);
@ -1788,7 +1784,7 @@ public class NPC extends AbstractCharacter { @@ -1788,7 +1784,7 @@ public class NPC extends AbstractCharacter {
}catch(Exception e){
Logger.error(e);
}finally{
this.lock.writeLock().unlock();
npc.lock.writeLock().unlock();
}
}

Loading…
Cancel
Save