PlayerInstance isOnline method should return a boolean value.

This commit is contained in:
MobiusDevelopment 2020-02-01 10:47:36 +00:00
parent ff157fe4bb
commit 29f2d60f28
39 changed files with 110 additions and 125 deletions

View File

@ -326,14 +326,14 @@ public class RecipeController
if ((_player == null) || (_target == null))
{
LOGGER.warning("player or target == null (disconnected?), aborting" + _target + _player);
LOGGER.warning("Player or target == null (disconnected?), aborting" + _target + _player);
abort();
return;
}
if ((_player.isOnline() == 0) || (_target.isOnline() == 0))
if (_player.isOnline() || _target.isOnline())
{
LOGGER.warning("player or target is not online, aborting " + _target + _player);
LOGGER.warning("Player or target is not online, aborting " + _target + _player);
abort();
return;
}
@ -342,12 +342,12 @@ public class RecipeController
{
if (_target != _player)
{
_target.sendMessage("Manufacture aborted");
_player.sendMessage("Manufacture aborted");
_target.sendMessage("Manufacture aborted.");
_player.sendMessage("Manufacture aborted.");
}
else
{
_player.sendMessage("Item creation aborted");
_player.sendMessage("Item creation aborted.");
}
abort();

View File

@ -327,15 +327,11 @@ abstract class AbstractAI implements Ctrl
@Override
public void notifyEvent(CtrlEvent evt, Object arg0, Object arg1)
{
if (!_actor.isVisible() || !_actor.hasAI() || ((_actor instanceof PlayerInstance) && (((PlayerInstance) _actor).isOnline() == 0)) || ((_actor instanceof PlayerInstance) && ((PlayerInstance) _actor).isInOfflineMode()))
if (!_actor.isVisible() || !_actor.hasAI() || ((_actor instanceof PlayerInstance) && !((PlayerInstance) _actor).isOnline()) || ((_actor instanceof PlayerInstance) && ((PlayerInstance) _actor).isInOfflineMode()))
{
return;
}
/*
* if (Config.DEBUG) LOGGER.warning("AbstractAI: notifyEvent -> " + evt + " " + arg0 + " " + arg1);
*/
switch (evt)
{
case EVT_THINK:
@ -744,7 +740,7 @@ abstract class AbstractAI implements Ctrl
if (_actor instanceof PlayerInstance)
{
if (!AttackStanceTaskManager.getInstance().getAttackStanceTask(_actor) && isAutoAttacking)
if (!AttackStanceTaskManager.getInstance().hasAttackStanceTask(_actor) && isAutoAttacking)
{
AttackStanceTaskManager.getInstance().addAttackStanceTask(_actor);
}

View File

@ -648,7 +648,7 @@ public class AttackableAI extends CreatureAI
final Creature originalAttackTarget = getAttackTarget();
// Check if target is dead or if timeout is expired to stop this attack
if ((originalAttackTarget == null) || originalAttackTarget.isAlikeDead() || ((originalAttackTarget instanceof PlayerInstance) && (((PlayerInstance) originalAttackTarget).isInOfflineMode() || (((PlayerInstance) originalAttackTarget).isOnline() == 0))) || (_attackTimeout < GameTimeController.getGameTicks()))
if ((originalAttackTarget == null) || originalAttackTarget.isAlikeDead() || ((originalAttackTarget instanceof PlayerInstance) && (((PlayerInstance) originalAttackTarget).isInOfflineMode() || !((PlayerInstance) originalAttackTarget).isOnline())) || (_attackTimeout < GameTimeController.getGameTicks()))
{
// Stop hating this target after the attack timeout or if target is dead
if (originalAttackTarget != null)

View File

@ -593,7 +593,7 @@ public class CreatureAI extends AbstractAI
// Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)
_actor.broadcastPacket(new AutoAttackStop(_actor.getObjectId()));
if (AttackStanceTaskManager.getInstance().getAttackStanceTask(_actor))
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(_actor))
{
AttackStanceTaskManager.getInstance().removeAttackStanceTask(_actor);
}
@ -625,7 +625,7 @@ public class CreatureAI extends AbstractAI
// Stop the actor auto-attack client side by sending Server->Client packet AutoAttackStop (broadcast)
_actor.broadcastPacket(new AutoAttackStop(_actor.getObjectId()));
if (AttackStanceTaskManager.getInstance().getAttackStanceTask(_actor))
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(_actor))
{
AttackStanceTaskManager.getInstance().removeAttackStanceTask(_actor);
}
@ -902,7 +902,7 @@ public class CreatureAI extends AbstractAI
// Stop an AI Follow Task
stopFollow();
if (!AttackStanceTaskManager.getInstance().getAttackStanceTask(_actor))
if (!AttackStanceTaskManager.getInstance().hasAttackStanceTask(_actor))
{
_actor.broadcastPacket(new AutoAttackStop(_actor.getObjectId()));
}

View File

@ -255,7 +255,7 @@ public class FriendsBBSManager extends BaseBBSManager
}
final PlayerInstance friend = World.getInstance().getPlayer(id);
StringUtil.append(sb, "<a action=\"bypass _friend;select;", id, "\">[Select]</a>&nbsp;", friendName, " ", (((friend != null) && (friend.isOnline() == 1)) ? "(on)" : "(off)"), "<br1>");
StringUtil.append(sb, "<a action=\"bypass _friend;select;", id, "\">[Select]</a>&nbsp;", friendName, " ", (((friend != null) && friend.isOnline()) ? "(on)" : "(off)"), "<br1>");
}
content = content.replace("%friendslist%", sb.toString());
@ -272,7 +272,7 @@ public class FriendsBBSManager extends BaseBBSManager
}
final PlayerInstance friend = World.getInstance().getPlayer(id);
StringUtil.append(sb, "<a action=\"bypass _friend;deselect;", id, "\">[Deselect]</a>&nbsp;", friendName, " ", (((friend != null) && (friend.isOnline() == 1)) ? "(on)" : "(off)"), "<br1>");
StringUtil.append(sb, "<a action=\"bypass _friend;deselect;", id, "\">[Deselect]</a>&nbsp;", friendName, " ", (((friend != null) && friend.isOnline()) ? "(on)" : "(off)"), "<br1>");
}
content = content.replace("%selectedFriendsList%", sb.toString());
@ -311,7 +311,7 @@ public class FriendsBBSManager extends BaseBBSManager
}
final PlayerInstance block = World.getInstance().getPlayer(id);
StringUtil.append(sb, "<a action=\"bypass _block;select;", id, "\">[Select]</a>&nbsp;", blockName, " ", (((block != null) && (block.isOnline() == 1)) ? "(on)" : "(off)"), "<br1>");
StringUtil.append(sb, "<a action=\"bypass _block;select;", id, "\">[Select]</a>&nbsp;", blockName, " ", (((block != null) && block.isOnline()) ? "(on)" : "(off)"), "<br1>");
}
content = content.replace("%blocklist%", sb.toString());
@ -328,7 +328,7 @@ public class FriendsBBSManager extends BaseBBSManager
}
final PlayerInstance block = World.getInstance().getPlayer(id);
StringUtil.append(sb, "<a action=\"bypass _block;deselect;", id, "\">[Deselect]</a>&nbsp;", blockName, " ", (((block != null) && (block.isOnline() == 1)) ? "(on)" : "(off)"), "<br1>");
StringUtil.append(sb, "<a action=\"bypass _block;deselect;", id, "\">[Deselect]</a>&nbsp;", blockName, " ", (((block != null) && block.isOnline()) ? "(on)" : "(off)"), "<br1>");
}
content = content.replace("%selectedBlocksList%", sb.toString());

