Dropped MMOCore.

This commit is contained in:
MobiusDev
2018-04-04 22:55:11 +00:00
parent f2cf96c6c8
commit 100c30c653
845 changed files with 15162 additions and 15192 deletions

View File

@@ -145,27 +145,6 @@ SkillCheckRemove = True
SkillCheckGM = False
# ---------------------------------------------------------------------------
# Thread Configuration
# ---------------------------------------------------------------------------
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
# Default: -1
ScheduledThreadPoolCount = -1
# Specifies how many threads will be in a single scheduled pool.
# Default: 4
ThreadsPerScheduledThreadPool = 40
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
# Default: -1
InstantThreadPoolCount = -1
# Specifies how many threads will be in a single instant pool.
# Default: 2
ThreadsPerInstantThreadPool = 20
# ---------------------------------------------------------------------------
# Dead Lock Detector (separate thread for detecting deadlocks)
# ---------------------------------------------------------------------------

View File

@@ -1,26 +0,0 @@
#---------------------------------------------------------------
# MMO
#---------------------------------------------------------------
# Sleep time for all Selectors
# After he finished his job the Selector waits the given time in milliseconds
# Lower values will speed up the loop and the Ping is smaller
SleepTime = 20
# Every loop it send a maximum of the given packages to each connection
# Lower values will speed up the loop and the Ping is smaller but cause less output
# Default: 12
MaxSendPerPass = 60
# Every loop it read a maximum of the given packages from each connection
# Lower values will speed up the loop and the Ping is smaller but cause less input
# Default: 12
MaxReadPerPass = 60
# Each unfinished read/write need a TEMP storage Buffer
# on large player amount we need more Buffers
# if there are not enough buffers new ones are generated but not stored for future usage
HelperBufferCount = 20
# Setting this to True will lower your ping, at the cost of an increase in bandwidth consumption.
TcpNoDelay = True

View File

@@ -26,7 +26,7 @@ LoginPort = 9014
# WARNING: <u><b><font color="red">Please don't change default IPs here if you don't know what are you doing!</font></b></u>
# WARNING: <u><b><font color="red">External/Internal IPs are now inside "ipconfig.xml" file.</font></b></u>
# Default: * (0.0.0.0)
GameserverHostname = *
GameserverHostname = 0.0.0.0
# Default: 7777
GameserverPort = 7777
@@ -91,6 +91,30 @@ MaximumOnlineUsers = 2000
AllowedProtocolRevisions = 267;268;271;273
# ---------------------------------------------------------------------------
# Thread Configuration
# ---------------------------------------------------------------------------
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
# Default: -1
ScheduledThreadPoolCount = -1
# Specifies how many threads will be in a single scheduled pool.
# Default: 4
ThreadsPerScheduledThreadPool = 40
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
# Default: -1
InstantThreadPoolCount = -1
# Specifies how many threads will be in a single instant pool.
# Default: 2
ThreadsPerInstantThreadPool = 20
# Default: 2
UrgentPacketThreadCoreSize = 20
# ---------------------------------------------------------------------------
# Misc Player Settings
# ---------------------------------------------------------------------------

View File

@@ -5,7 +5,6 @@
# Warning:
# Please take extreme caution when changing anything. Also please understand what you are changing before you do so on a live server.
# ---------------------------------------------------------------------------
# Allows text based monitoring and administration of L2J GS
# by using a telnet client. Communication protocol is insecure
# and you should use SSL tunnels, VPN, etc. if you plan to connect
@@ -13,16 +12,20 @@
# Default: False
EnableTelnet = False
# This is the hostname address on which telnet server will be listening.
# Note for all adapters use: *
# Default: 127.0.0.1
BindAddress = 127.0.0.1
# This is the port L2J should listen to for incoming telnet
# requests.
# Default: 54321
StatusPort = 54321
Port = 54321
# If the following is not set, a random password is generated on server startup.
# Usage: StatusPW = somePass
StatusPW =
Password = somepassword
# This list can contain IPs or Hosts of clients you wish to allow. Hostnames must be resolvable to an IP.
# Example: 0.0.0.0,host,0.0.0.1,host2,host3,host4,0.0.0.3
# Default: 127.0.0.1,localhost
ListOfHosts = 127.0.0.1,localhost
# Default: 127.0.0.1,localhost,::1
ListOfHosts = 127.0.0.1,localhost,::1

View File

