Restore auto use shortcuts after level change.

Contributed by nasseka.
This commit is contained in:
MobiusDevelopment
2021-12-10 01:33:00 +00:00
parent aa8252283c
commit 354b21b9f0
8 changed files with 72 additions and 64 deletions
@@ -2677,6 +2677,7 @@ public class Player extends Playable
sendPacket(new ShortCutInit(this)); sendPacket(new ShortCutInit(this));
sendMessage("You have learned " + skillCounter + " new skills."); sendMessage("You have learned " + skillCounter + " new skills.");
} }
restoreAutoShortcutVisual();
return skillCounter; return skillCounter;
} }
@@ -14265,29 +14266,29 @@ public class Player extends Playable
public void restoreAutoShortcutVisual() public void restoreAutoShortcutVisual()
{ {
if (_autoUseSettings.isEmpty()) if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
{ {
return; return;
} }
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
for (Shortcut shortcut : getAllShortCuts()) for (Shortcut shortcut : getAllShortCuts())
{ {
if (!shortcut.isAutoUse()) final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
if (!positions.contains(position))
{ {
continue; continue;
} }
if (_autoUseSettings.isAutoSkill(shortcut.getId())) final Skill knownSkill = getKnownSkill(shortcut.getId());
{ if (knownSkill != null)
if (getKnownSkill(shortcut.getId()) != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
}
else else
{ {
final Item item = getInventory().getItemByObjectId(shortcut.getId()); final Item item = getInventory().getItemByObjectId(shortcut.getId());
if ((item != null) && _autoUseSettings.getAutoSupplyItems().contains(item.getId())) if (item != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
@@ -2707,6 +2707,7 @@ public class Player extends Playable
sendPacket(new ShortCutInit(this)); sendPacket(new ShortCutInit(this));
sendMessage("You have learned " + skillCounter + " new skills."); sendMessage("You have learned " + skillCounter + " new skills.");
} }
restoreAutoShortcutVisual();
return skillCounter; return skillCounter;
} }
@@ -14334,29 +14335,29 @@ public class Player extends Playable
public void restoreAutoShortcutVisual() public void restoreAutoShortcutVisual()
{ {
if (_autoUseSettings.isEmpty()) if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
{ {
return; return;
} }
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
for (Shortcut shortcut : getAllShortCuts()) for (Shortcut shortcut : getAllShortCuts())
{ {
if (!shortcut.isAutoUse()) final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
if (!positions.contains(position))
{ {
continue; continue;
} }
if (_autoUseSettings.isAutoSkill(shortcut.getId())) final Skill knownSkill = getKnownSkill(shortcut.getId());
{ if (knownSkill != null)
if (getKnownSkill(shortcut.getId()) != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
}
else else
{ {
final Item item = getInventory().getItemByObjectId(shortcut.getId()); final Item item = getInventory().getItemByObjectId(shortcut.getId());
if ((item != null) && _autoUseSettings.getAutoSupplyItems().contains(item.getId())) if (item != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
@@ -2724,6 +2724,7 @@ public class Player extends Playable
sendPacket(new ShortCutInit(this)); sendPacket(new ShortCutInit(this));
sendMessage("You have learned " + skillCounter + " new skills."); sendMessage("You have learned " + skillCounter + " new skills.");
} }
restoreAutoShortcutVisual();
return skillCounter; return skillCounter;
} }
@@ -14371,29 +14372,29 @@ public class Player extends Playable
public void restoreAutoShortcutVisual() public void restoreAutoShortcutVisual()
{ {
if (_autoUseSettings.isEmpty()) if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
{ {
return; return;
} }
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
for (Shortcut shortcut : getAllShortCuts()) for (Shortcut shortcut : getAllShortCuts())
{ {
if (!shortcut.isAutoUse()) final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
if (!positions.contains(position))
{ {
continue; continue;
} }
if (_autoUseSettings.isAutoSkill(shortcut.getId())) final Skill knownSkill = getKnownSkill(shortcut.getId());
{ if (knownSkill != null)
if (getKnownSkill(shortcut.getId()) != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
}
else else
{ {
final Item item = getInventory().getItemByObjectId(shortcut.getId()); final Item item = getInventory().getItemByObjectId(shortcut.getId());
if ((item != null) && _autoUseSettings.getAutoSupplyItems().contains(item.getId())) if (item != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
@@ -2726,6 +2726,7 @@ public class Player extends Playable
sendPacket(new ShortCutInit(this)); sendPacket(new ShortCutInit(this));
sendMessage("You have learned " + skillCounter + " new skills."); sendMessage("You have learned " + skillCounter + " new skills.");
} }
restoreAutoShortcutVisual();
return skillCounter; return skillCounter;
} }
@@ -14421,29 +14422,29 @@ public class Player extends Playable
public void restoreAutoShortcutVisual() public void restoreAutoShortcutVisual()
{ {
if (_autoUseSettings.isEmpty()) if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
{ {
return; return;
} }
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
for (Shortcut shortcut : getAllShortCuts()) for (Shortcut shortcut : getAllShortCuts())
{ {
if (!shortcut.isAutoUse()) final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
if (!positions.contains(position))
{ {
continue; continue;
} }
if (_autoUseSettings.isAutoSkill(shortcut.getId())) final Skill knownSkill = getKnownSkill(shortcut.getId());
{ if (knownSkill != null)
if (getKnownSkill(shortcut.getId()) != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
}
else else
{ {
final Item item = getInventory().getItemByObjectId(shortcut.getId()); final Item item = getInventory().getItemByObjectId(shortcut.getId());
if ((item != null) && _autoUseSettings.getAutoSupplyItems().contains(item.getId())) if (item != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
@@ -2604,6 +2604,7 @@ public class Player extends Playable
sendPacket(new ShortCutInit(this)); sendPacket(new ShortCutInit(this));
sendMessage("You have learned " + skillCounter + " new skills."); sendMessage("You have learned " + skillCounter + " new skills.");
} }
restoreAutoShortcutVisual();
return skillCounter; return skillCounter;
} }
@@ -14212,29 +14213,29 @@ public class Player extends Playable
public void restoreAutoShortcutVisual() public void restoreAutoShortcutVisual()
{ {
if (_autoUseSettings.isEmpty()) if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
{ {
return; return;
} }
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
for (Shortcut shortcut : getAllShortCuts()) for (Shortcut shortcut : getAllShortCuts())
{ {
if (!shortcut.isAutoUse()) final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
if (!positions.contains(position))
{ {
continue; continue;
} }
if (_autoUseSettings.isAutoSkill(shortcut.getId())) final Skill knownSkill = getKnownSkill(shortcut.getId());
{ if (knownSkill != null)
if (getKnownSkill(shortcut.getId()) != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
}
else else
{ {
final Item item = getInventory().getItemByObjectId(shortcut.getId()); final Item item = getInventory().getItemByObjectId(shortcut.getId());
if ((item != null) && _autoUseSettings.getAutoSupplyItems().contains(item.getId())) if (item != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
@@ -2676,6 +2676,7 @@ public class Player extends Playable
sendPacket(new ShortCutInit(this)); sendPacket(new ShortCutInit(this));
sendMessage("You have learned " + skillCounter + " new skills."); sendMessage("You have learned " + skillCounter + " new skills.");
} }
restoreAutoShortcutVisual();
return skillCounter; return skillCounter;
} }
@@ -14479,29 +14480,29 @@ public class Player extends Playable
public void restoreAutoShortcutVisual() public void restoreAutoShortcutVisual()
{ {
if (_autoUseSettings.isEmpty()) if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
{ {
return; return;
} }
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
for (Shortcut shortcut : getAllShortCuts()) for (Shortcut shortcut : getAllShortCuts())
{ {
if (!shortcut.isAutoUse()) final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
if (!positions.contains(position))
{ {
continue; continue;
} }
if (_autoUseSettings.isAutoSkill(shortcut.getId())) final Skill knownSkill = getKnownSkill(shortcut.getId());
{ if (knownSkill != null)
if (getKnownSkill(shortcut.getId()) != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
}
else else
{ {
final Item item = getInventory().getItemByObjectId(shortcut.getId()); final Item item = getInventory().getItemByObjectId(shortcut.getId());
if ((item != null) && _autoUseSettings.getAutoSupplyItems().contains(item.getId())) if (item != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
@@ -2707,6 +2707,7 @@ public class Player extends Playable
sendPacket(new ShortCutInit(this)); sendPacket(new ShortCutInit(this));
sendMessage("You have learned " + skillCounter + " new skills."); sendMessage("You have learned " + skillCounter + " new skills.");
} }
restoreAutoShortcutVisual();
return skillCounter; return skillCounter;
} }
@@ -14556,29 +14557,29 @@ public class Player extends Playable
public void restoreAutoShortcutVisual() public void restoreAutoShortcutVisual()
{ {
if (_autoUseSettings.isEmpty()) if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
{ {
return; return;
} }
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
for (Shortcut shortcut : getAllShortCuts()) for (Shortcut shortcut : getAllShortCuts())
{ {
if (!shortcut.isAutoUse()) final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
if (!positions.contains(position))
{ {
continue; continue;
} }
if (_autoUseSettings.isAutoSkill(shortcut.getId())) final Skill knownSkill = getKnownSkill(shortcut.getId());
{ if (knownSkill != null)
if (getKnownSkill(shortcut.getId()) != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
}
else else
{ {
final Item item = getInventory().getItemByObjectId(shortcut.getId()); final Item item = getInventory().getItemByObjectId(shortcut.getId());
if ((item != null) && _autoUseSettings.getAutoSupplyItems().contains(item.getId())) if (item != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
@@ -2707,6 +2707,7 @@ public class Player extends Playable
sendPacket(new ShortCutInit(this)); sendPacket(new ShortCutInit(this));
sendMessage("You have learned " + skillCounter + " new skills."); sendMessage("You have learned " + skillCounter + " new skills.");
} }
restoreAutoShortcutVisual();
return skillCounter; return skillCounter;
} }
@@ -14556,29 +14557,29 @@ public class Player extends Playable
public void restoreAutoShortcutVisual() public void restoreAutoShortcutVisual()
{ {
if (_autoUseSettings.isEmpty()) if (!getVariables().contains(PlayerVariables.AUTO_USE_SHORTCUTS))
{ {
return; return;
} }
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
for (Shortcut shortcut : getAllShortCuts()) for (Shortcut shortcut : getAllShortCuts())
{ {
if (!shortcut.isAutoUse()) final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
if (!positions.contains(position))
{ {
continue; continue;
} }
if (_autoUseSettings.isAutoSkill(shortcut.getId())) final Skill knownSkill = getKnownSkill(shortcut.getId());
{ if (knownSkill != null)
if (getKnownSkill(shortcut.getId()) != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }
}
else else
{ {
final Item item = getInventory().getItemByObjectId(shortcut.getId()); final Item item = getInventory().getItemByObjectId(shortcut.getId());
if ((item != null) && _autoUseSettings.getAutoSupplyItems().contains(item.getId())) if (item != null)
{ {
sendPacket(new ExActivateAutoShortcut(shortcut, true)); sendPacket(new ExActivateAutoShortcut(shortcut, true));
} }