Merge remote-tracking branch 'origin/feature-json7.4' into feature-json7.4
This commit is contained in:
@@ -92,7 +92,10 @@ public class dbItemHandler extends dbHandlerBase {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
preparedStatement.setByte(7, (byte) toAdd.equipSlot.ordinal());
|
if (toAdd.equipSlot.equals(Enum.EquipSlotType.NONE))
|
||||||
|
preparedStatement.setString(7, "");
|
||||||
|
else
|
||||||
|
preparedStatement.setString(7, toAdd.equipSlot.name());
|
||||||
|
|
||||||
String flagString = "";
|
String flagString = "";
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import engine.devcmd.AbstractDevCmd;
|
|||||||
import engine.gameManager.SessionManager;
|
import engine.gameManager.SessionManager;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.client.msg.RecvSummonsRequestMsg;
|
import engine.net.client.msg.RecvSummonsMsg;
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
import engine.objects.Zone;
|
import engine.objects.Zone;
|
||||||
@@ -41,7 +41,7 @@ public class SummonCmd extends AbstractDevCmd {
|
|||||||
String location = "Somewhere";
|
String location = "Somewhere";
|
||||||
if (zone != null)
|
if (zone != null)
|
||||||
location = zone.zoneName;
|
location = zone.zoneName;
|
||||||
RecvSummonsRequestMsg rsrm = new RecvSummonsRequestMsg(pc.getObjectType().ordinal(), pc.getObjectUUID(), pc.getFirstName(),
|
RecvSummonsMsg rsrm = new RecvSummonsMsg(pc.getObjectType().ordinal(), pc.getObjectUUID(), pc.getFirstName(),
|
||||||
location, false);
|
location, false);
|
||||||
toSummon.getClientConnection().sendMsg(rsrm);
|
toSummon.getClientConnection().sendMsg(rsrm);
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,11 @@ import engine.net.Dispatch;
|
|||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.MessageDispatcher;
|
import engine.net.MessageDispatcher;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.Protocol;
|
import engine.net.client.handlers.ClientAdminCommandMsgHandler;
|
||||||
import engine.net.client.msg.chat.*;
|
import engine.net.client.msg.chat.*;
|
||||||
import engine.net.client.msg.commands.ClientAdminCommandMsg;
|
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import engine.server.world.WorldServer;
|
import engine.server.world.WorldServer;
|
||||||
import engine.session.Session;
|
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -42,8 +40,8 @@ public enum ChatManager {
|
|||||||
// (FLOOD_TIME_THRESHOLD) ms will flag as a flood message
|
// (FLOOD_TIME_THRESHOLD) ms will flag as a flood message
|
||||||
// Example, set to 3 & 2000 to flag the 3rd message within 2000 ms.
|
// Example, set to 3 & 2000 to flag the 3rd message within 2000 ms.
|
||||||
|
|
||||||
private static final int FLOOD_QTY_THRESHOLD = 3;
|
public static final int FLOOD_QTY_THRESHOLD = 3;
|
||||||
private static final int FLOOD_TIME_THRESHOLD = 2000;
|
public static final int FLOOD_TIME_THRESHOLD = 2000;
|
||||||
private static final String FLOOD_USER_ERROR = "You talk too much!";
|
private static final String FLOOD_USER_ERROR = "You talk too much!";
|
||||||
private static final String SILENCED = "You find yourself mute!";
|
private static final String SILENCED = "You find yourself mute!";
|
||||||
private static final String UNKNOWN_COMMAND = "No such command.";
|
private static final String UNKNOWN_COMMAND = "No such command.";
|
||||||
@@ -51,74 +49,6 @@ public enum ChatManager {
|
|||||||
/**
|
/**
|
||||||
* This method used when handling a ChatMsg received from the network.
|
* This method used when handling a ChatMsg received from the network.
|
||||||
*/
|
*/
|
||||||
public static void handleChatMsg(Session sender, AbstractChatMsg msg) {
|
|
||||||
|
|
||||||
if (msg == null) {
|
|
||||||
Logger.warn(
|
|
||||||
"null message: ");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sender == null) {
|
|
||||||
Logger.warn(
|
|
||||||
"null sender: ");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerCharacter pc = sender.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (pc == null) {
|
|
||||||
Logger.warn(
|
|
||||||
"invalid sender: ");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Protocol protocolMsg = msg.getProtocolMsg();
|
|
||||||
|
|
||||||
// Flood control, implemented per channel
|
|
||||||
|
|
||||||
boolean isFlood = false;
|
|
||||||
long curMsgTime = System.currentTimeMillis();
|
|
||||||
long checkTime = pc.chatFloodTime(protocolMsg.opcode, curMsgTime, FLOOD_QTY_THRESHOLD - 1);
|
|
||||||
|
|
||||||
if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD))
|
|
||||||
isFlood = true;
|
|
||||||
|
|
||||||
switch (protocolMsg) {
|
|
||||||
case CHATSAY:
|
|
||||||
ChatManager.chatSay(pc, msg.getMessage(), isFlood);
|
|
||||||
return;
|
|
||||||
case CHATCSR:
|
|
||||||
ChatManager.chatCSR(msg);
|
|
||||||
return;
|
|
||||||
case CHATTELL:
|
|
||||||
ChatTellMsg ctm = (ChatTellMsg) msg;
|
|
||||||
ChatManager.chatTell(pc, ctm.getTargetName(), ctm.getMessage(), isFlood);
|
|
||||||
return;
|
|
||||||
case CHATSHOUT:
|
|
||||||
ChatManager.chatShout(pc, msg.getMessage(), isFlood);
|
|
||||||
return;
|
|
||||||
case CHATGUILD:
|
|
||||||
ChatManager.chatGuild(pc, (ChatGuildMsg) msg);
|
|
||||||
return;
|
|
||||||
case CHATGROUP:
|
|
||||||
ChatManager.chatGroup(pc, (ChatGroupMsg) msg);
|
|
||||||
return;
|
|
||||||
case CHATIC:
|
|
||||||
ChatManager.chatIC(pc, (ChatICMsg) msg);
|
|
||||||
return;
|
|
||||||
case LEADERCHANNELMESSAGE:
|
|
||||||
ChatManager.chatGlobal(pc, msg.getMessage(), isFlood);
|
|
||||||
return;
|
|
||||||
case GLOBALCHANNELMESSAGE:
|
|
||||||
case CHATPVP:
|
|
||||||
case CHATCITY:
|
|
||||||
case CHATINFO:
|
|
||||||
case SYSTEMBROADCASTCHANNEL:
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Channels
|
* Channels
|
||||||
@@ -190,7 +120,7 @@ public enum ChatManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ChatManager.isDevCommand(text) == true) {
|
if (ChatManager.isDevCommand(text) == true) {
|
||||||
ChatManager.processDevCommand(player, text);
|
ClientAdminCommandMsgHandler.processDevCommand(player, text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1083,94 +1013,4 @@ public enum ChatManager {
|
|||||||
return text.equalsIgnoreCase("lua_population()");
|
return text.equalsIgnoreCase("lua_population()");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean processDevCommand(AbstractWorldObject sender, String text) {
|
|
||||||
|
|
||||||
if (sender.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
|
||||||
|
|
||||||
PlayerCharacter pcSender = (PlayerCharacter) sender;
|
|
||||||
|
|
||||||
// first remove the DEV_CMD_PREFIX
|
|
||||||
String[] words = text.split(MBServerStatics.DEV_CMD_PREFIX, 2);
|
|
||||||
|
|
||||||
if (words[1].length() == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// next get the command
|
|
||||||
String[] commands = words[1].split(" ", 2);
|
|
||||||
String cmd = commands[0].toLowerCase();
|
|
||||||
String cmdArgument = "";
|
|
||||||
|
|
||||||
if (commands.length > 1)
|
|
||||||
cmdArgument = commands[1].trim();
|
|
||||||
|
|
||||||
AbstractGameObject target = pcSender.getLastTarget();
|
|
||||||
// return DevCmd.processDevCommand(pcSender, cmd, cmdArgument,
|
|
||||||
// target);
|
|
||||||
return DevCmdManager.handleDevCmd(pcSender, cmd,
|
|
||||||
cmdArgument, target);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Process an Admin Command, which is a preset command sent from the client
|
|
||||||
*/
|
|
||||||
public static void HandleClientAdminCmd(ClientAdminCommandMsg data,
|
|
||||||
ClientConnection cc) {
|
|
||||||
|
|
||||||
PlayerCharacter pcSender = SessionManager.getPlayerCharacter(cc);
|
|
||||||
|
|
||||||
if (pcSender == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Account acct = SessionManager.getAccount(pcSender);
|
|
||||||
|
|
||||||
if (acct == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// require minimal access to continue
|
|
||||||
// specific accessLevel checks performed by the DevCmdManager
|
|
||||||
if (acct.status.equals(Enum.AccountStatus.ADMIN) == false) {
|
|
||||||
Logger.warn(pcSender.getFirstName() + " Attempted to use a client admin command");
|
|
||||||
//wtf? ChatManager.chatSystemInfo(pcSender, "CHEATER!!!!!!!!!!!!!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// First remove the initial slash
|
|
||||||
String d = data.getMsgCommand();
|
|
||||||
String[] words = d.split("/", 2);
|
|
||||||
|
|
||||||
if (words[1].length() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Next get the command
|
|
||||||
String[] commands = words[1].split(" ", 2);
|
|
||||||
String cmd = commands[0].toLowerCase();
|
|
||||||
String cmdArgument = "";
|
|
||||||
|
|
||||||
if (commands.length > 1)
|
|
||||||
cmdArgument = commands[1].trim();
|
|
||||||
|
|
||||||
AbstractGameObject target = data.getTarget();
|
|
||||||
|
|
||||||
// Map to a DevCmd
|
|
||||||
String devCmd = "";
|
|
||||||
|
|
||||||
if (cmd.compareTo("goto") == 0)
|
|
||||||
devCmd = "goto";
|
|
||||||
else if (cmd.compareTo("suspend") == 0)
|
|
||||||
devCmd = "suspend";
|
|
||||||
else if (cmd.compareTo("getinfo") == 0)
|
|
||||||
devCmd = "info";
|
|
||||||
else if (devCmd.isEmpty()) {
|
|
||||||
Logger.info("Unhandled admin command was used: /"
|
|
||||||
+ cmd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DevCmdManager.handleDevCmd(pcSender, devCmd, cmdArgument,
|
|
||||||
target);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ import engine.Enum.ModType;
|
|||||||
import engine.Enum.SourceType;
|
import engine.Enum.SourceType;
|
||||||
import engine.InterestManagement.InterestManager;
|
import engine.InterestManagement.InterestManager;
|
||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.job.JobContainer;
|
|
||||||
import engine.job.JobScheduler;
|
|
||||||
import engine.jobs.StuckJob;
|
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
@@ -30,7 +27,6 @@ import engine.server.MBServerStatics;
|
|||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import static engine.math.FastMath.sqr;
|
import static engine.math.FastMath.sqr;
|
||||||
|
|
||||||
@@ -474,26 +470,4 @@ public enum MovementManager {
|
|||||||
ac.teleport(ac.getLoc());
|
ac.teleport(ac.getLoc());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stuck(ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter sourcePlayer = origin.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (sourcePlayer == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (sourcePlayer.getTimers().containsKey("Stuck"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
StuckJob sj = new StuckJob(sourcePlayer);
|
|
||||||
JobContainer jc = JobScheduler.getInstance().scheduleJob(sj, 10000); // Convert
|
|
||||||
ConcurrentHashMap<String, JobContainer> timers = sourcePlayer.getTimers();
|
|
||||||
|
|
||||||
if (timers != null) {
|
|
||||||
if (timers.containsKey("Stuck")) {
|
|
||||||
timers.get("Stuck").cancelJob();
|
|
||||||
timers.remove("Stuck");
|
|
||||||
}
|
|
||||||
timers.put("Stuck", jc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ import engine.job.AbstractJob;
|
|||||||
import engine.job.AbstractScheduleJob;
|
import engine.job.AbstractScheduleJob;
|
||||||
import engine.job.JobContainer;
|
import engine.job.JobContainer;
|
||||||
import engine.job.JobScheduler;
|
import engine.job.JobScheduler;
|
||||||
import engine.jobs.*;
|
import engine.jobs.AbstractEffectJob;
|
||||||
|
import engine.jobs.FinishRecycleTimeJob;
|
||||||
|
import engine.jobs.UseItemJob;
|
||||||
|
import engine.jobs.UsePowerJob;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
@@ -28,7 +31,6 @@ import engine.net.client.msg.*;
|
|||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
import engine.powers.*;
|
import engine.powers.*;
|
||||||
import engine.powers.poweractions.AbstractPowerAction;
|
import engine.powers.poweractions.AbstractPowerAction;
|
||||||
import engine.powers.poweractions.TrackPowerAction;
|
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
@@ -1241,264 +1243,7 @@ public enum PowersManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void summon(SendSummonsRequestMsg msg, ClientConnection origin) {
|
public static void sendRecyclePower(int token, ClientConnection origin) {
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(
|
|
||||||
origin);
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
PlayerCharacter target = SessionManager
|
|
||||||
.getPlayerCharacterByLowerCaseName(msg.getTargetName());
|
|
||||||
if (target == null || target.equals(pc) || target.isCombat()) {
|
|
||||||
|
|
||||||
if (target == null) // Player not found. Send not found message
|
|
||||||
ChatManager.chatInfoError(pc,
|
|
||||||
"Cannot find that player to summon.");
|
|
||||||
else if (target.isCombat())
|
|
||||||
ChatManager.chatInfoError(pc,
|
|
||||||
"Cannot summon player in combat.");
|
|
||||||
// else trying to summon self, just fail
|
|
||||||
|
|
||||||
// recycle summon
|
|
||||||
sendRecyclePower(msg.getPowerToken(), origin);
|
|
||||||
|
|
||||||
// TODO: client already subtracted 200 mana.. need to correct it
|
|
||||||
// end cast
|
|
||||||
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(),
|
|
||||||
msg.getTrains(), msg.getSourceType(), msg.getSourceID(), 0,
|
|
||||||
0, 0f, 0f, 0f, 1, 0);
|
|
||||||
sendPowerMsg(pc, 2, pam);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ConfigManager.MB_RULESET.getValue() == "LORE") {
|
|
||||||
if (pc.guild.getGuildType().equals(target.guild.getGuildType()) == false) {
|
|
||||||
ChatManager.chatInfoError(pc,
|
|
||||||
"Cannot summon player outside your charter.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(), msg
|
|
||||||
.getTrains(), msg.getSourceType(), msg.getSourceID(), target
|
|
||||||
.getObjectType().ordinal(), target.getObjectUUID(), 0f, 0f, 0f, 1, 0);
|
|
||||||
|
|
||||||
// Client removes 200 mana on summon use.. so don't send message to self
|
|
||||||
target.addSummoner(pc.getObjectUUID(), System.currentTimeMillis() + MBServerStatics.FOURTYFIVE_SECONDS);
|
|
||||||
usePower(pam, origin, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void recvSummon(RecvSummonsRequestMsg msg, ClientConnection origin) {
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
PlayerCharacter source = PlayerCharacter.getFromCache(msg.getSourceID());
|
|
||||||
if (source == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
long tooLate = pc.getSummoner(source.getObjectUUID());
|
|
||||||
if (tooLate < System.currentTimeMillis()) {
|
|
||||||
ChatManager.chatInfoError(pc, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons.");
|
|
||||||
pc.removeSummoner(source.getObjectUUID());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pc.getBonuses() != null && pc.getBonuses().getBool(ModType.BlockedPowerType, SourceType.SUMMON)) {
|
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "You have been blocked from receiving summons!");
|
|
||||||
ErrorPopupMsg.sendErrorMsg(source, "Target is blocked from receiving summons!");
|
|
||||||
pc.removeSummoner(source.getObjectUUID());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pc.removeSummoner(source.getObjectUUID());
|
|
||||||
|
|
||||||
// Handle Accepting or Denying a summons.
|
|
||||||
// set timer based on summon type.
|
|
||||||
boolean wentThrough = false;
|
|
||||||
if (msg.accepted())
|
|
||||||
// summons accepted, let's move the player if within time
|
|
||||||
if (source.isAlive()) {
|
|
||||||
|
|
||||||
// //make sure summons handled in time
|
|
||||||
ConcurrentHashMap<String, JobContainer> timers = source.getTimers();
|
|
||||||
// if (timers == null || !timers.containsKey("SummonSend")) {
|
|
||||||
// ChatManager.chatInfoError(pc, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons.");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // clear last summons accept timer
|
|
||||||
// timers.get("SummonSend").cancelJob();
|
|
||||||
//timers.remove("SummonSend");
|
|
||||||
// cancel any other summons waiting
|
|
||||||
timers = pc.getTimers();
|
|
||||||
if (timers != null && timers.containsKey("Summon"))
|
|
||||||
timers.get("Summon").cancelJob();
|
|
||||||
|
|
||||||
// get time to wait before summons goes through
|
|
||||||
BaseClass base = source.baseClass;
|
|
||||||
PromotionClass promo = source.getPromotionClass();
|
|
||||||
int duration;
|
|
||||||
|
|
||||||
|
|
||||||
//determine if in combat with another player
|
|
||||||
|
|
||||||
|
|
||||||
//comment out this block to disable combat timer
|
|
||||||
// if (lastAttacked < 60000) {
|
|
||||||
// if (pc.inSafeZone()) //player in safe zone, no need for combat timer
|
|
||||||
// combat = false;
|
|
||||||
// else if (source.inSafeZone()) //summoner in safe zone, apply combat timer
|
|
||||||
// combat = true;
|
|
||||||
// else if ((source.getLoc().distance2D(pc.getLoc())) > 6144f)
|
|
||||||
// combat = true; //more than 1.5x width of zone, not tactical summons
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (promo != null && promo.getObjectUUID() == 2519)
|
|
||||||
duration = 10000; // Priest summons, 10 seconds
|
|
||||||
else if (base != null && base.getObjectUUID() == 2501)
|
|
||||||
duration = 15000; // Healer Summons, 15 seconds
|
|
||||||
else
|
|
||||||
duration = 45000; // Belgosh Summons, 45 seconds
|
|
||||||
|
|
||||||
|
|
||||||
// Teleport to summoners location
|
|
||||||
FinishSummonsJob fsj = new FinishSummonsJob(source, pc);
|
|
||||||
JobContainer jc = JobScheduler.getInstance().scheduleJob(fsj,
|
|
||||||
duration);
|
|
||||||
if (timers != null)
|
|
||||||
timers.put("Summon", jc);
|
|
||||||
wentThrough = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Summons failed
|
|
||||||
if (!wentThrough)
|
|
||||||
// summons refused. Let's be nice and reset recycle timer
|
|
||||||
if (source != null) {
|
|
||||||
|
|
||||||
// Send summons refused Message
|
|
||||||
ErrorPopupMsg.sendErrorPopup(source, 29);
|
|
||||||
|
|
||||||
// recycle summons power
|
|
||||||
//finishRecycleTime(428523680, source, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void trackWindow(TrackWindowMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(
|
|
||||||
origin);
|
|
||||||
|
|
||||||
if (playerCharacter == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (MBServerStatics.POWERS_DEBUG) {
|
|
||||||
ChatManager.chatSayInfo(
|
|
||||||
playerCharacter,
|
|
||||||
"Using Power: " + Integer.toHexString(msg.getPowerToken())
|
|
||||||
+ " (" + msg.getPowerToken() + ')');
|
|
||||||
Logger.info("Using Power: "
|
|
||||||
+ Integer.toHexString(msg.getPowerToken()) + " ("
|
|
||||||
+ msg.getPowerToken() + ')');
|
|
||||||
}
|
|
||||||
|
|
||||||
// get track power used
|
|
||||||
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerToken());
|
|
||||||
|
|
||||||
if (pb == null || !pb.isTrack())
|
|
||||||
return;
|
|
||||||
|
|
||||||
//check track threshold timer to prevent spam
|
|
||||||
long currentTime = System.currentTimeMillis();
|
|
||||||
long timestamp = playerCharacter.getTimeStamp("trackWindow");
|
|
||||||
long dif = currentTime - timestamp;
|
|
||||||
if (dif < MBServerStatics.TRACK_WINDOW_THRESHOLD)
|
|
||||||
return;
|
|
||||||
playerCharacter.setTimeStamp("trackWindow", currentTime);
|
|
||||||
|
|
||||||
ArrayList<ActionsBase> ablist = pb.getActions();
|
|
||||||
if (ablist == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
TrackPowerAction tpa = null;
|
|
||||||
for (ActionsBase ab : ablist) {
|
|
||||||
AbstractPowerAction apa = ab.getPowerAction();
|
|
||||||
if (apa != null && apa instanceof TrackPowerAction)
|
|
||||||
tpa = (TrackPowerAction) apa;
|
|
||||||
}
|
|
||||||
if (tpa == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Check powers for normal users
|
|
||||||
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerToken()))
|
|
||||||
if (!playerCharacter.isCSR())
|
|
||||||
if (!MBServerStatics.POWERS_DEBUG) {
|
|
||||||
// ChatManager.chatSayInfo(pc, "You may not cast that spell!");
|
|
||||||
// this.logEXPLOIT("usePowerA(): Cheat attempted? '" + msg.getPowerToken() + "' was not associated with " + pc.getName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get search mask for track
|
|
||||||
int mask = 0;
|
|
||||||
if (pb.targetPlayer())
|
|
||||||
if (tpa.trackVampire()) // track vampires
|
|
||||||
mask = MBServerStatics.MASK_PLAYER | MBServerStatics.MASK_UNDEAD;
|
|
||||||
else
|
|
||||||
// track all players
|
|
||||||
mask = MBServerStatics.MASK_PLAYER;
|
|
||||||
else if (pb.targetCorpse()) // track corpses
|
|
||||||
mask = MBServerStatics.MASK_CORPSE;
|
|
||||||
else if (tpa.trackNPC()) // Track NPCs
|
|
||||||
mask = MBServerStatics.MASK_NPC;
|
|
||||||
else if (tpa.trackUndead()) // Track Undead
|
|
||||||
mask = MBServerStatics.MASK_MOB | MBServerStatics.MASK_UNDEAD;
|
|
||||||
else
|
|
||||||
// Track All
|
|
||||||
mask = MBServerStatics.MASK_MOB | MBServerStatics.MASK_NPC;
|
|
||||||
|
|
||||||
// Find characters in range
|
|
||||||
HashSet<AbstractWorldObject> allTargets;
|
|
||||||
allTargets = WorldGrid.getObjectsInRangeContains(playerCharacter.getLoc(),
|
|
||||||
pb.getRange(), mask);
|
|
||||||
|
|
||||||
//remove anyone who can't be tracked
|
|
||||||
Iterator<AbstractWorldObject> it = allTargets.iterator();
|
|
||||||
while (it.hasNext()) {
|
|
||||||
AbstractWorldObject awo = it.next();
|
|
||||||
if (awo == null)
|
|
||||||
continue;
|
|
||||||
else if (!awo.isAlive())
|
|
||||||
it.remove();
|
|
||||||
else if (awo.getObjectType().equals(GameObjectType.PlayerCharacter)) {
|
|
||||||
PlayerBonuses bonus = ((PlayerCharacter) awo).getBonuses();
|
|
||||||
if (bonus != null && bonus.getBool(ModType.CannotTrack, SourceType.NONE))
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get max charcters for window
|
|
||||||
int maxTargets = 20;
|
|
||||||
PromotionClass promo = playerCharacter.getPromotionClass();
|
|
||||||
if (promo != null) {
|
|
||||||
int tableID = promo.getObjectUUID();
|
|
||||||
if (tableID == 2512 || tableID == 2514 || tableID == 2515)
|
|
||||||
maxTargets = 40;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create list of characters
|
|
||||||
HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList(
|
|
||||||
allTargets, playerCharacter, maxTargets);
|
|
||||||
|
|
||||||
TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg);
|
|
||||||
|
|
||||||
// send track window
|
|
||||||
trackWindowMsg.setSource(playerCharacter);
|
|
||||||
trackWindowMsg.setCharacters(trackChars);
|
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, trackWindowMsg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void sendRecyclePower(int token, ClientConnection origin) {
|
|
||||||
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token);
|
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token);
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), recyclePowerMsg);
|
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), recyclePowerMsg);
|
||||||
|
|||||||
@@ -1,161 +0,0 @@
|
|||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
||||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
||||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
||||||
// Magicbane Emulator Project © 2013 - 2022
|
|
||||||
// www.magicbane.com
|
|
||||||
|
|
||||||
package engine.gameManager;
|
|
||||||
|
|
||||||
import engine.Enum;
|
|
||||||
import engine.net.Dispatch;
|
|
||||||
import engine.net.DispatchMessage;
|
|
||||||
import engine.net.client.ClientConnection;
|
|
||||||
import engine.net.client.msg.*;
|
|
||||||
import engine.objects.CharacterItemManager;
|
|
||||||
import engine.objects.PlayerCharacter;
|
|
||||||
import org.pmw.tinylog.Logger;
|
|
||||||
|
|
||||||
public enum TradeManager {
|
|
||||||
|
|
||||||
TRADEMANAGER;
|
|
||||||
|
|
||||||
public static void tradeRequest(TradeRequestMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter source = origin.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (source == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
source.charItemManager.tradeRequest(msg);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void acceptTradeRequest(AcceptTradeRequestMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter source = origin.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (source == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
source.charItemManager.acceptTradeRequest(msg);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void rejectTradeRequest(RejectTradeRequestMsg msg, ClientConnection origin) {
|
|
||||||
// TODO Do nothing? If so, delete this method & case above
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addItemToTradeWindow(AddItemToTradeWindowMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
|
|
||||||
PlayerCharacter source = origin.getPlayerCharacter();
|
|
||||||
if (source == null || !source.isAlive())
|
|
||||||
return;
|
|
||||||
try {
|
|
||||||
source.charItemManager.addItemToTradeWindow(msg);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addGoldToTradeWindow(AddGoldToTradeWindowMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter source = origin.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (source == null || !source.isAlive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
CharacterItemManager sourceItemMan = source.charItemManager;
|
|
||||||
|
|
||||||
if (sourceItemMan == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
sourceItemMan.addGoldToTradeWindow(msg);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void commitToTrade(CommitToTradeMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter source = origin.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (source == null || !source.isAlive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
CharacterItemManager sourceItemMan = source.charItemManager;
|
|
||||||
|
|
||||||
if (sourceItemMan == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
sourceItemMan.commitToTrade(msg);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void uncommitToTrade(UncommitToTradeMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter source = origin.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (source == null || !source.isAlive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
CharacterItemManager sourceItemMan = source.charItemManager;
|
|
||||||
|
|
||||||
if (sourceItemMan == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
sourceItemMan.uncommitToTrade(msg);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void closeTradeWindow(CloseTradeWindowMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter source = origin.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (source == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CharacterItemManager sourceItemMan = source.charItemManager;
|
|
||||||
|
|
||||||
if (sourceItemMan == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
sourceItemMan.closeTradeWindow(msg, true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
Logger.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void invalidTradeRequest(InvalidTradeRequestMsg msg) {
|
|
||||||
PlayerCharacter requester = PlayerCharacter.getFromCache(msg.getRequesterID());
|
|
||||||
Dispatch dispatch;
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(requester, msg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,31 +9,15 @@
|
|||||||
|
|
||||||
package engine.net.client;
|
package engine.net.client;
|
||||||
|
|
||||||
import engine.Enum.DispatchChannel;
|
import engine.gameManager.SessionManager;
|
||||||
import engine.Enum.GameObjectType;
|
|
||||||
import engine.InterestManagement.WorldGrid;
|
|
||||||
import engine.exception.MsgSendException;
|
|
||||||
import engine.gameManager.*;
|
|
||||||
import engine.job.JobScheduler;
|
|
||||||
import engine.jobs.RefreshGroupJob;
|
|
||||||
import engine.net.Dispatch;
|
|
||||||
import engine.net.DispatchMessage;
|
|
||||||
import engine.net.NetMsgHandler;
|
import engine.net.NetMsgHandler;
|
||||||
import engine.net.client.handlers.AbstractClientMsgHandler;
|
import engine.net.client.handlers.AbstractClientMsgHandler;
|
||||||
import engine.net.client.msg.*;
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
import engine.net.client.msg.chat.AbstractChatMsg;
|
|
||||||
import engine.net.client.msg.commands.ClientAdminCommandMsg;
|
|
||||||
import engine.objects.*;
|
|
||||||
import engine.server.MBServerStatics;
|
|
||||||
import engine.server.world.WorldServer;
|
import engine.server.world.WorldServer;
|
||||||
import engine.session.Session;
|
import engine.session.Session;
|
||||||
import engine.util.StringUtils;
|
import engine.util.StringUtils;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import static engine.math.FastMath.sqr;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author:
|
* @author:
|
||||||
* @summary: This class is the mainline router for application protocol
|
* @summary: This class is the mainline router for application protocol
|
||||||
@@ -51,639 +35,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void toggleLfgRecruiting(ToggleLfgRecruitingMsg msg, ClientConnection origin) throws MsgSendException {
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
int num = msg.toggleLfgRecruiting();
|
|
||||||
if (num == 1)
|
|
||||||
pc.toggleLFGroup();
|
|
||||||
else if (num == 2)
|
|
||||||
pc.toggleLFGuild();
|
|
||||||
else if (num == 3)
|
|
||||||
pc.toggleRecruiting();
|
|
||||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
|
||||||
rwss.setPlayer(pc);
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void toggleSitStand(ToggleSitStandMsg msg, ClientConnection origin) throws MsgSendException {
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pc.update();
|
|
||||||
|
|
||||||
pc.setSit(msg.toggleSitStand());
|
|
||||||
|
|
||||||
// cancel effects that break on sit
|
|
||||||
if (pc.isSit()) {
|
|
||||||
pc.setCombat(false);
|
|
||||||
pc.cancelOnSit();
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
|
||||||
if (pc.isSit()) {
|
|
||||||
pc.setCombat(false);
|
|
||||||
rwss.setAware(1);
|
|
||||||
}
|
|
||||||
rwss.setPlayer(pc);
|
|
||||||
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void DeleteItem(DeleteItemMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
CharacterItemManager itemManager = origin.getPlayerCharacter().charItemManager;
|
|
||||||
int uuid = msg.getUUID();
|
|
||||||
|
|
||||||
|
|
||||||
PlayerCharacter sourcePlayer = origin.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (sourcePlayer == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!sourcePlayer.isAlive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Item i = Item.getFromCache(msg.getUUID());
|
|
||||||
|
|
||||||
if (i == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!itemManager.doesCharOwnThisItem(i.getObjectUUID()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!itemManager.inventoryContains(i))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (i.isCanDestroy())
|
|
||||||
if (itemManager.delete(i) == true) {
|
|
||||||
Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) {
|
|
||||||
// According to the Wiki, the client should not send this message.
|
|
||||||
// Log the instance to investigate, and modify Wiki accordingly.
|
|
||||||
Logger.error(msg.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void modifyStat(ModifyStatMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
|
||||||
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int type = msg.getType();
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case MBServerStatics.STAT_STR_ID:
|
|
||||||
pc.addStr(msg.getAmount());
|
|
||||||
break;
|
|
||||||
case MBServerStatics.STAT_DEX_ID:
|
|
||||||
pc.addDex(msg.getAmount());
|
|
||||||
break;
|
|
||||||
case MBServerStatics.STAT_CON_ID:
|
|
||||||
pc.addCon(msg.getAmount());
|
|
||||||
break;
|
|
||||||
case MBServerStatics.STAT_INT_ID:
|
|
||||||
pc.addInt(msg.getAmount());
|
|
||||||
break;
|
|
||||||
case MBServerStatics.STAT_SPI_ID:
|
|
||||||
pc.addSpi(msg.getAmount());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// called when player clicks respawn button
|
|
||||||
private static void respawn(RespawnMsg msg, ClientConnection origin) throws MsgSendException {
|
|
||||||
|
|
||||||
PlayerCharacter sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
|
||||||
|
|
||||||
if (sourcePlayer == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (msg.getObjectType() != sourcePlayer.getObjectType().ordinal() || msg.getObjectID() != sourcePlayer.getObjectUUID()) {
|
|
||||||
Logger.error("Player " + sourcePlayer.getObjectUUID() + " respawning character of id " + msg.getObjectType() + ' '
|
|
||||||
+ msg.getObjectID());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sourcePlayer.isAlive()) {
|
|
||||||
Logger.error("Player " + sourcePlayer.getObjectUUID() + " respawning while alive");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// ResetAfterDeath player
|
|
||||||
sourcePlayer.respawnLock.writeLock().lock();
|
|
||||||
try {
|
|
||||||
sourcePlayer.respawn(true, false, true);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.error(e);
|
|
||||||
} finally {
|
|
||||||
sourcePlayer.respawnLock.writeLock().unlock();
|
|
||||||
|
|
||||||
}
|
|
||||||
// Echo ResetAfterDeath message back
|
|
||||||
msg.setPlayerHealth(sourcePlayer.getHealth());
|
|
||||||
// TODO calculate any experience loss before this point
|
|
||||||
msg.setPlayerExp(sourcePlayer.getExp() + sourcePlayer.getOverFlowEXP());
|
|
||||||
Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
|
||||||
|
|
||||||
MoveToPointMsg moveMsg = new MoveToPointMsg();
|
|
||||||
moveMsg.setPlayer(sourcePlayer);
|
|
||||||
moveMsg.setStartCoord(sourcePlayer.getLoc());
|
|
||||||
moveMsg.setEndCoord(sourcePlayer.getLoc());
|
|
||||||
moveMsg.setInBuilding(-1);
|
|
||||||
moveMsg.setInBuildingFloor(-1);
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(sourcePlayer, moveMsg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
|
||||||
|
|
||||||
MovementManager.sendRWSSMsg(sourcePlayer);
|
|
||||||
|
|
||||||
// refresh the whole group with what just happened
|
|
||||||
JobScheduler.getInstance().scheduleJob(new RefreshGroupJob(sourcePlayer), MBServerStatics.LOAD_OBJECT_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void lootWindowRequest(LootWindowRequestMsg msg, ClientConnection origin) throws MsgSendException {
|
|
||||||
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
|
||||||
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!pc.isAlive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (msg.getSourceType() != pc.getObjectType().ordinal() || msg.getSourceID() != pc.getObjectUUID()) {
|
|
||||||
Logger.error("Player " + pc.getObjectUUID() + " looting from character of id "
|
|
||||||
+ msg.getSourceType() + ' ' + msg.getSourceID());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pc.getAltitude() > 0)
|
|
||||||
return;
|
|
||||||
if (!pc.isAlive()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LootWindowResponseMsg lwrm = null;
|
|
||||||
GameObjectType targetType = GameObjectType.values()[msg.getTargetType()];
|
|
||||||
AbstractCharacter characterTarget = null;
|
|
||||||
Corpse corpseTarget = null;
|
|
||||||
|
|
||||||
switch (targetType) {
|
|
||||||
case PlayerCharacter:
|
|
||||||
|
|
||||||
characterTarget = PlayerCharacter.getFromCache(msg.getTargetID());
|
|
||||||
if (characterTarget == null)
|
|
||||||
return;
|
|
||||||
if (characterTarget.isAlive())
|
|
||||||
return;
|
|
||||||
if (pc.getLoc().distanceSquared2D(characterTarget.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "You are too far away to loot this corpse.");
|
|
||||||
|
|
||||||
Logger.info(pc.getFirstName() + " tried looting at " + pc.getLoc().distance2D(characterTarget.getLoc()) + " distance.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
lwrm = new LootWindowResponseMsg(characterTarget.getObjectType().ordinal(), characterTarget.getObjectUUID(), characterTarget.getInventory(true));
|
|
||||||
break;
|
|
||||||
case NPC:
|
|
||||||
characterTarget = NPC.getFromCache(msg.getTargetID());
|
|
||||||
if (characterTarget == null)
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
case Mob:
|
|
||||||
characterTarget = Mob.getFromCache(msg.getTargetID());
|
|
||||||
if ((characterTarget == null) || characterTarget.isAlive()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pc.getLoc().distanceSquared2D(characterTarget.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "You are too far away to loot this corpse.");
|
|
||||||
|
|
||||||
Logger.info(pc.getFirstName() + " tried looting at " + pc.getLoc().distance2D(characterTarget.getLoc()) + " distance.");
|
|
||||||
|
|
||||||
if (!((Mob) characterTarget).isLootSync()) {
|
|
||||||
|
|
||||||
((Mob) characterTarget).setLootSync(true);
|
|
||||||
WorldGrid.updateObject(characterTarget, pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lwrm = new LootWindowResponseMsg(characterTarget.getObjectType().ordinal(), characterTarget.getObjectUUID(), characterTarget.getInventory());
|
|
||||||
break;
|
|
||||||
case Corpse:
|
|
||||||
corpseTarget = Corpse.getCorpse(msg.getTargetID());
|
|
||||||
|
|
||||||
if ((corpseTarget == null)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pc.getLoc().distanceSquared(corpseTarget.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
|
||||||
ErrorPopupMsg.sendErrorMsg(pc, "You are too far away to loot this corpse.");
|
|
||||||
|
|
||||||
Logger.info(pc.getFirstName() + " tried looting at " + pc.getLoc().distance2D(characterTarget.getLoc()) + " distance.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
lwrm = new LootWindowResponseMsg(corpseTarget.getObjectType().ordinal(), msg.getTargetID(), corpseTarget.getInventory());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lwrm == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
|
||||||
Dispatch dispatch = Dispatch.borrow(pc, lwrm);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loot(LootMsg msg, ClientConnection origin) throws MsgSendException {
|
|
||||||
|
|
||||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!player.isAlive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Item item = msg.getItem();
|
|
||||||
|
|
||||||
if (item == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (item.lootLock.tryLock()) {
|
|
||||||
try {
|
|
||||||
Item itemRet = null;
|
|
||||||
// get current owner
|
|
||||||
int targetType = msg.getTargetType();
|
|
||||||
int targetID = msg.getTargetID();
|
|
||||||
|
|
||||||
if (targetType == GameObjectType.PlayerCharacter.ordinal() || targetType == GameObjectType.Mob.ordinal() || targetType == GameObjectType.Corpse.ordinal()) {
|
|
||||||
} else { //needed for getting contracts for some reason
|
|
||||||
targetType = msg.getSourceID2();
|
|
||||||
targetID = msg.getUnknown01();
|
|
||||||
}
|
|
||||||
|
|
||||||
//can't loot while flying
|
|
||||||
if (player.getAltitude() > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
AbstractCharacter tar = null;
|
|
||||||
Corpse corpse = null;
|
|
||||||
|
|
||||||
if (targetType == GameObjectType.PlayerCharacter.ordinal() || targetType == GameObjectType.Mob.ordinal()) {
|
|
||||||
|
|
||||||
if (targetType == GameObjectType.PlayerCharacter.ordinal()) {
|
|
||||||
tar = PlayerCharacter.getFromCache(targetID);
|
|
||||||
|
|
||||||
if (tar == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (player.getObjectUUID() != tar.getObjectUUID() && ((PlayerCharacter) tar).isInSafeZone())
|
|
||||||
return;
|
|
||||||
|
|
||||||
} else if (targetType == GameObjectType.NPC.ordinal())
|
|
||||||
tar = NPC.getFromCache(targetID);
|
|
||||||
else if (targetType == GameObjectType.Mob.ordinal())
|
|
||||||
tar = Mob.getFromCache(targetID);
|
|
||||||
if (tar == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (tar.equals(player)) {
|
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot loot this item.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (player.getLoc().distanceSquared2D(tar.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse.");
|
|
||||||
|
|
||||||
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(tar.getLoc()) + " distance.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//can't loot from someone who is alive.
|
|
||||||
if (AbstractWorldObject.IsAbstractCharacter(tar)) {
|
|
||||||
if (tar.isAlive())
|
|
||||||
return;
|
|
||||||
// Logger.error("WorldServer.loot", "Looting from live player");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GroupManager.goldSplit(player, item, origin, tar)) {
|
|
||||||
|
|
||||||
if (tar.charItemManager != null) {
|
|
||||||
|
|
||||||
itemRet = tar.charItemManager.lootItemFromMe(item, player, origin);
|
|
||||||
|
|
||||||
//Take equipment off mob
|
|
||||||
if (tar.getObjectType() == GameObjectType.Mob && itemRet != null) {
|
|
||||||
Mob mobTarget = (Mob) tar;
|
|
||||||
|
|
||||||
if (item != null && item.getObjectType() == GameObjectType.MobLoot) {
|
|
||||||
|
|
||||||
for (Item equip : mobTarget.charItemManager.equipped.values()) {
|
|
||||||
|
|
||||||
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.equipSlot);
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(mobTarget, back, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
|
||||||
|
|
||||||
LootMsg lootMsg = new LootMsg(0, 0, tar.getObjectType().ordinal(), tar.getObjectUUID(), equip);
|
|
||||||
Dispatch dispatch = Dispatch.borrow(player, lootMsg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} else if (targetType == GameObjectType.Corpse.ordinal()) {
|
|
||||||
corpse = Corpse.getCorpse(targetID);
|
|
||||||
if (corpse == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (player.getLoc().distanceSquared2D(corpse.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse.");
|
|
||||||
|
|
||||||
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(corpse.getLoc()) + " distance.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//can't loot other players in safe zone.
|
|
||||||
if (corpse.getBelongsToType() == GameObjectType.PlayerCharacter.ordinal()) {
|
|
||||||
|
|
||||||
if (player.getObjectUUID() == corpse.getBelongsToID())
|
|
||||||
itemRet = corpse.lootItem(item, player);
|
|
||||||
else if (!GroupManager.goldSplit(player, item, origin, corpse)) {
|
|
||||||
itemRet = corpse.lootItem(item, player);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemRet == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) {
|
|
||||||
// this is done to prevent the temporary goldItem item
|
|
||||||
// (from the mob) from appearing in player's inventory.
|
|
||||||
// It also updates the goldItem quantity display
|
|
||||||
UpdateGoldMsg updateTargetGold = null;
|
|
||||||
|
|
||||||
|
|
||||||
if (corpse != null)
|
|
||||||
updateTargetGold = new UpdateGoldMsg(corpse);
|
|
||||||
|
|
||||||
updateTargetGold.configure();
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(corpse, updateTargetGold, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
|
||||||
|
|
||||||
UpdateGoldMsg ugm = new UpdateGoldMsg(player);
|
|
||||||
ugm.configure();
|
|
||||||
Dispatch dispatch = Dispatch.borrow(player, ugm);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
// respond back loot message. Try sending to everyone.
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(corpse, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, true);
|
|
||||||
|
|
||||||
|
|
||||||
//player.getCharItemManager().updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO send group loot message if player is grouped and visible
|
|
||||||
Group group = GroupManager.getGroup(player);
|
|
||||||
|
|
||||||
if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) {
|
|
||||||
String name = item.getName();
|
|
||||||
String text = player.getFirstName() + " has looted " + name + '.';
|
|
||||||
ChatManager.chatGroupInfoCanSee(player, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
if (itemRet == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) {
|
|
||||||
// this is done to prevent the temporary goldItem item
|
|
||||||
// (from the mob) from appearing in player's inventory.
|
|
||||||
// It also updates the goldItem quantity display
|
|
||||||
UpdateGoldMsg updateTargetGold = null;
|
|
||||||
|
|
||||||
if (tar != null)
|
|
||||||
updateTargetGold = new UpdateGoldMsg(tar);
|
|
||||||
else if (corpse != null)
|
|
||||||
updateTargetGold = new UpdateGoldMsg(corpse);
|
|
||||||
|
|
||||||
updateTargetGold.configure();
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(tar, updateTargetGold, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
|
||||||
|
|
||||||
UpdateGoldMsg ugm = new UpdateGoldMsg(player);
|
|
||||||
ugm.configure();
|
|
||||||
Dispatch dispatch = Dispatch.borrow(player, ugm);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
// respond back loot message. Try sending to everyone.
|
|
||||||
|
|
||||||
} else {
|
|
||||||
msg.setSourceType1(0);
|
|
||||||
msg.setSourceType2(0);
|
|
||||||
msg.setSourceID1(0);
|
|
||||||
msg.setSourceID2(0);
|
|
||||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
|
||||||
//DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
|
||||||
DispatchMessage.dispatchMsgToInterestArea(tar, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, true);
|
|
||||||
LootMsg newItemMsg = new LootMsg(GameObjectType.PlayerCharacter.ordinal(), player.getObjectUUID(), 0, 0, itemRet);
|
|
||||||
dispatch = Dispatch.borrow(player, newItemMsg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
|
||||||
|
|
||||||
//player.getCharItemManager().updateInventory();
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO send group loot message if player is grouped and visible
|
|
||||||
Group group = GroupManager.getGroup(player);
|
|
||||||
|
|
||||||
if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) {
|
|
||||||
String name = item.getName();
|
|
||||||
String text = player.getFirstName() + " has looted " + name + '.';
|
|
||||||
ChatManager.chatGroupInfoCanSee(player, text);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Logger.info(e.getMessage());
|
|
||||||
} finally {
|
|
||||||
item.lootLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// called when player types /show
|
|
||||||
private static void show(ShowMsg msg, ClientConnection origin) throws MsgSendException {
|
|
||||||
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
|
||||||
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int targetType = msg.getTargetType();
|
|
||||||
AbstractCharacter tar = null;
|
|
||||||
|
|
||||||
if (targetType == GameObjectType.PlayerCharacter.ordinal())
|
|
||||||
tar = PlayerCharacter.getFromCache(msg.getTargetID());
|
|
||||||
else if (targetType == GameObjectType.NPC.ordinal())
|
|
||||||
tar = NPC.getFromCache(msg.getTargetID());
|
|
||||||
else if (targetType == GameObjectType.Mob.ordinal())
|
|
||||||
tar = Mob.getFromCache(msg.getTargetID());
|
|
||||||
|
|
||||||
if (tar == null || !tar.isAlive() || !tar.isActive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
msg.setUnknown01(pc.getLoc());
|
|
||||||
msg.setUnknown02(pc.getLoc());
|
|
||||||
msg.setRange01(pc.getRange());
|
|
||||||
msg.setUnknown03(tar.getLoc());
|
|
||||||
msg.setUnknown04(tar.getLoc());
|
|
||||||
msg.setRange01(tar.getRange());
|
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(pc, msg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ViewResourcesMessage(ViewResourcesMessage msg, ClientConnection origin) throws SQLException {
|
|
||||||
|
|
||||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Guild guild = player.getGuild();
|
|
||||||
City city = guild.getOwnedCity();
|
|
||||||
|
|
||||||
if (city == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Building warehouse = BuildingManager.getBuilding(city.getWarehouseBuildingID());
|
|
||||||
|
|
||||||
if (warehouse == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
|
||||||
vrm.setWarehouseBuilding(warehouse);
|
|
||||||
vrm.setGuild(player.getGuild());
|
|
||||||
vrm.configure();
|
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(player, vrm);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void petAttack(PetAttackMsg msg, ClientConnection conn) throws MsgSendException {
|
|
||||||
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(conn);
|
|
||||||
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Mob pet = pc.getPet();
|
|
||||||
|
|
||||||
if (pet == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!pet.isAlive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((pc.inSafeZone())
|
|
||||||
&& (msg.getTargetType() == GameObjectType.PlayerCharacter.ordinal()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
//CombatManager.setAttackTarget(msg, conn);
|
|
||||||
if (msg.getTargetType() == GameObjectType.Building.ordinal()) {
|
|
||||||
conn.getPlayerCharacter().getPet().setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
|
|
||||||
}
|
|
||||||
switch (msg.getTargetType()) {
|
|
||||||
case 53: //player character
|
|
||||||
conn.getPlayerCharacter().getPet().setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
|
|
||||||
break;
|
|
||||||
case 37://mob
|
|
||||||
conn.getPlayerCharacter().getPet().setCombatTarget(Mob.getMob(msg.getTargetID()));
|
|
||||||
break;
|
|
||||||
case 8://mob
|
|
||||||
conn.getPlayerCharacter().getPet().setCombatTarget(BuildingManager.getBuilding(msg.getTargetID()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pet.getCombatTarget() == null)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void petCmd(PetCmdMsg msg, ClientConnection conn) throws MsgSendException {
|
|
||||||
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(conn);
|
|
||||||
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Mob pet = pc.getPet();
|
|
||||||
|
|
||||||
if (pet == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!pet.isAlive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
//if (pet.state == STATE.Disabled)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
int type = msg.getType();
|
|
||||||
|
|
||||||
if (type == 1) { //stop attack
|
|
||||||
pet.setCombatTarget(null);
|
|
||||||
pc.setCombat(false);
|
|
||||||
|
|
||||||
} else if (type == 2) { //dismiss
|
|
||||||
pet.dismiss();
|
|
||||||
pc.dismissPet();
|
|
||||||
|
|
||||||
if (pet.isAlive())
|
|
||||||
WorldGrid.updateObject(pet);
|
|
||||||
} else if (type == 3) //toggle assist
|
|
||||||
pet.toggleAssist();
|
|
||||||
else if (type == 5) { //rest
|
|
||||||
boolean sit = (!(pet.isSit()));
|
|
||||||
pet.setSit(sit);
|
|
||||||
|
|
||||||
// cancel effects that break on sit
|
|
||||||
if (pet.isSit())
|
|
||||||
pet.cancelOnSit();
|
|
||||||
|
|
||||||
UpdateStateMsg rwss = new UpdateStateMsg();
|
|
||||||
rwss.setPlayer(pet);
|
|
||||||
DispatchMessage.sendToAllInRange(pet, rwss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Handle RepairObject Window and RepairObject Requests
|
//Handle RepairObject Window and RepairObject Requests
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -716,129 +67,11 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
protocolMsg = msg.getProtocolMsg();
|
protocolMsg = msg.getProtocolMsg();
|
||||||
|
|
||||||
switch (protocolMsg) {
|
switch (protocolMsg) {
|
||||||
/*
|
|
||||||
* Chat
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Simplify by fall through. Route in ChatManager
|
|
||||||
case CHATSAY:
|
|
||||||
case CHATSHOUT:
|
|
||||||
case CHATTELL:
|
|
||||||
case CHATGUILD:
|
|
||||||
case CHATGROUP:
|
|
||||||
case CHATPVP:
|
|
||||||
case CHATIC:
|
|
||||||
case CHATCITY:
|
|
||||||
case CHATINFO:
|
|
||||||
case SYSTEMBROADCASTCHANNEL:
|
|
||||||
case CHATCSR:
|
|
||||||
case SYSTEMCHANNEL:
|
|
||||||
case GLOBALCHANNELMESSAGE:
|
|
||||||
case LEADERCHANNELMESSAGE:
|
|
||||||
ChatManager.handleChatMsg(s, (AbstractChatMsg) msg);
|
|
||||||
break;
|
|
||||||
case READYTOENTER:
|
case READYTOENTER:
|
||||||
break;
|
break;
|
||||||
case OPENVAULT:
|
case OPENVAULT:
|
||||||
break;
|
break;
|
||||||
case CLIENTADMINCOMMAND:
|
|
||||||
ChatManager.HandleClientAdminCmd((ClientAdminCommandMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case COMBATMODE:
|
|
||||||
CombatManager.toggleCombat(((ToggleCombatMsg) msg).toggleCombat(), origin);
|
|
||||||
break;
|
|
||||||
case ARCCOMBATMODEATTACKING:
|
|
||||||
CombatManager.toggleCombat(((SetCombatModeMsg) msg).getToggle(), origin);
|
|
||||||
break;
|
|
||||||
case MODIFYGUILDSTATE:
|
|
||||||
ToggleLfgRecruitingMsg tlrm = (ToggleLfgRecruitingMsg) msg;
|
|
||||||
toggleLfgRecruiting(tlrm, origin);
|
|
||||||
break;
|
|
||||||
case TOGGLESITSTAND:
|
|
||||||
ToggleSitStandMsg tssm = (ToggleSitStandMsg) msg;
|
|
||||||
toggleSitStand(tssm, origin);
|
|
||||||
break;
|
|
||||||
case IGNORE:
|
|
||||||
((IgnoreMsg) msg).handleRequest(origin);
|
|
||||||
break;
|
|
||||||
case DELETEOBJECT:
|
|
||||||
DeleteItem((DeleteItemMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case VIEWRESOURCES:
|
|
||||||
ViewResourcesMessage((ViewResourcesMessage) msg, origin);
|
|
||||||
break;
|
|
||||||
case RAISEATTR:
|
|
||||||
modifyStat((ModifyStatMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case COSTTOOPENBANK:
|
|
||||||
ackBankWindowOpened((AckBankWindowOpenedMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case RESETAFTERDEATH:
|
|
||||||
respawn((RespawnMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case REQUESTCONTENTS:
|
|
||||||
lootWindowRequest((LootWindowRequestMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case MOVEOBJECTTOCONTAINER:
|
|
||||||
loot((LootMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case SHOWCOMBATINFO:
|
|
||||||
show((ShowMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case REQUESTTOTRADE:
|
|
||||||
TradeManager.tradeRequest((TradeRequestMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case REQUESTTRADEOK:
|
|
||||||
TradeManager.acceptTradeRequest((AcceptTradeRequestMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case REQUESTTRADECANCEL:
|
|
||||||
TradeManager.rejectTradeRequest((RejectTradeRequestMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case TRADEADDOBJECT:
|
|
||||||
TradeManager.addItemToTradeWindow((AddItemToTradeWindowMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case TRADEADDGOLD:
|
|
||||||
TradeManager.addGoldToTradeWindow((AddGoldToTradeWindowMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case TRADECONFIRM:
|
|
||||||
TradeManager.commitToTrade((CommitToTradeMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case TRADEUNCONFIRM:
|
|
||||||
TradeManager.uncommitToTrade((UncommitToTradeMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case TRADECLOSE:
|
|
||||||
TradeManager.closeTradeWindow((CloseTradeWindowMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case ARCREQUESTTRADEBUSY:
|
|
||||||
TradeManager.invalidTradeRequest((InvalidTradeRequestMsg) msg);
|
|
||||||
break;
|
|
||||||
case TRAINERLIST:
|
|
||||||
WorldServer.trainerInfo((TrainerInfoMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case ARCUNTRAINLIST:
|
|
||||||
WorldServer.refinerScreen((RefinerScreenMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case ARCUNTRAINABILITY:
|
|
||||||
RefineMsg.refine((RefineMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case POWERTARGNAME:
|
|
||||||
PowersManager.summon((SendSummonsRequestMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case ARCSUMMON:
|
|
||||||
PowersManager.recvSummon((RecvSummonsRequestMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case ARCTRACKINGLIST:
|
|
||||||
PowersManager.trackWindow((TrackWindowMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case STUCK:
|
|
||||||
MovementManager.stuck(origin);
|
|
||||||
break;
|
|
||||||
case ARCPETATTACK:
|
|
||||||
petAttack((PetAttackMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case ARCPETCMD:
|
|
||||||
petCmd((PetCmdMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case CHANNELMUTE:
|
case CHANNELMUTE:
|
||||||
break;
|
break;
|
||||||
case KEEPALIVESERVERCLIENT:
|
case KEEPALIVESERVERCLIENT:
|
||||||
@@ -856,7 +89,7 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (MsgSendException | SQLException e) {
|
} catch (Exception e) {
|
||||||
Logger.error("handler for " + protocolMsg + " failed: " + e);
|
Logger.error("handler for " + protocolMsg + " failed: " + e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public enum Protocol {
|
|||||||
ADDFRIEND(0xCFA1C787, AddFriendMessage.class, null),
|
ADDFRIEND(0xCFA1C787, AddFriendMessage.class, null),
|
||||||
ALLIANCECHANGE(0x0E7D0B57, AllianceChangeMsg.class, AllianceChangeMsgHandler.class), // Remove From Allies/Enemies List
|
ALLIANCECHANGE(0x0E7D0B57, AllianceChangeMsg.class, AllianceChangeMsgHandler.class), // Remove From Allies/Enemies List
|
||||||
ALLYENEMYLIST(0xAEA443FD, AllyEnemyListMsg.class, AllyEnemyListMsgHandler.class),
|
ALLYENEMYLIST(0xAEA443FD, AllyEnemyListMsg.class, AllyEnemyListMsgHandler.class),
|
||||||
ARCCOMBATMODEATTACKING(0xD8B10579, SetCombatModeMsg.class, null), // Attack From Outside Combat Mode
|
ARCCOMBATMODEATTACKING(0xD8B10579, SetCombatModeMsg.class, SetCombatModeMsgHandler.class), // Attack From Outside Combat Mode
|
||||||
ARCHOTZONECHANGE(0xDCFF196F, null, null), //change hotzone
|
ARCHOTZONECHANGE(0xDCFF196F, null, null), //change hotzone
|
||||||
ARCIGNORELISTUPDATE(0x4B1B17C2, IgnoreListMsg.class, null), //req/show ignore list
|
ARCIGNORELISTUPDATE(0x4B1B17C2, IgnoreListMsg.class, null), //req/show ignore list
|
||||||
ARCLOGINNOTIFY(0x010FED87, ArcLoginNotifyMsg.class, ArcLoginNotifyMsgHandler.class), //Client Confirms entering world
|
ARCLOGINNOTIFY(0x010FED87, ArcLoginNotifyMsg.class, ArcLoginNotifyMsgHandler.class), //Client Confirms entering world
|
||||||
@@ -37,18 +37,18 @@ public enum Protocol {
|
|||||||
ARCMINEWINDOWAVAILABLETIME(0x6C909DE7, ArcMineWindowAvailableTimeMsg.class, ArcMineWindowAvailableTimeHandler.class),
|
ARCMINEWINDOWAVAILABLETIME(0x6C909DE7, ArcMineWindowAvailableTimeMsg.class, ArcMineWindowAvailableTimeHandler.class),
|
||||||
ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class),
|
ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class),
|
||||||
ARCOWNEDMINESLIST(0x59184455, ArcOwnedMinesListMsg.class, ArcOwnedMinesListHandler.class),
|
ARCOWNEDMINESLIST(0x59184455, ArcOwnedMinesListMsg.class, ArcOwnedMinesListHandler.class),
|
||||||
ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, null), // Pet Attack
|
ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, PetAttackMsgHandler.class), // Pet Attack
|
||||||
ARCPETCMD(0x4E80E001, PetCmdMsg.class, null), // Stop ArcPetAttack, Toggle Assist, Toggle Rest
|
ARCPETCMD(0x4E80E001, PetCmdMsg.class, PetCmdMsgHandler.class), // Stop ArcPetAttack, Toggle Assist, Toggle Rest
|
||||||
ARCPOWERPROJECTILE(0xA2312D3B, null, null),
|
ARCPOWERPROJECTILE(0xA2312D3B, null, null),
|
||||||
ARCPROMPTRECALL(0xE3196B6E, PromptRecallMsg.class, PromptRecallMsgHandler.class), //Recall Prompt
|
ARCPROMPTRECALL(0xE3196B6E, PromptRecallMsg.class, PromptRecallMsgHandler.class), //Recall Prompt
|
||||||
ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, null), // Attempt trade with someone who is already trading
|
ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, InvalidTradeRequestMsgHandler.class), // Attempt trade with someone who is already trading
|
||||||
ARCSERVERSTATUS(0x87BA4462, null, null), //Update Server Status
|
ARCSERVERSTATUS(0x87BA4462, null, null), //Update Server Status
|
||||||
ARCSIEGESPIRE(0x36A49BC6, ArcSiegeSpireMsg.class, ArcSiegeSpireMsgHandler.class), // Activate/Deactivate Spires
|
ARCSIEGESPIRE(0x36A49BC6, ArcSiegeSpireMsg.class, ArcSiegeSpireMsgHandler.class), // Activate/Deactivate Spires
|
||||||
ARCSUMMON(0xFD816A0A, RecvSummonsRequestMsg.class, null), // Suspect Recv Summons Request
|
ARCSUMMON(0xFD816A0A, RecvSummonsMsg.class, RecvSummonsMsgHandler.class), // Suspect Recv Summons Request
|
||||||
ARCTRACKINGLIST(0xC89CF08B, TrackWindowMsg.class, null), //Request/Send Track window
|
ARCTRACKINGLIST(0xC89CF08B, TrackWindowMsg.class, TrackWindowMsgHandler.class), //Request/Send Track window
|
||||||
ARCTRACKOBJECT(0x609B6BA2, TrackArrowMsg.class, null), //Send Track Arrow
|
ARCTRACKOBJECT(0x609B6BA2, TrackArrowMsg.class, null), //Send Track Arrow
|
||||||
ARCUNTRAINABILITY(0x548DBF83, RefineMsg.class, null), //Refine
|
ARCUNTRAINABILITY(0x548DBF83, RefineMsg.class, RefineMsgHandler.class), //Refine
|
||||||
ARCUNTRAINLIST(0x38879E90, RefinerScreenMsg.class, null), //Refiner screen
|
ARCUNTRAINLIST(0x38879E90, RefinerScreenMsg.class, RefinerScreenMsgHandler.class), //Refiner screen
|
||||||
ARCVIEWASSETTRANSACTIONS(0xBFA476E4, ArcViewAssetTransactionsMsg.class, ArcViewAssetTransactionsMsgHandler.class),
|
ARCVIEWASSETTRANSACTIONS(0xBFA476E4, ArcViewAssetTransactionsMsg.class, ArcViewAssetTransactionsMsgHandler.class),
|
||||||
ASSETSUPPORT(0xc481f89D, AssetSupportMsg.class, AssetSupportMsgHandler.class),
|
ASSETSUPPORT(0xc481f89D, AssetSupportMsg.class, AssetSupportMsgHandler.class),
|
||||||
BANISHMEMBER(0x31AA3368, BanishUnbanishMsg.class, BanishUnbanishHandler.class), // Banish/Unbanish
|
BANISHMEMBER(0x31AA3368, BanishUnbanishMsg.class, BanishUnbanishHandler.class), // Banish/Unbanish
|
||||||
@@ -60,16 +60,16 @@ public enum Protocol {
|
|||||||
CHANGEGUILDLEADER(0xE40BC95D, ChangeGuildLeaderMsg.class, ChangeGuildLeaderHandler.class),
|
CHANGEGUILDLEADER(0xE40BC95D, ChangeGuildLeaderMsg.class, ChangeGuildLeaderHandler.class),
|
||||||
CHANNELMUTE(0xC1BDC53A, ChatFilterMsg.class, ChannelMuteMsgHandler.class), //Chat Channels that are turned on
|
CHANNELMUTE(0xC1BDC53A, ChatFilterMsg.class, ChannelMuteMsgHandler.class), //Chat Channels that are turned on
|
||||||
CHARSELECTSCREEN(0x682C935D, null, null), // Character Selection Screen
|
CHARSELECTSCREEN(0x682C935D, null, null), // Character Selection Screen
|
||||||
CHATCITY(0x9D402901, ChatCityMsg.class, null), // Chat Channel: /City
|
CHATCITY(0x9D402901, ChatCityMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /City
|
||||||
CHATCSR(0x14EBA1C3, ChatCSRMsg.class, null), //Chat Channel: CSR
|
CHATCSR(0x14EBA1C3, ChatCSRMsg.class, AbstractChatMsgHandler.class), //Chat Channel: CSR
|
||||||
CHATGROUP(0xA895B634, ChatGroupMsg.class, null), // Chat Channel: /group
|
CHATGROUP(0xA895B634, ChatGroupMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /group
|
||||||
CHATGUILD(0xA9D92ED4, ChatGuildMsg.class, null), // Chat Channel: /guild
|
CHATGUILD(0xA9D92ED4, ChatGuildMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /guild
|
||||||
CHATIC(0x00A75F35, ChatICMsg.class, null), // Chat Channel: /IC
|
CHATIC(0x00A75F35, ChatICMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /IC
|
||||||
CHATINFO(0x9D4B61EB, ChatInfoMsg.class, null), // Chat Channel: /Info
|
CHATINFO(0x9D4B61EB, ChatInfoMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /Info
|
||||||
CHATPVP(0x14EBA570, ChatPvPMsg.class, null), // Chat Channel: PVP
|
CHATPVP(0x14EBA570, ChatPvPMsg.class, AbstractChatMsgHandler.class), // Chat Channel: PVP
|
||||||
CHATSAY(0x14EA0393, ChatSayMsg.class, null), // Chat Channel: /say
|
CHATSAY(0x14EA0393, ChatSayMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /say
|
||||||
CHATSHOUT(0xA8D5B560, ChatShoutMsg.class, null), // Chat Channel: /shout
|
CHATSHOUT(0xA8D5B560, ChatShoutMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /shout
|
||||||
CHATTELL(0x9D4AC896, ChatTellMsg.class, null), // Chat Channel: /tell
|
CHATTELL(0x9D4AC896, ChatTellMsg.class, AbstractChatMsgHandler.class), // Chat Channel: /tell
|
||||||
CHECKUNIQUEGUILD(0x689097D7, GuildCreationOptionsMsg.class, GuildCreationOptionsHandler.class), // Set Guild Name/Motto in Use Guild Charter
|
CHECKUNIQUEGUILD(0x689097D7, GuildCreationOptionsMsg.class, GuildCreationOptionsHandler.class), // Set Guild Name/Motto in Use Guild Charter
|
||||||
CITYASSET(0x7cae1678, CityAssetMsg.class, null),
|
CITYASSET(0x7cae1678, CityAssetMsg.class, null),
|
||||||
CITYCHOICE(0x406610BB, CityChoiceMsg.class, CityChoiceMsgHandler.class),
|
CITYCHOICE(0x406610BB, CityChoiceMsg.class, CityChoiceMsgHandler.class),
|
||||||
@@ -77,15 +77,15 @@ public enum Protocol {
|
|||||||
CITYZONE(0x254947F2, CityZoneMsg.class, null), //For Creating City Object Clientside(Terraform)/Rename City.
|
CITYZONE(0x254947F2, CityZoneMsg.class, null), //For Creating City Object Clientside(Terraform)/Rename City.
|
||||||
CLAIMASSET(0x948C62CC, ClaimAssetMsg.class, ClaimAssetMsgHandler.class), // ClaimAsset
|
CLAIMASSET(0x948C62CC, ClaimAssetMsg.class, ClaimAssetMsgHandler.class), // ClaimAsset
|
||||||
CLAIMGUILDTREE(0xFD1C6442, ClaimGuildTreeMsg.class, ClaimGuildTreeMsgHandler.class),
|
CLAIMGUILDTREE(0xFD1C6442, ClaimGuildTreeMsg.class, ClaimGuildTreeMsgHandler.class),
|
||||||
CLIENTADMINCOMMAND(0x624EAB5F, ClientAdminCommandMsg.class, null), //Admin Command
|
CLIENTADMINCOMMAND(0x624EAB5F, ClientAdminCommandMsg.class, ClientAdminCommandMsgHandler.class), //Admin Command
|
||||||
CLIENTUPDATEVAULT(0x66EDBECD, UpdateVaultMsg.class, null),
|
CLIENTUPDATEVAULT(0x66EDBECD, UpdateVaultMsg.class, null),
|
||||||
COMBATMODE(0xFE4BF353, ToggleCombatMsg.class, null), //Toggle Combat mode
|
COMBATMODE(0xFE4BF353, ToggleCombatMsg.class, ToggleCombatMsgHandler.class), //Toggle Combat mode
|
||||||
CONFIRMPROMOTE(0x153BB5F9, ConfirmPromoteMsg.class, null),
|
CONFIRMPROMOTE(0x153BB5F9, ConfirmPromoteMsg.class, null),
|
||||||
COSTTOOPENBANK(0x135BE5E8, AckBankWindowOpenedMsg.class, null), // ACK Bank Window Opened
|
COSTTOOPENBANK(0x135BE5E8, CostOpenBankMsg.class, null), // ACK Bank Window Opened
|
||||||
CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character,
|
CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character,
|
||||||
CREATEPETITION(0xD489CFED, GuildCreationFinalizeMsg.class, GuildCreationFinalizeHandler.class), //Confirm guild creation
|
CREATEPETITION(0xD489CFED, GuildCreationFinalizeMsg.class, GuildCreationFinalizeHandler.class), //Confirm guild creation
|
||||||
CUSTOMERPETITION(0x7F9D7D6D, PetitionReceivedMsg.class, PetitionReceivedMsgHandler.class),
|
CUSTOMERPETITION(0x7F9D7D6D, PetitionReceivedMsg.class, PetitionReceivedMsgHandler.class),
|
||||||
DELETEOBJECT(0x57F069D8, DeleteItemMsg.class, null), //Delete Item from Inventory
|
DELETEOBJECT(0x57F069D8, DeleteItemMsg.class, DeleteItemMsgHandler.class), //Delete Item from Inventory
|
||||||
DESTROYBUILDING(0x3CB6FAD3, DestroyBuildingMsg.class, DestroyBuildingHandler.class), // Destroy Building
|
DESTROYBUILDING(0x3CB6FAD3, DestroyBuildingMsg.class, DestroyBuildingHandler.class), // Destroy Building
|
||||||
DISBANDGUILD(0x77AABD64, DisbandGuildMsg.class, DisbandGuildHandler.class), //Disband Guild
|
DISBANDGUILD(0x77AABD64, DisbandGuildMsg.class, DisbandGuildHandler.class), //Disband Guild
|
||||||
DISMISSGUILD(0x8D2D3D61, DismissGuildMsg.class, DismissGuildHandler.class),
|
DISMISSGUILD(0x8D2D3D61, DismissGuildMsg.class, DismissGuildHandler.class),
|
||||||
@@ -98,7 +98,7 @@ public enum Protocol {
|
|||||||
FRIENDDECLINE(0xF08FC279, DeclineFriendMsg.class, FriendDeclineHandler.class),
|
FRIENDDECLINE(0xF08FC279, DeclineFriendMsg.class, FriendDeclineHandler.class),
|
||||||
FURNITURE(0xCE7FA503, FurnitureMsg.class, FurnitureHandler.class),
|
FURNITURE(0xCE7FA503, FurnitureMsg.class, FurnitureHandler.class),
|
||||||
GAMESERVERIPRESPONSE(0x6C95CF87, GameServerIPResponseMsg.class, null), // Game Server IP Response
|
GAMESERVERIPRESPONSE(0x6C95CF87, GameServerIPResponseMsg.class, null), // Game Server IP Response
|
||||||
GLOBALCHANNELMESSAGE(0x2bf03fd2, null, null),
|
GLOBALCHANNELMESSAGE(0x2bf03fd2, ChatGlobalMsg.class, AbstractChatMsgHandler.class),
|
||||||
GOLDFROMVAULT(0x011D0123, GoldFromVaultMsg.class, GoldFromVaultMsgHandler.class), // Transfer Gold from Vault to Inventory
|
GOLDFROMVAULT(0x011D0123, GoldFromVaultMsg.class, GoldFromVaultMsgHandler.class), // Transfer Gold from Vault to Inventory
|
||||||
GOLDTOVAULT(0x3ABAEE49, GoldToVaultMsg.class, GoldToVaultMsgHandler.class), // Transfer Gold from Inventory to Vault
|
GOLDTOVAULT(0x3ABAEE49, GoldToVaultMsg.class, GoldToVaultMsgHandler.class), // Transfer Gold from Inventory to Vault
|
||||||
GROUPDISBAND(0xE2B85AA4, DisbandGroupMsg.class, DisbandGroupHandler.class), //Disband Group
|
GROUPDISBAND(0xE2B85AA4, DisbandGroupMsg.class, DisbandGroupHandler.class), //Disband Group
|
||||||
@@ -110,7 +110,7 @@ public enum Protocol {
|
|||||||
GUILDRANKCHANGE(0x0DEFB21F, ChangeRankMsg.class, ChangeRankHandler.class), // Change Rank
|
GUILDRANKCHANGE(0x0DEFB21F, ChangeRankMsg.class, ChangeRankHandler.class), // Change Rank
|
||||||
GUILDTREESTATUS(0x4B95FB85, GuildTreeStatusMsg.class, GuildTreeStatusMsgHandler.class),
|
GUILDTREESTATUS(0x4B95FB85, GuildTreeStatusMsg.class, GuildTreeStatusMsgHandler.class),
|
||||||
HIRELINGSERVICE(0xD3D93322, HirelingServiceMsg.class, HirelingServiceMsgHandler.class),
|
HIRELINGSERVICE(0xD3D93322, HirelingServiceMsg.class, HirelingServiceMsgHandler.class),
|
||||||
IGNORE(0xBD8881EE, IgnoreMsg.class, null), //client sent /ignore command
|
IGNORE(0xBD8881EE, IgnoreMsg.class, IgnoreMsgHandler.class), //client sent /ignore command
|
||||||
INITIATETRADEHUDS(0x667D29D8, OpenTradeWindowMsg.class, null), // Open Trade Window
|
INITIATETRADEHUDS(0x667D29D8, OpenTradeWindowMsg.class, null), // Open Trade Window
|
||||||
INVITEGROUP(0x004A2012, GroupInviteMsg.class, GroupInviteHandler.class), // Send/Receive/Deny Group Invite
|
INVITEGROUP(0x004A2012, GroupInviteMsg.class, GroupInviteHandler.class), // Send/Receive/Deny Group Invite
|
||||||
INVITEGUILDFEALTY(0x0274D612, InviteToSubMsg.class, InviteToSubHandler.class), // Invite Guild to Swear
|
INVITEGUILDFEALTY(0x0274D612, InviteToSubMsg.class, InviteToSubHandler.class), // Invite Guild to Swear
|
||||||
@@ -125,7 +125,7 @@ public enum Protocol {
|
|||||||
JOINGUILD(0xF0C5F2FF, AcceptInviteToGuildMsg.class, AcceptInviteToGuildHandler.class), // Accept guild invite
|
JOINGUILD(0xF0C5F2FF, AcceptInviteToGuildMsg.class, AcceptInviteToGuildHandler.class), // Accept guild invite
|
||||||
KEEPALIVESERVERCLIENT(0x49EE129C, KeepAliveServerClientMsg.class, KeepAliveServerClientHandler.class), // Keep Alive
|
KEEPALIVESERVERCLIENT(0x49EE129C, KeepAliveServerClientMsg.class, KeepAliveServerClientHandler.class), // Keep Alive
|
||||||
LEADERBOARD(0x6F0C1386, LeaderboardMessage.class, null),
|
LEADERBOARD(0x6F0C1386, LeaderboardMessage.class, null),
|
||||||
LEADERCHANNELMESSAGE(0x17b306f9, ChatGlobalMsg.class, null),
|
LEADERCHANNELMESSAGE(0x17b306f9, ChatLeaderMsg.class, AbstractChatMsgHandler.class),
|
||||||
LEAVEGROUP(0xD8037303, LeaveGroupMsg.class, LeaveGroupHandler.class), //Leave Group
|
LEAVEGROUP(0xD8037303, LeaveGroupMsg.class, LeaveGroupHandler.class), //Leave Group
|
||||||
LEAVEGUILD(0x1801EA32, LeaveGuildMsg.class, LeaveGuildHandler.class), // Leave Guild
|
LEAVEGUILD(0x1801EA32, LeaveGuildMsg.class, LeaveGuildHandler.class), // Leave Guild
|
||||||
LEAVEREQUEST(0xC79D775C, LeaveWorldMsg.class, LeaveWorldMsgHandler.class), //Client Request Leave World
|
LEAVEREQUEST(0xC79D775C, LeaveWorldMsg.class, LeaveWorldMsgHandler.class), //Client Request Leave World
|
||||||
@@ -140,10 +140,10 @@ public enum Protocol {
|
|||||||
MANAGENPC(0x43A273FA, null, null), // Open Hireling Management Page
|
MANAGENPC(0x43A273FA, null, null), // Open Hireling Management Page
|
||||||
MERCHANT(0x3E645EF4, MerchantMsg.class, MerchantMsgHandler.class), // Open Teleport List, Teleport, Open Shrine, Request Boon, open/manage warehouse window
|
MERCHANT(0x3E645EF4, MerchantMsg.class, MerchantMsgHandler.class), // Open Teleport List, Teleport, Open Shrine, Request Boon, open/manage warehouse window
|
||||||
MINIONTRAINING(0xD355F528, MinionTrainingMessage.class, MinionTrainingMsgHandler.class),
|
MINIONTRAINING(0xD355F528, MinionTrainingMessage.class, MinionTrainingMsgHandler.class),
|
||||||
MODIFYGUILDSTATE(0x38936FEA, ToggleLfgRecruitingMsg.class, null), //Toggle LFGroup/LFGuild/Recruiting
|
MODIFYGUILDSTATE(0x38936FEA, ToggleLfgRecruitingMsg.class, ToggleLfgRecruitingMsgHandler.class), //Toggle LFGroup/LFGuild/Recruiting
|
||||||
MOTD(0xEC841E8D, MOTDMsg.class, MOTDEditHandler.class), //Send/Rec Guild/Nation/IC MOTD Message
|
MOTD(0xEC841E8D, MOTDMsg.class, MOTDEditHandler.class), //Send/Rec Guild/Nation/IC MOTD Message
|
||||||
MOVECORRECTION(0x47FAD1E3, null, null), //Force move to point?
|
MOVECORRECTION(0x47FAD1E3, null, null), //Force move to point?
|
||||||
MOVEOBJECTTOCONTAINER(0xD1639F7C, LootMsg.class, null), //Send/Recv MoveObjectToContainer Msg
|
MOVEOBJECTTOCONTAINER(0xD1639F7C, LootMsg.class, LootMsgHandler.class), //Send/Recv MoveObjectToContainer Msg
|
||||||
MOVETOPOINT(0x49EF7241, MoveToPointMsg.class, MoveToPointHandler.class), // Move to point
|
MOVETOPOINT(0x49EF7241, MoveToPointMsg.class, MoveToPointHandler.class), // Move to point
|
||||||
NAMEVERIFY(0x1B3BF0B1, null, null), // Invalid Name in Character Creation
|
NAMEVERIFY(0x1B3BF0B1, null, null), // Invalid Name in Character Creation
|
||||||
NEWWORLD(0x982E4A77, WorldDataMsg.class, null), // World Data
|
NEWWORLD(0x982E4A77, WorldDataMsg.class, null), // World Data
|
||||||
@@ -161,8 +161,8 @@ public enum Protocol {
|
|||||||
POWERACTION(0xA0B27EEB, ApplyEffectMsg.class, null), // Apply Effect, add to effects icons
|
POWERACTION(0xA0B27EEB, ApplyEffectMsg.class, null), // Apply Effect, add to effects icons
|
||||||
POWERACTIONDD(0xD43052F8, ModifyHealthMsg.class, null), //Modify Health/Mana/Stamina using power
|
POWERACTIONDD(0xD43052F8, ModifyHealthMsg.class, null), //Modify Health/Mana/Stamina using power
|
||||||
POWERACTIONDDDIE(0xC27D446B, null, null), //Modify Health/Mana/Stamina using power and kill target
|
POWERACTIONDDDIE(0xC27D446B, null, null), //Modify Health/Mana/Stamina using power and kill target
|
||||||
POWERTARGNAME(0x5A807CCE, SendSummonsRequestMsg.class, null), // Send Summons Request
|
POWERTARGNAME(0x5A807CCE, SendSummonsMsg.class, SendSummonsMsgHandler.class), // Send Summons Request
|
||||||
RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, null), // Modify Stat
|
RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, ModifyStatMsgHandler.class), // Modify Stat
|
||||||
RANDOM(0xAC5D0135, RandomMsg.class, RandomMsgHandler.class), //RequestSend random roll
|
RANDOM(0xAC5D0135, RandomMsg.class, RandomMsgHandler.class), //RequestSend random roll
|
||||||
READYTOENTER(0x490E4FE0, EnterWorldReceivedMsg.class, null), //Client Ack Receive Enter World
|
READYTOENTER(0x490E4FE0, EnterWorldReceivedMsg.class, null), //Client Ack Receive Enter World
|
||||||
REALMDATA(0x2399B775, null, null), //Realm Data - Optional(?)
|
REALMDATA(0x2399B775, null, null), //Realm Data - Optional(?)
|
||||||
@@ -172,15 +172,15 @@ public enum Protocol {
|
|||||||
REMOVEFRIEND(0xE0D5DB42, RemoveFriendMessage.class, RemoveFriendHandler.class),
|
REMOVEFRIEND(0xE0D5DB42, RemoveFriendMessage.class, RemoveFriendHandler.class),
|
||||||
REPAIRBUILDING(0xAF8C2560, RepairBuildingMsg.class, RepairBuildingMsgHandler.class),
|
REPAIRBUILDING(0xAF8C2560, RepairBuildingMsg.class, RepairBuildingMsgHandler.class),
|
||||||
REPAIROBJECT(0x782219CE, RepairMsg.class, RepairMsgHandler.class), //Repair Window Req/Ack, RepairObject item Req/Ack
|
REPAIROBJECT(0x782219CE, RepairMsg.class, RepairMsgHandler.class), //Repair Window Req/Ack, RepairObject item Req/Ack
|
||||||
REQUESTCONTENTS(0xA786B0A2, LootWindowRequestMsg.class, null), // MoveObjectToContainer Window Request
|
REQUESTCONTENTS(0xA786B0A2, LootWindowRequestMsg.class, LootWindowRequestMsgHandler.class), // MoveObjectToContainer Window Request
|
||||||
REQUESTGUILDLIST(0x85DCC6D7, ReqGuildListMsg.class, RequestGuildListHandler.class),
|
REQUESTGUILDLIST(0x85DCC6D7, ReqGuildListMsg.class, RequestGuildListHandler.class),
|
||||||
REQUESTMELEEATTACK(0x98C71545, AttackCmdMsg.class, AttackCmdMsgHandler.class), // Attack
|
REQUESTMELEEATTACK(0x98C71545, AttackCmdMsg.class, AttackCmdMsgHandler.class), // Attack
|
||||||
REQUESTMEMBERLIST(0x3235E5EA, GuildControlMsg.class, GuildControlHandler.class), // Part of Promote/Demote, Also Player History
|
REQUESTMEMBERLIST(0x3235E5EA, GuildControlMsg.class, GuildControlHandler.class), // Part of Promote/Demote, Also Player History
|
||||||
REQUESTTOOPENBANK(0xF26E453F, null, null), // RequestToOpenBankMsg
|
REQUESTTOOPENBANK(0xF26E453F, null, null), // RequestToOpenBankMsg
|
||||||
REQUESTTOTRADE(0x4D84259B, TradeRequestMsg.class, null), // Trade Request
|
REQUESTTOTRADE(0x4D84259B, TradeRequestMsg.class, TradeRequestMsgHandler.class), // Trade Request
|
||||||
REQUESTTRADECANCEL(0xCB0C5735, RejectTradeRequestMsg.class, null), // Reject RequestToTrade
|
REQUESTTRADECANCEL(0xCB0C5735, RejectTradeRequestMsg.class, null), // Reject RequestToTrade
|
||||||
REQUESTTRADEOK(0xFFD29841, AcceptTradeRequestMsg.class, null), // Accept Trade Request
|
REQUESTTRADEOK(0xFFD29841, AcceptTradeRequestMsg.class, AcceptTradeRequestMsgHandler.class), // Accept Trade Request
|
||||||
RESETAFTERDEATH(0xFDCBB98F, RespawnMsg.class, null), //Respawn Request/Response
|
RESETAFTERDEATH(0xFDCBB98F, RespawnMsg.class, RespawnMsgHandler.class), //Respawn Request/Response
|
||||||
ROTATEMSG(0x57F2088E, RotateObjectMsg.class, null),
|
ROTATEMSG(0x57F2088E, RotateObjectMsg.class, null),
|
||||||
SAFEMODE(0x9CF3922A, SafeModeMsg.class, null), //Tell client they're in safe mode
|
SAFEMODE(0x9CF3922A, SafeModeMsg.class, null), //Tell client they're in safe mode
|
||||||
SCALEOBJECT(0xE2B392D9, null, null), // Adjust scale of object
|
SCALEOBJECT(0xE2B392D9, null, null), // Adjust scale of object
|
||||||
@@ -196,11 +196,11 @@ public enum Protocol {
|
|||||||
SETOBJVAL(0x08A50FD1, null, null),
|
SETOBJVAL(0x08A50FD1, null, null),
|
||||||
SETRUNE(0x888E7C64, ApplyRuneMsg.class, null), //Apply Promotion, Stat Rune (maybe disc also)
|
SETRUNE(0x888E7C64, ApplyRuneMsg.class, null), //Apply Promotion, Stat Rune (maybe disc also)
|
||||||
TARGETOBJECT(0x64E10938, TargetObjectMsg.class, TargetObjectMsgHandler.class), // Target an object
|
TARGETOBJECT(0x64E10938, TargetObjectMsg.class, TargetObjectMsgHandler.class), // Target an object
|
||||||
SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, null), // Request/Response /show
|
SHOWCOMBATINFO(0x9BF1E5EA, ShowMsg.class, ShowMsgHandler.class), // Request/Response /show
|
||||||
SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory
|
SHOWVAULTINVENTORY(0xD1FB4842, null, null), // Show Vault Inventory
|
||||||
SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, SocialMsgHandler.class), // Socials
|
SOCIALCHANNEL(0x2BF58FA6, SocialMsg.class, SocialMsgHandler.class), // Socials
|
||||||
STANDARDALERT(0xFA0A24BB, ErrorPopupMsg.class, null), //Popup messages
|
STANDARDALERT(0xFA0A24BB, ErrorPopupMsg.class, null), //Popup messages
|
||||||
STUCK(0x3D04AF3A, StuckCommandMsg.class, null), // /Stuck Command
|
STUCK(0x3D04AF3A, StuckMsg.class, StuckMsgHandler.class), // /Stuck Command
|
||||||
SWEARINGUILD(0x389B66B1, SwearInGuildMsg.class, SwearInGuildHandler.class),
|
SWEARINGUILD(0x389B66B1, SwearInGuildMsg.class, SwearInGuildHandler.class),
|
||||||
SYNC(0x49ec109f, null, null), //Client/Server loc sync
|
SYNC(0x49ec109f, null, null), //Client/Server loc sync
|
||||||
SYSTEMBROADCASTCHANNEL(0x2FAD89D1, ChatSystemMsg.class, null), // Chat Channel: System Message
|
SYSTEMBROADCASTCHANNEL(0x2FAD89D1, ChatSystemMsg.class, null), // Chat Channel: System Message
|
||||||
@@ -210,14 +210,14 @@ public enum Protocol {
|
|||||||
TAXRESOURCES(0x4AD458AF, TaxResourcesMsg.class, TaxResourcesMsgHandler.class),
|
TAXRESOURCES(0x4AD458AF, TaxResourcesMsg.class, TaxResourcesMsgHandler.class),
|
||||||
TELEPORT(0x23E726EA, TeleportToPointMsg.class, null), // Teleport to point
|
TELEPORT(0x23E726EA, TeleportToPointMsg.class, null), // Teleport to point
|
||||||
TERRITORYCHANGE(0x6B388C8C, TerritoryChangeMessage.class, null), //Hey rich, look what I found? :)
|
TERRITORYCHANGE(0x6B388C8C, TerritoryChangeMessage.class, null), //Hey rich, look what I found? :)
|
||||||
TOGGLESITSTAND(0x624F3C0F, ToggleSitStandMsg.class, null), //Toggle Sit/Stand
|
TOGGLESITSTAND(0x624F3C0F, ToggleSitStandMsg.class, ToggleSitStandMsgHandler.class), //Toggle Sit/Stand
|
||||||
TRADEADDGOLD(0x654ACB45, AddGoldToTradeWindowMsg.class, null), // Add Gold to Trade Window
|
TRADEADDGOLD(0x654ACB45, AddGoldToTradeWindowMsg.class, AddGoldToTradeWindowMsgHandler.class), // Add Gold to Trade Window
|
||||||
TRADEADDOBJECT(0x55D363E9, AddItemToTradeWindowMsg.class, null), // Add an Item to the Trade Window
|
TRADEADDOBJECT(0x55D363E9, AddItemToTradeWindowMsg.class, AddItemToTradeWindowMsgHandler.class), // Add an Item to the Trade Window
|
||||||
TRADECLOSE(0x5008D7FC, CloseTradeWindowMsg.class, null), // Cancel trade/ACK trade complete
|
TRADECLOSE(0x5008D7FC, CloseTradeWindowMsg.class, CloseTradeWindowMsgHandler.class), // Cancel trade/ACK trade complete
|
||||||
TRADECONFIRM(0x6911E65E, CommitToTradeMsg.class, null), // Commit to trade
|
TRADECONFIRM(0x6911E65E, CommitToTradeMsg.class, CommitToTradeMsgHandler.class), // Commit to trade
|
||||||
TRADECONFIRMSTATUS(0x9F85DAFC, null, null), // Other player commit/uncommit/add item
|
TRADECONFIRMSTATUS(0x9F85DAFC, null, null), // Other player commit/uncommit/add item
|
||||||
TRADEUNCONFIRM(0xEBE280E0, UncommitToTradeMsg.class, null), // Uncommit to trade
|
TRADEUNCONFIRM(0xEBE280E0, UncommitToTradeMsg.class, UncommitToTradeMsgHandler.class), // Uncommit to trade
|
||||||
TRAINERLIST(0x41FABA62, TrainerInfoMsg.class, null), //Req/Send Trainer Info/Pricing
|
TRAINERLIST(0x41FABA62, TrainerInfoMsg.class, TrainerInfoMsgHandler.class), //Req/Send Trainer Info/Pricing
|
||||||
TRAINSKILL(0xB0BF68CD, TrainMsg.class, TrainMsgHandler.class), //Train skills/powers
|
TRAINSKILL(0xB0BF68CD, TrainMsg.class, TrainMsgHandler.class), //Train skills/powers
|
||||||
TRANSFERASSET(0x3EA1C4C9, TransferAssetMsg.class, TransferAssetMsgHandler.class), // Transfer Building
|
TRANSFERASSET(0x3EA1C4C9, TransferAssetMsg.class, TransferAssetMsgHandler.class), // Transfer Building
|
||||||
TRANSFERGOLDTOFROMBUILDING(0x1B1AC8C7, TransferGoldToFromBuildingMsg.class, TransferGoldToFromBuildingMsgHandler.class), // Transfer Gold to/From Building, Transfer Error
|
TRANSFERGOLDTOFROMBUILDING(0x1B1AC8C7, TransferGoldToFromBuildingMsg.class, TransferGoldToFromBuildingMsgHandler.class), // Transfer Gold to/From Building, Transfer Error
|
||||||
@@ -241,7 +241,7 @@ public enum Protocol {
|
|||||||
VENDORSELLWINDOW(0x267DAB90, VendorSellWindowMsg.class, VendorSellWindowMsgHandler.class), //open Sell to NPC Window
|
VENDORSELLWINDOW(0x267DAB90, VendorSellWindowMsg.class, VendorSellWindowMsgHandler.class), //open Sell to NPC Window
|
||||||
VENDORBUYWINDOW(0x682DAB4D, VendorBuyWindowMsg.class, VendorBuyWindowMsgHandler.class), // Open Buy From NPC Window
|
VENDORBUYWINDOW(0x682DAB4D, VendorBuyWindowMsg.class, VendorBuyWindowMsgHandler.class), // Open Buy From NPC Window
|
||||||
VERSIONINFO(0x4B7EE463, VersionInfoMsg.class, null), // Version Information
|
VERSIONINFO(0x4B7EE463, VersionInfoMsg.class, null), // Version Information
|
||||||
VIEWRESOURCES(0xCEFD0346, ViewResourcesMessage.class, null),
|
VIEWRESOURCES(0xCEFD0346, ViewResourcesMsg.class, ViewResourcesMsgHandler.class),
|
||||||
VISUALUPDATE(0x33402fd2, null, null),
|
VISUALUPDATE(0x33402fd2, null, null),
|
||||||
WEIGHTINVENTORY(0xF1B6A85C, LootWindowResponseMsg.class, null), // MoveObjectToContainer Window Response
|
WEIGHTINVENTORY(0xF1B6A85C, LootWindowResponseMsg.class, null), // MoveObjectToContainer Window Response
|
||||||
WHOREQUEST(0xF431CCE9, WhoRequestMsg.class, WhoRequestMsgHandler.class), // Request /who
|
WHOREQUEST(0xF431CCE9, WhoRequestMsg.class, WhoRequestMsgHandler.class), // Request /who
|
||||||
@@ -286,6 +286,35 @@ public enum Protocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean handleClientMsg(ClientNetMsg msg) {
|
||||||
|
|
||||||
|
if (msg == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Protocol protocol = msg.getProtocolMsg();
|
||||||
|
|
||||||
|
// Unhandled opcode
|
||||||
|
|
||||||
|
if (protocol == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
AbstractClientMsgHandler msgHandler = protocol.handler;
|
||||||
|
|
||||||
|
// Eat this message; no or empty handler
|
||||||
|
|
||||||
|
if (msgHandler == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error("handler for " + msg.getProtocolMsg() + " failed: " + e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static Protocol getByOpcode(int opcode) {
|
public static Protocol getByOpcode(int opcode) {
|
||||||
|
|
||||||
Protocol protocol = _protocolMsgByOpcode.get(opcode);
|
Protocol protocol = _protocolMsgByOpcode.get(opcode);
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.Protocol;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.chat.*;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
import static engine.gameManager.ChatManager.FLOOD_QTY_THRESHOLD;
|
||||||
|
import static engine.gameManager.ChatManager.FLOOD_TIME_THRESHOLD;
|
||||||
|
|
||||||
|
public class AbstractChatMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public AbstractChatMsgHandler() {
|
||||||
|
super(AbstractChatMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
AbstractChatMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (AbstractChatMsg) baseMsg;
|
||||||
|
|
||||||
|
if (msg == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Protocol protocolMsg = msg.getProtocolMsg();
|
||||||
|
|
||||||
|
// Flood control, implemented per channel
|
||||||
|
|
||||||
|
boolean isFlood = false;
|
||||||
|
long curMsgTime = System.currentTimeMillis();
|
||||||
|
long checkTime = playerCharacter.chatFloodTime(protocolMsg.opcode, curMsgTime, FLOOD_QTY_THRESHOLD - 1);
|
||||||
|
|
||||||
|
if ((checkTime > 0L) && (curMsgTime - checkTime < FLOOD_TIME_THRESHOLD))
|
||||||
|
isFlood = true;
|
||||||
|
|
||||||
|
switch (protocolMsg) {
|
||||||
|
case CHATSAY:
|
||||||
|
ChatManager.chatSay(playerCharacter, msg.getMessage(), isFlood);
|
||||||
|
return true;
|
||||||
|
case CHATCSR:
|
||||||
|
ChatManager.chatCSR(msg);
|
||||||
|
return true;
|
||||||
|
case CHATTELL:
|
||||||
|
ChatTellMsg ctm = (ChatTellMsg) msg;
|
||||||
|
ChatManager.chatTell(playerCharacter, ctm.getTargetName(), ctm.getMessage(), isFlood);
|
||||||
|
return true;
|
||||||
|
case CHATSHOUT:
|
||||||
|
ChatManager.chatShout(playerCharacter, msg.getMessage(), isFlood);
|
||||||
|
return true;
|
||||||
|
case CHATGUILD:
|
||||||
|
ChatManager.chatGuild(playerCharacter, (ChatGuildMsg) msg);
|
||||||
|
return true;
|
||||||
|
case CHATGROUP:
|
||||||
|
ChatManager.chatGroup(playerCharacter, (ChatGroupMsg) msg);
|
||||||
|
return true;
|
||||||
|
case CHATIC:
|
||||||
|
ChatManager.chatIC(playerCharacter, (ChatICMsg) msg);
|
||||||
|
return true;
|
||||||
|
case LEADERCHANNELMESSAGE:
|
||||||
|
case GLOBALCHANNELMESSAGE:
|
||||||
|
ChatManager.chatGlobal(playerCharacter, msg.getMessage(), isFlood);
|
||||||
|
return true;
|
||||||
|
case CHATPVP:
|
||||||
|
case CHATCITY:
|
||||||
|
case CHATINFO:
|
||||||
|
case SYSTEMBROADCASTCHANNEL:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.AcceptTradeRequestMsg;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.OpenTradeWindowMsg;
|
||||||
|
import engine.net.client.msg.UpdateVaultMsg;
|
||||||
|
import engine.objects.Account;
|
||||||
|
import engine.objects.CharacterItemManager;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
|
||||||
|
import static engine.math.FastMath.sqr;
|
||||||
|
import static engine.objects.CharacterItemManager.canTrade;
|
||||||
|
|
||||||
|
public class AcceptTradeRequestMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public AcceptTradeRequestMsgHandler() {
|
||||||
|
super(AcceptTradeRequestMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
AcceptTradeRequestMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (AcceptTradeRequestMsg) baseMsg;
|
||||||
|
|
||||||
|
PlayerCharacter source = (PlayerCharacter) origin.getPlayerCharacter();
|
||||||
|
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID());
|
||||||
|
|
||||||
|
Dispatch dispatch;
|
||||||
|
|
||||||
|
if (source == null || !source.isAlive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (target == null || !target.isAlive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (source.charItemManager.tradingWith != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!canTrade(source, target))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// verify characterTarget is in range
|
||||||
|
if (source.getLoc().distanceSquared2D(target.getLoc()) > sqr(MBServerStatics.TRADE_RANGE))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// TODO uncomment this block after we determine when we
|
||||||
|
// setBankOpen(false) and setVaultOpen(false)
|
||||||
|
/*
|
||||||
|
* CharacterItemManager cim1 = source.getCharItemManager();
|
||||||
|
* CharacterItemManager cim2 = characterTarget.getCharItemManager(); if (cim1 ==
|
||||||
|
* null) return false; if (cim2 == null) return false; if (cim1.isBankOpen())
|
||||||
|
* return false; if (cim2.isVaultOpen()) return false;
|
||||||
|
*/
|
||||||
|
ClientConnection sourceConn = origin;
|
||||||
|
ClientConnection targetConn = target.getClientConnection();
|
||||||
|
|
||||||
|
if (sourceConn == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (targetConn == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CharacterItemManager toTradeWith = target.charItemManager;
|
||||||
|
|
||||||
|
if (toTradeWith == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Account sourceAccount = source.getAccount();
|
||||||
|
Account targetAccount = target.getAccount();
|
||||||
|
|
||||||
|
UpdateVaultMsg uvmSource = new UpdateVaultMsg(sourceAccount);
|
||||||
|
UpdateVaultMsg uvmTarget = new UpdateVaultMsg(targetAccount);
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(source, uvmSource);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(target, uvmTarget);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
source.charItemManager.setVaultOpen(false);
|
||||||
|
toTradeWith.setVaultOpen(false);
|
||||||
|
source.charItemManager.setBankOpen(false);
|
||||||
|
toTradeWith.setBankOpen(false);
|
||||||
|
|
||||||
|
OpenTradeWindowMsg otwm = new OpenTradeWindowMsg(msg.getUnknown01(), source, target);
|
||||||
|
|
||||||
|
// Only start trade if both players aren't already trading with
|
||||||
|
// someone
|
||||||
|
|
||||||
|
if (source.charItemManager.tradingWith != null || toTradeWith.getTradingWith() != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
source.charItemManager.initializeTrade();
|
||||||
|
toTradeWith.initializeTrade();
|
||||||
|
source.charItemManager.setTradingWith(targetConn);
|
||||||
|
toTradeWith.setTradingWith(sourceConn);
|
||||||
|
source.charItemManager.tradeID = msg.getUnknown01();
|
||||||
|
toTradeWith.tradeID = msg.getUnknown01();
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(source, otwm);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(target, otwm);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.AddGoldToTradeWindowMsg;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.UpdateGoldMsg;
|
||||||
|
import engine.net.client.msg.UpdateTradeWindowMsg;
|
||||||
|
import engine.objects.CharacterItemManager;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import static engine.objects.CharacterItemManager.canTrade;
|
||||||
|
|
||||||
|
public class AddGoldToTradeWindowMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public AddGoldToTradeWindowMsgHandler() {
|
||||||
|
super(AddGoldToTradeWindowMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter source = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
AddGoldToTradeWindowMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (AddGoldToTradeWindowMsg) baseMsg;
|
||||||
|
Dispatch dispatch;
|
||||||
|
|
||||||
|
if (source == null || !source.isAlive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ClientConnection ccOther = source.charItemManager.tradingWith;
|
||||||
|
|
||||||
|
if (ccOther == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
PlayerCharacter other = ccOther.getPlayerCharacter();
|
||||||
|
|
||||||
|
if (other == null || !other.isAlive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CharacterItemManager tradingWith = other.charItemManager;
|
||||||
|
|
||||||
|
if (tradingWith == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(other, source);
|
||||||
|
UpdateTradeWindowMsg utwmOther = new UpdateTradeWindowMsg(source, other);
|
||||||
|
|
||||||
|
if (!canTrade(source, other))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
source.charItemManager.setTradeCommitted((byte) 0);
|
||||||
|
tradingWith.setTradeCommitted((byte) 0);
|
||||||
|
|
||||||
|
int amt = msg.getAmount();
|
||||||
|
|
||||||
|
if (amt <= 0) {
|
||||||
|
Logger.info(source.getFirstName() + " added negative gold to trade window. Dupe attempt FAILED!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amt > MBServerStatics.PLAYER_GOLD_LIMIT)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (source.charItemManager.getGoldInventory().getNumOfItems() - amt < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
source.charItemManager.addGoldToTrade(amt);
|
||||||
|
|
||||||
|
// BONUS CODE BELOW: Thanks some unknown retard!
|
||||||
|
// sourceItemMan.updateInventory(sourceItemMan.getInventory(), true);
|
||||||
|
|
||||||
|
UpdateGoldMsg ugm = new UpdateGoldMsg(source);
|
||||||
|
ugm.configure();
|
||||||
|
|
||||||
|
source.charItemManager.modifyCommitToTrade();
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(source, utwm);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(source, ugm);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(other, utwmOther);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.AddItemToTradeWindowMsg;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.UpdateTradeWindowMsg;
|
||||||
|
import engine.objects.CharacterItemManager;
|
||||||
|
import engine.objects.Item;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
import static engine.objects.CharacterItemManager.canTrade;
|
||||||
|
|
||||||
|
public class AddItemToTradeWindowMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public AddItemToTradeWindowMsgHandler() {
|
||||||
|
super(AddItemToTradeWindowMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
AddItemToTradeWindowMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (AddItemToTradeWindowMsg) baseMsg;
|
||||||
|
|
||||||
|
PlayerCharacter source = origin.getPlayerCharacter();
|
||||||
|
Dispatch dispatch;
|
||||||
|
|
||||||
|
if (source == null || !source.isAlive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ClientConnection ccOther = source.charItemManager.tradingWith;
|
||||||
|
|
||||||
|
if (ccOther == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
PlayerCharacter other = ccOther.getPlayerCharacter();
|
||||||
|
|
||||||
|
if (other == null || !other.isAlive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CharacterItemManager tradingWith = other.charItemManager;
|
||||||
|
|
||||||
|
if (tradingWith == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!canTrade(source, other))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Item item = Item.getFromCache(msg.getItemID());
|
||||||
|
|
||||||
|
if (item == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!source.charItemManager.doesCharOwnThisItem(item.getObjectUUID()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//can't add item to trade window twice
|
||||||
|
if (source.charItemManager.tradingContains(item))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//dupe check
|
||||||
|
if (!item.validForInventory(source.getClientConnection(), source, source.charItemManager))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!tradingWith.hasRoomTrade(item.template.item_wt)) {
|
||||||
|
dispatch = Dispatch.borrow(source, msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(source, other);
|
||||||
|
|
||||||
|
source.charItemManager.setTradeCommitted((byte) 0);
|
||||||
|
tradingWith.setTradeCommitted((byte) 0);
|
||||||
|
|
||||||
|
source.charItemManager.addItemToTrade(item);
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(other, msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
source.charItemManager.modifyCommitToTrade();
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(other, utwm);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,7 +8,10 @@ import engine.gameManager.ZoneManager;
|
|||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.*;
|
import engine.net.client.msg.CityDataMsg;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.HotzoneChangeMsg;
|
||||||
|
import engine.net.client.msg.WorldRealmMsg;
|
||||||
import engine.objects.City;
|
import engine.objects.City;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
import engine.session.Session;
|
import engine.session.Session;
|
||||||
@@ -22,7 +25,7 @@ import engine.session.Session;
|
|||||||
public class CityDataHandler extends AbstractClientMsgHandler {
|
public class CityDataHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
public CityDataHandler() {
|
public CityDataHandler() {
|
||||||
super(KeepAliveServerClientMsg.class);
|
super(CityDataMsg.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.DevCmdManager;
|
||||||
|
import engine.gameManager.SessionManager;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.commands.ClientAdminCommandMsg;
|
||||||
|
import engine.objects.AbstractGameObject;
|
||||||
|
import engine.objects.AbstractWorldObject;
|
||||||
|
import engine.objects.Account;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
public class ClientAdminCommandMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public ClientAdminCommandMsgHandler() {
|
||||||
|
super(ClientAdminCommandMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean processDevCommand(AbstractWorldObject sender, String text) {
|
||||||
|
|
||||||
|
if (sender.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||||
|
|
||||||
|
PlayerCharacter pcSender = (PlayerCharacter) sender;
|
||||||
|
|
||||||
|
// first remove the DEV_CMD_PREFIX
|
||||||
|
String[] words = text.split(MBServerStatics.DEV_CMD_PREFIX, 2);
|
||||||
|
|
||||||
|
if (words[1].length() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// next get the command
|
||||||
|
String[] commands = words[1].split(" ", 2);
|
||||||
|
String cmd = commands[0].toLowerCase();
|
||||||
|
String cmdArgument = "";
|
||||||
|
|
||||||
|
if (commands.length > 1)
|
||||||
|
cmdArgument = commands[1].trim();
|
||||||
|
|
||||||
|
AbstractGameObject target = pcSender.getLastTarget();
|
||||||
|
// return DevCmd.processDevCommand(pcSender, cmd, cmdArgument,
|
||||||
|
// target);
|
||||||
|
return DevCmdManager.handleDevCmd(pcSender, cmd,
|
||||||
|
cmdArgument, target);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter player = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
ClientAdminCommandMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (ClientAdminCommandMsg) baseMsg;
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Account acct = SessionManager.getAccount(player);
|
||||||
|
|
||||||
|
if (acct == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// require minimal access to continue
|
||||||
|
// specific accessLevel checks performed by the DevCmdManager
|
||||||
|
if (acct.status.equals(Enum.AccountStatus.ADMIN) == false) {
|
||||||
|
Logger.warn(player.getFirstName() + " Attempted to use a client admin command");
|
||||||
|
//wtf? ChatManager.chatSystemInfo(pcSender, "CHEATER!!!!!!!!!!!!!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// First remove the initial slash
|
||||||
|
String d = msg.getMsgCommand();
|
||||||
|
String[] words = d.split("/", 2);
|
||||||
|
|
||||||
|
if (words[1].length() == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Next get the command
|
||||||
|
String[] commands = words[1].split(" ", 2);
|
||||||
|
String cmd = commands[0].toLowerCase();
|
||||||
|
String cmdArgument = "";
|
||||||
|
|
||||||
|
if (commands.length > 1)
|
||||||
|
cmdArgument = commands[1].trim();
|
||||||
|
|
||||||
|
AbstractGameObject target = msg.getTarget();
|
||||||
|
|
||||||
|
// Map to a DevCmd
|
||||||
|
String devCmd = "";
|
||||||
|
|
||||||
|
if (cmd.compareTo("goto") == 0)
|
||||||
|
devCmd = "goto";
|
||||||
|
else if (cmd.compareTo("suspend") == 0)
|
||||||
|
devCmd = "suspend";
|
||||||
|
else if (cmd.compareTo("getinfo") == 0)
|
||||||
|
devCmd = "info";
|
||||||
|
else if (devCmd.isEmpty()) {
|
||||||
|
Logger.info("Unhandled admin command was used: /"
|
||||||
|
+ cmd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DevCmdManager.handleDevCmd(player, devCmd, cmdArgument,
|
||||||
|
target);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.CloseTradeWindowMsg;
|
||||||
|
import engine.objects.CharacterItemManager;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class CloseTradeWindowMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public CloseTradeWindowMsgHandler() {
|
||||||
|
super(CloseTradeWindowMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter source = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
CloseTradeWindowMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (CloseTradeWindowMsg) baseMsg;
|
||||||
|
|
||||||
|
Dispatch dispatch;
|
||||||
|
|
||||||
|
if (source == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CharacterItemManager sourceItemMan = source.charItemManager;
|
||||||
|
|
||||||
|
if (sourceItemMan == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int tradeID = source.charItemManager.tradeID;
|
||||||
|
CloseTradeWindowMsg closeMsg = new CloseTradeWindowMsg(source, tradeID);
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(source, closeMsg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
ClientConnection cc2 = sourceItemMan.getTradingWith();
|
||||||
|
|
||||||
|
if (cc2 == null || cc2.getPlayerCharacter() == null) {
|
||||||
|
sourceItemMan.endTrade();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceItemMan.endTrade();
|
||||||
|
cc2.getPlayerCharacter().charItemManager.closeTradeWindow(msg, false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.CloseTradeWindowMsg;
|
||||||
|
import engine.net.client.msg.CommitToTradeMsg;
|
||||||
|
import engine.objects.CharacterItemManager;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
import static engine.objects.CharacterItemManager.canTrade;
|
||||||
|
|
||||||
|
public class CommitToTradeMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public CommitToTradeMsgHandler() {
|
||||||
|
super(CommitToTradeMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter source = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
CommitToTradeMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (CommitToTradeMsg) baseMsg;
|
||||||
|
|
||||||
|
if (source == null || !source.isAlive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
source.charItemManager.setTradeCommitted((byte) 1);
|
||||||
|
|
||||||
|
ClientConnection ccOther = source.charItemManager.tradingWith;
|
||||||
|
|
||||||
|
if (ccOther == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
PlayerCharacter other = ccOther.getPlayerCharacter();
|
||||||
|
|
||||||
|
if (other == null || !other.isAlive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CharacterItemManager tradingWith = other.charItemManager;
|
||||||
|
|
||||||
|
if (tradingWith == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!canTrade(source, other))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
source.charItemManager.modifyCommitToTrade();
|
||||||
|
|
||||||
|
if (source.charItemManager.getTradeCommitted() == (byte) 1 && tradingWith.getTradeCommitted() == (byte) 1) {
|
||||||
|
int tradeID = source.charItemManager.tradeID;
|
||||||
|
CloseTradeWindowMsg ctwm1 = new CloseTradeWindowMsg(source, tradeID);
|
||||||
|
CloseTradeWindowMsg ctwm2 = new CloseTradeWindowMsg(other, tradeID);
|
||||||
|
source.charItemManager.commitTrade();
|
||||||
|
source.charItemManager.closeTradeWindow(ctwm1, false);
|
||||||
|
other.charItemManager.closeTradeWindow(ctwm2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum.DispatchChannel;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.DeleteItemMsg;
|
||||||
|
import engine.objects.CharacterItemManager;
|
||||||
|
import engine.objects.Item;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class DeleteItemMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public DeleteItemMsgHandler() {
|
||||||
|
super(DeleteItemMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter player = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
DeleteItemMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (DeleteItemMsg) baseMsg;
|
||||||
|
CharacterItemManager itemManager = origin.getPlayerCharacter().charItemManager;
|
||||||
|
int uuid = msg.getUUID();
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!player.isAlive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Item item = Item.getFromCache(msg.getUUID());
|
||||||
|
|
||||||
|
if (item == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!itemManager.doesCharOwnThisItem(item.getObjectUUID()))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!itemManager.inventoryContains(item))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (item.isCanDestroy())
|
||||||
|
if (itemManager.delete(item) == true) {
|
||||||
|
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.gameManager.DbManager;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.IgnoreMsg;
|
||||||
|
import engine.objects.Account;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class IgnoreMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public IgnoreMsgHandler() {
|
||||||
|
super(IgnoreMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
IgnoreMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (IgnoreMsg) baseMsg;
|
||||||
|
|
||||||
|
if (msg.nameToIgnore.isEmpty()) { // list ignored players
|
||||||
|
String[] ignoredPlayers = playerCharacter.getIgnoredPlayerNames();
|
||||||
|
String crlf = "\r\n";
|
||||||
|
String out = "Ignored players (" + ignoredPlayers.length + "):";
|
||||||
|
|
||||||
|
for (String name : ignoredPlayers)
|
||||||
|
out += crlf + name;
|
||||||
|
|
||||||
|
ChatManager.chatSystemInfo(playerCharacter, out);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//FIX THIS, USE OUR CACHE!
|
||||||
|
PlayerCharacter pcToIgnore = PlayerCharacter.getByFirstName(msg.nameToIgnore);
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
if (pcToIgnore == null || pcToIgnore.getAccount() == null) {
|
||||||
|
ChatManager.chatSystemError(playerCharacter, "Character name " + msg.nameToIgnore + " does not exist and cannot be ignored.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (pcToIgnore.getObjectUUID() == playerCharacter.getObjectUUID()) {
|
||||||
|
ChatManager.chatSystemError(playerCharacter, "Try as you might, you are unable to ignore yourself!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String firstName = pcToIgnore.getFirstName();
|
||||||
|
|
||||||
|
Account account = playerCharacter.getAccount();
|
||||||
|
|
||||||
|
if (account == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (playerCharacter.isIgnoringPlayer(pcToIgnore)) {
|
||||||
|
|
||||||
|
if (account != null) {
|
||||||
|
if (!DbManager.PlayerCharacterQueries.SET_IGNORE_LIST(account.getObjectUUID(), pcToIgnore.getObjectUUID(), false, pcToIgnore.getFirstName())) {
|
||||||
|
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list.");
|
||||||
|
}
|
||||||
|
|
||||||
|
playerCharacter.removeIgnoredPlayer(pcToIgnore.getAccount());
|
||||||
|
ChatManager.chatSystemInfo(playerCharacter, "Character " + firstName + " is no longer ignored.");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (!PlayerCharacter.isIgnorable()) {
|
||||||
|
ChatManager.chatSystemError(playerCharacter, "This character cannot be ignored.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PlayerCharacter.isIgnoreListFull()) {
|
||||||
|
ChatManager.chatSystemError(playerCharacter, "Your ignore list is already full.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account != null) {
|
||||||
|
if (!DbManager.PlayerCharacterQueries.SET_IGNORE_LIST(account.getObjectUUID(), pcToIgnore.getObjectUUID(), true, pcToIgnore.getFirstName())) {
|
||||||
|
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list. This ignore will not persist past server down.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ChatManager.chatSystemError(playerCharacter, "Unable to update database ignore list.");
|
||||||
|
}
|
||||||
|
|
||||||
|
playerCharacter.addIgnoredPlayer(pcToIgnore.getAccount(), pcToIgnore.getFirstName());
|
||||||
|
ChatManager.chatSystemInfo(playerCharacter, "Character " + firstName + " is now being ignored.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.InvalidTradeRequestMsg;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class InvalidTradeRequestMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public InvalidTradeRequestMsgHandler() {
|
||||||
|
super(InvalidTradeRequestMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
InvalidTradeRequestMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (InvalidTradeRequestMsg) baseMsg;
|
||||||
|
|
||||||
|
Dispatch dispatch;
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,8 +26,7 @@ public class KeepAliveServerClientHandler extends AbstractClientMsgHandler {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
|
||||||
// Member variable declaration
|
// Member variable declaration
|
||||||
|
|
||||||
@@ -37,10 +36,9 @@ public class KeepAliveServerClientHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
msg = (KeepAliveServerClientMsg) baseMsg;
|
msg = (KeepAliveServerClientMsg) baseMsg;
|
||||||
|
|
||||||
|
|
||||||
// Send ping to client
|
// Send ping to client
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(pc, msg);
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -0,0 +1,260 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.Enum.DispatchChannel;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.gameManager.GroupManager;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.*;
|
||||||
|
import engine.objects.*;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import static engine.math.FastMath.sqr;
|
||||||
|
|
||||||
|
public class LootMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public LootMsgHandler() {
|
||||||
|
super(LootMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter player = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
LootMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (LootMsg) baseMsg;
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!player.isAlive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Item item = msg.getItem();
|
||||||
|
|
||||||
|
if (item == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (item.lootLock.tryLock()) {
|
||||||
|
try {
|
||||||
|
Item itemRet = null;
|
||||||
|
// get current owner
|
||||||
|
int targetType = msg.getTargetType();
|
||||||
|
int targetID = msg.getTargetID();
|
||||||
|
|
||||||
|
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal() || targetType == Enum.GameObjectType.Mob.ordinal() || targetType == Enum.GameObjectType.Corpse.ordinal()) {
|
||||||
|
} else { //needed for getting contracts for some reason
|
||||||
|
targetType = msg.getSourceID2();
|
||||||
|
targetID = msg.getUnknown01();
|
||||||
|
}
|
||||||
|
|
||||||
|
//can't loot while flying
|
||||||
|
if (player.getAltitude() > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
AbstractCharacter tar = null;
|
||||||
|
Corpse corpse = null;
|
||||||
|
|
||||||
|
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal() || targetType == Enum.GameObjectType.Mob.ordinal()) {
|
||||||
|
|
||||||
|
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal()) {
|
||||||
|
tar = PlayerCharacter.getFromCache(targetID);
|
||||||
|
|
||||||
|
if (tar == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (player.getObjectUUID() != tar.getObjectUUID() && ((PlayerCharacter) tar).isInSafeZone())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else if (targetType == Enum.GameObjectType.NPC.ordinal())
|
||||||
|
tar = NPC.getFromCache(targetID);
|
||||||
|
else if (targetType == Enum.GameObjectType.Mob.ordinal())
|
||||||
|
tar = Mob.getFromCache(targetID);
|
||||||
|
|
||||||
|
if (tar == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (tar.equals(player)) {
|
||||||
|
ErrorPopupMsg.sendErrorMsg(player, "Cannot loot this item.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.getLoc().distanceSquared2D(tar.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
||||||
|
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse.");
|
||||||
|
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(tar.getLoc()) + " distance.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//can't loot from someone who is alive.
|
||||||
|
if (AbstractWorldObject.IsAbstractCharacter(tar)) {
|
||||||
|
if (tar.isAlive())
|
||||||
|
return true;
|
||||||
|
// Logger.error("WorldServer.loot", "Looting from live player");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GroupManager.goldSplit(player, item, origin, tar)) {
|
||||||
|
|
||||||
|
if (tar.charItemManager != null) {
|
||||||
|
|
||||||
|
itemRet = tar.charItemManager.lootItemFromMe(item, player, origin);
|
||||||
|
|
||||||
|
//Take equipment off mob
|
||||||
|
if (tar.getObjectType() == Enum.GameObjectType.Mob && itemRet != null) {
|
||||||
|
Mob mobTarget = (Mob) tar;
|
||||||
|
|
||||||
|
if (item != null && item.getObjectType() == Enum.GameObjectType.MobLoot) {
|
||||||
|
|
||||||
|
for (Item equip : mobTarget.charItemManager.equipped.values()) {
|
||||||
|
|
||||||
|
TransferItemFromEquipToInventoryMsg back = new TransferItemFromEquipToInventoryMsg(mobTarget, equip.equipSlot);
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(mobTarget, back, DispatchChannel.SECONDARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||||
|
|
||||||
|
LootMsg lootMsg = new LootMsg(0, 0, tar.getObjectType().ordinal(), tar.getObjectUUID(), equip);
|
||||||
|
Dispatch dispatch = Dispatch.borrow(player, lootMsg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (targetType == Enum.GameObjectType.Corpse.ordinal()) {
|
||||||
|
corpse = Corpse.getCorpse(targetID);
|
||||||
|
|
||||||
|
if (corpse == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (player.getLoc().distanceSquared2D(corpse.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
||||||
|
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse.");
|
||||||
|
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(corpse.getLoc()) + " distance.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//can't loot other players in safe zone.
|
||||||
|
if (corpse.getBelongsToType() == Enum.GameObjectType.PlayerCharacter.ordinal()) {
|
||||||
|
|
||||||
|
if (player.getObjectUUID() == corpse.getBelongsToID())
|
||||||
|
itemRet = corpse.lootItem(item, player);
|
||||||
|
else if (!GroupManager.goldSplit(player, item, origin, corpse)) {
|
||||||
|
itemRet = corpse.lootItem(item, player);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemRet == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) {
|
||||||
|
// this is done to prevent the temporary goldItem item
|
||||||
|
// (from the mob) from appearing in player's inventory.
|
||||||
|
// It also updates the goldItem quantity display
|
||||||
|
UpdateGoldMsg updateTargetGold = null;
|
||||||
|
|
||||||
|
if (corpse != null)
|
||||||
|
updateTargetGold = new UpdateGoldMsg(corpse);
|
||||||
|
|
||||||
|
updateTargetGold.configure();
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(corpse, updateTargetGold, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||||
|
|
||||||
|
UpdateGoldMsg ugm = new UpdateGoldMsg(player);
|
||||||
|
ugm.configure();
|
||||||
|
Dispatch dispatch = Dispatch.borrow(player, ugm);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
// respond back loot message. Try sending to everyone.
|
||||||
|
|
||||||
|
} else
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(corpse, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, true);
|
||||||
|
|
||||||
|
|
||||||
|
//TODO send group loot message if player is grouped and visible
|
||||||
|
Group group = GroupManager.getGroup(player);
|
||||||
|
|
||||||
|
if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) {
|
||||||
|
String name = item.getName();
|
||||||
|
String text = player.getFirstName() + " has looted " + name + '.';
|
||||||
|
ChatManager.chatGroupInfoCanSee(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (itemRet == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) {
|
||||||
|
// this is done to prevent the temporary goldItem item
|
||||||
|
// (from the mob) from appearing in player's inventory.
|
||||||
|
// It also updates the goldItem quantity display
|
||||||
|
UpdateGoldMsg updateTargetGold = null;
|
||||||
|
|
||||||
|
if (tar != null)
|
||||||
|
updateTargetGold = new UpdateGoldMsg(tar);
|
||||||
|
else if (corpse != null)
|
||||||
|
updateTargetGold = new UpdateGoldMsg(corpse);
|
||||||
|
|
||||||
|
updateTargetGold.configure();
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(tar, updateTargetGold, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||||
|
|
||||||
|
UpdateGoldMsg ugm = new UpdateGoldMsg(player);
|
||||||
|
ugm.configure();
|
||||||
|
Dispatch dispatch = Dispatch.borrow(player, ugm);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
// respond back loot message. Try sending to everyone.
|
||||||
|
|
||||||
|
} else {
|
||||||
|
msg.setSourceType1(0);
|
||||||
|
msg.setSourceType2(0);
|
||||||
|
msg.setSourceID1(0);
|
||||||
|
msg.setSourceID2(0);
|
||||||
|
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||||
|
//DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(tar, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, true);
|
||||||
|
LootMsg newItemMsg = new LootMsg(Enum.GameObjectType.PlayerCharacter.ordinal(), player.getObjectUUID(), 0, 0, itemRet);
|
||||||
|
dispatch = Dispatch.borrow(player, newItemMsg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
//player.getCharItemManager().updateInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO send group loot message if player is grouped and visible
|
||||||
|
Group group = GroupManager.getGroup(player);
|
||||||
|
|
||||||
|
if (group != null && group.getSplitGold() && (item.template.item_type.equals(engine.Enum.ItemType.GOLD) == false)) {
|
||||||
|
String name = item.getName();
|
||||||
|
String text = player.getFirstName() + " has looted " + name + '.';
|
||||||
|
ChatManager.chatGroupInfoCanSee(player, text);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.info(e.getMessage());
|
||||||
|
} finally {
|
||||||
|
item.lootLock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.Enum.DispatchChannel;
|
||||||
|
import engine.InterestManagement.WorldGrid;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
|
import engine.net.client.msg.LootWindowRequestMsg;
|
||||||
|
import engine.net.client.msg.LootWindowResponseMsg;
|
||||||
|
import engine.objects.*;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import static engine.math.FastMath.sqr;
|
||||||
|
|
||||||
|
public class LootWindowRequestMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public LootWindowRequestMsgHandler() {
|
||||||
|
super(LootWindowRequestMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter player = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
LootWindowRequestMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (LootWindowRequestMsg) baseMsg;
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!player.isAlive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (msg.getSourceType() != player.getObjectType().ordinal() || msg.getSourceID() != player.getObjectUUID()) {
|
||||||
|
Logger.error("Player " + player.getObjectUUID() + " looting from character of id "
|
||||||
|
+ msg.getSourceType() + ' ' + msg.getSourceID());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.getAltitude() > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!player.isAlive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
LootWindowResponseMsg lwrm = null;
|
||||||
|
Enum.GameObjectType targetType = Enum.GameObjectType.values()[msg.getTargetType()];
|
||||||
|
AbstractCharacter characterTarget = null;
|
||||||
|
Corpse corpseTarget;
|
||||||
|
|
||||||
|
switch (targetType) {
|
||||||
|
case PlayerCharacter:
|
||||||
|
|
||||||
|
characterTarget = PlayerCharacter.getFromCache(msg.getTargetID());
|
||||||
|
|
||||||
|
if (characterTarget == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (characterTarget.isAlive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (player.getLoc().distanceSquared2D(characterTarget.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
||||||
|
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse.");
|
||||||
|
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(characterTarget.getLoc()) + " distance.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
lwrm = new LootWindowResponseMsg(characterTarget.getObjectType().ordinal(), characterTarget.getObjectUUID(), characterTarget.getInventory(true));
|
||||||
|
break;
|
||||||
|
case NPC:
|
||||||
|
characterTarget = NPC.getFromCache(msg.getTargetID());
|
||||||
|
|
||||||
|
if (characterTarget == null)
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
case Mob:
|
||||||
|
characterTarget = Mob.getFromCache(msg.getTargetID());
|
||||||
|
|
||||||
|
if ((characterTarget == null) || characterTarget.isAlive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (player.getLoc().distanceSquared2D(characterTarget.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
||||||
|
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse.");
|
||||||
|
|
||||||
|
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(characterTarget.getLoc()) + " distance.");
|
||||||
|
|
||||||
|
if (!((Mob) characterTarget).isLootSync()) {
|
||||||
|
((Mob) characterTarget).setLootSync(true);
|
||||||
|
WorldGrid.updateObject(characterTarget, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
lwrm = new LootWindowResponseMsg(characterTarget.getObjectType().ordinal(), characterTarget.getObjectUUID(), characterTarget.getInventory());
|
||||||
|
break;
|
||||||
|
case Corpse:
|
||||||
|
corpseTarget = Corpse.getCorpse(msg.getTargetID());
|
||||||
|
|
||||||
|
if ((corpseTarget == null))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (player.getLoc().distanceSquared(corpseTarget.getLoc()) > sqr(MBServerStatics.LOOT_RANGE)) {
|
||||||
|
ErrorPopupMsg.sendErrorMsg(player, "You are too far away to loot this corpse.");
|
||||||
|
Logger.info(player.getFirstName() + " tried looting at " + player.getLoc().distance2D(characterTarget.getLoc()) + " distance.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
lwrm = new LootWindowResponseMsg(corpseTarget.getObjectType().ordinal(), msg.getTargetID(), corpseTarget.getInventory());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lwrm == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(player, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||||
|
Dispatch dispatch = Dispatch.borrow(player, lwrm);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -428,7 +428,7 @@ public class MerchantMsgHandler extends AbstractClientMsgHandler {
|
|||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
ViewResourcesMsg vrm = new ViewResourcesMsg(player);
|
||||||
warehouse = npc.getBuilding();
|
warehouse = npc.getBuilding();
|
||||||
vrm.setGuild(player.getGuild());
|
vrm.setGuild(player.getGuild());
|
||||||
vrm.setWarehouseBuilding(warehouse);
|
vrm.setWarehouseBuilding(warehouse);
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.ModifyStatMsg;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
|
||||||
|
public class ModifyStatMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public ModifyStatMsgHandler() {
|
||||||
|
super(ModifyStatMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
ModifyStatMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (ModifyStatMsg) baseMsg;
|
||||||
|
|
||||||
|
int type = msg.getType();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case MBServerStatics.STAT_STR_ID:
|
||||||
|
playerCharacter.addStr(msg.getAmount());
|
||||||
|
break;
|
||||||
|
case MBServerStatics.STAT_DEX_ID:
|
||||||
|
playerCharacter.addDex(msg.getAmount());
|
||||||
|
break;
|
||||||
|
case MBServerStatics.STAT_CON_ID:
|
||||||
|
playerCharacter.addCon(msg.getAmount());
|
||||||
|
break;
|
||||||
|
case MBServerStatics.STAT_INT_ID:
|
||||||
|
playerCharacter.addInt(msg.getAmount());
|
||||||
|
break;
|
||||||
|
case MBServerStatics.STAT_SPI_ID:
|
||||||
|
playerCharacter.addSpi(msg.getAmount());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,13 +12,12 @@ import engine.exception.MsgSendException;
|
|||||||
import engine.gameManager.PowersManager;
|
import engine.gameManager.PowersManager;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.ClientNetMsg;
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
import engine.net.client.msg.KeepAliveServerClientMsg;
|
|
||||||
import engine.net.client.msg.PerformActionMsg;
|
import engine.net.client.msg.PerformActionMsg;
|
||||||
|
|
||||||
public class PerformActionMsgHandler extends AbstractClientMsgHandler {
|
public class PerformActionMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
public PerformActionMsgHandler() {
|
public PerformActionMsgHandler() {
|
||||||
super(KeepAliveServerClientMsg.class);
|
super(PerformActionMsg.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.BuildingManager;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.PetAttackMsg;
|
||||||
|
import engine.objects.Mob;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class PetAttackMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public PetAttackMsgHandler() {
|
||||||
|
super(PetAttackMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
PetAttackMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (PetAttackMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Mob pet = playerCharacter.getPet();
|
||||||
|
|
||||||
|
if (pet == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!pet.isAlive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (pet.getCombatTarget() == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ((playerCharacter.inSafeZone())
|
||||||
|
&& (msg.getTargetType() == Enum.GameObjectType.PlayerCharacter.ordinal()))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (msg.getTargetType() == Enum.GameObjectType.Building.ordinal())
|
||||||
|
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
|
||||||
|
|
||||||
|
switch (msg.getTargetType()) {
|
||||||
|
case 53: //player character
|
||||||
|
pet.setCombatTarget(PlayerCharacter.getPlayerCharacter(msg.getTargetID()));
|
||||||
|
break;
|
||||||
|
case 37://mob
|
||||||
|
pet.setCombatTarget(Mob.getMob(msg.getTargetID()));
|
||||||
|
break;
|
||||||
|
case 8://mob
|
||||||
|
pet.setCombatTarget(BuildingManager.getBuilding(msg.getTargetID()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.InterestManagement.WorldGrid;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.PetCmdMsg;
|
||||||
|
import engine.net.client.msg.UpdateStateMsg;
|
||||||
|
import engine.objects.Mob;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class PetCmdMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public PetCmdMsgHandler() {
|
||||||
|
super(PetCmdMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
PetCmdMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (PetCmdMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Mob pet = playerCharacter.getPet();
|
||||||
|
|
||||||
|
if (pet == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!pet.isAlive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//if (pet.state == STATE.Disabled)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
int type = msg.getType();
|
||||||
|
|
||||||
|
if (type == 1) { //stop attack
|
||||||
|
pet.setCombatTarget(null);
|
||||||
|
playerCharacter.setCombat(false);
|
||||||
|
|
||||||
|
} else if (type == 2) { //dismiss
|
||||||
|
pet.dismiss();
|
||||||
|
playerCharacter.dismissPet();
|
||||||
|
|
||||||
|
if (pet.isAlive())
|
||||||
|
WorldGrid.updateObject(pet);
|
||||||
|
} else if (type == 3) //toggle assist
|
||||||
|
pet.toggleAssist();
|
||||||
|
else if (type == 5) { //rest
|
||||||
|
boolean sit = (!(pet.isSit()));
|
||||||
|
pet.setSit(sit);
|
||||||
|
|
||||||
|
// cancel effects that break on sit
|
||||||
|
if (pet.isSit())
|
||||||
|
pet.cancelOnSit();
|
||||||
|
|
||||||
|
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||||
|
rwss.setPlayer(pet);
|
||||||
|
DispatchMessage.sendToAllInRange(pet, rwss);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.job.JobContainer;
|
||||||
|
import engine.job.JobScheduler;
|
||||||
|
import engine.jobs.FinishSummonsJob;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
|
import engine.net.client.msg.RecvSummonsMsg;
|
||||||
|
import engine.objects.BaseClass;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.objects.PromotionClass;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class RecvSummonsMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public RecvSummonsMsgHandler() {
|
||||||
|
super(RecvSummonsMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
RecvSummonsMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (RecvSummonsMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
PlayerCharacter source = PlayerCharacter.getFromCache(msg.getSourceID());
|
||||||
|
|
||||||
|
if (source == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
long tooLate = playerCharacter.getSummoner(source.getObjectUUID());
|
||||||
|
|
||||||
|
if (tooLate < System.currentTimeMillis()) {
|
||||||
|
ChatManager.chatInfoError(playerCharacter, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons.");
|
||||||
|
playerCharacter.removeSummoner(source.getObjectUUID());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playerCharacter.getBonuses() != null && playerCharacter.getBonuses().getBool(Enum.ModType.BlockedPowerType, Enum.SourceType.SUMMON)) {
|
||||||
|
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You have been blocked from receiving summons!");
|
||||||
|
ErrorPopupMsg.sendErrorMsg(source, "Target is blocked from receiving summons!");
|
||||||
|
playerCharacter.removeSummoner(source.getObjectUUID());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerCharacter.removeSummoner(source.getObjectUUID());
|
||||||
|
|
||||||
|
// Handle Accepting or Denying a summons.
|
||||||
|
// set timer based on summon type.
|
||||||
|
|
||||||
|
boolean wentThrough = false;
|
||||||
|
|
||||||
|
if (msg.accepted()) // summons accepted, let's move the player if within time
|
||||||
|
if (source.isAlive()) {
|
||||||
|
|
||||||
|
//make sure summons handled in time
|
||||||
|
ConcurrentHashMap<String, JobContainer> timers;
|
||||||
|
timers = playerCharacter.getTimers();
|
||||||
|
|
||||||
|
if (timers != null && timers.containsKey("Summon"))
|
||||||
|
timers.get("Summon").cancelJob();
|
||||||
|
|
||||||
|
// get time to wait before summons goes through
|
||||||
|
|
||||||
|
BaseClass base = source.baseClass;
|
||||||
|
PromotionClass promo = source.getPromotionClass();
|
||||||
|
int duration;
|
||||||
|
|
||||||
|
//determine if in combat with another player
|
||||||
|
|
||||||
|
//comment out this block to disable combat timer
|
||||||
|
// if (lastAttacked < 60000) {
|
||||||
|
// if (pc.inSafeZone()) //player in safe zone, no need for combat timer
|
||||||
|
// combat = false;
|
||||||
|
// else if (source.inSafeZone()) //summoner in safe zone, apply combat timer
|
||||||
|
// combat = true;
|
||||||
|
// else if ((source.getLoc().distance2D(pc.getLoc())) > 6144f)
|
||||||
|
// combat = true; //more than 1.5x width of zone, not tactical summons
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (promo != null && promo.getObjectUUID() == 2519)
|
||||||
|
duration = 10000; // Priest summons, 10 seconds
|
||||||
|
else if (base != null && base.getObjectUUID() == 2501)
|
||||||
|
duration = 15000; // Healer Summons, 15 seconds
|
||||||
|
else
|
||||||
|
duration = 45000; // Belgosh Summons, 45 seconds
|
||||||
|
|
||||||
|
// Teleport to summoners location
|
||||||
|
|
||||||
|
FinishSummonsJob fsj = new FinishSummonsJob(source, playerCharacter);
|
||||||
|
JobContainer jc = JobScheduler.getInstance().scheduleJob(fsj,
|
||||||
|
duration);
|
||||||
|
|
||||||
|
if (timers != null)
|
||||||
|
timers.put("Summon", jc);
|
||||||
|
|
||||||
|
wentThrough = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Summons failed
|
||||||
|
if (!wentThrough) // summons refused. Let's be nice and reset recycle timer
|
||||||
|
{
|
||||||
|
// Send summons refused Message
|
||||||
|
ErrorPopupMsg.sendErrorPopup(source, 29);
|
||||||
|
// recycle summons power
|
||||||
|
//finishRecycleTime(428523680, source, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.RefineMsg;
|
||||||
|
import engine.net.client.msg.RefinerScreenMsg;
|
||||||
|
import engine.objects.*;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class RefineMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public RefineMsgHandler() {
|
||||||
|
super(RefineMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
RefineMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (RefineMsg) baseMsg;
|
||||||
|
|
||||||
|
NPC npc = NPC.getFromCache(msg.npcID);
|
||||||
|
|
||||||
|
if (npc == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
int type = msg.type;
|
||||||
|
int token = msg.token;
|
||||||
|
boolean worked = false;
|
||||||
|
boolean skillPower = true;
|
||||||
|
|
||||||
|
if (type == 0) { //refine skill
|
||||||
|
worked = refineSkill(origin, playerCharacter, token, msg);
|
||||||
|
} else if (type == 1) { //refine power
|
||||||
|
worked = refinePower(origin, playerCharacter, token, msg);
|
||||||
|
} else if (type == 2) { //refine stat
|
||||||
|
worked = refineStat(origin, playerCharacter, token, msg);
|
||||||
|
skillPower = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worked) {
|
||||||
|
|
||||||
|
//update player
|
||||||
|
playerCharacter.applyBonuses();
|
||||||
|
playerCharacter.charItemManager.RemoveEquipmentFromLackOfSkill(playerCharacter, true);
|
||||||
|
|
||||||
|
//echo refine message back
|
||||||
|
|
||||||
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
// if (type == 0 && token == 1488335491){
|
||||||
|
// dispatch = Dispatch.borrow(pc, msg);
|
||||||
|
// DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//resend refine screen
|
||||||
|
|
||||||
|
RefinerScreenMsg refinerScreenMsg = new RefinerScreenMsg(skillPower, npc.getSellPercent(playerCharacter)); //TODO set npc cost
|
||||||
|
dispatch = Dispatch.borrow(playerCharacter, refinerScreenMsg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||||
|
playerCharacter.recalculate();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean refineSkill(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
||||||
|
CharacterSkill skill = null;
|
||||||
|
ConcurrentHashMap<String, CharacterSkill> skills = pc.getSkills();
|
||||||
|
for (CharacterSkill sk : skills.values()) {
|
||||||
|
if (sk == null)
|
||||||
|
continue;
|
||||||
|
SkillsBase sb = sk.getSkillsBase();
|
||||||
|
if (sb == null)
|
||||||
|
continue;
|
||||||
|
if (sb.getToken() == token)
|
||||||
|
skill = sk;
|
||||||
|
}
|
||||||
|
//check if player has skill to refine
|
||||||
|
if (skill == null)
|
||||||
|
return false;
|
||||||
|
//check there's a train to refine
|
||||||
|
if (skill.getNumTrains() < 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//TODO verify if any skills have this as prereq
|
||||||
|
|
||||||
|
//TODO verify if any powers have this as a prereq
|
||||||
|
//get all players powers
|
||||||
|
for (CharacterPower power : pc.getPowers().values()) {
|
||||||
|
ArrayList<PowerReq> reqs = PowerReq.getPowerReqsForRune(power.getPowerID());
|
||||||
|
for (PowerReq req : reqs) {
|
||||||
|
ConcurrentHashMap<String, CharacterSkill> playerSkills = pc.getSkills();
|
||||||
|
CharacterSkill playerSkill = playerSkills.get(token);
|
||||||
|
int currentSkillLevel = playerSkill.getTotalSkillPercet();
|
||||||
|
if (token == req.getToken() && req.getLevel() == currentSkillLevel) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//refine skill
|
||||||
|
return skill.refine(pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean refinePower(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
||||||
|
CharacterPower power = null;
|
||||||
|
ConcurrentHashMap<Integer, CharacterPower> powers = pc.getPowers();
|
||||||
|
if (!powers.containsKey(token))
|
||||||
|
return false;
|
||||||
|
power = powers.get(token);
|
||||||
|
if (power == null)
|
||||||
|
return false;
|
||||||
|
if (power.getTrains() < 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//TODO verify if any powers have this as a prereq
|
||||||
|
|
||||||
|
return power.refine(pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean refineStat(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
||||||
|
if (token == MBServerStatics.STAT_STR_ID)
|
||||||
|
return pc.refineStr();
|
||||||
|
if (token == MBServerStatics.STAT_DEX_ID)
|
||||||
|
return pc.refineDex();
|
||||||
|
if (token == MBServerStatics.STAT_CON_ID)
|
||||||
|
return pc.refineCon();
|
||||||
|
if (token == MBServerStatics.STAT_INT_ID)
|
||||||
|
return pc.refineInt(msg);
|
||||||
|
if (token == MBServerStatics.STAT_SPI_ID)
|
||||||
|
return pc.refineSpi();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.RefinerScreenMsg;
|
||||||
|
import engine.objects.NPC;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class RefinerScreenMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public RefinerScreenMsgHandler() {
|
||||||
|
super(RefinerScreenMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
RefinerScreenMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (RefinerScreenMsg) baseMsg;
|
||||||
|
|
||||||
|
NPC npc = NPC.getFromCache(msg.getNpcID());
|
||||||
|
|
||||||
|
if (npc != null)
|
||||||
|
msg.setUnknown02(0); //cost to refine?
|
||||||
|
|
||||||
|
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum.DispatchChannel;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.MovementManager;
|
||||||
|
import engine.job.JobScheduler;
|
||||||
|
import engine.jobs.RefreshGroupJob;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.MoveToPointMsg;
|
||||||
|
import engine.net.client.msg.RespawnMsg;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
public class RespawnMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public RespawnMsgHandler() {
|
||||||
|
super(RespawnMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
RespawnMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (RespawnMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (msg.getObjectType() != playerCharacter.getObjectType().ordinal() || msg.getObjectID() != playerCharacter.getObjectUUID()) {
|
||||||
|
Logger.error("Player " + playerCharacter.getObjectUUID() + " respawning character of id " + msg.getObjectType() + ' '
|
||||||
|
+ msg.getObjectID());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playerCharacter.isAlive()) {
|
||||||
|
Logger.error("Player " + playerCharacter.getObjectUUID() + " respawning while alive");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetAfterDeath player
|
||||||
|
playerCharacter.respawnLock.writeLock().lock();
|
||||||
|
try {
|
||||||
|
playerCharacter.respawn(true, false, true);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error(e);
|
||||||
|
} finally {
|
||||||
|
playerCharacter.respawnLock.writeLock().unlock();
|
||||||
|
|
||||||
|
}
|
||||||
|
// Echo ResetAfterDeath message back
|
||||||
|
msg.setPlayerHealth(playerCharacter.getHealth());
|
||||||
|
// TODO calculate any experience loss before this point
|
||||||
|
msg.setPlayerExp(playerCharacter.getExp() + playerCharacter.getOverFlowEXP());
|
||||||
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
MoveToPointMsg moveMsg = new MoveToPointMsg();
|
||||||
|
moveMsg.setPlayer(playerCharacter);
|
||||||
|
moveMsg.setStartCoord(playerCharacter.getLoc());
|
||||||
|
moveMsg.setEndCoord(playerCharacter.getLoc());
|
||||||
|
moveMsg.setInBuilding(-1);
|
||||||
|
moveMsg.setInBuildingFloor(-1);
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(playerCharacter, moveMsg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||||
|
|
||||||
|
MovementManager.sendRWSSMsg(playerCharacter);
|
||||||
|
|
||||||
|
// refresh the whole group with what just happened
|
||||||
|
JobScheduler.getInstance().scheduleJob(new RefreshGroupJob(playerCharacter), MBServerStatics.LOAD_OBJECT_DELAY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.gameManager.ConfigManager;
|
||||||
|
import engine.gameManager.SessionManager;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.PerformActionMsg;
|
||||||
|
import engine.net.client.msg.SendSummonsMsg;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
|
||||||
|
import static engine.gameManager.PowersManager.*;
|
||||||
|
|
||||||
|
public class SendSummonsMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public SendSummonsMsgHandler() {
|
||||||
|
super(SendSummonsMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
SendSummonsMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (SendSummonsMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
PlayerCharacter target = SessionManager
|
||||||
|
.getPlayerCharacterByLowerCaseName(msg.getTargetName());
|
||||||
|
|
||||||
|
if (target == null || target.equals(playerCharacter) || target.isCombat()) {
|
||||||
|
|
||||||
|
if (target == null) // Player not found. Send not found message
|
||||||
|
ChatManager.chatInfoError(playerCharacter,
|
||||||
|
"Cannot find that player to summon.");
|
||||||
|
else if (target.isCombat())
|
||||||
|
ChatManager.chatInfoError(playerCharacter,
|
||||||
|
"Cannot summon player in combat.");
|
||||||
|
|
||||||
|
// else trying to summon self, just fail
|
||||||
|
|
||||||
|
// recycle summon
|
||||||
|
sendRecyclePower(msg.getPowerToken(), origin);
|
||||||
|
|
||||||
|
// TODO: client already subtracted 200 mana.. need to correct it
|
||||||
|
// end cast
|
||||||
|
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(),
|
||||||
|
msg.getTrains(), msg.getSourceType(), msg.getSourceID(), 0,
|
||||||
|
0, 0f, 0f, 0f, 1, 0);
|
||||||
|
sendPowerMsg(playerCharacter, 2, pam);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (ConfigManager.MB_RULESET.getValue() == "LORE") {
|
||||||
|
if (playerCharacter.guild.getGuildType().equals(target.guild.getGuildType()) == false) {
|
||||||
|
ChatManager.chatInfoError(playerCharacter,
|
||||||
|
"Cannot summon player outside your charter.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(), msg
|
||||||
|
.getTrains(), msg.getSourceType(), msg.getSourceID(), target
|
||||||
|
.getObjectType().ordinal(), target.getObjectUUID(), 0f, 0f, 0f, 1, 0);
|
||||||
|
|
||||||
|
// Client removes 200 mana on summon use.. so don't send message to self
|
||||||
|
target.addSummoner(playerCharacter.getObjectUUID(), System.currentTimeMillis() + MBServerStatics.FOURTYFIVE_SECONDS);
|
||||||
|
usePower(pam, origin, false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.SetCombatModeMsg;
|
||||||
|
import engine.net.client.msg.UpdateStateMsg;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
|
||||||
|
public class SetCombatModeMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public SetCombatModeMsgHandler() {
|
||||||
|
super(SetCombatModeMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
SetCombatModeMsg msg;
|
||||||
|
boolean toggle;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (SetCombatModeMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
toggle = msg.getToggle();
|
||||||
|
playerCharacter.setCombat(toggle);
|
||||||
|
|
||||||
|
if (!toggle) // toggle is move it to false so clear combat target
|
||||||
|
playerCharacter.setCombatTarget(null); //clear last combat target
|
||||||
|
|
||||||
|
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||||
|
rwss.setPlayer(playerCharacter);
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.Enum.DispatchChannel;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.ShowMsg;
|
||||||
|
import engine.objects.AbstractCharacter;
|
||||||
|
import engine.objects.Mob;
|
||||||
|
import engine.objects.NPC;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class ShowMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public ShowMsgHandler() {
|
||||||
|
super(ShowMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
ShowMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (ShowMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
int targetType = msg.getTargetType();
|
||||||
|
AbstractCharacter tar = null;
|
||||||
|
|
||||||
|
if (targetType == Enum.GameObjectType.PlayerCharacter.ordinal())
|
||||||
|
tar = PlayerCharacter.getFromCache(msg.getTargetID());
|
||||||
|
else if (targetType == Enum.GameObjectType.NPC.ordinal())
|
||||||
|
tar = NPC.getFromCache(msg.getTargetID());
|
||||||
|
else if (targetType == Enum.GameObjectType.Mob.ordinal())
|
||||||
|
tar = Mob.getFromCache(msg.getTargetID());
|
||||||
|
|
||||||
|
if (tar == null || !tar.isAlive() || !tar.isActive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
msg.setUnknown01(playerCharacter.getLoc());
|
||||||
|
msg.setUnknown02(playerCharacter.getLoc());
|
||||||
|
msg.setRange01(playerCharacter.getRange());
|
||||||
|
msg.setUnknown03(tar.getLoc());
|
||||||
|
msg.setUnknown04(tar.getLoc());
|
||||||
|
msg.setRange01(tar.getRange());
|
||||||
|
|
||||||
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.job.JobContainer;
|
||||||
|
import engine.job.JobScheduler;
|
||||||
|
import engine.jobs.StuckJob;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.StuckMsg;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class StuckMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public StuckMsgHandler() {
|
||||||
|
super(StuckMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
StuckMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (StuckMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (playerCharacter.getTimers().containsKey("Stuck"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
StuckJob sj = new StuckJob(playerCharacter);
|
||||||
|
JobContainer jc = JobScheduler.getInstance().scheduleJob(sj, 10000); // Convert
|
||||||
|
ConcurrentHashMap<String, JobContainer> timers = playerCharacter.getTimers();
|
||||||
|
|
||||||
|
if (timers != null) {
|
||||||
|
if (timers.containsKey("Stuck")) {
|
||||||
|
timers.get("Stuck").cancelJob();
|
||||||
|
timers.remove("Stuck");
|
||||||
|
}
|
||||||
|
timers.put("Stuck", jc);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ import engine.net.client.ClientConnection;
|
|||||||
import engine.net.client.msg.ClientNetMsg;
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
import engine.net.client.msg.TaxCityMsg;
|
import engine.net.client.msg.TaxCityMsg;
|
||||||
import engine.net.client.msg.ViewResourcesMessage;
|
import engine.net.client.msg.ViewResourcesMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -109,7 +109,7 @@ public class TaxCityMsgHandler extends AbstractClientMsgHandler {
|
|||||||
// return true;
|
// return true;
|
||||||
|
|
||||||
|
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
ViewResourcesMsg vrm = new ViewResourcesMsg(player);
|
||||||
vrm.setGuild(building.getGuild());
|
vrm.setGuild(building.getGuild());
|
||||||
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().warehouse.building.getObjectUUID()));
|
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().warehouse.building.getObjectUUID()));
|
||||||
vrm.configure();
|
vrm.configure();
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.ToggleCombatMsg;
|
||||||
|
import engine.net.client.msg.UpdateStateMsg;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
|
||||||
|
public class ToggleCombatMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public ToggleCombatMsgHandler() {
|
||||||
|
super(ToggleCombatMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
ToggleCombatMsg msg;
|
||||||
|
boolean toggle;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (ToggleCombatMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
toggle = msg.toggleCombat();
|
||||||
|
playerCharacter.setCombat(toggle);
|
||||||
|
|
||||||
|
if (!toggle) // toggle is move it to false so clear combat target
|
||||||
|
playerCharacter.setCombatTarget(null); //clear last combat target
|
||||||
|
|
||||||
|
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||||
|
rwss.setPlayer(playerCharacter);
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, Enum.DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum.DispatchChannel;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.ToggleLfgRecruitingMsg;
|
||||||
|
import engine.net.client.msg.UpdateStateMsg;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
|
||||||
|
public class ToggleLfgRecruitingMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public ToggleLfgRecruitingMsgHandler() {
|
||||||
|
super(ToggleLfgRecruitingMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
ToggleLfgRecruitingMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (ToggleLfgRecruitingMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
int num = msg.toggleLfgRecruiting();
|
||||||
|
|
||||||
|
if (num == 1)
|
||||||
|
playerCharacter.toggleLFGroup();
|
||||||
|
else if (num == 2)
|
||||||
|
playerCharacter.toggleLFGuild();
|
||||||
|
else if (num == 3)
|
||||||
|
playerCharacter.toggleRecruiting();
|
||||||
|
|
||||||
|
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||||
|
rwss.setPlayer(playerCharacter);
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum.DispatchChannel;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.ToggleSitStandMsg;
|
||||||
|
import engine.net.client.msg.UpdateStateMsg;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
|
||||||
|
public class ToggleSitStandMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public ToggleSitStandMsgHandler() {
|
||||||
|
super(ToggleSitStandMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
ToggleSitStandMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (ToggleSitStandMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
playerCharacter.update();
|
||||||
|
|
||||||
|
playerCharacter.setSit(msg.toggleSitStand());
|
||||||
|
|
||||||
|
// cancel effects that break on sit
|
||||||
|
if (playerCharacter.isSit()) {
|
||||||
|
playerCharacter.setCombat(false);
|
||||||
|
playerCharacter.cancelOnSit();
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateStateMsg rwss = new UpdateStateMsg();
|
||||||
|
|
||||||
|
if (playerCharacter.isSit()) {
|
||||||
|
playerCharacter.setCombat(false);
|
||||||
|
rwss.setAware(1);
|
||||||
|
}
|
||||||
|
rwss.setPlayer(playerCharacter);
|
||||||
|
|
||||||
|
DispatchMessage.dispatchMsgToInterestArea(playerCharacter, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.Enum.DispatchChannel;
|
||||||
|
import engine.InterestManagement.WorldGrid;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.gameManager.PowersManager;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.TrackWindowMsg;
|
||||||
|
import engine.objects.*;
|
||||||
|
import engine.powers.ActionsBase;
|
||||||
|
import engine.powers.PowersBase;
|
||||||
|
import engine.powers.RangeBasedAwo;
|
||||||
|
import engine.powers.poweractions.AbstractPowerAction;
|
||||||
|
import engine.powers.poweractions.TrackPowerAction;
|
||||||
|
import engine.server.MBServerStatics;
|
||||||
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class TrackWindowMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public TrackWindowMsgHandler() {
|
||||||
|
super(TrackWindowMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
TrackWindowMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (TrackWindowMsg) baseMsg;
|
||||||
|
|
||||||
|
if (playerCharacter == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (MBServerStatics.POWERS_DEBUG) {
|
||||||
|
ChatManager.chatSayInfo(
|
||||||
|
playerCharacter,
|
||||||
|
"Using Power: " + Integer.toHexString(msg.getPowerToken())
|
||||||
|
+ " (" + msg.getPowerToken() + ')');
|
||||||
|
Logger.info("Using Power: "
|
||||||
|
+ Integer.toHexString(msg.getPowerToken()) + " ("
|
||||||
|
+ msg.getPowerToken() + ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// get track power used
|
||||||
|
|
||||||
|
PowersBase pb = PowersManager.powersBaseByToken.get(msg.getPowerToken());
|
||||||
|
|
||||||
|
if (pb == null || !pb.isTrack())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
//check track threshold timer to prevent spam
|
||||||
|
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
long timestamp = playerCharacter.getTimeStamp("trackWindow");
|
||||||
|
long dif = currentTime - timestamp;
|
||||||
|
|
||||||
|
if (dif < MBServerStatics.TRACK_WINDOW_THRESHOLD)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
playerCharacter.setTimeStamp("trackWindow", currentTime);
|
||||||
|
|
||||||
|
ArrayList<ActionsBase> ablist = pb.getActions();
|
||||||
|
|
||||||
|
if (ablist == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
TrackPowerAction tpa = null;
|
||||||
|
|
||||||
|
for (ActionsBase ab : ablist) {
|
||||||
|
AbstractPowerAction apa = ab.getPowerAction();
|
||||||
|
if (apa != null && apa instanceof TrackPowerAction)
|
||||||
|
tpa = (TrackPowerAction) apa;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tpa == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Check powers for normal users
|
||||||
|
if (playerCharacter.getPowers() == null || !playerCharacter.getPowers().containsKey(msg.getPowerToken()))
|
||||||
|
if (!playerCharacter.isCSR())
|
||||||
|
if (!MBServerStatics.POWERS_DEBUG) {
|
||||||
|
// ChatManager.chatSayInfo(pc, "You may not cast that spell!");
|
||||||
|
// this.logEXPLOIT("usePowerA(): Cheat attempted? '" + msg.getPowerToken() + "' was not associated with " + pc.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get search mask for track
|
||||||
|
|
||||||
|
int mask = 0;
|
||||||
|
|
||||||
|
if (pb.targetPlayer())
|
||||||
|
if (tpa.trackVampire()) // track vampires
|
||||||
|
mask = MBServerStatics.MASK_PLAYER | MBServerStatics.MASK_UNDEAD;
|
||||||
|
else
|
||||||
|
// track all players
|
||||||
|
mask = MBServerStatics.MASK_PLAYER;
|
||||||
|
else if (pb.targetCorpse()) // track corpses
|
||||||
|
mask = MBServerStatics.MASK_CORPSE;
|
||||||
|
else if (tpa.trackNPC()) // Track NPCs
|
||||||
|
mask = MBServerStatics.MASK_NPC;
|
||||||
|
else if (tpa.trackUndead()) // Track Undead
|
||||||
|
mask = MBServerStatics.MASK_MOB | MBServerStatics.MASK_UNDEAD;
|
||||||
|
else
|
||||||
|
// Track All
|
||||||
|
mask = MBServerStatics.MASK_MOB | MBServerStatics.MASK_NPC;
|
||||||
|
|
||||||
|
// Find characters in range
|
||||||
|
|
||||||
|
HashSet<AbstractWorldObject> allTargets;
|
||||||
|
allTargets = WorldGrid.getObjectsInRangeContains(playerCharacter.getLoc(),
|
||||||
|
pb.getRange(), mask);
|
||||||
|
|
||||||
|
//remove anyone who can't be tracked
|
||||||
|
|
||||||
|
Iterator<AbstractWorldObject> it = allTargets.iterator();
|
||||||
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
AbstractWorldObject awo = it.next();
|
||||||
|
|
||||||
|
if (awo == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
else if (!awo.isAlive())
|
||||||
|
it.remove();
|
||||||
|
|
||||||
|
else if (awo.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
|
||||||
|
PlayerBonuses bonus = ((PlayerCharacter) awo).getBonuses();
|
||||||
|
|
||||||
|
if (bonus != null && bonus.getBool(Enum.ModType.CannotTrack, Enum.SourceType.NONE))
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get max characters for window
|
||||||
|
|
||||||
|
int maxTargets = 20;
|
||||||
|
PromotionClass promo = playerCharacter.getPromotionClass();
|
||||||
|
|
||||||
|
if (promo != null) {
|
||||||
|
int tableID = promo.getObjectUUID();
|
||||||
|
if (tableID == 2512 || tableID == 2514 || tableID == 2515)
|
||||||
|
maxTargets = 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create list of characters
|
||||||
|
HashSet<AbstractCharacter> trackChars = RangeBasedAwo.getTrackList(
|
||||||
|
allTargets, playerCharacter, maxTargets);
|
||||||
|
|
||||||
|
TrackWindowMsg trackWindowMsg = new TrackWindowMsg(msg);
|
||||||
|
|
||||||
|
// send track window
|
||||||
|
trackWindowMsg.setSource(playerCharacter);
|
||||||
|
trackWindowMsg.setCharacters(trackChars);
|
||||||
|
|
||||||
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, trackWindowMsg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.ChatManager;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.TradeRequestMsg;
|
||||||
|
import engine.objects.CharacterItemManager;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class TradeRequestMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public TradeRequestMsgHandler() {
|
||||||
|
super(TradeRequestMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
TradeRequestMsg msg = (TradeRequestMsg) baseMsg;
|
||||||
|
|
||||||
|
PlayerCharacter source = origin.getPlayerCharacter();
|
||||||
|
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getPlayerID());
|
||||||
|
Dispatch dispatch;
|
||||||
|
|
||||||
|
if (!CharacterItemManager.canTrade(source, target)) {
|
||||||
|
ChatManager.chatSystemError(source, "Can't currently trade with target player");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO uncomment this block after we determine when we
|
||||||
|
// setBankOpen(false) and setVaultOpen(false)
|
||||||
|
CharacterItemManager cim1 = source.charItemManager;
|
||||||
|
CharacterItemManager cim2 = target.charItemManager;
|
||||||
|
|
||||||
|
if (cim1 == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (cim2 == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
dispatch = Dispatch.borrow(target, msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.TrainerInfoMsg;
|
||||||
|
import engine.objects.NPC;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class TrainerInfoMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public TrainerInfoMsgHandler() {
|
||||||
|
super(TrainerInfoMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
TrainerInfoMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (TrainerInfoMsg) baseMsg;
|
||||||
|
|
||||||
|
NPC npc = NPC.getFromCache(msg.getObjectID());
|
||||||
|
float sellPercent = 1;
|
||||||
|
|
||||||
|
if (npc != null) {
|
||||||
|
|
||||||
|
if (origin.getPlayerCharacter() != null)
|
||||||
|
sellPercent = npc.getSellPercent(origin.getPlayerCharacter());
|
||||||
|
else
|
||||||
|
sellPercent = npc.getSellPercent();
|
||||||
|
|
||||||
|
msg.setTrainPercent(sellPercent); //TrainMsg.getTrainPercent(npc));
|
||||||
|
}
|
||||||
|
|
||||||
|
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.UncommitToTradeMsg;
|
||||||
|
import engine.objects.CharacterItemManager;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
import static engine.objects.CharacterItemManager.canTrade;
|
||||||
|
|
||||||
|
public class UncommitToTradeMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public UncommitToTradeMsgHandler() {
|
||||||
|
super(UncommitToTradeMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter source = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
UncommitToTradeMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (UncommitToTradeMsg) baseMsg;
|
||||||
|
|
||||||
|
if (source == null || !source.isAlive())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
CharacterItemManager sourceItemMan = source.charItemManager;
|
||||||
|
|
||||||
|
if (sourceItemMan == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
sourceItemMan.setTradeCommitted((byte) 0);
|
||||||
|
|
||||||
|
ClientConnection ccOther = sourceItemMan.getTradingWith();
|
||||||
|
|
||||||
|
if (ccOther == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
PlayerCharacter other = ccOther.getPlayerCharacter();
|
||||||
|
|
||||||
|
if (other == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!canTrade(source, other))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
source.charItemManager.modifyCommitToTrade();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,13 +14,12 @@ import engine.net.Dispatch;
|
|||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.ClientNetMsg;
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
import engine.net.client.msg.KeepAliveServerClientMsg;
|
|
||||||
import engine.net.client.msg.UseCharterMsg;
|
import engine.net.client.msg.UseCharterMsg;
|
||||||
|
|
||||||
public class UseCharterMsgHandler extends AbstractClientMsgHandler {
|
public class UseCharterMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
public UseCharterMsgHandler() {
|
public UseCharterMsgHandler() {
|
||||||
super(KeepAliveServerClientMsg.class);
|
super(UseCharterMsg.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -510,9 +510,9 @@ public class VendorDialogMsgHandler extends AbstractClientMsgHandler {
|
|||||||
// TODO When do we setBankOpen(false)? I don't think the client sends a
|
// TODO When do we setBankOpen(false)? I don't think the client sends a
|
||||||
// "CloseBank" message.
|
// "CloseBank" message.
|
||||||
|
|
||||||
AckBankWindowOpenedMsg ackBankWindowOpenedMsg = new AckBankWindowOpenedMsg(playerCharacter, 0L, 0L);
|
CostOpenBankMsg costOpenBankMsg = new CostOpenBankMsg(playerCharacter, 0L, 0L);
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, ackBankWindowOpenedMsg);
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, costOpenBankMsg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
ReqBankInventoryMsg reqBankInventoryMsg = new ReqBankInventoryMsg(playerCharacter, 0L);
|
ReqBankInventoryMsg reqBankInventoryMsg = new ReqBankInventoryMsg(playerCharacter, 0L);
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||||
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||||
|
// Magicbane Emulator Project © 2013 - 2022
|
||||||
|
// www.magicbane.com
|
||||||
|
|
||||||
|
package engine.net.client.handlers;
|
||||||
|
|
||||||
|
import engine.Enum.DispatchChannel;
|
||||||
|
import engine.exception.MsgSendException;
|
||||||
|
import engine.gameManager.BuildingManager;
|
||||||
|
import engine.net.Dispatch;
|
||||||
|
import engine.net.DispatchMessage;
|
||||||
|
import engine.net.client.ClientConnection;
|
||||||
|
import engine.net.client.msg.ClientNetMsg;
|
||||||
|
import engine.net.client.msg.ViewResourcesMsg;
|
||||||
|
import engine.objects.Building;
|
||||||
|
import engine.objects.City;
|
||||||
|
import engine.objects.Guild;
|
||||||
|
import engine.objects.PlayerCharacter;
|
||||||
|
|
||||||
|
public class ViewResourcesMsgHandler extends AbstractClientMsgHandler {
|
||||||
|
|
||||||
|
public ViewResourcesMsgHandler() {
|
||||||
|
super(ViewResourcesMsg.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||||
|
|
||||||
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||||
|
|
||||||
|
// Member variable declaration
|
||||||
|
|
||||||
|
ViewResourcesMsg msg;
|
||||||
|
|
||||||
|
// Member variable assignment
|
||||||
|
|
||||||
|
msg = (ViewResourcesMsg) baseMsg;
|
||||||
|
|
||||||
|
Guild guild = playerCharacter.getGuild();
|
||||||
|
City city = guild.getOwnedCity();
|
||||||
|
|
||||||
|
if (city == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Building warehouse = BuildingManager.getBuilding(city.getWarehouseBuildingID());
|
||||||
|
|
||||||
|
if (warehouse == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ViewResourcesMsg vrm = new ViewResourcesMsg(playerCharacter);
|
||||||
|
vrm.setWarehouseBuilding(warehouse);
|
||||||
|
vrm.setGuild(playerCharacter.getGuild());
|
||||||
|
vrm.configure();
|
||||||
|
|
||||||
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, vrm);
|
||||||
|
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-3
@@ -22,7 +22,7 @@ import engine.objects.PlayerCharacter;
|
|||||||
*
|
*
|
||||||
* @author Burfo
|
* @author Burfo
|
||||||
*/
|
*/
|
||||||
public class AckBankWindowOpenedMsg extends ClientNetMsg {
|
public class CostOpenBankMsg extends ClientNetMsg {
|
||||||
|
|
||||||
private int playerType;
|
private int playerType;
|
||||||
private int playerID;
|
private int playerID;
|
||||||
@@ -32,7 +32,7 @@ public class AckBankWindowOpenedMsg extends ClientNetMsg {
|
|||||||
/**
|
/**
|
||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
*/
|
*/
|
||||||
public AckBankWindowOpenedMsg(PlayerCharacter pc, long unknown01, long unknown02) {
|
public CostOpenBankMsg(PlayerCharacter pc, long unknown01, long unknown02) {
|
||||||
super(Protocol.COSTTOOPENBANK);
|
super(Protocol.COSTTOOPENBANK);
|
||||||
this.playerType = pc.getObjectType().ordinal();
|
this.playerType = pc.getObjectType().ordinal();
|
||||||
this.playerID = pc.getObjectUUID();
|
this.playerID = pc.getObjectUUID();
|
||||||
@@ -46,7 +46,7 @@ public class AckBankWindowOpenedMsg extends ClientNetMsg {
|
|||||||
* past the limit) then this constructor Throws that Exception to the
|
* past the limit) then this constructor Throws that Exception to the
|
||||||
* caller.
|
* caller.
|
||||||
*/
|
*/
|
||||||
public AckBankWindowOpenedMsg(AbstractConnection origin, ByteBufferReader reader) {
|
public CostOpenBankMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||||
super(Protocol.COSTTOOPENBANK, origin, reader);
|
super(Protocol.COSTTOOPENBANK, origin, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,23 +10,17 @@
|
|||||||
package engine.net.client.msg;
|
package engine.net.client.msg;
|
||||||
|
|
||||||
|
|
||||||
import engine.gameManager.ChatManager;
|
|
||||||
import engine.gameManager.DbManager;
|
|
||||||
import engine.gameManager.SessionManager;
|
|
||||||
import engine.net.AbstractConnection;
|
import engine.net.AbstractConnection;
|
||||||
import engine.net.ByteBufferReader;
|
import engine.net.ByteBufferReader;
|
||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.client.ClientConnection;
|
|
||||||
import engine.net.client.Protocol;
|
import engine.net.client.Protocol;
|
||||||
import engine.objects.Account;
|
|
||||||
import engine.objects.PlayerCharacter;
|
|
||||||
|
|
||||||
|
|
||||||
public class IgnoreMsg extends ClientNetMsg {
|
public class IgnoreMsg extends ClientNetMsg {
|
||||||
|
|
||||||
private int unknown1;
|
private int unknown1;
|
||||||
private int unknown2;
|
private int unknown2;
|
||||||
private String nameToIgnore;
|
public String nameToIgnore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
@@ -65,77 +59,6 @@ public class IgnoreMsg extends ClientNetMsg {
|
|||||||
nameToIgnore = reader.getUnicodeString();
|
nameToIgnore = reader.getUnicodeString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleRequest(ClientConnection origin) {
|
|
||||||
|
|
||||||
PlayerCharacter pcSource = SessionManager.getPlayerCharacter(origin);
|
|
||||||
|
|
||||||
if (nameToIgnore.isEmpty()) { // list ignored players
|
|
||||||
String[] ignoredPlayers = pcSource.getIgnoredPlayerNames();
|
|
||||||
String crlf = "\r\n";
|
|
||||||
String out = "Ignored players (" + ignoredPlayers.length + "):";
|
|
||||||
for (String name : ignoredPlayers) {
|
|
||||||
out += crlf + name;
|
|
||||||
}
|
|
||||||
ChatManager.chatSystemInfo(pcSource, out);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIX THIS, USE OUR CACHE!
|
|
||||||
PlayerCharacter pcToIgnore = PlayerCharacter.getByFirstName(nameToIgnore);
|
|
||||||
|
|
||||||
if (pcSource == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (pcToIgnore == null || pcToIgnore.getAccount() == null) {
|
|
||||||
ChatManager.chatSystemError(pcSource, "Character name " + nameToIgnore + " does not exist and cannot be ignored.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (pcToIgnore.getObjectUUID() == pcSource.getObjectUUID()) {
|
|
||||||
ChatManager.chatSystemError(pcSource, "Try as you might, you are unable to ignore yourself!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String fn = pcToIgnore.getFirstName();
|
|
||||||
|
|
||||||
Account ac = pcSource.getAccount();
|
|
||||||
|
|
||||||
if (ac == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (pcSource.isIgnoringPlayer(pcToIgnore)) {
|
|
||||||
|
|
||||||
if (ac != null) {
|
|
||||||
if (!DbManager.PlayerCharacterQueries.SET_IGNORE_LIST(ac.getObjectUUID(), pcToIgnore.getObjectUUID(), false, pcToIgnore.getFirstName())) {
|
|
||||||
ChatManager.chatSystemError(pcSource, "Unable to update database ignore list.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ChatManager.chatSystemError(pcSource, "Unable to update database ignore list.");
|
|
||||||
}
|
|
||||||
|
|
||||||
pcSource.removeIgnoredPlayer(pcToIgnore.getAccount());
|
|
||||||
ChatManager.chatSystemInfo(pcSource, "Character " + fn + " is no longer ignored.");
|
|
||||||
} else {
|
|
||||||
if (!PlayerCharacter.isIgnorable()) {
|
|
||||||
ChatManager.chatSystemError(pcSource, "This character cannot be ignored.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (PlayerCharacter.isIgnoreListFull()) {
|
|
||||||
ChatManager.chatSystemError(pcSource, "Your ignore list is already full.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ac != null) {
|
|
||||||
if (!DbManager.PlayerCharacterQueries.SET_IGNORE_LIST(ac.getObjectUUID(), pcToIgnore.getObjectUUID(), true, pcToIgnore.getFirstName())) {
|
|
||||||
ChatManager.chatSystemError(pcSource, "Unable to update database ignore list. This ignore will not persist past server down.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ChatManager.chatSystemError(pcSource, "Unable to update database ignore list.");
|
|
||||||
}
|
|
||||||
|
|
||||||
pcSource.addIgnoredPlayer(pcToIgnore.getAccount(), pcToIgnore.getFirstName());
|
|
||||||
ChatManager.chatSystemInfo(pcSource, "Character " + fn + " is now being ignored.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the unknown1
|
* @return the unknown1
|
||||||
*/
|
*/
|
||||||
|
|||||||
+3
-3
@@ -15,7 +15,7 @@ import engine.net.ByteBufferReader;
|
|||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.client.Protocol;
|
import engine.net.client.Protocol;
|
||||||
|
|
||||||
public class RecvSummonsRequestMsg extends ClientNetMsg {
|
public class RecvSummonsMsg extends ClientNetMsg {
|
||||||
|
|
||||||
private int sourceType;
|
private int sourceType;
|
||||||
private int sourceID;
|
private int sourceID;
|
||||||
@@ -26,7 +26,7 @@ public class RecvSummonsRequestMsg extends ClientNetMsg {
|
|||||||
/**
|
/**
|
||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
*/
|
*/
|
||||||
public RecvSummonsRequestMsg(int sourceType, int sourceID, String sourceName, String locationName, boolean accepted) {
|
public RecvSummonsMsg(int sourceType, int sourceID, String sourceName, String locationName, boolean accepted) {
|
||||||
super(Protocol.ARCSUMMON);
|
super(Protocol.ARCSUMMON);
|
||||||
this.sourceType = sourceType;
|
this.sourceType = sourceType;
|
||||||
this.sourceID = sourceID;
|
this.sourceID = sourceID;
|
||||||
@@ -41,7 +41,7 @@ public class RecvSummonsRequestMsg extends ClientNetMsg {
|
|||||||
* past the limit) then this constructor Throws that Exception to the
|
* past the limit) then this constructor Throws that Exception to the
|
||||||
* caller.
|
* caller.
|
||||||
*/
|
*/
|
||||||
public RecvSummonsRequestMsg(AbstractConnection origin, ByteBufferReader reader) {
|
public RecvSummonsMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||||
super(Protocol.ARCSUMMON, origin, reader);
|
super(Protocol.ARCSUMMON, origin, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,23 +10,18 @@
|
|||||||
package engine.net.client.msg;
|
package engine.net.client.msg;
|
||||||
|
|
||||||
|
|
||||||
import engine.gameManager.SessionManager;
|
import engine.net.AbstractConnection;
|
||||||
import engine.net.*;
|
import engine.net.ByteBufferReader;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.client.Protocol;
|
import engine.net.client.Protocol;
|
||||||
import engine.objects.*;
|
|
||||||
import engine.server.MBServerStatics;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
public class RefineMsg extends ClientNetMsg {
|
public class RefineMsg extends ClientNetMsg {
|
||||||
|
|
||||||
private int npcType;
|
private int npcType;
|
||||||
private int npcID;
|
public int npcID;
|
||||||
private int unknown01;
|
private int unknown01;
|
||||||
private int type;
|
public int type;
|
||||||
private int token;
|
public int token;
|
||||||
private int unknown02;
|
private int unknown02;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,122 +51,6 @@ public class RefineMsg extends ClientNetMsg {
|
|||||||
super(Protocol.ARCUNTRAINABILITY, origin, reader);
|
super(Protocol.ARCUNTRAINABILITY, origin, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void refine(RefineMsg msg, ClientConnection origin) {
|
|
||||||
if (origin == null)
|
|
||||||
return;
|
|
||||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
|
|
||||||
if (pc == null)
|
|
||||||
return;
|
|
||||||
NPC npc = NPC.getFromCache(msg.npcID);
|
|
||||||
if (npc == null)
|
|
||||||
return;
|
|
||||||
int type = msg.type;
|
|
||||||
int token = msg.token;
|
|
||||||
boolean worked = false;
|
|
||||||
boolean skillPower = true;
|
|
||||||
if (type == 0) { //refine skill
|
|
||||||
worked = refineSkill(origin, pc, token, msg);
|
|
||||||
} else if (type == 1) { //refine power
|
|
||||||
worked = refinePower(origin, pc, token, msg);
|
|
||||||
} else if (type == 2) { //refine stat
|
|
||||||
worked = refineStat(origin, pc, token, msg);
|
|
||||||
skillPower = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (worked) {
|
|
||||||
|
|
||||||
//update player
|
|
||||||
pc.applyBonuses();
|
|
||||||
pc.charItemManager.RemoveEquipmentFromLackOfSkill(pc, true);
|
|
||||||
|
|
||||||
//echo refine message back
|
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(pc, msg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
// if (type == 0 && token == 1488335491){
|
|
||||||
// dispatch = Dispatch.borrow(pc, msg);
|
|
||||||
// DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
|
||||||
// }
|
|
||||||
|
|
||||||
//resend refine screen
|
|
||||||
|
|
||||||
RefinerScreenMsg refinerScreenMsg = new RefinerScreenMsg(skillPower, npc.getSellPercent(pc)); //TODO set npc cost
|
|
||||||
dispatch = Dispatch.borrow(pc, refinerScreenMsg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
|
||||||
pc.recalculate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean refineSkill(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
|
||||||
CharacterSkill skill = null;
|
|
||||||
ConcurrentHashMap<String, CharacterSkill> skills = pc.getSkills();
|
|
||||||
for (CharacterSkill sk : skills.values()) {
|
|
||||||
if (sk == null)
|
|
||||||
continue;
|
|
||||||
SkillsBase sb = sk.getSkillsBase();
|
|
||||||
if (sb == null)
|
|
||||||
continue;
|
|
||||||
if (sb.getToken() == token)
|
|
||||||
skill = sk;
|
|
||||||
}
|
|
||||||
//check if player has skill to refine
|
|
||||||
if (skill == null)
|
|
||||||
return false;
|
|
||||||
//check there's a train to refine
|
|
||||||
if (skill.getNumTrains() < 1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//TODO verify if any skills have this as prereq
|
|
||||||
|
|
||||||
//TODO verify if any powers have this as a prereq
|
|
||||||
//get all players powers
|
|
||||||
for (CharacterPower power : pc.getPowers().values()) {
|
|
||||||
ArrayList<PowerReq> reqs = PowerReq.getPowerReqsForRune(power.getPowerID());
|
|
||||||
for (PowerReq req : reqs) {
|
|
||||||
ConcurrentHashMap<String, CharacterSkill> playerSkills = pc.getSkills();
|
|
||||||
CharacterSkill playerSkill = playerSkills.get(token);
|
|
||||||
int currentSkillLevel = playerSkill.getTotalSkillPercet();
|
|
||||||
if (token == req.getToken() && req.getLevel() == currentSkillLevel) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//refine skill
|
|
||||||
return skill.refine(pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean refinePower(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
|
||||||
CharacterPower power = null;
|
|
||||||
ConcurrentHashMap<Integer, CharacterPower> powers = pc.getPowers();
|
|
||||||
if (!powers.containsKey(token))
|
|
||||||
return false;
|
|
||||||
power = powers.get(token);
|
|
||||||
if (power == null)
|
|
||||||
return false;
|
|
||||||
if (power.getTrains() < 1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//TODO verify if any powers have this as a prereq
|
|
||||||
|
|
||||||
return power.refine(pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean refineStat(ClientConnection origin, PlayerCharacter pc, int token, RefineMsg msg) {
|
|
||||||
if (token == MBServerStatics.STAT_STR_ID)
|
|
||||||
return pc.refineStr();
|
|
||||||
if (token == MBServerStatics.STAT_DEX_ID)
|
|
||||||
return pc.refineDex();
|
|
||||||
if (token == MBServerStatics.STAT_CON_ID)
|
|
||||||
return pc.refineCon();
|
|
||||||
if (token == MBServerStatics.STAT_INT_ID)
|
|
||||||
return pc.refineInt(msg);
|
|
||||||
if (token == MBServerStatics.STAT_SPI_ID)
|
|
||||||
return pc.refineSpi();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+3
-3
@@ -15,7 +15,7 @@ import engine.net.ByteBufferReader;
|
|||||||
import engine.net.ByteBufferWriter;
|
import engine.net.ByteBufferWriter;
|
||||||
import engine.net.client.Protocol;
|
import engine.net.client.Protocol;
|
||||||
|
|
||||||
public class SendSummonsRequestMsg extends ClientNetMsg {
|
public class SendSummonsMsg extends ClientNetMsg {
|
||||||
|
|
||||||
private int powerToken;
|
private int powerToken;
|
||||||
private int sourceType;
|
private int sourceType;
|
||||||
@@ -26,7 +26,7 @@ public class SendSummonsRequestMsg extends ClientNetMsg {
|
|||||||
/**
|
/**
|
||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
*/
|
*/
|
||||||
public SendSummonsRequestMsg() {
|
public SendSummonsMsg() {
|
||||||
super(Protocol.POWERTARGNAME);
|
super(Protocol.POWERTARGNAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ public class SendSummonsRequestMsg extends ClientNetMsg {
|
|||||||
* past the limit) then this constructor Throws that Exception to the
|
* past the limit) then this constructor Throws that Exception to the
|
||||||
* caller.
|
* caller.
|
||||||
*/
|
*/
|
||||||
public SendSummonsRequestMsg(AbstractConnection origin, ByteBufferReader reader) {
|
public SendSummonsMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||||
super(Protocol.POWERTARGNAME, origin, reader);
|
super(Protocol.POWERTARGNAME, origin, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
+3
-3
@@ -16,12 +16,12 @@ import engine.net.ByteBufferWriter;
|
|||||||
import engine.net.client.Protocol;
|
import engine.net.client.Protocol;
|
||||||
|
|
||||||
|
|
||||||
public class StuckCommandMsg extends ClientNetMsg {
|
public class StuckMsg extends ClientNetMsg {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
*/
|
*/
|
||||||
public StuckCommandMsg() {
|
public StuckMsg() {
|
||||||
super(Protocol.STUCK);
|
super(Protocol.STUCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ public class StuckCommandMsg extends ClientNetMsg {
|
|||||||
* past the limit) then this constructor Throws that Exception to the
|
* past the limit) then this constructor Throws that Exception to the
|
||||||
* caller.
|
* caller.
|
||||||
*/
|
*/
|
||||||
public StuckCommandMsg(AbstractConnection origin, ByteBufferReader reader) {
|
public StuckMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||||
super(Protocol.STUCK, origin, reader);
|
super(Protocol.STUCK, origin, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
+3
-3
@@ -18,7 +18,7 @@ import engine.net.client.Protocol;
|
|||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
|
|
||||||
|
|
||||||
public class ViewResourcesMessage extends ClientNetMsg {
|
public class ViewResourcesMsg extends ClientNetMsg {
|
||||||
|
|
||||||
//resource hashes
|
//resource hashes
|
||||||
//0001240F
|
//0001240F
|
||||||
@@ -55,7 +55,7 @@ public class ViewResourcesMessage extends ClientNetMsg {
|
|||||||
* This is the general purpose constructor.
|
* This is the general purpose constructor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public ViewResourcesMessage(PlayerCharacter player) {
|
public ViewResourcesMsg(PlayerCharacter player) {
|
||||||
super(Protocol.VIEWRESOURCES);
|
super(Protocol.VIEWRESOURCES);
|
||||||
this.guild = null;
|
this.guild = null;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@@ -64,7 +64,7 @@ public class ViewResourcesMessage extends ClientNetMsg {
|
|||||||
/**
|
/**
|
||||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the ByteBuffer into a message. If a BufferUnderflow occurs (based on reading past the limit) then this constructor Throws that Exception to the caller.
|
* This constructor is used by NetMsgFactory. It attempts to deserialize the ByteBuffer into a message. If a BufferUnderflow occurs (based on reading past the limit) then this constructor Throws that Exception to the caller.
|
||||||
*/
|
*/
|
||||||
public ViewResourcesMessage(AbstractConnection origin, ByteBufferReader reader) {
|
public ViewResourcesMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||||
super(Protocol.VIEWRESOURCES, origin, reader);
|
super(Protocol.VIEWRESOURCES, origin, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,12 +53,12 @@ public class CharacterItemManager {
|
|||||||
private short inventoryWeight;
|
private short inventoryWeight;
|
||||||
private short equipWeight;
|
private short equipWeight;
|
||||||
private short vaultWeight;
|
private short vaultWeight;
|
||||||
private ClientConnection tradingWith;
|
public ClientConnection tradingWith;
|
||||||
private byte tradeCommitted;
|
private byte tradeCommitted;
|
||||||
private boolean tradeSuccess;
|
private boolean tradeSuccess;
|
||||||
private HashSet<Integer> trading;
|
private HashSet<Integer> trading;
|
||||||
private int goldTradingAmount;
|
private int goldTradingAmount;
|
||||||
private int tradeID = 0;
|
public int tradeID = 0;
|
||||||
|
|
||||||
public CharacterItemManager(AbstractCharacter ac) {
|
public CharacterItemManager(AbstractCharacter ac) {
|
||||||
super();
|
super();
|
||||||
@@ -411,7 +411,7 @@ public class CharacterItemManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean canTrade(PlayerCharacter playerA, PlayerCharacter playerB) {
|
public static synchronized boolean canTrade(PlayerCharacter playerA, PlayerCharacter playerB) {
|
||||||
|
|
||||||
if (playerA == null || playerB == null)
|
if (playerA == null || playerB == null)
|
||||||
return false;
|
return false;
|
||||||
@@ -444,298 +444,7 @@ public class CharacterItemManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean acceptTradeRequest(AcceptTradeRequestMsg msg) {
|
public synchronized boolean modifyCommitToTrade() {
|
||||||
|
|
||||||
PlayerCharacter source = (PlayerCharacter) this.getOwner();
|
|
||||||
PlayerCharacter target = PlayerCharacter.getFromCache(msg.getTargetID());
|
|
||||||
|
|
||||||
Dispatch dispatch;
|
|
||||||
|
|
||||||
if (source == null || !source.isAlive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (target == null || !target.isAlive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (this.tradingWith != null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!canTrade(source, target))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// verify characterTarget is in range
|
|
||||||
if (source.getLoc().distanceSquared2D(target.getLoc()) > sqr(MBServerStatics.TRADE_RANGE))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// TODO uncomment this block after we determine when we
|
|
||||||
// setBankOpen(false) and setVaultOpen(false)
|
|
||||||
/*
|
|
||||||
* CharacterItemManager cim1 = source.getCharItemManager();
|
|
||||||
* CharacterItemManager cim2 = characterTarget.getCharItemManager(); if (cim1 ==
|
|
||||||
* null) return false; if (cim2 == null) return false; if (cim1.isBankOpen())
|
|
||||||
* return false; if (cim2.isVaultOpen()) return false;
|
|
||||||
*/
|
|
||||||
ClientConnection sourceConn = source.getClientConnection();
|
|
||||||
ClientConnection targetConn = target.getClientConnection();
|
|
||||||
|
|
||||||
if (sourceConn == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (targetConn == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
CharacterItemManager toTradeWith = target.charItemManager;
|
|
||||||
|
|
||||||
if (toTradeWith == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Account sourceAccount = source.getAccount();
|
|
||||||
Account targetAccount = target.getAccount();
|
|
||||||
|
|
||||||
UpdateVaultMsg uvmSource = new UpdateVaultMsg(sourceAccount);
|
|
||||||
UpdateVaultMsg uvmTarget = new UpdateVaultMsg(targetAccount);
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(source, uvmSource);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(target, uvmTarget);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
|
||||||
|
|
||||||
this.setVaultOpen(false);
|
|
||||||
toTradeWith.setVaultOpen(false);
|
|
||||||
this.setBankOpen(false);
|
|
||||||
toTradeWith.setBankOpen(false);
|
|
||||||
|
|
||||||
OpenTradeWindowMsg otwm = new OpenTradeWindowMsg(msg.getUnknown01(), source, target);
|
|
||||||
|
|
||||||
// Only start trade if both players aren't already trading with
|
|
||||||
// someone
|
|
||||||
|
|
||||||
if (this.getTradingWith() != null || toTradeWith.getTradingWith() != null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
this.initializeTrade();
|
|
||||||
toTradeWith.initializeTrade();
|
|
||||||
this.setTradingWith(targetConn);
|
|
||||||
toTradeWith.setTradingWith(sourceConn);
|
|
||||||
this.tradeID = msg.getUnknown01();
|
|
||||||
toTradeWith.tradeID = msg.getUnknown01();
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(source, otwm);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(target, otwm);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean addItemToTradeWindow(AddItemToTradeWindowMsg msg) {
|
|
||||||
PlayerCharacter source = (PlayerCharacter) this.getOwner();
|
|
||||||
Dispatch dispatch;
|
|
||||||
|
|
||||||
if (source == null || !source.isAlive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
ClientConnection ccOther = this.getTradingWith();
|
|
||||||
|
|
||||||
if (ccOther == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
PlayerCharacter other = ccOther.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (other == null || !other.isAlive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
CharacterItemManager tradingWith = other.charItemManager;
|
|
||||||
|
|
||||||
if (tradingWith == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!canTrade(source, other))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Item i = Item.getFromCache(msg.getItemID());
|
|
||||||
|
|
||||||
if (i == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!this.doesCharOwnThisItem(i.getObjectUUID()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//can't add item to trade window twice
|
|
||||||
if (this.tradingContains(i))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//dupe check
|
|
||||||
if (!i.validForInventory(source.getClientConnection(), source, this))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!tradingWith.hasRoomTrade(i.template.item_wt)) {
|
|
||||||
dispatch = Dispatch.borrow(source, msg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(source, other);
|
|
||||||
|
|
||||||
this.setTradeCommitted((byte) 0);
|
|
||||||
tradingWith.setTradeCommitted((byte) 0);
|
|
||||||
|
|
||||||
this.addItemToTrade(i);
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(other, msg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
|
||||||
|
|
||||||
modifyCommitToTrade();
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(other, utwm);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.PRIMARY);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean addGoldToTradeWindow(AddGoldToTradeWindowMsg msg) {
|
|
||||||
|
|
||||||
PlayerCharacter source = (PlayerCharacter) this.getOwner();
|
|
||||||
Dispatch dispatch;
|
|
||||||
|
|
||||||
if (source == null || !source.isAlive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
ClientConnection ccOther = this.getTradingWith();
|
|
||||||
|
|
||||||
if (ccOther == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
PlayerCharacter other = ccOther.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (other == null || !other.isAlive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
CharacterItemManager tradingWith = other.charItemManager;
|
|
||||||
|
|
||||||
if (tradingWith == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
UpdateTradeWindowMsg utwm = new UpdateTradeWindowMsg(other, source);
|
|
||||||
UpdateTradeWindowMsg utwmOther = new UpdateTradeWindowMsg(source, other);
|
|
||||||
|
|
||||||
if (!canTrade(source, other))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
this.setTradeCommitted((byte) 0);
|
|
||||||
tradingWith.setTradeCommitted((byte) 0);
|
|
||||||
|
|
||||||
int amt = msg.getAmount();
|
|
||||||
|
|
||||||
if (amt <= 0) {
|
|
||||||
Logger.info(source.getFirstName() + " added negative gold to trade window. Dupe attempt FAILED!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amt > MBServerStatics.PLAYER_GOLD_LIMIT)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (this.getGoldInventory().getNumOfItems() - amt < 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
this.addGoldToTrade(amt);
|
|
||||||
|
|
||||||
// BONUS CODE BELOW: Thanks some unknown retard!
|
|
||||||
// sourceItemMan.updateInventory(sourceItemMan.getInventory(), true);
|
|
||||||
|
|
||||||
UpdateGoldMsg ugm = new UpdateGoldMsg(source);
|
|
||||||
ugm.configure();
|
|
||||||
|
|
||||||
modifyCommitToTrade();
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(source, utwm);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(source, ugm);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
dispatch = Dispatch.borrow(other, utwmOther);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean uncommitToTrade(UncommitToTradeMsg msg) {
|
|
||||||
|
|
||||||
PlayerCharacter source = (PlayerCharacter) this.getOwner();
|
|
||||||
|
|
||||||
if (source == null || !source.isAlive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
CharacterItemManager sourceItemMan = source.charItemManager;
|
|
||||||
|
|
||||||
if (sourceItemMan == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
sourceItemMan.setTradeCommitted((byte) 0);
|
|
||||||
|
|
||||||
ClientConnection ccOther = sourceItemMan.getTradingWith();
|
|
||||||
|
|
||||||
if (ccOther == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
PlayerCharacter other = ccOther.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (other == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!canTrade(source, other))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return modifyCommitToTrade();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean commitToTrade(CommitToTradeMsg msg) {
|
|
||||||
|
|
||||||
PlayerCharacter source = (PlayerCharacter) this.getOwner();
|
|
||||||
|
|
||||||
if (source == null || !source.isAlive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
|
|
||||||
this.setTradeCommitted((byte) 1);
|
|
||||||
|
|
||||||
ClientConnection ccOther = this.getTradingWith();
|
|
||||||
|
|
||||||
if (ccOther == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
PlayerCharacter other = ccOther.getPlayerCharacter();
|
|
||||||
|
|
||||||
if (other == null || !other.isAlive())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
CharacterItemManager tradingWith = other.charItemManager;
|
|
||||||
|
|
||||||
if (tradingWith == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!canTrade(source, other))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
modifyCommitToTrade();
|
|
||||||
|
|
||||||
if (this.getTradeCommitted() == (byte) 1 && tradingWith.getTradeCommitted() == (byte) 1) {
|
|
||||||
int tradeID = this.tradeID;
|
|
||||||
CloseTradeWindowMsg ctwm1 = new CloseTradeWindowMsg(source, tradeID);
|
|
||||||
CloseTradeWindowMsg ctwm2 = new CloseTradeWindowMsg(other, tradeID);
|
|
||||||
this.commitTrade();
|
|
||||||
this.closeTradeWindow(ctwm1, false);
|
|
||||||
other.charItemManager.closeTradeWindow(ctwm2, false);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized boolean modifyCommitToTrade() {
|
|
||||||
CharacterItemManager man1 = this;
|
CharacterItemManager man1 = this;
|
||||||
|
|
||||||
if (this.getTradingWith() == null)
|
if (this.getTradingWith() == null)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import engine.net.Dispatch;
|
|||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.client.msg.ErrorPopupMsg;
|
import engine.net.client.msg.ErrorPopupMsg;
|
||||||
import engine.net.client.msg.TaxResourcesMsg;
|
import engine.net.client.msg.TaxResourcesMsg;
|
||||||
import engine.net.client.msg.ViewResourcesMessage;
|
import engine.net.client.msg.ViewResourcesMsg;
|
||||||
import engine.powers.EffectsBase;
|
import engine.powers.EffectsBase;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
import engine.server.world.WorldServer;
|
import engine.server.world.WorldServer;
|
||||||
@@ -1387,7 +1387,7 @@ public class City extends AbstractWorldObject {
|
|||||||
|
|
||||||
// Member variable assignment
|
// Member variable assignment
|
||||||
|
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
ViewResourcesMsg vrm = new ViewResourcesMsg(player);
|
||||||
vrm.setGuild(building.getGuild());
|
vrm.setGuild(building.getGuild());
|
||||||
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().warehouse.building.getObjectUUID()));
|
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().warehouse.building.getObjectUUID()));
|
||||||
vrm.configure();
|
vrm.configure();
|
||||||
|
|||||||
@@ -147,7 +147,12 @@ public class Item extends AbstractWorldObject {
|
|||||||
|
|
||||||
this.canDestroy = true;
|
this.canDestroy = true;
|
||||||
|
|
||||||
this.equipSlot = EquipSlotType.values()[rs.getByte("equipSlot")];
|
String equipString = rs.getString("equipSlot");
|
||||||
|
|
||||||
|
if (equipString.isEmpty())
|
||||||
|
this.equipSlot = EquipSlotType.NONE;
|
||||||
|
else
|
||||||
|
this.equipSlot = EquipSlotType.valueOf(equipString);
|
||||||
|
|
||||||
this.numberOfItems = rs.getInt("numberOfItems");
|
this.numberOfItems = rs.getInt("numberOfItems");
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class Warehouse {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
ViewResourcesMsg vrm = new ViewResourcesMsg(player);
|
||||||
vrm.setGuild(player.getGuild());
|
vrm.setGuild(player.getGuild());
|
||||||
vrm.setWarehouseBuilding(warehouseBuilding);
|
vrm.setWarehouseBuilding(warehouseBuilding);
|
||||||
vrm.configure();
|
vrm.configure();
|
||||||
@@ -164,7 +164,7 @@ public class Warehouse {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
ViewResourcesMsg vrm = new ViewResourcesMsg(player);
|
||||||
vrm.setGuild(player.getGuild());
|
vrm.setGuild(player.getGuild());
|
||||||
vrm.setWarehouseBuilding(warehouseBuilding);
|
vrm.setWarehouseBuilding(warehouseBuilding);
|
||||||
vrm.configure();
|
vrm.configure();
|
||||||
@@ -205,7 +205,7 @@ public class Warehouse {
|
|||||||
worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse);
|
worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse);
|
||||||
|
|
||||||
if (worked) {
|
if (worked) {
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
ViewResourcesMsg vrm = new ViewResourcesMsg(player);
|
||||||
vrm.setGuild(player.getGuild());
|
vrm.setGuild(player.getGuild());
|
||||||
vrm.setWarehouseBuilding(warehouseBuilding);
|
vrm.setWarehouseBuilding(warehouseBuilding);
|
||||||
vrm.configure();
|
vrm.configure();
|
||||||
@@ -222,7 +222,7 @@ public class Warehouse {
|
|||||||
worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse);
|
worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse);
|
||||||
|
|
||||||
if (worked) {
|
if (worked) {
|
||||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
ViewResourcesMsg vrm = new ViewResourcesMsg(player);
|
||||||
vrm.setGuild(player.getGuild());
|
vrm.setGuild(player.getGuild());
|
||||||
vrm.setWarehouseBuilding(warehouseBuilding);
|
vrm.setWarehouseBuilding(warehouseBuilding);
|
||||||
vrm.configure();
|
vrm.configure();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import engine.math.Vector3fImmutable;
|
|||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.client.ClientConnection;
|
import engine.net.client.ClientConnection;
|
||||||
import engine.net.client.msg.RecvSummonsRequestMsg;
|
import engine.net.client.msg.RecvSummonsMsg;
|
||||||
import engine.objects.AbstractCharacter;
|
import engine.objects.AbstractCharacter;
|
||||||
import engine.objects.AbstractWorldObject;
|
import engine.objects.AbstractWorldObject;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
@@ -57,7 +57,7 @@ public class SummonPowerAction extends AbstractPowerAction {
|
|||||||
if (zone != null)
|
if (zone != null)
|
||||||
location = zone.zoneName;
|
location = zone.zoneName;
|
||||||
|
|
||||||
RecvSummonsRequestMsg rsrm = new RecvSummonsRequestMsg(source.getObjectType().ordinal(), source.getObjectUUID(), source.getFirstName(),
|
RecvSummonsMsg rsrm = new RecvSummonsMsg(source.getObjectType().ordinal(), source.getObjectUUID(), source.getFirstName(),
|
||||||
location, false);
|
location, false);
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(target, rsrm);
|
Dispatch dispatch = Dispatch.borrow(target, rsrm);
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import engine.job.JobScheduler;
|
|||||||
import engine.jobs.LogoutCharacterJob;
|
import engine.jobs.LogoutCharacterJob;
|
||||||
import engine.mobileAI.Threads.MobAIThread;
|
import engine.mobileAI.Threads.MobAIThread;
|
||||||
import engine.mobileAI.Threads.Respawner;
|
import engine.mobileAI.Threads.Respawner;
|
||||||
import engine.net.Dispatch;
|
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
import engine.net.ItemProductionManager;
|
import engine.net.ItemProductionManager;
|
||||||
import engine.net.Network;
|
import engine.net.Network;
|
||||||
@@ -33,8 +32,6 @@ import engine.net.client.ClientConnection;
|
|||||||
import engine.net.client.ClientConnectionManager;
|
import engine.net.client.ClientConnectionManager;
|
||||||
import engine.net.client.ClientMessagePump;
|
import engine.net.client.ClientMessagePump;
|
||||||
import engine.net.client.Protocol;
|
import engine.net.client.Protocol;
|
||||||
import engine.net.client.msg.RefinerScreenMsg;
|
|
||||||
import engine.net.client.msg.TrainerInfoMsg;
|
|
||||||
import engine.net.client.msg.UpdateStateMsg;
|
import engine.net.client.msg.UpdateStateMsg;
|
||||||
import engine.net.client.msg.chat.ChatSystemMsg;
|
import engine.net.client.msg.chat.ChatSystemMsg;
|
||||||
import engine.objects.*;
|
import engine.objects.*;
|
||||||
@@ -123,38 +120,6 @@ public class WorldServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void trainerInfo(TrainerInfoMsg msg, ClientConnection origin) {
|
|
||||||
|
|
||||||
NPC npc = NPC.getFromCache(msg.getObjectID());
|
|
||||||
float sellPercent = 1;
|
|
||||||
|
|
||||||
if (npc != null) {
|
|
||||||
|
|
||||||
if (origin.getPlayerCharacter() != null)
|
|
||||||
sellPercent = npc.getSellPercent(origin.getPlayerCharacter());
|
|
||||||
else
|
|
||||||
sellPercent = npc.getSellPercent();
|
|
||||||
|
|
||||||
msg.setTrainPercent(sellPercent); //TrainMsg.getTrainPercent(npc));
|
|
||||||
}
|
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void refinerScreen(RefinerScreenMsg msg, ClientConnection origin)
|
|
||||||
throws MsgSendException {
|
|
||||||
|
|
||||||
NPC npc = NPC.getFromCache(msg.getNpcID());
|
|
||||||
|
|
||||||
if (npc != null)
|
|
||||||
msg.setUnknown02(0); //cost to refine?
|
|
||||||
|
|
||||||
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUptimeString() {
|
public static String getUptimeString() {
|
||||||
|
|
||||||
String outString = null;
|
String outString = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user