mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-13 19:01:28 +01:00
Fix tests and refactor code
This commit is contained in:
parent
b5d9d2e52e
commit
fe2e9e1a9e
@ -105,14 +105,12 @@ public class EnterExitListener extends FlagListener {
|
||||
// Send message if island is owned by someone
|
||||
if (island.isOwned()) {
|
||||
// Leave messages are always specific to this world
|
||||
|
||||
String islandMessage = user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner()));
|
||||
// Send specific message if the player is member of this island
|
||||
if (island.getMemberSet().contains(user.getUniqueId())) {
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
||||
user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
|
||||
} else {
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
||||
user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
|
||||
}
|
||||
}
|
||||
// Send message if island is unowned, but has a name
|
||||
@ -132,17 +130,15 @@ public class EnterExitListener extends FlagListener {
|
||||
if (!Flags.ENTER_EXIT_MESSAGES.isSetForWorld(island.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send message if island is owned by someone
|
||||
if (island.isOwned()) {
|
||||
// Enter messages are always specific to this world
|
||||
String islandMessage = user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner()));
|
||||
// Send specific message if the player is member of this island
|
||||
if (island.getMemberSet().contains(user.getUniqueId())) {
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
||||
user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
|
||||
} else {
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
||||
user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
|
||||
}
|
||||
}
|
||||
// Send message if island is unowned, but has a name
|
||||
|
@ -140,6 +140,7 @@ public class EnterExitListenerTest {
|
||||
when(island.getOwner()).thenReturn(uuid);
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid));
|
||||
when(island.isOwned()).thenReturn(true);
|
||||
when(island.getWorld()).thenReturn(world);
|
||||
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(island);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user