@@ -39,7 +39,7 @@ import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import com.l2jmobius.gameserver.network.serverpackets.NpcSay;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Util;
@@ -691,7 +691,7 @@ public class HallOfErosionAttack extends AbstractNpcAI
}
}
protected void broadCastPacket(HEAWorld world, L2GameServerPacket packet)
protected void broadCastPacket(HEAWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
{

View File

@@ -39,7 +39,7 @@ import com.l2jmobius.gameserver.model.quest.QuestState;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import com.l2jmobius.gameserver.network.serverpackets.NpcSay;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Util;
@@ -684,7 +684,7 @@ public class HallOfErosionDefence extends AbstractNpcAI
}
}
protected void broadCastPacket(HEDWorld world, L2GameServerPacket packet)
protected void broadCastPacket(HEDWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
{

View File

@@ -43,7 +43,7 @@ import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import com.l2jmobius.gameserver.network.serverpackets.NpcSay;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Util;
@@ -867,7 +867,7 @@ public class HeartInfinityAttack extends Quest
}
}
protected void broadCastPacket(HIAWorld world, L2GameServerPacket packet)
protected void broadCastPacket(HIAWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
{

View File

@@ -42,7 +42,7 @@ import com.l2jmobius.gameserver.model.zone.L2ZoneType;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import com.l2jmobius.gameserver.network.serverpackets.NpcSay;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Util;
@@ -762,7 +762,7 @@ public class HeartInfinityDefence extends Quest
return null;
}
protected void broadCastPacket(HIDWorld world, L2GameServerPacket packet)
protected void broadCastPacket(HIDWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
{

View File

@@ -48,7 +48,7 @@ import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.CameraMode;
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import com.l2jmobius.gameserver.network.serverpackets.NormalCamera;
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
import com.l2jmobius.gameserver.network.serverpackets.SpecialCamera;
@@ -1732,7 +1732,7 @@ public class SeedOfDestruction extends AbstractNpcAI
return super.onEnterZone(character, zone);
}
private void broadcastPacket(L2GameServerPacket mov, SODWorld world)
private void broadcastPacket(IClientOutgoingPacket mov, SODWorld world)
{
for (L2PcInstance player : world.PlayersInInstance)
{

View File

@@ -34,9 +34,9 @@ import com.l2jmobius.gameserver.handler.IHandler;
import com.l2jmobius.gameserver.handler.ItemHandler;
import com.l2jmobius.gameserver.handler.PunishmentHandler;
import com.l2jmobius.gameserver.handler.TargetHandler;
import com.l2jmobius.gameserver.handler.TelnetHandler;
import com.l2jmobius.gameserver.handler.UserCommandHandler;
import com.l2jmobius.gameserver.handler.VoicedCommandHandler;
import com.l2jmobius.gameserver.network.telnet.TelnetServer;
import handlers.actionhandlers.L2ArtefactInstanceAction;
import handlers.actionhandlers.L2DecoyAction;
@@ -250,14 +250,30 @@ import handlers.targethandlers.Servitor;
import handlers.targethandlers.Summon;
import handlers.targethandlers.TargetParty;
import handlers.targethandlers.Unlockable;
import handlers.telnethandlers.ChatsHandler;
import handlers.telnethandlers.DebugHandler;
import handlers.telnethandlers.HelpHandler;
import handlers.telnethandlers.PlayerHandler;
import handlers.telnethandlers.ReloadHandler;
import handlers.telnethandlers.ServerHandler;
import handlers.telnethandlers.StatusHandler;
import handlers.telnethandlers.ThreadHandler;
import handlers.telnethandlers.chat.Announce;
import handlers.telnethandlers.chat.GMChat;
import handlers.telnethandlers.chat.Msg;
import handlers.telnethandlers.player.AccessLevel;
import handlers.telnethandlers.player.Ban;
import handlers.telnethandlers.player.BanChat;
import handlers.telnethandlers.player.Enchant;
import handlers.telnethandlers.player.GMList;
import handlers.telnethandlers.player.Give;
import handlers.telnethandlers.player.Jail;
import handlers.telnethandlers.player.Kick;
import handlers.telnethandlers.player.SendMail;
import handlers.telnethandlers.player.Unban;
import handlers.telnethandlers.player.UnbanChat;
import handlers.telnethandlers.player.Unjail;
import handlers.telnethandlers.server.ForceGC;
import handlers.telnethandlers.server.Memusage;
import handlers.telnethandlers.server.Performance;
import handlers.telnethandlers.server.Purge;
import handlers.telnethandlers.server.Reload;
import handlers.telnethandlers.server.ServerAbort;
import handlers.telnethandlers.server.ServerRestart;
import handlers.telnethandlers.server.ServerShutdown;
import handlers.telnethandlers.server.Status;
import handlers.usercommandhandlers.ChannelDelete;
import handlers.usercommandhandlers.ChannelInfo;
import handlers.usercommandhandlers.ChannelLeave;
@@ -304,7 +320,6 @@ public class MasterHandler
UserCommandHandler.getInstance(),
VoicedCommandHandler.getInstance(),
TargetHandler.getInstance(),
TelnetHandler.getInstance(),
};
private static final Class<?>[][] HANDLERS =
@@ -581,17 +596,6 @@ public class MasterHandler
TargetParty.class,
Unlockable.class,
},
{
// Telnet Handlers
ChatsHandler.class,
DebugHandler.class,
HelpHandler.class,
PlayerHandler.class,
ReloadHandler.class,
ServerHandler.class,
StatusHandler.class,
ThreadHandler.class,
},
};
public static void main(String[] args)
@@ -644,6 +648,35 @@ public class MasterHandler
}
}
if (Config.TELNET_ENABLED)
{
TelnetServer.getInstance().addHandler(new Announce());
TelnetServer.getInstance().addHandler(new GMChat());
TelnetServer.getInstance().addHandler(new Msg());
TelnetServer.getInstance().addHandler(new AccessLevel());
TelnetServer.getInstance().addHandler(new Ban());
TelnetServer.getInstance().addHandler(new BanChat());
TelnetServer.getInstance().addHandler(new Enchant());
TelnetServer.getInstance().addHandler(new Give());
TelnetServer.getInstance().addHandler(new GMList());
TelnetServer.getInstance().addHandler(new Jail());
TelnetServer.getInstance().addHandler(new Kick());
TelnetServer.getInstance().addHandler(new Unban());
TelnetServer.getInstance().addHandler(new UnbanChat());
TelnetServer.getInstance().addHandler(new Unjail());
TelnetServer.getInstance().addHandler(new ForceGC());
TelnetServer.getInstance().addHandler(new Memusage());
TelnetServer.getInstance().addHandler(new Performance());
TelnetServer.getInstance().addHandler(new Purge());
TelnetServer.getInstance().addHandler(new Reload());
TelnetServer.getInstance().addHandler(new SendMail());
TelnetServer.getInstance().addHandler(new ServerAbort());
TelnetServer.getInstance().addHandler(new ServerRestart());
TelnetServer.getInstance().addHandler(new ServerShutdown());
TelnetServer.getInstance().addHandler(new Status());
TelnetServer.getInstance().addHandler(new handlers.telnethandlers.server.Debug());
}
for (IHandler<?, ?> loadInstance : LOAD_INSTANCES)
{
_log.log(Level.INFO, loadInstance.getClass().getSimpleName() + ": Loaded " + loadInstance.size() + " Handlers");

View File

@@ -296,7 +296,7 @@ public final class AdminCHSiege implements IAdminCommandHandler
}
else if (split[0].equals(COMMANDS[7]))
{
activeChar.sendPacket(new SiegeInfo(hall));
activeChar.sendPacket(new SiegeInfo(hall, activeChar));
}
else if (split[0].equals(COMMANDS[8]))
{

View File

@@ -991,7 +991,7 @@ public class AdminEditChar implements IAdminCommandHandler
}
else
{
ip = client.getConnection().getInetAddress().getHostAddress();
ip = client.getConnectionAddress().getHostAddress();
// if (client.getHWID() != null)
// {
// hwid = client.getHWID();
@@ -1209,7 +1209,7 @@ public class AdminEditChar implements IAdminCommandHandler
continue;
}
ip = client.getConnection().getInetAddress().getHostAddress();
ip = client.getConnectionAddress().getHostAddress();
if (!ip.equals(IpAdress))
{
continue;
@@ -1304,7 +1304,7 @@ public class AdminEditChar implements IAdminCommandHandler
continue;
}
ip = client.getConnection().getInetAddress().getHostAddress();
ip = client.getConnectionAddress().getHostAddress();
if (ipMap.get(ip) == null)
{
ipMap.put(ip, new ArrayList<L2PcInstance>());
@@ -1356,7 +1356,7 @@ public class AdminEditChar implements IAdminCommandHandler
continue;
}
final IpPack pack = new IpPack(client.getConnection().getInetAddress().getHostAddress(), client.getTrace());
final IpPack pack = new IpPack(client.getConnectionAddress().getHostAddress(), client.getTrace());
if (ipMap.get(pack) == null)
{
ipMap.put(pack, new ArrayList<L2PcInstance>());

View File

@@ -31,18 +31,15 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
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.CharInfo;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
import com.l2jmobius.gameserver.network.serverpackets.ExRedSky;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
import com.l2jmobius.gameserver.network.serverpackets.SSQInfo;
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
import com.l2jmobius.gameserver.network.serverpackets.SunRise;
import com.l2jmobius.gameserver.network.serverpackets.SunSet;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.Util;
@@ -382,11 +379,7 @@ public class AdminEffects implements IAdminCommandHandler
final String id = st.nextToken();
activeChar.getPoly().setPolyInfo("npc", id);
activeChar.teleToLocation(activeChar.getLocation());
final CharInfo info1 = new CharInfo(activeChar);
activeChar.broadcastPacket(info1);
final UserInfo info2 = new UserInfo(activeChar);
activeChar.sendPacket(info2);
activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
activeChar.broadcastUserInfo();
}
catch (Exception e)
{
@@ -398,11 +391,7 @@ public class AdminEffects implements IAdminCommandHandler
activeChar.getPoly().setPolyInfo(null, "1");
activeChar.decayMe();
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
final CharInfo info1 = new CharInfo(activeChar);
activeChar.broadcastPacket(info1);
final UserInfo info2 = new UserInfo(activeChar);
activeChar.sendPacket(info2);
activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
activeChar.broadcastUserInfo();
}
else if (command.equals("admin_clearteams"))
{
@@ -718,7 +707,7 @@ public class AdminEffects implements IAdminCommandHandler
*/
private void adminAtmosphere(String type, String state, int duration, L2PcInstance activeChar)
{
L2GameServerPacket packet = null;
IClientOutgoingPacket packet = null;
if (type.equals("signsky"))
{

View File

@@ -25,10 +25,7 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
import com.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
/**
* This class handles following admin commands: - enchant_armor
@@ -214,9 +211,7 @@ public class AdminEnchant implements IAdminCommandHandler
final InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(itemInstance);
player.sendPacket(iu);
player.broadcastPacket(new CharInfo(player));
player.sendPacket(new UserInfo(player));
player.broadcastPacket(new ExBrExtraUserInfo(player));
player.broadcastUserInfo();
// informations
activeChar.sendMessage("Changed enchantment of " + player.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");

View File

@@ -35,11 +35,8 @@ import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.L2Event;
import com.l2jmobius.gameserver.model.entity.L2Event.EventState;
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
import com.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
import com.l2jmobius.gameserver.util.Broadcast;
/**
@@ -324,11 +321,7 @@ public class AdminEventEngine implements IAdminCommandHandler
{
player.getPoly().setPolyInfo("npc", polyIds[Rnd.get(polyIds.length)]);
player.teleToLocation(player.getLocation(), true);
final CharInfo info1 = new CharInfo(player);
player.broadcastPacket(info1);
final UserInfo info2 = new UserInfo(player);
player.sendPacket(info2);
player.broadcastPacket(new ExBrExtraUserInfo(player));
player.broadcastUserInfo();
}
showEventControl(activeChar);
}
@@ -341,11 +334,7 @@ public class AdminEventEngine implements IAdminCommandHandler
player.getPoly().setPolyInfo(null, "1");
player.decayMe();
player.spawnMe(player.getX(), player.getY(), player.getZ());
final CharInfo info1 = new CharInfo(player);
player.broadcastPacket(info1);
final UserInfo info2 = new UserInfo(player);
player.sendPacket(info2);
player.broadcastPacket(new ExBrExtraUserInfo(player));
player.broadcastUserInfo();
}
}
showEventControl(activeChar);

View File

@@ -22,9 +22,6 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.StringTokenizer;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.commons.mmocore.NioNetStringBuffer;
import com.l2jmobius.gameserver.GameServer;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
@@ -32,7 +29,6 @@ import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2BoatInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.clientpackets.L2GameClientPacket;
import com.l2jmobius.gameserver.network.serverpackets.AdminForgePacket;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
@@ -88,7 +84,7 @@ public final class AdminPForge implements IAdminCommandHandler
long opCodeLong;
try
{
opCodeLong = Long.parseLong(opCode);
opCodeLong = Long.decode(opCode);
}
catch (Exception e)
{
@@ -596,16 +592,20 @@ public final class AdminPForge implements IAdminCommandHandler
}
else if (bb != null)
{
bb.flip();
final L2GameClientPacket p = (L2GameClientPacket) GameServer.gameServer.getL2GamePacketHandler().handlePacket(bb, activeChar.getClient());
// TODO: Implement me!
// @formatter:off
/*bb.flip();
L2GameClientPacket p = (L2GameClientPacket) GameServer.gameServer.getL2GamePacketHandler().handlePacket(bb, activeChar.getClient());
if (p != null)
{
p.setBuffers(bb, activeChar.getClient(), new NioNetStringBuffer(2000));
if (p.read())
{
ThreadPool.execute(p);
ThreadPoolManager.getInstance().executePacket(p);
}
}
}*/
// @formatter:on
throw new UnsupportedOperationException("Not implemented yet!");
}
showValuesPage(activeChar, opCodes, format);

View File

@@ -334,7 +334,7 @@ public class AdminShowQuests implements IAdminCommandHandler
{
Quest.deleteQuestInDb(qs, true);
qs.exitQuest(true);
target.sendPacket(new QuestList());
target.sendPacket(new QuestList(target));
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
break;
}
@@ -343,7 +343,7 @@ public class AdminShowQuests implements IAdminCommandHandler
qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
qs.setState(State.STARTED);
qs.set("cond", "1");
target.sendPacket(new QuestList());
target.sendPacket(new QuestList(target));
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
val[0] = qs.getQuest().getName();
break;
@@ -352,7 +352,7 @@ public class AdminShowQuests implements IAdminCommandHandler
{
qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
qs.exitQuest(false);
target.sendPacket(new QuestList());
target.sendPacket(new QuestList(target));
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
val[0] = qs.getQuest().getName();
break;
@@ -369,7 +369,7 @@ public class AdminShowQuests implements IAdminCommandHandler
{
qs.set(val[1], val[2]);
}
target.sendPacket(new QuestList());
target.sendPacket(new QuestList(target));
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
}
actor.sendMessage("");

View File

@@ -1,112 +0,0 @@
/*
* 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.telnethandlers;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.handler.ITelnetHandler;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* @author UnAfraid
*/
public class ChatsHandler implements ITelnetHandler
{
private final String[] _commands =
{
"announce",
"msg",
"gmchat"
};
@Override
public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int _uptime)
{
if (command.startsWith("announce"))
{
try
{
command = command.substring(9);
Broadcast.toAllOnlinePlayers(command);
_print.println("Announcement Sent!");
}
catch (StringIndexOutOfBoundsException e)
{
_print.println("Please Enter Some Text To Announce!");
}
}
else if (command.startsWith("msg"))
{
try
{
final String val = command.substring(4);
final StringTokenizer st = new StringTokenizer(val);
final String name = st.nextToken();
final String message = val.substring(name.length() + 1);
final L2PcInstance reciever = L2World.getInstance().getPlayer(name);
final CreatureSay cs = new CreatureSay(0, ChatType.WHISPER, "Telnet Priv", message);
if (reciever != null)
{
reciever.sendPacket(cs);
_print.println("Telnet Priv->" + name + ": " + message);
_print.println("Message Sent!");
}
else
{
_print.println("Unable To Find Username: " + name);
}
}
catch (StringIndexOutOfBoundsException e)
{
_print.println("Please Enter Some Text!");
}
}
else if (command.startsWith("gmchat"))
{
try
{
command = command.substring(7);
final CreatureSay cs = new CreatureSay(0, ChatType.ALLIANCE, "Telnet GM Broadcast from " + _cSocket.getInetAddress().getHostAddress(), command);
AdminData.getInstance().broadcastToGMs(cs);
_print.println("Your Message Has Been Sent To " + getOnlineGMS() + " GM(s).");
}
catch (StringIndexOutOfBoundsException e)
{
_print.println("Please Enter Some Text To Announce!");
}
}
return false;
}
private int getOnlineGMS()
{
return AdminData.getInstance().getAllGms(true).size();
}
@Override
public String[] getCommandList()
{
return _commands;
}
}

View File

@@ -1,420 +0,0 @@
/*
* 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.telnethandlers;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.LoginServerThread;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.handler.ITelnetHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.serverpackets.AdminForgePacket;
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
/**
* @author UnAfraid
*/
public class DebugHandler implements ITelnetHandler
{
private final String[] _commands =
{
"debug"
};
private int uptime = 0;
@Override
public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int _uptime)
{
if (command.startsWith("debug") && (command.length() > 6))
{
final StringTokenizer st = new StringTokenizer(command.substring(6));
// TODO: Rewrite to use ARM.
FileOutputStream fos = null;
OutputStreamWriter out = null;
try
{
final String dbg = st.nextToken();
if (dbg.equals("decay"))
{
_print.print(DecayTaskManager.getInstance().toString());
}
else if (dbg.equals("packetsend"))
{
if (st.countTokens() < 2)
{
_print.println("Usage: debug packetsend <charName> <packetData>");
return false;
}
final String charName = st.nextToken();
final L2PcInstance targetPlayer = L2World.getInstance().getPlayer(charName);
if (targetPlayer == null)
{
_print.println("Player " + charName + " cannot be found online");
return false;
}
final AdminForgePacket sp = new AdminForgePacket();
while (st.hasMoreTokens())
{
final String b = st.nextToken();
if (!b.isEmpty())
{
sp.addPart("C".getBytes()[0], "0x" + b);
}
}
targetPlayer.sendPacket(sp);
_print.println("Packet sent to player " + charName);
}
else if (dbg.equals("full"))
{
final Calendar cal = Calendar.getInstance();
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
final StringBuilder sb = new StringBuilder();
sb.append(sdf.format(cal.getTime()));
sb.append("\n\n");
uptime = _uptime;
sb.append(getServerStatus());
sb.append("\n\n");
sb.append("\n## Java Platform Information ##");
sb.append("\nJava Runtime Name: " + System.getProperty("java.runtime.name"));
sb.append("\nJava Version: " + System.getProperty("java.version"));
sb.append("\nJava Class Version: " + System.getProperty("java.class.version"));
sb.append('\n');
sb.append("\n## Virtual Machine Information ##");
sb.append("\nVM Name: " + System.getProperty("java.vm.name"));
sb.append("\nVM Version: " + System.getProperty("java.vm.version"));
sb.append("\nVM Vendor: " + System.getProperty("java.vm.vendor"));
sb.append("\nVM Info: " + System.getProperty("java.vm.info"));
sb.append('\n');
sb.append("\n## OS Information ##");
sb.append("\nName: " + System.getProperty("os.name"));
sb.append("\nArchiteture: " + System.getProperty("os.arch"));
sb.append("\nVersion: " + System.getProperty("os.version"));
sb.append('\n');
sb.append("\n## Runtime Information ##");
sb.append("\nCPU Count: " + Runtime.getRuntime().availableProcessors());
sb.append("\nCurrent Free Heap Size: " + (Runtime.getRuntime().freeMemory() / 1024 / 1024) + " mb");
sb.append("\nCurrent Heap Size: " + (Runtime.getRuntime().totalMemory() / 1024 / 1024) + " mb");
sb.append("\nMaximum Heap Size: " + (Runtime.getRuntime().maxMemory() / 1024 / 1024) + " mb");
sb.append('\n');
sb.append("\n## Class Path Information ##\n");
final String cp = System.getProperty("java.class.path");
final String[] libs = cp.split(File.pathSeparator);
for (String lib : libs)
{
sb.append(lib);
sb.append('\n');
}
sb.append('\n');
sb.append("## Threads Information ##\n");
final Map<Thread, StackTraceElement[]> allThread = Thread.getAllStackTraces();
final List<Entry<Thread, StackTraceElement[]>> entries = new ArrayList<>(allThread.entrySet());
Collections.sort(entries, (e1, e2) -> e1.getKey().getName().compareTo(e2.getKey().getName()));
for (Entry<Thread, StackTraceElement[]> entry : entries)
{
final StackTraceElement[] stes = entry.getValue();
final Thread t = entry.getKey();
sb.append("--------------\n");
sb.append(t + " (" + t.getId() + ")\n");
sb.append("State: " + t.getState() + '\n');
sb.append("isAlive: " + t.isAlive() + " | isDaemon: " + t.isDaemon() + " | isInterrupted: " + t.isInterrupted() + '\n');
sb.append('\n');
for (StackTraceElement ste : stes)
{
sb.append(ste.toString());
sb.append('\n');
}
sb.append('\n');
}
sb.append('\n');
final ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
final long[] ids = findDeadlockedThreads(mbean);
if ((ids != null) && (ids.length > 0))
{
final Thread[] threads = new Thread[ids.length];
for (int i = 0; i < threads.length; i++)
{
threads[i] = findMatchingThread(mbean.getThreadInfo(ids[i]));
}
sb.append("Deadlocked Threads:\n");
sb.append("-------------------\n");
for (Thread thread : threads)
{
System.err.println(thread);
for (StackTraceElement ste : thread.getStackTrace())
{
sb.append("\t" + ste);
sb.append('\n');
}
}
}
sb.append("\n\n## Thread Pool Manager Statistics ##\n");
for (String line : ThreadPool.getStats())
{
sb.append(line);
sb.append('\n');
}
int i = 0;
File f = new File("./log/Debug-" + i + ".txt");
while (f.exists())
{
i++;
f = new File("./log/Debug-" + i + ".txt");
}
f.getParentFile().mkdirs();
fos = new FileOutputStream(f);
out = new OutputStreamWriter(fos, "UTF-8");
out.write(sb.toString());
out.flush();
out.close();
fos.close();
_print.println("Debug output saved to log/" + f.getName());
_print.flush();
}
}
catch (Exception e)
{
}
finally
{
try
{
if (out != null)
{
out.close();
}
}
catch (Exception e)
{
}
try
{
if (fos != null)
{
fos.close();
}
}
catch (Exception e)
{
}
}
}
return false;
}
private long[] findDeadlockedThreads(ThreadMXBean mbean)
{
// JDK 1.5 only supports the findMonitorDeadlockedThreads()
// method, so you need to comment out the following three lines
if (mbean.isSynchronizerUsageSupported())
{
return mbean.findDeadlockedThreads();
}
return mbean.findMonitorDeadlockedThreads();
}
private Thread findMatchingThread(ThreadInfo inf)
{
for (Thread thread : Thread.getAllStackTraces().keySet())
{
if (thread.getId() == inf.getThreadId())
{
return thread;
}
}
throw new IllegalStateException("Deadlocked Thread not found");
}
public String getServerStatus()
{
int playerCount = 0, objectCount = 0;
final int max = LoginServerThread.getInstance().getMaxPlayer();
playerCount = L2World.getInstance().getAllPlayersCount();
objectCount = L2World.getInstance().getVisibleObjectsCount();
int itemCount = 0;
int itemVoidCount = 0;
int monsterCount = 0;
int minionCount = 0;
int minionsGroupCount = 0;
int npcCount = 0;
int charCount = 0;
int pcCount = 0;
int detachedCount = 0;
int doorCount = 0;
int summonCount = 0;
int AICount = 0;
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (obj == null)
{
continue;
}
if (obj instanceof L2Character)
{
if (((L2Character) obj).hasAI())
{
AICount++;
}
}
if (obj instanceof L2ItemInstance)
{
if (((L2ItemInstance) obj).getItemLocation() == ItemLocation.VOID)
{
itemVoidCount++;
}
else
{
itemCount++;
}
}
else if (obj instanceof L2MonsterInstance)
{
monsterCount++;
if (((L2MonsterInstance) obj).hasMinions())
{
minionCount += ((L2MonsterInstance) obj).getMinionList().countSpawnedMinions();
minionsGroupCount += ((L2MonsterInstance) obj).getMinionList().lazyCountSpawnedMinionsGroups();
}
}
else if (obj instanceof L2Npc)
{
npcCount++;
}
else if (obj instanceof L2PcInstance)
{
pcCount++;
if ((((L2PcInstance) obj).getClient() != null) && ((L2PcInstance) obj).getClient().isDetached())
{
detachedCount++;
}
}
else if (obj instanceof L2Summon)
{
summonCount++;
}
else if (obj instanceof L2DoorInstance)
{
doorCount++;
}
else if (obj instanceof L2Character)
{
charCount++;
}
}
final StringBuilder sb = new StringBuilder();
sb.append("Server Status: ");
sb.append("\r\n ---> Player Count: " + playerCount + "/" + max);
sb.append("\r\n ---> Offline Count: " + detachedCount + "/" + playerCount);
sb.append("\r\n +--> Object Count: " + objectCount);
sb.append("\r\n +--> AI Count: " + AICount);
sb.append("\r\n +.... L2Item(Void): " + itemVoidCount);
sb.append("\r\n +.......... L2Item: " + itemCount);
sb.append("\r\n +....... L2Monster: " + monsterCount);
sb.append("\r\n +......... Minions: " + minionCount);
sb.append("\r\n +.. Minions Groups: " + minionsGroupCount);
sb.append("\r\n +........... L2Npc: " + npcCount);
sb.append("\r\n +............ L2Pc: " + pcCount);
sb.append("\r\n +........ L2Summon: " + summonCount);
sb.append("\r\n +.......... L2Door: " + doorCount);
sb.append("\r\n +.......... L2Char: " + charCount);
sb.append("\r\n ---> Ingame Time: " + gameTime());
sb.append("\r\n ---> Server Uptime: " + getUptime(uptime));
sb.append("\r\n ---> GM Count: " + getOnlineGMS());
sb.append("\r\n ---> Threads: " + Thread.activeCount());
sb.append("\r\n RAM Used: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576)); // 1024 * 1024 = 1048576
sb.append("\r\n");
return sb.toString();
}
private int getOnlineGMS()
{
return AdminData.getInstance().getAllGms(true).size();
}
private String getUptime(int time)
{
int uptime = (int) System.currentTimeMillis() - time;
uptime = uptime / 1000;
final int h = uptime / 3600;
final int m = (uptime - (h * 3600)) / 60;
final int s = ((uptime - (h * 3600)) - (m * 60));
return h + "hrs " + m + "mins " + s + "secs";
}
private String gameTime()
{
final int t = GameTimeController.getInstance().getGameTime();
final int h = t / 60;
final int m = t % 60;
final SimpleDateFormat format = new SimpleDateFormat("H:mm");
final Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, h);
cal.set(Calendar.MINUTE, m);
return format.format(cal.getTime());
}
@Override
public String[] getCommandList()
{
return _commands;
}
}

