From be6443a66a2177ec1ae153c00d0ae2667c0e7dde Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Sun, 23 Oct 2016 14:56:34 +0000 Subject: [PATCH] Partial sync L2jUnity free release Feb 16th 2015. --- .../dist/game/config/MentorCoins.xml | 80 ++--- .../admin/teleports/raid/raid_special.htm | 2 +- .../ai/individual/Antharas/Antharas.java | 4 +- .../scripts/ai/individual/Baium/Baium.java | 4 +- .../game/data/scripts/ai/individual/Core.java | 4 +- .../data/scripts/ai/individual/Orfen.java | 4 +- .../data/scripts/ai/individual/QueenAnt.java | 4 +- .../data/scripts/ai/individual/Valakas.java | 4 +- .../scripts/ai/npc/ArenaManager/31225.html | 8 +- .../scripts/ai/npc/ArenaManager/31226.html | 11 +- .../ai/npc/MentorGuide/MentorGuide.java | 3 + .../ai/zones/TalkingIsland/Raina/Raina.java | 2 + .../Raina/addDualClassErtheia.html | 22 +- .../L2DoorInstanceActionShift.java | 2 +- .../L2ItemInstanceActionShift.java | 6 +- .../actionshifthandlers/L2NpcActionShift.java | 2 +- .../L2StaticObjectInstanceActionShift.java | 7 +- .../admincommandhandlers/AdminBuffs.java | 54 ++- .../admincommandhandlers/AdminClanHall.java | 19 +- .../AdminCursedWeapons.java | 42 ++- .../admincommandhandlers/AdminEditChar.java | 30 +- .../AdminEventEngine.java | 18 +- .../admincommandhandlers/AdminEvents.java | 3 +- .../AdminFightCalculator.java | 26 +- .../admincommandhandlers/AdminFortSiege.java | 3 +- .../AdminInstanceZone.java | 8 +- .../admincommandhandlers/AdminManor.java | 9 +- .../admincommandhandlers/AdminSkill.java | 20 +- .../admincommandhandlers/AdminSpawn.java | 22 +- .../admincommandhandlers/AdminTeleport.java | 3 +- .../admincommandhandlers/AdminZone.java | 15 +- .../handlers/bypasshandlers/QuestLink.java | 32 +- .../handlers/communityboard/ClanBoard.java | 62 +++- .../usercommandhandlers/ClanPenalty.java | 18 +- .../handlers/voicedcommandhandlers/Lang.java | 5 +- .../voicedcommandhandlers/StatsVCmd.java | 6 +- .../scripts/instances/AbstractInstance.java | 5 + .../instances/ElcadiasTent/ElcadiasTent.java | 6 +- .../FaeronTrainingGrounds1.java | 6 +- .../FaeronTrainingGrounds2.java | 6 +- .../HarnakUndergroundRuins.java | 31 +- .../HideoutOfTheDawn/HideoutOfTheDawn.java | 6 +- .../JiniaGuildHideout1.java | 6 +- .../JiniaGuildHideout2.java | 6 +- .../JiniaGuildHideout3.java | 6 +- .../JiniaGuildHideout4.java | 6 +- .../PailakaSongOfIceAndFire.java | 6 +- .../32497-01.htm | 2 +- .../32497-02.htm | 13 +- .../32510-00.htm | 2 +- .../32510-01.htm | 19 +- .../32510-02.htm | 4 +- .../Q00128_PailakaSongOfIceAndFire.java | 62 ++-- .../Q00129_PailakaDevilsLegacy.java | 9 +- .../game/data/stats/skills/10000-10099.xml | 49 +-- .../game/data/stats/skills/10200-10299.xml | 239 +++++++------ .../game/data/stats/skills/10300-10399.xml | 51 +-- .../game/data/stats/skills/11300-11399.xml | 14 +- .../game/data/stats/skills/11700-11799.xml | 65 +++- .../game/data/stats/skills/13000-13099.xml | 315 ++++++++---------- .../game/data/stats/skills/30000-30099.xml | 8 +- .../game/data/stats/skills/30400-30499.xml | 25 +- .../game/data/stats/skills/30500-30599.xml | 8 +- .../game/data/stats/transformations/20007.xml | 2 +- .../java/com/l2jmobius/Config.java | 69 ++-- .../gameserver/ThreadPoolManager.java | 27 +- .../communitybbs/Manager/PostBBSManager.java | 15 +- .../communitybbs/Manager/TopicBBSManager.java | 25 +- .../gameserver/data/xml/impl/NpcData.java | 2 +- .../instancemanager/GrandBossManager.java | 10 +- .../instancemanager/PetitionManager.java | 14 +- .../l2jmobius/gameserver/model/MacroList.java | 5 +- .../actor/instance/L2ClassMasterInstance.java | 5 +- .../model/actor/instance/L2NpcInstance.java | 3 +- .../model/actor/instance/L2PcInstance.java | 8 +- .../gameserver/model/entity/Hero.java | 29 +- .../gameserver/model/entity/Message.java | 3 +- .../gameserver/model/entity/TvTEvent.java | 3 +- .../model/itemcontainer/Inventory.java | 4 +- .../gameserver/model/items/L2Armor.java | 3 +- .../gameserver/model/items/L2EtcItem.java | 7 +- .../gameserver/model/items/L2Item.java | 99 +++--- .../gameserver/model/items/L2Weapon.java | 39 ++- .../gameserver/model/quest/QuestState.java | 18 +- .../gameserver/model/skills/AbnormalType.java | 2 + .../model/zone/type/L2EffectZone.java | 5 +- .../model/zone/type/L2ScriptZone.java | 2 +- .../clientpackets/RequestSendPost.java | 3 +- .../serverpackets/ExUserInfoFishing.java | 44 +++ .../network/serverpackets/ShowBoard.java | 4 +- .../cellnodes/CellPathFinding.java | 51 ++- .../scripting/java/JavaExecutionContext.java | 13 +- .../gameserver/util/FloodProtectorAction.java | 20 +- .../l2jmobius/gameserver/util/HtmlUtil.java | 59 +++- .../log/formatter/AbstractFormatter.java | 42 +++ .../log/formatter/AccountingFormatter.java | 219 ++++++------ .../log/formatter/AuditFormatter.java | 106 +++--- .../log/formatter/ChatLogFormatter.java | 95 +++--- .../log/formatter/ConsoleLogFormatter.java | 96 +++--- .../log/formatter/DamageFormatter.java | 173 +++++----- .../log/formatter/EnchantFormatter.java | 193 ++++++----- .../log/formatter/FileLogFormatter.java | 87 ++--- .../log/formatter/ItemLogFormatter.java | 140 ++++---- .../log/formatter/OlympiadFormatter.java | 97 +++--- .../java/com/l2jmobius/util/StringUtil.java | 276 --------------- .../java/com/l2jmobius/util/Util.java | 13 + 106 files changed, 1866 insertions(+), 1803 deletions(-) create mode 100644 L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/serverpackets/ExUserInfoFishing.java create mode 100644 L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AbstractFormatter.java delete mode 100644 L2J_Mobius_Test/java/com/l2jmobius/util/StringUtil.java diff --git a/L2J_Mobius_Test/dist/game/config/MentorCoins.xml b/L2J_Mobius_Test/dist/game/config/MentorCoins.xml index 452bf07319..f0c9278ae8 100644 --- a/L2J_Mobius_Test/dist/game/config/MentorCoins.xml +++ b/L2J_Mobius_Test/dist/game/config/MentorCoins.xml @@ -1,44 +1,44 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/L2J_Mobius_Test/dist/game/data/html/admin/teleports/raid/raid_special.htm b/L2J_Mobius_Test/dist/game/data/html/admin/teleports/raid/raid_special.htm index 69fb2074e7..50ba48e9e3 100644 --- a/L2J_Mobius_Test/dist/game/data/html/admin/teleports/raid/raid_special.htm +++ b/L2J_Mobius_Test/dist/game/data/html/admin/teleports/raid/raid_special.htm @@ -24,7 +24,7 @@ -
-
+ + + -
+ \ No newline at end of file diff --git a/L2J_Mobius_Test/dist/game/data/scripts/ai/npc/ArenaManager/31226.html b/L2J_Mobius_Test/dist/game/data/scripts/ai/npc/ArenaManager/31226.html index f701d7a9df..37f3798a27 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/ai/npc/ArenaManager/31226.html +++ b/L2J_Mobius_Test/dist/game/data/scripts/ai/npc/ArenaManager/31226.html @@ -1,9 +1,10 @@ Arena Director:
-Play the game according to the rules! The loser should be silent! What? Unfair? Then, why don't you hold your tongue and give it another try!

- -
-
+Play the game according to the rules! The loser should be silent!
+What? Unfair? Then, why don't you hold your tongue and give it another try!

