mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-01 00:10:40 +01:00
parent
bbb8207cf0
commit
a604d5cf82
@ -122,7 +122,7 @@ public class AdminDeleteCommand extends ConfirmableCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute commands when leaving
|
// Execute commands when leaving
|
||||||
Util.runCommands(target, getIWM().getOnLeaveCommands(getWorld()), "leave");
|
Util.runCommands(target, target.getName(), getIWM().getOnLeaveCommands(getWorld()), "leave");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -187,7 +187,7 @@ public class IslandResetCommand extends ConfirmableCommand {
|
|||||||
getIslands().removePlayer(getWorld(), memberUUID);
|
getIslands().removePlayer(getWorld(), memberUUID);
|
||||||
|
|
||||||
// Clean player
|
// Clean player
|
||||||
getPlayers().cleanLeavingPlayer(getWorld(), member, false);
|
getPlayers().cleanLeavingPlayer(getWorld(), member, false, island);
|
||||||
|
|
||||||
// Fire event
|
// Fire event
|
||||||
TeamEvent.builder()
|
TeamEvent.builder()
|
||||||
|
@ -176,6 +176,10 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
|||||||
// Put player back into normal mode
|
// Put player back into normal mode
|
||||||
user.setGameMode(getIWM().getDefaultGameMode(getWorld()));
|
user.setGameMode(getIWM().getDefaultGameMode(getWorld()));
|
||||||
|
|
||||||
|
// Execute commands
|
||||||
|
String ownerName = this.getPlayers().getName(teamIsland.getOwner());
|
||||||
|
Util.runCommands(user, ownerName, getIWM().getOnJoinCommands(getWorld()), "join");
|
||||||
|
|
||||||
});
|
});
|
||||||
// Reset deaths
|
// Reset deaths
|
||||||
if (getIWM().isTeamJoinDeathReset(getWorld())) {
|
if (getIWM().isTeamJoinDeathReset(getWorld())) {
|
||||||
@ -228,7 +232,5 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
|||||||
user.getPlayer().setTotalExperience(0);
|
user.getPlayer().setTotalExperience(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute commands
|
|
||||||
Util.runCommands(user, getIWM().getOnJoinCommands(getWorld()), "join");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
|
|||||||
|
|
||||||
getIslands().removePlayer(getWorld(), targetUUID);
|
getIslands().removePlayer(getWorld(), targetUUID);
|
||||||
// Clean the target player
|
// Clean the target player
|
||||||
getPlayers().cleanLeavingPlayer(getWorld(), target, true);
|
getPlayers().cleanLeavingPlayer(getWorld(), target, true, oldIsland);
|
||||||
|
|
||||||
user.sendMessage("commands.island.team.kick.success", TextVariables.NAME, target.getName());
|
user.sendMessage("commands.island.team.kick.success", TextVariables.NAME, target.getName());
|
||||||
IslandEvent.builder()
|
IslandEvent.builder()
|
||||||
|
@ -82,7 +82,7 @@ public class IslandTeamLeaveCommand extends ConfirmableCommand {
|
|||||||
}
|
}
|
||||||
getIslands().setLeaveTeam(getWorld(), user.getUniqueId());
|
getIslands().setLeaveTeam(getWorld(), user.getUniqueId());
|
||||||
// Clean the player
|
// Clean the player
|
||||||
getPlayers().cleanLeavingPlayer(getWorld(), user, false);
|
getPlayers().cleanLeavingPlayer(getWorld(), user, false, island);
|
||||||
|
|
||||||
// Add cooldown for this player and target
|
// Add cooldown for this player and target
|
||||||
if (getSettings().getInviteCooldown() > 0 && getParent() != null) {
|
if (getSettings().getInviteCooldown() > 0 && getParent() != null) {
|
||||||
|
@ -288,6 +288,8 @@ public interface WorldSettings extends ConfigObject {
|
|||||||
* Available placeholders for the commands are the following:
|
* Available placeholders for the commands are the following:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@code [player]}: name of the player</li>
|
* <li>{@code [player]}: name of the player</li>
|
||||||
|
* <li>{@code [owner]}: name of the owner of the island. When joining a team, this will be the team leader's name. When
|
||||||
|
* creating an island, it is the name of the player</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <br/>
|
* <br/>
|
||||||
* Here are some examples of valid commands to execute:
|
* Here are some examples of valid commands to execute:
|
||||||
@ -345,6 +347,8 @@ public interface WorldSettings extends ConfigObject {
|
|||||||
* Available placeholders for the commands are the following:
|
* Available placeholders for the commands are the following:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@code [player]}: name of the player</li>
|
* <li>{@code [player]}: name of the player</li>
|
||||||
|
* <li>{@code [owner]}: name of the owner of the island. When joining a team, this will be the team leader's name. When
|
||||||
|
* creating an island, it is the name of the player</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* <br/>
|
* <br/>
|
||||||
* Here are some examples of valid commands to execute:
|
* Here are some examples of valid commands to execute:
|
||||||
@ -363,6 +367,22 @@ public interface WorldSettings extends ConfigObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of commands that should be executed when the player respawns after death if {@link Flags#ISLAND_RESPAWN} is true.<br/>
|
* Returns a list of commands that should be executed when the player respawns after death if {@link Flags#ISLAND_RESPAWN} is true.<br/>
|
||||||
|
* These commands are executed by the console, unless otherwise stated using the {@code [SUDO]} prefix, in which case they are executed by the player.<br/>
|
||||||
|
* <br/>
|
||||||
|
* Available placeholders for the commands are the following:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code [player]}: name of the player</li>
|
||||||
|
* <li>{@code [owner]}: name of the owner of the island. When joining a team, this will be the team leader's name. When
|
||||||
|
* creating an island, it is the name of the player</li>
|
||||||
|
* </ul>
|
||||||
|
* <br/>
|
||||||
|
* Here are some examples of valid commands to execute:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code "[SUDO] bbox version"}</li>
|
||||||
|
* <li>{@code "bsbadmin deaths set [player] 0"}</li>
|
||||||
|
* </ul>
|
||||||
|
* <br/>
|
||||||
|
* Note that player-executed commands might not work, as these commands can be run with said player being offline.
|
||||||
* @return a list of commands.
|
* @return a list of commands.
|
||||||
* @since 1.14.0
|
* @since 1.14.0
|
||||||
* @see #getOnJoinCommands()
|
* @see #getOnJoinCommands()
|
||||||
|
@ -11,8 +11,10 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.lists.Flags;
|
import world.bentobox.bentobox.lists.Flags;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
@ -61,14 +63,20 @@ public class IslandRespawnListener extends FlagListener {
|
|||||||
return; // world no longer available
|
return; // world no longer available
|
||||||
}
|
}
|
||||||
World w = Util.getWorld(world);
|
World w = Util.getWorld(world);
|
||||||
|
String ownerName = e.getPlayer().getName();
|
||||||
if (w != null) {
|
if (w != null) {
|
||||||
final Location respawnLocation = getIslands().getSafeHomeLocation(w, User.getInstance(e.getPlayer().getUniqueId()), "");
|
final Location respawnLocation = getIslands().getSafeHomeLocation(w, User.getInstance(e.getPlayer().getUniqueId()), "");
|
||||||
if (respawnLocation != null) {
|
if (respawnLocation != null) {
|
||||||
e.setRespawnLocation(respawnLocation);
|
e.setRespawnLocation(respawnLocation);
|
||||||
|
// Get the island owner name
|
||||||
|
Island island = BentoBox.getInstance().getIslandsManager().getIsland(w, User.getInstance(e.getPlayer()));
|
||||||
|
if (island != null) {
|
||||||
|
ownerName = BentoBox.getInstance().getPlayers().getName(island.getOwner());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Run respawn commands, if any
|
// Run respawn commands, if any
|
||||||
Util.runCommands(User.getInstance(e.getPlayer()), getIWM().getOnRespawnCommands(world), "respawn");
|
Util.runCommands(User.getInstance(e.getPlayer()), ownerName, getIWM().getOnRespawnCommands(world), "respawn");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1172,7 +1172,7 @@ public class IslandsManager {
|
|||||||
user.setGameMode(plugin.getIWM().getDefaultGameMode(world));
|
user.setGameMode(plugin.getIWM().getDefaultGameMode(world));
|
||||||
|
|
||||||
// Execute commands
|
// Execute commands
|
||||||
Util.runCommands(user, plugin.getIWM().getOnJoinCommands(world), "join");
|
Util.runCommands(user, user.getName(), plugin.getIWM().getOnJoinCommands(world), "join");
|
||||||
}
|
}
|
||||||
// Remove from mid-teleport set
|
// Remove from mid-teleport set
|
||||||
goingHome.remove(user.getUniqueId());
|
goingHome.remove(user.getUniqueId());
|
||||||
|
@ -22,6 +22,7 @@ import world.bentobox.bentobox.BentoBox;
|
|||||||
import world.bentobox.bentobox.api.flags.Flag;
|
import world.bentobox.bentobox.api.flags.Flag;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.Database;
|
import world.bentobox.bentobox.database.Database;
|
||||||
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.database.objects.Names;
|
import world.bentobox.bentobox.database.objects.Names;
|
||||||
import world.bentobox.bentobox.database.objects.Players;
|
import world.bentobox.bentobox.database.objects.Players;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
@ -538,11 +539,13 @@ public class PlayersManager {
|
|||||||
* @param world - island world
|
* @param world - island world
|
||||||
* @param target - target user
|
* @param target - target user
|
||||||
* @param kicked - true if player is being kicked
|
* @param kicked - true if player is being kicked
|
||||||
|
* @param island - island being left
|
||||||
* @since 1.15.4
|
* @since 1.15.4
|
||||||
*/
|
*/
|
||||||
public void cleanLeavingPlayer(World world, User target, boolean kicked) {
|
public void cleanLeavingPlayer(World world, User target, boolean kicked, Island island) {
|
||||||
// Execute commands when leaving
|
// Execute commands when leaving
|
||||||
Util.runCommands(target, plugin.getIWM().getOnLeaveCommands(world), "leave");
|
String ownerName = this.getName(island.getOwner());
|
||||||
|
Util.runCommands(target, ownerName, plugin.getIWM().getOnLeaveCommands(world), "leave");
|
||||||
|
|
||||||
// Remove any tamed animals
|
// Remove any tamed animals
|
||||||
world.getEntitiesByClass(Tameable.class).stream()
|
world.getEntitiesByClass(Tameable.class).stream()
|
||||||
|
@ -49,7 +49,6 @@ import world.bentobox.bentobox.BentoBox;
|
|||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.nms.PasteHandler;
|
import world.bentobox.bentobox.nms.PasteHandler;
|
||||||
import world.bentobox.bentobox.nms.WorldRegenerator;
|
import world.bentobox.bentobox.nms.WorldRegenerator;
|
||||||
import world.bentobox.bentobox.versions.ServerCompatibility;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -663,12 +662,14 @@ public class Util {
|
|||||||
/**
|
/**
|
||||||
* Run a list of commands for a user
|
* Run a list of commands for a user
|
||||||
* @param user - user affected by the commands
|
* @param user - user affected by the commands
|
||||||
|
* @param ownerName - name of the island owner, or the user's name if it is the user's island
|
||||||
* @param commands - a list of commands
|
* @param commands - a list of commands
|
||||||
* @param commandType - the type of command being run - used in the console error message
|
* @param commandType - the type of command being run - used in the console error message
|
||||||
*/
|
*/
|
||||||
public static void runCommands(User user, @NonNull List<String> commands, String commandType) {
|
public static void runCommands(User user, String ownerName, @NonNull List<String> commands, String commandType) {
|
||||||
commands.forEach(command -> {
|
commands.forEach(command -> {
|
||||||
command = command.replace("[player]", user.getName());
|
command = command.replace("[player]", user.getName());
|
||||||
|
command = command.replace("[owner]", ownerName);
|
||||||
if (command.startsWith("[SUDO]")) {
|
if (command.startsWith("[SUDO]")) {
|
||||||
// Execute the command by the player
|
// Execute the command by the player
|
||||||
if (!user.isOnline() || !user.performCommand(command.substring(6))) {
|
if (!user.isOnline() || !user.performCommand(command.substring(6))) {
|
||||||
|
@ -406,7 +406,7 @@ public class IslandTeamKickCommandTest {
|
|||||||
verify(im).removePlayer(any(), eq(notUUID));
|
verify(im).removePlayer(any(), eq(notUUID));
|
||||||
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch");
|
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch");
|
||||||
verify(target, Mockito.never()).getInventory();
|
verify(target, Mockito.never()).getInventory();
|
||||||
verify(pm).cleanLeavingPlayer(any(), any(User.class), eq(true));
|
verify(pm).cleanLeavingPlayer(any(), any(User.class), eq(true), eq(island));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,7 @@ package world.bentobox.bentobox.listeners.flags.worldsettings;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@ -217,7 +218,7 @@ public class IslandRespawnListenerTest {
|
|||||||
assertEquals(safeLocation, ev.getRespawnLocation());
|
assertEquals(safeLocation, ev.getRespawnLocation());
|
||||||
// Verify commands
|
// Verify commands
|
||||||
PowerMockito.verifyStatic(Util.class);
|
PowerMockito.verifyStatic(Util.class);
|
||||||
Util.runCommands(any(User.class), eq(Collections.emptyList()), eq("respawn"));
|
Util.runCommands(any(User.class), anyString(), eq(Collections.emptyList()), eq("respawn"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,6 +58,7 @@ import world.bentobox.bentobox.database.AbstractDatabaseHandler;
|
|||||||
import world.bentobox.bentobox.database.Database;
|
import world.bentobox.bentobox.database.Database;
|
||||||
import world.bentobox.bentobox.database.DatabaseSetup;
|
import world.bentobox.bentobox.database.DatabaseSetup;
|
||||||
import world.bentobox.bentobox.database.DatabaseSetup.DatabaseType;
|
import world.bentobox.bentobox.database.DatabaseSetup.DatabaseType;
|
||||||
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.database.objects.Players;
|
import world.bentobox.bentobox.database.objects.Players;
|
||||||
import world.bentobox.bentobox.hooks.VaultHook;
|
import world.bentobox.bentobox.hooks.VaultHook;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
@ -95,6 +96,9 @@ public class PlayersManagerTest {
|
|||||||
private VaultHook vault;
|
private VaultHook vault;
|
||||||
@Mock
|
@Mock
|
||||||
private PlayerInventory playerInv;
|
private PlayerInventory playerInv;
|
||||||
|
@Mock
|
||||||
|
private Island island;
|
||||||
|
|
||||||
private static AbstractDatabaseHandler<Object> h;
|
private static AbstractDatabaseHandler<Object> h;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -153,6 +157,9 @@ public class PlayersManagerTest {
|
|||||||
while(notUUID.equals(uuid)) {
|
while(notUUID.equals(uuid)) {
|
||||||
notUUID = UUID.randomUUID();
|
notUUID = UUID.randomUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Island
|
||||||
|
when(island.getOwner()).thenReturn(uuid);
|
||||||
|
|
||||||
// Player
|
// Player
|
||||||
when(p.getEnderChest()).thenReturn(inv);
|
when(p.getEnderChest()).thenReturn(inv);
|
||||||
@ -391,7 +398,7 @@ public class PlayersManagerTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCleanLeavingPlayerLeave() {
|
public void testCleanLeavingPlayerLeave() {
|
||||||
pm.cleanLeavingPlayer(world, user, false);
|
pm.cleanLeavingPlayer(world, user, false, island);
|
||||||
// Tamed animals
|
// Tamed animals
|
||||||
verify(tamed).setOwner(eq(null));
|
verify(tamed).setOwner(eq(null));
|
||||||
// Economy
|
// Economy
|
||||||
@ -415,7 +422,7 @@ public class PlayersManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCleanLeavingPlayerKicked() {
|
public void testCleanLeavingPlayerKicked() {
|
||||||
// Player is kicked
|
// Player is kicked
|
||||||
pm.cleanLeavingPlayer(world, user, true);
|
pm.cleanLeavingPlayer(world, user, true, island);
|
||||||
// Tamed animals
|
// Tamed animals
|
||||||
verify(tamed).setOwner(eq(null));
|
verify(tamed).setOwner(eq(null));
|
||||||
// Economy
|
// Economy
|
||||||
@ -440,7 +447,7 @@ public class PlayersManagerTest {
|
|||||||
public void testCleanLeavingPlayerKickedOffline() {
|
public void testCleanLeavingPlayerKickedOffline() {
|
||||||
when(user.isOnline()).thenReturn(false);
|
when(user.isOnline()).thenReturn(false);
|
||||||
// Player is kicked
|
// Player is kicked
|
||||||
pm.cleanLeavingPlayer(world, user, true);
|
pm.cleanLeavingPlayer(world, user, true, island);
|
||||||
// Tamed animals
|
// Tamed animals
|
||||||
verify(tamed).setOwner(eq(null));
|
verify(tamed).setOwner(eq(null));
|
||||||
// Economy
|
// Economy
|
||||||
|
@ -406,7 +406,7 @@ public class UtilTest {
|
|||||||
when(user.getName()).thenReturn("tastybento");
|
when(user.getName()).thenReturn("tastybento");
|
||||||
when(user.isOnline()).thenReturn(true);
|
when(user.isOnline()).thenReturn(true);
|
||||||
when(user.performCommand(anyString())).thenReturn(true);
|
when(user.performCommand(anyString())).thenReturn(true);
|
||||||
Util.runCommands(user, Collections.singletonList("[SUDO]help"), "test");
|
Util.runCommands(user, "tasty", Collections.singletonList("[SUDO]help"), "test");
|
||||||
verify(plugin, never()).logError(anyString());
|
verify(plugin, never()).logError(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ public class UtilTest {
|
|||||||
when(user.getName()).thenReturn("tastybento");
|
when(user.getName()).thenReturn("tastybento");
|
||||||
when(user.isOnline()).thenReturn(true);
|
when(user.isOnline()).thenReturn(true);
|
||||||
when(user.performCommand(anyString())).thenReturn(false);
|
when(user.performCommand(anyString())).thenReturn(false);
|
||||||
Util.runCommands(user, Collections.singletonList("[SUDO]help"), "test");
|
Util.runCommands(user, "tasty", Collections.singletonList("[SUDO]help"), "test");
|
||||||
verify(plugin).logError(eq("Could not execute test command for tastybento: help"));
|
verify(plugin).logError(eq("Could not execute test command for tastybento: help"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ public class UtilTest {
|
|||||||
when(user.getName()).thenReturn("tastybento");
|
when(user.getName()).thenReturn("tastybento");
|
||||||
when(user.isOnline()).thenReturn(false);
|
when(user.isOnline()).thenReturn(false);
|
||||||
when(user.performCommand(anyString())).thenReturn(true);
|
when(user.performCommand(anyString())).thenReturn(true);
|
||||||
Util.runCommands(user, Collections.singletonList("[SUDO]help"), "test");
|
Util.runCommands(user, "tasty", Collections.singletonList("[SUDO]help"), "test");
|
||||||
verify(plugin).logError(eq("Could not execute test command for tastybento: help"));
|
verify(plugin).logError(eq("Could not execute test command for tastybento: help"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,9 +441,13 @@ public class UtilTest {
|
|||||||
public void testRunCommandsConsoleCommand() {
|
public void testRunCommandsConsoleCommand() {
|
||||||
when(user.getName()).thenReturn("tastybento");
|
when(user.getName()).thenReturn("tastybento");
|
||||||
when(Bukkit.dispatchCommand(eq(sender), anyString())).thenReturn(true);
|
when(Bukkit.dispatchCommand(eq(sender), anyString())).thenReturn(true);
|
||||||
Util.runCommands(user, Collections.singletonList("replace [player]"), "test");
|
Util.runCommands(user, "tasty", List.of("replace [player]", "replace owner [owner]", "[owner] [player]"), "test");
|
||||||
PowerMockito.verifyStatic(Bukkit.class);
|
PowerMockito.verifyStatic(Bukkit.class);
|
||||||
Bukkit.dispatchCommand(sender, "replace tastybento");
|
Bukkit.dispatchCommand(sender, "replace tastybento");
|
||||||
|
PowerMockito.verifyStatic(Bukkit.class);
|
||||||
|
Bukkit.dispatchCommand(sender, "replace owner tasty");
|
||||||
|
PowerMockito.verifyStatic(Bukkit.class);
|
||||||
|
Bukkit.dispatchCommand(sender, "tasty tastybento");
|
||||||
verify(plugin, never()).logError(anyString());
|
verify(plugin, never()).logError(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +458,7 @@ public class UtilTest {
|
|||||||
public void testRunCommandsConsoleCommandFail() {
|
public void testRunCommandsConsoleCommandFail() {
|
||||||
when(user.getName()).thenReturn("tastybento");
|
when(user.getName()).thenReturn("tastybento");
|
||||||
when(Bukkit.dispatchCommand(eq(sender), anyString())).thenReturn(false);
|
when(Bukkit.dispatchCommand(eq(sender), anyString())).thenReturn(false);
|
||||||
Util.runCommands(user, Collections.singletonList("replace [player]"), "test");
|
Util.runCommands(user, "", Collections.singletonList("replace [player]"), "test");
|
||||||
PowerMockito.verifyStatic(Bukkit.class);
|
PowerMockito.verifyStatic(Bukkit.class);
|
||||||
Bukkit.dispatchCommand(sender, "replace tastybento");
|
Bukkit.dispatchCommand(sender, "replace tastybento");
|
||||||
verify(plugin).logError("Could not execute test command as console: replace tastybento");
|
verify(plugin).logError("Could not execute test command as console: replace tastybento");
|
||||||
|
Loading…
Reference in New Issue
Block a user