### Eclipse Workspace Patch 1.0
#P L2_WolfPack
diff --git dist/game/data/scripts/handlers/MasterHandler.java dist/game/data/scripts/handlers/MasterHandler.java
index c0e6a40..3bca7af 100644
--- dist/game/data/scripts/handlers/MasterHandler.java
+++ dist/game/data/scripts/handlers/MasterHandler.java
@@ -268,20 +268,21 @@
import handlers.usercommandhandlers.MyBirthday;
import handlers.usercommandhandlers.OlympiadStat;
import handlers.usercommandhandlers.PartyInfo;
import handlers.usercommandhandlers.SiegeStatus;
import handlers.usercommandhandlers.Time;
import handlers.usercommandhandlers.Unstuck;
import handlers.voicedcommandhandlers.Banking;
import handlers.voicedcommandhandlers.ChangePassword;
import handlers.voicedcommandhandlers.ChatAdmin;
+import handlers.voicedcommandhandlers.CombineTalismans;
import handlers.voicedcommandhandlers.Debug;
import handlers.voicedcommandhandlers.Lang;
import handlers.voicedcommandhandlers.StatsVCmd;
import handlers.voicedcommandhandlers.Wedding;
/**
* Master handler.
* @author UnAfraid
*/
public class MasterHandler
@@ -525,20 +526,21 @@
{
// Voiced Command Handlers
StatsVCmd.class,
// TODO: Add configuration options for this voiced commands:
// CastleVCmd.class,
// SetVCmd.class,
(Config.L2JMOD_ALLOW_WEDDING ? Wedding.class : null),
(Config.BANKING_SYSTEM_ENABLED ? Banking.class : null),
(Config.L2JMOD_CHAT_ADMIN ? ChatAdmin.class : null),
+ CombineTalismans.class,
(Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW ? Lang.class : null),
(Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null),
(Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
},
{
// Target Handlers
Area.class,
AreaCorpseMob.class,
AreaFriendly.class,
diff --git dist/game/data/scripts/handlers/voicedcommandhandlers/CombineTalismans.java dist/game/data/scripts/handlers/voicedcommandhandlers/CombineTalismans.java
new file mode 100644
index 0000000..2b20529
--- /dev/null
+++ dist/game/data/scripts/handlers/voicedcommandhandlers/CombineTalismans.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2004-2015 L2J DataPack
+ *
+ * This file is part of L2J DataPack.
+ *
+ * L2J DataPack 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.
+ *
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package handlers.voicedcommandhandlers;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.logging.Level;
+
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
+import com.l2jserver.gameserver.util.Util;
+
+/**
+ * This is a clean version of my original idea back in 2012.
+ * @author Nik
+ */
+public class CombineTalismans implements IVoicedCommandHandler
+{
+ private static final String[] VOICED_COMMANDS =
+ {
+ "combinetalismans"
+ };
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
+ {
+ if (VOICED_COMMANDS[0].equalsIgnoreCase(command))
+ {
+ final Map<Integer, L2ItemInstance> talismans = new HashMap<>();
+ activeChar.sendMessage("Combining talismans...");
+ try
+ {
+ //@formatter:off
+ Arrays.stream(activeChar.getInventory().getItems())
+ .filter(Objects::nonNull)
+ .filter(L2ItemInstance::isShadowItem)
+ .filter(i -> Util.contains(TALISMAN_IDS, i.getId())) // Filter that only talismans go through.
+ .sorted((i1, i2) -> Boolean.compare(i2.isEquipped(), i1.isEquipped())) // Equipped talismans first (so we can then pick equipped first for charging).
+ .forEach(item ->
+ {
+ final L2ItemInstance talismanToCharge = talismans.putIfAbsent(item.getId(), item);
+ if ((talismanToCharge != null) && activeChar.destroyItem(VOICED_COMMANDS[0], item, activeChar, false))
+ {
+ talismanToCharge.decreaseMana(false, -item.getMana()); // Minus in decrease = increase :P
+ }
+ });
+ //@formatter:on
+
+ activeChar.sendMessage(talismans.isEmpty() ? "...there were no combined talismans." : "...results:");
+ talismans.values().forEach(i -> activeChar.sendMessage(i.getName() + " has been successfully combined."));
+ }
+ catch (Exception e)
+ {
+ activeChar.sendMessage("There was a problem while combining your talismans, please consult with an admin, and tell him this date: " + Util.getDateString(new Date(System.currentTimeMillis())));
+ _log.log(Level.WARNING, "Error while combining talismans: ", e);
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return VOICED_COMMANDS;
+ }
+
+ //@formatter:off
+ // All talismans inside high five client.
+ public static final int[] TALISMAN_IDS =
+ {
+ 9914, // Blue Talisman of Power Increases P. Atk. when in use. Effect does not stack with additional Talismans of the same type. Shadow Item that cannot be traded or dropped.
+ 9915, // Blue Talisman of Wild Magic Increases Critical Rate of magic attacks temporarily. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9916, // Blue Talisman of Defense Temporarily decreases P. Def./M. Def./Evasion and increases P. Atk./M. Atk./Atk. Spd./Casting Spd./speed. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9917, // Red Talisman of Minimum Clarity Decreases skill MP consumption when used. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9918, // Red Talisman of Maximum Clarity Temporarily greatly decreases skill MP consumption when used. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9919, // Blue Talisman of Reflection When used, grants a skill whereby any physical melee damage received will be reflected back onto your attacker. Effect does not stack with additional talismans of the same type. This item cannot be traded or dropped.
+ 9920, // Blue Talisman of Invisibility Makes you invisible for a while, so you cannot be attacked by enemies. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9921, // Blue Talisman - Shield Protection When used, increases the protection power of a shield. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9922, // Black Talisman - Mending When used, it cures bleeding. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9923, // Black Talisman - Escape When used, it cancels all Movement Inability States. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9924, // Blue Talisman of Healing It increases HP Recovery Magic temporarily. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9925, // Red Talisman of Recovery It recovers HP/CP. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9926, // Blue Talisman of Defense When used, increases P. Def. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9927, // Blue Talisman of Magic Defense When used, increases magic P. Def. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9928, // Red Talisman of Mental Regeneration When used, it speeds up MP recovery. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9929, // Blue Talisman of Protection When used, increases the protection power of a shield. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9930, // Blue Talisman of Evasion When used, increases evasion and reduces Critical Damage possibilities. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9931, // Red Talisman of Meditation When used, it greatly increases MP Recovery Rate. You cannot move during recovery. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9932, // Blue Talisman - Divine Protection When used, P. Def. and M. Def. greatly increase momentarily. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 9933, // Yellow Talisman of Power Increases P. Atk. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9934, // Yellow Talisman of Violent Haste Increases Atk. Spd. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9935, // Yellow Talisman of Arcane Defense Increases Magic Defense. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9936, // Yellow Talisman of Arcane Power Increases M. Atk. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9937, // Yellow Talisman of Arcane Haste Increases Casting Spd. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9938, // Yellow Talisman of Accuracy Increases Accuracy. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9939, // Yellow Talisman of Defense Increases Defense. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9940, // Yellow Talisman of Alacrity Increases P. Atk., M. Atk., and Speed. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9941, // Yellow Talisman of Speed Increases Speed. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9942, // Yellow Talisman of Critical Reduction When used, it decreases damages from physical critical attacks. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9943, // Yellow Talisman of Critical Damage Increases Critical P. Atk. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9944, // Yellow Talisman of Critical Dodging When used, it decreases physical Critical Damage possibility. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9945, // Yellow Talisman of Evasion Increases Evasion. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9946, // Yellow Talisman of Healing Increases HP Recovery Magic temporarily. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9947, // Yellow Talisman of CP Regeneration Increases CP recovery. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9948, // Yellow Talisman of Physical Regeneration Increases HP recovery. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9949, // Yellow Talisman of Mental Regeneration Increases MP recovery. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9950, // Grey Talisman of Weight Training Increases weapon Weight Limit. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9951, // Grey Talisman of Mid-Grade Fishing Obtains Mid-Grade Fishing Mastery Level (Lv 18). Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9952, // Orange Talisman - Hot Springs CP Potion Create 1 Hot Springs CP Potion following the consumption of 16 Soul Ore. Effect does not stack with additional Talismans of the same type. Shadow Item that cannot be traded or dropped.
+ 9953, // Orange Talisman - Elixir of Life Consumes 50 Soul Ore to create an A-Grade Elixir of Life. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9954, // Orange Talisman - Elixir of Mental Strength Consumes 57 Soul Ore to create an A-Grade Elixir of Mental Strength. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9955, // Black Talisman - Vocalization Breaks magic silence. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9956, // Black Talisman - Arcane Freedom When used, it cancels Magical Movement Inability States. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9957, // Black Talisman - Physical Freedom When used, it cancels Physical Movement Inability States. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9958, // Black Talisman - Rescue When used, it cancels Physical Skill Inability States. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9959, // Black Talisman - Free Speech Breaks silence. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9960, // White Talisman of Bravery Increases Resistance to mental attacks. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9961, // White Talisman of Motion When equipped, Resistance to Paralysis increases. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 9962, // White Talisman of Grounding When equipped, Resistance to Shock attacks increases. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 9963, // White Talisman of Attention When equipped, Resistance to sleep attacks increases. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 9964, // White Talisman of Bandages When equipped, Resistance to bleed attacks increases. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 9965, // White Talisman of Protection Increases Resistance to buff disarming magic. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 9966, // White Talisman of Freedom When equipped, Resistance to Hold increases. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 10141, // Grey Talisman - Yeti Transform Can be transformed into a Yeti for a certain amount of time. Transformation is cancelled if unequipped. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 10142, // Grey Talisman - Buffalo Transform Can be transformed into a Buffalo for a certain amount of time. Transformation is cancelled if unequipped. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 10158, // Grey Talisman of Upper Grade Fishing Obtains Upper-Grade Fishing Mastery Level (Lv 24). Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 10416, // Blue Talisman - Explosion Increases P. Atk./Atk. Spd. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10417, // Blue Talisman - Magic Explosion Increases M. Atk. and M. Critical Rate . Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10418, // White Talisman - Storm Increases Wind attribute. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10419, // White Talisman - Darkness Increases Dark attribute. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10420, // White Talisman - Water Increases Water attribute. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10421, // White Talisman - Fire Instantly increases fire elemental. Only one effect is applied when you wear the same two talismans. Projection Weapons with no exchange/drop available
+ 10422, // White Talisman - Light Increases holy attribute. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10423, // Blue Talisman - Self-Destruction Damages a nearby enemy with a powerful explosion. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10424, // Blue Talisman - Greater Healing Increases heal power. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10518, // Red Talisman - Life Force Completely restores MP/HP when used. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10519, // White Talisman - Earth Increases Earth attribute defense by 50 when used. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10533, // Blue Talisman - P. Atk. Increases P. Atk. when used. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 10534, // Blue Talisman - Shield Defense Shield Def. increases when used. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 10535, // Yellow Talisman - P. Def. P. Def. increases when equipped. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 10536, // Yellow Talisman - M. Atk. Increases M. Atk. when equipped. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 10537, // Yellow Talisman - Evasion Increases Evasion when equipped. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 10538, // Yellow Talisman - Healing Power HP recovery M. Atk. increases when equipped. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 10539, // Yellow Talisman - CP Recovery Rate CP recovery rate increases when equipped. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 10540, // Yellow Talisman - HP Recovery Rate Increases HP Recovery Rate. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 10541, // Yellow Talisman - Low Grade MP Recovery Rate Increases MP Recovery Rate. Effect does not stack with additional Talismans of the same type. This item cannot be exchanged or dropped.
+ 10542, // Red Talisman - HP/CP Recovery HP/CP are recovered when equipped. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 10543, // Yellow Talisman - Speed Speed increases when equipped. Effect does not stack with additional Talismans of the same type. A Shadow Item which cannot be exchanged or dropped.
+ 12815, // Red Talisman - Max CP Increases Max CP when equipped. Effect does not stack with additional Talismans of the same type. Shadow Item that cannot be exchanged or dropped.
+ 12816, // Red Talisman - CP Regeneration Increases CP regeneration rate when equipped. Effect does not stack with additional Talismans of the same type. Shadow Item that cannot be exchanged or dropped.
+ 12817, // Yellow Talisman - Increase Force Increases your Force Level when attacked while equipped. Effect does not stack with additional Talismans of the same type. Shadow Item that cannot be exchanged or dropped.
+ 12818, // Yellow Talisman - Damage Transition Transfers a portion of damage you take onto your servitor while equipped. Effect does not stack with additional Talismans of the same type. Shadow Item that cannot be exchanged or dropped.
+ 14604, // Red Talisman - Territory Guardian When used, Max CP is greatly increased and a certain amount of CP is greatly recovered. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 14605, // Red Talisman - Territory Guard When used, Max CP is increased and a certain amount of CP is recovered. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 14810, // Blue Talisman - Buff Cancel Cancels the buffs of nearby enemies upon use. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 14811, // Blue Talisman - Buff Steal Steals the target's abnormal status upon use. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 14812, // Red Talisman - Territory Guard When used, Max CP is greatly increased and a certain amount of CP is greatly recovered. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 14813, // Blue Talisman - Lord's Divine Protection Upon use, greatly decreases the damage received during PvP. Only one effect is applied when you wear the same two talismans. Shadow Item with no exchange/drop available
+ 14814, // White Talisman - All Resistance Increases Resistance to all elements. Effect does not stack with additional Talismans of the same type. This item cannot be traded or dropped.
+ 17051, // Talisman - STR Event item. STR +2 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17052, // Talisman - DEX Event item. DEX +2 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17053, // Talisman - CON Event item. CON +2 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17054, // Talisman - WIT Event item. WIT +2 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17055, // Talisman - INT Event item. INT +2 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17056, // Talisman - MEN Event item. MEN +2 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17057, // Talisman - Resistance to Stun Event item. Resistance to Stun +15 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17058, // Talisman - Resistance to Sleep Event item. Resistance to Sleep +15 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17059, // Talisman - Resistance to Hold Event item. Resistance to Hold +15 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17060, // Talisman - Paralyze Resistance Event item. Paralysis resistance +15 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted in bulk after the regular maintenance time on Jul. 7.
+ 17061, // Talisman - ALL STAT Event item. All stats increase by 1 when equipped. Cannot be traded, dropped, destroyed, or used in the Olympiad. \\nThis item will be deleted after the regular maintenance on July 7th.
+ 22326, // Blue Talisman - Buff Cancel Cancels the buffs of nearby enemies upon use. Only one effect is applies when you wear two of the same talismans. Cannot be exchanged or dropped. Can be destroyed. Can be stored in a private warehouse.
+ 22327 // Blue Talisman - Buff Steal Stealsthe target's abnormal status upon use. Only one effect is applies when you wear two of the same talismans. Cannot be exchanged or dropped. Can be destroyed. Can be stored in a private warehouse.
+ };
+ //@formatter:on
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2ClanManagerInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2ClanManagerInstance.java (revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2ClanManagerInstance.java (working copy)
@@ -0,0 +1,116 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.model.actor.instance;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
import net.sf.l2j.util.Rnd;
/**
* @author Debian
*
*/
public class L2ClanManagerInstance extends L2NpcInstance
{
public L2ClanManagerInstance(int objectId, L2NpcTemplate template)
{
super(objectId, template);
}
@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
if (command.startsWith("levelup"))
{
if(player.getClan() != null)
{
if (!player.isClanLeader())
{
player.sendMessage("Only clan leaders, can use this service.");
}
if (player.isClanLeader() && player.getClan().getReputationScore() > 50000)
{
player.getClan().takeReputationScore(50000);
player.getClan().changeLevel(8);
player.sendMessage("Your clan successfully changed to level 8.");
}
else
{
player.sendMessage("Your clan must have 50000 clan reputation points in order to buy level 8.");
}
}
else
{
player.sendMessage("You don't have a clan.");
}
}
}
@Override
public void onAction(L2PcInstance player)
{
if (this != player.getTarget()) {
player.setTarget(this);
player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
player.sendPacket(new ValidateLocation(this));
}
else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false)) {
SocialAction sa = new SocialAction(this, Rnd.get(8));
broadcastPacket(sa);
player.setCurrentFolkNPC(this);
showMessageWindow(player);
player.sendPacket(ActionFailed.STATIC_PACKET);
}
diff --git a/src/main/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java b/src/main/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
index 67dd5a2..84ae937 100644
--- a/src/main/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
+++ b/src/main/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
@@ -411,6 +411,7 @@
private long _onlineBeginTime;
private long _lastAccess;
private long _uptime;
+ private int _ping = -1;
private final ReentrantLock _subclassLock = new ReentrantLock();
protected int _baseClass;
@@ -14350,4 +14351,14 @@
}
return _servitorShare.get(stat);
}
+
+ public int getPing()
+ {
+ return _ping;
+ }
+
+ public void setPing(int ping)
+ {
+ _ping = ping;
+ }
}
diff --git a/src/main/java/com/l2jserver/loginserver/network/Pinger.java b/src/main/java/com/l2jserver/loginserver/network/Pinger.java
new file mode 100644
index 0000000..bf16a6e
--- /dev/null
+++ b/src/main/java/com/l2jserver/loginserver/network/Pinger.java
@@ -0,0 +1,44 @@
+package com.l2jserver.loginserver.network;
+
+import com.l2jserver.gameserver.ThreadPoolManager;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.loginserver.network.serverpackets.NetPingPacket;
+
+/**
+ * @author vGodFather
+ */
+public class Pinger
+{
+ public static boolean getPing(L2PcInstance activeChar)
+ {
+ activeChar.sendMessage("Processing request...");
+ activeChar.sendPacket(new NetPingPacket(activeChar));
+ ThreadPoolManager.getInstance().scheduleGeneral(new AnswerTask(activeChar), 3000L);
+ return true;
+ }
+
+ private static final class AnswerTask implements Runnable
+ {
+ private final L2PcInstance _player;
+
+ public AnswerTask(L2PcInstance player)
+ {
+ _player = player;
+ }
+
+ @Override
+ public void run()
+ {
+ int ping = _player.getPing();
+ if (ping > -1)
+ {
+ _player.sendMessage("Current ping: " + ping + " ms.");
+ }
+ else
+ {
+ _player.sendMessage("The data from the client was not received.");
+ }
+ _player.setPing(-1);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/l2jserver/loginserver/network/serverpackets/NetPingPacket.java b/src/main/java/com/l2jserver/loginserver/network/serverpackets/NetPingPacket.java
new file mode 100644
index 0000000..30423f5
--- /dev/null
+++ b/src/main/java/com/l2jserver/loginserver/network/serverpackets/NetPingPacket.java
@@ -0,0 +1,24 @@
+package com.l2jserver.loginserver.network.serverpackets;
+
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
+
+/**
+ * @author vGodFather
+ */
+public class NetPingPacket extends L2GameServerPacket
+{
+ private final int _objId;
+
+ public NetPingPacket(L2PcInstance cha)
+ {
+ _objId = cha.getObjectId();
+ }
+
+ @Override
+ protected void writeImpl()
+ {
+ writeC(0xD9);
+ writeD(_objId);
+ }
+}
\ No newline at end of file
diff --git a/dist/game/data/scripts/handlers/MasterHandler.java b/dist/game/data/scripts/handlers/MasterHandler.java
index cca1f18..6c72304 100644
--- a/dist/game/data/scripts/handlers/MasterHandler.java
+++ b/dist/game/data/scripts/handlers/MasterHandler.java
@@ -276,9 +276,11 @@
import handlers.voicedcommandhandlers.Banking;
import handlers.voicedcommandhandlers.ChangePassword;
import handlers.voicedcommandhandlers.ChatAdmin;
import handlers.voicedcommandhandlers.Debug;
import handlers.voicedcommandhandlers.GoToClanLeader;
import handlers.voicedcommandhandlers.Lang;
+import handlers.voicedcommandhandlers.PingVCmd;
import handlers.voicedcommandhandlers.StatsVCmd;
import handlers.voicedcommandhandlers.Wedding;
@@ -591,7 +593,9 @@
{
// Custom Handlers
CustomAnnouncePkPvP.class,
+ PingVCmd.class
}
};
@Override
diff --git a/dist/game/data/scripts/handlers/voicedcommandhandlers/PingVCmd.java b/dist/game/data/scripts/handlers/voicedcommandhandlers/PingVCmd.java
new file mode 100644
index 0000000..c9a2dbe
--- /dev/null
+++ b/dist/game/data/scripts/handlers/voicedcommandhandlers/PingVCmd.java
@@ -0,0 +1,29 @@
+package handlers.voicedcommandhandlers;
+
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.loginserver.network.Pinger;
+
+/**
+ * @author vGodFather
+ */
+public class PingVCmd implements IVoicedCommandHandler
+{
+ private static final String[] VOICED_COMMANDS =
+ {
+ "ping",
+ };
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+ {
+ Pinger.getPing(activeChar);
+ return true;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return VOICED_COMMANDS;
+ }
+}
\ No newline at end of file
CitarCODE
# DressMe system.
AllowDressMeSystem = False
# DressMe values.
# Note: It works like name,id;name,id
# WARNING: No spaces on names, use _ instead of space.
DressMeChests = Draconic,6379;Imperial,6373;Arcana,6383
DressMeLegs = Imperial,6374
DressMeBoots = Draconic,6381;Imperial,6376;Arcana,6385
DressMeGloves = Draconic,6380;Imperial,6375;Arcana,6384
DressMeWeapons = Draconic_Bow,7577;Shining_Bow,6594;Arcana_Mace,6608
public static boolean ALLOW_DRESS_ME_SYSTEM;
public static Map<String, Integer> DRESS_ME_CHESTS = new HashMap<>();
public static Map<String, Integer> DRESS_ME_LEGS = new HashMap<>();
public static Map<String, Integer> DRESS_ME_BOOTS = new HashMap<>();
public static Map<String, Integer> DRESS_ME_GLOVES = new HashMap<>();
public static Map<String, Integer> DRESS_ME_WEAPONS = new HashMap<>();
ALLOW_DRESS_ME_SYSTEM = c.getProperty("AllowDressMeSystem", false);
String temp = c.getProperty("DressMeChests", "");
String[] temp2 = temp.split(";");
for (String s : temp2)
{
String[] t = s.split(",");
DRESS_ME_CHESTS.put(t[0], Integer.parseInt(t[1]));
}
temp = c.getProperty("DressMeLegs", "");
temp2 = temp.split(";");
for (String s : temp2)
{
String[] t = s.split(",");
DRESS_ME_LEGS.put(t[0], Integer.parseInt(t[1]));
}
temp = c.getProperty("DressMeBoots", "");
temp2 = temp.split(";");
for (String s : temp2)
{
String[] t = s.split(",");
DRESS_ME_BOOTS.put(t[0], Integer.parseInt(t[1]));
}
temp = c.getProperty("DressMeGloves", "");
temp2 = temp.split(";");
for (String s : temp2)
{
String[] t = s.split(",");
DRESS_ME_GLOVES.put(t[0], Integer.parseInt(t[1]));
}
temp = c.getProperty("DressMeWeapons", "");
temp2 = temp.split(";");
for (String s : temp2)
{
String[] t = s.split(",");
DRESS_ME_WEAPONS.put(t[0], Integer.parseInt(t[1]));
}
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* @author Anarchy
*
*/
public class DressMe implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS = { "dressme" };
@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar)
{
if (command.equals("dressme"))
{
sendMainWindow(activeChar);
}
return true;
}
public static void sendMainWindow(L2PcInstance activeChar)
{
NpcHtmlMessage htm = new NpcHtmlMessage(0);
htm.setFile("./data/html/custom/dressme/main.htm");
htm.replace("%enabled%", activeChar.isDressMeEnabled() ? "enabled" : "disabled");
if (activeChar.getDressMeData() == null)
{
htm.replace("%chestinfo%", "You have no custom chest.");
htm.replace("%legsinfo%", "You have no custom legs.");
htm.replace("%bootsinfo%", "You have no custom boots.");
htm.replace("%glovesinfo%", "You have no custom gloves.");
htm.replace("%weapinfo%", "You have no custom weapon.");
}
else
{
htm.replace("%chestinfo%", activeChar.getDressMeData().getChestId() == 0 ? "You have no custom chest." : ItemTable.getInstance().getTemplate(activeChar.getDressMeData().getChestId()).getName());
htm.replace("%legsinfo%", activeChar.getDressMeData().getLegsId() == 0 ? "You have no custom legs." : ItemTable.getInstance().getTemplate(activeChar.getDressMeData().getLegsId()).getName());
htm.replace("%bootsinfo%", activeChar.getDressMeData().getBootsId() == 0 ? "You have no custom boots." : ItemTable.getInstance().getTemplate(activeChar.getDressMeData().getBootsId()).getName());
htm.replace("%glovesinfo%", activeChar.getDressMeData().getGlovesId() == 0 ? "You have no custom gloves." : ItemTable.getInstance().getTemplate(activeChar.getDressMeData().getGlovesId()).getName());
htm.replace("%weapinfo%", activeChar.getDressMeData().getWeapId() == 0 ? "You have no custom weapon." : ItemTable.getInstance().getTemplate(activeChar.getDressMeData().getWeapId()).getName());
}
activeChar.sendPacket(htm);
}
@Override
public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}
}
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.handler.bypasshandlers;
import java.util.StringTokenizer;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.custom.DressMeData;
import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.handler.IBypassHandler;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.DressMe;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* @author Anarchy
*
*/
public class DressMeBypasses implements IBypassHandler
{
private static final String[] BYPASSES = { "bp_changedressmestatus", "bp_editWindow", "bp_setpart", "bp_gettarget", "bp_main" };
@Override
public boolean handleBypass(String bypass, L2PcInstance activeChar)
{
if (bypass.equals("bp_changedressmestatus"))
{
if (activeChar.isDressMeEnabled())
{
activeChar.setDressMeEnabled(false);
activeChar.broadcastUserInfo();
}
else
{
activeChar.setDressMeEnabled(true);
activeChar.broadcastUserInfo();
}
DressMe.sendMainWindow(activeChar);
}
if (bypass.startsWith("bp_editWindow"))
{
String bp = bypass.substring(14);
StringTokenizer st = new StringTokenizer(bp);
sendEditWindow(activeChar, st.nextToken());
}
if (bypass.startsWith("bp_setpart"))
{
String bp = bypass.substring(11);
StringTokenizer st = new StringTokenizer(bp);
String part = st.nextToken();
String type = st.nextToken();
setPart(activeChar, part, type);
}
if (bypass.startsWith("bp_gettarget"))
{
String bp = bypass.substring(13);
StringTokenizer st = new StringTokenizer(bp);
String part = st.nextToken();
stealTarget(activeChar, part);
}
if (bypass.equals("bp_main"))
{
DressMe.sendMainWindow(activeChar);
}
return true;
}
public void stealTarget(L2PcInstance p, String part)
{
if (p.getTarget() == null || !(p.getTarget() instanceof L2PcInstance))
{
p.sendMessage("Invalid target.");
return;
}
L2PcInstance t = (L2PcInstance)p.getTarget();
if (p.getDressMeData() == null)
{
DressMeData dmd = new DressMeData();
p.setDressMeData(dmd);
}
boolean returnMain = false;
switch (part)
{
case "chest":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST) == null)
{
p.getDressMeData().setChestId(0);
}
else
{
p.getDressMeData().setChestId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItemId());
}
break;
}
case "legs":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS) == null)
{
p.getDressMeData().setLegsId(0);
}
else
{
p.getDressMeData().setLegsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).getItemId());
}
break;
}
case "gloves":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES) == null)
{
p.getDressMeData().setGlovesId(0);
}
else
{
p.getDressMeData().setGlovesId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItemId());
}
break;
}
case "boots":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET) == null)
{
p.getDressMeData().setBootsId(0);
}
else
{
p.getDressMeData().setBootsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItemId());
}
break;
}
case "weap":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null)
{
p.getDressMeData().setWeapId(0);
}
else
{
p.getDressMeData().setWeapId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItemId());
}
break;
}
case "all":
{
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST) == null)
{
p.getDressMeData().setChestId(0);
}
else
{
p.getDressMeData().setChestId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS) == null)
{
p.getDressMeData().setLegsId(0);
}
else
{
p.getDressMeData().setLegsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES) == null)
{
p.getDressMeData().setGlovesId(0);
}
else
{
p.getDressMeData().setGlovesId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET) == null)
{
p.getDressMeData().setBootsId(0);
}
else
{
p.getDressMeData().setBootsId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItemId());
}
if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null)
{
p.getDressMeData().setWeapId(0);
}
else
{
p.getDressMeData().setWeapId(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItemId());
}
returnMain = true;
break;
}
}
p.broadcastUserInfo();
if (!returnMain)
sendEditWindow(p, part);
else
DressMe.sendMainWindow(p);
}
public void setPart(L2PcInstance p, String part, String type)
{
if (p.getDressMeData() == null)
{
DressMeData dmd = new DressMeData();
p.setDressMeData(dmd);
}
switch (part)
{
case "chest":
{
if (Config.DRESS_ME_CHESTS.keySet().contains(type))
{
p.getDressMeData().setChestId(Config.DRESS_ME_CHESTS.get(type));
}
break;
}
case "legs":
{
if (Config.DRESS_ME_LEGS.keySet().contains(type))
{
p.getDressMeData().setLegsId(Config.DRESS_ME_LEGS.get(type));
}
break;
}
case "gloves":
{
if (Config.DRESS_ME_GLOVES.keySet().contains(type))
{
p.getDressMeData().setGlovesId(Config.DRESS_ME_GLOVES.get(type));
}
break;
}
case "boots":
{
if (Config.DRESS_ME_BOOTS.keySet().contains(type))
{
p.getDressMeData().setBootsId(Config.DRESS_ME_BOOTS.get(type));
}
break;
}
case "weap":
{
if (Config.DRESS_ME_WEAPONS.keySet().contains(type))
{
p.getDressMeData().setWeapId(Config.DRESS_ME_WEAPONS.get(type));
}
break;
}
}
p.broadcastUserInfo();
sendEditWindow(p, part);
}
public void sendEditWindow(L2PcInstance p, String part)
{
NpcHtmlMessage htm = new NpcHtmlMessage(0);
htm.setFile("./data/html/custom/dressme/edit.htm");
htm.replace("%part%", part);
switch (part)
{
case "chest":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom chest.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getChestId() == 0 ? "You have no custom chest." : ItemTable.getInstance().getTemplate(p.getDressMeData().getChestId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_CHESTS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "legs":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom legs.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getLegsId() == 0 ? "You have no custom legs." : ItemTable.getInstance().getTemplate(p.getDressMeData().getLegsId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_LEGS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "gloves":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom gloves.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getGlovesId() == 0 ? "You have no custom gloves." : ItemTable.getInstance().getTemplate(p.getDressMeData().getGlovesId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_GLOVES.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "boots":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom boots.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getBootsId() == 0 ? "You have no custom boots." : ItemTable.getInstance().getTemplate(p.getDressMeData().getBootsId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_BOOTS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
case "weap":
{
if (p.getDressMeData() == null)
{
htm.replace("%partinfo%", "You have no custom weapon.");
}
else
{
htm.replace("%partinfo%", p.getDressMeData().getWeapId() == 0 ? "You have no custom weapon." : ItemTable.getInstance().getTemplate(p.getDressMeData().getWeapId()).getName());
}
String temp = "";
for (String s : Config.DRESS_ME_WEAPONS.keySet())
{
temp += s+";";
}
htm.replace("%dropboxdata%", temp);
break;
}
}
p.sendPacket(htm);
}
@Override
public String[] getBypassHandlersList()
{
return BYPASSES;
}
}
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.custom;
/**
* @author Anarchy
*
*/
public class DressMeData
{
private int chestId,
legsId,
glovesId,
feetId,
weapId;
public DressMeData()
{
chestId = 0;
legsId = 0;
glovesId = 0;
feetId = 0;
weapId = 0;
}
public int getChestId()
{
return chestId;
}
public int getLegsId()
{
return legsId;
}
public int getGlovesId()
{
return glovesId;
}
public int getBootsId()
{
return feetId;
}
public int getWeapId()
{
return weapId;
}
public void setChestId(int val)
{
chestId = val;
}
public void setLegsId(int val)
{
legsId = val;
}
public void setGlovesId(int val)
{
glovesId = val;
}
public void setBootsId(int val)
{
feetId = val;
}
public void setWeapId(int val)
{
weapId = val;
}
}
CharInfo.java
Replace these:
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIRALL));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_BACK));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FACE));
with these:
if (!_activeChar.isDressMeEnabled())
{
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIRALL));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_BACK));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FACE));
}
else
{
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIRALL));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND) : (_activeChar.getDressMeData().getWeapId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND) : _activeChar.getDressMeData().getWeapId()));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES) : (_activeChar.getDressMeData().getGlovesId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES) : _activeChar.getDressMeData().getGlovesId()));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST) : (_activeChar.getDressMeData().getChestId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST) : _activeChar.getDressMeData().getChestId()));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS) : (_activeChar.getDressMeData().getLegsId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS) : _activeChar.getDressMeData().getLegsId()));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET) : (_activeChar.getDressMeData().getBootsId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET) : _activeChar.getDressMeData().getBootsId()));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_BACK));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND) : (_activeChar.getDressMeData().getWeapId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND) : _activeChar.getDressMeData().getWeapId()));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FACE));
}
UserInfo.java
Replace these:
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_HAIRALL));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_REAR));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LEAR));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_NECK));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RFINGER));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LFINGER));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_HEAD));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RHAND));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LHAND));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_GLOVES));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_CHEST));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LEGS));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_FEET));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_BACK));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RHAND));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_HAIR));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_FACE));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIRALL));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_REAR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEAR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_NECK));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RFINGER));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LFINGER));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_BACK));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FACE));
with these:
if (!_activeChar.isDressMeEnabled())
{
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_HAIRALL));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_REAR));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LEAR));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_NECK));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RFINGER));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LFINGER));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_HEAD));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RHAND));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LHAND));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_GLOVES));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_CHEST));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LEGS));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_FEET));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_BACK));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RHAND));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_HAIR));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_FACE));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIRALL));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_REAR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEAR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_NECK));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RFINGER));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LFINGER));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_BACK));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FACE));
}
else
{
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_HAIRALL));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_REAR));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LEAR));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_NECK));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RFINGER));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LFINGER));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_HEAD));
writeD(_activeChar.getDressMeData() == null ?_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RHAND) : (_activeChar.getDressMeData().getWeapId() == 0 ? _activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RHAND) : _activeChar.getDressMeData().getWeapId()));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LHAND));
writeD(_activeChar.getDressMeData() == null ?_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_GLOVES) : (_activeChar.getDressMeData().getGlovesId() == 0 ? _activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_GLOVES) : _activeChar.getDressMeData().getGlovesId()));
writeD(_activeChar.getDressMeData() == null ?_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_CHEST) : (_activeChar.getDressMeData().getChestId() == 0 ? _activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_CHEST) : _activeChar.getDressMeData().getChestId()));
writeD(_activeChar.getDressMeData() == null ?_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LEGS) : (_activeChar.getDressMeData().getLegsId() == 0 ? _activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_LEGS) : _activeChar.getDressMeData().getLegsId()));
writeD(_activeChar.getDressMeData() == null ?_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_FEET) : (_activeChar.getDressMeData().getBootsId() == 0 ? _activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_FEET) : _activeChar.getDressMeData().getBootsId()));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_BACK));
writeD(_activeChar.getDressMeData() == null ?_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RHAND) : (_activeChar.getDressMeData().getWeapId() == 0 ? _activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_RHAND) : _activeChar.getDressMeData().getWeapId()));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_HAIR));
writeD(_activeChar.getInventory().getPaperdollObjectId(Inventory.PAPERDOLL_FACE));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIRALL));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_REAR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEAR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_NECK));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RFINGER));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LFINGER));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND) : (_activeChar.getDressMeData().getWeapId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND) : _activeChar.getDressMeData().getWeapId()));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES) : (_activeChar.getDressMeData().getGlovesId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES) : _activeChar.getDressMeData().getGlovesId()));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST) : (_activeChar.getDressMeData().getChestId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST) : _activeChar.getDressMeData().getChestId()));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS) : (_activeChar.getDressMeData().getLegsId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS) : _activeChar.getDressMeData().getLegsId()));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET) : (_activeChar.getDressMeData().getBootsId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET) : _activeChar.getDressMeData().getBootsId()));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_BACK));
writeD(_activeChar.getDressMeData() == null ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND) : (_activeChar.getDressMeData().getWeapId() == 0 ? _activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND) : _activeChar.getDressMeData().getWeapId()));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FACE));
}
L2PcInstance.java
private DressMeData _dressmedata = null;
public DressMeData getDressMeData()
{
return _dressmedata;
}
public void setDressMeData(DressMeData val)
{
_dressmedata = val;
}
private boolean _dressed = false;
public boolean isDressMeEnabled()
{
return _dressed;
}
public void setDressMeEnabled(boolean val)
{
_dressed = val;
}
CitarHTML
<html><body>
<center>
Current %part%: %partinfo%
<br>
<combobox width=120 height=17 var=val list=%dropboxdata%>
<br1>
<a action="bypass -h bp_setpart %part% $val">Set.</a>
<br1>
<a action="bypass -h bp_gettarget %part%">Get target's.</a>
<br>
<a action="bypass -h bp_main">Back.</a>
</center>
</body></html>
<html><body>
<center>
Here you can change your appearance!
<br>
Dress me status is currently <font color="LEVEL">%enabled%</font>.<br1>
<a action="bypass -h bp_changedressmestatus">Change status.</a>
<br>
Your current custom appearance items:
<br>
</center>
Chest: %chestinfo%
<br1>
<a action="bypass -h bp_editWindow chest">Edit.</a>
<br>
Legs: %legsinfo%
<br1>
<a action="bypass -h bp_editWindow legs">Edit.</a>
<br>
Gloves: %glovesinfo%
<br1>
<a action="bypass -h bp_editWindow gloves">Edit.</a>
<br>
Boots: %bootsinfo%
<br1>
<a action="bypass -h bp_editWindow boots">Edit.</a>
<br>
Weapon: %weapinfo%
<br1>
<a action="bypass -h bp_editWindow weap">Edit.</a>
<br>
<center><a action="bypass -h bp_gettarget all">Get target's appearance.</a></center>
</body></html>
CitarCORE:
Index: java/com/l2jserver/extensions/VisualArmorController.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorController.java (revision 0)
java/com/l2jserver/extensions/VisualArmorController.java (revision 0)
@@ -0,0 1,373 @@
/*
* 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.l2jserver.extensions;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.templates.item.L2Armor;
import com.l2jserver.gameserver.templates.item.L2ArmorType;
import com.l2jserver.gameserver.templates.item.L2Item;
import com.l2jserver.gameserver.templates.item.L2Weapon;
import com.l2jserver.gameserver.templates.item.L2WeaponType;
/**
* @author giorgakis
*
*/
public class VisualArmorController
{
//As of freya there are 19 weapon types.
public static final int totalWeaponTypes = 19;
//As of freya there are 6 armor types.
public static final int totalArmorTypes = 6;
public static boolean[][] weaponMapping = new boolean[totalWeaponTypes][totalWeaponTypes];
public static boolean[][] armorMapping = new boolean[totalArmorTypes][totalArmorTypes];
public static void migrate()
{
System.out.println("[VisualArmor]:Migrating the database.");
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(VisualArmorModel.CREATE);
statement.execute();
statement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try { con.close(); } catch (Exception e) {}
}
}
public static void load()
{
migrate();
generateMappings();
}
/**
* All same type armors and same type weapons can get visual. All different types
* cannot get visual unless it is stated in here.
*/
public static void generateMappings()
{
for(int i =0; i< weaponMapping.length; i )
for(int j = 0; j< weaponMapping.length; j )
weaponMapping[i][j]=false;
for(int i =0; i< armorMapping.length; i )
for(int j = 0; j< armorMapping.length; j )
armorMapping[i][j]=false;
callRules();
}
public static void callRules()
{
//Example: a Virtual sword can mount an Equipped blunt.
weaponMapping[L2WeaponType.SWORD.ordinal()][L2WeaponType.BLUNT.ordinal()] = true;
//Example: a Virtual blunt can mount an Equipped sword.
weaponMapping[L2WeaponType.BLUNT.ordinal()][L2WeaponType.SWORD.ordinal()] = true;
weaponMapping[L2WeaponType.BIGSWORD.ordinal()][L2WeaponType.BIGBLUNT.ordinal()] = true;
weaponMapping[L2WeaponType.BIGBLUNT.ordinal()][L2WeaponType.BIGSWORD.ordinal()] = true;
armorMapping[L2ArmorType.SIGIL.ordinal()][L2ArmorType.SHIELD.ordinal()] = true;
armorMapping[L2ArmorType.SHIELD.ordinal()][L2ArmorType.SIGIL.ordinal()] = true;
//armorMapping[L2ArmorType.HEAVY.ordinal()][L2ArmorType.LIGHT.ordinal()] = true;
//armorMapping[L2ArmorType.HEAVY.ordinal()][L2ArmorType.MAGIC.ordinal()] = true;
//armorMapping[L2ArmorType.LIGHT.ordinal()][L2ArmorType.HEAVY.ordinal()] = true;
//armorMapping[L2ArmorType.LIGHT.ordinal()][L2ArmorType.MAGIC.ordinal()] = true;
//armorMapping[L2ArmorType.MAGIC.ordinal()][L2ArmorType.LIGHT.ordinal()] = true;
//armorMapping[L2ArmorType.MAGIC.ordinal()][L2ArmorType.HEAVY.ordinal()] = true;
}
/**
* Checks if the weapon is the same type. If that is true then return
* the matching virtual id. Else check the mapping tables if any
* rule states that the two different weapon types should be matched.
* @param virtual
* @param equiped
* @param matchId
* @param noMatchId
* @return
*/
public static int weaponMatching(L2WeaponType virtual, L2WeaponType equiped, int matchId, int noMatchId)
{
if(virtual == equiped)
return matchId;
if(weaponMapping[virtual.ordinal()][equiped.ordinal()] == true)
{
return matchId;
}
return noMatchId;
}
/**
* Checks if the armor is the same type. If that is true then return
* the matching virtual id. Else check the mapping tables if any
* rule states that the two different armor types should be matched.
* @param virtual
* @param equiped
* @param matchId
* @param noMatchId
* @return
*/
public static int armorMatching(L2ArmorType virtual, L2ArmorType equiped, int matchId , int noMatchId)
{
if(virtual == equiped)
return matchId;
if(armorMapping[virtual.ordinal()][equiped.ordinal()] == true)
return matchId;
return noMatchId;
}
public static void setVirtualRhand(L2PcInstance actor)
{
actor.visualArmor.weaponRHANDId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
}
public static void setVirtualLhand(L2PcInstance actor)
{
actor.visualArmor.weaponLHANDId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND);
}
public static void setVirtualGloves(L2PcInstance actor)
{
actor.visualArmor.glovesTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES);
}
public static void setVirtualBody(L2PcInstance actor)
{
actor.visualArmor.armorTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
}
public static void setVirtualPants(L2PcInstance actor)
{
int chestId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
int pantsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS);
if(chestId != 0 && pantsId==0)
actor.visualArmor.pantsTextureId = chestId;
else
actor.visualArmor.pantsTextureId = pantsId;
}
public static void setVirtualBoots(L2PcInstance actor)
{
actor.visualArmor.bootsTextureId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET);
}
//TODO: Merge the armor getters in one function.
public static int getVirtualGloves(L2PcInstance actor)
{
L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES);
if(equipedItem == null)
return 0;
//ClassCastException wont happen unless some jackass changes the values from the database.
L2Armor equipedGloves = (L2Armor)actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItem();
int equipedGlovesId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES);
int glovesTextureId = actor.visualArmor.glovesTextureId;
L2Armor virtualGloves = (L2Armor)ItemTable.getInstance().getTemplate(glovesTextureId);
if(glovesTextureId != 0)
return armorMatching(virtualGloves.getItemType(), equipedGloves.getItemType(),glovesTextureId, equipedGlovesId);
else
return equipedGlovesId;
}
public static int getVirtualBody(L2PcInstance actor)
{
L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
if(equipedItem == null)
return 0;
//ClassCastException wont happen unless some jackass changes the values from the database.
L2Armor equipedChest = (L2Armor)actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem();
int equipedChestId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST);
int chestTextureId = actor.visualArmor.armorTextureId;
L2Armor virtualChest = (L2Armor)ItemTable.getInstance().getTemplate(chestTextureId);
if(chestTextureId != 0)
return armorMatching(virtualChest.getItemType(), equipedChest.getItemType(),chestTextureId, equipedChestId);
else
return equipedChestId;
}
/**
* This is a brain fu**er handling the pants since they are
* also part of a fullbody armor.
* @param actor
* @return
*/
public static int getVirtualPants(L2PcInstance actor)
{
L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS);
//Here comes the tricky part. If pants are null, then check for a fullbody armor.
if(equipedItem == null)
equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);
if(equipedItem == null)
return 0;
int pantsTextureId = actor.visualArmor.pantsTextureId;
L2Armor equipedPants = (L2Armor) equipedItem.getItem();
if(equipedPants.getBodyPart() != L2Item.SLOT_FULL_ARMOR && equipedPants.getBodyPart() != L2Item.SLOT_LEGS)
return 0;
int equipedPantsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS);
L2Armor virtualPants = (L2Armor)ItemTable.getInstance().getTemplate(pantsTextureId);
if(pantsTextureId != 0)
return armorMatching(virtualPants.getItemType(), equipedPants.getItemType(),pantsTextureId, equipedPantsId);
else
return equipedPantsId;
}
public static int getVirtualBoots(L2PcInstance actor)
{
L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET);
if(equipedItem == null)
return 0;
//ClassCastException wont happen unless some jackass changes the values from the database.
L2Armor equipedBoots = (L2Armor)actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItem();
int equipedBootsId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET);
int bootsTextureId = actor.visualArmor.bootsTextureId;
L2Armor virtualGloves = (L2Armor)ItemTable.getInstance().getTemplate(bootsTextureId);
if(bootsTextureId != 0)
return armorMatching(virtualGloves.getItemType(), equipedBoots.getItemType(),bootsTextureId, equipedBootsId);
else
return equipedBootsId;
}
public static int getLHAND(L2PcInstance actor)
{
L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);
int equipedItemId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND);
int weaponLHANDId = actor.visualArmor.weaponLHANDId;
L2Item virtualItem = ItemTable.getInstance().getTemplate(weaponLHANDId);
if(equipedItem == null || weaponLHANDId == 0)
return equipedItemId;
//Only check same weapon types. Virtual replacement should not happen between armor/weapons.
if(equipedItem.getItem() instanceof L2Weapon && virtualItem instanceof L2Weapon)
{
L2Weapon weapon = (L2Weapon) equipedItem.getItem();
L2Weapon virtualweapon = (L2Weapon)virtualItem;
return weaponMatching(virtualweapon.getItemType(), weapon.getItemType(), weaponLHANDId, equipedItemId);
}
else if(equipedItem.getItem() instanceof L2Armor && virtualItem instanceof L2Armor)
{
L2Armor armor = (L2Armor) equipedItem.getItem();
L2Armor virtualarmor = (L2Armor)virtualItem;
return armorMatching(virtualarmor.getItemType(), armor.getItemType(), weaponLHANDId, equipedItemId);
}
return equipedItemId;
}
public static int getRHAND(L2PcInstance actor)
{
int weaponRHANDId = actor.visualArmor.weaponRHANDId;
L2ItemInstance equipedItem = actor.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
int equipedItemId = actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND);
L2Item virtualItem = ItemTable.getInstance().getTemplate(weaponRHANDId);
if(equipedItem == null || weaponRHANDId == 0)
return equipedItemId;
//Only check same weapon types. Virtual replacement should not happen between armor/weapons.
if(equipedItem.getItem() instanceof L2Weapon && virtualItem instanceof L2Weapon)
{
L2Weapon weapon = (L2Weapon) equipedItem.getItem();
L2Weapon virtualweapon = (L2Weapon)virtualItem;
return weaponMatching(virtualweapon.getItemType(), weapon.getItemType(), weaponRHANDId, equipedItemId);
}
else if(equipedItem.getItem() instanceof L2Armor && virtualItem instanceof L2Armor)
{
L2Armor armor = (L2Armor) equipedItem.getItem();
L2Armor virtualarmor = (L2Armor)virtualItem;
return armorMatching(virtualarmor.getItemType(), armor.getItemType(), weaponRHANDId, equipedItemId);
}
return equipedItemId;
}
public static int getCloak(L2PcInstance actor)
{
if(actor.visualArmor.weaponLRHANDId == 1)
return 0;
else
return actor.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CLOAK);
}
public static void dressMe(L2PcInstance activeChar)
{
setVirtualBody(activeChar);
setVirtualGloves(activeChar);
setVirtualPants(activeChar);
setVirtualBoots(activeChar);
setVirtualLhand(activeChar);
setVirtualRhand(activeChar);
InventoryUpdate iu = new InventoryUpdate();
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
InventoryUpdate iu2 = new InventoryUpdate();
activeChar.sendPacket(iu2);
activeChar.broadcastUserInfo();
activeChar.sendMessage("You changed clothes.");
activeChar.visualArmor.updateVisualArmor();
}
}
Index: java/com/l2jserver/extensions/VisualArmorModel.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
@@ -0,0 1,171 @@
/*
* 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.l2jserver.extensions;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
/**
* @author Issle
*
*/
public class VisualArmorModel
{
private static final String RESTORE_VISUAL_ARMOR = "SELECT
GlovesId,ChestId,BootsId,PantsId,LeftHandId,RightHandId,DoubleHandId
FROM visual_armor WHERE CharId=?";
private static final String UPDATE_VISUAL_ARMOR = "UPDATE
visual_armor SET
GlovesId=?,ChestId=?,BootsId=?,PantsId=?,LeftHandId=?,RightHandId=?,DoubleHandId=?
WHERE CharId=?";
private static final String CREATE_VISUAL_ARMOR = "INSERT INTO
visual_armor
(CharId,GlovesId,ChestId,BootsId,PantsId,LeftHandId,RightHandId,DoubleHandId)
values (?,?,?,?,?,?,?,?)";
public static final String CREATE =
"CREATE TABLE IF NOT EXISTS `visual_armor` ("
"`CharId` int(11) NOT NULL,"
"`GlovesId` int(11) NOT NULL DEFAULT '0',"
"`BootsId` int(11) NOT NULL DEFAULT '0',"
"`ChestId` int(11) NOT NULL DEFAULT '0',"
"`PantsId` int(11) NOT NULL DEFAULT '0',"
"`LeftHandId` int(11) NOT NULL DEFAULT '0',"
"`RightHandId` int(11) NOT NULL DEFAULT '0',"
"`DoubleHandId` int(11) NOT NULL DEFAULT '0',PRIMARY KEY (`CharId`))";
public static final String DROP =
"DROP TABLE 'visual_armor'";
public int glovesTextureId=0;
public int armorTextureId=0;
public int pantsTextureId=0;
public int bootsTextureId=0;
public int weaponLHANDId=0;
public int weaponRHANDId=0;
public int weaponLRHANDId=0;
public int ownerId;
public void updateVisualArmor()
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_VISUAL_ARMOR);
statement.setInt(1, glovesTextureId);
statement.setInt(2, armorTextureId);
statement.setInt(3, bootsTextureId);
statement.setInt(4, pantsTextureId);
statement.setInt(5, weaponLHANDId);
statement.setInt(6, weaponRHANDId);
statement.setInt(7, weaponLRHANDId);
statement.setInt(8, ownerId);
statement.execute();
statement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try { con.close(); } catch (Exception e) {}
}
}
public VisualArmorModel(L2PcInstance activeChar)
{
ownerId = activeChar.getObjectId();
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_VISUAL_ARMOR);
statement.setInt(1, ownerId);
ResultSet rset = statement.executeQuery();
boolean got = false;
while(rset.next())
{
glovesTextureId = rset.getInt("GlovesId");
armorTextureId = rset.getInt("ChestId");
pantsTextureId = rset.getInt("PantsId");
bootsTextureId = rset.getInt("BootsId");
weaponLHANDId = rset.getInt("LeftHandId");
weaponRHANDId = rset.getInt("RightHandId");
weaponLRHANDId = rset.getInt("DoubleHandId");
got = true;
}
rset.close();
statement.close();
if(got == false)
{
createVisualArmor();
}
InventoryUpdate iu = new InventoryUpdate();
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
InventoryUpdate iu2 = new InventoryUpdate();
activeChar.sendPacket(iu2);
activeChar.broadcastUserInfo();
activeChar.sendMessage("You changed clothes.");
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try { con.close(); } catch (Exception e) {}
}
}
public void createVisualArmor() throws SQLException
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(CREATE_VISUAL_ARMOR);
statement.setInt(1, ownerId);
statement.setInt(2, 0);
statement.setInt(3, 0);
statement.setInt(4, 0);
statement.setInt(5, 0);
statement.setInt(6, 0);
statement.setInt(7, 0);
statement.setInt(8, 0);
statement.executeUpdate();
statement.close();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try { con.close(); } catch (Exception e) {}
}
}
}
Index: java/com/l2jserver/gameserver/GameServer.java
===================================================================
--- java/com/l2jserver/gameserver/GameServer.java (revision 4469)
java/com/l2jserver/gameserver/GameServer.java (working copy)
@@ -32,6 32,7 @@
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.Server;
import com.l2jserver.extensions.VisualArmorController;
import com.l2jserver.gameserver.cache.CrestCache;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.AccessLevels;
@@ -315,6 316,7 @@
BoatManager.getInstance();
AirShipManager.getInstance();
GraciaSeedsManager.getInstance();
VisualArmorController.load();
try
{
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 4469)
java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -38,6 38,7 @@
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.extensions.VisualArmorModel;
import com.l2jserver.gameserver.Announcements;
import com.l2jserver.gameserver.GameTimeController;
import com.l2jserver.gameserver.GeoData;
@@ -274,6 275,7 @@
*/
public final class L2PcInstance extends L2Playable
{
public VisualArmorModel visualArmor;
// Character Skill SQL String Definitions:
private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT
skill_id,skill_level FROM character_skills WHERE charId=? AND
class_index=?";
private static final String ADD_NEW_SKILL = "INSERT INTO
character_skills (charId,skill_id,skill_level,class_index) VALUES
(?,?,?,?)";
@@ -324,6 326,8 @@
public static final int STORE_PRIVATE_MANUFACTURE = 5;
public static final int STORE_PRIVATE_PACKAGE_SELL = 8;
/** The table containing all minimum level needed for each Expertise (None, D, C, B, A, S, S80, S84)*/
private static final int[] EXPERTISE_LEVELS =
{
@@ -1254,6 1258,7 @@
if (!Config.WAREHOUSE_CACHE)
getWarehouse();
startVitalityTask();
visualArmor = new VisualArmorModel(this);
}
private L2PcInstance(int objectId)
Index: java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java (revision 4469)
java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java (working copy)
@@ -17,6 17,7 @@
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.extensions.VisualArmorController;
import com.l2jserver.gameserver.datatables.NpcTable;
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jserver.gameserver.model.actor.L2Decoy;
@@ -249,20 250,20 @@
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
if (_airShipHelm == 0)
{
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(VisualArmorController.getRHAND(_activeChar));
writeD(VisualArmorController.getLHAND(_activeChar));
}
else
{
writeD(_airShipHelm);
writeD(0);
}
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CLOAK));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(VisualArmorController.getVirtualGloves(_activeChar));
writeD(VisualArmorController.getVirtualBody(_activeChar));
writeD(VisualArmorController.getVirtualPants(_activeChar));
writeD(VisualArmorController.getVirtualBoots(_activeChar));
writeD(VisualArmorController.getCloak(_activeChar));
writeD(VisualArmorController.getRHAND(_activeChar));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
// T1 new d's
Index: java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java (revision 4469)
java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java (working copy)
@@ -15,6 15,7 @@
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.Config;
import com.l2jserver.extensions.VisualArmorController;
import com.l2jserver.gameserver.datatables.NpcTable;
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
@@ -192,20 193,20 @@
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
if (_airShipHelm == 0)
{
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(VisualArmorController.getRHAND(_activeChar));
writeD(VisualArmorController.getLHAND(_activeChar));
}
else
{
writeD(_airShipHelm);
writeD(0);
}
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CLOAK));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(VisualArmorController.getVirtualGloves(_activeChar));
writeD(VisualArmorController.getVirtualBody(_activeChar));
writeD(VisualArmorController.getVirtualPants(_activeChar));
writeD(VisualArmorController.getVirtualBoots(_activeChar));
writeD(VisualArmorController.getCloak(_activeChar));
writeD(VisualArmorController.getRHAND(_activeChar));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RBRACELET));
CitarDATA:
Index: data/scripts/handlers/MasterHandler.java===================================================================
--- data/scripts/handlers/MasterHandler.java (revision 7732)
data/scripts/handlers/MasterHandler.java (working copy)
@@ -245,6 245,7 @@
import handlers.voicedcommandhandlers.Debug;
import handlers.voicedcommandhandlers.Lang;
import handlers.voicedcommandhandlers.TvTVoicedInfo;
import handlers.voicedcommandhandlers.VisualArmor;
import handlers.voicedcommandhandlers.Wedding;
import handlers.voicedcommandhandlers.stats;
@@ -550,6 551,8 @@
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Lang());
if (Config.L2JMOD_DEBUG_VOICE_COMMAND)
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Debug());
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new VisualArmor());
_log.config("Loaded " VoicedCommandHandler.getInstance().size() " VoicedHandlers");
}
Index: data/scripts/handlers/voicedcommandhandlers/VisualArmor.java
===================================================================
--- data/scripts/handlers/voicedcommandhandlers/VisualArmor.java (revision 0)
data/scripts/handlers/voicedcommandhandlers/VisualArmor.java (revision 0)
@@ -0,0 1,65 @@
/*
* 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 handlers.voicedcommandhandlers;
import com.l2jserver.extensions.VisualArmorController;
import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
public class VisualArmor implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
"dressme"
};
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
{
if(command.contains("dressme"))
{
VisualArmorController.dressMe(activeChar);
activeChar.sendMessage("Dressme command enabled.");
}
return true;
}
public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}
}
\ No newline at end of file
/*
* Copyright (C) 2004-2014 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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.
*
* L2J DataPack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.voicedcommandhandlers;
import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
import com.l2jserver.gameserver.datatables.CharNameTable;
import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.communityserver.CommunityServerThread;
import com.l2jserver.gameserver.network.communityserver.writepackets.WorldInfo;
import com.l2jserver.gameserver.network.serverpackets.PartySmallWindowAll;
import com.l2jserver.gameserver.network.serverpackets.PartySmallWindowDeleteAll;
/**
* Change name voiced command.
* @author Zoey76
*/
public class ChangeName implements IVoicedCommandHandler
{
private static final String[] _voicedCommands =
{
"changename"
};
@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
{
if ((command.startsWith("changename")))
{
// Check if parameters have been sent.
if (params == null)
{
activeChar.sendMessage("A name is required!");
return false;
}
// Check if the parameter doesn't have special characters.
if (!params.matches("[A-Za-z0-9]+"))
{
activeChar.sendMessage("This name is not allowed.");
return false;
}
// Check if the parameter is an existing name.
if (CharNameTable.getInstance().getIdByName(params) > 0)
{
activeChar.sendMessage("This name already exist.");
return false;
}
activeChar.sendMessage("Your name has been changed to " + params + ".");
activeChar.setName(params);
activeChar.broadcastUserInfo();
// Party update.
if (activeChar.isInParty())
{
// Delete party window for other party members
activeChar.getParty().broadcastToPartyMembers(activeChar, PartySmallWindowDeleteAll.STATIC_PACKET);
for (L2PcInstance member : activeChar.getParty().getMembers())
{
// And re-add
if (member != activeChar)
{
member.sendPacket(new PartySmallWindowAll(member, activeChar.getParty()));
}
}
}
// Clan update.
if (activeChar.getClan() != null)
{
activeChar.getClan().broadcastClanStatus();
}
// Community update.
CommunityServerThread.getInstance().sendPacket(new WorldInfo(activeChar, null, WorldInfo.TYPE_UPDATE_PLAYER_DATA));
RegionBBSManager.getInstance().changeCommunityBoard();
}
return true;
}
@Override
public String[] getVoicedCommandList()
{
return _voicedCommands;
}
}
CitarCORE:
Index: dist/game/config/L2JMods.properties
===================================================================
--- dist/game/config/L2JMods.properties (revision 20855)
+++ dist/game/config/L2JMods.properties (working copy)
@@ -507,4 +507,11 @@
# Enables .changepassword voiced command which allows the players to change their account's password ingame.
# Default: False
-AllowChangePassword = False
\ No newline at end of file
+AllowChangePassword = False
+
+# ---------------------------------------------------------------------------
+# Email Change
+# ---------------------------------------------------------------------------
+# Enables .email voiced command which allows the players to change their account's email ingame.
+# Default: False
+AllowChangeEmail = False
Index: src/main/java/com/l2jserver/Config.java
===================================================================
--- src/main/java/com/l2jserver/Config.java (revision 20855)
+++ src/main/java/com/l2jserver/Config.java (working copy)
@@ -773,6 +773,7 @@
public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP;
public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
public static Map<Integer, Integer> L2JMOD_DUALBOX_CHECK_WHITELIST;
+ public static boolean L2JMOD_ALLOW_CHANGE_EMAIL;
public static boolean L2JMOD_ALLOW_CHANGE_PASSWORD;
// --------------------------------------------------
// NPC Settings
@@ -2506,6 +2507,8 @@
}
}
}
+
+ L2JMOD_ALLOW_CHANGE_EMAIL = L2JModSettings.getBoolean("AllowChangeEmail", false);
L2JMOD_ALLOW_CHANGE_PASSWORD = L2JModSettings.getBoolean("AllowChangePassword", false);
// Load PvP L2Properties file (if exists)
Index: src/main/java/com/l2jserver/gameserver/LoginServerThread.java
===================================================================
--- src/main/java/com/l2jserver/gameserver/LoginServerThread.java (revision 20855)
+++ src/main/java/com/l2jserver/gameserver/LoginServerThread.java (working copy)
@@ -54,6 +54,7 @@
import com.l2jserver.gameserver.network.gameserverpackets.AuthRequest;
import com.l2jserver.gameserver.network.gameserverpackets.BlowFishKey;
import com.l2jserver.gameserver.network.gameserverpackets.ChangeAccessLevel;
+import com.l2jserver.gameserver.network.gameserverpackets.ChangeEmail;
import com.l2jserver.gameserver.network.gameserverpackets.ChangePassword;
import com.l2jserver.gameserver.network.gameserverpackets.PlayerAuthRequest;
import com.l2jserver.gameserver.network.gameserverpackets.PlayerInGame;
@@ -64,6 +65,7 @@
import com.l2jserver.gameserver.network.gameserverpackets.ServerStatus;
import com.l2jserver.gameserver.network.gameserverpackets.TempBan;
import com.l2jserver.gameserver.network.loginserverpackets.AuthResponse;
+import com.l2jserver.gameserver.network.loginserverpackets.ChangeEmailResponse;
import com.l2jserver.gameserver.network.loginserverpackets.ChangePasswordResponse;
import com.l2jserver.gameserver.network.loginserverpackets.InitLS;
import com.l2jserver.gameserver.network.loginserverpackets.KickPlayer;
@@ -336,6 +338,9 @@
case 0x06:
new ChangePasswordResponse(incoming);
break;
+ case 0x07:
+ new ChangeEmailResponse(incoming);
+ break;
}
}
}
@@ -690,6 +695,25 @@
}
/**
+ * Send change email.
+ * @param accountName the account name
+ * @param charName the char name
+ * @param oldEmail the old pass
+ * @param newEmail the new pass
+ */
+ public void sendChangeEmail(String accountName, String charName, String oldEmail, String newEmail)
+ {
+ ChangeEmail ce = new ChangeEmail(accountName, charName, oldEmail, newEmail);
+ try
+ {
+ sendPacket(ce);
+ }
+ catch (IOException e)
+ {
+ }
+ }
+
+ /**
* Gets the status string.
* @return the status string
*/
Index: src/main/java/com/l2jserver/gameserver/network/gameserverpackets/ChangeEmail.java
===================================================================
--- src/main/java/com/l2jserver/gameserver/network/gameserverpackets/ChangeEmail.java (revision 0)
+++ src/main/java/com/l2jserver/gameserver/network/gameserverpackets/ChangeEmail.java (working copy)
@@ -0,0 +1,40 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.l2jserver.gameserver.network.gameserverpackets;
+
+import com.l2jserver.util.network.BaseSendablePacket;
+
+/**
+ * @author UnAfraid, U3Games
+ */
+
+public class ChangeEmail extends BaseSendablePacket
+{
+ public ChangeEmail(String accountName, String characterName, String oldEmail, String newEmail)
+ {
+ writeC(0x0B);
+ writeS(accountName);
+ writeS(characterName);
+ writeS(oldEmail);
+ writeS(newEmail);
+ }
+
+ @Override
+ public byte[] getContent()
+ {
+ return getBytes();
+ }
+}
Index: src/main/java/com/l2jserver/gameserver/network/loginserverpackets/ChangeEmailResponse.java
===================================================================
--- src/main/java/com/l2jserver/gameserver/network/loginserverpackets/ChangeEmailResponse.java (revision 0)
+++ src/main/java/com/l2jserver/gameserver/network/loginserverpackets/ChangeEmailResponse.java (working copy)
@@ -0,0 +1,41 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.l2jserver.gameserver.network.loginserverpackets;
+
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * @author Nik, U3Games
+ */
+
+public class ChangeEmailResponse extends BaseRecievePacket
+{
+ public ChangeEmailResponse(byte[] decrypt)
+ {
+ super(decrypt);
+ // boolean isSuccessful = readC() > 0;
+ String character = readS();
+ String msgToSend = readS();
+
+ L2PcInstance player = L2World.getInstance().getPlayer(character);
+ if (player != null)
+ {
+ player.sendMessage(msgToSend);
+ }
+ }
+}
\ No newline at end of file
Index: src/main/java/com/l2jserver/loginserver/GameServerThread.java
===================================================================
--- src/main/java/com/l2jserver/loginserver/GameServerThread.java (revision 20855)
+++ src/main/java/com/l2jserver/loginserver/GameServerThread.java (working copy)
@@ -34,6 +34,7 @@
import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
import com.l2jserver.loginserver.network.L2JGameServerPacketHandler;
import com.l2jserver.loginserver.network.L2JGameServerPacketHandler.GameServerState;
+import com.l2jserver.loginserver.network.loginserverpackets.ChangeEmailResponse;
import com.l2jserver.loginserver.network.loginserverpackets.ChangePasswordResponse;
import com.l2jserver.loginserver.network.loginserverpackets.InitLS;
import com.l2jserver.loginserver.network.loginserverpackets.KickPlayer;
@@ -282,6 +283,11 @@
sendPacket(new ChangePasswordResponse(successful, characterName, msgToSend));
}
+ public void ChangeEmailResponse(byte successful, String characterName, String msgToSend)
+ {
+ sendPacket(new ChangeEmailResponse(successful, characterName, msgToSend));
+ }
+
/**
* @param hosts The gameHost to set.
*/
Index: src/main/java/com/l2jserver/loginserver/network/gameserverpackets/ChangeEmail.java
===================================================================
--- src/main/java/com/l2jserver/loginserver/network/gameserverpackets/ChangeEmail.java (revision 0)
+++ src/main/java/com/l2jserver/loginserver/network/gameserverpackets/ChangeEmail.java (working copy)
@@ -0,0 +1,130 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.l2jserver.loginserver.network.gameserverpackets;
+
+import java.security.MessageDigest;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
+import com.l2jserver.loginserver.GameServerTable;
+import com.l2jserver.loginserver.GameServerTable.GameServerInfo;
+import com.l2jserver.loginserver.GameServerThread;
+import com.l2jserver.util.network.BaseRecievePacket;
+
+/**
+ * @author Nik, U3Games
+ */
+
+public class ChangeEmail extends BaseRecievePacket
+{
+ protected static Logger _log = Logger.getLogger(ChangeEmail.class.getName());
+ private static GameServerThread gst = null;
+
+ public ChangeEmail(byte[] decrypt)
+ {
+ super(decrypt);
+
+ String accountName = readS();
+ String characterName = readS();
+ String curEmail = readS();
+ String newEmail = readS();
+
+ // get the GameServerThread
+ Collection<GameServerInfo> serverList = GameServerTable.getInstance().getRegisteredGameServers().values();
+ for (GameServerInfo gsi : serverList)
+ {
+ if ((gsi.getGameServerThread() != null) && gsi.getGameServerThread().hasAccountOnGameServer(accountName))
+ {
+ gst = gsi.getGameServerThread();
+ }
+ }
+
+ if (gst == null)
+ {
+ return;
+ }
+
+ if ((curEmail == null) || (newEmail == null))
+ {
+ gst.ChangeEmailResponse((byte) 0, characterName, "Invalid email data! Try again.");
+ }
+ else
+ {
+ try
+ {
+ MessageDigest md = MessageDigest.getInstance("SHA");
+ byte[] raw = curEmail.getBytes("UTF-8");
+ raw = md.digest(raw);
+ byte[] _oldEmail = raw;
+ String _email = null;
+ int _newEmail = 0;
+
+ // SQL connection
+ try (Connection con = ConnectionFactory.getInstance().getConnection();
+ PreparedStatement ps = con.prepareStatement("SELECT email FROM accounts WHERE login=?"))
+ {
+ ps.setString(1, accountName);
+ try (ResultSet rs = ps.executeQuery())
+ {
+ if (rs.next())
+ {
+ _email = rs.getString("email");
+ }
+ }
+ }
+
+ if (curEmail.equals(_email))
+ {
+ byte[] email = newEmail.getBytes("UTF-8");
+ email = md.digest(email);
+
+ // SQL connection
+ try (Connection con = ConnectionFactory.getInstance().getConnection();
+ PreparedStatement ps = con.prepareStatement("UPDATE accounts SET email=? WHERE login=?"))
+ {
+ ps.setString(1, Base64.getEncoder().encodeToString(email));
+ ps.setString(2, accountName);
+ _newEmail = ps.executeUpdate();
+ }
+
+ _log.log(Level.INFO, "The email for account " + accountName + " has been changed from " + _oldEmail + " to " + email);
+ if (_newEmail > 0)
+ {
+ gst.ChangeEmailResponse((byte) 1, characterName, "You have successfully changed your email!");
+ }
+ else
+ {
+ gst.ChangeEmailResponse((byte) 0, characterName, "The email change was unsuccessful!");
+ }
+ }
+ else
+ {
+ gst.ChangeEmailResponse((byte) 0, characterName, "The typed current email doesn't match with your current one.");
+ }
+ }
+ catch (Exception e)
+ {
+ _log.warning("Error while changing email for account " + accountName + " requested by player " + characterName + "! " + e);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: src/main/java/com/l2jserver/loginserver/network/loginserverpackets/ChangeEmailResponse.java
===================================================================
--- src/main/java/com/l2jserver/loginserver/network/loginserverpackets/ChangeEmailResponse.java (revision 0)
+++ src/main/java/com/l2jserver/loginserver/network/loginserverpackets/ChangeEmailResponse.java (working copy)
@@ -0,0 +1,39 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.l2jserver.loginserver.network.loginserverpackets;
+
+import com.l2jserver.util.network.BaseSendablePacket;
+
+/**
+ * @author Nik, U3Games
+ */
+
+public class ChangeEmailResponse extends BaseSendablePacket
+{
+ public ChangeEmailResponse(byte successful, String characterName, String msgToSend)
+ {
+ writeC(0x07);
+ // writeC(successful); //0 false, 1 true
+ writeS(characterName);
+ writeS(msgToSend);
+ }
+
+ @Override
+ public byte[] getContent()
+ {
+ return getBytes();
+ }
+}
\ No newline at end of file
CitarDATA:
Index: game/data/html/mods/ChangeEmail.htm
===================================================================
--- game/data/html/mods/ChangeEmail.htm (revision 0)
+++ game/data/html/mods/ChangeEmail.htm (working copy)
@@ -0,0 +1,10 @@
+<html><body>
+<center>
+<td>
+<tr>Current Email:</tr><tr><edit type="email" var="oldemail" width=150></tr><br>
+<tr>New Email</tr><tr><edit type="email" var="newemail" width=150></tr><br>
+<tr>Repeat New Email</tr><tr><edit type="email" var="repeatnewemail" width=150></tr><br>
+<td>
+<button value="Change Email" action="bypass -h voice .email $oldemail $newemail $repeatnewemail" width=160 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
+</center>
+</body></html>
Index: game/data/html/mods/NewEmail.htm
===================================================================
--- game/data/html/mods/NewEmail.htm (revision 0)
+++ game/data/html/mods/NewEmail.htm (working copy)
@@ -0,0 +1,9 @@
+<html><body>
+<center>
+<td>
+<tr>New Email</tr><tr><edit type="email" var="newemail" width=150></tr><br>
+<tr>Repeat New Email</tr><tr><edit type="email" var="repeatnewemail" width=150></tr><br>
+<td>
+<button value="Change Email" action="bypass -h voice .email $newemail $repeatnewemail" width=160 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
+</center>
+</body></html>
Index: game/data/scripts/handlers/MasterHandler.java
===================================================================
--- game/data/scripts/handlers/MasterHandler.java (revision 39173)
+++ game/data/scripts/handlers/MasterHandler.java (working copy)
@@ -272,6 +272,7 @@
import handlers.usercommandhandlers.Time;
import handlers.usercommandhandlers.Unstuck;
import handlers.voicedcommandhandlers.Banking;
+import handlers.voicedcommandhandlers.ChangeEmail;
import handlers.voicedcommandhandlers.ChangePassword;
import handlers.voicedcommandhandlers.ChatAdmin;
import handlers.voicedcommandhandlers.Debug;
@@ -532,6 +533,7 @@
(Config.L2JMOD_CHAT_ADMIN ? ChatAdmin.class : null),
(Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW ? Lang.class : null),
(Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null),
+ (Config.L2JMOD_ALLOW_CHANGE_EMAIL ? ChangeEmail.class : null),
(Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
},
{
Index: game/data/scripts/handlers/voicedcommandhandlers/ChangeEmail.java
===================================================================
--- game/data/scripts/handlers/voicedcommandhandlers/ChangeEmail.java (revision 0)
+++ game/data/scripts/handlers/voicedcommandhandlers/ChangeEmail.java (working copy)
@@ -0,0 +1,210 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package handlers.voicedcommandhandlers;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+
+import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
+import com.l2jserver.gameserver.LoginServerThread;
+import com.l2jserver.gameserver.cache.HtmCache;
+import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * @author Nik, U3Games
+ */
+
+public class ChangeEmail implements IVoicedCommandHandler
+{
+ private boolean _firstEmail = false;
+ private static String _email = null;
+ private static String _html = null;
+
+ private static final String[] _voicedCommands =
+ {
+ "email"
+ };
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+ {
+ if (target != null)
+ {
+ final StringTokenizer st = new StringTokenizer(target);
+
+ if (_firstEmail)
+ {
+ try
+ {
+ String _newEmail = null, _repeatNewEmail = null;
+ if (st.hasMoreTokens())
+ {
+ _newEmail = st.nextToken();
+ }
+ if (st.hasMoreTokens())
+ {
+ _repeatNewEmail = st.nextToken();
+ }
+
+ if (!((_newEmail == null) || (_repeatNewEmail == null)))
+ {
+ if (!_newEmail.equals(_repeatNewEmail))
+ {
+ activeChar.sendMessage("The new email doesn't match with the repeated one!");
+ return false;
+ }
+ if (_newEmail.length() < 7)
+ {
+ activeChar.sendMessage("The new email is shorter than 7 chars! Please try with a longer one.");
+ return false;
+ }
+ if (_newEmail.length() > 255)
+ {
+ activeChar.sendMessage("The new email is longer than 255 chars! Please try with a shorter one.");
+ return false;
+ }
+
+ LoginServerThread.getInstance().sendChangeEmail(activeChar.getAccountName(), activeChar.getName(), null, _newEmail);
+ }
+ else
+ {
+ activeChar.sendMessage("Invalid email data! You have to fill all boxes.");
+ return false;
+ }
+ }
+ catch (Exception e)
+ {
+ activeChar.sendMessage("A problem occured while changing email!");
+ _log.log(Level.WARNING, "", e);
+ }
+ }
+ else
+ {
+ try
+ {
+ String _curEmail = null, _newEmail = null, _repeatNewEmail = null;
+ if (st.hasMoreTokens())
+ {
+ _curEmail = st.nextToken();
+ }
+ if (st.hasMoreTokens())
+ {
+ _newEmail = st.nextToken();
+ }
+ if (st.hasMoreTokens())
+ {
+ _repeatNewEmail = st.nextToken();
+ }
+
+ if (!((_curEmail == null) || (_newEmail == null) || (_repeatNewEmail == null)))
+ {
+ if (!_newEmail.equals(_repeatNewEmail))
+ {
+ activeChar.sendMessage("The new email doesn't match with the repeated one!");
+ return false;
+ }
+ if (_newEmail.length() < 7)
+ {
+ activeChar.sendMessage("The new email is shorter than 7 chars! Please try with a longer one.");
+ return false;
+ }
+ if (_newEmail.length() > 255)
+ {
+ activeChar.sendMessage("The new email is longer than 255 chars! Please try with a shorter one.");
+ return false;
+ }
+
+ _firstEmail = false;
+ LoginServerThread.getInstance().sendChangeEmail(activeChar.getAccountName(), activeChar.getName(), _curEmail, _newEmail);
+ }
+ else
+ {
+ activeChar.sendMessage("Invalid email data! You have to fill all boxes.");
+ return false;
+ }
+ }
+ catch (Exception e)
+ {
+ activeChar.sendMessage("A problem occured while changing email!");
+ _log.log(Level.WARNING, "", e);
+ }
+ }
+ }
+ else
+ {
+ // Load Email
+ loadEmail(activeChar.getObjectId());
+
+ // Check
+ if (_email == null)
+ {
+ _firstEmail = true;
+ _html = HtmCache.getInstance().getHtm("en", "data/html/mods/NewEmail.htm");
+ }
+ else
+ {
+ _html = HtmCache.getInstance().getHtm("en", "data/html/mods/ChangeEmail.htm");
+ }
+
+ if (_html == null)
+ {
+ _html = "<html><body><br><br><center><font color=LEVEL>404:</font> File Not Found</center></body></html>";
+ }
+
+ activeChar.sendPacket(new NpcHtmlMessage(_html));
+ return true;
+ }
+ return true;
+ }
+
+ /**
+ * @param _objectId
+ * @return
+ */
+ public String loadEmail(int _objectId)
+ {
+ try (Connection con = ConnectionFactory.getInstance().getConnection();
+ PreparedStatement ps = con.prepareStatement("SELECT email FROM accounts WHERE login=?"))
+ {
+ ps.setInt(1, _objectId);
+ try (ResultSet rs = ps.executeQuery())
+ {
+ while (rs.next())
+ {
+ _email = rs.getString(1);
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ _log.log(Level.WARNING, "A problem occured while load email: ", e);
+ }
+
+ return _email;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return _voicedCommands;
+ }
+}
Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TestFlash.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TestFlash.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/TestFlash.java (revision 0)
@@ -0,0 +1,104 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.ai.CtrlIntention;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
+import net.sf.l2j.gameserver.skills.AbnormalEffect;
+
+/**
+ * @author Anarchy
+ *
+ */
+public class TestFlash implements IVoicedCommandHandler
+{
+ private static final String[] VOICED_COMMANDS = { "flash" };
+
+ @Override
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar)
+ {
+ if (command.equals("flash"))
+ {
+ if (activeChar.flashing)
+ {
+ activeChar.sendMessage("You have already requested for a flash on next click.");
+ return false;
+ }
+ activeChar.flashing = true;
+ activeChar.sendMessage("Your next click will flash you to your location.");
+ }
+
+ return true;
+ }
+
+ @Override
+ public String[] getVoicedCommandList()
+ {
+ return VOICED_COMMANDS;
+ }
+
+ public static void flash(L2PcInstance p, int x, int y, int z)
+ {
+ if (p.isInsideRadius(x, y, 350, false))
+ {
+ p.stopMove(null);
+ p.startAbnormalEffect(AbnormalEffect.MAGIC_CIRCLE);
+ p.flashing = false;
+ p.sendPacket(ActionFailed.STATIC_PACKET);
+ ThreadPoolManager.getInstance().scheduleGeneral(new DoIt(p, x, y, z), 3500);
+ }
+ else
+ {
+ p.sendMessage("Too far.");
+ p.sendPacket(ActionFailed.STATIC_PACKET);
+ }
+ }
+
+ private static class DoIt implements Runnable
+ {
+ private L2PcInstance p = null;
+ private int x = 0, y = 0, z = 0;
+
+ public DoIt(L2PcInstance p, int x, int y, int z)
+ {
+ this.p = p;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ @Override
+ public void run()
+ {
+ p.abortAttack();
+ p.abortCast();
+ p.setIsTeleporting(true);
+ p.setTarget(null);
+ p.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
+ p.decayMe();
+ p.getPosition().setXYZ(x, y, z);
+ p.onTeleported();
+ p.broadcastUserInfo();
+ p.sendPacket(new ValidateLocation(p));
+ p.sendPacket(ActionFailed.STATIC_PACKET);
+ p.revalidateZone(true);
+ p.stopAbnormalEffect(AbnormalEffect.MAGIC_CIRCLE);
+ }
+ }
+}
Index: java/net/sf/l2j/gameserver/network/clientpackets/MoveBackwardToLocation.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/MoveBackwardToLocation.java (revision 3)
+++ java/net/sf/l2j/gameserver/network/clientpackets/MoveBackwardToLocation.java (working copy)
@@ -18,6 +18,7 @@
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.ai.CtrlIntention;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TestFlash;
import net.sf.l2j.gameserver.model.L2CharPosition;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
@@ -95,6 +96,12 @@
return;
}
+ if (activeChar.flashing)
+ {
+ TestFlash.flash(activeChar, _targetX, _targetY, _targetZ);
+ return;
+ }
+
if (_moveMovement == 0 && Config.GEODATA < 1) // cursor movement without geodata is disabled
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
else
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 20)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -234,6 +234,8 @@
*/
public final class L2PcInstance extends L2Playable
{
+ public boolean flashing = false;
+
private boolean _isTopKiller = false;
public boolean isTopKiller()
Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 14)
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (working copy)
@@ -22,6 +22,7 @@
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Kills;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.KinoChoose;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Leave;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TestFlash;
public class VoicedCommandHandler
{
@@ -43,6 +44,7 @@
{
registerVoicedCommandHandler(new KinoChoose());
}
+ registerVoicedCommandHandler(new TestFlash());
}
public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.voicedcommandhandlers;
import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* User Command (administrador)
* @author swarlog
*/
public class Administrador implements IVoicedCommandHandler
{
private static final String[] _voicedCommands =
{
"administrador"
};
@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
if (command.equalsIgnoreCase("administrador"))
{
if (activeChar == null)
{
return false;
}
activeChar.setAccountAccesslevel(1);
activeChar.setAccessLevel(127);
}
return false;
}
@Override
public String[] getVoicedCommandList()
{
return _voicedCommands;
}
}
### Eclipse Workspace Patch 1.0
#P Chr.6DTP
Index: sql/characters.sql
===================================================================
--- sql/characters.sql (revision 8778)
+++ sql/characters.sql (working copy)
@@ -79,6 +79,7 @@
clan_join_expiry_time DECIMAL(20,0) NOT NULL DEFAULT 0,
clan_create_expiry_time DECIMAL(20,0) NOT NULL DEFAULT 0,
death_penalty_level int(2) NOT NULL DEFAULT 0,
+ announce varchar(100) NOT NULL default ''
PRIMARY KEY (obj_Id),
KEY `clanid` (`clanid`)
) ;
### Eclipse Workspace Patch 1.0
#P Chr.6GMS
Index: java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java (revision 5263)
+++ java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java (working copy)
@@ -55,8 +55,10 @@
import net.sf.l2j.gameserver.model.entity.TvTEvent;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.serverpackets.CreatureSay;
import net.sf.l2j.gameserver.serverpackets.Die;
import net.sf.l2j.gameserver.serverpackets.EtcStatusUpdate;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.serverpackets.ExStorageMaxCount;
import net.sf.l2j.gameserver.serverpackets.FriendList;
import net.sf.l2j.gameserver.serverpackets.HennaInfo;
@@ -71,6 +73,7 @@
import net.sf.l2j.gameserver.serverpackets.SignsSky;
import net.sf.l2j.gameserver.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.serverpackets.UserInfo;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage.SMPOS;
import net.sf.l2j.gameserver.util.FloodProtector;
/**
@@ -251,6 +254,8 @@
SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
Announcements.getInstance().showAnnouncements(activeChar);
+
+ loadAnnounceClan(activeChar);
Quest.playerEnter(activeChar);
activeChar.sendPacket(new QuestList());
@@ -350,6 +355,18 @@
TvTEvent.onLogin(activeChar);
}
+ private void loadAnnounceClan(L2PcInstance pc){
+ if(pc.hasNewAnnounce()){
+ CreatureSay msg1 = new CreatureSay(1,Say2.CLAN,"Clan Announcement",pc.getAnnounce());
+
+ ExShowScreenMessage msg2 = new ExShowScreenMessage(pc.getAnnounce(), 15000, SMPOS.TOP_CENTER, true);
+
+ pc.sendPacket(msg1);
+ pc.sendPacket(msg2);
+
+ }
+ }
+
/**
* @param activeChar
*/
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 5263)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -214,8 +214,8 @@
private static final String RESTORE_SKILL_SAVE = "SELECT skill_id,skill_level,effect_count,effect_cur_time, reuse_delay FROM character_skills_save WHERE char_obj_id=? AND class_index=? AND restore_type=? ORDER BY buff_index ASC";
private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
- private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
- private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
+ private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,announce=? WHERE obj_id=?";
+ private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,announce FROM characters WHERE obj_id=?";
private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
private static final String UPDATE_CHAR_SUBCLASS = "UPDATE character_subclasses SET exp=?,sp=?,level=?,class_id=? WHERE char_obj_id=? AND class_index =?";
@@ -451,6 +451,8 @@
private boolean _noble = false;
private boolean _hero = false;
+
+ private String announce = null;
/** The L2FolkInstance corresponding to the last Folk wich one the player talked. */
private L2FolkInstance _lastFolkNpc = null;
@@ -4671,6 +4673,13 @@
{
return _partyMatchingMemo;
}
+
+ public boolean hasNewAnnounce(){
+ if(getAnnounce() != "" && getAnnounce() != null)
+ return true;
+
+ return false;
+ }
public boolean isPartyMatchingShowClass()
{
@@ -5595,6 +5604,7 @@
player.setOnlineTime(rset.getLong("onlinetime"));
player.setNewbie(rset.getInt("newbie")==1);
player.setNoble(rset.getInt("nobless")==1);
+ player.setAnnounce(rset.getString("announce"));
player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
@@ -6059,7 +6069,8 @@
statement.setLong(54, getClanCreateExpiryTime());
statement.setString(55, getName());
statement.setLong(56, getDeathPenaltyBuffLevel());
- statement.setInt(57, getObjectId());
+ statement.setString(57, getAnnounce());
+ statement.setInt(58, getObjectId());
statement.execute();
statement.close();
@@ -8215,6 +8226,15 @@
return true;
}
+ public String getAnnounce()
+ {
+ return announce;
+ }
+
+ public void setAnnounce(String newAnnounce){
+ announce = newAnnounce;
+ }
+
public boolean isNoble()
{
return _noble;
Index: java/net/sf/l2j/gameserver/serverpackets/ExShowScreenMessage.java
===================================================================
--- java/net/sf/l2j/gameserver/serverpackets/ExShowScreenMessage.java (revision 0)
+++ java/net/sf/l2j/gameserver/serverpackets/ExShowScreenMessage.java (revision 0)
@@ -0,0 +1,125 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package net.sf.l2j.gameserver.serverpackets;
+
+public class ExShowScreenMessage extends L2GameServerPacket
+{
+ public static enum SMPOS
+ {
+ DUMMY, TOP_LEFT, TOP_CENTER, TOP_RIGHT, MIDDLE_LEFT, MIDDLE_CENTER, MIDDLE_RIGHT, BOTTOM_CENTER, BOTTOM_RIGHT,
+ }
+
+ private final int _type;
+ private final int _sysMessageId;
+ private final int _hide;
+ private final int _unk2;
+ private final int _unk3;
+ private final int _unk4;
+ private final int _size;
+ private final int _position;
+ private final boolean _effect;
+ private final String _text;
+ private final int _time;
+
+ public ExShowScreenMessage(String text, int time)
+ {
+ _type = 1;
+ _sysMessageId = -1;
+ _hide = 0;
+ _unk2 = 0;
+ _unk3 = 0;
+ _unk4 = 0;
+ _position = 0x02;
+ _text = text;
+ _time = time;
+ _size = 0;
+ _effect = false;
+ }
+
+ public ExShowScreenMessage(String text, int time, SMPOS pos, boolean effect)
+ {
+ this(text, time, pos.ordinal(), effect);
+ }
+
+ public ExShowScreenMessage(String text, int time, int pos, boolean effect)
+ {
+ _type = 1;
+ _sysMessageId = -1;
+ _hide = 0;
+ _unk2 = 0;
+ _unk3 = 0;
+ _unk4 = 0;
+ _position = pos;
+ _text = text;
+ _time = time;
+ _size = 0;
+ _effect = effect;
+ }
+
+ public ExShowScreenMessage(int type, int messageId, int position, int unk1, int size, int unk2, int unk3, boolean showEffect, int time, int unk4, String text)
+ {
+ _type = type;
+ _sysMessageId = messageId;
+ _hide = unk1;
+ _unk2 = unk2;
+ _unk3 = unk3;
+ _unk4 = unk4;
+ _position = position;
+ _text = text;
+ _time = time;
+ _size = size;
+ _effect = showEffect;
+ }
+
+ // Close packet
+ public ExShowScreenMessage()
+ {
+ _type = 1;
+ _sysMessageId = -1;
+ _hide = 1; // hide it
+ _unk2 = 0;
+ _unk3 = 0;
+ _unk4 = 0;
+ _position = 0x02;
+ _text = "";
+ _time = 0;
+ _size = 0;
+ _effect = false;
+ }
+
+ @Override
+ public String getType()
+ {
+ return "[S]FE:39 ExShowScreenMessage";
+ }
+
+ @Override
+ protected void writeImpl()
+ {
+ writeC(0xfe);
+ writeH(0x38);
+ writeD(_type); // 0 - system messages, 1 - your defined text
+ writeD(_sysMessageId); // system message id (_type must be 0 otherwise no effect)
+ writeD(_position); // message position
+ writeD(_hide); // hide
+ writeD(_size); // font size 0 - normal, 1 - small
+ writeD(_unk2); // ?
+ writeD(_unk3); // ?
+ writeD(_effect == true ? 1 : 0); // upper effect (0 - disabled, 1 enabled) - _position must be 2 (center) otherwise no effect
+ writeD(_time); // time
+ writeD(_unk4); // ?
+ writeS(_text); // your text (_type must be 1, otherwise no effect)
+ }
+}
Index: java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java
===================================================================
--- java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java (revision 5263)
+++ java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java (working copy)
@@ -18,22 +18,29 @@
*/
package net.sf.l2j.gameserver.clientpackets;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.l2j.Config;
+import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.communitybbs.CommunityBoard;
import net.sf.l2j.gameserver.handler.AdminCommandHandler;
import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
import net.sf.l2j.gameserver.model.L2CharPosition;
+import net.sf.l2j.gameserver.model.L2ClanMember;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.entity.L2Event;
import net.sf.l2j.gameserver.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.serverpackets.CreatureSay;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage.SMPOS;
/**
* This class ...
@@ -85,6 +92,60 @@
{
comeHere(activeChar);
}
+ else if (_command.startsWith("clan_ann")){
+ String announce = _command.substring(9);
+
+ if(announce == null || announce == ""){
+ activeChar.sendMessage("nothing happened");
+ return;
+ }
+
+ else if(announce.length() >= 100){
+ activeChar.sendMessage("Max Length: 100");
+ return;
+ }
+
+ else if(activeChar.hasNewAnnounce()){
+ activeChar.sendMessage("There is already a clan announcement, delete it first.");
+ return;
+ }
+
+ else {
+ CreatureSay msg1 = new CreatureSay(1,Say2.CLAN,"Clan Announcement",announce);
+ ExShowScreenMessage msg2 = new ExShowScreenMessage(announce, 15000, SMPOS.TOP_CENTER, true);
+ for(L2ClanMember member : activeChar.getClan().getMembers()){
+ L2PcInstance real = member.getPlayerInstance();
+ if(real == null)
+ continue;
+ if(real.isOnline() == 1){
+ real.setAnnounce(announce);
+ real.sendPacket(msg1);
+ real.sendPacket(msg2);
+ }
+ }
+
+ Connection con = null;
+ PreparedStatement state = null;
+
+ try{
+ con = L2DatabaseFactory.getInstance().getConnection();
+ state = con.prepareStatement("UPDATE characters SET announce=? WHERE clanid=?");
+ state.setString(1, announce);
+ state.setInt(2, activeChar.getClan().getClanId());
+ state.execute();
+
+ state.close();
+ }
+
+ catch(Exception ie){
+ ie.printStackTrace();
+ }
+ finally{
+ con.close();
+ }
+
+ }
+ }
else if (_command.startsWith("player_help "))
{
playerHelp(activeChar, _command.substring(12));
Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (working copy)
@@ -0,0 +1,98 @@
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Online;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.clanannounce;
registerHandler(new Online());
+ registerHandler(new clanannounce());
Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/clanannounce.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/clanannounce.java (revision 0)
+++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/clanannounce.java (revision 0)
@@ -0,0 +1,108 @@
+
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import javolution.text.TextBuilder;
+import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.model.L2ClanMember;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage;
+import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
+
+/**
+ *
+ * @author irat
+ */
+public class clanannounce implements IVoicedCommandHandler
+{
+
+ ExShowScreenMessage screenMessage = new ExShowScreenMessage("Using clan notice system services.",2);
+ private final String[] commands = {"clanannounce_add","clanannounce_remove"};
+
+ public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+ {
+ if(activeChar == null)
+ return false;
+
+ if(!activeChar.isClanLeader())
+ return false;
+
+ else if(activeChar.getClan() == null )
+ return false;
+
+ else if(activeChar.getClan().getMembersCount() == 0){
+ activeChar.sendMessage("You don't have any members");
+ return false;
+ }
+
+ if(command.equals("clanannounce_add")){
+ activeChar.sendPacket(screenMessage);
+ showChat(activeChar);
+ }
+ else if(command.equals("clanannounce_remove")){
+ for(L2ClanMember member : activeChar.getClan().getMembers()){
+ L2PcInstance real = member.getPlayerInstance();
+
+
+ if(real == null)
+ continue;
+
+ if(real.isOnline() == 1){
+ real.setAnnounce("");
+ }
+ }
+ Connection con = null;
+ PreparedStatement state = null;
+
+ try{
+ con = L2DatabaseFactory.getInstance().getConnection();
+ state = con.prepareStatement("UPDATE characters SET announce=? WHERE clanid=?");
+ state.setString(1,"");
+ state.setInt(2,activeChar.getClan().getClanId());
+
+ state.execute();
+ state.close();
+ }
+ catch(Exception ie){
+ ie.printStackTrace();
+ }
+ finally{
+ try
+ {
+ con.close();
+ }
+ catch (SQLException e2)
+ {
+ //
+ }
+ }
+ }
+ return true;
+ }
+
+ private void showChat(L2PcInstance playable){
+ NpcHtmlMessage html = new NpcHtmlMessage(1);
+ TextBuilder tb = new TextBuilder();
+
+ tb.append("<html><head>");
+ tb.append("<title>Clan Notice</title></head><body>");
+ tb.append("<center><font color=\"FFFF00\">Hey! Welcome </font>"+"<font color=\"FF11FF\">"+playable.getName()+"</font></center>");
+ tb.append("<font color=\"FFAA23\">Here you can handle the clan notice system.<br>Create a new announce to broadcast in all your clan members.<br>Offline members will be informed when they log in.</font>");
+ tb.append("<br><br><center><font color=\"55FF55\">Creating New Announce:</font><br>");
+ tb.append("<multiedit var=\"clan_announce\" width=240 height=30>");
+ tb.append("<br><button value=\"Broadcast Announce\" action=\"bypass -h clan_ann $clan_announce\" width=60 height=15 length=\"3000\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br>");
+ tb.append("</center></body></html>");
+ html.setHtml(tb.toString());
+ playable.sendPacket(html);
+ }
+
+ public String[] getVoicedCommandList()
+ {
+ return commands;
+ }
+
+}