Retail like builder messages.

Adapted from: L2jUnity free files.
This commit is contained in:
MobiusDev 2018-05-03 22:30:45 +00:00
parent cdcd780e7a
commit 8e76b4772d
188 changed files with 5621 additions and 1645 deletions

View File

@ -158,8 +158,6 @@
<admin command="admin_earthquake_menu" accessLevel="100" />
<admin command="admin_bighead" accessLevel="100" />
<admin command="admin_shrinkhead" accessLevel="100" />
<admin command="admin_gmspeed" accessLevel="100" />
<admin command="admin_gmspeed_menu" accessLevel="100" />
<admin command="admin_unpara_all" accessLevel="100" />
<admin command="admin_para_all" accessLevel="100" />
<admin command="admin_unpara" accessLevel="100" />
@ -189,6 +187,13 @@
<admin command="admin_set_displayeffect_menu" accessLevel="100" />
<admin command="admin_playmovie" accessLevel="100" />
<!-- ADMIN SPEED -->
<admin command="admin_gmspeed" accessLevel="100" />
<admin command="admin_superhaste" accessLevel="100" />
<admin command="admin_superhaste_menu" accessLevel="100" />
<admin command="admin_speed" accessLevel="100" />
<admin command="admin_speed_menu" accessLevel="100" />
<!-- ADMIN ELEMENT -->
<admin command="admin_setlh" accessLevel="100" />
<admin command="admin_setlc" accessLevel="100" />
@ -615,4 +620,7 @@
<admin command="banchat" accessLevel="100" />
<admin command="debug" accessLevel="100" />
<admin command="unbanchat" accessLevel="100" />
<!-- HIDE -->
<admin command="admin_hide" accessLevel="100" />
</list>

View File

@ -25,6 +25,10 @@ ServerGMOnly = False
# Default: False
GMHeroAura = False
# Whether GM logins in builder hide mode by default.
# Default: True
GMStartupBuilderHide = True
# Auto set invulnerable status to a GM on login.
# Default: False
GMStartupInvulnerable = True
@ -79,6 +83,11 @@ GMGiveSpecialSkills = False
# Default: False
GMGiveSpecialAuraSkills = False
# In case you are not satisfied with the retail-like implementation of //gmspeed",
# with this config you can rollback it to the old custom L2J version of the GM Speed.
# Default: False
UseSuperHasteAsGMSpeed = False
# ---------------------------------------------------------------------------
# Server Security

View File

@ -38,11 +38,11 @@
</table><br1>
<table width=270><tr>
<td><font color="LEVEL">Super Haste:</font></td>
<td><button value="1" action="bypass -h admin_gmspeed_menu 1" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="2" action="bypass -h admin_gmspeed_menu 2" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="3" action="bypass -h admin_gmspeed_menu 3" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="4" action="bypass -h admin_gmspeed_menu 4" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Off" action="bypass -h admin_gmspeed_menu 0" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="1" action="bypass -h admin_superhaste 1" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="2" action="bypass -h admin_superhaste 2" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="3" action="bypass -h admin_superhaste 3" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="4" action="bypass -h admin_superhaste 4" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Off" action="bypass -h admin_superhaste 0" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr></table><br>
<center><multiedit var="new_announcement" width=250 height=50></center>
<table width="160"><tr>

View File

@ -84,9 +84,11 @@ import handlers.admincommandhandlers.AdminFortSiege;
import handlers.admincommandhandlers.AdminGeodata;
import handlers.admincommandhandlers.AdminGm;
import handlers.admincommandhandlers.AdminGmChat;
import handlers.admincommandhandlers.AdminGmSpeed;
import handlers.admincommandhandlers.AdminGraciaSeeds;
import handlers.admincommandhandlers.AdminGrandBoss;
import handlers.admincommandhandlers.AdminHeal;
import handlers.admincommandhandlers.AdminHide;
import handlers.admincommandhandlers.AdminHtml;
import handlers.admincommandhandlers.AdminHwid;
import handlers.admincommandhandlers.AdminInstance;
@ -126,6 +128,7 @@ import handlers.admincommandhandlers.AdminShutdown;
import handlers.admincommandhandlers.AdminSkill;
import handlers.admincommandhandlers.AdminSpawn;
import handlers.admincommandhandlers.AdminSummon;
import handlers.admincommandhandlers.AdminSuperHaste;
import handlers.admincommandhandlers.AdminTarget;
import handlers.admincommandhandlers.AdminTargetSay;
import handlers.admincommandhandlers.AdminTeleport;
@ -413,9 +416,11 @@ public class MasterHandler
AdminGeodata.class,
AdminGm.class,
AdminGmChat.class,
AdminGmSpeed.class,
AdminGraciaSeeds.class,
AdminGrandBoss.class,
AdminHeal.class,
AdminHide.class,
AdminHtml.class,
AdminHwid.class,
AdminInstance.class,
@ -455,6 +460,7 @@ public class MasterHandler
AdminSkill.class,
AdminSpawn.class,
AdminSummon.class,
AdminSuperHaste.class,
AdminTarget.class,
AdminTargetSay.class,
AdminTeleport.class,

View File

@ -19,7 +19,6 @@ package handlers.actionshifthandlers;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -37,11 +36,7 @@ public class L2PcInstanceActionShift implements IActionShiftHandler
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_character_info");
if (ach != null)
{
ach.useAdminCommand("admin_character_info " + target.getName(), activeChar);
}
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_character_info " + target.getName(), true);
}
return true;
}

View File

@ -19,7 +19,6 @@ package handlers.actionshifthandlers;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -36,11 +35,7 @@ public class L2SummonActionShift implements IActionShiftHandler
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_summon_info");
if (ach != null)
{
ach.useAdminCommand("admin_summon_info", activeChar);
}
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_summon_info", true);
}
return true;
}

View File

