mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 19:55:17 +01:00
Added default Game Mode to world settings.
https://github.com/tastybento/bskyblock/issues/179 Removed references to acid from settings for BSB.
This commit is contained in:
parent
617fc712aa
commit
8125ec52af
@ -131,6 +131,11 @@ world:
|
||||
# If the number of islands is greater than this number, no new island will be created.
|
||||
max-islands: 0
|
||||
|
||||
# The default game mode for this world. Players will be set to this mode when they create
|
||||
# a new island for example. Options are SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR
|
||||
default-game-mode: SURVIVAL
|
||||
|
||||
|
||||
### Nether-related Settings ###
|
||||
nether:
|
||||
# Generate Nether - if this is false, the nether world will not be made and access to
|
||||
|
@ -1,7 +1,6 @@
|
||||
package us.tastybento.bskyblock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -9,11 +8,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import us.tastybento.bskyblock.Constants.GameType;
|
||||
import us.tastybento.bskyblock.api.configuration.ConfigComment;
|
||||
import us.tastybento.bskyblock.api.configuration.ConfigEntry;
|
||||
import us.tastybento.bskyblock.api.configuration.StoreAt;
|
||||
@ -21,8 +19,6 @@ import us.tastybento.bskyblock.api.configuration.WorldSettings;
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.database.BSBDbSetup.DatabaseType;
|
||||
import us.tastybento.bskyblock.database.objects.DataObject;
|
||||
import us.tastybento.bskyblock.database.objects.adapters.Adapter;
|
||||
import us.tastybento.bskyblock.database.objects.adapters.PotionEffectListAdapter;
|
||||
|
||||
/**
|
||||
* All the plugin settings are here
|
||||
@ -185,6 +181,11 @@ public class Settings implements DataObject, WorldSettings {
|
||||
@ConfigEntry(path = "world.max-islands")
|
||||
private int maxIslands = -1;
|
||||
|
||||
@ConfigComment("The default game mode for this world. Players will be set to this mode when they create")
|
||||
@ConfigComment("a new island for example. Options are SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR")
|
||||
@ConfigEntry(path = "world.default-game-mode")
|
||||
private GameMode defaultGameMode = GameMode.SURVIVAL;
|
||||
|
||||
// Nether
|
||||
@ConfigComment("Generate Nether - if this is false, the nether world will not be made and access to")
|
||||
@ConfigComment("the nether will not occur. Other plugins may still enable portal usage.")
|
||||
@ -235,7 +236,7 @@ public class Settings implements DataObject, WorldSettings {
|
||||
@ConfigComment("World flags. These are boolean settings for various flags for this world")
|
||||
@ConfigEntry(path = "world.flags")
|
||||
private Map<String, Boolean> worldFlags = new HashMap<>();
|
||||
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
/* ISLAND */
|
||||
@ -252,7 +253,7 @@ public class Settings implements DataObject, WorldSettings {
|
||||
private int maxTeamSize = 4;
|
||||
@ConfigComment("Default maximum number of homes a player can have. Min = 1")
|
||||
@ConfigComment("Accessed via sethome <number> or go <number>")
|
||||
@ConfigComment("Use this permission to set for specific user groups: askyblock.island.maxhomes.<number>")
|
||||
@ConfigComment("Use this permission to set for specific user groups: askyblock.island.maxhomes.<number>")
|
||||
@ConfigEntry(path = "island.max-homes")
|
||||
private int maxHomes = 5;
|
||||
@ConfigComment("Island naming")
|
||||
@ -351,34 +352,9 @@ public class Settings implements DataObject, WorldSettings {
|
||||
private List<String> ivSettings = new ArrayList<>();
|
||||
|
||||
//TODO flags
|
||||
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
/* ACID */
|
||||
|
||||
/*
|
||||
* This settings category only exists if the GameType is ACIDISLAND.
|
||||
*/
|
||||
|
||||
@ConfigEntry(path = "acid.damage-op", specificTo = GameType.ACIDISLAND)
|
||||
private boolean acidDamageOp = false;
|
||||
|
||||
@ConfigEntry(path = "acid.damage-chickens", specificTo = GameType.ACIDISLAND)
|
||||
private boolean acidDamageChickens = false;
|
||||
|
||||
@ConfigEntry(path = "acid.options.item-destroy-time", specificTo = GameType.ACIDISLAND)
|
||||
private int acidDestroyItemTime = 0;
|
||||
|
||||
// Damage
|
||||
@ConfigEntry(path = "acid.damage.acid.player", specificTo = GameType.ACIDISLAND)
|
||||
private int acidDamage = 10;
|
||||
|
||||
@ConfigEntry(path = "acid.damage.rain", specificTo = GameType.ACIDISLAND)
|
||||
private int acidRainDamage = 1;
|
||||
|
||||
@ConfigEntry(path = "acid.damage.effects", specificTo = GameType.ACIDISLAND)
|
||||
@Adapter(PotionEffectListAdapter.class)
|
||||
private List<PotionEffectType> acidEffects = new ArrayList<>(Arrays.asList(PotionEffectType.CONFUSION, PotionEffectType.SLOW));
|
||||
|
||||
/* SCHEMATICS */
|
||||
private List<String> companionNames = new ArrayList<>();
|
||||
@ -475,30 +451,6 @@ public class Settings implements DataObject, WorldSettings {
|
||||
public void setDisableOfflineRedstone(boolean disableOfflineRedstone) {
|
||||
this.disableOfflineRedstone = disableOfflineRedstone;
|
||||
}
|
||||
/**
|
||||
* @return the acidDamage
|
||||
*/
|
||||
public int getAcidDamage() {
|
||||
return acidDamage;
|
||||
}
|
||||
/**
|
||||
* @return the acidDestroyItemTime
|
||||
*/
|
||||
public int getAcidDestroyItemTime() {
|
||||
return acidDestroyItemTime;
|
||||
}
|
||||
/**
|
||||
* @return the acidEffects
|
||||
*/
|
||||
public List<PotionEffectType> getAcidEffects() {
|
||||
return acidEffects;
|
||||
}
|
||||
/**
|
||||
* @return the acidRainDamage
|
||||
*/
|
||||
public int getAcidRainDamage() {
|
||||
return acidRainDamage;
|
||||
}
|
||||
/**
|
||||
* @return the chestItems
|
||||
*/
|
||||
@ -586,6 +538,7 @@ public class Settings implements DataObject, WorldSettings {
|
||||
/**
|
||||
* @return the entityLimits
|
||||
*/
|
||||
@Override
|
||||
public Map<EntityType, Integer> getEntityLimits() {
|
||||
return entityLimits;
|
||||
}
|
||||
@ -599,42 +552,49 @@ public class Settings implements DataObject, WorldSettings {
|
||||
/**
|
||||
* @return the islandDistance
|
||||
*/
|
||||
@Override
|
||||
public int getIslandDistance() {
|
||||
return islandDistance;
|
||||
}
|
||||
/**
|
||||
* @return the islandHeight
|
||||
*/
|
||||
@Override
|
||||
public int getIslandHeight() {
|
||||
return islandHeight;
|
||||
}
|
||||
/**
|
||||
* @return the islandProtectionRange
|
||||
*/
|
||||
@Override
|
||||
public int getIslandProtectionRange() {
|
||||
return islandProtectionRange;
|
||||
}
|
||||
/**
|
||||
* @return the islandStartX
|
||||
*/
|
||||
@Override
|
||||
public int getIslandStartX() {
|
||||
return islandStartX;
|
||||
}
|
||||
/**
|
||||
* @return the islandStartZ
|
||||
*/
|
||||
@Override
|
||||
public int getIslandStartZ() {
|
||||
return islandStartZ;
|
||||
}
|
||||
/**
|
||||
* @return the islandXOffset
|
||||
*/
|
||||
@Override
|
||||
public int getIslandXOffset() {
|
||||
return islandXOffset;
|
||||
}
|
||||
/**
|
||||
* @return the islandZOffset
|
||||
*/
|
||||
@Override
|
||||
public int getIslandZOffset() {
|
||||
return islandZOffset;
|
||||
}
|
||||
@ -666,12 +626,14 @@ public class Settings implements DataObject, WorldSettings {
|
||||
/**
|
||||
* @return the maxIslands
|
||||
*/
|
||||
@Override
|
||||
public int getMaxIslands() {
|
||||
return maxIslands;
|
||||
}
|
||||
/**
|
||||
* @return the maxTeamSize
|
||||
*/
|
||||
@Override
|
||||
public int getMaxTeamSize() {
|
||||
return maxTeamSize;
|
||||
}
|
||||
@ -690,6 +652,7 @@ public class Settings implements DataObject, WorldSettings {
|
||||
/**
|
||||
* @return the netherSpawnRadius
|
||||
*/
|
||||
@Override
|
||||
public int getNetherSpawnRadius() {
|
||||
return netherSpawnRadius;
|
||||
}
|
||||
@ -714,12 +677,14 @@ public class Settings implements DataObject, WorldSettings {
|
||||
/**
|
||||
* @return the seaHeight
|
||||
*/
|
||||
@Override
|
||||
public int getSeaHeight() {
|
||||
return seaHeight;
|
||||
}
|
||||
/**
|
||||
* @return the tileEntityLimits
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Integer> getTileEntityLimits() {
|
||||
return tileEntityLimits;
|
||||
}
|
||||
@ -739,21 +704,10 @@ public class Settings implements DataObject, WorldSettings {
|
||||
/**
|
||||
* @return the worldName
|
||||
*/
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return worldName;
|
||||
}
|
||||
/**
|
||||
* @return the acidDamageChickens
|
||||
*/
|
||||
public boolean isAcidDamageChickens() {
|
||||
return acidDamageChickens;
|
||||
}
|
||||
/**
|
||||
* @return the acidDamageOp
|
||||
*/
|
||||
public boolean isAcidDamageOp() {
|
||||
return acidDamageOp;
|
||||
}
|
||||
/**
|
||||
* @return the allowChestDamage
|
||||
*/
|
||||
@ -823,12 +777,14 @@ public class Settings implements DataObject, WorldSettings {
|
||||
/**
|
||||
* @return the endGenerate
|
||||
*/
|
||||
@Override
|
||||
public boolean isEndGenerate() {
|
||||
return endGenerate;
|
||||
}
|
||||
/**
|
||||
* @return the endIslands
|
||||
*/
|
||||
@Override
|
||||
public boolean isEndIslands() {
|
||||
return endIslands;
|
||||
}
|
||||
@ -937,42 +893,6 @@ public class Settings implements DataObject, WorldSettings {
|
||||
public boolean isUseOwnGenerator() {
|
||||
return useOwnGenerator;
|
||||
}
|
||||
/**
|
||||
* @param acidDamage the acidDamage to set
|
||||
*/
|
||||
public void setAcidDamage(int acidDamage) {
|
||||
this.acidDamage = acidDamage;
|
||||
}
|
||||
/**
|
||||
* @param acidDamageChickens the acidDamageChickens to set
|
||||
*/
|
||||
public void setAcidDamageChickens(boolean acidDamageChickens) {
|
||||
this.acidDamageChickens = acidDamageChickens;
|
||||
}
|
||||
/**
|
||||
* @param acidDamageOp the acidDamageOp to set
|
||||
*/
|
||||
public void setAcidDamageOp(boolean acidDamageOp) {
|
||||
this.acidDamageOp = acidDamageOp;
|
||||
}
|
||||
/**
|
||||
* @param acidDestroyItemTime the acidDestroyItemTime to set
|
||||
*/
|
||||
public void setAcidDestroyItemTime(int acidDestroyItemTime) {
|
||||
this.acidDestroyItemTime = acidDestroyItemTime;
|
||||
}
|
||||
/**
|
||||
* @param acidEffects the acidEffects to set
|
||||
*/
|
||||
public void setAcidEffects(List<PotionEffectType> acidEffects) {
|
||||
this.acidEffects = acidEffects;
|
||||
}
|
||||
/**
|
||||
* @param acidRainDamage the acidRainDamage to set
|
||||
*/
|
||||
public void setAcidRainDamage(int acidRainDamage) {
|
||||
this.acidRainDamage = acidRainDamage;
|
||||
}
|
||||
/**
|
||||
* @param allowChestDamage the allowChestDamage to set
|
||||
*/
|
||||
@ -1436,6 +1356,7 @@ public class Settings implements DataObject, WorldSettings {
|
||||
/**
|
||||
* @return the dragonSpawn
|
||||
*/
|
||||
@Override
|
||||
public boolean isDragonSpawn() {
|
||||
return dragonSpawn;
|
||||
}
|
||||
@ -1466,7 +1387,7 @@ public class Settings implements DataObject, WorldSettings {
|
||||
public void setIvSettings(List<String> ivSettings) {
|
||||
this.ivSettings = ivSettings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the worldFlags
|
||||
*/
|
||||
@ -1495,5 +1416,19 @@ public class Settings implements DataObject, WorldSettings {
|
||||
public void setClosePanelOnClickOutside(boolean closePanelOnClickOutside) {
|
||||
this.closePanelOnClickOutside = closePanelOnClickOutside;
|
||||
}
|
||||
/**
|
||||
* @return the defaultGameMode
|
||||
*/
|
||||
@Override
|
||||
public GameMode getDefaultGameMode() {
|
||||
return defaultGameMode;
|
||||
}
|
||||
/**
|
||||
* @param defaultGameMode the defaultGameMode to set
|
||||
*/
|
||||
public void setDefaultGameMode(GameMode defaultGameMode) {
|
||||
this.defaultGameMode = defaultGameMode;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -97,24 +97,6 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
|
||||
private static Map<User, Confirmer> toBeConfirmed = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Used only for testing....
|
||||
*/
|
||||
public CompositeCommand(BSkyBlock plugin, String label, String... string) {
|
||||
super(label);
|
||||
this.plugin = plugin;
|
||||
setAliases(new ArrayList<>(Arrays.asList(string)));
|
||||
parent = null;
|
||||
setUsage("");
|
||||
subCommandLevel = 0; // Top level
|
||||
subCommands = new LinkedHashMap<>();
|
||||
subCommandAliases = new LinkedHashMap<>();
|
||||
setup();
|
||||
if (!getSubCommand("help").isPresent() && !label.equals("help")) {
|
||||
new DefaultHelpCommand(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Top level command
|
||||
* @param addon - addon creating the command
|
||||
@ -122,17 +104,8 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
* @param aliases - aliases
|
||||
*/
|
||||
public CompositeCommand(Addon addon, String label, String... aliases) {
|
||||
this(label, aliases);
|
||||
this.addon = addon;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the top-level command constructor for commands that have no parent.
|
||||
* @param label - string for this command
|
||||
* @param aliases - aliases for this command
|
||||
*/
|
||||
public CompositeCommand(String label, String... aliases) {
|
||||
super(label);
|
||||
this.addon = addon;
|
||||
this.topLabel = label;
|
||||
this.plugin = BSkyBlock.getInstance();
|
||||
setAliases(new ArrayList<>(Arrays.asList(aliases)));
|
||||
@ -143,7 +116,8 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
subCommandAliases = new LinkedHashMap<>();
|
||||
// Register command if it is not already registered
|
||||
if (plugin.getCommand(label) == null) {
|
||||
plugin.getCommandsManager().registerCommand(this);
|
||||
plugin.getCommandsManager()
|
||||
.registerCommand(this);
|
||||
}
|
||||
setup();
|
||||
if (!getSubCommand("help").isPresent() && !label.equals("help")) {
|
||||
@ -151,6 +125,15 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the top-level command constructor for commands that have no parent.
|
||||
* @param label - string for this command
|
||||
* @param aliases - aliases for this command
|
||||
*/
|
||||
public CompositeCommand(String label, String... aliases) {
|
||||
this((Addon)null, label, aliases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sub-command constructor
|
||||
* @param parent - the parent composite command
|
||||
@ -333,7 +316,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
}
|
||||
// Try aliases
|
||||
if (subCommandAliases.containsKey(label.toLowerCase())) {
|
||||
return Optional.ofNullable(subCommandAliases.get(label));
|
||||
return Optional.ofNullable(subCommandAliases.get(label));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
@ -434,7 +417,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
*/
|
||||
public void inheritPermission() {
|
||||
this.permission = parent.getPermission();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This creates the full linking chain of commands
|
||||
@ -518,7 +501,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the permission prefix. This will be added automatically to the permission
|
||||
* Set the permission prefix. This will be added automatically to the permission
|
||||
* and will apply to any sub commands too.
|
||||
* Do not put a dot on the end of it.
|
||||
* @param permissionPrefix the permissionPrefix to set
|
||||
@ -584,7 +567,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
user.sendMessage("general.request-cancelled");
|
||||
toBeConfirmed.remove(user);
|
||||
}, getPlugin().getSettings().getConfirmationTime() * 20L);
|
||||
|
||||
|
||||
// Add to the global confirmation map
|
||||
toBeConfirmed.put(user, new Confirmer(getTopLabel(), getLabel(), confirmed, task));
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package us.tastybento.bskyblock.api.configuration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
/**
|
||||
@ -11,7 +12,7 @@ import org.bukkit.entity.EntityType;
|
||||
*
|
||||
*/
|
||||
public interface WorldSettings {
|
||||
|
||||
|
||||
/**
|
||||
* @return the friendly name of the world. Used in player commands
|
||||
*/
|
||||
@ -21,7 +22,7 @@ public interface WorldSettings {
|
||||
* @return the entityLimits
|
||||
*/
|
||||
Map<EntityType, Integer> getEntityLimits();
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandDistance
|
||||
*/
|
||||
@ -31,77 +32,77 @@ public interface WorldSettings {
|
||||
* @return the islandHeight
|
||||
*/
|
||||
int getIslandHeight();
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandProtectionRange
|
||||
*/
|
||||
int getIslandProtectionRange();
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandStartX
|
||||
*/
|
||||
int getIslandStartX();
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandStartZ
|
||||
*/
|
||||
int getIslandStartZ();
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandXOffset
|
||||
*/
|
||||
int getIslandXOffset();
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandZOffset
|
||||
*/
|
||||
int getIslandZOffset();
|
||||
|
||||
|
||||
/**
|
||||
* @return the maxIslands
|
||||
*/
|
||||
int getMaxIslands();
|
||||
|
||||
|
||||
/**
|
||||
* @return the netherSpawnRadius
|
||||
*/
|
||||
int getNetherSpawnRadius();
|
||||
|
||||
|
||||
/**
|
||||
* @return the seaHeight
|
||||
*/
|
||||
int getSeaHeight();
|
||||
|
||||
|
||||
/**
|
||||
* @return the tileEntityLimits
|
||||
*/
|
||||
Map<String, Integer> getTileEntityLimits();
|
||||
|
||||
|
||||
/**
|
||||
* @return the worldName
|
||||
*/
|
||||
String getWorldName();
|
||||
|
||||
|
||||
/**
|
||||
* @return the endGenerate
|
||||
*/
|
||||
boolean isEndGenerate();
|
||||
|
||||
|
||||
/**
|
||||
* @return the endIslands
|
||||
*/
|
||||
boolean isEndIslands();
|
||||
|
||||
|
||||
/**
|
||||
* @return the netherGenerate
|
||||
*/
|
||||
boolean isNetherGenerate();
|
||||
|
||||
|
||||
/**
|
||||
* @return the netherIslands
|
||||
*/
|
||||
boolean isNetherIslands();
|
||||
|
||||
|
||||
/**
|
||||
* @return the netherTrees
|
||||
*/
|
||||
@ -137,5 +138,11 @@ public interface WorldSettings {
|
||||
* @return Map of world flags
|
||||
*/
|
||||
Map<String, Boolean> getWorldFlags();
|
||||
|
||||
|
||||
/**
|
||||
* Get the default game mode for this game world, e.g. SURVIVAL
|
||||
* @return game mode
|
||||
*/
|
||||
GameMode getDefaultGameMode();
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ public class AdminInfoCommand extends CompositeCommand {
|
||||
}
|
||||
// If there are no args, then the player wants info on the island at this location
|
||||
if (args.isEmpty()) {
|
||||
getPlugin().log("DEBUG: getting info - no args");
|
||||
if (!getIslands().getIslandAt(user.getLocation()).map(i -> i.showInfo(getPlugin(), user, getWorld())).orElse(false)) {
|
||||
user.sendMessage("commands.admin.info.no-island");
|
||||
return false;
|
||||
@ -46,8 +45,8 @@ public class AdminInfoCommand extends CompositeCommand {
|
||||
user.sendMessage("general.errors.player-has-no-island");
|
||||
return false;
|
||||
}
|
||||
// Show info for this player
|
||||
getIslands().getIsland(getWorld(), targetUUID).showInfo(getPlugin(), user, getWorld());
|
||||
// Show info for this player
|
||||
getIslands().getIsland(getWorld(), targetUUID).showInfo(getPlugin(), user, getWorld());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
|
||||
public class IslandTeamInviteAcceptCommand extends CompositeCommand {
|
||||
|
||||
|
||||
private IslandTeamCommand itc;
|
||||
|
||||
public IslandTeamInviteAcceptCommand(IslandTeamCommand islandTeamCommand) {
|
||||
@ -89,7 +89,7 @@ public class IslandTeamInviteAcceptCommand extends CompositeCommand {
|
||||
getPlayers().setDeaths(playerUUID, 0);
|
||||
}
|
||||
// Put player back into normal mode
|
||||
user.setGameMode(GameMode.SURVIVAL);
|
||||
user.setGameMode(getIWM().getDefaultGameMode(getWorld()));
|
||||
|
||||
user.sendMessage("commands.island.team.invite.accept.you-joined-island", TextVariables.LABEL, getTopLabel());
|
||||
User inviter = User.getInstance(itc.getInviteCommand().getInviteList().get(playerUUID));
|
||||
|
@ -7,6 +7,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
@ -162,7 +163,7 @@ public class IslandWorldManager {
|
||||
.filter(w -> !plugin.getIslands().hasIsland(w.getKey(), user))
|
||||
.map(Map.Entry::getValue).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a name is a known friendly world name, ignores case
|
||||
* @param name - world name
|
||||
@ -183,7 +184,7 @@ public class IslandWorldManager {
|
||||
worldSettings.put(world, settings);
|
||||
multiverseReg(world);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the settings for this world or sub-worlds (nether, end)
|
||||
* @param world - world
|
||||
@ -208,7 +209,7 @@ public class IslandWorldManager {
|
||||
public Map<EntityType, Integer> getEntityLimits(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getEntityLimits();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandDistance
|
||||
*/
|
||||
@ -222,98 +223,98 @@ public class IslandWorldManager {
|
||||
public int getIslandHeight(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getIslandHeight();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandProtectionRange
|
||||
*/
|
||||
public int getIslandProtectionRange(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getIslandProtectionRange();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandStartX
|
||||
*/
|
||||
public int getIslandStartX(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getIslandStartX();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandStartZ
|
||||
*/
|
||||
public int getIslandStartZ(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getIslandStartZ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandXOffset
|
||||
*/
|
||||
public int getIslandXOffset(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getIslandXOffset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the islandZOffset
|
||||
*/
|
||||
public int getIslandZOffset(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getIslandZOffset();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the maxIslands
|
||||
*/
|
||||
public int getMaxIslands(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getMaxIslands();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the netherSpawnRadius
|
||||
*/
|
||||
public int getNetherSpawnRadius(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getNetherSpawnRadius();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the seaHeight
|
||||
*/
|
||||
public int getSeaHeight(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getSeaHeight();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the tileEntityLimits
|
||||
*/
|
||||
public Map<String, Integer> getTileEntityLimits(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getTileEntityLimits();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the worldName
|
||||
*/
|
||||
public String getWorldName(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getWorldName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the endGenerate
|
||||
*/
|
||||
public boolean isEndGenerate(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).isEndGenerate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the endIslands
|
||||
*/
|
||||
public boolean isEndIslands(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).isEndIslands();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the netherGenerate
|
||||
*/
|
||||
public boolean isNetherGenerate(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).isNetherGenerate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the netherIslands
|
||||
*/
|
||||
@ -330,7 +331,7 @@ public class IslandWorldManager {
|
||||
World w = Util.getWorld(world);
|
||||
return worldSettings.containsKey(w) && worldSettings.get(w).isNetherGenerate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a world is a known island nether world
|
||||
* @param world - world
|
||||
@ -350,7 +351,7 @@ public class IslandWorldManager {
|
||||
World w = Util.getWorld(world);
|
||||
return worldSettings.containsKey(w) && worldSettings.get(w).isEndGenerate();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a world is a known island end world
|
||||
* @param world - world
|
||||
@ -437,7 +438,7 @@ public class IslandWorldManager {
|
||||
public int getMaxHomes(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getMaxHomes();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the friendly name for world or related nether or end
|
||||
* @param world - world
|
||||
@ -454,7 +455,7 @@ public class IslandWorldManager {
|
||||
*/
|
||||
public String getPermissionPrefix(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getPermissionPrefix();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -477,4 +478,12 @@ public class IslandWorldManager {
|
||||
return flag.isSetForWorld(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default game mode for this world.
|
||||
* @param world - world
|
||||
* @return GameMode: SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR
|
||||
*/
|
||||
public GameMode getDefaultGameMode(World world) {
|
||||
return worldSettings.get(Util.getWorld(world)).getDefaultGameMode();
|
||||
}
|
||||
}
|
||||
|
@ -74,11 +74,6 @@ public class IslandsManager {
|
||||
|| space1.getType() == Material.ENDER_PORTAL || ground.getType() == Material.ENDER_PORTAL || space2.getType() == Material.ENDER_PORTAL) {
|
||||
return false;
|
||||
}
|
||||
// In BSkyBlock, liquid may be unsafe
|
||||
// Check if acid has no damage
|
||||
if (plugin.getSettings().getAcidDamage() > 0D && (ground.isLiquid() || space1.isLiquid() || space2.isLiquid())) {
|
||||
return false;
|
||||
}
|
||||
if (ground.getType().equals(Material.STATIONARY_LAVA) || ground.getType().equals(Material.LAVA)
|
||||
|| space1.getType().equals(Material.STATIONARY_LAVA) || space1.getType().equals(Material.LAVA)
|
||||
|| space2.getType().equals(Material.STATIONARY_LAVA) || space2.getType().equals(Material.LAVA)) {
|
||||
@ -340,7 +335,7 @@ public class IslandsManager {
|
||||
/**
|
||||
* Determines a safe teleport spot on player's island or the team island
|
||||
* they belong to.
|
||||
*
|
||||
*
|
||||
* @param world - world to check
|
||||
* @param user - the player
|
||||
* @param number - a number - starting home location e.g., 1
|
||||
@ -362,11 +357,11 @@ public class IslandsManager {
|
||||
// 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
|
||||
plugin.getPlayers().setHomeLocation(user, lPlusOne, number);
|
||||
return lPlusOne;
|
||||
}
|
||||
if (isSafeLocation(lPlusOne)) {
|
||||
// Adjust the home location accordingly
|
||||
plugin.getPlayers().setHomeLocation(user, lPlusOne, number);
|
||||
return lPlusOne;
|
||||
}
|
||||
}
|
||||
// Home location either isn't safe, or does not exist so try the island
|
||||
// location
|
||||
@ -517,7 +512,7 @@ public class IslandsManager {
|
||||
}
|
||||
// Exit spectator mode if in it
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setGameMode(plugin.getIWM().getDefaultGameMode(world));
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,7 +628,7 @@ public class IslandsManager {
|
||||
|
||||
/**
|
||||
* Checks if an online player is in the protected area of their island, a team island or a
|
||||
* coop island in the specific world in the arguments. Note that the user
|
||||
* coop island in the specific world in the arguments. Note that the user
|
||||
*
|
||||
* @param world - the world to check
|
||||
* @param user - the user
|
||||
|
@ -110,7 +110,7 @@ public class SafeSpotTeleport {
|
||||
entity.sendMessage(failureMessage);
|
||||
}
|
||||
if (entity instanceof Player && ((Player)entity).getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
((Player)entity).setGameMode(GameMode.SURVIVAL);
|
||||
((Player)entity).setGameMode(plugin.getIWM().getDefaultGameMode(bestSpot.getWorld()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,13 +152,13 @@ public class SafeSpotTeleport {
|
||||
if (is.inIslandSpace(blockCoord)) {
|
||||
result.add(chunkCoord);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loops through the chunks and if a safe spot is found, fires off the teleportation
|
||||
* Loops through the chunks and if a safe spot is found, fires off the teleportation
|
||||
* @param chunkSnapshot - list of chunk snapshots to check
|
||||
*/
|
||||
private void checkChunks(final List<ChunkSnapshot> chunkSnapshot) {
|
||||
@ -180,7 +180,7 @@ public class SafeSpotTeleport {
|
||||
* @param chunk - chunk snapshot
|
||||
* @return true if a safe spot was found
|
||||
*/
|
||||
private boolean scanChunk(ChunkSnapshot chunk) {
|
||||
private boolean scanChunk(ChunkSnapshot chunk) {
|
||||
// Max height
|
||||
int maxHeight = location.getWorld().getMaxHeight() - 20;
|
||||
// Run through the chunk
|
||||
@ -214,7 +214,7 @@ public class SafeSpotTeleport {
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player)entity;
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setGameMode(plugin.getIWM().getDefaultGameMode(loc.getWorld()));
|
||||
}
|
||||
} else {
|
||||
entity.setVelocity(velocity);
|
||||
|
@ -59,6 +59,7 @@ import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
import us.tastybento.bskyblock.listeners.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
import us.tastybento.bskyblock.managers.CommandsManager;
|
||||
import us.tastybento.bskyblock.managers.FlagsManager;
|
||||
import us.tastybento.bskyblock.managers.IslandWorldManager;
|
||||
import us.tastybento.bskyblock.managers.IslandsManager;
|
||||
@ -80,11 +81,12 @@ public class TestBSkyBlock {
|
||||
private static Block block;
|
||||
private static Player ownerOfIsland;
|
||||
private static Player visitorToIsland;
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() {
|
||||
public static void setUpBeforeClass() {
|
||||
// Set up plugin
|
||||
plugin = mock(BSkyBlock.class);
|
||||
when(plugin.getCommandsManager()).thenReturn(mock(CommandsManager.class));
|
||||
Whitebox.setInternalState(BSkyBlock.class, "instance", plugin);
|
||||
|
||||
Server server = mock(Server.class);
|
||||
@ -92,25 +94,25 @@ public class TestBSkyBlock {
|
||||
Mockito.when(server.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
Mockito.when(server.getWorld("world")).thenReturn(world);
|
||||
Mockito.when(server.getVersion()).thenReturn("BSB_Mocking");
|
||||
|
||||
|
||||
PluginManager pluginManager = mock(PluginManager.class);
|
||||
when(server.getPluginManager()).thenReturn(pluginManager);
|
||||
|
||||
|
||||
ItemFactory itemFactory = mock(ItemFactory.class);
|
||||
when(server.getItemFactory()).thenReturn(itemFactory);
|
||||
|
||||
|
||||
Bukkit.setServer(server);
|
||||
|
||||
|
||||
SkullMeta skullMeta = mock(SkullMeta.class);
|
||||
when(itemFactory.getItemMeta(any())).thenReturn(skullMeta);
|
||||
|
||||
|
||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||
when(offlinePlayer.getName()).thenReturn("tastybento");
|
||||
|
||||
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
|
||||
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
|
||||
|
||||
sender = mock(CommandSender.class);
|
||||
player = mock(Player.class);
|
||||
ownerOfIsland = mock(Player.class);
|
||||
@ -162,16 +164,12 @@ public class TestBSkyBlock {
|
||||
members.put(OWNER_UUID, RanksManager.OWNER_RANK);
|
||||
members.put(MEMBER_UUID, RanksManager.MEMBER_RANK);
|
||||
island.setMembers(members);
|
||||
Bukkit.getLogger().info("SETUP: owner UUID = " + OWNER_UUID);
|
||||
Bukkit.getLogger().info("SETUP: member UUID = " + MEMBER_UUID);
|
||||
Bukkit.getLogger().info("SETUP: visitor UUID = " + VISITOR_UUID);
|
||||
Mockito.when(im.getIslandAt(Matchers.any())).thenReturn(Optional.of(island));
|
||||
when(im.getProtectedIslandAt(Mockito.any())).thenReturn(Optional.of(island));
|
||||
|
||||
Settings settings = mock(Settings.class);
|
||||
Mockito.when(plugin.getSettings()).thenReturn(settings);
|
||||
Mockito.when(settings.getFakePlayers()).thenReturn(new HashSet<>());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -252,7 +250,7 @@ public class TestBSkyBlock {
|
||||
private class TestCommand extends CompositeCommand {
|
||||
|
||||
public TestCommand() {
|
||||
super(plugin, "test", "t", "tt");
|
||||
super("test", "t", "tt");
|
||||
setParameters("test.params");
|
||||
}
|
||||
|
||||
@ -354,7 +352,7 @@ public class TestBSkyBlock {
|
||||
private class Test3ArgsCommand extends CompositeCommand {
|
||||
|
||||
public Test3ArgsCommand() {
|
||||
super(plugin, "args", "");
|
||||
super("args", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,7 +100,7 @@ public class IslandsManagerTest {
|
||||
// Set up user already
|
||||
User.getInstance(player);
|
||||
|
||||
// Locales
|
||||
// Locales
|
||||
LocalesManager lm = mock(LocalesManager.class);
|
||||
when(plugin.getLocalesManager()).thenReturn(lm);
|
||||
when(lm.get(any(), any())).thenReturn("mock translation");
|
||||
@ -118,7 +118,7 @@ public class IslandsManagerTest {
|
||||
|
||||
// Standard location
|
||||
manager = new IslandsManager(plugin);
|
||||
location = mock(Location.class);
|
||||
location = mock(Location.class);
|
||||
when(location.getWorld()).thenReturn(world);
|
||||
space1 = mock(Block.class);
|
||||
ground = mock(Block.class);
|
||||
@ -148,7 +148,7 @@ public class IslandsManagerTest {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Worlds
|
||||
iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
@ -156,10 +156,10 @@ public class IslandsManagerTest {
|
||||
when(iwm.getNetherWorld()).thenReturn(world);
|
||||
when(iwm.getEndWorld()).thenReturn(world);
|
||||
when(iwm.inWorld(any())).thenReturn(true);
|
||||
|
||||
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
when(Util.getWorld(Mockito.any())).thenReturn(world);
|
||||
|
||||
|
||||
// Scheduler
|
||||
when(Bukkit.getScheduler()).thenReturn(mock(BukkitScheduler.class));
|
||||
}
|
||||
@ -188,7 +188,7 @@ public class IslandsManagerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testIsSafeLocationNonSolidGround() {
|
||||
when(ground.getType()).thenReturn(Material.WATER);
|
||||
when(ground.getType()).thenReturn(Material.WATER);
|
||||
assertFalse(manager.isSafeLocation(location));
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ public class IslandsManagerTest {
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#isSafeLocation(org.bukkit.Location)}.
|
||||
*/
|
||||
@Test
|
||||
public void testIsSafeLocationPortals() {
|
||||
public void testIsSafeLocationPortals() {
|
||||
when(ground.getType()).thenReturn(Material.STONE);
|
||||
when(space1.getType()).thenReturn(Material.AIR);
|
||||
when(space2.getType()).thenReturn(Material.PORTAL);
|
||||
@ -234,31 +234,6 @@ public class IslandsManagerTest {
|
||||
assertFalse(manager.isSafeLocation(location));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#isSafeLocation(org.bukkit.Location)}.
|
||||
*/
|
||||
@Test
|
||||
public void testIsSafeLocationAcid() {
|
||||
when(ground.getType()).thenReturn(Material.GRASS);
|
||||
when(space1.getType()).thenReturn(Material.STATIONARY_WATER);
|
||||
when(space2.getType()).thenReturn(Material.AIR);
|
||||
|
||||
when(s.getAcidDamage()).thenReturn(10);
|
||||
|
||||
when(ground.isLiquid()).thenReturn(true);
|
||||
when(space1.isLiquid()).thenReturn(false);
|
||||
when(space2.isLiquid()).thenReturn(false);
|
||||
assertFalse("In acid", manager.isSafeLocation(location));
|
||||
when(ground.isLiquid()).thenReturn(false);
|
||||
when(space1.isLiquid()).thenReturn(true);
|
||||
when(space2.isLiquid()).thenReturn(false);
|
||||
assertFalse("In acid", manager.isSafeLocation(location));
|
||||
when(ground.isLiquid()).thenReturn(false);
|
||||
when(space1.isLiquid()).thenReturn(false);
|
||||
when(space2.isLiquid()).thenReturn(true);
|
||||
assertFalse("In acid", manager.isSafeLocation(location));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#isSafeLocation(org.bukkit.Location)}.
|
||||
*/
|
||||
@ -288,7 +263,7 @@ public class IslandsManagerTest {
|
||||
when(space1.getType()).thenReturn(Material.AIR);
|
||||
when(space2.getType()).thenReturn(Material.STATIONARY_LAVA);
|
||||
assertFalse("In lava", manager.isSafeLocation(location));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#isSafeLocation(org.bukkit.Location)}.
|
||||
@ -452,7 +427,7 @@ public class IslandsManagerTest {
|
||||
public void testDeleteIslandIslandBoolean() {
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
|
||||
im.deleteIsland((Island)null, true);
|
||||
im.deleteIsland((Island)null, true);
|
||||
UUID owner = UUID.randomUUID();
|
||||
Island island = im.createIsland(location, owner);
|
||||
im.deleteIsland(island, false);
|
||||
@ -486,7 +461,7 @@ public class IslandsManagerTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#getIslandAt(org.bukkit.Location)}.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testGetIslandAtLocation() throws Exception {
|
||||
@ -537,7 +512,7 @@ public class IslandsManagerTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#getMembers(java.util.UUID)}.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testGetMembers() throws Exception {
|
||||
@ -548,14 +523,14 @@ public class IslandsManagerTest {
|
||||
members.add(UUID.randomUUID());
|
||||
members.add(UUID.randomUUID());
|
||||
when(ic.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
||||
PowerMockito.whenNew(IslandCache.class).withAnyArguments().thenReturn(ic);
|
||||
PowerMockito.whenNew(IslandCache.class).withAnyArguments().thenReturn(ic);
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
assertEquals(members, im.getMembers(world, UUID.randomUUID()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#getProtectedIslandAt(org.bukkit.Location)}.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testGetProtectedIslandAt() throws Exception {
|
||||
@ -575,7 +550,7 @@ public class IslandsManagerTest {
|
||||
assertEquals(oi, im.getProtectedIslandAt(location));
|
||||
|
||||
// Not in protected space
|
||||
when(is.onIsland(Mockito.any())).thenReturn(false);
|
||||
when(is.onIsland(Mockito.any())).thenReturn(false);
|
||||
assertEquals(Optional.empty(), im.getProtectedIslandAt(location));
|
||||
|
||||
im.setSpawn(is);
|
||||
@ -584,7 +559,7 @@ public class IslandsManagerTest {
|
||||
assertEquals(oi, im.getProtectedIslandAt(location));
|
||||
|
||||
// Not in protected space
|
||||
when(is.onIsland(Mockito.any())).thenReturn(false);
|
||||
when(is.onIsland(Mockito.any())).thenReturn(false);
|
||||
assertEquals(Optional.empty(), im.getProtectedIslandAt(location));
|
||||
}
|
||||
|
||||
@ -623,6 +598,7 @@ public class IslandsManagerTest {
|
||||
*/
|
||||
@Test
|
||||
public void testHomeTeleportPlayerInt() {
|
||||
when(iwm.getDefaultGameMode(world)).thenReturn(GameMode.SURVIVAL);
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
when(pm.getHomeLocation(Mockito.any(), Mockito.any(User.class), Mockito.eq(0))).thenReturn(null);
|
||||
when(pm.getHomeLocation(Mockito.any(), Mockito.any(User.class), Mockito.eq(1))).thenReturn(location);
|
||||
@ -633,6 +609,22 @@ public class IslandsManagerTest {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#homeTeleport(org.bukkit.entity.Player, int)}.
|
||||
*/
|
||||
@Test
|
||||
public void testHomeTeleportPlayerIntDifferentGameMode() {
|
||||
when(iwm.getDefaultGameMode(world)).thenReturn(GameMode.CREATIVE);
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
when(pm.getHomeLocation(Mockito.any(), Mockito.any(User.class), Mockito.eq(0))).thenReturn(null);
|
||||
when(pm.getHomeLocation(Mockito.any(), Mockito.any(User.class), Mockito.eq(1))).thenReturn(location);
|
||||
when(player.getGameMode()).thenReturn(GameMode.SPECTATOR);
|
||||
im.homeTeleport(world, player, 0);
|
||||
Mockito.verify(player).teleport(location);
|
||||
Mockito.verify(player).setGameMode(GameMode.CREATIVE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#isAtSpawn(org.bukkit.Location)}.
|
||||
*/
|
||||
@ -649,7 +641,7 @@ public class IslandsManagerTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#isIsland(org.bukkit.Location)}.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testIsIsland() throws Exception {
|
||||
@ -679,7 +671,7 @@ public class IslandsManagerTest {
|
||||
// Location
|
||||
when(location.getWorld()).thenReturn(world);
|
||||
when(location.getBlockX()).thenReturn(10);
|
||||
when(location.getBlockZ()).thenReturn(10);
|
||||
when(location.getBlockZ()).thenReturn(10);
|
||||
when(location.getBlock()).thenReturn(space1);
|
||||
|
||||
PowerMockito.whenNew(Location.class).withAnyArguments().thenReturn(location);
|
||||
@ -693,7 +685,7 @@ public class IslandsManagerTest {
|
||||
when(space1.isLiquid()).thenReturn(true);
|
||||
assertTrue(im.isIsland(location));
|
||||
|
||||
// Empty space
|
||||
// Empty space
|
||||
when(space1.isEmpty()).thenReturn(true);
|
||||
when(space1.isLiquid()).thenReturn(false);
|
||||
assertTrue(im.isIsland(location));
|
||||
@ -702,7 +694,7 @@ public class IslandsManagerTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#getClosestIsland(org.bukkit.Location)}.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testGetClosestIsland() throws Exception {
|
||||
@ -720,7 +712,7 @@ public class IslandsManagerTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#isOwner(java.util.UUID)}.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testIsOwner() throws Exception {
|
||||
@ -757,12 +749,12 @@ public class IslandsManagerTest {
|
||||
public void testLoad() {
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
im.load();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#locationIsOnIsland(org.bukkit.entity.Player, org.bukkit.Location)}.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testLocationIsOnIsland() throws Exception {
|
||||
@ -776,23 +768,23 @@ public class IslandsManagerTest {
|
||||
|
||||
// In world
|
||||
when(is.onIsland(Mockito.any())).thenReturn(true);
|
||||
|
||||
|
||||
Builder<UUID> members = new ImmutableSet.Builder<>();
|
||||
members.add(uuid);
|
||||
when(is.getMemberSet()).thenReturn(members.build());
|
||||
|
||||
when(player.getUniqueId()).thenReturn(uuid);
|
||||
|
||||
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
assertFalse(im.locationIsOnIsland(null, null));
|
||||
|
||||
|
||||
assertTrue(im.locationIsOnIsland(player, location));
|
||||
|
||||
|
||||
// No members
|
||||
Builder<UUID> mem = new ImmutableSet.Builder<>();
|
||||
when(is.getMemberSet()).thenReturn(mem.build());
|
||||
assertFalse(im.locationIsOnIsland(player, location));
|
||||
|
||||
|
||||
// Not on island
|
||||
when(is.getMemberSet()).thenReturn(members.build());
|
||||
when(is.onIsland(Mockito.any())).thenReturn(false);
|
||||
@ -801,7 +793,7 @@ public class IslandsManagerTest {
|
||||
|
||||
/**
|
||||
* Test method for {@link us.tastybento.bskyblock.managers.IslandsManager#userIsOnIsland(us.tastybento.bskyblock.api.user.User)}.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testUserIsOnIsland() throws Exception {
|
||||
@ -815,12 +807,12 @@ public class IslandsManagerTest {
|
||||
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
assertFalse(im.userIsOnIsland(world, null));
|
||||
|
||||
|
||||
when(is.onIsland(Mockito.any())).thenReturn(false);
|
||||
assertFalse(im.userIsOnIsland(world, user));
|
||||
|
||||
|
||||
when(is.onIsland(Mockito.any())).thenReturn(true);
|
||||
assertTrue(im.userIsOnIsland(world, user));
|
||||
assertTrue(im.userIsOnIsland(world, user));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user