Fix bug with sethome not replacing previous homes.

This commit is contained in:
tastybento 2018-05-28 20:23:15 -07:00
parent 8f469eb339
commit d34ad5dce3
2 changed files with 8 additions and 1 deletions

View File

@ -165,6 +165,8 @@ public class Players implements DataObject {
* @param number - a number
*/
public void setHomeLocation(Location location, int number) {
// Remove any home locations in the same world with the same number
homeLocations.entrySet().removeIf(e -> Util.sameWorld(location.getWorld(), e.getKey().getWorld()) && e.getValue().equals(number));
homeLocations.put(location, number);
}

View File

@ -23,6 +23,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
@ -33,9 +34,10 @@ import us.tastybento.bskyblock.api.flags.Flag;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.database.objects.Players;
import us.tastybento.bskyblock.lists.Flags;
import us.tastybento.bskyblock.util.Util;
@RunWith(PowerMockRunner.class)
@PrepareForTest( { BSkyBlock.class })
@PrepareForTest( { BSkyBlock.class, Util.class })
public class MySQLDatabaseHandlerTest {
private static MySQLDatabaseHandler<Island> handler;
@ -86,6 +88,9 @@ public class MySQLDatabaseHandlerTest {
instance = new Island();
instance.setUniqueId(UNIQUE_ID);
handler = new MySQLDatabaseHandler<>(plugin, Island.class, dbConn);
PowerMockito.mockStatic(Util.class);
when(Util.sameWorld(Mockito.any(), Mockito.any())).thenReturn(true);
}