@ -19,7 +19,6 @@ package handlers.admincommandhandlers;
import java.util.Arrays;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.enums.Movie;
import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
@ -34,7 +33,6 @@ import com.l2jmobius.gameserver.model.html.PageBuilder;
import com.l2jmobius.gameserver.model.html.PageResult;
import com.l2jmobius.gameserver.model.html.styles.ButtonsStyle;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.ExRedSky;
@ -81,8 +79,6 @@ public class AdminEffects implements IAdminCommandHandler
"admin_earthquake_menu",
"admin_bighead",
"admin_shrinkhead",
"admin_gmspeed",
"admin_gmspeed_menu",
"admin_unpara_all",
"admin_para_all",
"admin_unpara",
@ -351,35 +347,6 @@ public class AdminEffects implements IAdminCommandHandler
{
}
}
else if (command.startsWith("admin_gmspeed"))
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = activeChar.isAffectedBySkill(7029);
activeChar.stopSkillEffects((val == 0) && sendMessage, 7029);
if ((val >= 1) && (val <= 4))
{
int time = 0;
if (st.hasMoreTokens())
{
time = Integer.parseInt(st.nextToken());
}
final Skill gmSpeedSkill = SkillData.getInstance().getSkill(7029, val);
gmSpeedSkill.applyEffects(activeChar, activeChar, true, time);
}
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //gmspeed <Effect level (0-4)> <Time in seconds>");
}
if (command.contains("_menu"))
{
command = "";
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
}
}
else if (command.startsWith("admin_polyself"))
{
try

View File

@ -0,0 +1,119 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.EnumSet;
import java.util.Set;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.stats.Stats;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/**
* A retail-like implementation of //gmspeed builder command.
* @author lord_rex
*/
public final class AdminGmSpeed implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_gmspeed",
};
private static final Set<Stats> SPEED_STATS = EnumSet.of(Stats.RUN_SPEED, Stats.WALK_SPEED, Stats.SWIM_RUN_SPEED, Stats.SWIM_WALK_SPEED, Stats.FLY_RUN_SPEED, Stats.FLY_WALK_SPEED);
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
if (cmd.equals("admin_gmspeed"))
{
if (!st.hasMoreTokens())
{
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final String token = st.nextToken();
// Rollback feature for old custom way, in order to make everyone happy.
if (Config.USE_SUPER_HASTE_AS_GM_SPEED)
{
AdminCommandHandler.getInstance().useAdminCommand(player, AdminSuperHaste.ADMIN_COMMANDS[0] + " " + token, false);
return true;
}
if (!Util.isDouble(token))
{
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final double runSpeedBoost = Double.parseDouble(token);
if ((runSpeedBoost < 0) || (runSpeedBoost > 10))
{
// Custom limit according to SDW's request - real retail limit is unknown.
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final L2Character targetCharacter;
final L2Object target = player.getTarget();
if ((target != null) && target.isCharacter())
{
targetCharacter = (L2Character) target;
}
else
{
// If there is no target, let's use the command executer.
targetCharacter = player;
}
SPEED_STATS.forEach(speedStat -> targetCharacter.getStat().removeFixedValue(speedStat));
if (runSpeedBoost > 0)
{
SPEED_STATS.forEach(speedStat -> targetCharacter.getStat().addFixedValue(speedStat, targetCharacter.getTemplate().getBaseValue(speedStat, 120) * runSpeedBoost));
}
targetCharacter.getStat().recalculateStats(false);
if (targetCharacter.isPlayer())
{
((L2PcInstance) targetCharacter).broadcastUserInfo();
}
else
{
targetCharacter.broadcastInfo();
}
BuilderUtil.sendSysMessage(player, "[" + targetCharacter.getName() + "] speed is [" + (runSpeedBoost * 100) + "0]% fast.");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -0,0 +1,87 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.util.BuilderUtil;
/**
* @author lord_rex
*/
public final class AdminHide implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_hide"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
try
{
final String param = st.nextToken();
switch (param)
{
case "on":
{
if (!BuilderUtil.setHiding(player, true))
{
BuilderUtil.sendSysMessage(player, "Currently, you cannot be seen.");
return true;
}
BuilderUtil.sendSysMessage(player, "Now, you cannot be seen.");
return true;
}
case "off":
{
if (!BuilderUtil.setHiding(player, false))
{
BuilderUtil.sendSysMessage(player, "Currently, you can be seen.");
return true;
}
BuilderUtil.sendSysMessage(player, "Now, you can be seen.");
return true;
}
default:
{
BuilderUtil.sendSysMessage(player, "//hide [on|off]");
return true;
}
}
}
catch (final Exception e)
{
BuilderUtil.sendSysMessage(player, "//hide [on|off]");
return true;
}
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -21,7 +21,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
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.L2Clan;
@ -187,14 +186,7 @@ public class AdminMenu implements IAdminCommandHandler
if (st.countTokens() > 1)
{
final String subCommand = "admin_ban_char";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + command.substring(14), activeChar);
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + command.substring(14), true);
}
showMainPage(activeChar);
}
@ -204,14 +196,7 @@ public class AdminMenu implements IAdminCommandHandler
if (st.countTokens() > 1)
{
final String subCommand = "admin_unban_char";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + command.substring(16), activeChar);
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + command.substring(16), true);
}
showMainPage(activeChar);
}

View File

@ -16,9 +16,6 @@
*/
package handlers.admincommandhandlers;
import java.util.logging.Logger;
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;
@ -28,8 +25,6 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
*/
public class AdminSummon implements IAdminCommandHandler
{
private static final Logger LOGGER = Logger.getLogger(AdminSummon.class.getName());
public static final String[] ADMIN_COMMANDS =
{
"admin_summon"
@ -62,34 +57,24 @@ public class AdminSummon implements IAdminCommandHandler
return false;
}
String subCommand;
final String subCommand;
if (id < 1000000)
{
subCommand = "admin_create_item";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
}
else
{
subCommand = "admin_spawn_once";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
activeChar.sendMessage("This is only a temporary spawn. The mob(s) will NOT respawn.");
id -= 1000000;
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
}
if ((id > 0) && (count > 0))
{
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + " " + id + " " + count, true);
}
return true;
}
}

View File

@ -0,0 +1,92 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* The classical custom L2J implementation of the old //gmspeed GM command.
* @author lord_rex (No, it wasn't me at all. Eclipse added my name there.)
*/
public final class AdminSuperHaste implements IAdminCommandHandler
{
public static final String[] ADMIN_COMMANDS =
{
"admin_superhaste",
"admin_superhaste_menu",
"admin_speed",
"admin_speed_menu",
};
private static final int SUPER_HASTE_ID = 7029;
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
switch (cmd)
{
case "admin_superhaste":
case "admin_speed":
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = player.isAffectedBySkill(SUPER_HASTE_ID);
player.stopSkillEffects((val == 0) && sendMessage, SUPER_HASTE_ID);
if ((val >= 1) && (val <= 4))
{
int time = 0;
if (st.hasMoreTokens())
{
time = Integer.parseInt(st.nextToken());
}
final Skill superHasteSkill = SkillData.getInstance().getSkill(SUPER_HASTE_ID, val);
superHasteSkill.applyEffects(player, player, true, time);
}
}
catch (final Exception e)
{
player.sendMessage("Usage: //superhaste <Effect level (0-4)> <Time in seconds>");
}
break;
}
case "admin_superhaste_menu":
case "admin_speed_menu":
{
AdminHtml.showAdminHtml(player, "gm_menu.htm");
break;
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -394,6 +394,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;
@ -407,6 +408,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;
@ -1799,6 +1801,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);
@ -1812,6 +1815,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);

View File

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

View File

