Code review Part 2.

This commit is contained in:
MobiusDevelopment
2019-12-18 11:25:03 +00:00
parent b7fef9acf5
commit 6954f58f5e
739 changed files with 6985 additions and 8820 deletions

View File

@@ -43,7 +43,6 @@ public class Config
private static final String NPC_CONFIG_FILE = "./config/npc.ini"; private static final String NPC_CONFIG_FILE = "./config/npc.ini";
// Game // Game
public static String _ip;
public static int SERVER_PORT; public static int SERVER_PORT;
public static String SERVER_HOST_NAME; public static String SERVER_HOST_NAME;
public static int CLIENT_PROTOCOL_VERSION; public static int CLIENT_PROTOCOL_VERSION;

View File

@@ -20,6 +20,7 @@ package org.l2jmobius.gameserver;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Collection; import java.util.Collection;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -441,7 +442,7 @@ public class AdminCommands extends Thread
{ {
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Server Status</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Server Status</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
replyMSG.append("<table>"); replyMSG.append("<table>");
replyMSG.append("<tr><td>Players Online: " + World.getInstance().getAllPlayers().size() + "</td></tr>"); replyMSG.append("<tr><td>Players Online: " + World.getInstance().getAllPlayers().size() + "</td></tr>");
@@ -492,7 +493,7 @@ public class AdminCommands extends Thread
activeChar.sendPacket(il); activeChar.sendPacket(il);
activeChar.sendMessage("You have spawned " + num + " item(s) number " + id + " in your inventory."); activeChar.sendMessage("You have spawned " + num + " item(s) number " + id + " in your inventory.");
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Item Creation Complete</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Item Creation Complete</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
replyMSG.append("<center><button value=\"Back\" action=\"bypass -h admin_show\" width=40 height=15></center>"); replyMSG.append("<center><button value=\"Back\" action=\"bypass -h admin_show\" width=40 height=15></center>");
replyMSG.append("</body></html>"); replyMSG.append("</body></html>");
@@ -505,23 +506,23 @@ public class AdminCommands extends Thread
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final Collection<PlayerInstance> allWorldPlayers = World.getInstance().getAllPlayers(); final Collection<PlayerInstance> allWorldPlayers = World.getInstance().getAllPlayers();
final PlayerInstance[] players = allWorldPlayers.toArray(new PlayerInstance[allWorldPlayers.size()]); final PlayerInstance[] players = allWorldPlayers.toArray(new PlayerInstance[allWorldPlayers.size()]);
final int MaxCharactersPerPage = 20; final int maxCharactersPerPage = 20;
int MaxPages = players.length / MaxCharactersPerPage; int maxPages = players.length / maxCharactersPerPage;
final int modulus = players.length % MaxCharactersPerPage; final int modulus = players.length % maxCharactersPerPage;
if (modulus != 0) if (modulus != 0)
{ {
++MaxPages; ++maxPages;
} }
if (page > MaxPages) if (page > maxPages)
{ {
page = MaxPages; page = maxPages;
} }
final int CharactersStart = MaxCharactersPerPage * page; final int CharactersStart = maxCharactersPerPage * page;
final int CharactersEnd = players.length - CharactersStart; final int CharactersEnd = players.length - CharactersStart;
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Characters List</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Characters List</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
for (int x = 0; x < MaxPages; ++x) for (int x = 0; x < maxPages; ++x)
{ {
replyMSG.append("<a action=\"bypass -h admin_show_characters " + x + "\">Page" + x + 1 + "</a>\t"); replyMSG.append("<a action=\"bypass -h admin_show_characters " + x + "\">Page" + x + 1 + "</a>\t");
} }
@@ -543,12 +544,12 @@ public class AdminCommands extends Thread
activeChar.sendPacket(adminReply); activeChar.sendPacket(adminReply);
} }
private void showCharacterList(ClientThread client, String CharName) private void showCharacterList(ClientThread client, String charName)
{ {
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final PlayerInstance player = World.getInstance().getPlayer(CharName); final PlayerInstance player = World.getInstance().getPlayer(charName);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Character Information</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Character Information</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
replyMSG.append("<br>"); replyMSG.append("<br>");
replyMSG.append("<center>" + player.getName() + "</center><p>"); replyMSG.append("<center>" + player.getName() + "</center><p>");
@@ -609,7 +610,7 @@ public class AdminCommands extends Thread
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate); final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Add Exp-Sp to " + player.getName() + "</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Add Exp-Sp to " + player.getName() + "</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
replyMSG.append("<br>"); replyMSG.append("<br>");
replyMSG.append("<center>Lv: " + player.getLevel() + " " + CharTemplateTable.getInstance().getTemplate(player.getClassId()).getClassName() + "<p>"); replyMSG.append("<center>Lv: " + player.getLevel() + " " + CharTemplateTable.getInstance().getTemplate(player.getClassId()).getClassName() + "<p>");
@@ -628,11 +629,11 @@ public class AdminCommands extends Thread
activeChar.sendPacket(adminReply); activeChar.sendPacket(adminReply);
} }
private void adminAddExpSp(ClientThread client, String ExpSp) private void adminAddExpSp(ClientThread client, String expSp)
{ {
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate); final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate);
final StringTokenizer st = new StringTokenizer(ExpSp); final StringTokenizer st = new StringTokenizer(expSp);
if (st.countTokens() != 2) if (st.countTokens() != 2)
{ {
addExpSp(client); addExpSp(client);
@@ -707,7 +708,7 @@ public class AdminCommands extends Thread
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate); final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Editing character " + player.getName() + "</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Editing character " + player.getName() + "</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
replyMSG.append("<br><center>Caution ! Dont forget that modifying players stats can ruin the game...</center><br>"); replyMSG.append("<br><center>Caution ! Dont forget that modifying players stats can ruin the game...</center><br>");
replyMSG.append("Note: you must type all values to confirm modifications.</center><br>"); replyMSG.append("Note: you must type all values to confirm modifications.</center><br>");
@@ -775,27 +776,27 @@ public class AdminCommands extends Thread
showMainPage(client); showMainPage(client);
} }
private void findCharacter(ClientThread client, String CharacterToFind) private void findCharacter(ClientThread client, String characterToFind)
{ {
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
int CharactersFound = 0; int charactersFound = 0;
final StringBuffer replyMSG = new StringBuffer("<html><title>Character Search</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Character Search</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
replyMSG.append("<br>"); replyMSG.append("<br>");
replyMSG.append("<table>"); replyMSG.append("<table>");
replyMSG.append("<tr><td>Name</td><td>Class</td><td>Level</td></tr>"); replyMSG.append("<tr><td>Name</td><td>Class</td><td>Level</td></tr>");
for (PlayerInstance player : World.getInstance().getAllPlayers()) for (PlayerInstance player : World.getInstance().getAllPlayers())
{ {
if (!player.getName().startsWith(CharacterToFind)) if (!player.getName().startsWith(characterToFind))
{ {
continue; continue;
} }
++CharactersFound; ++charactersFound;
replyMSG.append("<tr><td><a action=\"bypass -h admin_character_list " + player.getName() + "\">" + player.getName() + "</a>" + "</td><td>" + CharTemplateTable.getInstance().getTemplate(player.getClassId()).getClassName() + "</td><td>" + player.getLevel() + "</td></tr>"); replyMSG.append("<tr><td><a action=\"bypass -h admin_character_list " + player.getName() + "\">" + player.getName() + "</a>" + "</td><td>" + CharTemplateTable.getInstance().getTemplate(player.getClassId()).getClassName() + "</td><td>" + player.getLevel() + "</td></tr>");
} }
replyMSG.append("</table>"); replyMSG.append("</table>");
if (CharactersFound == 0) if (charactersFound == 0)
{ {
replyMSG.append("<br>Your search did not find any characters. Please try again:"); replyMSG.append("<br>Your search did not find any characters. Please try again:");
replyMSG.append("<edit var=\"character_name\" width=110>"); replyMSG.append("<edit var=\"character_name\" width=110>");
@@ -804,12 +805,12 @@ public class AdminCommands extends Thread
} }
else else
{ {
replyMSG.append("<br>Found " + CharactersFound + " character"); replyMSG.append("<br>Found " + charactersFound + " character");
if (CharactersFound == 1) if (charactersFound == 1)
{ {
replyMSG.append("."); replyMSG.append(".");
} }
else if (CharactersFound > 1) else if (charactersFound > 1)
{ {
replyMSG.append("s."); replyMSG.append("s.");
} }
@@ -826,7 +827,7 @@ public class AdminCommands extends Thread
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate); final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Teleport Character</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Teleport Character</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
replyMSG.append("The character you will teleport is " + player.getName() + "."); replyMSG.append("The character you will teleport is " + player.getName() + ".");
replyMSG.append("<br>"); replyMSG.append("<br>");
@@ -844,7 +845,7 @@ public class AdminCommands extends Thread
activeChar.sendPacket(adminReply); activeChar.sendPacket(adminReply);
} }
private void teleportCharacter(ClientThread client, String Cords) private void teleportCharacter(ClientThread client, String coords)
{ {
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate); final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate);
@@ -854,7 +855,7 @@ public class AdminCommands extends Thread
} }
else else
{ {
final StringTokenizer st = new StringTokenizer(Cords); final StringTokenizer st = new StringTokenizer(coords);
final String x1 = st.nextToken(); final String x1 = st.nextToken();
final int x = Integer.parseInt(x1); final int x = Integer.parseInt(x1);
final String y1 = st.nextToken(); final String y1 = st.nextToken();
@@ -888,7 +889,7 @@ public class AdminCommands extends Thread
{ {
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Custom Spawn Menu</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Custom Spawn Menu</title>");
replyMSG.append("<body><br>Enter target player's name below.<br>You may leave the field blank for self-spawn.<br><br>"); replyMSG.append("<body><br>Enter target player's name below.<br>You may leave the field blank for self-spawn.<br><br>");
replyMSG.append("<center><edit var=\"targetname\" width=160></center><br><br>"); replyMSG.append("<center><edit var=\"targetname\" width=160></center><br><br>");
replyMSG.append("<center><button value=\"Spawn on self\" action=\"bypass -h admin_spawn_confirm " + monsterId + " " + activeChar.getName() + "\" width=160 height=15></center><br>"); replyMSG.append("<center><button value=\"Spawn on self\" action=\"bypass -h admin_spawn_confirm " + monsterId + " " + activeChar.getName() + "\" width=160 height=15></center><br>");
@@ -897,10 +898,10 @@ public class AdminCommands extends Thread
activeChar.sendPacket(adminReply); activeChar.sendPacket(adminReply);
} }
private void spawnMonster(ClientThread client, String monsterId, String CharName) private void spawnMonster(ClientThread client, String monsterId, String charName)
{ {
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final PlayerInstance targetPlayer = World.getInstance().getPlayer(CharName); final PlayerInstance targetPlayer = World.getInstance().getPlayer(charName);
final int monsterTemplate = Integer.parseInt(monsterId); final int monsterTemplate = Integer.parseInt(monsterId);
final Npc template1 = NpcTable.getInstance().getTemplate(monsterTemplate); final Npc template1 = NpcTable.getInstance().getTemplate(monsterTemplate);
if (template1 == null) if (template1 == null)
@@ -931,14 +932,13 @@ public class AdminCommands extends Thread
private int disconnectAllCharacters() private int disconnectAllCharacters()
{ {
final LeaveWorld leaveWorld = new LeaveWorld();
for (PlayerInstance player : World.getInstance().getAllPlayers()) for (PlayerInstance player : World.getInstance().getAllPlayers())
{ {
final LeaveWorld ql = new LeaveWorld(); player.sendPacket(leaveWorld);
player.sendPacket(ql);
try try
{ {
player.getNetConnection().close(); player.getNetConnection().close();
continue;
} }
catch (IOException e) catch (IOException e)
{ {
@@ -952,8 +952,8 @@ public class AdminCommands extends Thread
{ {
secondsShut = seconds; secondsShut = seconds;
clientShut = client; clientShut = client;
final AdminCommands ShutDownThread = new AdminCommands(); final AdminCommands shutDownThread = new AdminCommands();
ShutDownThread.start(); shutDownThread.start();
} }
@Override @Override
@@ -963,7 +963,7 @@ public class AdminCommands extends Thread
{ {
final PlayerInstance activeChar = clientShut.getActiveChar(); final PlayerInstance activeChar = clientShut.getActiveChar();
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Shutdown Server</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Shutdown Server</title>");
replyMSG.append("<body><br>"); replyMSG.append("<body><br>");
replyMSG.append("Enter in seconds the time till the server<p> shutdowns bellow:"); replyMSG.append("Enter in seconds the time till the server<p> shutdowns bellow:");
replyMSG.append("<edit var=\"shutdown_time\" width=110>"); replyMSG.append("<edit var=\"shutdown_time\" width=110>");
@@ -1044,14 +1044,13 @@ public class AdminCommands extends Thread
fis = new FileInputStream(file); fis = new FileInputStream(file);
final byte[] raw = new byte[fis.available()]; final byte[] raw = new byte[fis.available()];
fis.read(raw); fis.read(raw);
final String content = new String(raw, "UTF-8"); final String content = new String(raw, StandardCharsets.UTF_8);
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
adminReply.setHtml(content); adminReply.setHtml(content);
activeChar.sendPacket(adminReply); activeChar.sendPacket(adminReply);
fis.close(); fis.close();
return;
} }
catch (Exception e) catch (Exception e)
{ {
@@ -1100,7 +1099,7 @@ public class AdminCommands extends Thread
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate); final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Remove skills of " + player.getName() + "</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Remove skills of " + player.getName() + "</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
replyMSG.append("<br>"); replyMSG.append("<br>");
replyMSG.append("<center>Lv: " + player.getLevel() + " " + CharTemplateTable.getInstance().getTemplate(player.getClassId()).getClassName() + "<p>"); replyMSG.append("<center>Lv: " + player.getLevel() + " " + CharTemplateTable.getInstance().getTemplate(player.getClassId()).getClassName() + "<p>");
@@ -1131,7 +1130,7 @@ public class AdminCommands extends Thread
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate); final PlayerInstance player = World.getInstance().getPlayer(_characterToManipulate);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Modify skills of " + player.getName() + "</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Modify skills of " + player.getName() + "</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
replyMSG.append("<br>"); replyMSG.append("<br>");
replyMSG.append("<center>Lv: " + player.getLevel() + " " + CharTemplateTable.getInstance().getTemplate(player.getClassId()).getClassName() + "<p>"); replyMSG.append("<center>Lv: " + player.getLevel() + " " + CharTemplateTable.getInstance().getTemplate(player.getClassId()).getClassName() + "<p>");
@@ -1261,24 +1260,12 @@ public class AdminCommands extends Thread
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
final int skillid = Integer.parseInt(val); final int skillid = Integer.parseInt(val);
final Skill skill = SkillTable.getInstance().getInfo(skillid, 1); final Skill skill = SkillTable.getInstance().getInfo(skillid, 1);
if (skill != null) if ((skill != null) && (skill.getTargetType() == 0))
{ {
if (skill.getTargetType() == 0) activeChar.setTarget(activeChar);
{ final MagicSkillUser msk = new MagicSkillUser(activeChar, skillid, 1, skill.getHitTime(), skill.getReuseDelay());
activeChar.setTarget(activeChar); activeChar.sendPacket(msk);
final MagicSkillUser msk = new MagicSkillUser(activeChar, skillid, 1, skill.getHitTime(), skill.getReuseDelay()); activeChar.broadcastPacket(msk);
activeChar.sendPacket(msk);
activeChar.broadcastPacket(msk);
// ActionFailed af = new ActionFailed();
}
// else if (skill.getTargetType() == 1)
// {
// ActionFailed af = new ActionFailed();
// }
} }
// else
// {
// ActionFailed af = new ActionFailed();
// }
} }
} }

View File

@@ -71,7 +71,7 @@ public class Announcements
{ {
for (int i = 0; i < _announcements.size(); ++i) for (int i = 0; i < _announcements.size(); ++i)
{ {
final CreatureSay cs = new CreatureSay(0, 10, activeChar.getName(), _announcements.get(i).toString()); final CreatureSay cs = new CreatureSay(0, 10, activeChar.getName(), _announcements.get(i));
activeChar.sendPacket(cs); activeChar.sendPacket(cs);
} }
} }
@@ -79,11 +79,11 @@ public class Announcements
public void listAnnouncements(PlayerInstance activeChar) public void listAnnouncements(PlayerInstance activeChar)
{ {
final NpcHtmlMessage adminReply = new NpcHtmlMessage(5); final NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
final StringBuffer replyMSG = new StringBuffer("<html><title>Announcements:</title>"); final StringBuilder replyMSG = new StringBuilder("<html><title>Announcements:</title>");
replyMSG.append("<body>"); replyMSG.append("<body>");
for (int i = 0; i < _announcements.size(); ++i) for (int i = 0; i < _announcements.size(); ++i)
{ {
replyMSG.append(_announcements.get(i).toString()); replyMSG.append(_announcements.get(i));
replyMSG.append("<center><button value=\"Delete\" action=\"bypass -h admin_del_announcement " + i + "\" width=110 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center>"); replyMSG.append("<center><button value=\"Delete\" action=\"bypass -h admin_del_announcement " + i + "\" width=110 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center>");
} }
replyMSG.append("<br>"); replyMSG.append("<br>");
@@ -149,7 +149,7 @@ public class Announcements
final FileWriter save = new FileWriter(new File("data/announcements.txt")); final FileWriter save = new FileWriter(new File("data/announcements.txt"));
for (int i = 0; i < _announcements.size(); ++i) for (int i = 0; i < _announcements.size(); ++i)
{ {
save.write(_announcements.get(i).toString()); save.write(_announcements.get(i));
save.write("\r\n"); save.write("\r\n");
} }
save.close(); save.close();

View File

@@ -130,9 +130,9 @@ public class GameServer extends Thread
if (!Config.SERVER_HOST_NAME.equals("*")) if (!Config.SERVER_HOST_NAME.equals("*"))
{ {
final InetAddress adr = InetAddress.getByName(Config.SERVER_HOST_NAME); final InetAddress adr = InetAddress.getByName(Config.SERVER_HOST_NAME);
Config._ip = adr.getHostAddress(); String ip = adr.getHostAddress();
_serverSocket = new ServerSocket(Config.SERVER_PORT, 50, adr); _serverSocket = new ServerSocket(Config.SERVER_PORT, 50, adr);
_log.config("GameServer listening on IP:" + Config._ip + " Port " + Config.SERVER_PORT); _log.config("GameServer listening on IP:" + ip + " Port " + Config.SERVER_PORT);
} }
else else
{ {

View File

@@ -66,7 +66,6 @@ public class GameTimeController extends Thread
} }
catch (InterruptedException e1) catch (InterruptedException e1)
{ {
return;
} }
} }

View File

@@ -38,21 +38,20 @@ public class CharNameTable
private CharNameTable() private CharNameTable()
{ {
final File _accountsFolder = new File("data/accounts"); final File accountsFolder = new File("data/accounts");
_accountsFolder.mkdirs(); accountsFolder.mkdirs();
_charNames = new ArrayList<>(); _charNames = new ArrayList<>();
final File[] accounts = _accountsFolder.listFiles(); final File[] accounts = accountsFolder.listFiles();
for (File account : accounts) for (File account : accounts)
{ {
try try
{ {
final File _charFolder = new File("data/accounts/" + account.getName()); final File charFolder = new File("data/accounts/" + account.getName());
final File[] chars = _charFolder.listFiles((FilenameFilter) (dir, name) -> name.endsWith("_char.csv")); final File[] chars = charFolder.listFiles((FilenameFilter) (dir, name) -> name.endsWith("_char.csv"));
for (File c : chars) for (File c : chars)
{ {
_charNames.add(c.getName().replaceAll("_char.csv", "").toLowerCase()); _charNames.add(c.getName().replaceAll("_char.csv", "").toLowerCase());
} }
continue;
} }
catch (NullPointerException e) catch (NullPointerException e)
{ {

View File

@@ -186,9 +186,9 @@ public class ItemTable
private void fixEtcItems(HashMap<Integer, Item> items) private void fixEtcItems(HashMap<Integer, Item> items)
{ {
for (int key : items.keySet()) for (Item i : items.values())
{ {
final EtcItem item = (EtcItem) items.get(key); final EtcItem item = (EtcItem) i;
if ((item.getWeight() == 0) && (item.getEtcItemType() != EtcItem.TYPE_MONEY) && !item.getName().startsWith("world_map") && !item.getName().startsWith("crystal_")) if ((item.getWeight() == 0) && (item.getEtcItemType() != EtcItem.TYPE_MONEY) && !item.getName().startsWith("world_map") && !item.getName().startsWith("crystal_"))
{ {
item.setType2(Item.TYPE2_QUEST); item.setType2(Item.TYPE2_QUEST);

View File

@@ -87,7 +87,7 @@ public class SpawnTable
} }
} }
private Spawn parseList(String line) throws SecurityException, ClassNotFoundException private Spawn parseList(String line) throws ClassNotFoundException
{ {
final StringTokenizer st = new StringTokenizer(line, ";"); final StringTokenizer st = new StringTokenizer(line, ";");
final int spawnId = Integer.parseInt(st.nextToken()); final int spawnId = Integer.parseInt(st.nextToken());
@@ -115,9 +115,9 @@ public class SpawnTable
return spawnDat; return spawnDat;
} }
public Spawn getTemplate(int Id) public Spawn getTemplate(int id)
{ {
return _spawntable.get(Id); return _spawntable.get(id);
} }
public void addNewSpawn(Spawn spawn) public void addNewSpawn(Spawn spawn)

View File

@@ -43,27 +43,27 @@ public class Potions implements IItemHandler
@Override @Override
public int useItem(PlayerInstance activeChar, ItemInstance item) public int useItem(PlayerInstance activeChar, ItemInstance item)
{ {
final Potion Potion = new Potion(); final Potion potion = new Potion();
final int itemId = item.getItemId(); final int itemId = item.getItemId();
if ((itemId == 65) || (itemId == 725) || (itemId == 727) || (itemId == 1060) || (itemId == 1061) || (itemId == 1539) || (itemId == 1540) || (itemId == 1073)) if ((itemId == 65) || (itemId == 725) || (itemId == 727) || (itemId == 1060) || (itemId == 1061) || (itemId == 1539) || (itemId == 1540) || (itemId == 1073))
{ {
final WorldObject OldTarget = activeChar.getTarget(); final WorldObject oldTarget = activeChar.getTarget();
activeChar.setTarget(activeChar); activeChar.setTarget(activeChar);
final MagicSkillUser MSU = new MagicSkillUser(activeChar, 2038, 1, 0, 0); final MagicSkillUser msu = new MagicSkillUser(activeChar, 2038, 1, 0, 0);
activeChar.sendPacket(MSU); activeChar.sendPacket(msu);
activeChar.broadcastPacket(MSU); activeChar.broadcastPacket(msu);
activeChar.setTarget(OldTarget); activeChar.setTarget(oldTarget);
Potion.setCurrentHpPotion1(activeChar, itemId); potion.setCurrentHpPotion1(activeChar, itemId);
} }
else if ((itemId == 726) || (itemId == 728)) else if ((itemId == 726) || (itemId == 728))
{ {
final WorldObject OldTarget = activeChar.getTarget(); final WorldObject oldTarget = activeChar.getTarget();
activeChar.setTarget(activeChar); activeChar.setTarget(activeChar);
final MagicSkillUser MSU = new MagicSkillUser(activeChar, 2038, 1, 0, 0); final MagicSkillUser msu = new MagicSkillUser(activeChar, 2038, 1, 0, 0);
activeChar.sendPacket(MSU); activeChar.sendPacket(msu);
activeChar.broadcastPacket(MSU); activeChar.broadcastPacket(msu);
activeChar.setTarget(OldTarget); activeChar.setTarget(oldTarget);
Potion.setCurrentMpPotion1(activeChar, itemId); potion.setCurrentMpPotion1(activeChar, itemId);
} }
return 1; return 1;
} }

View File

@@ -72,12 +72,12 @@ public class SoulShots implements IItemHandler
} }
activeChar.setActiveSoulshotGrade(grade); activeChar.setActiveSoulshotGrade(grade);
activeChar.sendPacket(new SystemMessage(SystemMessage.ENABLED_SOULSHOT)); activeChar.sendPacket(new SystemMessage(SystemMessage.ENABLED_SOULSHOT));
final WorldObject OldTarget = activeChar.getTarget(); final WorldObject oldTarget = activeChar.getTarget();
activeChar.setTarget(activeChar); activeChar.setTarget(activeChar);
final MagicSkillUser MSU = new MagicSkillUser(activeChar, 2039, 1, 0, 0); final MagicSkillUser msu = new MagicSkillUser(activeChar, 2039, 1, 0, 0);
activeChar.sendPacket(MSU); activeChar.sendPacket(msu);
activeChar.broadcastPacket(MSU); activeChar.broadcastPacket(msu);
activeChar.setTarget(OldTarget); activeChar.setTarget(oldTarget);
return soulShotConsumption; return soulShotConsumption;
} }

View File

@@ -52,7 +52,7 @@ public class CommunityBoardManager
final PlayerInstance activeChar = client.getActiveChar(); final PlayerInstance activeChar = client.getActiveChar();
if (command.startsWith("bbs_")) if (command.startsWith("bbs_"))
{ {
final StringBuffer htmlCode = new StringBuffer("<html imgsrc=\"sek.cbui353\"><body><br><table border=0><tr><td FIXWIDTH=15></td><td align=center>Community Board<img src=\"sek.cbui355\" width=610 height=1></td></tr><tr><td FIXWIDTH=15></td><td>"); final StringBuilder htmlCode = new StringBuilder("<html imgsrc=\"sek.cbui353\"><body><br><table border=0><tr><td FIXWIDTH=15></td><td align=center>Community Board<img src=\"sek.cbui355\" width=610 height=1></td></tr><tr><td FIXWIDTH=15></td><td>");
if (command.equals("bbs_default")) if (command.equals("bbs_default"))
{ {
final Collection<PlayerInstance> players = World.getInstance().getAllPlayers(); final Collection<PlayerInstance> players = World.getInstance().getAllPlayers();
@@ -122,7 +122,7 @@ public class CommunityBoardManager
htmlCode.append("<tr><td><br></td></tr>"); htmlCode.append("<tr><td><br></td></tr>");
for (ClanMember member : clan.getMembers()) for (ClanMember member : clan.getMembers())
{ {
if (member.getName() == clan.getLeaderName()) if (member.getName().equals(clan.getLeaderName()))
{ {
continue; continue;
} }

View File

@@ -19,17 +19,18 @@ package org.l2jmobius.gameserver.model;
public class Skill public class Skill
{ {
public static int OP_ALWAYS = 1; public static final int OP_ALWAYS = 1;
public static int OP_ONCE = 2; public static final int OP_ONCE = 2;
public static int OP_DURATION = 3; public static final int OP_DURATION = 3;
public static int OP_TOGGLE = 4; public static final int OP_TOGGLE = 4;
public static int TARGET_SELF = 0; public static final int TARGET_SELF = 0;
public static int TARGET_ONE = 1; public static final int TARGET_ONE = 1;
public static int TARGET_PARTY = 2; public static final int TARGET_PARTY = 2;
public static int TARGET_CLAN = 3; public static final int TARGET_CLAN = 3;
public static int TARGET_PET = 4; public static final int TARGET_PET = 4;
public static int TARGET_ENEMY = 5; public static final int TARGET_ENEMY = 5;
public static int TARGET_FRIEND = 6; public static final int TARGET_FRIEND = 6;
private int _id; private int _id;
private int _level; private int _level;
private String _name; private String _name;

View File

@@ -46,7 +46,7 @@ public class Spawn
private int _respawnDelay; private int _respawnDelay;
private final Constructor<?> _constructor; private final Constructor<?> _constructor;
public Spawn(Npc mobTemplate) throws SecurityException, ClassNotFoundException public Spawn(Npc mobTemplate) throws ClassNotFoundException
{ {
_template = mobTemplate; _template = mobTemplate;
final String implementationName = _template.getType(); final String implementationName = _template.getType();
@@ -182,14 +182,7 @@ public class Spawn
}; };
mob = (NpcInstance) _constructor.newInstance(parameters); mob = (NpcInstance) _constructor.newInstance(parameters);
mob.setObjectId(IdFactory.getInstance().getNextId()); mob.setObjectId(IdFactory.getInstance().getNextId());
if (mob instanceof MonsterInstance) mob.setAutoAttackable(mob instanceof MonsterInstance);
{
mob.setAutoAttackable(true);
}
else
{
mob.setAutoAttackable(false);
}
if (getRandomx() > 0) if (getRandomx() > 0)
{ {
final int random1 = Rnd.get(getRandomx()); final int random1 = Rnd.get(getRandomx());

View File

@@ -89,12 +89,12 @@ public class TradeList
return -1; return -1;
} }
public ItemInstance getItem(int ObjectId) public ItemInstance getItem(int objectId)
{ {
for (int i = 0; i < _items.size(); ++i) for (int i = 0; i < _items.size(); ++i)
{ {
final ItemInstance item = _items.get(i); final ItemInstance item = _items.get(i);
if (item.getObjectId() != ObjectId) if (item.getObjectId() != objectId)
{ {
continue; continue;
} }
@@ -280,12 +280,12 @@ public class TradeList
} }
else else
{ {
msg = new SystemMessage(SystemMessage.S1_PURCHASED_S3_S2_s); msg = new SystemMessage(SystemMessage.S1_PURCHASED_S3_S2_S);
msg.addString(buyer.getName()); msg.addString(buyer.getName());
msg.addItemName(((ItemInstance) sellerItem).getItemId()); msg.addItemName(((ItemInstance) sellerItem).getItemId());
msg.addNumber(amount); msg.addNumber(amount);
sysmsgs.add(msg); sysmsgs.add(msg);
msg = new SystemMessage(SystemMessage.S1_PURCHASED_S3_S2_s); msg = new SystemMessage(SystemMessage.S1_PURCHASED_S3_S2_S);
msg.addString("You"); msg.addString("You");
msg.addItemName(((ItemInstance) sellerItem).getItemId()); msg.addItemName(((ItemInstance) sellerItem).getItemId());
msg.addNumber(amount); msg.addNumber(amount);

View File

@@ -115,11 +115,10 @@ public class World
public void removeVisibleObject(WorldObject object) public void removeVisibleObject(WorldObject object)
{ {
_visibleObjects.remove(object.getObjectId()); _visibleObjects.remove(object.getObjectId());
for (Object element : object.getKnownObjects()) for (WorldObject wo : object.getKnownObjects())
{ {
final WorldObject temp1 = (WorldObject) element; wo.removeKnownObject(object);
temp1.removeKnownObject(object); object.removeKnownObject(wo);
object.removeKnownObject(temp1);
} }
if (object instanceof PlayerInstance) if (object instanceof PlayerInstance)
{ {

View File

@@ -31,7 +31,7 @@ public class WorldObject implements Serializable
private int _x; private int _x;
private int _y; private int _y;
private int _z; private int _z;
protected Set<WorldObject> _knownObjects = ConcurrentHashMap.newKeySet(); protected final Set<WorldObject> _knownObjects = ConcurrentHashMap.newKeySet();
private final Set<PlayerInstance> _knownPlayers = ConcurrentHashMap.newKeySet(); private final Set<PlayerInstance> _knownPlayers = ConcurrentHashMap.newKeySet();
public int getObjectId() public int getObjectId()

View File

@@ -110,24 +110,6 @@ public class Attackable extends NpcInstance
super.startAttack(target); super.startAttack(target);
} }
@Override
public void setX(int x)
{
super.setX(x);
}
@Override
public void setY(int y)
{
super.setY(y);
}
@Override
public void setZ(int z)
{
super.setZ(z);
}
@Override @Override
public void removeKnownObject(WorldObject object) public void removeKnownObject(WorldObject object)
{ {
@@ -153,8 +135,8 @@ public class Attackable extends NpcInstance
} }
else if (isDead()) else if (isDead())
{ {
final Attackable Attackable = this; final Attackable attackable = this;
synchronized (Attackable) synchronized (attackable)
{ {
if (!_killedAlready) if (!_killedAlready)
{ {
@@ -263,14 +245,7 @@ public class Attackable extends NpcInstance
newAggro += aggroValue.intValue(); newAggro += aggroValue.intValue();
} }
_aggroList.put(attacker, newAggro); _aggroList.put(attacker, newAggro);
if (_aggroList.size() == 1) setTarget(attacker);
{
setTarget(attacker);
}
else
{
setTarget(attacker);
}
} }
public void doItemDrop() public void doItemDrop()
@@ -298,12 +273,11 @@ public class Attackable extends NpcInstance
dropit.setZ(getZ() + 100); dropit.setZ(getZ() + 100);
dropit.setOnTheGround(true); dropit.setOnTheGround(true);
final DropItem dis = new DropItem(dropit, getObjectId()); final DropItem dis = new DropItem(dropit, getObjectId());
for (Creature player : broadcastPacket(dis)) for (PlayerInstance player : broadcastPacket(dis))
{ {
((PlayerInstance) player).addKnownObjectWithoutCreate(dropit); player.addKnownObjectWithoutCreate(dropit);
} }
World.getInstance().addVisibleObject(dropit); World.getInstance().addVisibleObject(dropit);
continue;
} }
} }
} }
@@ -331,12 +305,6 @@ public class Attackable extends NpcInstance
} }
} }
@Override
public void setCurrentHp(double currentHp)
{
super.setCurrentHp(currentHp);
}
@Override @Override
public Weapon getActiveWeapon() public Weapon getActiveWeapon()
{ {
@@ -409,7 +377,7 @@ public class Attackable extends NpcInstance
{ {
for (PlayerInstance player : getKnownPlayers()) for (PlayerInstance player : getKnownPlayers())
{ {
if (!getCondition2(player) || !(getDistance(player.getX(), player.getY()) <= (getCollisionRadius() + 200.0))) if (!getCondition2(player) || (getDistance(player.getX(), player.getY()) > (getCollisionRadius() + 200.0)))
{ {
continue; continue;
} }

View File

@@ -407,7 +407,6 @@ public abstract class Creature extends WorldObject
try try
{ {
player.sendPacket(su); player.sendPacket(su);
continue;
} }
catch (Exception e1) catch (Exception e1)
{ {
@@ -879,7 +878,6 @@ public abstract class Creature extends WorldObject
{ {
sendPacket(new ActionFailed()); sendPacket(new ActionFailed());
onTargetReached(); onTargetReached();
return;
} }
} }
@@ -1519,10 +1517,7 @@ public abstract class Creature extends WorldObject
setX(x); setX(x);
setY(y); setY(y);
setZ(z); setZ(z);
ThreadPool.schedule(() -> ThreadPool.schedule(() -> World.getInstance().addVisibleObject(this), 2000);
{
World.getInstance().addVisibleObject(this);
}, 2000);
} }
@Override @Override

View File

@@ -35,12 +35,6 @@ public class MerchantInstance extends NpcInstance
super(template); super(template);
} }
@Override
public void onAction(PlayerInstance player)
{
super.onAction(player);
}
@Override @Override
public String getHtmlPath(int npcId, int val) public String getHtmlPath(int npcId, int val)
{ {

View File

@@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.actor.instance;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -58,6 +59,9 @@ public class NpcInstance extends Creature
_npcTemplate = template; _npcTemplate = template;
setCollisionHeight(template.getHeight()); setCollisionHeight(template.getHeight());
setCollisionRadius(template.getRadius()); setCollisionRadius(template.getRadius());
// TODO: Datapack support for name and title.
// setName(template.getName());
// setTitle(template.getTitle());
} }
public boolean isAggressive() public boolean isAggressive()
@@ -171,7 +175,7 @@ public class NpcInstance extends Creature
if (client.getAccessLevel() >= 100) if (client.getAccessLevel() >= 100)
{ {
final NpcHtmlMessage html = new NpcHtmlMessage(1); final NpcHtmlMessage html = new NpcHtmlMessage(1);
final StringBuffer html1 = new StringBuffer("<html><body><table border=0>"); final StringBuilder html1 = new StringBuilder("<html><body><table border=0>");
html1.append("<tr><td>Current Target:</td></tr>"); html1.append("<tr><td>Current Target:</td></tr>");
html1.append("<tr><td><br></td></tr>"); html1.append("<tr><td><br></td></tr>");
html1.append("<tr><td>Object ID: " + getObjectId() + "</td></tr>"); html1.append("<tr><td>Object ID: " + getObjectId() + "</td></tr>");
@@ -219,7 +223,7 @@ public class NpcInstance extends Creature
public void insertObjectIdAndShowChatWindow(PlayerInstance player, String content) public void insertObjectIdAndShowChatWindow(PlayerInstance player, String content)
{ {
content = content.replaceAll("%objectId%", String.valueOf(getObjectId())); content = content.replace("%objectId%", String.valueOf(getObjectId()));
final NpcHtmlMessage npcReply = new NpcHtmlMessage(5); final NpcHtmlMessage npcReply = new NpcHtmlMessage(5);
npcReply.setHtml(content); npcReply.setHtml(content);
player.sendPacket(npcReply); player.sendPacket(npcReply);
@@ -265,7 +269,7 @@ public class NpcInstance extends Creature
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
final byte[] raw = new byte[fis.available()]; final byte[] raw = new byte[fis.available()];
fis.read(raw); fis.read(raw);
final String content = new String(raw, "UTF-8"); final String content = new String(raw, StandardCharsets.UTF_8);
insertObjectIdAndShowChatWindow(player, content); insertObjectIdAndShowChatWindow(player, content);
fis.close(); fis.close();
} }
@@ -314,8 +318,7 @@ public class NpcInstance extends Creature
super.reduceCurrentHp(i, attacker); super.reduceCurrentHp(i, attacker);
if (isDead()) if (isDead())
{ {
final NpcInstance NpcInstance = this; synchronized (this)
synchronized (NpcInstance)
{ {
if ((_decayTask == null) || _decayTask.isCancelled() || _decayTask.isDone()) if ((_decayTask == null) || _decayTask.isCancelled() || _decayTask.isDone())
{ {

View File

@@ -353,8 +353,7 @@ public class PetInstance extends Creature
} }
final ItemInstance target = (ItemInstance) getTarget(); final ItemInstance target = (ItemInstance) getTarget();
boolean pickupOk = false; boolean pickupOk = false;
final ItemInstance ItemInstance = target; synchronized (target)
synchronized (ItemInstance)
{ {
if (target.isOnTheGround()) if (target.isOnTheGround())
{ {
@@ -387,21 +386,13 @@ public class PetInstance extends Creature
public void reduceCurrentHp(int damage, Creature attacker) public void reduceCurrentHp(int damage, Creature attacker)
{ {
super.reduceCurrentHp(damage, attacker); super.reduceCurrentHp(damage, attacker);
if (!isDead() && (attacker != null)) if (!isDead() && (attacker != null) && !isInCombat())
{ {
if (!isInCombat()) startAttack(attacker);
{
startAttack(attacker);
}
// else
// {
// _log.fine("already attacking");
// }
} }
if (isDead()) if (isDead())
{ {
final PetInstance PetInstance = this; synchronized (this)
synchronized (PetInstance)
{ {
if ((_decayTask == null) || _decayTask.isCancelled() || _decayTask.isDone()) if ((_decayTask == null) || _decayTask.isCancelled() || _decayTask.isDone())
{ {
@@ -445,10 +436,10 @@ public class PetInstance extends Creature
_owner.getInventory().addItem(item); _owner.getInventory().addItem(item);
getInventory().dropItem(item, item.getCount()); getInventory().dropItem(item, item.getCount());
final PetInventoryUpdate petiu = new PetInventoryUpdate(); final PetInventoryUpdate petiu = new PetInventoryUpdate();
final ItemList PlayerUI = new ItemList(_owner, false); final ItemList playerUI = new ItemList(_owner, false);
petiu.addRemovedItem(item); petiu.addRemovedItem(item);
_owner.sendPacket(petiu); _owner.sendPacket(petiu);
_owner.sendPacket(PlayerUI); _owner.sendPacket(playerUI);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -531,9 +522,9 @@ public class PetInstance extends Creature
dropit.setZ(getZ() + 100); dropit.setZ(getZ() + 100);
dropit.setOnTheGround(true); dropit.setOnTheGround(true);
final DropItem dis = new DropItem(dropit, getObjectId()); final DropItem dis = new DropItem(dropit, getObjectId());
for (Creature player : broadcastPacket(dis)) for (PlayerInstance player : broadcastPacket(dis))
{ {
((PlayerInstance) player).addKnownObjectWithoutCreate(dropit); player.addKnownObjectWithoutCreate(dropit);
} }
World.getInstance().addVisibleObject(dropit); World.getInstance().addVisibleObject(dropit);
} }
@@ -586,11 +577,11 @@ public class PetInstance extends Creature
updateKnownCounter = (byte) (updateKnownCounter + 1); updateKnownCounter = (byte) (updateKnownCounter + 1);
if (updateKnownCounter > 3) if (updateKnownCounter > 3)
{ {
if (getKnownObjects().size() != 0) if (!getKnownObjects().isEmpty())
{ {
for (WorldObject object : _knownObjects) for (WorldObject object : _knownObjects)
{ {
if (!(getDistance(object.getX(), object.getY()) > 4000.0)) if (getDistance(object.getX(), object.getY()) <= 4000.0)
{ {
continue; continue;
} }

View File

@@ -138,8 +138,7 @@ public class PlayerInstance extends Creature
public Skill addSkill(Skill newSkill) public Skill addSkill(Skill newSkill)
{ {
final Skill oldSkill = _skills.put(newSkill.getId(), newSkill); return _skills.put(newSkill.getId(), newSkill);
return oldSkill;
} }
public Skill removeSkill(Skill skill) public Skill removeSkill(Skill skill)
@@ -720,6 +719,7 @@ public class PlayerInstance extends Creature
case CASTING: case CASTING:
{ {
useMagic(_skill); useMagic(_skill);
break; // Use a fallthrou?
} }
case INTERACT: case INTERACT:
{ {
@@ -765,8 +765,7 @@ public class PlayerInstance extends Creature
final StopMove sm = new StopMove(getObjectId(), getX(), getY(), getZ(), getHeading()); final StopMove sm = new StopMove(getObjectId(), getX(), getY(), getZ(), getHeading());
sendPacket(sm); sendPacket(sm);
boolean pickupOk = false; boolean pickupOk = false;
final ItemInstance ItemInstance = target; synchronized (target)
synchronized (ItemInstance)
{ {
if (target.isOnTheGround()) if (target.isOnTheGround())
{ {
@@ -844,7 +843,7 @@ public class PlayerInstance extends Creature
((Creature) oldTarget).removeStatusListener(this); ((Creature) oldTarget).removeStatusListener(this);
} }
} }
if ((newTarget != null) && (newTarget instanceof Creature)) if (newTarget instanceof Creature)
{ {
((Creature) newTarget).addStatusListener(this); ((Creature) newTarget).addStatusListener(this);
} }
@@ -1366,10 +1365,10 @@ public class PlayerInstance extends Creature
Armor armorPiece; Armor armorPiece;
final double lvlBonus = (89.0 + getLevel()) / 100.0; final double lvlBonus = (89.0 + getLevel()) / 100.0;
final StatModifiers modifier = CharStatsTable.getInstance().getTemplate(getClassId()); final StatModifiers modifier = CharStatsTable.getInstance().getTemplate(getClassId());
double MENbonus = 1.0; double menBonus = 1.0;
if (modifier != null) if (modifier != null)
{ {
MENbonus = (100.0 + modifier.getModmen()) / 100.0; menBonus = (100.0 + modifier.getModmen()) / 100.0;
} }
else else
{ {
@@ -1411,7 +1410,7 @@ public class PlayerInstance extends Creature
armorPiece = (Armor) dummy.getItem(); armorPiece = (Armor) dummy.getItem();
totalItemDef += armorPiece.getMDef(); totalItemDef += armorPiece.getMDef();
} }
final double mDef = totalItemDef * lvlBonus * MENbonus; final double mDef = totalItemDef * lvlBonus * menBonus;
setMagicalDefense((int) Math.round(mDef)); setMagicalDefense((int) Math.round(mDef));
} }

View File

@@ -53,12 +53,6 @@ public class TeleporterInstance extends NpcInstance
return "data/html/teleporter/" + pom + ".htm"; return "data/html/teleporter/" + pom + ".htm";
} }
@Override
public void onAction(PlayerInstance player)
{
super.onAction(player);
}
private void doTeleport(PlayerInstance player, int val) private void doTeleport(PlayerInstance player, int val)
{ {
final TeleportLocation list = TeleportLocationTable.getInstance().getTemplate(val); final TeleportLocation list = TeleportLocationTable.getInstance().getTemplate(val);

View File

@@ -30,12 +30,6 @@ public class TrainerInstance extends NpcInstance
super(template); super(template);
} }
@Override
public void onAction(PlayerInstance player)
{
super.onAction(player);
}
@Override @Override
public String getHtmlPath(int npcId, int val) public String getHtmlPath(int npcId, int val)
{ {

View File

@@ -50,12 +50,6 @@ public class VillageMasterInstance extends NpcInstance
return "data/html/villagemaster/" + pom + ".htm"; return "data/html/villagemaster/" + pom + ".htm";
} }
@Override
public void onAction(PlayerInstance player)
{
super.onAction(player);
}
public void createClan(PlayerInstance player, String clanName) public void createClan(PlayerInstance player, String clanName)
{ {
if (player.getLevel() < 10) if (player.getLevel() < 10)

View File

@@ -35,12 +35,6 @@ public class WarehouseInstance extends NpcInstance
super(template); super(template);
} }
@Override
public void onAction(PlayerInstance player)
{
super.onAction(player);
}
@Override @Override
public String getHtmlPath(int npcId, int val) public String getHtmlPath(int npcId, int val)
{ {

View File

@@ -284,7 +284,7 @@ public class ClientThread extends Thread
} }
else else
{ {
_log.warning("could not restore " + chars[charslot]); _log.warning("Could not restore " + chars[charslot]);
} }
return character; return character;
} }

View File

@@ -124,7 +124,7 @@ public class Connection
int a; int a;
int charpoint; int charpoint;
byte t1; byte t1;
final StringBuffer result = new StringBuffer(); final StringBuilder result = new StringBuilder();
int counter = 0; int counter = 0;
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)
{ {

View File

@@ -544,7 +544,7 @@ public class PacketHandler
int a; int a;
int charpoint; int charpoint;
byte t1; byte t1;
final StringBuffer result = new StringBuffer(); final StringBuilder result = new StringBuilder();
int counter = 0; int counter = 0;
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)
{ {

View File

@@ -42,7 +42,7 @@ public class AddTradeItem extends ClientBasePacket
final TradeList playerItemList = player.getTradeList(); final TradeList playerItemList = player.getTradeList();
player.getTradeList().setConfirmedTrade(false); player.getTradeList().setConfirmedTrade(false);
requestor.getTradeList().setConfirmedTrade(false); requestor.getTradeList().setConfirmedTrade(false);
if (playerItemList.getItems().size() > 0) if (!playerItemList.getItems().isEmpty())
{ {
if (!playerItemList.contains(objectId)) if (!playerItemList.contains(objectId))
{ {

View File

@@ -27,7 +27,7 @@ import org.l2jmobius.loginserver.LoginController;
public class AuthLogin extends ClientBasePacket public class AuthLogin extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(AuthLogin.class.getName()); private static final Logger _log = Logger.getLogger(AuthLogin.class.getName());
public AuthLogin(byte[] decrypt, ClientThread client) throws IOException public AuthLogin(byte[] decrypt, ClientThread client) throws IOException
{ {

View File

@@ -17,7 +17,6 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import org.l2jmobius.gameserver.IdFactory; import org.l2jmobius.gameserver.IdFactory;
@@ -91,7 +90,7 @@ public class CharacterCreate extends ClientBasePacket
return result; return result;
} }
private void initNewChar(ClientThread client, PlayerInstance newChar) throws FileNotFoundException, IOException private void initNewChar(ClientThread client, PlayerInstance newChar) throws IOException
{ {
newChar.setObjectId(IdFactory.getInstance().getNextId()); newChar.setObjectId(IdFactory.getInstance().getNextId());
World.getInstance().storeObject(newChar); World.getInstance().storeObject(newChar);

View File

@@ -17,6 +17,8 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import java.nio.charset.StandardCharsets;
public abstract class ClientBasePacket public abstract class ClientBasePacket
{ {
private final byte[] _decrypt; private final byte[] _decrypt;
@@ -65,7 +67,7 @@ public abstract class ClientBasePacket
String result = null; String result = null;
try try
{ {
result = new String(_decrypt, _off, _decrypt.length - _off, "UTF-16LE"); result = new String(_decrypt, _off, _decrypt.length - _off, StandardCharsets.UTF_16LE);
result = result.substring(0, result.indexOf(0)); result = result.substring(0, result.indexOf(0));
} }
catch (Exception e) catch (Exception e)

View File

@@ -35,7 +35,7 @@ import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
public class EnterWorld extends ClientBasePacket public class EnterWorld extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(EnterWorld.class.getName()); private static final Logger _log = Logger.getLogger(EnterWorld.class.getName());
public EnterWorld(byte[] decrypt, ClientThread client) public EnterWorld(byte[] decrypt, ClientThread client)
{ {

View File

@@ -27,7 +27,7 @@ import org.l2jmobius.gameserver.network.serverpackets.KeyPacket;
public class ProtocolVersion extends ClientBasePacket public class ProtocolVersion extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(ProtocolVersion.class.getName()); private static final Logger _log = Logger.getLogger(ProtocolVersion.class.getName());
public ProtocolVersion(byte[] rawPacket, ClientThread client) throws IOException public ProtocolVersion(byte[] rawPacket, ClientThread client) throws IOException
{ {

View File

@@ -30,7 +30,7 @@ import org.l2jmobius.gameserver.network.serverpackets.StopMove;
public class RequestActionUse extends ClientBasePacket public class RequestActionUse extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestActionUse.class.getName()); private static final Logger _log = Logger.getLogger(RequestActionUse.class.getName());
public RequestActionUse(byte[] rawPacket, ClientThread client) public RequestActionUse(byte[] rawPacket, ClientThread client)
{ {

View File

@@ -26,7 +26,7 @@ import org.l2jmobius.gameserver.network.serverpackets.AllyCrest;
public class RequestAllyCrest extends ClientBasePacket public class RequestAllyCrest extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestAllyCrest.class.getName()); private static final Logger _log = Logger.getLogger(RequestAllyCrest.class.getName());
public RequestAllyCrest(byte[] rawPacket, ClientThread client) throws IOException public RequestAllyCrest(byte[] rawPacket, ClientThread client) throws IOException
{ {

View File

@@ -33,7 +33,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class RequestBuyItem extends ClientBasePacket public class RequestBuyItem extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestBuyItem.class.getName()); private static final Logger _log = Logger.getLogger(RequestBuyItem.class.getName());
public RequestBuyItem(byte[] decrypt, ClientThread client) public RequestBuyItem(byte[] decrypt, ClientThread client)
{ {

View File

@@ -29,7 +29,7 @@ import org.l2jmobius.gameserver.network.ClientThread;
public class RequestBypassToServer extends ClientBasePacket public class RequestBypassToServer extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestBypassToServer.class.getName()); private static final Logger _log = Logger.getLogger(RequestBypassToServer.class.getName());
public RequestBypassToServer(byte[] decrypt, ClientThread client) public RequestBypassToServer(byte[] decrypt, ClientThread client)
{ {

View File

@@ -20,7 +20,6 @@ package org.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.l2jmobius.gameserver.model.World; import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.ItemInstance; import org.l2jmobius.gameserver.model.actor.instance.ItemInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.ClientThread; import org.l2jmobius.gameserver.network.ClientThread;
@@ -31,7 +30,7 @@ import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
public class RequestDropItem extends ClientBasePacket public class RequestDropItem extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestDropItem.class.getName()); private static final Logger _log = Logger.getLogger(RequestDropItem.class.getName());
public RequestDropItem(byte[] decrypt, ClientThread client) public RequestDropItem(byte[] decrypt, ClientThread client)
{ {
@@ -87,9 +86,9 @@ public class RequestDropItem extends ClientBasePacket
final DropItem di = new DropItem(dropedItem, activeChar.getObjectId()); final DropItem di = new DropItem(dropedItem, activeChar.getObjectId());
activeChar.sendPacket(di); activeChar.sendPacket(di);
activeChar.addKnownObjectWithoutCreate(dropedItem); activeChar.addKnownObjectWithoutCreate(dropedItem);
for (Creature player : activeChar.broadcastPacket(di)) for (PlayerInstance player : activeChar.broadcastPacket(di))
{ {
((PlayerInstance) player).addKnownObjectWithoutCreate(dropedItem); player.addKnownObjectWithoutCreate(dropedItem);
} }
final InventoryUpdate iu = new InventoryUpdate(); final InventoryUpdate iu = new InventoryUpdate();
if (oldCount == dropedItem.getCount()) if (oldCount == dropedItem.getCount())

View File

@@ -27,7 +27,7 @@ import org.l2jmobius.gameserver.network.serverpackets.PetInventoryUpdate;
public class RequestGetItemFromPet extends ClientBasePacket public class RequestGetItemFromPet extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestGetItemFromPet.class.getName()); private static final Logger _log = Logger.getLogger(RequestGetItemFromPet.class.getName());
public RequestGetItemFromPet(byte[] decrypt, ClientThread client) public RequestGetItemFromPet(byte[] decrypt, ClientThread client)
{ {

View File

@@ -28,7 +28,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class RequestJoinParty extends ClientBasePacket public class RequestJoinParty extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestJoinParty.class.getName()); private static final Logger _log = Logger.getLogger(RequestJoinParty.class.getName());
public RequestJoinParty(byte[] decrypt, ClientThread client) public RequestJoinParty(byte[] decrypt, ClientThread client)
{ {
@@ -120,9 +120,5 @@ public class RequestJoinParty extends ClientBasePacket
_log.warning(requestor.getName() + " already received a party invitation"); _log.warning(requestor.getName() + " already received a party invitation");
} }
} }
else if (target.getKnownPlayers().contains(requestor))
{
_log.warning(client.getActiveChar().getName() + " invited someone who doesn't know him.");
}
} }
} }

View File

@@ -26,7 +26,7 @@ import org.l2jmobius.gameserver.network.ClientThread;
public class RequestMagicSkillUse extends ClientBasePacket public class RequestMagicSkillUse extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestMagicSkillUse.class.getName()); private static final Logger _log = Logger.getLogger(RequestMagicSkillUse.class.getName());
public RequestMagicSkillUse(byte[] rawPacket, ClientThread client) public RequestMagicSkillUse(byte[] rawPacket, ClientThread client)
{ {

View File

@@ -31,7 +31,7 @@ import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
public class RequestOustPledgeMember extends ClientBasePacket public class RequestOustPledgeMember extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestOustPledgeMember.class.getName()); private static final Logger _log = Logger.getLogger(RequestOustPledgeMember.class.getName());
public RequestOustPledgeMember(byte[] rawPacket, ClientThread client) public RequestOustPledgeMember(byte[] rawPacket, ClientThread client)
{ {

View File

@@ -26,7 +26,7 @@ import org.l2jmobius.gameserver.network.serverpackets.PledgeCrest;
public class RequestPledgeCrest extends ClientBasePacket public class RequestPledgeCrest extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestPledgeCrest.class.getName()); private static final Logger _log = Logger.getLogger(RequestPledgeCrest.class.getName());
public RequestPledgeCrest(byte[] rawPacket, ClientThread client) throws IOException public RequestPledgeCrest(byte[] rawPacket, ClientThread client) throws IOException
{ {

View File

@@ -28,7 +28,7 @@ import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListAll;
public class RequestPledgeInfo extends ClientBasePacket public class RequestPledgeInfo extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(RequestPledgeInfo.class.getName()); private static final Logger _log = Logger.getLogger(RequestPledgeInfo.class.getName());
public RequestPledgeInfo(byte[] rawPacket, ClientThread client) public RequestPledgeInfo(byte[] rawPacket, ClientThread client)
{ {

View File

@@ -50,7 +50,7 @@ public class RequestUnEquipItem extends ClientBasePacket
activeChar.setAttackStatus(false); activeChar.setAttackStatus(false);
final CharInfo info = new CharInfo(activeChar); final CharInfo info = new CharInfo(activeChar);
activeChar.broadcastPacket(info); activeChar.broadcastPacket(info);
if (unequiped.size() > 0) if (!unequiped.isEmpty())
{ {
final SystemMessage sm = new SystemMessage(SystemMessage.S1_DISARMED); final SystemMessage sm = new SystemMessage(SystemMessage.S1_DISARMED);
sm.addItemName(unequiped.stream().findFirst().get().getItemId()); sm.addItemName(unequiped.stream().findFirst().get().getItemId());

View File

@@ -55,7 +55,7 @@ public class SendPrivateStoreBuyBuyList extends ClientBasePacket
{ {
buyer.getTradeList().BuySellItems(buyer, buyerlist, seller, sellerlist); buyer.getTradeList().BuySellItems(buyer, buyerlist, seller, sellerlist);
buyer.getTradeList().updateBuyList(buyer, buyerlist); buyer.getTradeList().updateBuyList(buyer, buyerlist);
if (buyer.getBuyList().size() == 0) if (buyer.getBuyList().isEmpty())
{ {
buyer.setPrivateStoreType(0); buyer.setPrivateStoreType(0);
buyer.sendPacket(new ChangeWaitType(buyer, 1)); buyer.sendPacket(new ChangeWaitType(buyer, 1));

View File

@@ -54,7 +54,7 @@ public class SendPrivateStoreBuyList extends ClientBasePacket
if ((buyer.getAdena() >= cost) && (count > 0) && (seller.getPrivateStoreType() == 1)) if ((buyer.getAdena() >= cost) && (count > 0) && (seller.getPrivateStoreType() == 1))
{ {
seller.getTradeList().BuySellItems(buyer, buyerlist, seller, sellerlist); seller.getTradeList().BuySellItems(buyer, buyerlist, seller, sellerlist);
if (seller.getSellList().size() == 0) if (seller.getSellList().isEmpty())
{ {
seller.setPrivateStoreType(0); seller.setPrivateStoreType(0);
seller.sendPacket(new ChangeWaitType(seller, 1)); seller.sendPacket(new ChangeWaitType(seller, 1));

View File

@@ -28,7 +28,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class TradeRequest extends ClientBasePacket public class TradeRequest extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(TradeRequest.class.getName()); private static final Logger _log = Logger.getLogger(TradeRequest.class.getName());
public TradeRequest(byte[] decrypt, ClientThread client) public TradeRequest(byte[] decrypt, ClientThread client)
{ {
@@ -37,7 +37,7 @@ public class TradeRequest extends ClientBasePacket
final PlayerInstance player = client.getActiveChar(); final PlayerInstance player = client.getActiveChar();
final World world = World.getInstance(); final World world = World.getInstance();
final WorldObject target = world.findObject(objectId); final WorldObject target = world.findObject(objectId);
if ((target == null) || !(target instanceof PlayerInstance) || (target.getObjectId() != objectId)) if (!(target instanceof PlayerInstance) || (target.getObjectId() != objectId))
{ {
player.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT)); player.sendPacket(new SystemMessage(SystemMessage.TARGET_IS_INCORRECT));
return; return;

View File

@@ -32,7 +32,7 @@ import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
public class UseItem extends ClientBasePacket public class UseItem extends ClientBasePacket
{ {
final static Logger _log = Logger.getLogger(UseItem.class.getName()); private static final Logger _log = Logger.getLogger(UseItem.class.getName());
public UseItem(byte[] decrypt, ClientThread client) public UseItem(byte[] decrypt, ClientThread client)
{ {

View File

@@ -19,17 +19,18 @@ package org.l2jmobius.gameserver.network.serverpackets;
public class AuthLoginFail extends ServerBasePacket public class AuthLoginFail extends ServerBasePacket
{ {
public static int NO_TEXT = 0; public static final int NO_TEXT = 0;
public static int SYSTEM_ERROR_LOGIN_LATER = 1; public static final int SYSTEM_ERROR_LOGIN_LATER = 1;
public static int PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT = 2; public static final int PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT = 2;
public static int PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT2 = 3; public static final int PASSWORD_DOES_NOT_MATCH_THIS_ACCOUNT2 = 3;
public static int ACCESS_FAILED_TRY_LATER = 4; public static final int ACCESS_FAILED_TRY_LATER = 4;
public static int INCORRECT_ACCOUNT_INFO_CONTACT_CUSTOMER_SUPPORT = 5; public static final int INCORRECT_ACCOUNT_INFO_CONTACT_CUSTOMER_SUPPORT = 5;
public static int ACCESS_FAILED_TRY_LATER2 = 6; public static final int ACCESS_FAILED_TRY_LATER2 = 6;
public static int ACOUNT_ALREADY_IN_USE = 7; public static final int ACOUNT_ALREADY_IN_USE = 7;
public static int ACCESS_FAILED_TRY_LATER3 = 8; public static final int ACCESS_FAILED_TRY_LATER3 = 8;
public static int ACCESS_FAILED_TRY_LATER4 = 9; public static final int ACCESS_FAILED_TRY_LATER4 = 9;
public static int ACCESS_FAILED_TRY_LATER5 = 10; public static final int ACCESS_FAILED_TRY_LATER5 = 10;
private final int _reason; private final int _reason;
public AuthLoginFail(int reason) public AuthLoginFail(int reason)

View File

@@ -21,8 +21,8 @@ import org.l2jmobius.gameserver.model.actor.Creature;
public class ChangeMoveType extends ServerBasePacket public class ChangeMoveType extends ServerBasePacket
{ {
public static int WALK = 0; public static final int WALK = 0;
public static int RUN = 1; public static final int RUN = 1;
private final Creature _cha; private final Creature _cha;
private final int _moveType; private final int _moveType;

View File

@@ -19,10 +19,10 @@ package org.l2jmobius.gameserver.network.serverpackets;
public class CharCreateFail extends ServerBasePacket public class CharCreateFail extends ServerBasePacket
{ {
public static int REASON_CREATION_FAILED = 0; public static final int REASON_CREATION_FAILED = 0;
public static int REASON_TOO_MANY_CHARACTERS = 1; public static final int REASON_TOO_MANY_CHARACTERS = 1;
public static int REASON_NAME_ALREADY_EXISTS = 2; public static final int REASON_NAME_ALREADY_EXISTS = 2;
public static int REASON_16_ENG_CHARS = 3; public static final int REASON_16_ENG_CHARS = 3;
private final int _error; private final int _error;

View File

@@ -121,9 +121,9 @@ public class CharSelectInfo extends ServerBasePacket
public CharSelectInfoPackage[] loadCharacterSelectInfoFromDisk() public CharSelectInfoPackage[] loadCharacterSelectInfoFromDisk()
{ {
final File _charFolder = new File("data/accounts", _loginName); final File charFolder = new File("data/accounts", _loginName);
_charFolder.mkdirs(); charFolder.mkdirs();
final File[] chars = _charFolder.listFiles((FilenameFilter) (dir, name) -> name.endsWith("_char.csv")); final File[] chars = charFolder.listFiles((FilenameFilter) (dir, name) -> name.endsWith("_char.csv"));
_charNameList = new String[chars.length]; _charNameList = new String[chars.length];
final CharSelectInfoPackage[] characters = new CharSelectInfoPackage[chars.length]; final CharSelectInfoPackage[] characters = new CharSelectInfoPackage[chars.length];
for (int i = 0; i < chars.length; ++i) for (int i = 0; i < chars.length; ++i)
@@ -132,12 +132,10 @@ public class CharSelectInfo extends ServerBasePacket
restoreChar(chars[i]); restoreChar(chars[i]);
if (_charInfopackage != null) if (_charInfopackage != null)
{ {
restoreInventory(new File(_charFolder, _charInfopackage.getName() + "_items.csv")); restoreInventory(new File(charFolder, _charInfopackage.getName() + "_items.csv"));
characters[i] = _charInfopackage; characters[i] = _charInfopackage;
_charNameList[i] = _charInfopackage.getName(); _charNameList[i] = _charInfopackage.getName();
continue;
} }
// _log.warning("could not restore " + chars[i]);
} }
return characters; return characters;
} }

View File

@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.network.serverpackets;
public class KeyPacket extends ServerBasePacket public class KeyPacket extends ServerBasePacket
{ {
final private byte[] _key; private final byte[] _key;
public KeyPacket(byte[] key) public KeyPacket(byte[] key)
{ {

View File

@@ -41,16 +41,15 @@ public class PrivateSellListBuy extends ServerBasePacket
writeD(_buyer.getAdena()); writeD(_buyer.getAdena());
final TradeList list = new TradeList(0); final TradeList list = new TradeList(0);
final List<TradeItem> buyList = _buyer.getBuyList(); final List<TradeItem> buyList = _buyer.getBuyList();
int count = _buyer.getInventory().getSize();
for (ItemInstance item : _buyer.getInventory().getItems()) for (ItemInstance item : _buyer.getInventory().getItems())
{ {
if (item.isEquipped() || (item.getItem().getType2() == 3) || ((item.getItem().getType2() == 4) && (item.getItem().getType1() == 4)) || ((item.getItem().getType2() == 1) && (item.getItem().getType1() == 1)) || item.isEquipped()) if (item.isEquipped() || (item.getItem().getType2() == 3) || ((item.getItem().getType2() == 4) && (item.getItem().getType1() == 4)) || ((item.getItem().getType2() == 1) && (item.getItem().getType1() == 1)))
{ {
continue; continue;
} }
list.addItem(item); list.addItem(item);
} }
count = list.getItems().size(); int count = list.getItems().size();
writeD(count); writeD(count);
for (ItemInstance item : list.getItems()) for (ItemInstance item : list.getItems())
{ {

View File

@@ -41,23 +41,22 @@ public class PrivateSellListSell extends ServerBasePacket
writeD(_seller.getAdena()); writeD(_seller.getAdena());
final TradeList list = new TradeList(0); final TradeList list = new TradeList(0);
final List<TradeItem> sellList = _seller.getSellList(); final List<TradeItem> sellList = _seller.getSellList();
int count = _seller.getInventory().getSize();
for (ItemInstance item : _seller.getInventory().getItems()) for (ItemInstance item : _seller.getInventory().getItems())
{ {
if (item.isEquipped() || (item.getItem().getType2() == 3) || ((item.getItem().getType2() == 4) && (item.getItem().getType1() == 4)) || ((item.getItem().getType2() == 1) && (item.getItem().getType1() == 1)) || item.isEquipped()) if (item.isEquipped() || (item.getItem().getType2() == 3) || ((item.getItem().getType2() == 4) && (item.getItem().getType1() == 4)) || ((item.getItem().getType2() == 1) && (item.getItem().getType1() == 1)))
{ {
continue; continue;
} }
list.addItem(item); list.addItem(item);
} }
if (sellList.size() != 0) if (!sellList.isEmpty())
{ {
for (TradeItem tradeItem : sellList) for (TradeItem tradeItem : sellList)
{ {
list.removeItem(tradeItem.getObjectId(), tradeItem.getCount()); list.removeItem(tradeItem.getObjectId(), tradeItem.getCount());
} }
} }
count = list.getItems().size(); int count = list.getItems().size();
writeD(count); writeD(count);
for (ItemInstance item : list.getItems()) for (ItemInstance item : list.getItems())
{ {

View File

@@ -19,13 +19,13 @@ package org.l2jmobius.gameserver.network.serverpackets;
public class RestartResponse extends ServerBasePacket public class RestartResponse extends ServerBasePacket
{ {
private static final String _message = "ok merong~ khaha"; private static final String MESSAGE = "ok merong~ khaha";
@Override @Override
public void writeImpl() public void writeImpl()
{ {
writeC(0x74); writeC(0x74);
writeD(1); writeD(1);
writeS(_message); writeS(MESSAGE);
} }
} }

View File

@@ -41,7 +41,6 @@ public class SellList extends ServerBasePacket
writeC(0x1C); writeC(0x1C);
writeD(_money); writeD(_money);
writeD(0); writeD(0);
int count = _char.getInventory().getSize();
for (ItemInstance item : _char.getInventory().getItems()) for (ItemInstance item : _char.getInventory().getItems())
{ {
if (item.isEquipped() || (item.getItemId() == 57) || (item.getItem().getType2() == 3)) if (item.isEquipped() || (item.getItemId() == 57) || (item.getItem().getType2() == 3))
@@ -50,8 +49,7 @@ public class SellList extends ServerBasePacket
} }
_selllist.add(item); _selllist.add(item);
} }
count = _selllist.size(); writeH(_selllist.size());
writeH(count);
for (ItemInstance item : _selllist) for (ItemInstance item : _selllist)
{ {
writeH(item.getItem().getType1()); writeH(item.getItem().getType1());

View File

@@ -18,6 +18,7 @@
package org.l2jmobius.gameserver.network.serverpackets; package org.l2jmobius.gameserver.network.serverpackets;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
public abstract class ServerBasePacket public abstract class ServerBasePacket
{ {
@@ -61,7 +62,7 @@ public abstract class ServerBasePacket
{ {
if (text != null) if (text != null)
{ {
_bao.write(text.getBytes("UTF-16LE")); _bao.write(text.getBytes(StandardCharsets.UTF_16LE));
} }
} }
catch (Exception e) catch (Exception e)

View File

@@ -22,32 +22,32 @@ import java.util.List;
public class StatusUpdate extends ServerBasePacket public class StatusUpdate extends ServerBasePacket
{ {
public static int LEVEL = 1; public static final int LEVEL = 1;
public static int EXP = 2; public static final int EXP = 2;
public static int STR = 3; public static final int STR = 3;
public static int DEX = 4; public static final int DEX = 4;
public static int CON = 5; public static final int CON = 5;
public static int INT = 6; public static final int INT = 6;
public static int WIT = 7; public static final int WIT = 7;
public static int MEN = 8; public static final int MEN = 8;
public static int CUR_HP = 9; public static final int CUR_HP = 9;
public static int MAX_HP = 10; public static final int MAX_HP = 10;
public static int CUR_MP = 11; public static final int CUR_MP = 11;
public static int MAX_MP = 12; public static final int MAX_MP = 12;
public static int SP = 13; public static final int SP = 13;
public static int CUR_LOAD = 14; public static final int CUR_LOAD = 14;
public static int MAX_LOAD = 15; public static final int MAX_LOAD = 15;
public static int P_ATK = 17; public static final int P_ATK = 17;
public static int ATK_SPD = 18; public static final int ATK_SPD = 18;
public static int P_DEF = 19; public static final int P_DEF = 19;
public static int EVASION = 20; public static final int EVASION = 20;
public static int ACCURACY = 21; public static final int ACCURACY = 21;
public static int CRITICAL = 22; public static final int CRITICAL = 22;
public static int M_ATK = 23; public static final int M_ATK = 23;
public static int CAST_SPD = 24; public static final int CAST_SPD = 24;
public static int M_DEF = 25; public static final int M_DEF = 25;
public static int PVP_FLAG = 26; public static final int PVP_FLAG = 26;
public static int KARMA = 27; public static final int KARMA = 27;
private final int _objectId; private final int _objectId;
private final List<Attribute> _attributes = new ArrayList<>(); private final List<Attribute> _attributes = new ArrayList<>();

View File

@@ -101,12 +101,12 @@ public class SystemMessage extends ServerBasePacket
public static final int ENABLED_SOULSHOT = 342; public static final int ENABLED_SOULSHOT = 342;
public static final int S1_PURCHASED_S2 = 378; public static final int S1_PURCHASED_S2 = 378;
public static final int S1_PURCHASED_S2_S3 = 379; public static final int S1_PURCHASED_S2_S3 = 379;
public static final int S1_PURCHASED_S3_S2_s = 380; public static final int S1_PURCHASED_S3_S2_S = 380;
public static final int S1_DISARMED = 417; public static final int S1_DISARMED = 417;
public static final int WEIGHT_LIMIT_EXCEEDED = 422; public static final int WEIGHT_LIMIT_EXCEEDED = 422;
public static final int PURCHASED_S2_FROM_S1 = 559; public static final int PURCHASED_S2_FROM_S1 = 559;
public static final int PURCHASED_S2_S3_FROM_S1 = 560; public static final int PURCHASED_S2_S3_FROM_S1 = 560;
public static final int PURCHASED_S3_S2_s_FROM_S1 = 561; public static final int PURCHASED_S3_S2_S_FROM_S1 = 561;
public static final int S1_INVITED_YOU_TO_PARTY_FINDER_KEEPER = 572; public static final int S1_INVITED_YOU_TO_PARTY_FINDER_KEEPER = 572;
public static final int S1_INVITED_YOU_TO_PARTY_RANDOM = 573; public static final int S1_INVITED_YOU_TO_PARTY_RANDOM = 573;
public static final int S1_S2 = 614; public static final int S1_S2 = 614;

View File

@@ -38,7 +38,6 @@ public class TradeStart extends ServerBasePacket
{ {
writeC(0x2E); writeC(0x2E);
writeD(_me.getTransactionRequester().getObjectId()); writeD(_me.getTransactionRequester().getObjectId());
int count = _me.getInventory().getSize();
for (ItemInstance item : _me.getInventory().getItems()) for (ItemInstance item : _me.getInventory().getItems())
{ {
if (item.isEquipped() || (item.getItem().getType2() == 3)) if (item.isEquipped() || (item.getItem().getType2() == 3))
@@ -47,7 +46,7 @@ public class TradeStart extends ServerBasePacket
} }
_tradelist.add(item); _tradelist.add(item);
} }
count = _tradelist.size(); int count = _tradelist.size();
writeH(count); writeH(count);
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {

View File

@@ -41,7 +41,6 @@ public class WareHouseDepositList extends ServerBasePacket
writeC(0x53); writeC(0x53);
writeD(_money); writeD(_money);
final List<ItemInstance> itemlist = new ArrayList<>(); final List<ItemInstance> itemlist = new ArrayList<>();
int count = _cha.getInventory().getSize();
for (ItemInstance item : _cha.getInventory().getItems()) for (ItemInstance item : _cha.getInventory().getItems())
{ {
if (item.isEquipped() || (item.getItem().getType2() == 3)) if (item.isEquipped() || (item.getItem().getType2() == 3))
@@ -50,7 +49,7 @@ public class WareHouseDepositList extends ServerBasePacket
} }
itemlist.add(item); itemlist.add(item);
} }
count = itemlist.size(); int count = itemlist.size();
writeH(count); writeH(count);
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
{ {

View File

@@ -29,6 +29,7 @@ public class Npc
private double _radius; private double _radius;
private double _height; private double _height;
private String _name; private String _name;
private String _title;
private String _sex; private String _sex;
private int _level; private int _level;
private int _attackRange; private int _attackRange;
@@ -250,6 +251,11 @@ public class Npc
_name = name; _name = name;
} }
public void setTitle(String title)
{
_title = title;
}
public void setType(String type) public void setType(String type)
{ {
_type = type; _type = type;
@@ -275,6 +281,11 @@ public class Npc
return _name; return _name;
} }
public String getTitle()
{
return _title;
}
public int getNpcId() public int getNpcId()
{ {
return _npcId; return _npcId;

View File

@@ -52,10 +52,7 @@ public class ThreadPool
INSTANT_POOL.prestartAllCoreThreads(); INSTANT_POOL.prestartAllCoreThreads();
// Launch purge task. // Launch purge task.
scheduleAtFixedRate(() -> scheduleAtFixedRate(ThreadPool::purge, 60000, 60000);
{
purge();
}, 60000, 60000);
LOGGER.info("ThreadPool: Initialized"); LOGGER.info("ThreadPool: Initialized");
LOGGER.info("...scheduled pool executor with " + Config.SCHEDULED_THREAD_POOL_COUNT + " total threads."); LOGGER.info("...scheduled pool executor with " + Config.SCHEDULED_THREAD_POOL_COUNT + " total threads.");
@@ -166,7 +163,7 @@ public class ThreadPool
} }
catch (Throwable t) catch (Throwable t)
{ {
t.printStackTrace(); LOGGER.info("ThreadPool: Problem at Shutting down. " + t.getMessage());
} }
} }
} }

View File

@@ -109,7 +109,7 @@ public class Gui
final String input = ((String) answer).trim(); final String input = ((String) answer).trim();
if (Util.isDigit(input)) if (Util.isDigit(input))
{ {
final int delay = Integer.valueOf(input); final int delay = Integer.parseInt(input);
if (delay > 0) if (delay > 0)
{ {
AdminCommands.getInstance().serverShutdown(null, delay); AdminCommands.getInstance().serverShutdown(null, delay);
@@ -170,10 +170,7 @@ public class Gui
{ {
final JMenuItem mntmFont = new JMenuItem(font); final JMenuItem mntmFont = new JMenuItem(font);
mntmFont.setFont(new Font("Segoe UI", Font.PLAIN, 13)); mntmFont.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmFont.addActionListener(arg0 -> mntmFont.addActionListener(arg0 -> txtrConsole.setFont(new Font("Monospaced", Font.PLAIN, Integer.parseInt(font))));
{
txtrConsole.setFont(new Font("Monospaced", Font.PLAIN, Integer.parseInt(font)));
});
mnFont.add(mntmFont); mnFont.add(mntmFont);
} }
@@ -183,10 +180,7 @@ public class Gui
final JMenuItem mntmAbout = new JMenuItem("About"); final JMenuItem mntmAbout = new JMenuItem("About");
mntmAbout.setFont(new Font("Segoe UI", Font.PLAIN, 13)); mntmAbout.setFont(new Font("Segoe UI", Font.PLAIN, 13));
mntmAbout.addActionListener(arg0 -> mntmAbout.addActionListener(arg0 -> new frmAbout());
{
new frmAbout();
});
mnHelp.add(mntmAbout); mnHelp.add(mntmAbout);
// Set icons. // Set icons.

View File

@@ -41,7 +41,7 @@ import org.l2jmobius.util.Locator;
*/ */
public class SystemPanel extends JPanel public class SystemPanel extends JPanel
{ {
static final long startTime = System.currentTimeMillis(); static final long START_TIME = System.currentTimeMillis();
public SystemPanel() public SystemPanel()
{ {
@@ -98,6 +98,7 @@ public class SystemPanel extends JPanel
} }
catch (Exception e) catch (Exception e)
{ {
// Handled above.
} }
// Initial update task. // Initial update task.
@@ -118,7 +119,7 @@ public class SystemPanel extends JPanel
{ {
lblConnected.setText("Connected: " + World.getInstance().getAllPlayers().size()); lblConnected.setText("Connected: " + World.getInstance().getAllPlayers().size());
lblMaxConnected.setText("Max connected: " + PlayerCountManager.getInstance().getMaxConnectedCount()); lblMaxConnected.setText("Max connected: " + PlayerCountManager.getInstance().getMaxConnectedCount());
lblElapsedTime.setText("Elapsed: " + getDurationBreakdown(System.currentTimeMillis() - startTime)); lblElapsedTime.setText("Elapsed: " + getDurationBreakdown(System.currentTimeMillis() - START_TIME));
} }
}, 1000, 1000); }, 1000, 1000);
} }

View File

@@ -25,10 +25,6 @@ import java.util.logging.LogManager;
*/ */
public class ServerLogManager extends LogManager public class ServerLogManager extends LogManager
{ {
public ServerLogManager()
{
}
@Override @Override
public void reset() public void reset()
{ {

View File

@@ -22,7 +22,7 @@ import java.util.logging.FileHandler;
public class ErrorLogHandler extends FileHandler public class ErrorLogHandler extends FileHandler
{ {
public ErrorLogHandler() throws IOException, SecurityException public ErrorLogHandler() throws IOException
{ {
super(); super();
} }

View File

@@ -47,12 +47,12 @@ public class LoginController
return _instance; return _instance;
} }
public int assignSessionKeyToLogin(String account, int accessLevel, Socket _csocket) public int assignSessionKeyToLogin(String account, int accessLevel, Socket cSocket)
{ {
int key = -1; int key = -1;
key = (int) System.currentTimeMillis() & 0xFFFFFF; key = (int) System.currentTimeMillis() & 0xFFFFFF;
_logins.put(account, key); _logins.put(account, key);
_accountsInLoginServer.put(account, _csocket); _accountsInLoginServer.put(account, cSocket);
_accessLevels.put(account, accessLevel); _accessLevels.put(account, accessLevel);
return key; return key;
} }

View File

@@ -72,7 +72,6 @@ public class LoginServer extends Thread
} }
catch (IOException e) catch (IOException e)
{ {
continue;
} }
} }
while (true); while (true);

View File

@@ -24,9 +24,11 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.LineNumberReader; import java.io.LineNumberReader;
import java.net.InetAddress; import java.net.InetAddress;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Base64; import java.util.Base64;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -38,7 +40,6 @@ public class AccountData
{ {
private static Logger _log = Logger.getLogger(AccountData.class.getName()); private static Logger _log = Logger.getLogger(AccountData.class.getName());
private static final String SHA = "SHA"; private static final String SHA = "SHA";
private static final String UTF_8 = "UTF-8";
private static final Map<String, byte[]> _logPass = new ConcurrentHashMap<>(); private static final Map<String, byte[]> _logPass = new ConcurrentHashMap<>();
private static final Map<String, Integer> _accessLevels = new ConcurrentHashMap<>(); private static final Map<String, Integer> _accessLevels = new ConcurrentHashMap<>();
private static final Map<String, Integer> _hackProtection = new ConcurrentHashMap<>(); private static final Map<String, Integer> _hackProtection = new ConcurrentHashMap<>();
@@ -78,7 +79,7 @@ public class AccountData
try try
{ {
final MessageDigest md = MessageDigest.getInstance(SHA); final MessageDigest md = MessageDigest.getInstance(SHA);
final byte[] raw = password.getBytes(UTF_8); final byte[] raw = password.getBytes(StandardCharsets.UTF_8);
final byte[] hash = md.digest(raw); final byte[] hash = md.digest(raw);
final byte[] expected = _logPass.get(user); final byte[] expected = _logPass.get(user);
if (expected == null) if (expected == null)
@@ -128,7 +129,7 @@ public class AccountData
return ok; return ok;
} }
private void readFromDisk(File loginFile) throws NumberFormatException, IOException private void readFromDisk(File loginFile) throws IOException
{ {
_logPass.clear(); _logPass.clear();
int i = 0; int i = 0;
@@ -165,11 +166,12 @@ public class AccountData
try try
{ {
final FileWriter writer = new FileWriter(new File("data/accounts.txt")); final FileWriter writer = new FileWriter(new File("data/accounts.txt"));
for (String name : _logPass.keySet()) for (Entry<String, byte[]> entry : _logPass.entrySet())
{ {
final String name = entry.getKey();
writer.write(name); writer.write(name);
writer.write("\t"); writer.write("\t");
writer.write(Base64.getEncoder().encodeToString(_logPass.get(name))); writer.write(Base64.getEncoder().encodeToString(entry.getValue()));
writer.write("\t"); writer.write("\t");
writer.write("" + _accessLevels.get(name)); writer.write("" + _accessLevels.get(name));
writer.write("\r\n"); writer.write("\r\n");

View File

@@ -41,7 +41,8 @@ import org.l2jmobius.loginserver.network.serverpackets.ServerList;
public class ClientThread extends Thread public class ClientThread extends Thread
{ {
private final static Logger _log = Logger.getLogger(ClientThread.class.getName()); private static final Logger _log = Logger.getLogger(ClientThread.class.getName());
private final InputStream _in; private final InputStream _in;
private final OutputStream _out; private final OutputStream _out;
private final NewCrypt _crypt; private final NewCrypt _crypt;
@@ -243,7 +244,7 @@ public class ClientThread extends Thread
int a; int a;
int charpoint; int charpoint;
byte t1; byte t1;
final StringBuffer result = new StringBuffer(); final StringBuilder result = new StringBuilder();
int counter = 0; int counter = 0;
for (int i = 0; i < len; ++i) for (int i = 0; i < len; ++i)
{ {
@@ -305,7 +306,7 @@ public class ClientThread extends Thread
@SuppressWarnings("unused") @SuppressWarnings("unused")
private String getTerminatedString(byte[] data, int offset) private String getTerminatedString(byte[] data, int offset)
{ {
final StringBuffer result = new StringBuffer(); final StringBuilder result = new StringBuilder();
for (int i = offset; (i < data.length) && (data[i] != 0); ++i) for (int i = offset; (i < data.length) && (data[i] != 0); ++i)
{ {
result.append((char) data[i]); result.append((char) data[i]);

View File

@@ -19,7 +19,7 @@ package org.l2jmobius.loginserver.network;
public class HackingException extends Exception public class HackingException extends Exception
{ {
String _ip; private final String _ip;
public HackingException(String ip) public HackingException(String ip)
{ {

View File

@@ -17,6 +17,8 @@
*/ */
package org.l2jmobius.loginserver.network.clientpackets; package org.l2jmobius.loginserver.network.clientpackets;
import java.nio.charset.StandardCharsets;
public abstract class ClientBasePacket public abstract class ClientBasePacket
{ {
private final byte[] _decrypt; private final byte[] _decrypt;
@@ -38,8 +40,7 @@ public abstract class ClientBasePacket
public int readC() public int readC()
{ {
final int result = _decrypt[_off++] & 0xFF; return _decrypt[_off++] & 0xFF;
return result;
} }
public int readH() public int readH()
@@ -65,7 +66,7 @@ public abstract class ClientBasePacket
String result = null; String result = null;
try try
{ {
result = new String(_decrypt, _off, _decrypt.length - _off, "UTF-16LE"); result = new String(_decrypt, _off, _decrypt.length - _off, StandardCharsets.UTF_16LE);
result = result.substring(0, result.indexOf(0)); result = result.substring(0, result.indexOf(0));
} }
catch (Exception e) catch (Exception e)

View File

@@ -19,11 +19,11 @@ package org.l2jmobius.loginserver.network.serverpackets;
public class PlayFail extends ServerBasePacket public class PlayFail extends ServerBasePacket
{ {
public static int REASON_TOO_MANY_PLAYERS = 15; public static final int REASON_TOO_MANY_PLAYERS = 15;
public static int REASON1 = 1; public static final int REASON1 = 1;
public static int REASON2 = 2; public static final int REASON2 = 2;
public static int REASON3 = 3; public static final int REASON3 = 3;
public static int REASON4 = 4; public static final int REASON4 = 4;
private final int _reason; private final int _reason;

View File

@@ -18,6 +18,7 @@
package org.l2jmobius.loginserver.network.serverpackets; package org.l2jmobius.loginserver.network.serverpackets;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.nio.charset.StandardCharsets;
public abstract class ServerBasePacket public abstract class ServerBasePacket
{ {
@@ -61,7 +62,7 @@ public abstract class ServerBasePacket
{ {
if (text != null) if (text != null)
{ {
_bao.write(text.getBytes("UTF-16LE")); _bao.write(text.getBytes(StandardCharsets.UTF_16LE));
} }
} }
catch (Exception e) catch (Exception e)

View File

@@ -24,6 +24,7 @@ import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.LineNumberReader; import java.io.LineNumberReader;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Base64; import java.util.Base64;
@@ -99,10 +100,10 @@ public class AccountManager
private static void printAccInfo(String fin) throws FileNotFoundException, IOException private static void printAccInfo(String fin) throws FileNotFoundException, IOException
{ {
final File _test = new File(fin); final File test = new File(fin);
if (!_test.exists()) if (!test.exists())
{ {
_test.createNewFile(); test.createNewFile();
} }
final FileInputStream in = new FileInputStream(fin); final FileInputStream in = new FileInputStream(fin);
@SuppressWarnings("resource") @SuppressWarnings("resource")
@@ -121,15 +122,15 @@ public class AccountManager
private static void updateAccounts(String fin, String fout) throws FileNotFoundException, IOException, NoSuchAlgorithmException private static void updateAccounts(String fin, String fout) throws FileNotFoundException, IOException, NoSuchAlgorithmException
{ {
final File _test = new File(fin); final File test = new File(fin);
if (!_test.exists()) if (!test.exists())
{ {
_test.createNewFile(); test.createNewFile();
} }
final FileInputStream in = new FileInputStream(fin); final FileInputStream in = new FileInputStream(fin);
final FileWriter out = new FileWriter(fout); final FileWriter out = new FileWriter(fout);
final MessageDigest md = MessageDigest.getInstance("SHA"); final MessageDigest md = MessageDigest.getInstance("SHA");
byte[] newpass = _pass.getBytes("UTF-8"); byte[] newpass = _pass.getBytes(StandardCharsets.UTF_8);
newpass = md.digest(newpass); newpass = md.digest(newpass);
try try
{ {
@@ -159,7 +160,7 @@ public class AccountManager
System.out.println("Account for user " + _uname + " deleted"); System.out.println("Account for user " + _uname + " deleted");
} }
} }
if (line == "") if (line.equals(""))
{ {
continue; continue;
} }
@@ -177,10 +178,10 @@ public class AccountManager
{ {
out.close(); out.close();
in.close(); in.close();
final File _fin = new File(fin); final File fileIn = new File(fin);
final File _fout = new File(fout); final File fileOut = new File(fout);
_fin.delete(); fileIn.delete();
_fout.renameTo(_fin); fileOut.renameTo(fileIn);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -191,10 +192,10 @@ public class AccountManager
{ {
out.close(); out.close();
in.close(); in.close();
final File _fin = new File(fin); final File fileIn = new File(fin);
final File _fout = new File(fout); final File fileOut = new File(fout);
_fin.delete(); fileIn.delete();
_fout.renameTo(_fin); fileOut.renameTo(fileIn);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -77,7 +77,7 @@ public class Locator
final String u = url.toString(); final String u = url.toString();
if (u.startsWith("jar:file:")) if (u.startsWith("jar:file:"))
{ {
final int pling = u.indexOf("!"); final int pling = u.indexOf('!');
final String jarName = u.substring(4, pling); final String jarName = u.substring(4, pling);
return new File(fromURI(jarName)); return new File(fromURI(jarName));
} }
@@ -118,7 +118,7 @@ public class Locator
{ {
throw new IllegalArgumentException("Can only handle valid file: URIs"); throw new IllegalArgumentException("Can only handle valid file: URIs");
} }
final StringBuffer buf = new StringBuffer(url.getHost()); final StringBuilder buf = new StringBuilder(url.getHost());
if (buf.length() > 0) if (buf.length() > 0)
{ {
buf.insert(0, File.separatorChar).insert(0, File.separatorChar); buf.insert(0, File.separatorChar).insert(0, File.separatorChar);
@@ -133,8 +133,7 @@ public class Locator
{ {
uri = uri.substring(1); uri = uri.substring(1);
} }
final String path = decodeUri(uri); return decodeUri(uri);
return path;
} }
/** /**
@@ -148,7 +147,7 @@ public class Locator
{ {
return uri; return uri;
} }
final StringBuffer sb = new StringBuffer(); final StringBuilder sb = new StringBuilder();
final CharacterIterator iter = new StringCharacterIterator(uri); final CharacterIterator iter = new StringCharacterIterator(uri);
for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next())
{ {
@@ -171,8 +170,7 @@ public class Locator
sb.append(c); sb.append(c);
} }
} }
final String path = sb.toString(); return sb.toString();
return path;
} }
/** /**

View File

@@ -592,9 +592,6 @@
<admin command="admin_tvt_remove" accessLevel="100" /> <admin command="admin_tvt_remove" accessLevel="100" />
<admin command="admin_tvt_advance" accessLevel="100" /> <admin command="admin_tvt_advance" accessLevel="100" />
<!-- ADMIN UNBLOCK IP -->
<admin command="admin_unblockip" accessLevel="100" />
<!-- ADMIN VITALITY --> <!-- ADMIN VITALITY -->
<admin command="admin_set_vitality" accessLevel="100" /> <admin command="admin_set_vitality" accessLevel="100" />
<admin command="admin_set_vitality_level" accessLevel="100" /> <admin command="admin_set_vitality_level" accessLevel="100" />

View File

@@ -145,9 +145,9 @@ public class FeedableBeasts extends AbstractNpcAI
_chance = chance; _chance = chance;
} }
public void addMobs(int spice, int[][] Mobs) public void addMobs(int spice, int[][] mobs)
{ {
_spiceToMob.put(spice, Mobs); _spiceToMob.put(spice, mobs);
} }
public Integer getMob(int spice, int mobType, int classType) public Integer getMob(int spice, int mobType, int classType)
@@ -395,12 +395,9 @@ public class FeedableBeasts extends AbstractNpcAI
} }
// remove the feedinfo of the mob that got despawned, if any // remove the feedinfo of the mob that got despawned, if any
if (FEED_INFO.containsKey(npc.getObjectId())) if (FEED_INFO.containsKey(npc.getObjectId()) && (FEED_INFO.get(npc.getObjectId()) == player.getObjectId()))
{ {
if (FEED_INFO.get(npc.getObjectId()) == player.getObjectId()) FEED_INFO.remove(npc.getObjectId());
{
FEED_INFO.remove(npc.getObjectId());
}
} }
// despawn the old mob // despawn the old mob
// TODO: same code? FIXED? // TODO: same code? FIXED?
@@ -484,26 +481,23 @@ public class FeedableBeasts extends AbstractNpcAI
@Override @Override
public String onAdvEvent(String event, Npc npc, PlayerInstance player) public String onAdvEvent(String event, Npc npc, PlayerInstance player)
{ {
if (event.equalsIgnoreCase("polymorph Mad Cow") && (npc != null) && (player != null)) if (event.equalsIgnoreCase("polymorph Mad Cow") && (npc != null) && (player != null) && MAD_COW_POLYMORPH.containsKey(npc.getId()))
{ {
if (MAD_COW_POLYMORPH.containsKey(npc.getId())) // remove the feed info from the previous mob
if (FEED_INFO.get(npc.getObjectId()) == player.getObjectId())
{ {
// remove the feed info from the previous mob FEED_INFO.remove(npc.getObjectId());
if (FEED_INFO.get(npc.getObjectId()) == player.getObjectId())
{
FEED_INFO.remove(npc.getObjectId());
}
// despawn the mad cow
npc.deleteMe();
// spawn the new mob
final Attackable nextNpc = (Attackable) addSpawn(MAD_COW_POLYMORPH.get(npc.getId()), npc);
// register the player in the feedinfo for the mob that just spawned
FEED_INFO.put(nextNpc.getObjectId(), player.getObjectId());
nextNpc.setRunning();
nextNpc.addDamageHate(player, 0, 99999);
nextNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
} }
// despawn the mad cow
npc.deleteMe();
// spawn the new mob
final Attackable nextNpc = (Attackable) addSpawn(MAD_COW_POLYMORPH.get(npc.getId()), npc);
// register the player in the feedinfo for the mob that just spawned
FEED_INFO.put(nextNpc.getObjectId(), player.getObjectId());
nextNpc.setRunning();
nextNpc.addDamageHate(player, 0, 99999);
nextNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
} }
return super.onAdvEvent(event, npc, player); return super.onAdvEvent(event, npc, player);
} }
@@ -548,7 +542,7 @@ public class FeedableBeasts extends AbstractNpcAI
{ {
food = GOLDEN_SPICE; food = GOLDEN_SPICE;
} }
else if (skillId == SKILL_CRYSTAL_SPICE) else // if (skillId == SKILL_CRYSTAL_SPICE)
{ {
food = CRYSTAL_SPICE; food = CRYSTAL_SPICE;
} }

View File

@@ -71,14 +71,12 @@ public class SummonPc extends AbstractNpcAI
final Attackable monster = (Attackable) npc; final Attackable monster = (Attackable) npc;
if (monster.getMostHated() != null) if (monster.getMostHated() != null)
{ {
if (((monster.getMostHated() == attacker) && (chance < 50)) || (chance < 10)) if ((((monster.getMostHated() == attacker) && (chance < 50)) || (chance < 10)) //
&& ((SUMMON_PC.getSkill().getMpConsume() < npc.getCurrentMp()) && (SUMMON_PC.getSkill().getHpConsume() < npc.getCurrentHp()) && !npc.isSkillDisabled(SUMMON_PC.getSkill())))
{ {
if ((SUMMON_PC.getSkill().getMpConsume() < npc.getCurrentMp()) && (SUMMON_PC.getSkill().getHpConsume() < npc.getCurrentHp()) && !npc.isSkillDisabled(SUMMON_PC.getSkill())) npc.setTarget(attacker);
{ npc.doCast(SUMMON_PC.getSkill());
npc.setTarget(attacker); npc.getVariables().set("attacked", true);
npc.doCast(SUMMON_PC.getSkill());
npc.getVariables().set("attacked", true);
}
} }
} }
} }

View File

@@ -216,7 +216,7 @@ public class Parade extends AbstractNpcAI
@Override @Override
public void run() public void run()
{ {
if (spawns.size() <= 0) if (spawns.isEmpty())
{ {
return; return;
} }
@@ -235,7 +235,7 @@ public class Parade extends AbstractNpcAI
} }
} }
} }
if ((spawns.size() == 0) && (deleteTask != null)) if ((spawns.isEmpty()) && (deleteTask != null))
{ {
deleteTask.cancel(false); deleteTask.cancel(false);
} }

View File

@@ -56,7 +56,7 @@ public class TalentShow extends AbstractNpcAI
32424, 32425, 32426, 32427, 32428 32424, 32425, 32426, 32427, 32428
}; };
// @formatter:on // @formatter:on
private static boolean IS_STARTED = false; private static boolean HAS_STARTED = false;
private static NpcStringId[] MESSAGES = private static NpcStringId[] MESSAGES =
{ {
NpcStringId.HOW_COME_PEOPLE_ARE_NOT_HERE_WE_ARE_ABOUT_TO_START_THE_SHOW_HMM, NpcStringId.HOW_COME_PEOPLE_ARE_NOT_HERE_WE_ARE_ABOUT_TO_START_THE_SHOW_HMM,
@@ -173,7 +173,7 @@ public class TalentShow extends AbstractNpcAI
private void load() private void load()
{ {
// TODO put this stuff in Routes.xml // TODO: Put this stuff in Routes.xml
TALKS.put("1", new ShoutInfo(MESSAGES[1], "2", 1000)); TALKS.put("1", new ShoutInfo(MESSAGES[1], "2", 1000));
TALKS.put("2", new ShoutInfo(MESSAGES[2], "3", 6000)); TALKS.put("2", new ShoutInfo(MESSAGES[2], "3", 6000));
TALKS.put("3", new ShoutInfo(MESSAGES[3], "4", 4000)); TALKS.put("3", new ShoutInfo(MESSAGES[3], "4", 4000));
@@ -310,7 +310,7 @@ public class TalentShow extends AbstractNpcAI
@Override @Override
public String onSpawn(Npc npc) public String onSpawn(Npc npc)
{ {
if (IS_STARTED) if (HAS_STARTED)
{ {
switch (npc.getId()) switch (npc.getId())
{ {
@@ -369,11 +369,11 @@ public class TalentShow extends AbstractNpcAI
if (event.equalsIgnoreCase("Start")) if (event.equalsIgnoreCase("Start"))
{ {
IS_STARTED = true; HAS_STARTED = true;
addSpawn(MC, -56698, -56430, -2008, 32768, false, 0); addSpawn(MC, -56698, -56430, -2008, 32768, false, 0);
startQuestTimer("Start", 14400000L, null, null); // repeat startQuestTimer("Start", 14400000L, null, null); // repeat
} }
else if ((npc != null) && IS_STARTED) else if ((npc != null) && HAS_STARTED)
{ {
// TODO switch on event // TODO switch on event
if (event.equalsIgnoreCase("6")) if (event.equalsIgnoreCase("6"))
@@ -485,7 +485,7 @@ public class TalentShow extends AbstractNpcAI
} }
else if (event.equalsIgnoreCase("clean_npc")) else if (event.equalsIgnoreCase("clean_npc"))
{ {
IS_STARTED = false; HAS_STARTED = false;
npc.deleteMe(); npc.deleteMe();
} }
else if (TALKS.containsKey(event)) else if (TALKS.containsKey(event))

View File

@@ -243,26 +243,23 @@ public class TarBeetleSpawn implements IXmlReader
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); LOGGER.warning("Problem with TarBeetleSpawn: " + e.getMessage());
} }
} }
public void refreshShots() public void refreshShots()
{ {
if (_spawn.size() > 0) for (Npc npc : _spawn)
{ {
for (Npc npc : _spawn) final int val = npc.getScriptValue();
if (val == 5)
{ {
final int val = npc.getScriptValue(); npc.deleteMe();
if (val == 5) _spawn.remove(npc);
{ }
npc.deleteMe(); else
_spawn.remove(npc); {
} npc.setScriptValue(val + 1);
else
{
npc.setScriptValue(val + 1);
}
} }
} }
} }

View File

@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.Config; import org.l2jmobius.Config;
@@ -510,11 +511,11 @@ public class EnergySeeds extends AbstractNpcAI
public void stopAI(GraciaSeeds type) public void stopAI(GraciaSeeds type)
{ {
for (Npc seed : _spawnedNpcs.keySet()) for (Entry<Npc, Integer> entry : _spawnedNpcs.entrySet())
{ {
if (type == SPAWNS.get(_spawnedNpcs.get(seed))._seedId) if (type == SPAWNS.get(entry.getValue())._seedId)
{ {
seed.deleteMe(); entry.getKey().deleteMe();
} }
} }
} }

View File

@@ -47,10 +47,6 @@ public class Lindvior extends AbstractNpcAI
private static boolean ALT_MODE = false; private static boolean ALT_MODE = false;
private static int ALT_MODE_MIN = 60; // schedule delay in minutes if ALT_MODE enabled private static int ALT_MODE_MIN = 60; // schedule delay in minutes if ALT_MODE enabled
private Npc _lindviorCamera = null;
private Npc _tomaris = null;
private Npc _artius = null;
public Lindvior() public Lindvior()
{ {
scheduleNextLindviorVisit(); scheduleNextLindviorVisit();
@@ -92,13 +88,13 @@ public class Lindvior extends AbstractNpcAI
} }
case "start": case "start":
{ {
_lindviorCamera = SpawnTable.getInstance().getAnySpawn(LINDVIOR_CAMERA).getLastSpawn(); final Npc lindviorCamera = SpawnTable.getInstance().getAnySpawn(LINDVIOR_CAMERA).getLastSpawn();
_tomaris = SpawnTable.getInstance().getAnySpawn(TOMARIS).getLastSpawn(); final Npc tomaris = SpawnTable.getInstance().getAnySpawn(TOMARIS).getLastSpawn();
_artius = SpawnTable.getInstance().getAnySpawn(ARTIUS).getLastSpawn(); final Npc artius = SpawnTable.getInstance().getAnySpawn(ARTIUS).getLastSpawn();
startQuestTimer("tomaris_shout1", 1000, _tomaris, null); startQuestTimer("tomaris_shout1", 1000, tomaris, null);
startQuestTimer("artius_shout", 60000, _artius, null); startQuestTimer("artius_shout", 60000, artius, null);
startQuestTimer("tomaris_shout2", 90000, _tomaris, null); startQuestTimer("tomaris_shout2", 90000, tomaris, null);
startQuestTimer("lindvior_scene", 120000, _lindviorCamera, null); startQuestTimer("lindvior_scene", 120000, lindviorCamera, null);
scheduleNextLindviorVisit(); scheduleNextLindviorVisit();
break; break;
} }

View File

@@ -61,12 +61,9 @@ public class AbyssGaze extends AbstractNpcAI
htmltext = "32539-1.htm"; htmltext = "32539-1.htm";
} }
} }
else if (event.equals("enter_seed")) else if (event.equals("enter_seed") && (SoIManager.getCurrentStage() == 3))
{ {
if (SoIManager.getCurrentStage() == 3) return null;
{
return null;
}
} }
return htmltext; return htmltext;
} }

View File

@@ -43,7 +43,7 @@ public class FortuneTelling extends AbstractNpcAI
@Override @Override
public String onTalk(Npc npc, PlayerInstance player) public String onTalk(Npc npc, PlayerInstance player)
{ {
String htmltext = getNoQuestMsg(player); String htmltext;
if (player.getAdena() < COST) if (player.getAdena() < COST)
{ {
htmltext = "lowadena.htm"; htmltext = "lowadena.htm";

View File

@@ -63,10 +63,6 @@ public class HallOfErosionAttack extends AbstractNpcAI
{ {
tumorCount += value; tumorCount += value;
} }
public HEAWorld()
{
}
} }
private static final int INSTANCEID = 119; private static final int INSTANCEID = 119;

View File

@@ -57,10 +57,6 @@ public class HallOfErosionDefence extends AbstractNpcAI
protected Npc deadTumor; protected Npc deadTumor;
public long startTime = 0; public long startTime = 0;
public ScheduledFuture<?> finishTask = null; public ScheduledFuture<?> finishTask = null;
public HEDWorld()
{
}
} }
private static final int INSTANCEID = 120; private static final int INSTANCEID = 120;

View File

@@ -56,10 +56,6 @@ public class HallOfSufferingAttack extends AbstractNpcAI
0, 0,
0 0
}; // 0: instance start, 1: finish time }; // 0: instance start, 1: finish time
public HSAWorld()
{
}
} }
private static final int INSTANCEID = 115; private static final int INSTANCEID = 115;
@@ -512,74 +508,72 @@ public class HallOfSufferingAttack extends AbstractNpcAI
runTwins(world); runTwins(world);
} }
} }
else if ((world.getStatus() == 6) && ((npc.getId() == KLODEKUS) || (npc.getId() == KLANIKUS))) else if (((world.getStatus() == 6) && ((npc.getId() == KLODEKUS) || (npc.getId() == KLANIKUS))) //
&& (world.klanikus.isDead() && world.klodekus.isDead()))
{ {
if (world.klanikus.isDead() && world.klodekus.isDead()) world.incStatus();
world.storeTime[1] = System.currentTimeMillis();
final Long finishDiff = world.storeTime[1] - world.storeTime[0];
if (finishDiff < 1260000)
{ {
world.incStatus(); world.setParameter("tag", 13777);
world.storeTime[1] = System.currentTimeMillis();
final Long finishDiff = world.storeTime[1] - world.storeTime[0];
if (finishDiff < 1260000)
{
world.setParameter("tag", 13777);
}
else if (finishDiff < 1380000)
{
world.setParameter("tag", 13778);
}
else if (finishDiff < 1500000)
{
world.setParameter("tag", 13779);
}
else if (finishDiff < 1620000)
{
world.setParameter("tag", 13780);
}
else if (finishDiff < 1740000)
{
world.setParameter("tag", 13781);
}
else if (finishDiff < 1860000)
{
world.setParameter("tag", 13782);
}
else if (finishDiff < 1980000)
{
world.setParameter("tag", 13783);
}
else if (finishDiff < 2100000)
{
world.setParameter("tag", 13784);
}
else if (finishDiff < 2220000)
{
world.setParameter("tag", 13785);
}
else
{
world.setParameter("tag", 13786);
}
world.klanikus = null;
world.klodekus = null;
cancelQuestTimers("ressurectTwin");
cancelQuestTimers("spawnBossGuards");
cancelQuestTimers("isTwinSeparated");
addSpawn(TEPIOS, TEPIOS_SPAWN[0], TEPIOS_SPAWN[1], TEPIOS_SPAWN[2], 0, false, 0, false, world.getInstanceId());
for (PlayerInstance killer : world.getAllowed())
{
if (killer != null)
{
killer.sendPacket(new ExSendUIEvent(killer, true, true, 0, 0, ""));
}
}
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
inst.setDuration(5 * 60000);
inst.setEmptyDestroyTime(0);
} }
else if (finishDiff < 1380000)
{
world.setParameter("tag", 13778);
}
else if (finishDiff < 1500000)
{
world.setParameter("tag", 13779);
}
else if (finishDiff < 1620000)
{
world.setParameter("tag", 13780);
}
else if (finishDiff < 1740000)
{
world.setParameter("tag", 13781);
}
else if (finishDiff < 1860000)
{
world.setParameter("tag", 13782);
}
else if (finishDiff < 1980000)
{
world.setParameter("tag", 13783);
}
else if (finishDiff < 2100000)
{
world.setParameter("tag", 13784);
}
else if (finishDiff < 2220000)
{
world.setParameter("tag", 13785);
}
else
{
world.setParameter("tag", 13786);
}
world.klanikus = null;
world.klodekus = null;
cancelQuestTimers("ressurectTwin");
cancelQuestTimers("spawnBossGuards");
cancelQuestTimers("isTwinSeparated");
addSpawn(TEPIOS, TEPIOS_SPAWN[0], TEPIOS_SPAWN[1], TEPIOS_SPAWN[2], 0, false, 0, false, world.getInstanceId());
for (PlayerInstance killer : world.getAllowed())
{
if (killer != null)
{
killer.sendPacket(new ExSendUIEvent(killer, true, true, 0, 0, ""));
}
}
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
inst.setDuration(5 * 60000);
inst.setEmptyDestroyTime(0);
} }
} }
return ""; return "";

View File

@@ -56,10 +56,6 @@ public class HallOfSufferingDefence extends AbstractNpcAI
0, 0,
0 0
}; // 0: instance start, 1: finish time }; // 0: instance start, 1: finish time
public HSDWorld()
{
}
} }
private static final int INSTANCEID = 116; // this is the client number private static final int INSTANCEID = 116; // this is the client number
@@ -512,74 +508,72 @@ public class HallOfSufferingDefence extends AbstractNpcAI
runTwins(world); runTwins(world);
} }
} }
else if ((world.getStatus() == 6) && ((npc.getId() == KLODEKUS) || (npc.getId() == KLANIKUS))) else if (((world.getStatus() == 6) && ((npc.getId() == KLODEKUS) || (npc.getId() == KLANIKUS))) //
&& (world.klanikus.isDead() && world.klodekus.isDead()))
{ {
if (world.klanikus.isDead() && world.klodekus.isDead()) world.incStatus();
world.storeTime[1] = System.currentTimeMillis();
final Long finishDiff = world.storeTime[1] - world.storeTime[0];
if (finishDiff < 1260000)
{ {
world.incStatus(); world.setParameter("tag", 13777);
world.storeTime[1] = System.currentTimeMillis();
final Long finishDiff = world.storeTime[1] - world.storeTime[0];
if (finishDiff < 1260000)
{
world.setParameter("tag", 13777);
}
else if (finishDiff < 1380000)
{
world.setParameter("tag", 13778);
}
else if (finishDiff < 1500000)
{
world.setParameter("tag", 13779);
}
else if (finishDiff < 1620000)
{
world.setParameter("tag", 13780);
}
else if (finishDiff < 1740000)
{
world.setParameter("tag", 13781);
}
else if (finishDiff < 1860000)
{
world.setParameter("tag", 13782);
}
else if (finishDiff < 1980000)
{
world.setParameter("tag", 13783);
}
else if (finishDiff < 2100000)
{
world.setParameter("tag", 13784);
}
else if (finishDiff < 2220000)
{
world.setParameter("tag", 13785);
}
else
{
world.setParameter("tag", 13786);
}
world.klanikus = null;
world.klodekus = null;
cancelQuestTimers("ressurectTwin");
cancelQuestTimers("spawnBossGuards");
cancelQuestTimers("isTwinSeparated");
addSpawn(TEPIOS, TEPIOS_SPAWN[0], TEPIOS_SPAWN[1], TEPIOS_SPAWN[2], 0, false, 0, false, world.getInstanceId());
for (PlayerInstance killer : world.getAllowed())
{
if (killer != null)
{
killer.sendPacket(new ExSendUIEvent(killer, true, true, 0, 0, ""));
}
}
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
inst.setDuration(5 * 60000);
inst.setEmptyDestroyTime(0);
} }
else if (finishDiff < 1380000)
{
world.setParameter("tag", 13778);
}
else if (finishDiff < 1500000)
{
world.setParameter("tag", 13779);
}
else if (finishDiff < 1620000)
{
world.setParameter("tag", 13780);
}
else if (finishDiff < 1740000)
{
world.setParameter("tag", 13781);
}
else if (finishDiff < 1860000)
{
world.setParameter("tag", 13782);
}
else if (finishDiff < 1980000)
{
world.setParameter("tag", 13783);
}
else if (finishDiff < 2100000)
{
world.setParameter("tag", 13784);
}
else if (finishDiff < 2220000)
{
world.setParameter("tag", 13785);
}
else
{
world.setParameter("tag", 13786);
}
world.klanikus = null;
world.klodekus = null;
cancelQuestTimers("ressurectTwin");
cancelQuestTimers("spawnBossGuards");
cancelQuestTimers("isTwinSeparated");
addSpawn(TEPIOS, TEPIOS_SPAWN[0], TEPIOS_SPAWN[1], TEPIOS_SPAWN[2], 0, false, 0, false, world.getInstanceId());
for (PlayerInstance killer : world.getAllowed())
{
if (killer != null)
{
killer.sendPacket(new ExSendUIEvent(killer, true, true, 0, 0, ""));
}
}
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
inst.setDuration(5 * 60000);
inst.setEmptyDestroyTime(0);
} }
} }
return ""; return "";

View File

@@ -69,10 +69,6 @@ public class HeartInfinityAttack extends AbstractNpcAI
{ {
tumorCount += value; tumorCount += value;
} }
public HIAWorld()
{
}
} }
private static final String qn = "HeartInfinityAttack"; private static final String qn = "HeartInfinityAttack";

View File

@@ -60,10 +60,6 @@ public class HeartInfinityDefence extends AbstractNpcAI
protected ScheduledFuture<?> finishTask = null; protected ScheduledFuture<?> finishTask = null;
protected ScheduledFuture<?> timerTask = null; protected ScheduledFuture<?> timerTask = null;
protected ScheduledFuture<?> wagonSpawnTask = null; protected ScheduledFuture<?> wagonSpawnTask = null;
public HIDWorld()
{
}
} }
private static final String qn = "HeartInfinityDefence"; private static final String qn = "HeartInfinityDefence";
@@ -406,16 +402,13 @@ public class HeartInfinityDefence extends AbstractNpcAI
ThreadPool.schedule(() -> ThreadPool.schedule(() ->
{ {
if (!conquestEnded) if (!conquestEnded && !world.deadTumors.isEmpty())
{ {
if (!world.deadTumors.isEmpty()) for (Npc npc : world.deadTumors)
{ {
for (Npc npc : world.deadTumors) if (npc != null)
{ {
if (npc != null) spawnCoffin(npc, world);
{
spawnCoffin(npc, world);
}
} }
} }
} }
@@ -563,13 +556,10 @@ public class HeartInfinityDefence extends AbstractNpcAI
} }
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc); final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(npc);
if (tmpworld instanceof HIDWorld) if ((tmpworld instanceof HIDWorld) && (npc.getId() == SOULWAGON))
{ {
if (npc.getId() == SOULWAGON) // ((MonsterInstance) npc).setPassive(true);
{ ((MonsterInstance) npc).getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
// ((MonsterInstance) npc).setPassive(true);
((MonsterInstance) npc).getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
}
} }
return super.onSpawn(npc); return super.onSpawn(npc);
} }

View File

@@ -32,14 +32,12 @@ import org.l2jmobius.gameserver.instancemanager.InstanceManager;
import org.l2jmobius.gameserver.instancemanager.SoDManager; import org.l2jmobius.gameserver.instancemanager.SoDManager;
import org.l2jmobius.gameserver.model.CommandChannel; import org.l2jmobius.gameserver.model.CommandChannel;
import org.l2jmobius.gameserver.model.Location; import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Attackable; import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc; import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.Summon;
import org.l2jmobius.gameserver.model.actor.instance.DoorInstance; import org.l2jmobius.gameserver.model.actor.instance.DoorInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
import org.l2jmobius.gameserver.model.instancezone.Instance; import org.l2jmobius.gameserver.model.instancezone.Instance;
import org.l2jmobius.gameserver.model.instancezone.InstanceWorld; import org.l2jmobius.gameserver.model.instancezone.InstanceWorld;
import org.l2jmobius.gameserver.model.quest.QuestState; import org.l2jmobius.gameserver.model.quest.QuestState;
@@ -96,11 +94,6 @@ public class SeedOfDestruction extends AbstractNpcAI
private static final int[] MOB_IDS = {22536, 22537, 22538, 22539, 22540, 22541, 22542, 22543, 22544, 22547, 22550, 22551, 22552, 22596, 29162}; private static final int[] MOB_IDS = {22536, 22537, 22538, 22539, 22540, 22541, 22542, 22543, 22544, 22547, 22550, 22551, 22552, 22596, 29162};
private static final Location MOVE_TO_TIAT = new Location(-250403, 207273, -11952, 16384); private static final Location MOVE_TO_TIAT = new Location(-250403, 207273, -11952, 16384);
// Traps/Skills
private static final SkillHolder TRAP_HOLD = new SkillHolder(4186, 9); // 18720-18728
private static final SkillHolder TRAP_STUN = new SkillHolder(4072, 10); // 18729-18736
private static final SkillHolder TRAP_DAMAGE = new SkillHolder(5340, 4); // 18737-18774
// Doors/Walls/Zones // Doors/Walls/Zones
private static final int[] ATTACKABLE_DOORS = {12240005, 12240006, 12240007, 12240008, 12240009, 12240010, 12240013, 12240014, 12240015, 12240016, 12240017, 12240018, 12240021, 12240022, 12240023, 12240024, 12240025, 12240026, 12240028, 12240029, 12240030}; private static final int[] ATTACKABLE_DOORS = {12240005, 12240006, 12240007, 12240008, 12240009, 12240010, 12240013, 12240014, 12240015, 12240016, 12240017, 12240018, 12240021, 12240022, 12240023, 12240024, 12240025, 12240026, 12240028, 12240029, 12240030};
private static final int[] ENTRANCE_ROOM_DOORS = {12240001, 12240002}; private static final int[] ENTRANCE_ROOM_DOORS = {12240001, 12240002};
@@ -971,7 +964,6 @@ public class SeedOfDestruction extends AbstractNpcAI
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
player.setInstanceId(teleto.instanceId); player.setInstanceId(teleto.instanceId);
player.teleToLocation(teleto.x, teleto.y, teleto.z); player.teleToLocation(teleto.x, teleto.y, teleto.z);
return;
} }
private void teleportplayer(PlayerInstance player, teleCoord teleto, SODWorld world) private void teleportplayer(PlayerInstance player, teleCoord teleto, SODWorld world)
@@ -1092,21 +1084,7 @@ public class SeedOfDestruction extends AbstractNpcAI
// traps // traps
if ((mob[0] >= 18720) && (mob[0] <= 18774)) if ((mob[0] >= 18720) && (mob[0] <= 18774))
{ {
Skill skill = null; addTrap(mob[0], mob[1], mob[2], mob[3], mob[4], world.getInstanceId());
if (mob[0] <= 18728)
{
skill = TRAP_HOLD.getSkill();
}
else if (mob[0] <= 18736)
{
skill = TRAP_STUN.getSkill();
}
else
// if (mob[0] <= 18774)
{
skill = TRAP_DAMAGE.getSkill();
}
addTrap(mob[0], mob[1], mob[2], mob[3], mob[4], skill, world.getInstanceId());
continue; continue;
} }
@@ -1171,12 +1149,6 @@ public class SeedOfDestruction extends AbstractNpcAI
} }
} }
@Override
public String onSkillSee(Npc npc, PlayerInstance caster, Skill skill, WorldObject[] targets, boolean isPet)
{
return super.onSkillSee(npc, caster, skill, targets, isPet);
}
@Override @Override
public String onSpawn(Npc npc) public String onSpawn(Npc npc)
{ {
@@ -1203,18 +1175,15 @@ public class SeedOfDestruction extends AbstractNpcAI
} }
else if ((world.getStatus() <= 8) && (npc.getId() == TIAT)) else if ((world.getStatus() <= 8) && (npc.getId() == TIAT))
{ {
if (npc.getCurrentHp() < (npc.getMaxHp() / 2)) if ((npc.getCurrentHp() < (npc.getMaxHp() / 2)) && (_numAtk < 1))
{ {
if (_numAtk < 1) final ExShowScreenMessage message4 = new ExShowScreenMessage(NpcStringId.COME_OUT_WARRIORS_PROTECT_SEED_OF_DESTRUCTION, 5, 5000);
{ sendScreenMessage(world, message4);
final ExShowScreenMessage message4 = new ExShowScreenMessage(NpcStringId.COME_OUT_WARRIORS_PROTECT_SEED_OF_DESTRUCTION, 5, 5000); world._tiat.doCast(SkillData.getInstance().getSkill(5818, 1));
sendScreenMessage(world, message4); world._tiat.doCast(SkillData.getInstance().getSkill(181, 1));
world._tiat.doCast(SkillData.getInstance().getSkill(5818, 1)); world.deviceSpawnedMobCount = 0;
world._tiat.doCast(SkillData.getInstance().getSkill(181, 1)); spawn(world, THRONE_PORTALS, false, true);
world.deviceSpawnedMobCount = 0; _numAtk++;
spawn(world, THRONE_PORTALS, false, true);
_numAtk++;
}
} }
} }
} }
@@ -1228,60 +1197,64 @@ public class SeedOfDestruction extends AbstractNpcAI
if (tmpworld instanceof SODWorld) if (tmpworld instanceof SODWorld)
{ {
final SODWorld world = (SODWorld) tmpworld; final SODWorld world = (SODWorld) tmpworld;
if (event.equals("ThroneSpawn")) switch (event)
{ {
world._tiat = addSpawn(TIAT, -250400, 207271, -11961, 16285, false, 0, false, world.getInstanceId()); case "ThroneSpawn":
world._tiat.setRandomWalking(false);
world._naezdTR1 = addSpawn(NAEZD, -250154, 207203, -11970, 33818, false, 0, false, world.getInstanceId());
world._naezdTR1.setRandomWalking(false);
world._naezdTR2 = addSpawn(NAEZD, -250209, 206941, -11966, 27379, false, 0, false, world.getInstanceId());
world._naezdTR2.setRandomWalking(false);
world._naezdTL1 = addSpawn(NAEZD, -250652, 207203, -11970, 0, false, 0, false, world.getInstanceId());
world._naezdTL1.setRandomWalking(false);
world._naezdTL2 = addSpawn(NAEZD, -250597, 206941, -11966, 6867, false, 0, false, world.getInstanceId());
world._naezdTL2.setRandomWalking(false);
for (int i = 0; i < 12; i++)
{ {
final Npc npc1 = addSpawn(22543, ONETR[i][0], ONETR[i][1], ONETR[i][2], 16285, false, 0, false, world.getInstanceId()); world._tiat = addSpawn(TIAT, -250400, 207271, -11961, 16285, false, 0, false, world.getInstanceId());
npc1.setRandomWalking(false); world._tiat.setRandomWalking(false);
world._mags.add(npc1); world._naezdTR1 = addSpawn(NAEZD, -250154, 207203, -11970, 33818, false, 0, false, world.getInstanceId());
world._naezdTR1.setRandomWalking(false);
final Npc npc2 = addSpawn(22541, TWOTR[i][0], TWOTR[i][1], TWOTR[i][2], 16285, false, 0, false, world.getInstanceId()); world._naezdTR2 = addSpawn(NAEZD, -250209, 206941, -11966, 27379, false, 0, false, world.getInstanceId());
npc2.setRandomWalking(false); world._naezdTR2.setRandomWalking(false);
} world._naezdTL1 = addSpawn(NAEZD, -250652, 207203, -11970, 0, false, 0, false, world.getInstanceId());
for (int i = 0; i < 6; i++) world._naezdTL1.setRandomWalking(false);
{ world._naezdTL2 = addSpawn(NAEZD, -250597, 206941, -11966, 6867, false, 0, false, world.getInstanceId());
final Npc npc3 = addSpawn(FRETR[i][0], FRETR[i][1], FRETR[i][2], FRETR[i][3], 16285, false, 0, false, world.getInstanceId()); world._naezdTL2.setRandomWalking(false);
npc3.setRandomWalking(false); for (int i = 0; i < 12; i++)
final Npc npc4 = addSpawn(22536, FORTR[i][0], FORTR[i][1], FORTR[i][2], 16285, false, 0, false, world.getInstanceId());
npc4.setRandomWalking(false);
final Npc npc5 = addSpawn(22537, FIVETR[i][0], FIVETR[i][1], FIVETR[i][2], 16285, false, 0, false, world.getInstanceId());
npc5.setRandomWalking(false);
}
spawn(world, FORT_PORTALS, false, true);
}
else if (event.equals("KillTiatPart1"))
{
playMovie(world, Movie.SC_BOSS_TIAT_ENDING_SUCCES);
InstanceManager.getInstance().getInstance(world.getInstanceId()).getNpcs().forEach(Npc::deleteMe);
}
else if (event.equals("Spawn"))
{
if (world.getStatus() <= 7)
{
final PlayerInstance target = world.getAllowed().stream().findAny().get();
if ((world.deviceSpawnedMobCount < MAX_DEVICE_SPAWNED_MOB_COUNT) && (target != null) && ((npc != null) && (target.getInstanceId() == npc.getInstanceId())) && !target.isDead())
{ {
final Attackable mob = (Attackable) addSpawn(SPAWN_MOB_IDS[Rnd.get(SPAWN_MOB_IDS.length)], npc.getSpawn().getX(), npc.getSpawn().getY(), npc.getSpawn().getZ(), npc.getSpawn().getHeading(), false, 0, false, world.getInstanceId()); final Npc npc1 = addSpawn(22543, ONETR[i][0], ONETR[i][1], ONETR[i][2], 16285, false, 0, false, world.getInstanceId());
world.deviceSpawnedMobCount++; npc1.setRandomWalking(false);
mob.setSeeThroughSilentMove(true); world._mags.add(npc1);
mob.setRunning();
mob.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MOVE_TO_TIAT); final Npc npc2 = addSpawn(22541, TWOTR[i][0], TWOTR[i][1], TWOTR[i][2], 16285, false, 0, false, world.getInstanceId());
npc2.setRandomWalking(false);
} }
for (int i = 0; i < 6; i++)
{
final Npc npc3 = addSpawn(FRETR[i][0], FRETR[i][1], FRETR[i][2], FRETR[i][3], 16285, false, 0, false, world.getInstanceId());
npc3.setRandomWalking(false);
final Npc npc4 = addSpawn(22536, FORTR[i][0], FORTR[i][1], FORTR[i][2], 16285, false, 0, false, world.getInstanceId());
npc4.setRandomWalking(false);
final Npc npc5 = addSpawn(22537, FIVETR[i][0], FIVETR[i][1], FIVETR[i][2], 16285, false, 0, false, world.getInstanceId());
npc5.setRandomWalking(false);
}
spawn(world, FORT_PORTALS, false, true);
break;
}
case "KillTiatPart1":
{
playMovie(world, Movie.SC_BOSS_TIAT_ENDING_SUCCES);
InstanceManager.getInstance().getInstance(world.getInstanceId()).getNpcs().forEach(Npc::deleteMe);
break;
}
case "Spawn":
{
if (world.getStatus() <= 7)
{
final PlayerInstance target = world.getAllowed().stream().findAny().get();
if ((world.deviceSpawnedMobCount < MAX_DEVICE_SPAWNED_MOB_COUNT) && (target != null) && ((npc != null) && (target.getInstanceId() == npc.getInstanceId())) && !target.isDead())
{
final Attackable mob = (Attackable) addSpawn(SPAWN_MOB_IDS[Rnd.get(SPAWN_MOB_IDS.length)], npc.getSpawn().getX(), npc.getSpawn().getY(), npc.getSpawn().getZ(), npc.getSpawn().getHeading(), false, 0, false, world.getInstanceId());
world.deviceSpawnedMobCount++;
mob.setSeeThroughSilentMove(true);
mob.setRunning();
mob.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, MOVE_TO_TIAT);
}
}
break;
} }
} }
} }

View File

@@ -286,28 +286,25 @@ public abstract class AirShipController extends AbstractNpcAI
@Override @Override
public String onEnterZone(Creature creature, ZoneType zone) public String onEnterZone(Creature creature, ZoneType zone)
{ {
if (creature instanceof ControllableAirShipInstance) if ((creature instanceof ControllableAirShipInstance) && (_dockedShip == null))
{ {
if (_dockedShip == null) _dockedShip = (ControllableAirShipInstance) creature;
_dockedShip.setInDock(_dockZone);
_dockedShip.setOustLoc(_oustLoc);
// Ship is not empty - display movie to passengers and dock
if (!_dockedShip.isEmpty())
{ {
_dockedShip = (ControllableAirShipInstance) creature; if (_movie != null)
_dockedShip.setInDock(_dockZone); {
_dockedShip.setOustLoc(_oustLoc); playMovie(_dockedShip.getPassengers(), _movie);
}
// Ship is not empty - display movie to passengers and dock ThreadPool.schedule(_decayTask, 1000);
if (!_dockedShip.isEmpty()) }
{ else
if (_movie != null) {
{ _departSchedule = ThreadPool.schedule(_departTask, DEPART_INTERVAL);
playMovie(_dockedShip.getPassengers(), _movie);
}
ThreadPool.schedule(_decayTask, 1000);
}
else
{
_departSchedule = ThreadPool.schedule(_departTask, DEPART_INTERVAL);
}
} }
} }
return null; return null;
@@ -316,20 +313,17 @@ public abstract class AirShipController extends AbstractNpcAI
@Override @Override
public String onExitZone(Creature creature, ZoneType zone) public String onExitZone(Creature creature, ZoneType zone)
{ {
if (creature instanceof ControllableAirShipInstance) if ((creature instanceof ControllableAirShipInstance) && creature.equals(_dockedShip))
{ {
if (creature.equals(_dockedShip)) if (_departSchedule != null)
{ {
if (_departSchedule != null) _departSchedule.cancel(false);
{ _departSchedule = null;
_departSchedule.cancel(false);
_departSchedule = null;
}
_dockedShip.setInDock(0);
_dockedShip = null;
_isBusy = false;
} }
_dockedShip.setInDock(0);
_dockedShip = null;
_isBusy = false;
} }
return null; return null;
} }
@@ -368,14 +362,11 @@ public abstract class AirShipController extends AbstractNpcAI
} }
} }
} }
if (_arrivalPath == null) if ((_arrivalPath == null) && !ZoneManager.getInstance().getZoneById(_dockZone, ScriptZone.class).isInsideZone(_shipSpawnX, _shipSpawnY, _shipSpawnZ))
{ {
if (!ZoneManager.getInstance().getZoneById(_dockZone, ScriptZone.class).isInsideZone(_shipSpawnX, _shipSpawnY, _shipSpawnZ)) LOGGER.log(Level.WARNING, getName() + ": Arrival path is null and spawn point not in zone " + _dockZone + ", controller disabled");
{ _isBusy = true;
LOGGER.log(Level.WARNING, getName() + ": Arrival path is null and spawn point not in zone " + _dockZone + ", controller disabled"); return;
_isBusy = true;
return;
}
} }
if (_departPath != null) if (_departPath != null)

View File

@@ -303,7 +303,7 @@ public class AirShipGludioGracia extends AbstractNpcAI implements Runnable
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); LOGGER.warning(e.toString());
} }
} }

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