Skip to content

Commit

Permalink
Add Netherboard#hasBoard method, fix error on clear()
Browse files Browse the repository at this point in the history
  • Loading branch information
MinusKube committed Jun 10, 2020
1 parent c5fc2bd commit 6304ddf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
10 changes: 10 additions & 0 deletions bukkit/src/main/java/fr/minuskube/netherboard/Netherboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ public void removeBoard(Player player) {
boards.remove(player);
}

/**
* Checks if the player has a board.
*
* @param player the player
* @return <code>true</code> if the player has a board, otherwise <code>false</code>
*/
public boolean hasBoard(Player player) {
return boards.containsKey(player);
}

/**
* Gets the board of a player.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class BPlayerBoard implements PlayerBoard<String, Integer, String> {
Expand Down Expand Up @@ -125,13 +126,13 @@ public void setAll(String... lines) {
for(int i = 0; i < lines.length; i++) {
String line = lines[i];

set(line, 16 - i);
set(line, lines.length - i);
}
}

@Override
public void clear() {
this.lines.keySet().forEach(this::remove);
new HashSet<>(this.lines.keySet()).forEach(this::remove);
this.lines.clear();
}

Expand Down
10 changes: 10 additions & 0 deletions sponge/src/main/java/fr/minuskube/netherboard/Netherboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ public void removeBoard(Player player) {
boards.remove(player);
}

/**
* Checks if the player has a board.
*
* @param player the player
* @return <code>true</code> if the player has a board, otherwise <code>false</code>
*/
public boolean hasBoard(Player player) {
return boards.containsKey(player);
}

/**
* Gets the board of a player.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.spongepowered.api.text.Text;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class SPlayerBoard implements PlayerBoard<Text, Integer, Text> {
Expand Down Expand Up @@ -129,13 +130,13 @@ public void setAll(Text... lines) {
for(int i = 0; i < lines.length; i++) {
Text line = lines[i];

set(line, 16 - i);
set(line, lines.length - i);
}
}

@Override
public void clear() {
this.lines.keySet().forEach(this::remove);
new HashSet<>(this.lines.keySet()).forEach(this::remove);
this.lines.clear();
}

Expand Down

0 comments on commit 6304ddf

Please sign in to comment.