@ -97,8 +97,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;
@ -336,7 +334,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;
/**
@ -10048,8 +10045,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.");
@ -13782,50 +13780,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

View File

@ -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()))

View File

@ -98,6 +98,7 @@ import com.l2jmobius.gameserver.network.serverpackets.SkillList;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.ability.ExAcquireAPSkillList;
import com.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList;
import com.l2jmobius.gameserver.util.BuilderUtil;
/**
* Enter World Packet Handler
@ -205,35 +206,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)

View File

@ -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))
{

View File

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

View File

@ -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
{

View File

@ -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
{

View File

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

View File

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

View File

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

View File

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

View File

@ -158,8 +158,6 @@
<admin command="admin_earthquake_menu" accessLevel="100" />
<admin command="admin_bighead" accessLevel="100" />
<admin command="admin_shrinkhead" accessLevel="100" />
<admin command="admin_gmspeed" accessLevel="100" />
<admin command="admin_gmspeed_menu" accessLevel="100" />
<admin command="admin_unpara_all" accessLevel="100" />
<admin command="admin_para_all" accessLevel="100" />
<admin command="admin_unpara" accessLevel="100" />
@ -189,6 +187,13 @@
<admin command="admin_set_displayeffect_menu" accessLevel="100" />
<admin command="admin_playmovie" accessLevel="100" />
<!-- ADMIN SPEED -->
<admin command="admin_gmspeed" accessLevel="100" />
<admin command="admin_superhaste" accessLevel="100" />
<admin command="admin_superhaste_menu" accessLevel="100" />
<admin command="admin_speed" accessLevel="100" />
<admin command="admin_speed_menu" accessLevel="100" />
<!-- ADMIN ELEMENT -->
<admin command="admin_setlh" accessLevel="100" />
<admin command="admin_setlc" accessLevel="100" />
@ -615,4 +620,7 @@
<admin command="banchat" accessLevel="100" />
<admin command="debug" accessLevel="100" />
<admin command="unbanchat" accessLevel="100" />
<!-- HIDE -->
<admin command="admin_hide" accessLevel="100" />
</list>

View File

@ -25,6 +25,10 @@ ServerGMOnly = False
# Default: False
GMHeroAura = False
# Whether GM logins in builder hide mode by default.
# Default: True
GMStartupBuilderHide = True
# Auto set invulnerable status to a GM on login.
# Default: False
GMStartupInvulnerable = True
@ -79,6 +83,11 @@ GMGiveSpecialSkills = False
# Default: False
GMGiveSpecialAuraSkills = False
# In case you are not satisfied with the retail-like implementation of //gmspeed",
# with this config you can rollback it to the old custom L2J version of the GM Speed.
# Default: False
UseSuperHasteAsGMSpeed = False
# ---------------------------------------------------------------------------
# Server Security

View File

@ -38,11 +38,11 @@
</table><br1>
<table width=270><tr>
<td><font color="LEVEL">Super Haste:</font></td>
<td><button value="1" action="bypass -h admin_gmspeed_menu 1" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="2" action="bypass -h admin_gmspeed_menu 2" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="3" action="bypass -h admin_gmspeed_menu 3" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="4" action="bypass -h admin_gmspeed_menu 4" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Off" action="bypass -h admin_gmspeed_menu 0" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="1" action="bypass -h admin_superhaste 1" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="2" action="bypass -h admin_superhaste 2" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="3" action="bypass -h admin_superhaste 3" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="4" action="bypass -h admin_superhaste 4" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Off" action="bypass -h admin_superhaste 0" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr></table><br>
<center><multiedit var="new_announcement" width=250 height=50></center>
<table width="160"><tr>

View File

@ -84,9 +84,11 @@ import handlers.admincommandhandlers.AdminFortSiege;
import handlers.admincommandhandlers.AdminGeodata;
import handlers.admincommandhandlers.AdminGm;
import handlers.admincommandhandlers.AdminGmChat;
import handlers.admincommandhandlers.AdminGmSpeed;
import handlers.admincommandhandlers.AdminGraciaSeeds;
import handlers.admincommandhandlers.AdminGrandBoss;
import handlers.admincommandhandlers.AdminHeal;
import handlers.admincommandhandlers.AdminHide;
import handlers.admincommandhandlers.AdminHtml;
import handlers.admincommandhandlers.AdminHwid;
import handlers.admincommandhandlers.AdminInstance;
@ -126,6 +128,7 @@ import handlers.admincommandhandlers.AdminShutdown;
import handlers.admincommandhandlers.AdminSkill;
import handlers.admincommandhandlers.AdminSpawn;
import handlers.admincommandhandlers.AdminSummon;
import handlers.admincommandhandlers.AdminSuperHaste;
import handlers.admincommandhandlers.AdminTarget;
import handlers.admincommandhandlers.AdminTargetSay;
import handlers.admincommandhandlers.AdminTeleport;
@ -414,9 +417,11 @@ public class MasterHandler
AdminGeodata.class,
AdminGm.class,
AdminGmChat.class,
AdminGmSpeed.class,
AdminGraciaSeeds.class,
AdminGrandBoss.class,
AdminHeal.class,
AdminHide.class,
AdminHtml.class,
AdminHwid.class,
AdminInstance.class,
@ -456,6 +461,7 @@ public class MasterHandler
AdminSkill.class,
AdminSpawn.class,
AdminSummon.class,
AdminSuperHaste.class,
AdminTarget.class,
AdminTargetSay.class,
AdminTeleport.class,

View File

@ -19,7 +19,6 @@ package handlers.actionshifthandlers;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -37,11 +36,7 @@ public class L2PcInstanceActionShift implements IActionShiftHandler
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_character_info");
if (ach != null)
{
ach.useAdminCommand("admin_character_info " + target.getName(), activeChar);
}
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_character_info " + target.getName(), true);
}
return true;
}

View File

@ -19,7 +19,6 @@ package handlers.actionshifthandlers;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -36,11 +35,7 @@ public class L2SummonActionShift implements IActionShiftHandler
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_summon_info");
if (ach != null)
{
ach.useAdminCommand("admin_summon_info", activeChar);
}
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_summon_info", true);
}
return true;
}

View File

@ -19,7 +19,6 @@ package handlers.admincommandhandlers;
import java.util.Arrays;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.enums.Movie;
import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
@ -34,7 +33,6 @@ import com.l2jmobius.gameserver.model.html.PageBuilder;
import com.l2jmobius.gameserver.model.html.PageResult;
import com.l2jmobius.gameserver.model.html.styles.ButtonsStyle;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.ExRedSky;
@ -81,8 +79,6 @@ public class AdminEffects implements IAdminCommandHandler
"admin_earthquake_menu",
"admin_bighead",
"admin_shrinkhead",
"admin_gmspeed",
"admin_gmspeed_menu",
"admin_unpara_all",
"admin_para_all",
"admin_unpara",
@ -351,35 +347,6 @@ public class AdminEffects implements IAdminCommandHandler
{
}
}
else if (command.startsWith("admin_gmspeed"))
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = activeChar.isAffectedBySkill(7029);
activeChar.stopSkillEffects((val == 0) && sendMessage, 7029);
if ((val >= 1) && (val <= 4))
{
int time = 0;
if (st.hasMoreTokens())
{
time = Integer.parseInt(st.nextToken());
}
final Skill gmSpeedSkill = SkillData.getInstance().getSkill(7029, val);
gmSpeedSkill.applyEffects(activeChar, activeChar, true, time);
}
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //gmspeed <Effect level (0-4)> <Time in seconds>");
}
if (command.contains("_menu"))
{
command = "";
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
}
}
else if (command.startsWith("admin_polyself"))
{
try

View File

@ -0,0 +1,119 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.EnumSet;
import java.util.Set;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.stats.Stats;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/**
* A retail-like implementation of //gmspeed builder command.
* @author lord_rex
*/
public final class AdminGmSpeed implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_gmspeed",
};
private static final Set<Stats> SPEED_STATS = EnumSet.of(Stats.RUN_SPEED, Stats.WALK_SPEED, Stats.SWIM_RUN_SPEED, Stats.SWIM_WALK_SPEED, Stats.FLY_RUN_SPEED, Stats.FLY_WALK_SPEED);
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
if (cmd.equals("admin_gmspeed"))
{
if (!st.hasMoreTokens())
{
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final String token = st.nextToken();
// Rollback feature for old custom way, in order to make everyone happy.
if (Config.USE_SUPER_HASTE_AS_GM_SPEED)
{
AdminCommandHandler.getInstance().useAdminCommand(player, AdminSuperHaste.ADMIN_COMMANDS[0] + " " + token, false);
return true;
}
if (!Util.isDouble(token))
{
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final double runSpeedBoost = Double.parseDouble(token);
if ((runSpeedBoost < 0) || (runSpeedBoost > 10))
{
// Custom limit according to SDW's request - real retail limit is unknown.
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final L2Character targetCharacter;
final L2Object target = player.getTarget();
if ((target != null) && target.isCharacter())
{
targetCharacter = (L2Character) target;
}
else
{
// If there is no target, let's use the command executer.
targetCharacter = player;
}
SPEED_STATS.forEach(speedStat -> targetCharacter.getStat().removeFixedValue(speedStat));
if (runSpeedBoost > 0)
{
SPEED_STATS.forEach(speedStat -> targetCharacter.getStat().addFixedValue(speedStat, targetCharacter.getTemplate().getBaseValue(speedStat, 120) * runSpeedBoost));
}
targetCharacter.getStat().recalculateStats(false);
if (targetCharacter.isPlayer())
{
((L2PcInstance) targetCharacter).broadcastUserInfo();
}
else
{
targetCharacter.broadcastInfo();
}
BuilderUtil.sendSysMessage(player, "[" + targetCharacter.getName() + "] speed is [" + (runSpeedBoost * 100) + "0]% fast.");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -0,0 +1,87 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.util.BuilderUtil;
/**
* @author lord_rex
*/
public final class AdminHide implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_hide"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
try
{
final String param = st.nextToken();
switch (param)
{
case "on":
{
if (!BuilderUtil.setHiding(player, true))
{
BuilderUtil.sendSysMessage(player, "Currently, you cannot be seen.");
return true;
}
BuilderUtil.sendSysMessage(player, "Now, you cannot be seen.");
return true;
}
case "off":
{
if (!BuilderUtil.setHiding(player, false))
{
BuilderUtil.sendSysMessage(player, "Currently, you can be seen.");
return true;
}
BuilderUtil.sendSysMessage(player, "Now, you can be seen.");
return true;
}
default:
{
BuilderUtil.sendSysMessage(player, "//hide [on|off]");
return true;
}
}
}
catch (final Exception e)
{
BuilderUtil.sendSysMessage(player, "//hide [on|off]");
return true;
}
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -21,7 +21,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
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.L2Clan;
@ -187,14 +186,7 @@ public class AdminMenu implements IAdminCommandHandler
if (st.countTokens() > 1)
{
final String subCommand = "admin_ban_char";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + command.substring(14), activeChar);
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + command.substring(14), true);
}
showMainPage(activeChar);
}
@ -204,14 +196,7 @@ public class AdminMenu implements IAdminCommandHandler
if (st.countTokens() > 1)
{
final String subCommand = "admin_unban_char";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + command.substring(16), activeChar);
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + command.substring(16), true);
}
showMainPage(activeChar);
}

