Compare commits
13 Commits
f81185a6ab
...
56481ac6d0
Author | SHA1 | Date |
---|---|---|
tastybento | 56481ac6d0 | |
tastybento | 3de0ff236e | |
tastybento | 29507fd3d9 | |
tastybento | ba6a4d5b9c | |
tastybento | c3e25bec3f | |
tastybento | c86eb6a19c | |
tastybento | a7aeed08fd | |
tastybento | e7055c6cba | |
tastybento | c4feb5b52f | |
tastybento | 29be58da5d | |
tastybento | 9baaa0dc1a | |
tastybento | 5834dcbb59 | |
tastybento | c3142f68fd |
2
pom.xml
2
pom.xml
|
@ -88,7 +88,7 @@
|
||||||
<!-- Do not change unless you want different name for local builds. -->
|
<!-- Do not change unless you want different name for local builds. -->
|
||||||
<build.number>-LOCAL</build.number>
|
<build.number>-LOCAL</build.number>
|
||||||
<!-- This allows to change between versions. -->
|
<!-- This allows to change between versions. -->
|
||||||
<build.version>2.3.0</build.version>
|
<build.version>2.3.0-mp</build.version>
|
||||||
<sonar.organization>bentobox-world</sonar.organization>
|
<sonar.organization>bentobox-world</sonar.organization>
|
||||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||||
<server.jars>${project.basedir}/lib</server.jars>
|
<server.jars>${project.basedir}/lib</server.jars>
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
User target = User.getInstance(targetUUID);
|
User target = User.getInstance(targetUUID);
|
||||||
Island oldIsland = Objects.requireNonNull(getIslands().getIsland(getWorld(), targetUUID)); // Should never be
|
Island oldIsland = Objects.requireNonNull(getIslands().getIsland(getWorld(), user)); // Should never be
|
||||||
// null because of
|
// null because of
|
||||||
// checks above
|
// checks above
|
||||||
// Fire event
|
// Fire event
|
||||||
|
@ -108,7 +108,7 @@ public class IslandTeamKickCommand extends ConfirmableCommand {
|
||||||
getAddon().getDescription().getName(), TextVariables.NAME, user.getName(), TextVariables.DISPLAY_NAME,
|
getAddon().getDescription().getName(), TextVariables.NAME, user.getName(), TextVariables.DISPLAY_NAME,
|
||||||
user.getDisplayName());
|
user.getDisplayName());
|
||||||
|
|
||||||
getIslands().removePlayer(getWorld(), targetUUID);
|
getIslands().removePlayer(oldIsland, targetUUID);
|
||||||
// Clean the target player
|
// Clean the target player
|
||||||
getPlayers().cleanLeavingPlayer(getWorld(), target, true, oldIsland);
|
getPlayers().cleanLeavingPlayer(getWorld(), target, true, oldIsland);
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.adapters.Adapter;
|
import world.bentobox.bentobox.database.objects.adapters.Adapter;
|
||||||
import world.bentobox.bentobox.database.objects.adapters.LogEntryListAdapter;
|
import world.bentobox.bentobox.database.objects.adapters.LogEntryListAdapter;
|
||||||
import world.bentobox.bentobox.lists.Flags;
|
import world.bentobox.bentobox.lists.Flags;
|
||||||
|
import world.bentobox.bentobox.managers.IslandsManager;
|
||||||
import world.bentobox.bentobox.managers.RanksManager;
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
import world.bentobox.bentobox.util.Pair;
|
import world.bentobox.bentobox.util.Pair;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
@ -290,6 +291,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
this.world = island.getWorld();
|
this.world = island.getWorld();
|
||||||
this.bonusRanges.addAll(island.getBonusRanges());
|
this.bonusRanges.addAll(island.getBonusRanges());
|
||||||
this.primaries.addAll(island.getPrimaries());
|
this.primaries.addAll(island.getPrimaries());
|
||||||
|
BentoBox.getInstance().logDebug("Constructor copy");
|
||||||
this.setChanged();
|
this.setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,6 +308,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void addMember(@NonNull UUID playerUUID) {
|
public void addMember(@NonNull UUID playerUUID) {
|
||||||
if (getRank(playerUUID) != RanksManager.MEMBER_RANK) {
|
if (getRank(playerUUID) != RanksManager.MEMBER_RANK) {
|
||||||
setRank(playerUUID, RanksManager.MEMBER_RANK);
|
setRank(playerUUID, RanksManager.MEMBER_RANK);
|
||||||
|
BentoBox.getInstance().logDebug("Add member");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -326,6 +329,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
setRank(target, RanksManager.BANNED_RANK);
|
setRank(target, RanksManager.BANNED_RANK);
|
||||||
log(new LogEntry.Builder("BAN").data("player", target.toString()).data("issuer", issuer.toString())
|
log(new LogEntry.Builder("BAN").data("player", target.toString()).data("issuer", issuer.toString())
|
||||||
.build());
|
.build());
|
||||||
|
BentoBox.getInstance().logDebug("Ban");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -615,6 +619,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public int getMaxEverProtectionRange() {
|
public int getMaxEverProtectionRange() {
|
||||||
if (maxEverProtectionRange > this.getRange()) {
|
if (maxEverProtectionRange > this.getRange()) {
|
||||||
maxEverProtectionRange = this.getRange();
|
maxEverProtectionRange = this.getRange();
|
||||||
|
BentoBox.getInstance().logDebug("get max ever protect");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
return Math.max(this.getProtectionRange(), maxEverProtectionRange);
|
return Math.max(this.getProtectionRange(), maxEverProtectionRange);
|
||||||
|
@ -634,6 +639,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
if (maxEverProtectionRange > this.range) {
|
if (maxEverProtectionRange > this.range) {
|
||||||
this.maxEverProtectionRange = this.range;
|
this.maxEverProtectionRange = this.range;
|
||||||
}
|
}
|
||||||
|
BentoBox.getInstance().logDebug("setMaxEverProtectionRange");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,6 +1017,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void removeMember(UUID playerUUID) {
|
public void removeMember(UUID playerUUID) {
|
||||||
if (members.remove(playerUUID) != null) {
|
if (members.remove(playerUUID) != null) {
|
||||||
|
BentoBox.getInstance().logDebug("removeMember");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1019,9 +1026,10 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
* @param center the center to set
|
* @param center the center to set
|
||||||
*/
|
*/
|
||||||
public void setCenter(@NonNull Location center) {
|
public void setCenter(@NonNull Location center) {
|
||||||
if (!center.getWorld().equals(this.center.getWorld()) || !center.equals(this.center)) {
|
if (this.center == null || !center.getWorld().equals(this.center.getWorld()) || !center.equals(this.center)) {
|
||||||
this.world = center.getWorld();
|
this.world = center.getWorld();
|
||||||
this.center = center;
|
this.center = center;
|
||||||
|
BentoBox.getInstance().logDebug("setCenter");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1032,6 +1040,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void setCreatedDate(long createdDate) {
|
public void setCreatedDate(long createdDate) {
|
||||||
if (this.createdDate != createdDate) {
|
if (this.createdDate != createdDate) {
|
||||||
this.createdDate = createdDate;
|
this.createdDate = createdDate;
|
||||||
|
BentoBox.getInstance().logDebug("setCreatedDate");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1058,6 +1067,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void setFlag(Flag flag, int value, boolean doSubflags) {
|
public void setFlag(Flag flag, int value, boolean doSubflags) {
|
||||||
if (flags.containsKey(flag.getID()) && flags.get(flag.getID()) != value) {
|
if (flags.containsKey(flag.getID()) && flags.get(flag.getID()) != value) {
|
||||||
flags.put(flag.getID(), value);
|
flags.put(flag.getID(), value);
|
||||||
|
BentoBox.getInstance().logDebug("setFlag " + flag);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
// Subflag support
|
// Subflag support
|
||||||
|
@ -1072,6 +1082,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setFlags(Map<String, Integer> flags) {
|
public void setFlags(Map<String, Integer> flags) {
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
|
BentoBox.getInstance().logDebug("setFlags ");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1090,7 +1101,6 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
.forEach(f -> result.put(f.getID(),
|
.forEach(f -> result.put(f.getID(),
|
||||||
plugin.getIWM().getDefaultIslandSettings(world).getOrDefault(f, f.getDefaultRank())));
|
plugin.getIWM().getDefaultIslandSettings(world).getOrDefault(f, f.getDefaultRank())));
|
||||||
this.setFlags(result);
|
this.setFlags(result);
|
||||||
setChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1098,6 +1108,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setMembers(Map<UUID, Integer> members) {
|
public void setMembers(Map<UUID, Integer> members) {
|
||||||
this.members = members;
|
this.members = members;
|
||||||
|
BentoBox.getInstance().logDebug("setMembers");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1111,6 +1122,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
if (name == null || !name.equals(this.name)) {
|
if (name == null || !name.equals(this.name)) {
|
||||||
this.name = (name != null && !name.equals("")) ? name : null;
|
this.name = (name != null && !name.equals("")) ? name : null;
|
||||||
|
BentoBox.getInstance().logDebug("setName");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1137,6 +1149,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setRank(owner, RanksManager.OWNER_RANK);
|
setRank(owner, RanksManager.OWNER_RANK);
|
||||||
|
BentoBox.getInstance().logDebug("setOwner");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1147,6 +1160,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
if (this.protectionRange != protectionRange) {
|
if (this.protectionRange != protectionRange) {
|
||||||
this.protectionRange = protectionRange;
|
this.protectionRange = protectionRange;
|
||||||
this.updateMaxEverProtectionRange();
|
this.updateMaxEverProtectionRange();
|
||||||
|
BentoBox.getInstance().logDebug("setProtectionRange");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1182,6 +1196,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void setPurgeProtected(boolean purgeProtected) {
|
public void setPurgeProtected(boolean purgeProtected) {
|
||||||
if (this.purgeProtected != purgeProtected) {
|
if (this.purgeProtected != purgeProtected) {
|
||||||
this.purgeProtected = purgeProtected;
|
this.purgeProtected = purgeProtected;
|
||||||
|
BentoBox.getInstance().logDebug("setPurgeProtected");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1199,6 +1214,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void setRange(int range) {
|
public void setRange(int range) {
|
||||||
if (this.range != range) {
|
if (this.range != range) {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
|
BentoBox.getInstance().logDebug("setRange");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1240,6 +1256,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setRanks(Map<UUID, Integer> ranks) {
|
public void setRanks(Map<UUID, Integer> ranks) {
|
||||||
members = ranks;
|
members = ranks;
|
||||||
|
BentoBox.getInstance().logDebug("setRanks");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1264,6 +1281,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
setFlag(Flags.LOCK, RanksManager.VISITOR_RANK);
|
setFlag(Flags.LOCK, RanksManager.VISITOR_RANK);
|
||||||
}
|
}
|
||||||
log(new LogEntry.Builder("SPAWN").data("value", String.valueOf(isSpawn)).build());
|
log(new LogEntry.Builder("SPAWN").data("value", String.valueOf(isSpawn)).build());
|
||||||
|
BentoBox.getInstance().logDebug("setSpawn");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1285,6 +1303,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setSpawnPoint(Map<Environment, Location> spawnPoint) {
|
public void setSpawnPoint(Map<Environment, Location> spawnPoint) {
|
||||||
this.spawnPoint = spawnPoint;
|
this.spawnPoint = spawnPoint;
|
||||||
|
BentoBox.getInstance().logDebug("setSpawnPoint");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1305,6 +1324,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setWorld(World world) {
|
public void setWorld(World world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
BentoBox.getInstance().logDebug("setWorld");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1329,6 +1349,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
if (flag.getType().equals(Flag.Type.SETTING) || flag.getType().equals(Flag.Type.WORLD_SETTING)) {
|
if (flag.getType().equals(Flag.Type.SETTING) || flag.getType().equals(Flag.Type.WORLD_SETTING)) {
|
||||||
setSettingsFlag(flag, newToggleValue, doSubflags);
|
setSettingsFlag(flag, newToggleValue, doSubflags);
|
||||||
}
|
}
|
||||||
|
BentoBox.getInstance().logDebug("toggleFlag " + flag);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1360,6 +1381,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
flag.getSubflags().forEach(subflag -> setSettingsFlag(subflag, state, true));
|
flag.getSubflags().forEach(subflag -> setSettingsFlag(subflag, state, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BentoBox.getInstance().logDebug("setSettingsFlag " + flag);
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1397,6 +1419,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void removeRank(Integer rank) {
|
public void removeRank(Integer rank) {
|
||||||
if (members.values().removeIf(rank::equals)) {
|
if (members.values().removeIf(rank::equals)) {
|
||||||
|
BentoBox.getInstance().logDebug("removeRank");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1417,6 +1440,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void log(LogEntry logEntry) {
|
public void log(LogEntry logEntry) {
|
||||||
history.add(logEntry);
|
history.add(logEntry);
|
||||||
|
BentoBox.getInstance().logDebug("log");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1427,6 +1451,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setHistory(List<LogEntry> history) {
|
public void setHistory(List<LogEntry> history) {
|
||||||
this.history = history;
|
this.history = history;
|
||||||
|
BentoBox.getInstance().logDebug("setHistory");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1442,6 +1467,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setDoNotLoad(boolean doNotLoad) {
|
public void setDoNotLoad(boolean doNotLoad) {
|
||||||
this.doNotLoad = doNotLoad;
|
this.doNotLoad = doNotLoad;
|
||||||
|
BentoBox.getInstance().logDebug("setDoNotLoad");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1457,6 +1483,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setDeleted(boolean deleted) {
|
public void setDeleted(boolean deleted) {
|
||||||
this.deleted = deleted;
|
this.deleted = deleted;
|
||||||
|
BentoBox.getInstance().logDebug("setDeleted");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1546,8 +1573,10 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
if (cooldowns.containsKey(flag.getID()) && cooldowns.get(flag.getID()) > System.currentTimeMillis()) {
|
if (cooldowns.containsKey(flag.getID()) && cooldowns.get(flag.getID()) > System.currentTimeMillis()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
cooldowns.remove(flag.getID());
|
if (cooldowns.remove(flag.getID()) != null) {
|
||||||
setChanged();
|
BentoBox.getInstance().logDebug("isCooldown");
|
||||||
|
setChanged();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1558,6 +1587,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setCooldown(Flag flag) {
|
public void setCooldown(Flag flag) {
|
||||||
cooldowns.put(flag.getID(), flag.getCooldown() * 1000L + System.currentTimeMillis());
|
cooldowns.put(flag.getID(), flag.getCooldown() * 1000L + System.currentTimeMillis());
|
||||||
|
BentoBox.getInstance().logDebug("setCooldown");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1573,6 +1603,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setCooldowns(Map<String, Long> cooldowns) {
|
public void setCooldowns(Map<String, Long> cooldowns) {
|
||||||
this.cooldowns = cooldowns;
|
this.cooldowns = cooldowns;
|
||||||
|
BentoBox.getInstance().logDebug("setCooldowns");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1588,6 +1619,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setCommandRanks(Map<String, Integer> commandRanks) {
|
public void setCommandRanks(Map<String, Integer> commandRanks) {
|
||||||
this.commandRanks = commandRanks;
|
this.commandRanks = commandRanks;
|
||||||
|
BentoBox.getInstance().logDebug("setCommandRanks");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1659,6 +1691,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void setReserved(boolean reserved) {
|
public void setReserved(boolean reserved) {
|
||||||
if (this.reserved != reserved) {
|
if (this.reserved != reserved) {
|
||||||
this.reserved = reserved;
|
this.reserved = reserved;
|
||||||
|
BentoBox.getInstance().logDebug("setReserved");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1682,6 +1715,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
@Override
|
@Override
|
||||||
public void setMetaData(Map<String, MetaDataValue> metaData) {
|
public void setMetaData(Map<String, MetaDataValue> metaData) {
|
||||||
this.metaData = metaData;
|
this.metaData = metaData;
|
||||||
|
BentoBox.getInstance().logDebug("setMetaData");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1698,7 +1732,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void setChanged() {
|
public void setChanged() {
|
||||||
this.setUpdatedDate(System.currentTimeMillis());
|
this.setUpdatedDate(System.currentTimeMillis());
|
||||||
this.changed = true;
|
this.changed = true;
|
||||||
//IslandsManager.updateIsland(this);
|
IslandsManager.updateIsland(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1737,6 +1771,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
}
|
}
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.updateMaxEverProtectionRange();
|
this.updateMaxEverProtectionRange();
|
||||||
|
BentoBox.getInstance().logDebug("setProtectionCenter");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1795,6 +1830,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getHomes().put(name.toLowerCase(), location);
|
getHomes().put(name.toLowerCase(), location);
|
||||||
|
BentoBox.getInstance().logDebug("addHome");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1865,6 +1901,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void setMaxHomes(@Nullable Integer maxHomes) {
|
public void setMaxHomes(@Nullable Integer maxHomes) {
|
||||||
if (this.maxHomes != maxHomes) {
|
if (this.maxHomes != maxHomes) {
|
||||||
this.maxHomes = maxHomes;
|
this.maxHomes = maxHomes;
|
||||||
|
BentoBox.getInstance().logDebug("setMaxHomes");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1887,6 +1924,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void setMaxMembers(Map<Integer, Integer> maxMembers) {
|
public void setMaxMembers(Map<Integer, Integer> maxMembers) {
|
||||||
if (this.maxMembers != maxMembers) {
|
if (this.maxMembers != maxMembers) {
|
||||||
this.maxMembers = maxMembers;
|
this.maxMembers = maxMembers;
|
||||||
|
BentoBox.getInstance().logDebug("setMaxMembers");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1937,6 +1975,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setBonusRanges(List<BonusRangeRecord> bonusRanges) {
|
public void setBonusRanges(List<BonusRangeRecord> bonusRanges) {
|
||||||
this.bonusRanges = bonusRanges;
|
this.bonusRanges = bonusRanges;
|
||||||
|
BentoBox.getInstance().logDebug("setBonusRanges");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1973,6 +2012,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
public void addBonusRange(String id, int range, String message) {
|
public void addBonusRange(String id, int range, String message) {
|
||||||
this.getBonusRanges().add(new BonusRangeRecord(id, range, message));
|
this.getBonusRanges().add(new BonusRangeRecord(id, range, message));
|
||||||
setMaxEverProtectionRange(this.getProtectionRange());
|
setMaxEverProtectionRange(this.getProtectionRange());
|
||||||
|
BentoBox.getInstance().logDebug("addBonusRange");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1983,6 +2023,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void clearBonusRange(String id) {
|
public void clearBonusRange(String id) {
|
||||||
if (this.getBonusRanges().removeIf(r -> r.getUniqueId().equals(id))) {
|
if (this.getBonusRanges().removeIf(r -> r.getUniqueId().equals(id))) {
|
||||||
|
BentoBox.getInstance().logDebug("clearBonusRange");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1992,6 +2033,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void clearAllBonusRanges() {
|
public void clearAllBonusRanges() {
|
||||||
this.getBonusRanges().clear();
|
this.getBonusRanges().clear();
|
||||||
|
BentoBox.getInstance().logDebug("clearAllBonusRanges");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2008,6 +2050,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setPrimary(UUID userID) {
|
public void setPrimary(UUID userID) {
|
||||||
if (getPrimaries().add(userID)) {
|
if (getPrimaries().add(userID)) {
|
||||||
|
BentoBox.getInstance().logDebug("setPrimary");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2018,6 +2061,7 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void removePrimary(UUID userID) {
|
public void removePrimary(UUID userID) {
|
||||||
if (getPrimaries().remove(userID)) {
|
if (getPrimaries().remove(userID)) {
|
||||||
|
BentoBox.getInstance().logDebug("removePrimary");
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2074,5 +2118,28 @@ public class Island implements DataObject, MetaDataAble {
|
||||||
*/
|
*/
|
||||||
public void setPrimaries(Set<UUID> primaries) {
|
public void setPrimaries(Set<UUID> primaries) {
|
||||||
this.primaries = primaries;
|
this.primaries = primaries;
|
||||||
|
BentoBox.getInstance().logDebug("setPrimaries");
|
||||||
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Islands are equal if they have the same uniqueId
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Island other = (Island) obj;
|
||||||
|
return Objects.equals(uniqueId, other.uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,15 +54,25 @@ public class IslandCache {
|
||||||
grids = new HashMap<>();
|
grids = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace the island we have with this one
|
||||||
|
* @param island island
|
||||||
|
*/
|
||||||
public void updateIsland(@NonNull Island island) {
|
public void updateIsland(@NonNull Island island) {
|
||||||
if (island.getCenter() != null || island.getWorld() != null) {
|
if (islandsByLocation.put(island.getCenter(), island) == null) {
|
||||||
islandsByLocation.put(island.getCenter(), island);
|
BentoBox.getInstance().logDebug("islandsByLocation failed to update");
|
||||||
islandsById.put(island.getUniqueId(), island);
|
}
|
||||||
// Only add islands to this map if they are owned
|
if (islandsById.put(island.getUniqueId(), island) == null) {
|
||||||
if (island.isOwned()) {
|
BentoBox.getInstance().logDebug("islandsById failed to update");
|
||||||
islandsByUUID.computeIfAbsent(island.getOwner(), k -> new HashSet<>()).add(island);
|
}
|
||||||
island.getMemberSet().forEach(member -> addPlayer(member, island));
|
|
||||||
|
// Only add islands to this map if they are owned
|
||||||
|
if (island.getOwner() != null) {
|
||||||
|
Set<Island> set = islandsByUUID.computeIfAbsent(island.getOwner(), k -> new HashSet<>());
|
||||||
|
if (!set.remove(island)) {
|
||||||
|
BentoBox.getInstance().logDebug("islandsByUUID failed to remove");
|
||||||
}
|
}
|
||||||
|
set.add(island);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +117,7 @@ public class IslandCache {
|
||||||
* @return true if successfully added, false if not
|
* @return true if successfully added, false if not
|
||||||
*/
|
*/
|
||||||
private boolean addToGrid(@NonNull Island newIsland) {
|
private boolean addToGrid(@NonNull Island newIsland) {
|
||||||
return grids.computeIfAbsent(newIsland.getWorld(), k -> new IslandGrid()).addToGrid(newIsland);
|
return grids.computeIfAbsent(newIsland.getWorld(), k -> new IslandGrid(this)).addToGrid(newIsland);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
|
@ -220,8 +230,13 @@ public class IslandCache {
|
||||||
* @param island island to make primary
|
* @param island island to make primary
|
||||||
*/
|
*/
|
||||||
public void setPrimaryIsland(@NonNull UUID uuid, @NonNull Island island) {
|
public void setPrimaryIsland(@NonNull UUID uuid, @NonNull Island island) {
|
||||||
|
if (island.getPrimaries().contains(uuid)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (Island is : getIslands(island.getWorld(), uuid)) {
|
for (Island is : getIslands(island.getWorld(), uuid)) {
|
||||||
is.removePrimary(uuid);
|
if (is.getPrimaries().contains(uuid)) {
|
||||||
|
is.removePrimary(uuid);
|
||||||
|
}
|
||||||
if (is.equals(island)) {
|
if (is.equals(island)) {
|
||||||
is.setPrimary(uuid);
|
is.setPrimary(uuid);
|
||||||
}
|
}
|
||||||
|
@ -337,6 +352,7 @@ public class IslandCache {
|
||||||
islandSet.remove(island);
|
islandSet.remove(island);
|
||||||
}
|
}
|
||||||
island.removeMember(uuid);
|
island.removeMember(uuid);
|
||||||
|
island.removePrimary(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -396,7 +412,7 @@ public class IslandCache {
|
||||||
public void removeIsland(@NonNull Island island) {
|
public void removeIsland(@NonNull Island island) {
|
||||||
islandsByLocation.values().removeIf(island::equals);
|
islandsByLocation.values().removeIf(island::equals);
|
||||||
islandsById.values().removeIf(island::equals);
|
islandsById.values().removeIf(island::equals);
|
||||||
islandsByUUID.values().removeIf(island::equals);
|
islandsByUUID.values().forEach(s -> s.removeIf(island::equals));
|
||||||
World w = Util.getWorld(island.getWorld());
|
World w = Util.getWorld(island.getWorld());
|
||||||
if (w == null) {
|
if (w == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -12,7 +12,17 @@ import world.bentobox.bentobox.database.objects.Island;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class IslandGrid {
|
class IslandGrid {
|
||||||
private final TreeMap<Integer, TreeMap<Integer, Island>> grid = new TreeMap<>();
|
private final TreeMap<Integer, TreeMap<Integer, String>> grid = new TreeMap<>();
|
||||||
|
private final IslandCache im;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param im IslandsManager
|
||||||
|
*/
|
||||||
|
public IslandGrid(IslandCache im) {
|
||||||
|
super();
|
||||||
|
this.im = im;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds island to grid
|
* Adds island to grid
|
||||||
* @param island - island to add
|
* @param island - island to add
|
||||||
|
@ -21,9 +31,9 @@ class IslandGrid {
|
||||||
public boolean addToGrid(Island island) {
|
public boolean addToGrid(Island island) {
|
||||||
// Check if we know about this island already
|
// Check if we know about this island already
|
||||||
if (grid.containsKey(island.getMinX())) {
|
if (grid.containsKey(island.getMinX())) {
|
||||||
TreeMap<Integer, Island> zEntry = grid.get(island.getMinX());
|
TreeMap<Integer, String> zEntry = grid.get(island.getMinX());
|
||||||
if (zEntry.containsKey(island.getMinZ())) {
|
if (zEntry.containsKey(island.getMinZ())) {
|
||||||
if (island.getUniqueId().equals(zEntry.get(island.getMinZ()).getUniqueId())) {
|
if (island.getUniqueId().equals(zEntry.get(island.getMinZ()))) {
|
||||||
BentoBox.getInstance().logDebug("I already know about this island");
|
BentoBox.getInstance().logDebug("I already know about this island");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -31,13 +41,13 @@ class IslandGrid {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// Add island
|
// Add island
|
||||||
zEntry.put(island.getMinZ(), island);
|
zEntry.put(island.getMinZ(), island.getUniqueId());
|
||||||
grid.put(island.getMinX(), zEntry);
|
grid.put(island.getMinX(), zEntry);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Add island
|
// Add island
|
||||||
TreeMap<Integer, Island> zEntry = new TreeMap<>();
|
TreeMap<Integer, String> zEntry = new TreeMap<>();
|
||||||
zEntry.put(island.getMinZ(), island);
|
zEntry.put(island.getMinZ(), island.getUniqueId());
|
||||||
grid.put(island.getMinX(), zEntry);
|
grid.put(island.getMinX(), zEntry);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -54,7 +64,7 @@ class IslandGrid {
|
||||||
int x = island.getMinX();
|
int x = island.getMinX();
|
||||||
int z = island.getMinZ();
|
int z = island.getMinZ();
|
||||||
if (grid.containsKey(x)) {
|
if (grid.containsKey(x)) {
|
||||||
TreeMap<Integer, Island> zEntry = grid.get(x);
|
TreeMap<Integer, String> zEntry = grid.get(x);
|
||||||
if (zEntry.containsKey(z)) {
|
if (zEntry.containsKey(z)) {
|
||||||
// Island exists - delete it
|
// Island exists - delete it
|
||||||
zEntry.remove(z);
|
zEntry.remove(z);
|
||||||
|
@ -67,25 +77,38 @@ class IslandGrid {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the island at the x,z location or null if there is none.
|
* Retrieves the island located at the specified x and z coordinates, covering both the protected area
|
||||||
* This includes the full island space, not just the protected area.
|
* and the full island space. Returns null if no island exists at the given location.
|
||||||
*
|
*
|
||||||
* @param x - x coordinate
|
* @param x the x coordinate of the location
|
||||||
* @param z - z coordinate
|
* @param z the z coordinate of the location
|
||||||
* @return Island or null
|
* @return the Island at the specified location, or null if no island is found
|
||||||
*/
|
*/
|
||||||
public Island getIslandAt(int x, int z) {
|
public Island getIslandAt(int x, int z) {
|
||||||
Entry<Integer, TreeMap<Integer, Island>> en = grid.floorEntry(x);
|
// Attempt to find the closest x-coordinate entry that does not exceed 'x'
|
||||||
if (en != null) {
|
Entry<Integer, TreeMap<Integer, String>> xEntry = grid.floorEntry(x);
|
||||||
Entry<Integer, Island> ent = en.getValue().floorEntry(z);
|
if (xEntry == null) {
|
||||||
if (ent != null) {
|
return null; // No x-coordinate entry found, return null
|
||||||
// Check if in the island range
|
|
||||||
Island island = ent.getValue();
|
|
||||||
if (island.inIslandSpace(x, z)) {
|
|
||||||
return island;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attempt to find the closest z-coordinate entry that does not exceed 'z' within the found x-coordinate
|
||||||
|
Entry<Integer, String> zEntry = xEntry.getValue().floorEntry(z);
|
||||||
|
if (zEntry == null) {
|
||||||
|
return null; // No z-coordinate entry found, return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the island using the id found in the z-coordinate entry
|
||||||
|
Island island = im.getIslandById(zEntry.getValue());
|
||||||
|
if (island == null) {
|
||||||
|
return null; // No island found by the id, return null
|
||||||
|
}
|
||||||
|
// Check if the specified coordinates are within the island space
|
||||||
|
if (island.inIslandSpace(x, z)) {
|
||||||
|
return island; // Coordinates are within island space, return the island
|
||||||
|
}
|
||||||
|
|
||||||
|
// Coordinates are outside the island space, return null
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
|
@ -50,11 +52,12 @@ import world.bentobox.bentobox.listeners.flags.AbstractCommonSetup;
|
||||||
import world.bentobox.bentobox.lists.Flags;
|
import world.bentobox.bentobox.lists.Flags;
|
||||||
import world.bentobox.bentobox.managers.CommandsManager;
|
import world.bentobox.bentobox.managers.CommandsManager;
|
||||||
import world.bentobox.bentobox.managers.FlagsManager;
|
import world.bentobox.bentobox.managers.FlagsManager;
|
||||||
|
import world.bentobox.bentobox.managers.IslandsManager;
|
||||||
import world.bentobox.bentobox.managers.RanksManager;
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ BentoBox.class, Flags.class, Util.class, Bukkit.class})
|
@PrepareForTest({ BentoBox.class, Flags.class, Util.class, Bukkit.class, IslandsManager.class })
|
||||||
public class TestBentoBox extends AbstractCommonSetup {
|
public class TestBentoBox extends AbstractCommonSetup {
|
||||||
private static final UUID MEMBER_UUID = UUID.randomUUID();
|
private static final UUID MEMBER_UUID = UUID.randomUUID();
|
||||||
private static final UUID VISITOR_UUID = UUID.randomUUID();
|
private static final UUID VISITOR_UUID = UUID.randomUUID();
|
||||||
|
@ -74,6 +77,9 @@ public class TestBentoBox extends AbstractCommonSetup {
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
|
// IslandsManager static
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
|
|
||||||
when(plugin.getCommandsManager()).thenReturn(cm);
|
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||||
|
|
||||||
SkullMeta skullMeta = mock(SkullMeta.class);
|
SkullMeta skullMeta = mock(SkullMeta.class);
|
||||||
|
@ -85,6 +91,7 @@ public class TestBentoBox extends AbstractCommonSetup {
|
||||||
|
|
||||||
when(player.hasPermission(anyString())).thenReturn(true);
|
when(player.hasPermission(anyString())).thenReturn(true);
|
||||||
|
|
||||||
|
when(location.getWorld()).thenReturn(world);
|
||||||
when(ownerOfIsland.getLocation()).thenReturn(location);
|
when(ownerOfIsland.getLocation()).thenReturn(location);
|
||||||
when(visitorToIsland.getLocation()).thenReturn(location);
|
when(visitorToIsland.getLocation()).thenReturn(location);
|
||||||
when(location.clone()).thenReturn(location);
|
when(location.clone()).thenReturn(location);
|
||||||
|
@ -95,6 +102,7 @@ public class TestBentoBox extends AbstractCommonSetup {
|
||||||
|
|
||||||
island.setOwner(uuid);
|
island.setOwner(uuid);
|
||||||
island.setProtectionRange(100);
|
island.setProtectionRange(100);
|
||||||
|
island.setCenter(location);
|
||||||
HashMap<UUID, Integer> members = new HashMap<>();
|
HashMap<UUID, Integer> members = new HashMap<>();
|
||||||
members.put(uuid, RanksManager.OWNER_RANK);
|
members.put(uuid, RanksManager.OWNER_RANK);
|
||||||
members.put(MEMBER_UUID, RanksManager.MEMBER_RANK);
|
members.put(MEMBER_UUID, RanksManager.MEMBER_RANK);
|
||||||
|
|
|
@ -51,7 +51,7 @@ import world.bentobox.bentobox.util.Util;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ Bukkit.class, BentoBox.class, Util.class })
|
@PrepareForTest({ Bukkit.class, BentoBox.class, Util.class, IslandsManager.class })
|
||||||
public class AdminInfoCommandTest extends RanksManagerBeforeClassTest {
|
public class AdminInfoCommandTest extends RanksManagerBeforeClassTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -84,6 +84,8 @@ public class AdminInfoCommandTest extends RanksManagerBeforeClassTest {
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
|
|
||||||
// IWM
|
// IWM
|
||||||
when(plugin.getIWM()).thenReturn(iwm);
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
@ -54,7 +55,7 @@ import world.bentobox.bentobox.util.Util;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ Bukkit.class, BentoBox.class })
|
@PrepareForTest({ Bukkit.class, BentoBox.class, IslandsManager.class })
|
||||||
public class AdminUnregisterCommandTest {
|
public class AdminUnregisterCommandTest {
|
||||||
|
|
||||||
private UUID uuid = UUID.randomUUID();
|
private UUID uuid = UUID.randomUUID();
|
||||||
|
@ -83,6 +84,7 @@ public class AdminUnregisterCommandTest {
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
// Set up plugin
|
// Set up plugin
|
||||||
BentoBox plugin = mock(BentoBox.class);
|
BentoBox plugin = mock(BentoBox.class);
|
||||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
|
|
|
@ -39,7 +39,7 @@ import world.bentobox.bentobox.managers.RanksManagerBeforeClassTest;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ Bukkit.class, BentoBox.class })
|
@PrepareForTest({ Bukkit.class, BentoBox.class, IslandsManager.class })
|
||||||
public class DefaultPlayerCommandTest extends RanksManagerBeforeClassTest {
|
public class DefaultPlayerCommandTest extends RanksManagerBeforeClassTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -68,6 +68,7 @@ public class DefaultPlayerCommandTest extends RanksManagerBeforeClassTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
|
|
||||||
// User
|
// User
|
||||||
when(user.getUniqueId()).thenReturn(UUID.randomUUID());
|
when(user.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||||
|
|
|
@ -51,7 +51,7 @@ import world.bentobox.bentobox.util.Util;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({Bukkit.class, BentoBox.class, Util.class})
|
@PrepareForTest({ Bukkit.class, BentoBox.class, Util.class, IslandsManager.class })
|
||||||
public class IslandInfoCommandTest extends RanksManagerBeforeClassTest {
|
public class IslandInfoCommandTest extends RanksManagerBeforeClassTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -84,6 +84,8 @@ public class IslandInfoCommandTest extends RanksManagerBeforeClassTest {
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
|
|
||||||
// IWM
|
// IWM
|
||||||
when(plugin.getIWM()).thenReturn(iwm);
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ import world.bentobox.bentobox.managers.island.NewIsland;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ Bukkit.class, BentoBox.class, NewIsland.class })
|
@PrepareForTest({ Bukkit.class, BentoBox.class, NewIsland.class, IslandsManager.class })
|
||||||
public class IslandResetCommandTest {
|
public class IslandResetCommandTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -97,6 +97,7 @@ public class IslandResetCommandTest {
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
// Set up plugin
|
// Set up plugin
|
||||||
BentoBox plugin = mock(BentoBox.class);
|
BentoBox plugin = mock(BentoBox.class);
|
||||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
|
|
|
@ -7,10 +7,13 @@ 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.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.atLeast;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.beans.IntrospectionException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -29,10 +32,10 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
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.database.objects.TeamInvite;
|
|
||||||
import world.bentobox.bentobox.database.objects.TeamInvite.Type;
|
import world.bentobox.bentobox.database.objects.TeamInvite.Type;
|
||||||
import world.bentobox.bentobox.managers.CommandsManager;
|
import world.bentobox.bentobox.managers.CommandsManager;
|
||||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||||
|
@ -75,6 +78,9 @@ public class IslandTeamCommandTest extends RanksManagerBeforeClassTest {
|
||||||
@Mock
|
@Mock
|
||||||
private @Nullable Island island;
|
private @Nullable Island island;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private GameModeAddon addon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
|
@ -88,6 +94,7 @@ public class IslandTeamCommandTest extends RanksManagerBeforeClassTest {
|
||||||
// Parent command
|
// Parent command
|
||||||
when(ic.getPermissionPrefix()).thenReturn("bskyblock.");
|
when(ic.getPermissionPrefix()).thenReturn("bskyblock.");
|
||||||
when(ic.getWorld()).thenReturn(world);
|
when(ic.getWorld()).thenReturn(world);
|
||||||
|
when(ic.getAddon()).thenReturn(addon);
|
||||||
|
|
||||||
// user
|
// user
|
||||||
uuid = UUID.randomUUID();
|
uuid = UUID.randomUUID();
|
||||||
|
@ -172,11 +179,14 @@ public class IslandTeamCommandTest extends RanksManagerBeforeClassTest {
|
||||||
/**
|
/**
|
||||||
* Test method for
|
* Test method for
|
||||||
* {@link world.bentobox.bentobox.api.commands.island.team.IslandTeamCommand#addInvite(world.bentobox.bentobox.api.commands.island.team.Invite.Type, java.util.UUID, java.util.UUID)}.
|
* {@link world.bentobox.bentobox.api.commands.island.team.IslandTeamCommand#addInvite(world.bentobox.bentobox.api.commands.island.team.Invite.Type, java.util.UUID, java.util.UUID)}.
|
||||||
|
* @throws IntrospectionException
|
||||||
|
* @throws InvocationTargetException
|
||||||
|
* @throws IllegalAccessException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAddInvite() {
|
public void testAddInvite() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
|
||||||
tc.addInvite(Type.TEAM, uuid, invitee, island);
|
tc.addInvite(Type.TEAM, uuid, invitee, island);
|
||||||
assertTrue(tc.isInvited(invitee));
|
verify(h, atLeast(1)).saveObject(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,8 +204,7 @@ public class IslandTeamCommandTest extends RanksManagerBeforeClassTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetInviter() {
|
public void testGetInviter() {
|
||||||
tc.addInvite(Type.TEAM, uuid, invitee, island);
|
assertNull(tc.getInviter(invitee));
|
||||||
assertEquals(uuid, tc.getInviter(invitee));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,12 +223,6 @@ public class IslandTeamCommandTest extends RanksManagerBeforeClassTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetInvite() {
|
public void testGetInvite() {
|
||||||
assertNull(tc.getInvite(invitee));
|
assertNull(tc.getInvite(invitee));
|
||||||
tc.addInvite(Type.TEAM, uuid, invitee, island);
|
|
||||||
@Nullable
|
|
||||||
TeamInvite invite = tc.getInvite(invitee);
|
|
||||||
assertEquals(invitee, invite.getInvitee());
|
|
||||||
assertEquals(Type.TEAM, invite.getType());
|
|
||||||
assertEquals(uuid, invite.getInviter());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -250,7 +250,7 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||||
|
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
|
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
|
||||||
verify(im).removePlayer(any(World.class), eq(notUUID));
|
verify(im).removePlayer(any(Island.class), eq(notUUID));
|
||||||
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch", TextVariables.DISPLAY_NAME, "&Cposlovich");
|
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch", TextVariables.DISPLAY_NAME, "&Cposlovich");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||||
|
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
|
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
|
||||||
verify(im).removePlayer(any(World.class), eq(notUUID));
|
verify(im).removePlayer(any(Island.class), eq(notUUID));
|
||||||
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch", TextVariables.DISPLAY_NAME, "&Cposlovich");
|
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch", TextVariables.DISPLAY_NAME, "&Cposlovich");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||||
|
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
|
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
|
||||||
verify(im).removePlayer(any(World.class), eq(notUUID));
|
verify(im).removePlayer(any(Island.class), eq(notUUID));
|
||||||
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch", TextVariables.DISPLAY_NAME, "&Cposlovich");
|
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch", TextVariables.DISPLAY_NAME, "&Cposlovich");
|
||||||
verify(target, never()).getInventory();
|
verify(target, never()).getInventory();
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ public class IslandTeamKickCommandTest extends RanksManagerBeforeClassTest {
|
||||||
|
|
||||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||||
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
|
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("poslovitch")));
|
||||||
verify(im).removePlayer(any(World.class), eq(notUUID));
|
verify(im).removePlayer(any(Island.class), eq(notUUID));
|
||||||
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch", TextVariables.DISPLAY_NAME, "&Cposlovich");
|
verify(user).sendMessage("commands.island.team.kick.success", TextVariables.NAME, "poslovitch", TextVariables.DISPLAY_NAME, "&Cposlovich");
|
||||||
verify(target, Mockito.never()).getInventory();
|
verify(target, Mockito.never()).getInventory();
|
||||||
verify(pm).cleanLeavingPlayer(any(), any(User.class), eq(true), eq(island));
|
verify(pm).cleanLeavingPlayer(any(), any(User.class), eq(true), eq(island));
|
||||||
|
|
|
@ -54,7 +54,7 @@ import world.bentobox.bentobox.managers.PlayersManager;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class })
|
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, IslandsManager.class })
|
||||||
public class IslandTeamSetownerCommandTest {
|
public class IslandTeamSetownerCommandTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -84,6 +84,8 @@ public class IslandTeamSetownerCommandTest {
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
|
|
||||||
// Set up plugin
|
// Set up plugin
|
||||||
BentoBox plugin = mock(BentoBox.class);
|
BentoBox plugin = mock(BentoBox.class);
|
||||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
|
@ -276,7 +278,8 @@ public class IslandTeamSetownerCommandTest {
|
||||||
assertTrue(its.canExecute(user, "", List.of("tastybento")));
|
assertTrue(its.canExecute(user, "", List.of("tastybento")));
|
||||||
assertTrue(its.execute(user, "", List.of("tastybento")));
|
assertTrue(its.execute(user, "", List.of("tastybento")));
|
||||||
verify(im).setOwner(any(), eq(user), eq(target));
|
verify(im).setOwner(any(), eq(user), eq(target));
|
||||||
verify(im).updateIsland(island);
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(island);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -292,7 +295,8 @@ public class IslandTeamSetownerCommandTest {
|
||||||
assertTrue(its.canExecute(user, "", List.of("tastybento")));
|
assertTrue(its.canExecute(user, "", List.of("tastybento")));
|
||||||
assertTrue(its.execute(user, "", List.of("tastybento")));
|
assertTrue(its.execute(user, "", List.of("tastybento")));
|
||||||
verify(im).setOwner(any(), eq(user), eq(target));
|
verify(im).setOwner(any(), eq(user), eq(target));
|
||||||
verify(im).updateIsland(island);
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(island);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.mockito.Mockito;
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
import org.powermock.reflect.Whitebox;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
||||||
|
@ -28,13 +29,14 @@ import world.bentobox.bentobox.api.events.island.IslandEvent.Reason;
|
||||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.database.objects.IslandDeletion;
|
import world.bentobox.bentobox.database.objects.IslandDeletion;
|
||||||
|
import world.bentobox.bentobox.managers.IslandsManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ BentoBox.class, Bukkit.class })
|
@PrepareForTest({ BentoBox.class, Bukkit.class, IslandsManager.class })
|
||||||
public class IslandEventTest {
|
public class IslandEventTest {
|
||||||
|
|
||||||
private Island island;
|
private Island island;
|
||||||
|
@ -47,11 +49,18 @@ public class IslandEventTest {
|
||||||
private IslandDeletion deletedIslandInfo;
|
private IslandDeletion deletedIslandInfo;
|
||||||
@Mock
|
@Mock
|
||||||
private PluginManager pim;
|
private PluginManager pim;
|
||||||
|
@Mock
|
||||||
|
private BentoBox plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
|
|
||||||
|
// Set up plugin
|
||||||
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
|
|
||||||
uuid = UUID.randomUUID();
|
uuid = UUID.randomUUID();
|
||||||
// Bukkit
|
// Bukkit
|
||||||
PowerMockito.mockStatic(Bukkit.class);
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
|
|
|
@ -46,6 +46,7 @@ import world.bentobox.bentobox.lists.Flags;
|
||||||
import world.bentobox.bentobox.managers.CommandsManager;
|
import world.bentobox.bentobox.managers.CommandsManager;
|
||||||
import world.bentobox.bentobox.managers.FlagsManager;
|
import world.bentobox.bentobox.managers.FlagsManager;
|
||||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||||
|
import world.bentobox.bentobox.managers.IslandsManager;
|
||||||
import world.bentobox.bentobox.managers.RanksManager;
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
import world.bentobox.bentobox.util.Pair;
|
import world.bentobox.bentobox.util.Pair;
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ import world.bentobox.bentobox.util.Pair;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ Bukkit.class })
|
@PrepareForTest({ Bukkit.class, IslandsManager.class })
|
||||||
public class IslandTest {
|
public class IslandTest {
|
||||||
|
|
||||||
private static final int DISTANCE = 400;
|
private static final int DISTANCE = 400;
|
||||||
|
@ -105,6 +106,9 @@ public class IslandTest {
|
||||||
// Commands manager
|
// Commands manager
|
||||||
when(plugin.getCommandsManager()).thenReturn(cm);
|
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||||
|
|
||||||
|
// Islands Manager
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
|
|
||||||
i = new Island(new Island(location, uuid, 100));
|
i = new Island(new Island(location, uuid, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ import world.bentobox.bentobox.util.Util;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ BentoBox.class, Util.class, Bukkit.class })
|
@PrepareForTest({ BentoBox.class, Util.class, Bukkit.class, IslandsManager.class })
|
||||||
public class JoinLeaveListenerTest {
|
public class JoinLeaveListenerTest {
|
||||||
|
|
||||||
private static final String[] NAMES = { "adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry",
|
private static final String[] NAMES = { "adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry",
|
||||||
|
@ -111,6 +111,8 @@ public class JoinLeaveListenerTest {
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
|
|
||||||
// Set up plugin
|
// Set up plugin
|
||||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,14 @@ import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
import org.powermock.reflect.Whitebox;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
|
import world.bentobox.bentobox.Settings;
|
||||||
|
import world.bentobox.bentobox.TestWorldSettings;
|
||||||
import world.bentobox.bentobox.api.addons.AddonDescription;
|
import world.bentobox.bentobox.api.addons.AddonDescription;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
|
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||||
import world.bentobox.bentobox.api.hooks.Hook;
|
import world.bentobox.bentobox.api.hooks.Hook;
|
||||||
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
import world.bentobox.bentobox.hooks.placeholders.PlaceholderAPIHook;
|
||||||
import world.bentobox.bentobox.lists.GameModePlaceholder;
|
import world.bentobox.bentobox.lists.GameModePlaceholder;
|
||||||
|
@ -43,9 +47,17 @@ public class PlaceholdersManagerTest {
|
||||||
private HooksManager hm;
|
private HooksManager hm;
|
||||||
@Mock
|
@Mock
|
||||||
private PlaceholderAPIHook hook;
|
private PlaceholderAPIHook hook;
|
||||||
|
@Mock
|
||||||
|
private IslandWorldManager iwm;
|
||||||
|
private Settings settings;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
// Set up plugin
|
||||||
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
|
settings = new Settings();
|
||||||
|
when(plugin.getSettings()).thenReturn(settings);
|
||||||
|
|
||||||
// Addon
|
// Addon
|
||||||
@NonNull
|
@NonNull
|
||||||
AddonDescription desc = new AddonDescription.Builder("main", "bskyblock", "1.0").build();
|
AddonDescription desc = new AddonDescription.Builder("main", "bskyblock", "1.0").build();
|
||||||
|
@ -61,6 +73,13 @@ public class PlaceholdersManagerTest {
|
||||||
when(hm.getHook(eq("PlaceholderAPI"))).thenReturn(optionalHook);
|
when(hm.getHook(eq("PlaceholderAPI"))).thenReturn(optionalHook);
|
||||||
when(hook.isPlaceholder(any(), any())).thenReturn(false);
|
when(hook.isPlaceholder(any(), any())).thenReturn(false);
|
||||||
|
|
||||||
|
// World settings
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
WorldSettings ws = new TestWorldSettings();
|
||||||
|
when(iwm.getWorldSettings(any())).thenReturn(ws);
|
||||||
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
|
|
||||||
// Placeholder manager
|
// Placeholder manager
|
||||||
pm = new PlaceholdersManager(plugin);
|
pm = new PlaceholdersManager(plugin);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +96,7 @@ public class PlaceholdersManagerTest {
|
||||||
public void testRegisterGameModePlaceholdersAllDefaults() {
|
public void testRegisterGameModePlaceholdersAllDefaults() {
|
||||||
pm.registerDefaultPlaceholders(addon);
|
pm.registerDefaultPlaceholders(addon);
|
||||||
// + 300 because we register team member placeholders up to 50 members
|
// + 300 because we register team member placeholders up to 50 members
|
||||||
verify(hook, times(GameModePlaceholder.values().length + 302)).registerPlaceholder(any(), anyString(), any());
|
verify(hook, times(GameModePlaceholder.values().length + 304)).registerPlaceholder(any(), anyString(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +110,7 @@ public class PlaceholdersManagerTest {
|
||||||
pm.registerDefaultPlaceholders(addon);
|
pm.registerDefaultPlaceholders(addon);
|
||||||
|
|
||||||
// 3 less registrations for this addon
|
// 3 less registrations for this addon
|
||||||
verify(hook, times(GameModePlaceholder.values().length - 3 + 302)).registerPlaceholder(any(), anyString(),
|
verify(hook, times(GameModePlaceholder.values().length - 3 + 304)).registerPlaceholder(any(), anyString(),
|
||||||
any());
|
any());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
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.atLeast;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
@ -40,7 +41,6 @@ import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -411,24 +411,13 @@ public class PlayersManagerTest {
|
||||||
assertEquals("tastybento", name);
|
assertEquals("tastybento", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test method for
|
|
||||||
* {@link world.bentobox.bentobox.managers.PlayersManager#getPlayer(java.util.UUID)}.
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void testGetPlayer() {
|
|
||||||
Players player = pm.getPlayer(uuid);
|
|
||||||
assertEquals("tastybento", player.getPlayerName());
|
|
||||||
assertEquals(uuid.toString(), player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for
|
* Test method for
|
||||||
* {@link world.bentobox.bentobox.managers.PlayersManager#getPlayers()}.
|
* {@link world.bentobox.bentobox.managers.PlayersManager#getPlayers()}.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetPlayers() {
|
public void testGetPlayers() {
|
||||||
assertTrue(pm.getPlayers().isEmpty());
|
assertFalse(pm.getPlayers().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -679,15 +668,15 @@ public class PlayersManagerTest {
|
||||||
/**
|
/**
|
||||||
* Test method for
|
* Test method for
|
||||||
* {@link world.bentobox.bentobox.managers.PlayersManager#setPlayerName(world.bentobox.bentobox.api.user.User)}.
|
* {@link world.bentobox.bentobox.managers.PlayersManager#setPlayerName(world.bentobox.bentobox.api.user.User)}.
|
||||||
|
* @throws IntrospectionException
|
||||||
|
* @throws InvocationTargetException
|
||||||
|
* @throws IllegalAccessException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSetPlayerName() {
|
public void testSetPlayerName() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
|
||||||
pm.setPlayerName(user);
|
pm.setPlayerName(user);
|
||||||
assertEquals("tastybento", pm.getName(uuid));
|
// Player and names database saves
|
||||||
when(user.getName()).thenReturn("newName");
|
verify(h, atLeast(2)).saveObject(any());
|
||||||
assertEquals("tastybento", pm.getName(uuid));
|
|
||||||
pm.setPlayerName(user);
|
|
||||||
assertEquals("newName", pm.getName(uuid));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
package world.bentobox.bentobox.managers;
|
package world.bentobox.bentobox.managers;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import java.beans.IntrospectionException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
@ -22,6 +28,7 @@ import org.powermock.reflect.Whitebox;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
import world.bentobox.bentobox.database.AbstractDatabaseHandler;
|
||||||
import world.bentobox.bentobox.database.DatabaseSetup;
|
import world.bentobox.bentobox.database.DatabaseSetup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,6 +70,22 @@ public abstract class RanksManagerBeforeClassTest {
|
||||||
@Mock
|
@Mock
|
||||||
public RanksManager rm;
|
public RanksManager rm;
|
||||||
|
|
||||||
|
protected static AbstractDatabaseHandler<Object> h;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@BeforeClass
|
||||||
|
public static void beforeClass() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
|
||||||
|
// This has to be done beforeClass otherwise the tests will interfere with each
|
||||||
|
// other
|
||||||
|
h = mock(AbstractDatabaseHandler.class);
|
||||||
|
// Database
|
||||||
|
PowerMockito.mockStatic(DatabaseSetup.class);
|
||||||
|
DatabaseSetup dbSetup = mock(DatabaseSetup.class);
|
||||||
|
when(DatabaseSetup.getDatabase()).thenReturn(dbSetup);
|
||||||
|
when(dbSetup.getHandler(any())).thenReturn(h);
|
||||||
|
when(h.saveObject(any())).thenReturn(CompletableFuture.completedFuture(true));
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
// Set up plugin
|
// Set up plugin
|
||||||
|
|
|
@ -56,7 +56,7 @@ import world.bentobox.bentobox.util.Util;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ Util.class, IslandEvent.class, Bukkit.class })
|
@PrepareForTest({ Util.class, IslandEvent.class, Bukkit.class, IslandsManager.class })
|
||||||
public class NewIslandTest {
|
public class NewIslandTest {
|
||||||
|
|
||||||
private static final String NAME = "name";
|
private static final String NAME = "name";
|
||||||
|
@ -105,6 +105,7 @@ public class NewIslandTest {
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
// Islands manager
|
// Islands manager
|
||||||
when(plugin.getIslands()).thenReturn(im);
|
when(plugin.getIslands()).thenReturn(im);
|
||||||
|
@ -205,7 +206,8 @@ public class NewIslandTest {
|
||||||
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).oldIsland(oldIsland)
|
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).oldIsland(oldIsland)
|
||||||
.build();
|
.build();
|
||||||
// Verifications
|
// Verifications
|
||||||
verify(im).updateIsland(eq(island));
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(eq(island));
|
||||||
verify(island).setFlagsDefaults();
|
verify(island).setFlagsDefaults();
|
||||||
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
||||||
verify(builder, times(2)).build();
|
verify(builder, times(2)).build();
|
||||||
|
@ -224,7 +226,8 @@ public class NewIslandTest {
|
||||||
when(builder.build()).thenReturn(ire);
|
when(builder.build()).thenReturn(ire);
|
||||||
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.RESET).oldIsland(oldIsland).build();
|
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.RESET).oldIsland(oldIsland).build();
|
||||||
// Verifications
|
// Verifications
|
||||||
verify(im).updateIsland(eq(island));
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(eq(island));
|
||||||
verify(island).setFlagsDefaults();
|
verify(island).setFlagsDefaults();
|
||||||
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
||||||
verify(builder, times(2)).build();
|
verify(builder, times(2)).build();
|
||||||
|
@ -243,7 +246,8 @@ public class NewIslandTest {
|
||||||
public void testBuilderNoOldIsland() throws Exception {
|
public void testBuilderNoOldIsland() throws Exception {
|
||||||
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).build();
|
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).build();
|
||||||
// Verifications
|
// Verifications
|
||||||
verify(im).updateIsland(eq(island));
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(eq(island));
|
||||||
verify(island).setFlagsDefaults();
|
verify(island).setFlagsDefaults();
|
||||||
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
||||||
verify(builder, times(2)).build();
|
verify(builder, times(2)).build();
|
||||||
|
@ -262,7 +266,8 @@ public class NewIslandTest {
|
||||||
when(location.distance(any())).thenReturn(30D);
|
when(location.distance(any())).thenReturn(30D);
|
||||||
NewIsland.builder().addon(addon).name(NAME).player(user).reason(Reason.CREATE).build();
|
NewIsland.builder().addon(addon).name(NAME).player(user).reason(Reason.CREATE).build();
|
||||||
// Verifications
|
// Verifications
|
||||||
verify(im).updateIsland(eq(island));
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(eq(island));
|
||||||
verify(island).setFlagsDefaults();
|
verify(island).setFlagsDefaults();
|
||||||
verify(bpm).paste(eq(addon), eq(island), eq(NAME), any(Runnable.class), eq(false));
|
verify(bpm).paste(eq(addon), eq(island), eq(NAME), any(Runnable.class), eq(false));
|
||||||
verify(builder, times(2)).build();
|
verify(builder, times(2)).build();
|
||||||
|
@ -281,7 +286,8 @@ public class NewIslandTest {
|
||||||
NewIsland.builder().addon(addon).name(NAME).player(user).reason(Reason.CREATE).build();
|
NewIsland.builder().addon(addon).name(NAME).player(user).reason(Reason.CREATE).build();
|
||||||
PowerMockito.mockStatic(Bukkit.class);
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
// Verifications
|
// Verifications
|
||||||
verify(im).updateIsland(island);
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(eq(island));
|
||||||
verify(island).setFlagsDefaults();
|
verify(island).setFlagsDefaults();
|
||||||
verify(bpm).paste(eq(addon), eq(island), eq(NAME), any(Runnable.class), eq(true));
|
verify(bpm).paste(eq(addon), eq(island), eq(NAME), any(Runnable.class), eq(true));
|
||||||
verify(builder, times(2)).build();
|
verify(builder, times(2)).build();
|
||||||
|
@ -299,7 +305,8 @@ public class NewIslandTest {
|
||||||
when(im.hasIsland(any(), any(User.class))).thenReturn(true);
|
when(im.hasIsland(any(), any(User.class))).thenReturn(true);
|
||||||
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).oldIsland(oldIsland).build();
|
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).oldIsland(oldIsland).build();
|
||||||
// Verifications
|
// Verifications
|
||||||
verify(im).updateIsland(eq(island));
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(eq(island));
|
||||||
verify(island).setFlagsDefaults();
|
verify(island).setFlagsDefaults();
|
||||||
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
||||||
verify(builder, times(2)).build();
|
verify(builder, times(2)).build();
|
||||||
|
@ -320,7 +327,8 @@ public class NewIslandTest {
|
||||||
when(im.hasIsland(any(), any(User.class))).thenReturn(true);
|
when(im.hasIsland(any(), any(User.class))).thenReturn(true);
|
||||||
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).oldIsland(oldIsland).build();
|
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).oldIsland(oldIsland).build();
|
||||||
// Verifications
|
// Verifications
|
||||||
verify(im).updateIsland(eq(island));
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(eq(island));
|
||||||
verify(island).setFlagsDefaults();
|
verify(island).setFlagsDefaults();
|
||||||
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
||||||
verify(builder, times(2)).build();
|
verify(builder, times(2)).build();
|
||||||
|
@ -342,7 +350,8 @@ public class NewIslandTest {
|
||||||
when(im.hasIsland(any(), any(User.class))).thenReturn(true);
|
when(im.hasIsland(any(), any(User.class))).thenReturn(true);
|
||||||
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).oldIsland(oldIsland).build();
|
NewIsland.builder().addon(addon).name(NAME).player(user).noPaste().reason(Reason.CREATE).oldIsland(oldIsland).build();
|
||||||
// Verifications
|
// Verifications
|
||||||
verify(im).updateIsland(eq(island));
|
PowerMockito.verifyStatic(IslandsManager.class);
|
||||||
|
IslandsManager.updateIsland(eq(island));
|
||||||
verify(island).setFlagsDefaults();
|
verify(island).setFlagsDefaults();
|
||||||
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
verify(scheduler).runTask(any(BentoBox.class), any(Runnable.class));
|
||||||
verify(builder, times(2)).build();
|
verify(builder, times(2)).build();
|
||||||
|
|
|
@ -58,7 +58,7 @@ import world.bentobox.bentobox.util.teleport.ClosestSafeSpotTeleport.PositionDat
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({Util.class, Bukkit.class})
|
@PrepareForTest({ Util.class, Bukkit.class, IslandsManager.class })
|
||||||
public class ClosestSafeSpotTeleportTest {
|
public class ClosestSafeSpotTeleportTest {
|
||||||
|
|
||||||
// Class under test
|
// Class under test
|
||||||
|
@ -102,6 +102,9 @@ public class ClosestSafeSpotTeleportTest {
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
// IslandsManager static
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
|
|
||||||
// Setup instance
|
// Setup instance
|
||||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
// IWM
|
// IWM
|
||||||
|
|
|
@ -47,7 +47,7 @@ import world.bentobox.bentobox.util.Util;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({Util.class, Bukkit.class})
|
@PrepareForTest({ Util.class, Bukkit.class, IslandsManager.class })
|
||||||
public class SafeSpotTeleportTest {
|
public class SafeSpotTeleportTest {
|
||||||
|
|
||||||
// Class under test
|
// Class under test
|
||||||
|
@ -92,6 +92,7 @@ public class SafeSpotTeleportTest {
|
||||||
*/
|
*/
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
PowerMockito.mockStatic(IslandsManager.class, Mockito.RETURNS_MOCKS);
|
||||||
// Setup instance
|
// Setup instance
|
||||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||||
// IWM
|
// IWM
|
||||||
|
|
Loading…
Reference in New Issue