View File

@@ -1,81 +0,0 @@
/*
* 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.telnethandlers;
import java.io.PrintWriter;
import java.net.Socket;
import com.l2jmobius.gameserver.handler.ITelnetHandler;
/**
* @author UnAfraid
*/
public class HelpHandler implements ITelnetHandler
{
private final String[] _commands =
{
"help"
};
@Override
public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int _uptime)
{
if (command.equals("help"))
{
_print.println("The following is a list of all available commands: ");
_print.println("help - shows this help.");
_print.println("status - displays basic server statistics.");
_print.println("gamestat privatestore - displays info about stores");
_print.println("performance - shows server performance statistics.");
_print.println("forcegc - forced garbage collection.");
_print.println("purge - removes finished threads from thread pools.");
_print.println("memusage - displays memory amounts in JVM.");
_print.println("announce <text> - announces <text> in game.");
_print.println("msg <nick> <text> - Sends a whisper to char <nick> with <text>.");
_print.println("gmchat <text> - Sends a message to all GMs with <text>.");
_print.println("gmlist - lists all gms online.");
_print.println("kick - kick player <name> from server.");
_print.println("shutdown <time> - shuts down server in <time> seconds.");
_print.println("restart <time> - restarts down server in <time> seconds.");
_print.println("abort - aborts shutdown/restart.");
_print.println("give <player> <itemid> <amount>");
_print.println("enchant <player> <itemType> <enchant> (itemType: 1 - Helmet, 2 - Chest, 3 - Gloves, 4 - Feet, 5 - Legs, 6 - Right Hand, 7 - Left Hand, 8 - Left Ear, 9 - Right Ear , 10 - Left Finger, 11 - Right Finger, 12- Necklace, 13 - Underwear, 14 - Back, 15 - Belt, 0 - No Enchant)");
_print.println("debug <cmd> - executes the debug command (see 'help debug').");
_print.println("reload <type> - reload data");
_print.println("jail <player> [time]");
_print.println("unjail <player>");
_print.println("quit - closes telnet session.");
}
else if (command.equals("help debug"))
{
_print.println("The following is a list of all available debug commands: ");
_print.println("full - Dumps complete debug information to an file (recommended)");
_print.println("decay - prints info about the DecayManager");
_print.println("packetsend - Send packet data to a player");
_print.println("PacketTP - prints info about the General Packet ThreadPool");
_print.println("IOPacketTP - prints info about the I/O Packet ThreadPool");
_print.println("GeneralTP - prints info about the General ThreadPool");
}
return false;
}
@Override
public String[] getCommandList()
{
return _commands;
}
}

