mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 13:15:28 +01:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
15351c61c8
@ -88,10 +88,10 @@ public class BentoBox extends JavaPlugin {
|
||||
if (!ServerCompatibility.getInstance().checkCompatibility(this).isCanLaunch()) {
|
||||
// The server's most likely incompatible.
|
||||
// Show a warning
|
||||
getServer().getLogger().warning("************ Disclaimer **************");
|
||||
getServer().getLogger().warning("BentoBox may not be compatible with this server!");
|
||||
getServer().getLogger().warning("BentoBox is tested only on the latest version of Spigot.");
|
||||
return;
|
||||
logWarning("************ Disclaimer **************");
|
||||
logWarning("BentoBox may not be compatible with this server!");
|
||||
logWarning("BentoBox is tested only on the latest version of Spigot.");
|
||||
logWarning("**************************************");
|
||||
}
|
||||
|
||||
// Not loaded
|
||||
|
@ -0,0 +1,38 @@
|
||||
package world.bentobox.bentobox.api.events;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Fired when a message is going to an offline player
|
||||
*
|
||||
* @author tastybento
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class OfflineMessageEvent extends PremadeEvent {
|
||||
private final UUID offlinePlayer;
|
||||
private final String message;
|
||||
|
||||
/**
|
||||
* @param offlinePlayer
|
||||
* @param message
|
||||
*/
|
||||
public OfflineMessageEvent(UUID offlinePlayer, String message) {
|
||||
this.offlinePlayer = offlinePlayer;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the offlinePlayer
|
||||
*/
|
||||
public UUID getOfflinePlayer() {
|
||||
return offlinePlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
@ -21,11 +21,12 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.events.OfflineMessageEvent;
|
||||
|
||||
/**
|
||||
* Combines {@link Player}, {@link OfflinePlayer} and {@link CommandSender} to provide convenience methods related to
|
||||
@ -131,6 +132,7 @@ public class User {
|
||||
private Player player;
|
||||
private OfflinePlayer offlinePlayer;
|
||||
private final UUID playerUUID;
|
||||
@Nullable
|
||||
private final CommandSender sender;
|
||||
|
||||
private Addon addon;
|
||||
@ -368,8 +370,8 @@ public class User {
|
||||
*/
|
||||
public void sendMessage(String reference, String... variables) {
|
||||
String message = getTranslation(reference, variables);
|
||||
if (!ChatColor.stripColor(message).trim().isEmpty() && sender != null) {
|
||||
sender.sendMessage(message);
|
||||
if (!ChatColor.stripColor(message).trim().isEmpty()) {
|
||||
sendRawMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,6 +382,9 @@ public class User {
|
||||
public void sendRawMessage(String message) {
|
||||
if (sender != null) {
|
||||
sender.sendMessage(message);
|
||||
} else {
|
||||
// Offline player fire event
|
||||
Bukkit.getPluginManager().callEvent(new OfflineMessageEvent(this.playerUUID, message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,7 @@ public class AdminTeamAddCommandTest {
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
|
@ -108,6 +108,7 @@ public class AdminTeamDisbandCommandTest {
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
|
@ -107,6 +107,7 @@ public class AdminTeamKickCommandTest {
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
|
@ -112,6 +112,7 @@ public class IslandTeamKickCommandTest {
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
|
@ -84,6 +84,7 @@ public class UserTest {
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
when(Bukkit.getPlayer(Mockito.any(UUID.class))).thenReturn(player);
|
||||
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
@ -451,8 +452,8 @@ public class UserTest {
|
||||
User u = User.getInstance(player);
|
||||
assertEquals(33, u.getPermissionValue("bskyblock.max", 2));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test for {@link User#getPermissionValue(String, int)}
|
||||
*/
|
||||
@ -473,7 +474,7 @@ public class UserTest {
|
||||
User u = User.getInstance(player);
|
||||
assertEquals(-1, u.getPermissionValue("bskyblock.max", 2));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test for {@link User#getPermissionValue(String, int)}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user