StatSet getIntegerList rework and addition of setIntegerList.
This commit is contained in:
@ -392,16 +392,50 @@ public class StatSet implements IParserAdvUtils
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Integer> getIntegerList(String key, String splitOn)
|
||||
public List<Integer> getIntegerList(String key)
|
||||
{
|
||||
final List<Integer> result = new ArrayList<>();
|
||||
for (int i : getIntArray(key, splitOn))
|
||||
final String val = getString(key, null);
|
||||
final List<Integer> result;
|
||||
if (val != null)
|
||||
{
|
||||
result.add(i);
|
||||
final String[] splitVal = val.split(",");
|
||||
result = new ArrayList<>(splitVal.length + 1);
|
||||
for (String split : splitVal)
|
||||
{
|
||||
result.add(Integer.parseInt(split));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new ArrayList<>(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setIntegerList(String key, List<Integer> list)
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((list == null) || list.isEmpty())
|
||||
{
|
||||
remove(key);
|
||||
return;
|
||||
}
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int element : list)
|
||||
{
|
||||
sb.append(element);
|
||||
sb.append(",");
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1); // Prettify value.
|
||||
|
||||
set(key, sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(String key)
|
||||
{
|
||||
|
@ -14336,7 +14336,7 @@ public class PlayerInstance extends Playable
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||
for (Shortcut shortcut : getAllShortCuts())
|
||||
{
|
||||
final Integer position = shortcut.getSlot() + (shortcut.getPage() * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||
@ -14366,16 +14366,7 @@ public class PlayerInstance extends Playable
|
||||
|
||||
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 List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||
if (usedShortcut == null)
|
||||
{
|
||||
@ -14399,20 +14390,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
|
||||
}
|
||||
|
||||
public synchronized void removeAutoShortcut(int slot, int page)
|
||||
@ -14422,7 +14400,7 @@ public class PlayerInstance extends Playable
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||
final List<Integer> positions = getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||
final Shortcut usedShortcut = getShortCut(slot, page);
|
||||
if (usedShortcut == null)
|
||||
{
|
||||
@ -14443,20 +14421,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
|
||||
}
|
||||
|
||||
public boolean isInTimedHuntingZone(int zoneId)
|
||||
|
@ -76,9 +76,9 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
||||
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))
|
||||
if (!player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
{
|
||||
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, ",");
|
||||
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))
|
||||
{
|
||||
@ -86,21 +86,7 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
player.getVariables().setIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS, positions);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user