View File

@@ -1,363 +0,0 @@
/*
* 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.telnethandlers;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.handler.ITelnetHandler;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
import com.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
import com.l2jmobius.gameserver.util.GMAudit;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class PlayerHandler implements ITelnetHandler
{
private final String[] _commands =
{
"kick",
"give",
"enchant",
"jail",
"unjail"
};
@Override
public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int _uptime)
{
if (command.startsWith("kick"))
{
try
{
command = command.substring(5);
final L2PcInstance player = L2World.getInstance().getPlayer(command);
if (player != null)
{
player.sendMessage("You are kicked by gm");
player.logout();
_print.println("Player kicked");
}
}
catch (StringIndexOutOfBoundsException e)
{
_print.println("Please enter player name to kick");
}
}
else if (command.startsWith("give"))
{
final StringTokenizer st = new StringTokenizer(command.substring(5));
try
{
final L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
final int itemId = Integer.parseInt(st.nextToken());
final int amount = Integer.parseInt(st.nextToken());
if (player != null)
{
final L2ItemInstance item = player.getInventory().addItem("Status-Give", itemId, amount, null, null);
final InventoryUpdate iu = new InventoryUpdate();
iu.addItem(item);
player.sendPacket(iu);
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_OBTAINED_S2_S1);
sm.addItemName(itemId);
sm.addLong(amount);
player.sendPacket(sm);
_print.println("ok");
GMAudit.auditGMAction("Telnet Admin", "Give Item", player.getName(), "item: " + itemId + " amount: " + amount);
}
else
{
_print.println("Player not found");
}
}
catch (Exception e)
{
}
}
else if (command.startsWith("enchant"))
{
final StringTokenizer st = new StringTokenizer(command.substring(8), " ");
int enchant = 0, itemType = 0;
try
{
final L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
itemType = Integer.parseInt(st.nextToken());
enchant = Integer.parseInt(st.nextToken());
switch (itemType)
{
case 1:
{
itemType = Inventory.PAPERDOLL_HEAD;
break;
}
case 2:
{
itemType = Inventory.PAPERDOLL_CHEST;
break;
}
case 3:
{
itemType = Inventory.PAPERDOLL_GLOVES;
break;
}
case 4:
{
itemType = Inventory.PAPERDOLL_FEET;
break;
}
case 5:
{
itemType = Inventory.PAPERDOLL_LEGS;
break;
}
case 6:
{
itemType = Inventory.PAPERDOLL_RHAND;
break;
}
case 7:
{
itemType = Inventory.PAPERDOLL_LHAND;
break;
}
case 8:
{
itemType = Inventory.PAPERDOLL_LEAR;
break;
}
case 9:
{
itemType = Inventory.PAPERDOLL_REAR;
break;
}
case 10:
{
itemType = Inventory.PAPERDOLL_LFINGER;
break;
}
case 11:
{
itemType = Inventory.PAPERDOLL_RFINGER;
break;
}
case 12:
{
itemType = Inventory.PAPERDOLL_NECK;
break;
}
case 13:
{
itemType = Inventory.PAPERDOLL_UNDER;
break;
}
case 14:
{
itemType = Inventory.PAPERDOLL_CLOAK;
break;
}
case 15:
{
itemType = Inventory.PAPERDOLL_BELT;
break;
}
default:
{
itemType = 0;
}
}
if (enchant > 65535)
{
enchant = 65535;
}
else if (enchant < 0)
{
enchant = 0;
}
boolean success = false;
if ((player != null) && (itemType > 0))
{
success = setEnchant(player, enchant, itemType);
if (success)
{
_print.println("Item enchanted successfully.");
}
}
else if (!success)
{
_print.println("Item failed to enchant.");
}
}
catch (Exception e)
{
}
}
else if (command.startsWith("jail"))
{
final StringTokenizer st = new StringTokenizer(command.substring(5));
try
{
final String name = st.nextToken();
final int charId = CharNameTable.getInstance().getIdByName(name);
int delay = 0;
String reason = "";
if (st.hasMoreTokens())
{
final String token = st.nextToken();
if (Util.isDigit(token))
{
delay = Integer.parseInt(token);
}
while (st.hasMoreTokens())
{
reason += st.nextToken() + " ";
}
if (!reason.isEmpty())
{
reason = reason.substring(0, reason.length() - 1);
}
}
if (charId > 0)
{
final long expirationTime = delay > 0 ? System.currentTimeMillis() + (delay * 60 * 1000) : -1;
PunishmentManager.getInstance().startPunishment(new PunishmentTask(charId, PunishmentAffect.CHARACTER, PunishmentType.JAIL, expirationTime, reason, "Telnet Admin: " + _cSocket.getInetAddress().getHostAddress()));
_print.println("Character " + name + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
}
else
{
_print.println("Character with name: " + name + " was not found!");
}
}
catch (NoSuchElementException nsee)
{
_print.println("Specify a character name.");
}
catch (Exception e)
{
}
}
else if (command.startsWith("unjail"))
{
final StringTokenizer st = new StringTokenizer(command.substring(7));
try
{
final String name = st.nextToken();
final int charId = CharNameTable.getInstance().getIdByName(name);
if (charId > 0)
{
PunishmentManager.getInstance().stopPunishment(charId, PunishmentAffect.CHARACTER, PunishmentType.JAIL);
_print.println("Character " + name + " have been unjailed");
}
else
{
_print.println("Character with name: " + name + " was not found!");
}
}
catch (NoSuchElementException nsee)
{
_print.println("Specify a character name.");
}
catch (Exception e)
{
}
}
return false;
}
private boolean setEnchant(L2PcInstance activeChar, int ench, int armorType)
{
// now we need to find the equipped weapon of the targeted character...
int curEnchant = 0; // display purposes only
L2ItemInstance itemInstance = null;
// only attempt to enchant if there is a weapon equipped
L2ItemInstance parmorInstance = activeChar.getInventory().getPaperdollItem(armorType);
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType))
{
itemInstance = parmorInstance;
}
else
{
// for bows/crossbows and double handed weapons
parmorInstance = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == Inventory.PAPERDOLL_RHAND))
{
itemInstance = parmorInstance;
}
}
if (itemInstance != null)
{
curEnchant = itemInstance.getEnchantLevel();
// set enchant value
activeChar.getInventory().unEquipItemInSlot(armorType);
itemInstance.setEnchantLevel(ench);
activeChar.getInventory().equipItem(itemInstance);
// send packets
final InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(itemInstance);
activeChar.sendPacket(iu);
activeChar.broadcastPacket(new CharInfo(activeChar));
activeChar.sendPacket(new UserInfo(activeChar));
activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
// informations
activeChar.sendMessage("Changed enchantment of " + activeChar.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
activeChar.sendMessage("Admin has changed the enchantment of your " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
// log
GMAudit.auditGMAction("TelnetAdministrator", "enchant", activeChar.getName(), itemInstance.getItem().getName() + "(" + itemInstance.getObjectId() + ") from " + curEnchant + " to " + ench);
return true;
}
return false;
}
@Override
public String[] getCommandList()
{
return _commands;
}
}

View File

@@ -1,148 +0,0 @@
/*
* 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.telnethandlers;
import java.io.PrintWriter;
import java.net.Socket;
import java.nio.file.Paths;
import java.util.StringTokenizer;
import java.util.logging.Level;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.sql.impl.TeleportLocationTable;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.handler.ITelnetHandler;
import com.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
import com.l2jmobius.gameserver.instancemanager.QuestManager;
import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
/**
* @author UnAfraid
*/
public class ReloadHandler implements ITelnetHandler
{
private final String[] _commands =
{
"reload"
};
@Override
public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int _uptime)
{
if (command.startsWith("reload"))
{
final StringTokenizer st = new StringTokenizer(command.substring(7));
try
{
final String type = st.nextToken();
if (type.equals("multisell"))
{
_print.print("Reloading multisell... ");
MultisellData.getInstance().load();
_print.println("done");
}
else if (type.equals("skill"))
{
_print.print("Reloading skills... ");
SkillData.getInstance().reload();
_print.println("done");
}
else if (type.equals("npc"))
{
_print.print("Reloading npc templates... ");
NpcData.getInstance().load();
QuestManager.getInstance().reloadAllScripts();
_print.println("done");
}
else if (type.equals("html"))
{
_print.print("Reloading html cache... ");
HtmCache.getInstance().reload();
_print.println("done");
}
else if (type.equals("item"))
{
_print.print("Reloading item templates... ");
ItemTable.getInstance().reload();
_print.println("done");
}
else if (type.equals("zone"))
{
_print.print("Reloading zone tables... ");
ZoneManager.getInstance().reload();
_print.println("done");
}
else if (type.equals("teleports"))
{
_print.print("Reloading telport location table... ");
TeleportLocationTable.getInstance().reloadAll();
_print.println("done");
}
else if (type.equals("spawns"))
{
_print.print("Reloading spawns... ");
RaidBossSpawnManager.getInstance().cleanUp();
DayNightSpawnManager.getInstance().cleanUp();
L2World.getInstance().deleteVisibleNpcSpawns();
NpcData.getInstance().load();
SpawnTable.getInstance().load();
RaidBossSpawnManager.getInstance().load();
_print.println("done\n");
}
else if (type.equalsIgnoreCase("script"))
{
try
{
String questPath = st.hasMoreTokens() ? st.nextToken() : "";
try
{
ScriptEngineManager.getInstance().executeScript(Paths.get(questPath));
_print.println(questPath + " was successfully loaded!\n");
}
catch (Exception e)
{
_log.log(Level.WARNING, "Failed to execute script!", e);
}
}
catch (StringIndexOutOfBoundsException e)
{
_print.println("Please Enter Some Text!");
}
}
}
catch (Exception e)
{
}
}
return false;
}
@Override
public String[] getCommandList()
{
return _commands;
}
}