View File

@ -16,9 +16,6 @@
*/
package handlers.admincommandhandlers;
import java.util.logging.Logger;
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;
@ -28,8 +25,6 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
*/
public class AdminSummon implements IAdminCommandHandler
{
private static final Logger LOGGER = Logger.getLogger(AdminSummon.class.getName());
public static final String[] ADMIN_COMMANDS =
{
"admin_summon"
@ -62,34 +57,24 @@ public class AdminSummon implements IAdminCommandHandler
return false;
}
String subCommand;
final String subCommand;
if (id < 1000000)
{
subCommand = "admin_create_item";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
}
else
{
subCommand = "admin_spawn_once";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
activeChar.sendMessage("This is only a temporary spawn. The mob(s) will NOT respawn.");
id -= 1000000;
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
}
if ((id > 0) && (count > 0))
{
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + " " + id + " " + count, true);
}
return true;
}
}

View File

@ -0,0 +1,92 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* The classical custom L2J implementation of the old //gmspeed GM command.
* @author lord_rex (No, it wasn't me at all. Eclipse added my name there.)
*/
public final class AdminSuperHaste implements IAdminCommandHandler
{
public static final String[] ADMIN_COMMANDS =
{
"admin_superhaste",
"admin_superhaste_menu",
"admin_speed",
"admin_speed_menu",
};
private static final int SUPER_HASTE_ID = 7029;
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
switch (cmd)
{
case "admin_superhaste":
case "admin_speed":
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = player.isAffectedBySkill(SUPER_HASTE_ID);
player.stopSkillEffects((val == 0) && sendMessage, SUPER_HASTE_ID);
if ((val >= 1) && (val <= 4))
{
int time = 0;
if (st.hasMoreTokens())
{
time = Integer.parseInt(st.nextToken());
}
final Skill superHasteSkill = SkillData.getInstance().getSkill(SUPER_HASTE_ID, val);
superHasteSkill.applyEffects(player, player, true, time);
}
}
catch (final Exception e)
{
player.sendMessage("Usage: //superhaste <Effect level (0-4)> <Time in seconds>");
}
break;
}
case "admin_superhaste_menu":
case "admin_speed_menu":
{
AdminHtml.showAdminHtml(player, "gm_menu.htm");
break;
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

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

View File

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

View File

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

View File

@ -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()))

View File

@ -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)

View File