+ + + -
+ \ No newline at end of file diff --git a/L2J_Mobius_Test/dist/game/data/scripts/ai/npc/MentorGuide/MentorGuide.java b/L2J_Mobius_Test/dist/game/data/scripts/ai/npc/MentorGuide/MentorGuide.java index edfddeb571..0db19a3625 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/ai/npc/MentorGuide/MentorGuide.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/ai/npc/MentorGuide/MentorGuide.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.logging.Level; +import java.util.logging.Logger; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -61,6 +62,8 @@ import ai.AbstractNpcAI; */ public final class MentorGuide extends AbstractNpcAI implements IXmlReader { + private static final Logger LOGGER = Logger.getLogger(MentorGuide.class.getName()); + // NPCs private static final int MENTOR_GUIDE = 33587; diff --git a/L2J_Mobius_Test/dist/game/data/scripts/ai/zones/TalkingIsland/Raina/Raina.java b/L2J_Mobius_Test/dist/game/data/scripts/ai/zones/TalkingIsland/Raina/Raina.java index 50046fadf5..5164229e76 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/ai/zones/TalkingIsland/Raina/Raina.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/ai/zones/TalkingIsland/Raina/Raina.java @@ -66,6 +66,7 @@ public final class Raina extends AbstractNpcAI private static final int RAINA = 33491; // Items private static final int SUBCLASS_CERTIFICATE = 30433; + private static final int CHAOS_POMANDER = 37375; private static final int ABELIUS_POWER = 32264; private static final int SAPYROS_POWER = 32265; private static final int ASHAGEN_POWER = 32266; @@ -593,6 +594,7 @@ public final class Raina extends AbstractNpcAI player.sendPacket(new AcquireSkillList(player)); player.sendSkillList(); addPowerItem(player); + giveItems(player, CHAOS_POMANDER, 2); } break; } diff --git a/L2J_Mobius_Test/dist/game/data/scripts/ai/zones/TalkingIsland/Raina/addDualClassErtheia.html b/L2J_Mobius_Test/dist/game/data/scripts/ai/zones/TalkingIsland/Raina/addDualClassErtheia.html index 39b7f96ab3..01e08c9fb4 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/ai/zones/TalkingIsland/Raina/addDualClassErtheia.html +++ b/L2J_Mobius_Test/dist/game/data/scripts/ai/zones/TalkingIsland/Raina/addDualClassErtheia.html @@ -1,12 +1,12 @@ -Subclass/Dual Class Master Raina:

-So, into which class would you like to Reawaken?
-Remember that if you proceed, you will go back to Lv. 85, and all your skills will be reset.
- - - - - - - - +Subclass/Dual Class Master Raina:
+Which class would you like as your Dual Class? +(A Level 85 Dual Class will be added, and the 3rd transfer skills provided will be based on Human class.)
+ + + + + + + + \ No newline at end of file diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2DoorInstanceActionShift.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2DoorInstanceActionShift.java index aed8ea32e5..f814e5a038 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2DoorInstanceActionShift.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2DoorInstanceActionShift.java @@ -29,7 +29,7 @@ public class L2DoorInstanceActionShift implements IActionShiftHandler @Override public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) { - if (activeChar.getAccessLevel().isGm()) + if (activeChar.isGM()) { activeChar.setTarget(target); final L2DoorInstance door = (L2DoorInstance) target; diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2ItemInstanceActionShift.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2ItemInstanceActionShift.java index 5f2a5bd5be..2ed3fa375f 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2ItemInstanceActionShift.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2ItemInstanceActionShift.java @@ -22,16 +22,16 @@ import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; -import com.l2jmobius.util.StringUtil; public class L2ItemInstanceActionShift implements IActionShiftHandler { @Override public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) { - if (activeChar.getAccessLevel().isGm()) + if (activeChar.isGM()) { - activeChar.sendPacket(new NpcHtmlMessage(StringUtil.concat("
Item Info

", "
Object ID: ", String.valueOf(target.getObjectId()), "
Item ID: ", String.valueOf(target.getId()), "
Owner ID: ", String.valueOf(((L2ItemInstance) target).getOwnerId()), "
Location: ", String.valueOf(((L2ItemInstance) target).getLocation()), "

Class: ", target.getClass().getSimpleName(), "
"))); + final NpcHtmlMessage html = new NpcHtmlMessage("
Item Info

Object ID: " + target.getObjectId() + "
Item ID: " + target.getId() + "
Owner ID: " + ((L2ItemInstance) target).getOwnerId() + "
Location: " + ((L2ItemInstance) target).getLocation() + "

Class: " + target.getClass().getSimpleName() + "
"); + activeChar.sendPacket(html); } return true; } diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2NpcActionShift.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2NpcActionShift.java index 3daa348cd0..be8361248c 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2NpcActionShift.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2NpcActionShift.java @@ -57,7 +57,7 @@ public class L2NpcActionShift implements IActionShiftHandler public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) { // Check if the L2PcInstance is a GM - if (activeChar.getAccessLevel().isGm()) + if (activeChar.isGM()) { // Set the target of the L2PcInstance activeChar activeChar.setTarget(target); diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2StaticObjectInstanceActionShift.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2StaticObjectInstanceActionShift.java index 45b4d4d4e8..521d60ef44 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2StaticObjectInstanceActionShift.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/actionshifthandlers/L2StaticObjectInstanceActionShift.java @@ -23,18 +23,19 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.StaticObject; -import com.l2jmobius.util.StringUtil; public class L2StaticObjectInstanceActionShift implements IActionShiftHandler { @Override public boolean action(L2PcInstance activeChar, L2Object target, boolean interact) { - if (activeChar.getAccessLevel().isGm()) + if (activeChar.isGM()) { activeChar.setTarget(target); activeChar.sendPacket(new StaticObject((L2StaticObjectInstance) target)); - activeChar.sendPacket(new NpcHtmlMessage(StringUtil.concat("
Static Object Info

Coords X,Y,Z: ", String.valueOf(target.getX()), ", ", String.valueOf(target.getY()), ", ", String.valueOf(target.getZ()), "
Object ID: ", String.valueOf(target.getObjectId()), "
Static Object ID: ", String.valueOf(target.getId()), "
Mesh Index: ", String.valueOf(((L2StaticObjectInstance) target).getMeshIndex()), "

Class: ", target.getClass().getSimpleName(), "
"))); + + final NpcHtmlMessage html = new NpcHtmlMessage("
Static Object Info

Coords X,Y,Z: " + target.getX() + ", " + target.getY() + ", " + target.getZ() + "
Object ID: " + target.getObjectId() + "
Static Object ID: " + target.getId() + "
Mesh Index: " + ((L2StaticObjectInstance) target).getMeshIndex() + "

Class: " + target.getClass().getSimpleName() + "
"); + activeChar.sendPacket(html); } return true; } diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminBuffs.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminBuffs.java index 2ec775ca61..f72aab0b8d 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminBuffs.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminBuffs.java @@ -36,7 +36,6 @@ import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.SkillCoolTime; import com.l2jmobius.gameserver.util.GMAudit; -import com.l2jmobius.util.StringUtil; public class AdminBuffs implements IAdminCommandHandler { @@ -252,9 +251,13 @@ public class AdminBuffs implements IAdminCommandHandler max++; } - final StringBuilder html = StringUtil.startAppend(500 + (effects.size() * 200), "
Effects of ", target.getName(), "

"); - final int start = (page - 1) * PAGE_LIMIT; - final int end = Math.min(((page - 1) * PAGE_LIMIT) + PAGE_LIMIT, effects.size()); + final StringBuilder html = new StringBuilder(500 + (effects.size() * 200)); + html.append("
SkillRem. TimeAction
Effects of "); + html.append(target.getName()); + html.append("

"); + + int start = ((page - 1) * PAGE_LIMIT); + int end = Math.min(((page - 1) * PAGE_LIMIT) + PAGE_LIMIT, effects.size()); int count = 0; for (BuffInfo info : effects) { @@ -263,7 +266,22 @@ public class AdminBuffs implements IAdminCommandHandler final Skill skill = info.getSkill(); for (AbstractEffect effect : info.getEffects()) { - StringUtil.append(html, ""); + html.append(""); } } count++; @@ -294,17 +312,29 @@ public class AdminBuffs implements IAdminCommandHandler html.append("
SkillRem. TimeAction
", (!info.isInUse() ? FONT_RED1 : "") + skill.getName(), " Lv ", String.valueOf(skill.getLevel()), " (", effect.getClass().getSimpleName(), ")" + (!info.isInUse() ? FONT_RED2 : ""), "", skill.isToggle() ? "T (" + info.getTickCount(effect) + ")" : skill.isPassive() ? "P" : info.getTime() + "s", "
"); + html.append(!info.isInUse() ? FONT_RED1 : ""); + html.append(skill.getName()); + html.append(" Lv "); + html.append(skill.getLevel()); + html.append(" ("); + html.append(effect.getClass().getSimpleName()); + html.append(")"); + html.append(!info.isInUse() ? FONT_RED2 : ""); + html.append(""); + html.append(skill.isToggle() ? "T (" + info.getTickCount(effect) + ")" : skill.isPassive() ? "P" : info.getTime() + "s"); + html.append("
"); // Buttons - StringUtil.append(html, "
"); + replyMSG = "Selected mobs to fight
FirstSecond
level " + lvl1 + "level " + lvl2 + "
id " + npc1.getId() + "id " + npc2.getId() + "
" + npc1.getName() + "" + npc2.getName() + "



"; } else if ((lvl1 != 0) && (npc1 == null)) { final List npcs = NpcData.getInstance().getAllOfLevel(lvl1); - final StringBuilder sb = StringUtil.startAppend(50 + (npcs.size() * 200), "Select first mob to fight"); + final StringBuilder sb = new StringBuilder(50 + (npcs.size() * 200)); + sb.append("Select first mob to fight
"); for (L2NpcTemplate n : npcs) { - StringUtil.append(sb, ""); + sb.append(""); } sb.append("
", n.getName(), "
" + n.getName() + "
"); @@ -133,11 +133,12 @@ public class AdminFightCalculator implements IAdminCommandHandler else if ((lvl2 != 0) && (npc2 == null)) { final List npcs = NpcData.getInstance().getAllOfLevel(lvl2); - final StringBuilder sb = StringUtil.startAppend(50 + (npcs.size() * 200), "Select second mob to fight"); + final StringBuilder sb = new StringBuilder(50 + (npcs.size() * 200)); + sb.append("Select second mob to fight
"); for (L2NpcTemplate n : npcs) { - StringUtil.append(sb, ""); + sb.append(""); } sb.append("
", n.getName(), "
" + n.getName() + "
"); @@ -291,7 +292,8 @@ public class AdminFightCalculator implements IAdminCommandHandler final NpcHtmlMessage adminReply = new NpcHtmlMessage(); - final StringBuilder replyMSG = StringUtil.startAppend(1000, "Selected mobs to fight"); + final StringBuilder replyMSG = new StringBuilder(1000); + replyMSG.append("Selected mobs to fight
"); if (params.length() == 0) { @@ -299,14 +301,14 @@ public class AdminFightCalculator implements IAdminCommandHandler } else { - StringUtil.append(replyMSG, ""); + replyMSG.append(""); } - StringUtil.append(replyMSG, ""); + replyMSG.append(""); if ((tdmg2 - hp1) > 1) { - StringUtil.append(replyMSG, ""); + replyMSG.append(""); } else { @@ -315,7 +317,7 @@ public class AdminFightCalculator implements IAdminCommandHandler if ((tdmg1 - hp2) > 1) { - StringUtil.append(replyMSG, ""); + replyMSG.append(""); } else { @@ -330,7 +332,7 @@ public class AdminFightCalculator implements IAdminCommandHandler } else { - StringUtil.append(replyMSG, ""); + cList.append(""); i++; } diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminInstanceZone.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminInstanceZone.java index 1d2727f612..4c05ea7d6b 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminInstanceZone.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminInstanceZone.java @@ -25,7 +25,6 @@ import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.util.GMAudit; -import com.l2jmobius.util.StringUtil; public class AdminInstanceZone implements IAdminCommandHandler { @@ -118,7 +117,8 @@ public class AdminInstanceZone implements IAdminCommandHandler { final Map instanceTimes = InstanceManager.getInstance().getAllInstanceTimes(player.getObjectId()); - final StringBuilder html = StringUtil.startAppend(500 + (instanceTimes.size() * 200), "
Parameter", ((L2NpcTemplate) npc1.getTemplate()).getName(), "", ((L2NpcTemplate) npc2.getTemplate()).getName(), "
Parameter" + ((L2NpcTemplate) npc1.getTemplate()).getName() + "" + ((L2NpcTemplate) npc2.getTemplate()).getName() + "
miss", String.valueOf(miss1), "%", String.valueOf(miss2), "%
shld", String.valueOf(shld2), "%", String.valueOf(shld1), "%
crit", String.valueOf(crit1), "%", String.valueOf(crit2), "%
pAtk / pDef", String.valueOf((int) patk1), " / ", String.valueOf((int) pdef1), "", String.valueOf((int) patk2), " / ", String.valueOf((int) pdef2), "
made hits", String.valueOf(sAtk1), "", String.valueOf(sAtk2), "
dmg per hit", String.valueOf((int) dmg1), "", String.valueOf((int) dmg2), "
got dmg", String.valueOf(tdmg2), "", String.valueOf(tdmg1), "
got regen", String.valueOf(hp1), "", String.valueOf(hp2), "
had HP", String.valueOf((int) maxHp1), "", String.valueOf((int) maxHp2), "
die
miss" + miss1 + "%" + miss2 + "%
shld" + shld2 + "%" + shld1 + "%
crit" + crit1 + "%" + crit2 + "%
pAtk / pDef" + (int) patk1 + " / " + (int) pdef1 + "" + (int) patk2 + " / " + (int) pdef2 + "
made hits" + sAtk1 + "" + sAtk2 + "
dmg per hit" + (int) dmg1 + "" + (int) dmg2 + "
got dmg" + tdmg2 + "" + tdmg1 + "
got regen" + hp1 + "" + hp2 + "
had HP" + (int) maxHp1 + "" + (int) maxHp2 + "
die", String.valueOf((int) ((100 * maxHp1) / (tdmg2 - hp1))), " sec" + ((int) ((100 * maxHp1) / (tdmg2 - hp1))) + " sec", String.valueOf((int) ((100 * maxHp2) / (tdmg1 - hp2))), " sec" + ((int) ((100 * maxHp2) / (tdmg1 - hp2))) + " sec", fort.getName(), " id: ", String.valueOf(fort.getResidenceId()), "" + fort.getName() + " id: " + fort.getResidenceId() + "
Character Instances

Instances for ", player.getName(), "

"); + final StringBuilder html = new StringBuilder(500 + (instanceTimes.size() * 200)); + html.append("
NameTimeAction
Character Instances

Instances for " + player.getName() + "

"); for (int id : instanceTimes.keySet()) { @@ -131,10 +131,10 @@ public class AdminInstanceZone implements IAdminCommandHandler minutes = (int) ((remainingTime % 3600) / 60); } - StringUtil.append(html, ""); + html.append(""); } - StringUtil.append(html, "
NameTimeAction
", InstanceManager.getInstance().getInstanceIdName(id), "", String.valueOf(hours), ":", String.valueOf(minutes), "
" + InstanceManager.getInstance().getInstanceIdName(id) + "" + hours + ":" + minutes + "
"); + html.append(""); final NpcHtmlMessage ms = new NpcHtmlMessage(); ms.setHtml(html.toString()); diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminManor.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminManor.java index 3cefb45bc1..29b4d38690 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminManor.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminManor.java @@ -23,7 +23,6 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.entity.Castle; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.util.Util; -import com.l2jmobius.util.StringUtil; /** * @author malyelfik @@ -42,10 +41,10 @@ public final class AdminManor implements IAdminCommandHandler final StringBuilder sb = new StringBuilder(3400); for (Castle c : CastleManager.getInstance().getCastles()) { - StringUtil.append(sb, "Name:" + c.getName() + ""); - StringUtil.append(sb, "Current period cost:", Util.formatAdena(manor.getManorCost(c.getResidenceId(), false)), " Adena"); - StringUtil.append(sb, "Next period cost:", Util.formatAdena(manor.getManorCost(c.getResidenceId(), true)), " Adena"); - StringUtil.append(sb, "----------------------------------------------------"); + sb.append("Name:" + c.getName() + ""); + sb.append("Current period cost:" + Util.formatAdena(manor.getManorCost(c.getResidenceId(), false)) + " Adena"); + sb.append("Next period cost:" + Util.formatAdena(manor.getManorCost(c.getResidenceId(), true)) + " Adena"); + sb.append("----------------------------------------------------"); } msg.replace("%castleInfo%", sb.toString()); activeChar.sendPacket(msg); diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminSkill.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminSkill.java index 09cbd79822..df13f8e865 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminSkill.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminSkill.java @@ -36,7 +36,6 @@ import com.l2jmobius.gameserver.network.serverpackets.AcquireSkillList; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.PledgeSkillList; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; -import com.l2jmobius.util.StringUtil; /** * This class handles following admin commands: @@ -302,21 +301,28 @@ public class AdminSkill implements IAdminCommandHandler page = maxPages; } - final int skillsStart = maxSkillsPerPage * page; - final int skillsEnd = (skills.length - skillsStart) > maxSkillsPerPage ? skillsStart + maxSkillsPerPage : skills.length; - final NpcHtmlMessage adminReply = new NpcHtmlMessage(); - final StringBuilder replyMSG = StringUtil.startAppend(500 + (maxPages * 50) + (((skillsEnd - skillsStart) + 1) * 50), "
Character Selection Menu


Editing ", player.getName(), "

Lv: ", String.valueOf(player.getLevel()), " ", ClassListData.getInstance().getClass(player.getClassId()).getClientCode(), "

Note: Dont forget that modifying players skills can
ruin the game...

Click on the skill you wish to remove:

"); + int skillsStart = maxSkillsPerPage * page; + int skillsEnd = skills.length; + if ((skillsEnd - skillsStart) > maxSkillsPerPage) + { + skillsEnd = skillsStart + maxSkillsPerPage; + } + + final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1); + final StringBuilder replyMSG = new StringBuilder(500 + (maxPages * 50) + (((skillsEnd - skillsStart) + 1) * 50)); + replyMSG.append("
Character Selection Menu


Editing " + player.getName() + "

Lv: " + player.getLevel() + " " + ClassListData.getInstance().getClass(player.getClassId()).getClientCode() + "

Note: Dont forget that modifying players skills can
ruin the game...

Click on the skill you wish to remove:

"); for (int x = 0; x < maxPages; x++) { - StringUtil.append(replyMSG, ""); + int pagenr = x + 1; + replyMSG.append(""); } replyMSG.append("
Page ", String.valueOf(x + 1), "Page " + pagenr + "

"); for (int i = skillsStart; i < skillsEnd; i++) { - StringUtil.append(replyMSG, ""); + replyMSG.append(""); } replyMSG.append("
Name:Level:Id:
", skills[i].getName(), "", String.valueOf(skills[i].getLevel()), "", String.valueOf(skills[i].getId()), "
" + skills[i].getName() + "" + skills[i].getLevel() + "" + skills[i].getId() + "

Remove skill by ID :
Id:

"); diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java index 69fde4e057..d46b2530b9 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java @@ -44,7 +44,6 @@ import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.util.Broadcast; -import com.l2jmobius.util.StringUtil; /** * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target @@ -169,7 +168,8 @@ public class AdminSpawn implements IAdminCommandHandler final int instance = Integer.parseInt(st.nextToken()); if (instance >= 300000) { - final StringBuilder html = StringUtil.startAppend(500 + 1000, "
", "Spawns for " + String.valueOf(instance) + "", "

", ""); + final StringBuilder html = new StringBuilder(1500); + html.append("
NpcNameAction
Spawns for " + instance + "

"); int counter = 0; int skiped = 0; final Instance inst = InstanceManager.getInstance().getInstance(instance); @@ -182,7 +182,7 @@ public class AdminSpawn implements IAdminCommandHandler // Only 50 because of client html limitation if (counter < 50) { - StringUtil.append(html, ""); + html.append(""); counter++; } else @@ -191,7 +191,7 @@ public class AdminSpawn implements IAdminCommandHandler } } } - StringUtil.append(html, "
NpcNameAction
" + npc.getName() + "", "Go", "
" + npc.getName() + "Go
Skipped:" + String.valueOf(skiped) + "
"); + html.append("Skipped:" + skiped + ""); final NpcHtmlMessage ms = new NpcHtmlMessage(); ms.setHtml(html.toString()); activeChar.sendPacket(ms); @@ -466,13 +466,14 @@ public class AdminSpawn implements IAdminCommandHandler { final List mobs = NpcData.getInstance().getAllMonstersOfLevel(level); final int mobsCount = mobs.size(); - final StringBuilder tb = StringUtil.startAppend(500 + (mobsCount * 80), "Spawn Monster:

Level : ", Integer.toString(level), "
Total Npc's : ", Integer.toString(mobsCount), "
"); + final StringBuilder tb = new StringBuilder(500 + (mobsCount * 80)); + tb.append("Spawn Monster:

Level : " + level + "
Total Npc's : " + mobsCount + "
"); // Loop int i = from; for (int j = 0; (i < mobsCount) && (j < 50); i++, j++) { - StringUtil.append(tb, "", mobs.get(i).getName(), ""); + tb.append("" + mobs.get(i).getName() + ""); } if (i == mobsCount) @@ -481,7 +482,7 @@ public class AdminSpawn implements IAdminCommandHandler } else { - StringUtil.append(tb, "

"); + tb.append("
"); } activeChar.sendPacket(new NpcHtmlMessage(tb.toString())); @@ -491,13 +492,14 @@ public class AdminSpawn implements IAdminCommandHandler { final List mobs = NpcData.getInstance().getAllNpcStartingWith(starting); final int mobsCount = mobs.size(); - final StringBuilder tb = StringUtil.startAppend(500 + (mobsCount * 80), "Spawn Monster:

There are ", Integer.toString(mobsCount), " Npcs whose name starts with ", starting, ":
"); + final StringBuilder tb = new StringBuilder(500 + (mobsCount * 80)); + tb.append("Spawn Monster:

There are " + mobsCount + " Npcs whose name starts with " + starting + ":
"); // Loop int i = from; for (int j = 0; (i < mobsCount) && (j < 50); i++, j++) { - StringUtil.append(tb, "", mobs.get(i).getName(), ""); + tb.append("" + mobs.get(i).getName() + ""); } if (i == mobsCount) @@ -506,7 +508,7 @@ public class AdminSpawn implements IAdminCommandHandler } else { - StringUtil.append(tb, "

"); + tb.append("
"); } activeChar.sendPacket(new NpcHtmlMessage(tb.toString())); diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java index 8dc48d3443..1bef367921 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java @@ -40,7 +40,6 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2RaidBossInstance; import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; -import com.l2jmobius.util.StringUtil; /** * This class handles following admin commands: - show_moves - show_teleport - teleport_to_character - move_to - teleport_character @@ -401,7 +400,7 @@ public class AdminTeleport implements IAdminCommandHandler } final NpcHtmlMessage adminReply = new NpcHtmlMessage(); - final String replyMSG = StringUtil.concat("Teleport CharacterThe character you will teleport is ", player.getName(), ".
Co-ordinate xCo-ordinate yCo-ordinate z
"); + final String replyMSG = "Teleport CharacterThe character you will teleport is " + player.getName() + ".
Co-ordinate xCo-ordinate yCo-ordinate z
"; adminReply.setHtml(replyMSG); activeChar.sendPacket(adminReply); } diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminZone.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminZone.java index 0d1f59e109..2805232bc2 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminZone.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/admincommandhandlers/AdminZone.java @@ -31,7 +31,6 @@ import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; import com.l2jmobius.gameserver.model.zone.type.NpcSpawnTerritory; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; -import com.l2jmobius.util.StringUtil; /** * Small typo fix by Zoey76 24/02/2011 @@ -138,22 +137,26 @@ public class AdminZone implements IAdminCommandHandler { if (zone.getName() != null) { - StringUtil.append(zones, zone.getName() + ""); + zones.append(zone.getName()); + zones.append(""); if (zone.getId() < 300000) { - StringUtil.append(zones, "(", String.valueOf(zone.getId()), ")"); + zones.append("("); + zones.append(zone.getId()); + zones.append(")"); } } else { - StringUtil.append(zones, String.valueOf(zone.getId())); + zones.append(zone.getId()); } - StringUtil.append(zones, " "); + zones.append(" "); } } for (NpcSpawnTerritory territory : ZoneManager.getInstance().getSpawnTerritories(activeChar)) { - StringUtil.append(zones, territory.getName() + ""); + zones.append(territory.getName()); + zones.append(""); } adminReply.replace("%ZLIST%", zones.toString()); activeChar.sendPacket(adminReply); diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/bypasshandlers/QuestLink.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/bypasshandlers/QuestLink.java index 8b4c757b8e..f5fa2b06a9 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/bypasshandlers/QuestLink.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/bypasshandlers/QuestLink.java @@ -32,7 +32,6 @@ import com.l2jmobius.gameserver.model.quest.QuestState; import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.serverpackets.ActionFailed; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; -import com.l2jmobius.util.StringUtil; public class QuestLink implements IBypassHandler { @@ -82,11 +81,12 @@ public class QuestLink implements IBypassHandler */ private static void showQuestChooseWindow(L2PcInstance player, L2Npc npc, Collection quests) { - final StringBuilder sb = StringUtil.startAppend(150, ""); - final StringBuilder qStarted = StringUtil.startAppend(150, ""); - final StringBuilder qCanStart = StringUtil.startAppend(150, ""); - final StringBuilder qCannotstart = StringUtil.startAppend(150, ""); - final StringBuilder qComplete = StringUtil.startAppend(150, ""); + final StringBuilder sb = new StringBuilder(128); + final StringBuilder qStarted = new StringBuilder(128); + final StringBuilder qCanStart = new StringBuilder(128); + final StringBuilder qCannotstart = new StringBuilder(128); + final StringBuilder qComplete = new StringBuilder(128); + sb.append(""); String state = ""; String color = ""; @@ -129,29 +129,29 @@ public class QuestLink implements IBypassHandler { case "ffdd66": // started { - StringUtil.append(qStarted, ""); - StringUtil.append(qStarted, ""); } diff --git a/L2J_Mobius_Test/dist/game/data/scripts/handlers/communityboard/ClanBoard.java b/L2J_Mobius_Test/dist/game/data/scripts/handlers/communityboard/ClanBoard.java index 1c5f43c255..81a24843de 100644 --- a/L2J_Mobius_Test/dist/game/data/scripts/handlers/communityboard/ClanBoard.java +++ b/L2J_Mobius_Test/dist/game/data/scripts/handlers/communityboard/ClanBoard.java @@ -16,6 +16,9 @@ */ package handlers.communityboard; +import java.util.Arrays; +import java.util.stream.Collectors; + import com.l2jmobius.gameserver.data.sql.impl.ClanTable; import com.l2jmobius.gameserver.handler.CommunityBoardHandler; import com.l2jmobius.gameserver.handler.IWriteBoardHandler; @@ -23,7 +26,6 @@ import com.l2jmobius.gameserver.model.L2Clan; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.util.Util; -import com.l2jmobius.util.StringUtil; /** * Clan board. @@ -147,32 +149,35 @@ public class ClanBoard implements IWriteBoardHandler } else { - final StringBuilder html = StringUtil.startAppend(2000, "

HOME > CLAN COMMUNITY > &$802;
"); + final StringBuilder html = new StringBuilder(2048); + html.append("

HOME > CLAN COMMUNITY > &$802;
"); if (activeChar.isClanLeader()) { - StringUtil.append(html, "

"); + html.append("

The Clan Notice function allows the clan leader to send messages through a pop-up window to clan members at login.
"); if (activeChar.getClan().isNoticeEnabled()) { - StringUtil.append(html, "
The Clan Notice function allows the clan leader to send messages through a pop-up window to clan members at login.
Clan Notice Function:   on   /   off"); + html.append("
Clan Notice Function:   on   /   off"); } else { - StringUtil.append(html, "
Clan Notice Function:   on   /   off"); + html.append("
Clan Notice Function:   on   /   off"); } - StringUtil.append(html, "


Edit Notice:

"); + html.append("

Edit Notice:

"); Util.sendCBHtml(activeChar, html.toString(), activeChar.getClan().getNotice()); } else { - StringUtil.append(html, "
You are not your clan's leader, and therefore cannot change the clan notice
"); + html.append("
You are not your clan's leader, and therefore cannot change the clan notice
"); if (activeChar.getClan().isNoticeEnabled()) { - StringUtil.append(html, "
The current clan notice:
" + activeChar.getClan().getNotice() + "
"); + html.append("
The current clan notice:
" + activeChar.getClan().getNotice() + "
"); } - StringUtil.append(html, "
"); + html.append("
"); CommunityBoardHandler.separateAndSend(html.toString(), activeChar); } } @@ -187,7 +192,10 @@ public class ClanBoard implements IWriteBoardHandler } // header - final StringBuilder html = StringUtil.startAppend(2000, "

  CLAN COMMUNITY
[GO TO MY CLAN]  

CLAN NAMECLAN LEADERCLAN LEVELCLAN MEMBERS
"); + final StringBuilder html = new StringBuilder(2048); + html.append("

  CLAN COMMUNITY
[GO TO MY CLAN]  

CLAN NAMECLAN LEADERCLAN LEVELCLAN MEMBERS
"); int i = 0; for (L2Clan cl : ClanTable.getInstance().getClans()) @@ -199,7 +207,17 @@ public class ClanBoard implements IWriteBoardHandler if (i++ >= ((index - 1) * 7)) { - StringUtil.append(html, "
", cl.getName(), "", cl.getLeaderName(), "", String.valueOf(cl.getLevel()), "", String.valueOf(cl.getMembersCount()), "
"); + html.append("
"); + html.append(cl.getName()); + html.append(""); + html.append(cl.getLeaderName()); + html.append(""); + html.append(cl.getLevel()); + html.append(""); + html.append(cl.getMembersCount()); + html.append("
"); } } @@ -211,7 +229,9 @@ public class ClanBoard implements IWriteBoardHandler } else { - StringUtil.append(html, "
"); + html.append("
"); CommunityBoardHandler.separateAndSend(html.toString(), activeChar); } diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/data/xml/impl/NpcData.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/data/xml/impl/NpcData.java index 2bb160c556..4504ee67f2 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/data/xml/impl/NpcData.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/data/xml/impl/NpcData.java @@ -96,7 +96,7 @@ public class NpcData implements IXmlReader if ("npc".equalsIgnoreCase(listNode.getNodeName())) { NamedNodeMap attrs = listNode.getAttributes(); - final StatsSet set = new StatsSet(); + final StatsSet set = new StatsSet(new HashMap<>()); final int npcId = parseInteger(attrs, "id"); Map parameters = null; Map skills = null; diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/instancemanager/GrandBossManager.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/instancemanager/GrandBossManager.java index 24b17b827a..6a205f1008 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/instancemanager/GrandBossManager.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/instancemanager/GrandBossManager.java @@ -88,13 +88,9 @@ public final class GrandBossManager implements IStorable info.set("loc_z", rs.getInt("loc_z")); info.set("heading", rs.getInt("heading")); info.set("respawn_time", rs.getLong("respawn_time")); - final double HP = rs.getDouble("currentHP"); // jython doesn't recognize doubles - final int true_HP = (int) HP; // so use java's ability to type cast - info.set("currentHP", true_HP); // to convert double to int - final double MP = rs.getDouble("currentMP"); - final int true_MP = (int) MP; - info.set("currentMP", true_MP); - final int status = rs.getInt("status"); + info.set("currentHP", rs.getDouble("currentHP")); + info.set("currentMP", rs.getDouble("currentMP")); + int status = rs.getInt("status"); _bossStatus.put(bossId, status); _storedInfo.put(bossId, info); _log.info(getClass().getSimpleName() + ": " + NpcData.getInstance().getTemplate(bossId).getName() + "(" + bossId + ") status is " + status + "."); diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/instancemanager/PetitionManager.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/instancemanager/PetitionManager.java index 9a889f0c27..1f6f5d3467 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/instancemanager/PetitionManager.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/instancemanager/PetitionManager.java @@ -32,7 +32,6 @@ import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.serverpackets.CreatureSay; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; -import com.l2jmobius.util.StringUtil; /** * Petition Manager @@ -352,7 +351,8 @@ public final class PetitionManager public void sendPendingPetitionList(L2PcInstance activeChar) { - final StringBuilder htmlContent = StringUtil.startAppend(600 + (getPendingPetitionCount() * 300), "
Petition Menu

"); + final StringBuilder htmlContent = new StringBuilder(600 + (getPendingPetitionCount() * 300)); + htmlContent.append("

Petition Menu

"); final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); @@ -374,18 +374,18 @@ public final class PetitionManager continue; } - StringUtil.append(htmlContent, ""); color = !color; petcount++; if (petcount > 10) diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/MacroList.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/MacroList.java index 4972660fdd..a24fd2a202 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/MacroList.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/MacroList.java @@ -36,7 +36,6 @@ import com.l2jmobius.gameserver.enums.ShortcutType; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.interfaces.IRestorable; import com.l2jmobius.gameserver.network.serverpackets.SendMacroList; -import com.l2jmobius.util.StringUtil; public class MacroList implements IRestorable { @@ -136,10 +135,10 @@ public class MacroList implements IRestorable final StringBuilder sb = new StringBuilder(300); for (MacroCmd cmd : macro.getCommands()) { - StringUtil.append(sb, String.valueOf(cmd.getType().ordinal()), ",", String.valueOf(cmd.getD1()), ",", String.valueOf(cmd.getD2())); + sb.append(cmd.getType().ordinal() + "," + cmd.getD1() + "," + cmd.getD2()); if ((cmd.getCmd() != null) && (cmd.getCmd().length() > 0)) { - StringUtil.append(sb, ",", cmd.getCmd()); + sb.append("," + cmd.getCmd()); } sb.append(';'); } diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2ClassMasterInstance.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2ClassMasterInstance.java index 72b0676766..e6cdee324d 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2ClassMasterInstance.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2ClassMasterInstance.java @@ -34,7 +34,6 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.TutorialCloseHtml; import com.l2jmobius.gameserver.network.serverpackets.TutorialShowQuestionMark; import com.l2jmobius.gameserver.network.serverpackets.UserInfo; -import com.l2jmobius.util.StringUtil; /** * This class ... @@ -295,7 +294,7 @@ public final class L2ClassMasterInstance extends L2MerchantInstance } if (validateClassId(currentClassId, cid) && (cid.level() == level)) { - StringUtil.append(menu, "", ClassListData.getInstance().getClass(cid).getClientCode(), "
"); + menu.append("" + ClassListData.getInstance().getClass(cid).getClientCode() + "
"); } } @@ -346,7 +345,7 @@ public final class L2ClassMasterInstance extends L2MerchantInstance } if (validateClassId(currentClassId, cid)) { - StringUtil.append(menu, "", ClassListData.getInstance().getClass(cid).getEscapedClientCode(), "
"); + menu.append("" + ClassListData.getInstance().getClass(cid).getEscapedClientCode() + "
"); } } diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2NpcInstance.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2NpcInstance.java index 64d2d3ab65..1a77edaf89 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2NpcInstance.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2NpcInstance.java @@ -32,7 +32,6 @@ import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.serverpackets.ExAcquirableSkillListByClass; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; -import com.l2jmobius.util.StringUtil; public class L2NpcInstance extends L2Npc { @@ -112,7 +111,7 @@ public class L2NpcInstance extends L2Npc if (((L2NpcInstance) npc).getClassesToTeach().isEmpty()) { final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId()); - final String sb = StringUtil.concat("I cannot teach you. My class list is empty.
Ask admin to fix it. Need add my npcid and classes to skill_learn.sql.
NpcId:", String.valueOf(npcId), ", Your classId:", String.valueOf(player.getClassId().getId()), ""); + final String sb = "I cannot teach you. My class list is empty.
Ask admin to fix it. Need add my npcid and classes to skill_learn.sql.
NpcId:" + npcId + ", Your classId:" + player.getClassId().getId() + ""; html.setHtml(sb); player.sendPacket(html); return; diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 6067eef248..7e6de10138 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -287,6 +287,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ExSubjobInfo; import com.l2jmobius.gameserver.network.serverpackets.ExUseSharedGroupItem; import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoAbnormalVisualEffect; import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoCubic; +import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoFishing; import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoInvenWeight; import com.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType; import com.l2jmobius.gameserver.network.serverpackets.GameGuardQuery; @@ -303,6 +304,7 @@ import com.l2jmobius.gameserver.network.serverpackets.ObservationMode; import com.l2jmobius.gameserver.network.serverpackets.ObservationReturn; import com.l2jmobius.gameserver.network.serverpackets.PartySmallWindowUpdate; import com.l2jmobius.gameserver.network.serverpackets.PetInventoryUpdate; +import com.l2jmobius.gameserver.network.serverpackets.PlaySound; import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListDelete; import com.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListUpdate; import com.l2jmobius.gameserver.network.serverpackets.PrivateStoreListBuy; @@ -11832,7 +11834,7 @@ public final class L2PcInstance extends L2Playable _fishx = _x; _fishy = _y; _fishz = _z; - // broadcastUserInfo(); + // Starts fishing final int lvl = getRandomFishLvl(); final int grade = getRandomFishGrade(); @@ -11852,9 +11854,9 @@ public final class L2PcInstance extends L2Playable { _fish.setFishGroup(-1); } - // sendMessage("Hook x,y: " + _x + "," + _y + " - Water Z, Player Z:" + _z + ", " + getZ()); // debug line, uncoment to show coordinates used in fishing. broadcastPacket(new ExFishingStart(this, _fish.getFishGroup(), _x, _y, _z, _lure.isNightLure())); - // sendPacket(new PlaySound(1, "SF_P_01", 0, 0, 0, 0, 0)); + sendPacket(new ExUserInfoFishing(this)); + sendPacket(new PlaySound(1, "SF_P_01", 0, 0, 0, 0, 0)); startLookingForFishTask(); } diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/Hero.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/Hero.java index e26bbc2934..9e1a081137 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/Hero.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/Hero.java @@ -54,7 +54,6 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.SocialAction; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.UserInfo; -import com.l2jmobius.util.StringUtil; /** * Hero entity. @@ -464,19 +463,19 @@ public class Hero { breakat = i; final StatsSet diaryEntry = list.get(i); - StringUtil.append(fList, ""); + fList.append(""); + fList.append(""); + fList.append("

"); - StringUtil.append(htmlContent, ""); + htmlContent.append("" + currPetition.getTypeAsString() + "
", dateFormat.format(new Date(currPetition.getSubmitTime()))); - StringUtil.append(htmlContent, "", currPetition.getPetitioner().getName(), "
"); + htmlContent.append("
"); + htmlContent.append("", currPetition.getTypeAsString(), "
" + dateFormat.format(new Date(currPetition.getSubmitTime()))); + htmlContent.append("" + currPetition.getPetitioner().getName() + "
"); if (currPetition.getState() != PetitionState.IN_PROCESS) { - StringUtil.append(htmlContent, "
"); + htmlContent.append("
"); } else { htmlContent.append("" + currPetition.getResponder().getName() + ""); } - StringUtil.append(htmlContent, "
", currPetition.getTypeAsString(), "
" + currPetition.getTypeAsString() + "
"); + fList.append("
"); if (color) { - StringUtil.append(fList, ""); + fList.append("
"); } else { - StringUtil.append(fList, "
"); + fList.append("
"); } - StringUtil.append(fList, ""); - StringUtil.append(fList, ""); - StringUtil.append(fList, "
" + diaryEntry.getString("date") + ":xx
" + diaryEntry.getString("action") + "
 
"); - StringUtil.append(fList, "
" + diaryEntry.getString("date") + ":xx
" + diaryEntry.getString("action") + "
 
"); + fList.append(""); color = !color; counter++; if (counter >= perpage) @@ -552,19 +551,19 @@ public class Hero { breakat = i; final StatsSet fight = heroFights.get(i); - StringUtil.append(fList, ""); + fList.append(""); if (color) { - StringUtil.append(fList, ""); + fList.append("
"); } else { - StringUtil.append(fList, "
"); + fList.append("
"); } - StringUtil.append(fList, ""); - StringUtil.append(fList, ""); - StringUtil.append(fList, "
" + fight.getString("start") + "  " + fight.getString("result") + "" + (fight.getInt("classed") > 0 ? "cls" : "non-cls") + "
vs " + fight.getString("oponent") + " (" + fight.getString("oponentclass") + ")(" + fight.getString("time") + ")
 
"); - StringUtil.append(fList, ""); + fList.append("" + fight.getString("start") + "  " + fight.getString("result") + "" + (fight.getInt("classed") > 0 ? "cls" : "non-cls") + ""); + fList.append("vs " + fight.getString("oponent") + " (" + fight.getString("oponentclass") + ")(" + fight.getString("time") + ")"); + fList.append(" "); + fList.append(""); color = !color; counter++; if (counter >= perpage) diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/Message.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/Message.java index 76d9cbb28b..07f49aec10 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/Message.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/Message.java @@ -52,7 +52,7 @@ public class Message private String _receiverName = null; private final String _subject, _content; private boolean _unread, _returned; - private MailType _messageType = MailType.REGULAR; + private final MailType _messageType; private boolean _deletedBySender; private boolean _deletedByReceiver; private final long _reqAdena; @@ -112,6 +112,7 @@ public class Message _deletedBySender = false; _deletedByReceiver = false; _reqAdena = reqAdena; + _messageType = MailType.REGULAR; } /* diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/TvTEvent.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/TvTEvent.java index 7d9b423ed7..cef69acf75 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/TvTEvent.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/entity/TvTEvent.java @@ -55,7 +55,6 @@ import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.util.Rnd; -import com.l2jmobius.util.StringUtil; /** * @author HorridoJoho @@ -540,7 +539,7 @@ public class TvTEvent return "-"; } - return StringUtil.concat(String.valueOf(itemNum), " ", ItemTable.getInstance().getTemplate(itemId).getName()); + return itemNum + " " + ItemTable.getInstance().getTemplate(itemId).getName(); } /** diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java index 79b2a4be1d..f8074c0773 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/itemcontainer/Inventory.java @@ -43,7 +43,7 @@ import com.l2jmobius.gameserver.model.items.type.WeaponType; import com.l2jmobius.gameserver.model.skills.Skill; import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoEquipSlot; import com.l2jmobius.gameserver.network.serverpackets.SkillCoolTime; -import com.l2jmobius.util.StringUtil; +import com.l2jmobius.util.Util; /** * This class manages inventory @@ -1678,7 +1678,7 @@ public abstract class Inventory extends ItemContainer default: { _log.info("Unhandled slot type: " + slot); - _log.info(StringUtil.getTraceString(Thread.currentThread().getStackTrace())); + _log.info(Util.getTraceString(Thread.currentThread().getStackTrace())); } } if (pdollSlot < 0) diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Armor.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Armor.java index 66eeee3b10..7f5f0899f0 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Armor.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Armor.java @@ -20,7 +20,6 @@ import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.holders.SkillHolder; import com.l2jmobius.gameserver.model.items.type.ArmorType; import com.l2jmobius.gameserver.model.skills.Skill; -import com.l2jmobius.util.StringUtil; /** * This class is dedicated to the management of armors. @@ -86,7 +85,7 @@ public final class L2Armor extends L2Item catch (Exception nfe) { // Incorrect syntax, don't add new skill - _log.info(StringUtil.concat("> Couldnt parse ", skill, " in armor enchant skills! item ", toString())); + _log.info("> Couldnt parse " + skill + " in armor enchant skills! item " + this); } if ((id > 0) && (level > 0)) { diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2EtcItem.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2EtcItem.java index 574c955b88..d8bfa5e696 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2EtcItem.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2EtcItem.java @@ -23,7 +23,6 @@ import com.l2jmobius.gameserver.model.L2ExtractableProduct; import com.l2jmobius.gameserver.model.StatsSet; import com.l2jmobius.gameserver.model.itemcontainer.Inventory; import com.l2jmobius.gameserver.model.items.type.EtcItemType; -import com.l2jmobius.util.StringUtil; /** * This class is dedicated to the management of EtcItem. @@ -96,7 +95,7 @@ public final class L2EtcItem extends L2Item final String[] data = part.split(","); if ((data.length != 4) && (data.length != 6)) { - _log.info(StringUtil.concat("> Couldnt parse ", part, " in capsuled_items! item ", toString())); + _log.info("> Couldnt parse " + part + " in capsuled_items! item " + this); continue; } final int itemId = Integer.parseInt(data[0]); @@ -104,7 +103,7 @@ public final class L2EtcItem extends L2Item final int max = Integer.parseInt(data[2]); if (max < min) { - _log.info(StringUtil.concat("> Max amount < Min amount in ", part, ", item ", toString())); + _log.info("> Max amount < Min amount in " + part + ", item " + this); continue; } final double chance = Double.parseDouble(data[3]); @@ -116,7 +115,7 @@ public final class L2EtcItem extends L2Item maxEnchant = Integer.parseInt(data[5]); if (maxEnchant < minEnchant) { - _log.info(StringUtil.concat("> Max enchant < Min enchant in ", part, ", item ", toString())); + _log.info("> Max enchant < Min enchant in " + part + ", item " + this); continue; } } diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Item.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Item.java index 88510e673c..e90bb3d057 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Item.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Item.java @@ -48,7 +48,6 @@ import com.l2jmobius.gameserver.model.stats.functions.AbstractFunction; import com.l2jmobius.gameserver.model.stats.functions.FuncTemplate; import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; -import com.l2jmobius.util.StringUtil; /** * This class contains all informations concerning the item (weapon, armor, etc).
@@ -66,7 +65,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable public static final int TYPE1_WEAPON_RING_EARRING_NECKLACE = 0; public static final int TYPE1_SHIELD_ARMOR = 1; public static final int TYPE1_ITEM_QUESTITEM_ADENA = 4; - + public static final int TYPE2_WEAPON = 0; public static final int TYPE2_SHIELD_ARMOR = 1; public static final int TYPE2_ACCESSORY = 2; @@ -112,43 +111,43 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable public static final int SLOT_MULTI_ALLWEAPON = SLOT_LR_HAND | SLOT_R_HAND; - private int _itemId; - private int _displayId; - private String _name; - private String _additionalName; - private String _icon; - private int _weight; - private boolean _stackable; - private MaterialType _materialType; - private CrystalType _crystalType; - private int _equipReuseDelay; - private int _duration; - private int _time; - private int _autoDestroyTime; - private int _bodyPart; - private int _referencePrice; - private int _crystalCount; - private boolean _sellable; - private boolean _dropable; - private boolean _destroyable; - private boolean _tradeable; - private boolean _depositable; - private boolean _auctionable; - private int _enchantable; - private boolean _elementable; - private boolean _questItem; - private boolean _freightable; - private boolean _allow_self_resurrection; - private boolean _is_oly_restricted; - private boolean _for_npc; - private boolean _common; - private boolean _heroItem; - private boolean _pvpItem; - private boolean _immediate_effect; - private boolean _ex_immediate_effect; - private int _defaultEnchantLevel; - private ActionType _defaultAction; - private boolean _isBlessedItem; + private int _itemId; + private int _displayId; + private String _name; + private String _additionalName; + private String _icon; + private int _weight; + private boolean _stackable; + private MaterialType _materialType; + private CrystalType _crystalType; + private int _equipReuseDelay; + private int _duration; + private int _time; + private int _autoDestroyTime; + private int _bodyPart; + private int _referencePrice; + private int _crystalCount; + private boolean _sellable; + private boolean _dropable; + private boolean _destroyable; + private boolean _tradeable; + private boolean _depositable; + private boolean _auctionable; + private int _enchantable; + private boolean _elementable; + private boolean _questItem; + private boolean _freightable; + private boolean _allow_self_resurrection; + private boolean _is_oly_restricted; + private boolean _for_npc; + private boolean _common; + private boolean _heroItem; + private boolean _pvpItem; + private boolean _immediate_effect; + private boolean _ex_immediate_effect; + private int _defaultEnchantLevel; + private ActionType _defaultAction; + private boolean _isBlessedItem; protected int _type1; // needed for item list (inventory) protected int _type2; // different lists for armor, weapon, etc @@ -159,13 +158,13 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable private SkillHolder _unequipSkill = null; private SkillHolder _equipSkill = null; - private int _useSkillDisTime; - private int _reuseDelay; - private int _sharedReuseGroup; + private int _useSkillDisTime; + private int _reuseDelay; + private int _sharedReuseGroup; - private CommissionItemType _commissionItemType; - private int _compoundItem; - private float _compoundChance; + private CommissionItemType _commissionItemType; + private int _compoundItem; + private float _compoundChance; /** * Constructor of the L2Item that fill class variables.
@@ -240,13 +239,13 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable if (id == 0) { - _log.info(StringUtil.concat("Ignoring item_skill(", element, ") for item ", toString(), ". Skill id is 0!")); + _log.info("Ignoring item_skill(" + element + ") for item " + this + ". Skill id is 0!"); continue; } if (level == 0) { - _log.info(StringUtil.concat("Ignoring item_skill(", element, ") for item ", toString(), ". Skill level is 0!")); + _log.info("Ignoring item_skill(" + element + ") for item " + this + ". Skill level is 0!"); continue; } @@ -255,7 +254,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable } catch (Exception e) { - _log.warning(StringUtil.concat("Failed to parse item_skill(", element, ") for item ", toString(), "! Format: SkillId0-SkillLevel0[;SkillIdN-SkillLevelN]")); + _log.warning("Failed to parse item_skill(" + element + ") for item " + this + "! Format: SkillId0-SkillLevel0[;SkillIdN-SkillLevelN]"); } } @@ -284,7 +283,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable catch (Exception nfe) { // Incorrect syntax, don't add new skill - _log.info(StringUtil.concat("Couldnt parse ", skills, " in weapon unequip skills! item ", toString())); + _log.info("Couldnt parse " + skills + " in weapon unequip skills! item " + this); } if ((id > 0) && (level > 0)) { @@ -309,7 +308,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable catch (Exception nfe) { // Incorrect syntax, don't add new skill - _log.info(StringUtil.concat("Couldnt parse ", skills, " in item equip skill! item ", toString())); + _log.info("Couldnt parse " + skills + " in item equip skill! item " + this); } if ((id > 0) && (level > 0)) { diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Weapon.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Weapon.java index 3a78917498..831398bc18 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Weapon.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/items/L2Weapon.java @@ -33,26 +33,25 @@ import com.l2jmobius.gameserver.model.stats.Formulas; import com.l2jmobius.gameserver.network.SystemMessageId; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.util.Util; -import com.l2jmobius.util.StringUtil; /** * This class is dedicated to the management of weapons. */ public final class L2Weapon extends L2Item { - private WeaponType _type; - private boolean _isMagicWeapon; - private int _rndDam; - private int _soulShotCount; - private int _spiritShotCount; - private int _mpConsume; - private int _baseAttackRange; - private int _baseAttackAngle; + private WeaponType _type; + private boolean _isMagicWeapon; + private int _rndDam; + private int _soulShotCount; + private int _spiritShotCount; + private int _mpConsume; + private int _baseAttackRange; + private int _baseAttackAngle; /** * Skill that activates when item is enchanted +4 (for duals). */ private SkillHolder _enchant4Skill = null; - private int _changeWeaponId; + private int _changeWeaponId; // Attached skills for Special Abilities private SkillHolder _skillsOnMagic; @@ -60,15 +59,15 @@ public final class L2Weapon extends L2Item private SkillHolder _skillsOnCrit; private Condition _skillsOnCritCondition = null; - private int _reducedSoulshot; - private int _reducedSoulshotChance; + private int _reducedSoulshot; + private int _reducedSoulshotChance; - private int _reducedMpConsume; - private int _reducedMpConsumeChance; + private int _reducedMpConsume; + private int _reducedMpConsumeChance; - private boolean _isForceEquip; - private boolean _isAttackWeapon; - private boolean _useWeaponSkillsOnly; + private boolean _isForceEquip; + private boolean _isAttackWeapon; + private boolean _useWeaponSkillsOnly; /** * Constructor for Weapon. @@ -120,7 +119,7 @@ public final class L2Weapon extends L2Item catch (Exception nfe) { // Incorrect syntax, dont add new skill - _log.info(StringUtil.concat("> Couldnt parse ", skill, " in weapon enchant skills! item ", toString())); + _log.info("> Couldnt parse " + skill + " in weapon enchant skills! item " + this); } if ((id > 0) && (level > 0)) { @@ -146,7 +145,7 @@ public final class L2Weapon extends L2Item catch (Exception nfe) { // Incorrect syntax, don't add new skill - _log.info(StringUtil.concat("> Couldnt parse ", skill, " in weapon onmagic skills! item ", toString())); + _log.info("> Couldnt parse " + skill + " in weapon onmagic skills! item " + this); } if ((id > 0) && (level > 0) && (chance > 0)) { @@ -173,7 +172,7 @@ public final class L2Weapon extends L2Item catch (Exception nfe) { // Incorrect syntax, don't add new skill - _log.info(StringUtil.concat("> Couldnt parse ", skill, " in weapon oncrit skills! item ", toString())); + _log.info("> Couldnt parse " + skill + " in weapon oncrit skills! item " + this); } if ((id > 0) && (level > 0) && (chance > 0)) { diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/quest/QuestState.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/quest/QuestState.java index ae1deae0b9..d5d6384b59 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/quest/QuestState.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/quest/QuestState.java @@ -533,7 +533,11 @@ public final class QuestState */ public int getCond() { - return isStarted() ? getInt("cond") : 0; + if (isStarted()) + { + return getInt("cond"); + } + return 0; } /** @@ -583,7 +587,11 @@ public final class QuestState */ public int getMemoState() { - return isStarted() ? getInt("memoState") : 0; + if (isStarted()) + { + return getInt("memoState"); + } + return 0; } public boolean isMemoState(int memoState) @@ -598,7 +606,11 @@ public final class QuestState */ public int getMemoStateEx(int slot) { - return isStarted() ? getInt("memoStateEx" + slot) : 0; + if (isStarted()) + { + return getInt("memoStateEx" + slot); + } + return 0; } /** diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/skills/AbnormalType.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/skills/AbnormalType.java index 33f62f052b..35cd7fd2cd 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/skills/AbnormalType.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/skills/AbnormalType.java @@ -375,6 +375,8 @@ public enum AbnormalType ELEMENTAL_RESISTANCE_ISS, HOLY_ATTACK_RESISTANCE_ISS, MENTAL_ATTACK_RESISTANCE_ISS, + CRIPPLING_ATTACK, + SHADOW_BLADE, SIGEL_AURA, FEOH_STANCE, YUL_STANCE, diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/zone/type/L2EffectZone.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/zone/type/L2EffectZone.java index 378f843a95..3c80c47469 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/zone/type/L2EffectZone.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/zone/type/L2EffectZone.java @@ -31,7 +31,6 @@ import com.l2jmobius.gameserver.model.zone.TaskZoneSettings; import com.l2jmobius.gameserver.model.zone.ZoneId; import com.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate; import com.l2jmobius.util.Rnd; -import com.l2jmobius.util.StringUtil; /** * another type of damage zone with skills @@ -96,7 +95,7 @@ public class L2EffectZone extends L2ZoneType final String[] skillSplit = skill.split("-"); if (skillSplit.length != 2) { - _log.warning(StringUtil.concat(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"", skill, "\"")); + _log.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skill + "\""); } else { @@ -108,7 +107,7 @@ public class L2EffectZone extends L2ZoneType { if (!skill.isEmpty()) { - _log.warning(StringUtil.concat(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"", skillSplit[0], "\"", skillSplit[1])); + _log.warning(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"" + skillSplit[0] + "\"" + skillSplit[1]); } } } diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/zone/type/L2ScriptZone.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/zone/type/L2ScriptZone.java index af3b8d9707..d33223aa10 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/zone/type/L2ScriptZone.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/model/zone/type/L2ScriptZone.java @@ -21,7 +21,7 @@ import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; /** - * A scripted zone... Creation of such a zone should require somekind of jython script reference which can handle onEnter() / onExit() + * A scripted zone... Creation of such a zone should require somekind of script reference which can handle onEnter() / onExit() * @author durgus */ public class L2ScriptZone extends L2ZoneType diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/clientpackets/RequestSendPost.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/clientpackets/RequestSendPost.java index 0fb3cdbab5..8da980f294 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/clientpackets/RequestSendPost.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/clientpackets/RequestSendPost.java @@ -38,7 +38,6 @@ import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoInvenWeight; import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate; import com.l2jmobius.gameserver.network.serverpackets.ItemList; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; -import com.l2jmobius.util.StringUtil; /** * @author Migi, DS @@ -316,7 +315,7 @@ public final class RequestSendPost extends L2GameClientPacket } final StringBuilder recv = new StringBuilder(32); - StringUtil.append(recv, msg.getReceiverName(), "[", String.valueOf(msg.getReceiverId()), "]"); + recv.append(msg.getReceiverName() + "[" + msg.getReceiverId() + "]"); final String receiver = recv.toString(); // Proceed to the transfer diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/serverpackets/ExUserInfoFishing.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/serverpackets/ExUserInfoFishing.java new file mode 100644 index 0000000000..98d998c4b9 --- /dev/null +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/serverpackets/ExUserInfoFishing.java @@ -0,0 +1,44 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.gameserver.network.serverpackets; + +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; + +/** + * @author Sdw + */ +public class ExUserInfoFishing extends L2GameServerPacket +{ + private final L2PcInstance _activeChar; + + public ExUserInfoFishing(L2PcInstance activeChar) + { + _activeChar = activeChar; + } + + @Override + protected final void writeImpl() + { + writeC(0xFE); + writeH(0x159); + writeD(_activeChar.getObjectId()); + writeC(_activeChar.isFishing() ? 1 : 0); + writeD(_activeChar.getFishx()); + writeD(_activeChar.getFishy()); + writeD(_activeChar.getFishz()); + } +} \ No newline at end of file diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/serverpackets/ShowBoard.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/serverpackets/ShowBoard.java index 12376f84f7..6a0b26d292 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/serverpackets/ShowBoard.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/network/serverpackets/ShowBoard.java @@ -18,8 +18,6 @@ package com.l2jmobius.gameserver.network.serverpackets; import java.util.List; -import com.l2jmobius.util.StringUtil; - public class ShowBoard extends L2GameServerPacket { private final String _content; @@ -41,7 +39,7 @@ public class ShowBoard extends L2GameServerPacket public ShowBoard(List arg) { - final StringBuilder builder = new StringBuilder(5 + StringUtil.getLength(arg) + arg.size()).append("1002\u0008"); + StringBuilder builder = new StringBuilder(256).append("1002\u0008"); for (String str : arg) { builder.append(str).append("\u0008"); diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/pathfinding/cellnodes/CellPathFinding.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/pathfinding/cellnodes/CellPathFinding.java index 67e430f6cf..0555054370 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/pathfinding/cellnodes/CellPathFinding.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/pathfinding/cellnodes/CellPathFinding.java @@ -31,7 +31,6 @@ import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; import com.l2jmobius.gameserver.pathfinding.AbstractNode; import com.l2jmobius.gameserver.pathfinding.AbstractNodeLoc; import com.l2jmobius.gameserver.pathfinding.PathFinding; -import com.l2jmobius.util.StringUtil; /** * @author Sami, DS Credits to Diamond @@ -359,16 +358,32 @@ public class CellPathFinding extends PathFinding @Override public String toString() { - final StringBuilder stat = new StringBuilder(100); - StringUtil.append(stat, String.valueOf(mapSize), "x", String.valueOf(mapSize), " num:", String.valueOf(bufs.size()), "/", String.valueOf(count), " uses:", String.valueOf(uses), "/", String.valueOf(playableUses)); + final StringBuilder sb = new StringBuilder(100); + sb.append(mapSize); + sb.append("x"); + sb.append(mapSize); + sb.append(" num:"); + sb.append(bufs.size()); + sb.append("/"); + sb.append(count); + sb.append(" uses:"); + sb.append(uses); + sb.append("/"); + sb.append(playableUses); if (uses > 0) { - StringUtil.append(stat, " total/avg(ms):", String.valueOf(elapsed), "/", String.format("%1.2f", (double) elapsed / uses)); + sb.append(" total/avg(ms):"); + sb.append(elapsed); + sb.append("/"); + sb.append(String.format("%1.2f", (double) elapsed / uses)); } - StringUtil.append(stat, " ovf:", String.valueOf(overflows), "/", String.valueOf(playableOverflows)); + sb.append(" ovf:"); + sb.append(overflows); + sb.append("/"); + sb.append(playableOverflows); - return stat.toString(); + return sb.toString(); } } @@ -381,14 +396,28 @@ public class CellPathFinding extends PathFinding result[i] = _allBuffers[i].toString(); } - final StringBuilder stat = new StringBuilder(100); - StringUtil.append(stat, "LOS postfilter uses:", String.valueOf(_postFilterUses), "/", String.valueOf(_postFilterPlayableUses)); + final StringBuilder sb = new StringBuilder(128); + sb.append("LOS postfilter uses:"); + sb.append(_postFilterUses); + sb.append("/"); + sb.append(_postFilterPlayableUses); if (_postFilterUses > 0) { - StringUtil.append(stat, " total/avg(ms):", String.valueOf(_postFilterElapsed), "/", String.format("%1.2f", (double) _postFilterElapsed / _postFilterUses), " passes total/avg:", String.valueOf(_postFilterPasses), "/", String.format("%1.1f", (double) _postFilterPasses / _postFilterUses), Config.EOL); + sb.append(" total/avg(ms):"); + sb.append(_postFilterElapsed); + sb.append("/"); + sb.append(String.format("%1.2f", (double) _postFilterElapsed / _postFilterUses)); + sb.append(" passes total/avg:"); + sb.append(_postFilterPasses); + sb.append("/"); + sb.append(String.format("%1.1f", (double) _postFilterPasses / _postFilterUses)); + sb.append(Config.EOL); } - StringUtil.append(stat, "Pathfind success/fail:", String.valueOf(_findSuccess), "/", String.valueOf(_findFails)); - result[result.length - 1] = stat.toString(); + sb.append("Pathfind success/fail:"); + sb.append(_findSuccess); + sb.append("/"); + sb.append(_findFails); + result[result.length - 1] = sb.toString(); return result; } diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/scripting/java/JavaExecutionContext.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/scripting/java/JavaExecutionContext.java index 984d27cfed..683a40e221 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/scripting/java/JavaExecutionContext.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/scripting/java/JavaExecutionContext.java @@ -46,7 +46,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext list, final String nullChecked, final String before) + private boolean addOptionIfNotNull(List list, String nullChecked, String before) { if (nullChecked == null) { @@ -93,15 +93,14 @@ public final class JavaExecutionContext extends AbstractExecutionContext executeScripts(final Iterable sourcePaths) throws Exception + public Map executeScripts(Iterable sourcePaths) throws Exception { final DiagnosticCollector fileManagerDiagnostics = new DiagnosticCollector<>(); final DiagnosticCollector compilationDiagnostics = new DiagnosticCollector<>(); try (final ScriptingFileManager fileManager = new ScriptingFileManager(getScriptingEngine().getCompiler().getStandardFileManager(fileManagerDiagnostics, null, StandardCharsets.UTF_8))) { - final LinkedList options = new LinkedList<>(); - + final List options = new LinkedList<>(); addOptionIfNotNull(options, getProperty("source"), "-source"); addOptionIfNotNull(options, getProperty("sourcepath"), "-sourcepath"); if (!addOptionIfNotNull(options, getProperty("cp"), "-cp") && !addOptionIfNotNull(options, getProperty("classpath"), "-classpath")) @@ -172,11 +171,11 @@ public final class JavaExecutionContext extends AbstractExecutionContext executionFailures = new LinkedHashMap<>(); final Iterable compiledClasses = fileManager.getCompiledClasses(); - for (final Path sourcePath : sourcePaths) + for (Path sourcePath : sourcePaths) { boolean found = false; - for (final ScriptingOutputFileObject compiledClass : compiledClasses) + for (ScriptingOutputFileObject compiledClass : compiledClasses) { Path compiledSourcePath = compiledClass.getSourcePath(); // sourePath can be relative, so we have to use endsWith @@ -223,7 +222,7 @@ public final class JavaExecutionContext extends AbstractExecutionContext executeScript(final Path sourcePath) throws Exception + public Entry executeScript(Path sourcePath) throws Exception { final Map executionFailures = executeScripts(Arrays.asList(sourcePath)); if (!executionFailures.isEmpty()) diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/util/FloodProtectorAction.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/util/FloodProtectorAction.java index 2c4ac90e89..ef4c3932f4 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/util/FloodProtectorAction.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/util/FloodProtectorAction.java @@ -16,6 +16,7 @@ */ package com.l2jmobius.gameserver.util; +import java.util.Arrays; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; import java.util.logging.Logger; @@ -27,7 +28,6 @@ import com.l2jmobius.gameserver.model.punishment.PunishmentAffect; import com.l2jmobius.gameserver.model.punishment.PunishmentTask; import com.l2jmobius.gameserver.model.punishment.PunishmentType; import com.l2jmobius.gameserver.network.L2GameClient; -import com.l2jmobius.util.StringUtil; /** * Flood protector implementation. @@ -189,7 +189,9 @@ public final class FloodProtectorAction private void log(String... lines) { - final StringBuilder output = StringUtil.startAppend(100, _config.FLOOD_PROTECTOR_TYPE, ": "); + final StringBuilder output = new StringBuilder(100); + output.append(_config.FLOOD_PROTECTOR_TYPE); + output.append(": "); String address = null; try { @@ -208,8 +210,10 @@ public final class FloodProtectorAction { if (_client.getActiveChar() != null) { - StringUtil.append(output, _client.getActiveChar().getName()); - StringUtil.append(output, "(", String.valueOf(_client.getActiveChar().getObjectId()), ") "); + output.append(_client.getActiveChar().getName()); + output.append("("); + output.append(_client.getActiveChar().getObjectId()); + output.append(") "); } break; } @@ -217,7 +221,8 @@ public final class FloodProtectorAction { if (_client.getAccountName() != null) { - StringUtil.append(output, _client.getAccountName(), " "); + output.append(_client.getAccountName()); + output.append(" "); } break; } @@ -225,7 +230,7 @@ public final class FloodProtectorAction { if (address != null) { - StringUtil.append(output, address); + output.append(address); } break; } @@ -235,7 +240,8 @@ public final class FloodProtectorAction } } - StringUtil.append(output, lines); + Arrays.stream(lines).forEach(output::append); + _log.warning(output.toString()); } } \ No newline at end of file diff --git a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/util/HtmlUtil.java b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/util/HtmlUtil.java index 1ffc6f3808..391e38d5e7 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/gameserver/util/HtmlUtil.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/gameserver/util/HtmlUtil.java @@ -21,7 +21,6 @@ import java.util.Collection; import java.util.function.Function; import com.l2jmobius.gameserver.model.PageResult; -import com.l2jmobius.util.StringUtil; /** * A class containing useful methods for constructing HTML @@ -163,20 +162,62 @@ public class HtmlUtil { current = Math.min(current, max); final StringBuilder sb = new StringBuilder(); - StringUtil.append(sb, ""); + sb.append(""); + sb.append("
"); - StringUtil.append(sb, ""); - StringUtil.append(sb, "
"); + sb.append(""); + sb.append("
"); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append("
"); + sb.append(""); + sb.append("
"); + sb.append(""); + sb.append(""); + sb.append("
"); if (displayAsPercentage) { - StringUtil.append(sb, "
", String.format("%.2f%%", ((double) current / max) * 100), "
"); + sb.append(""); + sb.append(""); + sb.append("
"); + sb.append(String.format("%.2f%%", ((double) current / max) * 100)); + sb.append("
"); } else { - final String tdWidth = String.valueOf((width - 10) / 2); - StringUtil.append(sb, ""); - StringUtil.append(sb, "
", String.valueOf(current), "/", String.valueOf(max), "
"); + int tdWidth = (width - 10) / 2; + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append(""); + sb.append("
"); + sb.append(current); + sb.append("/"); + sb.append(max); + sb.append("
"); } - StringUtil.append(sb, "
"); + sb.append("
"); + sb.append("
"); return sb.toString(); } diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AbstractFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AbstractFormatter.java new file mode 100644 index 0000000000..4bbc276c13 --- /dev/null +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AbstractFormatter.java @@ -0,0 +1,42 @@ +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; + +/** + * @author Nos + */ +public abstract class AbstractFormatter extends Formatter +{ + private final DateFormat _dateFormat = new SimpleDateFormat("dd/MM HH:mm:ss"); + + @Override + public String format(LogRecord record) + { + final StringBuilder sb = new StringBuilder(32); + sb.append("["); + sb.append(_dateFormat.format(new Date(record.getMillis()))); + sb.append("] "); + sb.append(record.getMessage()); + return sb.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AccountingFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AccountingFormatter.java index 59ddad3604..5fa2774b2f 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AccountingFormatter.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AccountingFormatter.java @@ -1,114 +1,105 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.log.formatter; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -import com.l2jmobius.Config; -import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; -import com.l2jmobius.gameserver.network.L2GameClient; -import com.l2jmobius.util.StringUtil; - -public class AccountingFormatter extends Formatter -{ - private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss"); - - @Override - public String format(LogRecord record) - { - final Object[] params = record.getParameters(); - final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage()); - - if (params != null) - { - for (Object p : params) - { - if (p == null) - { - continue; - } - - StringUtil.append(output, ", "); - - if (p instanceof L2GameClient) - { - final L2GameClient client = (L2GameClient) p; - String address = null; - try - { - if (!client.isDetached()) - { - address = client.getConnection().getInetAddress().getHostAddress(); - } - } - catch (Exception e) - { - } - - switch (client.getState()) - { - case IN_GAME: - { - if (client.getActiveChar() != null) - { - StringUtil.append(output, client.getActiveChar().getName()); - StringUtil.append(output, "(", String.valueOf(client.getActiveChar().getObjectId()), ") "); - } - break; - } - case AUTHED: - { - if (client.getAccountName() != null) - { - StringUtil.append(output, client.getAccountName(), " "); - } - break; - } - case CONNECTED: - { - if (address != null) - { - StringUtil.append(output, address); - } - break; - } - default: - { - throw new IllegalStateException("Missing state on switch"); - } - } - } - else if (p instanceof L2PcInstance) - { - final L2PcInstance player = (L2PcInstance) p; - StringUtil.append(output, player.getName()); - StringUtil.append(output, "(", String.valueOf(player.getObjectId()), ")"); - } - else - { - StringUtil.append(output, p.toString()); - } - } - } - - output.append(Config.EOL); - return output.toString(); - } -} +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.util.logging.LogRecord; + +import com.l2jmobius.Config; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.network.L2GameClient; + +public class AccountingFormatter extends AbstractFormatter +{ + @Override + public String format(LogRecord record) + { + final Object[] params = record.getParameters(); + final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0)); + output.append(super.format(record)); + + if (params != null) + { + for (Object p : params) + { + if (p == null) + { + continue; + } + + output.append(", "); + + if (p instanceof L2GameClient) + { + final L2GameClient client = (L2GameClient) p; + String address = null; + try + { + if (!client.isDetached()) + { + address = client.getConnection().getInetAddress().getHostAddress(); + } + } + catch (Exception e) + { + + } + + switch (client.getState()) + { + case IN_GAME: + if (client.getActiveChar() != null) + { + output.append(client.getActiveChar().getName()); + output.append("("); + output.append(client.getActiveChar().getObjectId()); + output.append(") "); + } + case AUTHED: + if (client.getAccountName() != null) + { + output.append(client.getAccountName()); + output.append(" "); + } + case CONNECTED: + if (address != null) + { + output.append(address); + } + break; + default: + throw new IllegalStateException("Missing state on switch"); + } + } + else if (p instanceof L2PcInstance) + { + L2PcInstance player = (L2PcInstance) p; + output.append(player.getName()); + output.append("("); + output.append(player.getObjectId()); + output.append(")"); + } + else + { + output.append(p); + } + } + } + + output.append(Config.EOL); + return output.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AuditFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AuditFormatter.java index 6fa2f02003..b241ef1ea2 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AuditFormatter.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/AuditFormatter.java @@ -1,55 +1,51 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.log.formatter; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -import com.l2jmobius.Config; -import com.l2jmobius.util.StringUtil; - -/** - * @author zabbix - */ -public class AuditFormatter extends Formatter -{ - private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss"); - - @Override - public String format(LogRecord record) - { - final Object[] params = record.getParameters(); - final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage()); - - if (params != null) - { - for (Object p : params) - { - if (p == null) - { - continue; - } - StringUtil.append(output, ", ", p.toString()); - } - } - - output.append(Config.EOL); - return output.toString(); - } -} +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.util.logging.LogRecord; + +import com.l2jmobius.Config; + +/** + * @author zabbix + */ +public class AuditFormatter extends AbstractFormatter +{ + @Override + public String format(LogRecord record) + { + final Object[] params = record.getParameters(); + final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0)); + output.append(super.format(record)); + + if (params != null) + { + for (Object p : params) + { + if (p == null) + { + continue; + } + output.append(", "); + output.append(p); + } + } + output.append(Config.EOL); + + return output.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ChatLogFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ChatLogFormatter.java index de2f9a69ce..618be791a9 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ChatLogFormatter.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ChatLogFormatter.java @@ -1,49 +1,46 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.log.formatter; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -import com.l2jmobius.Config; -import com.l2jmobius.util.StringUtil; - -public class ChatLogFormatter extends Formatter -{ - private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss"); - - @Override - public String format(LogRecord record) - { - final Object[] params = record.getParameters(); - final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params != null ? 10 * params.length : 0), "[", dateFmt.format(new Date(record.getMillis())), "] "); - - if (params != null) - { - for (Object p : params) - { - StringUtil.append(output, String.valueOf(p), " "); - } - } - - StringUtil.append(output, record.getMessage(), Config.EOL); - - return output.toString(); - } -} +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.util.logging.LogRecord; + +import com.l2jmobius.Config; + +public class ChatLogFormatter extends AbstractFormatter +{ + @Override + public String format(LogRecord record) + { + Object[] params = record.getParameters(); + final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0)); + output.append(super.format(record)); + + if (params != null) + { + for (Object p : params) + { + output.append(p); + output.append(" "); + } + } + + output.append(record.getMessage()); + output.append(Config.EOL); + + return output.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ConsoleLogFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ConsoleLogFormatter.java index dc7ae7dcde..4c6df871f9 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ConsoleLogFormatter.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ConsoleLogFormatter.java @@ -1,50 +1,46 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.log.formatter; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -import com.l2jmobius.Config; -import com.l2jmobius.util.StringUtil; -import com.l2jmobius.util.Util; - -public class ConsoleLogFormatter extends Formatter -{ - private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd/MM HH:mm:ss"); - - @Override - public String format(LogRecord record) - { - final StringBuilder output = new StringBuilder(500); - StringUtil.append(output, "[", dateFmt.format(new Date(record.getMillis())), "] " + record.getMessage(), Config.EOL); - - if (record.getThrown() != null) - { - try - { - StringUtil.append(output, Util.getStackTrace(record.getThrown()), Config.EOL); - } - catch (Exception ex) - { - } - } - return output.toString(); - } -} +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.util.logging.LogRecord; + +import com.l2jmobius.Config; +import com.l2jmobius.util.Util; + +public class ConsoleLogFormatter extends AbstractFormatter +{ + @Override + public String format(LogRecord record) + { + final StringBuilder output = new StringBuilder(128); + output.append(super.format(record)); + output.append(Config.EOL); + + if (record.getThrown() != null) + { + try + { + output.append(Util.getStackTrace(record.getThrown())); + output.append(Config.EOL); + } + catch (Exception ex) + { + } + } + return output.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/DamageFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/DamageFormatter.java index 1f3369e6d1..30ed950ea2 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/DamageFormatter.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/DamageFormatter.java @@ -1,84 +1,89 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.log.formatter; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -import com.l2jmobius.Config; -import com.l2jmobius.gameserver.model.actor.L2Attackable; -import com.l2jmobius.gameserver.model.actor.L2Character; -import com.l2jmobius.gameserver.model.actor.L2Summon; -import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; -import com.l2jmobius.gameserver.model.skills.Skill; -import com.l2jmobius.util.StringUtil; - -public class DamageFormatter extends Formatter -{ - private final SimpleDateFormat dateFmt = new SimpleDateFormat("yy.MM.dd H:mm:ss"); - - @Override - public String format(LogRecord record) - { - final Object[] params = record.getParameters(); - final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), "[", dateFmt.format(new Date(record.getMillis())), "] '---': ", record.getMessage()); - - if (params != null) - { - for (Object p : params) - { - if (p == null) - { - continue; - } - - if (p instanceof L2Character) - { - if ((p instanceof L2Attackable) && ((L2Attackable) p).isRaid()) - { - StringUtil.append(output, "RaidBoss "); - } - - StringUtil.append(output, ((L2Character) p).getName(), "(", String.valueOf(((L2Character) p).getObjectId()), ") "); - StringUtil.append(output, String.valueOf(((L2Character) p).getLevel()), " lvl"); - - if (p instanceof L2Summon) - { - final L2PcInstance owner = ((L2Summon) p).getOwner(); - if (owner != null) - { - StringUtil.append(output, " Owner:", owner.getName(), "(", String.valueOf(owner.getObjectId()), ")"); - } - } - } - else if (p instanceof Skill) - { - StringUtil.append(output, " with skill ", ((Skill) p).getName(), "(", String.valueOf(((Skill) p).getId()), ")"); - } - else - { - StringUtil.append(output, p.toString()); - } - } - } - - output.append(Config.EOL); - return output.toString(); - } -} +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.util.logging.LogRecord; + +import com.l2jmobius.Config; +import com.l2jmobius.gameserver.model.actor.L2Attackable; +import com.l2jmobius.gameserver.model.actor.L2Character; +import com.l2jmobius.gameserver.model.actor.L2Summon; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.model.skills.Skill; + +public class DamageFormatter extends AbstractFormatter +{ + @Override + public String format(LogRecord record) + { + final Object[] params = record.getParameters(); + final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0)); + output.append(super.format(record)); + + if (params != null) + { + for (Object p : params) + { + if (p == null) + { + continue; + } + + if (p instanceof L2Character) + { + final L2Character creature = (L2Character) p; + if ((p instanceof L2Attackable) && ((L2Attackable) p).isRaid()) + { + output.append("RaidBoss "); + } + + output.append(creature.getName()); + output.append("("); + output.append(creature.getObjectId()); + output.append(") "); + output.append(creature.getLevel()); + output.append(" lvl"); + + if (p instanceof L2Summon) + { + L2PcInstance owner = ((L2Summon) p).getOwner(); + if (owner != null) + { + output.append(" Owner:"); + output.append(owner.getName()); + output.append("("); + output.append(owner.getObjectId()); + output.append(")"); + } + } + } + else if (p instanceof Skill) + { + output.append(" with skill "); + output.append(p); + } + else + { + output.append(p); + } + } + } + + output.append(Config.EOL); + return output.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/EnchantFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/EnchantFormatter.java index 9fa1bb9fe8..e9604e83a6 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/EnchantFormatter.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/EnchantFormatter.java @@ -1,89 +1,104 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.log.formatter; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -import com.l2jmobius.Config; -import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; -import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; -import com.l2jmobius.gameserver.model.skills.Skill; -import com.l2jmobius.util.StringUtil; - -public class EnchantFormatter extends Formatter -{ - private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss"); - - @Override - public String format(LogRecord record) - { - final Object[] params = record.getParameters(); - final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage()); - - if (params != null) - { - for (Object p : params) - { - if (p == null) - { - continue; - } - - StringUtil.append(output, ", "); - - if (p instanceof L2PcInstance) - { - final L2PcInstance player = (L2PcInstance) p; - StringUtil.append(output, "Character:", player.getName(), " [" + String.valueOf(player.getObjectId()) + "] Account:", player.getAccountName()); - if ((player.getClient() != null) && !player.getClient().isDetached()) - { - StringUtil.append(output, " IP:", player.getClient().getConnection().getInetAddress().getHostAddress()); - } - } - else if (p instanceof L2ItemInstance) - { - final L2ItemInstance item = (L2ItemInstance) p; - if (item.getEnchantLevel() > 0) - { - StringUtil.append(output, "+", String.valueOf(item.getEnchantLevel()), " "); - } - StringUtil.append(output, item.getItem().getName(), "(", String.valueOf(item.getCount()), ")"); - StringUtil.append(output, " [", String.valueOf(item.getObjectId()), "]"); - } - else if (p instanceof Skill) - { - final Skill skill = (Skill) p; - if (skill.getLevel() > 100) - { - StringUtil.append(output, "+", String.valueOf(skill.getLevel() % 100), " "); - } - StringUtil.append(output, skill.getName(), "(", String.valueOf(skill.getId()), " ", String.valueOf(skill.getLevel()), ")"); - } - else - { - StringUtil.append(output, p.toString()); - } - } - } - - output.append(Config.EOL); - return output.toString(); - } -} +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.util.logging.LogRecord; + +import com.l2jmobius.Config; +import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; +import com.l2jmobius.gameserver.model.skills.Skill; + +public class EnchantFormatter extends AbstractFormatter +{ + @Override + public String format(LogRecord record) + { + final Object[] params = record.getParameters(); + final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0)); + output.append(super.format(record)); + + if (params != null) + { + for (Object p : params) + { + if (p == null) + { + continue; + } + + output.append(", "); + + if (p instanceof L2PcInstance) + { + L2PcInstance player = (L2PcInstance) p; + output.append("Character:"); + output.append(player.getName()); + output.append(" ["); + output.append(player.getObjectId()); + output.append("] Account:"); + output.append(player.getAccountName()); + if ((player.getClient() != null) && !player.getClient().isDetached()) + { + output.append(" IP:"); + output.append(player.getClient().getConnection().getInetAddress().getHostAddress()); + } + } + else if (p instanceof L2ItemInstance) + { + L2ItemInstance item = (L2ItemInstance) p; + if (item.getEnchantLevel() > 0) + { + output.append("+"); + output.append(item.getEnchantLevel()); + output.append(" "); + } + output.append(item.getItem().getName()); + output.append("("); + output.append(item.getCount()); + output.append(")"); + output.append(" ["); + output.append(item.getObjectId()); + output.append("]"); + } + else if (p instanceof Skill) + { + Skill skill = (Skill) p; + if (skill.getLevel() > 100) + { + output.append("+"); + output.append(skill.getLevel() % 100); + output.append(" "); + } + output.append(skill.getName()); + output.append("("); + output.append(skill.getId()); + output.append(" "); + output.append(skill.getLevel()); + output.append(")"); + } + else + { + output.append(p); + } + } + } + + output.append(Config.EOL); + return output.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/FileLogFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/FileLogFormatter.java index 9cc1217c8d..a9c12d1d90 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/FileLogFormatter.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/FileLogFormatter.java @@ -1,41 +1,46 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.log.formatter; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -import com.l2jmobius.Config; -import com.l2jmobius.util.StringUtil; - -/** - * This class ... - * @version $Revision: 1.1.4.1 $ $Date: 2005/03/27 15:30:08 $ - */ -public class FileLogFormatter extends Formatter -{ - private static final String TAB = "\t"; - private final SimpleDateFormat dateFmt = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss,SSS"); - - @Override - public String format(LogRecord record) - { - return StringUtil.concat(dateFmt.format(new Date(record.getMillis())), TAB, record.getLevel().getName(), TAB, String.valueOf(record.getThreadID()), TAB, record.getLoggerName(), TAB, record.getMessage(), Config.EOL); - } -} +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.StringJoiner; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; + +import com.l2jmobius.Config; + +/** + * This class ... + * @version $Revision: 1.1.4.1 $ $Date: 2005/03/27 15:30:08 $ + */ +public class FileLogFormatter extends Formatter +{ + private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss,SSS"); + + @Override + public String format(LogRecord record) + { + final StringJoiner sj = new StringJoiner("\t", "", Config.EOL); + sj.add(dateFormat.format(new Date(record.getMillis()))); + sj.add(record.getLevel().getName()); + sj.add(String.valueOf(record.getThreadID())); + sj.add(record.getLoggerName()); + sj.add(record.getMessage()); + return sj.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ItemLogFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ItemLogFormatter.java index da2cf80628..01c994a5dc 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ItemLogFormatter.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/ItemLogFormatter.java @@ -1,70 +1,70 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.log.formatter; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -import com.l2jmobius.Config; -import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; -import com.l2jmobius.util.StringUtil; - -/** - * @author Advi - */ -public class ItemLogFormatter extends Formatter -{ - private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss"); - - @Override - public String format(LogRecord record) - { - final Object[] params = record.getParameters(); - final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params.length * 50), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage()); - - for (Object p : record.getParameters()) - { - if (p == null) - { - continue; - } - output.append(", "); - if (p instanceof L2ItemInstance) - { - final L2ItemInstance item = (L2ItemInstance) p; - StringUtil.append(output, "item ", String.valueOf(item.getObjectId()), ":"); - if (item.getEnchantLevel() > 0) - { - StringUtil.append(output, "+", String.valueOf(item.getEnchantLevel()), " "); - } - - StringUtil.append(output, item.getItem().getName(), "(", String.valueOf(item.getCount()), ")"); - } - // else if (p instanceof L2PcInstance) - // output.append(((L2PcInstance)p).getName()); - else - { - output.append(p.toString()/* + ":" + ((L2Object)p).getObjectId() */); - } - } - output.append(Config.EOL); - - return output.toString(); - } -} +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.util.logging.LogRecord; + +import com.l2jmobius.Config; +import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance; + +/** + * @author Advi + */ +public class ItemLogFormatter extends AbstractFormatter +{ + @Override + public String format(LogRecord record) + { + final Object[] params = record.getParameters(); + final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0)); + output.append(super.format(record)); + + for (Object p : record.getParameters()) + { + if (p == null) + { + continue; + } + output.append(", "); + if (p instanceof L2ItemInstance) + { + L2ItemInstance item = (L2ItemInstance) p; + output.append("item "); + output.append(item.getObjectId()); + output.append(":"); + if (item.getEnchantLevel() > 0) + { + output.append("+"); + output.append(item.getEnchantLevel()); + output.append(" "); + } + + output.append(item.getItem().getName()); + output.append("("); + output.append(item.getCount()); + output.append(")"); + } + else + { + output.append(p); + } + } + output.append(Config.EOL); + + return output.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/OlympiadFormatter.java b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/OlympiadFormatter.java index 53caf3c652..23c3192fd6 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/OlympiadFormatter.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/log/formatter/OlympiadFormatter.java @@ -1,50 +1,47 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.log.formatter; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -import com.l2jmobius.Config; -import com.l2jmobius.util.StringUtil; - -public class OlympiadFormatter extends Formatter -{ - private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd/MM/yyyy H:mm:ss"); - - @Override - public String format(LogRecord record) - { - final Object[] params = record.getParameters(); - final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), dateFmt.format(new Date(record.getMillis())), ",", record.getMessage()); - if (params != null) - { - for (Object p : params) - { - if (p == null) - { - continue; - } - StringUtil.append(output, ",", p.toString()); - } - } - output.append(Config.EOL); - return output.toString(); - } -} +/* + * This file is part of the L2J Mobius project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.l2jmobius.log.formatter; + +import java.util.logging.LogRecord; + +import com.l2jmobius.Config; + +public class OlympiadFormatter extends AbstractFormatter +{ + @Override + public String format(LogRecord record) + { + final Object[] params = record.getParameters(); + final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0)); + output.append(super.format(record)); + + if (params != null) + { + for (Object p : params) + { + if (p == null) + { + continue; + } + output.append(","); + output.append(p); + } + } + output.append(Config.EOL); + return output.toString(); + } +} diff --git a/L2J_Mobius_Test/java/com/l2jmobius/util/StringUtil.java b/L2J_Mobius_Test/java/com/l2jmobius/util/StringUtil.java deleted file mode 100644 index 87b3119e45..0000000000 --- a/L2J_Mobius_Test/java/com/l2jmobius/util/StringUtil.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * This file is part of the L2J Mobius project. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.l2jmobius.util; - -import com.l2jmobius.Config; - -/** - * String utilities optimized for the best performance.
- *

How to Use It

- *

concat() or append()

If concatenating strings
- * in single call, use StringUtil.concat(), otherwise use StringUtil.append()
- * and its variants.
- *
- *

Minimum Calls


- * Bad: - * - *
- * final StringBuilder sbString = new StringBuilder();
- * StringUtil.append(sbString, "text 1", String.valueOf(npcId));
- * StringUtil.append("text 2");
- * 
- * - * Good: - * - *
- * final StringBuilder sbString = new StringBuilder();
- * StringUtil.append(sbString, "text 1", String.valueOf(npcId), "text 2");
- * 
- * - * Why?
- * Because the less calls you do, the less memory re-allocations have to be done
- * so the whole text fits into the memory and less array copy tasks has to be
- * performed. So if using less calls, less memory is used and string concatenation is faster.
- *
- *

Size Hints for Loops


- * Bad: - * - *
- * final StringBuilder sbString = new StringBuilder();
- * StringUtil.append(sbString, "header start", someText, "header end");
- * for (int i = 0; i < 50; i++)
- * {
- * 	StringUtil.append(sbString, "text 1", stringArray[i], "text 2");
- * }
- * 
- * - * Good: - * - *
- * final StringBuilder sbString = StringUtil.startAppend(1300, "header start", someText, "header end");
- * for (int i = 0; i < 50; i++)
- * {
- * 	StringUtil.append(sbString, "text 1", stringArray[i], "text 2");
- * }
- * 
- * - * Why?
- * When using StringUtil.append(), memory is only allocated to fit in the strings in method argument. So on each loop new memory for the string has to be allocated and old string has to be copied to the new string. With size hint, even if the size hint is above the needed memory, memory is saved - * because new memory has not to be allocated on each cycle. Also it is much faster if no string copy tasks has to be performed. So if concatenating strings in a loop, count approximately the size and set it as the hint for the string builder size. It's better to make the size hint little bit larger - * rather than smaller.
- * In case there is no text appended before the cycle, just use new - * StringBuilder(1300).
- *
- *

Concatenation and Constants


- * Bad: - * - *
- * StringUtil.concat("text 1 ", "text 2", String.valueOf(npcId));
- * 
- * - * Good: - * - *
- * StringUtil.concat("text 1 " + "text 2", String.valueOf(npcId));
- * 
- * - * or - * - *
- * StringUtil.concat("text 1 text 2", String.valueOf(npcId));
- * 
- * - * Why?
- * It saves some cycles when determining size of memory that needs to be allocated because less strings are passed to concat() method. But do not use + for concatenation of non-constant strings, that degrades performance and makes extra memory allocations needed.
- *

Concatenation and Constant Variables

Bad: - * - *
- * String glue = "some glue";
- * StringUtil.concat("text 1", glue, "text 2", glue, String.valueOf(npcId));
- * 
- * - * Good: - * - *
- * final String glue = "some glue";
- * StringUtil.concat("text 1" + glue + "text2" + glue, String.valueOf(npcId));
- * 
- * - * Why? Because when using final keyword, the glue is marked as constant string and compiler treats it as a constant string so it is able to create string "text1some gluetext2some glue" during the compilation. But this only works in case the value is known at compilation - * time, so this cannot be used for cases like final String objectIdString = - * String.valueOf(getObjectId).
- *
- *

StringBuilder Reuse


- * Bad: - * - *
- * final StringBuilder sbString1 = new StringBuilder();
- * StringUtil.append(sbString1, "text 1", String.valueOf(npcId), "text 2");
- * ... // output of sbString1, it is no more needed
- * final StringBuilder sbString2 = new StringBuilder();
- * StringUtil.append(sbString2, "text 3", String.valueOf(npcId), "text 4");
- * 
- * - * Good: - * - *
- * final StringBuilder sbString = new StringBuilder();
- * StringUtil.append(sbString, "text 1", String.valueOf(npcId), "text 2");
- * ... // output of sbString, it is no more needed
- * sbString.setLength(0);
- * StringUtil.append(sbString, "text 3", String.valueOf(npcId), "text 4");
- * 
- * - * Why?
- * In first case, new memory has to be allocated for the second string. In second case already allocated memory is reused, but only in case the new string is not longer than the previously allocated string. Anyway, the second way is better because the string either fits in the memory and some memory - * is saved, or it does not fit in the memory, and in that case it works as in the first case. - *

Primitives to Strings

To convert primitives to string, use String.valueOf().
- *
- *

How much faster is it?


- * Here are some results of my tests. Count is number of strings concatenated. Don't take the numbers as 100% true as the numbers are affected by other programs running on my computer at the same time. Anyway, from the results it is obvious that using StringBuilder with predefined size is the - * fastest (and also most memory efficient) solution. It is about 5 times faster when concatenating 7 strings, compared to TextBuilder. Also, with more strings concatenated, the difference between StringBuilder and TextBuilder gets larger. In code, there are many cases, where there are concatenated - * 50+ strings so the time saving is even greater.
- * - *
- * Count: 2
- * TextBuilder: 1893
- * TextBuilder with size: 1703
- * String: 1033
- * StringBuilder: 993
- * StringBuilder with size: 1024
- * Count: 3
- * TextBuilder: 1973
- * TextBuilder with size: 1872
- * String: 2583
- * StringBuilder: 1633
- * StringBuilder with size: 1156
- * Count: 4
- * TextBuilder: 2188
- * TextBuilder with size: 2229
- * String: 4207
- * StringBuilder: 1816
- * StringBuilder with size: 1444
- * Count: 5
- * TextBuilder: 9185
- * TextBuilder with size: 9464
- * String: 6937
- * StringBuilder: 2745
- * StringBuilder with size: 1882
- * Count: 6
- * TextBuilder: 9785
- * TextBuilder with size: 10082
- * String: 9471
- * StringBuilder: 2889
- * StringBuilder with size: 1857
- * Count: 7
- * TextBuilder: 10169
- * TextBuilder with size: 10528
- * String: 12746
- * StringBuilder: 3081
- * StringBuilder with size: 2139
- * 
- * - * @author fordfrog - */ -public final class StringUtil -{ - private StringUtil() - { - } - - /** - * Concatenates strings. - * @param strings strings to be concatenated - * @return concatenated string - */ - public static String concat(String... strings) - { - final StringBuilder sbString = new StringBuilder(); - for (String string : strings) - { - sbString.append(string); - } - return sbString.toString(); - } - - /** - * Creates new string builder with size initializated to sizeHint, unless total length of strings is greater than sizeHint. - * @param sizeHint hint for string builder size allocation - * @param strings strings to be appended - * @return created string builder - */ - public static StringBuilder startAppend(int sizeHint, String... strings) - { - final int length = getLength(strings); - final StringBuilder sbString = new StringBuilder(sizeHint > length ? sizeHint : length); - for (String string : strings) - { - sbString.append(string); - } - return sbString; - } - - /** - * Appends strings to existing string builder. - * @param sbString string builder - * @param strings strings to be appended - */ - public static void append(StringBuilder sbString, String... strings) - { - sbString.ensureCapacity(sbString.length() + getLength(strings)); - - for (String string : strings) - { - sbString.append(string); - } - } - - public static int getLength(Iterable strings) - { - int length = 0; - for (String string : strings) - { - length += (string == null) ? 4 : string.length(); - } - return length; - } - - /** - * Counts total length of all the strings. - * @param strings array of strings - * @return total length of all the strings - */ - public static int getLength(String[] strings) - { - int length = 0; - for (String string : strings) - { - length += (string == null) ? 4 : string.length(); - } - return length; - } - - public static String getTraceString(StackTraceElement[] trace) - { - final StringBuilder sbString = new StringBuilder(); - for (StackTraceElement element : trace) - { - sbString.append(element.toString()).append(Config.EOL); - } - return sbString.toString(); - } -} \ No newline at end of file diff --git a/L2J_Mobius_Test/java/com/l2jmobius/util/Util.java b/L2J_Mobius_Test/java/com/l2jmobius/util/Util.java index 8d59ac58ca..3b11dfd045 100644 --- a/L2J_Mobius_Test/java/com/l2jmobius/util/Util.java +++ b/L2J_Mobius_Test/java/com/l2jmobius/util/Util.java @@ -29,8 +29,11 @@ import java.time.temporal.TemporalAdjusters; import java.util.Arrays; import java.util.Comparator; import java.util.List; +import java.util.StringJoiner; import java.util.logging.Logger; +import com.l2jmobius.Config; + /** * Useful utilities common to L2J Server. */ @@ -221,4 +224,14 @@ public final class Util .orElse(dateNowWithDifferentTime.with(TemporalAdjusters.next(daysOfWeek.get(0)))); // @formatter:on } + + public static String getTraceString(StackTraceElement[] stackTraceElements) + { + final StringJoiner sj = new StringJoiner(Config.EOL); + for (final StackTraceElement stackTraceElement : stackTraceElements) + { + sj.add(stackTraceElement.toString()); + } + return sj.toString(); + } }