Store auto use of shortcuts.
This commit is contained in:
@@ -38,7 +38,9 @@ import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
|||||||
public class ShortCuts implements IRestorable
|
public class ShortCuts implements IRestorable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
||||||
private static final int MAX_SHORTCUTS_PER_BAR = 12;
|
|
||||||
|
public static final int MAX_SHORTCUTS_PER_BAR = 12;
|
||||||
|
|
||||||
private final PlayerInstance _owner;
|
private final PlayerInstance _owner;
|
||||||
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public class Shortcut
|
|||||||
private final int _characterType;
|
private final int _characterType;
|
||||||
/** Shared reuse group. */
|
/** Shared reuse group. */
|
||||||
private int _sharedReuseGroup = -1;
|
private int _sharedReuseGroup = -1;
|
||||||
|
/** Auto use enabled. */
|
||||||
|
private boolean _autoUse = false;
|
||||||
|
|
||||||
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
||||||
{
|
{
|
||||||
@@ -132,4 +134,22 @@ public class Shortcut
|
|||||||
{
|
{
|
||||||
_sharedReuseGroup = sharedReuseGroup;
|
_sharedReuseGroup = sharedReuseGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets is shortcut is auto use enabled.
|
||||||
|
* @return if shortcut is auto use enabled.
|
||||||
|
*/
|
||||||
|
public boolean isAutoUse()
|
||||||
|
{
|
||||||
|
return _autoUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the auto use status.
|
||||||
|
* @param value of shortcut auto use status.
|
||||||
|
*/
|
||||||
|
public void setAutoUse(boolean value)
|
||||||
|
{
|
||||||
|
_autoUse = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+142
-11
@@ -14298,36 +14298,167 @@ public class PlayerInstance extends Playable
|
|||||||
return _autoUseSettings;
|
return _autoUseSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreVisualAutoUse()
|
public void restoreAutoShortcutVisual()
|
||||||
{
|
{
|
||||||
if (_autoUseSettings.isEmpty())
|
if (_autoUseSettings.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut shortcut;
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
for (int i = 0; i < 12; i++)
|
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(i, 22);
|
if (!shortcut.isAutoUse())
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()) && (getInventory().getItemByObjectId(shortcut.getId()) != null))
|
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut((22 * 12) + i, true));
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getInventory().getItemByObjectId(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 21; i++)
|
public void restoreAutoShortcuts()
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 12; j++)
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(j, i);
|
return;
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSkills().contains(shortcut.getId()) && (getKnownSkill(shortcut.getId()) != null))
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut(j + (i * 12), true));
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final ItemInstance item = getInventory().getItemByObjectId(shortcut.getId());
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSupplyItem(this, item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void addAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
final List<Integer> positions;
|
||||||
|
if (getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
positions = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
positions.add(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void removeAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(false);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, false));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInTimedHuntingZone(int zoneId)
|
public boolean isInTimedHuntingZone(int zoneId)
|
||||||
{
|
{
|
||||||
return isInTimedHuntingZone(zoneId, getX(), getY());
|
return isInTimedHuntingZone(zoneId, getX(), getY());
|
||||||
|
|||||||
+1
@@ -62,6 +62,7 @@ public class PlayerVariables extends AbstractVariables
|
|||||||
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
||||||
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
||||||
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
||||||
|
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
|
||||||
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
||||||
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
||||||
|
|
||||||
|
|||||||
+3
@@ -644,6 +644,9 @@ public class EnterWorld implements IClientIncomingPacket
|
|||||||
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
||||||
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
||||||
|
|
||||||
|
// Auto use restore.
|
||||||
|
player.restoreAutoShortcuts();
|
||||||
|
|
||||||
// Fix for equipped item skills
|
// Fix for equipped item skills
|
||||||
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -666,7 +666,7 @@ public class RequestAcquireSkill implements IClientIncomingPacket
|
|||||||
{
|
{
|
||||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
||||||
}
|
}
|
||||||
player.restoreVisualAutoUse();
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+21
-11
@@ -17,6 +17,7 @@
|
|||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
@@ -27,16 +28,15 @@ import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
|||||||
*/
|
*/
|
||||||
public class RequestShortCutDel implements IClientIncomingPacket
|
public class RequestShortCutDel implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private int _id;
|
|
||||||
private int _slot;
|
private int _slot;
|
||||||
private int _page;
|
private int _page;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_id = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = _id % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = _id / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,23 +54,33 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store shortcut reference id.
|
|
||||||
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
|
||||||
final int id = shortcut == null ? -1 : shortcut.getId();
|
|
||||||
|
|
||||||
// Delete the shortcut.
|
// Delete the shortcut.
|
||||||
player.deleteShortCut(_slot, _page);
|
player.deleteShortCut(_slot, _page);
|
||||||
|
|
||||||
|
// Keep other similar shortcuts activated.
|
||||||
|
final Shortcut oldShortcut = player.getShortCut(_slot, _page);
|
||||||
|
if ((oldShortcut != null) && oldShortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (oldShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(shortcut.getSlot(), shortcut.getPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove auto used ids.
|
// Remove auto used ids.
|
||||||
|
final int id = oldShortcut == null ? -1 : oldShortcut.getId();
|
||||||
if (_slot > 263)
|
if (_slot > 263)
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
||||||
player.restoreVisualAutoUse();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||||
player.restoreVisualAutoUse();
|
}
|
||||||
}
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-6
@@ -16,11 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
import org.l2jmobius.gameserver.enums.ShortcutType;
|
import org.l2jmobius.gameserver.enums.ShortcutType;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
||||||
|
|
||||||
public class RequestShortCutReg implements IClientIncomingPacket
|
public class RequestShortCutReg implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
@@ -31,16 +37,17 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
private int _level;
|
private int _level;
|
||||||
private int _subLevel;
|
private int _subLevel;
|
||||||
private int _characterType; // 1 - player, 2 - pet
|
private int _characterType; // 1 - player, 2 - pet
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
final int typeId = packet.readD();
|
final int typeId = packet.readD();
|
||||||
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
||||||
final int slot = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = slot % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = slot / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
packet.readC(); // 228
|
_active = packet.readC() == 1; // 228
|
||||||
_id = packet.readD();
|
_id = packet.readD();
|
||||||
_level = packet.readH();
|
_level = packet.readH();
|
||||||
_subLevel = packet.readH(); // Sublevel
|
_subLevel = packet.readH(); // Sublevel
|
||||||
@@ -51,13 +58,65 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
@Override
|
@Override
|
||||||
public void run(GameClient client)
|
public void run(GameClient client)
|
||||||
{
|
{
|
||||||
if ((client.getPlayer() == null) || (_page > 23) || (_page < 0))
|
final PlayerInstance player = client.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((_page > 23) || (_page < 0))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
||||||
client.getPlayer().registerShortCut(sc);
|
sc.setAutoUse(_active);
|
||||||
|
player.registerShortCut(sc);
|
||||||
client.sendPacket(new ShortCutRegister(sc));
|
client.sendPacket(new ShortCutRegister(sc));
|
||||||
|
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||||
|
|
||||||
|
// When id is not auto used, deactivate auto shortcuts.
|
||||||
|
if (player.getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS) && !player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||||
|
{
|
||||||
|
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
positions.remove(position);
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
player.getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activate if any other similar shortcut is activated.
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (!shortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_id == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-12
@@ -22,28 +22,31 @@ import org.l2jmobius.gameserver.data.xml.ActionData;
|
|||||||
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
|
||||||
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson, Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private boolean _activate;
|
private int _slot;
|
||||||
private int _room;
|
private int _page;
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_room = packet.readH();
|
final int position = packet.readH();
|
||||||
_activate = packet.readC() == 1;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_active = packet.readC() == 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +59,20 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int slot = _room % 12;
|
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
||||||
final int page = _room / 12;
|
|
||||||
final Shortcut shortcut = player.getShortCut(slot, page);
|
|
||||||
if (shortcut == null)
|
if (shortcut == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.sendPacket(new ExActivateAutoShortcut(_room, _activate));
|
|
||||||
|
if (_active)
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
|
||||||
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
||||||
Skill skill = null;
|
Skill skill = null;
|
||||||
@@ -73,7 +82,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
if (!_activate)
|
if (!_active)
|
||||||
{
|
{
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
@@ -111,7 +120,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// auto potion
|
// auto potion
|
||||||
if ((page == 23) && (slot == 1))
|
if ((_page == 23) && (_slot == 1))
|
||||||
{
|
{
|
||||||
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-8
@@ -17,29 +17,31 @@
|
|||||||
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final int _room;
|
private final int _position;
|
||||||
private final boolean _activate;
|
private final boolean _active;
|
||||||
|
|
||||||
public ExActivateAutoShortcut(int room, boolean activate)
|
public ExActivateAutoShortcut(Shortcut shortcut, boolean active)
|
||||||
{
|
{
|
||||||
_room = room;
|
_position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
_activate = activate;
|
_active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean write(PacketWriter packet)
|
public boolean write(PacketWriter packet)
|
||||||
{
|
{
|
||||||
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
||||||
packet.writeH(_room);
|
packet.writeH(_position);
|
||||||
packet.writeC(_activate ? 0x01 : 0x00);
|
packet.writeC(_active ? 0x01 : 0x00);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
|||||||
public class ShortCuts implements IRestorable
|
public class ShortCuts implements IRestorable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
||||||
private static final int MAX_SHORTCUTS_PER_BAR = 12;
|
|
||||||
|
public static final int MAX_SHORTCUTS_PER_BAR = 12;
|
||||||
|
|
||||||
private final PlayerInstance _owner;
|
private final PlayerInstance _owner;
|
||||||
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public class Shortcut
|
|||||||
private final int _characterType;
|
private final int _characterType;
|
||||||
/** Shared reuse group. */
|
/** Shared reuse group. */
|
||||||
private int _sharedReuseGroup = -1;
|
private int _sharedReuseGroup = -1;
|
||||||
|
/** Auto use enabled. */
|
||||||
|
private boolean _autoUse = false;
|
||||||
|
|
||||||
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
||||||
{
|
{
|
||||||
@@ -132,4 +134,22 @@ public class Shortcut
|
|||||||
{
|
{
|
||||||
_sharedReuseGroup = sharedReuseGroup;
|
_sharedReuseGroup = sharedReuseGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets is shortcut is auto use enabled.
|
||||||
|
* @return if shortcut is auto use enabled.
|
||||||
|
*/
|
||||||
|
public boolean isAutoUse()
|
||||||
|
{
|
||||||
|
return _autoUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the auto use status.
|
||||||
|
* @param value of shortcut auto use status.
|
||||||
|
*/
|
||||||
|
public void setAutoUse(boolean value)
|
||||||
|
{
|
||||||
|
_autoUse = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+142
-11
@@ -14368,36 +14368,167 @@ public class PlayerInstance extends Playable
|
|||||||
return _autoUseSettings;
|
return _autoUseSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreVisualAutoUse()
|
public void restoreAutoShortcutVisual()
|
||||||
{
|
{
|
||||||
if (_autoUseSettings.isEmpty())
|
if (_autoUseSettings.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut shortcut;
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
for (int i = 0; i < 12; i++)
|
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(i, 22);
|
if (!shortcut.isAutoUse())
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()) && (getInventory().getItemByObjectId(shortcut.getId()) != null))
|
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut((22 * 12) + i, true));
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getInventory().getItemByObjectId(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 21; i++)
|
public void restoreAutoShortcuts()
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 12; j++)
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(j, i);
|
return;
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSkills().contains(shortcut.getId()) && (getKnownSkill(shortcut.getId()) != null))
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut(j + (i * 12), true));
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final ItemInstance item = getInventory().getItemByObjectId(shortcut.getId());
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSupplyItem(this, item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void addAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
final List<Integer> positions;
|
||||||
|
if (getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
positions = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
positions.add(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void removeAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(false);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, false));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInTimedHuntingZone(int zoneId)
|
public boolean isInTimedHuntingZone(int zoneId)
|
||||||
{
|
{
|
||||||
return isInTimedHuntingZone(zoneId, getX(), getY());
|
return isInTimedHuntingZone(zoneId, getX(), getY());
|
||||||
|
|||||||
+1
@@ -62,6 +62,7 @@ public class PlayerVariables extends AbstractVariables
|
|||||||
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
||||||
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
||||||
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
||||||
|
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
|
||||||
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
||||||
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
||||||
public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS";
|
public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS";
|
||||||
|
|||||||
+3
@@ -654,6 +654,9 @@ public class EnterWorld implements IClientIncomingPacket
|
|||||||
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
||||||
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
||||||
|
|
||||||
|
// Auto use restore.
|
||||||
|
player.restoreAutoShortcuts();
|
||||||
|
|
||||||
// Fix for equipped item skills
|
// Fix for equipped item skills
|
||||||
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -666,7 +666,7 @@ public class RequestAcquireSkill implements IClientIncomingPacket
|
|||||||
{
|
{
|
||||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
||||||
}
|
}
|
||||||
player.restoreVisualAutoUse();
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+21
-11
@@ -17,6 +17,7 @@
|
|||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
@@ -27,16 +28,15 @@ import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
|||||||
*/
|
*/
|
||||||
public class RequestShortCutDel implements IClientIncomingPacket
|
public class RequestShortCutDel implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private int _id;
|
|
||||||
private int _slot;
|
private int _slot;
|
||||||
private int _page;
|
private int _page;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_id = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = _id % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = _id / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,23 +54,33 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store shortcut reference id.
|
|
||||||
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
|
||||||
final int id = shortcut == null ? -1 : shortcut.getId();
|
|
||||||
|
|
||||||
// Delete the shortcut.
|
// Delete the shortcut.
|
||||||
player.deleteShortCut(_slot, _page);
|
player.deleteShortCut(_slot, _page);
|
||||||
|
|
||||||
|
// Keep other similar shortcuts activated.
|
||||||
|
final Shortcut oldShortcut = player.getShortCut(_slot, _page);
|
||||||
|
if ((oldShortcut != null) && oldShortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (oldShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(shortcut.getSlot(), shortcut.getPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove auto used ids.
|
// Remove auto used ids.
|
||||||
|
final int id = oldShortcut == null ? -1 : oldShortcut.getId();
|
||||||
if (_slot > 263)
|
if (_slot > 263)
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
||||||
player.restoreVisualAutoUse();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||||
player.restoreVisualAutoUse();
|
}
|
||||||
}
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-6
@@ -16,11 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
import org.l2jmobius.gameserver.enums.ShortcutType;
|
import org.l2jmobius.gameserver.enums.ShortcutType;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
||||||
|
|
||||||
public class RequestShortCutReg implements IClientIncomingPacket
|
public class RequestShortCutReg implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
@@ -31,16 +37,17 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
private int _level;
|
private int _level;
|
||||||
private int _subLevel;
|
private int _subLevel;
|
||||||
private int _characterType; // 1 - player, 2 - pet
|
private int _characterType; // 1 - player, 2 - pet
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
final int typeId = packet.readD();
|
final int typeId = packet.readD();
|
||||||
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
||||||
final int slot = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = slot % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = slot / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
packet.readC(); // 228
|
_active = packet.readC() == 1; // 228
|
||||||
_id = packet.readD();
|
_id = packet.readD();
|
||||||
_level = packet.readH();
|
_level = packet.readH();
|
||||||
_subLevel = packet.readH(); // Sublevel
|
_subLevel = packet.readH(); // Sublevel
|
||||||
@@ -51,13 +58,65 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
@Override
|
@Override
|
||||||
public void run(GameClient client)
|
public void run(GameClient client)
|
||||||
{
|
{
|
||||||
if ((client.getPlayer() == null) || (_page > 23) || (_page < 0))
|
final PlayerInstance player = client.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((_page > 23) || (_page < 0))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
||||||
client.getPlayer().registerShortCut(sc);
|
sc.setAutoUse(_active);
|
||||||
|
player.registerShortCut(sc);
|
||||||
client.sendPacket(new ShortCutRegister(sc));
|
client.sendPacket(new ShortCutRegister(sc));
|
||||||
|
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||||
|
|
||||||
|
// When id is not auto used, deactivate auto shortcuts.
|
||||||
|
if (player.getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS) && !player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||||
|
{
|
||||||
|
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
positions.remove(position);
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
player.getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activate if any other similar shortcut is activated.
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (!shortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_id == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-12
@@ -22,28 +22,31 @@ import org.l2jmobius.gameserver.data.xml.ActionData;
|
|||||||
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
|
||||||
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson, Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private boolean _activate;
|
private int _slot;
|
||||||
private int _room;
|
private int _page;
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_room = packet.readH();
|
final int position = packet.readH();
|
||||||
_activate = packet.readC() == 1;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_active = packet.readC() == 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +59,20 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int slot = _room % 12;
|
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
||||||
final int page = _room / 12;
|
|
||||||
final Shortcut shortcut = player.getShortCut(slot, page);
|
|
||||||
if (shortcut == null)
|
if (shortcut == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.sendPacket(new ExActivateAutoShortcut(_room, _activate));
|
|
||||||
|
if (_active)
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
|
||||||
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
||||||
Skill skill = null;
|
Skill skill = null;
|
||||||
@@ -73,7 +82,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
if (!_activate)
|
if (!_active)
|
||||||
{
|
{
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
@@ -111,7 +120,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// auto potion
|
// auto potion
|
||||||
if ((page == 23) && (slot == 1))
|
if ((_page == 23) && (_slot == 1))
|
||||||
{
|
{
|
||||||
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-8
@@ -17,29 +17,31 @@
|
|||||||
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final int _room;
|
private final int _position;
|
||||||
private final boolean _activate;
|
private final boolean _active;
|
||||||
|
|
||||||
public ExActivateAutoShortcut(int room, boolean activate)
|
public ExActivateAutoShortcut(Shortcut shortcut, boolean active)
|
||||||
{
|
{
|
||||||
_room = room;
|
_position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
_activate = activate;
|
_active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean write(PacketWriter packet)
|
public boolean write(PacketWriter packet)
|
||||||
{
|
{
|
||||||
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
||||||
packet.writeH(_room);
|
packet.writeH(_position);
|
||||||
packet.writeC(_activate ? 0x01 : 0x00);
|
packet.writeC(_active ? 0x01 : 0x00);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -38,7 +38,9 @@ import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
|||||||
public class ShortCuts implements IRestorable
|
public class ShortCuts implements IRestorable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
||||||
private static final int MAX_SHORTCUTS_PER_BAR = 12;
|
|
||||||
|
public static final int MAX_SHORTCUTS_PER_BAR = 12;
|
||||||
|
|
||||||
private final PlayerInstance _owner;
|
private final PlayerInstance _owner;
|
||||||
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public class Shortcut
|
|||||||
private final int _characterType;
|
private final int _characterType;
|
||||||
/** Shared reuse group. */
|
/** Shared reuse group. */
|
||||||
private int _sharedReuseGroup = -1;
|
private int _sharedReuseGroup = -1;
|
||||||
|
/** Auto use enabled. */
|
||||||
|
private boolean _autoUse = false;
|
||||||
|
|
||||||
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
||||||
{
|
{
|
||||||
@@ -132,4 +134,22 @@ public class Shortcut
|
|||||||
{
|
{
|
||||||
_sharedReuseGroup = sharedReuseGroup;
|
_sharedReuseGroup = sharedReuseGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets is shortcut is auto use enabled.
|
||||||
|
* @return if shortcut is auto use enabled.
|
||||||
|
*/
|
||||||
|
public boolean isAutoUse()
|
||||||
|
{
|
||||||
|
return _autoUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the auto use status.
|
||||||
|
* @param value of shortcut auto use status.
|
||||||
|
*/
|
||||||
|
public void setAutoUse(boolean value)
|
||||||
|
{
|
||||||
|
_autoUse = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+142
-11
@@ -14405,36 +14405,167 @@ public class PlayerInstance extends Playable
|
|||||||
return _autoUseSettings;
|
return _autoUseSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreVisualAutoUse()
|
public void restoreAutoShortcutVisual()
|
||||||
{
|
{
|
||||||
if (_autoUseSettings.isEmpty())
|
if (_autoUseSettings.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut shortcut;
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
for (int i = 0; i < 12; i++)
|
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(i, 22);
|
if (!shortcut.isAutoUse())
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()) && (getInventory().getItemByObjectId(shortcut.getId()) != null))
|
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut((22 * 12) + i, true));
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getInventory().getItemByObjectId(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 21; i++)
|
public void restoreAutoShortcuts()
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 12; j++)
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(j, i);
|
return;
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSkills().contains(shortcut.getId()) && (getKnownSkill(shortcut.getId()) != null))
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut(j + (i * 12), true));
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final ItemInstance item = getInventory().getItemByObjectId(shortcut.getId());
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSupplyItem(this, item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void addAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
final List<Integer> positions;
|
||||||
|
if (getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
positions = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
positions.add(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void removeAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(false);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, false));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInTimedHuntingZone(int zoneId)
|
public boolean isInTimedHuntingZone(int zoneId)
|
||||||
{
|
{
|
||||||
return isInTimedHuntingZone(zoneId, getX(), getY());
|
return isInTimedHuntingZone(zoneId, getX(), getY());
|
||||||
|
|||||||
+1
@@ -62,6 +62,7 @@ public class PlayerVariables extends AbstractVariables
|
|||||||
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
||||||
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
||||||
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
||||||
|
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
|
||||||
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
||||||
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
||||||
public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS";
|
public static final String FAVORITE_TELEPORTS = "FAVORITE_TELEPORTS";
|
||||||
|
|||||||
+3
@@ -659,6 +659,9 @@ public class EnterWorld implements IClientIncomingPacket
|
|||||||
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
||||||
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
||||||
|
|
||||||
|
// Auto use restore.
|
||||||
|
player.restoreAutoShortcuts();
|
||||||
|
|
||||||
// Fix for equipped item skills
|
// Fix for equipped item skills
|
||||||
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -666,7 +666,7 @@ public class RequestAcquireSkill implements IClientIncomingPacket
|
|||||||
{
|
{
|
||||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
||||||
}
|
}
|
||||||
player.restoreVisualAutoUse();
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+21
-11
@@ -17,6 +17,7 @@
|
|||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
@@ -27,16 +28,15 @@ import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
|||||||
*/
|
*/
|
||||||
public class RequestShortCutDel implements IClientIncomingPacket
|
public class RequestShortCutDel implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private int _id;
|
|
||||||
private int _slot;
|
private int _slot;
|
||||||
private int _page;
|
private int _page;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_id = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = _id % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = _id / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,23 +54,33 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store shortcut reference id.
|
|
||||||
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
|
||||||
final int id = shortcut == null ? -1 : shortcut.getId();
|
|
||||||
|
|
||||||
// Delete the shortcut.
|
// Delete the shortcut.
|
||||||
player.deleteShortCut(_slot, _page);
|
player.deleteShortCut(_slot, _page);
|
||||||
|
|
||||||
|
// Keep other similar shortcuts activated.
|
||||||
|
final Shortcut oldShortcut = player.getShortCut(_slot, _page);
|
||||||
|
if ((oldShortcut != null) && oldShortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (oldShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(shortcut.getSlot(), shortcut.getPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove auto used ids.
|
// Remove auto used ids.
|
||||||
|
final int id = oldShortcut == null ? -1 : oldShortcut.getId();
|
||||||
if (_slot > 263)
|
if (_slot > 263)
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
||||||
player.restoreVisualAutoUse();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||||
player.restoreVisualAutoUse();
|
}
|
||||||
}
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-6
@@ -16,11 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
import org.l2jmobius.gameserver.enums.ShortcutType;
|
import org.l2jmobius.gameserver.enums.ShortcutType;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
||||||
|
|
||||||
public class RequestShortCutReg implements IClientIncomingPacket
|
public class RequestShortCutReg implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
@@ -31,16 +37,17 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
private int _level;
|
private int _level;
|
||||||
private int _subLevel;
|
private int _subLevel;
|
||||||
private int _characterType; // 1 - player, 2 - pet
|
private int _characterType; // 1 - player, 2 - pet
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
final int typeId = packet.readD();
|
final int typeId = packet.readD();
|
||||||
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
||||||
final int slot = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = slot % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = slot / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
packet.readC(); // 228
|
_active = packet.readC() == 1; // 228
|
||||||
_id = packet.readD();
|
_id = packet.readD();
|
||||||
_level = packet.readH();
|
_level = packet.readH();
|
||||||
_subLevel = packet.readH(); // Sublevel
|
_subLevel = packet.readH(); // Sublevel
|
||||||
@@ -51,13 +58,65 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
@Override
|
@Override
|
||||||
public void run(GameClient client)
|
public void run(GameClient client)
|
||||||
{
|
{
|
||||||
if ((client.getPlayer() == null) || (_page > 23) || (_page < 0))
|
final PlayerInstance player = client.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((_page > 23) || (_page < 0))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
||||||
client.getPlayer().registerShortCut(sc);
|
sc.setAutoUse(_active);
|
||||||
|
player.registerShortCut(sc);
|
||||||
client.sendPacket(new ShortCutRegister(sc));
|
client.sendPacket(new ShortCutRegister(sc));
|
||||||
|
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||||
|
|
||||||
|
// When id is not auto used, deactivate auto shortcuts.
|
||||||
|
if (player.getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS) && !player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||||
|
{
|
||||||
|
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
positions.remove(position);
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
player.getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activate if any other similar shortcut is activated.
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (!shortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_id == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-12
@@ -22,28 +22,31 @@ import org.l2jmobius.gameserver.data.xml.ActionData;
|
|||||||
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
|
||||||
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson, Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private boolean _activate;
|
private int _slot;
|
||||||
private int _room;
|
private int _page;
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_room = packet.readH();
|
final int position = packet.readH();
|
||||||
_activate = packet.readC() == 1;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_active = packet.readC() == 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +59,20 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int slot = _room % 12;
|
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
||||||
final int page = _room / 12;
|
|
||||||
final Shortcut shortcut = player.getShortCut(slot, page);
|
|
||||||
if (shortcut == null)
|
if (shortcut == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.sendPacket(new ExActivateAutoShortcut(_room, _activate));
|
|
||||||
|
if (_active)
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
|
||||||
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
||||||
Skill skill = null;
|
Skill skill = null;
|
||||||
@@ -73,7 +82,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
if (!_activate)
|
if (!_active)
|
||||||
{
|
{
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
@@ -111,7 +120,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// auto potion
|
// auto potion
|
||||||
if ((page == 23) && (slot == 1))
|
if ((_page == 23) && (_slot == 1))
|
||||||
{
|
{
|
||||||
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-8
@@ -17,29 +17,31 @@
|
|||||||
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final int _room;
|
private final int _position;
|
||||||
private final boolean _activate;
|
private final boolean _active;
|
||||||
|
|
||||||
public ExActivateAutoShortcut(int room, boolean activate)
|
public ExActivateAutoShortcut(Shortcut shortcut, boolean active)
|
||||||
{
|
{
|
||||||
_room = room;
|
_position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
_activate = activate;
|
_active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean write(PacketWriter packet)
|
public boolean write(PacketWriter packet)
|
||||||
{
|
{
|
||||||
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
||||||
packet.writeH(_room);
|
packet.writeH(_position);
|
||||||
packet.writeC(_activate ? 0x01 : 0x00);
|
packet.writeC(_active ? 0x01 : 0x00);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
|||||||
public class ShortCuts implements IRestorable
|
public class ShortCuts implements IRestorable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
||||||
private static final int MAX_SHORTCUTS_PER_BAR = 12;
|
|
||||||
|
public static final int MAX_SHORTCUTS_PER_BAR = 12;
|
||||||
|
|
||||||
private final PlayerInstance _owner;
|
private final PlayerInstance _owner;
|
||||||
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public class Shortcut
|
|||||||
private final int _characterType;
|
private final int _characterType;
|
||||||
/** Shared reuse group. */
|
/** Shared reuse group. */
|
||||||
private int _sharedReuseGroup = -1;
|
private int _sharedReuseGroup = -1;
|
||||||
|
/** Auto use enabled. */
|
||||||
|
private boolean _autoUse = false;
|
||||||
|
|
||||||
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
||||||
{
|
{
|
||||||
@@ -132,4 +134,22 @@ public class Shortcut
|
|||||||
{
|
{
|
||||||
_sharedReuseGroup = sharedReuseGroup;
|
_sharedReuseGroup = sharedReuseGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets is shortcut is auto use enabled.
|
||||||
|
* @return if shortcut is auto use enabled.
|
||||||
|
*/
|
||||||
|
public boolean isAutoUse()
|
||||||
|
{
|
||||||
|
return _autoUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the auto use status.
|
||||||
|
* @param value of shortcut auto use status.
|
||||||
|
*/
|
||||||
|
public void setAutoUse(boolean value)
|
||||||
|
{
|
||||||
|
_autoUse = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+142
-11
@@ -14278,36 +14278,167 @@ public class PlayerInstance extends Playable
|
|||||||
return _autoUseSettings;
|
return _autoUseSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreVisualAutoUse()
|
public void restoreAutoShortcutVisual()
|
||||||
{
|
{
|
||||||
if (_autoUseSettings.isEmpty())
|
if (_autoUseSettings.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut shortcut;
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
for (int i = 0; i < 12; i++)
|
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(i, 22);
|
if (!shortcut.isAutoUse())
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()) && (getInventory().getItemByObjectId(shortcut.getId()) != null))
|
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut((22 * 12) + i, true));
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getInventory().getItemByObjectId(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 21; i++)
|
public void restoreAutoShortcuts()
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 12; j++)
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(j, i);
|
return;
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSkills().contains(shortcut.getId()) && (getKnownSkill(shortcut.getId()) != null))
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut(j + (i * 12), true));
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final ItemInstance item = getInventory().getItemByObjectId(shortcut.getId());
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSupplyItem(this, item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void addAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
final List<Integer> positions;
|
||||||
|
if (getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
positions = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
positions.add(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void removeAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(false);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, false));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInTimedHuntingZone(int zoneId)
|
public boolean isInTimedHuntingZone(int zoneId)
|
||||||
{
|
{
|
||||||
return isInTimedHuntingZone(zoneId, getX(), getY());
|
return isInTimedHuntingZone(zoneId, getX(), getY());
|
||||||
|
|||||||
+1
@@ -63,6 +63,7 @@ public class PlayerVariables extends AbstractVariables
|
|||||||
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
||||||
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
||||||
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
||||||
|
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
|
||||||
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
||||||
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
||||||
|
|
||||||
|
|||||||
+3
@@ -633,6 +633,9 @@ public class EnterWorld implements IClientIncomingPacket
|
|||||||
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
||||||
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
||||||
|
|
||||||
|
// Auto use restore.
|
||||||
|
player.restoreAutoShortcuts();
|
||||||
|
|
||||||
// Fix for equipped item skills
|
// Fix for equipped item skills
|
||||||
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -633,7 +633,7 @@ public class RequestAcquireSkill implements IClientIncomingPacket
|
|||||||
{
|
{
|
||||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
||||||
}
|
}
|
||||||
player.restoreVisualAutoUse();
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+21
-11
@@ -17,6 +17,7 @@
|
|||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
@@ -27,16 +28,15 @@ import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
|||||||
*/
|
*/
|
||||||
public class RequestShortCutDel implements IClientIncomingPacket
|
public class RequestShortCutDel implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private int _id;
|
|
||||||
private int _slot;
|
private int _slot;
|
||||||
private int _page;
|
private int _page;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_id = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = _id % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = _id / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,23 +54,33 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store shortcut reference id.
|
|
||||||
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
|
||||||
final int id = shortcut == null ? -1 : shortcut.getId();
|
|
||||||
|
|
||||||
// Delete the shortcut.
|
// Delete the shortcut.
|
||||||
player.deleteShortCut(_slot, _page);
|
player.deleteShortCut(_slot, _page);
|
||||||
|
|
||||||
|
// Keep other similar shortcuts activated.
|
||||||
|
final Shortcut oldShortcut = player.getShortCut(_slot, _page);
|
||||||
|
if ((oldShortcut != null) && oldShortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (oldShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(shortcut.getSlot(), shortcut.getPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove auto used ids.
|
// Remove auto used ids.
|
||||||
|
final int id = oldShortcut == null ? -1 : oldShortcut.getId();
|
||||||
if (_slot > 263)
|
if (_slot > 263)
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
||||||
player.restoreVisualAutoUse();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||||
player.restoreVisualAutoUse();
|
}
|
||||||
}
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-6
@@ -16,11 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
import org.l2jmobius.gameserver.enums.ShortcutType;
|
import org.l2jmobius.gameserver.enums.ShortcutType;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
||||||
|
|
||||||
public class RequestShortCutReg implements IClientIncomingPacket
|
public class RequestShortCutReg implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
@@ -31,16 +37,17 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
private int _level;
|
private int _level;
|
||||||
private int _subLevel;
|
private int _subLevel;
|
||||||
private int _characterType; // 1 - player, 2 - pet
|
private int _characterType; // 1 - player, 2 - pet
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
final int typeId = packet.readD();
|
final int typeId = packet.readD();
|
||||||
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
||||||
final int slot = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = slot % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = slot / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
packet.readC(); // 228
|
_active = packet.readC() == 1; // 228
|
||||||
_id = packet.readD();
|
_id = packet.readD();
|
||||||
_level = packet.readH();
|
_level = packet.readH();
|
||||||
_subLevel = packet.readH(); // Sublevel
|
_subLevel = packet.readH(); // Sublevel
|
||||||
@@ -51,13 +58,65 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
@Override
|
@Override
|
||||||
public void run(GameClient client)
|
public void run(GameClient client)
|
||||||
{
|
{
|
||||||
if ((client.getPlayer() == null) || (_page > 23) || (_page < 0))
|
final PlayerInstance player = client.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((_page > 23) || (_page < 0))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
||||||
client.getPlayer().registerShortCut(sc);
|
sc.setAutoUse(_active);
|
||||||
|
player.registerShortCut(sc);
|
||||||
client.sendPacket(new ShortCutRegister(sc));
|
client.sendPacket(new ShortCutRegister(sc));
|
||||||
|
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||||
|
|
||||||
|
// When id is not auto used, deactivate auto shortcuts.
|
||||||
|
if (player.getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS) && !player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||||
|
{
|
||||||
|
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
positions.remove(position);
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
player.getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activate if any other similar shortcut is activated.
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (!shortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_id == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-12
@@ -22,28 +22,31 @@ import org.l2jmobius.gameserver.data.xml.ActionData;
|
|||||||
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
|
||||||
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson, Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private boolean _activate;
|
private int _slot;
|
||||||
private int _room;
|
private int _page;
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_room = packet.readH();
|
final int position = packet.readH();
|
||||||
_activate = packet.readC() == 1;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_active = packet.readC() == 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +59,20 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int slot = _room % 12;
|
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
||||||
final int page = _room / 12;
|
|
||||||
final Shortcut shortcut = player.getShortCut(slot, page);
|
|
||||||
if (shortcut == null)
|
if (shortcut == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.sendPacket(new ExActivateAutoShortcut(_room, _activate));
|
|
||||||
|
if (_active)
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
|
||||||
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
||||||
Skill skill = null;
|
Skill skill = null;
|
||||||
@@ -73,7 +82,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
if (!_activate)
|
if (!_active)
|
||||||
{
|
{
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
@@ -111,7 +120,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// auto potion
|
// auto potion
|
||||||
if ((page == 23) && (slot == 1))
|
if ((_page == 23) && (_slot == 1))
|
||||||
{
|
{
|
||||||
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-8
@@ -17,29 +17,31 @@
|
|||||||
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final int _room;
|
private final int _position;
|
||||||
private final boolean _activate;
|
private final boolean _active;
|
||||||
|
|
||||||
public ExActivateAutoShortcut(int room, boolean activate)
|
public ExActivateAutoShortcut(Shortcut shortcut, boolean active)
|
||||||
{
|
{
|
||||||
_room = room;
|
_position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
_activate = activate;
|
_active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean write(PacketWriter packet)
|
public boolean write(PacketWriter packet)
|
||||||
{
|
{
|
||||||
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
||||||
packet.writeH(_room);
|
packet.writeH(_position);
|
||||||
packet.writeC(_activate ? 0x01 : 0x00);
|
packet.writeC(_active ? 0x01 : 0x00);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -38,7 +38,9 @@ import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
|||||||
public class ShortCuts implements IRestorable
|
public class ShortCuts implements IRestorable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
||||||
private static final int MAX_SHORTCUTS_PER_BAR = 12;
|
|
||||||
|
public static final int MAX_SHORTCUTS_PER_BAR = 12;
|
||||||
|
|
||||||
private final PlayerInstance _owner;
|
private final PlayerInstance _owner;
|
||||||
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|||||||
+20
@@ -40,6 +40,8 @@ public class Shortcut
|
|||||||
private final int _characterType;
|
private final int _characterType;
|
||||||
/** Shared reuse group. */
|
/** Shared reuse group. */
|
||||||
private int _sharedReuseGroup = -1;
|
private int _sharedReuseGroup = -1;
|
||||||
|
/** Auto use enabled. */
|
||||||
|
private boolean _autoUse = false;
|
||||||
|
|
||||||
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
||||||
{
|
{
|
||||||
@@ -132,4 +134,22 @@ public class Shortcut
|
|||||||
{
|
{
|
||||||
_sharedReuseGroup = sharedReuseGroup;
|
_sharedReuseGroup = sharedReuseGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets is shortcut is auto use enabled.
|
||||||
|
* @return if shortcut is auto use enabled.
|
||||||
|
*/
|
||||||
|
public boolean isAutoUse()
|
||||||
|
{
|
||||||
|
return _autoUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the auto use status.
|
||||||
|
* @param value of shortcut auto use status.
|
||||||
|
*/
|
||||||
|
public void setAutoUse(boolean value)
|
||||||
|
{
|
||||||
|
_autoUse = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+142
-11
@@ -14538,36 +14538,167 @@ public class PlayerInstance extends Playable
|
|||||||
return _autoUseSettings;
|
return _autoUseSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreVisualAutoUse()
|
public void restoreAutoShortcutVisual()
|
||||||
{
|
{
|
||||||
if (_autoUseSettings.isEmpty())
|
if (_autoUseSettings.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut shortcut;
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
for (int i = 0; i < 12; i++)
|
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(i, 22);
|
if (!shortcut.isAutoUse())
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()) && (getInventory().getItemByObjectId(shortcut.getId()) != null))
|
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut((22 * 12) + i, true));
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getInventory().getItemByObjectId(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 21; i++)
|
public void restoreAutoShortcuts()
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 12; j++)
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(j, i);
|
return;
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSkills().contains(shortcut.getId()) && (getKnownSkill(shortcut.getId()) != null))
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut(j + (i * 12), true));
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final ItemInstance item = getInventory().getItemByObjectId(shortcut.getId());
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSupplyItem(this, item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void addAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
final List<Integer> positions;
|
||||||
|
if (getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
positions = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
positions.add(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void removeAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(false);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, false));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInTimedHuntingZone(int zoneId)
|
public boolean isInTimedHuntingZone(int zoneId)
|
||||||
{
|
{
|
||||||
return isInTimedHuntingZone(zoneId, getX(), getY());
|
return isInTimedHuntingZone(zoneId, getX(), getY());
|
||||||
|
|||||||
+1
@@ -63,6 +63,7 @@ public class PlayerVariables extends AbstractVariables
|
|||||||
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
||||||
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
||||||
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
||||||
|
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
|
||||||
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
||||||
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
||||||
public static final String SAYHA_GRACE_SUPPORT_ENDTIME = "SAYHA_GRACE_SUPPORT_ENDTIME";
|
public static final String SAYHA_GRACE_SUPPORT_ENDTIME = "SAYHA_GRACE_SUPPORT_ENDTIME";
|
||||||
|
|||||||
+3
@@ -636,6 +636,9 @@ public class EnterWorld implements IClientIncomingPacket
|
|||||||
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
||||||
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
||||||
|
|
||||||
|
// Auto use restore.
|
||||||
|
player.restoreAutoShortcuts();
|
||||||
|
|
||||||
// Fix for equipped item skills
|
// Fix for equipped item skills
|
||||||
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -633,7 +633,7 @@ public class RequestAcquireSkill implements IClientIncomingPacket
|
|||||||
{
|
{
|
||||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
||||||
}
|
}
|
||||||
player.restoreVisualAutoUse();
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+21
-11
@@ -17,6 +17,7 @@
|
|||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
@@ -27,16 +28,15 @@ import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
|||||||
*/
|
*/
|
||||||
public class RequestShortCutDel implements IClientIncomingPacket
|
public class RequestShortCutDel implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private int _id;
|
|
||||||
private int _slot;
|
private int _slot;
|
||||||
private int _page;
|
private int _page;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_id = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = _id % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = _id / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,23 +54,33 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store shortcut reference id.
|
|
||||||
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
|
||||||
final int id = shortcut == null ? -1 : shortcut.getId();
|
|
||||||
|
|
||||||
// Delete the shortcut.
|
// Delete the shortcut.
|
||||||
player.deleteShortCut(_slot, _page);
|
player.deleteShortCut(_slot, _page);
|
||||||
|
|
||||||
|
// Keep other similar shortcuts activated.
|
||||||
|
final Shortcut oldShortcut = player.getShortCut(_slot, _page);
|
||||||
|
if ((oldShortcut != null) && oldShortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (oldShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(shortcut.getSlot(), shortcut.getPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove auto used ids.
|
// Remove auto used ids.
|
||||||
|
final int id = oldShortcut == null ? -1 : oldShortcut.getId();
|
||||||
if (_slot > 263)
|
if (_slot > 263)
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
||||||
player.restoreVisualAutoUse();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||||
player.restoreVisualAutoUse();
|
}
|
||||||
}
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-6
@@ -16,11 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
import org.l2jmobius.gameserver.enums.ShortcutType;
|
import org.l2jmobius.gameserver.enums.ShortcutType;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
||||||
|
|
||||||
public class RequestShortCutReg implements IClientIncomingPacket
|
public class RequestShortCutReg implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
@@ -31,16 +37,17 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
private int _level;
|
private int _level;
|
||||||
private int _subLevel;
|
private int _subLevel;
|
||||||
private int _characterType; // 1 - player, 2 - pet
|
private int _characterType; // 1 - player, 2 - pet
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
final int typeId = packet.readD();
|
final int typeId = packet.readD();
|
||||||
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
||||||
final int slot = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = slot % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = slot / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
packet.readC(); // 228
|
_active = packet.readC() == 1; // 228
|
||||||
_id = packet.readD();
|
_id = packet.readD();
|
||||||
_level = packet.readH();
|
_level = packet.readH();
|
||||||
_subLevel = packet.readH(); // Sublevel
|
_subLevel = packet.readH(); // Sublevel
|
||||||
@@ -51,13 +58,65 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
@Override
|
@Override
|
||||||
public void run(GameClient client)
|
public void run(GameClient client)
|
||||||
{
|
{
|
||||||
if ((client.getPlayer() == null) || (_page > 23) || (_page < 0))
|
final PlayerInstance player = client.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((_page > 23) || (_page < 0))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
||||||
client.getPlayer().registerShortCut(sc);
|
sc.setAutoUse(_active);
|
||||||
|
player.registerShortCut(sc);
|
||||||
client.sendPacket(new ShortCutRegister(sc));
|
client.sendPacket(new ShortCutRegister(sc));
|
||||||
|
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||||
|
|
||||||
|
// When id is not auto used, deactivate auto shortcuts.
|
||||||
|
if (player.getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS) && !player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||||
|
{
|
||||||
|
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
positions.remove(position);
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
player.getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activate if any other similar shortcut is activated.
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (!shortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_id == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-12
@@ -22,28 +22,31 @@ import org.l2jmobius.gameserver.data.xml.ActionData;
|
|||||||
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
|
||||||
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson, Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private boolean _activate;
|
private int _slot;
|
||||||
private int _room;
|
private int _page;
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_room = packet.readH();
|
final int position = packet.readH();
|
||||||
_activate = packet.readC() == 1;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_active = packet.readC() == 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +59,20 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int slot = _room % 12;
|
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
||||||
final int page = _room / 12;
|
|
||||||
final Shortcut shortcut = player.getShortCut(slot, page);
|
|
||||||
if (shortcut == null)
|
if (shortcut == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.sendPacket(new ExActivateAutoShortcut(_room, _activate));
|
|
||||||
|
if (_active)
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
|
||||||
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
||||||
Skill skill = null;
|
Skill skill = null;
|
||||||
@@ -73,7 +82,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
if (!_activate)
|
if (!_active)
|
||||||
{
|
{
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
@@ -111,7 +120,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// auto potion
|
// auto potion
|
||||||
if ((page == 23) && (slot == 1))
|
if ((_page == 23) && (_slot == 1))
|
||||||
{
|
{
|
||||||
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-8
@@ -17,29 +17,31 @@
|
|||||||
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final int _room;
|
private final int _position;
|
||||||
private final boolean _activate;
|
private final boolean _active;
|
||||||
|
|
||||||
public ExActivateAutoShortcut(int room, boolean activate)
|
public ExActivateAutoShortcut(Shortcut shortcut, boolean active)
|
||||||
{
|
{
|
||||||
_room = room;
|
_position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
_activate = activate;
|
_active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean write(PacketWriter packet)
|
public boolean write(PacketWriter packet)
|
||||||
{
|
{
|
||||||
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
||||||
packet.writeH(_room);
|
packet.writeH(_position);
|
||||||
packet.writeC(_activate ? 0x01 : 0x00);
|
packet.writeC(_active ? 0x01 : 0x00);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,9 @@ import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
|||||||
public class ShortCuts implements IRestorable
|
public class ShortCuts implements IRestorable
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ShortCuts.class.getName());
|
||||||
private static final int MAX_SHORTCUTS_PER_BAR = 12;
|
|
||||||
|
public static final int MAX_SHORTCUTS_PER_BAR = 12;
|
||||||
|
|
||||||
private final PlayerInstance _owner;
|
private final PlayerInstance _owner;
|
||||||
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
private final Map<Integer, Shortcut> _shortCuts = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ public class Shortcut
|
|||||||
private final int _characterType;
|
private final int _characterType;
|
||||||
/** Shared reuse group. */
|
/** Shared reuse group. */
|
||||||
private int _sharedReuseGroup = -1;
|
private int _sharedReuseGroup = -1;
|
||||||
|
/** Auto use enabled. */
|
||||||
|
private boolean _autoUse = false;
|
||||||
|
|
||||||
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
public Shortcut(int slot, int page, ShortcutType type, int id, int level, int subLevel, int characterType)
|
||||||
{
|
{
|
||||||
@@ -132,4 +134,22 @@ public class Shortcut
|
|||||||
{
|
{
|
||||||
_sharedReuseGroup = sharedReuseGroup;
|
_sharedReuseGroup = sharedReuseGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets is shortcut is auto use enabled.
|
||||||
|
* @return if shortcut is auto use enabled.
|
||||||
|
*/
|
||||||
|
public boolean isAutoUse()
|
||||||
|
{
|
||||||
|
return _autoUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the auto use status.
|
||||||
|
* @param value of shortcut auto use status.
|
||||||
|
*/
|
||||||
|
public void setAutoUse(boolean value)
|
||||||
|
{
|
||||||
|
_autoUse = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+142
-11
@@ -14615,36 +14615,167 @@ public class PlayerInstance extends Playable
|
|||||||
return _autoUseSettings;
|
return _autoUseSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreVisualAutoUse()
|
public void restoreAutoShortcutVisual()
|
||||||
{
|
{
|
||||||
if (_autoUseSettings.isEmpty())
|
if (_autoUseSettings.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Shortcut shortcut;
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
for (int i = 0; i < 12; i++)
|
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(i, 22);
|
if (!shortcut.isAutoUse())
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()) && (getInventory().getItemByObjectId(shortcut.getId()) != null))
|
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut((22 * 12) + i, true));
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_autoUseSettings.getAutoSupplyItems().contains(shortcut.getId()))
|
||||||
|
{
|
||||||
|
if (getInventory().getItemByObjectId(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 21; i++)
|
public void restoreAutoShortcuts()
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 12; j++)
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
{
|
{
|
||||||
shortcut = getShortCut(j, i);
|
return;
|
||||||
if ((shortcut != null) && _autoUseSettings.getAutoSkills().contains(shortcut.getId()) && (getKnownSkill(shortcut.getId()) != null))
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
{
|
{
|
||||||
sendPacket(new ExActivateAutoShortcut(j + (i * 12), true));
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getKnownSkill(shortcut.getId()) != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final ItemInstance item = getInventory().getItemByObjectId(shortcut.getId());
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
AutoUseTaskManager.getInstance().addAutoSupplyItem(this, item.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void addAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
final List<Integer> positions;
|
||||||
|
if (getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
positions = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(true);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
positions.add(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void removeAutoShortcut(int slot, int page)
|
||||||
|
{
|
||||||
|
if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||||
|
if (usedShortcut == null)
|
||||||
|
{
|
||||||
|
final Integer position = slot + (page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Shortcut shortcut : getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (usedShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
shortcut.setAutoUse(false);
|
||||||
|
sendPacket(new ExActivateAutoShortcut(shortcut, false));
|
||||||
|
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
positions.remove(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInTimedHuntingZone(int zoneId)
|
public boolean isInTimedHuntingZone(int zoneId)
|
||||||
{
|
{
|
||||||
return isInTimedHuntingZone(zoneId, getX(), getY());
|
return isInTimedHuntingZone(zoneId, getX(), getY());
|
||||||
|
|||||||
+1
@@ -63,6 +63,7 @@ public class PlayerVariables extends AbstractVariables
|
|||||||
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
|
||||||
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
|
||||||
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
public static final String DELUSION_RETURN = "DELUSION_RETURN";
|
||||||
|
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
|
||||||
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";
|
||||||
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
public static final String HUNTING_ZONE_TIME = "HUNTING_ZONE_TIME_";
|
||||||
public static final String SAYHA_GRACE_SUPPORT_ENDTIME = "SAYHA_GRACE_SUPPORT_ENDTIME";
|
public static final String SAYHA_GRACE_SUPPORT_ENDTIME = "SAYHA_GRACE_SUPPORT_ENDTIME";
|
||||||
|
|||||||
+3
@@ -643,6 +643,9 @@ public class EnterWorld implements IClientIncomingPacket
|
|||||||
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
player.sendPacket(new ExAutoSoulShot(0, true, 2));
|
||||||
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
player.sendPacket(new ExAutoSoulShot(0, true, 3));
|
||||||
|
|
||||||
|
// Auto use restore.
|
||||||
|
player.restoreAutoShortcuts();
|
||||||
|
|
||||||
// Fix for equipped item skills
|
// Fix for equipped item skills
|
||||||
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
if (!player.getEffectList().getCurrentAbnormalVisualEffects().isEmpty())
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -633,7 +633,7 @@ public class RequestAcquireSkill implements IClientIncomingPacket
|
|||||||
{
|
{
|
||||||
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSkillLearn(trainer, player, skill, _skillType), player);
|
||||||
}
|
}
|
||||||
player.restoreVisualAutoUse();
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+21
-11
@@ -17,6 +17,7 @@
|
|||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
@@ -27,16 +28,15 @@ import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
|||||||
*/
|
*/
|
||||||
public class RequestShortCutDel implements IClientIncomingPacket
|
public class RequestShortCutDel implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private int _id;
|
|
||||||
private int _slot;
|
private int _slot;
|
||||||
private int _page;
|
private int _page;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_id = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = _id % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = _id / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,23 +54,33 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store shortcut reference id.
|
|
||||||
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
|
||||||
final int id = shortcut == null ? -1 : shortcut.getId();
|
|
||||||
|
|
||||||
// Delete the shortcut.
|
// Delete the shortcut.
|
||||||
player.deleteShortCut(_slot, _page);
|
player.deleteShortCut(_slot, _page);
|
||||||
|
|
||||||
|
// Keep other similar shortcuts activated.
|
||||||
|
final Shortcut oldShortcut = player.getShortCut(_slot, _page);
|
||||||
|
if ((oldShortcut != null) && oldShortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (oldShortcut.getId() == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(shortcut.getSlot(), shortcut.getPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove auto used ids.
|
// Remove auto used ids.
|
||||||
|
final int id = oldShortcut == null ? -1 : oldShortcut.getId();
|
||||||
if (_slot > 263)
|
if (_slot > 263)
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSupplyItem(player, id);
|
||||||
player.restoreVisualAutoUse();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||||
player.restoreVisualAutoUse();
|
}
|
||||||
}
|
player.restoreAutoShortcutVisual();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-6
@@ -16,11 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.network.clientpackets;
|
package org.l2jmobius.gameserver.network.clientpackets;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketReader;
|
import org.l2jmobius.commons.network.PacketReader;
|
||||||
import org.l2jmobius.gameserver.enums.ShortcutType;
|
import org.l2jmobius.gameserver.enums.ShortcutType;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
|
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
import org.l2jmobius.gameserver.network.serverpackets.ShortCutRegister;
|
||||||
|
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
||||||
|
|
||||||
public class RequestShortCutReg implements IClientIncomingPacket
|
public class RequestShortCutReg implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
@@ -31,16 +37,17 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
private int _level;
|
private int _level;
|
||||||
private int _subLevel;
|
private int _subLevel;
|
||||||
private int _characterType; // 1 - player, 2 - pet
|
private int _characterType; // 1 - player, 2 - pet
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
final int typeId = packet.readD();
|
final int typeId = packet.readD();
|
||||||
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
|
||||||
final int slot = packet.readD();
|
final int position = packet.readD();
|
||||||
_slot = slot % 12;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
_page = slot / 12;
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
packet.readC(); // 228
|
_active = packet.readC() == 1; // 228
|
||||||
_id = packet.readD();
|
_id = packet.readD();
|
||||||
_level = packet.readH();
|
_level = packet.readH();
|
||||||
_subLevel = packet.readH(); // Sublevel
|
_subLevel = packet.readH(); // Sublevel
|
||||||
@@ -51,13 +58,65 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
|||||||
@Override
|
@Override
|
||||||
public void run(GameClient client)
|
public void run(GameClient client)
|
||||||
{
|
{
|
||||||
if ((client.getPlayer() == null) || (_page > 23) || (_page < 0))
|
final PlayerInstance player = client.getPlayer();
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((_page > 23) || (_page < 0))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _level, _subLevel, _characterType);
|
||||||
client.getPlayer().registerShortCut(sc);
|
sc.setAutoUse(_active);
|
||||||
|
player.registerShortCut(sc);
|
||||||
client.sendPacket(new ShortCutRegister(sc));
|
client.sendPacket(new ShortCutRegister(sc));
|
||||||
|
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||||
|
|
||||||
|
// When id is not auto used, deactivate auto shortcuts.
|
||||||
|
if (player.getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS) && !player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||||
|
{
|
||||||
|
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||||
|
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
|
if (!positions.contains(position))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
positions.remove(position);
|
||||||
|
|
||||||
|
final StringBuilder variable = new StringBuilder();
|
||||||
|
for (int id : positions)
|
||||||
|
{
|
||||||
|
variable.append(id);
|
||||||
|
variable.append(",");
|
||||||
|
}
|
||||||
|
if (variable.isEmpty())
|
||||||
|
{
|
||||||
|
player.getVariables().remove(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.getVariables().set(PlayerVariables.AUTO_USE_SHORTCUTS, variable.toString());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activate if any other similar shortcut is activated.
|
||||||
|
for (Shortcut shortcut : player.getAllShortCuts())
|
||||||
|
{
|
||||||
|
if (!shortcut.isAutoUse())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_id == shortcut.getId())
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-12
@@ -22,28 +22,31 @@ import org.l2jmobius.gameserver.data.xml.ActionData;
|
|||||||
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.IPlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
import org.l2jmobius.gameserver.handler.PlayerActionHandler;
|
||||||
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
import org.l2jmobius.gameserver.model.ActionDataHolder;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
import org.l2jmobius.gameserver.model.Shortcut;
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||||
import org.l2jmobius.gameserver.network.GameClient;
|
import org.l2jmobius.gameserver.network.GameClient;
|
||||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.autoplay.ExActivateAutoShortcut;
|
|
||||||
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
import org.l2jmobius.gameserver.taskmanager.AutoUseTaskManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson, Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||||
{
|
{
|
||||||
private boolean _activate;
|
private int _slot;
|
||||||
private int _room;
|
private int _page;
|
||||||
|
private boolean _active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean read(GameClient client, PacketReader packet)
|
public boolean read(GameClient client, PacketReader packet)
|
||||||
{
|
{
|
||||||
_room = packet.readH();
|
final int position = packet.readH();
|
||||||
_activate = packet.readC() == 1;
|
_slot = position % ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_page = position / ShortCuts.MAX_SHORTCUTS_PER_BAR;
|
||||||
|
_active = packet.readC() == 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +59,20 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int slot = _room % 12;
|
final Shortcut shortcut = player.getShortCut(_slot, _page);
|
||||||
final int page = _room / 12;
|
|
||||||
final Shortcut shortcut = player.getShortCut(slot, page);
|
|
||||||
if (shortcut == null)
|
if (shortcut == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
client.sendPacket(new ExActivateAutoShortcut(_room, _activate));
|
|
||||||
|
if (_active)
|
||||||
|
{
|
||||||
|
player.addAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.removeAutoShortcut(_slot, _page);
|
||||||
|
}
|
||||||
|
|
||||||
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
final ItemInstance item = player.getInventory().getItemByObjectId(shortcut.getId());
|
||||||
Skill skill = null;
|
Skill skill = null;
|
||||||
@@ -73,7 +82,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
if (!_activate)
|
if (!_active)
|
||||||
{
|
{
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
@@ -111,7 +120,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// auto potion
|
// auto potion
|
||||||
if ((page == 23) && (slot == 1))
|
if ((_page == 23) && (_slot == 1))
|
||||||
{
|
{
|
||||||
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-8
@@ -17,29 +17,31 @@
|
|||||||
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
package org.l2jmobius.gameserver.network.serverpackets.autoplay;
|
||||||
|
|
||||||
import org.l2jmobius.commons.network.PacketWriter;
|
import org.l2jmobius.commons.network.PacketWriter;
|
||||||
|
import org.l2jmobius.gameserver.model.ShortCuts;
|
||||||
|
import org.l2jmobius.gameserver.model.Shortcut;
|
||||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JoeAlisson
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
public class ExActivateAutoShortcut implements IClientOutgoingPacket
|
||||||
{
|
{
|
||||||
private final int _room;
|
private final int _position;
|
||||||
private final boolean _activate;
|
private final boolean _active;
|
||||||
|
|
||||||
public ExActivateAutoShortcut(int room, boolean activate)
|
public ExActivateAutoShortcut(Shortcut shortcut, boolean active)
|
||||||
{
|
{
|
||||||
_room = room;
|
_position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||||
_activate = activate;
|
_active = active;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean write(PacketWriter packet)
|
public boolean write(PacketWriter packet)
|
||||||
{
|
{
|
||||||
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
OutgoingPackets.EX_ACTIVATE_AUTO_SHORTCUT.writeId(packet);
|
||||||
packet.writeH(_room);
|
packet.writeH(_position);
|
||||||
packet.writeC(_activate ? 0x01 : 0x00);
|
packet.writeC(_active ? 0x01 : 0x00);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user