commit
95d89c56bc
20
pom.xml
20
pom.xml
|
@ -88,7 +88,7 @@
|
|||
<!-- Do not change unless you want different name for local builds. -->
|
||||
<build.number>-LOCAL</build.number>
|
||||
<!-- This allows to change between versions. -->
|
||||
<build.version>2.0.0</build.version>
|
||||
<build.version>2.1.0</build.version>
|
||||
<sonar.organization>bentobox-world</sonar.organization>
|
||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||
<server.jars>${project.basedir}/lib</server.jars>
|
||||
|
@ -224,6 +224,24 @@
|
|||
<version>${spigot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc.</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.20.3-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc..</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc...</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Paper API -->
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
|
|
|
@ -2,11 +2,13 @@ package world.bentobox.bentobox.api.commands.admin;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||
|
@ -19,6 +21,10 @@ import world.bentobox.bentobox.util.Util;
|
|||
|
||||
public class AdminRegisterCommand extends ConfirmableCommand {
|
||||
|
||||
private Island island;
|
||||
private Location closestIsland;
|
||||
private @Nullable UUID targetUUID;
|
||||
|
||||
public AdminRegisterCommand(CompositeCommand parent) {
|
||||
super(parent, "register");
|
||||
}
|
||||
|
@ -32,104 +38,108 @@ public class AdminRegisterCommand extends ConfirmableCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
public boolean canExecute(User user, String label, List<String> args) {
|
||||
// If args are not right, show help
|
||||
if (args.size() != 1) {
|
||||
showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
// Check world
|
||||
if (!getWorld().equals(user.getWorld())) {
|
||||
user.sendMessage("general.errors.wrong-world");
|
||||
return false;
|
||||
}
|
||||
// Get target
|
||||
UUID targetUUID = Util.getUUID(args.get(0));
|
||||
targetUUID = Util.getUUID(args.get(0));
|
||||
if (targetUUID == null) {
|
||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
||||
return false;
|
||||
}
|
||||
if (getIslands().hasIsland(getWorld(), targetUUID)) {
|
||||
user.sendMessage("general.errors.player-has-island");
|
||||
return false;
|
||||
}
|
||||
if (getIslands().inTeam(getWorld(), targetUUID)) {
|
||||
user.sendMessage("commands.admin.register.cannot-register-team-player");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if this spot is still being deleted
|
||||
Location closestIsland = Util.getClosestIsland(user.getLocation());
|
||||
closestIsland = Util.getClosestIsland(user.getLocation());
|
||||
if (getPlugin().getIslandDeletionManager().inDeletion(closestIsland)) {
|
||||
user.sendMessage("commands.admin.register.in-deletion");
|
||||
return false;
|
||||
}
|
||||
// Check if island is owned
|
||||
Optional<Island> island = getIslands().getIslandAt(user.getLocation());
|
||||
if (island.filter(Island::isOwned)
|
||||
.filter(i -> !i.getOwner().equals(targetUUID))
|
||||
.isPresent()) {
|
||||
Optional<Island> opIsland = getIslands().getIslandAt(user.getLocation());
|
||||
if (opIsland.isEmpty()) {
|
||||
// Reserve spot
|
||||
this.askConfirmation(user, user.getTranslation("commands.admin.register.no-island-here"),
|
||||
() -> reserve(user, args.get(0)));
|
||||
return false;
|
||||
}
|
||||
island = opIsland.get();
|
||||
if (targetUUID.equals(island.getOwner())) {
|
||||
user.sendMessage("commands.admin.register.already-owned");
|
||||
return false;
|
||||
}
|
||||
// Check if island is spawn
|
||||
if (island.map(Island::isSpawn).orElse(false)) {
|
||||
askConfirmation(user, user.getTranslation("commands.admin.register.island-is-spawn"), () -> register(user, args.get(0), targetUUID, island, closestIsland));
|
||||
if (island.isSpawn()) {
|
||||
askConfirmation(user, user.getTranslation("commands.admin.register.island-is-spawn"),
|
||||
() -> register(user, args.get(0)));
|
||||
return false;
|
||||
}
|
||||
return register(user, args.get(0),targetUUID, island, closestIsland);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean register(User user, String targetName, UUID targetUUID, Optional<Island> island, Location closestIsland) {
|
||||
// Register island if it exists
|
||||
if (!island.map(i -> {
|
||||
// Island exists
|
||||
getIslands().setOwner(user, targetUUID, i, RanksManager.VISITOR_RANK);
|
||||
if (i.isSpawn()) {
|
||||
getIslands().clearSpawn(i.getWorld());
|
||||
}
|
||||
user.sendMessage("commands.admin.register.registered-island", TextVariables.XYZ, Util.xyz(i.getCenter().toVector()),
|
||||
TextVariables.NAME, targetName);
|
||||
user.sendMessage("general.success");
|
||||
// Build and call event
|
||||
IslandEvent.builder()
|
||||
.island(i)
|
||||
.location(i.getCenter())
|
||||
.reason(IslandEvent.Reason.REGISTERED)
|
||||
.involvedPlayer(targetUUID)
|
||||
.admin(true)
|
||||
.build();
|
||||
IslandEvent.builder()
|
||||
.island(i)
|
||||
.involvedPlayer(targetUUID)
|
||||
.admin(true)
|
||||
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||
.rankChange(RanksManager.VISITOR_RANK, RanksManager.OWNER_RANK)
|
||||
.build();
|
||||
return true;
|
||||
}).orElse(false)) {
|
||||
// Island does not exist - this is a reservation
|
||||
this.askConfirmation(user, user.getTranslation("commands.admin.register.no-island-here"), () -> {
|
||||
// Make island here
|
||||
Island i = getIslands().createIsland(closestIsland, targetUUID);
|
||||
if (i == null) {
|
||||
user.sendMessage("commands.admin.register.cannot-make-island");
|
||||
return;
|
||||
}
|
||||
getIslands().setOwner(user, targetUUID, i, RanksManager.VISITOR_RANK);
|
||||
i.setReserved(true);
|
||||
i.getCenter().getBlock().setType(Material.BEDROCK);
|
||||
user.sendMessage("commands.admin.register.reserved-island", TextVariables.XYZ, Util.xyz(i.getCenter().toVector()),
|
||||
TextVariables.NAME, targetName);
|
||||
// Build and fire event
|
||||
IslandEvent.builder()
|
||||
.island(i)
|
||||
.location(i.getCenter())
|
||||
.reason(IslandEvent.Reason.RESERVED)
|
||||
.involvedPlayer(targetUUID)
|
||||
.admin(true)
|
||||
.build();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
register(user, args.get(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reserve a spot for a target
|
||||
* @param user user doing the reserving
|
||||
* @param targetName target name
|
||||
*/
|
||||
void reserve(User user, String targetName) {
|
||||
Objects.requireNonNull(closestIsland);
|
||||
Objects.requireNonNull(targetUUID);
|
||||
// Island does not exist - this is a reservation
|
||||
// Make island here
|
||||
Island i = getIslands().createIsland(closestIsland, targetUUID);
|
||||
if (i == null) {
|
||||
user.sendMessage("commands.admin.register.cannot-make-island");
|
||||
return;
|
||||
}
|
||||
getIslands().setOwner(user, targetUUID, i, RanksManager.VISITOR_RANK);
|
||||
i.setReserved(true);
|
||||
i.getCenter().getBlock().setType(Material.BEDROCK);
|
||||
user.sendMessage("commands.admin.register.reserved-island", TextVariables.XYZ,
|
||||
Util.xyz(i.getCenter().toVector()), TextVariables.NAME, targetName);
|
||||
// Build and fire event
|
||||
IslandEvent.builder().island(i).location(i.getCenter()).reason(IslandEvent.Reason.RESERVED)
|
||||
.involvedPlayer(targetUUID).admin(true).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the island to a target
|
||||
* @param user user doing the registering
|
||||
* @param targetName name of target
|
||||
*/
|
||||
void register(User user, String targetName) {
|
||||
Objects.requireNonNull(closestIsland);
|
||||
Objects.requireNonNull(targetUUID);
|
||||
Objects.requireNonNull(island);
|
||||
// Island exists
|
||||
getIslands().setOwner(user, targetUUID, island, RanksManager.VISITOR_RANK);
|
||||
if (island.isSpawn()) {
|
||||
getIslands().clearSpawn(island.getWorld());
|
||||
}
|
||||
user.sendMessage("commands.admin.register.registered-island", TextVariables.XYZ,
|
||||
Util.xyz(island.getCenter().toVector()), TextVariables.NAME, targetName);
|
||||
user.sendMessage("general.success");
|
||||
// Build and call event
|
||||
IslandEvent.builder().island(island).location(island.getCenter()).reason(IslandEvent.Reason.REGISTERED)
|
||||
.involvedPlayer(targetUUID).admin(true).build();
|
||||
IslandEvent.builder().island(island).involvedPlayer(targetUUID).admin(true)
|
||||
.reason(IslandEvent.Reason.RANK_CHANGE).rankChange(RanksManager.VISITOR_RANK, RanksManager.OWNER_RANK)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||
|
|
|
@ -65,8 +65,8 @@ public class AdminSetspawnCommand extends ConfirmableCommand {
|
|||
.build();
|
||||
}
|
||||
// If island is owned, then unregister the owner and any members
|
||||
new ImmutableSet.Builder<UUID>().addAll(i.getMembers().keySet()).build().forEach(m ->
|
||||
getIslands().removePlayer(getWorld(), m));
|
||||
new ImmutableSet.Builder<UUID>().addAll(i.getMembers().keySet()).build()
|
||||
.forEach(m -> getIslands().removePlayer(i, m));
|
||||
}
|
||||
getIslands().setSpawn(i);
|
||||
i.setSpawnPoint(World.Environment.NORMAL, user.getLocation());
|
||||
|
|
|
@ -2,13 +2,19 @@ package world.bentobox.bentobox.api.commands.admin;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.logs.LogEntry;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
|
@ -16,6 +22,9 @@ import world.bentobox.bentobox.util.Util;
|
|||
|
||||
public class AdminUnregisterCommand extends ConfirmableCommand {
|
||||
|
||||
private Island targetIsland;
|
||||
private @Nullable UUID targetUUID;
|
||||
|
||||
public AdminUnregisterCommand(CompositeCommand parent) {
|
||||
super(parent, "unregister");
|
||||
}
|
||||
|
@ -30,12 +39,12 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
|||
@Override
|
||||
public boolean canExecute(User user, String label, List<String> args) {
|
||||
// If args are not right, show help
|
||||
if (args.size() != 1) {
|
||||
if (args.isEmpty()) {
|
||||
showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
// Get target
|
||||
UUID targetUUID = Util.getUUID(args.get(0));
|
||||
targetUUID = Util.getUUID(args.get(0));
|
||||
if (targetUUID == null) {
|
||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
||||
return false;
|
||||
|
@ -44,43 +53,72 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
|||
user.sendMessage("general.errors.player-has-no-island");
|
||||
return false;
|
||||
}
|
||||
// Check if the player has more than one island
|
||||
Map<String, Island> islands = getIslandsXYZ(targetUUID);
|
||||
if (islands.size() == 0) {
|
||||
user.sendMessage("general.errors.player-has-no-island");
|
||||
return false;
|
||||
} else if (args.size() == 1) {
|
||||
if (islands.size() == 1) {
|
||||
targetIsland = islands.values().iterator().next();
|
||||
return true;
|
||||
} else {
|
||||
// They need to specify which island
|
||||
user.sendMessage("commands.admin.unregister.errors.player-has-more-than-one-island");
|
||||
user.sendMessage("commands.admin.unregister.errors.specify-island-location");
|
||||
return false;
|
||||
}
|
||||
} else if (args.size() != 2) {
|
||||
// Check if the name given works
|
||||
user.sendMessage("commands.admin.unregister.errors.specify-island-location");
|
||||
return false;
|
||||
} else if (!islands.containsKey(args.get(1))) {
|
||||
if (args.get(1).equalsIgnoreCase("help")) {
|
||||
this.showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
user.sendMessage("commands.admin.unregister.errors.unknown-island-location");
|
||||
return false;
|
||||
}
|
||||
targetIsland = islands.get(args.get(1));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
// Get target
|
||||
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||
Objects.requireNonNull(targetIsland);
|
||||
Objects.requireNonNull(targetUUID);
|
||||
// Everything's fine, we can set the island as spawn :)
|
||||
askConfirmation(user, () -> unregisterPlayer(user, args.get(0), targetUUID));
|
||||
askConfirmation(user, () -> unregisterIsland(user));
|
||||
return true;
|
||||
}
|
||||
|
||||
void unregisterPlayer(User user, String targetName, UUID targetUUID) {
|
||||
void unregisterIsland(User user) {
|
||||
// Unregister island
|
||||
Island oldIsland = getIslands().getIsland(getWorld(), targetUUID);
|
||||
if (oldIsland == null) return;
|
||||
IslandEvent.builder()
|
||||
.island(oldIsland)
|
||||
.location(oldIsland.getCenter())
|
||||
.island(targetIsland)
|
||||
.location(targetIsland.getCenter())
|
||||
.reason(IslandEvent.Reason.UNREGISTERED)
|
||||
.involvedPlayer(targetUUID)
|
||||
.admin(true)
|
||||
.build();
|
||||
IslandEvent.builder()
|
||||
.island(oldIsland)
|
||||
.island(targetIsland)
|
||||
.involvedPlayer(targetUUID)
|
||||
.admin(true)
|
||||
.reason(IslandEvent.Reason.RANK_CHANGE)
|
||||
.rankChange(RanksManager.OWNER_RANK, RanksManager.VISITOR_RANK)
|
||||
.build();
|
||||
targetIsland.setOwner(null);
|
||||
// Remove all island members
|
||||
oldIsland.getMemberSet().forEach(m -> getIslands().removePlayer(getWorld(), m));
|
||||
targetIsland.getMemberSet().forEach(m -> getIslands().removePlayer(targetIsland, m));
|
||||
// Remove all island players that reference this island
|
||||
oldIsland.getMembers().clear();
|
||||
getIslands().save(oldIsland);
|
||||
user.sendMessage("commands.admin.unregister.unregistered-island", TextVariables.XYZ, Util.xyz(oldIsland.getCenter().toVector()),
|
||||
TextVariables.NAME, targetName);
|
||||
targetIsland.getMembers().clear();
|
||||
targetIsland.log(new LogEntry.Builder("UNREGISTER").data("player", targetUUID.toString())
|
||||
.data("admin", user.getUniqueId().toString()).build());
|
||||
getIslands().save(targetIsland);
|
||||
user.sendMessage("commands.admin.unregister.unregistered-island", TextVariables.XYZ, Util.xyz(targetIsland.getCenter().toVector()),
|
||||
TextVariables.NAME, getPlayers().getName(targetUUID));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,8 +127,22 @@ public class AdminUnregisterCommand extends ConfirmableCommand {
|
|||
if (args.isEmpty()) {
|
||||
// Don't show every player on the server. Require at least the first letter
|
||||
return Optional.empty();
|
||||
} else if (args.size() == 2) {
|
||||
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user));
|
||||
return Optional.of(Util.tabLimit(options, lastArg));
|
||||
} else if (args.size() > 2) {
|
||||
// Find out which user
|
||||
UUID uuid = getPlayers().getUUID(args.get(1));
|
||||
if (uuid != null) {
|
||||
return Optional.of(Util.tabLimit(new ArrayList<>(getIslandsXYZ(uuid).keySet()), lastArg));
|
||||
}
|
||||
}
|
||||
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user));
|
||||
return Optional.of(Util.tabLimit(options, lastArg));
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private Map<String, Island> getIslandsXYZ(UUID target) {
|
||||
return getIslands().getOwnedIslands(getWorld(), target).stream()
|
||||
.collect(Collectors.toMap(island -> Util.xyz(island.getCenter().toVector()), island -> island));
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ public class AdminBlueprintPasteCommand extends CompositeCommand {
|
|||
AdminBlueprintCommand parent = (AdminBlueprintCommand) getParent();
|
||||
BlueprintClipboard clipboard = parent.getClipboards().computeIfAbsent(user.getUniqueId(), v -> new BlueprintClipboard());
|
||||
if (clipboard.isFull()) {
|
||||
new BlueprintPaster(getPlugin(), clipboard, user.getLocation()).paste().thenAccept(b -> {
|
||||
new BlueprintPaster(getPlugin(), clipboard, user.getLocation()).paste(false).thenAccept(b -> {
|
||||
user.sendMessage("general.success");
|
||||
parent.showClipboard(user);
|
||||
});
|
||||
|
|
|
@ -32,7 +32,7 @@ public class AdminTeamCommand extends CompositeCommand
|
|||
|
||||
new AdminTeamAddCommand(this);
|
||||
new AdminTeamDisbandCommand(this);
|
||||
new AdminTeamFixCommand(this);
|
||||
|
||||
new AdminTeamKickCommand(this);
|
||||
new AdminTeamSetownerCommand(this);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
package world.bentobox.bentobox.api.commands.admin.team;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||
|
@ -14,6 +21,13 @@ import world.bentobox.bentobox.util.Util;
|
|||
|
||||
public class AdminTeamDisbandCommand extends CompositeCommand {
|
||||
|
||||
private Island island;
|
||||
private @Nullable UUID targetUUID;
|
||||
|
||||
/**
|
||||
* Disbands a team
|
||||
* @param parent parent command
|
||||
*/
|
||||
public AdminTeamDisbandCommand(CompositeCommand parent) {
|
||||
super(parent, "disband");
|
||||
}
|
||||
|
@ -26,32 +40,55 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
public boolean canExecute(User user, String label, List<String> args) {
|
||||
// If args are not right, show help
|
||||
if (args.size() != 1) {
|
||||
if (args.isEmpty() || args.size() > 2) {
|
||||
showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
// Get target
|
||||
UUID targetUUID = Util.getUUID(args.get(0));
|
||||
targetUUID = Util.getUUID(args.get(0));
|
||||
if (targetUUID == null) {
|
||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
||||
return false;
|
||||
}
|
||||
if (!getIslands().hasIsland(getWorld(), targetUUID)) {
|
||||
user.sendMessage("general.errors.no-island");
|
||||
return false;
|
||||
}
|
||||
if (!getIslands().inTeam(getWorld(), targetUUID)) {
|
||||
user.sendMessage("general.errors.not-in-team");
|
||||
user.sendMessage("general.errors.player-is-not-owner", TextVariables.NAME, args.get(0));
|
||||
return false;
|
||||
}
|
||||
Island island = getIslands().getPrimaryIsland(getWorld(), targetUUID);
|
||||
if (!targetUUID.equals(island.getOwner())) {
|
||||
user.sendMessage("commands.admin.team.disband.use-disband-owner", "[owner]",
|
||||
getPlayers().getName(island.getOwner()));
|
||||
// Find the island the player is an owner of
|
||||
Map<String, Island> islands = getIslandsXYZ(targetUUID);
|
||||
if (islands.isEmpty()) {
|
||||
user.sendMessage("general.errors.player-has-no-island");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (islands.size() > 1) {
|
||||
if (args.size() != 2 || !islands.containsKey(args.get(1))) {
|
||||
user.sendMessage("commands.admin.team.disband.more-than-one-island", TextVariables.NAME,
|
||||
getPlayers().getName(island.getOwner()));
|
||||
islands.keySet().forEach(coords -> user.sendMessage("commands.admin.team.disband.more-than-one-island",
|
||||
TextVariables.XYZ, coords));
|
||||
return false;
|
||||
}
|
||||
// Get the named island
|
||||
island = islands.get(args.get(1));
|
||||
} else {
|
||||
// Get the only island
|
||||
island = islands.values().iterator().next();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Map<String, Island> getIslandsXYZ(UUID target) {
|
||||
return getIslands().getOwnedIslands(getWorld(), target).stream().filter(is -> is.getMemberSet().size() > 1) // Filter for teams
|
||||
.collect(Collectors.toMap(island -> Util.xyz(island.getCenter().toVector()), island -> island));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
Objects.requireNonNull(island);
|
||||
Objects.requireNonNull(targetUUID);
|
||||
// Disband team
|
||||
island.getMemberSet().forEach(m -> {
|
||||
User mUser = User.getInstance(m);
|
||||
|
@ -68,4 +105,24 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
|
|||
user.sendMessage("commands.admin.team.disband.success", TextVariables.NAME, args.get(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||
String lastArg = !args.isEmpty() ? args.get(args.size() - 1) : "";
|
||||
if (args.isEmpty()) {
|
||||
// Don't show every player on the server. Require at least the first letter
|
||||
return Optional.empty();
|
||||
} else if (args.size() == 3) {
|
||||
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user));
|
||||
return Optional.of(Util.tabLimit(options, lastArg));
|
||||
} else if (args.size() > 3) {
|
||||
// Find out which user
|
||||
UUID uuid = getPlayers().getUUID(args.get(1));
|
||||
if (uuid != null) {
|
||||
return Optional.of(Util.tabLimit(new ArrayList<>(getIslandsXYZ(uuid).keySet()), lastArg));
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class AdminTeamKickCommand extends CompositeCommand {
|
|||
User target = User.getInstance(targetUUID);
|
||||
target.sendMessage("commands.admin.team.kick.admin-kicked");
|
||||
|
||||
getIslands().removePlayer(getWorld(), targetUUID);
|
||||
getIslands().removePlayer(island, targetUUID);
|
||||
user.sendMessage("commands.admin.team.kick.success", TextVariables.NAME, target.getName(), "[owner]", getPlayers().getName(island.getOwner()));
|
||||
|
||||
// Fire event so add-ons know
|
||||
|
|
|
@ -156,7 +156,7 @@ public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
|
|||
user.sendMessage("commands.island.team.invite.errors.island-is-full");
|
||||
return;
|
||||
}
|
||||
// Remove player as owner of the old island
|
||||
// Remove the player's other islands
|
||||
getIslands().removePlayer(getWorld(), user.getUniqueId());
|
||||
// Remove money inventory etc. for leaving
|
||||
cleanPlayer(user);
|
||||
|
|
|
@ -36,6 +36,9 @@ import world.bentobox.bentobox.util.Util;
|
|||
*/
|
||||
public class BlueprintPaster {
|
||||
|
||||
/**
|
||||
* This tracks the stages of pasting from loading the chunk, pasting blocks, attachments, entities and then finishing.
|
||||
*/
|
||||
enum PasteState {
|
||||
CHUNK_LOAD,
|
||||
CHUNK_LOADING,
|
||||
|
@ -55,6 +58,7 @@ public class BlueprintPaster {
|
|||
|
||||
private final BentoBox plugin;
|
||||
private final PasteHandler paster = Util.getPasteHandler();
|
||||
private final PasteHandler fallback = new world.bentobox.bentobox.nms.fallback.PasteHandlerImpl();
|
||||
private final World world;
|
||||
// The minimum block position (x,y,z)
|
||||
private Location pos1;
|
||||
|
@ -124,10 +128,20 @@ public class BlueprintPaster {
|
|||
Iterator<Entry<Vector, BlueprintBlock>> it2,
|
||||
Iterator<Entry<Vector, List<BlueprintEntity>>> it3,
|
||||
int pasteSpeed) {}
|
||||
|
||||
/**
|
||||
* The main pasting method
|
||||
*/
|
||||
public CompletableFuture<Boolean> paste() {
|
||||
return this.paste(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paste the clipboard
|
||||
* @param useNMS if true, NMS pasting will be used, otherwise Bukkit API
|
||||
* @return Future boolean where true is success
|
||||
*/
|
||||
public CompletableFuture<Boolean> paste(boolean useNMS) {
|
||||
CompletableFuture<Boolean> result = new CompletableFuture<>();
|
||||
// Iterators for the various maps to paste
|
||||
final Map<Vector, BlueprintBlock> blocks = blueprint.getBlocks() == null ? Collections.emptyMap() : blueprint.getBlocks();
|
||||
|
@ -145,12 +159,12 @@ public class BlueprintPaster {
|
|||
Bits bits = new Bits(blocks, attached, entities,
|
||||
blocks.entrySet().iterator(), attached.entrySet().iterator(), entities.entrySet().iterator(),
|
||||
plugin.getSettings().getPasteSpeed());
|
||||
pastingTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> pasterTask(result, owner, bits), 0L, 1L);
|
||||
pastingTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> pasterTask(result, owner, bits, useNMS), 0L, 1L);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void pasterTask(CompletableFuture<Boolean> result, Optional<User> owner, Bits bits) {
|
||||
private void pasterTask(CompletableFuture<Boolean> result, Optional<User> owner, Bits bits, boolean useNMS) {
|
||||
if (!currentTask.isDone()) return;
|
||||
|
||||
final int pasteSpeed = plugin.getSettings().getPasteSpeed();
|
||||
|
@ -160,10 +174,10 @@ public class BlueprintPaster {
|
|||
loadChunk();
|
||||
}
|
||||
else if (pasteState.equals(PasteState.BLOCKS) || pasteState.equals(PasteState.ATTACHMENTS)) {
|
||||
pasteBlocks(bits, count, owner, pasteSpeed);
|
||||
pasteBlocks(bits, count, owner, pasteSpeed, useNMS);
|
||||
}
|
||||
else if (pasteState.equals(PasteState.ENTITIES)) {
|
||||
pasteEntities(bits, count, owner, pasteSpeed);
|
||||
pasteEntities(bits, count, owner, pasteSpeed, useNMS);
|
||||
}
|
||||
else if (pasteState.equals(PasteState.DONE)) {
|
||||
// All done. Cancel task
|
||||
|
@ -185,7 +199,7 @@ public class BlueprintPaster {
|
|||
result.complete(true);
|
||||
}
|
||||
|
||||
private void pasteEntities(Bits bits, int count, Optional<User> owner, int pasteSpeed) {
|
||||
private void pasteEntities(Bits bits, int count, Optional<User> owner, int pasteSpeed, boolean useNMS) {
|
||||
if (bits.it3().hasNext()) {
|
||||
Map<Location, List<BlueprintEntity>> entityMap = new HashMap<>();
|
||||
// Paste entities
|
||||
|
@ -203,7 +217,8 @@ public class BlueprintPaster {
|
|||
count++;
|
||||
}
|
||||
if (!entityMap.isEmpty()) {
|
||||
currentTask = paster.pasteEntities(island, world, entityMap);
|
||||
currentTask = useNMS ? paster.pasteEntities(island, world, entityMap)
|
||||
: fallback.pasteEntities(island, world, entityMap);
|
||||
}
|
||||
} else {
|
||||
pasteState = PasteState.DONE;
|
||||
|
@ -219,7 +234,7 @@ public class BlueprintPaster {
|
|||
|
||||
}
|
||||
|
||||
private void pasteBlocks(Bits bits, int count, Optional<User> owner, int pasteSpeed) {
|
||||
private void pasteBlocks(Bits bits, int count, Optional<User> owner, int pasteSpeed, boolean useNMS) {
|
||||
Iterator<Entry<Vector, BlueprintBlock>> it = pasteState.equals(PasteState.BLOCKS) ? bits.it : bits.it2;
|
||||
if (it.hasNext()) {
|
||||
Map<Location, BlueprintBlock> blockMap = new HashMap<>();
|
||||
|
@ -238,7 +253,8 @@ public class BlueprintPaster {
|
|||
count++;
|
||||
}
|
||||
if (!blockMap.isEmpty()) {
|
||||
currentTask = paster.pasteBlocks(island, world, blockMap);
|
||||
currentTask = useNMS ? paster.pasteBlocks(island, world, blockMap)
|
||||
: fallback.pasteBlocks(island, world, blockMap);
|
||||
}
|
||||
} else {
|
||||
if (pasteState.equals(PasteState.BLOCKS)) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
import com.google.gson.annotations.Expose;
|
||||
|
||||
/**
|
||||
* Represents a block to be pasted
|
||||
* @author tastybento
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
@ -19,8 +20,14 @@ public class BlueprintBlock {
|
|||
|
||||
@Expose
|
||||
private String blockData;
|
||||
/**
|
||||
* Front of sign
|
||||
*/
|
||||
@Expose
|
||||
private List<String> signLines;
|
||||
/**
|
||||
* Back of sign
|
||||
*/
|
||||
@Expose
|
||||
private List<String> signLines2;
|
||||
@Expose
|
||||
|
@ -37,8 +44,14 @@ public class BlueprintBlock {
|
|||
*/
|
||||
@Expose
|
||||
private List<Pattern> bannerPatterns;
|
||||
/**
|
||||
* Front of sign
|
||||
*/
|
||||
@Expose
|
||||
private boolean glowingText;
|
||||
/**
|
||||
* Back of sign
|
||||
*/
|
||||
@Expose
|
||||
private boolean glowingText2;
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ public class BentoBoxVersionCommand extends CompositeCommand {
|
|||
user.sendMessage("commands.bentobox.version.server",
|
||||
TextVariables.NAME, serverSoftware.equals(ServerSoftware.UNKNOWN) ? user.getTranslation("general.invalid") + " (" + serverSoftware.getName() + ")" : serverSoftware.toString(),
|
||||
TextVariables.VERSION, serverVersion != null ? serverVersion.toString() : user.getTranslation("general.invalid"));
|
||||
user.sendRawMessage("(" + Bukkit.getVersion() + ")");
|
||||
user.sendMessage("commands.bentobox.version.plugin-version", TextVariables.VERSION, getPlugin().getDescription().getVersion());
|
||||
user.sendMessage("commands.bentobox.version.database", "[database]", getSettings().getDatabaseType().toString());
|
||||
user.sendMessage("commands.bentobox.version.loaded-game-worlds");
|
||||
|
|
|
@ -12,7 +12,8 @@ import com.google.gson.annotations.Expose;
|
|||
@Table(name = "Ranks")
|
||||
public class Ranks implements DataObject {
|
||||
|
||||
public static final String ID = "BentoBox-Ranks";
|
||||
@Expose
|
||||
public String uniqueId = "BentoBox-Ranks";
|
||||
|
||||
public Ranks(Map<String, Integer> rankReference) {
|
||||
super();
|
||||
|
@ -24,12 +25,12 @@ public class Ranks implements DataObject {
|
|||
|
||||
@Override
|
||||
public String getUniqueId() {
|
||||
return ID;
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUniqueId(String uniqueId) {
|
||||
// Nothing to do
|
||||
this.uniqueId = uniqueId;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getRankReference() {
|
||||
|
|
|
@ -448,9 +448,13 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||
Map<Object, Object> result = new HashMap<>();
|
||||
for (Entry<Object, Object> object : value.entrySet()) {
|
||||
// Serialize all key and values
|
||||
String key = (String)serialize(object.getKey());
|
||||
key = key.replace("\\.", ":dot:");
|
||||
result.put(key, serialize(object.getValue()));
|
||||
if (serialize(object.getKey()) instanceof String key) {
|
||||
key = key.replace("\\.", ":dot:");
|
||||
result.put(key, serialize(object.getValue()));
|
||||
} else {
|
||||
plugin.logWarning("Map key in config file could not be serialized, skipping. Entry is "
|
||||
+ object.getKey() + ": " + object.getValue());
|
||||
}
|
||||
}
|
||||
// Save the list in the config file
|
||||
config.set(storageLocation, result);
|
||||
|
@ -637,7 +641,7 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||
.or(Enums.getIfPresent(EntityType.class, "PIG_ZOMBIE").or(EntityType.PIG));
|
||||
}
|
||||
// Backwards compatibility for upgrade to 1.20.4
|
||||
if (name.equals("GRASS")) {
|
||||
if (name.equals("GRASS") && Enums.getIfPresent(EntityType.class, "SHORT_GRASS").isPresent()) {
|
||||
return Enums.getIfPresent(EntityType.class, "SHORT_GRASS");
|
||||
}
|
||||
value = Enum.valueOf(enumClass, name);
|
||||
|
|
|
@ -74,7 +74,8 @@ public class ItemsAdderHook extends Hook {
|
|||
* @param location
|
||||
*/
|
||||
public void clearBlockInfo(Location location) {
|
||||
CustomBlock.remove(location);
|
||||
// TODO: find a more efficient way of doing this.
|
||||
// CustomBlock.remove(location);
|
||||
}
|
||||
|
||||
class BlockInteractListener extends FlagListener {
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.bukkit.World;
|
|||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.api.panels.Panel;
|
||||
import world.bentobox.bentobox.api.panels.PanelItem.ClickHandler;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
@ -18,6 +19,7 @@ import world.bentobox.bentobox.managers.RanksManager;
|
|||
*/
|
||||
public class CommandCycleClick implements ClickHandler {
|
||||
|
||||
protected static final String COMMAND_RANK_PREFIX = "COMMAND_RANK:";
|
||||
private final BentoBox plugin = BentoBox.getInstance();
|
||||
private final String command;
|
||||
private final CommandRankClickListener commandRankClickListener;
|
||||
|
@ -53,6 +55,8 @@ public class CommandCycleClick implements ClickHandler {
|
|||
island.setRankCommand(command, RanksManager.getInstance().getRankDownValue(currentRank));
|
||||
}
|
||||
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1F, 1F);
|
||||
} else if (click.equals(ClickType.SHIFT_LEFT) && user.isOp()) {
|
||||
leftShiftClick(user);
|
||||
}
|
||||
// Apply change to panel
|
||||
panel.getInventory().setItem(slot, commandRankClickListener.getPanelItem(command, user, world).getItem());
|
||||
|
@ -65,4 +69,22 @@ public class CommandCycleClick implements ClickHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds or removes the command rank from visibility by non-Ops
|
||||
* @param user - the Op requesting the change
|
||||
*/
|
||||
private void leftShiftClick(User user) {
|
||||
String configSetting = COMMAND_RANK_PREFIX + command;
|
||||
if (!plugin.getIWM().getHiddenFlags(user.getWorld()).contains(configSetting)) {
|
||||
plugin.getIWM().getHiddenFlags(user.getWorld()).add(configSetting);
|
||||
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_GLASS_BREAK, 1F, 1F);
|
||||
} else {
|
||||
plugin.getIWM().getHiddenFlags(user.getWorld()).remove(configSetting);
|
||||
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1F, 1F);
|
||||
}
|
||||
// Save changes
|
||||
plugin.getIWM().getAddon(user.getWorld()).ifPresent(GameModeAddon::saveWorldSettings);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class CommandRankClickListener implements ClickHandler {
|
|||
if (panel.getName().equals(panelName)) {
|
||||
// This is a click on the panel
|
||||
// Slot relates to the command
|
||||
String c = getCommands(panel.getWorld().orElse(user.getWorld())).get(slot);
|
||||
String c = getCommands(panel.getWorld().orElse(user.getWorld()), user).get(slot);
|
||||
// Apply change to panel
|
||||
panel.getInventory().setItem(slot, getPanelItem(c, user, panel.getWorld().orElse(user.getWorld())).getItem());
|
||||
} else {
|
||||
|
@ -94,7 +94,7 @@ public class CommandRankClickListener implements ClickHandler {
|
|||
PanelBuilder pb = new PanelBuilder();
|
||||
pb.user(user).name(panelName).world(world);
|
||||
// Make panel items
|
||||
getCommands(world).forEach(c -> pb.item(getPanelItem(c, user, world)));
|
||||
getCommands(world, user).forEach(c -> pb.item(getPanelItem(c, user, world)));
|
||||
pb.build();
|
||||
|
||||
}
|
||||
|
@ -123,18 +123,19 @@ public class CommandRankClickListener implements ClickHandler {
|
|||
pib.description(user.getTranslation("protection.panel.flag-item.minimal-rank") + user.getTranslation(reference));
|
||||
}
|
||||
});
|
||||
pib.invisible(plugin.getIWM().getHiddenFlags(world).contains(CommandCycleClick.COMMAND_RANK_PREFIX + c));
|
||||
return pib.build();
|
||||
}
|
||||
|
||||
private List<String> getCommands(World world) {
|
||||
List<String> result = new ArrayList<>();
|
||||
plugin.getCommandsManager().getCommands().values().stream()
|
||||
.filter(c -> c.getWorld() != null && c.getWorld().equals(world))
|
||||
.forEach(c -> result.addAll(getCmdRecursively("/", c)));
|
||||
if (result.size() > 49) {
|
||||
plugin.logError("Number of rank setting commands is too big for GUI");
|
||||
result.subList(49, result.size()).clear();
|
||||
}
|
||||
private List<String> getCommands(World world, User user) {
|
||||
List<String> hiddenItems = plugin.getIWM().getHiddenFlags(world);
|
||||
List<String> result = plugin.getCommandsManager().getCommands().values().stream()
|
||||
.filter(c -> c.getWorld() != null && c.getWorld().equals(world)) // Only allow commands in this world
|
||||
.filter(c -> c.testPermission(user.getSender())) // Only allow them to see commands they have permission to see
|
||||
.flatMap(c -> getCmdRecursively("/", c).stream())
|
||||
.filter(label -> user.isOp() || !hiddenItems.contains(CommandCycleClick.COMMAND_RANK_PREFIX + label))
|
||||
.limit(49) // Silently limit to 49
|
||||
.toList();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class IslandRespawnListener extends FlagListener {
|
|||
*
|
||||
* @param e - event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent e) {
|
||||
final UUID worldUUID = respawn.remove(e.getPlayer().getUniqueId());
|
||||
if (worldUUID == null) {
|
||||
|
@ -67,11 +67,11 @@ public class IslandRespawnListener extends FlagListener {
|
|||
return; // world no longer available
|
||||
}
|
||||
World w = Util.getWorld(world);
|
||||
|
||||
String ownerName = e.getPlayer().getName();
|
||||
if (w != null) {
|
||||
final Location respawnLocation = getIslands().getPrimaryIsland(world, e.getPlayer().getUniqueId())
|
||||
.getSpawnPoint(world.getEnvironment());
|
||||
if (respawnLocation != null) {
|
||||
final Location respawnLocation = getIslands().getHomeLocation(world, e.getPlayer().getUniqueId());
|
||||
if (respawnLocation != null && getIslands().isSafeLocation(respawnLocation)) {
|
||||
e.setRespawnLocation(respawnLocation);
|
||||
// Get the island owner name
|
||||
Island island = BentoBox.getInstance().getIslands().getIsland(w, User.getInstance(e.getPlayer()));
|
||||
|
|
|
@ -198,15 +198,23 @@ public class AddonsManager {
|
|||
Addon addon;
|
||||
try {
|
||||
Plugin pladdon = Bukkit.getPluginManager().loadPlugin(f);
|
||||
if (pladdon instanceof Pladdon pl) {
|
||||
if (pladdon != null && pladdon instanceof Pladdon pl) {
|
||||
addon = pl.getAddon();
|
||||
addon.setDescription(AddonClassLoader.asDescription(data));
|
||||
// Mark pladdon as enabled.
|
||||
pl.setEnabled();
|
||||
pladdons.put(addon, pladdon);
|
||||
} else {
|
||||
plugin.logError("Could not load pladdon!");
|
||||
return new PladdonData(null, false);
|
||||
// Try to load it as an addon
|
||||
BentoBox.getInstance()
|
||||
.log("Failed to load " + f.getName() + ", trying to load it as a BentoBox addon");
|
||||
// Addon not pladdon
|
||||
AddonClassLoader addonClassLoader = new AddonClassLoader(this, data, f,
|
||||
this.getClass().getClassLoader());
|
||||
// Get the addon itself
|
||||
addon = addonClassLoader.getAddon();
|
||||
// Add to the list of loaders
|
||||
loaders.put(addon, addonClassLoader);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// Addon not pladdon
|
||||
|
|
|
@ -445,7 +445,7 @@ public class BlueprintsManager {
|
|||
* @param name - bundle name
|
||||
*/
|
||||
public void paste(GameModeAddon addon, Island island, String name) {
|
||||
paste(addon, island, name, null);
|
||||
paste(addon, island, name, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -455,9 +455,10 @@ public class BlueprintsManager {
|
|||
* @param island - the island
|
||||
* @param name - name of bundle to paste
|
||||
* @param task - task to run after pasting is completed
|
||||
* @param useNMS - true to use NMS pasting
|
||||
* @return true if okay, false is there is a problem
|
||||
*/
|
||||
public boolean paste(GameModeAddon addon, Island island, String name, Runnable task) {
|
||||
public boolean paste(GameModeAddon addon, Island island, String name, Runnable task, boolean useNMS) {
|
||||
if (validate(addon, name) == null) {
|
||||
plugin.logError("Tried to paste '" + name + "' but the bundle is not loaded!");
|
||||
return false;
|
||||
|
@ -478,7 +479,9 @@ public class BlueprintsManager {
|
|||
}
|
||||
// Paste
|
||||
if (bp != null) {
|
||||
new BlueprintPaster(plugin, bp, addon.getOverWorld(), island).paste().thenAccept(b -> pasteNether(addon, bb, island).thenAccept(b2 ->
|
||||
new BlueprintPaster(plugin, bp, addon.getOverWorld(), island).paste(useNMS)
|
||||
.thenAccept(b -> pasteNether(addon, bb, island).thenAccept(
|
||||
b2 ->
|
||||
pasteEnd(addon, bb, island).thenAccept(message -> sendMessage(island)).thenAccept(b3 -> Bukkit.getScheduler().runTask(plugin, task))));
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -326,11 +326,10 @@ public class IslandsManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets all the islands for this player in this world. If they are in a team,
|
||||
* the team island is returned.
|
||||
* Gets all the islands for this player in this world including team islands.
|
||||
*
|
||||
* @param world world to check
|
||||
* @param uniqueId user's uuid
|
||||
* @param uniqueId user's UUID
|
||||
* @return List of islands or empty list if none found for user
|
||||
*/
|
||||
@NonNull
|
||||
|
@ -338,6 +337,36 @@ public class IslandsManager {
|
|||
return islandCache.getIslands(world, uniqueId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the islands for this player in this world that this player owns.
|
||||
*
|
||||
* @param world world to check
|
||||
* @param uniqueId user's UUID
|
||||
* @return List of islands or empty list if none found for user
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@NonNull
|
||||
public Set<Island> getOwnedIslands(@NonNull World world, @NonNull User user) {
|
||||
if (user.getUniqueId() == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return getOwnedIslands(world, user.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the islands for this player in this world that this player owns.
|
||||
*
|
||||
* @param world world to check
|
||||
* @param uniqueId user's UUID
|
||||
* @return List of islands or empty list if none found for user
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@NonNull
|
||||
public Set<Island> getOwnedIslands(@NonNull World world, @NonNull UUID uniqueId) {
|
||||
return islandCache.getIslands(world, uniqueId).stream().filter(island -> uniqueId.equals(island.getOwner()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the active island for this player. If they are in a team, the team
|
||||
* island is returned. User may have more than one island. Returns the island
|
||||
|
@ -439,44 +468,6 @@ public class IslandsManager {
|
|||
return last.get(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of island member UUID's for the island of playerUUID of rank
|
||||
* <tt>minimumRank</tt> and above. This includes the owner of the island. If
|
||||
* there is no island, this set will be empty.
|
||||
*
|
||||
* @param world - world to check
|
||||
* @param playerUUID - the player's UUID
|
||||
* @param minimumRank - the minimum rank to be included in the set.
|
||||
* @return Set of team UUIDs
|
||||
* @deprecated This will be removed in 2.0 because it is ambiguous when a user
|
||||
* has more than one island in the world.
|
||||
*/
|
||||
|
||||
@Deprecated(since = "2.0", forRemoval = true)
|
||||
@NonNull
|
||||
public Set<UUID> getMembers(@NonNull World world, @NonNull UUID playerUUID, int minimumRank) {
|
||||
return islandCache.getMembers(world, playerUUID, minimumRank);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of island member UUID's for the island of playerUUID. Only
|
||||
* includes players of rank {@link RanksManager#MEMBER_RANK} and above. This
|
||||
* includes the owner of the island. If there is no island, this set will be
|
||||
* empty.
|
||||
*
|
||||
* @param world - world to check
|
||||
* @param playerUUID - the player's UUID
|
||||
* @return Set of team UUIDs
|
||||
* @deprecated This will be removed in 2.0 because it is ambiguous when a user
|
||||
* has more than one island in the world.
|
||||
*/
|
||||
|
||||
@Deprecated(since = "2.0", forRemoval = true)
|
||||
@NonNull
|
||||
public Set<UUID> getMembers(@NonNull World world, @NonNull UUID playerUUID) {
|
||||
return islandCache.getMembers(world, playerUUID, RanksManager.MEMBER_RANK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum number of island members allowed on this island. Will update
|
||||
* the value based on world settings or island owner permissions (if online). If
|
||||
|
@ -676,101 +667,6 @@ public class IslandsManager {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines a safe teleport spot on player's island or the team island they
|
||||
* belong to.
|
||||
*
|
||||
* @param world - world to check, not null
|
||||
* @param user - the player, not null
|
||||
* @param name - named home location. Blank means default.
|
||||
* @return Location of a safe teleport spot or {@code null} if one cannot be
|
||||
* found or if the world is not an island world.
|
||||
* @deprecated This will be removed in 2.0 because it is ambiguous when a user
|
||||
* has more than one island in the world.
|
||||
*/
|
||||
|
||||
@Deprecated(since = "2.0", forRemoval = true)
|
||||
@Nullable
|
||||
public Location getSafeHomeLocation(@NonNull World world, @NonNull User user, String name) {
|
||||
// Check if the world is a gamemode world
|
||||
if (!plugin.getIWM().inWorld(world)) {
|
||||
return null;
|
||||
}
|
||||
// Try the named home location first
|
||||
Location l = getHomeLocation(world, user, name);
|
||||
if (l == null) {
|
||||
// Get the default home, which may be null too, but that's okay
|
||||
name = "";
|
||||
l = getHomeLocation(world, user, name);
|
||||
}
|
||||
// Check if it is safe
|
||||
if (l != null) {
|
||||
if (isSafeLocation(l)) {
|
||||
return l;
|
||||
}
|
||||
// To cover slabs, stairs and other half blocks, try one block above
|
||||
Location lPlusOne = l.clone();
|
||||
lPlusOne.add(new Vector(0, 1, 0));
|
||||
if (isSafeLocation(lPlusOne)) {
|
||||
// Adjust the home location accordingly
|
||||
setHomeLocation(user, lPlusOne, name);
|
||||
return lPlusOne;
|
||||
}
|
||||
}
|
||||
// Home location either isn't safe, or does not exist so try the island
|
||||
// location
|
||||
if (inTeam(world, user.getUniqueId())) {
|
||||
l = getIslandLocation(world, user.getUniqueId());
|
||||
if (l != null && isSafeLocation(l)) {
|
||||
setHomeLocation(user, l, name);
|
||||
return l;
|
||||
} else {
|
||||
// try owner's home
|
||||
UUID owner = getOwner(world, user.getUniqueId());
|
||||
if (owner != null) {
|
||||
Location tlh = getHomeLocation(world, owner);
|
||||
if (tlh != null && isSafeLocation(tlh)) {
|
||||
setHomeLocation(user, tlh, name);
|
||||
return tlh;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
l = getIslandLocation(world, user.getUniqueId());
|
||||
if (l != null && isSafeLocation(l)) {
|
||||
setHomeLocation(user, l, name);
|
||||
return l.clone().add(new Vector(0.5D, 0, 0.5D));
|
||||
}
|
||||
}
|
||||
if (l == null) {
|
||||
plugin.logWarning(user.getName() + " player has no island in world " + world.getName() + "!");
|
||||
return null;
|
||||
}
|
||||
// If these island locations are not safe, then we need to get creative
|
||||
// Try the default location
|
||||
Location dl = new Location(l.getWorld(), l.getX() + 0.5D, l.getY() + 5D, l.getZ() + 2.5D, 0F, 30F);
|
||||
if (isSafeLocation(dl)) {
|
||||
setHomeLocation(user, dl, name);
|
||||
return dl;
|
||||
}
|
||||
// Try just above the bedrock
|
||||
dl = new Location(l.getWorld(), l.getX() + 0.5D, l.getY() + 5D, l.getZ() + 0.5D, 0F, 30F);
|
||||
if (isSafeLocation(dl)) {
|
||||
setHomeLocation(user, dl, name);
|
||||
return dl;
|
||||
}
|
||||
// Try all the way up to the sky
|
||||
for (int y = l.getBlockY(); y < 255; y++) {
|
||||
final Location n = new Location(l.getWorld(), l.getX() + 0.5D, y, l.getZ() + 0.5D);
|
||||
if (isSafeLocation(n)) {
|
||||
setHomeLocation(user, n, name);
|
||||
return n;
|
||||
}
|
||||
}
|
||||
// Unsuccessful
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a default home location on user's island. Replaces previous default
|
||||
* location.
|
||||
|
@ -1008,22 +904,6 @@ public class IslandsManager {
|
|||
return spawn.containsKey(world) ? spawn.get(world).getSpawnPoint(world.getEnvironment()) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides UUID of this player's island owner or null if it does not exist
|
||||
*
|
||||
* @param world world to check
|
||||
* @param playerUUID the player's UUID
|
||||
* @return island owner's UUID or null if player has no island
|
||||
* @deprecated This will be removed in 2.0 because it is ambiguous when a user
|
||||
* has more than one island in the world.
|
||||
*/
|
||||
|
||||
@Deprecated(since = "2.0", forRemoval = true)
|
||||
@Nullable
|
||||
public UUID getOwner(@NonNull World world, @NonNull UUID playerUUID) {
|
||||
return islandCache.getOwner(world, playerUUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player has an island in the world and owns it. Note that players
|
||||
* may have more than one island
|
||||
|
@ -1890,7 +1770,9 @@ public class IslandsManager {
|
|||
* @param user - admin calling
|
||||
* @param world - game world to check
|
||||
* @return CompletableFuture boolean - true when done
|
||||
* @deprecated Not compatible with multi-islands. Will be removed.
|
||||
*/
|
||||
@Deprecated
|
||||
public CompletableFuture<Boolean> checkTeams(User user, World world) {
|
||||
CompletableFuture<Boolean> r = new CompletableFuture<>();
|
||||
user.sendMessage("commands.admin.team.fix.scanning");
|
||||
|
|
|
@ -4,6 +4,8 @@ import java.util.Arrays;
|
|||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
@ -167,6 +169,27 @@ public class PlaceholdersManager {
|
|||
return "";
|
||||
});
|
||||
}
|
||||
// Counts
|
||||
// Number of online members
|
||||
// {@since 2.1.0}
|
||||
registerPlaceholder(addon, "island_online_members_count", user -> {
|
||||
if (user == null)
|
||||
return "";
|
||||
Island island = plugin.getIslands().getIsland(addon.getOverWorld(), user);
|
||||
return island != null
|
||||
? String.valueOf(island.getMemberSet(RanksManager.MEMBER_RANK).stream()
|
||||
.map(Bukkit::getOfflinePlayer).filter(OfflinePlayer::isOnline).count())
|
||||
: "";
|
||||
});
|
||||
// Number of online members of visited island
|
||||
registerPlaceholder(addon, "visited_island_online_members_count", user -> {
|
||||
if (user == null)
|
||||
return "";
|
||||
return plugin.getIslands().getIslandAt(user.getLocation())
|
||||
.map(island -> String.valueOf(island.getMemberSet(RanksManager.MEMBER_RANK).stream()
|
||||
.map(Bukkit::getOfflinePlayer).filter(OfflinePlayer::isOnline).count()))
|
||||
.orElse("");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,18 +69,22 @@ public class RanksManager {
|
|||
public void loadRanksFromDatabase() {
|
||||
// Set up the database handler to store and retrieve Island classes
|
||||
handler = new Database<>(BentoBox.getInstance(), Ranks.class);
|
||||
if (!handler.objectExists(Ranks.ID)) {
|
||||
if (!handler.objectExists("BentoBox-Ranks")) {
|
||||
// Make the initial object
|
||||
DEFAULT_RANKS.forEach((ref, rank) -> ranksPut(ref, rank));
|
||||
handler.saveObject(new Ranks(ranks));
|
||||
save();
|
||||
} else {
|
||||
// Load the ranks from the database
|
||||
Objects.requireNonNull(handler.loadObject(Ranks.ID)).getRankReference()
|
||||
Objects.requireNonNull(handler.loadObject("BentoBox-Ranks")).getRankReference()
|
||||
.forEach((rankRef, rankValue) -> ranksPut(rankRef, rankValue));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void save() {
|
||||
handler.saveObject(new Ranks(ranks));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a rank exists
|
||||
* @param reference YAML reference to rank, e.g., ranks.trusted
|
||||
|
@ -101,7 +105,6 @@ public class RanksManager {
|
|||
return false;
|
||||
}
|
||||
ranksPut(reference, value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -110,6 +113,7 @@ public class RanksManager {
|
|||
// Sort
|
||||
ranks = ranks.entrySet().stream().sorted(Map.Entry.comparingByValue())
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,8 +122,11 @@ public class RanksManager {
|
|||
* @return true if removed
|
||||
*/
|
||||
public boolean removeRank(String reference) {
|
||||
return ranks.remove(reference) != null;
|
||||
|
||||
boolean result = ranks.remove(reference) != null;
|
||||
if (result) {
|
||||
save();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -259,48 +259,6 @@ public class IslandCache {
|
|||
.map(Map.Entry::getValue).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the members of the user's team
|
||||
*
|
||||
* @param world world to check
|
||||
* @param uuid uuid of player to check
|
||||
* @param minimumRank minimum rank requested
|
||||
* @return set of UUID's of island members. If there are no islands, this set
|
||||
* will be empty
|
||||
* @deprecated This will be removed in 2.0 because it is ambiguous when a user
|
||||
* has more than one island in the world.
|
||||
*/
|
||||
|
||||
@Deprecated(since = "2.0", forRemoval = true)
|
||||
@NonNull
|
||||
public Set<UUID> getMembers(@NonNull World world, @NonNull UUID uuid, int minimumRank) {
|
||||
return getIslands(world, uuid).stream().flatMap(island -> island.getMemberSet(minimumRank).stream())
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UUID of the owner of the island of the player, which may be their
|
||||
* UUID
|
||||
*
|
||||
* @param world the world to check
|
||||
* @param uuid the player's UUID
|
||||
* @return island owner's UUID or null if there is no island owned by the player
|
||||
* in this world
|
||||
* @deprecated This will be removed in 2.0 because it is ambiguous when a user
|
||||
* has more than one island in the world.
|
||||
*/
|
||||
|
||||
@Deprecated(since = "2.0", forRemoval = true)
|
||||
@Nullable
|
||||
public UUID getOwner(@NonNull World world, @NonNull UUID uuid) {
|
||||
World w = Util.getWorld(world);
|
||||
Set<Island> islands = islandsByUUID.get(uuid);
|
||||
if (w == null || islands == null || islands.isEmpty()) {
|
||||
return null;
|
||||
} // Find the island for this world return
|
||||
return islands.stream().filter(i -> w.equals(i.getWorld())).findFirst().map(Island::getOwner).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks is a player has an island and owns it in this world. Note that players
|
||||
* may have multiple islands so this means the player is an owner of ANY island.
|
||||
|
|
|
@ -206,8 +206,11 @@ public class NewIsland {
|
|||
if (noPaste) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> postCreationTask(oldIsland));
|
||||
} else {
|
||||
// Find out how far away the player is from the new island
|
||||
boolean useNMS = !user.getWorld().equals(island.getWorld())
|
||||
|| (user.getLocation().distance(island.getCenter()) >= Bukkit.getViewDistance() * 16D);
|
||||
// Create islands, then run task
|
||||
plugin.getBlueprintsManager().paste(addon, island, name, () -> postCreationTask(oldIsland));
|
||||
plugin.getBlueprintsManager().paste(addon, island, name, () -> postCreationTask(oldIsland), useNMS);
|
||||
}
|
||||
// Set default settings
|
||||
island.setFlagsDefaults();
|
||||
|
|
|
@ -3,18 +3,25 @@ package world.bentobox.bentobox.nms;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.util.DefaultPasteUtil;
|
||||
|
||||
/**
|
||||
* A helper class for {@link world.bentobox.bentobox.blueprints.BlueprintPaster}
|
||||
*/
|
||||
public interface PasteHandler {
|
||||
|
||||
static final BlockData AIR_BLOCKDATA = Bukkit.createBlockData(Material.AIR);
|
||||
/**
|
||||
* Create a future to paste the blocks
|
||||
*
|
||||
|
@ -23,7 +30,13 @@ public interface PasteHandler {
|
|||
* @param blockMap the block map
|
||||
* @return the future
|
||||
*/
|
||||
CompletableFuture<Void> pasteBlocks(Island island, World world, Map<Location, BlueprintBlock> blockMap);
|
||||
default CompletableFuture<Void> pasteBlocks(Island island, World world, Map<Location, BlueprintBlock> blockMap) {
|
||||
return blockMap.entrySet().stream().map(entry -> setBlock(island, entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.collectingAndThen(Collectors.toList(),
|
||||
list -> CompletableFuture.allOf(list.toArray(new CompletableFuture[0]))));
|
||||
}
|
||||
|
||||
CompletableFuture<Void> setBlock(Island island, Location location, BlueprintBlock bpBlock);
|
||||
|
||||
/**
|
||||
* Create a future to paste the entities
|
||||
|
@ -33,5 +46,11 @@ public interface PasteHandler {
|
|||
* @param entityMap the entities map
|
||||
* @return the future
|
||||
*/
|
||||
CompletableFuture<Void> pasteEntities(Island island, World world, Map<Location, List<BlueprintEntity>> entityMap);
|
||||
default CompletableFuture<Void> pasteEntities(Island island, World world,
|
||||
Map<Location, List<BlueprintEntity>> entityMap) {
|
||||
return entityMap.entrySet().stream()
|
||||
.map(entry -> DefaultPasteUtil.setEntity(island, entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.collectingAndThen(Collectors.toList(),
|
||||
list -> CompletableFuture.allOf(list.toArray(new CompletableFuture[0]))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class PasteHandlerImpl implements PasteHandler {
|
|||
@Override
|
||||
public CompletableFuture<Void> pasteBlocks(Island island, World world, Map<Location, BlueprintBlock> blockMap) {
|
||||
return blockMap.entrySet().stream()
|
||||
.map(entry -> DefaultPasteUtil.setBlock(island, entry.getKey(), entry.getValue()))
|
||||
.map(entry -> setBlock(island, entry.getKey(), entry.getValue()))
|
||||
.collect(
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.toList(),
|
||||
|
@ -38,4 +38,9 @@ public class PasteHandlerImpl implements PasteHandler {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> setBlock(Island island, Location location, BlueprintBlock bpBlock) {
|
||||
return DefaultPasteUtil.setBlock(island, location, bpBlock);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
package world.bentobox.bentobox.nms.v1_20_R1;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.block.data.CraftBlockData;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.nms.PasteHandler;
|
||||
import world.bentobox.bentobox.util.DefaultPasteUtil;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
public class PasteHandlerImpl implements PasteHandler {
|
||||
|
||||
|
||||
protected static final IBlockData AIR = ((CraftBlockData) AIR_BLOCKDATA).getState();
|
||||
|
||||
/**
|
||||
* Set the block to the location
|
||||
*
|
||||
* @param island - island
|
||||
* @param location - location
|
||||
* @param bpBlock - blueprint block
|
||||
*/
|
||||
public CompletableFuture<Void> setBlock(Island island, Location location, BlueprintBlock bpBlock) {
|
||||
return Util.getChunkAtAsync(location).thenRun(() -> {
|
||||
Block block = location.getBlock();
|
||||
// Set the block data - default is AIR
|
||||
BlockData bd = DefaultPasteUtil.createBlockData(bpBlock);
|
||||
CraftBlockData craft = (CraftBlockData) bd;
|
||||
net.minecraft.world.level.World nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
|
||||
Chunk nmsChunk = nmsWorld.d(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
BlockPosition bp = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
// Setting the block to air before setting to another state prevents some console errors
|
||||
nmsChunk.a(bp, AIR, false);
|
||||
nmsChunk.a(bp, craft.getState(), false);
|
||||
block.setBlockData(bd, false);
|
||||
DefaultPasteUtil.setBlockState(island, block, bpBlock);
|
||||
// Set biome
|
||||
if (bpBlock.getBiome() != null) {
|
||||
block.setBiome(bpBlock.getBiome());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package world.bentobox.bentobox.nms.v1_20_R1;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.block.data.CraftBlockData;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import world.bentobox.bentobox.nms.CopyWorldRegenerator;
|
||||
|
||||
public class WorldRegeneratorImpl extends CopyWorldRegenerator {
|
||||
|
||||
@Override
|
||||
public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData,
|
||||
boolean applyPhysics) {
|
||||
CraftBlockData craft = (CraftBlockData) blockData;
|
||||
World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle();
|
||||
Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ());
|
||||
BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z);
|
||||
// Setting the block to air before setting to another state prevents some console errors
|
||||
nmsChunk.a(bp, PasteHandlerImpl.AIR, applyPhysics);
|
||||
nmsChunk.a(bp, craft.getState(), applyPhysics);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package world.bentobox.bentobox.nms.v1_20_R2;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_20_R2.block.data.CraftBlockData;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.nms.PasteHandler;
|
||||
import world.bentobox.bentobox.util.DefaultPasteUtil;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
public class PasteHandlerImpl implements PasteHandler {
|
||||
|
||||
protected static final IBlockData AIR = ((CraftBlockData) AIR_BLOCKDATA).getState();
|
||||
|
||||
/**
|
||||
* Set the block to the location
|
||||
*
|
||||
* @param island - island
|
||||
* @param location - location
|
||||
* @param bpBlock - blueprint block
|
||||
*/
|
||||
public CompletableFuture<Void> setBlock(Island island, Location location, BlueprintBlock bpBlock) {
|
||||
return Util.getChunkAtAsync(location).thenRun(() -> {
|
||||
Block block = location.getBlock();
|
||||
// Set the block data - default is AIR
|
||||
BlockData bd = DefaultPasteUtil.createBlockData(bpBlock);
|
||||
CraftBlockData craft = (CraftBlockData) bd;
|
||||
net.minecraft.world.level.World nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
|
||||
Chunk nmsChunk = nmsWorld.d(location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
BlockPosition bp = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
// Setting the block to air before setting to another state prevents some console errors
|
||||
nmsChunk.a(bp, AIR, false);
|
||||
nmsChunk.a(bp, craft.getState(), false);
|
||||
block.setBlockData(bd, false);
|
||||
DefaultPasteUtil.setBlockState(island, block, bpBlock);
|
||||
// Set biome
|
||||
if (bpBlock.getBiome() != null) {
|
||||
block.setBiome(bpBlock.getBiome());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package world.bentobox.bentobox.nms.v1_20_R2;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_20_R2.block.data.CraftBlockData;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import world.bentobox.bentobox.nms.CopyWorldRegenerator;
|
||||
|
||||
public class WorldRegeneratorImpl extends CopyWorldRegenerator {
|
||||
|
||||
@Override
|
||||
public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData,
|
||||
boolean applyPhysics) {
|
||||
CraftBlockData craft = (CraftBlockData) blockData;
|
||||
World nmsWorld = ((CraftWorld) chunk.getWorld()).getHandle();
|
||||
Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ());
|
||||
BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z);
|
||||
// Setting the block to air before setting to another state prevents some console errors
|
||||
nmsChunk.a(bp, PasteHandlerImpl.AIR, applyPhysics);
|
||||
nmsChunk.a(bp, craft.getState(), applyPhysics);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,8 @@
|
|||
package world.bentobox.bentobox.nms.v1_20_R3;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
|
||||
|
@ -18,7 +12,6 @@ import net.minecraft.core.BlockPosition;
|
|||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBlock;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintEntity;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.nms.PasteHandler;
|
||||
import world.bentobox.bentobox.util.DefaultPasteUtil;
|
||||
|
@ -26,23 +19,7 @@ import world.bentobox.bentobox.util.Util;
|
|||
|
||||
public class PasteHandlerImpl implements PasteHandler {
|
||||
|
||||
protected static final IBlockData AIR = ((CraftBlockData) Bukkit.createBlockData(Material.AIR)).getState();
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> pasteBlocks(Island island, World world, Map<Location, BlueprintBlock> blockMap) {
|
||||
return blockMap.entrySet().stream().map(entry -> setBlock(island, entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.collectingAndThen(Collectors.toList(),
|
||||
list -> CompletableFuture.allOf(list.toArray(new CompletableFuture[0]))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> pasteEntities(Island island, World world,
|
||||
Map<Location, List<BlueprintEntity>> entityMap) {
|
||||
return entityMap.entrySet().stream()
|
||||
.map(entry -> DefaultPasteUtil.setEntity(island, entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.collectingAndThen(Collectors.toList(),
|
||||
list -> CompletableFuture.allOf(list.toArray(new CompletableFuture[0]))));
|
||||
}
|
||||
protected static final IBlockData AIR = ((CraftBlockData) AIR_BLOCKDATA).getState();
|
||||
|
||||
/**
|
||||
* Set the block to the location
|
||||
|
@ -51,7 +28,8 @@ public class PasteHandlerImpl implements PasteHandler {
|
|||
* @param location - location
|
||||
* @param bpBlock - blueprint block
|
||||
*/
|
||||
public static CompletableFuture<Void> setBlock(Island island, Location location, BlueprintBlock bpBlock) {
|
||||
@Override
|
||||
public CompletableFuture<Void> setBlock(Island island, Location location, BlueprintBlock bpBlock) {
|
||||
return Util.getChunkAtAsync(location).thenRun(() -> {
|
||||
Block block = location.getBlock();
|
||||
// Set the block data - default is AIR
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
package world.bentobox.bentobox.nms.v1_20_R3;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_20_R3.block.data.CraftBlockData;
|
||||
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import world.bentobox.bentobox.nms.CopyWorldRegenerator;
|
||||
|
||||
public class WorldRegeneratorImpl extends CopyWorldRegenerator {
|
||||
|
||||
private static final IBlockData AIR = ((CraftBlockData) Bukkit.createBlockData(Material.AIR)).getState();
|
||||
|
||||
@Override
|
||||
public void setBlockInNativeChunk(org.bukkit.Chunk chunk, int x, int y, int z, BlockData blockData,
|
||||
boolean applyPhysics) {
|
||||
|
@ -24,7 +19,7 @@ public class WorldRegeneratorImpl extends CopyWorldRegenerator {
|
|||
Chunk nmsChunk = nmsWorld.d(chunk.getX(), chunk.getZ());
|
||||
BlockPosition bp = new BlockPosition((chunk.getX() << 4) + x, y, (chunk.getZ() << 4) + z);
|
||||
// Setting the block to air before setting to another state prevents some console errors
|
||||
nmsChunk.a(bp, AIR, applyPhysics);
|
||||
nmsChunk.a(bp, PasteHandlerImpl.AIR, applyPhysics);
|
||||
nmsChunk.a(bp, craft.getState(), applyPhysics);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,9 +99,6 @@ public class Util {
|
|||
int dist = plugin.getIWM().getIslandDistance(location.getWorld()) * 2;
|
||||
long x = Math.round((double) location.getBlockX() / dist) * dist + plugin.getIWM().getIslandXOffset(location.getWorld());
|
||||
long z = Math.round((double) location.getBlockZ() / dist) * dist + plugin.getIWM().getIslandZOffset(location.getWorld());
|
||||
if (location.getBlockX() == x && location.getBlockZ() == z) {
|
||||
return location;
|
||||
}
|
||||
int y = plugin.getIWM().getIslandHeight(location.getWorld());
|
||||
return new Location(location.getWorld(), x, y, z);
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ commands:
|
|||
island-is-spawn: "&6 Ostrov je spawn. Jsi si jistý? Potvrď opětovným zadáním
|
||||
příkazu."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: <owner> [x,y,z]
|
||||
description: odregistrovat vlastníka z ostrova, ale zachovat bloky ostrova
|
||||
unregistered-island: "&a Hráč odregistrován z ostrova [xyz]."
|
||||
info:
|
||||
|
|
|
@ -188,7 +188,7 @@ commands:
|
|||
island-is-spawn: "&6 Die Insel ist der Spawn. Bist du sicher? Gib den Befehl
|
||||
zur Bestätigung noch einmal ein."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: Besitzer von Insel entfernen, aber Inselblöcke behalten
|
||||
unregistered-island: "&a Unregistrierter Spieler von der Insel bei [xyz]."
|
||||
info:
|
||||
|
|
|
@ -192,9 +192,13 @@ commands:
|
|||
for possible errors.'
|
||||
island-is-spawn: '&6 Island is spawn. Are you sure? Enter command again to confirm.'
|
||||
unregister:
|
||||
parameters: <owner>
|
||||
description: unregister owner from island, but keep island blocks
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: "unregister owner from island, but keep island blocks"
|
||||
unregistered-island: '&a Unregistered [name] from island at [xyz].'
|
||||
errors:
|
||||
unknown-island-location: "&c Unknown island location"
|
||||
specify-island-location: "&c Specify island location in x,y,z format"
|
||||
player-has-more-than-one-island: "&c Player has more than one island. Specify which one."
|
||||
info:
|
||||
parameters: <player>
|
||||
description: get info on where you are or player's island
|
||||
|
@ -710,7 +714,7 @@ commands:
|
|||
name-has-invited-you: '&a [name] has invited you to join their island.'
|
||||
to-accept-or-reject: '&a Do /[label] team accept to accept, or /[label] team
|
||||
reject to reject'
|
||||
you-will-lose-your-island: '&c WARNING! You will lose your island if you accept!'
|
||||
you-will-lose-your-island: '&c WARNING! You will lose all your islands if you accept!'
|
||||
gui:
|
||||
titles:
|
||||
team-invite-panel: "Invite Players"
|
||||
|
@ -753,7 +757,7 @@ commands:
|
|||
name-joined-your-island: '&a [name] joined your island!'
|
||||
confirmation: |-
|
||||
&c Are you sure you want to accept this invite?
|
||||
&c&l You will &n LOSE &r&c&l your current island!
|
||||
&c&l You will &n LOSE ALL &r&c&l your islands!
|
||||
reject:
|
||||
description: reject an invitation
|
||||
you-rejected-invite: '&a You rejected the invitation to join an island.'
|
||||
|
|
|
@ -190,7 +190,7 @@ commands:
|
|||
island-is-spawn: "&6La isla está spawneada. ¿Estás seguro? Ingrese el comando
|
||||
nuevamente para confirmar."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: Desregistrar propietario de isla, pero mantener bloques de islas
|
||||
unregistered-island: "&aRemover jugador de la isla registrada en [xyz]."
|
||||
info:
|
||||
|
|
|
@ -185,7 +185,7 @@ commands:
|
|||
island-is-spawn: "&6 L'île est un spawn. Êtes-vous sûr? Entrez à nouveau la
|
||||
commande pour confirmer."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: désenregistrer le propriétaire de l''île, mais garder les blocs
|
||||
de l''île
|
||||
unregistered-island: "&b [name] &a a été supprimé de l'île à [xyz]."
|
||||
|
|
|
@ -182,7 +182,7 @@ commands:
|
|||
island-is-spawn: "&6 Otok je mrijest. Jesi li siguran? Ponovno unesite naredbu
|
||||
za potvrdu."
|
||||
unregister:
|
||||
parameters: "<vlasnik>"
|
||||
parameters: "<vlasnik> [x,y,z]"
|
||||
description: odjaviti vlasnika s otoka, ali zadržati otočne blokove
|
||||
unregistered-island: "&a Neregistrirano [name] otoka na [xyz]."
|
||||
info:
|
||||
|
|
|
@ -190,7 +190,7 @@ commands:
|
|||
island-is-spawn: "&6 A sziget spawn. biztos vagy ebben? A megerősítéshez írja
|
||||
be újra a parancsot."
|
||||
unregister:
|
||||
parameters: "<tulajdonos>"
|
||||
parameters: "<tulajdonos> [x,y,z]"
|
||||
description: törölje a tulajdonos regisztrációját a szigetről, de tartsa meg
|
||||
a szigettömböket
|
||||
unregistered-island: "&a Nem regisztrált [name] a következő szigetről: [xyz]."
|
||||
|
|
|
@ -190,7 +190,7 @@ commands:
|
|||
island-is-spawn: "&6 Pulau muncul. Apa kamu yakin? Masukkan perintah lagi untuk
|
||||
mengonfirmasi."
|
||||
unregister:
|
||||
parameters: "<pemilik>"
|
||||
parameters: "<pemilik> [x,y,z]"
|
||||
description: batalkan pendaftaran pemilik dari pulau, tetapi pertahankan blok
|
||||
pulau
|
||||
unregistered-island: "&a [name] tidak terdaftar dari pulau di [xyz]."
|
||||
|
|
|
@ -364,7 +364,7 @@ commands:
|
|||
title: "&d=========== Isole nel Cestino ==========="
|
||||
unregister:
|
||||
description: dissocia un proprietario dall'isola, ma mantenendo i blocchi dell'isola
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
unregistered-island: "&aDisassociato il giocatore dall'isola a [xyz]."
|
||||
version:
|
||||
description: mostra le versioni di BentoBox e degli addons
|
||||
|
|
|
@ -170,7 +170,7 @@ commands:
|
|||
cannot-make-island: "&c島はここに配置できません。申し訳ありません。考えられるエラーについては、コンソールをご覧ください。"
|
||||
island-is-spawn: "&6島が生成されます。本気ですか?もう一度コマンドを入力して確認します。"
|
||||
unregister:
|
||||
parameters: "<所有者>"
|
||||
parameters: "<所有者> [x,y,z]"
|
||||
description: 島から所有者を登録解除するが、島のブロックを維持する
|
||||
unregistered-island: "[xyz]で島から未登録のプレーヤー。"
|
||||
info:
|
||||
|
|
|
@ -164,7 +164,7 @@ commands:
|
|||
cannot-make-island: "&c 섬은 이곳에 만들수 없습니다. 죄송합니다. 콘솔을 참고해주세요."
|
||||
island-is-spawn: "&6 섬이 생성되었습니다. 정말로 하시겠습니까? 명령어를 한번더 입력해주세요."
|
||||
unregister:
|
||||
parameters: "<주인>"
|
||||
parameters: "<주인> [x,y,z]"
|
||||
description: 섬을 주인없는 섬으로 만들지만 섬은 유지됩니다
|
||||
unregistered-island: "&a [xyz]에 있는 [name]의 섬을 주인 없는 섬으로 만들었습니다."
|
||||
info:
|
||||
|
|
|
@ -385,7 +385,7 @@ commands:
|
|||
uz spēlētāja salu no atkritnes."
|
||||
unregister:
|
||||
description: atreģistrē īpašnieku no salas paturot salas blokus
|
||||
parameters: "<īpašnieks>"
|
||||
parameters: "<īpašnieks> [x,y,z]"
|
||||
unregistered-island: "&aSpēlētājs atreģistrēts no salas ar koordinātēm [xyz]."
|
||||
version:
|
||||
description: attaino BentoBox un papildinājumu versijas
|
||||
|
|
|
@ -186,7 +186,7 @@ commands:
|
|||
island-is-spawn: "&6 Eiland wordt uitgezet. Weet je het zeker? Voer de opdracht
|
||||
nogmaals in om te bevestigen."
|
||||
unregister:
|
||||
parameters: "<eigenaar>"
|
||||
parameters: "<eigenaar> [x,y,z]"
|
||||
description: de registratie van de eigenaar van het eiland ongedaan maken, maar
|
||||
eilandblokken behouden
|
||||
unregistered-island: "&a niet-geregistreerde [name] van het eiland op [xyz]."
|
||||
|
|
|
@ -174,7 +174,7 @@ commands:
|
|||
island-is-spawn: '&6 Ta wyspa jest wyspą spawnu. Jesteś pewny? Wpisz ponownie
|
||||
tę komendę.'
|
||||
unregister:
|
||||
parameters: <właściciel>
|
||||
parameters: "<właściciel> [x,y,z]"
|
||||
description: wyrejestruj właściciela z wyspy, ale zachowaj bloki wyspy
|
||||
unregistered-island: '&aWyrejestrowano gracza z wyspy [xyz].'
|
||||
info:
|
||||
|
|
|
@ -192,7 +192,7 @@ commands:
|
|||
island-is-spawn: "&6 Ilha é spawn. Você tem certeza? Digite o comando novamente
|
||||
para confirmar."
|
||||
unregister:
|
||||
parameters: "<proprietário>"
|
||||
parameters: "<proprietário> [x,y,z]"
|
||||
description: Remover o registro de dono da ilha, mas manter os blocos da ilha
|
||||
unregistered-island: "&a Registro removido de [name] de ilha em [xyz]."
|
||||
info:
|
||||
|
|
|
@ -173,7 +173,7 @@ commands:
|
|||
island-is-spawn: '&6 Essa ilha é o spawn. Você tem certeza? Digite o comando
|
||||
novamente para confirmar.'
|
||||
unregister:
|
||||
parameters: <dono>
|
||||
parameters: "<dono> [x,y,z]"
|
||||
description: desregistrar dono da ilha, mas manter os blocos
|
||||
unregistered-island: '&a [name] desregistrado da ilha em [xyz].'
|
||||
info:
|
||||
|
|
|
@ -187,7 +187,7 @@ commands:
|
|||
island-is-spawn: "&6 Insula este reprodusă. Esti sigur? Introduceți din nou
|
||||
comanda pentru a confirma."
|
||||
unregister:
|
||||
parameters: "<proprietar>"
|
||||
parameters: "<proprietar> [x,y,z]"
|
||||
description: anulați înregistrarea proprietarului de pe insulă, dar păstrați
|
||||
blocurile de insule
|
||||
unregistered-island: "&a [name] neînregistrat de pe insulă la [xyz]."
|
||||
|
|
|
@ -185,7 +185,7 @@ commands:
|
|||
island-is-spawn: "&6Остров является спавном. Вы уверены? Введите команду снова
|
||||
для подтверждения."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: разрегистрирует остров, но сохраняет блоки на острове
|
||||
unregistered-island: "&aИгрок [name] разрегистрирован с острова на координатах
|
||||
[xyz]."
|
||||
|
|
|
@ -186,7 +186,7 @@ commands:
|
|||
island-is-spawn: "&6Başlangıç adası, buna emin misiniz ?Kabul etmek için komutu
|
||||
tekrar girin!"
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: Oyuncuyu adadan siler ama ada silinmez.
|
||||
unregistered-island: "&aOyuncu başarıyla &e[xyz] &akoordinatlarındaki adadan
|
||||
silindi!"
|
||||
|
|
|
@ -185,7 +185,7 @@ commands:
|
|||
консоль для можливих помилок."
|
||||
island-is-spawn: "&6 Острів ікру. Ти впевнений? Введіть команду ще раз для підтвердження."
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: скасувати реєстрацію власника з острова, але зберегти блоки острова
|
||||
unregistered-island: "&a Незареєстрований [name] з острова на [xyz]."
|
||||
info:
|
||||
|
|
|
@ -180,7 +180,7 @@ commands:
|
|||
island-is-spawn: "&6 Đảo là điểm triệu hồi. Bạn chắc chứ? Nhập lần nữa để xác
|
||||
nhận."
|
||||
unregister:
|
||||
parameters: "<chủ>"
|
||||
parameters: "<chủ> [x,y,z]"
|
||||
description: hủy đăng kí chủ đảo khỏi đảo này. nhưng giữ lại tài nguyên đảo
|
||||
unregistered-island: "&a Đã hủy đăng kí [name] khỏi đảo tại [xyz]."
|
||||
info:
|
||||
|
|
|
@ -176,7 +176,7 @@ commands:
|
|||
&c所处位置为出生点岛屿, 您确定要将玩家注册到这个岛屿上?
|
||||
&6请再次输入命令以确认。
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: 注销岛主身份, 但保留岛屿资源。
|
||||
unregistered-island: "&a已将岛主 &b[name] &a从位于 &b[xyz] &a的岛屿注销。"
|
||||
info:
|
||||
|
|
|
@ -187,7 +187,7 @@ commands:
|
|||
&c所處位置為出生點島嶼, 您確定要將玩家注冊到這個島嶼上?
|
||||
&6請再次輸入命令以確認。
|
||||
unregister:
|
||||
parameters: "<owner>"
|
||||
parameters: "<owner> [x,y,z]"
|
||||
description: "將島主註銷但保留方塊"
|
||||
unregistered-island: "&a已將位於 [xyz] 的島嶼的玩家註銷。"
|
||||
info:
|
||||
|
|
|
@ -3,19 +3,24 @@ package world.bentobox.bentobox.api.commands.admin;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
@ -26,12 +31,14 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.Settings;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
@ -42,6 +49,7 @@ import world.bentobox.bentobox.managers.IslandWorldManager;
|
|||
import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +57,7 @@ import world.bentobox.bentobox.util.Util;
|
|||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class })
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, Util.class })
|
||||
public class AdminRegisterCommandTest {
|
||||
|
||||
@Mock
|
||||
|
@ -61,10 +69,19 @@ public class AdminRegisterCommandTest {
|
|||
private IslandsManager im;
|
||||
@Mock
|
||||
private PlayersManager pm;
|
||||
@Mock
|
||||
private Island is;
|
||||
@Mock
|
||||
private Location loc;
|
||||
|
||||
private UUID notUUID;
|
||||
|
||||
private IslandDeletionManager idm;
|
||||
private AdminRegisterCommand itl;
|
||||
@Mock
|
||||
private World world;
|
||||
@Mock
|
||||
private Block block;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -75,6 +92,12 @@ public class AdminRegisterCommandTest {
|
|||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
Util.setPlugin(plugin);
|
||||
|
||||
Settings settings = new Settings();
|
||||
// Settings
|
||||
when(plugin.getSettings()).thenReturn(settings);
|
||||
// World
|
||||
when(ac.getWorld()).thenReturn(world);
|
||||
|
||||
// Command manager
|
||||
CommandsManager cm = mock(CommandsManager.class);
|
||||
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||
|
@ -91,8 +114,16 @@ public class AdminRegisterCommandTest {
|
|||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.getPlayer()).thenReturn(p);
|
||||
when(user.getName()).thenReturn("tastybento");
|
||||
when(user.getWorld()).thenReturn(world);
|
||||
when(user.getTranslation(anyString()))
|
||||
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
User.getInstance(p);
|
||||
User.setPlugin(plugin);
|
||||
|
||||
// Util
|
||||
PowerMockito.mockStatic(Util.class, Mockito.RETURNS_MOCKS);
|
||||
when(Util.getUUID("tastybento")).thenReturn(uuid);
|
||||
|
||||
// Parent command has no aliases
|
||||
when(ac.getSubCommandAliases()).thenReturn(new HashMap<>());
|
||||
|
||||
|
@ -131,6 +162,14 @@ public class AdminRegisterCommandTest {
|
|||
PluginManager pim = mock(PluginManager.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
// Island
|
||||
when(is.getWorld()).thenReturn(world);
|
||||
when(is.getCenter()).thenReturn(loc);
|
||||
when(im.createIsland(any(), eq(uuid))).thenReturn(is);
|
||||
when(loc.getBlock()).thenReturn(block);
|
||||
|
||||
// DUT
|
||||
itl = new AdminRegisterCommand(ac);
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -141,81 +180,75 @@ public class AdminRegisterCommandTest {
|
|||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link AdminRegisterCommand#execute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
* {@link AdminRegisterCommand#canExecute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteNoTarget() {
|
||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||
public void testCanExecuteNoTarget() {
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), new ArrayList<>()));
|
||||
// Show help
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link AdminRegisterCommand#execute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
* {@link AdminRegisterCommand#canExecute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUnknownPlayer() {
|
||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||
when(pm.getUUID(any())).thenReturn(null);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("tastybento")));
|
||||
verify(user).sendMessage(eq("general.errors.unknown-player"), eq("[name]"), eq("tastybento"));
|
||||
public void testCanExecuteWrongWorld() {
|
||||
when(user.getWorld()).thenReturn(mock(World.class));
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
|
||||
verify(user).sendMessage("general.errors.wrong-world");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link AdminRegisterCommand#execute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
* {@link AdminRegisterCommand#canExecute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecutePlayerHasIsland() {
|
||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(true);
|
||||
when(im.inTeam(any(), any())).thenReturn(false);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("tastybento")));
|
||||
verify(user).sendMessage(eq("general.errors.player-has-island"));
|
||||
public void testCanExecuteUnknownPlayer() {
|
||||
when(pm.getUUID(any())).thenReturn(null);
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento2")));
|
||||
verify(user).sendMessage("general.errors.unknown-player", TextVariables.NAME, "tastybento2");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminRegisterCommand#execute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
* Test method for
|
||||
* {@link AdminRegisterCommand#canExecute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteInTeam() {
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(false);
|
||||
when(im.inTeam(any(), any())).thenReturn(true);
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("tastybento")));
|
||||
verify(user).sendMessage("commands.admin.register.cannot-register-team-player");
|
||||
public void testCanExecuteNoIsland() {
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
|
||||
verify(user).getTranslation("commands.admin.register.no-island-here");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminRegisterCommand#execute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
* Test method for {@link AdminRegisterCommand#canExecute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteAlreadyOwnedIsland() {
|
||||
public void testCanExecuteAlreadyOwnedIsland() {
|
||||
when(im.inTeam(any(), any())).thenReturn(false);
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(false);
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
Location loc = mock(Location.class);
|
||||
|
||||
when(loc.toVector()).thenReturn(new Vector(1, 2, 3));
|
||||
// Island has owner
|
||||
Island is = mock(Island.class);
|
||||
when(is.getOwner()).thenReturn(uuid);
|
||||
when(is.isOwned()).thenReturn(true);
|
||||
when(is.getCenter()).thenReturn(loc);
|
||||
Optional<Island> opi = Optional.of(is);
|
||||
when(im.getIslandAt(any())).thenReturn(opi);
|
||||
when(user.getLocation()).thenReturn(loc);
|
||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("tastybento")));
|
||||
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
|
||||
verify(user).sendMessage("commands.admin.register.already-owned");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminRegisterCommand#execute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
* Test method for {@link AdminRegisterCommand#canExecute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteInDeletionIsland() {
|
||||
public void testCanExecuteInDeletionIsland() {
|
||||
when(idm.inDeletion(any())).thenReturn(true);
|
||||
when(im.inTeam(any(), any())).thenReturn(false);
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(false);
|
||||
|
@ -223,25 +256,20 @@ public class AdminRegisterCommandTest {
|
|||
Location loc = mock(Location.class);
|
||||
|
||||
// Island has owner
|
||||
Island is = mock(Island.class);
|
||||
when(is.getOwner()).thenReturn(uuid);
|
||||
Optional<Island> opi = Optional.of(is);
|
||||
when(im.getIslandAt(any())).thenReturn(opi);
|
||||
when(user.getLocation()).thenReturn(loc);
|
||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("tastybento")));
|
||||
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
|
||||
verify(user).sendMessage("commands.admin.register.in-deletion");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminRegisterCommand#execute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
* Test method for {@link AdminRegisterCommand#canExecute(org.bukkit.command.CommandSender, String, String[])}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteSuccess() {
|
||||
when(im.inTeam(any(), any())).thenReturn(false);
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(false);
|
||||
Island is = mock(Island.class);
|
||||
Location loc = mock(Location.class);
|
||||
public void testCanExecuteSuccess() {
|
||||
when(loc.toVector()).thenReturn(new Vector(123,123,432));
|
||||
when(is.getCenter()).thenReturn(loc);
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(is);
|
||||
|
@ -250,11 +278,48 @@ public class AdminRegisterCommandTest {
|
|||
when(user.getLocation()).thenReturn(loc);
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
|
||||
AdminRegisterCommand itl = new AdminRegisterCommand(ac);
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList("tastybento")));
|
||||
// Add other verifications
|
||||
verify(user).sendMessage(eq("commands.admin.register.registered-island"), eq(TextVariables.XYZ), eq("123,123,432"), eq("[name]"), eq("tastybento"));
|
||||
verify(user).sendMessage(eq("general.success"));
|
||||
assertTrue(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminRegisterCommand#register(User, String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testRegister() {
|
||||
testCanExecuteSuccess();
|
||||
when(is.isSpawn()).thenReturn(true);
|
||||
itl.register(user, "tastybento");
|
||||
verify(im).setOwner(user, uuid, is, RanksManager.VISITOR_RANK);
|
||||
verify(im).clearSpawn(world);
|
||||
verify(user).sendMessage("commands.admin.register.registered-island", TextVariables.XYZ, "", TextVariables.NAME,
|
||||
"tastybento");
|
||||
verify(user).sendMessage("general.success");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminRegisterCommand#reserve(User, String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testReserveCannotMakeIsland() {
|
||||
when(im.createIsland(any(), eq(uuid))).thenReturn(null);
|
||||
testCanExecuteNoIsland();
|
||||
itl.reserve(user, "tastybento");
|
||||
verify(im).createIsland(any(), eq(uuid));
|
||||
verify(user).sendMessage("commands.admin.register.cannot-make-island");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminRegisterCommand#reserve(User, String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testReserveCanMakeIsland() {
|
||||
testCanExecuteNoIsland();
|
||||
itl.reserve(user, "tastybento");
|
||||
verify(im).createIsland(any(), eq(uuid));
|
||||
verify(user, never()).sendMessage("commands.admin.register.cannot-make-island");
|
||||
verify(block).setType(Material.BEDROCK);
|
||||
verify(user).sendMessage("commands.admin.register.reserved-island", TextVariables.XYZ, "", TextVariables.NAME,
|
||||
"tastybento");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import static org.mockito.ArgumentMatchers.any;
|
|||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.framework;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -23,13 +23,12 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
@ -48,7 +47,6 @@ import world.bentobox.bentobox.managers.IslandWorldManager;
|
|||
import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
/**
|
||||
|
@ -56,9 +54,10 @@ import world.bentobox.bentobox.util.Util;
|
|||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class })
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class })
|
||||
public class AdminUnregisterCommandTest {
|
||||
|
||||
private UUID uuid = UUID.randomUUID();
|
||||
@Mock
|
||||
private CompositeCommand ac;
|
||||
@Mock
|
||||
|
@ -70,6 +69,15 @@ public class AdminUnregisterCommandTest {
|
|||
private UUID notUUID;
|
||||
@Mock
|
||||
private World world;
|
||||
@Mock
|
||||
private Island island;
|
||||
@Mock
|
||||
private Island island2;
|
||||
@Mock
|
||||
private @NonNull Location location1;
|
||||
@Mock
|
||||
private @NonNull Location location2;
|
||||
private AdminUnregisterCommand itl;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -92,15 +100,18 @@ public class AdminUnregisterCommandTest {
|
|||
// Player
|
||||
Player p = mock(Player.class);
|
||||
when(user.isOp()).thenReturn(false);
|
||||
UUID uuid = UUID.randomUUID();
|
||||
|
||||
notUUID = UUID.randomUUID();
|
||||
while (notUUID.equals(uuid)) {
|
||||
notUUID = UUID.randomUUID();
|
||||
}
|
||||
User.setPlugin(plugin);
|
||||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.getPlayer()).thenReturn(p);
|
||||
when(user.getName()).thenReturn("tastybento");
|
||||
User.setPlugin(plugin);
|
||||
when(pm.getUUID("tastybento")).thenReturn(uuid);
|
||||
User.getInstance(p);
|
||||
|
||||
|
||||
// Parent command has no aliases
|
||||
when(ac.getSubCommandAliases()).thenReturn(new HashMap<>());
|
||||
|
@ -136,6 +147,21 @@ public class AdminUnregisterCommandTest {
|
|||
PluginManager pim = mock(PluginManager.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
// Islands
|
||||
when(location1.toVector()).thenReturn(new Vector(1, 2, 3));
|
||||
when(location2.toVector()).thenReturn(new Vector(4, 5, 6));
|
||||
when(island.getCenter()).thenReturn(location1);
|
||||
when(island2.getCenter()).thenReturn(location2);
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, notUUID));
|
||||
when(island2.getMemberSet()).thenReturn(ImmutableSet.of(uuid, notUUID));
|
||||
when(im.getOwnedIslands(world, uuid)).thenReturn(Set.of(island, island2));
|
||||
|
||||
// Player Manager
|
||||
when(pm.getName(uuid)).thenReturn("name");
|
||||
when(pm.getName(notUUID)).thenReturn("name2");
|
||||
|
||||
itl = new AdminUnregisterCommand(ac);
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -149,8 +175,7 @@ public class AdminUnregisterCommandTest {
|
|||
* {@link AdminUnregisterCommand#canExecute(User, String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteNoTarget() {
|
||||
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
||||
public void testCanExecuteNoTarget() {
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), Collections.emptyList()));
|
||||
// Show help
|
||||
}
|
||||
|
@ -160,8 +185,7 @@ public class AdminUnregisterCommandTest {
|
|||
* {@link AdminUnregisterCommand#canExecute(User, String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUnknownPlayer() {
|
||||
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
||||
public void testCanExecuteUnknownPlayer() {
|
||||
String[] name = { "tastybento" };
|
||||
when(pm.getUUID(any())).thenReturn(null);
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
|
@ -173,69 +197,96 @@ public class AdminUnregisterCommandTest {
|
|||
* {@link AdminUnregisterCommand#canExecute(User, String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecutePlayerNoIsland() {
|
||||
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
||||
String[] name = { "tastybento" };
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(false);
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
verify(user).sendMessage(Mockito.eq("general.errors.player-has-no-island"));
|
||||
public void testCanExecutePlayerFailNoIsland() {
|
||||
// No island
|
||||
when(im.getOwnedIslands(world, uuid)).thenReturn(Set.of());
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
|
||||
verify(user).sendMessage("general.errors.player-has-no-island");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminUnregisterCommand#execute(User, String, java.util.List)}.
|
||||
* Test method for
|
||||
* {@link AdminUnregisterCommand#canExecute(User, String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteSuccess() {
|
||||
when(im.inTeam(any(), any())).thenReturn(false);
|
||||
Island is = mock(Island.class);
|
||||
Location loc = mock(Location.class);
|
||||
when(loc.toVector()).thenReturn(new Vector(123,123,432));
|
||||
when(is.getCenter()).thenReturn(loc);
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(is);
|
||||
String[] name = {"tastybento"};
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
public void testCanExecutePlayerFailMoreIsland() {
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
|
||||
verify(user).sendMessage("commands.admin.unregister.errors.player-has-more-than-one-island");
|
||||
verify(user).sendMessage("commands.admin.unregister.errors.specify-island-location");
|
||||
}
|
||||
|
||||
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
/**
|
||||
* Test method for
|
||||
* {@link AdminUnregisterCommand#canExecute(User, String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecutePlayerFailWrongIsland() {
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento", "1,2,4")));
|
||||
verify(user).sendMessage("commands.admin.unregister.errors.unknown-island-location");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link AdminUnregisterCommand#canExecute(User, String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteDiffernetPlayerFailWrongIsland() {
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("BoxManager", "1,2,4")));
|
||||
verify(user).sendMessage("general.errors.unknown-player", TextVariables.NAME, "BoxManager");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link AdminUnregisterCommand#canExecute(User, String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecutePlayerSuccessMultiIsland() {
|
||||
assertTrue(itl.canExecute(user, itl.getLabel(), List.of("tastybento", "1,2,3")));
|
||||
assertTrue(itl.canExecute(user, itl.getLabel(), List.of("tastybento", "4,5,6")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminUnregisterCommand#canExecute(User, String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteSuccessOneIsland() {
|
||||
when(im.getOwnedIslands(world, uuid)).thenReturn(Set.of(island));
|
||||
itl.canExecute(user, itl.getLabel(), List.of("tastybento"));
|
||||
assertTrue(itl.execute(user, itl.getLabel(), List.of("tastybento")));
|
||||
// Add other verifications
|
||||
verify(user).sendMessage("commands.confirmation.confirm", "[seconds]", "0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminUnregisterCommand#unregisterPlayer(User, UUID)}.
|
||||
* Test method for {@link AdminUnregisterCommand#unregisterIsland(User)}
|
||||
*/
|
||||
@Test
|
||||
public void testUnregisterPlayer() {
|
||||
@Nullable
|
||||
Island oldIsland = mock(Island.class);
|
||||
@Nullable
|
||||
Location center = mock(Location.class);
|
||||
when(oldIsland.getCenter()).thenReturn(center);
|
||||
when(center.toVector()).thenReturn(new Vector(1, 2, 3));
|
||||
// Members
|
||||
UUID uuid1 = UUID.randomUUID();
|
||||
UUID uuid2 = UUID.randomUUID();
|
||||
UUID uuid3 = UUID.randomUUID();
|
||||
ImmutableSet<UUID> imSet = ImmutableSet.of(uuid1, uuid2, uuid3);
|
||||
when(oldIsland.getMemberSet()).thenReturn(imSet);
|
||||
// Trusted member
|
||||
UUID uuid4 = UUID.randomUUID();
|
||||
// Map must be mutable because it is cleared
|
||||
Map<UUID, Integer> map = new HashMap<>();
|
||||
map.put(uuid4, RanksManager.TRUSTED_RANK);
|
||||
when(oldIsland.getMembers()).thenReturn(map);
|
||||
// Island
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(oldIsland);
|
||||
AdminUnregisterCommand itl = new AdminUnregisterCommand(ac);
|
||||
UUID targetUUID = UUID.randomUUID();
|
||||
itl.unregisterPlayer(user, "name", targetUUID);
|
||||
public void testUnregisterIsland() {
|
||||
this.testCanExecuteSuccessOneIsland();
|
||||
itl.unregisterIsland(user);
|
||||
verify(user).sendMessage("commands.admin.unregister.unregistered-island", TextVariables.XYZ, "1,2,3",
|
||||
TextVariables.NAME, "name");
|
||||
assertTrue(map.isEmpty());
|
||||
verify(im).removePlayer(any(World.class), eq(uuid1));
|
||||
verify(im).removePlayer(any(World.class), eq(uuid2));
|
||||
verify(im).removePlayer(any(World.class), eq(uuid3));
|
||||
verify(im, never()).removePlayer(any(World.class), eq(uuid4));
|
||||
verify(island).setOwner(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminUnregisterCommand#unregisterIsland(User)}
|
||||
*/
|
||||
@Test
|
||||
public void testUnregisterIslandMulti() {
|
||||
this.testCanExecutePlayerSuccessMultiIsland();
|
||||
itl.unregisterIsland(user);
|
||||
verify(user).sendMessage("commands.admin.unregister.unregistered-island", TextVariables.XYZ, "4,5,6",
|
||||
TextVariables.NAME, "name");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link AdminUnregisterCommand#canExecute(User, String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteHelp() {
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento", "help")));
|
||||
verify(user).sendMessage("commands.help.header", TextVariables.LABEL, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package world.bentobox.bentobox.api.commands.admin.team;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.framework;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -16,19 +17,23 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
@ -55,7 +60,7 @@ import world.bentobox.bentobox.util.Util;
|
|||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class })
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, Util.class })
|
||||
public class AdminTeamDisbandCommandTest {
|
||||
|
||||
@Mock
|
||||
|
@ -76,6 +81,9 @@ public class AdminTeamDisbandCommandTest {
|
|||
private UUID notUUID;
|
||||
@Mock
|
||||
private @Nullable Island island;
|
||||
@Mock
|
||||
private @NonNull Location location;
|
||||
private AdminTeamDisbandCommand itl;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -121,8 +129,10 @@ public class AdminTeamDisbandCommandTest {
|
|||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(true);
|
||||
when(im.hasIsland(any(), any(User.class))).thenReturn(true);
|
||||
when(island.getOwner()).thenReturn(uuid);
|
||||
when(im.getIsland(any(World.class), any(UUID.class))).thenReturn(island);
|
||||
when(im.getPrimaryIsland(any(), any())).thenReturn(island);
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, notUUID));
|
||||
when(island.getCenter()).thenReturn(location);
|
||||
when(location.toVector()).thenReturn(new Vector(1, 2, 3));
|
||||
when(im.getOwnedIslands(any(), eq(uuid))).thenReturn(Set.of(island));
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
|
||||
// Has team
|
||||
|
@ -152,6 +162,15 @@ public class AdminTeamDisbandCommandTest {
|
|||
|
||||
// Plugin Manager
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
|
||||
// Online players
|
||||
PowerMockito.mockStatic(Util.class, Mockito.RETURNS_MOCKS);
|
||||
when(Util.getOnlinePlayerList(user)).thenReturn(List.of("tastybento", "BONNe"));
|
||||
when(Util.translateColorCodes(anyString()))
|
||||
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
|
||||
// DUT
|
||||
itl = new AdminTeamDisbandCommand(ac);
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -161,56 +180,59 @@ public class AdminTeamDisbandCommandTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||
* Test method for {@link AdminTeamDisbandCommand#canExecute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteNoTarget() {
|
||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), new ArrayList<>()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||
* Test method for {@link AdminTeamDisbandCommand#canExecute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUnknownPlayer() {
|
||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||
String[] name = { "tastybento" };
|
||||
when(pm.getUUID(any())).thenReturn(null);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
verify(user).sendMessage("general.errors.unknown-player", "[name]", name[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||
* Test method for {@link AdminTeamDisbandCommand#canExecute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecutePlayerNotInTeam() {
|
||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||
String[] name = { "tastybento" };
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
// when(im.getMembers(any(), any())).thenReturn(new HashSet<>());
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
verify(user).sendMessage(eq("general.errors.not-in-team"));
|
||||
when(Util.getUUID("tastybento")).thenReturn(notUUID);
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
|
||||
verify(user).sendMessage("general.errors.player-is-not-owner", "[name]", "tastybento");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||
* Test method for {@link AdminTeamDisbandCommand#canExecute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteDisbandNotOwner() {
|
||||
public void testExecuteDisbandNoIsland() {
|
||||
when(im.inTeam(any(), any())).thenReturn(true);
|
||||
Island is = mock(Island.class);
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(is);
|
||||
String[] name = {"tastybento"};
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
when(Util.getUUID("tastybento")).thenReturn(uuid);
|
||||
when(im.getOwnedIslands(any(), eq(uuid))).thenReturn(Set.of());
|
||||
assertFalse(itl.canExecute(user, itl.getLabel(), Arrays.asList("tastybento")));
|
||||
verify(user).sendMessage("general.errors.player-has-no-island");
|
||||
}
|
||||
|
||||
//when(im.getOwner(any(), eq(notUUID))).thenReturn(uuid);
|
||||
when(pm.getName(any())).thenReturn("owner");
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.api.commands.admin.team.AdminTeamDisbandCommand#canExecute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCanExecuteSuccess() {
|
||||
when(im.inTeam(any(), any())).thenReturn(true);
|
||||
when(Util.getUUID("tastybento")).thenReturn(uuid);
|
||||
when(pm.getName(uuid)).thenReturn("tastybento");
|
||||
// Members
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, notUUID));
|
||||
|
||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
verify(user).sendMessage("commands.admin.team.disband.use-disband-owner", "[owner]", "owner");
|
||||
|
||||
assertTrue(itl.canExecute(user, itl.getLabel(), List.of("tastybento")));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,24 +240,64 @@ public class AdminTeamDisbandCommandTest {
|
|||
*/
|
||||
@Test
|
||||
public void testExecuteSuccess() {
|
||||
when(im.inTeam(any(), any())).thenReturn(true);
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(island);
|
||||
String[] name = {"tastybento"};
|
||||
when(pm.getUUID(any())).thenReturn(notUUID);
|
||||
when(pm.getName(any())).thenReturn(name[0]);
|
||||
// Owner
|
||||
when(island.getOwner()).thenReturn(notUUID);
|
||||
// Members
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(uuid, notUUID));
|
||||
|
||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
verify(im, never()).removePlayer(island, notUUID);
|
||||
verify(im).removePlayer(island, uuid);
|
||||
verify(user).sendMessage("commands.admin.team.disband.success", TextVariables.NAME, name[0]);
|
||||
this.testCanExecuteSuccess();
|
||||
assertTrue(itl.execute(user, itl.getLabel(), List.of("tastybento")));
|
||||
verify(im, never()).removePlayer(island, uuid);
|
||||
verify(im).removePlayer(island, notUUID);
|
||||
verify(user).sendMessage("commands.admin.team.disband.success", TextVariables.NAME, "tastybento");
|
||||
verify(p).sendMessage("commands.admin.team.disband.disbanded");
|
||||
verify(p2).sendMessage("commands.admin.team.disband.disbanded");
|
||||
// 2 + 1
|
||||
verify(pim, times(3)).callEvent(any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.api.commands.admin.team.AdminTeamDisbandCommand#tabComplete(User, String, List)}
|
||||
*/
|
||||
@Test
|
||||
public void testTabCompleteNoArgs() {
|
||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||
Optional<List<String>> list = itl.tabComplete(user, "", List.of(""));
|
||||
assertTrue(list.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.api.commands.admin.team.AdminTeamDisbandCommand#tabComplete(User, String, List)}
|
||||
*/
|
||||
@Test
|
||||
public void testTabCompleteOneArg() {
|
||||
when(Util.getUUID("tastybento")).thenReturn(uuid);
|
||||
when(pm.getName(uuid)).thenReturn("tastybento");
|
||||
|
||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||
Optional<List<String>> list = itl.tabComplete(user, "", List.of("tasty"));
|
||||
assertTrue(list.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.api.commands.admin.team.AdminTeamDisbandCommand#tabComplete(User, String, List)}
|
||||
*/
|
||||
@Test
|
||||
public void testTabCompleteTwoArgs() {
|
||||
when(Util.getUUID("tastybento")).thenReturn(uuid);
|
||||
when(pm.getName(uuid)).thenReturn("tastybento");
|
||||
|
||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||
Optional<List<String>> list = itl.tabComplete(user, "", List.of("tastybento", "1"));
|
||||
assertTrue(list.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.api.commands.admin.team.AdminTeamDisbandCommand#tabComplete(User, String, List)}
|
||||
*/
|
||||
@Test
|
||||
public void testTabCompleteThreeArgs() {
|
||||
when(Util.getUUID("tastybento")).thenReturn(uuid);
|
||||
when(pm.getName(uuid)).thenReturn("tastybento");
|
||||
|
||||
AdminTeamDisbandCommand itl = new AdminTeamDisbandCommand(ac);
|
||||
Optional<List<String>> list = itl.tabComplete(user, "", List.of("tastybento", "1,2,3", "ddd"));
|
||||
assertFalse(list.isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ public class AdminTeamKickCommandTest {
|
|||
AdminTeamKickCommand itl = new AdminTeamKickCommand(ac);
|
||||
assertTrue(itl.canExecute(user, itl.getLabel(), Collections.singletonList(name)));
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList(name)));
|
||||
verify(im).removePlayer(eq(world), eq(notUUID));
|
||||
verify(im).removePlayer(is, notUUID);
|
||||
verify(user).sendMessage(eq("commands.admin.team.kick.success"), eq(TextVariables.NAME), eq(name), eq("[owner]"), anyString());
|
||||
// Offline so event will be called 4 times
|
||||
verify(pim, times(4)).callEvent(any());
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.bukkit.plugin.PluginManager;
|
|||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
|
@ -208,6 +209,7 @@ public class ItemsAdderHookTest {
|
|||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.hooks.ItemsAdderHook#clearBlockInfo(org.bukkit.Location)}.
|
||||
*/
|
||||
@Ignore("Temp skip until this is optimized")
|
||||
@Test
|
||||
public void testClearBlockInfo() {
|
||||
hook.clearBlockInfo(location);
|
||||
|
|
|
@ -116,6 +116,7 @@ public class CommandRankClickListenerTest extends RanksManagerBeforeClassTest {
|
|||
// Tab
|
||||
when(tab.getIsland()).thenReturn(island);
|
||||
// User
|
||||
when(user.isOp()).thenReturn(true);
|
||||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.hasPermission(anyString())).thenReturn(true);
|
||||
when(user.getPlayer()).thenReturn(player);
|
||||
|
@ -137,6 +138,7 @@ public class CommandRankClickListenerTest extends RanksManagerBeforeClassTest {
|
|||
when(cc.isConfigurableRankCommand()).thenReturn(true);
|
||||
when(cc.getName()).thenReturn("test");
|
||||
when(cc.getSubCommands()).thenReturn(Collections.emptyMap());
|
||||
when(cc.testPermission(any())).thenReturn(true); // All commands are allowed
|
||||
map.put("test", cc);
|
||||
when(cm.getCommands()).thenReturn(map);
|
||||
crcl = new CommandRankClickListener();
|
||||
|
@ -157,6 +159,7 @@ public class CommandRankClickListenerTest extends RanksManagerBeforeClassTest {
|
|||
*/
|
||||
@Test
|
||||
public void testOnClickNoPermission() {
|
||||
when(user.isOp()).thenReturn(false);
|
||||
when(user.hasPermission(anyString())).thenReturn(false);
|
||||
assertTrue(crcl.onClick(panel, user, ClickType.LEFT, 0));
|
||||
verify(user).sendMessage("general.errors.no-permission", TextVariables.PERMISSION, "oneblock.settings.COMMAND_RANKS");
|
||||
|
@ -207,11 +210,12 @@ public class CommandRankClickListenerTest extends RanksManagerBeforeClassTest {
|
|||
when(cc.getName()).thenReturn("test" + i);
|
||||
when(cc.getSubCommands()).thenReturn(Collections.emptyMap());
|
||||
map.put("test" + i, cc);
|
||||
when(cc.testPermission(any())).thenReturn(true);
|
||||
}
|
||||
when(cm.getCommands()).thenReturn(map);
|
||||
|
||||
assertTrue(crcl.onClick(panel, user, ClickType.LEFT, 0));
|
||||
verify(plugin).logError("Number of rank setting commands is too big for GUI");
|
||||
verify(user).getTranslation("protection.panel.flag-item.description-layout", TextVariables.DESCRIPTION, "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -384,7 +384,7 @@ public class BreakBlocksListenerTest extends AbstractCommonSetup {
|
|||
DamageCause cause = DamageCause.ENTITY_ATTACK;
|
||||
Entity damagee = player;
|
||||
Entity damager = player;
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -397,15 +397,15 @@ public class BreakBlocksListenerTest extends AbstractCommonSetup {
|
|||
DamageCause cause = DamageCause.ENTITY_ATTACK;
|
||||
Entity damagee = mock(ArmorStand.class);
|
||||
Entity damager = player;
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
damagee = mock(ItemFrame.class);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
damagee = mock(EnderCrystal.class);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -420,17 +420,17 @@ public class BreakBlocksListenerTest extends AbstractCommonSetup {
|
|||
Entity damagee = mock(ArmorStand.class);
|
||||
when(damagee.getLocation()).thenReturn(location);
|
||||
Entity damager = player;
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
damagee = mock(ItemFrame.class);
|
||||
when(damagee.getLocation()).thenReturn(location);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
damagee = mock(EnderCrystal.class);
|
||||
when(damagee.getLocation()).thenReturn(location);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
verify(notifier, times(3)).notify(any(), eq("protection.protected"));
|
||||
|
@ -445,15 +445,15 @@ public class BreakBlocksListenerTest extends AbstractCommonSetup {
|
|||
Entity damagee = mock(ArmorStand.class);
|
||||
Projectile damager = mock(Projectile.class);
|
||||
when(damager.getShooter()).thenReturn(player);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
damagee = mock(ItemFrame.class);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
damagee = mock(EnderCrystal.class);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -467,15 +467,15 @@ public class BreakBlocksListenerTest extends AbstractCommonSetup {
|
|||
Entity damagee = mock(ArmorStand.class);
|
||||
Projectile damager = mock(Projectile.class);
|
||||
when(damager.getShooter()).thenReturn(mock(Skeleton.class));
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
damagee = mock(ItemFrame.class);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
damagee = mock(EnderCrystal.class);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -491,21 +491,21 @@ public class BreakBlocksListenerTest extends AbstractCommonSetup {
|
|||
when(damagee.getLocation()).thenReturn(location);
|
||||
Projectile damager = mock(Projectile.class);
|
||||
when(damager.getShooter()).thenReturn(player);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
verify(damagee).setFireTicks(0);
|
||||
|
||||
damagee = mock(ItemFrame.class);
|
||||
when(damagee.getLocation()).thenReturn(location);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
verify(damagee).setFireTicks(0);
|
||||
|
||||
damagee = mock(EnderCrystal.class);
|
||||
when(damagee.getLocation()).thenReturn(location);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, 10);
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, cause, null, 10);
|
||||
bbl.onEntityDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
verify(notifier, times(3)).notify(any(), eq("protection.protected"));
|
||||
|
|
|
@ -77,7 +77,7 @@ public class HurtingListenerTest extends AbstractCommonSetup {
|
|||
*/
|
||||
@Test
|
||||
public void testOnEntityDamageMonsteronMonster() {
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, enderman, null, 0);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, enderman, null, null, 0);
|
||||
HurtingListener hl = new HurtingListener();
|
||||
hl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
|
@ -88,7 +88,7 @@ public class HurtingListenerTest extends AbstractCommonSetup {
|
|||
*/
|
||||
@Test
|
||||
public void testOnEntityDamagePlayeronMonster() {
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, enderman, null, 0);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, enderman, null, null, 0);
|
||||
HurtingListener hl = new HurtingListener();
|
||||
hl.onEntityDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
|
@ -101,7 +101,7 @@ public class HurtingListenerTest extends AbstractCommonSetup {
|
|||
@Test
|
||||
public void testOnEntityDamagePlayeronMonsterOp() {
|
||||
when(player.isOp()).thenReturn(true);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, enderman, null, 0);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, enderman, null, null, 0);
|
||||
HurtingListener hl = new HurtingListener();
|
||||
hl.onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
|
|
|
@ -299,7 +299,8 @@ public class TNTListenerTest extends AbstractCommonSetup {
|
|||
|
||||
@Test
|
||||
public void testOnEntityExplosion() {
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(entity, player, DamageCause.ENTITY_EXPLOSION, 20D);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(entity, player, DamageCause.ENTITY_EXPLOSION, null,
|
||||
20D);
|
||||
listener.onExplosion(e);
|
||||
assertTrue(e.isCancelled());
|
||||
}
|
||||
|
@ -309,7 +310,8 @@ public class TNTListenerTest extends AbstractCommonSetup {
|
|||
Flags.WORLD_TNT_DAMAGE.setDefaultSetting(false);
|
||||
assertFalse(Flags.WORLD_TNT_DAMAGE.isSetForWorld(world));
|
||||
when(im.getProtectedIslandAt(any())).thenReturn(Optional.empty());
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(entity, player, DamageCause.ENTITY_EXPLOSION, 20D);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(entity, player, DamageCause.ENTITY_EXPLOSION, null,
|
||||
20D);
|
||||
listener.onExplosion(e);
|
||||
assertTrue(e.isCancelled());
|
||||
}
|
||||
|
@ -319,7 +321,8 @@ public class TNTListenerTest extends AbstractCommonSetup {
|
|||
Flags.WORLD_TNT_DAMAGE.setDefaultSetting(true);
|
||||
assertTrue(Flags.WORLD_TNT_DAMAGE.isSetForWorld(world));
|
||||
when(im.getProtectedIslandAt(any())).thenReturn(Optional.empty());
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(entity, player, DamageCause.ENTITY_EXPLOSION, 20D);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(entity, player, DamageCause.ENTITY_EXPLOSION, null,
|
||||
20D);
|
||||
listener.onExplosion(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -327,7 +330,8 @@ public class TNTListenerTest extends AbstractCommonSetup {
|
|||
@Test
|
||||
public void testOnEntityExplosionWrongWorld() {
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(entity, player, DamageCause.ENTITY_EXPLOSION, 20D);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(entity, player, DamageCause.ENTITY_EXPLOSION, null,
|
||||
20D);
|
||||
listener.onExplosion(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
|
|
@ -252,7 +252,8 @@ public class PVPListenerTest {
|
|||
public void testOnEntityDamageNotPlayer() {
|
||||
Entity damager = mock(Zombie.class);
|
||||
Entity damagee = mock(Creeper.class);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -265,7 +266,8 @@ public class PVPListenerTest {
|
|||
@Test
|
||||
public void testOnEntityDamageSelfDamage() {
|
||||
Entity damager = mock(Player.class);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damager, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damager,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -281,7 +283,8 @@ public class PVPListenerTest {
|
|||
when(player2.hasMetadata(eq("NPC"))).thenReturn(true);
|
||||
// PVP is not allowed
|
||||
when(island.isAllowed(any())).thenReturn(false);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -304,21 +307,22 @@ public class PVPListenerTest {
|
|||
when(damagee.getWorld()).thenReturn(world);
|
||||
when(damager.getLocation()).thenReturn(loc);
|
||||
when(damagee.getLocation()).thenReturn(loc);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
|
||||
// Different attack type
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK,
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
|
||||
// Wrong world
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
wrongWorld();
|
||||
|
@ -346,13 +350,14 @@ public class PVPListenerTest {
|
|||
when(iwm.getIvSettings(world)).thenReturn(visitorProtectionList);
|
||||
// This player is on their island, i.e., not a visitor
|
||||
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
// Wrong world
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
wrongWorld();
|
||||
|
@ -376,7 +381,8 @@ public class PVPListenerTest {
|
|||
// This player is a visitor
|
||||
when(im.userIsOnIsland(any(), any())).thenReturn(false);
|
||||
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -403,7 +409,8 @@ public class PVPListenerTest {
|
|||
// This player is a visitor
|
||||
when(im.userIsOnIsland(any(), any())).thenReturn(false);
|
||||
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
wrongWorld();
|
||||
|
@ -431,7 +438,8 @@ public class PVPListenerTest {
|
|||
// This player is a visitor
|
||||
when(im.userIsOnIsland(any(), any())).thenReturn(false);
|
||||
// Damage is not entity attack
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.THORNS,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee,
|
||||
EntityDamageEvent.DamageCause.THORNS, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -458,13 +466,14 @@ public class PVPListenerTest {
|
|||
// This player is a visitor
|
||||
when(im.userIsOnIsland(any(), any())).thenReturn(false);
|
||||
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(damager, damagee,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
// Wrong world
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
e = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
wrongWorld();
|
||||
|
@ -489,7 +498,8 @@ public class PVPListenerTest {
|
|||
@Test
|
||||
public void testOnEntityDamagePVPNotAllowed() {
|
||||
// No visitor protection
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -504,7 +514,8 @@ public class PVPListenerTest {
|
|||
*/
|
||||
@Test
|
||||
public void testOnEntityDamagePVPNotAllowedInvVisitor() {
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
|
||||
|
@ -525,7 +536,8 @@ public class PVPListenerTest {
|
|||
public void testOnEntityDamageOnPVPAllowed() {
|
||||
// PVP is allowed
|
||||
when(island.isAllowed(any())).thenReturn(true);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(player, player2,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -552,7 +564,8 @@ public class PVPListenerTest {
|
|||
when(p.getShooter()).thenReturn(player);
|
||||
when(p.getLocation()).thenReturn(loc);
|
||||
when(p.getWorld()).thenReturn(world);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -580,7 +593,8 @@ public class PVPListenerTest {
|
|||
Projectile p = mock(Projectile.class);
|
||||
when(p.getShooter()).thenReturn(player);
|
||||
when(p.getLocation()).thenReturn(loc);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -598,7 +612,8 @@ public class PVPListenerTest {
|
|||
when(p.getLocation()).thenReturn(loc);
|
||||
// PVP is allowed
|
||||
when(island.isAllowed(any())).thenReturn(true);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -626,7 +641,8 @@ public class PVPListenerTest {
|
|||
when(p.getLocation()).thenReturn(loc);
|
||||
// PVP is allowed
|
||||
when(island.isAllowed(any())).thenReturn(true);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -646,7 +662,8 @@ public class PVPListenerTest {
|
|||
when(p.getLocation()).thenReturn(loc);
|
||||
// PVP is allowed
|
||||
when(island.isAllowed(any())).thenReturn(true);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2, EntityDamageEvent.DamageCause.ENTITY_ATTACK,
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, player2,
|
||||
EntityDamageEvent.DamageCause.ENTITY_ATTACK, null,
|
||||
new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, 0D)),
|
||||
new EnumMap<DamageModifier, Function<? super Double, Double>>(ImmutableMap.of(DamageModifier.BASE, Functions.constant(-0.0))));
|
||||
new PVPListener().onEntityDamage(e);
|
||||
|
@ -1126,7 +1143,8 @@ public class PVPListenerTest {
|
|||
listener.onPlayerShootFireworkEvent(e);
|
||||
|
||||
// Now damage
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(firework, player, DamageCause.ENTITY_ATTACK, 0);
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(firework, player, DamageCause.ENTITY_ATTACK, null,
|
||||
0);
|
||||
listener.onEntityDamage(en);
|
||||
assertFalse(en.isCancelled());
|
||||
}
|
||||
|
@ -1142,7 +1160,7 @@ public class PVPListenerTest {
|
|||
EntityShootBowEvent e = new EntityShootBowEvent(player, bow, null, arrow, EquipmentSlot.HAND, 1F, false);
|
||||
listener.onPlayerShootFireworkEvent(e);
|
||||
// Now damage
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(arrow, player, DamageCause.ENTITY_ATTACK, 0);
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(arrow, player, DamageCause.ENTITY_ATTACK, null, 0);
|
||||
listener.onEntityDamage(en);
|
||||
assertFalse(en.isCancelled());
|
||||
}
|
||||
|
@ -1163,7 +1181,8 @@ public class PVPListenerTest {
|
|||
listener.onPlayerShootFireworkEvent(e);
|
||||
|
||||
// Now damage
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(firework, player, DamageCause.ENTITY_EXPLOSION, 0);
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(firework, player, DamageCause.ENTITY_EXPLOSION,
|
||||
null, 0);
|
||||
listener.onEntityDamage(en);
|
||||
assertFalse(en.isCancelled());
|
||||
}
|
||||
|
@ -1185,7 +1204,8 @@ public class PVPListenerTest {
|
|||
listener.onPlayerShootFireworkEvent(e);
|
||||
|
||||
// Now damage
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(firework, player2, DamageCause.ENTITY_EXPLOSION, 0);
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(firework, player2, DamageCause.ENTITY_EXPLOSION,
|
||||
null, 0);
|
||||
listener.onEntityDamage(en);
|
||||
assertTrue(en.isCancelled());
|
||||
}
|
||||
|
@ -1206,7 +1226,8 @@ public class PVPListenerTest {
|
|||
listener.onPlayerShootFireworkEvent(e);
|
||||
|
||||
// Now damage
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(firework, player2, DamageCause.ENTITY_EXPLOSION, 0);
|
||||
EntityDamageByEntityEvent en = new EntityDamageByEntityEvent(firework, player2, DamageCause.ENTITY_EXPLOSION,
|
||||
null, 0);
|
||||
listener.onEntityDamage(en);
|
||||
assertFalse(en.isCancelled());
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ public class InvincibleVisitorsListenerTest {
|
|||
@Test
|
||||
public void testOnVisitorGetDamageNotPlayer() {
|
||||
LivingEntity le = mock(LivingEntity.class);
|
||||
EntityDamageEvent e = new EntityDamageEvent(le, EntityDamageEvent.DamageCause.CRAMMING, 0D);
|
||||
EntityDamageEvent e = new EntityDamageEvent(le, EntityDamageEvent.DamageCause.CRAMMING, null, 0D);
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ public class InvincibleVisitorsListenerTest {
|
|||
public void testOnVisitorGetDamageNotInWorld() {
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, null, 0D);
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -265,14 +265,14 @@ public class InvincibleVisitorsListenerTest {
|
|||
public void testOnVisitorGetDamageNotInIvSettings() {
|
||||
when(iwm.inWorld(any(World.class))).thenReturn(false);
|
||||
when(iwm.inWorld(any(Location.class))).thenReturn(false);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.BLOCK_EXPLOSION, 0D);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.BLOCK_EXPLOSION, null, 0D);
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnVisitorGetDamageNotVisitor() {
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, null, 0D);
|
||||
when(im.userIsOnIsland(any(), any())).thenReturn(true);
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
|
@ -280,7 +280,7 @@ public class InvincibleVisitorsListenerTest {
|
|||
|
||||
@Test
|
||||
public void testOnVisitorGetDamageNotVoid() {
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, null, 0D);
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
verify(player, never()).setGameMode(eq(GameMode.SPECTATOR));
|
||||
|
@ -290,7 +290,7 @@ public class InvincibleVisitorsListenerTest {
|
|||
@Test
|
||||
public void testOnVisitorGetDamageNPC() {
|
||||
when(player.hasMetadata(eq("NPC"))).thenReturn(true);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, null, 0D);
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ public class InvincibleVisitorsListenerTest {
|
|||
@Test
|
||||
public void testOnVisitorGetDamageVoidIslandHere() {
|
||||
when(im.getIslandAt(any())).thenReturn(optionalIsland);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.VOID, 0D);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.VOID, null, 0D);
|
||||
// Player should be teleported to this island
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
|
@ -310,7 +310,7 @@ public class InvincibleVisitorsListenerTest {
|
|||
public void testOnVisitorGetDamageVoidNoIslandHerePlayerHasNoIsland() {
|
||||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(false);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.VOID, 0D);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.VOID, null, 0D);
|
||||
// Player should die
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
|
@ -323,7 +323,7 @@ public class InvincibleVisitorsListenerTest {
|
|||
when(im.getIslandAt(any())).thenReturn(Optional.empty());
|
||||
// Player has an island
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(true);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.VOID, 0D);
|
||||
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.VOID, null, 0D);
|
||||
// Player should be teleported to their island
|
||||
listener.onVisitorGetDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
|
|
|
@ -114,9 +114,10 @@ public class IslandRespawnListenerTest {
|
|||
when(iwm.getAddon(any())).thenReturn(opGma);
|
||||
safeLocation = mock(Location.class);
|
||||
when(safeLocation.getWorld()).thenReturn(world);
|
||||
when(island.getSpawnPoint(Environment.NORMAL)).thenReturn(safeLocation);
|
||||
when(im.getHomeLocation(eq(world), any(UUID.class))).thenReturn(safeLocation);
|
||||
when(im.getPrimaryIsland(any(), any())).thenReturn(island);
|
||||
when(im.hasIsland(any(), any(UUID.class))).thenReturn(true);
|
||||
when(im.isSafeLocation(safeLocation)).thenReturn(true);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
|
||||
// when(im.getSafeHomeLocation(any(), any(),
|
||||
|
|
|
@ -155,7 +155,7 @@ public class ItemFrameListenerTest {
|
|||
public void testOnItemFrameDamageEntityDamageByEntityEvent() {
|
||||
ItemFrameListener ifl = new ItemFrameListener();
|
||||
DamageCause cause = DamageCause.ENTITY_ATTACK;
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, entity, cause , 0);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, entity, cause, null, 0);
|
||||
ifl.onItemFrameDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ public class ItemFrameListenerTest {
|
|||
Creeper creeper = mock(Creeper.class);
|
||||
when(creeper.getLocation()).thenReturn(location);
|
||||
DamageCause cause = DamageCause.ENTITY_ATTACK;
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, creeper, cause , 0);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(enderman, creeper, cause, null, 0);
|
||||
ifl.onItemFrameDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class ItemFrameListenerTest {
|
|||
DamageCause cause = DamageCause.ENTITY_ATTACK;
|
||||
Projectile p = mock(Projectile.class);
|
||||
when(p.getShooter()).thenReturn(enderman);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause , 0);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause, null, 0);
|
||||
ifl.onItemFrameDamage(e);
|
||||
assertTrue(e.isCancelled());
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public class ItemFrameListenerTest {
|
|||
Projectile p = mock(Projectile.class);
|
||||
Player player = mock(Player.class);
|
||||
when(p.getShooter()).thenReturn(player);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause , 0);
|
||||
EntityDamageByEntityEvent e = new EntityDamageByEntityEvent(p, entity, cause, null, 0);
|
||||
ifl.onItemFrameDamage(e);
|
||||
assertFalse(e.isCancelled());
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class PlaceholdersManagerTest {
|
|||
public void testRegisterGameModePlaceholdersAllDefaults() {
|
||||
pm.registerDefaultPlaceholders(addon);
|
||||
// + 300 because we register team member placeholders up to 50 members
|
||||
verify(hook, times(GameModePlaceholder.values().length + 300)).registerPlaceholder(any(), anyString(), any());
|
||||
verify(hook, times(GameModePlaceholder.values().length + 302)).registerPlaceholder(any(), anyString(), any());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,6 +91,7 @@ public class PlaceholdersManagerTest {
|
|||
pm.registerDefaultPlaceholders(addon);
|
||||
|
||||
// 3 less registrations for this addon
|
||||
verify(hook, times(GameModePlaceholder.values().length - 3 + 300)).registerPlaceholder(any(), anyString(), any());
|
||||
verify(hook, times(GameModePlaceholder.values().length - 3 + 302)).registerPlaceholder(any(), anyString(),
|
||||
any());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.bukkit.Material;
|
|||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
|
@ -97,6 +98,8 @@ public class NewIslandTest {
|
|||
private final UUID uuid = UUID.randomUUID();
|
||||
@Mock
|
||||
private BlueprintsManager bpm;
|
||||
@Mock
|
||||
private @NonNull Location location2;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -129,6 +132,8 @@ public class NewIslandTest {
|
|||
when(user.getPermissionValue(Mockito.anyString(), Mockito.anyInt())).thenReturn(20);
|
||||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.getName()).thenReturn("tastybento");
|
||||
when(user.getWorld()).thenReturn(world);
|
||||
when(user.getLocation()).thenReturn(location);
|
||||
|
||||
// Events
|
||||
PowerMockito.mockStatic(IslandEvent.class);
|
||||
|
@ -147,9 +152,11 @@ public class NewIslandTest {
|
|||
|
||||
// Location and blocks
|
||||
when(island.getWorld()).thenReturn(world);
|
||||
when(island.getCenter()).thenReturn(location2);
|
||||
when(location.getWorld()).thenReturn(world);
|
||||
when(world.getMaxHeight()).thenReturn(5);
|
||||
when(location.getBlock()).thenReturn(block);
|
||||
when(location.distance(any())).thenReturn(320D);
|
||||
when(block.getType()).thenReturn(Material.AIR);
|
||||
when(block.isEmpty()).thenReturn(true);
|
||||
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(block);
|
||||
|
@ -163,6 +170,7 @@ public class NewIslandTest {
|
|||
// Bukkit Scheduler
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
||||
when(Bukkit.getViewDistance()).thenReturn(10);
|
||||
|
||||
// Addon
|
||||
when(addon.getOverWorld()).thenReturn(world);
|
||||
|
@ -250,12 +258,32 @@ public class NewIslandTest {
|
|||
* {@link world.bentobox.bentobox.managers.island.NewIsland#builder()}.
|
||||
*/
|
||||
@Test
|
||||
public void testBuilderNoOldIslandPaste() throws Exception {
|
||||
public void testBuilderNoOldIslandPasteNoNMS() throws Exception {
|
||||
when(location.distance(any())).thenReturn(30D);
|
||||
NewIsland.builder().addon(addon).name(NAME).player(user).reason(Reason.CREATE).build();
|
||||
// Verifications
|
||||
verify(im).save(eq(island));
|
||||
verify(island).setFlagsDefaults();
|
||||
verify(bpm).paste(eq(addon), eq(island), eq(NAME), any(Runnable.class));
|
||||
verify(bpm).paste(eq(addon), eq(island), eq(NAME), any(Runnable.class), eq(false));
|
||||
verify(builder, times(2)).build();
|
||||
verify(bpb).getUniqueId();
|
||||
verify(ice).getBlueprintBundle();
|
||||
verify(pm).setDeaths(eq(world), eq(uuid), eq(0));
|
||||
verify(im, never()).setHomeLocation(eq(user), any());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link world.bentobox.bentobox.managers.island.NewIsland#builder()}.
|
||||
*/
|
||||
@Test
|
||||
public void testBuilderNoOldIslandPasteWithNMS() throws Exception {
|
||||
NewIsland.builder().addon(addon).name(NAME).player(user).reason(Reason.CREATE).build();
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
// Verifications
|
||||
verify(im).save(eq(island));
|
||||
verify(island).setFlagsDefaults();
|
||||
verify(bpm).paste(eq(addon), eq(island), eq(NAME), any(Runnable.class), eq(true));
|
||||
verify(builder, times(2)).build();
|
||||
verify(bpb).getUniqueId();
|
||||
verify(ice).getBlueprintBundle();
|
||||
|
|
Loading…
Reference in New Issue