mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-10 01:11:29 +01:00
Added specific messages when entering/leaving an island the player is member of
Implements https://github.com/BentoBoxWorld/BentoBox/issues/1084 Improved color codes for existing messages
This commit is contained in:
parent
e62240f523
commit
37a4145322
@ -100,8 +100,15 @@ public class EnterExitListener extends FlagListener {
|
||||
// Send message if island is owned by someone
|
||||
if (island.isOwned()) {
|
||||
// Leave messages are always specific to this world
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
||||
user.getTranslation(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.island", 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(), "protection.flags.ENTER_EXIT_MESSAGES.island", TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
||||
} else {
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
||||
user.getTranslation(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.island", TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
||||
}
|
||||
}
|
||||
// Send message if island is unowned, but has a name
|
||||
else if (island.getName() != null) {
|
||||
@ -123,9 +130,15 @@ public class EnterExitListener extends FlagListener {
|
||||
|
||||
// Send message if island is owned by someone
|
||||
if (island.isOwned()) {
|
||||
// Leave messages are always specific to this world
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
||||
user.getTranslation(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.island", TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
||||
// Enter messages are always specific to this world
|
||||
// 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(), "protection.flags.ENTER_EXIT_MESSAGES.island", TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
||||
} else {
|
||||
user.notify(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (island.getName() != null) ? island.getName() :
|
||||
user.getTranslation(island.getWorld(), "protection.flags.ENTER_EXIT_MESSAGES.island", TextVariables.NAME, getPlugin().getPlayers().getName(island.getOwner())));
|
||||
}
|
||||
}
|
||||
// Send message if island is unowned, but has a name
|
||||
else if (island.getName() != null) {
|
||||
|
@ -834,8 +834,10 @@ protection:
|
||||
description: "Display entry and exit messages"
|
||||
island: "[name]'s island"
|
||||
name: "Enter/Exit messages"
|
||||
now-entering: "&b Now entering [name]"
|
||||
now-leaving: "&b Now leaving [name]"
|
||||
now-entering: "&a Now entering &b [name]&a ."
|
||||
now-entering-your-island: "&a Now entering your island."
|
||||
now-leaving: "&a Now leaving &b [name]&a ."
|
||||
now-leaving-your-island: "&a Now leaving your island."
|
||||
EXPERIENCE_BOTTLE_THROWING:
|
||||
name: "Experience bottle throwing"
|
||||
description: "Toggle throwing experience bottles."
|
||||
|
@ -14,6 +14,8 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -136,6 +138,7 @@ public class EnterExitListenerTest {
|
||||
when(island.getCenter()).thenReturn(loc);
|
||||
when(island.getProtectionRange()).thenReturn(PROTECTION_RANGE);
|
||||
when(island.getOwner()).thenReturn(uuid);
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid));
|
||||
when(island.isOwned()).thenReturn(true);
|
||||
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(island);
|
||||
@ -376,4 +379,5 @@ public class EnterExitListenerTest {
|
||||
verify(pim).callEvent(any(IslandExitEvent.class));
|
||||
}
|
||||
|
||||
// TODO add tests to make sure the enter/exit messages work properly when on an island the player is part of.
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user