@ -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))
{

View File

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

View File

@ -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
{

View File

@ -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
{

View File

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

View File

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

View File

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

View File

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

View File

@ -158,8 +158,6 @@
<admin command="admin_earthquake_menu" accessLevel="100" />
<admin command="admin_bighead" accessLevel="100" />
<admin command="admin_shrinkhead" accessLevel="100" />
<admin command="admin_gmspeed" accessLevel="100" />
<admin command="admin_gmspeed_menu" accessLevel="100" />
<admin command="admin_unpara_all" accessLevel="100" />
<admin command="admin_para_all" accessLevel="100" />
<admin command="admin_unpara" accessLevel="100" />
@ -189,6 +187,13 @@
<admin command="admin_set_displayeffect_menu" accessLevel="100" />
<admin command="admin_playmovie" accessLevel="100" />
<!-- ADMIN SPEED -->
<admin command="admin_gmspeed" accessLevel="100" />
<admin command="admin_superhaste" accessLevel="100" />
<admin command="admin_superhaste_menu" accessLevel="100" />
<admin command="admin_speed" accessLevel="100" />
<admin command="admin_speed_menu" accessLevel="100" />
<!-- ADMIN ELEMENT -->
<admin command="admin_setlh" accessLevel="100" />
<admin command="admin_setlc" accessLevel="100" />
@ -615,4 +620,7 @@
<admin command="banchat" accessLevel="100" />
<admin command="debug" accessLevel="100" />
<admin command="unbanchat" accessLevel="100" />
<!-- HIDE -->
<admin command="admin_hide" accessLevel="100" />
</list>

View File

@ -25,6 +25,10 @@ ServerGMOnly = False
# Default: False
GMHeroAura = False
# Whether GM logins in builder hide mode by default.
# Default: True
GMStartupBuilderHide = True
# Auto set invulnerable status to a GM on login.
# Default: False
GMStartupInvulnerable = True
@ -79,6 +83,11 @@ GMGiveSpecialSkills = False
# Default: False
GMGiveSpecialAuraSkills = False
# In case you are not satisfied with the retail-like implementation of //gmspeed",
# with this config you can rollback it to the old custom L2J version of the GM Speed.
# Default: False
UseSuperHasteAsGMSpeed = False
# ---------------------------------------------------------------------------
# Server Security

View File

@ -38,11 +38,11 @@
</table><br1>
<table width=270><tr>
<td><font color="LEVEL">Super Haste:</font></td>
<td><button value="1" action="bypass -h admin_gmspeed_menu 1" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="2" action="bypass -h admin_gmspeed_menu 2" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="3" action="bypass -h admin_gmspeed_menu 3" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="4" action="bypass -h admin_gmspeed_menu 4" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Off" action="bypass -h admin_gmspeed_menu 0" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="1" action="bypass -h admin_superhaste 1" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="2" action="bypass -h admin_superhaste 2" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="3" action="bypass -h admin_superhaste 3" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="4" action="bypass -h admin_superhaste 4" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Off" action="bypass -h admin_superhaste 0" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr></table><br>
<center><multiedit var="new_announcement" width=250 height=50></center>
<table width="160"><tr>

View File

@ -84,9 +84,11 @@ import handlers.admincommandhandlers.AdminFortSiege;
import handlers.admincommandhandlers.AdminGeodata;
import handlers.admincommandhandlers.AdminGm;
import handlers.admincommandhandlers.AdminGmChat;
import handlers.admincommandhandlers.AdminGmSpeed;
import handlers.admincommandhandlers.AdminGraciaSeeds;
import handlers.admincommandhandlers.AdminGrandBoss;
import handlers.admincommandhandlers.AdminHeal;
import handlers.admincommandhandlers.AdminHide;
import handlers.admincommandhandlers.AdminHtml;
import handlers.admincommandhandlers.AdminHwid;
import handlers.admincommandhandlers.AdminInstance;
@ -126,6 +128,7 @@ import handlers.admincommandhandlers.AdminShutdown;
import handlers.admincommandhandlers.AdminSkill;
import handlers.admincommandhandlers.AdminSpawn;
import handlers.admincommandhandlers.AdminSummon;
import handlers.admincommandhandlers.AdminSuperHaste;
import handlers.admincommandhandlers.AdminTarget;
import handlers.admincommandhandlers.AdminTargetSay;
import handlers.admincommandhandlers.AdminTeleport;
@ -415,9 +418,11 @@ public class MasterHandler
AdminGeodata.class,
AdminGm.class,
AdminGmChat.class,
AdminGmSpeed.class,
AdminGraciaSeeds.class,
AdminGrandBoss.class,
AdminHeal.class,
AdminHide.class,
AdminHtml.class,
AdminHwid.class,
AdminInstance.class,
@ -457,6 +462,7 @@ public class MasterHandler
AdminSkill.class,
AdminSpawn.class,
AdminSummon.class,
AdminSuperHaste.class,
AdminTarget.class,
AdminTargetSay.class,
AdminTeleport.class,

View File

@ -19,7 +19,6 @@ package handlers.actionshifthandlers;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -37,11 +36,7 @@ public class L2PcInstanceActionShift implements IActionShiftHandler
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_character_info");
if (ach != null)
{
ach.useAdminCommand("admin_character_info " + target.getName(), activeChar);
}
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_character_info " + target.getName(), true);
}
return true;
}

View File

@ -19,7 +19,6 @@ package handlers.actionshifthandlers;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -36,11 +35,7 @@ public class L2SummonActionShift implements IActionShiftHandler
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_summon_info");
if (ach != null)
{
ach.useAdminCommand("admin_summon_info", activeChar);
}
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_summon_info", true);
}
return true;
}

View File

