New networking.
This commit is contained in:
parent
2299fe1c72
commit
c042489655
@ -7,11 +7,6 @@
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="dist/libs/exp4j-0.4.8.jar" sourcepath="dist/libs/exp4j-0.4.8-sources.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/mariadb-java-client-2.7.5.jar" sourcepath="dist/libs/mariadb-java-client-2.7.5-sources.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-buffer-4.1.75.Final.jar" sourcepath="dist/libs/netty-buffer-4.1.75.Final-sources.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-codec-4.1.75.Final.jar" sourcepath="dist/libs/netty-codec-4.1.75.Final-sources.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-common-4.1.75.Final.jar" sourcepath="dist/libs/netty-common-4.1.75.Final-sources.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-handler-4.1.75.Final.jar" sourcepath="dist/libs/netty-handler-4.1.75.Final-sources.jar"/>
|
||||
<classpathentry kind="lib" path="dist/libs/netty-transport-4.1.75.Final.jar" sourcepath="dist/libs/netty-transport-4.1.75.Final-sources.jar"/>
|
||||
<classpathentry including="**/*.java" kind="src" path="dist/game/data/scripts"/>
|
||||
<classpathentry kind="src" path="java"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
@ -31,6 +31,49 @@ GameserverHostname = 0.0.0.0
|
||||
# Default: 7777
|
||||
GameserverPort = 7777
|
||||
|
||||
# Client pool size for reading client packets.
|
||||
# Each pool is executed on a separate thread.
|
||||
# Default: 100
|
||||
ClientReadPoolSize = 100
|
||||
|
||||
# Client pool size for executing client packets.
|
||||
# Each pool is executed on a separate thread.
|
||||
# Default: 50
|
||||
ClientExecutePoolSize = 50
|
||||
|
||||
# Expected client packet count queued by the server.
|
||||
# Default: 80
|
||||
PacketQueueLimit = 80
|
||||
|
||||
# Disconnect client when queue has reached the queue packet limit.
|
||||
# Default: False
|
||||
PacketFloodDisconnect = False
|
||||
|
||||
# Drop packets when queue has reached the queue packet limit.
|
||||
# Default: False
|
||||
PacketFloodDrop = False
|
||||
|
||||
# Log message when queue has reached the queue packet limit.
|
||||
# Default: True
|
||||
PacketFloodLogged = True
|
||||
|
||||
# Nagle's algorithm tries to conserve bandwidth by minimizing the number of segments that are sent.
|
||||
# When applications wish to decrease network latency, they can disable Nagle's algorithm (by enabling TcpNoDelay).
|
||||
# Data will be sent earlier, at the cost of an increase in bandwidth consumption.
|
||||
# Default: True (disabled)
|
||||
TcpNoDelay = True
|
||||
|
||||
# Connection timeout in milliseconds.
|
||||
# Default 800
|
||||
ConnectionTimeout = 800
|
||||
|
||||
# Packet encryption.
|
||||
# By default packets sent or received are encrypted using the Blowfish algorithm.
|
||||
# Disabling this reduces the resources needed to process any packets transfered,
|
||||
# also broadcasted packets do not need to be re-encrypted for each client sent.
|
||||
# Retail: True
|
||||
PacketEncryption = False
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Database
|
||||
@ -138,8 +181,11 @@ InstantThreadPoolCount = -1
|
||||
# Specifies how many threads will be in a single instant pool.
|
||||
ThreadsPerInstantThreadPool = 2
|
||||
|
||||
# Urgent packet thread core size.
|
||||
UrgentPacketThreadCoreSize = -1
|
||||
# Use threads to run client packets individually.
|
||||
# Less lag when using threads, but more CPU consumption.
|
||||
# Can try disabling it when server is highly populated and CPU is high.
|
||||
# Default: True
|
||||
ThreadsForClientPackets = True
|
||||
|
||||
# Use threads to decrease startup time.
|
||||
# Default: False
|
||||
|
@ -1,31 +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 GS
|
||||
# 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 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
|
||||
Port = 54321
|
||||
|
||||
# If the following is not set, a random password is generated on server startup.
|
||||
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,::1
|
||||
ListOfHosts = 127.0.0.1,localhost,::1
|
@ -33,10 +33,10 @@ import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.network.NpcStringId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.Earthquake;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillCanceld;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SpecialCamera;
|
||||
|
||||
@ -879,7 +879,7 @@ public class LastImperialTomb extends AbstractInstance
|
||||
}
|
||||
}
|
||||
|
||||
void broadcastPacket(Instance world, IClientOutgoingPacket packet)
|
||||
void broadcastPacket(Instance world, ServerPacket packet)
|
||||
{
|
||||
for (Player player : world.getPlayers())
|
||||
{
|
||||
@ -890,7 +890,7 @@ public class LastImperialTomb extends AbstractInstance
|
||||
}
|
||||
}
|
||||
|
||||
private void sendPacketX(Instance world, IClientOutgoingPacket packet1, IClientOutgoingPacket packet2, int x)
|
||||
private void sendPacketX(Instance world, ServerPacket packet1, ServerPacket packet2, int x)
|
||||
{
|
||||
for (Player player : world.getPlayers())
|
||||
{
|
||||
|
@ -52,8 +52,8 @@ import org.l2jmobius.gameserver.network.NpcStringId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.Earthquake;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExSendUIEvent;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.OnEventTrigger;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SpecialCamera;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
@ -910,12 +910,12 @@ public class Lindvior extends AbstractNpcAI
|
||||
|
||||
private void sendEventTrigger(boolean status, int... triggers)
|
||||
{
|
||||
IClientOutgoingPacket[] pakets = new IClientOutgoingPacket[triggers.length];
|
||||
final ServerPacket[] packets = new ServerPacket[triggers.length];
|
||||
for (int i = 0; i < triggers.length; i++)
|
||||
{
|
||||
pakets[i] = new OnEventTrigger(triggers[i], status);
|
||||
packets[i] = new OnEventTrigger(triggers[i], status);
|
||||
}
|
||||
for (IClientOutgoingPacket packet : pakets)
|
||||
for (ServerPacket packet : packets)
|
||||
{
|
||||
_zoneLair.broadcastPacket(packet);
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import org.l2jmobius.gameserver.handler.PunishmentHandler;
|
||||
import org.l2jmobius.gameserver.handler.TargetHandler;
|
||||
import org.l2jmobius.gameserver.handler.UserCommandHandler;
|
||||
import org.l2jmobius.gameserver.handler.VoicedCommandHandler;
|
||||
import org.l2jmobius.gameserver.network.telnet.TelnetServer;
|
||||
|
||||
import handlers.actionhandlers.ArtefactAction;
|
||||
import handlers.actionhandlers.DecoyAction;
|
||||
@ -291,30 +290,6 @@ import handlers.targethandlers.affectscope.Square;
|
||||
import handlers.targethandlers.affectscope.SquarePB;
|
||||
import handlers.targethandlers.affectscope.StaticObjectScope;
|
||||
import handlers.targethandlers.affectscope.SummonExceptMaster;
|
||||
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;
|
||||
@ -733,35 +708,6 @@ 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)
|
||||
{
|
||||
LOGGER.info(loadInstance.getClass().getSimpleName() + ": Loaded " + loadInstance.size() + " handlers.");
|
||||
|
@ -1146,7 +1146,7 @@ public class AdminEditChar implements IAdminCommandHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
ip = client.getConnectionAddress().getHostAddress();
|
||||
ip = client.getIp();
|
||||
}
|
||||
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
@ -1356,7 +1356,7 @@ public class AdminEditChar implements IAdminCommandHandler
|
||||
continue;
|
||||
}
|
||||
|
||||
ip = client.getConnectionAddress().getHostAddress();
|
||||
ip = client.getIp();
|
||||
if (!ip.equals(ipAdress))
|
||||
{
|
||||
continue;
|
||||
@ -1450,7 +1450,7 @@ public class AdminEditChar implements IAdminCommandHandler
|
||||
continue;
|
||||
}
|
||||
|
||||
ip = client.getConnectionAddress().getHostAddress();
|
||||
ip = client.getIp();
|
||||
if (ipMap.get(ip) == null)
|
||||
{
|
||||
ipMap.put(ip, new ArrayList<>());
|
||||
@ -1503,7 +1503,7 @@ public class AdminEditChar implements IAdminCommandHandler
|
||||
continue;
|
||||
}
|
||||
|
||||
final IpPack pack = new IpPack(client.getConnectionAddress().getHostAddress(), client.getTrace());
|
||||
final IpPack pack = new IpPack(client.getIp(), client.getTrace());
|
||||
if (ipMap.get(pack) == null)
|
||||
{
|
||||
ipMap.put(pack, new ArrayList<>());
|
||||
|
@ -38,11 +38,11 @@ import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.Earthquake;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExRedSky;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExUserInfoAbnormalVisualEffect;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.OnEventTrigger;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SunRise;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SunSet;
|
||||
@ -717,7 +717,7 @@ public class AdminEffects implements IAdminCommandHandler
|
||||
*/
|
||||
private void adminAtmosphere(String type, String state, int duration, Player activeChar)
|
||||
{
|
||||
IClientOutgoingPacket packet = null;
|
||||
ServerPacket packet = null;
|
||||
if (type.equals("sky"))
|
||||
{
|
||||
if (state.equals("night"))
|
||||
|
@ -1,56 +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.chat;
|
||||
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class Announce implements ITelnetCommand
|
||||
{
|
||||
@Override
|
||||
public String getCommand()
|
||||
{
|
||||
return "announce";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage()
|
||||
{
|
||||
return "Announce <text>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(ChannelHandlerContext ctx, String[] args)
|
||||
{
|
||||
if ((args.length == 0) || args[0].isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String str : args)
|
||||
{
|
||||
sb.append(str + " ");
|
||||
}
|
||||
Broadcast.toAllOnlinePlayers(sb.toString());
|
||||
return "Announcement sent!";
|
||||
}
|
||||
}
|
@ -1,58 +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.chat;
|
||||
|
||||
import org.l2jmobius.gameserver.data.xml.AdminData;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.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(null, ChatType.ALLIANCE, "Telnet GM Broadcast", sb.toString()));
|
||||
return "GMChat sent!";
|
||||
}
|
||||
}
|
@ -1,64 +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.chat;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.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 Player player = World.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(null, ChatType.WHISPER, "Telnet Priv", sb.toString()));
|
||||
return "Announcement sent!";
|
||||
}
|
||||
return "Couldn't find player with such name.";
|
||||
}
|
||||
}
|
@ -1,59 +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.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.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 Player player = World.getInstance().getPlayer(args[0]);
|
||||
if (player != null)
|
||||
{
|
||||
final int level = Integer.parseInt(args[1]);
|
||||
player.setAccessLevel(level, true, true);
|
||||
return "Player " + player.getName() + "'s access level has been changed to: " + level;
|
||||
}
|
||||
return "Couldn't find player with such name.";
|
||||
}
|
||||
}
|
@ -1,84 +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.player;
|
||||
|
||||
import org.l2jmobius.gameserver.data.sql.CharNameTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentAffect;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.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.";
|
||||
}
|
||||
}
|
@ -1,84 +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.player;
|
||||
|
||||
import org.l2jmobius.gameserver.data.sql.CharNameTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentAffect;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.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.";
|
||||
}
|
||||
}
|
@ -1,198 +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.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.l2jmobius.gameserver.util.GMAudit;
|
||||
import org.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 Player player = World.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(Player player, int ench, int armorType)
|
||||
{
|
||||
// now we need to find the equipped weapon of the targeted character...
|
||||
int curEnchant = 0; // display purposes only
|
||||
Item itemInstance = null;
|
||||
|
||||
// only attempt to enchant if there is a weapon equipped
|
||||
Item parmorInstance = player.getInventory().getPaperdollItem(armorType);
|
||||
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType))
|
||||
{
|
||||
itemInstance = parmorInstance;
|
||||
}
|
||||
else
|
||||
{
|
||||
// for bows/crossbows and double handed weapons
|
||||
parmorInstance = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
|
||||
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == Inventory.PAPERDOLL_RHAND))
|
||||
{
|
||||
itemInstance = parmorInstance;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemInstance != null)
|
||||
{
|
||||
curEnchant = itemInstance.getEnchantLevel();
|
||||
|
||||
// set enchant value
|
||||
player.getInventory().unEquipItemInSlot(armorType);
|
||||
itemInstance.setEnchantLevel(ench);
|
||||
player.getInventory().equipItem(itemInstance);
|
||||
|
||||
// send packets
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(itemInstance);
|
||||
player.sendPacket(iu);
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// informations
|
||||
player.sendMessage("Changed enchantment of " + player.getName() + "'s " + itemInstance.getTemplate().getName() + " from " + curEnchant + " to " + ench + ".");
|
||||
player.sendMessage("Admin has changed the enchantment of your " + itemInstance.getTemplate().getName() + " from " + curEnchant + " to " + ench + ".");
|
||||
|
||||
// log
|
||||
GMAudit.auditGMAction("TelnetAdmin", "enchant", player.getName(), itemInstance.getTemplate().getName() + "(" + itemInstance.getObjectId() + ") from " + curEnchant + " to " + ench);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,58 +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.player;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.data.xml.AdminData;
|
||||
import org.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;
|
||||
}
|
||||
}
|
@ -1,85 +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.player;
|
||||
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.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 Player player = World.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 Item 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.";
|
||||
}
|
||||
}
|
@ -1,84 +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.player;
|
||||
|
||||
import org.l2jmobius.gameserver.data.sql.CharNameTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentAffect;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentTask;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.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.";
|
||||
}
|
||||
}
|
@ -1,59 +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.player;
|
||||
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.Disconnection;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.LeaveWorld;
|
||||
import org.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 Player player = World.getInstance().getPlayer(args[0]);
|
||||
if (player != null)
|
||||
{
|
||||
Disconnection.of(player).defaultSequence(LeaveWorld.STATIC_PACKET);
|
||||
return "Player has been successfully kicked.";
|
||||
}
|
||||
return "Couldn't find player with such name.";
|
||||
}
|
||||
}
|
@ -1,97 +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.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.gameserver.data.sql.CharNameTable;
|
||||
import org.l2jmobius.gameserver.enums.MailType;
|
||||
import org.l2jmobius.gameserver.instancemanager.MailManager;
|
||||
import org.l2jmobius.gameserver.model.Message;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.model.itemcontainer.Mail;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.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("_", " "), args.length > 3 ? MailType.PRIME_SHOP_GIFT : MailType.REGULAR);
|
||||
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.";
|
||||
}
|
||||
}
|
@ -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 handlers.telnethandlers.player;
|
||||
|
||||
import org.l2jmobius.gameserver.data.sql.CharNameTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentAffect;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
|
||||
import org.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.";
|
||||
}
|
||||
}
|
@ -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 handlers.telnethandlers.player;
|
||||
|
||||
import org.l2jmobius.gameserver.data.sql.CharNameTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentAffect;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
|
||||
import org.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.";
|
||||
}
|
||||
}
|
@ -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 handlers.telnethandlers.player;
|
||||
|
||||
import org.l2jmobius.gameserver.data.sql.CharNameTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.PunishmentManager;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentAffect;
|
||||
import org.l2jmobius.gameserver.model.punishment.PunishmentType;
|
||||
import org.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.";
|
||||
}
|
||||
}
|
@ -1,366 +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.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 org.l2jmobius.commons.threads.ThreadPool;
|
||||
import org.l2jmobius.gameserver.GameServer;
|
||||
import org.l2jmobius.gameserver.LoginServerThread;
|
||||
import org.l2jmobius.gameserver.data.xml.AdminData;
|
||||
import org.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.Monster;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.AdminForgePacket;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
|
||||
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 Player player = World.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.out.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");
|
||||
}
|
||||
|
||||
static String getServerStatus()
|
||||
{
|
||||
int playerCount = 0;
|
||||
int objectCount = 0;
|
||||
final int max = LoginServerThread.getInstance().getMaxPlayer();
|
||||
playerCount = World.getInstance().getPlayers().size();
|
||||
objectCount = World.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 (WorldObject obj : World.getInstance().getVisibleObjects())
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (obj.isCreature() && ((Creature) obj).hasAI())
|
||||
{
|
||||
aiCount++;
|
||||
}
|
||||
if (obj.isItem())
|
||||
{
|
||||
if (((Item) obj).getItemLocation() == ItemLocation.VOID)
|
||||
{
|
||||
itemVoidCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemCount++;
|
||||
}
|
||||
}
|
||||
else if (obj.isMonster())
|
||||
{
|
||||
monsterCount++;
|
||||
if (((Monster) obj).hasMinions())
|
||||
{
|
||||
minionCount += ((Monster) obj).getMinionList().countSpawnedMinions();
|
||||
minionsGroupCount += ((Monster) obj).getMinionList().lazyCountSpawnedMinionsGroups();
|
||||
}
|
||||
}
|
||||
else if (obj.isNpc())
|
||||
{
|
||||
npcCount++;
|
||||
}
|
||||
else if (obj.isPlayer())
|
||||
{
|
||||
pcCount++;
|
||||
if ((((Player) obj).getClient() != null) && ((Player) obj).getClient().isDetached())
|
||||
{
|
||||
detachedCount++;
|
||||
}
|
||||
}
|
||||
else if (obj.isSummon())
|
||||
{
|
||||
summonCount++;
|
||||
}
|
||||
else if (obj.isDoor())
|
||||
{
|
||||
doorCount++;
|
||||
}
|
||||
else if (obj.isCreature())
|
||||
{
|
||||
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 +.... Item(Void): " + itemVoidCount);
|
||||
sb.append("\r\n +.......... Item: " + itemCount);
|
||||
sb.append("\r\n +....... Monster: " + monsterCount);
|
||||
sb.append("\r\n +......... Minions: " + minionCount);
|
||||
sb.append("\r\n +.. Minions Groups: " + minionsGroupCount);
|
||||
sb.append("\r\n +........... Npc: " + npcCount);
|
||||
sb.append("\r\n +............ Player: " + pcCount);
|
||||
sb.append("\r\n +........ Summon: " + summonCount);
|
||||
sb.append("\r\n +.......... Door: " + doorCount);
|
||||
sb.append("\r\n +.......... Creature: " + 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 = GameTimeTaskManager.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());
|
||||
}
|
||||
}
|
@ -1,46 +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.server;
|
||||
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class ForceGC implements ITelnetCommand
|
||||
{
|
||||
@Override
|
||||
public String getCommand()
|
||||
{
|
||||
return "forcegc";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage()
|
||||
{
|
||||
return "ForceGC";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(ChannelHandlerContext ctx, String[] args)
|
||||
{
|
||||
System.gc();
|
||||
return "RAM Used: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1048576);
|
||||
}
|
||||
}
|
@ -1,69 +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.server;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.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();
|
||||
}
|
||||
}
|
@ -1,53 +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.server;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.threads.ThreadPool;
|
||||
import org.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();
|
||||
}
|
||||
}
|
@ -1,53 +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.server;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.threads.ThreadPool;
|
||||
import org.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();
|
||||
}
|
||||
}
|
@ -1,263 +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.server;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.sql.CrestTable;
|
||||
import org.l2jmobius.gameserver.data.xml.AbilityPointsData;
|
||||
import org.l2jmobius.gameserver.data.xml.AdminData;
|
||||
import org.l2jmobius.gameserver.data.xml.AppearanceItemData;
|
||||
import org.l2jmobius.gameserver.data.xml.ArmorSetData;
|
||||
import org.l2jmobius.gameserver.data.xml.BuyListData;
|
||||
import org.l2jmobius.gameserver.data.xml.DoorData;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemData;
|
||||
import org.l2jmobius.gameserver.data.xml.EnchantItemGroupsData;
|
||||
import org.l2jmobius.gameserver.data.xml.ItemCrystallizationData;
|
||||
import org.l2jmobius.gameserver.data.xml.MultisellData;
|
||||
import org.l2jmobius.gameserver.data.xml.NpcData;
|
||||
import org.l2jmobius.gameserver.data.xml.SayuneData;
|
||||
import org.l2jmobius.gameserver.data.xml.SkillData;
|
||||
import org.l2jmobius.gameserver.data.xml.TeleporterData;
|
||||
import org.l2jmobius.gameserver.data.xml.TransformData;
|
||||
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
import org.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(ServerMode.GAME);
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Configs.");
|
||||
}
|
||||
case "access":
|
||||
{
|
||||
AdminData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Access.");
|
||||
}
|
||||
case "npc":
|
||||
{
|
||||
NpcData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Npcs.");
|
||||
}
|
||||
case "quest":
|
||||
{
|
||||
if (args.length > 1)
|
||||
{
|
||||
final String value = args[1];
|
||||
if (!Util.isDigit(value))
|
||||
{
|
||||
QuestManager.getInstance().reload(value);
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Quest Name:" + value + ".");
|
||||
}
|
||||
final int questId = Integer.parseInt(value);
|
||||
QuestManager.getInstance().reload(questId);
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Quest ID:" + questId + ".");
|
||||
}
|
||||
QuestManager.getInstance().reloadAllScripts();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Quests.");
|
||||
}
|
||||
case "walker":
|
||||
{
|
||||
WalkingManager.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("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 AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Htm File:" + file.getName() + ".");
|
||||
}
|
||||
return "File or Directory does not exist.";
|
||||
}
|
||||
HtmCache.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Htms.");
|
||||
return "Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " megabytes on " + HtmCache.getInstance().getLoadedFiles() + " files loaded";
|
||||
}
|
||||
case "multisell":
|
||||
{
|
||||
MultisellData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Multisells.");
|
||||
}
|
||||
case "buylist":
|
||||
{
|
||||
BuyListData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Buylists.");
|
||||
}
|
||||
case "teleport":
|
||||
{
|
||||
TeleporterData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Teleports.");
|
||||
}
|
||||
case "skill":
|
||||
{
|
||||
SkillData.getInstance().reload();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Skills.");
|
||||
}
|
||||
case "item":
|
||||
{
|
||||
ItemTable.getInstance().reload();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Items.");
|
||||
}
|
||||
case "door":
|
||||
{
|
||||
DoorData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Doors.");
|
||||
}
|
||||
case "zone":
|
||||
{
|
||||
ZoneManager.getInstance().reload();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Zones.");
|
||||
}
|
||||
case "cw":
|
||||
{
|
||||
CursedWeaponsManager.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Cursed Weapons.");
|
||||
}
|
||||
case "crest":
|
||||
{
|
||||
CrestTable.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Crests.");
|
||||
}
|
||||
case "effect":
|
||||
{
|
||||
try
|
||||
{
|
||||
ScriptEngineManager.getInstance().executeScript(ScriptEngineManager.EFFECT_MASTER_HANDLER_FILE);
|
||||
return AdminData.getInstance().broadcastMessageToGMs("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().executeScript(ScriptEngineManager.MASTER_HANDLER_FILE);
|
||||
return AdminData.getInstance().broadcastMessageToGMs("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 AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded item enchanting data.");
|
||||
}
|
||||
case "transform":
|
||||
{
|
||||
TransformData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded transform data.");
|
||||
}
|
||||
case "crystalizable":
|
||||
{
|
||||
ItemCrystallizationData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded item crystalization data.");
|
||||
}
|
||||
case "ability":
|
||||
{
|
||||
AbilityPointsData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded ability points data.");
|
||||
}
|
||||
case "appearance":
|
||||
{
|
||||
AppearanceItemData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded appearance item data.");
|
||||
}
|
||||
case "sayune":
|
||||
{
|
||||
SayuneData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("Telnet Admin: Reloaded Sayune data.");
|
||||
}
|
||||
case "sets":
|
||||
{
|
||||
ArmorSetData.getInstance().load();
|
||||
return AdminData.getInstance().broadcastMessageToGMs("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;
|
||||
}
|
||||
}
|
@ -1,47 +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.server;
|
||||
|
||||
import org.l2jmobius.gameserver.Shutdown;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class ServerAbort implements ITelnetCommand
|
||||
{
|
||||
@Override
|
||||
public String getCommand()
|
||||
{
|
||||
return "abort";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage()
|
||||
{
|
||||
return "Abort";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String handle(ChannelHandlerContext ctx, String[] args)
|
||||
{
|
||||
Shutdown.getInstance().abort(null);
|
||||
return "Server shutdown/restart aborted!";
|
||||
}
|
||||
}
|
@ -1,53 +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.server;
|
||||
|
||||
import org.l2jmobius.gameserver.Shutdown;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.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().startShutdown(null, time, true);
|
||||
return "Server will restart in " + time + " seconds!";
|
||||
}
|
||||
}
|
@ -1,53 +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.server;
|
||||
|
||||
import org.l2jmobius.gameserver.Shutdown;
|
||||
import org.l2jmobius.gameserver.network.telnet.ITelnetCommand;
|
||||
import org.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().startShutdown(null, time, false);
|
||||
return "Server will shutdown in " + time + " seconds!";
|
||||
}
|
||||
}
|
@ -1,45 +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.server;
|
||||
|
||||
import org.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();
|
||||
}
|
||||
}
|
@ -61,8 +61,8 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExUserInfoAbnormalVisualEffect;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.appearance.ExCuriousHouseMemberUpdate;
|
||||
@ -1124,7 +1124,7 @@ public class CeremonyOfChaos extends AbstractNpcAI
|
||||
return canRegister;
|
||||
}
|
||||
|
||||
private void broadcastPacket(IClientOutgoingPacket packet)
|
||||
private void broadcastPacket(ServerPacket packet)
|
||||
{
|
||||
for (Player player : PARTICIPANT_PLAYERS)
|
||||
{
|
||||
|
2
L2J_Mobius_03.0_Helios/dist/game/java.cfg
vendored
2
L2J_Mobius_03.0_Helios/dist/game/java.cfg
vendored
@ -1 +1 @@
|
||||
-server -Dfile.encoding=UTF-8 -Djava.util.logging.manager=org.l2jmobius.log.ServerLogManager -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Xmx4g -Xms2g
|
||||
-server -Dfile.encoding=UTF-8 -Djava.util.logging.manager=org.l2jmobius.log.ServerLogManager -Xmx4g -Xms2g
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2
L2J_Mobius_03.0_Helios/dist/login/java.cfg
vendored
2
L2J_Mobius_03.0_Helios/dist/login/java.cfg
vendored
@ -1 +1 @@
|
||||
-server -Dfile.encoding=UTF-8 -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Xms128m -Xmx256m
|
||||
-server -Dfile.encoding=UTF-8 -Xms128m -Xmx256m
|
@ -105,7 +105,6 @@ public class Config
|
||||
private static final String PVP_CONFIG_FILE = "./config/PVP.ini";
|
||||
private static final String RATES_CONFIG_FILE = "./config/Rates.ini";
|
||||
private static final String SERVER_CONFIG_FILE = "./config/Server.ini";
|
||||
private static final String TELNET_CONFIG_FILE = "./config/Telnet.ini";
|
||||
private static final String TRAINING_CAMP_CONFIG_FILE = "./config/TrainingCamp.ini";
|
||||
private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
|
||||
private static final String HEXID_FILE = "./config/hexid.txt";
|
||||
@ -468,7 +467,7 @@ public 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 IO_PACKET_THREAD_CORE_SIZE;
|
||||
public static boolean THREADS_FOR_CLIENT_PACKETS;
|
||||
public static boolean THREADS_FOR_LOADING;
|
||||
public static boolean DEADLOCK_DETECTOR;
|
||||
public static int DEADLOCK_CHECK_INTERVAL;
|
||||
@ -780,6 +779,15 @@ public class Config
|
||||
public static int LOGIN_TRY_BEFORE_BAN;
|
||||
public static int LOGIN_BLOCK_AFTER_BAN;
|
||||
public static String GAMESERVER_HOSTNAME;
|
||||
public static int CLIENT_READ_POOL_SIZE;
|
||||
public static int CLIENT_EXECUTE_POOL_SIZE;
|
||||
public static int PACKET_QUEUE_LIMIT;
|
||||
public static boolean PACKET_FLOOD_DISCONNECT;
|
||||
public static boolean PACKET_FLOOD_DROP;
|
||||
public static boolean PACKET_FLOOD_LOGGED;
|
||||
public static boolean TCP_NO_DELAY;
|
||||
public static int CONNECTION_TIMEOUT;
|
||||
public static boolean PACKET_ENCRYPTION;
|
||||
public static String DATABASE_DRIVER;
|
||||
public static String DATABASE_URL;
|
||||
public static String DATABASE_LOGIN;
|
||||
@ -864,11 +872,6 @@ public class Config
|
||||
public static double HP_REGEN_MULTIPLIER;
|
||||
public static double MP_REGEN_MULTIPLIER;
|
||||
public static double CP_REGEN_MULTIPLIER;
|
||||
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 TRAINING_CAMP_ENABLE;
|
||||
public static boolean TRAINING_CAMP_PREMIUM_ONLY;
|
||||
public static int TRAINING_CAMP_MAX_DURATION;
|
||||
@ -1380,10 +1383,19 @@ public class Config
|
||||
PORT_GAME = serverConfig.getInt("GameserverPort", 7777);
|
||||
GAME_SERVER_LOGIN_PORT = serverConfig.getInt("LoginPort", 9014);
|
||||
GAME_SERVER_LOGIN_HOST = serverConfig.getString("LoginHost", "127.0.0.1");
|
||||
CLIENT_READ_POOL_SIZE = serverConfig.getInt("ClientReadPoolSize", 100);
|
||||
CLIENT_EXECUTE_POOL_SIZE = serverConfig.getInt("ClientExecutePoolSize", 50);
|
||||
PACKET_QUEUE_LIMIT = serverConfig.getInt("PacketQueueLimit", 80);
|
||||
PACKET_FLOOD_DISCONNECT = serverConfig.getBoolean("PacketFloodDisconnect", false);
|
||||
PACKET_FLOOD_DROP = serverConfig.getBoolean("PacketFloodDrop", false);
|
||||
PACKET_FLOOD_LOGGED = serverConfig.getBoolean("PacketFloodLogged", true);
|
||||
TCP_NO_DELAY = serverConfig.getBoolean("TcpNoDelay", true);
|
||||
CONNECTION_TIMEOUT = serverConfig.getInt("ConnectionTimeout", 800);
|
||||
PACKET_ENCRYPTION = serverConfig.getBoolean("PacketEncryption", false);
|
||||
REQUEST_ID = serverConfig.getInt("RequestServerID", 0);
|
||||
ACCEPT_ALTERNATE_ID = serverConfig.getBoolean("AcceptAlternateID", true);
|
||||
DATABASE_DRIVER = serverConfig.getString("Driver", "org.mariadb.jdbc.Driver");
|
||||
DATABASE_URL = serverConfig.getString("URL", "jdbc:mariadb://localhost/l2jgs");
|
||||
DATABASE_URL = serverConfig.getString("URL", "jdbc:mariadb://localhost/l2jmobius");
|
||||
DATABASE_LOGIN = serverConfig.getString("Login", "root");
|
||||
DATABASE_PASSWORD = serverConfig.getString("Password", "");
|
||||
DATABASE_MAX_CONNECTIONS = serverConfig.getInt("MaximumDbConnections", 10);
|
||||
@ -1459,11 +1471,7 @@ public class Config
|
||||
INSTANT_THREAD_POOL_COUNT = Runtime.getRuntime().availableProcessors();
|
||||
}
|
||||
THREADS_PER_INSTANT_THREAD_POOL = serverConfig.getInt("ThreadsPerInstantThreadPool", 2);
|
||||
IO_PACKET_THREAD_CORE_SIZE = serverConfig.getInt("UrgentPacketThreadCoreSize", -1);
|
||||
if (IO_PACKET_THREAD_CORE_SIZE == -1)
|
||||
{
|
||||
IO_PACKET_THREAD_CORE_SIZE = Runtime.getRuntime().availableProcessors();
|
||||
}
|
||||
THREADS_FOR_CLIENT_PACKETS = serverConfig.getBoolean("ThreadsForClientPackets", true);
|
||||
THREADS_FOR_LOADING = serverConfig.getBoolean("ThreadsForLoading", false);
|
||||
DEADLOCK_DETECTOR = serverConfig.getBoolean("DeadLockDetector", true);
|
||||
DEADLOCK_CHECK_INTERVAL = serverConfig.getInt("DeadLockCheckInterval", 20);
|
||||
@ -1963,14 +1971,6 @@ public class Config
|
||||
ABILITY_MAX_POINTS = characterConfig.getInt("AbilityMaxPoints", 16);
|
||||
ABILITY_POINTS_RESET_ADENA = characterConfig.getLong("AbilityPointsResetAdena", 10000000);
|
||||
|
||||
// Load Telnet config file (if exists)
|
||||
final PropertiesParser telnetConfig = new PropertiesParser(TELNET_CONFIG_FILE);
|
||||
TELNET_ENABLED = telnetConfig.getBoolean("EnableTelnet", false);
|
||||
TELNET_PORT = telnetConfig.getInt("Port", 12345);
|
||||
TELNET_HOSTNAME = telnetConfig.getString("BindAddress", "127.0.0.1");
|
||||
TELNET_PASSWORD = telnetConfig.getString("Password", "");
|
||||
TELNET_HOSTS = Arrays.asList(telnetConfig.getString("ListOfHosts", "127.0.0.1,::1").split(","));
|
||||
|
||||
// Load Training Camp config file (if exists)
|
||||
final PropertiesParser trainingCampConfig = new PropertiesParser(TRAINING_CAMP_CONFIG_FILE);
|
||||
TRAINING_CAMP_ENABLE = trainingCampConfig.getBoolean("TrainingCampEnable", false);
|
||||
@ -3613,7 +3613,7 @@ public class Config
|
||||
LOGIN_SERVER_SCHEDULE_RESTART = loginConfig.getBoolean("LoginRestartSchedule", false);
|
||||
LOGIN_SERVER_SCHEDULE_RESTART_TIME = loginConfig.getLong("LoginRestartTime", 24);
|
||||
DATABASE_DRIVER = loginConfig.getString("Driver", "org.mariadb.jdbc.Driver");
|
||||
DATABASE_URL = loginConfig.getString("URL", "jdbc:mariadb://localhost/l2jls");
|
||||
DATABASE_URL = loginConfig.getString("URL", "jdbc:mariadb://localhost/l2jmobius");
|
||||
DATABASE_LOGIN = loginConfig.getString("Login", "root");
|
||||
DATABASE_PASSWORD = loginConfig.getString("Password", "");
|
||||
DATABASE_MAX_CONNECTIONS = loginConfig.getInt("MaximumDbConnections", 10);
|
||||
|
@ -15,7 +15,7 @@
|
||||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.l2jmobius.commons.util.crypt;
|
||||
package org.l2jmobius.commons.crypt;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.commons.util.crypt;
|
||||
package org.l2jmobius.commons.crypt;
|
||||
|
||||
/**
|
||||
* Class to use a blowfish cipher with ECB processing.<br>
|
||||
@ -153,7 +153,7 @@ public class NewCrypt
|
||||
* @param size Length of the data to be encrypted
|
||||
* @param key The 4 bytes (int) XOR key
|
||||
*/
|
||||
static void encXORPass(byte[] raw, int offset, int size, int key)
|
||||
public static void encXORPass(byte[] raw, int offset, int size, int key)
|
||||
{
|
||||
final int stop = size - 8;
|
||||
int pos = 4 + offset;
|
@ -1,106 +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 org.l2jmobius.commons.network;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:12 $
|
||||
*/
|
||||
public abstract class BaseRecievePacket
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(BaseRecievePacket.class.getName());
|
||||
|
||||
private final byte[] _decrypt;
|
||||
private int _off;
|
||||
|
||||
public BaseRecievePacket(byte[] decrypt)
|
||||
{
|
||||
_decrypt = decrypt;
|
||||
_off = 1; // skip packet type id
|
||||
}
|
||||
|
||||
public int readD()
|
||||
{
|
||||
int result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] << 8) & 0xff00;
|
||||
result |= (_decrypt[_off++] << 0x10) & 0xff0000;
|
||||
result |= (_decrypt[_off++] << 0x18) & 0xff000000;
|
||||
return result;
|
||||
}
|
||||
|
||||
public int readC()
|
||||
{
|
||||
return _decrypt[_off++] & 0xff;
|
||||
}
|
||||
|
||||
public int readH()
|
||||
{
|
||||
return (_decrypt[_off++] & 0xff) | ((_decrypt[_off++] << 8) & 0xff00);
|
||||
}
|
||||
|
||||
public double readF()
|
||||
{
|
||||
long result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 8L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 16L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 24L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 32L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 40L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 48L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 56L;
|
||||
return Double.longBitsToDouble(result);
|
||||
}
|
||||
|
||||
public String readS()
|
||||
{
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
result = new String(_decrypt, _off, _decrypt.length - _off, StandardCharsets.UTF_16LE);
|
||||
result = result.substring(0, result.indexOf(0));
|
||||
_off += (result.length() * 2) + 2;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public byte[] readB(int length)
|
||||
{
|
||||
final byte[] result = new byte[length];
|
||||
System.arraycopy(_decrypt, _off, result, 0, length);
|
||||
_off += length;
|
||||
return result;
|
||||
}
|
||||
|
||||
public long readQ()
|
||||
{
|
||||
long result = _decrypt[_off++] & 0xff;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 8L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 16L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 24L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 32L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 40L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 48L;
|
||||
result |= (_decrypt[_off++] & 0xffL) << 56L;
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,137 +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 org.l2jmobius.commons.network;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2.4.1 $ $Date: 2005/03/27 15:30:11 $
|
||||
*/
|
||||
public abstract class BaseSendablePacket
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(BaseSendablePacket.class.getName());
|
||||
|
||||
private final ByteArrayOutputStream _bao;
|
||||
|
||||
protected BaseSendablePacket()
|
||||
{
|
||||
_bao = new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
protected void writeD(int value)
|
||||
{
|
||||
_bao.write(value & 0xff);
|
||||
_bao.write((value >> 8) & 0xff);
|
||||
_bao.write((value >> 16) & 0xff);
|
||||
_bao.write((value >> 24) & 0xff);
|
||||
}
|
||||
|
||||
protected void writeH(int value)
|
||||
{
|
||||
_bao.write(value & 0xff);
|
||||
_bao.write((value >> 8) & 0xff);
|
||||
}
|
||||
|
||||
protected void writeC(int value)
|
||||
{
|
||||
_bao.write(value & 0xff);
|
||||
}
|
||||
|
||||
protected void writeF(double org)
|
||||
{
|
||||
final long value = Double.doubleToRawLongBits(org);
|
||||
_bao.write((int) (value & 0xff));
|
||||
_bao.write((int) ((value >> 8) & 0xff));
|
||||
_bao.write((int) ((value >> 16) & 0xff));
|
||||
_bao.write((int) ((value >> 24) & 0xff));
|
||||
_bao.write((int) ((value >> 32) & 0xff));
|
||||
_bao.write((int) ((value >> 40) & 0xff));
|
||||
_bao.write((int) ((value >> 48) & 0xff));
|
||||
_bao.write((int) ((value >> 56) & 0xff));
|
||||
}
|
||||
|
||||
protected void writeS(String text)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
_bao.write(text.getBytes(StandardCharsets.UTF_16LE));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
_bao.write(0);
|
||||
_bao.write(0);
|
||||
}
|
||||
|
||||
protected void writeB(byte[] array)
|
||||
{
|
||||
try
|
||||
{
|
||||
_bao.write(array);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQ(long value)
|
||||
{
|
||||
_bao.write((int) (value & 0xff));
|
||||
_bao.write((int) ((value >> 8) & 0xff));
|
||||
_bao.write((int) ((value >> 16) & 0xff));
|
||||
_bao.write((int) ((value >> 24) & 0xff));
|
||||
_bao.write((int) ((value >> 32) & 0xff));
|
||||
_bao.write((int) ((value >> 40) & 0xff));
|
||||
_bao.write((int) ((value >> 48) & 0xff));
|
||||
_bao.write((int) ((value >> 56) & 0xff));
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return _bao.size() + 2;
|
||||
}
|
||||
|
||||
public byte[] getBytes()
|
||||
{
|
||||
// if (this instanceof Init)
|
||||
// writeD(0); // reserve for XOR initial key
|
||||
|
||||
writeD(0); // reserve for checksum
|
||||
|
||||
final int padding = _bao.size() % 8;
|
||||
if (padding != 0)
|
||||
{
|
||||
for (int i = padding; i < 8; i++)
|
||||
{
|
||||
writeC(0);
|
||||
}
|
||||
}
|
||||
|
||||
return _bao.toByteArray();
|
||||
}
|
||||
|
||||
public abstract byte[] getContent() throws IOException;
|
||||
}
|
@ -1,46 +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 org.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;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
/**
|
||||
* @author Pantelis Andrianakis
|
||||
* @since October 4th 2022
|
||||
*/
|
||||
public interface EncryptionInterface
|
||||
{
|
||||
default void encrypt(byte[] data, int offset, int size)
|
||||
{
|
||||
}
|
||||
|
||||
default void decrypt(byte[] data, int offset, int size)
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
|
||||
/**
|
||||
* @author Pantelis Andrianakis
|
||||
* @since September 7th 2020
|
||||
* @param <E> extends NetClient
|
||||
*/
|
||||
public class ExecuteThread<E extends NetClient> implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(ExecuteThread.class.getName());
|
||||
|
||||
private final Set<E> _pool;
|
||||
private final PacketHandlerInterface<E> _packetHandler;
|
||||
|
||||
public ExecuteThread(Set<E> pool, PacketHandlerInterface<E> packetHandler)
|
||||
{
|
||||
_pool = pool;
|
||||
_packetHandler = packetHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
long executionStart;
|
||||
long currentTime;
|
||||
while (true)
|
||||
{
|
||||
executionStart = System.currentTimeMillis();
|
||||
|
||||
// No need to iterate when pool is empty.
|
||||
if (!_pool.isEmpty())
|
||||
{
|
||||
// Iterate client pool.
|
||||
ITERATE: for (E client : _pool)
|
||||
{
|
||||
if (client.getChannel() == null)
|
||||
{
|
||||
_pool.remove(client);
|
||||
continue ITERATE;
|
||||
}
|
||||
|
||||
final byte[] data = client.getPacketData().poll();
|
||||
if (data == null)
|
||||
{
|
||||
continue ITERATE;
|
||||
}
|
||||
|
||||
if (client.getEncryption() != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
client.getEncryption().decrypt(data, 0, data.length);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning("ExecuteThread: Problem with " + client + " data decryption.");
|
||||
LOGGER.warning(CommonUtil.getStackTrace(e));
|
||||
client.disconnect();
|
||||
continue ITERATE;
|
||||
}
|
||||
}
|
||||
_packetHandler.handle(client, new ReadablePacket(data));
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent high CPU caused by repeatedly looping.
|
||||
currentTime = System.currentTimeMillis();
|
||||
if ((currentTime - executionStart) < 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(1);
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +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 org.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.util.AttributeKey;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public interface IConnectionState
|
||||
{
|
||||
AttributeKey<IConnectionState> ATTRIBUTE_KEY = AttributeKey.valueOf(IConnectionState.class, "");
|
||||
}
|
@ -1,29 +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 org.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public interface ICrypt
|
||||
{
|
||||
void encrypt(ByteBuf buf);
|
||||
|
||||
void decrypt(ByteBuf buf);
|
||||
}
|
@ -1,34 +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 org.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;
|
||||
}
|
@ -1,32 +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 org.l2jmobius.commons.network;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
* @param <T>
|
||||
*/
|
||||
public interface IIncomingPackets<T>extends IConnectionState
|
||||
{
|
||||
int getPacketId();
|
||||
|
||||
IIncomingPacket<T> newIncomingPacket();
|
||||
|
||||
Set<IConnectionState> getConnectionStates();
|
||||
}
|
@ -1,29 +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 org.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,157 @@
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Pantelis Andrianakis
|
||||
* @since September 7th 2020
|
||||
*/
|
||||
public class NetClient
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(NetClient.class.getName());
|
||||
|
||||
private String _ip;
|
||||
private SocketChannel _channel;
|
||||
private NetConfig _netConfig;
|
||||
private Queue<byte[]> _pendingPacketData;
|
||||
|
||||
/**
|
||||
* Initialize the client.
|
||||
* @param channel
|
||||
* @param netConfig
|
||||
*/
|
||||
public void init(SocketChannel channel, NetConfig netConfig)
|
||||
{
|
||||
_channel = channel;
|
||||
_netConfig = netConfig;
|
||||
_pendingPacketData = new ConcurrentLinkedQueue<>();
|
||||
|
||||
try
|
||||
{
|
||||
_ip = _channel.getRemoteAddress().toString();
|
||||
_ip = _ip.substring(1, _ip.lastIndexOf(':')); // Trim out /127.0.0.1:12345
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
|
||||
// Client is ready for communication.
|
||||
onConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when client is connected.
|
||||
*/
|
||||
public void onConnection()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when client is disconnected.
|
||||
*/
|
||||
public void onDisconnection()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect the client.
|
||||
*/
|
||||
public void disconnect()
|
||||
{
|
||||
if (_channel != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_channel.close();
|
||||
_channel = null;
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
_pendingPacketData.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add packet data to the queue.
|
||||
* @param data
|
||||
*/
|
||||
public void addPacketData(byte[] data)
|
||||
{
|
||||
// Check packet flooding.
|
||||
final int size = _pendingPacketData.size();
|
||||
if (size >= _netConfig.getPacketQueueLimit())
|
||||
{
|
||||
if (_netConfig.isPacketFloodDisconnect())
|
||||
{
|
||||
disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_netConfig.isPacketFloodDrop())
|
||||
{
|
||||
if (_netConfig.isPacketFloodLogged() && ((size % _netConfig.getPacketQueueLimit()) == 0))
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(this);
|
||||
sb.append(" packet queue size(");
|
||||
sb.append(size);
|
||||
sb.append(") exceeded limit(");
|
||||
sb.append(_netConfig.getPacketQueueLimit());
|
||||
sb.append(").");
|
||||
LOGGER.warning(sb.toString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add to queue.
|
||||
_pendingPacketData.add(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pending packet data.
|
||||
*/
|
||||
public Queue<byte[]> getPacketData()
|
||||
{
|
||||
return _pendingPacketData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Encryption of this client.
|
||||
*/
|
||||
public EncryptionInterface getEncryption()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the SocketChannel of this client.
|
||||
*/
|
||||
public SocketChannel getChannel()
|
||||
{
|
||||
return _channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the IP address of this client.
|
||||
*/
|
||||
public String getIp()
|
||||
{
|
||||
return _ip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" - IP: ");
|
||||
sb.append(_ip);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
/**
|
||||
* @author Pantelis Andrianakis
|
||||
* @since October 4th 2022
|
||||
*/
|
||||
public class NetConfig
|
||||
{
|
||||
private int _readPoolSize = 100;
|
||||
private int _executePoolSize = 50;
|
||||
private int _connectionTimeout = 800;
|
||||
private int _packetQueueLimit = 80;
|
||||
private boolean _packetFloodDisconnect = false;
|
||||
private boolean _packetFloodDrop = false;
|
||||
private boolean _packetFloodLogged = true;
|
||||
private boolean _tcpNoDelay = true;
|
||||
|
||||
/**
|
||||
* @return the NetClient pool size for reading client packets.
|
||||
*/
|
||||
public int getReadPoolSize()
|
||||
{
|
||||
return _readPoolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the NetClient pool size for reading client packets.
|
||||
* @param clientPoolSize
|
||||
*/
|
||||
public void setReadPoolSize(int clientPoolSize)
|
||||
{
|
||||
_readPoolSize = clientPoolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the NetClient pool size for executing client packets.
|
||||
*/
|
||||
public int getExecutePoolSize()
|
||||
{
|
||||
return _executePoolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the NetClient pool size for executing client packets.
|
||||
* @param executePoolSize
|
||||
*/
|
||||
public void setExecutePoolSize(int executePoolSize)
|
||||
{
|
||||
_executePoolSize = executePoolSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the timeout until a connection is established.
|
||||
*/
|
||||
public int getConnectionTimeout()
|
||||
{
|
||||
return _connectionTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the timeout until a connection is established.
|
||||
* @param connectionTimeout
|
||||
*/
|
||||
public void setConnectionTimeout(int connectionTimeout)
|
||||
{
|
||||
_connectionTimeout = connectionTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the packet queue limit of receivable packets.
|
||||
*/
|
||||
public int getPacketQueueLimit()
|
||||
{
|
||||
return _packetQueueLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the packet queue limit of receivable packets.
|
||||
* @param packetQueueLimit
|
||||
*/
|
||||
public void setPacketQueueLimit(int packetQueueLimit)
|
||||
{
|
||||
_packetQueueLimit = packetQueueLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if disconnect when packets that exceed the packet queue limit.
|
||||
*/
|
||||
public boolean isPacketFloodDisconnect()
|
||||
{
|
||||
return _packetFloodDisconnect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets to disconnect when the packet queue limit is exceeded.
|
||||
* @param packetFloodDisconnect
|
||||
*/
|
||||
public void setPacketFloodDisconnect(boolean packetFloodDisconnect)
|
||||
{
|
||||
_packetFloodDisconnect = packetFloodDisconnect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if packets that exceed the packet queue limit are dropped.
|
||||
*/
|
||||
public boolean isPacketFloodDrop()
|
||||
{
|
||||
return _packetFloodDrop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if packets that exceed the packet queue limit are dropped.
|
||||
* @param packetQueueDrop
|
||||
*/
|
||||
public void setPacketFloodDrop(boolean packetQueueDrop)
|
||||
{
|
||||
_packetFloodDrop = packetQueueDrop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if dropped packets are logged.
|
||||
*/
|
||||
public boolean isPacketFloodLogged()
|
||||
{
|
||||
return _packetFloodLogged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if dropped packets are logged.
|
||||
* @param packetFloodLogged
|
||||
*/
|
||||
public void setPacketFloodLogged(boolean packetFloodLogged)
|
||||
{
|
||||
_packetFloodLogged = packetFloodLogged;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if TCP_NODELAY (Nagle's Algorithm) is used.
|
||||
*/
|
||||
public boolean isTcpNoDelay()
|
||||
{
|
||||
return _tcpNoDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if TCP_NODELAY (Nagle's Algorithm) is used.
|
||||
* @param tcpNoDelay
|
||||
*/
|
||||
public void setTcpNoDelay(boolean tcpNoDelay)
|
||||
{
|
||||
_tcpNoDelay = tcpNoDelay;
|
||||
}
|
||||
}
|
@ -0,0 +1,206 @@
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Pantelis Andrianakis
|
||||
* @since September 7th 2020
|
||||
* @param <E> extends NetClient
|
||||
*/
|
||||
public class NetServer<E extends NetClient>
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(NetServer.class.getName());
|
||||
|
||||
protected final List<Set<E>> _clientReadPools = new LinkedList<>();
|
||||
protected final List<Set<E>> _clientExecutePools = new LinkedList<>();
|
||||
protected final NetConfig _netConfig = new NetConfig();
|
||||
protected final String _hostname;
|
||||
protected final int _port;
|
||||
protected final Supplier<E> _clientSupplier;
|
||||
protected final PacketHandlerInterface<E> _packetHandler;
|
||||
protected String _name = getClass().getSimpleName();
|
||||
|
||||
/**
|
||||
* Creates a new NetServer.
|
||||
* @param port that the server will listen for incoming connections.
|
||||
* @param packetHandler that will be used to handle incoming data.
|
||||
* @param clientSupplier that will be used to create new client objects.
|
||||
*/
|
||||
public NetServer(int port, PacketHandlerInterface<E> packetHandler, Supplier<E> clientSupplier)
|
||||
{
|
||||
this("0.0.0.0", port, packetHandler, clientSupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new NetServer.
|
||||
* @param hostname of the server, use 0.0.0.0 to bind on all available IPs.
|
||||
* @param port that the server will listen for incoming connections.
|
||||
* @param packetHandler that will be used to handle incoming data.
|
||||
* @param clientSupplier that will be used to create new client objects.
|
||||
*/
|
||||
public NetServer(String hostname, int port, PacketHandlerInterface<E> packetHandler, Supplier<E> clientSupplier)
|
||||
{
|
||||
_hostname = hostname;
|
||||
_port = port;
|
||||
_packetHandler = packetHandler;
|
||||
_clientSupplier = clientSupplier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use alternative name for this NetServer object.
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the network configurations of this server.
|
||||
*/
|
||||
public NetConfig getNetConfig()
|
||||
{
|
||||
return _netConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start listening for clients.
|
||||
*/
|
||||
public void start()
|
||||
{
|
||||
if (_clientSupplier == null)
|
||||
{
|
||||
LOGGER.warning(_name + ": Could not start because client Supplier was not set.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_packetHandler == null)
|
||||
{
|
||||
LOGGER.warning(_name + ": Could not start because PacketHandler was not set.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Runs on a separate thread.
|
||||
final Thread thread = new Thread(new NetworkListenerThread(), _name + ": Network listener thread");
|
||||
thread.setPriority(Thread.MAX_PRIORITY);
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private class NetworkListenerThread implements Runnable
|
||||
{
|
||||
public NetworkListenerThread()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// Create server and bind port.
|
||||
try (ServerSocketChannel server = ServerSocketChannel.open())
|
||||
{
|
||||
server.bind(new InetSocketAddress(_hostname, _port));
|
||||
server.configureBlocking(false); // Non-blocking I/O.
|
||||
|
||||
// Listen for new connections.
|
||||
LOGGER.info(_name + ": Listening on port " + _port + " for incoming connections.");
|
||||
long executionStart;
|
||||
long currentTime;
|
||||
while (true)
|
||||
{
|
||||
executionStart = System.currentTimeMillis();
|
||||
|
||||
final SocketChannel channel = server.accept();
|
||||
if (channel != null)
|
||||
{
|
||||
// Configure channel.
|
||||
channel.socket().setTcpNoDelay(_netConfig.isTcpNoDelay());
|
||||
channel.socket().setSoTimeout(_netConfig.getConnectionTimeout());
|
||||
channel.configureBlocking(false); // Non-blocking I/O.
|
||||
|
||||
// Create client.
|
||||
final E client = _clientSupplier.get();
|
||||
client.init(channel, _netConfig);
|
||||
|
||||
// Add to read pool.
|
||||
|
||||
// Find a pool that is not full.
|
||||
boolean readPoolFound = false;
|
||||
READ_POOLS: for (Set<E> pool : _clientReadPools)
|
||||
{
|
||||
if (pool.size() < _netConfig.getReadPoolSize())
|
||||
{
|
||||
pool.add(client);
|
||||
readPoolFound = true;
|
||||
break READ_POOLS;
|
||||
}
|
||||
}
|
||||
|
||||
// All pools are full.
|
||||
if (!readPoolFound)
|
||||
{
|
||||
// Create a new client pool.
|
||||
final Set<E> newReadPool = ConcurrentHashMap.newKeySet(_netConfig.getReadPoolSize());
|
||||
newReadPool.add(client);
|
||||
// Create a new task for the new pool.
|
||||
final Thread readThread = new Thread(new ReadThread<>(newReadPool), _name + ": Packet read thread " + _clientReadPools.size());
|
||||
readThread.setPriority(Thread.MAX_PRIORITY);
|
||||
readThread.setDaemon(true);
|
||||
readThread.start();
|
||||
// Add the new pool to the pool list.
|
||||
_clientReadPools.add(newReadPool);
|
||||
}
|
||||
|
||||
// Add to execute pool.
|
||||
|
||||
// Find a pool that is not full.
|
||||
boolean executePoolFound = false;
|
||||
EXECUTE_POOLS: for (Set<E> pool : _clientExecutePools)
|
||||
{
|
||||
if (pool.size() < _netConfig.getExecutePoolSize())
|
||||
{
|
||||
pool.add(client);
|
||||
executePoolFound = true;
|
||||
break EXECUTE_POOLS;
|
||||
}
|
||||
}
|
||||
|
||||
// All pools are full.
|
||||
if (!executePoolFound)
|
||||
{
|
||||
// Create a new client pool.
|
||||
final Set<E> newExecutePool = ConcurrentHashMap.newKeySet(_netConfig.getExecutePoolSize());
|
||||
newExecutePool.add(client);
|
||||
// Create a new task for the new pool.
|
||||
final Thread executeThread = new Thread(new ExecuteThread<>(newExecutePool, _packetHandler), _name + ": Packet execute thread " + _clientExecutePools.size());
|
||||
executeThread.setPriority(Thread.MAX_PRIORITY);
|
||||
executeThread.setDaemon(true);
|
||||
executeThread.start();
|
||||
// Add the new pool to the pool list.
|
||||
_clientExecutePools.add(newExecutePool);
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent high CPU caused by repeatedly polling the channel.
|
||||
currentTime = System.currentTimeMillis();
|
||||
if ((currentTime - executionStart) < 1)
|
||||
{
|
||||
Thread.sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.warning(_name + ": Problem initializing. " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,76 +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 org.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 static final Logger LOGGER = Logger.getLogger(NetworkManager.class.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,13 @@
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
/**
|
||||
* @author Pantelis Andrianakis
|
||||
* @since October 4th 2022
|
||||
* @param <E> extends NetClient
|
||||
*/
|
||||
public interface PacketHandlerInterface<E extends NetClient>
|
||||
{
|
||||
default void handle(E client, ReadablePacket packet)
|
||||
{
|
||||
}
|
||||
}
|
@ -1,163 +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 org.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public 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) > _buf.readableBytes())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,141 +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 org.l2jmobius.commons.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author Nos
|
||||
*/
|
||||
public 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,127 @@
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Pantelis Andrianakis
|
||||
* @since September 7th 2020
|
||||
* @param <E> extends NetClient
|
||||
*/
|
||||
public class ReadThread<E extends NetClient> implements Runnable
|
||||
{
|
||||
private final ByteBuffer _sizeBuffer = ByteBuffer.allocate(2); // Reusable size buffer.
|
||||
private final Set<E> _pool;
|
||||
|
||||
public ReadThread(Set<E> pool)
|
||||
{
|
||||
_pool = pool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
long executionStart;
|
||||
long currentTime;
|
||||
while (true)
|
||||
{
|
||||
executionStart = System.currentTimeMillis();
|
||||
|
||||
// No need to iterate when pool is empty.
|
||||
if (!_pool.isEmpty())
|
||||
{
|
||||
// Iterate client pool.
|
||||
ITERATE: for (E client : _pool)
|
||||
{
|
||||
try
|
||||
{
|
||||
final SocketChannel channel = client.getChannel();
|
||||
if (channel == null) // Unexpected disconnection?
|
||||
{
|
||||
// Null SocketChannel: client
|
||||
onDisconnection(client);
|
||||
continue ITERATE;
|
||||
}
|
||||
|
||||
// Read incoming packet size (short).
|
||||
_sizeBuffer.clear();
|
||||
switch (channel.read(_sizeBuffer))
|
||||
{
|
||||
// Disconnected.
|
||||
case -1:
|
||||
{
|
||||
onDisconnection(client);
|
||||
continue ITERATE;
|
||||
}
|
||||
// Nothing read.
|
||||
case 0:
|
||||
{
|
||||
continue ITERATE;
|
||||
}
|
||||
// Read actual packet bytes.
|
||||
default:
|
||||
{
|
||||
// Allocate a new ByteBuffer based on packet size read.
|
||||
final ByteBuffer packetByteBuffer = ByteBuffer.allocate(calculatePacketSize());
|
||||
switch (channel.read(packetByteBuffer))
|
||||
{
|
||||
// Disconnected.
|
||||
case -1:
|
||||
{
|
||||
onDisconnection(client);
|
||||
continue ITERATE;
|
||||
}
|
||||
// Nothing read.
|
||||
case 0:
|
||||
{
|
||||
continue ITERATE;
|
||||
}
|
||||
// Send data read to the client packet queue.
|
||||
default:
|
||||
{
|
||||
client.addPacketData(packetByteBuffer.array());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SocketTimeoutException e)
|
||||
{
|
||||
onDisconnection(client);
|
||||
}
|
||||
catch (Exception e) // Unexpected disconnection?
|
||||
{
|
||||
onDisconnection(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent high CPU caused by repeatedly looping.
|
||||
currentTime = System.currentTimeMillis();
|
||||
if ((currentTime - executionStart) < 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(1);
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int calculatePacketSize()
|
||||
{
|
||||
_sizeBuffer.rewind();
|
||||
return ((_sizeBuffer.get() & 0xff) | ((_sizeBuffer.get() << 8) & 0xffff)) - 2;
|
||||
}
|
||||
|
||||
private void onDisconnection(E client)
|
||||
{
|
||||
_pool.remove(client);
|
||||
client.onDisconnection();
|
||||
}
|
||||
}
|
@ -0,0 +1,184 @@
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author Pantelis Andrianakis
|
||||
* @since October 29th 2020
|
||||
*/
|
||||
public class ReadablePacket
|
||||
{
|
||||
private final byte[] _bytes;
|
||||
private int _position = 0;
|
||||
|
||||
public ReadablePacket(byte[] bytes)
|
||||
{
|
||||
_bytes = bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>boolean</b> from the packet data.<br>
|
||||
* 8bit integer (00) or (01)
|
||||
* @return
|
||||
*/
|
||||
public boolean readBoolean()
|
||||
{
|
||||
return readByte() != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>String</b> from the packet data.
|
||||
* @return
|
||||
*/
|
||||
public String readString()
|
||||
{
|
||||
final StringBuilder result = new StringBuilder();
|
||||
try
|
||||
{
|
||||
int charId;
|
||||
while ((charId = readShort() & 0x00ff) != 0)
|
||||
{
|
||||
result.append((char) charId);
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>String</b> with fixed size specified as (short size, char[size]) from the packet data.
|
||||
* @return
|
||||
*/
|
||||
public String readSizedString()
|
||||
{
|
||||
String result = "";
|
||||
try
|
||||
{
|
||||
result = new String(readBytes(readShort()), StandardCharsets.UTF_16LE);
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>byte[]</b> from the packet data.<br>
|
||||
* 8bit integer array (00...)
|
||||
* @param length of the array.
|
||||
* @return
|
||||
*/
|
||||
public byte[] readBytes(int length)
|
||||
{
|
||||
final byte[] result = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
result[i] = _bytes[_position++];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>byte[]</b> from the packet data.<br>
|
||||
* 8bit integer array (00...)
|
||||
* @param array used to store data.
|
||||
* @return
|
||||
*/
|
||||
public byte[] readBytes(byte[] array)
|
||||
{
|
||||
for (int i = 0; i < array.length; i++)
|
||||
{
|
||||
array[i] = _bytes[_position++];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>byte</b> from the packet data.<br>
|
||||
* 8bit integer (00)
|
||||
* @return
|
||||
*/
|
||||
public int readByte()
|
||||
{
|
||||
return _bytes[_position++] & 0xff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>short</b> from the packet data.<br>
|
||||
* 16bit integer (00 00)
|
||||
* @return
|
||||
*/
|
||||
public int readShort()
|
||||
{
|
||||
return (_bytes[_position++] & 0xff) //
|
||||
| ((_bytes[_position++] << 8) & 0xff00);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>int</b> from the packet data.<br>
|
||||
* 32bit integer (00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
public int readInt()
|
||||
{
|
||||
return (_bytes[_position++] & 0xff) //
|
||||
| ((_bytes[_position++] << 8) & 0xff00) //
|
||||
| ((_bytes[_position++] << 16) & 0xff0000) //
|
||||
| ((_bytes[_position++] << 24) & 0xff000000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>long</b> from the packet data.<br>
|
||||
* 64bit integer (00 00 00 00 00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
public long readLong()
|
||||
{
|
||||
return (_bytes[_position++] & 0xff) //
|
||||
| ((_bytes[_position++] << 8) & 0xff00) //
|
||||
| ((_bytes[_position++] << 16) & 0xff0000) //
|
||||
| ((_bytes[_position++] << 24) & 0xff000000) //
|
||||
| (((long) _bytes[_position++] << 32) & 0xff00000000L) //
|
||||
| (((long) _bytes[_position++] << 40) & 0xff0000000000L) //
|
||||
| (((long) _bytes[_position++] << 48) & 0xff000000000000L) //
|
||||
| (((long) _bytes[_position++] << 56) & 0xff00000000000000L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>float</b> from the packet data.<br>
|
||||
* 32bit single precision float (00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
public float readFloat()
|
||||
{
|
||||
return Float.intBitsToFloat(readInt());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads <b>double</b> from the packet data.<br>
|
||||
* 64bit double precision float (00 00 00 00 00 00 00 00)
|
||||
* @return
|
||||
*/
|
||||
public double readDouble()
|
||||
{
|
||||
return Double.longBitsToDouble(readLong());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of unread bytes.
|
||||
*/
|
||||
public int getRemainingLength()
|
||||
{
|
||||
return _bytes.length - _position;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the byte size.
|
||||
*/
|
||||
public int getLength()
|
||||
{
|
||||
return _bytes.length;
|
||||
}
|
||||
}
|
@ -0,0 +1,321 @@
|
||||
package org.l2jmobius.commons.network;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Writable packet backed up by a byte array, with a maximum raw data size of 65533 bytes.
|
||||
* @author Pantelis Andrianakis
|
||||
* @since October 29th 2020
|
||||
*/
|
||||
public abstract class WritablePacket
|
||||
{
|
||||
private byte[] _data;
|
||||
private byte[] _sendableBytes;
|
||||
private ByteBuffer _byteBuffer;
|
||||
private int _position = 2; // Allocate space for size (max length 65535 - size header).
|
||||
|
||||
/**
|
||||
* Construct a WritablePacket with an initial data size of 32 bytes.
|
||||
*/
|
||||
protected WritablePacket()
|
||||
{
|
||||
this(32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a WritablePacket with a given initial data size.
|
||||
* @param initialSize
|
||||
*/
|
||||
protected WritablePacket(int initialSize)
|
||||
{
|
||||
_data = new byte[initialSize];
|
||||
}
|
||||
|
||||
public void write(byte value)
|
||||
{
|
||||
// Check current size.
|
||||
if (_position < 65535)
|
||||
{
|
||||
// Check capacity.
|
||||
if (_position == _data.length)
|
||||
{
|
||||
_data = Arrays.copyOf(_data, _data.length * 2); // Double the capacity.
|
||||
}
|
||||
|
||||
// Set value.
|
||||
_data[_position++] = value;
|
||||
return;
|
||||
}
|
||||
|
||||
throw new IndexOutOfBoundsException("Packet data exceeded the raw data size limit of 65533!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>boolean</b> to the packet data.<br>
|
||||
* 8bit integer (00) or (01)
|
||||
* @param value
|
||||
*/
|
||||
public void writeBoolean(boolean value)
|
||||
{
|
||||
writeByte(value ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>String</b> to the packet data.
|
||||
* @param text
|
||||
*/
|
||||
public void writeString(String text)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
final byte[] bytes = text.getBytes(StandardCharsets.UTF_16LE);
|
||||
for (int i = 0; i < bytes.length; i++)
|
||||
{
|
||||
writeByte(bytes[i]);
|
||||
}
|
||||
}
|
||||
writeShort(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>String</b> with fixed size specified as (short size, char[size]) to the packet data.
|
||||
* @param text
|
||||
*/
|
||||
public void writeSizedString(String text)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
writeShort(text.length());
|
||||
final byte[] bytes = text.getBytes(StandardCharsets.UTF_16LE);
|
||||
for (int i = 0; i < bytes.length; i++)
|
||||
{
|
||||
writeByte(bytes[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writeShort(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>byte[]</b> to the packet data.<br>
|
||||
* 8bit integer array (00...)
|
||||
* @param array
|
||||
*/
|
||||
public void writeBytes(byte[] array)
|
||||
{
|
||||
for (int i = 0; i < array.length; i++)
|
||||
{
|
||||
write(array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>byte</b> to the packet data.<br>
|
||||
* 8bit integer (00)
|
||||
* @param value
|
||||
*/
|
||||
public void writeByte(int value)
|
||||
{
|
||||
write((byte) (value & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>boolean</b> to the packet data.<br>
|
||||
* 8bit integer (00) or (01)
|
||||
* @param value
|
||||
*/
|
||||
public void writeByte(boolean value)
|
||||
{
|
||||
writeByte(value ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>short</b> to the packet data.<br>
|
||||
* 16bit integer (00 00)
|
||||
* @param value
|
||||
*/
|
||||
public void writeShort(int value)
|
||||
{
|
||||
write((byte) (value & 0xff));
|
||||
write((byte) ((value >> 8) & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>boolean</b> to the packet data.<br>
|
||||
* 16bit integer (00 00)
|
||||
* @param value
|
||||
*/
|
||||
public void writeShort(boolean value)
|
||||
{
|
||||
writeShort(value ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>int</b> to the packet data.<br>
|
||||
* 32bit integer (00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
public void writeInt(int value)
|
||||
{
|
||||
write((byte) (value & 0xff));
|
||||
write((byte) ((value >> 8) & 0xff));
|
||||
write((byte) ((value >> 16) & 0xff));
|
||||
write((byte) ((value >> 24) & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>boolean</b> to the packet data.<br>
|
||||
* 32bit integer (00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
public void writeInt(boolean value)
|
||||
{
|
||||
writeInt(value ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>long</b> to the packet data.<br>
|
||||
* 64bit integer (00 00 00 00 00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
public void writeLong(long value)
|
||||
{
|
||||
write((byte) (value & 0xff));
|
||||
write((byte) ((value >> 8) & 0xff));
|
||||
write((byte) ((value >> 16) & 0xff));
|
||||
write((byte) ((value >> 24) & 0xff));
|
||||
write((byte) ((value >> 32) & 0xff));
|
||||
write((byte) ((value >> 40) & 0xff));
|
||||
write((byte) ((value >> 48) & 0xff));
|
||||
write((byte) ((value >> 56) & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>boolean</b> to the packet data.<br>
|
||||
* 64bit integer (00 00 00 00 00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
public void writeLong(boolean value)
|
||||
{
|
||||
writeLong(value ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>float</b> to the packet data.<br>
|
||||
* 32bit single precision float (00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
public void writeFloat(float value)
|
||||
{
|
||||
writeInt(Float.floatToRawIntBits(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write <b>double</b> to the packet data.<br>
|
||||
* 64bit double precision float (00 00 00 00 00 00 00 00)
|
||||
* @param value
|
||||
*/
|
||||
public void writeDouble(double value)
|
||||
{
|
||||
writeLong(Double.doubleToRawLongBits(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be overridden to write data after packet has initialized.<br>
|
||||
* Called when getSendableBytes generates data, ensures that the data are processed only once.
|
||||
*/
|
||||
public void write()
|
||||
{
|
||||
// Overridden by server implementation.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <b>byte[]</b> of the sendable packet data, including a size header.
|
||||
*/
|
||||
public byte[] getSendableBytes()
|
||||
{
|
||||
return getSendableBytes(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param encryption if EncryptionInterface is used.
|
||||
* @return <b>byte[]</b> of the sendable packet data, including a size header.
|
||||
*/
|
||||
public synchronized byte[] getSendableBytes(EncryptionInterface encryption)
|
||||
{
|
||||
// Generate sendable byte array.
|
||||
if ((_sendableBytes == null /* Not processed */) || (encryption != null /* Encryption can change */))
|
||||
{
|
||||
// Write packet implementation (only once).
|
||||
if (_position == 2)
|
||||
{
|
||||
write();
|
||||
}
|
||||
|
||||
// Check if data was written.
|
||||
if (_position > 2)
|
||||
{
|
||||
// Trim array of data.
|
||||
_sendableBytes = Arrays.copyOf(_data, _position);
|
||||
|
||||
// Add size info at start (unsigned short - max size 65535).
|
||||
_sendableBytes[0] = (byte) (_position & 0xff);
|
||||
_sendableBytes[1] = (byte) ((_position >> 8) & 0xffff);
|
||||
|
||||
// Encrypt data.
|
||||
if (encryption != null)
|
||||
{
|
||||
encryption.encrypt(_sendableBytes, 2, _position - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the data.
|
||||
return _sendableBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ByteBuffer of the sendable packet data, including a size header.
|
||||
*/
|
||||
public ByteBuffer getSendableByteBuffer()
|
||||
{
|
||||
return getSendableByteBuffer(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param encryption if EncryptionInterface is used.
|
||||
* @return ByteBuffer of the sendable packet data, including a size header.
|
||||
*/
|
||||
public synchronized ByteBuffer getSendableByteBuffer(EncryptionInterface encryption)
|
||||
{
|
||||
// Generate sendable ByteBuffer.
|
||||
if ((_byteBuffer == null /* Not processed */) || (encryption != null /* Encryption can change */))
|
||||
{
|
||||
final byte[] bytes = getSendableBytes(encryption);
|
||||
if (bytes != null) // Data was actually written.
|
||||
{
|
||||
_byteBuffer = ByteBuffer.wrap(bytes);
|
||||
}
|
||||
}
|
||||
else // Rewind the buffer.
|
||||
{
|
||||
_byteBuffer.rewind();
|
||||
}
|
||||
|
||||
// Return the buffer.
|
||||
return _byteBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take in consideration that data must be written first.
|
||||
* @return The length of the data (includes size header).
|
||||
*/
|
||||
public int getLength()
|
||||
{
|
||||
return _position;
|
||||
}
|
||||
}
|
@ -1,71 +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 org.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.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()));
|
||||
}
|
||||
}
|
@ -1,41 +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 org.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());
|
||||
}
|
||||
}
|
@ -1,91 +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 org.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.network.IConnectionState;
|
||||
import org.l2jmobius.commons.network.IIncomingPacket;
|
||||
import org.l2jmobius.commons.network.IIncomingPackets;
|
||||
import org.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());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,71 +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 org.l2jmobius.commons.network.codecs;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.network.IOutgoingPacket;
|
||||
import org.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 expected client 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,149 +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 org.l2jmobius.commons.util.crypt;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import org.l2jmobius.commons.network.ICrypt;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class LoginCrypt implements ICrypt
|
||||
{
|
||||
private static final byte[] STATIC_BLOWFISH_KEY =
|
||||
{
|
||||
(byte) 0x6b,
|
||||
(byte) 0x60,
|
||||
(byte) 0xcb,
|
||||
(byte) 0x5b,
|
||||
(byte) 0x82,
|
||||
(byte) 0xce,
|
||||
(byte) 0x90,
|
||||
(byte) 0xb1,
|
||||
(byte) 0xcc,
|
||||
(byte) 0x2b,
|
||||
(byte) 0x6c,
|
||||
(byte) 0x55,
|
||||
(byte) 0x6c,
|
||||
(byte) 0x6c,
|
||||
(byte) 0x6c,
|
||||
(byte) 0x6c
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
public LoginCrypt(SecretKey blowfishKey)
|
||||
{
|
||||
_blowfishEngine.init(blowfishKey.getEncoded());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.l2jmobius.commons.network.ICrypt#encrypt(io.netty.buffer.ByteBuf)
|
||||
*/
|
||||
@Override
|
||||
public void encrypt(ByteBuf buf)
|
||||
{
|
||||
// Checksum & XOR Key or Checksum only
|
||||
buf.writeZero(_static ? 16 : 12);
|
||||
|
||||
// Padding
|
||||
buf.writeZero(8 - (buf.readableBytes() % 8));
|
||||
|
||||
if (_static)
|
||||
{
|
||||
_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
|
||||
{
|
||||
int checksum = 0;
|
||||
while (buf.isReadable(8))
|
||||
{
|
||||
checksum ^= buf.readIntLE();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.l2jmobius.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!
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.enums.ServerMode;
|
||||
import org.l2jmobius.commons.network.NetServer;
|
||||
import org.l2jmobius.commons.threads.ThreadPool;
|
||||
import org.l2jmobius.commons.util.DeadLockDetector;
|
||||
import org.l2jmobius.commons.util.PropertiesParser;
|
||||
@ -152,10 +153,10 @@ import org.l2jmobius.gameserver.model.events.EventType;
|
||||
import org.l2jmobius.gameserver.model.events.impl.OnServerStart;
|
||||
import org.l2jmobius.gameserver.model.olympiad.Hero;
|
||||
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import org.l2jmobius.gameserver.network.ClientNetworkManager;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.NpcStringId;
|
||||
import org.l2jmobius.gameserver.network.PacketHandler;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.telnet.TelnetServer;
|
||||
import org.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.ItemsAutoDestroyTaskManager;
|
||||
@ -224,9 +225,6 @@ public class GameServer
|
||||
EventDispatcher.getInstance();
|
||||
ScriptEngineManager.getInstance();
|
||||
|
||||
printSection("Telnet");
|
||||
TelnetServer.getInstance();
|
||||
|
||||
printSection("World");
|
||||
World.getInstance();
|
||||
MapRegionManager.getInstance();
|
||||
@ -463,7 +461,17 @@ public class GameServer
|
||||
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.");
|
||||
|
||||
ClientNetworkManager.getInstance().start();
|
||||
final NetServer<GameClient> server = new NetServer<>(Config.GAMESERVER_HOSTNAME, Config.PORT_GAME, new PacketHandler(), GameClient::new);
|
||||
server.setName(getClass().getSimpleName());
|
||||
server.getNetConfig().setReadPoolSize(Config.CLIENT_READ_POOL_SIZE);
|
||||
server.getNetConfig().setExecutePoolSize(Config.CLIENT_EXECUTE_POOL_SIZE);
|
||||
server.getNetConfig().setPacketQueueLimit(Config.PACKET_QUEUE_LIMIT);
|
||||
server.getNetConfig().setPacketFloodDisconnect(Config.PACKET_FLOOD_DISCONNECT);
|
||||
server.getNetConfig().setPacketFloodDrop(Config.PACKET_FLOOD_DROP);
|
||||
server.getNetConfig().setPacketFloodLogged(Config.PACKET_FLOOD_LOGGED);
|
||||
server.getNetConfig().setTcpNoDelay(Config.TCP_NO_DELAY);
|
||||
server.getNetConfig().setConnectionTimeout(Config.CONNECTION_TIMEOUT);
|
||||
server.start();
|
||||
|
||||
LoginServerThread.getInstance().start();
|
||||
|
||||
|
@ -42,10 +42,10 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.crypt.NewCrypt;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.network.BaseSendablePacket;
|
||||
import org.l2jmobius.commons.network.WritablePacket;
|
||||
import org.l2jmobius.commons.util.CommonUtil;
|
||||
import org.l2jmobius.commons.util.crypt.NewCrypt;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.ConnectionState;
|
||||
@ -308,6 +308,7 @@ public class LoginServerThread extends Thread
|
||||
if (wc.account.equals(account))
|
||||
{
|
||||
wcToRemove = wc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -361,7 +362,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (SocketException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": LoginServer not avaible, trying to reconnect...");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": LoginServer not available, trying to reconnect...");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
@ -396,25 +397,26 @@ public class LoginServerThread extends Thread
|
||||
|
||||
/**
|
||||
* Adds the waiting client and send request.
|
||||
* @param acc the account
|
||||
* @param accountName the account
|
||||
* @param client the game client
|
||||
* @param key the session key
|
||||
*/
|
||||
public void addWaitingClientAndSendRequest(String acc, GameClient client, SessionKey key)
|
||||
public void addWaitingClientAndSendRequest(String accountName, GameClient client, SessionKey key)
|
||||
{
|
||||
final WaitingClient wc = new WaitingClient(acc, client, key);
|
||||
final WaitingClient wc = new WaitingClient(accountName, client, key);
|
||||
synchronized (_waitingClients)
|
||||
{
|
||||
_waitingClients.add(wc);
|
||||
}
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(acc, key);
|
||||
|
||||
final PlayerAuthRequest par = new PlayerAuthRequest(accountName, key);
|
||||
try
|
||||
{
|
||||
sendPacket(par);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending player auth request.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,6 +434,7 @@ public class LoginServerThread extends Thread
|
||||
if (c.gameClient == client)
|
||||
{
|
||||
toRemove = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (toRemove != null)
|
||||
@ -458,7 +461,7 @@ public class LoginServerThread extends Thread
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login");
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Error while sending logout packet to login.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -630,25 +633,38 @@ public class LoginServerThread extends Thread
|
||||
|
||||
/**
|
||||
* Send packet.
|
||||
* @param sl the sendable packet
|
||||
* @param packet the sendable packet
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private void sendPacket(BaseSendablePacket sl) throws IOException
|
||||
private void sendPacket(WritablePacket packet) throws IOException
|
||||
{
|
||||
if (_blowfish == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final byte[] data = sl.getContent();
|
||||
NewCrypt.appendChecksum(data);
|
||||
_blowfish.crypt(data, 0, data.length);
|
||||
|
||||
final int len = data.length + 2;
|
||||
synchronized (_out) // avoids tow threads writing in the mean time
|
||||
packet.write(); // write initial data
|
||||
packet.writeInt(0); // reserved for checksum
|
||||
int size = packet.getLength() - 2; // size without header
|
||||
final int padding = size % 8; // padding of 8 bytes
|
||||
if (padding != 0)
|
||||
{
|
||||
for (int i = padding; i < 8; i++)
|
||||
{
|
||||
packet.writeByte(0);
|
||||
}
|
||||
}
|
||||
|
||||
// size header + encrypted[data + checksum (int) + padding]
|
||||
final byte[] data = packet.getSendableBytes();
|
||||
|
||||
// encrypt
|
||||
size = data.length - 2; // data size without header
|
||||
NewCrypt.appendChecksum(data, 2, size);
|
||||
_blowfish.crypt(data, 2, size);
|
||||
|
||||
synchronized (_out)
|
||||
{
|
||||
_out.write(len & 0xff);
|
||||
_out.write((len >> 8) & 0xff);
|
||||
_out.write(data);
|
||||
_out.flush();
|
||||
}
|
||||
|
@ -39,14 +39,11 @@ import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.olympiad.Hero;
|
||||
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import org.l2jmobius.gameserver.network.ClientNetworkManager;
|
||||
import org.l2jmobius.gameserver.network.Disconnection;
|
||||
import org.l2jmobius.gameserver.network.EventLoopGroupManager;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.loginserverpackets.game.ServerStatus;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerClose;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.telnet.TelnetServer;
|
||||
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
@ -77,7 +74,7 @@ public class Shutdown extends Thread
|
||||
private int _shutdownMode;
|
||||
|
||||
/**
|
||||
* This function starts a shutdown count down from Telnet (Copied from Function startShutdown())
|
||||
* This function starts a shutdown count down (Copied from Function startShutdown())
|
||||
* @param seconds seconds until shutdown
|
||||
*/
|
||||
private void sendServerQuit(int seconds)
|
||||
@ -176,32 +173,10 @@ public class Shutdown extends Thread
|
||||
// ignore
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
TelnetServer.getInstance().shutdown();
|
||||
LOGGER.info("Telnet Server Thread: Thread interruped(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
// last byebye, save all data and quit this server
|
||||
saveData();
|
||||
tc.restartCounter();
|
||||
|
||||
// saveData sends messages to exit players, so shutdown selector after it
|
||||
try
|
||||
{
|
||||
ClientNetworkManager.getInstance().stop();
|
||||
EventLoopGroupManager.getInstance().shutdown();
|
||||
LOGGER.info("Game Server: Selector thread has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
// commit data, last chance
|
||||
try
|
||||
{
|
||||
|
@ -446,7 +446,7 @@ public class BotReportTable
|
||||
*/
|
||||
private static int hashIp(Player player)
|
||||
{
|
||||
final String con = player.getClient().getConnectionAddress().getHostAddress();
|
||||
final String con = player.getClient().getIp();
|
||||
final String[] rawByte = con.split("\\.");
|
||||
final int[] rawIp = new int[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
@ -35,7 +35,7 @@ import org.l2jmobius.gameserver.model.AdminCommandAccessRight;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@ -293,7 +293,7 @@ public class AdminData implements IXmlReader
|
||||
* Broadcast to GMs.
|
||||
* @param packet the packet
|
||||
*/
|
||||
public void broadcastToGMs(IClientOutgoingPacket packet)
|
||||
public void broadcastToGMs(ServerPacket packet)
|
||||
{
|
||||
for (Player gm : getAllGms(true))
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ public class AntiFeedManager
|
||||
return !Config.ANTIFEED_DISCONNECTED_AS_DUALBOX;
|
||||
}
|
||||
|
||||
return !targetClient.getConnectionAddress().equals(attackerClient.getConnectionAddress());
|
||||
return !targetClient.getIp().equals(attackerClient.getIp());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -157,7 +157,7 @@ public class AntiFeedManager
|
||||
return false; // no such event registered
|
||||
}
|
||||
|
||||
final Integer addrHash = client.getConnectionAddress().hashCode();
|
||||
final Integer addrHash = client.getIp().hashCode();
|
||||
final AtomicInteger connectionCount = event.computeIfAbsent(addrHash, k -> new AtomicInteger());
|
||||
if ((connectionCount.get() + 1) <= (max + Config.DUALBOX_CHECK_WHITELIST.getOrDefault(addrHash, 0)))
|
||||
{
|
||||
@ -198,7 +198,7 @@ public class AntiFeedManager
|
||||
return false; // no such event registered
|
||||
}
|
||||
|
||||
final Integer addrHash = client.getConnectionAddress().hashCode();
|
||||
final Integer addrHash = client.getIp().hashCode();
|
||||
return event.computeIfPresent(addrHash, (k, v) ->
|
||||
{
|
||||
if ((v == null) || (v.decrementAndGet() == 0))
|
||||
@ -215,7 +215,7 @@ public class AntiFeedManager
|
||||
*/
|
||||
public void onDisconnect(GameClient client)
|
||||
{
|
||||
if ((client == null) || (client.getConnectionAddress() == null) || (client.getPlayer() == null))
|
||||
if ((client == null) || (client.getIp() == null) || (client.getPlayer() == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -258,7 +258,7 @@ public class AntiFeedManager
|
||||
return max;
|
||||
}
|
||||
|
||||
final Integer addrHash = client.getConnectionAddress().hashCode();
|
||||
final Integer addrHash = client.getIp().hashCode();
|
||||
int limit = max;
|
||||
if (Config.DUALBOX_CHECK_WHITELIST.containsKey(addrHash))
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.Boat;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.CreatureTemplate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
|
||||
public class BoatManager
|
||||
{
|
||||
@ -156,7 +156,7 @@ public class BoatManager
|
||||
* @param point2
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastPacket(VehiclePathPoint point1, VehiclePathPoint point2, IClientOutgoingPacket packet)
|
||||
public void broadcastPacket(VehiclePathPoint point1, VehiclePathPoint point2, ServerPacket packet)
|
||||
{
|
||||
broadcastPacketsToPlayers(point1, point2, packet);
|
||||
}
|
||||
@ -167,25 +167,19 @@ public class BoatManager
|
||||
* @param point2
|
||||
* @param packets
|
||||
*/
|
||||
public void broadcastPackets(VehiclePathPoint point1, VehiclePathPoint point2, IClientOutgoingPacket... packets)
|
||||
public void broadcastPackets(VehiclePathPoint point1, VehiclePathPoint point2, ServerPacket... packets)
|
||||
{
|
||||
broadcastPacketsToPlayers(point1, point2, packets);
|
||||
}
|
||||
|
||||
private void broadcastPacketsToPlayers(VehiclePathPoint point1, VehiclePathPoint point2, IClientOutgoingPacket... packets)
|
||||
private void broadcastPacketsToPlayers(VehiclePathPoint point1, VehiclePathPoint point2, ServerPacket... packets)
|
||||
{
|
||||
for (Player player : World.getInstance().getPlayers())
|
||||
{
|
||||
if (Math.hypot(player.getX() - point1.getX(), player.getY() - point1.getY()) < Config.BOAT_BROADCAST_RADIUS)
|
||||
if ((Math.hypot(player.getX() - point1.getX(), player.getY() - point1.getY()) < Config.BOAT_BROADCAST_RADIUS) || //
|
||||
(Math.hypot(player.getX() - point2.getX(), player.getY() - point2.getY()) < Config.BOAT_BROADCAST_RADIUS))
|
||||
{
|
||||
for (IClientOutgoingPacket p : packets)
|
||||
{
|
||||
player.sendPacket(p);
|
||||
}
|
||||
}
|
||||
else if (Math.hypot(player.getX() - point2.getX(), player.getY() - point2.getY()) < Config.BOAT_BROADCAST_RADIUS)
|
||||
{
|
||||
for (IClientOutgoingPacket p : packets)
|
||||
for (ServerPacket p : packets)
|
||||
{
|
||||
player.sendPacket(p);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.model.Duel;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
|
||||
public class DuelManager
|
||||
{
|
||||
@ -174,7 +174,7 @@ public class DuelManager
|
||||
* @param player
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastToOppositTeam(Player player, IClientOutgoingPacket packet)
|
||||
public void broadcastToOppositTeam(Player player, ServerPacket packet)
|
||||
{
|
||||
if ((player == null) || !player.isInDuel())
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ import org.l2jmobius.gameserver.enums.Race;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@ -130,7 +130,7 @@ public abstract class AbstractPlayerGroup
|
||||
* Broadcast a packet to every member of this group.
|
||||
* @param packet the packet to broadcast
|
||||
*/
|
||||
public void broadcastPacket(IClientOutgoingPacket packet)
|
||||
public void broadcastPacket(ServerPacket packet)
|
||||
{
|
||||
forEachMember(m ->
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ import org.l2jmobius.gameserver.instancemanager.HandysBlockCheckerManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.games.BlockChecker;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@ -112,7 +112,7 @@ public class ArenaParticipantsHolder
|
||||
return _bluePlayers.size();
|
||||
}
|
||||
|
||||
public void broadCastPacketToTeam(IClientOutgoingPacket packet)
|
||||
public void broadCastPacketToTeam(ServerPacket packet)
|
||||
{
|
||||
for (Player p : _redPlayers)
|
||||
{
|
||||
|
@ -45,8 +45,8 @@ import org.l2jmobius.gameserver.network.serverpackets.ExDuelEnd;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExDuelReady;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExDuelStart;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExDuelUpdateUserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
@ -644,7 +644,7 @@ public class Duel
|
||||
* Broadcast a packet to the challenger team
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastToTeam1(IClientOutgoingPacket packet)
|
||||
public void broadcastToTeam1(ServerPacket packet)
|
||||
{
|
||||
if (_playerA == null)
|
||||
{
|
||||
@ -668,7 +668,7 @@ public class Duel
|
||||
* Broadcast a packet to the challenged team
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastToTeam2(IClientOutgoingPacket packet)
|
||||
public void broadcastToTeam2(ServerPacket packet)
|
||||
{
|
||||
if (_playerB == null)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
@ -119,7 +119,7 @@ public class Mentee
|
||||
return isOnline() ? getPlayer().isOnlineInt() : 0;
|
||||
}
|
||||
|
||||
public void sendPacket(IClientOutgoingPacket packet)
|
||||
public void sendPacket(ServerPacket packet)
|
||||
{
|
||||
if (isOnline())
|
||||
{
|
||||
|
@ -57,12 +57,12 @@ import org.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowAdd;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowDelete;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExSetPartyLooting;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExTacticalSign;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PartyMemberPosition;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PartySmallWindowAdd;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PartySmallWindowAll;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PartySmallWindowDelete;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PartySmallWindowDeleteAll;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
@ -265,15 +265,15 @@ public class Party extends AbstractPlayerGroup
|
||||
/**
|
||||
* Send a Server->Client packet to all other Player of the Party.
|
||||
* @param player
|
||||
* @param msg
|
||||
* @param packet
|
||||
*/
|
||||
public void broadcastToPartyMembers(Player player, IClientOutgoingPacket msg)
|
||||
public void broadcastToPartyMembers(Player player, ServerPacket packet)
|
||||
{
|
||||
for (Player member : _members)
|
||||
{
|
||||
if ((member != null) && (member.getObjectId() != player.getObjectId()))
|
||||
{
|
||||
member.sendPacket(msg);
|
||||
member.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ import org.l2jmobius.gameserver.instancemanager.PetitionManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PetitionVotePacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@ -136,7 +136,7 @@ public class Petition
|
||||
return _type.toString().replace("_", " ");
|
||||
}
|
||||
|
||||
public void sendPetitionerPacket(IClientOutgoingPacket responsePacket)
|
||||
public void sendPetitionerPacket(ServerPacket responsePacket)
|
||||
{
|
||||
if ((_petitioner == null) || !_petitioner.isOnline())
|
||||
{
|
||||
@ -150,7 +150,7 @@ public class Petition
|
||||
_petitioner.sendPacket(responsePacket);
|
||||
}
|
||||
|
||||
public void sendResponderPacket(IClientOutgoingPacket responsePacket)
|
||||
public void sendResponderPacket(ServerPacket responsePacket)
|
||||
{
|
||||
if ((_responder == null) || !_responder.isOnline())
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model;
|
||||
import org.l2jmobius.commons.threads.ThreadPool;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.ClientPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@ -34,7 +34,7 @@ public class Request
|
||||
protected Player _partner;
|
||||
protected boolean _isRequestor;
|
||||
protected boolean _isAnswerer;
|
||||
protected IClientIncomingPacket _requestPacket;
|
||||
protected ClientPacket _requestPacket;
|
||||
|
||||
public Request(Player player)
|
||||
{
|
||||
@ -67,19 +67,19 @@ public class Request
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the packet incomed from requester.
|
||||
* Set the packet that came from requester.
|
||||
* @param packet
|
||||
*/
|
||||
private synchronized void setRequestPacket(IClientIncomingPacket packet)
|
||||
private synchronized void setRequestPacket(ClientPacket packet)
|
||||
{
|
||||
_requestPacket = packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the packet originally incomed from requester.
|
||||
* Return the packet originally the came from requester.
|
||||
* @return
|
||||
*/
|
||||
public IClientIncomingPacket getRequestPacket()
|
||||
public ClientPacket getRequestPacket()
|
||||
{
|
||||
return _requestPacket;
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class Request
|
||||
* @param packet
|
||||
* @return
|
||||
*/
|
||||
public synchronized boolean setRequest(Player partner, IClientIncomingPacket packet)
|
||||
public synchronized boolean setRequest(Player partner, ClientPacket packet)
|
||||
{
|
||||
if (partner == null)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
@ -250,7 +250,7 @@ public abstract class WorldObject extends ListenersContainer implements IIdentif
|
||||
|
||||
public abstract void sendInfo(Player player);
|
||||
|
||||
public void sendPacket(IClientOutgoingPacket packet)
|
||||
public void sendPacket(ServerPacket packet)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -151,11 +151,11 @@ import org.l2jmobius.gameserver.network.serverpackets.ChangeMoveType;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ChangeWaitType;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExTeleportToLocationActivate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.FakePlayerInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MoveToLocation;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.Revive;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerObjectInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SetupGauge;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
|
||||
@ -667,12 +667,12 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
* In order to inform other players of state modification on the Creature, server just need to go through _knownPlayers to send Server->Client Packet
|
||||
* @param mov
|
||||
*/
|
||||
public void broadcastPacket(IClientOutgoingPacket mov)
|
||||
public void broadcastPacket(ServerPacket mov)
|
||||
{
|
||||
broadcastPacket(mov, true);
|
||||
}
|
||||
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, boolean includeSelf)
|
||||
public void broadcastPacket(ServerPacket mov, boolean includeSelf)
|
||||
{
|
||||
World.getInstance().forEachVisibleObject(this, Player.class, player ->
|
||||
{
|
||||
@ -693,7 +693,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
* @param mov
|
||||
* @param radiusInKnownlist
|
||||
*/
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, int radiusInKnownlist)
|
||||
public void broadcastPacket(ServerPacket mov, int radiusInKnownlist)
|
||||
{
|
||||
World.getInstance().forEachVisibleObjectInRange(this, Player.class, radiusInKnownlist, player ->
|
||||
{
|
||||
|
@ -308,7 +308,6 @@ import org.l2jmobius.gameserver.network.serverpackets.ExUserInfoCubic;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.GetOnVehicle;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.HennaInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
@ -329,6 +328,7 @@ import org.l2jmobius.gameserver.network.serverpackets.RecipeShopMsg;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.RecipeShopSellList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.RelationChanged;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.Ride;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SetupGauge;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ShortCutInit;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
|
||||
@ -3952,9 +3952,9 @@ public class Player extends Playable
|
||||
public void setClient(GameClient client)
|
||||
{
|
||||
_client = client;
|
||||
if ((_client != null) && (_client.getConnectionAddress() != null))
|
||||
if ((_client != null) && (_client.getIp() != null))
|
||||
{
|
||||
_ip = _client.getConnectionAddress().getHostAddress();
|
||||
_ip = _client.getIp();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4201,16 +4201,16 @@ public class Player extends Playable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, boolean includeSelf)
|
||||
public void broadcastPacket(ServerPacket packet, boolean includeSelf)
|
||||
{
|
||||
if (mov instanceof CharInfo)
|
||||
if (packet instanceof CharInfo)
|
||||
{
|
||||
new IllegalArgumentException("CharInfo is being send via broadcastPacket. Do NOT do that! Use broadcastCharInfo() instead.");
|
||||
}
|
||||
|
||||
if (includeSelf)
|
||||
{
|
||||
sendPacket(mov);
|
||||
sendPacket(packet);
|
||||
}
|
||||
|
||||
World.getInstance().forEachVisibleObject(this, Player.class, player ->
|
||||
@ -4220,19 +4220,19 @@ public class Player extends Playable
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendPacket(mov);
|
||||
player.sendPacket(packet);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, int radiusInKnownlist)
|
||||
public void broadcastPacket(ServerPacket packet, int radiusInKnownlist)
|
||||
{
|
||||
if (mov instanceof CharInfo)
|
||||
if (packet instanceof CharInfo)
|
||||
{
|
||||
new IllegalArgumentException("CharInfo is being send via broadcastPacket. Do NOT do that! Use broadcastCharInfo() instead.");
|
||||
}
|
||||
|
||||
sendPacket(mov);
|
||||
sendPacket(packet);
|
||||
|
||||
World.getInstance().forEachVisibleObject(this, Player.class, player ->
|
||||
{
|
||||
@ -4240,7 +4240,7 @@ public class Player extends Playable
|
||||
{
|
||||
return;
|
||||
}
|
||||
player.sendPacket(mov);
|
||||
player.sendPacket(packet);
|
||||
});
|
||||
}
|
||||
|
||||
@ -4259,7 +4259,7 @@ public class Player extends Playable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(IClientOutgoingPacket packet)
|
||||
public void sendPacket(ServerPacket packet)
|
||||
{
|
||||
if (_client != null)
|
||||
{
|
||||
|
@ -67,13 +67,13 @@ import org.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowAdd;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowDelete;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPartyPetWindowUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExPetInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PetDelete;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PetInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PetItemList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PetStatusUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.RelationChanged;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SummonInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
|
||||
@ -1049,7 +1049,7 @@ public abstract class Summon extends Playable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(IClientOutgoingPacket packet)
|
||||
public void sendPacket(ServerPacket packet)
|
||||
{
|
||||
if (_owner != null)
|
||||
{
|
||||
|
@ -38,8 +38,8 @@ import org.l2jmobius.gameserver.model.item.Weapon;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneRegion;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
import org.l2jmobius.gameserver.taskmanager.MovementTaskManager;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
@ -313,13 +313,13 @@ public abstract class Vehicle extends Creature
|
||||
return _passengers;
|
||||
}
|
||||
|
||||
public void broadcastToPassengers(IClientOutgoingPacket sm)
|
||||
public void broadcastToPassengers(ServerPacket packet)
|
||||
{
|
||||
for (Player player : _passengers)
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.sendPacket(sm);
|
||||
player.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CharInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
|
||||
public class Decoy extends Creature
|
||||
@ -228,7 +228,7 @@ public class Decoy extends Creature
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(IClientOutgoingPacket packet)
|
||||
public void sendPacket(ServerPacket packet)
|
||||
{
|
||||
if (_owner != null)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
|
||||
import org.l2jmobius.gameserver.model.skill.BuffInfo;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@ -191,7 +191,7 @@ public class Doppelganger extends Npc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(IClientOutgoingPacket packet)
|
||||
public void sendPacket(ServerPacket packet)
|
||||
{
|
||||
if (getSummoner() != null)
|
||||
{
|
||||
|
@ -41,8 +41,8 @@ import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
|
||||
import org.l2jmobius.gameserver.model.skill.Skill;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
|
||||
@ -90,25 +90,25 @@ public class Trap extends Npc
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, boolean includeSelf)
|
||||
public void broadcastPacket(ServerPacket packet, boolean includeSelf)
|
||||
{
|
||||
World.getInstance().forEachVisibleObject(this, Player.class, player ->
|
||||
{
|
||||
if (_isTriggered || canBeSeen(player))
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
player.sendPacket(packet);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastPacket(IClientOutgoingPacket mov, int radiusInKnownlist)
|
||||
public void broadcastPacket(ServerPacket packet, int radiusInKnownlist)
|
||||
{
|
||||
World.getInstance().forEachVisibleObjectInRange(this, Player.class, radiusInKnownlist, player ->
|
||||
{
|
||||
if (_isTriggered || canBeSeen(player))
|
||||
{
|
||||
player.sendPacket(mov);
|
||||
player.sendPacket(packet);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -72,7 +72,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExSubPledgeSkillAdd;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PledgeReceiveSubPledgeCreated;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PledgeShowInfoUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
|
||||
@ -81,6 +80,7 @@ import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListUpdate
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillList;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillList.SubPledgeSkill;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillListAdd;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.pledgebonus.ExPledgeBonusMarkReset;
|
||||
@ -1588,7 +1588,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToOnlineAllyMembers(IClientOutgoingPacket packet)
|
||||
public void broadcastToOnlineAllyMembers(ServerPacket packet)
|
||||
{
|
||||
for (Clan clan : ClanTable.getInstance().getClanAllies(getAllyId()))
|
||||
{
|
||||
@ -1596,7 +1596,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToOnlineMembers(IClientOutgoingPacket packet)
|
||||
public void broadcastToOnlineMembers(ServerPacket packet)
|
||||
{
|
||||
for (ClanMember member : _members.values())
|
||||
{
|
||||
@ -1618,7 +1618,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToOtherOnlineMembers(IClientOutgoingPacket packet, Player player)
|
||||
public void broadcastToOtherOnlineMembers(ServerPacket packet, Player player)
|
||||
{
|
||||
for (ClanMember member : _members.values())
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ import org.l2jmobius.gameserver.model.spawns.SpawnGroup;
|
||||
import org.l2jmobius.gameserver.model.spawns.SpawnTemplate;
|
||||
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@ -878,11 +878,11 @@ public class Instance implements IIdentifiable, INamable
|
||||
* Send packet to each player from instance world.
|
||||
* @param packets packets to be send
|
||||
*/
|
||||
public void broadcastPacket(IClientOutgoingPacket... packets)
|
||||
public void broadcastPacket(ServerPacket... packets)
|
||||
{
|
||||
for (Player player : _players)
|
||||
{
|
||||
for (IClientOutgoingPacket packet : packets)
|
||||
for (ServerPacket packet : packets)
|
||||
{
|
||||
player.sendPacket(packet);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ServerPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
@ -390,12 +390,12 @@ public class ItemAuction
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastToAllBidders(IClientOutgoingPacket packet)
|
||||
public void broadcastToAllBidders(ServerPacket packet)
|
||||
{
|
||||
ThreadPool.execute(() -> broadcastToAllBiddersInternal(packet));
|
||||
}
|
||||
|
||||
public void broadcastToAllBiddersInternal(IClientOutgoingPacket packet)
|
||||
public void broadcastToAllBiddersInternal(ServerPacket packet)
|
||||
{
|
||||
for (int i = _auctionBids.size(); i-- > 0;)
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user