View File

@@ -1,89 +0,0 @@
/*
* 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.telnethandlers;
import java.io.PrintWriter;
import java.net.Socket;
import com.l2jmobius.gameserver.Shutdown;
import com.l2jmobius.gameserver.handler.ITelnetHandler;
/**
* @author UnAfraid
*/
public class ServerHandler implements ITelnetHandler
{
private final String[] _commands =
{
"shutdown",
"restart",
"abort"
};
@Override
public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int _uptime)
{
if (command.startsWith("shutdown"))
{
try
{
final int val = Integer.parseInt(command.substring(9));
Shutdown.getInstance().startTelnetShutdown(_cSocket.getInetAddress().getHostAddress(), val, false);
_print.println("Server Will Shutdown In " + val + " Seconds!");
_print.println("Type \"abort\" To Abort Shutdown!");
}
catch (StringIndexOutOfBoundsException e)
{
_print.println("Please Enter * amount of seconds to shutdown!");
}
catch (Exception NumberFormatException)
{
_print.println("Numbers Only!");
}
}
else if (command.startsWith("restart"))
{
try
{
final int val = Integer.parseInt(command.substring(8));
Shutdown.getInstance().startTelnetShutdown(_cSocket.getInetAddress().getHostAddress(), val, true);
_print.println("Server Will Restart In " + val + " Seconds!");
_print.println("Type \"abort\" To Abort Restart!");
}
catch (StringIndexOutOfBoundsException e)
{
_print.println("Please Enter * amount of seconds to restart!");
}
catch (Exception NumberFormatException)
{
_print.println("Numbers Only!");
}
}
else if (command.startsWith("abort"))
{
Shutdown.getInstance().telnetAbort(_cSocket.getInetAddress().getHostAddress());
_print.println("OK! - Shutdown/Restart Aborted.");
}
return false;
}
@Override
public String[] getCommandList()
{
return _commands;
}
}

View File

@@ -1,255 +0,0 @@
/*
* 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.telnethandlers;
import java.io.PrintWriter;
import java.net.Socket;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.LoginServerThread;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.handler.ITelnetHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
/**
* @author UnAfraid
*/
public class StatusHandler implements ITelnetHandler
{
private final String[] _commands =
{
"status",
"forcegc",
"memusage",
"gmlist"
};
private int uptime;
@Override
public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int _uptime)
{
if (command.equals("status"))
{
uptime = _uptime;
_print.print(getServerStatus());
_print.flush();
}
else if (command.equals("forcegc"))
{
System.gc();
final StringBuilder sb = new StringBuilder();
sb.append("RAM Used: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576)); // 1024 * 1024 = 1048576
_print.println(sb.toString());
}
else if (command.startsWith("memusage"))
{
final double max = Runtime.getRuntime().maxMemory() / 1024; // maxMemory is the upper
// limit the jvm can use
final double allocated = Runtime.getRuntime().totalMemory() / 1024; // totalMemory the
// size of the
// current
// allocation pool
final double nonAllocated = max - allocated; // non allocated memory till jvm limit
final double cached = Runtime.getRuntime().freeMemory() / 1024; // freeMemory the
// unused memory in
// the allocation pool
final double used = allocated - cached; // really used memory
final double useable = max - used; // allocated, but non-used and non-allocated memory
final DecimalFormat df = new DecimalFormat(" (0.0000'%')");
final DecimalFormat df2 = new DecimalFormat(" # 'KB'");
_print.println("+----");// ...
_print.println("| Allowed Memory:" + df2.format(max));
_print.println("| |= Allocated Memory:" + df2.format(allocated) + df.format((allocated / max) * 100));
_print.println("| |= Non-Allocated Memory:" + df2.format(nonAllocated) + df.format((nonAllocated / max) * 100));
_print.println("| Allocated Memory:" + df2.format(allocated));
_print.println("| |= Used Memory:" + df2.format(used) + df.format((used / max) * 100));
_print.println("| |= Unused (cached) Memory:" + df2.format(cached) + df.format((cached / max) * 100));
_print.println("| Useable Memory:" + df2.format(useable) + df.format((useable / max) * 100)); // ...
_print.println("+----");
}
else if (command.equals("gmlist"))
{
int igm = 0;
String gmList = "";
for (String player : AdminData.getInstance().getAllGmNames(true))
{
gmList = gmList + ", " + player;
igm++;
}
_print.println("There are currently " + igm + " GM(s) online...");
if (!gmList.isEmpty())
{
_print.println(gmList);
}
}
return false;
}
public String getServerStatus()
{
int playerCount = 0, objectCount = 0;
final int max = LoginServerThread.getInstance().getMaxPlayer();
playerCount = L2World.getInstance().getAllPlayersCount();
objectCount = L2World.getInstance().getVisibleObjectsCount();
int itemCount = 0;
int itemVoidCount = 0;
int monsterCount = 0;
int minionCount = 0;
int minionsGroupCount = 0;
int npcCount = 0;
int charCount = 0;
int pcCount = 0;
int detachedCount = 0;
int doorCount = 0;
int summonCount = 0;
int AICount = 0;
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (obj == null)
{
continue;
}
if (obj instanceof L2Character)
{
if (((L2Character) obj).hasAI())
{
AICount++;
}
}
if (obj instanceof L2ItemInstance)
{
if (((L2ItemInstance) obj).getItemLocation() == ItemLocation.VOID)
{
itemVoidCount++;
}
else
{
itemCount++;
}
}
else if (obj instanceof L2MonsterInstance)
{
monsterCount++;
if (((L2MonsterInstance) obj).hasMinions())
{
minionCount += ((L2MonsterInstance) obj).getMinionList().countSpawnedMinions();
minionsGroupCount += ((L2MonsterInstance) obj).getMinionList().lazyCountSpawnedMinionsGroups();
}
}
else if (obj instanceof L2Npc)
{
npcCount++;
}
else if (obj instanceof L2PcInstance)
{
pcCount++;
if ((((L2PcInstance) obj).getClient() != null) && ((L2PcInstance) obj).getClient().isDetached())
{
detachedCount++;
}
}
else if (obj instanceof L2Summon)
{
summonCount++;
}
else if (obj instanceof L2DoorInstance)
{
doorCount++;
}
else if (obj instanceof L2Character)
{
charCount++;
}
}
final StringBuilder sb = new StringBuilder();
sb.append("Server Status: ");
sb.append("\r\n ---> Player Count: " + playerCount + "/" + max);
sb.append("\r\n ---> Offline Count: " + detachedCount + "/" + playerCount);
sb.append("\r\n +--> Object Count: " + objectCount);
sb.append("\r\n +--> AI Count: " + AICount);
sb.append("\r\n +.... L2Item(Void): " + itemVoidCount);
sb.append("\r\n +.......... L2Item: " + itemCount);
sb.append("\r\n +....... L2Monster: " + monsterCount);
sb.append("\r\n +......... Minions: " + minionCount);
sb.append("\r\n +.. Minions Groups: " + minionsGroupCount);
sb.append("\r\n +........... L2Npc: " + npcCount);
sb.append("\r\n +............ L2Pc: " + pcCount);
sb.append("\r\n +........ L2Summon: " + summonCount);
sb.append("\r\n +.......... L2Door: " + doorCount);
sb.append("\r\n +.......... L2Char: " + charCount);
sb.append("\r\n ---> Ingame Time: " + gameTime());
sb.append("\r\n ---> Server Uptime: " + getUptime(uptime));
sb.append("\r\n ---> GM Count: " + getOnlineGMS());
sb.append("\r\n ---> Threads: " + Thread.activeCount());
sb.append("\r\n RAM Used: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576)); // 1024 * 1024 = 1048576
sb.append("\r\n");
return sb.toString();
}
private int getOnlineGMS()
{
return AdminData.getInstance().getAllGms(true).size();
}
private String getUptime(int time)
{
int uptime = (int) System.currentTimeMillis() - time;
uptime = uptime / 1000;
final int h = uptime / 3600;
final int m = (uptime - (h * 3600)) / 60;
final int s = ((uptime - (h * 3600)) - (m * 60));
return h + "hrs " + m + "mins " + s + "secs";
}
private String gameTime()
{
final int t = GameTimeController.getInstance().getGameTime();
final int h = t / 60;
final int m = t % 60;
final SimpleDateFormat format = new SimpleDateFormat("H:mm");
final Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, h);
cal.set(Calendar.MINUTE, m);
return format.format(cal.getTime());
}
@Override
public String[] getCommandList()
{
return _commands;
}
}

View File

@@ -1,66 +0,0 @@
/*
* 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.telnethandlers;
import java.io.PrintWriter;
import java.net.Socket;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.handler.ITelnetHandler;
/**
* @author UnAfraid
*/
public class ThreadHandler implements ITelnetHandler
{
private final String[] _commands =
{
"purge",
"performance"
};
@Override
public boolean useCommand(String command, PrintWriter _print, Socket _cSocket, int _uptime)
{
if (command.equals("performance"))
{
for (String line : ThreadPool.getStats())
{
_print.println(line);
}
_print.flush();
}
else if (command.equals("purge"))
{
ThreadPool.purge();
_print.println("STATUS OF THREAD POOLS AFTER PURGE COMMAND:");
_print.println("");
for (String line : ThreadPool.getStats())
{
_print.println(line);
}
_print.flush();
}
return false;
}
@Override
public String[] getCommandList()
{
return _commands;
}
}

View File

