mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-09-27 22:27:29 +02:00
Fixes VisitorKeepInventory to disregard coops and trusted
#2126 Also fixes some tests.
This commit is contained in:
parent
f05d4dc57f
commit
8f954090e7
@ -11,11 +11,13 @@ 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.database.objects.Island;
|
||||||
import world.bentobox.bentobox.lists.Flags;
|
import world.bentobox.bentobox.lists.Flags;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevents visitors from losing their items if they
|
* Prevents visitors from losing their items if they
|
||||||
* die on an island in which they are a visitor.
|
* die on an island in which they are a visitor.
|
||||||
|
* Coops and above are not considered visitors.
|
||||||
* Handles {@link world.bentobox.bentobox.lists.Flags#VISITOR_KEEP_INVENTORY}.
|
* Handles {@link world.bentobox.bentobox.lists.Flags#VISITOR_KEEP_INVENTORY}.
|
||||||
* @author jstnf
|
* @author jstnf
|
||||||
* @since 1.17.0
|
* @since 1.17.0
|
||||||
@ -32,7 +34,7 @@ public class VisitorKeepInventoryListener extends FlagListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Optional<Island> island = getIslands().getProtectedIslandAt(e.getEntity().getLocation());
|
Optional<Island> island = getIslands().getProtectedIslandAt(e.getEntity().getLocation());
|
||||||
if (island.isPresent() && !island.get().getMemberSet().contains(e.getEntity().getUniqueId())) {
|
if (island.isPresent() && !island.get().getMemberSet(RanksManager.COOP_RANK).contains(e.getEntity().getUniqueId())) {
|
||||||
e.setKeepInventory(true);
|
e.setKeepInventory(true);
|
||||||
e.setKeepLevel(true);
|
e.setKeepLevel(true);
|
||||||
e.getDrops().clear();
|
e.getDrops().clear();
|
||||||
|
@ -171,6 +171,17 @@ public class PanelListenerManagerTest {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOriginalTitle() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTitle(String title) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
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;
|
||||||
@ -122,7 +123,7 @@ public class VisitorKeepInventoryListenerTest {
|
|||||||
/* Islands */
|
/* Islands */
|
||||||
when(plugin.getIslands()).thenReturn(islandsManager);
|
when(plugin.getIslands()).thenReturn(islandsManager);
|
||||||
// Visitor
|
// Visitor
|
||||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of());
|
when(island.getMemberSet(anyInt())).thenReturn(ImmutableSet.of());
|
||||||
// By default, there should be an island.
|
// By default, there should be an island.
|
||||||
when(islandsManager.getProtectedIslandAt(any())).thenReturn(Optional.of(island));
|
when(islandsManager.getProtectedIslandAt(any())).thenReturn(Optional.of(island));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user