@ -19,7 +19,6 @@ package handlers.admincommandhandlers;
import java.util.Arrays;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.enums.Movie;
import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
@ -34,7 +33,6 @@ import com.l2jmobius.gameserver.model.html.PageBuilder;
import com.l2jmobius.gameserver.model.html.PageResult;
import com.l2jmobius.gameserver.model.html.styles.ButtonsStyle;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.ExRedSky;
@ -81,8 +79,6 @@ public class AdminEffects implements IAdminCommandHandler
"admin_earthquake_menu",
"admin_bighead",
"admin_shrinkhead",
"admin_gmspeed",
"admin_gmspeed_menu",
"admin_unpara_all",
"admin_para_all",
"admin_unpara",
@ -351,35 +347,6 @@ public class AdminEffects implements IAdminCommandHandler
{
}
}
else if (command.startsWith("admin_gmspeed"))
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = activeChar.isAffectedBySkill(7029);
activeChar.stopSkillEffects((val == 0) && sendMessage, 7029);
if ((val >= 1) && (val <= 4))
{
int time = 0;
if (st.hasMoreTokens())
{
time = Integer.parseInt(st.nextToken());
}
final Skill gmSpeedSkill = SkillData.getInstance().getSkill(7029, val);
gmSpeedSkill.applyEffects(activeChar, activeChar, true, time);
}
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //gmspeed <Effect level (0-4)> <Time in seconds>");
}
if (command.contains("_menu"))
{
command = "";
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
}
}
else if (command.startsWith("admin_polyself"))
{
try

View File

@ -0,0 +1,119 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.EnumSet;
import java.util.Set;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.stats.Stats;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/**
* A retail-like implementation of //gmspeed builder command.
* @author lord_rex
*/
public final class AdminGmSpeed implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_gmspeed",
};
private static final Set<Stats> SPEED_STATS = EnumSet.of(Stats.RUN_SPEED, Stats.WALK_SPEED, Stats.SWIM_RUN_SPEED, Stats.SWIM_WALK_SPEED, Stats.FLY_RUN_SPEED, Stats.FLY_WALK_SPEED);
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
if (cmd.equals("admin_gmspeed"))
{
if (!st.hasMoreTokens())
{
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final String token = st.nextToken();
// Rollback feature for old custom way, in order to make everyone happy.
if (Config.USE_SUPER_HASTE_AS_GM_SPEED)
{
AdminCommandHandler.getInstance().useAdminCommand(player, AdminSuperHaste.ADMIN_COMMANDS[0] + " " + token, false);
return true;
}
if (!Util.isDouble(token))
{
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final double runSpeedBoost = Double.parseDouble(token);
if ((runSpeedBoost < 0) || (runSpeedBoost > 10))
{
// Custom limit according to SDW's request - real retail limit is unknown.
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final L2Character targetCharacter;
final L2Object target = player.getTarget();
if ((target != null) && target.isCharacter())
{
targetCharacter = (L2Character) target;
}
else
{
// If there is no target, let's use the command executer.
targetCharacter = player;
}
SPEED_STATS.forEach(speedStat -> targetCharacter.getStat().removeFixedValue(speedStat));
if (runSpeedBoost > 0)
{
SPEED_STATS.forEach(speedStat -> targetCharacter.getStat().addFixedValue(speedStat, targetCharacter.getTemplate().getBaseValue(speedStat, 120) * runSpeedBoost));
}
targetCharacter.getStat().recalculateStats(false);
if (targetCharacter.isPlayer())
{
((L2PcInstance) targetCharacter).broadcastUserInfo();
}
else
{
targetCharacter.broadcastInfo();
}
BuilderUtil.sendSysMessage(player, "[" + targetCharacter.getName() + "] speed is [" + (runSpeedBoost * 100) + "0]% fast.");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -0,0 +1,87 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.util.BuilderUtil;
/**
* @author lord_rex
*/
public final class AdminHide implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_hide"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
try
{
final String param = st.nextToken();
switch (param)
{
case "on":
{
if (!BuilderUtil.setHiding(player, true))
{
BuilderUtil.sendSysMessage(player, "Currently, you cannot be seen.");
return true;
}
BuilderUtil.sendSysMessage(player, "Now, you cannot be seen.");
return true;
}
case "off":
{
if (!BuilderUtil.setHiding(player, false))
{
BuilderUtil.sendSysMessage(player, "Currently, you can be seen.");
return true;
}
BuilderUtil.sendSysMessage(player, "Now, you can be seen.");
return true;
}
default:
{
BuilderUtil.sendSysMessage(player, "//hide [on|off]");
return true;
}
}
}
catch (final Exception e)
{
BuilderUtil.sendSysMessage(player, "//hide [on|off]");
return true;
}
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -21,7 +21,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
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.L2Clan;
@ -187,14 +186,7 @@ public class AdminMenu implements IAdminCommandHandler
if (st.countTokens() > 1)
{
final String subCommand = "admin_ban_char";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + command.substring(14), activeChar);
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + command.substring(14), true);
}
showMainPage(activeChar);
}
@ -204,14 +196,7 @@ public class AdminMenu implements IAdminCommandHandler
if (st.countTokens() > 1)
{
final String subCommand = "admin_unban_char";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + command.substring(16), activeChar);
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + command.substring(16), true);
}
showMainPage(activeChar);
}

View File

@ -16,9 +16,6 @@
*/
package handlers.admincommandhandlers;
import java.util.logging.Logger;
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;
@ -28,8 +25,6 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
*/
public class AdminSummon implements IAdminCommandHandler
{
private static final Logger LOGGER = Logger.getLogger(AdminSummon.class.getName());
public static final String[] ADMIN_COMMANDS =
{
"admin_summon"
@ -62,34 +57,24 @@ public class AdminSummon implements IAdminCommandHandler
return false;
}
String subCommand;
final String subCommand;
if (id < 1000000)
{
subCommand = "admin_create_item";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
}
else
{
subCommand = "admin_spawn_once";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
activeChar.sendMessage("This is only a temporary spawn. The mob(s) will NOT respawn.");
id -= 1000000;
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
}
if ((id > 0) && (count > 0))
{
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + " " + id + " " + count, true);
}
return true;
}
}

View File

@ -0,0 +1,92 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* The classical custom L2J implementation of the old //gmspeed GM command.
* @author lord_rex (No, it wasn't me at all. Eclipse added my name there.)
*/
public final class AdminSuperHaste implements IAdminCommandHandler
{
public static final String[] ADMIN_COMMANDS =
{
"admin_superhaste",
"admin_superhaste_menu",
"admin_speed",
"admin_speed_menu",
};
private static final int SUPER_HASTE_ID = 7029;
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
switch (cmd)
{
case "admin_superhaste":
case "admin_speed":
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = player.isAffectedBySkill(SUPER_HASTE_ID);
player.stopSkillEffects((val == 0) && sendMessage, SUPER_HASTE_ID);
if ((val >= 1) && (val <= 4))
{
int time = 0;
if (st.hasMoreTokens())
{
time = Integer.parseInt(st.nextToken());
}
final Skill superHasteSkill = SkillData.getInstance().getSkill(SUPER_HASTE_ID, val);
superHasteSkill.applyEffects(player, player, true, time);
}
}
catch (final Exception e)
{
player.sendMessage("Usage: //superhaste <Effect level (0-4)> <Time in seconds>");
}
break;
}
case "admin_superhaste_menu":
case "admin_speed_menu":
{
AdminHtml.showAdminHtml(player, "gm_menu.htm");
break;
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -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;
@ -1822,6 +1824,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);
@ -1835,6 +1838,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);

View File

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

View File

