Same thing after some cleanup.
Untested.
Index: dist/game/config/main/Character.ini
===================================================================
--- dist/game/config/main/Character.ini (revision 7034)
+++ dist/game/config/main/Character.ini (working copy)
@@ -299,3 +299,11 @@
# Class Manager Handled Remotely at Level 20/40/76
AllowRemoteClassMasters = True
+
+
+# ---------------------------------------------------------------------------
+# Voice-command for turning off XP-gain
+# ---------------------------------------------------------------------------
+# Player can use .xpoff to disable XP-gain, and .xpon to enable again.
+# Default: False
+EnableExpGainCommands = False
Index: java/org/l2jmobius/Config.java
===================================================================
--- java/org/l2jmobius/Config.java (revision 7148)
+++ java/org/l2jmobius/Config.java (working copy)
@@ -1097,6 +1097,7 @@
public static boolean ALLOW_CLASS_MASTERS_THIRD_CLASS;
public static ClassMasterSettings CLASS_MASTER_SETTINGS;
public static boolean ALLOW_REMOTE_CLASS_MASTERS;
+ public static boolean ENABLE_EXP_GAIN_COMMANDS;
public static long DEADLOCKCHECK_INTIAL_TIME;
public static long DEADLOCKCHECK_DELAY_TIME;
@@ -2788,6 +2789,7 @@
ALLOW_CLASS_MASTERS_THIRD_CLASS = characterConfig.getBoolean("AllowClassMastersThirdClass", true);
CLASS_MASTER_SETTINGS = new ClassMasterSettings(characterConfig.getString("ConfigClassMaster", ""));
ALLOW_REMOTE_CLASS_MASTERS = characterConfig.getBoolean("AllowRemoteClassMasters", false);
+ ENABLE_EXP_GAIN_COMMANDS = characterConfig.getBoolean("EnableExpGainCommands", false);
}
public static void loadDaemonsConf()
Index: java/org/l2jmobius/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- java/org/l2jmobius/gameserver/handler/VoicedCommandHandler.java (revision 7034)
+++ java/org/l2jmobius/gameserver/handler/VoicedCommandHandler.java (working copy)
@@ -25,6 +25,7 @@
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.CTFCmd;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.DMCmd;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.FarmPvpCmd;
+import org.l2jmobius.gameserver.handler.voicedcommandhandlers.ExperienceGain;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.OfflineShop;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.Online;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.StatsCmd;
@@ -84,6 +85,10 @@
{
registerVoicedCommandHandler(new OfflineShop());
}
+ if (Config.ENABLE_EXP_GAIN_COMMANDS)
+ {
+ registerVoicedCommandHandler(new ExperienceGain());
+ }
LOGGER.info("VoicedCommandHandler: Loaded " + _datatable.size() + " handlers.");
}
Index: java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/ExperienceGain.java
===================================================================
--- java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/ExperienceGain.java (nonexistent)
+++ java/org/l2jmobius/gameserver/handler/voicedcommandhandlers/ExperienceGain.java (working copy)
@@ -0,0 +1,55 @@
+/*
+ * This file is part of the L2J Mobius project.
+ *
+ * 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 org.l2jmobius.gameserver.handler.voicedcommandhandlers;
+
+import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
+import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
+
+/**
+ * This class allows user to turn XP-gain off and on.
+ * @author Notorious
+ */
+public class ExperienceGain implements IVoicedCommandHandler
+{
+ private static final String[] _voicedCommands =
+ {
+ "xpoff",
+ "xpon"
+ };
+
+ @Override
+ public boolean useVoicedCommand(String command, PlayerInstance activeChar, String params)
+ {
+ if (command.equalsIgnoreCase("xpoff"))
+ {
+ activeChar.setExpGain(false);
+ activeChar.sendMessage("Experience gain is disabled.");
+ }
+ else if (command.equalsIgnoreCase("xpon"))
+ {
+ activeChar.setExpGain(true);
+ activeChar.sendMessage("Experience gain is enabled.");
+ }
+ return true;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return _voicedCommands;
+ }
+}
\ No newline at end of file
Index: java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java
===================================================================
--- java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (revision 7158)
+++ java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java (working copy)
@@ -316,6 +316,7 @@
public String _originalTitleAway;
private boolean _isAio = false;
private long _aioEndTime = 0;
+ private boolean _expGain = true;
public int eventX;
public int eventY;
@@ -15898,6 +15899,16 @@
return _aioEndTime;
}
+ public void setExpGain(boolean value)
+ {
+ _expGain = value;
+ }
+
+ public boolean isExpGainEnabled()
+ {
+ return _expGain;
+ }
+
/**
* Gets the offline start time.
* @return the offline start time
Index: java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java
===================================================================
--- java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java (revision 7034)
+++ java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java (working copy)
@@ -52,8 +52,8 @@
{
final PlayerInstance player = getActiveChar();
- // Player is GM and access level is below or equal to canGainExp and is in party, don't give XP
- if (!getActiveChar().getAccessLevel().canGainExp() && getActiveChar().isInParty())
+ // Disable exp gain.
+ if (!player.getAccessLevel().canGainExp() || (Config.ENABLE_EXP_GAIN_COMMANDS && !getActiveChar().isExpGainEnabled()))
{
return false;
}
@@ -63,7 +63,7 @@
return false;
}
- // Set new karma
+ // Set new karma.
if (!player.isCursedWeaponEquiped() && (player.getKarma() > 0) && (player.isGM() || !player.isInsideZone(ZoneId.PVP)))
{
final int karmaLost = player.calculateKarmaLost(value);
@@ -95,9 +95,9 @@
{
float ratioTakenByPet = 0;
- // Player is GM and access level is below or equal to GM_DONT_TAKE_EXPSP and is in party, don't give Xp/Sp
+ // Disable exp gain.
final PlayerInstance player = getActiveChar();
- if (!player.getAccessLevel().canGainExp() && player.isInParty())
+ if (!player.getAccessLevel().canGainExp() || (Config.ENABLE_EXP_GAIN_COMMANDS && !getActiveChar().isExpGainEnabled()))
{
return false;
}