mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-12-26 11:08:15 +01:00
Use a constant instead of 10 throughout code.
This commit is contained in:
parent
e0736fca4c
commit
eba7e1d531
@ -42,6 +42,9 @@ import world.bentobox.level.requests.TopTenRequestHandler;
|
||||
*/
|
||||
public class Level extends Addon implements Listener {
|
||||
|
||||
// The 10 in top ten
|
||||
public static final int TEN = 10;
|
||||
|
||||
// Settings
|
||||
private ConfigSettings settings;
|
||||
private Config<ConfigSettings> configObject = new Config<>(this, ConfigSettings.class);
|
||||
@ -201,16 +204,16 @@ public class Level extends Addon implements Listener {
|
||||
|
||||
String getRankName(World world, int rank) {
|
||||
if (rank < 1) rank = 1;
|
||||
if (rank > 10) rank = 10;
|
||||
return getPlayers().getName(getManager().getTopTen(world, 10).keySet().stream().skip(rank - 1L).limit(1L).findFirst().orElse(null));
|
||||
if (rank > TEN) rank = TEN;
|
||||
return getPlayers().getName(getManager().getTopTen(world, TEN).keySet().stream().skip(rank - 1L).limit(1L).findFirst().orElse(null));
|
||||
}
|
||||
|
||||
String getRankLevel(World world, int rank) {
|
||||
if (rank < 1) rank = 1;
|
||||
if (rank > 10) rank = 10;
|
||||
if (rank > TEN) rank = TEN;
|
||||
return getManager()
|
||||
.formatLevel(getManager()
|
||||
.getTopTen(world, 10)
|
||||
.getTopTen(world, TEN)
|
||||
.values()
|
||||
.stream()
|
||||
.skip(rank - 1L)
|
||||
|
@ -241,7 +241,7 @@ public class LevelsManager {
|
||||
*/
|
||||
public void getGUI(World world, final User user) {
|
||||
// Check world
|
||||
Map<UUID, Long> topTen = getTopTen(world, 10);
|
||||
Map<UUID, Long> topTen = getTopTen(world, Level.TEN);
|
||||
|
||||
PanelBuilder panel = new PanelBuilder()
|
||||
.name(user.getTranslation("island.top.gui-title"))
|
||||
|
@ -30,7 +30,7 @@ public class AdminTopCommand extends CompositeCommand {
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
user.sendMessage("island.top.gui-title");
|
||||
int rank = 0;
|
||||
for (Map.Entry<UUID, Long> topTen : levelPlugin.getManager().getTopTen(getWorld(), 10).entrySet()) {
|
||||
for (Map.Entry<UUID, Long> topTen : levelPlugin.getManager().getTopTen(getWorld(), Level.TEN).entrySet()) {
|
||||
Island island = getPlugin().getIslands().getIsland(getWorld(), topTen.getKey());
|
||||
if (island != null) {
|
||||
rank++;
|
||||
|
@ -59,7 +59,7 @@ public class AdminTopRemoveCommand extends CompositeCommand {
|
||||
|
||||
@Override
|
||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||
return Optional.of(addon.getManager().getTopTen(getWorld(), 10).keySet().stream().map(addon.getPlayers()::getName)
|
||||
return Optional.of(addon.getManager().getTopTen(getWorld(), Level.TEN).keySet().stream().map(addon.getPlayers()::getName)
|
||||
.filter(n -> !n.isEmpty()).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,6 @@ public class TopTenRequestHandler extends AddonRequestHandler {
|
||||
}
|
||||
|
||||
// No null check required
|
||||
return addon.getManager().getTopTen(Bukkit.getWorld((String) map.get(WORLD_NAME)), 10);
|
||||
return addon.getManager().getTopTen(Bukkit.getWorld((String) map.get(WORLD_NAME)), Level.TEN);
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ public class LevelsManagerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testGetTopTenEmpty() {
|
||||
Map<UUID, Long> tt = lm.getTopTen(world, 10);
|
||||
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
||||
assertTrue(tt.isEmpty());
|
||||
}
|
||||
|
||||
@ -347,7 +347,7 @@ public class LevelsManagerTest {
|
||||
@Test
|
||||
public void testGetTopTen() {
|
||||
testLoadTopTens();
|
||||
Map<UUID, Long> tt = lm.getTopTen(world, 10);
|
||||
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
||||
assertFalse(tt.isEmpty());
|
||||
assertEquals(1, tt.size());
|
||||
assertEquals(1, lm.getTopTen(world, 1).size());
|
||||
@ -360,7 +360,7 @@ public class LevelsManagerTest {
|
||||
public void testGetTopTenNoOwners() {
|
||||
when(im.isOwner(eq(world), any())).thenReturn(false);
|
||||
testLoadTopTens();
|
||||
Map<UUID, Long> tt = lm.getTopTen(world, 10);
|
||||
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
||||
assertTrue(tt.isEmpty());
|
||||
}
|
||||
|
||||
@ -394,10 +394,10 @@ public class LevelsManagerTest {
|
||||
@Test
|
||||
public void testRemoveEntry() {
|
||||
testLoadTopTens();
|
||||
Map<UUID, Long> tt = lm.getTopTen(world, 10);
|
||||
Map<UUID, Long> tt = lm.getTopTen(world, Level.TEN);
|
||||
assertTrue(tt.containsKey(uuid));
|
||||
lm.removeEntry(world, uuid);
|
||||
tt = lm.getTopTen(world, 10);
|
||||
tt = lm.getTopTen(world, Level.TEN);
|
||||
assertFalse(tt.containsKey(uuid));
|
||||
}
|
||||
|
||||
@ -414,8 +414,8 @@ public class LevelsManagerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetInitialIslandLevel() {
|
||||
lm.setInitialIslandLevel(island, 10);
|
||||
assertEquals(10, lm.getInitialLevel(island));
|
||||
lm.setInitialIslandLevel(island, Level.TEN);
|
||||
assertEquals(Level.TEN, lm.getInitialLevel(island));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user