mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-18 21:32:04 +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
|
// Send message if island is owned by someone
|
||||||
if (island.isOwned()) {
|
if (island.isOwned()) {
|
||||||
// Leave messages are always specific to this world
|
// 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
|
// Send specific message if the player is member of this island
|
||||||
if (island.getMemberSet().contains(user.getUniqueId())) {
|
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.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
|
||||||
user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
|
||||||
} else {
|
} else {
|
||||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
|
||||||
user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Send message if island is unowned, but has a name
|
// 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())) {
|
if (!Flags.ENTER_EXIT_MESSAGES.isSetForWorld(island.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send message if island is owned by someone
|
// Send message if island is owned by someone
|
||||||
if (island.isOwned()) {
|
if (island.isOwned()) {
|
||||||
// Enter messages are always specific to this world
|
// 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
|
// Send specific message if the player is member of this island
|
||||||
if (island.getMemberSet().contains(user.getUniqueId())) {
|
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.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering-your-island", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
|
||||||
user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
|
||||||
} else {
|
} else {
|
||||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (island.getName() != null) ? island.getName() : islandMessage);
|
||||||
user.getTranslation(island.getWorld(), ISLAND_MESSAGE, TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Send message if island is unowned, but has a name
|
// Send message if island is unowned, but has a name
|
||||||
|
@ -140,6 +140,7 @@ public class EnterExitListenerTest {
|
|||||||
when(island.getOwner()).thenReturn(uuid);
|
when(island.getOwner()).thenReturn(uuid);
|
||||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid));
|
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid));
|
||||||
when(island.isOwned()).thenReturn(true);
|
when(island.isOwned()).thenReturn(true);
|
||||||
|
when(island.getWorld()).thenReturn(world);
|
||||||
|
|
||||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(island);
|
when(im.getIsland(any(), any(UUID.class))).thenReturn(island);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user