Added [name] textvariable to admin setowner command 'already-owner' message

This commit is contained in:
Florian CUNY 2019-04-28 11:15:26 +02:00
parent 722f136e3f
commit f333cfbe6f
3 changed files with 22 additions and 21 deletions

View File

@ -1,10 +1,6 @@
package world.bentobox.bentobox.api.commands.admin.team;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.api.events.team.TeamEvent;
@ -12,6 +8,9 @@ import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import java.util.List;
import java.util.UUID;
public class AdminTeamSetownerCommand extends CompositeCommand {
public AdminTeamSetownerCommand(CompositeCommand parent) {
@ -43,7 +42,7 @@ public class AdminTeamSetownerCommand extends CompositeCommand {
return false;
}
if (getIslands().getOwner(getWorld(), targetUUID).equals(targetUUID)) {
user.sendMessage("commands.admin.team.setowner.already-owner");
user.sendMessage("commands.admin.team.setowner.already-owner", TextVariables.NAME, args.get(0));
return false;
}
// Make new owner

View File

@ -78,7 +78,8 @@ commands:
setowner:
parameters: "<player>"
description: "transfers island ownership to the player"
already-owner: "&cPlayer is already the owner of this island!"
already-owner: "&c[name] is already the owner of this island!"
range:
description: "Admin island range command"
display:

View File

@ -1,18 +1,5 @@
package world.bentobox.bentobox.api.commands.admin.team;
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.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.entity.Player;
@ -26,9 +13,9 @@ 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.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.managers.CommandsManager;
@ -37,6 +24,19 @@ import world.bentobox.bentobox.managers.IslandsManager;
import world.bentobox.bentobox.managers.LocalesManager;
import world.bentobox.bentobox.managers.PlayersManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
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
*
@ -167,12 +167,13 @@ public class AdminTeamSetownerCommandTest {
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(is);
String[] name = {"tastybento"};
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
when(pm.getName(Mockito.any())).thenReturn(name[0]);
when(im.getOwner(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
AdminTeamSetownerCommand itl = new AdminTeamSetownerCommand(ac);
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
Mockito.verify(user).sendMessage("commands.admin.team.setowner.already-owner");
Mockito.verify(user).sendMessage("commands.admin.team.setowner.already-owner", TextVariables.NAME, name[0]);
}
/**