Skip to content

Commit

Permalink
add UUID to MaskSlot
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Feb 2, 2024
1 parent 4c6514d commit 7d2561a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
* The slot for the mask
* The slot for the mask.
* Used to get the slots for the unique id.
*/
public interface MaskSlot {
/**
Expand All @@ -20,7 +22,7 @@ public interface MaskSlot {
*/
@NotNull
static MaskSlot of(@NotNull List<@NotNull Integer> slots) {
return () -> slots;
return uuid -> slots;
}

/**
Expand All @@ -33,7 +35,7 @@ static MaskSlot of(@NotNull List<@NotNull Integer> slots) {
@NotNull
static MaskSlot of(@NotNull Integer... slots) {
List<Integer> slotList = Arrays.asList(slots);
return () -> slotList;
return uuid -> slotList;
}

/**
Expand All @@ -51,8 +53,10 @@ static MaskSlot of(IntStream slotStream) {
/**
* Get the slots
*
* @param uuid the unique id
*
* @return the slots
*/
@NotNull
List<Integer> getSlots();
List<Integer> getSlots(UUID uuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public MaskSlot getMaskSlot() {
@Override
public @NotNull Map<Integer, Button> generateButtons(@NotNull UUID uuid, int size) {
List<Button> buttons = getButtons(uuid);
List<Integer> slots = this.maskSlot.getSlots();
List<Integer> slots = this.maskSlot.getSlots(uuid);
if (buttons.isEmpty() || slots.isEmpty()) {
return Collections.emptyMap();
}
Expand Down Expand Up @@ -74,7 +74,7 @@ public void stop() {

@Override
public int getPageAmount(@NotNull UUID uuid) {
List<Integer> slots = this.maskSlot.getSlots();
List<Integer> slots = this.maskSlot.getSlots(uuid);
return slots.isEmpty() ? 0 : (int) Math.ceil((double) getButtons(uuid).size() / slots.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public MaskSlot getMaskSlot() {
@Override
public @NotNull Map<Integer, Button> generateButtons(@NotNull UUID uuid, int size) {
Map<Integer, Button> map = new HashMap<>();
List<Integer> slots = this.maskSlot.getSlots();
List<Integer> slots = this.maskSlot.getSlots(uuid);
if (!this.buttons.isEmpty() && !slots.isEmpty()) {
int slotsSize = slots.size();
int buttonsSize = this.buttons.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public MaskSlot getMaskSlot() {
@Override
public @NotNull Map<Integer, Button> generateButtons(@NotNull UUID uuid, int size) {
List<Button> buttons = getButtons(uuid);
List<Integer> slots = this.maskSlot.getSlots();
List<Integer> slots = this.maskSlot.getSlots(uuid);
if (buttons.isEmpty() || slots.isEmpty()) {
return Collections.emptyMap();
}
Expand Down

0 comments on commit 7d2561a

Please sign in to comment.