Fix tests and refactor code

This commit is contained in:
tastybento 2021-10-08 17:15:41 -07:00
parent b5d9d2e52e
commit fe2e9e1a9e
2 changed files with 7 additions and 10 deletions

View File

@ -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

View File

@ -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);