@@ -0,0 +1,56 @@
/*
* 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.telnethandlers.chat;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.Broadcast;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Announce implements ITelnetCommand
{
@Override
public String getCommand()
{
return "announce";
}
@Override
public String getUsage()
{
return "Announce <text>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
final StringBuilder sb = new StringBuilder();
for (String str : args)
{
sb.append(str + " ");
}
Broadcast.toAllOnlinePlayers(sb.toString());
return "Announcement sent!";
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.telnethandlers.chat;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class GMChat implements ITelnetCommand
{
@Override
public String getCommand()
{
return "gmchat";
}
@Override
public String getUsage()
{
return "Gmchat <text>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
final StringBuilder sb = new StringBuilder();
for (String str : args)
{
sb.append(str + " ");
}
AdminData.getInstance().broadcastToGMs(new CreatureSay(0, ChatType.ALLIANCE, "Telnet GM Broadcast", sb.toString()));
return "GMChat sent!";
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.telnethandlers.chat;
import com.l2jmobius.gameserver.enums.ChatType;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Msg implements ITelnetCommand
{
@Override
public String getCommand()
{
return "msg";
}
@Override
public String getUsage()
{
return "Msg <player> <text>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length < 2) || args[0].isEmpty())
{
return null;
}
final L2PcInstance player = L2World.getInstance().getPlayer(args[0]);
if (player != null)
{
final StringBuilder sb = new StringBuilder();
for (int i = 1; i < args.length; i++)
{
sb.append(args[i] + " ");
}
player.sendPacket(new CreatureSay(0, ChatType.WHISPER, "Telnet Priv", sb.toString()));
return "Announcement sent!";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,59 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class AccessLevel implements ITelnetCommand
{
@Override
public String getCommand()
{
return "accesslevel";
}
@Override
public String getUsage()
{
return "AccessLevel <player name> <access level>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length < 2) || args[0].isEmpty() || !Util.isDigit(args[1]))
{
return null;
}
final L2PcInstance player = L2World.getInstance().getPlayer(args[0]);
if (player != null)
{
final int level = Integer.parseInt(args[1]);
player.setAccessLevel(level);
return "Player " + player.getName() + "'s access level has been changed to: " + level;
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,84 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Ban implements ITelnetCommand
{
@Override
public String getCommand()
{
return "ban";
}
@Override
public String getUsage()
{
return "Ban <player name> [time in minutes]";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
final int objectId = CharNameTable.getInstance().getIdByName(args[0]);
if (objectId > 0)
{
if (PunishmentManager.getInstance().hasPunishment(objectId, PunishmentAffect.CHARACTER, PunishmentType.BAN))
{
return "Player is already banned.";
}
long time = -1;
String reason = "You have been banned by telnet admin.";
if (args.length > 1)
{
final String token = args[1];
if (Util.isDigit(token))
{
time = Integer.parseInt(token) * 60 * 1000;
time += System.currentTimeMillis();
}
if (args.length > 2)
{
reason = args[2];
for (int i = 3; i < args.length; i++)
{
reason += " " + args[i];
}
}
}
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objectId, PunishmentAffect.CHARACTER, PunishmentType.BAN, time, reason, "Telnet Admin"));
return "Player has been successfully banned.";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,84 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author lion
*/
public class BanChat implements ITelnetCommand
{
@Override
public String getCommand()
{
return "ban_chat";
}
@Override
public String getUsage()
{
return "ban_chat <player name> [time in minutes]";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
final int objectId = CharNameTable.getInstance().getIdByName(args[0]);
if (objectId > 0)
{
if (PunishmentManager.getInstance().hasPunishment(objectId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN))
{
return "Player is already chat banned.";
}
long time = -1;
String reason = "Your chat have been banned by telnet admin.";
if (args.length > 1)
{
final String token = args[1];
if (Util.isDigit(token))
{
time = Integer.parseInt(token) * 60 * 1000;
time += System.currentTimeMillis();
}
if (args.length > 2)
{
reason = args[2];
for (int i = 3; i < args.length; i++)
{
reason += " " + args[i];
}
}
}
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objectId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, time, reason, "Telnet Admin"));
return "Player has been successfully banned.";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,198 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.GMAudit;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Enchant implements ITelnetCommand
{
@Override
public String getCommand()
{
return "enchant";
}
@Override
public String getUsage()
{
return "Enchant <player name> <item id> [item amount] [item enchant]";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length < 3) || args[0].isEmpty() || !Util.isDigit(args[1]) || !Util.isDigit(args[2]))
{
return null;
}
final L2PcInstance player = L2World.getInstance().getPlayer(args[0]);
if (player != null)
{
int itemType = Integer.parseInt(args[1]);
int enchant = Integer.parseInt(args[2]);
enchant = Math.min(enchant, 127);
enchant = Math.max(enchant, 0);
switch (itemType)
{
case 1:
{
itemType = Inventory.PAPERDOLL_HEAD;
break;
}
case 2:
{
itemType = Inventory.PAPERDOLL_CHEST;
break;
}
case 3:
{
itemType = Inventory.PAPERDOLL_GLOVES;
break;
}
case 4:
{
itemType = Inventory.PAPERDOLL_FEET;
break;
}
case 5:
{
itemType = Inventory.PAPERDOLL_LEGS;
break;
}
case 6:
{
itemType = Inventory.PAPERDOLL_RHAND;
break;
}
case 7:
{
itemType = Inventory.PAPERDOLL_LHAND;
break;
}
case 8:
{
itemType = Inventory.PAPERDOLL_LEAR;
break;
}
case 9:
{
itemType = Inventory.PAPERDOLL_REAR;
break;
}
case 10:
{
itemType = Inventory.PAPERDOLL_LFINGER;
break;
}
case 11:
{
itemType = Inventory.PAPERDOLL_RFINGER;
break;
}
case 12:
{
itemType = Inventory.PAPERDOLL_NECK;
break;
}
case 13:
{
itemType = Inventory.PAPERDOLL_UNDER;
break;
}
case 14:
{
itemType = Inventory.PAPERDOLL_CLOAK;
break;
}
case 15:
{
itemType = Inventory.PAPERDOLL_BELT;
break;
}
default:
{
itemType = 0;
break;
}
}
final boolean success = setEnchant(player, enchant, itemType);
return success ? "Item has been successfully enchanted." : "Failed to enchant player's item!";
}
return "Couldn't find player with such name.";
}
private boolean setEnchant(L2PcInstance activeChar, int ench, int armorType)
{
// now we need to find the equipped weapon of the targeted character...
int curEnchant = 0; // display purposes only
L2ItemInstance itemInstance = null;
// only attempt to enchant if there is a weapon equipped
L2ItemInstance parmorInstance = activeChar.getInventory().getPaperdollItem(armorType);
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType))
{
itemInstance = parmorInstance;
}
else
{
// for bows/crossbows and double handed weapons
parmorInstance = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == Inventory.PAPERDOLL_RHAND))
{
itemInstance = parmorInstance;
}
}
if (itemInstance != null)
{
curEnchant = itemInstance.getEnchantLevel();
// set enchant value
activeChar.getInventory().unEquipItemInSlot(armorType);
itemInstance.setEnchantLevel(ench);
activeChar.getInventory().equipItem(itemInstance);
// send packets
final InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(itemInstance);
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
// informations
activeChar.sendMessage("Changed enchantment of " + activeChar.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
activeChar.sendMessage("Admin has changed the enchantment of your " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
// log
GMAudit.auditGMAction("TelnetAdmin", "enchant", activeChar.getName(), itemInstance.getItem().getName() + "(" + itemInstance.getObjectId() + ") from " + curEnchant + " to " + ench);
return true;
}
return false;
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class GMList implements ITelnetCommand
{
@Override
public String getCommand()
{
return "gmlist";
}
@Override
public String getUsage()
{
return "GMList";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
int i = 0;
String gms = "";
for (String player : AdminData.getInstance().getAllGmNames(true))
{
gms += player + ", ";
i++;
}
if (!gms.isEmpty())
{
gms = gms.substring(0, gms.length() - 2) + ".";
}
return "There are currently " + i + " GM(s) online..." + Config.EOL + gms;
}
}

View File

@@ -0,0 +1,85 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Give implements ITelnetCommand
{
@Override
public String getCommand()
{
return "give";
}
@Override
public String getUsage()
{
return "Give <player name> <item id> [item amount] [item enchant] [donators]";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length < 2) || args[0].isEmpty() || !Util.isDigit(args[1]))
{
return null;
}
final L2PcInstance player = L2World.getInstance().getPlayer(args[0]);
if (player != null)
{
final int itemId = Integer.parseInt(args[1]);
long amount = 1;
int enchanted = 0;
if (args.length > 2)
{
String token = args[2];
if (Util.isDigit(token))
{
amount = Long.parseLong(token);
}
if (args.length > 3)
{
token = args[3];
if (Util.isDigit(token))
{
enchanted = Integer.parseInt(token);
}
}
}
final L2ItemInstance item = ItemTable.getInstance().createItem("Telnet-Admin", itemId, amount, player, null);
if (enchanted > 0)
{
item.setEnchantLevel(enchanted);
}
player.addItem("Telnet-Admin", item, null, true);
return "Item has been successfully given to the player.";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,84 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Jail implements ITelnetCommand
{
@Override
public String getCommand()
{
return "jail";
}
@Override
public String getUsage()
{
return "Jail <player name> [time in minutes]";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
final int objectId = CharNameTable.getInstance().getIdByName(args[0]);
if (objectId > 0)
{
if (PunishmentManager.getInstance().hasPunishment(objectId, PunishmentAffect.CHARACTER, PunishmentType.JAIL))
{
return "Player is already jailed.";
}
String reason = "You have been jailed by telnet admin.";
long time = -1;
if (args.length > 1)
{
final String token = args[1];
if (Util.isDigit(token))
{
time = Integer.parseInt(token) * 60 * 1000;
time += System.currentTimeMillis();
}
if (args.length > 2)
{
reason = args[2];
for (int i = 3; i < args.length; i++)
{
reason += " " + args[i];
}
}
}
PunishmentManager.getInstance().startPunishment(new PunishmentTask(objectId, PunishmentAffect.CHARACTER, PunishmentType.JAIL, time, reason, "Telnet Admin"));
return "Player has been successfully jailed.";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,57 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Kick implements ITelnetCommand
{
@Override
public String getCommand()
{
return "kick";
}
@Override
public String getUsage()
{
return "Kick <player name>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
final L2PcInstance player = L2World.getInstance().getPlayer(args[0]);
if (player != null)
{
player.logout();
return "Player has been successfully kicked.";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,96 @@
/*
* 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.telnethandlers.player;
import java.util.ArrayList;
import java.util.List;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.instancemanager.MailManager;
import com.l2jmobius.gameserver.model.entity.Message;
import com.l2jmobius.gameserver.model.holders.ItemHolder;
import com.l2jmobius.gameserver.model.itemcontainer.Mail;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author Mobius
*/
public class SendMail implements ITelnetCommand
{
@Override
public String getCommand()
{
return "sendmail";
}
@Override
public String getUsage()
{
return "sendmail <player name> <mail subject (use _ for spaces)> <mail message (use _ for spaces)> <item(s) (optional) e.g. 57x1000000>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length < 3) || args[0].isEmpty())
{
return null;
}
final int objectId = CharNameTable.getInstance().getIdByName(args[0]);
if (objectId > 0)
{
final Message msg = new Message(objectId, args[1].replace("_", " "), args[2].replace("_", " "), Message.SendBySystem.NEWS);
final List<ItemHolder> itemHolders = new ArrayList<>();
int counter = -1;
for (String str : args)
{
counter++;
if (counter < 3)
{
continue;
}
if (str.toLowerCase().contains("x"))
{
final String itemId = str.toLowerCase().split("x")[0];
final String itemCount = str.toLowerCase().split("x")[1];
if (Util.isDigit(itemId) && Util.isDigit(itemCount))
{
itemHolders.add(new ItemHolder(Integer.parseInt(itemId), Long.parseLong(itemCount)));
}
}
else if (Util.isDigit(str))
{
itemHolders.add(new ItemHolder(Integer.parseInt(str), 1));
}
}
if (!itemHolders.isEmpty())
{
final Mail attachments = msg.createAttachments();
for (ItemHolder itemHolder : itemHolders)
{
attachments.addItem("Telnet-Mail", itemHolder.getId(), itemHolder.getCount(), null, null);
}
}
MailManager.getInstance().sendMessage(msg);
return "An ingame mail has been sent to " + args[0] + ".";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Unban implements ITelnetCommand
{
@Override
public String getCommand()
{
return "unban";
}
@Override
public String getUsage()
{
return "Unban <player name>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
final int objectId = CharNameTable.getInstance().getIdByName(args[0]);
if (objectId > 0)
{
if (!PunishmentManager.getInstance().hasPunishment(objectId, PunishmentAffect.CHARACTER, PunishmentType.BAN))
{
return "Player is not banned at all.";
}
PunishmentManager.getInstance().stopPunishment(objectId, PunishmentAffect.CHARACTER, PunishmentType.BAN);
return "Player has been successfully unbanned.";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class UnbanChat implements ITelnetCommand
{
@Override
public String getCommand()
{
return "unban_chat";
}
@Override
public String getUsage()
{
return "unban_chat <player name>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
final int objectId = CharNameTable.getInstance().getIdByName(args[0]);
if (objectId > 0)
{
if (!PunishmentManager.getInstance().hasPunishment(objectId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN))
{
return "Player is not banned at all.";
}
PunishmentManager.getInstance().stopPunishment(objectId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN);
return "Player chat has been successfully unbanned.";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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.telnethandlers.player;
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Unjail implements ITelnetCommand
{
@Override
public String getCommand()
{
return "unjail";
}
@Override
public String getUsage()
{
return "Unjail <player name>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
final int objectId = CharNameTable.getInstance().getIdByName(args[0]);
if (objectId > 0)
{
if (!PunishmentManager.getInstance().hasPunishment(objectId, PunishmentAffect.CHARACTER, PunishmentType.JAIL))
{
return "Player is not jailed at all.";
}
PunishmentManager.getInstance().stopPunishment(objectId, PunishmentAffect.CHARACTER, PunishmentType.JAIL);
return "Player has been successfully unjailed.";
}
return "Couldn't find player with such name.";
}
}

View File

@@ -0,0 +1,375 @@
/*
* 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.telnethandlers.server;
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.GameServer;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.LoginServerThread;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.serverpackets.AdminForgePacket;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Debug implements ITelnetCommand
{
private static final Logger LOGGER = Logger.getLogger(Debug.class.getName());
@Override
public String getCommand()
{
return "debug";
}
@Override
public String getUsage()
{
return "Debug <decay/packetsend/full>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
switch (args[0])
{
case "decay":
{
return DecayTaskManager.getInstance().toString();
}
case "packetsend":
{
if (args.length < 4)
{
return "Usage: debug packetsend <charName> <packetData>";
}
final L2PcInstance player = L2World.getInstance().getPlayer(args[1]);
if (player == null)
{
return "Couldn't find player with such name.";
}
final AdminForgePacket sp = new AdminForgePacket();
for (int i = 2; i < args.length; i++)
{
final String b = args[i];
if (!b.isEmpty())
{
sp.addPart("C".getBytes()[0], "0x" + b);
}
}
player.sendPacket(sp);
return "Packet has been sent!";
}
case "full":
{
final Calendar cal = Calendar.getInstance();
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
final StringBuilder sb = new StringBuilder();
sb.append(sdf.format(cal.getTime()));
sb.append("\r\nServer");
sb.append("\r\n");
sb.append(getServerStatus());
sb.append("\r\n");
sb.append("\r\n## Java Platform Information ##");
sb.append("\r\nJava Runtime Name: " + System.getProperty("java.runtime.name"));
sb.append("\r\nJava Version: " + System.getProperty("java.version"));
sb.append("\r\nJava Class Version: " + System.getProperty("java.class.version"));
sb.append("\r\n");
sb.append("\r\n## Virtual Machine Information ##");
sb.append("\r\nVM Name: " + System.getProperty("java.vm.name"));
sb.append("\r\nVM Version: " + System.getProperty("java.vm.version"));
sb.append("\r\nVM Vendor: " + System.getProperty("java.vm.vendor"));
sb.append("\r\nVM Info: " + System.getProperty("java.vm.info"));
sb.append("\r\n");
sb.append("\r\n## OS Information ##");
sb.append("\r\nName: " + System.getProperty("os.name"));
sb.append("\r\nArchiteture: " + System.getProperty("os.arch"));
sb.append("\r\nVersion: " + System.getProperty("os.version"));
sb.append("\r\n");
sb.append("\r\n## Runtime Information ##");
sb.append("\r\nCPU Count: " + Runtime.getRuntime().availableProcessors());
sb.append("\r\nCurrent Free Heap Size: " + (Runtime.getRuntime().freeMemory() / 1024 / 1024) + " mb");
sb.append("\r\nCurrent Heap Size: " + (Runtime.getRuntime().totalMemory() / 1024 / 1024) + " mb");
sb.append("\r\nMaximum Heap Size: " + (Runtime.getRuntime().maxMemory() / 1024 / 1024) + " mb");
sb.append("\r\n");
sb.append("\r\n## Class Path Information ##\r\n");
final String cp = System.getProperty("java.class.path");
final String[] libs = cp.split(File.pathSeparator);
for (String lib : libs)
{
sb.append(lib);
sb.append("\r\n");
}
sb.append("\r\n");
sb.append("## Threads Information ##\r\n");
final Map<Thread, StackTraceElement[]> allThread = Thread.getAllStackTraces();
final List<Entry<Thread, StackTraceElement[]>> entries = new ArrayList<>(allThread.entrySet());
Collections.sort(entries, (e1, e2) -> e1.getKey().getName().compareTo(e2.getKey().getName()));
for (Entry<Thread, StackTraceElement[]> entry : entries)
{
final StackTraceElement[] stes = entry.getValue();
final Thread t = entry.getKey();
sb.append("--------------\r\n");
sb.append(t + " (" + t.getId() + ")\r\n");
sb.append("State: " + t.getState() + "\r\n");
sb.append("isAlive: " + t.isAlive() + " | isDaemon: " + t.isDaemon() + " | isInterrupted: " + t.isInterrupted() + "\r\n");
sb.append("\r\n");
for (StackTraceElement ste : stes)
{
sb.append(ste.toString());
sb.append("\r\n");
}
sb.append("\r\n");
}
sb.append("\r\n");
final ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
final long[] ids = findDeadlockedThreads(mbean);
if ((ids != null) && (ids.length > 0))
{
final Thread[] threads = new Thread[ids.length];
for (int i = 0; i < threads.length; i++)
{
threads[i] = findMatchingThread(mbean.getThreadInfo(ids[i]));
}
sb.append("Deadlocked Threads:\r\n");
sb.append("-------------------\r\n");
for (Thread thread : threads)
{
System.err.println(thread);
for (StackTraceElement ste : thread.getStackTrace())
{
sb.append("\t" + ste);
sb.append("\r\n");
}
}
}
sb.append("\r\n## Thread Pool Manager Statistics ##\r\n");
for (String line : ThreadPool.getStats())
{
sb.append(line);
sb.append("\r\n");
}
int i = 0;
File f = new File("./log/Debug-" + i + ".txt");
while (f.exists())
{
i++;
f = new File("./log/Debug-" + i + ".txt");
}
f.getParentFile().mkdirs();
try
{
Files.write(f.toPath(), sb.toString().getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE_NEW, StandardOpenOption.WRITE);
}
catch (IOException e)
{
LOGGER.log(Level.WARNING, "Couldn't write packet tp.", e);
}
return "Debug output saved to log/" + f.getName();
}
}
return null;
}
private long[] findDeadlockedThreads(ThreadMXBean mbean)
{
// JDK 1.5 only supports the findMonitorDeadlockedThreads()
// method, so you need to comment out the following three lines
if (mbean.isSynchronizerUsageSupported())
{
return mbean.findDeadlockedThreads();
}
return mbean.findMonitorDeadlockedThreads();
}
private Thread findMatchingThread(ThreadInfo inf)
{
for (Thread thread : Thread.getAllStackTraces().keySet())
{
if (thread.getId() == inf.getThreadId())
{
return thread;
}
}
throw new IllegalStateException("Deadlocked Thread not found");
}
public static String getServerStatus()
{
int playerCount = 0, objectCount = 0;
final int max = LoginServerThread.getInstance().getMaxPlayer();
playerCount = L2World.getInstance().getPlayers().size();
objectCount = L2World.getInstance().getVisibleObjectsCount();
int itemCount = 0;
int itemVoidCount = 0;
int monsterCount = 0;
int minionCount = 0;
int minionsGroupCount = 0;
int npcCount = 0;
int charCount = 0;
int pcCount = 0;
int detachedCount = 0;
int doorCount = 0;
int summonCount = 0;
int AICount = 0;
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (obj == null)
{
continue;
}
if (obj.isCharacter())
{
if (((L2Character) obj).hasAI())
{
AICount++;
}
}
if (obj.isItem())
{
if (((L2ItemInstance) obj).getItemLocation() == ItemLocation.VOID)
{
itemVoidCount++;
}
else
{
itemCount++;
}
}
else if (obj.isMonster())
{
monsterCount++;
if (((L2MonsterInstance) obj).hasMinions())
{
minionCount += ((L2MonsterInstance) obj).getMinionList().countSpawnedMinions();
minionsGroupCount += ((L2MonsterInstance) obj).getMinionList().lazyCountSpawnedMinionsGroups();
}
}
else if (obj.isNpc())
{
npcCount++;
}
else if (obj.isPlayer())
{
pcCount++;
if ((((L2PcInstance) obj).getClient() != null) && ((L2PcInstance) obj).getClient().isDetached())
{
detachedCount++;
}
}
else if (obj.isSummon())
{
summonCount++;
}
else if (obj.isDoor())
{
doorCount++;
}
else if (obj.isCharacter())
{
charCount++;
}
}
final StringBuilder sb = new StringBuilder();
sb.append("Server Status: ");
sb.append("\r\n ---> Player Count: " + playerCount + "/" + max);
sb.append("\r\n ---> Offline Count: " + detachedCount + "/" + playerCount);
sb.append("\r\n +--> Object Count: " + objectCount);
sb.append("\r\n +--> AI Count: " + AICount);
sb.append("\r\n +.... L2Item(Void): " + itemVoidCount);
sb.append("\r\n +.......... L2Item: " + itemCount);
sb.append("\r\n +....... L2Monster: " + monsterCount);
sb.append("\r\n +......... Minions: " + minionCount);
sb.append("\r\n +.. Minions Groups: " + minionsGroupCount);
sb.append("\r\n +........... L2Npc: " + npcCount);
sb.append("\r\n +............ L2Pc: " + pcCount);
sb.append("\r\n +........ L2Summon: " + summonCount);
sb.append("\r\n +.......... L2Door: " + doorCount);
sb.append("\r\n +.......... L2Char: " + charCount);
sb.append("\r\n ---> Ingame Time: " + gameTime());
sb.append("\r\n ---> Server Uptime: " + GameServer.getInstance().getUptime());
sb.append("\r\n ---> GM Count: " + getOnlineGMS());
sb.append("\r\n ---> Threads: " + Thread.activeCount());
sb.append("\r\n RAM Used: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576)); // 1024 * 1024 = 1048576
sb.append("\r\n");
return sb.toString();
}
private static int getOnlineGMS()
{
return AdminData.getInstance().getAllGms(true).size();
}
private static String gameTime()
{
final int t = GameTimeController.getInstance().getGameTime();
final int h = t / 60;
final int m = t % 60;
final SimpleDateFormat format = new SimpleDateFormat("H:mm");
final Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, h);
cal.set(Calendar.MINUTE, m);
return format.format(cal.getTime());
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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.telnethandlers.server;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class ForceGC implements ITelnetCommand
{
@Override
public String getCommand()
{
return "forcegc";
}
@Override
public String getUsage()
{
return "ForceGC";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
System.gc();
return "RAM Used: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576);
}
}

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 handlers.telnethandlers.server;
import java.text.DecimalFormat;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Memusage implements ITelnetCommand
{
@Override
public String getCommand()
{
return "memusage";
}
@Override
public String getUsage()
{
return "MemUsage";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
final double max = Runtime.getRuntime().maxMemory() / 1024; // maxMemory is the upper
// limit the jvm can use
final double allocated = Runtime.getRuntime().totalMemory() / 1024; // totalMemory the
// size of the current allocation pool
final double nonAllocated = max - allocated; // non allocated memory till jvm limit
final double cached = Runtime.getRuntime().freeMemory() / 1024; // freeMemory the
// unused memory in the allocation pool
final double used = allocated - cached; // really used memory
final double useable = max - used; // allocated, but non-used and non-allocated memory
final StringBuilder sb = new StringBuilder();
final DecimalFormat df = new DecimalFormat(" (0.0000'%')");
final DecimalFormat df2 = new DecimalFormat(" # 'KB'");
sb.append("+----" + Config.EOL); // ...
sb.append("| Allowed Memory:" + df2.format(max) + Config.EOL);
sb.append("| |= Allocated Memory:" + df2.format(allocated) + df.format((allocated / max) * 100) + Config.EOL);
sb.append("| |= Non-Allocated Memory:" + df2.format(nonAllocated) + df.format((nonAllocated / max) * 100) + Config.EOL);
sb.append("| Allocated Memory:" + df2.format(allocated) + Config.EOL);
sb.append("| |= Used Memory:" + df2.format(used) + df.format((used / max) * 100) + Config.EOL);
sb.append("| |= Unused (cached) Memory:" + df2.format(cached) + df.format((cached / max) * 100) + Config.EOL);
sb.append("| Useable Memory:" + df2.format(useable) + df.format((useable / max) * 100) + Config.EOL); // ...
sb.append("+----" + Config.EOL);
return sb.toString();
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.telnethandlers.server;
import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Performance implements ITelnetCommand
{
@Override
public String getCommand()
{
return "performance";
}
@Override
public String getUsage()
{
return "Performance";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
// ThreadPoolManager.purge();
final StringBuilder sb = new StringBuilder();
for (String line : ThreadPool.getStats())
{
sb.append(line + Config.EOL);
}
return sb.toString();
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.telnethandlers.server;
import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Purge implements ITelnetCommand
{
@Override
public String getCommand()
{
return "purge";
}
@Override
public String getUsage()
{
return "Purge";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
ThreadPool.purge();
final StringBuilder sb = new StringBuilder("STATUS OF THREAD POOLS AFTER PURGE COMMAND:" + Config.EOL);
for (String line : ThreadPool.getStats())
{
sb.append(line + Config.EOL);
}
return sb.toString();
}
}

View File

@@ -0,0 +1,225 @@
/*
* 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.telnethandlers.server;
import java.io.File;
import java.nio.file.Paths;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.sql.impl.CrestTable;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.instancemanager.QuestManager;
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Reload implements ITelnetCommand
{
private static final Logger LOGGER = Logger.getLogger(Reload.class.getName());
@Override
public String getCommand()
{
return "reload";
}
@Override
public String getUsage()
{
return "Reload <zone/multisell/teleport/skill/npc/htm/item/config/npcwalkers/access/quests/door/primeshop/html/script>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || args[0].isEmpty())
{
return null;
}
switch (args[0])
{
case "config":
{
Config.load();
return "Telnet Admin: Reloaded Configs.";
}
case "access":
{
AdminData.getInstance().load();
return "Telnet Admin: Reloaded Access.";
}
case "npc":
{
NpcData.getInstance().load();
return "Telnet Admin: Reloaded Npcs.";
}
case "quest":
{
if (args.length > 1)
{
final String value = args[1];
if (!Util.isDigit(value))
{
QuestManager.getInstance().reload(value);
return "Telnet Admin: Reloaded Quest Name:" + value + ".";
}
final int questId = Integer.parseInt(value);
QuestManager.getInstance().reload(questId);
return "Telnet Admin: Reloaded Quest ID:" + questId + ".";
}
QuestManager.getInstance().reloadAllScripts();
return "Telnet Admin: Reloaded Quests.";
}
case "walker":
{
WalkingManager.getInstance().load();
return "Telnet Admin: Reloaded Walkers.";
}
case "htm":
case "html":
{
if (args.length > 1)
{
final String path = args[1];
final File file = new File(Config.DATAPACK_ROOT, "data/html/" + path);
if (file.exists())
{
HtmCache.getInstance().reload(file);
return "Telnet Admin: Reloaded Htm File:" + file.getName() + ".";
}
return "File or Directory does not exist.";
}
HtmCache.getInstance().reload();
return "Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " megabytes on " + HtmCache.getInstance().getLoadedFiles() + " files loaded";
}
case "multisell":
{
MultisellData.getInstance().load();
return "Telnet Admin: Reloaded Multisells.";
}
case "buylist":
{
BuyListData.getInstance().load();
return "Telnet Admin: Reloaded Buylists.";
}
case "skill":
{
SkillData.getInstance().reload();
return "Telnet Admin: Reloaded Skills.";
}
case "item":
{
ItemTable.getInstance().reload();
return "Telnet Admin: Reloaded Items.";
}
case "door":
{
DoorData.getInstance().load();
return "Telnet Admin: Reloaded Doors.";
}
case "zone":
{
ZoneManager.getInstance().reload();
return "Telnet Admin: Reloaded Zones.";
}
case "crest":
{
CrestTable.getInstance().load();
return "Telnet Admin: Reloaded Crests.";
}
case "effect":
{
try
{
ScriptEngineManager.getInstance().executeEffectMasterHandler();
return "Telnet Admin: Reloaded effect master handler.";
}
catch (Exception e)
{
LOGGER.log(Level.WARNING, "Failed executing effect master handler!", e);
return "Error reloading effect master handler: " + e.getMessage();
}
}
case "handler":
{
try
{
ScriptEngineManager.getInstance().executeMasterHandler();
return "Telnet Admin: Reloaded master handler.";
}
catch (Exception e)
{
LOGGER.log(Level.WARNING, "Failed executing master handler!", e);
return "Error reloading master handler: " + e.getMessage();
}
}
case "enchant":
{
EnchantItemGroupsData.getInstance().load();
EnchantItemData.getInstance().load();
return "Telnet Admin: Reloaded item enchanting data.";
}
case "transform":
{
TransformData.getInstance().load();
return "Telnet Admin: Reloaded transform data.";
}
case "sets":
{
ArmorSetsData.getInstance().load();
return "Telnet Admin: Reloaded Armor sets data.";
}
case "script":
{
if (args.length < 2)
{
return "Syntax: reload script <path>";
}
try
{
ScriptEngineManager.getInstance().executeScript(Paths.get(args[1]));
return "Script " + args[1] + " has been reloaded successfuly.";
}
catch (Exception e)
{
return "Couldn't reload script: " + args[1] + " err: " + e.getMessage();
}
}
}
return null;
}
}

View File

@@ -0,0 +1,47 @@
/*
* 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.telnethandlers.server;
import com.l2jmobius.gameserver.Shutdown;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class ServerAbort implements ITelnetCommand
{
@Override
public String getCommand()
{
return "abort";
}
@Override
public String getUsage()
{
return "Abort";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
return "Server shutdown/restart aborted!";
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.telnethandlers.server;
import com.l2jmobius.gameserver.Shutdown;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class ServerRestart implements ITelnetCommand
{
@Override
public String getCommand()
{
return "restart";
}
@Override
public String getUsage()
{
return "Restart <time in seconds>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || !Util.isDigit(args[0]))
{
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, true);
return "Server will restart in " + time + " seconds!";
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.telnethandlers.server;
import com.l2jmobius.gameserver.Shutdown;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import com.l2jmobius.gameserver.util.Util;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class ServerShutdown implements ITelnetCommand
{
@Override
public String getCommand()
{
return "shutdown";
}
@Override
public String getUsage()
{
return "Shutdown <time in seconds>";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
if ((args.length == 0) || !Util.isDigit(args[0]))
{
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, false);
return "Server will shutdown in " + time + " seconds!";
}
}

View File

@@ -0,0 +1,45 @@
/*
* 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.telnethandlers.server;
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
import io.netty.channel.ChannelHandlerContext;
/**
* @author UnAfraid
*/
public class Status implements ITelnetCommand
{
@Override
public String getCommand()
{
return "status";
}
@Override
public String getUsage()
{
return "Status";
}
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
return Debug.getServerStatus();
}
}

View File

@@ -58,8 +58,8 @@ import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillCanceld;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillCanceled;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
import com.l2jmobius.gameserver.network.serverpackets.SpecialCamera;
@@ -648,7 +648,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
case 4: // second morph
{
world.isVideo = true;
broadCastPacket(world, new MagicSkillCanceld(world.frintezza.getObjectId()));
broadCastPacket(world, new MagicSkillCanceled(world.frintezza.getObjectId()));
if (world.songEffectTask != null)
{
world.songEffectTask.cancel(false);
@@ -661,7 +661,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
case 5: // raid success
{
world.isVideo = true;
broadCastPacket(world, new MagicSkillCanceld(world.frintezza.getObjectId()));
broadCastPacket(world, new MagicSkillCanceled(world.frintezza.getObjectId()));
if (world.songTask != null)
{
world.songTask.cancel(true);
@@ -1285,7 +1285,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
}
}
private void sendPacketX(L2GameServerPacket packet1, L2GameServerPacket packet2, int x)
private void sendPacketX(IClientOutgoingPacket packet1, IClientOutgoingPacket packet2, int x)
{
for (int objId : _world.getAllowed())
{
@@ -1392,7 +1392,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IGameXm
}
}
protected void broadCastPacket(FETWorld world, L2GameServerPacket packet)
protected void broadCastPacket(FETWorld world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
{

View File

@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.quest.State;
import com.l2jmobius.gameserver.network.NpcStringId;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import quests.Q00727_HopeWithinTheDarkness.Q00727_HopeWithinTheDarkness;
@@ -430,7 +430,7 @@ public class Q00726_LightWithinTheDarkness extends Quest
}
}
protected void broadCastPacket(PAWORLD world, L2GameServerPacket packet)
protected void broadCastPacket(PAWORLD world, IClientOutgoingPacket packet)
{
for (int objId : world.getAllowed())
{