@Test public void shiftAfterRemoval() { Executable oneZero = addAtSlot(1, 0); Executable oneTen = addAtSlot(1, 10); Executable one53 = addAtSlot(1, 53); Executable twoZero = addAtSlot(2, 0); Executable twoTwenty = addAtSlot(2, 20); Executable two53 = addAtSlot(2, 53); Executable threeZero = addAtSlot(3, 0); Executable threeForty = addAtSlot(3, 40); Executable three53 = addAtSlot(3, 53); slotActions.shiftAfterPageRemoval(2); executeAndAssertCalled(1, 0, oneZero, true); executeAndAssertCalled(1, 10, oneTen, true); executeAndAssertCalled(1, 53, one53, true); executeAndAssertCalled(2, 0, threeZero, true); executeAndAssertCalled(2, 40, threeForty, true); executeAndAssertCalled(2, 53, three53, true); for (int i = 0; i < 4; i++) { for (int j = 0; j < 55; j++) { executeAndAssertCalled(i, j, twoZero, false); executeAndAssertCalled(i, j, twoTwenty, false); executeAndAssertCalled(i, j, two53, false); } } }
public void shiftAfterPageRemoval(int removedPage) { Map<Integer, Executable> shiftedIndexes = new HashMap<>(); for (Map.Entry<Integer, Executable> entry : actions.entrySet()) { int key = entry.getKey(); if (key / INVENTORY_SIZE != removedPage) { if (key >= (removedPage + 1) * INVENTORY_SIZE) { key = key - INVENTORY_SIZE; } shiftedIndexes.put(key, entry.getValue()); } } this.actions.clear(); this.actions.putAll(shiftedIndexes); }
SlotActions { public void shiftAfterPageRemoval(int removedPage) { Map<Integer, Executable> shiftedIndexes = new HashMap<>(); for (Map.Entry<Integer, Executable> entry : actions.entrySet()) { int key = entry.getKey(); if (key / INVENTORY_SIZE != removedPage) { if (key >= (removedPage + 1) * INVENTORY_SIZE) { key = key - INVENTORY_SIZE; } shiftedIndexes.put(key, entry.getValue()); } } this.actions.clear(); this.actions.putAll(shiftedIndexes); } }
SlotActions { public void shiftAfterPageRemoval(int removedPage) { Map<Integer, Executable> shiftedIndexes = new HashMap<>(); for (Map.Entry<Integer, Executable> entry : actions.entrySet()) { int key = entry.getKey(); if (key / INVENTORY_SIZE != removedPage) { if (key >= (removedPage + 1) * INVENTORY_SIZE) { key = key - INVENTORY_SIZE; } shiftedIndexes.put(key, entry.getValue()); } } this.actions.clear(); this.actions.putAll(shiftedIndexes); }  }
SlotActions { public void shiftAfterPageRemoval(int removedPage) { Map<Integer, Executable> shiftedIndexes = new HashMap<>(); for (Map.Entry<Integer, Executable> entry : actions.entrySet()) { int key = entry.getKey(); if (key / INVENTORY_SIZE != removedPage) { if (key >= (removedPage + 1) * INVENTORY_SIZE) { key = key - INVENTORY_SIZE; } shiftedIndexes.put(key, entry.getValue()); } } this.actions.clear(); this.actions.putAll(shiftedIndexes); }  void executeSlotAction(UUID playerId, int sourceSlot); void shiftAfterPageRemoval(int removedPage); void removeSlotAction(int page, int slot); void addSlotAction(InventoryItem inventoryItem, Executable executable); void clear(); }
SlotActions { public void shiftAfterPageRemoval(int removedPage) { Map<Integer, Executable> shiftedIndexes = new HashMap<>(); for (Map.Entry<Integer, Executable> entry : actions.entrySet()) { int key = entry.getKey(); if (key / INVENTORY_SIZE != removedPage) { if (key >= (removedPage + 1) * INVENTORY_SIZE) { key = key - INVENTORY_SIZE; } shiftedIndexes.put(key, entry.getValue()); } } this.actions.clear(); this.actions.putAll(shiftedIndexes); }  void executeSlotAction(UUID playerId, int sourceSlot); void shiftAfterPageRemoval(int removedPage); void removeSlotAction(int page, int slot); void addSlotAction(InventoryItem inventoryItem, Executable executable); void clear();  }