Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: config/altsettings.properties
- ===================================================================
- --- config/altsettings.properties (revision 4751)
- +++ config/altsettings.properties (working copy)
- @@ -520,3 +520,19 @@
- # -------------------------------------------------------------
- # Allow usage of mana potions
- AllowManaPotions = False
- +
- +# -------------------------------------------------------------
- +# Away System Config
- +# -------------------------------------------------------------
- +# Allow Players to change status Away
- +AllowAwayStatus = True
- +#Allow other Player target Away Player's
- +AwayAllowInterference = False
- +# Player take mobs aggro if he is Away
- +AwayPlayerTakeAggro = False
- +# Away status title Color (red 0000FF)
- +AwayTitleColor = 0000FF
- +# how many sec till player goes in away mode
- +AwayTimer = 30
- +# how many sec till player goes back from away mode
- +BackTimer = 30
- \ No newline at end of file
- Index: src/main/java/com/l2jfree/Config.java
- ===================================================================
- --- src/main/java/com/l2jfree/Config.java (revision 4751)
- +++ src/main/java/com/l2jfree/Config.java (working copy)
- @@ -1449,6 +1449,12 @@
- public static boolean ALT_ITEM_SKILLS_NOT_INFLUENCED;
- public static boolean ALT_MANA_POTIONS;
- public static int ALT_AUTOCHAT_DELAY;
- + public static boolean ALT_ALLOW_AWAY_STATUS;
- + public static int ALT_AWAY_TIMER;
- + public static int ALT_BACK_TIMER;
- + public static int ALT_AWAY_TITLE_COLOR;
- + public static boolean ALT_AWAY_ALLOW_INTERFERENCE;
- + public static boolean ALT_AWAY_PLAYER_TAKE_AGGRO;
- // *******************************************************************************************
- // *******************************************************************************************
- @@ -1662,6 +1668,12 @@
- ALT_MANA_POTIONS = Boolean.parseBoolean(altSettings.getProperty("AllowManaPotions", "false"));
- ALT_AUTOCHAT_DELAY = Integer.parseInt(altSettings.getProperty("AutoChatDelay", "30000"));
- + ALT_ALLOW_AWAY_STATUS = Boolean.parseBoolean(altSettings.getProperty("AllowAwayStatus", "False"));
- + ALT_AWAY_ALLOW_INTERFERENCE = Boolean.parseBoolean(altSettings.getProperty("AwayAllowInterference", "False"));
- + ALT_AWAY_PLAYER_TAKE_AGGRO = Boolean.parseBoolean(altSettings.getProperty("AwayPlayerTakeAggro", "False"));
- + ALT_AWAY_TITLE_COLOR = Integer.decode("0x" + altSettings.getProperty("AwayTitleColor", "0000FF"));
- + ALT_AWAY_TIMER = Integer.parseInt(altSettings.getProperty("AwayTimer", "30"));
- + ALT_BACK_TIMER = Integer.parseInt(altSettings.getProperty("BackTimer", "30"));
- }
- catch (Exception e)
- {
- Index: src/main/java/com/l2jfree/gameserver/ai/L2AttackableAI.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/ai/L2AttackableAI.java (revision 4751)
- +++ src/main/java/com/l2jfree/gameserver/ai/L2AttackableAI.java (working copy)
- @@ -200,10 +200,12 @@
- //event playere are also ignored
- if(player.isInFunEvent())
- return false;
- -
- // check if the target is within the grace period for JUST getting up from fake death
- if (player.isRecentFakeDeath())
- return false;
- + // check player is in away mod
- + if(player.isAway() && !Config.ALT_AWAY_PLAYER_TAKE_AGGRO)
- + return false;
- }
- // Check if the target is a L2Summon
- if (target instanceof L2Summon)
- Index: src/main/java/com/l2jfree/gameserver/communitybbs/Manager/RegionBBSManager.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/communitybbs/Manager/RegionBBSManager.java (revision 4751)
- +++ src/main/java/com/l2jfree/gameserver/communitybbs/Manager/RegionBBSManager.java (working copy)
- @@ -225,6 +225,11 @@
- return;
- }
- + if (receiver.isAway())
- + {
- + activeChar.sendMessage(receiver.getName() + " is Away please try again later.");
- + return;
- + }
- if (Config.LOG_CHAT)
- {
- LogRecord record = new LogRecord(Level.INFO, ar3);
- @@ -452,6 +457,8 @@
- if (player.isGM())
- htmlCode.append("<font color=\"LEVEL\">" + player.getName() + "</font>");
- + else if(player.isAway() && Config.ALT_ALLOW_AWAY_STATUS)
- + htmlCode.append(player.getName() + "*Away*");
- else if (player.getClan() != null && player.isClanLeader() && Config.SHOW_CLAN_LEADER
- && player.getClan().getLevel() >= Config.SHOW_CLAN_LEADER_CLAN_LEVEL)
- htmlCode.append("<font color=\"00FF00\">" + player.getName() + "</font>");
- Index: src/main/java/com/l2jfree/gameserver/GameServer.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/GameServer.java (revision 4751)
- +++ src/main/java/com/l2jfree/gameserver/GameServer.java (working copy)
- @@ -67,6 +67,7 @@
- import com.l2jfree.gameserver.handler.VoicedCommandHandler;
- import com.l2jfree.gameserver.idfactory.IdFactory;
- import com.l2jfree.gameserver.instancemanager.AuctionManager;
- +import com.l2jfree.gameserver.instancemanager.AwayManager;
- import com.l2jfree.gameserver.instancemanager.BoatManager;
- import com.l2jfree.gameserver.instancemanager.CastleManager;
- import com.l2jfree.gameserver.instancemanager.CastleManorManager;
- @@ -328,6 +329,11 @@
- FactionManager.getInstance();
- FactionQuestManager.getInstance();
- }
- + if (Config.ALT_ALLOW_AWAY_STATUS)
- + {
- + Util.printSection("Away System");
- + AwayManager.getInstance();
- + }
- try
- {
- DynamicExtension.getInstance();
- Index: src/main/java/com/l2jfree/gameserver/handler/chathandlers/ChatWhisper.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/handler/chathandlers/ChatWhisper.java (revision 4751)
- +++ src/main/java/com/l2jfree/gameserver/handler/chathandlers/ChatWhisper.java (working copy)
- @@ -52,6 +52,14 @@
- {
- if ((!receiver.getMessageRefusal() && !BlockList.isBlocked(receiver, activeChar)) || activeChar.isGM())
- {
- + if (receiver.isAway())
- + {
- + receiver.sendPacket(new CreatureSay(activeChar.getObjectId(), chatType.getId(), activeChar.getName(), text));
- + activeChar.sendPacket(new CreatureSay(activeChar.getObjectId(), chatType.getId(), "->" + receiver.getName(), text));
- + SystemMessage sm = new SystemMessage(SystemMessageId.S1);
- + sm.addString(target + " is Away try again later");
- + activeChar.sendPacket(sm);
- + }
- if (Config.JAIL_DISABLE_CHAT && receiver.isInJail())
- {
- activeChar.sendMessage(receiver.getName()+" is currently in jail.");
- Index: src/main/java/com/l2jfree/gameserver/handler/VoicedCommandHandler.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/handler/VoicedCommandHandler.java (revision 4751)
- +++ src/main/java/com/l2jfree/gameserver/handler/VoicedCommandHandler.java (working copy)
- @@ -45,6 +45,10 @@
- private VoicedCommandHandler()
- {
- _datatable = new FastMap<String, IVoicedCommandHandler>();
- + if (Config.ALT_ALLOW_AWAY_STATUS)
- + {
- + registerVoicedCommandHandler(new Away());
- + }
- registerVoicedCommandHandler(new CastleDoors());
- registerVoicedCommandHandler(new Hellbound());
- registerVoicedCommandHandler(new VersionInfo());
- Index: src/main/java/com/l2jfree/gameserver/handler/voicedcommandhandlers/Away.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/handler/voicedcommandhandlers/Away.java (revision 0)
- +++ src/main/java/com/l2jfree/gameserver/handler/voicedcommandhandlers/Away.java (revision 0)
- @@ -0,0 +1,140 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package com.l2jfree.gameserver.handler.voicedcommandhandlers;
- +
- +import com.l2jfree.gameserver.handler.IVoicedCommandHandler;
- +import com.l2jfree.gameserver.instancemanager.AwayManager;
- +import com.l2jfree.gameserver.instancemanager.SiegeManager;
- +import com.l2jfree.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfree.gameserver.model.entity.Siege;
- +
- +/**
- + * @author Michiru
- + *
- + */
- +public class Away implements IVoicedCommandHandler
- +{
- + private static final String[] VOICED_COMMANDS =
- + { "away", "back" };
- +
- + /* (non-Javadoc)
- + * @see com.l2jfree.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(String, com.l2jfree.gameserver.model.L2PcInstance), String)
- + */
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String text)
- + {
- + if (command.startsWith("away"))
- + return away(activeChar, text);
- + else if (command.startsWith("back"))
- + return back(activeChar);
- + return false;
- + }
- +
- + /* (non-Javadoc)
- + * @see com.l2jfree.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
- + */
- +
- + private boolean away(L2PcInstance activeChar, String text)
- + {
- + Siege siege = SiegeManager.getInstance().getSiege(activeChar);
- + //check char is all ready in away mode
- + if (activeChar.isAway())
- + {
- + activeChar.sendMessage("You are allready Away");
- + return false;
- + }
- +
- + //check player is death/fake death and movement disable
- + if (activeChar.isMovementDisabled() || activeChar.isAlikeDead())
- + return false;
- + // Check if player is in Siege
- + if (siege != null && siege.getIsInProgress())
- + {
- + activeChar.sendMessage("You are in siege, you can't go Afk.");
- + return false;
- + }
- + // Check if player is a Cursed Weapon owner
- + if (activeChar.isCursedWeaponEquipped())
- + {
- + activeChar.sendMessage("You can't go Afk! You are currently holding a cursed weapon.");
- + return false;
- + }
- + // Check if player is in Duel
- + if (activeChar.isInDuel())
- + {
- + activeChar.sendMessage("You can't go Afk! You are in a duel!");
- + return false;
- + }
- + //check is in DimensionsRift
- + if (activeChar.isInParty() && activeChar.getParty().isInDimensionalRift())
- + {
- + activeChar.sendMessage("You can't go Afk! You are in the dimensional rift.");
- + return false;
- + }
- + // Check to see if the player is in an event
- + if (activeChar.isInFunEvent())
- + {
- + activeChar.sendMessage("You can't go Afk! You are in event now.");
- + return false;
- + }
- + //check player is in Olympiade
- + if (activeChar.isInOlympiadMode())
- + {
- + activeChar.sendMessage("You can't go Afk! Your are fighting in Olympiad!");
- + return false;
- + }
- + // Check player is in observer mode
- + if (activeChar.inObserverMode())
- + {
- + activeChar.sendMessage("You can't go Afk in Observer mode!");
- + return false;
- + }
- + //check player have karma/pk/pvp status
- + if (activeChar.getKarma() > 0 || activeChar.getPvpFlag() > 0)
- + {
- + activeChar.sendMessage("Player in PVP or with Karma can't use the Away command!");
- + return false;
- + }
- + if (activeChar.isImmobilized())
- + return false;
- + //check away text have not more then 10 letter
- + if (text.length() > 10)
- + {
- + activeChar.sendMessage("You can't set your status Away with more then 10 letters");
- + return false;
- + }
- + // check if player have no one in target
- + if (activeChar.getTarget() == null && text.length() <= 1 || text.length() <= 10)
- +
- + //set this Player status away in AwayManager
- + AwayManager.getInstance().setAway(activeChar, text);
- + return true;
- + }
- +
- + private boolean back(L2PcInstance activeChar)
- + {
- + if (!activeChar.isAway())
- + {
- + activeChar.sendMessage("You are not Away!");
- + return false;
- + }
- + AwayManager.getInstance().setBack(activeChar);
- + return true;
- + }
- +
- + public String[] getVoicedCommandList()
- + {
- + return VOICED_COMMANDS;
- + }
- +}
- Index: src/main/java/com/l2jfree/gameserver/instancemanager/AwayManager.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/instancemanager/AwayManager.java (revision 0)
- +++ src/main/java/com/l2jfree/gameserver/instancemanager/AwayManager.java (revision 0)
- @@ -0,0 +1,186 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package com.l2jfree.gameserver.instancemanager;
- +
- +import java.util.Collections;
- +import java.util.Map;
- +import java.util.WeakHashMap;
- +
- +import org.apache.commons.logging.Log;
- +import org.apache.commons.logging.LogFactory;
- +
- +import com.l2jfree.Config;
- +import com.l2jfree.gameserver.ThreadPoolManager;
- +import com.l2jfree.gameserver.ai.CtrlIntention;
- +import com.l2jfree.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfree.gameserver.network.serverpackets.SetupGauge;
- +import com.l2jfree.gameserver.network.serverpackets.SocialAction;
- +
- +/**
- + * @author Michiru
- + *
- + */
- +public final class AwayManager
- +{
- + private static final Log _log = LogFactory.getLog(AwayManager.class.getName());
- + private static AwayManager _instance;
- + private Map<L2PcInstance, RestoreData> _awayPlayers;
- +
- + public static final AwayManager getInstance()
- + {
- + if (_instance == null)
- + {
- + _instance = new AwayManager();
- + _log.info("AwayManager: initialized.");
- + }
- + return _instance;
- + }
- +
- + private final class RestoreData
- + {
- + private final String _originalTitle;
- + private final int _originalTitleColor;
- + private final boolean _sitForced;
- +
- + public RestoreData(L2PcInstance activeChar)
- + {
- + _originalTitle = activeChar.getTitle();
- + _originalTitleColor = activeChar.getAppearance().getTitleColor();
- + _sitForced = !activeChar.isSitting();
- + }
- +
- + public boolean isSitForced()
- + {
- + return _sitForced;
- + }
- +
- + public void restore(L2PcInstance activeChar)
- + {
- + activeChar.getAppearance().setTitleColor(_originalTitleColor);
- + activeChar.setTitle(_originalTitle);
- + }
- + }
- +
- + private AwayManager()
- + {
- + _awayPlayers = Collections.synchronizedMap(new WeakHashMap<L2PcInstance, RestoreData>());
- + }
- +
- + /**
- + * @param activeChar
- + * @param text
- + */
- + public void setAway(L2PcInstance activeChar, String text)
- + {
- + activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 9));
- + activeChar.sendMessage("Your status is Away in " + Config.ALT_AWAY_TIMER + " Sec.");
- + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
- + SetupGauge sg = new SetupGauge(SetupGauge.BLUE, Config.ALT_AWAY_TIMER * 1000);
- + activeChar.sendPacket(sg);
- + activeChar.setIsImmobilized(true);
- + ThreadPoolManager.getInstance().scheduleGeneral(new setPlayerAwayTask(activeChar, text), Config.ALT_AWAY_TIMER * 1000);
- + }
- +
- + /**
- + * @param activeChar
- + */
- + public void setBack(L2PcInstance activeChar)
- + {
- + activeChar.sendMessage("You are back from Away Status in " + Config.ALT_BACK_TIMER + " Sec.");
- + SetupGauge sg = new SetupGauge(SetupGauge.BLUE, Config.ALT_BACK_TIMER * 1000);
- + activeChar.sendPacket(sg);
- + ThreadPoolManager.getInstance().scheduleGeneral(new setPlayerBackTask(activeChar), Config.ALT_BACK_TIMER * 1000);
- + }
- +
- + class setPlayerAwayTask implements Runnable
- + {
- +
- + private final L2PcInstance _activeChar;
- + private final String _awayText;
- +
- + setPlayerAwayTask(L2PcInstance activeChar, String awayText)
- + {
- + _activeChar = activeChar;
- + _awayText = awayText;
- + }
- +
- + public void run()
- + {
- + if (_activeChar == null)
- + return;
- + if (_activeChar.isAttackingNow() || _activeChar.isCastingNow())
- + return;
- +
- + _awayPlayers.put(_activeChar, new RestoreData(_activeChar));
- +
- + _activeChar.disableAllSkills();
- + _activeChar.abortAttack();
- + _activeChar.abortCast();
- + _activeChar.setTarget(null);
- + _activeChar.setIsImmobilized(false);
- + if (!_activeChar.isSitting())
- + _activeChar.sitDown(true);
- + if (_awayText.length() <= 1)
- + {
- + _activeChar.sendMessage("You are now *Away*");
- + }
- + else
- + {
- + _activeChar.sendMessage("You are now Away *" + _awayText + "*");
- + }
- + _activeChar.getAppearance().setTitleColor(Config.ALT_AWAY_TITLE_COLOR);
- + if (_awayText.length() <= 1)
- + {
- + _activeChar.setTitle("*Away*");
- + }
- + else
- + {
- + _activeChar.setTitle("Away*" + _awayText + "*");
- + }
- + _activeChar.broadcastUserInfo();
- + _activeChar.setIsParalyzed(true);
- + _activeChar.setIsAway(true);
- + }
- + }
- +
- + class setPlayerBackTask implements Runnable
- + {
- +
- + private final L2PcInstance _activeChar;
- +
- + setPlayerBackTask(L2PcInstance activeChar)
- + {
- + _activeChar = activeChar;
- + }
- +
- + public void run()
- + {
- + if (_activeChar == null)
- + return;
- + RestoreData rd = _awayPlayers.get(_activeChar);
- + if (rd == null)
- + return;
- + _activeChar.setIsParalyzed(false);
- + _activeChar.enableAllSkills();
- + _activeChar.setIsAway(false);
- + if (rd.isSitForced())
- + _activeChar.standUp();
- + rd.restore(_activeChar);
- + _awayPlayers.remove(_activeChar);
- + _activeChar.broadcastUserInfo();
- + _activeChar.sendMessage("You are Back now!");
- + }
- + }
- +}
- Index: src/main/java/com/l2jfree/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/model/actor/instance/L2PcInstance.java (revision 4751)
- +++ src/main/java/com/l2jfree/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -752,6 +752,11 @@
- private int _clientRevision = 0;
- + /** character away mode **/
- + private boolean _isAway = false;
- + public int _originalTitleColorAway;
- + public String _originalTitleAway;
- +
- private FactionMember _faction;
- /* Flag to disable equipment/skills while wearing formal wear **/
- @@ -2784,6 +2789,8 @@
- {
- sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up ...");
- }
- + else if (isAway())
- + sendMessage("You can't stand up if your Status is Away");
- else if (TvT._sitForced && _inEventTvT || CTF._sitForced && _inEventCTF || DM._sitForced && _inEventDM || VIP._sitForced && _inEventVIP)
- sendMessage("The Admin/GM handle if you sit or stand in this match!");
- else if (_waitTypeSitting && !isInStoreMode() && !isAlikeDead() && (!_protectedSitStand || force))
- @@ -3735,6 +3742,12 @@
- return;
- }
- + if (isAway() && !Config.ALT_AWAY_ALLOW_INTERFERENCE)
- + {
- + sendMessage("You can't target Away Players");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- if (Config.SIEGE_ONLY_REGISTERED)
- {
- if (!canBeTargetedByAtSiege(player))
- @@ -12995,7 +13008,17 @@
- {
- _olympiadOpponentId = value;
- }
- -
- +
- + public boolean isAway()
- + {
- + return _isAway;
- + }
- +
- + public void setIsAway(boolean state)
- + {
- + _isAway = state;
- + }
- +
- private ImmutableReference<L2PcInstance> _immutableReference;
- private ClearableReference<L2PcInstance> _clearableReference;
- Index: src/main/java/com/l2jfree/gameserver/network/clientpackets/Logout.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/network/clientpackets/Logout.java (revision 4751)
- +++ src/main/java/com/l2jfree/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -78,6 +78,13 @@
- player.sendMessage("You can not log out while flying.");
- return;
- }
- +
- + if (player.isAway())
- + {
- + player.sendMessage("You can't logout in Away mode.");
- + return;
- + }
- +
- // [L2J_JP ADD END]
- if(AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && !player.isGM())
- Index: src/main/java/com/l2jfree/gameserver/network/clientpackets/RequestRestart.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/network/clientpackets/RequestRestart.java (revision 4751)
- +++ src/main/java/com/l2jfree/gameserver/network/clientpackets/RequestRestart.java (working copy)
- @@ -66,6 +66,12 @@
- return;
- }
- + if (player.isAway())
- + {
- + player.sendMessage("You can't restart in Away mode.");
- + return;
- + }
- +
- if(player.atEvent)
- {
- player.sendMessage("A superior power doesn't allow you to leave the event.");
- Index: src/main/java/com/l2jfree/gameserver/network/L2IrcClient.java
- ===================================================================
- --- src/main/java/com/l2jfree/gameserver/network/L2IrcClient.java (revision 4751)
- +++ src/main/java/com/l2jfree/gameserver/network/L2IrcClient.java (working copy)
- @@ -337,8 +337,11 @@
- boolean _isFirst = true;
- for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- {
- - _onlineNames = _onlineNames + (_isFirst ? " " : ", ") + player.getName();
- - _isFirst = false;
- + if (player.isAway())
- + _onlineNames = _onlineNames + (_isFirst ? " " : ", ") + player.getName() + "*Away*";
- + else
- + _onlineNames = _onlineNames + (_isFirst ? " " : ", ") + player.getName();
- + _isFirst = false;
- }
- sendChan(_onlineNames);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement