Retail like builder messages.
Adapted from: L2jUnity free files.
This commit is contained in:
@ -400,6 +400,7 @@ public final class Config
|
||||
public static int DEFAULT_ACCESS_LEVEL;
|
||||
public static boolean SERVER_GMONLY;
|
||||
public static boolean GM_HERO_AURA;
|
||||
public static boolean GM_STARTUP_BUILDER_HIDE;
|
||||
public static boolean GM_STARTUP_INVULNERABLE;
|
||||
public static boolean GM_STARTUP_INVISIBLE;
|
||||
public static boolean GM_STARTUP_SILENCE;
|
||||
@ -413,6 +414,7 @@ public final class Config
|
||||
public static boolean GM_CRITANNOUNCER_NAME;
|
||||
public static boolean GM_GIVE_SPECIAL_SKILLS;
|
||||
public static boolean GM_GIVE_SPECIAL_AURA_SKILLS;
|
||||
public static boolean USE_SUPER_HASTE_AS_GM_SPEED;
|
||||
public static boolean GAMEGUARD_ENFORCE;
|
||||
public static boolean GAMEGUARD_PROHIBITACTION;
|
||||
public static boolean LOG_CHAT;
|
||||
@ -1814,6 +1816,7 @@ public final class Config
|
||||
DEFAULT_ACCESS_LEVEL = General.getInt("DefaultAccessLevel", 0);
|
||||
SERVER_GMONLY = General.getBoolean("ServerGMOnly", false);
|
||||
GM_HERO_AURA = General.getBoolean("GMHeroAura", false);
|
||||
GM_STARTUP_BUILDER_HIDE = General.getBoolean("GMStartupBuilderHide", false);
|
||||
GM_STARTUP_INVULNERABLE = General.getBoolean("GMStartupInvulnerable", false);
|
||||
GM_STARTUP_INVISIBLE = General.getBoolean("GMStartupInvisible", false);
|
||||
GM_STARTUP_SILENCE = General.getBoolean("GMStartupSilence", false);
|
||||
@ -1827,6 +1830,7 @@ public final class Config
|
||||
GM_CRITANNOUNCER_NAME = General.getBoolean("GMShowCritAnnouncerName", false);
|
||||
GM_GIVE_SPECIAL_SKILLS = General.getBoolean("GMGiveSpecialSkills", false);
|
||||
GM_GIVE_SPECIAL_AURA_SKILLS = General.getBoolean("GMGiveSpecialAuraSkills", false);
|
||||
USE_SUPER_HASTE_AS_GM_SPEED = General.getBoolean("UseSuperHasteAsGMSpeed", false);
|
||||
GAMEGUARD_ENFORCE = General.getBoolean("GameGuardEnforce", false);
|
||||
GAMEGUARD_PROHIBITACTION = General.getBoolean("GameGuardProhibitAction", false);
|
||||
LOG_CHAT = General.getBoolean("LogChat", false);
|
||||
|
@ -18,12 +18,26 @@ package com.l2jmobius.gameserver.handler;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.enums.PlayerAction;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
import com.l2jmobius.gameserver.util.TimeAmountInterpreter;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class AdminCommandHandler implements IHandler<IAdminCommandHandler, String>
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AdminCommandHandler.class.getName());
|
||||
|
||||
private final Map<String, IAdminCommandHandler> _datatable;
|
||||
|
||||
protected AdminCommandHandler()
|
||||
@ -49,10 +63,85 @@ public class AdminCommandHandler implements IHandler<IAdminCommandHandler, Strin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Please use {@link #useAdminCommand(L2PcInstance, String, boolean)} instead.
|
||||
*/
|
||||
@Override
|
||||
public IAdminCommandHandler getHandler(String adminCommand)
|
||||
{
|
||||
return _datatable.get(adminCommand.contains(" ") ? adminCommand.substring(0, adminCommand.indexOf(" ")) : adminCommand);
|
||||
String command = adminCommand;
|
||||
if (adminCommand.contains(" "))
|
||||
{
|
||||
command = adminCommand.substring(0, adminCommand.indexOf(" "));
|
||||
}
|
||||
return _datatable.get(command);
|
||||
}
|
||||
|
||||
public void useAdminCommand(L2PcInstance player, String fullCommand, boolean useConfirm)
|
||||
{
|
||||
final String command = fullCommand.split(" ")[0];
|
||||
final String commandNoPrefix = command.substring(6);
|
||||
|
||||
final IAdminCommandHandler handler = getHandler(command);
|
||||
if (handler == null)
|
||||
{
|
||||
if (player.isGM())
|
||||
{
|
||||
player.sendMessage("The command '" + commandNoPrefix + "' does not exist!");
|
||||
}
|
||||
LOGGER.warning("No handler registered for admin command '" + command + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AdminData.getInstance().hasAccess(command, player.getAccessLevel()))
|
||||
{
|
||||
player.sendMessage("You don't have the access rights to use this command!");
|
||||
LOGGER.warning("Player " + player.getName() + " tried to use admin command '" + command + "', without proper access level!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (useConfirm && AdminData.getInstance().requireConfirm(command))
|
||||
{
|
||||
player.setAdminConfirmCmd(fullCommand);
|
||||
final ConfirmDlg dlg = new ConfirmDlg(SystemMessageId.S1_3);
|
||||
dlg.addString("Are you sure you want execute command '" + commandNoPrefix + "' ?");
|
||||
player.addAction(PlayerAction.ADMIN_COMMAND);
|
||||
player.sendPacket(dlg);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Admin Commands must run through a long running task, otherwise a command that takes too much time will freeze the server, this way you'll feel only a minor spike.
|
||||
ThreadPool.execute(() ->
|
||||
{
|
||||
final long begin = System.currentTimeMillis();
|
||||
try
|
||||
{
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
final L2Object target = player.getTarget();
|
||||
GMAudit.auditGMAction(player.getName() + " [" + player.getObjectId() + "]", fullCommand, (target != null ? target.getName() : "no-target"));
|
||||
}
|
||||
|
||||
handler.useAdminCommand(fullCommand, player);
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
player.sendMessage("Exception during execution of '" + fullCommand + "': " + e.toString());
|
||||
LOGGER.warning("Exception during execution of " + fullCommand + " " + e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
final long runtime = System.currentTimeMillis() - begin;
|
||||
|
||||
if (runtime < 5000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage("The execution of '" + fullCommand + "' took " + TimeAmountInterpreter.consolidateMillis(runtime) + ".");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,11 +152,11 @@ public class AdminCommandHandler implements IHandler<IAdminCommandHandler, Strin
|
||||
|
||||
public static AdminCommandHandler getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final AdminCommandHandler _instance = new AdminCommandHandler();
|
||||
protected static final AdminCommandHandler INSTANCE = new AdminCommandHandler();
|
||||
}
|
||||
}
|
||||
|
@ -98,8 +98,6 @@ import com.l2jmobius.gameserver.enums.SubclassInfoType;
|
||||
import com.l2jmobius.gameserver.enums.Team;
|
||||
import com.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import com.l2jmobius.gameserver.geoengine.GeoEngine;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.handler.ItemHandler;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
@ -338,7 +336,6 @@ import com.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
import com.l2jmobius.gameserver.util.EnumIntBitmask;
|
||||
import com.l2jmobius.gameserver.util.FloodProtectors;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
@ -10055,8 +10052,9 @@ public final class L2PcInstance extends L2Playable
|
||||
{
|
||||
startWarnUserTakeBreak();
|
||||
|
||||
if (isGM())
|
||||
if (isGM() && !Config.GM_STARTUP_BUILDER_HIDE)
|
||||
{
|
||||
// Bleah, see L2J custom below.
|
||||
if (isInvul())
|
||||
{
|
||||
sendMessage("Entering world in Invulnerable mode.");
|
||||
@ -13789,50 +13787,6 @@ public final class L2PcInstance extends L2Playable
|
||||
return (super.isVisibleFor(player) || ((player.getParty() != null) && (player.getParty() == getParty())));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fullCommand
|
||||
*/
|
||||
public void useAdminCommand(String fullCommand)
|
||||
{
|
||||
final String command = fullCommand.split(" ")[0];
|
||||
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);
|
||||
if (ach == null)
|
||||
{
|
||||
if (isGM())
|
||||
{
|
||||
sendMessage("The command " + command.substring(6) + " does not exist!");
|
||||
}
|
||||
LOGGER.warning("No handler registered for admin command '" + command + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AdminData.getInstance().hasAccess(command, getAccessLevel()))
|
||||
{
|
||||
sendMessage("You don't have the access rights to use this command!");
|
||||
LOGGER.warning("Character " + getName() + " tried to use admin command " + command + ", without proper access level!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (AdminData.getInstance().requireConfirm(command))
|
||||
{
|
||||
setAdminConfirmCmd(fullCommand);
|
||||
final ConfirmDlg dlg = new ConfirmDlg(SystemMessageId.S1_3);
|
||||
dlg.addString("Are you sure you want execute command " + fullCommand.substring(6) + " ?");
|
||||
addAction(PlayerAction.ADMIN_COMMAND);
|
||||
sendPacket(dlg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(getName() + " [" + getObjectId() + "]", fullCommand, (getTarget() != null ? getTarget().getName() : "no-target"));
|
||||
}
|
||||
|
||||
ach.useAdminCommand(fullCommand, this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Quest zone ID.
|
||||
* @param id the quest zone ID
|
||||
|
@ -16,12 +16,9 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.enums.PlayerAction;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDlgAnswer;
|
||||
@ -30,7 +27,6 @@ import com.l2jmobius.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SummonRequestHolder;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
|
||||
/**
|
||||
* @author Dezmond_snz
|
||||
@ -75,16 +71,9 @@ public final class DlgAnswer implements IClientIncomingPacket
|
||||
{
|
||||
return;
|
||||
}
|
||||
final String command = cmd.split(" ")[0];
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);
|
||||
if (AdminData.getInstance().hasAccess(command, activeChar.getAccessLevel()))
|
||||
{
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", cmd, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
|
||||
}
|
||||
ach.useAdminCommand(cmd, activeChar);
|
||||
}
|
||||
|
||||
// The 'useConfirm' must be disabled here, as we don't want to repeat that process.
|
||||
AdminCommandHandler.getInstance().useAdminCommand(activeChar, cmd, false);
|
||||
}
|
||||
}
|
||||
else if ((_messageId == SystemMessageId.C1_IS_ATTEMPTING_TO_DO_A_RESURRECTION_THAT_RESTORES_S2_S3_XP_ACCEPT.getId()) || (_messageId == SystemMessageId.YOUR_CHARM_OF_COURAGE_IS_TRYING_TO_RESURRECT_YOU_WOULD_YOU_LIKE_TO_RESURRECT_NOW.getId()))
|
||||
|
@ -103,6 +103,7 @@ import com.l2jmobius.gameserver.network.serverpackets.attendance.ExVipAttendance
|
||||
import com.l2jmobius.gameserver.network.serverpackets.dailymission.ExConnectedTimeAndGettableReward;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayReceiveRewardList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList;
|
||||
import com.l2jmobius.gameserver.util.BuilderUtil;
|
||||
|
||||
/**
|
||||
* Enter World Packet Handler
|
||||
@ -210,35 +211,50 @@ public class EnterWorld implements IClientIncomingPacket
|
||||
// Apply special GM properties to the GM when entering
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
if (Config.GM_STARTUP_INVULNERABLE && AdminData.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel()))
|
||||
gmStartupProcess:
|
||||
{
|
||||
activeChar.setIsInvul(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_INVISIBLE && AdminData.getInstance().hasAccess("admin_invisible", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setInvisible(true);
|
||||
activeChar.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.STEALTH);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_SILENCE && AdminData.getInstance().hasAccess("admin_silence", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setSilenceMode(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_DIET_MODE && AdminData.getInstance().hasAccess("admin_diet", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.refreshOverloaded(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_AUTO_LIST && AdminData.getInstance().hasAccess("admin_gmliston", activeChar.getAccessLevel()))
|
||||
{
|
||||
AdminData.getInstance().addGm(activeChar, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdminData.getInstance().addGm(activeChar, true);
|
||||
if (Config.GM_STARTUP_BUILDER_HIDE && AdminData.getInstance().hasAccess("admin_hide", activeChar.getAccessLevel()))
|
||||
{
|
||||
BuilderUtil.setHiding(activeChar, true);
|
||||
|
||||
BuilderUtil.sendSysMessage(activeChar, "hide is default for builder.");
|
||||
BuilderUtil.sendSysMessage(activeChar, "FriendAddOff is default for builder.");
|
||||
BuilderUtil.sendSysMessage(activeChar, "whisperoff is default for builder.");
|
||||
|
||||
// It isn't recommend to use the below custom L2J GMStartup functions together with retail-like GMStartupBuilderHide, so breaking the process at that stage.
|
||||
break gmStartupProcess;
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_INVULNERABLE && AdminData.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setIsInvul(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_INVISIBLE && AdminData.getInstance().hasAccess("admin_invisible", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setInvisible(true);
|
||||
activeChar.getEffectList().startAbnormalVisualEffect(AbnormalVisualEffect.STEALTH);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_SILENCE && AdminData.getInstance().hasAccess("admin_silence", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setSilenceMode(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_DIET_MODE && AdminData.getInstance().hasAccess("admin_diet", activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.refreshOverloaded(true);
|
||||
}
|
||||
|
||||
if (Config.GM_STARTUP_AUTO_LIST && AdminData.getInstance().hasAccess("admin_gmliston", activeChar.getAccessLevel()))
|
||||
{
|
||||
AdminData.getInstance().addGm(activeChar, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdminData.getInstance().addGm(activeChar, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.GM_GIVE_SPECIAL_SKILLS)
|
||||
|
@ -23,6 +23,7 @@ import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.BypassHandler;
|
||||
import com.l2jmobius.gameserver.handler.CommunityBoardHandler;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
@ -133,7 +134,7 @@ public final class RequestBypassToServer implements IClientIncomingPacket
|
||||
{
|
||||
if (_command.startsWith("admin_"))
|
||||
{
|
||||
activeChar.useAdminCommand(_command);
|
||||
AdminCommandHandler.getInstance().useAdminCommand(activeChar, _command, true);
|
||||
}
|
||||
else if (CommunityBoardHandler.getInstance().isCommunityBoardCommand(_command))
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
@ -107,7 +108,7 @@ public final class RequestDestroyItem implements IClientIncomingPacket
|
||||
{
|
||||
count = ((L2ItemInstance) obj).getCount();
|
||||
}
|
||||
activeChar.useAdminCommand("admin_delete_item " + _objectId + " " + count);
|
||||
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_delete_item " + _objectId + " " + count, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.BypassHandler;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
@ -45,7 +46,7 @@ public class RequestTutorialLinkHtml implements IClientIncomingPacket
|
||||
|
||||
if (_bypass.startsWith("admin_"))
|
||||
{
|
||||
player.useAdminCommand(_bypass);
|
||||
AdminCommandHandler.getInstance().useAdminCommand(player, _bypass, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.BypassHandler;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
@ -46,7 +47,7 @@ public class RequestTutorialPassCmdToServer implements IClientIncomingPacket
|
||||
|
||||
if (_bypass.startsWith("admin_"))
|
||||
{
|
||||
player.useAdminCommand(_bypass);
|
||||
AdminCommandHandler.getInstance().useAdminCommand(player, _bypass, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -16,14 +16,10 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
|
||||
/**
|
||||
* This class handles all GM commands triggered by //command
|
||||
@ -56,33 +52,6 @@ public final class SendBypassBuildCmd implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
final String command = "admin_" + _command.split(" ")[0];
|
||||
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(command);
|
||||
|
||||
if (ach == null)
|
||||
{
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
activeChar.sendMessage("The command " + command.substring(6) + " does not exists!");
|
||||
}
|
||||
|
||||
LOGGER.warning("No handler registered for admin command '" + command + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AdminData.getInstance().hasAccess(command, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access right to use this command!");
|
||||
LOGGER.warning("Character " + activeChar.getName() + " tryed to use admin command " + command + ", but have no access to it!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", _command, (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));
|
||||
}
|
||||
|
||||
ach.useAdminCommand("admin_" + _command, activeChar);
|
||||
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_" + _command, true);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.ai.NextAction;
|
||||
import com.l2jmobius.gameserver.enums.ItemSkillType;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.handler.ItemHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortSiegeManager;
|
||||
@ -95,7 +96,7 @@ public final class UseItem implements IClientIncomingPacket
|
||||
final L2Object obj = L2World.getInstance().findObject(_objectId);
|
||||
if (obj instanceof L2ItemInstance)
|
||||
{
|
||||
activeChar.useAdminCommand("admin_use_item " + _objectId);
|
||||
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_use_item " + _objectId, true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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 com.l2jmobius.gameserver.util;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoAbnormalVisualEffect;
|
||||
|
||||
/**
|
||||
* @author lord_rex
|
||||
*/
|
||||
public final class BuilderUtil
|
||||
{
|
||||
private BuilderUtil()
|
||||
{
|
||||
// utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends builder system message to the player.
|
||||
* @param player
|
||||
* @param message
|
||||
*/
|
||||
public static void sendSysMessage(L2PcInstance player, String message)
|
||||
{
|
||||
player.sendPacket(new CreatureSay(0, ChatType.GENERAL, "SYS", message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes player's hiding state.
|
||||
* @param player
|
||||
* @param hide
|
||||
* @return {@code true} if hide state was changed, otherwise {@code false}
|
||||
*/
|
||||
public static boolean setHiding(L2PcInstance player, boolean hide)
|
||||
{
|
||||
if (player.isInvisible() && hide)
|
||||
{
|
||||
// already hiding
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player.isInvisible() && !hide)
|
||||
{
|
||||
// already visible
|
||||
return false;
|
||||
}
|
||||
|
||||
player.setSilenceMode(hide);
|
||||
player.setIsInvul(hide);
|
||||
player.setInvisible(hide);
|
||||
|
||||
player.broadcastUserInfo();
|
||||
player.sendPacket(new ExUserInfoAbnormalVisualEffect(player));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 1999 CERN - European Organization for Nuclear Research.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear in
|
||||
* supporting documentation. CERN makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without expressed or implied warranty.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.util;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Allows to present time intervals in a standardized, user friendly manner.
|
||||
* @author _dev_
|
||||
*/
|
||||
public class TimeAmountInterpreter
|
||||
{
|
||||
private static final TimeUnit[] UNIT_CACHE = TimeUnit.values();
|
||||
|
||||
private TimeAmountInterpreter()
|
||||
{
|
||||
// utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #consolidate(long, TimeUnit)} with {@link TimeUnit#NANOSECONDS}.
|
||||
* @param timeAmountInNanos amount of time in nanoseconds
|
||||
* @return an user-friendly description of the given time amount
|
||||
*/
|
||||
public static String consolidateNanos(long timeAmountInNanos)
|
||||
{
|
||||
return consolidate(timeAmountInNanos, NANOSECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #consolidate(long, TimeUnit)} with {@link TimeUnit#MILLISECONDS}.
|
||||
* @param timeAmountInMillis amount of time in milliseconds
|
||||
* @return an user-friendly description of the given time amount
|
||||
*/
|
||||
public static String consolidateMillis(long timeAmountInMillis)
|
||||
{
|
||||
return consolidate(timeAmountInMillis, MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an user-friendly description of the given amount of time, specifying the number of days (if any), hours (if any), minutes (if any), seconds (if any) and milliseconds (if any). Otherwise, returns the string value {@code 0}.
|
||||
* @param timeAmount amount of time to be written
|
||||
* @param timeUnit unit of the given amount
|
||||
* @return an user-friendly description of the given time amount
|
||||
*/
|
||||
public static String consolidate(long timeAmount, TimeUnit timeUnit)
|
||||
{
|
||||
return consolidate(timeAmount, timeUnit, timeUnit, DAYS, "0 " + timeUnit.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an user-friendly description of the given amount of time.
|
||||
* @param timeAmount amount of time to be written
|
||||
* @param timeUnit unit of the given amount
|
||||
* @param minConsolidationUnit smallest unit to be included within the description
|
||||
* @param maxConsolidationUnit largest unit to be included within the description
|
||||
* @param noTimeUsedIndicator text to be written if the amount is not positive
|
||||
* @return an user-friendly description of the given time amount
|
||||
*/
|
||||
public static String consolidate(long timeAmount, TimeUnit timeUnit, TimeUnit minConsolidationUnit, TimeUnit maxConsolidationUnit, String noTimeUsedIndicator)
|
||||
{
|
||||
return appendConsolidated(new StringBuilder(), timeAmount, timeUnit, minConsolidationUnit, maxConsolidationUnit, noTimeUsedIndicator).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an user-friendly description of the given amount of time to the specified text builder.<BR>
|
||||
* <BR>
|
||||
* Please keep in mind, that this method is primarily designed to be used with heap text builders. Therefore, if the given text builder throws an {@link IOException}, this exception will be wrapped in a {@link RuntimeException} and returned to the caller as an unchecked exception.
|
||||
* @param <T>
|
||||
* @param textBuilder a character sequence builder
|
||||
* @param timeAmount amount of time to be written
|
||||
* @param timeUnit unit of the given amount
|
||||
* @param minConsolidationUnit smallest unit to be included within the description
|
||||
* @param maxConsolidationUnit largest unit to be included within the description
|
||||
* @param noTimeUsedIndicator text to be written if the amount is not positive
|
||||
* @return {@code textBuilder}
|
||||
* @throws RuntimeException if {@code textBuilder} throws an {@link IOException}
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Appendable & CharSequence> T appendConsolidated(T textBuilder, long timeAmount, TimeUnit timeUnit, TimeUnit minConsolidationUnit, TimeUnit maxConsolidationUnit, String noTimeUsedIndicator) throws RuntimeException
|
||||
{
|
||||
try
|
||||
{
|
||||
if (timeAmount < 1)
|
||||
{
|
||||
return (T) textBuilder.append(noTimeUsedIndicator);
|
||||
}
|
||||
|
||||
final int len = textBuilder.length();
|
||||
for (int i = maxConsolidationUnit.ordinal(); i >= minConsolidationUnit.ordinal(); --i)
|
||||
{
|
||||
final TimeUnit activeUnit = UNIT_CACHE[i];
|
||||
final long num = activeUnit.convert(timeAmount, timeUnit);
|
||||
if (num == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (textBuilder.length() > len)
|
||||
{
|
||||
textBuilder.append(", ");
|
||||
}
|
||||
textBuilder.append(String.valueOf(num)).append(' ');
|
||||
final String unit = activeUnit.name().toLowerCase(Locale.ENGLISH);
|
||||
textBuilder.append(unit, 0, num == 1 ? unit.length() - 1 : unit.length());
|
||||
|
||||
timeAmount -= timeUnit.convert(num, activeUnit);
|
||||
}
|
||||
|
||||
if (textBuilder.length() == len)
|
||||
{
|
||||
return (T) textBuilder.append(noTimeUsedIndicator).append(' ').append(minConsolidationUnit.name().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return textBuilder;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user