@ -99,8 +99,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;
@ -340,7 +338,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;
/**
@ -10065,8 +10062,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.");
@ -13800,50 +13798,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

View File

@ -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()))

View File

@ -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)

View File

@ -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))
{

View File

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

View File

@ -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
{

View File

@ -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
{

View File

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

View File

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

View File

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

View File

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

View File

@ -158,8 +158,6 @@
<admin command="admin_earthquake_menu" accessLevel="100" />
<admin command="admin_bighead" accessLevel="100" />
<admin command="admin_shrinkhead" accessLevel="100" />
<admin command="admin_gmspeed" accessLevel="100" />
<admin command="admin_gmspeed_menu" accessLevel="100" />
<admin command="admin_unpara_all" accessLevel="100" />
<admin command="admin_para_all" accessLevel="100" />
<admin command="admin_unpara" accessLevel="100" />
@ -189,6 +187,13 @@
<admin command="admin_set_displayeffect_menu" accessLevel="100" />
<admin command="admin_playmovie" accessLevel="100" />
<!-- ADMIN SPEED -->
<admin command="admin_gmspeed" accessLevel="100" />
<admin command="admin_superhaste" accessLevel="100" />
<admin command="admin_superhaste_menu" accessLevel="100" />
<admin command="admin_speed" accessLevel="100" />
<admin command="admin_speed_menu" accessLevel="100" />
<!-- ADMIN ELEMENT -->
<admin command="admin_setlh" accessLevel="100" />
<admin command="admin_setlc" accessLevel="100" />
@ -615,4 +620,7 @@
<admin command="banchat" accessLevel="100" />
<admin command="debug" accessLevel="100" />
<admin command="unbanchat" accessLevel="100" />
<!-- HIDE -->
<admin command="admin_hide" accessLevel="100" />
</list>

View File

@ -25,6 +25,10 @@ ServerGMOnly = False
# Default: False
GMHeroAura = False
# Whether GM logins in builder hide mode by default.
# Default: True
GMStartupBuilderHide = True
# Auto set invulnerable status to a GM on login.
# Default: False
GMStartupInvulnerable = True
@ -79,6 +83,11 @@ GMGiveSpecialSkills = False
# Default: False
GMGiveSpecialAuraSkills = False
# In case you are not satisfied with the retail-like implementation of //gmspeed",
# with this config you can rollback it to the old custom L2J version of the GM Speed.
# Default: False
UseSuperHasteAsGMSpeed = False
# ---------------------------------------------------------------------------
# Server Security

View File

@ -38,11 +38,11 @@
</table><br1>
<table width=270><tr>
<td><font color="LEVEL">Super Haste:</font></td>
<td><button value="1" action="bypass -h admin_gmspeed_menu 1" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="2" action="bypass -h admin_gmspeed_menu 2" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="3" action="bypass -h admin_gmspeed_menu 3" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="4" action="bypass -h admin_gmspeed_menu 4" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Off" action="bypass -h admin_gmspeed_menu 0" width=35 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="1" action="bypass -h admin_superhaste 1" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="2" action="bypass -h admin_superhaste 2" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="3" action="bypass -h admin_superhaste 3" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="4" action="bypass -h admin_superhaste 4" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Off" action="bypass -h admin_superhaste 0" width=30 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr></table><br>
<center><multiedit var="new_announcement" width=250 height=50></center>
<table width="160"><tr>

View File

@ -84,9 +84,11 @@ import handlers.admincommandhandlers.AdminFortSiege;
import handlers.admincommandhandlers.AdminGeodata;
import handlers.admincommandhandlers.AdminGm;
import handlers.admincommandhandlers.AdminGmChat;
import handlers.admincommandhandlers.AdminGmSpeed;
import handlers.admincommandhandlers.AdminGraciaSeeds;
import handlers.admincommandhandlers.AdminGrandBoss;
import handlers.admincommandhandlers.AdminHeal;
import handlers.admincommandhandlers.AdminHide;
import handlers.admincommandhandlers.AdminHtml;
import handlers.admincommandhandlers.AdminHwid;
import handlers.admincommandhandlers.AdminInstance;
@ -126,6 +128,7 @@ import handlers.admincommandhandlers.AdminShutdown;
import handlers.admincommandhandlers.AdminSkill;
import handlers.admincommandhandlers.AdminSpawn;
import handlers.admincommandhandlers.AdminSummon;
import handlers.admincommandhandlers.AdminSuperHaste;
import handlers.admincommandhandlers.AdminTarget;
import handlers.admincommandhandlers.AdminTargetSay;
import handlers.admincommandhandlers.AdminTeleport;
@ -415,9 +418,11 @@ public class MasterHandler
AdminGeodata.class,
AdminGm.class,
AdminGmChat.class,
AdminGmSpeed.class,
AdminGraciaSeeds.class,
AdminGrandBoss.class,
AdminHeal.class,
AdminHide.class,
AdminHtml.class,
AdminHwid.class,
AdminInstance.class,
@ -457,6 +462,7 @@ public class MasterHandler
AdminSkill.class,
AdminSpawn.class,
AdminSummon.class,
AdminSuperHaste.class,
AdminTarget.class,
AdminTargetSay.class,
AdminTeleport.class,

View File

@ -19,7 +19,6 @@ package handlers.actionshifthandlers;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -37,11 +36,7 @@ public class L2PcInstanceActionShift implements IActionShiftHandler
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_character_info");
if (ach != null)
{
ach.useAdminCommand("admin_character_info " + target.getName(), activeChar);
}
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_character_info " + target.getName(), true);
}
return true;
}

View File

@ -19,7 +19,6 @@ package handlers.actionshifthandlers;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -36,11 +35,7 @@ public class L2SummonActionShift implements IActionShiftHandler
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_summon_info");
if (ach != null)
{
ach.useAdminCommand("admin_summon_info", activeChar);
}
AdminCommandHandler.getInstance().useAdminCommand(activeChar, "admin_summon_info", true);
}
return true;
}

View File

@ -19,7 +19,6 @@ package handlers.admincommandhandlers;
import java.util.Arrays;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.enums.Movie;
import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
@ -34,7 +33,6 @@ import com.l2jmobius.gameserver.model.html.PageBuilder;
import com.l2jmobius.gameserver.model.html.PageResult;
import com.l2jmobius.gameserver.model.html.styles.ButtonsStyle;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.ExRedSky;
@ -81,8 +79,6 @@ public class AdminEffects implements IAdminCommandHandler
"admin_earthquake_menu",
"admin_bighead",
"admin_shrinkhead",
"admin_gmspeed",
"admin_gmspeed_menu",
"admin_unpara_all",
"admin_para_all",
"admin_unpara",
@ -351,35 +347,6 @@ public class AdminEffects implements IAdminCommandHandler
{
}
}
else if (command.startsWith("admin_gmspeed"))
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = activeChar.isAffectedBySkill(7029);
activeChar.stopSkillEffects((val == 0) && sendMessage, 7029);
if ((val >= 1) && (val <= 4))
{
int time = 0;
if (st.hasMoreTokens())
{
time = Integer.parseInt(st.nextToken());
}
final Skill gmSpeedSkill = SkillData.getInstance().getSkill(7029, val);
gmSpeedSkill.applyEffects(activeChar, activeChar, true, time);
}
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //gmspeed <Effect level (0-4)> <Time in seconds>");
}
if (command.contains("_menu"))
{
command = "";
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
}
}
else if (command.startsWith("admin_polyself"))
{
try

View File

@ -0,0 +1,119 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.EnumSet;
import java.util.Set;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.stats.Stats;
import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/**
* A retail-like implementation of //gmspeed builder command.
* @author lord_rex
*/
public final class AdminGmSpeed implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_gmspeed",
};
private static final Set<Stats> SPEED_STATS = EnumSet.of(Stats.RUN_SPEED, Stats.WALK_SPEED, Stats.SWIM_RUN_SPEED, Stats.SWIM_WALK_SPEED, Stats.FLY_RUN_SPEED, Stats.FLY_WALK_SPEED);
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
if (cmd.equals("admin_gmspeed"))
{
if (!st.hasMoreTokens())
{
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final String token = st.nextToken();
// Rollback feature for old custom way, in order to make everyone happy.
if (Config.USE_SUPER_HASTE_AS_GM_SPEED)
{
AdminCommandHandler.getInstance().useAdminCommand(player, AdminSuperHaste.ADMIN_COMMANDS[0] + " " + token, false);
return true;
}
if (!Util.isDouble(token))
{
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final double runSpeedBoost = Double.parseDouble(token);
if ((runSpeedBoost < 0) || (runSpeedBoost > 10))
{
// Custom limit according to SDW's request - real retail limit is unknown.
BuilderUtil.sendSysMessage(player, "//gmspeed [0...10]");
return false;
}
final L2Character targetCharacter;
final L2Object target = player.getTarget();
if ((target != null) && target.isCharacter())
{
targetCharacter = (L2Character) target;
}
else
{
// If there is no target, let's use the command executer.
targetCharacter = player;
}
SPEED_STATS.forEach(speedStat -> targetCharacter.getStat().removeFixedValue(speedStat));
if (runSpeedBoost > 0)
{
SPEED_STATS.forEach(speedStat -> targetCharacter.getStat().addFixedValue(speedStat, targetCharacter.getTemplate().getBaseValue(speedStat, 120) * runSpeedBoost));
}
targetCharacter.getStat().recalculateStats(false);
if (targetCharacter.isPlayer())
{
((L2PcInstance) targetCharacter).broadcastUserInfo();
}
else
{
targetCharacter.broadcastInfo();
}
BuilderUtil.sendSysMessage(player, "[" + targetCharacter.getName() + "] speed is [" + (runSpeedBoost * 100) + "0]% fast.");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -0,0 +1,87 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.util.BuilderUtil;
/**
* @author lord_rex
*/
public final class AdminHide implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_hide"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
try
{
final String param = st.nextToken();
switch (param)
{
case "on":
{
if (!BuilderUtil.setHiding(player, true))
{
BuilderUtil.sendSysMessage(player, "Currently, you cannot be seen.");
return true;
}
BuilderUtil.sendSysMessage(player, "Now, you cannot be seen.");
return true;
}
case "off":
{
if (!BuilderUtil.setHiding(player, false))
{
BuilderUtil.sendSysMessage(player, "Currently, you can be seen.");
return true;
}
BuilderUtil.sendSysMessage(player, "Now, you can be seen.");
return true;
}
default:
{
BuilderUtil.sendSysMessage(player, "//hide [on|off]");
return true;
}
}
}
catch (final Exception e)
{
BuilderUtil.sendSysMessage(player, "//hide [on|off]");
return true;
}
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -21,7 +21,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
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.L2Clan;
@ -187,14 +186,7 @@ public class AdminMenu implements IAdminCommandHandler
if (st.countTokens() > 1)
{
final String subCommand = "admin_ban_char";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + command.substring(14), activeChar);
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + command.substring(14), true);
}
showMainPage(activeChar);
}
@ -204,14 +196,7 @@ public class AdminMenu implements IAdminCommandHandler
if (st.countTokens() > 1)
{
final String subCommand = "admin_unban_char";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + command.substring(16), activeChar);
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + command.substring(16), true);
}
showMainPage(activeChar);
}

