mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 18:55:17 +01:00
Fixes #2219. Island homes were set incorrectly with a new island.
This commit is contained in:
parent
4200fe4abb
commit
6d09a5a359
@ -17,6 +17,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.api.panels.reader.ItemTemplateRecord.ActionRecords;
|
||||
|
||||
/**
|
||||
* This Record contains all necessary information about Item Template that can be used to craft panel item.
|
||||
*
|
||||
|
@ -15,6 +15,7 @@ import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.api.panels.Panel;
|
||||
import world.bentobox.bentobox.api.panels.reader.PanelTemplateRecord.TemplateItem;
|
||||
|
||||
/**
|
||||
* This is template object for the panel reader. It contains data that can exist in the panel.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,7 @@ public class PrimaryIslandListener implements Listener {
|
||||
|
||||
private void setIsland(Player player, Location location) {
|
||||
im.getIslandAt(location)
|
||||
.filter(i -> i.getOwner() != null && i.getOwner().equals(player.getUniqueId()))
|
||||
.filter(i -> player.getUniqueId().equals(i.getOwner()))
|
||||
.ifPresent(i -> im.setPrimaryIsland(player.getUniqueId(), i));
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,8 @@ public class NewIsland {
|
||||
// Do nothing of other cases
|
||||
}
|
||||
}
|
||||
|
||||
// Set the player's primary island
|
||||
plugin.getIslands().setPrimaryIsland(user.getUniqueId(), island);
|
||||
// Run task to run after creating the island in one tick if island is not being pasted
|
||||
if (noPaste) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> postCreationTask(oldIsland));
|
||||
@ -244,13 +245,11 @@ public class NewIsland {
|
||||
|
||||
/**
|
||||
* Cleans up a user before moving them to a new island.
|
||||
* Removes any old home locations. Sets the next home location. Resets deaths.
|
||||
* Resets deaths.
|
||||
* Checks range permissions and saves the player to the database.
|
||||
* @param loc - the new island location
|
||||
*/
|
||||
private void cleanUpUser(Location loc) {
|
||||
// Set home location
|
||||
plugin.getIslands().setHomeLocation(user, new Location(loc.getWorld(), loc.getX() + 0.5D, loc.getY(), loc.getZ() + 0.5D));
|
||||
// Reset deaths
|
||||
if (plugin.getIWM().isDeathsResetOnNewIsland(world)) {
|
||||
plugin.getPlayers().setDeaths(world, user.getUniqueId(), 0);
|
||||
|
@ -6,6 +6,9 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -21,6 +24,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@ -85,6 +89,7 @@ public class IslandTest {
|
||||
|
||||
// Location
|
||||
when(location.clone()).thenReturn(location);
|
||||
when(location.toVector()).thenReturn(new Vector(0,0,0));
|
||||
when(world.getName()).thenReturn("bskyblock_world");
|
||||
when(location.getWorld()).thenReturn(world);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
@ -1173,6 +1178,18 @@ public class IslandTest {
|
||||
i.addHome("backyard", location);
|
||||
assertEquals(location, i.getHome("backyard"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.database.objects.Island#addHome(java.lang.String, org.bukkit.Location)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAddHomeOutsideIsland() {
|
||||
when(location.toVector()).thenReturn(new Vector(1000000, 0, 10000000));
|
||||
i.addHome("backyard", location);
|
||||
// Check there is a warning about this home being outside of the island
|
||||
verify(plugin, times(3)).logWarning(anyString());
|
||||
assertEquals(location, i.getHome("backyard"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.database.objects.Island#removeHome(java.lang.String)}.
|
||||
|
@ -198,7 +198,7 @@ public class NewIslandTest {
|
||||
verify(bpb).getUniqueId();
|
||||
verify(ice).getBlueprintBundle();
|
||||
verify(pm).setDeaths(eq(world), eq(uuid), eq(0));
|
||||
verify(im).setHomeLocation(eq(user), any());
|
||||
verify(im, never()).setHomeLocation(eq(user), any());
|
||||
verify(island).setProtectionRange(eq(20));
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ public class NewIslandTest {
|
||||
verify(ice, never()).getBlueprintBundle();
|
||||
verify(ire).getBlueprintBundle();
|
||||
verify(pm).setDeaths(eq(world), eq(uuid), eq(0));
|
||||
verify(im).setHomeLocation(eq(user), any());
|
||||
verify(im, never()).setHomeLocation(eq(user), any());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,7 +235,7 @@ public class NewIslandTest {
|
||||
verify(bpb).getUniqueId();
|
||||
verify(ice).getBlueprintBundle();
|
||||
verify(pm).setDeaths(eq(world), eq(uuid), eq(0));
|
||||
verify(im).setHomeLocation(eq(user), any());
|
||||
verify(im, never()).setHomeLocation(eq(user), any());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,7 +252,7 @@ public class NewIslandTest {
|
||||
verify(bpb).getUniqueId();
|
||||
verify(ice).getBlueprintBundle();
|
||||
verify(pm).setDeaths(eq(world), eq(uuid), eq(0));
|
||||
verify(im).setHomeLocation(eq(user), any());
|
||||
verify(im, never()).setHomeLocation(eq(user), any());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,7 +270,7 @@ public class NewIslandTest {
|
||||
verify(bpb).getUniqueId();
|
||||
verify(ice).getBlueprintBundle();
|
||||
verify(pm).setDeaths(eq(world), eq(uuid), eq(0));
|
||||
verify(im).setHomeLocation(eq(user), any());
|
||||
verify(im, never()).setHomeLocation(eq(user), any());
|
||||
verify(island).setProtectionRange(eq(20));
|
||||
verify(island).setReserved(eq(false));
|
||||
}
|
||||
@ -291,7 +291,7 @@ public class NewIslandTest {
|
||||
verify(bpb).getUniqueId();
|
||||
verify(ice).getBlueprintBundle();
|
||||
verify(pm).setDeaths(eq(world), eq(uuid), eq(0));
|
||||
verify(im).setHomeLocation(eq(user), any());
|
||||
verify(im, never()).setHomeLocation(eq(user), any());
|
||||
verify(island).setProtectionRange(eq(20));
|
||||
verify(plugin).logError("New island for user tastybento was not reserved!");
|
||||
}
|
||||
@ -312,7 +312,7 @@ public class NewIslandTest {
|
||||
verify(bpb).getUniqueId();
|
||||
verify(ice).getBlueprintBundle();
|
||||
verify(pm).setDeaths(eq(world), eq(uuid), eq(0));
|
||||
verify(im).setHomeLocation(eq(user), any());
|
||||
verify(im, never()).setHomeLocation(eq(user), any());
|
||||
verify(island).setProtectionRange(eq(20));
|
||||
verify(plugin).logError("New island for user tastybento was not reserved!");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user