mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 03:35:11 +01:00
Added better success feedback messages for IslandBanCommand and IslandUnbanCommand
#630
This commit is contained in:
parent
b556b3fb0a
commit
8ba0ebd170
@ -1,14 +1,9 @@
|
||||
package world.bentobox.bentobox.api.commands.island;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
||||
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||
@ -17,6 +12,11 @@ import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class IslandBanCommand extends CompositeCommand {
|
||||
|
||||
public IslandBanCommand(CompositeCommand islandCommand) {
|
||||
@ -82,7 +82,7 @@ public class IslandBanCommand extends CompositeCommand {
|
||||
return ban(user, target);
|
||||
}
|
||||
|
||||
private boolean ban(User issuer, User target) {
|
||||
private boolean ban(@NonNull User issuer, User target) {
|
||||
Island island = getIslands().getIsland(getWorld(), issuer.getUniqueId());
|
||||
|
||||
// Check if player can ban any more players
|
||||
@ -98,7 +98,7 @@ public class IslandBanCommand extends CompositeCommand {
|
||||
|
||||
// Event is not cancelled
|
||||
if (!banEvent.isCancelled() && island.ban(issuer.getUniqueId(), target.getUniqueId())) {
|
||||
issuer.sendMessage("general.success");
|
||||
issuer.sendMessage("commands.island.ban.player-banned", TextVariables.NAME, target.getName());
|
||||
target.sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, issuer.getName());
|
||||
// If the player is online, has an island and on the banned island, move them home immediately
|
||||
if (target.isOnline() && getIslands().hasIsland(getWorld(), target.getUniqueId()) && island.onIsland(target.getLocation())) {
|
||||
|
@ -1,10 +1,5 @@
|
||||
package world.bentobox.bentobox.api.commands.island;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
||||
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||
@ -13,6 +8,11 @@ import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class IslandUnbanCommand extends CompositeCommand {
|
||||
|
||||
public IslandUnbanCommand(CompositeCommand islandCommand) {
|
||||
@ -79,7 +79,7 @@ public class IslandUnbanCommand extends CompositeCommand {
|
||||
|
||||
// Event is not cancelled
|
||||
if (!unbanEvent.isCancelled() && island.unban(issuer.getUniqueId(), target.getUniqueId())) {
|
||||
issuer.sendMessage("general.success");
|
||||
issuer.sendMessage("commands.island.unban.player-unbanned", TextVariables.NAME, target.getName());
|
||||
target.sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, issuer.getName());
|
||||
// Set cooldown
|
||||
if (getSettings().getBanCooldown() > 0 && getParent() != null) {
|
||||
|
@ -417,18 +417,20 @@ commands:
|
||||
cannot-ban: "&cThat player cannot be banned."
|
||||
cannot-ban-member: "&cKick the team member first, then ban."
|
||||
cannot-ban-more-players: "&cYou reached the ban limit, you cannot ban any more players from your island."
|
||||
player-already-banned: "&cPlayer is already banned"
|
||||
player-already-banned: "&cPlayer is already banned."
|
||||
player-banned: "&b[name]&c is now banned from your island."
|
||||
owner-banned-you: "&b[name]&c banned you from their island!"
|
||||
you-are-banned: "&bYou are banned from this island!"
|
||||
unban:
|
||||
description: "unban a player from your island"
|
||||
parameters: "<player>"
|
||||
cannot-unban-yourself: "&cYou cannot unban yourself!"
|
||||
player-not-banned: "&cPlayer is not banned"
|
||||
player-not-banned: "&cPlayer is not banned."
|
||||
player-unbanned: "&b[name]&a is now unbanned from your island."
|
||||
you-are-unbanned: "&b[name]&a unbanned you from their island!"
|
||||
banlist:
|
||||
description: "list banned players"
|
||||
noone: "&aNo one is banned on this island"
|
||||
noone: "&aNo one is banned on this island."
|
||||
the-following: "&bThe following players are banned:"
|
||||
names: "&c[line]"
|
||||
you-can-ban: "&bYou can ban up to &e[number] &bmore players."
|
||||
|
@ -1,23 +1,5 @@
|
||||
package world.bentobox.bentobox.api.commands.island;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -32,7 +14,6 @@ import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.Settings;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
@ -45,6 +26,24 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
@ -250,7 +249,7 @@ public class IslandBanCommandTest {
|
||||
when(island.ban(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||
|
||||
assertTrue(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
|
||||
Mockito.verify(user).sendMessage("general.success");
|
||||
Mockito.verify(user).sendMessage("commands.island.ban.player-banned", TextVariables.NAME, targetUser.getName());
|
||||
Mockito.verify(targetUser).sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, user.getName());
|
||||
}
|
||||
|
||||
@ -272,7 +271,7 @@ public class IslandBanCommandTest {
|
||||
when(island.ban(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||
|
||||
assertTrue(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
|
||||
Mockito.verify(user).sendMessage("general.success");
|
||||
Mockito.verify(user).sendMessage("commands.island.ban.player-banned", TextVariables.NAME, targetUser.getName());
|
||||
Mockito.verify(targetUser).sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, user.getName());
|
||||
}
|
||||
|
||||
@ -293,7 +292,7 @@ public class IslandBanCommandTest {
|
||||
when(island.ban(Mockito.any(), Mockito.any())).thenReturn(false);
|
||||
|
||||
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
|
||||
Mockito.verify(user, Mockito.never()).sendMessage("general.success");
|
||||
Mockito.verify(user, Mockito.never()).sendMessage("commands.island.ban.player-banned", TextVariables.NAME, targetUser.getName());
|
||||
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.ban.owner-banned-you", "[owner]", user.getName());
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,5 @@
|
||||
package world.bentobox.bentobox.api.commands.island;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -29,7 +13,6 @@ import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.Settings;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
@ -42,6 +25,22 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
@ -218,7 +217,7 @@ public class IslandUnbanCommandTest {
|
||||
when(island.unban(Mockito.any(), Mockito.any())).thenReturn(true);
|
||||
|
||||
assertTrue(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
|
||||
Mockito.verify(user).sendMessage("general.success");
|
||||
Mockito.verify(user).sendMessage("commands.island.unban.player-unbanned", TextVariables.NAME, targetUser.getName());
|
||||
Mockito.verify(targetUser).sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, user.getName());
|
||||
}
|
||||
|
||||
@ -242,7 +241,7 @@ public class IslandUnbanCommandTest {
|
||||
when(island.unban(Mockito.any(), Mockito.any())).thenReturn(false);
|
||||
|
||||
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
|
||||
Mockito.verify(user, Mockito.never()).sendMessage("general.success");
|
||||
Mockito.verify(user, Mockito.never()).sendMessage("commands.island.unban.player-unbanned", TextVariables.NAME, targetUser.getName());
|
||||
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.unban.you-are-unbanned", "[owner]", user.getName());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user