View File

@ -941,13 +941,13 @@ public class AdminEditChar implements IAdminCommandHandler
{
final List<PlayerInstance> onlinePlayersList = new ArrayList<>();
for (PlayerInstance actual_player : World.getInstance().getAllPlayers())
for (PlayerInstance actualPlayer : World.getInstance().getAllPlayers())
{
if ((actual_player != null) && (actual_player.isOnline() == 1) && !actual_player.isInOfflineMode())
if ((actualPlayer != null) && actualPlayer.isOnline() && !actualPlayer.isInOfflineMode())
{
onlinePlayersList.add(actual_player);
onlinePlayersList.add(actualPlayer);
}
else if (actual_player == null)
else if (actualPlayer == null)
{
LOGGER.warning("listCharacters: found player null into World Instance..");
}

View File

@ -96,7 +96,7 @@ public class AdminTownWar implements IAdminCommandHandler
for (PlayerInstance onlinePlayer : pls)
{
if (onlinePlayer.isOnline() == 1)
if (onlinePlayer.isOnline())
{
x = onlinePlayer.getX();
y = onlinePlayer.getY();
@ -176,7 +176,7 @@ public class AdminTownWar implements IAdminCommandHandler
for (PlayerInstance onlinePlayer : pls)
{
if (onlinePlayer.isOnline() == 1)
if (onlinePlayer.isOnline())
{
x = onlinePlayer.getX();
y = onlinePlayer.getY();

View File

@ -227,7 +227,7 @@ public class Continuous implements ISkillHandler
}
// If target is not in game anymore...
if ((target instanceof PlayerInstance) && (((PlayerInstance) target).isOnline() == 0))
if ((target instanceof PlayerInstance) && !((PlayerInstance) target).isOnline())
{
continue;
}

View File

@ -82,7 +82,7 @@ public class OfflineShop implements IUserCommandHandler
player.getInventory().updateDatabase();
if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && (!player.isGM() || !Config.GM_RESTART_FIGHTING))
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player) && (!player.isGM() || !Config.GM_RESTART_FIGHTING))
{
player.sendPacket(SystemMessageId.CANT_LOGOUT_WHILE_FIGHTING);
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -83,7 +83,7 @@ public class OfflineShop implements IVoicedCommandHandler
player.getInventory().updateDatabase();
if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && (!player.isGM() || !Config.GM_RESTART_FIGHTING))
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player) && (!player.isGM() || !Config.GM_RESTART_FIGHTING))
{
player.sendPacket(SystemMessageId.CANT_LOGOUT_WHILE_FIGHTING);
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -525,7 +525,7 @@ public class ChristmasManager
{
continue;
}
else if (pc.isOnline() == 0)
else if (!pc.isOnline())
{
continue;
}
@ -590,7 +590,7 @@ public class ChristmasManager
{
continue;
}
else if (pc.isOnline() == 0)
else if (!pc.isOnline())
{
continue;
}

View File

@ -113,7 +113,7 @@ public class PetitionManager
public boolean endPetitionConsultation(PetitionState endState)
{
setState(endState);
if ((_responder != null) && (_responder.isOnline() == 1))
if ((_responder != null) && _responder.isOnline())
{
if (endState == PetitionState.Responder_Reject)
{
@ -137,7 +137,7 @@ public class PetitionManager
}
// End petition consultation and inform them, if they are still online.
if ((_petitioner != null) && (_petitioner.isOnline() == 1))
if ((_petitioner != null) && _petitioner.isOnline())
{
_petitioner.sendPacket(SystemMessageId.THIS_END_THE_PETITION_PLEASE_PROVIDE_FEEDBACK);
}
@ -183,7 +183,7 @@ public class PetitionManager
public void sendPetitionerPacket(GameServerPacket responsePacket)
{
if ((_petitioner == null) || (_petitioner.isOnline() == 0))
if ((_petitioner == null) || !_petitioner.isOnline())
{
return;
}
@ -193,7 +193,7 @@ public class PetitionManager
public void sendResponderPacket(GameServerPacket responsePacket)
{
if ((_responder == null) || (_responder.isOnline() == 0))
if ((_responder == null) || !_responder.isOnline())
{
endPetitionConsultation(PetitionState.Responder_Missing);
return;

View File

@ -83,7 +83,7 @@ public class CursedWeapon
{
if (_isActivated)
{
if ((_player != null) && (_player.isOnline() == 1))
if ((_player != null) && _player.isOnline())
{
// Remove from player
LOGGER.info(_name + " being removed online.");

View File

@ -121,12 +121,12 @@ public class Radar
{
try
{
if ((_me == null) || (_me.isOnline() == 0))
if ((_me == null) || !_me.isOnline())
{
return;
}
_me.sendPacket(new RadarControl(1, 1, _me.getX(), _me.getY(), _me.getZ()));
if ((_myTarget == null) || (_myTarget.isOnline() == 0) || !_myTarget._haveFlagCTF)
if ((_myTarget == null) || !_myTarget.isOnline() || !_myTarget._haveFlagCTF)
{
return;
}

View File

@ -691,10 +691,10 @@ public class Attackable extends NpcInstance
}
// Manage Base, Quests and Sweep drops of the Attackable
doItemDrop((maxDealer != null) && (maxDealer.isOnline() == 1) ? maxDealer : lastAttacker);
doItemDrop((maxDealer != null) && maxDealer.isOnline() ? maxDealer : lastAttacker);
// Manage drop of Special Events created by GM for a defined period
doEventDrop((maxDealer != null) && (maxDealer.isOnline() == 1) ? maxDealer : lastAttacker);
doEventDrop((maxDealer != null) && maxDealer.isOnline() ? maxDealer : lastAttacker);
if (!_mustGiveExpSp)
{
@ -1148,8 +1148,7 @@ public class Attackable extends NpcInstance
continue;
}
if (ai._attacker.isAlikeDead() || !getKnownList().knowsObject(ai._attacker) || !ai._attacker.isVisible() || ((ai._attacker instanceof PlayerInstance) && (((PlayerInstance) ai._attacker).isOnline() == 0) && !((PlayerInstance) ai._attacker).isInOfflineMode())) // if player go in
// offline
if (ai._attacker.isAlikeDead() || !getKnownList().knowsObject(ai._attacker) || !ai._attacker.isVisible() || ((ai._attacker instanceof PlayerInstance) && !((PlayerInstance) ai._attacker).isOnline() && !((PlayerInstance) ai._attacker).isInOfflineMode()))
{
ai._hate = 0;
}

View File

@ -573,7 +573,7 @@ public class CubicInstance
return;
}
if (owner.isDead() || (owner.isOnline() == 0))
if (owner.isDead() || !owner.isOnline())
{
stopAction();
owner.delCubic(_id);
@ -582,11 +582,11 @@ public class CubicInstance
return;
}
if (!AttackStanceTaskManager.getInstance().getAttackStanceTask(owner))
if (!AttackStanceTaskManager.getInstance().hasAttackStanceTask(owner))
{
if (owner.getPet() != null)
{
if (!AttackStanceTaskManager.getInstance().getAttackStanceTask(owner.getPet()))
if (!AttackStanceTaskManager.getInstance().hasAttackStanceTask(owner.getPet()))
{
stopAction();
return;
@ -1026,7 +1026,7 @@ public class CubicInstance
@Override
public void run()
{
if (_owner.isDead() || (_owner.isOnline() == 0))
if (_owner.isDead() || !_owner.isOnline())
{
stopAction();
_owner.delCubic(_id);

View File

@ -6848,7 +6848,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs12 = new CreatureSay(0, 15, "", getName() + " 5 consecutive kill! Only Gm."); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0) && player.isGM())
if ((player != null) && player.isOnline() && player.isGM())
{
player.sendPacket(cs12);
}
@ -6861,7 +6861,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs = new CreatureSay(0, 15, "", getName() + " is Dominating!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs);
}
@ -6873,7 +6873,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs2 = new CreatureSay(0, 15, "", getName() + " is on a Rampage!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs2);
}
@ -6885,7 +6885,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs3 = new CreatureSay(0, 15, "", getName() + " is on a Killing Spree!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs3);
}
@ -6897,7 +6897,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs4 = new CreatureSay(0, 15, "", getName() + " is on a Monster Kill!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs4);
}
@ -6909,7 +6909,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs5 = new CreatureSay(0, 15, "", getName() + " is Unstoppable!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs5);
}
@ -6921,7 +6921,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs6 = new CreatureSay(0, 15, "", getName() + " is on an Ultra Kill!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs6);
}
@ -6933,7 +6933,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs7 = new CreatureSay(0, 15, "", getName() + " God Blessed!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs7);
}
@ -6945,7 +6945,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs8 = new CreatureSay(0, 15, "", getName() + " is Wicked Sick!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs8);
}
@ -6957,7 +6957,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs9 = new CreatureSay(0, 15, "", getName() + " is on a Ludricrous Kill!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs9);
}
@ -6969,7 +6969,7 @@ public class PlayerInstance extends Playable
final CreatureSay cs10 = new CreatureSay(0, 15, "", getName() + " is GodLike!"); // 8D
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs10);
}
@ -8378,7 +8378,7 @@ public class PlayerInstance extends Playable
try (Connection con = DatabaseFactory.getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE obj_id=?");
statement.setInt(1, isOnline());
statement.setInt(1, isOnline() ? 1 : 0);
statement.setLong(2, System.currentTimeMillis());
statement.setInt(3, getObjectId());
statement.execute();
@ -8499,7 +8499,7 @@ public class PlayerInstance extends Playable
statement.setInt(46, hasDwarvenCraft() ? 1 : 0);
statement.setString(47, getTitle());
statement.setInt(48, getAccessLevel().getLevel());
statement.setInt(49, isOnline());
statement.setInt(49, isOnline() ? 1 : 0);
statement.setInt(50, isIn7sDungeon() ? 1 : 0);
statement.setInt(51, getClanPrivileges());
statement.setInt(52, getWantsPeace());
@ -9128,13 +9128,13 @@ public class PlayerInstance extends Playable
statement.setString(34, getTitle());
statement.setInt(35, getAccessLevel().getLevel());
if (_isInOfflineMode || (isOnline() == 1)) // in offline mode or online
if (_isInOfflineMode || isOnline()) // in offline mode or online
{
statement.setInt(36, 1);
}
else
{
statement.setInt(36, isOnline());
statement.setInt(36, isOnline() ? 1 : 0);
}
statement.setInt(37, isIn7sDungeon() ? 1 : 0);
@ -9310,13 +9310,12 @@ public class PlayerInstance extends Playable
}
/**
* Return True if the PlayerInstance is on line.<BR>
* <BR>
* @return the int
* Return True if the PlayerInstance is online.
* @return if player is online
*/
public int isOnline()
public boolean isOnline()
{
return _isOnline ? 1 : 0;
return _isOnline;
}
/**
@ -11436,7 +11435,7 @@ public class PlayerInstance extends Playable
@Override
public void run()
{
if (isOnline() == 1)
if (isOnline())
{
sendPacket(new SystemMessage(SystemMessageId.PLAYING_FOR_LONG_TIME));
}
@ -16154,7 +16153,7 @@ public class PlayerInstance extends Playable
final Collection<PlayerInstance> allPlayers = World.getInstance().getAllPlayers();
for (PlayerInstance player : allPlayers)
{
if ((player != null) && (player.isOnline() == 1) && (player.getClient() != null) && (player.getClient().getConnection() != null) && !player.getClient().getConnection().isClosed() && (player.getClient().getConnection().getInetAddress() != null) && !player.getName().equals(getName()))
if ((player != null) && player.isOnline() && (player.getClient() != null) && (player.getClient().getConnection() != null) && !player.getClient().getConnection().isClosed() && (player.getClient().getConnection().getInetAddress() != null) && !player.getName().equals(getName()))
{
final String ip = player.getClient().getConnection().getInetAddress().getHostAddress();
if (thisip.equals(ip) && (this != player))
@ -16198,7 +16197,7 @@ public class PlayerInstance extends Playable
for (PlayerInstance player : players)
{
if ((player != null) && (player.isOnline() == 1) && (player.getClient() != null) && (player.getClient().getConnection() != null) && !player.getClient().getConnection().isClosed() && !player.getName().equals(getName()))
if ((player != null) && player.isOnline() && (player.getClient() != null) && (player.getClient().getConnection() != null) && !player.getClient().getConnection().isClosed() && !player.getName().equals(getName()))
{
final String ip = player.getClient().getConnection().getInetAddress().getHostAddress();
if (thisip.equals(ip) && (this != player))

View File

@ -304,7 +304,7 @@ public class TamedBeastInstance extends FeedableBeastInstance
public void onOwnerGotAttacked(Creature attacker)
{
// check if the owner is no longer around...if so, despawn
if ((_owner == null) || (_owner.isOnline() == 0))
if ((_owner == null) || !_owner.isOnline())
{
doDespawn();
return;
@ -466,7 +466,7 @@ public class TamedBeastInstance extends FeedableBeastInstance
final PlayerInstance owner = _tamedBeast.getOwner();
// check if the owner is no longer around...if so, despawn
if ((owner == null) || (owner.isOnline() == 0))
if ((owner == null) || !owner.isOnline())
{
doDespawn();
return;

View File

@ -113,7 +113,7 @@ public class WeddingManagerInstance extends NpcInstance
final PlayerInstance ptarget = (PlayerInstance) World.getInstance().findObject(player.getPartnerId());
// partner online ?
if ((ptarget == null) || (ptarget.isOnline() == 0))
if ((ptarget == null) || !ptarget.isOnline())
{
filename = "data/html/mods/Wedding_notfound.htm";
sendHtmlMessage(player, filename, replace);

View File

@ -239,7 +239,7 @@ public class Announcements
final CreatureSay cs = new CreatureSay(0, 18, null, text);
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
if ((player != null) && player.isOnline())
{
player.sendPacket(cs);
}

View File

@ -1086,7 +1086,7 @@ public class CTF implements EventTask
{
if (player != null)
{
if (player.isOnline() != 0)
if (player.isOnline())
{
player.teleToLocation(_npcX, _npcY, _npcZ, false);
}
@ -1372,7 +1372,7 @@ public class CTF implements EventTask
{
_playersShuffle.remove(player);
}
else if ((player.isOnline() == 0) || player.isInJail() || player.isInOfflineMode())
else if (!player.isOnline() || player.isInJail() || player.isInOfflineMode())
{
removePlayer(player);
}
@ -2329,7 +2329,7 @@ public class CTF implements EventTask
{
for (PlayerInstance player : _players)
{
if ((player != null) && (player.isOnline() != 0) && (player._inEventCTF))
if ((player != null) && player.isOnline() && (player._inEventCTF))
{
if ((teamName != null) && (player._teamNameCTF.equals(teamName)))
{
@ -2604,7 +2604,7 @@ public class CTF implements EventTask
{
for (PlayerInstance player : _playersShuffle)
{
if ((player == null) || (player.isOnline() == 0))
if ((player == null) || !player.isOnline())
{
_playersShuffle.remove(player);
eventPlayer._inEventCTF = false;
@ -2816,8 +2816,9 @@ public class CTF implements EventTask
{
if (player != null)
{
if ((player.isOnline() == 0) && player._haveFlagCTF)
{ // logged off with a flag in his hands
// logged off with a flag in his hands
if (!player.isOnline() && player._haveFlagCTF)
{
Announcements.getInstance().gameAnnounceToAll(_eventName + ": " + player.getName() + " logged off with a CTF flag!");
player._haveFlagCTF = false;
if ((_teams.indexOf(player._teamNameHaveFlagCTF) >= 0) && _flagsTaken.get(_teams.indexOf(player._teamNameHaveFlagCTF)))
@ -3189,7 +3190,7 @@ public class CTF implements EventTask
{
for (PlayerInstance player : _players)
{
if ((player != null) && (player.isOnline() != 0) && player._teamNameCTF.equals(ourFlag))
if ((player != null) && player.isOnline() && player._teamNameCTF.equals(ourFlag))
{
player.sendMessage(hasFlag.getName() + " took your flag!");
if (player._haveFlagCTF)
@ -3340,6 +3341,6 @@ public class CTF implements EventTask
*/
public static boolean isOutsideCTFArea(PlayerInstance player)
{
return (player == null) || (player.isOnline() == 0) || (player.getX() <= (_eventCenterX - _eventOffset)) || (player.getX() >= (_eventCenterX + _eventOffset)) || (player.getY() <= (_eventCenterY - _eventOffset)) || (player.getY() >= (_eventCenterY + _eventOffset)) || (player.getZ() <= (_eventCenterZ - _eventOffset)) || (player.getZ() >= (_eventCenterZ + _eventOffset));
return (player == null) || !player.isOnline() || (player.getX() <= (_eventCenterX - _eventOffset)) || (player.getX() >= (_eventCenterX + _eventOffset)) || (player.getY() <= (_eventCenterY - _eventOffset)) || (player.getY() >= (_eventCenterY + _eventOffset)) || (player.getZ() <= (_eventCenterZ - _eventOffset)) || (player.getZ() >= (_eventCenterZ + _eventOffset));
}
}

View File

@ -1010,7 +1010,7 @@ public class DM implements EventTask
{
if (player != null)
{
if (player.isOnline() != 0)
if (player.isOnline())
{
player.teleToLocation(_npcX, _npcY, _npcZ, false);
}
@ -1291,7 +1291,7 @@ public class DM implements EventTask
continue;
}
if ((player._inEventDM && (player.isOnline() == 0)) || player.isInJail() || player.isInOfflineMode())
if ((player._inEventDM && !player.isOnline()) || player.isInJail() || player.isInOfflineMode())
{
if (!_joining)
{

View File

@ -43,7 +43,7 @@ public class PcPoint implements Runnable
int score = 0;
for (PlayerInstance player : World.getInstance().getAllPlayers())
{
if ((player.isOnline() == 1) && (player.getLevel() > Config.PCB_MIN_LEVEL) && !player.isInOfflineMode())
if (player.isOnline() && (player.getLevel() > Config.PCB_MIN_LEVEL) && !player.isInOfflineMode())
{
score = Rnd.get(Config.PCB_POINT_MIN, Config.PCB_POINT_MAX);

View File

@ -1025,7 +1025,7 @@ public class TvT implements EventTask
{
if (player != null)
{
if (player.isOnline() != 0)
if (player.isOnline())
{
player.teleToLocation(_npcX, _npcY, _npcZ, false);
}
@ -1310,7 +1310,7 @@ public class TvT implements EventTask
{
_playersShuffle.remove(player);
}
else if ((player.isOnline() == 0) || player.isInJail() || player.isInOfflineMode())
else if (!player.isOnline() || player.isInJail() || player.isInOfflineMode())
{
removePlayer(player);
}
@ -2217,7 +2217,7 @@ public class TvT implements EventTask
{
for (PlayerInstance player : _players)
{
if ((player != null) && (player.isOnline() != 0) && (player._inEventTvT) && (!player.equals(looser)) && ((player._countTvTkills > 0) || Config.TVT_PRICE_NO_KILLS))
if ((player != null) && player.isOnline() && (player._inEventTvT) && (!player.equals(looser)) && ((player._countTvTkills > 0) || Config.TVT_PRICE_NO_KILLS))
{
if ((bestKiller != null) && (bestKiller.equals(player)))
{
@ -2489,7 +2489,7 @@ public class TvT implements EventTask
{
for (PlayerInstance player : _playersShuffle)
{
if ((player == null) || (player.isOnline() == 0))
if ((player == null) || !player.isOnline())
{
_playersShuffle.remove(player);
eventPlayer._inEventTvT = false;
@ -2644,7 +2644,7 @@ public class TvT implements EventTask
{
_playersShuffle.remove(playerToKick);
removePlayer(playerToKick);
if (playerToKick.isOnline() != 0)
if (playerToKick.isOnline())
{
playerToKick.getAppearance().setNameColor(playerToKick._originalNameColorTvT);
playerToKick.setKarma(playerToKick._originalKarmaTvT);

View File

@ -790,7 +790,7 @@ class OlympiadGame
sm1 = new SystemMessage(SystemMessageId.THE_GAME_ENDED_IN_A_TIE);
broadcastMessage(sm1, true);
}
else if ((_playerTwo == null) || (_playerTwo.isOnline() == 0) || ((playerTwoHp == 0) && (playerOneHp != 0)) || ((_damageP1 > _damageP2) && (playerTwoHp != 0) && (playerOneHp != 0)))
else if ((_playerTwo == null) || !_playerTwo.isOnline() || ((playerTwoHp == 0) && (playerOneHp != 0)) || ((_damageP1 > _damageP2) && (playerTwoHp != 0) && (playerOneHp != 0)))
{
playerOneStat.set(POINTS, playerOnePoints + pointDiff);
playerTwoStat.set(POINTS, playerTwoPoints - pointDiff);
@ -824,7 +824,7 @@ class OlympiadGame
LOGGER.warning("Olympiad System: Game - " + _stadiumID + " on player validateWinner, an error has been occurred: " + e);
}
}
else if ((_playerOne == null) || (_playerOne.isOnline() == 0) || ((playerOneHp == 0) && (playerTwoHp != 0)) || ((_damageP2 > _damageP1) && (playerOneHp != 0) && (playerTwoHp != 0)))
else if ((_playerOne == null) || !_playerOne.isOnline() || ((playerOneHp == 0) && (playerTwoHp != 0)) || ((_damageP2 > _damageP1) && (playerOneHp != 0) && (playerTwoHp != 0)))
{
playerTwoStat.set(POINTS, playerTwoPoints + pointDiff);
playerOneStat.set(POINTS, playerOnePoints - pointDiff);
@ -1124,7 +1124,7 @@ class OlympiadGameTask implements Runnable
final PlayerInstance otherPlayer = _game._players.get(i ^ 1);
SystemMessage sm = null;
if ((player == null) || (player.isOnline() == 0))
if ((player == null) || !player.isOnline())
{
defaulted = true;
}

View File

@ -119,8 +119,7 @@ public class ArenaZone extends ZoneType
if (creature instanceof PlayerInstance)
{
final PlayerInstance player = (PlayerInstance) creature;
if (player.isOnline() == 1)
if (player.isOnline())
{
player.teleToLocation(TeleportWhereType.TOWN);
}

View File

@ -176,7 +176,7 @@ public class BossZone extends ZoneType
if (creature instanceof PlayerInstance)
{
final PlayerInstance player = (PlayerInstance) creature;
if (player.isOnline() == 1)
if (player.isOnline())
{
player.teleToLocation(x, y, z);
}
@ -199,7 +199,7 @@ public class BossZone extends ZoneType
}
// if the player just got disconnected/logged out, store the dc time so that decisions can be made later about allowing or not the player to LOGGER into the zone
if ((player.isOnline() == 0) && _playersAllowed.contains(creature.getObjectId()))
if (!player.isOnline() && _playersAllowed.contains(creature.getObjectId()))
{
// mark the time that the player left the zone
_playerAllowedReEntryTimes.put(creature.getObjectId(), System.currentTimeMillis() + _timeInvade);
@ -283,8 +283,7 @@ public class BossZone extends ZoneType
if (creature instanceof PlayerInstance)
{
final PlayerInstance player = (PlayerInstance) creature;
if (player.isOnline() == 1)
if (player.isOnline())
{
player.teleToLocation(TeleportWhereType.TOWN);
}
@ -338,7 +337,7 @@ public class BossZone extends ZoneType
if (creature instanceof PlayerInstance)
{
final PlayerInstance player = (PlayerInstance) creature;
if ((player.isOnline() == 1) || player.isInOfflineMode())
if (player.isOnline() || player.isInOfflineMode())
{
npcKnownPlayers.put(player.getObjectId(), player);
}

View File

@ -134,8 +134,7 @@ public class CastleTeleportZone extends ZoneType
if ((creature != null) && (creature instanceof PlayerInstance))
{
final PlayerInstance player = (PlayerInstance) creature;
if (player.isOnline() == 1)
if (player.isOnline())
{
player.teleToLocation(Rnd.get(_spawnLoc[0], _spawnLoc[1]), Rnd.get(_spawnLoc[2], _spawnLoc[3]), _spawnLoc[4]);
}

View File

@ -35,7 +35,7 @@ public class Appearing extends GameClientPacket
{
final PlayerInstance player = getClient().getPlayer();
if ((player == null) || (player.isOnline() == 0))
if ((player == null) || !player.isOnline())
{
sendPacket(ActionFailed.STATIC_PACKET);
return;

View File

@ -55,7 +55,7 @@ public class Logout extends GameClientPacket
player.getInventory().updateDatabase();
if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && (!player.isGM() || !Config.GM_RESTART_FIGHTING))
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player) && (!player.isGM() || !Config.GM_RESTART_FIGHTING))
{
player.sendPacket(SystemMessageId.CANT_LOGOUT_WHILE_FIGHTING);
player.sendPacket(ActionFailed.STATIC_PACKET);

View File

@ -139,7 +139,7 @@ public class RequestEnchantItem extends GameClientPacket
return;
}
if (player.isOnline() == 0)
if (!player.isOnline())
{
player.setActiveEnchantItem(null);
return;

View File

@ -46,7 +46,7 @@ public class RequestFriendInvite extends GameClientPacket
final PlayerInstance friend = World.getInstance().getPlayer(_name);
// can't use friend invite for locating invisible characters
if ((friend == null) || (friend.isOnline() == 1) || friend.getAppearance().isInvisible())
if ((friend == null) || friend.isOnline() || friend.getAppearance().isInvisible())
{
// Target is not found in the game.
player.sendPacket(SystemMessageId.THE_USER_YOU_REQUESTED_IS_NOT_IN_GAME);

View File

@ -53,7 +53,7 @@ public class RequestFriendList extends GameClientPacket
final PlayerInstance friend = World.getInstance().getPlayer(id);
player.sendPacket(SystemMessage.getSystemMessage(((friend == null) || (friend.isOnline() == 0)) ? SystemMessageId.S1_OFFLINE : SystemMessageId.S1_ONLINE).addString(friendName));
player.sendPacket(SystemMessage.getSystemMessage(((friend == null) || !friend.isOnline()) ? SystemMessageId.S1_OFFLINE : SystemMessageId.S1_ONLINE).addString(friendName));
}
// =========================

View File

@ -83,7 +83,7 @@ public class RequestRestart extends GameClientPacket
}
// Check if player is in combat
if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && (!player.isGM() || !Config.GM_RESTART_FIGHTING))
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(player) && (!player.isGM() || !Config.GM_RESTART_FIGHTING))
{
player.sendPacket(SystemMessageId.CANT_RESTART_WHILE_FIGHTING);
sendPacket(RestartResponse.valueOf(false));

View File

@ -54,7 +54,7 @@ public class FriendList extends GameServerPacket
final String name = CharNameTable.getInstance().getPlayerName(objId);
final PlayerInstance player1 = World.getInstance().getPlayer(objId);
_info.add(new FriendInfo(objId, name, ((player1 != null) && (player1.isOnline() == 1))));
_info.add(new FriendInfo(objId, name, ((player1 != null) && player1.isOnline())));
}
}

View File

@ -48,7 +48,7 @@ public class PartyMatchList extends GameServerPacket
for (PartyMatchRoom room : PartyMatchRoomList.getInstance().getRooms())
{
if ((room.getMembers() < 1) || (room.getOwner() == null) || (room.getOwner().isOnline() == 0) || (room.getOwner().getPartyRoom() != room.getId()))
if ((room.getMembers() < 1) || (room.getOwner() == null) || !room.getOwner().isOnline() || (room.getOwner().getPartyRoom() != room.getId()))
{
PartyMatchRoomList.getInstance().deleteRoom(room.getId());
continue;

View File

@ -27,7 +27,7 @@ public class PledgeShowMemberListAdd extends GameServerPacket
private String _name;
private int _lvl;
private int _classId;
private int _isOnline;
private int _objectId;
private int _pledgeType;
public PledgeShowMemberListAdd(PlayerInstance player)
@ -35,7 +35,7 @@ public class PledgeShowMemberListAdd extends GameServerPacket
_name = player.getName();
_lvl = player.getLevel();
_classId = player.getClassId().getId();
_isOnline = player.isOnline() == 1 ? player.getObjectId() : 0;
_objectId = player.isOnline() ? player.getObjectId() : 0;
_pledgeType = player.getPledgeType();
}
@ -46,7 +46,7 @@ public class PledgeShowMemberListAdd extends GameServerPacket
_name = cm.getName();
_lvl = cm.getLevel();
_classId = cm.getClassId();
_isOnline = cm.isOnline() ? cm.getObjectId() : 0;
_objectId = cm.isOnline() ? cm.getObjectId() : 0;
_pledgeType = cm.getPledgeType();
}
catch (Exception e)
@ -63,7 +63,7 @@ public class PledgeShowMemberListAdd extends GameServerPacket
writeD(_classId);
writeD(0);
writeD(1);
writeD(_isOnline); // 1=online 0=offline
writeD(_objectId); // 1=online 0=offline?
writeD(_pledgeType);
}
}

View File

@ -32,7 +32,7 @@ public class PledgeShowMemberListUpdate extends GameServerPacket
private final int _level;
private final int _classId;
private final int _objectId;
private int _isOnline;
private final boolean _isOnline;
public PledgeShowMemberListUpdate(PlayerInstance player)
{
@ -42,7 +42,7 @@ public class PledgeShowMemberListUpdate extends GameServerPacket
{
_hasSponsor = _player.getSponsor() != 0 ? 1 : 0;
}
else if (_player.isOnline() == 1)
else if (_player.isOnline())
{
_hasSponsor = _player.isClanLeader() ? 1 : 0;
}
@ -64,14 +64,7 @@ public class PledgeShowMemberListUpdate extends GameServerPacket
_level = player.getLevel();
_classId = player.getClassId();
_objectId = player.getObjectId();
if (player.isOnline())
{
_isOnline = 1;
}
else
{
_isOnline = 0;
}
_isOnline = _player.isOnline();
_pledgeType = player.getPledgeType();
if (_pledgeType == Clan.SUBUNIT_ACADEMY)
{
@ -96,7 +89,7 @@ public class PledgeShowMemberListUpdate extends GameServerPacket
writeD(_classId);
writeD(0);
writeD(_objectId);
writeD(_isOnline); // 1=online 0=offline
writeD(_isOnline ? 1 : 0); // 1=online 0=offline
writeD(_pledgeType);
writeD(_hasSponsor);
}

View File

@ -79,7 +79,7 @@ public class AttackStanceTaskManager
_attackStanceTasks.remove(actor);
}
public boolean getAttackStanceTask(Creature actor)
public boolean hasAttackStanceTask(Creature actor)
{
if (actor instanceof Summon)
{