*/
public boolean engage(final Player activeChar)
{
if (activeChar.getTarget() == null)
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.NoneTargeted", activeChar));
return false;
}
if (!activeChar.getTarget().isPlayer())
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.OnlyAnotherPlayer", activeChar));
return false;
}
if (activeChar.getPartnerId() != 0)
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.AlreadyEngaged", activeChar));
if (Config.WEDDING_PUNISH_INFIDELITY)
{
activeChar.startAbnormalEffect(AbnormalEffect.BIG_HEAD);
int skillId;
int skillLevel = 1;
if (activeChar.getLevel() > 40)
{
skillLevel = 2;
}
if (activeChar.isMageClass())
{
skillId = 4361;
}
else
{
skillId = 4362;
}
Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);
if (activeChar.getEffectList().getEffectsBySkill(skill) == null)
{
skill.getEffects(activeChar, activeChar, false, false);
activeChar.sendPacket(new SystemMessage(SystemMessage.S1_S2S_EFFECT_CAN_BE_FELT).addSkillName(skillId, skillLevel));
}
}
return false;
}
final Player ptarget = (Player) activeChar.getTarget();
if (ptarget.getObjectId() == activeChar.getObjectId())
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.EngagingYourself", activeChar));
return false;
}
if (ptarget.isMaried())
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.PlayerAlreadyMarried", activeChar));
return false;
}
if (ptarget.getPartnerId() != 0)
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.PlayerAlreadyEngaged", activeChar));
return false;
}
Pair<Integer, OnAnswerListener> entry = ptarget.getAskListener(false);
if ((entry != null) && (entry.getValue() instanceof CoupleAnswerListener))
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.PlayerAlreadyAsked", activeChar));
return false;
}
if (ptarget.getPartnerId() != 0)
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.PlayerAlreadyEngaged", activeChar));
return false;
}
if ((ptarget.getSex() == activeChar.getSex()) && !Config.WEDDING_SAMESEX)
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.SameSex", activeChar));
return false;
}
boolean FoundOnFriendList = false;
int objectId;
Connection con = null;
PreparedStatement statement = null;
ResultSet rset = null;
try
{
con = DatabaseFactory.getInstance().getConnection();
statement = con.prepareStatement("SELECT friend_id FROM character_friends WHERE char_id=?");
statement.setInt(1, ptarget.getObjectId());
rset = statement.executeQuery();
while (rset.next())
{
objectId = rset.getInt("friend_id");
if (objectId == activeChar.getObjectId())
{
FoundOnFriendList = true;
break;
}
}
}
catch (Exception e)
{
_log.error("", e);
}
finally
{
DbUtils.closeQuietly(con, statement, rset);
}
if (!FoundOnFriendList)
{
activeChar.sendMessage(new CustomMessage("voicedcommandhandlers.Wedding.NotInFriendlist", activeChar));
return false;
}
ConfirmDlg packet = new ConfirmDlg(SystemMsg.S1, 60000).addString("Player " + activeChar.getName() + " asking you to engage. Do you want to start new relationship?");
ptarget.ask(packet, new CoupleAnswerListener(activeChar, ptarget));
return true;