View File

@ -16,9 +16,6 @@
*/
package handlers.admincommandhandlers;
import java.util.logging.Logger;
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;
@ -28,8 +25,6 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
*/
public class AdminSummon implements IAdminCommandHandler
{
private static final Logger LOGGER = Logger.getLogger(AdminSummon.class.getName());
public static final String[] ADMIN_COMMANDS =
{
"admin_summon"
@ -62,34 +57,24 @@ public class AdminSummon implements IAdminCommandHandler
return false;
}
String subCommand;
final String subCommand;
if (id < 1000000)
{
subCommand = "admin_create_item";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
}
else
{
subCommand = "admin_spawn_once";
if (!AdminData.getInstance().hasAccess(subCommand, 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 " + subCommand + ", but have no access to it!");
return false;
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
activeChar.sendMessage("This is only a temporary spawn. The mob(s) will NOT respawn.");
id -= 1000000;
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
}
if ((id > 0) && (count > 0))
{
AdminCommandHandler.getInstance().useAdminCommand(activeChar, subCommand + " " + id + " " + count, true);
}
return true;
}
}

View File

@ -0,0 +1,92 @@
/*
* 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 handlers.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
/**
* The classical custom L2J implementation of the old //gmspeed GM command.
* @author lord_rex (No, it wasn't me at all. Eclipse added my name there.)
*/
public final class AdminSuperHaste implements IAdminCommandHandler
{
public static final String[] ADMIN_COMMANDS =
{
"admin_superhaste",
"admin_superhaste_menu",
"admin_speed",
"admin_speed_menu",
};
private static final int SUPER_HASTE_ID = 7029;
@Override
public boolean useAdminCommand(String command, L2PcInstance player)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
switch (cmd)
{
case "admin_superhaste":
case "admin_speed":
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = player.isAffectedBySkill(SUPER_HASTE_ID);
player.stopSkillEffects((val == 0) && sendMessage, SUPER_HASTE_ID);
if ((val >= 1) && (val <= 4))
{
int time = 0;
if (st.hasMoreTokens())
{
time = Integer.parseInt(st.nextToken());
}
final Skill superHasteSkill = SkillData.getInstance().getSkill(SUPER_HASTE_ID, val);
superHasteSkill.applyEffects(player, player, true, time);
}
}
catch (final Exception e)
{
player.sendMessage("Usage: //superhaste <Effect level (0-4)> <Time in seconds>");
}
break;
}
case "admin_superhaste_menu":
case "admin_speed_menu":
{
AdminHtml.showAdminHtml(player, "gm_menu.htm");
break;
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -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;
@ -1820,6 +1822,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);
@ -1833,6 +1836,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);

View File

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

View File

@ -101,8 +101,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;
@ -345,7 +343,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;
/**
@ -10058,8 +10055,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.");
@ -13774,50 +13772,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

View File

@ -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()))

View File

@ -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)

View File

@ -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))
{

View File

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

View File

@ -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
{

View File

@ -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
{

View File

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

View File

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

View File

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

View File

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

Some files were not shown because too many files have changed in this diff Show More