Dropped MMOCore.
This commit is contained in:
@@ -7,5 +7,6 @@
|
||||
<classpathentry kind="lib" path="dist/libs/mysql-connector-java-5.1.43.jar"/>
|
||||
<classpathentry including="**/*.java" kind="src" path="dist/game/data/scripts"/>
|
||||
<classpathentry kind="src" path="java"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-all-4.1.14.Final.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@@ -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)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
@@ -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
|
@@ -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
|
||||
# ---------------------------------------------------------------------------
|
||||
|
@@ -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
|
@@ -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())
|
||||
{
|
||||
|
@@ -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())
|
||||
{
|
||||
|
@@ -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())
|
||||
{
|
||||
|
@@ -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())
|
||||
{
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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");
|
||||
|
@@ -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]))
|
||||
{
|
||||
|
@@ -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>());
|
||||
|
@@ -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"))
|
||||
{
|
||||
|
@@ -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 + ".");
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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("");
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -14,34 +14,43 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.loginserver.network.clientpackets;
|
||||
package handlers.telnethandlers.chat;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
import com.l2jmobius.commons.mmocore.ReceivablePacket;
|
||||
import com.l2jmobius.loginserver.network.L2LoginClient;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public abstract class L2LoginClientPacket extends ReceivablePacket<L2LoginClient>
|
||||
public class Announce implements ITelnetCommand
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(L2LoginClientPacket.class.getName());
|
||||
@Override
|
||||
public String getCommand()
|
||||
{
|
||||
return "announce";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean read()
|
||||
public String getUsage()
|
||||
{
|
||||
try
|
||||
{
|
||||
return readImpl();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.SEVERE, "ERROR READING: " + getClass().getSimpleName() + ": " + e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
return "Announce <text>";
|
||||
}
|
||||
|
||||
protected abstract boolean readImpl();
|
||||
@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!";
|
||||
}
|
||||
}
|
58
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/chat/GMChat.java
vendored
Normal file
58
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/chat/GMChat.java
vendored
Normal 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!";
|
||||
}
|
||||
}
|
64
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/chat/Msg.java
vendored
Normal file
64
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/chat/Msg.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
@@ -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.";
|
||||
}
|
||||
}
|
84
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Ban.java
vendored
Normal file
84
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Ban.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
84
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/BanChat.java
vendored
Normal file
84
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/BanChat.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
198
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Enchant.java
vendored
Normal file
198
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Enchant.java
vendored
Normal 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;
|
||||
}
|
||||
}
|
58
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/GMList.java
vendored
Normal file
58
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/GMList.java
vendored
Normal 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;
|
||||
}
|
||||
}
|
85
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Give.java
vendored
Normal file
85
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Give.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
84
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Jail.java
vendored
Normal file
84
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Jail.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
57
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Kick.java
vendored
Normal file
57
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Kick.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
96
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/SendMail.java
vendored
Normal file
96
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/SendMail.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
63
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Unban.java
vendored
Normal file
63
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Unban.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
63
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/UnbanChat.java
vendored
Normal file
63
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/UnbanChat.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
63
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Unjail.java
vendored
Normal file
63
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/player/Unjail.java
vendored
Normal 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.";
|
||||
}
|
||||
}
|
375
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Debug.java
vendored
Normal file
375
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Debug.java
vendored
Normal 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());
|
||||
}
|
||||
}
|
@@ -14,33 +14,33 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package handlers.telnethandlers.server;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public abstract class MMOClient<T extends MMOConnection<?>>
|
||||
public class ForceGC implements ITelnetCommand
|
||||
{
|
||||
private final T _con;
|
||||
|
||||
public MMOClient(T con)
|
||||
@Override
|
||||
public String getCommand()
|
||||
{
|
||||
_con = con;
|
||||
return "forcegc";
|
||||
}
|
||||
|
||||
public T getConnection()
|
||||
@Override
|
||||
public String getUsage()
|
||||
{
|
||||
return _con;
|
||||
return "ForceGC";
|
||||
}
|
||||
|
||||
public abstract boolean decrypt(ByteBuffer buf, int size);
|
||||
|
||||
public abstract boolean encrypt(ByteBuffer buf, int size);
|
||||
|
||||
protected abstract void onDisconnection();
|
||||
|
||||
protected abstract void onForcedDisconnection();
|
||||
@Override
|
||||
public String handle(ChannelHandlerContext ctx, String[] args)
|
||||
{
|
||||
System.gc();
|
||||
return "RAM Used: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576);
|
||||
}
|
||||
}
|
72
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Memusage.java
vendored
Normal file
72
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Memusage.java
vendored
Normal 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();
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
53
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Purge.java
vendored
Normal file
53
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Purge.java
vendored
Normal 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();
|
||||
}
|
||||
}
|
225
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Reload.java
vendored
Normal file
225
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Reload.java
vendored
Normal 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;
|
||||
}
|
||||
}
|
@@ -14,48 +14,34 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package handlers.telnethandlers.server;
|
||||
|
||||
import java.nio.BufferOverflowException;
|
||||
import com.l2jmobius.gameserver.Shutdown;
|
||||
import com.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* @author Forsaiken
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public final class NioNetStringBuffer
|
||||
public class ServerAbort implements ITelnetCommand
|
||||
{
|
||||
private final char[] _buf;
|
||||
|
||||
private final int _size;
|
||||
|
||||
private int _len;
|
||||
|
||||
public NioNetStringBuffer(int size)
|
||||
@Override
|
||||
public String getCommand()
|
||||
{
|
||||
_buf = new char[size];
|
||||
_size = size;
|
||||
_len = 0;
|
||||
}
|
||||
|
||||
public final void clear()
|
||||
{
|
||||
_len = 0;
|
||||
}
|
||||
|
||||
public final void append(char c)
|
||||
{
|
||||
if (_len < _size)
|
||||
{
|
||||
_buf[_len++] = c;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BufferOverflowException();
|
||||
}
|
||||
return "abort";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString()
|
||||
public String getUsage()
|
||||
{
|
||||
return new String(_buf, 0, _len);
|
||||
return "Abort";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(ChannelHandlerContext ctx, String[] args)
|
||||
{
|
||||
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
|
||||
return "Server shutdown/restart aborted!";
|
||||
}
|
||||
}
|
@@ -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!";
|
||||
}
|
||||
}
|
@@ -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!";
|
||||
}
|
||||
}
|
45
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Status.java
vendored
Normal file
45
L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/telnethandlers/server/Status.java
vendored
Normal 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();
|
||||
}
|
||||
}
|
@@ -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())
|
||||
{
|
||||
|
@@ -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())
|
||||
{
|
||||
|
BIN
L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.14.Final.jar
vendored
Normal file
BIN
L2J_Mobius_CT_2.6_HighFive/dist/libs/netty-all-4.1.14.Final.jar
vendored
Normal file
Binary file not shown.
@@ -12,11 +12,11 @@
|
||||
# Networking
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Bind ip of the LoginServer, use * to bind on all available IPs
|
||||
# Bind ip of the LoginServer, use 0.0.0.0 to bind on all available IPs
|
||||
# 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)
|
||||
LoginserverHostname = *
|
||||
# Default: 0.0.0.0
|
||||
LoginserverHostname = 0.0.0.0
|
||||
|
||||
# Default: 2106
|
||||
LoginserverPort = 2106
|
||||
@@ -107,8 +107,8 @@ ShowLicence = True
|
||||
AutoCreateAccounts = True
|
||||
|
||||
# Datapack root directory.
|
||||
# Defaults to the directory where the server data are stored.
|
||||
DatapackRoot = .\
|
||||
# Defaults to current directory from which the server is started.
|
||||
DatapackRoot = .
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
@@ -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
|
@@ -1,28 +0,0 @@
|
||||
# ---------------------------------------------------------------------------
|
||||
# Telnet Settings
|
||||
# ---------------------------------------------------------------------------
|
||||
# The defaults are set to be retail-like. If you modify any of these settings your server will deviate from being retail-like.
|
||||
# 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 LS
|
||||
# by using a telnet client. Communication protocol is insecure
|
||||
# and you should use SSL tunnels, VPN, etc. if you plan to connect
|
||||
# over non-trusted channels.
|
||||
# Default: False
|
||||
EnableTelnet = False
|
||||
|
||||
# This is the port L2J should listen to for incoming telnet
|
||||
# requests.
|
||||
# Default: 12345
|
||||
StatusPort = 12345
|
||||
|
||||
# If the following is not set, a random password is generated on server startup.
|
||||
# Usage: StatusPW = somePass
|
||||
StatusPW =
|
||||
|
||||
# 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
|
@@ -89,7 +89,6 @@ public final class Config
|
||||
public static final String GRANDBOSS_CONFIG_FILE = "./config/GrandBoss.ini";
|
||||
public static final String IDFACTORY_CONFIG_FILE = "./config/IdFactory.ini";
|
||||
public static final String LOGIN_CONFIG_FILE = "./config/LoginServer.ini";
|
||||
public static final String MMO_CONFIG_FILE = "./config/MMO.ini";
|
||||
public static final String NPC_CONFIG_FILE = "./config/NPC.ini";
|
||||
public static final String OLYMPIAD_CONFIG_FILE = "./config/Olympiad.ini";
|
||||
public static final String PVP_CONFIG_FILE = "./config/PVP.ini";
|
||||
@@ -494,15 +493,7 @@ public final class Config
|
||||
public static int THREADS_PER_SCHEDULED_THREAD_POOL;
|
||||
public static int INSTANT_THREAD_POOL_COUNT;
|
||||
public static int THREADS_PER_INSTANT_THREAD_POOL;
|
||||
public static int CLIENT_PACKET_QUEUE_SIZE;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_BURST_SIZE;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND;
|
||||
public static int CLIENT_PACKET_QUEUE_MEASURE_INTERVAL;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN;
|
||||
public static int CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN;
|
||||
public static int IO_PACKET_THREAD_CORE_SIZE;
|
||||
public static boolean DEADLOCK_DETECTOR;
|
||||
public static int DEADLOCK_CHECK_INTERVAL;
|
||||
public static boolean RESTART_ON_DEADLOCK;
|
||||
@@ -511,7 +502,7 @@ public final class Config
|
||||
public static int HERB_AUTO_DESTROY_TIME;
|
||||
public static List<Integer> LIST_PROTECTED_ITEMS;
|
||||
public static boolean DATABASE_CLEAN_UP;
|
||||
public static int CHAR_STORE_INTERVAL;
|
||||
public static int CHAR_DATA_STORE_INTERVAL;
|
||||
public static boolean LAZY_ITEMS_UPDATE;
|
||||
public static boolean UPDATE_ITEMS_ON_CHAR_STORE;
|
||||
public static boolean DESTROY_DROPPED_PLAYER_ITEM;
|
||||
@@ -1113,7 +1104,11 @@ public final class Config
|
||||
public static double HP_REGEN_MULTIPLIER;
|
||||
public static double MP_REGEN_MULTIPLIER;
|
||||
public static double CP_REGEN_MULTIPLIER;
|
||||
public static boolean IS_TELNET_ENABLED;
|
||||
public static boolean TELNET_ENABLED;
|
||||
public static String TELNET_PASSWORD;
|
||||
public static String TELNET_HOSTNAME;
|
||||
public static List<String> TELNET_HOSTS;
|
||||
public static int TELNET_PORT;
|
||||
public static boolean SHOW_LICENCE;
|
||||
public static boolean ACCEPT_NEW_GAMESERVER;
|
||||
public static int SERVER_ID;
|
||||
@@ -1237,7 +1232,7 @@ public final class Config
|
||||
|
||||
final PropertiesParser serverSettings = new PropertiesParser(SERVER_CONFIG_FILE);
|
||||
|
||||
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "*");
|
||||
GAMESERVER_HOSTNAME = serverSettings.getString("GameserverHostname", "0.0.0.0");
|
||||
PORT_GAME = serverSettings.getInt("GameserverPort", 7777);
|
||||
|
||||
GAME_SERVER_LOGIN_PORT = serverSettings.getInt("LoginPort", 9014);
|
||||
@@ -1250,7 +1245,7 @@ public final class Config
|
||||
DATABASE_URL = serverSettings.getString("URL", "jdbc:mysql://localhost/l2jmobiush5?useUnicode=true&characterEncoding=utf-8");
|
||||
DATABASE_LOGIN = serverSettings.getString("Login", "root");
|
||||
DATABASE_PASSWORD = serverSettings.getString("Password", "");
|
||||
DATABASE_MAX_CONNECTIONS = serverSettings.getInt("MaximumDbConnections", 500);
|
||||
DATABASE_MAX_CONNECTIONS = serverSettings.getInt("MaximumDbConnections", 10);
|
||||
DATABASE_MAX_IDLE_TIME = serverSettings.getInt("MaximumDbIdleTime", 0);
|
||||
|
||||
try
|
||||
@@ -1284,6 +1279,12 @@ public final class Config
|
||||
}
|
||||
}
|
||||
|
||||
SCHEDULED_THREAD_POOL_COUNT = serverSettings.getInt("ScheduledThreadPoolCount", -1);
|
||||
THREADS_PER_SCHEDULED_THREAD_POOL = serverSettings.getInt("ThreadsPerScheduledThreadPool", 4);
|
||||
INSTANT_THREAD_POOL_COUNT = serverSettings.getInt("InstantThreadPoolCount", -1);
|
||||
THREADS_PER_INSTANT_THREAD_POOL = serverSettings.getInt("ThreadsPerInstantThreadPool", 2);
|
||||
IO_PACKET_THREAD_CORE_SIZE = serverSettings.getInt("UrgentPacketThreadCoreSize", 2);
|
||||
|
||||
SERVER_RESTART_SCHEDULE_ENABLED = serverSettings.getBoolean("ServerRestartScheduleEnabled", false);
|
||||
SERVER_RESTART_SCHEDULE_MESSAGE = serverSettings.getBoolean("ServerRestartScheduleMessage", false);
|
||||
SERVER_RESTART_SCHEDULE_COUNTDOWN = serverSettings.getInt("ServerRestartScheduleCountdown", 600);
|
||||
@@ -1294,7 +1295,7 @@ public final class Config
|
||||
GAME_SERVER_SUBNETS = ipcd.getSubnets();
|
||||
GAME_SERVER_HOSTS = ipcd.getHosts();
|
||||
|
||||
// Load Feature L2Properties file (if exists)
|
||||
// Load Feature config file (if exists)
|
||||
final PropertiesParser Feature = new PropertiesParser(FEATURE_CONFIG_FILE);
|
||||
|
||||
CH_TELE_FEE_RATIO = Feature.getLong("ClanHallTeleportFunctionFeeRatio", 604800000);
|
||||
@@ -1478,7 +1479,7 @@ public final class Config
|
||||
ALLOW_WYVERN_DURING_SIEGE = Feature.getBoolean("AllowRideWyvernDuringSiege", true);
|
||||
ALLOW_MOUNTS_DURING_SIEGE = Feature.getBoolean("AllowRideMountsDuringSiege", false);
|
||||
|
||||
// Load Character L2Properties file (if exists)
|
||||
// Load Character config file (if exists)
|
||||
final PropertiesParser character = new PropertiesParser(CHARACTER_CONFIG_FILE);
|
||||
|
||||
PLAYER_DELEVEL = character.getBoolean("Delevel", true);
|
||||
@@ -1822,27 +1823,22 @@ public final class Config
|
||||
NEVIT_ADVENT_TIME = character.getInt("NevitAdventTime", 14400);
|
||||
NEVIT_IGNORE_ADVENT_TIME = character.getBoolean("NevitIgnoreAdventTime", false);
|
||||
|
||||
// Load Telnet L2Properties file (if exists)
|
||||
// Load Telnet config file (if exists)
|
||||
final PropertiesParser telnetSettings = new PropertiesParser(TELNET_CONFIG_FILE);
|
||||
|
||||
IS_TELNET_ENABLED = telnetSettings.getBoolean("EnableTelnet", false);
|
||||
TELNET_ENABLED = telnetSettings.getBoolean("EnableTelnet", false);
|
||||
TELNET_PORT = telnetSettings.getInt("Port", 12345);
|
||||
TELNET_HOSTNAME = telnetSettings.getString("BindAddress", "127.0.0.1");
|
||||
TELNET_PASSWORD = telnetSettings.getString("Password", "");
|
||||
TELNET_HOSTS = Arrays.asList(telnetSettings.getString("ListOfHosts", "127.0.0.1,::1").split(","));
|
||||
|
||||
// MMO
|
||||
final PropertiesParser mmoSettings = new PropertiesParser(MMO_CONFIG_FILE);
|
||||
|
||||
MMO_SELECTOR_SLEEP_TIME = mmoSettings.getInt("SleepTime", 20);
|
||||
MMO_MAX_SEND_PER_PASS = mmoSettings.getInt("MaxSendPerPass", 12);
|
||||
MMO_MAX_READ_PER_PASS = mmoSettings.getInt("MaxReadPerPass", 12);
|
||||
MMO_HELPER_BUFFER_COUNT = mmoSettings.getInt("HelperBufferCount", 20);
|
||||
MMO_TCP_NODELAY = mmoSettings.getBoolean("TcpNoDelay", false);
|
||||
|
||||
// Load IdFactory L2Properties file (if exists)
|
||||
// Load IdFactory config file (if exists)
|
||||
final PropertiesParser IdFactory = new PropertiesParser(IDFACTORY_CONFIG_FILE);
|
||||
|
||||
IDFACTORY_TYPE = IdFactory.getEnum("IDFactory", IdFactoryType.class, IdFactoryType.BitSet);
|
||||
BAD_ID_CHECKING = IdFactory.getBoolean("BadIdChecking", true);
|
||||
|
||||
// Load General L2Properties file (if exists)
|
||||
// Load General config file (if exists)
|
||||
final PropertiesParser General = new PropertiesParser(GENERAL_CONFIG_FILE);
|
||||
EVERYBODY_HAS_ADMIN_RIGHTS = General.getBoolean("EverybodyHasAdminRights", false);
|
||||
SERVER_LIST_BRACKET = General.getBoolean("ServerListBrackets", false);
|
||||
@@ -1883,27 +1879,6 @@ public final class Config
|
||||
ALT_DEV_NO_SPAWNS = General.getBoolean("AltDevNoSpawns", false) || Boolean.getBoolean("nospawns");
|
||||
ALT_DEV_SHOW_QUESTS_LOAD_IN_LOGS = General.getBoolean("AltDevShowQuestsLoadInLogs", false);
|
||||
ALT_DEV_SHOW_SCRIPTS_LOAD_IN_LOGS = General.getBoolean("AltDevShowScriptsLoadInLogs", false);
|
||||
SCHEDULED_THREAD_POOL_COUNT = General.getInt("ScheduledThreadPoolCount", -1);
|
||||
THREADS_PER_SCHEDULED_THREAD_POOL = General.getInt("ThreadsPerScheduledThreadPool", 4);
|
||||
INSTANT_THREAD_POOL_COUNT = General.getInt("InstantThreadPoolCount", -1);
|
||||
THREADS_PER_INSTANT_THREAD_POOL = General.getInt("ThreadsPerInstantThreadPool", 2);
|
||||
CLIENT_PACKET_QUEUE_SIZE = General.getInt("ClientPacketQueueSize", 0);
|
||||
if (CLIENT_PACKET_QUEUE_SIZE == 0)
|
||||
{
|
||||
CLIENT_PACKET_QUEUE_SIZE = MMO_MAX_READ_PER_PASS + 2;
|
||||
}
|
||||
CLIENT_PACKET_QUEUE_MAX_BURST_SIZE = General.getInt("ClientPacketQueueMaxBurstSize", 0);
|
||||
if (CLIENT_PACKET_QUEUE_MAX_BURST_SIZE == 0)
|
||||
{
|
||||
CLIENT_PACKET_QUEUE_MAX_BURST_SIZE = MMO_MAX_READ_PER_PASS + 1;
|
||||
}
|
||||
CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND = General.getInt("ClientPacketQueueMaxPacketsPerSecond", 80);
|
||||
CLIENT_PACKET_QUEUE_MEASURE_INTERVAL = General.getInt("ClientPacketQueueMeasureInterval", 5);
|
||||
CLIENT_PACKET_QUEUE_MAX_AVERAGE_PACKETS_PER_SECOND = General.getInt("ClientPacketQueueMaxAveragePacketsPerSecond", 40);
|
||||
CLIENT_PACKET_QUEUE_MAX_FLOODS_PER_MIN = General.getInt("ClientPacketQueueMaxFloodsPerMin", 2);
|
||||
CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN = General.getInt("ClientPacketQueueMaxOverflowsPerMin", 1);
|
||||
CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN = General.getInt("ClientPacketQueueMaxUnderflowsPerMin", 1);
|
||||
CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN = General.getInt("ClientPacketQueueMaxUnknownPerMin", 5);
|
||||
DEADLOCK_DETECTOR = General.getBoolean("DeadLockDetector", true);
|
||||
DEADLOCK_CHECK_INTERVAL = General.getInt("DeadLockCheckInterval", 20);
|
||||
RESTART_ON_DEADLOCK = General.getBoolean("RestartOnDeadlock", false);
|
||||
@@ -1917,7 +1892,7 @@ public final class Config
|
||||
LIST_PROTECTED_ITEMS.add(Integer.parseInt(id));
|
||||
}
|
||||
DATABASE_CLEAN_UP = General.getBoolean("DatabaseCleanUp", true);
|
||||
CHAR_STORE_INTERVAL = General.getInt("CharacterDataStoreInterval", 15);
|
||||
CHAR_DATA_STORE_INTERVAL = General.getInt("CharacterDataStoreInterval", 15) * 60 * 1000;
|
||||
LAZY_ITEMS_UPDATE = General.getBoolean("LazyItemsUpdate", false);
|
||||
UPDATE_ITEMS_ON_CHAR_STORE = General.getBoolean("UpdateItemsOnCharStore", false);
|
||||
DESTROY_DROPPED_PLAYER_ITEM = General.getBoolean("DestroyPlayerDroppedItem", false);
|
||||
@@ -2087,12 +2062,12 @@ public final class Config
|
||||
GAME_POINT_ITEM_ID = General.getInt("GamePointItemId", -1);
|
||||
ENABLE_FALLING_DAMAGE = General.getBoolean("EnableFallingDamage", true);
|
||||
|
||||
// Load FloodProtector L2Properties file
|
||||
// Load FloodProtector config file
|
||||
final PropertiesParser FloodProtectors = new PropertiesParser(FLOOD_PROTECTOR_CONFIG_FILE);
|
||||
|
||||
loadFloodProtectorConfigs(FloodProtectors);
|
||||
|
||||
// Load NPC L2Properties file (if exists)
|
||||
// Load NPC config file (if exists)
|
||||
final PropertiesParser NPC = new PropertiesParser(NPC_CONFIG_FILE);
|
||||
|
||||
ANNOUNCE_MAMMON_SPAWN = NPC.getBoolean("AnnounceMammonSpawn", false);
|
||||
@@ -2163,7 +2138,7 @@ public final class Config
|
||||
PET_HP_REGEN_MULTIPLIER = NPC.getDouble("PetHpRegenMultiplier", 100) / 100;
|
||||
PET_MP_REGEN_MULTIPLIER = NPC.getDouble("PetMpRegenMultiplier", 100) / 100;
|
||||
|
||||
// Load Rates L2Properties file (if exists)
|
||||
// Load Rates config file (if exists)
|
||||
final PropertiesParser RatesSettings = new PropertiesParser(RATES_CONFIG_FILE);
|
||||
|
||||
RATE_XP = RatesSettings.getFloat("RateXp", 1);
|
||||
@@ -2847,7 +2822,7 @@ public final class Config
|
||||
|
||||
L2WALKER_PROTECTION = WalkerBotProtection.getBoolean("L2WalkerProtection", false);
|
||||
|
||||
// Load PvP L2Properties file (if exists)
|
||||
// Load PvP config file (if exists)
|
||||
final PropertiesParser PVPSettings = new PropertiesParser(PVP_CONFIG_FILE);
|
||||
|
||||
KARMA_DROP_GM = PVPSettings.getBoolean("CanGMDropEquipment", false);
|
||||
@@ -2879,7 +2854,7 @@ public final class Config
|
||||
PVP_NORMAL_TIME = PVPSettings.getInt("PvPVsNormalTime", 120000);
|
||||
PVP_PVP_TIME = PVPSettings.getInt("PvPVsPvPTime", 60000);
|
||||
|
||||
// Load Olympiad L2Properties file (if exists)
|
||||
// Load Olympiad config file (if exists)
|
||||
final PropertiesParser Olympiad = new PropertiesParser(OLYMPIAD_CONFIG_FILE);
|
||||
|
||||
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 18);
|
||||
@@ -3056,7 +3031,7 @@ public final class Config
|
||||
GAME_SERVER_LOGIN_HOST = ServerSettings.getString("LoginHostname", "127.0.0.1");
|
||||
GAME_SERVER_LOGIN_PORT = ServerSettings.getInt("LoginPort", 9013);
|
||||
|
||||
LOGIN_BIND_ADDRESS = ServerSettings.getString("LoginserverHostname", "*");
|
||||
LOGIN_BIND_ADDRESS = ServerSettings.getString("LoginserverHostname", "0.0.0.0");
|
||||
PORT_LOGIN = ServerSettings.getInt("LoginserverPort", 2106);
|
||||
|
||||
try
|
||||
@@ -3093,20 +3068,6 @@ public final class Config
|
||||
NORMAL_CONNECTION_TIME = ServerSettings.getInt("NormalConnectionTime", 700);
|
||||
FAST_CONNECTION_TIME = ServerSettings.getInt("FastConnectionTime", 350);
|
||||
MAX_CONNECTION_PER_IP = ServerSettings.getInt("MaxConnectionPerIP", 50);
|
||||
|
||||
// MMO
|
||||
final PropertiesParser mmoSettings = new PropertiesParser(MMO_CONFIG_FILE);
|
||||
|
||||
MMO_SELECTOR_SLEEP_TIME = mmoSettings.getInt("SleepTime", 20);
|
||||
MMO_MAX_SEND_PER_PASS = mmoSettings.getInt("MaxSendPerPass", 12);
|
||||
MMO_MAX_READ_PER_PASS = mmoSettings.getInt("MaxReadPerPass", 12);
|
||||
MMO_HELPER_BUFFER_COUNT = mmoSettings.getInt("HelperBufferCount", 20);
|
||||
MMO_TCP_NODELAY = mmoSettings.getBoolean("TcpNoDelay", false);
|
||||
|
||||
// Load Telnet L2Properties file (if exists)
|
||||
final PropertiesParser telnetSettings = new PropertiesParser(TELNET_CONFIG_FILE);
|
||||
|
||||
IS_TELNET_ENABLED = telnetSettings.getBoolean("EnableTelnet", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3115,7 +3076,7 @@ public final class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Save hexadecimal ID of the server in the L2Properties file.<br>
|
||||
* Save hexadecimal ID of the server in the config file.<br>
|
||||
* Check {@link #HEXID_FILE}.
|
||||
* @param serverId the ID of the server whose hexId to save
|
||||
* @param hexId the hexadecimal ID to store
|
||||
@@ -3126,10 +3087,10 @@ public final class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* Save hexadecimal ID of the server in the L2Properties file.
|
||||
* Save hexadecimal ID of the server in the config file.
|
||||
* @param serverId the ID of the server whose hexId to save
|
||||
* @param hexId the hexadecimal ID to store
|
||||
* @param fileName name of the L2Properties file
|
||||
* @param fileName name of the config file
|
||||
*/
|
||||
public static void saveHexid(int serverId, String hexId, String fileName)
|
||||
{
|
||||
|
@@ -1,283 +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 com.l2jmobius.commons.mmocore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.CancelledKeyException;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
*/
|
||||
public class MMOConnection<T extends MMOClient<?>>
|
||||
{
|
||||
private final SelectorThread<T> _selectorThread;
|
||||
|
||||
private final Socket _socket;
|
||||
|
||||
private final InetAddress _address;
|
||||
|
||||
private final ReadableByteChannel _readableByteChannel;
|
||||
|
||||
private final WritableByteChannel _writableByteChannel;
|
||||
|
||||
private final int _port;
|
||||
|
||||
private final NioNetStackList<SendablePacket<T>> _sendQueue;
|
||||
|
||||
private final SelectionKey _selectionKey;
|
||||
|
||||
private ByteBuffer _readBuffer;
|
||||
|
||||
private ByteBuffer _primaryWriteBuffer;
|
||||
|
||||
private ByteBuffer _secondaryWriteBuffer;
|
||||
|
||||
private volatile boolean _pendingClose;
|
||||
|
||||
private T _client;
|
||||
|
||||
public MMOConnection(SelectorThread<T> selectorThread, Socket socket, SelectionKey key, boolean tcpNoDelay)
|
||||
{
|
||||
_selectorThread = selectorThread;
|
||||
_socket = socket;
|
||||
_address = socket.getInetAddress();
|
||||
_readableByteChannel = socket.getChannel();
|
||||
_writableByteChannel = socket.getChannel();
|
||||
_port = socket.getPort();
|
||||
_selectionKey = key;
|
||||
|
||||
_sendQueue = new NioNetStackList<>();
|
||||
|
||||
try
|
||||
{
|
||||
_socket.setTcpNoDelay(tcpNoDelay);
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
final void setClient(T client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public final T getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
||||
public final void sendPacket(SendablePacket<T> sp)
|
||||
{
|
||||
sp._client = _client;
|
||||
|
||||
if (_pendingClose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (getSendQueue())
|
||||
{
|
||||
_sendQueue.addLast(sp);
|
||||
}
|
||||
|
||||
if (!_sendQueue.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
_selectionKey.interestOps(_selectionKey.interestOps() | SelectionKey.OP_WRITE);
|
||||
}
|
||||
catch (CancelledKeyException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final SelectionKey getSelectionKey()
|
||||
{
|
||||
return _selectionKey;
|
||||
}
|
||||
|
||||
public final InetAddress getInetAddress()
|
||||
{
|
||||
return _address;
|
||||
}
|
||||
|
||||
public final int getPort()
|
||||
{
|
||||
return _port;
|
||||
}
|
||||
|
||||
final void close() throws IOException
|
||||
{
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
final int read(ByteBuffer buf) throws IOException
|
||||
{
|
||||
return _readableByteChannel.read(buf);
|
||||
}
|
||||
|
||||
final int write(ByteBuffer buf) throws IOException
|
||||
{
|
||||
return _writableByteChannel.write(buf);
|
||||
}
|
||||
|
||||
final void createWriteBuffer(ByteBuffer buf)
|
||||
{
|
||||
if (_primaryWriteBuffer == null)
|
||||
{
|
||||
_primaryWriteBuffer = _selectorThread.getPooledBuffer();
|
||||
_primaryWriteBuffer.put(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
final ByteBuffer temp = _selectorThread.getPooledBuffer();
|
||||
temp.put(buf);
|
||||
|
||||
final int remaining = temp.remaining();
|
||||
_primaryWriteBuffer.flip();
|
||||
final int limit = _primaryWriteBuffer.limit();
|
||||
|
||||
if (remaining >= _primaryWriteBuffer.remaining())
|
||||
{
|
||||
temp.put(_primaryWriteBuffer);
|
||||
_selectorThread.recycleBuffer(_primaryWriteBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
_primaryWriteBuffer.limit(remaining);
|
||||
temp.put(_primaryWriteBuffer);
|
||||
_primaryWriteBuffer.limit(limit);
|
||||
_primaryWriteBuffer.compact();
|
||||
_secondaryWriteBuffer = _primaryWriteBuffer;
|
||||
}
|
||||
_primaryWriteBuffer = temp;
|
||||
}
|
||||
}
|
||||
|
||||
final boolean hasPendingWriteBuffer()
|
||||
{
|
||||
return _primaryWriteBuffer != null;
|
||||
}
|
||||
|
||||
final void movePendingWriteBufferTo(ByteBuffer dest)
|
||||
{
|
||||
_primaryWriteBuffer.flip();
|
||||
dest.put(_primaryWriteBuffer);
|
||||
_selectorThread.recycleBuffer(_primaryWriteBuffer);
|
||||
_primaryWriteBuffer = _secondaryWriteBuffer;
|
||||
_secondaryWriteBuffer = null;
|
||||
}
|
||||
|
||||
final void setReadBuffer(ByteBuffer buf)
|
||||
{
|
||||
_readBuffer = buf;
|
||||
}
|
||||
|
||||
final ByteBuffer getReadBuffer()
|
||||
{
|
||||
return _readBuffer;
|
||||
}
|
||||
|
||||
public final boolean isClosed()
|
||||
{
|
||||
return _pendingClose;
|
||||
}
|
||||
|
||||
final NioNetStackList<SendablePacket<T>> getSendQueue()
|
||||
{
|
||||
return _sendQueue;
|
||||
}
|
||||
|
||||
/*
|
||||
* final SendablePacket<T> getClosePacket() { return _closePacket; }
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void close(SendablePacket<T> sp)
|
||||
{
|
||||
close(new SendablePacket[]
|
||||
{
|
||||
sp
|
||||
});
|
||||
}
|
||||
|
||||
public final void close(SendablePacket<T>[] closeList)
|
||||
{
|
||||
if (_pendingClose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (getSendQueue())
|
||||
{
|
||||
if (!_pendingClose)
|
||||
{
|
||||
_pendingClose = true;
|
||||
_sendQueue.clear();
|
||||
for (SendablePacket<T> sp : closeList)
|
||||
{
|
||||
_sendQueue.addLast(sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_selectionKey.interestOps(_selectionKey.interestOps() & ~SelectionKey.OP_WRITE);
|
||||
}
|
||||
catch (CancelledKeyException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
// _closePacket = sp;
|
||||
_selectorThread.closeConnection(this);
|
||||
}
|
||||
|
||||
final void releaseBuffers()
|
||||
{
|
||||
if (_primaryWriteBuffer != null)
|
||||
{
|
||||
_selectorThread.recycleBuffer(_primaryWriteBuffer);
|
||||
_primaryWriteBuffer = null;
|
||||
|
||||
if (_secondaryWriteBuffer != null)
|
||||
{
|
||||
_selectorThread.recycleBuffer(_secondaryWriteBuffer);
|
||||
_secondaryWriteBuffer = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (_readBuffer != null)
|
||||
{
|
||||
_selectorThread.recycleBuffer(_readBuffer);
|
||||
_readBuffer = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,101 +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 com.l2jmobius.commons.mmocore;
|
||||
|
||||
/**
|
||||
* @author Forsaiken
|
||||
* @param <E>
|
||||
*/
|
||||
public final class NioNetStackList<E>
|
||||
{
|
||||
private final NioNetStackNode _start = new NioNetStackNode();
|
||||
|
||||
private final NioNetStackNodeBuf _buf = new NioNetStackNodeBuf();
|
||||
|
||||
private NioNetStackNode _end = new NioNetStackNode();
|
||||
|
||||
public NioNetStackList()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
public final void addLast(E elem)
|
||||
{
|
||||
final NioNetStackNode newEndNode = _buf.removeFirst();
|
||||
_end._value = elem;
|
||||
_end._next = newEndNode;
|
||||
_end = newEndNode;
|
||||
}
|
||||
|
||||
public final E removeFirst()
|
||||
{
|
||||
final NioNetStackNode old = _start._next;
|
||||
final E value = old._value;
|
||||
_start._next = old._next;
|
||||
_buf.addLast(old);
|
||||
return value;
|
||||
}
|
||||
|
||||
public final boolean isEmpty()
|
||||
{
|
||||
return _start._next == _end;
|
||||
}
|
||||
|
||||
public final void clear()
|
||||
{
|
||||
_start._next = _end;
|
||||
}
|
||||
|
||||
protected final class NioNetStackNode
|
||||
{
|
||||
protected NioNetStackNode _next;
|
||||
|
||||
protected E _value;
|
||||
}
|
||||
|
||||
private final class NioNetStackNodeBuf
|
||||
{
|
||||
private final NioNetStackNode _start = new NioNetStackNode();
|
||||
|
||||
private NioNetStackNode _end = new NioNetStackNode();
|
||||
|
||||
NioNetStackNodeBuf()
|
||||
{
|
||||
_start._next = _end;
|
||||
}
|
||||
|
||||
final void addLast(NioNetStackNode node)
|
||||
{
|
||||
node._next = null;
|
||||
node._value = null;
|
||||
_end._next = node;
|
||||
_end = node;
|
||||
}
|
||||
|
||||
final NioNetStackNode removeFirst()
|
||||
{
|
||||
if (_start._next == _end)
|
||||
{
|
||||
return new NioNetStackNode();
|
||||
}
|
||||
|
||||
final NioNetStackNode old = _start._next;
|
||||
_start._next = old._next;
|
||||
return old;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,139 +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 com.l2jmobius.commons.mmocore;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class ReceivablePacket<T extends MMOClient<?>>extends AbstractPacket<T> implements Runnable
|
||||
{
|
||||
NioNetStringBuffer _sbuf;
|
||||
|
||||
protected ReceivablePacket()
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract boolean read();
|
||||
|
||||
@Override
|
||||
public abstract void run();
|
||||
|
||||
/**
|
||||
* Reads <B>byte[]</B> from the buffer. <BR>
|
||||
* Reads as many bytes as the length of the array.
|
||||
* @param dst : the byte array which will be filled with the data.
|
||||
*/
|
||||
protected final void readB(byte[] dst)
|
||||
{
|
||||
_buf.get(dst);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>byte[]</B> from the buffer. <BR>
|
||||
* Reads as many bytes as the given length (len). Starts to fill the byte array from the given offset to <B>offset</B> + <B>len</B>.
|
||||
* @param dst : the byte array which will be filled with the data.
|
||||
* @param offset : starts to fill the byte array from the given offset.
|
||||
* @param len : the given length of bytes to be read.
|
||||
*/
|
||||
protected final void readB(byte[] dst, int offset, int len)
|
||||
{
|
||||
_buf.get(dst, offset, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>byte</B> from the buffer. <BR>
|
||||
* 8bit integer (00)
|
||||
* @return
|
||||
*/
|
||||
protected final int readC()
|
||||
{
|
||||
return _buf.get() & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>short</B> from the buffer. <BR>
|
||||
* 16bit integer (00 00)
|
||||
* @return
|
||||
*/
|
||||
protected final int readH()
|
||||
{
|
||||
return _buf.getShort() & 0xFFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>int</B> from the buffer. <BR>
|
||||
* 32bit integer (00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
protected final int readD()
|
||||
{
|
||||
return _buf.getInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>long</B> from the buffer. <BR>
|
||||
* 64bit integer (00 00 00 00 00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
protected final long readQ()
|
||||
{
|
||||
return _buf.getLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>double</B> from the buffer. <BR>
|
||||
* 64bit double precision float (00 00 00 00 00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
protected final double readF()
|
||||
{
|
||||
return _buf.getDouble();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <B>String</B> from the buffer.
|
||||
* @return
|
||||
*/
|
||||
protected final String readS()
|
||||
{
|
||||
_sbuf.clear();
|
||||
|
||||
char ch;
|
||||
while ((ch = _buf.getChar()) != 0)
|
||||
{
|
||||
_sbuf.append(ch);
|
||||
}
|
||||
|
||||
return _sbuf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* packet forge purpose
|
||||
* @param data
|
||||
* @param client
|
||||
* @param sBuffer
|
||||
*/
|
||||
public void setBuffers(ByteBuffer data, T client, NioNetStringBuffer sBuffer)
|
||||
{
|
||||
_buf = data;
|
||||
_client = client;
|
||||
_sbuf = sBuffer;
|
||||
}
|
||||
}
|
@@ -1,63 +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 com.l2jmobius.commons.mmocore;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
*/
|
||||
public final class SelectorConfig
|
||||
{
|
||||
public int READ_BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
public int WRITE_BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
public int HELPER_BUFFER_COUNT = 20;
|
||||
|
||||
public int HELPER_BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
/**
|
||||
* Server will try to send MAX_SEND_PER_PASS packets per socket write call<br>
|
||||
* however it may send less if the write buffer was filled before achieving this value.
|
||||
*/
|
||||
public int MAX_SEND_PER_PASS = 10;
|
||||
|
||||
/**
|
||||
* Server will try to read MAX_READ_PER_PASS packets per socket read call<br>
|
||||
* however it may read less if the read buffer was empty before achieving this value.
|
||||
*/
|
||||
public int MAX_READ_PER_PASS = 10;
|
||||
|
||||
/**
|
||||
* Defines how much time (in milis) should the selector sleep, an higher value increases throughput but also increases latency(to a max of the sleep value itself).<BR>
|
||||
* Also an extremely high value(usually > 100) will decrease throughput due to the server not doing enough sends per second (depends on max sends per pass).<BR>
|
||||
* <BR>
|
||||
* Recommended values:<BR>
|
||||
* 1 for minimal latency.<BR>
|
||||
* 10-30 for an latency/troughput trade-off based on your needs.<BR>
|
||||
*/
|
||||
public int SLEEP_TIME = 10;
|
||||
|
||||
/**
|
||||
* Used to enable/disable TCP_NODELAY which disable/enable Nagle's algorithm.<BR>
|
||||
* <BR>
|
||||
* Nagle's algorithm try to conserve bandwidth by minimizing the number of segments that are sent. When applications wish to decrease network latency and increase performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). Data will be sent earlier, at the cost of an increase
|
||||
* in bandwidth consumption. The Nagle's algorithm is described in RFC 896.<BR>
|
||||
* <BR>
|
||||
* Summary, data will be sent earlier, thus lowering the ping, at the cost of a small increase in bandwidth consumption.
|
||||
*/
|
||||
public boolean TCP_NODELAY = true;
|
||||
}
|
@@ -1,714 +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 com.l2jmobius.commons.mmocore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Parts of design based on network core from WoodenGil
|
||||
* @param <T>
|
||||
* @author KenM
|
||||
*/
|
||||
public final class SelectorThread<T extends MMOClient<?>>extends Thread
|
||||
{
|
||||
// default BYTE_ORDER
|
||||
private static final ByteOrder BYTE_ORDER = ByteOrder.LITTLE_ENDIAN;
|
||||
// default HEADER_SIZE
|
||||
private static final int HEADER_SIZE = 2;
|
||||
// Selector
|
||||
private final Selector _selector;
|
||||
// Implementations
|
||||
private final IPacketHandler<T> _packetHandler;
|
||||
private final IMMOExecutor<T> _executor;
|
||||
private final IClientFactory<T> _clientFactory;
|
||||
private final IAcceptFilter _acceptFilter;
|
||||
// Configurations
|
||||
private final int HELPER_BUFFER_SIZE;
|
||||
private final int HELPER_BUFFER_COUNT;
|
||||
private final int MAX_SEND_PER_PASS;
|
||||
private final int MAX_READ_PER_PASS;
|
||||
private final long SLEEP_TIME;
|
||||
public boolean TCP_NODELAY;
|
||||
// Main Buffers
|
||||
private final ByteBuffer DIRECT_WRITE_BUFFER;
|
||||
private final ByteBuffer WRITE_BUFFER;
|
||||
private final ByteBuffer READ_BUFFER;
|
||||
// String Buffer
|
||||
private final NioNetStringBuffer STRING_BUFFER;
|
||||
// ByteBuffers General Purpose Pool
|
||||
private final LinkedList<ByteBuffer> _bufferPool;
|
||||
// Pending Close
|
||||
private final NioNetStackList<MMOConnection<T>> _pendingClose;
|
||||
|
||||
private boolean _shutdown;
|
||||
|
||||
public SelectorThread(SelectorConfig sc, IMMOExecutor<T> executor, IPacketHandler<T> packetHandler, IClientFactory<T> clientFactory, IAcceptFilter acceptFilter) throws IOException
|
||||
{
|
||||
super.setName("SelectorThread-" + super.getId());
|
||||
|
||||
HELPER_BUFFER_SIZE = sc.HELPER_BUFFER_SIZE;
|
||||
HELPER_BUFFER_COUNT = sc.HELPER_BUFFER_COUNT;
|
||||
MAX_SEND_PER_PASS = sc.MAX_SEND_PER_PASS;
|
||||
MAX_READ_PER_PASS = sc.MAX_READ_PER_PASS;
|
||||
SLEEP_TIME = sc.SLEEP_TIME;
|
||||
TCP_NODELAY = sc.TCP_NODELAY;
|
||||
|
||||
DIRECT_WRITE_BUFFER = ByteBuffer.allocateDirect(sc.WRITE_BUFFER_SIZE).order(BYTE_ORDER);
|
||||
WRITE_BUFFER = ByteBuffer.wrap(new byte[sc.WRITE_BUFFER_SIZE]).order(BYTE_ORDER);
|
||||
READ_BUFFER = ByteBuffer.wrap(new byte[sc.READ_BUFFER_SIZE]).order(BYTE_ORDER);
|
||||
|
||||
STRING_BUFFER = new NioNetStringBuffer(64 * 1024);
|
||||
|
||||
_pendingClose = new NioNetStackList<>();
|
||||
_bufferPool = new LinkedList<>();
|
||||
|
||||
for (int i = 0; i < HELPER_BUFFER_COUNT; i++)
|
||||
{
|
||||
_bufferPool.addLast(ByteBuffer.wrap(new byte[HELPER_BUFFER_SIZE]).order(BYTE_ORDER));
|
||||
}
|
||||
|
||||
_acceptFilter = acceptFilter;
|
||||
_packetHandler = packetHandler;
|
||||
_clientFactory = clientFactory;
|
||||
_executor = executor;
|
||||
_selector = Selector.open();
|
||||
}
|
||||
|
||||
public final void openServerSocket(InetAddress address, int tcpPort) throws IOException
|
||||
{
|
||||
final ServerSocketChannel selectable = ServerSocketChannel.open();
|
||||
selectable.configureBlocking(false);
|
||||
|
||||
final ServerSocket ss = selectable.socket();
|
||||
|
||||
if (address != null)
|
||||
{
|
||||
ss.bind(new InetSocketAddress(address, tcpPort));
|
||||
}
|
||||
else
|
||||
{
|
||||
ss.bind(new InetSocketAddress(tcpPort));
|
||||
}
|
||||
|
||||
selectable.register(_selector, SelectionKey.OP_ACCEPT);
|
||||
}
|
||||
|
||||
final ByteBuffer getPooledBuffer()
|
||||
{
|
||||
if (_bufferPool.isEmpty())
|
||||
{
|
||||
return ByteBuffer.wrap(new byte[HELPER_BUFFER_SIZE]).order(BYTE_ORDER);
|
||||
}
|
||||
|
||||
return _bufferPool.removeFirst();
|
||||
}
|
||||
|
||||
final void recycleBuffer(ByteBuffer buf)
|
||||
{
|
||||
if (_bufferPool.size() < HELPER_BUFFER_COUNT)
|
||||
{
|
||||
buf.clear();
|
||||
_bufferPool.addLast(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public final void run()
|
||||
{
|
||||
int selectedKeysCount = 0;
|
||||
|
||||
SelectionKey key;
|
||||
MMOConnection<T> con;
|
||||
|
||||
Iterator<SelectionKey> selectedKeys;
|
||||
|
||||
while (!_shutdown)
|
||||
{
|
||||
try
|
||||
{
|
||||
selectedKeysCount = _selector.selectNow();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (selectedKeysCount > 0)
|
||||
{
|
||||
selectedKeys = _selector.selectedKeys().iterator();
|
||||
|
||||
while (selectedKeys.hasNext())
|
||||
{
|
||||
key = selectedKeys.next();
|
||||
selectedKeys.remove();
|
||||
|
||||
con = (MMOConnection<T>) key.attachment();
|
||||
|
||||
switch (key.readyOps())
|
||||
{
|
||||
case SelectionKey.OP_CONNECT:
|
||||
{
|
||||
finishConnection(key, con);
|
||||
break;
|
||||
}
|
||||
case SelectionKey.OP_ACCEPT:
|
||||
{
|
||||
acceptConnection(key, con);
|
||||
break;
|
||||
}
|
||||
case SelectionKey.OP_READ:
|
||||
{
|
||||
readPacket(key, con);
|
||||
break;
|
||||
}
|
||||
case SelectionKey.OP_WRITE:
|
||||
{
|
||||
writePacket(key, con);
|
||||
break;
|
||||
}
|
||||
case SelectionKey.OP_READ | SelectionKey.OP_WRITE:
|
||||
{
|
||||
writePacket(key, con);
|
||||
if (key.isValid())
|
||||
{
|
||||
readPacket(key, con);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (_pendingClose)
|
||||
{
|
||||
while (!_pendingClose.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
con = _pendingClose.removeFirst();
|
||||
writeClosePacket(con);
|
||||
closeConnectionImpl(con.getSelectionKey(), con);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(SLEEP_TIME);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
closeSelectorThread();
|
||||
}
|
||||
|
||||
private final void finishConnection(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
try
|
||||
{
|
||||
((SocketChannel) key.channel()).finishConnect();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
con.getClient().onForcedDisconnection();
|
||||
closeConnectionImpl(key, con);
|
||||
}
|
||||
|
||||
// key might have been invalidated on finishConnect()
|
||||
if (key.isValid())
|
||||
{
|
||||
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
|
||||
key.interestOps(key.interestOps() & ~SelectionKey.OP_CONNECT);
|
||||
}
|
||||
}
|
||||
|
||||
private final void acceptConnection(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
final ServerSocketChannel ssc = (ServerSocketChannel) key.channel();
|
||||
SocketChannel sc;
|
||||
|
||||
try
|
||||
{
|
||||
while ((sc = ssc.accept()) != null)
|
||||
{
|
||||
if ((_acceptFilter == null) || _acceptFilter.accept(sc))
|
||||
{
|
||||
sc.configureBlocking(false);
|
||||
final SelectionKey clientKey = sc.register(_selector, SelectionKey.OP_READ);
|
||||
con = new MMOConnection<>(this, sc.socket(), clientKey, TCP_NODELAY);
|
||||
con.setClient(_clientFactory.create(con));
|
||||
clientKey.attach(con);
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.socket().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private final void readPacket(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
if (con.isClosed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ByteBuffer buf = con.getReadBuffer();
|
||||
if (buf == null)
|
||||
{
|
||||
buf = READ_BUFFER;
|
||||
}
|
||||
|
||||
// if we try to to do a read with no space in the buffer it will read 0 bytes going into infinite loop
|
||||
if (buf.position() == buf.limit())
|
||||
{
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
int result = -2;
|
||||
|
||||
try
|
||||
{
|
||||
result = con.read(buf);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// error handling goes bellow
|
||||
}
|
||||
|
||||
if (result > 0)
|
||||
{
|
||||
buf.flip();
|
||||
|
||||
final T client = con.getClient();
|
||||
|
||||
for (int i = 0; i < MAX_READ_PER_PASS; i++)
|
||||
{
|
||||
if (!tryReadPacket(key, client, buf, con))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// only reachable if MAX_READ_PER_PASS has been reached
|
||||
// check if there are some more bytes in buffer
|
||||
// and allocate/compact to prevent content lose.
|
||||
if (buf.remaining() > 0)
|
||||
{
|
||||
// did we use the READ_BUFFER ?
|
||||
if (buf == READ_BUFFER)
|
||||
{
|
||||
// move the pending byte to the connections READ_BUFFER
|
||||
allocateReadBuffer(con);
|
||||
}
|
||||
else
|
||||
{
|
||||
// move the first byte to the beginning :)
|
||||
buf.compact();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case 0:
|
||||
case -1:
|
||||
{
|
||||
closeConnectionImpl(key, con);
|
||||
break;
|
||||
}
|
||||
case -2:
|
||||
{
|
||||
con.getClient().onForcedDisconnection();
|
||||
closeConnectionImpl(key, con);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean tryReadPacket(SelectionKey key, T client, ByteBuffer buf, MMOConnection<T> con)
|
||||
{
|
||||
switch (buf.remaining())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
// buffer is full nothing to read
|
||||
return false;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
// we don`t have enough data for header so we need to read
|
||||
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
|
||||
|
||||
// did we use the READ_BUFFER ?
|
||||
if (buf == READ_BUFFER)
|
||||
{
|
||||
// move the pending byte to the connections READ_BUFFER
|
||||
allocateReadBuffer(con);
|
||||
}
|
||||
else
|
||||
{
|
||||
// move the first byte to the beginning :)
|
||||
buf.compact();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// data size excluding header size :>
|
||||
final int dataPending = (buf.getShort() & 0xFFFF) - HEADER_SIZE;
|
||||
|
||||
// do we got enough bytes for the packet?
|
||||
if (dataPending <= buf.remaining())
|
||||
{
|
||||
// avoid parsing dummy packets (packets without body)
|
||||
if (dataPending > 0)
|
||||
{
|
||||
final int pos = buf.position();
|
||||
parseClientPacket(pos, buf, dataPending, client);
|
||||
buf.position(pos + dataPending);
|
||||
}
|
||||
|
||||
if (buf.hasRemaining())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (buf != READ_BUFFER)
|
||||
{
|
||||
con.setReadBuffer(null);
|
||||
recycleBuffer(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
READ_BUFFER.clear();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// we don`t have enough bytes for the dataPacket so we need to read
|
||||
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
|
||||
|
||||
// move it`s position
|
||||
buf.position(buf.position() - HEADER_SIZE);
|
||||
// did we use the READ_BUFFER ?
|
||||
if (buf == READ_BUFFER)
|
||||
{
|
||||
// move the pending byte to the connections READ_BUFFER
|
||||
allocateReadBuffer(con);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.compact();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final void allocateReadBuffer(MMOConnection<T> con)
|
||||
{
|
||||
con.setReadBuffer(getPooledBuffer().put(READ_BUFFER));
|
||||
READ_BUFFER.clear();
|
||||
}
|
||||
|
||||
private final void parseClientPacket(int pos, ByteBuffer buf, int dataSize, T client)
|
||||
{
|
||||
if (!client.decrypt(buf, dataSize) || !buf.hasRemaining())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// apply limit
|
||||
final int limit = buf.limit();
|
||||
buf.limit(pos + dataSize);
|
||||
final ReceivablePacket<T> cp = _packetHandler.handlePacket(buf, client);
|
||||
|
||||
if (cp != null)
|
||||
{
|
||||
cp._buf = buf;
|
||||
cp._sbuf = STRING_BUFFER;
|
||||
cp._client = client;
|
||||
|
||||
if (cp.read())
|
||||
{
|
||||
_executor.execute(cp);
|
||||
}
|
||||
|
||||
cp._buf = null;
|
||||
cp._sbuf = null;
|
||||
}
|
||||
buf.limit(limit);
|
||||
}
|
||||
|
||||
private final void writeClosePacket(MMOConnection<T> con)
|
||||
{
|
||||
SendablePacket<T> sp;
|
||||
synchronized (con.getSendQueue())
|
||||
{
|
||||
if (con.getSendQueue().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while ((sp = con.getSendQueue().removeFirst()) != null)
|
||||
{
|
||||
WRITE_BUFFER.clear();
|
||||
|
||||
putPacketIntoWriteBuffer(con.getClient(), sp);
|
||||
|
||||
WRITE_BUFFER.flip();
|
||||
|
||||
try
|
||||
{
|
||||
con.write(WRITE_BUFFER);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// error handling goes on the if bellow
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected final void writePacket(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
if (!prepareWriteBuffer(con))
|
||||
{
|
||||
key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);
|
||||
return;
|
||||
}
|
||||
|
||||
DIRECT_WRITE_BUFFER.flip();
|
||||
|
||||
final int size = DIRECT_WRITE_BUFFER.remaining();
|
||||
|
||||
int result = -1;
|
||||
|
||||
try
|
||||
{
|
||||
result = con.write(DIRECT_WRITE_BUFFER);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// error handling goes on the if bellow
|
||||
}
|
||||
|
||||
// check if no error happened
|
||||
if (result >= 0)
|
||||
{
|
||||
// check if we written everything
|
||||
if (result == size)
|
||||
{
|
||||
// complete write
|
||||
synchronized (con.getSendQueue())
|
||||
{
|
||||
if (con.getSendQueue().isEmpty() && !con.hasPendingWriteBuffer())
|
||||
{
|
||||
key.interestOps(key.interestOps() & ~SelectionKey.OP_WRITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// incomplete write
|
||||
con.createWriteBuffer(DIRECT_WRITE_BUFFER);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
con.getClient().onForcedDisconnection();
|
||||
closeConnectionImpl(key, con);
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean prepareWriteBuffer(MMOConnection<T> con)
|
||||
{
|
||||
boolean hasPending = false;
|
||||
DIRECT_WRITE_BUFFER.clear();
|
||||
|
||||
// if there is pending content add it
|
||||
if (con.hasPendingWriteBuffer())
|
||||
{
|
||||
con.movePendingWriteBufferTo(DIRECT_WRITE_BUFFER);
|
||||
hasPending = true;
|
||||
}
|
||||
|
||||
if ((DIRECT_WRITE_BUFFER.remaining() > 1) && !con.hasPendingWriteBuffer())
|
||||
{
|
||||
final NioNetStackList<SendablePacket<T>> sendQueue = con.getSendQueue();
|
||||
final T client = con.getClient();
|
||||
SendablePacket<T> sp;
|
||||
|
||||
for (int i = 0; i < MAX_SEND_PER_PASS; i++)
|
||||
{
|
||||
synchronized (con.getSendQueue())
|
||||
{
|
||||
if (sendQueue.isEmpty())
|
||||
{
|
||||
sp = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
sp = sendQueue.removeFirst();
|
||||
}
|
||||
}
|
||||
|
||||
if (sp == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
hasPending = true;
|
||||
|
||||
// put into WriteBuffer
|
||||
putPacketIntoWriteBuffer(client, sp);
|
||||
|
||||
WRITE_BUFFER.flip();
|
||||
|
||||
if (DIRECT_WRITE_BUFFER.remaining() < WRITE_BUFFER.limit())
|
||||
{
|
||||
con.createWriteBuffer(WRITE_BUFFER);
|
||||
break;
|
||||
}
|
||||
DIRECT_WRITE_BUFFER.put(WRITE_BUFFER);
|
||||
}
|
||||
}
|
||||
return hasPending;
|
||||
}
|
||||
|
||||
private final void putPacketIntoWriteBuffer(T client, SendablePacket<T> sp)
|
||||
{
|
||||
WRITE_BUFFER.clear();
|
||||
|
||||
// reserve space for the size
|
||||
final int headerPos = WRITE_BUFFER.position();
|
||||
final int dataPos = headerPos + HEADER_SIZE;
|
||||
WRITE_BUFFER.position(dataPos);
|
||||
|
||||
// set the write buffer
|
||||
sp._buf = WRITE_BUFFER;
|
||||
// set the client.
|
||||
sp._client = client;
|
||||
// write content to buffer
|
||||
sp.write();
|
||||
// delete the write buffer
|
||||
sp._buf = null;
|
||||
|
||||
// size (inclusive header)
|
||||
int dataSize = WRITE_BUFFER.position() - dataPos;
|
||||
WRITE_BUFFER.position(dataPos);
|
||||
client.encrypt(WRITE_BUFFER, dataSize);
|
||||
|
||||
// recalculate size after encryption
|
||||
dataSize = WRITE_BUFFER.position() - dataPos;
|
||||
|
||||
WRITE_BUFFER.position(headerPos);
|
||||
// write header
|
||||
WRITE_BUFFER.putShort((short) (dataSize + HEADER_SIZE));
|
||||
WRITE_BUFFER.position(dataPos + dataSize);
|
||||
}
|
||||
|
||||
final void closeConnection(MMOConnection<T> con)
|
||||
{
|
||||
synchronized (_pendingClose)
|
||||
{
|
||||
_pendingClose.addLast(con);
|
||||
}
|
||||
}
|
||||
|
||||
private final void closeConnectionImpl(SelectionKey key, MMOConnection<T> con)
|
||||
{
|
||||
try
|
||||
{
|
||||
// notify connection
|
||||
con.getClient().onDisconnection();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
// close socket and the SocketChannel
|
||||
con.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// ignore, we are closing anyway
|
||||
}
|
||||
finally
|
||||
{
|
||||
con.releaseBuffers();
|
||||
// clear attachment
|
||||
key.attach(null);
|
||||
// cancel key
|
||||
key.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final void shutdown()
|
||||
{
|
||||
_shutdown = true;
|
||||
}
|
||||
|
||||
protected void closeSelectorThread()
|
||||
{
|
||||
for (SelectionKey key : _selector.keys())
|
||||
{
|
||||
try
|
||||
{
|
||||
key.channel().close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_selector.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,139 +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 com.l2jmobius.commons.mmocore;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class SendablePacket<T extends MMOClient<?>>extends AbstractPacket<T>
|
||||
{
|
||||
protected final void putInt(int value)
|
||||
{
|
||||
_buf.putInt(value);
|
||||
}
|
||||
|
||||
protected final void putDouble(double value)
|
||||
{
|
||||
_buf.putDouble(value);
|
||||
}
|
||||
|
||||
protected final void putFloat(float value)
|
||||
{
|
||||
_buf.putFloat(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>byte</B> to the buffer. <BR>
|
||||
* 8bit integer (00)
|
||||
* @param data
|
||||
*/
|
||||
protected final void writeC(boolean data)
|
||||
{
|
||||
_buf.put((byte) (data ? 0x01 : 0x00));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>byte</B> to the buffer. <BR>
|
||||
* 8bit integer (00)
|
||||
* @param data
|
||||
*/
|
||||
protected final void writeC(int data)
|
||||
{
|
||||
_buf.put((byte) data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>double</B> to the buffer. <BR>
|
||||
* 64bit double precision float (00 00 00 00 00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeF(double value)
|
||||
{
|
||||
_buf.putDouble(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>short</B> to the buffer. <BR>
|
||||
* 16bit integer (00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeH(int value)
|
||||
{
|
||||
_buf.putShort((short) value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>int</B> to the buffer. <BR>
|
||||
* 32bit integer (00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeD(int value)
|
||||
{
|
||||
_buf.putInt(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>int</B> to the buffer. <BR>
|
||||
* 32bit integer (00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeD(boolean value)
|
||||
{
|
||||
_buf.putInt(value ? 0x01 : 0x00);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>long</B> to the buffer. <BR>
|
||||
* 64bit integer (00 00 00 00 00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
protected final void writeQ(long value)
|
||||
{
|
||||
_buf.putLong(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>byte[]</B> to the buffer. <BR>
|
||||
* 8bit integer array (00 ...)
|
||||
* @param data
|
||||
*/
|
||||
protected final void writeB(byte[] data)
|
||||
{
|
||||
_buf.put(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <B>String</B> to the buffer.
|
||||
* @param text
|
||||
*/
|
||||
protected final void writeS(String text)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
final int len = text.length();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
_buf.putChar(text.charAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
_buf.putChar('\000');
|
||||
}
|
||||
|
||||
protected abstract void write();
|
||||
}
|
@@ -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 com.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class ChannelInboundHandler<T extends ChannelInboundHandler<?>>extends SimpleChannelInboundHandler<IIncomingPacket<T>>
|
||||
{
|
||||
private Channel _channel;
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx)
|
||||
{
|
||||
_channel = ctx.channel();
|
||||
}
|
||||
|
||||
public void setConnectionState(IConnectionState connectionState)
|
||||
{
|
||||
_channel.attr(IConnectionState.ATTRIBUTE_KEY).set(connectionState);
|
||||
}
|
||||
|
||||
public IConnectionState getConnectionState()
|
||||
{
|
||||
return _channel != null ? _channel.attr(IConnectionState.ATTRIBUTE_KEY).get() : null;
|
||||
}
|
||||
}
|
@@ -14,15 +14,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import io.netty.util.AttributeKey;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
* @author Nos
|
||||
*/
|
||||
public interface IPacketHandler<T extends MMOClient<?>>
|
||||
public interface IConnectionState
|
||||
{
|
||||
ReceivablePacket<T> handlePacket(ByteBuffer buf, T client);
|
||||
AttributeKey<IConnectionState> ATTRIBUTE_KEY = AttributeKey.valueOf(IConnectionState.class, "");
|
||||
}
|
@@ -14,13 +14,16 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @param <T>
|
||||
* @author Nos
|
||||
*/
|
||||
public interface IMMOExecutor<T extends MMOClient<?>>
|
||||
public interface ICrypt
|
||||
{
|
||||
void execute(ReceivablePacket<T> packet);
|
||||
void encrypt(ByteBuf buf);
|
||||
|
||||
void decrypt(ByteBuf buf);
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
* @param <T>
|
||||
*/
|
||||
public interface IIncomingPacket<T>
|
||||
{
|
||||
/**
|
||||
* Reads a packet.
|
||||
* @param client the client
|
||||
* @param packet the packet reader
|
||||
* @return {@code true} if packet was read successfully, {@code false} otherwise.
|
||||
*/
|
||||
boolean read(T client, PacketReader packet);
|
||||
|
||||
void run(T client) throws Exception;
|
||||
}
|
@@ -14,22 +14,19 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.mmocore;
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @author Nos
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class AbstractPacket<T extends MMOClient<?>>
|
||||
public interface IIncomingPackets<T>extends IConnectionState
|
||||
{
|
||||
protected ByteBuffer _buf;
|
||||
int getPacketId();
|
||||
|
||||
T _client;
|
||||
IIncomingPacket<T> newIncomingPacket();
|
||||
|
||||
public final T getClient()
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
Set<IConnectionState> getConnectionStates();
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public interface IOutgoingPacket
|
||||
{
|
||||
/**
|
||||
* @param packet the packet writer
|
||||
* @return {@code true} if packet was writen successfully, {@code false} otherwise.
|
||||
*/
|
||||
boolean write(PacketWriter packet);
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public class NetworkManager
|
||||
{
|
||||
private final Logger LOGGER = Logger.getLogger(getClass().getName());
|
||||
|
||||
private final ServerBootstrap _serverBootstrap;
|
||||
private final String _host;
|
||||
private final int _port;
|
||||
|
||||
private ChannelFuture _channelFuture;
|
||||
|
||||
public NetworkManager(EventLoopGroup bossGroup, EventLoopGroup workerGroup, ChannelInitializer<SocketChannel> clientInitializer, String host, int port)
|
||||
{
|
||||
// @formatter:off
|
||||
_serverBootstrap = new ServerBootstrap()
|
||||
.group(bossGroup, workerGroup)
|
||||
.channel(NioServerSocketChannel.class)
|
||||
.childHandler(clientInitializer)
|
||||
.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
|
||||
// @formatter:on
|
||||
_host = host;
|
||||
_port = port;
|
||||
}
|
||||
|
||||
public ChannelFuture getChannelFuture()
|
||||
{
|
||||
return _channelFuture;
|
||||
}
|
||||
|
||||
public void start() throws InterruptedException
|
||||
{
|
||||
if ((_channelFuture != null) && !_channelFuture.isDone())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_channelFuture = _serverBootstrap.bind(_host, _port).sync();
|
||||
LOGGER.info(getClass().getSimpleName() + ": Listening on " + _host + ":" + _port);
|
||||
}
|
||||
|
||||
public void stop() throws InterruptedException
|
||||
{
|
||||
_channelFuture.channel().close().sync();
|
||||
}
|
||||
}
|
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public final class PacketReader
|
||||
{
|
||||
private final ByteBuf _buf;
|
||||
|
||||
public PacketReader(ByteBuf buf)
|
||||
{
|
||||
_buf = buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the readable bytes.
|
||||
* @return the readable bytes
|
||||
*/
|
||||
public int getReadableBytes()
|
||||
{
|
||||
return _buf.readableBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an unsigned byte.
|
||||
* @return the unsigned byte
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 1}
|
||||
*/
|
||||
public short readC()
|
||||
{
|
||||
return _buf.readUnsignedByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an unsigned short.
|
||||
* @return the unsigned short
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 2}
|
||||
*/
|
||||
public int readH()
|
||||
{
|
||||
return _buf.readUnsignedShortLE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an integer.
|
||||
* @return the integer
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 4}
|
||||
*/
|
||||
public int readD()
|
||||
{
|
||||
return _buf.readIntLE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a long.
|
||||
* @return the long
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 8}
|
||||
*/
|
||||
public long readQ()
|
||||
{
|
||||
return _buf.readLongLE();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a float.
|
||||
* @return the float
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 4}
|
||||
*/
|
||||
public float readE()
|
||||
{
|
||||
return Float.intBitsToFloat(_buf.readIntLE());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a double.
|
||||
* @return the double
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 8}
|
||||
*/
|
||||
public double readF()
|
||||
{
|
||||
return Double.longBitsToDouble(_buf.readLongLE());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a string.
|
||||
* @return the string
|
||||
* @throws IndexOutOfBoundsException if string {@code null} terminator is not found within {@code readableBytes}
|
||||
*/
|
||||
public String readS()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
char chr;
|
||||
while ((chr = Character.reverseBytes(_buf.readChar())) != 0)
|
||||
{
|
||||
sb.append(chr);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a fixed length string.
|
||||
* @return the string
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code 2 + String.length * 2}
|
||||
*/
|
||||
public String readString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final int stringLength = _buf.readShortLE();
|
||||
if ((stringLength * 2) > getReadableBytes())
|
||||
{
|
||||
throw new IndexOutOfBoundsException("readerIndex(" + _buf.readerIndex() + ") + length(" + (stringLength * 2) + ") exceeds writerIndex(" + _buf.writerIndex() + "): " + _buf);
|
||||
}
|
||||
|
||||
for (int i = 0; i < stringLength; i++)
|
||||
{
|
||||
sb.append(Character.reverseBytes(_buf.readChar()));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a byte array.
|
||||
* @param length the length
|
||||
* @return the byte array
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code length}
|
||||
*/
|
||||
public byte[] readB(int length)
|
||||
{
|
||||
final byte[] result = new byte[length];
|
||||
_buf.readBytes(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a byte array.
|
||||
* @param dst the destination
|
||||
* @param dstIndex the destination index to start writing the bytes from
|
||||
* @param length the length
|
||||
* @throws IndexOutOfBoundsException if {@code readableBytes} is less than {@code length}, if the specified dstIndex is less than 0 or if {@code dstIndex + length} is greater than {@code dst.length}
|
||||
*/
|
||||
public void readB(byte[] dst, int dstIndex, int length)
|
||||
{
|
||||
_buf.readBytes(dst, dstIndex, length);
|
||||
}
|
||||
}
|
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public final class PacketWriter
|
||||
{
|
||||
private final ByteBuf _buf;
|
||||
|
||||
public PacketWriter(ByteBuf buf)
|
||||
{
|
||||
_buf = buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the writable bytes.
|
||||
* @return the writable bytes
|
||||
*/
|
||||
public int getWritableBytes()
|
||||
{
|
||||
return _buf.writableBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a byte.
|
||||
* @param value the byte (The 24 high-order bits are ignored)
|
||||
*/
|
||||
public void writeC(int value)
|
||||
{
|
||||
_buf.writeByte(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a short.
|
||||
* @param value the short (The 16 high-order bits are ignored)
|
||||
*/
|
||||
public void writeH(int value)
|
||||
{
|
||||
_buf.writeShortLE(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an integer.
|
||||
* @param value the integer
|
||||
*/
|
||||
public void writeD(int value)
|
||||
{
|
||||
_buf.writeIntLE(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a long.
|
||||
* @param value the long
|
||||
*/
|
||||
public void writeQ(long value)
|
||||
{
|
||||
_buf.writeLongLE(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a float.
|
||||
* @param value the float
|
||||
*/
|
||||
public void writeE(float value)
|
||||
{
|
||||
_buf.writeIntLE(Float.floatToIntBits(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a double.
|
||||
* @param value the double
|
||||
*/
|
||||
public void writeF(double value)
|
||||
{
|
||||
_buf.writeLongLE(Double.doubleToLongBits(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string.
|
||||
* @param value the string
|
||||
*/
|
||||
public void writeS(String value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
for (int i = 0; i < value.length(); i++)
|
||||
{
|
||||
_buf.writeChar(Character.reverseBytes(value.charAt(i)));
|
||||
}
|
||||
}
|
||||
|
||||
_buf.writeChar(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string with fixed length specified as [short length, char[length] data].
|
||||
* @param value the string
|
||||
*/
|
||||
public void writeString(String value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
_buf.writeShortLE(value.length());
|
||||
for (int i = 0; i < value.length(); i++)
|
||||
{
|
||||
_buf.writeChar(Character.reverseBytes(value.charAt(i)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_buf.writeShort(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a byte array.
|
||||
* @param bytes the byte array
|
||||
*/
|
||||
public void writeB(byte[] bytes)
|
||||
{
|
||||
_buf.writeBytes(bytes);
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.commons.network.ICrypt;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageCodec;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public class CryptCodec extends ByteToMessageCodec<ByteBuf>
|
||||
{
|
||||
private final ICrypt _crypt;
|
||||
|
||||
public CryptCodec(ICrypt crypt)
|
||||
{
|
||||
super();
|
||||
_crypt = crypt;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.netty.handler.codec.ByteToMessageCodec#encode(io.netty.channel.ChannelHandlerContext, java.lang.Object, io.netty.buffer.ByteBuf)
|
||||
*/
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out)
|
||||
{
|
||||
// Check if there are any data to encrypt.
|
||||
if (!msg.isReadable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
msg.resetReaderIndex();
|
||||
_crypt.encrypt(msg);
|
||||
msg.resetReaderIndex();
|
||||
out.writeBytes(msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see io.netty.handler.codec.ByteToMessageCodec#decode(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
|
||||
{
|
||||
in.resetReaderIndex();
|
||||
_crypt.decrypt(in);
|
||||
in.readerIndex(in.writerIndex());
|
||||
out.add(in.copy(0, in.writerIndex()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
@Sharable
|
||||
public class LengthFieldBasedFrameEncoder extends MessageToMessageEncoder<ByteBuf>
|
||||
{
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out)
|
||||
{
|
||||
final ByteBuf buf = ctx.alloc().buffer(2);
|
||||
final short length = (short) (msg.readableBytes() + 2);
|
||||
buf.writeShortLE(length);
|
||||
out.add(buf);
|
||||
out.add(msg.retain());
|
||||
}
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.network.IConnectionState;
|
||||
import com.l2jmobius.commons.network.IIncomingPacket;
|
||||
import com.l2jmobius.commons.network.IIncomingPackets;
|
||||
import com.l2jmobius.commons.network.PacketReader;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
* @param <T>
|
||||
*/
|
||||
public class PacketDecoder<T>extends ByteToMessageDecoder
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(PacketDecoder.class.getName());
|
||||
|
||||
private final IIncomingPackets<T>[] _incomingPackets;
|
||||
private final T _client;
|
||||
|
||||
public PacketDecoder(IIncomingPackets<T>[] incomingPackets, T client)
|
||||
{
|
||||
_incomingPackets = incomingPackets;
|
||||
_client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out)
|
||||
{
|
||||
if ((in == null) || !in.isReadable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final short packetId = in.readUnsignedByte();
|
||||
if (packetId >= _incomingPackets.length)
|
||||
{
|
||||
LOGGER.finer("Unknown packet: " + Integer.toHexString(packetId));
|
||||
return;
|
||||
}
|
||||
|
||||
final IIncomingPackets<T> incomingPacket = _incomingPackets[packetId];
|
||||
if (incomingPacket == null)
|
||||
{
|
||||
LOGGER.finer("Unknown packet: " + Integer.toHexString(packetId));
|
||||
return;
|
||||
}
|
||||
|
||||
final IConnectionState connectionState = ctx.channel().attr(IConnectionState.ATTRIBUTE_KEY).get();
|
||||
if ((connectionState == null) || !incomingPacket.getConnectionStates().contains(connectionState))
|
||||
{
|
||||
// LOGGER.warning(incomingPacket + ": Connection at invalid state: " + connectionState + " Required States: " + incomingPacket.getConnectionStates());
|
||||
return;
|
||||
}
|
||||
|
||||
final IIncomingPacket<T> packet = incomingPacket.newIncomingPacket();
|
||||
if ((packet != null) && packet.read(_client, new PacketReader(in)))
|
||||
{
|
||||
out.add(packet);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// We always consider that we read whole packet.
|
||||
in.readerIndex(in.writerIndex());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.network.IOutgoingPacket;
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
@Sharable
|
||||
public class PacketEncoder extends MessageToByteEncoder<IOutgoingPacket>
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(PacketEncoder.class.getName());
|
||||
|
||||
private final int _maxPacketSize;
|
||||
|
||||
public PacketEncoder(int maxPacketSize)
|
||||
{
|
||||
super();
|
||||
_maxPacketSize = maxPacketSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, IOutgoingPacket packet, ByteBuf out)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (packet.write(new PacketWriter(out)))
|
||||
{
|
||||
if (out.writerIndex() > _maxPacketSize)
|
||||
{
|
||||
throw new IllegalStateException("Packet (" + packet + ") size (" + out.writerIndex() + ") is bigger than the limit (" + _maxPacketSize + ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Avoid sending the packet
|
||||
out.clear();
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Failed sending Packet(" + packet + ")", e);
|
||||
// Avoid sending the packet if some exception happened
|
||||
out.clear();
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,8 +20,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -30,14 +28,11 @@ import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
|
||||
public final class CommonUtil
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(CommonUtil.class.getName());
|
||||
|
||||
private static final char[] ILLEGAL_CHARACTERS =
|
||||
{
|
||||
'/',
|
||||
@@ -57,26 +52,6 @@ public final class CommonUtil
|
||||
':'
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a host name is internal
|
||||
* @param host the host name to check
|
||||
* @return true: host name is internal<br>
|
||||
* false: host name is external
|
||||
*/
|
||||
public static boolean isInternalHostname(String host)
|
||||
{
|
||||
try
|
||||
{
|
||||
final InetAddress addr = InetAddress.getByName(host);
|
||||
return addr.isSiteLocalAddress() || addr.isLoopbackAddress();
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
_log.warning("Util: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate the hexadecimal representation of a byte array.<br>
|
||||
* 16 bytes per row, while ascii chars or "." is shown at the end of the line.
|
||||
@@ -123,19 +98,16 @@ public final class CommonUtil
|
||||
{
|
||||
final byte[] array = new byte[size];
|
||||
Rnd.nextBytes(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the stack trace of a Throwable into a String
|
||||
* @param t Throwable to get the stacktrace from
|
||||
* @return stack trace from Throwable as String
|
||||
*/
|
||||
public static String getStackTrace(Throwable t)
|
||||
// Don't allow 0s inside the array!
|
||||
for (int i = 0; i < array.length; i++)
|
||||
{
|
||||
final StringWriter sw = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(sw));
|
||||
return sw.toString();
|
||||
while (array[i] == 0)
|
||||
{
|
||||
array[i] = (byte) Rnd.get(Byte.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,10 +194,22 @@ public final class CommonUtil
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the stack trace of a Throwable into a String
|
||||
* @param t Throwable to get the stacktrace from
|
||||
* @return stack trace from Throwable as String
|
||||
*/
|
||||
public static String getStackTrace(Throwable t)
|
||||
{
|
||||
final StringWriter sw = new StringWriter();
|
||||
t.printStackTrace(new PrintWriter(sw));
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
public static String getTraceString(StackTraceElement[] stackTraceElements)
|
||||
{
|
||||
final StringJoiner sj = new StringJoiner(Config.EOL);
|
||||
for (final StackTraceElement stackTraceElement : stackTraceElements)
|
||||
for (StackTraceElement stackTraceElement : stackTraceElements)
|
||||
{
|
||||
sj.add(stackTraceElement.toString());
|
||||
}
|
||||
|
@@ -1118,7 +1118,7 @@ public final class BlowfishEngine
|
||||
|
||||
private int func(int x)
|
||||
{
|
||||
return ((S0[(x >>> 24)] + S1[(x >>> 16) & 0xff]) ^ S2[(x >>> 8) & 0xff]) + S3[x & 0xff];
|
||||
return (((S0[(x >>> 24)] + S1[(x >>> 16) & 0xff]) ^ S2[(x >>> 8) & 0xff]) + S3[x & 0xff]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1129,7 +1129,8 @@ public final class BlowfishEngine
|
||||
*/
|
||||
private void processTable(int xl, int xr, int[] table)
|
||||
{
|
||||
for (int s = 0; s < table.length; s += 2)
|
||||
final int size = table.length;
|
||||
for (int s = 0; s < size; s += 2)
|
||||
{
|
||||
xl ^= P[0];
|
||||
xr ^= func(xl) ^ P[1];
|
||||
@@ -1436,7 +1437,7 @@ public final class BlowfishEngine
|
||||
*/
|
||||
private int bytesTo32bits(byte[] src, int srcIndex)
|
||||
{
|
||||
return ((src[srcIndex + 3] & 0xff) << 24) | ((src[srcIndex + 2] & 0xff) << 16) | ((src[srcIndex + 1] & 0xff) << 8) | (src[srcIndex] & 0xff);
|
||||
return ((src[srcIndex + 3] & 0xff) << 24) | ((src[srcIndex + 2] & 0xff) << 16) | ((src[srcIndex + 1] & 0xff) << 8) | ((src[srcIndex] & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,14 +16,17 @@
|
||||
*/
|
||||
package com.l2jmobius.commons.util.crypt;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import com.l2jmobius.commons.network.ICrypt;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author KenM
|
||||
* @author NosBit
|
||||
*/
|
||||
public class LoginCrypt
|
||||
public class LoginCrypt implements ICrypt
|
||||
{
|
||||
private static final byte[] STATIC_BLOWFISH_KEY =
|
||||
{
|
||||
@@ -45,82 +48,102 @@ public class LoginCrypt
|
||||
(byte) 0x6c
|
||||
};
|
||||
|
||||
private static final NewCrypt _STATIC_CRYPT = new NewCrypt(STATIC_BLOWFISH_KEY);
|
||||
private NewCrypt _crypt = null;
|
||||
private static final BlowfishEngine STATIC_BLOWFISH_ENGINE = new BlowfishEngine();
|
||||
|
||||
static
|
||||
{
|
||||
STATIC_BLOWFISH_ENGINE.init(STATIC_BLOWFISH_KEY);
|
||||
}
|
||||
|
||||
private final BlowfishEngine _blowfishEngine = new BlowfishEngine();
|
||||
private boolean _static = true;
|
||||
|
||||
/**
|
||||
* Method to initialize the the blowfish cipher with dynamic key.
|
||||
* @param key the blowfish key to initialize the dynamic blowfish cipher with
|
||||
*/
|
||||
public void setKey(byte[] key)
|
||||
public LoginCrypt(SecretKey blowfishKey)
|
||||
{
|
||||
_crypt = new NewCrypt(key);
|
||||
_blowfishEngine.init(blowfishKey.getEncoded());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to decrypt an incoming login client packet.
|
||||
* @param raw array with encrypted data
|
||||
* @param offset offset where the encrypted data is located
|
||||
* @param size number of bytes of encrypted data
|
||||
* @return true when checksum could be verified, false otherwise
|
||||
* @throws IOException the size is not multiple of blowfishs block size or the raw array can't hold size bytes starting at offset due to it's size
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.l2jserver.commons.network.ICrypt#encrypt(io.netty.buffer.ByteBuf)
|
||||
*/
|
||||
public boolean decrypt(byte[] raw, int offset, int size) throws IOException
|
||||
@Override
|
||||
public void encrypt(ByteBuf buf)
|
||||
{
|
||||
if ((size % 8) != 0)
|
||||
{
|
||||
throw new IOException("size have to be multiple of 8");
|
||||
}
|
||||
if ((offset + size) > raw.length)
|
||||
{
|
||||
throw new IOException("raw array too short for size starting from offset");
|
||||
}
|
||||
// Checksum & XOR Key or Checksum only
|
||||
buf.writeZero(_static ? 16 : 12);
|
||||
|
||||
_crypt.decrypt(raw, offset, size);
|
||||
return NewCrypt.verifyChecksum(raw, offset, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to encrypt an outgoing packet to login client.<br>
|
||||
* Performs padding and resizing of data array.
|
||||
* @param raw array with plain data
|
||||
* @param offset offset where the plain data is located
|
||||
* @param size number of bytes of plain data
|
||||
* @return the new array size
|
||||
* @throws IOException packet is too long to make padding and add verification data
|
||||
*/
|
||||
public int encrypt(byte[] raw, int offset, int size) throws IOException
|
||||
{
|
||||
// reserve checksum
|
||||
size += 4;
|
||||
// Padding
|
||||
buf.writeZero(8 - (buf.readableBytes() % 8));
|
||||
|
||||
if (_static)
|
||||
{
|
||||
// reserve for XOR "key"
|
||||
size += 4;
|
||||
|
||||
// padding
|
||||
size += 8 - (size % 8);
|
||||
if ((offset + size) > raw.length)
|
||||
{
|
||||
throw new IOException("packet too long");
|
||||
}
|
||||
NewCrypt.encXORPass(raw, offset, size, Rnd.nextInt());
|
||||
_STATIC_CRYPT.crypt(raw, offset, size);
|
||||
_static = false;
|
||||
|
||||
int key = Rnd.nextInt();
|
||||
buf.skipBytes(4); // The first 4 bytes are ignored
|
||||
while (buf.readerIndex() < (buf.writerIndex() - 8))
|
||||
{
|
||||
int data = buf.readIntLE();
|
||||
key += data;
|
||||
data ^= key;
|
||||
buf.setIntLE(buf.readerIndex() - 4, data);
|
||||
}
|
||||
buf.setIntLE(buf.readerIndex(), key);
|
||||
|
||||
buf.resetReaderIndex();
|
||||
|
||||
final byte[] block = new byte[8];
|
||||
while (buf.isReadable(8))
|
||||
{
|
||||
buf.readBytes(block);
|
||||
STATIC_BLOWFISH_ENGINE.encryptBlock(block, 0);
|
||||
buf.setBytes(buf.readerIndex() - block.length, block);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// padding
|
||||
size += 8 - (size % 8);
|
||||
if ((offset + size) > raw.length)
|
||||
int checksum = 0;
|
||||
while (buf.isReadable(8))
|
||||
{
|
||||
throw new IOException("packet too long");
|
||||
checksum ^= buf.readIntLE();
|
||||
}
|
||||
NewCrypt.appendChecksum(raw, offset, size);
|
||||
_crypt.crypt(raw, offset, size);
|
||||
buf.setIntLE(buf.readerIndex(), checksum);
|
||||
|
||||
buf.resetReaderIndex();
|
||||
|
||||
final byte[] block = new byte[8];
|
||||
while (buf.isReadable(8))
|
||||
{
|
||||
buf.readBytes(block);
|
||||
_blowfishEngine.encryptBlock(block, 0);
|
||||
buf.setBytes(buf.readerIndex() - block.length, block);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.l2jserver.commons.network.ICrypt#decrypt(io.netty.buffer.ByteBuf)
|
||||
*/
|
||||
@Override
|
||||
public void decrypt(ByteBuf buf)
|
||||
{
|
||||
// Packet size must be multiple of 8
|
||||
if ((buf.readableBytes() % 8) != 0)
|
||||
{
|
||||
buf.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
final byte[] block = new byte[8];
|
||||
while (buf.isReadable(8))
|
||||
{
|
||||
buf.readBytes(block);
|
||||
_blowfishEngine.decryptBlock(block, 0);
|
||||
buf.setBytes(buf.readerIndex() - block.length, block);
|
||||
}
|
||||
|
||||
// TODO: verify checksum also dont forget!
|
||||
}
|
||||
}
|
||||
|
@@ -17,13 +17,11 @@
|
||||
package com.l2jmobius.commons.util.crypt;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.Key;
|
||||
import java.security.KeyPair;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ScrambledKeyPair
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(ScrambledKeyPair.class.getName());
|
||||
@@ -68,8 +66,23 @@ public class ScrambledKeyPair
|
||||
{
|
||||
scrambledMod[0x40 + i] = (byte) (scrambledMod[0x40 + i] ^ scrambledMod[i]);
|
||||
}
|
||||
_log.fine("Modulus was scrambled");
|
||||
_log.finer("Modulus was scrambled");
|
||||
|
||||
return scrambledMod;
|
||||
}
|
||||
|
||||
public byte[] getScrambledModulus()
|
||||
{
|
||||
return _scrambledModulus;
|
||||
}
|
||||
|
||||
public Key getPrivateKey()
|
||||
{
|
||||
return _pair.getPrivate();
|
||||
}
|
||||
|
||||
public Key getPublicKey()
|
||||
{
|
||||
return _pair.getPublic();
|
||||
}
|
||||
}
|
||||
|
@@ -19,10 +19,8 @@ package com.l2jmobius.gameserver;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Calendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
@@ -32,8 +30,6 @@ import com.l2jmobius.Config;
|
||||
import com.l2jmobius.Server;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.commons.mmocore.SelectorConfig;
|
||||
import com.l2jmobius.commons.mmocore.SelectorThread;
|
||||
import com.l2jmobius.commons.util.DeadLockDetector;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
|
||||
@@ -135,26 +131,23 @@ import com.l2jmobius.gameserver.model.entity.Hero;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTManager;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.L2GamePacketHandler;
|
||||
import com.l2jmobius.gameserver.network.ClientNetworkManager;
|
||||
import com.l2jmobius.gameserver.network.loginserver.LoginServerNetworkManager;
|
||||
import com.l2jmobius.gameserver.network.telnet.TelnetServer;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
import com.l2jmobius.gameserver.taskmanager.KnownListUpdateTaskManager;
|
||||
import com.l2jmobius.gameserver.taskmanager.TaskManager;
|
||||
import com.l2jmobius.loginserver.network.util.IPv4Filter;
|
||||
import com.l2jmobius.status.Status;
|
||||
|
||||
public final class GameServer
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(GameServer.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(GameServer.class.getName());
|
||||
|
||||
// Local Constants
|
||||
private static final String LOG_FOLDER = "log"; // Name of folder for log file
|
||||
private static final String LOG_NAME = "./log.cfg"; // Name of log file
|
||||
|
||||
private final SelectorThread<L2GameClient> _selectorThread;
|
||||
private final L2GamePacketHandler _gamePacketHandler;
|
||||
private final DeadLockDetector _deadDetectThread;
|
||||
public static GameServer gameServer;
|
||||
private static GameServer INSTANCE;
|
||||
public static final Calendar dateTimeServerStarted = Calendar.getInstance();
|
||||
|
||||
public GameServer() throws Exception
|
||||
@@ -167,7 +160,7 @@ public final class GameServer
|
||||
printSection("IdFactory");
|
||||
if (!IdFactory.getInstance().isInitialized())
|
||||
{
|
||||
_log.severe(getClass().getSimpleName() + ": Could not read object IDs from database. Please check your configuration.");
|
||||
LOGGER.severe(getClass().getSimpleName() + ": Could not read object IDs from database. Please check your configuration.");
|
||||
throw new Exception("Could not initialize the ID factory!");
|
||||
}
|
||||
|
||||
@@ -178,6 +171,9 @@ public final class GameServer
|
||||
EventDispatcher.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
printSection("Telnet");
|
||||
TelnetServer.getInstance();
|
||||
|
||||
printSection("World");
|
||||
// start game time control early
|
||||
GameTimeController.init();
|
||||
@@ -233,7 +229,7 @@ public final class GameServer
|
||||
|
||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||
{
|
||||
_log.info("PremiumManager: Premium system is enabled.");
|
||||
LOGGER.info("PremiumManager: Premium system is enabled.");
|
||||
PremiumManager.getInstance();
|
||||
}
|
||||
|
||||
@@ -295,12 +291,13 @@ public final class GameServer
|
||||
|
||||
try
|
||||
{
|
||||
_log.info("Loading server scripts...");
|
||||
LOGGER.info("Loading server scripts...");
|
||||
ScriptEngineManager.getInstance().executeMasterHandler();
|
||||
ScriptEngineManager.getInstance().executeScriptList();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Failed to execute script list!", e);
|
||||
LOGGER.log(Level.WARNING, "Failed to execute script list!", e);
|
||||
}
|
||||
|
||||
SpawnTable.getInstance().load();
|
||||
@@ -340,7 +337,7 @@ public final class GameServer
|
||||
SevenSignsFestival.getInstance();
|
||||
AutoSpawnHandler.getInstance();
|
||||
|
||||
_log.info("AutoSpawnHandler: Loaded " + AutoSpawnHandler.getInstance().size() + " handlers in total.");
|
||||
LOGGER.info("AutoSpawnHandler: Loaded " + AutoSpawnHandler.getInstance().size() + " handlers in total.");
|
||||
|
||||
if (Config.L2JMOD_ALLOW_WEDDING)
|
||||
{
|
||||
@@ -365,7 +362,7 @@ public final class GameServer
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
|
||||
|
||||
_log.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
|
||||
LOGGER.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
|
||||
|
||||
TvTManager.getInstance();
|
||||
KnownListUpdateTaskManager.getInstance();
|
||||
@@ -375,6 +372,11 @@ public final class GameServer
|
||||
OfflineTradersTable.getInstance().restoreOfflineTraders();
|
||||
}
|
||||
|
||||
if (Config.SERVER_RESTART_SCHEDULE_ENABLED)
|
||||
{
|
||||
ServerRestartManager.getInstance();
|
||||
}
|
||||
|
||||
if (Config.DEADLOCK_DETECTOR)
|
||||
{
|
||||
_deadDetectThread = new DeadLockDetector();
|
||||
@@ -387,55 +389,43 @@ public final class GameServer
|
||||
}
|
||||
System.gc();
|
||||
final long totalMem = Runtime.getRuntime().maxMemory() / 1048576;
|
||||
_log.info(getClass().getSimpleName() + ": Started, using " + getUsedMemoryMB() + " of " + totalMem + " MB total memory.");
|
||||
_log.info(getClass().getSimpleName() + ": Geodata use " + geodataMemory + " MB of memory.");
|
||||
_log.info(getClass().getSimpleName() + ": Maximum number of connected players is " + Config.MAXIMUM_ONLINE_USERS + ".");
|
||||
_log.info(getClass().getSimpleName() + ": Server loaded in " + ((System.currentTimeMillis() - serverLoadStart) / 1000) + " seconds.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Started, using " + getUsedMemoryMB() + " of " + totalMem + " MB total memory.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Geodata use " + geodataMemory + " MB of memory.");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Maximum number of connected players is " + Config.MAXIMUM_ONLINE_USERS + ".");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Server loaded in " + ((System.currentTimeMillis() - serverLoadStart) / 1000) + " seconds.");
|
||||
|
||||
final SelectorConfig sc = new SelectorConfig();
|
||||
sc.MAX_READ_PER_PASS = Config.MMO_MAX_READ_PER_PASS;
|
||||
sc.MAX_SEND_PER_PASS = Config.MMO_MAX_SEND_PER_PASS;
|
||||
sc.SLEEP_TIME = Config.MMO_SELECTOR_SLEEP_TIME;
|
||||
sc.HELPER_BUFFER_COUNT = Config.MMO_HELPER_BUFFER_COUNT;
|
||||
sc.TCP_NODELAY = Config.MMO_TCP_NODELAY;
|
||||
ClientNetworkManager.getInstance().start();
|
||||
|
||||
_gamePacketHandler = new L2GamePacketHandler();
|
||||
_selectorThread = new SelectorThread<>(sc, _gamePacketHandler, _gamePacketHandler, _gamePacketHandler, new IPv4Filter());
|
||||
|
||||
InetAddress bindAddress = null;
|
||||
if (!Config.GAMESERVER_HOSTNAME.equals("*"))
|
||||
if (Boolean.getBoolean("newLoginServer"))
|
||||
{
|
||||
try
|
||||
LoginServerNetworkManager.getInstance().connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
bindAddress = InetAddress.getByName(Config.GAMESERVER_HOSTNAME);
|
||||
}
|
||||
catch (UnknownHostException e1)
|
||||
{
|
||||
_log.log(Level.SEVERE, getClass().getSimpleName() + ": WARNING: The GameServer bind address is invalid, using all avaliable IPs! Reason: " + e1.getMessage(), e1);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_selectorThread.openServerSocket(bindAddress, Config.PORT_GAME);
|
||||
_selectorThread.start();
|
||||
_log.log(Level.INFO, getClass().getSimpleName() + ": is now listening on: " + Config.GAMESERVER_HOSTNAME + ":" + Config.PORT_GAME);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.log(Level.SEVERE, getClass().getSimpleName() + ": FATAL: Failed to open server socket. Reason: " + e.getMessage(), e);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (Config.SERVER_RESTART_SCHEDULE_ENABLED)
|
||||
{
|
||||
ServerRestartManager.getInstance();
|
||||
}
|
||||
|
||||
LoginServerThread.getInstance().start();
|
||||
}
|
||||
|
||||
Toolkit.getDefaultToolkit().beep();
|
||||
}
|
||||
|
||||
public long getStartedTime()
|
||||
{
|
||||
return ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
}
|
||||
|
||||
public String getUptime()
|
||||
{
|
||||
final long uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000;
|
||||
final long hours = uptime / 3600;
|
||||
final long mins = (uptime - (hours * 3600)) / 60;
|
||||
final long secs = ((uptime - (hours * 3600)) - (mins * 60));
|
||||
if (hours > 0)
|
||||
{
|
||||
return hours + "hrs " + mins + "mins " + secs + "secs";
|
||||
}
|
||||
return mins + "mins " + secs + "secs";
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
Server.serverMode = Server.MODE_GAMESERVER;
|
||||
@@ -455,12 +445,8 @@ public final class GameServer
|
||||
Config.load();
|
||||
printSection("Database");
|
||||
DatabaseFactory.getInstance();
|
||||
gameServer = new GameServer();
|
||||
|
||||
if (Config.IS_TELNET_ENABLED)
|
||||
{
|
||||
new Status(Server.serverMode).start();
|
||||
}
|
||||
INSTANCE = new GameServer();
|
||||
}
|
||||
|
||||
public long getUsedMemoryMB()
|
||||
@@ -468,16 +454,6 @@ public final class GameServer
|
||||
return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576;
|
||||
}
|
||||
|
||||
public SelectorThread<L2GameClient> getSelectorThread()
|
||||
{
|
||||
return _selectorThread;
|
||||
}
|
||||
|
||||
public L2GamePacketHandler getL2GamePacketHandler()
|
||||
{
|
||||
return _gamePacketHandler;
|
||||
}
|
||||
|
||||
public DeadLockDetector getDeadLockDetectorThread()
|
||||
{
|
||||
return _deadDetectThread;
|
||||
@@ -490,6 +466,11 @@ public final class GameServer
|
||||
{
|
||||
s = "-" + s;
|
||||
}
|
||||
_log.info(s);
|
||||
LOGGER.info(s);
|
||||
}
|
||||
|
||||
public static GameServer getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@@ -36,22 +36,20 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.commons.util.crypt.NewCrypt;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.ConnectionState;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient.GameClientState;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.loginserverpackets.game.AuthRequest;
|
||||
import com.l2jmobius.gameserver.network.loginserverpackets.game.BlowFishKey;
|
||||
@@ -78,8 +76,8 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class LoginServerThread extends Thread
|
||||
{
|
||||
protected static final Logger _log = Logger.getLogger(LoginServerThread.class.getName());
|
||||
protected static final Logger _logAccounting = Logger.getLogger("accounting");
|
||||
protected static final Logger LOGGER = Logger.getLogger(LoginServerThread.class.getName());
|
||||
protected static final Logger ACCOUNTING_LOGGER = Logger.getLogger("accounting");
|
||||
|
||||
/** @see com.l2jmobius.loginserver.L2LoginServer#PROTOCOL_REV */
|
||||
private static final int REVISION = 0x0106;
|
||||
@@ -104,7 +102,7 @@ public class LoginServerThread extends Thread
|
||||
private int _requestID;
|
||||
private final boolean _reserveHost;
|
||||
private int _maxPlayer;
|
||||
private final List<WaitingClient> _waitingClients;
|
||||
private final Set<WaitingClient> _waitingClients = ConcurrentHashMap.newKeySet();
|
||||
private final Map<String, L2GameClient> _accountsInGameServer = new ConcurrentHashMap<>();
|
||||
private int _status;
|
||||
private String _serverName;
|
||||
@@ -134,10 +132,18 @@ public class LoginServerThread extends Thread
|
||||
_reserveHost = Config.RESERVE_HOST_ON_LOGIN;
|
||||
_subnets = Config.GAME_SERVER_SUBNETS;
|
||||
_hosts = Config.GAME_SERVER_HOSTS;
|
||||
_waitingClients = new CopyOnWriteArrayList<>();
|
||||
_maxPlayer = Config.MAXIMUM_ONLINE_USERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single instance of LoginServerThread.
|
||||
* @return single instance of LoginServerThread
|
||||
*/
|
||||
public static LoginServerThread getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@@ -150,18 +156,13 @@ public class LoginServerThread extends Thread
|
||||
try
|
||||
{
|
||||
// Connection
|
||||
_log.info("Connecting to login on " + _hostname + ":" + _port);
|
||||
LOGGER.info(getClass().getSimpleName() + ": Connecting to login on " + _hostname + ":" + _port);
|
||||
_loginSocket = new Socket(_hostname, _port);
|
||||
final InputStream in = _loginSocket.getInputStream();
|
||||
_out = new BufferedOutputStream(_loginSocket.getOutputStream());
|
||||
|
||||
// init Blowfish
|
||||
final byte[] blowfishKey = CommonUtil.generateHex(40);
|
||||
// Protect the new blowfish key what cannot begin with zero
|
||||
if (blowfishKey[0] == 0)
|
||||
{
|
||||
blowfishKey[0] = (byte) Rnd.get(32, 64);
|
||||
}
|
||||
_blowfish = new NewCrypt("_;v.]05-31!|+-%xT!^[$\00");
|
||||
while (!isInterrupted())
|
||||
{
|
||||
@@ -171,7 +172,7 @@ public class LoginServerThread extends Thread
|
||||
|
||||
if (lengthHi < 0)
|
||||
{
|
||||
_log.finer("LoginServerThread: Login terminated the connection.");
|
||||
LOGGER.finer(getClass().getSimpleName() + ": Login terminated the connection.");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -189,7 +190,7 @@ public class LoginServerThread extends Thread
|
||||
|
||||
if (receivedBytes != (length - 2))
|
||||
{
|
||||
_log.warning("Incomplete Packet is sent to the server, closing connection.(LS)");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Incomplete Packet is sent to the server, closing connection.(LS)");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -199,11 +200,12 @@ public class LoginServerThread extends Thread
|
||||
|
||||
if (!checksumOk)
|
||||
{
|
||||
_log.warning("Incorrect packet checksum, ignoring packet (LS)");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Incorrect packet checksum, ignoring packet (LS)");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (incoming[0] & 0xff)
|
||||
final int packetType = incoming[0] & 0xff;
|
||||
switch (packetType)
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
@@ -211,7 +213,7 @@ public class LoginServerThread extends Thread
|
||||
if (init.getRevision() != REVISION)
|
||||
{
|
||||
// TODO: revision mismatch
|
||||
_log.warning("/!\\ Revision mismatch between LS and GS /!\\");
|
||||
LOGGER.warning("/!\\ Revision mismatch between LS and GS /!\\");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -219,11 +221,14 @@ public class LoginServerThread extends Thread
|
||||
|
||||
try
|
||||
{
|
||||
publicKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(new BigInteger(init.getRSAKey()), RSAKeyGenParameterSpec.F4));
|
||||
final KeyFactory kfac = KeyFactory.getInstance("RSA");
|
||||
final BigInteger modulus = new BigInteger(init.getRSAKey());
|
||||
final RSAPublicKeySpec kspec1 = new RSAPublicKeySpec(modulus, RSAKeyGenParameterSpec.F4);
|
||||
publicKey = (RSAPublicKey) kfac.generatePublic(kspec1);
|
||||
}
|
||||
catch (GeneralSecurityException e)
|
||||
{
|
||||
_log.warning("Trouble while init the public key send by login");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Trouble while init the public key send by login");
|
||||
break;
|
||||
}
|
||||
// send the blowfish key through the rsa encryption
|
||||
@@ -236,7 +241,7 @@ public class LoginServerThread extends Thread
|
||||
case 0x01:
|
||||
{
|
||||
final LoginServerFail lsf = new LoginServerFail(incoming);
|
||||
_log.info("Damn! Registeration Failed: " + lsf.getReasonString());
|
||||
LOGGER.info(getClass().getSimpleName() + ": Damn! Registeration Failed: " + lsf.getReasonString());
|
||||
// login will close the connection here
|
||||
break;
|
||||
}
|
||||
@@ -246,14 +251,39 @@ public class LoginServerThread extends Thread
|
||||
final int serverID = aresp.getServerId();
|
||||
_serverName = aresp.getServerName();
|
||||
Config.saveHexid(serverID, hexToString(_hexID));
|
||||
_log.info("Registered on login as Server " + serverID + " : " + _serverName);
|
||||
LOGGER.info(getClass().getSimpleName() + ": Registered on login as Server " + serverID + ": " + _serverName);
|
||||
final ServerStatus st = new ServerStatus();
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_SQUARE_BRACKET, Config.SERVER_LIST_BRACKET ? ServerStatus.ON : ServerStatus.OFF);
|
||||
if (Config.SERVER_LIST_BRACKET)
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_SQUARE_BRACKET, ServerStatus.ON);
|
||||
}
|
||||
else
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_SQUARE_BRACKET, ServerStatus.OFF);
|
||||
}
|
||||
st.addAttribute(ServerStatus.SERVER_TYPE, Config.SERVER_LIST_TYPE);
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_STATUS, Config.SERVER_GMONLY ? ServerStatus.STATUS_GM_ONLY : ServerStatus.STATUS_AUTO);
|
||||
st.addAttribute(ServerStatus.SERVER_AGE, Config.SERVER_LIST_AGE == 15 ? ServerStatus.SERVER_AGE_15 : Config.SERVER_LIST_AGE == 18 ? ServerStatus.SERVER_AGE_18 : ServerStatus.SERVER_AGE_ALL);
|
||||
if (Config.SERVER_GMONLY)
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_STATUS, ServerStatus.STATUS_GM_ONLY);
|
||||
}
|
||||
else
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_LIST_STATUS, ServerStatus.STATUS_AUTO);
|
||||
}
|
||||
if (Config.SERVER_LIST_AGE == 15)
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_AGE, ServerStatus.SERVER_AGE_15);
|
||||
}
|
||||
else if (Config.SERVER_LIST_AGE == 18)
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_AGE, ServerStatus.SERVER_AGE_18);
|
||||
}
|
||||
else
|
||||
{
|
||||
st.addAttribute(ServerStatus.SERVER_AGE, ServerStatus.SERVER_AGE_ALL);
|
||||
}
|
||||
sendPacket(st);
|
||||
if (L2World.getInstance().getAllPlayersCount() > 0)
|
||||
if (L2World.getInstance().getPlayers().size() > 0)
|
||||
{
|
||||
final List<String> playerList = new ArrayList<>();
|
||||
for (L2PcInstance player : L2World.getInstance().getPlayers())
|
||||
@@ -285,15 +315,15 @@ public class LoginServerThread extends Thread
|
||||
{
|
||||
final PlayerInGame pig = new PlayerInGame(par.getAccount());
|
||||
sendPacket(pig);
|
||||
wcToRemove.gameClient.setState(GameClientState.AUTHED);
|
||||
wcToRemove.gameClient.setConnectionState(ConnectionState.AUTHENTICATED);
|
||||
wcToRemove.gameClient.setSessionId(wcToRemove.session);
|
||||
final CharSelectionInfo cl = new CharSelectionInfo(wcToRemove.account, wcToRemove.gameClient.getSessionId().playOkID1);
|
||||
wcToRemove.gameClient.getConnection().sendPacket(cl);
|
||||
wcToRemove.gameClient.sendPacket(cl);
|
||||
wcToRemove.gameClient.setCharSelection(cl.getCharInfo());
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("Session key is not correct. Closing connection for account " + wcToRemove.account + ".");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Session key is not correct. Closing connection for account " + wcToRemove.account);
|
||||
// wcToRemove.gameClient.getConnection().sendPacket(new LoginFail(LoginFail.SYSTEM_ERROR_LOGIN_LATER));
|
||||
wcToRemove.gameClient.close(new LoginFail(LoginFail.SYSTEM_ERROR_LOGIN_LATER));
|
||||
_accountsInGameServer.remove(wcToRemove.account);
|
||||
@@ -324,15 +354,15 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (UnknownHostException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": ", e);
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
_log.warning("LoginServer not avaible, trying to reconnect...");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": LoginServer not avaible, trying to reconnect...");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Disconnected from Login, Trying to reconnect: " + e.getMessage(), e);
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Disconnected from Login, Trying to reconnect: ", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -380,7 +410,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.warning("Error while sending player auth request");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,7 +454,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
_log.warning("Error while sending logout packet to login");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -530,18 +560,11 @@ public class LoginServerThread extends Thread
|
||||
public void doKickPlayer(String account)
|
||||
{
|
||||
final L2GameClient client = _accountsInGameServer.get(account);
|
||||
if (client == null)
|
||||
if (client != null)
|
||||
{
|
||||
return;
|
||||
ACCOUNTING_LOGGER.info("Kicked by login, " + client);
|
||||
client.close(SystemMessage.getSystemMessage(SystemMessageId.ANOTHER_PERSON_HAS_LOGGED_IN_WITH_THE_SAME_ACCOUNT));
|
||||
}
|
||||
final LogRecord record = new LogRecord(Level.WARNING, "Kicked by login");
|
||||
record.setParameters(new Object[]
|
||||
{
|
||||
client
|
||||
});
|
||||
_logAccounting.log(record);
|
||||
client.setAditionalClosePacket(SystemMessage.getSystemMessage(SystemMessageId.ANOTHER_PERSON_HAS_LOGGED_IN_WITH_THE_SAME_ACCOUNT));
|
||||
client.closeNow();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -550,6 +573,7 @@ public class LoginServerThread extends Thread
|
||||
*/
|
||||
private void getCharsOnServer(String account)
|
||||
{
|
||||
|
||||
int chars = 0;
|
||||
final List<Long> charToDel = new ArrayList<>();
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
@@ -571,7 +595,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Exception: getCharsOnServer: " + e.getMessage(), e);
|
||||
}
|
||||
|
||||
final ReplyCharacters rec = new ReplyCharacters(account, chars, charToDel);
|
||||
@@ -800,15 +824,6 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single instance of LoginServerThread.
|
||||
* @return single instance of LoginServerThread
|
||||
*/
|
||||
public static LoginServerThread getInstance()
|
||||
{
|
||||
return SingletonHolder._instance;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final LoginServerThread _instance = new LoginServerThread();
|
||||
|
@@ -39,6 +39,8 @@ import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Hero;
|
||||
import com.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jmobius.gameserver.network.ClientNetworkManager;
|
||||
import com.l2jmobius.gameserver.network.EventLoopGroupManager;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||
@@ -53,7 +55,7 @@ import com.l2jmobius.gameserver.util.Broadcast;
|
||||
*/
|
||||
public class Shutdown extends Thread
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(Shutdown.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(Shutdown.class.getName());
|
||||
private static Shutdown _counterInstance = null;
|
||||
|
||||
private int _secondsShut;
|
||||
@@ -83,7 +85,7 @@ public class Shutdown extends Thread
|
||||
|
||||
public void startTelnetShutdown(String IP, int seconds, boolean restart)
|
||||
{
|
||||
_log.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
|
||||
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
|
||||
|
||||
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
|
||||
|
||||
@@ -131,7 +133,7 @@ public class Shutdown extends Thread
|
||||
*/
|
||||
public void telnetAbort(String IP)
|
||||
{
|
||||
_log.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
|
||||
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
|
||||
|
||||
if (_counterInstance != null)
|
||||
{
|
||||
@@ -182,18 +184,18 @@ public class Shutdown extends Thread
|
||||
if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS && !Config.STORE_OFFLINE_TRADE_IN_REALTIME)
|
||||
{
|
||||
OfflineTradersTable.getInstance().storeOffliners();
|
||||
_log.info("Offline Traders Table: Offline shops stored(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Offline Traders Table: Offline shops stored(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
_log.log(Level.WARNING, "Error saving offline shops.", t);
|
||||
LOGGER.log(Level.WARNING, "Error saving offline shops.", t);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
disconnectAllCharacters();
|
||||
_log.info("All players disconnected and saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("All players disconnected and saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -204,7 +206,7 @@ public class Shutdown extends Thread
|
||||
try
|
||||
{
|
||||
GameTimeController.getInstance().stopTimer();
|
||||
_log.info("Game Time Controller: Timer stopped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Game Time Controller: Timer stopped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -215,7 +217,7 @@ public class Shutdown extends Thread
|
||||
try
|
||||
{
|
||||
ThreadPool.shutdown();
|
||||
_log.info("Thread Pool Manager: Manager has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Thread Pool Manager: Manager has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -225,7 +227,7 @@ public class Shutdown extends Thread
|
||||
try
|
||||
{
|
||||
LoginServerThread.getInstance().interrupt();
|
||||
_log.info("Login Server Thread: Thread interruped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Login Server Thread: Thread interruped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -239,8 +241,9 @@ public class Shutdown extends Thread
|
||||
// saveData sends messages to exit players, so shutdown selector after it
|
||||
try
|
||||
{
|
||||
GameServer.gameServer.getSelectorThread().shutdown();
|
||||
_log.info("Game Server: Selector thread has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
ClientNetworkManager.getInstance().stop();
|
||||
EventLoopGroupManager.getInstance().shutdown();
|
||||
LOGGER.info("Game Server: Selector thread has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -251,7 +254,7 @@ public class Shutdown extends Thread
|
||||
try
|
||||
{
|
||||
DatabaseFactory.getInstance().close();
|
||||
_log.info("Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Database Factory: Database connection has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -267,14 +270,14 @@ public class Shutdown extends Thread
|
||||
Runtime.getRuntime().halt(0);
|
||||
}
|
||||
|
||||
_log.info("The server has been successfully shut down in " + (tc1.getEstimatedTime() / 1000) + "seconds.");
|
||||
LOGGER.info("The server has been successfully shut down in " + (tc1.getEstimatedTime() / 1000) + "seconds.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// gm shutdown: send warnings and then call exit to start shutdown sequence
|
||||
countdown();
|
||||
// last point where logging is operational :(
|
||||
_log.warning("GM shutdown countdown is over. " + MODE_TEXT[_shutdownMode] + " NOW!");
|
||||
LOGGER.warning("GM shutdown countdown is over. " + MODE_TEXT[_shutdownMode] + " NOW!");
|
||||
switch (_shutdownMode)
|
||||
{
|
||||
case GM_SHUTDOWN:
|
||||
@@ -310,11 +313,11 @@ public class Shutdown extends Thread
|
||||
|
||||
if (activeChar != null)
|
||||
{
|
||||
_log.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
|
||||
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("Server scheduled restart issued shutdown command. Restart in " + seconds + " seconds!");
|
||||
LOGGER.warning("Server scheduled restart issued shutdown command. Restart in " + seconds + " seconds!");
|
||||
}
|
||||
|
||||
if (_shutdownMode > 0)
|
||||
@@ -363,7 +366,7 @@ public class Shutdown extends Thread
|
||||
*/
|
||||
public void abort(L2PcInstance activeChar)
|
||||
{
|
||||
_log.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
|
||||
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
|
||||
if (_counterInstance != null)
|
||||
{
|
||||
_counterInstance._abort();
|
||||
@@ -508,17 +511,17 @@ public class Shutdown extends Thread
|
||||
{
|
||||
case SIGTERM:
|
||||
{
|
||||
_log.info("SIGTERM received. Shutting down NOW!");
|
||||
LOGGER.info("SIGTERM received. Shutting down NOW!");
|
||||
break;
|
||||
}
|
||||
case GM_SHUTDOWN:
|
||||
{
|
||||
_log.info("GM shutdown received. Shutting down NOW!");
|
||||
LOGGER.info("GM shutdown received. Shutting down NOW!");
|
||||
break;
|
||||
}
|
||||
case GM_RESTART:
|
||||
{
|
||||
_log.info("GM restart received. Restarting NOW!");
|
||||
LOGGER.info("GM restart received. Restarting NOW!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -528,72 +531,72 @@ public class Shutdown extends Thread
|
||||
if (!SevenSigns.getInstance().isSealValidationPeriod())
|
||||
{
|
||||
SevenSignsFestival.getInstance().saveFestivalData(false);
|
||||
_log.info("SevenSignsFestival: Festival data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("SevenSignsFestival: Festival data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
|
||||
// Save Seven Signs data before closing. :)
|
||||
SevenSigns.getInstance().saveSevenSignsData();
|
||||
_log.info("SevenSigns: Seven Signs data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("SevenSigns: Seven Signs data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
SevenSigns.getInstance().saveSevenSignsStatus();
|
||||
_log.info("SevenSigns: Seven Signs status saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("SevenSigns: Seven Signs status saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save all raidboss and GrandBoss status ^_^
|
||||
RaidBossSpawnManager.getInstance().cleanUp();
|
||||
_log.info("RaidBossSpawnManager: All raidboss info saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("RaidBossSpawnManager: All raidboss info saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
GrandBossManager.getInstance().cleanUp();
|
||||
_log.info("GrandBossManager: All Grand Boss info saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("GrandBossManager: All Grand Boss info saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
ItemAuctionManager.getInstance().shutdown();
|
||||
_log.info("Item Auction Manager: All tasks stopped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Item Auction Manager: All tasks stopped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
Olympiad.getInstance().saveOlympiadStatus();
|
||||
_log.info("Olympiad System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Olympiad System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
Hero.getInstance().shutdown();
|
||||
_log.info("Hero System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Hero System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
ClanTable.getInstance().storeClanScore();
|
||||
_log.info("Clan System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Clan System: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save Cursed Weapons data before closing.
|
||||
CursedWeaponsManager.getInstance().saveData();
|
||||
_log.info("Cursed Weapons Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Cursed Weapons Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save all manor data
|
||||
if (!Config.ALT_MANOR_SAVE_ALL_ACTIONS)
|
||||
{
|
||||
CastleManorManager.getInstance().storeMe();
|
||||
_log.info("Castle Manor Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Castle Manor Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
|
||||
CHSiegeManager.getInstance().onServerShutDown();
|
||||
_log.info("CHSiegeManager: Siegable hall attacker lists saved!");
|
||||
LOGGER.info("CHSiegeManager: Siegable hall attacker lists saved!");
|
||||
|
||||
// Save all global (non-player specific) Quest data that needs to persist after reboot
|
||||
QuestManager.getInstance().save();
|
||||
_log.info("Quest Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Quest Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save all global variables data
|
||||
GlobalVariablesManager.getInstance().storeMe();
|
||||
_log.info("Global Variables Manager: Variables saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Global Variables Manager: Variables saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
|
||||
// Save Fishing tournament data
|
||||
if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
|
||||
{
|
||||
FishingChampionshipManager.getInstance().shutdown();
|
||||
_log.info("Fishing Championship data has been saved.");
|
||||
LOGGER.info("Fishing Championship data has been saved.");
|
||||
}
|
||||
|
||||
// Save items on ground before closing
|
||||
if (Config.SAVE_DROPPED_ITEM)
|
||||
{
|
||||
ItemsOnGroundManager.getInstance().saveInDb();
|
||||
_log.info("Items On Ground Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Items On Ground Manager: Data saved(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
ItemsOnGroundManager.getInstance().cleanUp();
|
||||
_log.info("Items On Ground Manager: Cleaned up(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
LOGGER.info("Items On Ground Manager: Cleaned up(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
|
||||
// Save bot reports to database
|
||||
if (Config.BOTREPORT_ENABLE)
|
||||
{
|
||||
BotReportTable.getInstance().saveReportedCharData();
|
||||
_log.info("Bot Report Table: Successfully saved reports to database!");
|
||||
LOGGER.info("Bot Report Table: Successfully saved reports to database!");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -632,7 +635,7 @@ public class Shutdown extends Thread
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
_log.log(Level.WARNING, "Failed logout char " + player, t);
|
||||
LOGGER.log(Level.WARNING, "Failed logout char " + player, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -189,14 +189,14 @@ public class CharSummonTable
|
||||
final int curMp = rs.getInt("curMp");
|
||||
final int time = rs.getInt("time");
|
||||
|
||||
removeServitor(activeChar);
|
||||
skill = SkillData.getInstance().getSkill(skillId, activeChar.getSkillLevel(skillId));
|
||||
if (skill == null)
|
||||
{
|
||||
removeServitor(activeChar);
|
||||
return;
|
||||
}
|
||||
|
||||
skill.applyEffects(activeChar, activeChar);
|
||||
|
||||
if (activeChar.hasServitor())
|
||||
{
|
||||
final L2ServitorInstance summon = (L2ServitorInstance) activeChar.getSummon();
|
||||
|
@@ -33,7 +33,6 @@ import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.TradeItem;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient;
|
||||
import com.l2jmobius.gameserver.network.L2GameClient.GameClientState;
|
||||
|
||||
public class OfflineTradersTable
|
||||
{
|
||||
@@ -187,14 +186,13 @@ public class OfflineTradersTable
|
||||
|
||||
try
|
||||
{
|
||||
final L2GameClient client = new L2GameClient(null);
|
||||
final L2GameClient client = new L2GameClient();
|
||||
client.setDetached(true);
|
||||
player = L2PcInstance.load(rs.getInt("charId"));
|
||||
client.setActiveChar(player);
|
||||
player.setOnlineStatus(true, false);
|
||||
client.setAccountName(player.getAccountNamePlayer());
|
||||
L2World.getInstance().addPlayerToWorld(player);
|
||||
client.setState(GameClientState.IN_GAME);
|
||||
player.setClient(client);
|
||||
player.setOfflineStartTime(time);
|
||||
player.spawnMe(player.getX(), player.getY(), player.getZ());
|
||||
|
@@ -35,7 +35,7 @@ import com.l2jmobius.gameserver.model.L2AdminCommandAccessRight;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -317,7 +317,7 @@ public final class AdminData implements IGameXmlReader
|
||||
* Broadcast to GMs.
|
||||
* @param packet the packet
|
||||
*/
|
||||
public void broadcastToGMs(L2GameServerPacket packet)
|
||||
public void broadcastToGMs(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2PcInstance gm : getAllGms(true))
|
||||
{
|
||||
|
@@ -51,7 +51,7 @@ import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
*/
|
||||
public final class BotReportTable
|
||||
{
|
||||
// Zoey76: TODO: Split XML parsing from SQL operations, use IXmlReader instead of SAXParser.
|
||||
// Zoey76: TODO: Split XML parsing from SQL operations, use IGameXmlReader instead of SAXParser.
|
||||
private static final Logger LOGGER = Logger.getLogger(BotReportTable.class.getName());
|
||||
|
||||
private static final int COLUMN_BOT_ID = 1;
|
||||
@@ -443,7 +443,7 @@ public final class BotReportTable
|
||||
*/
|
||||
private static int hashIp(L2PcInstance player)
|
||||
{
|
||||
final String con = player.getClient().getConnection().getInetAddress().getHostAddress();
|
||||
final String con = player.getClient().getConnectionAddress().getHostAddress();
|
||||
final String[] rawByte = con.split("\\.");
|
||||
final int[] rawIp = new int[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
@@ -26,7 +26,7 @@ import com.l2jmobius.gameserver.model.VehiclePathPoint;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2BoatInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2CharTemplate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
public class BoatManager
|
||||
{
|
||||
@@ -151,7 +151,7 @@ public class BoatManager
|
||||
* @param point2
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastPacket(VehiclePathPoint point1, VehiclePathPoint point2, L2GameServerPacket packet)
|
||||
public void broadcastPacket(VehiclePathPoint point1, VehiclePathPoint point2, IClientOutgoingPacket packet)
|
||||
{
|
||||
broadcastPacketsToPlayers(point1, point2, packet);
|
||||
}
|
||||
@@ -162,25 +162,25 @@ public class BoatManager
|
||||
* @param point2
|
||||
* @param packets
|
||||
*/
|
||||
public void broadcastPackets(VehiclePathPoint point1, VehiclePathPoint point2, L2GameServerPacket... packets)
|
||||
public void broadcastPackets(VehiclePathPoint point1, VehiclePathPoint point2, IClientOutgoingPacket... packets)
|
||||
{
|
||||
broadcastPacketsToPlayers(point1, point2, packets);
|
||||
}
|
||||
|
||||
private void broadcastPacketsToPlayers(VehiclePathPoint point1, VehiclePathPoint point2, L2GameServerPacket... packets)
|
||||
private void broadcastPacketsToPlayers(VehiclePathPoint point1, VehiclePathPoint point2, IClientOutgoingPacket... packets)
|
||||
{
|
||||
for (L2PcInstance player : L2World.getInstance().getPlayers())
|
||||
{
|
||||
if (Math.hypot(player.getX() - point1.getX(), player.getY() - point1.getY()) < Config.BOAT_BROADCAST_RADIUS)
|
||||
{
|
||||
for (L2GameServerPacket p : packets)
|
||||
for (IClientOutgoingPacket p : packets)
|
||||
{
|
||||
player.sendPacket(p);
|
||||
}
|
||||
}
|
||||
else if (Math.hypot(player.getX() - point2.getX(), player.getY() - point2.getY()) < Config.BOAT_BROADCAST_RADIUS)
|
||||
{
|
||||
for (L2GameServerPacket p : packets)
|
||||
for (IClientOutgoingPacket p : packets)
|
||||
{
|
||||
player.sendPacket(p);
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Duel;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
public final class DuelManager
|
||||
{
|
||||
@@ -173,7 +173,7 @@ public final class DuelManager
|
||||
* @param player
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastToOppositTeam(L2PcInstance player, L2GameServerPacket packet)
|
||||
public void broadcastToOppositTeam(L2PcInstance player, IClientOutgoingPacket packet)
|
||||
{
|
||||
if ((player == null) || !player.isInDuel())
|
||||
{
|
||||
|
@@ -56,7 +56,7 @@ import com.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
@@ -1407,7 +1407,7 @@ public final class TerritoryWarManager implements Siegable
|
||||
}
|
||||
}
|
||||
|
||||
public void announceToParticipants(L2GameServerPacket sm, int exp, int sp)
|
||||
public void announceToParticipants(IClientOutgoingPacket sm, int exp, int sp)
|
||||
{
|
||||
// broadcast to clan members
|
||||
for (Territory ter : _territoryList.values())
|
||||
|
@@ -24,7 +24,7 @@ import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -97,7 +97,7 @@ public abstract class AbstractPlayerGroup
|
||||
* Broadcast a packet to every member of this group.
|
||||
* @param packet the packet to broadcast
|
||||
*/
|
||||
public void broadcastPacket(L2GameServerPacket packet)
|
||||
public void broadcastPacket(IClientOutgoingPacket packet)
|
||||
{
|
||||
forEachMember(m ->
|
||||
{
|
||||
|
@@ -23,7 +23,7 @@ import com.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.BlockCheckerEngine;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ public final class ArenaParticipantsHolder
|
||||
return _bluePlayers.size();
|
||||
}
|
||||
|
||||
public void broadCastPacketToTeam(L2GameServerPacket packet)
|
||||
public void broadCastPacketToTeam(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2PcInstance p : _redPlayers)
|
||||
{
|
||||
|
@@ -63,8 +63,8 @@ import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBrExtraUserInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExSubPledgeSkillAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeReceiveSubPledgeCreated;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowInfoUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
|
||||
@@ -1534,7 +1534,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToOnlineAllyMembers(L2GameServerPacket packet)
|
||||
public void broadcastToOnlineAllyMembers(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2Clan clan : ClanTable.getInstance().getClanAllies(getAllyId()))
|
||||
{
|
||||
@@ -1542,7 +1542,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToOnlineMembers(L2GameServerPacket packet)
|
||||
public void broadcastToOnlineMembers(IClientOutgoingPacket packet)
|
||||
{
|
||||
for (L2ClanMember member : _members.values())
|
||||
{
|
||||
@@ -1564,7 +1564,7 @@ public class L2Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToOtherOnlineMembers(L2GameServerPacket packet, L2PcInstance player)
|
||||
public void broadcastToOtherOnlineMembers(IClientOutgoingPacket packet, L2PcInstance player)
|
||||
{
|
||||
for (L2ClanMember member : _members.values())
|
||||
{
|
||||
|
@@ -47,7 +47,7 @@ import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExSendUIEvent;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
@@ -328,7 +328,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
|
||||
|
||||
public abstract void sendInfo(L2PcInstance activeChar);
|
||||
|
||||
public void sendPacket(L2GameServerPacket mov)
|
||||
public void sendPacket(IClientOutgoingPacket... packets)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ExOpenMPCC;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowDelete;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExSetPartyLooting;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PartyMemberPosition;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PartySmallWindowAdd;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PartySmallWindowAll;
|
||||
@@ -265,7 +265,7 @@ public class L2Party extends AbstractPlayerGroup
|
||||
* @param player
|
||||
* @param msg
|
||||
*/
|
||||
public void broadcastToPartyMembers(L2PcInstance player, L2GameServerPacket msg)
|
||||
public void broadcastToPartyMembers(L2PcInstance player, IClientOutgoingPacket msg)
|
||||
{
|
||||
for (L2PcInstance member : getMembers())
|
||||
{
|
||||
|
@@ -19,7 +19,7 @@ package com.l2jmobius.gameserver.model;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.L2GameClientPacket;
|
||||
import com.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ public class L2Request
|
||||
protected L2PcInstance _partner;
|
||||
protected boolean _isRequestor;
|
||||
protected boolean _isAnswerer;
|
||||
protected L2GameClientPacket _requestPacket;
|
||||
protected IClientIncomingPacket _requestPacket;
|
||||
|
||||
public L2Request(L2PcInstance player)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ public class L2Request
|
||||
* Set the packet incomed from requester.
|
||||
* @param packet
|
||||
*/
|
||||
private synchronized void setRequestPacket(L2GameClientPacket packet)
|
||||
private synchronized void setRequestPacket(IClientIncomingPacket packet)
|
||||
{
|
||||
_requestPacket = packet;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class L2Request
|
||||
* Return the packet originally incomed from requester.
|
||||
* @return
|
||||
*/
|
||||
public L2GameClientPacket getRequestPacket()
|
||||
public IClientIncomingPacket getRequestPacket()
|
||||
{
|
||||
return _requestPacket;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class L2Request
|
||||
* @param packet
|
||||
* @return
|
||||
*/
|
||||
public synchronized boolean setRequest(L2PcInstance partner, L2GameClientPacket packet)
|
||||
public synchronized boolean setRequest(L2PcInstance partner, IClientIncomingPacket packet)
|
||||
{
|
||||
if (partner == null)
|
||||
{
|
||||
|
@@ -26,7 +26,7 @@ import com.l2jmobius.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PetitionVotePacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
@@ -136,7 +136,7 @@ public final class Petition
|
||||
return _type.toString().replace("_", " ");
|
||||
}
|
||||
|
||||
public void sendPetitionerPacket(L2GameServerPacket responsePacket)
|
||||
public void sendPetitionerPacket(IClientOutgoingPacket responsePacket)
|
||||
{
|
||||
if ((getPetitioner() == null) || !getPetitioner().isOnline())
|
||||
{
|
||||
@@ -150,7 +150,7 @@ public final class Petition
|
||||
getPetitioner().sendPacket(responsePacket);
|
||||
}
|
||||
|
||||
public void sendResponderPacket(L2GameServerPacket responsePacket)
|
||||
public void sendResponderPacket(IClientOutgoingPacket responsePacket)
|
||||
{
|
||||
if ((getResponder() == null) || !getResponder().isOnline())
|
||||
{
|
||||
|
@@ -132,8 +132,8 @@ import com.l2jmobius.gameserver.network.serverpackets.ChangeMoveType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ChangeWaitType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExRotation;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
|
||||
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.MagicSkillLaunched;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MoveToLocation;
|
||||
@@ -533,9 +533,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* In order to inform other players of state modification on the L2Character, server just need to go through _knownPlayers to send Server->Client Packet
|
||||
* @param mov
|
||||
*/
|
||||
public void broadcastPacket(L2GameServerPacket mov)
|
||||
public void broadcastPacket(IClientOutgoingPacket mov)
|
||||
{
|
||||
mov.setInvisible(isInvisible());
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
@@ -554,9 +553,8 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
* @param mov
|
||||
* @param radiusInKnownlist
|
||||
*/
|
||||
public void broadcastPacket(L2GameServerPacket mov, int radiusInKnownlist)
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, int radiusInKnownlist)
|
||||
{
|
||||
mov.setInvisible(isInvisible());
|
||||
final Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
@@ -3915,7 +3913,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
{
|
||||
getAI().notifyEvent(CtrlEvent.EVT_FINISH_CASTING); // setting back previous intention
|
||||
}
|
||||
broadcastPacket(new MagicSkillCanceld(getObjectId())); // broadcast packet to stop animations client-side
|
||||
broadcastPacket(new MagicSkillCanceled(getObjectId())); // broadcast packet to stop animations client-side
|
||||
sendPacket(ActionFailed.STATIC_PACKET); // send an "action failed" packet to the caster
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ import com.l2jmobius.gameserver.model.items.L2Weapon;
|
||||
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.L2GameServerPacket;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
|
||||
public abstract class L2Decoy extends L2Character
|
||||
@@ -49,7 +49,7 @@ public abstract class L2Decoy extends L2Character
|
||||
public void onSpawn()
|
||||
{
|
||||
super.onSpawn();
|
||||
sendPacket(new CharInfo(this));
|
||||
sendPacket(new CharInfo(this, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +59,7 @@ public abstract class L2Decoy extends L2Character
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.sendPacket(new CharInfo(this));
|
||||
player.sendPacket(new CharInfo(this, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,15 +159,15 @@ public abstract class L2Decoy extends L2Character
|
||||
@Override
|
||||
public void sendInfo(L2PcInstance activeChar)
|
||||
{
|
||||
activeChar.sendPacket(new CharInfo(this));
|
||||
activeChar.sendPacket(new CharInfo(this, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(L2GameServerPacket mov)
|
||||
public void sendPacket(IClientOutgoingPacket... packets)
|
||||
{
|
||||
if (getOwner() != null)
|
||||
{
|
||||
getOwner().sendPacket(mov);
|
||||
getOwner().sendPacket(packets);
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user