Addition of .xpon/.xpoff voiced commands.

Contributed by ihearcolors.
This commit is contained in:
MobiusDevelopment 2020-05-14 09:32:56 +00:00
parent 801ec5b839
commit a858e674a3
6 changed files with 87 additions and 5 deletions

View File

@ -299,3 +299,11 @@ ConfigClassMaster = 1;[];[];2;[];[];3;[];[]
# Class Manager Handled Remotely at Level 20/40/76 # Class Manager Handled Remotely at Level 20/40/76
AllowRemoteClassMasters = True 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

View File

@ -1097,6 +1097,7 @@ public class Config
public static boolean ALLOW_CLASS_MASTERS_THIRD_CLASS; public static boolean ALLOW_CLASS_MASTERS_THIRD_CLASS;
public static ClassMasterSettings CLASS_MASTER_SETTINGS; public static ClassMasterSettings CLASS_MASTER_SETTINGS;
public static boolean ALLOW_REMOTE_CLASS_MASTERS; public static boolean ALLOW_REMOTE_CLASS_MASTERS;
public static boolean ENABLE_EXP_GAIN_COMMANDS;
public static long DEADLOCKCHECK_INTIAL_TIME; public static long DEADLOCKCHECK_INTIAL_TIME;
public static long DEADLOCKCHECK_DELAY_TIME; public static long DEADLOCKCHECK_DELAY_TIME;
@ -2788,6 +2789,7 @@ public class Config
ALLOW_CLASS_MASTERS_THIRD_CLASS = characterConfig.getBoolean("AllowClassMastersThirdClass", true); ALLOW_CLASS_MASTERS_THIRD_CLASS = characterConfig.getBoolean("AllowClassMastersThirdClass", true);
CLASS_MASTER_SETTINGS = new ClassMasterSettings(characterConfig.getString("ConfigClassMaster", "")); CLASS_MASTER_SETTINGS = new ClassMasterSettings(characterConfig.getString("ConfigClassMaster", ""));
ALLOW_REMOTE_CLASS_MASTERS = characterConfig.getBoolean("AllowRemoteClassMasters", false); ALLOW_REMOTE_CLASS_MASTERS = characterConfig.getBoolean("AllowRemoteClassMasters", false);
ENABLE_EXP_GAIN_COMMANDS = characterConfig.getBoolean("EnableExpGainCommands", false);
} }
public static void loadDaemonsConf() public static void loadDaemonsConf()

View File

@ -25,6 +25,7 @@ import org.l2jmobius.gameserver.handler.voicedcommandhandlers.BankingCmd;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.CTFCmd; import org.l2jmobius.gameserver.handler.voicedcommandhandlers.CTFCmd;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.DMCmd; import org.l2jmobius.gameserver.handler.voicedcommandhandlers.DMCmd;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.FarmPvpCmd; 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.OfflineShop;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.Online; import org.l2jmobius.gameserver.handler.voicedcommandhandlers.Online;
import org.l2jmobius.gameserver.handler.voicedcommandhandlers.StatsCmd; import org.l2jmobius.gameserver.handler.voicedcommandhandlers.StatsCmd;
@ -85,6 +86,11 @@ public class VoicedCommandHandler
registerVoicedCommandHandler(new OfflineShop()); registerVoicedCommandHandler(new OfflineShop());
} }
if (Config.ENABLE_EXP_GAIN_COMMANDS)
{
registerVoicedCommandHandler(new ExperienceGain());
}
LOGGER.info("VoicedCommandHandler: Loaded " + _datatable.size() + " handlers."); LOGGER.info("VoicedCommandHandler: Loaded " + _datatable.size() + " handlers.");
} }

View File

@ -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;
}
}

View File

@ -316,6 +316,7 @@ public class PlayerInstance extends Playable
public String _originalTitleAway; public String _originalTitleAway;
private boolean _isAio = false; private boolean _isAio = false;
private long _aioEndTime = 0; private long _aioEndTime = 0;
private boolean _expGain = true;
public int eventX; public int eventX;
public int eventY; public int eventY;
@ -15904,6 +15905,16 @@ public class PlayerInstance extends Playable
return _aioEndTime; return _aioEndTime;
} }
public void setExpGain(boolean value)
{
_expGain = value;
}
public boolean isExpGainEnabled()
{
return _expGain;
}
/** /**
* Gets the offline start time. * Gets the offline start time.
* @return the offline start time * @return the offline start time

View File

@ -52,8 +52,8 @@ public class PlayerStat extends PlayableStat
{ {
final PlayerInstance player = getActiveChar(); final PlayerInstance player = getActiveChar();
// Player is GM and access level is below or equal to canGainExp and is in party, don't give XP // Disable exp gain.
if (!getActiveChar().getAccessLevel().canGainExp() && getActiveChar().isInParty()) if (!player.getAccessLevel().canGainExp() || (Config.ENABLE_EXP_GAIN_COMMANDS && !getActiveChar().isExpGainEnabled()))
{ {
return false; return false;
} }
@ -63,7 +63,7 @@ public class PlayerStat extends PlayableStat
return false; return false;
} }
// Set new karma // Set new karma.
if (!player.isCursedWeaponEquiped() && (player.getKarma() > 0) && (player.isGM() || !player.isInsideZone(ZoneId.PVP))) if (!player.isCursedWeaponEquiped() && (player.getKarma() > 0) && (player.isGM() || !player.isInsideZone(ZoneId.PVP)))
{ {
final int karmaLost = player.calculateKarmaLost(value); final int karmaLost = player.calculateKarmaLost(value);
@ -95,9 +95,9 @@ public class PlayerStat extends PlayableStat
{ {
float ratioTakenByPet = 0; 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(); final PlayerInstance player = getActiveChar();
if (!player.getAccessLevel().canGainExp() && player.isInParty()) if (!player.getAccessLevel().canGainExp() || (Config.ENABLE_EXP_GAIN_COMMANDS && !getActiveChar().isExpGainEnabled()))
{ {
return false; return false;
} }