mirror of
https://github.com/BentoBoxWorld/AcidIsland.git
synced 2024-11-26 04:36:00 +01:00
Updated to BentoBox 1.13.0 API
This commit is contained in:
parent
0cdb761ecd
commit
2195a428d7
@ -34,6 +34,27 @@ public class AISettings implements WorldSettings {
|
||||
|
||||
// ---------------------------------------------
|
||||
|
||||
// Command
|
||||
@ConfigComment("Island Command. What command users will run to access their island")
|
||||
@ConfigEntry(path = "acid.command.island")
|
||||
private String playerCommandAliases = "ai";
|
||||
|
||||
@ConfigComment("The island admin command.")
|
||||
@ConfigEntry(path = "acid.command.admin")
|
||||
private String adminCommandAliases = "acid";
|
||||
|
||||
@ConfigComment("The default action for new player command call.")
|
||||
@ConfigComment("Sub-command of main player command that will be run on first player command call.")
|
||||
@ConfigComment("By default it is sub-command 'create'.")
|
||||
@ConfigEntry(path = "acid.command.new-player-action", since = "1.13.1")
|
||||
private String defaultNewPlayerAction = "create";
|
||||
|
||||
@ConfigComment("The default action for player command.")
|
||||
@ConfigComment("Sub-command of main player command that will be run on each player command call.")
|
||||
@ConfigComment("By default it is sub-command 'go'.")
|
||||
@ConfigEntry(path = "acid.command.default-action", since = "1.13.1")
|
||||
private String defaultPlayerAction = "go";
|
||||
|
||||
/* ACID */
|
||||
@ConfigComment("Acid can damage ops or not")
|
||||
@ConfigEntry(path = "acid.damage-op")
|
||||
@ -43,19 +64,6 @@ public class AISettings implements WorldSettings {
|
||||
@ConfigEntry(path = "acid.damage-chickens")
|
||||
private boolean acidDamageChickens = false;
|
||||
|
||||
// Command
|
||||
@ConfigComment("Island Command. What command users will run to access their island")
|
||||
@ConfigEntry(path = "acid.command.island")
|
||||
private String islandCommand = "ai";
|
||||
|
||||
@ConfigComment("The island admin command.")
|
||||
@ConfigEntry(path = "acid.command.admin")
|
||||
|
||||
private String adminCommand = "acid";
|
||||
@ConfigComment("Use control panel if it exists (ControlPanel addon must be in addons)")
|
||||
@ConfigEntry(path = "acid.use-control-panel", since = "1.13.0")
|
||||
private boolean useControlPanel = false;
|
||||
|
||||
// Damage
|
||||
@ConfigComment("Damage that a player will experience in acid. 10 is half their health typically. 5 would be easier.")
|
||||
@ConfigEntry(path = "acid.damage.acid.player")
|
||||
@ -568,10 +576,7 @@ public class AISettings implements WorldSettings {
|
||||
public int getAcidRainDamage() {
|
||||
return acidRainDamage;
|
||||
}
|
||||
/**
|
||||
* @return the command for accessing your admin command
|
||||
*/
|
||||
public String getAdminCommand() { return adminCommand; }
|
||||
|
||||
@Override
|
||||
public int getBanLimit() {
|
||||
return banLimit;
|
||||
@ -644,10 +649,6 @@ public class AISettings implements WorldSettings {
|
||||
public List<String> getGeoLimitSettings() {
|
||||
return geoLimitSettings;
|
||||
}
|
||||
/**
|
||||
* @return the command for accessing your island
|
||||
*/
|
||||
public String getIslandCommand() { return islandCommand; }
|
||||
/**
|
||||
* @return the islandDistance
|
||||
*/
|
||||
@ -1071,7 +1072,7 @@ public class AISettings implements WorldSettings {
|
||||
/**
|
||||
* @param adminCommand what you want your admin command to be
|
||||
*/
|
||||
public void setAdminCommand(String adminCommand) { this.adminCommand = adminCommand; }
|
||||
public void setAdminCommand(String adminCommand) { this.adminCommandAliases = adminCommand; }
|
||||
/**
|
||||
* @param allowSetHomeInNether the allowSetHomeInNether to set
|
||||
*/
|
||||
@ -1185,7 +1186,7 @@ public class AISettings implements WorldSettings {
|
||||
/**
|
||||
* @param islandCommand what you want your island command to be
|
||||
*/
|
||||
public void setIslandCommand(String islandCommand) { this.islandCommand = islandCommand; }
|
||||
public void setIslandCommand(String islandCommand) { this.playerCommandAliases = islandCommand; }
|
||||
|
||||
/**
|
||||
* @param islandDistance the islandDistance to set
|
||||
@ -1709,18 +1710,6 @@ public class AISettings implements WorldSettings {
|
||||
public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) {
|
||||
this.ticksPerMonsterSpawns = ticksPerMonsterSpawns;
|
||||
}
|
||||
/**
|
||||
* @return the useControlPanel
|
||||
*/
|
||||
public boolean isUseControlPanel() {
|
||||
return useControlPanel;
|
||||
}
|
||||
/**
|
||||
* @param useControlPanel the useControlPanel to set
|
||||
*/
|
||||
public void setUseControlPanel(boolean useControlPanel) {
|
||||
this.useControlPanel = useControlPanel;
|
||||
}
|
||||
/**
|
||||
* @return the maxCoopSize
|
||||
*/
|
||||
@ -1750,4 +1739,56 @@ public class AISettings implements WorldSettings {
|
||||
public void setMaxTrustSize(int maxTrustSize) {
|
||||
this.maxTrustSize = maxTrustSize;
|
||||
}
|
||||
/**
|
||||
* @return the playerCommandAliases
|
||||
*/
|
||||
@Override
|
||||
public String getPlayerCommandAliases() {
|
||||
return playerCommandAliases;
|
||||
}
|
||||
/**
|
||||
* @param playerCommandAliases the playerCommandAliases to set
|
||||
*/
|
||||
public void setPlayerCommandAliases(String playerCommandAliases) {
|
||||
this.playerCommandAliases = playerCommandAliases;
|
||||
}
|
||||
/**
|
||||
* @return the adminCommandAliases
|
||||
*/
|
||||
@Override
|
||||
public String getAdminCommandAliases() {
|
||||
return adminCommandAliases;
|
||||
}
|
||||
/**
|
||||
* @param adminCommandAliases the adminCommandAliases to set
|
||||
*/
|
||||
public void setAdminCommandAliases(String adminCommandAliases) {
|
||||
this.adminCommandAliases = adminCommandAliases;
|
||||
}
|
||||
/**
|
||||
* @return the defaultNewPlayerAction
|
||||
*/
|
||||
@Override
|
||||
public String getDefaultNewPlayerAction() {
|
||||
return defaultNewPlayerAction;
|
||||
}
|
||||
/**
|
||||
* @param defaultNewPlayerAction the defaultNewPlayerAction to set
|
||||
*/
|
||||
public void setDefaultNewPlayerAction(String defaultNewPlayerAction) {
|
||||
this.defaultNewPlayerAction = defaultNewPlayerAction;
|
||||
}
|
||||
/**
|
||||
* @return the defaultPlayerAction
|
||||
*/
|
||||
@Override
|
||||
public String getDefaultPlayerAction() {
|
||||
return defaultPlayerAction;
|
||||
}
|
||||
/**
|
||||
* @param defaultPlayerAction the defaultPlayerAction to set
|
||||
*/
|
||||
public void setDefaultPlayerAction(String defaultPlayerAction) {
|
||||
this.defaultPlayerAction = defaultPlayerAction;
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,21 @@
|
||||
package world.bentobox.acidisland;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.acidisland.commands.AcidCommand;
|
||||
import world.bentobox.acidisland.commands.AiCommand;
|
||||
import world.bentobox.acidisland.commands.IslandAboutCommand;
|
||||
import world.bentobox.acidisland.listeners.AcidEffect;
|
||||
import world.bentobox.acidisland.listeners.LavaCheck;
|
||||
import world.bentobox.acidisland.world.AcidTask;
|
||||
import world.bentobox.acidisland.world.ChunkGeneratorWorld;
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
import world.bentobox.bentobox.api.commands.admin.DefaultAdminCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.DefaultPlayerCommand;
|
||||
import world.bentobox.bentobox.api.configuration.Config;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
@ -43,8 +44,18 @@ public class AcidIsland extends GameModeAddon {
|
||||
// Chunk generator
|
||||
chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this);
|
||||
// Register commands
|
||||
adminCommand = new AcidCommand(this, settings.getAdminCommand());
|
||||
playerCommand = new AiCommand(this, settings.getIslandCommand());
|
||||
// Register commands
|
||||
playerCommand = new DefaultPlayerCommand(this)
|
||||
|
||||
{
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
super.setup();
|
||||
new IslandAboutCommand(this);
|
||||
}
|
||||
};
|
||||
adminCommand = new DefaultAdminCommand(this) {};
|
||||
}
|
||||
|
||||
private boolean loadSettings() {
|
||||
|
@ -1,103 +0,0 @@
|
||||
package world.bentobox.acidisland.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminDeleteCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminGetrankCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminInfoCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminRegisterCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminReloadCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminResetFlagsCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminSetrankCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminSetspawnCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminSettingsCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminSwitchCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminTeleportCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminUnregisterCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminVersionCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.AdminWhyCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.blueprints.AdminBlueprintCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.deaths.AdminDeathsCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.purge.AdminPurgeCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.range.AdminRangeCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.resets.AdminResetsCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamAddCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamDisbandCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamKickCommand;
|
||||
import world.bentobox.bentobox.api.commands.admin.team.AdminTeamSetownerCommand;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
||||
public class AcidCommand extends CompositeCommand {
|
||||
|
||||
public AcidCommand(Addon addon, String command) {
|
||||
super(addon, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
setPermission("admin");
|
||||
setOnlyPlayer(false);
|
||||
setParametersHelp("commands.admin.help.parameters");
|
||||
setDescription("commands.admin.help.description");
|
||||
|
||||
// Commands
|
||||
new AdminVersionCommand(this);
|
||||
new AdminTeleportCommand(this, "tp");
|
||||
new AdminTeleportCommand(this, "tpnether");
|
||||
new AdminTeleportCommand(this, "tpend");
|
||||
new AdminGetrankCommand(this);
|
||||
new AdminSetrankCommand(this);
|
||||
new AdminInfoCommand(this);
|
||||
// Team commands
|
||||
new AdminTeamAddCommand(this);
|
||||
new AdminTeamKickCommand(this);
|
||||
new AdminTeamDisbandCommand(this);
|
||||
new AdminTeamSetownerCommand(this);
|
||||
// Schems
|
||||
new AdminBlueprintCommand(this);
|
||||
// Register/unregister islands
|
||||
new AdminRegisterCommand(this);
|
||||
new AdminUnregisterCommand(this);
|
||||
// Range
|
||||
new AdminRangeCommand(this);
|
||||
// Resets
|
||||
new AdminResetsCommand(this);
|
||||
// Delete
|
||||
new AdminDeleteCommand(this);
|
||||
// Why
|
||||
new AdminWhyCommand(this);
|
||||
// Deaths
|
||||
new AdminDeathsCommand(this);
|
||||
// Reload
|
||||
new AdminReloadCommand(this);
|
||||
// Spawn
|
||||
new AdminSetspawnCommand(this);
|
||||
// Reset flags
|
||||
new AdminResetFlagsCommand(this);
|
||||
// Trash
|
||||
//new AdminTrashCommand(this);
|
||||
//new AdminEmptyTrashCommand(this);
|
||||
//new AdminSwitchtoCommand(this);
|
||||
// Switch
|
||||
new AdminSwitchCommand(this);
|
||||
// Purge
|
||||
new AdminPurgeCommand(this);
|
||||
// Settings
|
||||
new AdminSettingsCommand(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
if (!args.isEmpty()) {
|
||||
user.sendMessage("general.errors.unknown-command", TextVariables.LABEL, label);
|
||||
return false;
|
||||
}
|
||||
// By default run the attached help command, if it exists (it should)
|
||||
return showHelp(this, user);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package world.bentobox.acidisland.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import world.bentobox.acidisland.AcidIsland;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandBanCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandBanlistCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandCreateCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandExpelCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandGoCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandInfoCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandLanguageCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandNearCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandResetCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandResetnameCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandSethomeCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandSetnameCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandSettingsCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandSpawnCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.IslandUnbanCommand;
|
||||
import world.bentobox.bentobox.api.commands.island.team.IslandTeamCommand;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
||||
public class AiCommand extends CompositeCommand {
|
||||
|
||||
public AiCommand(Addon addon, String command) {
|
||||
super(addon, command);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see world.bentobox.bbox.api.commands.CompositeCommand#setup()
|
||||
*/
|
||||
@Override
|
||||
public void setup() {
|
||||
setDescription("commands.island.help.description");
|
||||
setOnlyPlayer(true);
|
||||
// Permission
|
||||
setPermission("island");
|
||||
// Set up subcommands
|
||||
new IslandAboutCommand(this);
|
||||
new IslandInfoCommand(this);
|
||||
new IslandCreateCommand(this);
|
||||
new IslandGoCommand(this);
|
||||
new IslandSpawnCommand(this);
|
||||
new IslandResetCommand(this);
|
||||
new IslandSetnameCommand(this);
|
||||
new IslandResetnameCommand(this);
|
||||
new IslandSethomeCommand(this);
|
||||
new IslandSettingsCommand(this);
|
||||
new IslandLanguageCommand(this);
|
||||
new IslandBanCommand(this);
|
||||
new IslandUnbanCommand(this);
|
||||
new IslandBanlistCommand(this);
|
||||
new IslandExpelCommand(this);
|
||||
new IslandNearCommand(this);
|
||||
// Team commands
|
||||
new IslandTeamCommand(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see world.bentobox.bbox.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
if (args.isEmpty()) {
|
||||
// If in world, go
|
||||
if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) != null) {
|
||||
if (((AcidIsland)getAddon()).getSettings().isUseControlPanel()
|
||||
&& getSubCommand("controlpanel").isPresent()) {
|
||||
return getSubCommand("controlpanel").get().call(user, label, new ArrayList<>());
|
||||
}
|
||||
return getSubCommand("go").map(goCmd -> goCmd.call(user, goCmd.getLabel(), new ArrayList<>())).orElse(false);
|
||||
}
|
||||
|
||||
// No islands currently
|
||||
return getSubCommand("create").map(createCmd -> createCmd.call(user, label, new ArrayList<>())).orElse(false);
|
||||
}
|
||||
user.sendMessage("general.errors.unknown-command", TextVariables.LABEL, getLabel());
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
name: AcidIsland
|
||||
main: world.bentobox.acidisland.AcidIsland
|
||||
version: ${version}${build.number}
|
||||
api-version: 1.13.0
|
||||
metrics: true
|
||||
repository: "BentoBoxWorld/AcidIsland"
|
||||
icon: "OAK_BOAT"
|
||||
|
@ -1,16 +1,24 @@
|
||||
# AcidIsland Configuration ${version}
|
||||
acid:
|
||||
# Acid can damage ops or not
|
||||
damage-op: true
|
||||
# Acid can damage chickens - best to leave false because they like to swim
|
||||
damage-chickens: false
|
||||
command:
|
||||
# Island Command. What command users will run to access their island
|
||||
island: ai
|
||||
# The island admin command.
|
||||
admin: acid
|
||||
# Use control panel if it exists (ControlPanel addon must be in addons)
|
||||
use-control-panel: false
|
||||
# The default action for new player command call.
|
||||
# Sub-command of main player command that will be run on first player command call.
|
||||
# By default it is sub-command 'create'.
|
||||
# Added since 1.13.1.
|
||||
new-player-action: create
|
||||
# The default action for player command.
|
||||
# Sub-command of main player command that will be run on each player command call.
|
||||
# By default it is sub-command 'go'.
|
||||
# Added since 1.13.1.
|
||||
default-action: go
|
||||
# Acid can damage ops or not
|
||||
damage-op: true
|
||||
# Acid can damage chickens - best to leave false because they like to swim
|
||||
damage-chickens: false
|
||||
damage:
|
||||
acid:
|
||||
# Damage that a player will experience in acid. 10 is half their health typically. 5 would be easier.
|
||||
@ -178,10 +186,10 @@ world:
|
||||
# This setting is toggled in world flags and set by the settings GUI.
|
||||
# Mob white list - these mobs will NOT be removed when logging in or doing /island
|
||||
remove-mobs-whitelist:
|
||||
- ENDERMAN
|
||||
- ZOMBIE_VILLAGER
|
||||
- PIG_ZOMBIE
|
||||
- ZOMBIE_VILLAGER
|
||||
- WITHER
|
||||
- ENDERMAN
|
||||
# World flags. These are boolean settings for various flags for this world
|
||||
flags:
|
||||
CREEPER_DAMAGE: true
|
||||
@ -214,22 +222,23 @@ world:
|
||||
ENDER_PEARL: 500
|
||||
DOOR: 500
|
||||
FURNACE: 500
|
||||
MINECART: 500
|
||||
ANVIL: 500
|
||||
MINECART: 500
|
||||
FISH_SCOOPING: 500
|
||||
END_PORTAL: 500
|
||||
BREEDING: 500
|
||||
HURT_VILLAGERS: 500
|
||||
FROST_WALKER: 500
|
||||
TURTLE_EGGS: 500
|
||||
FROST_WALKER: 500
|
||||
COLLECT_LAVA: 500
|
||||
BREAK_SPAWNERS: 500
|
||||
LEVER: 500
|
||||
ELYTRA: 0
|
||||
HURT_MONSTERS: 0
|
||||
RIDING: 500
|
||||
HURT_MONSTERS: 0
|
||||
CAKE: 500
|
||||
NAME_TAG: 500
|
||||
ARMOR_STAND: 500
|
||||
NAME_TAG: 500
|
||||
TRADING: 0
|
||||
EGGS: 500
|
||||
ITEM_DROP: 0
|
||||
@ -237,10 +246,10 @@ world:
|
||||
FLINT_AND_STEEL: 500
|
||||
NETHER_PORTAL: 500
|
||||
LECTERN: 500
|
||||
ITEM_PICKUP: 0
|
||||
CROP_TRAMPLE: 500
|
||||
BREWING: 500
|
||||
ITEM_PICKUP: 0
|
||||
DROPPER: 500
|
||||
BREWING: 500
|
||||
TNT_PRIMING: 500
|
||||
COLLECT_WATER: 500
|
||||
BUTTON: 500
|
||||
@ -248,17 +257,17 @@ world:
|
||||
COMMAND_RANKS: 500
|
||||
BEACON: 500
|
||||
TRAPDOOR: 500
|
||||
PRESSURE_PLATE: 0
|
||||
EXPERIENCE_BOTTLE_THROWING: 500
|
||||
PRESSURE_PLATE: 0
|
||||
DYE: 500
|
||||
PLACE_BLOCKS: 500
|
||||
ITEM_FRAME: 500
|
||||
PLACE_BLOCKS: 500
|
||||
CRAFTING: 0
|
||||
SHEARING: 500
|
||||
ENCHANTING: 0
|
||||
SHEARING: 500
|
||||
BOAT: 500
|
||||
SPAWN_EGGS: 500
|
||||
BED: 500
|
||||
SPAWN_EGGS: 500
|
||||
MILKING: 0
|
||||
DISPENSER: 500
|
||||
GATE: 0
|
||||
@ -269,17 +278,17 @@ world:
|
||||
MOUNT_INVENTORY: 500
|
||||
CHORUS_FRUIT: 500
|
||||
CONTAINER: 500
|
||||
POTION_THROWING: 500
|
||||
JUKEBOX: 500
|
||||
POTION_THROWING: 500
|
||||
# These are the default settings for new islands
|
||||
default-island-settings:
|
||||
PVP_END: false
|
||||
ANIMAL_SPAWN: true
|
||||
PVP_NETHER: false
|
||||
ANIMAL_SPAWN: true
|
||||
LEAF_DECAY: true
|
||||
TNT_DAMAGE: true
|
||||
FIRE_IGNITE: true
|
||||
MONSTER_SPAWN: true
|
||||
FIRE_IGNITE: true
|
||||
FIRE_SPREAD: true
|
||||
FIRE_BURNING: true
|
||||
PVP_OVERWORLD: false
|
||||
|
@ -1,127 +0,0 @@
|
||||
package world.bentobox.acidisland.commands;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
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.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.managers.CommandsManager;
|
||||
import world.bentobox.bentobox.managers.FlagsManager;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Bukkit.class, BentoBox.class, User.class })
|
||||
public class AcidCommandTest {
|
||||
|
||||
private static final int NUM_COMMANDS = 26;
|
||||
@Mock
|
||||
private User user;
|
||||
@Mock
|
||||
private FlagsManager fm;
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
// Command manager
|
||||
CommandsManager cm = mock(CommandsManager.class);
|
||||
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||
|
||||
// Player
|
||||
Player p = mock(Player.class);
|
||||
// Sometimes use Mockito.withSettings().verboseLogging()
|
||||
when(user.isOp()).thenReturn(false);
|
||||
UUID uuid = UUID.randomUUID();
|
||||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.getPlayer()).thenReturn(p);
|
||||
when(user.getName()).thenReturn("tastybento");
|
||||
User.setPlugin(plugin);
|
||||
|
||||
// Locales
|
||||
// Return the reference (USE THIS IN THE FUTURE)
|
||||
when(user.getTranslation(Mockito.anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
|
||||
// Flags manager
|
||||
when(plugin.getFlagsManager()).thenReturn(fm);
|
||||
when(fm.getFlags()).thenReturn(Collections.emptyList());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AcidCommand#AcidCommand(world.bentobox.bentobox.api.addons.Addon, java.lang.String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAcidCommand() {
|
||||
Addon addon = mock(Addon.class);
|
||||
AcidCommand cmd = new AcidCommand(addon, "acid");
|
||||
assertEquals("acid", cmd.getLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AcidCommand#setup()}.
|
||||
*/
|
||||
@Test
|
||||
public void testSetup() {
|
||||
Addon addon = mock(Addon.class);
|
||||
when(addon.getPermissionPrefix()).thenReturn("acidisland.");
|
||||
AcidCommand cmd = new AcidCommand(addon, "acid");
|
||||
assertEquals("acidisland.admin", cmd.getPermission());
|
||||
assertFalse(cmd.isOnlyPlayer());
|
||||
assertEquals("commands.admin.help.parameters", cmd.getParameters());
|
||||
assertEquals("commands.admin.help.description", cmd.getDescription());
|
||||
// Number of commands = sub commands + help
|
||||
assertEquals("Number of sub commands registered", NUM_COMMANDS, cmd.getSubCommands().values().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AcidCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringUnknownCommand() {
|
||||
Addon addon = mock(Addon.class);
|
||||
AcidCommand cmd = new AcidCommand(addon, "acid");
|
||||
assertFalse(cmd.execute(user, "acid", Collections.singletonList("unknown")));
|
||||
Mockito.verify(user).sendMessage("general.errors.unknown-command", TextVariables.LABEL, "acid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AcidCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringNoCommand() {
|
||||
Addon addon = mock(Addon.class);
|
||||
AcidCommand cmd = new AcidCommand(addon, "acid");
|
||||
assertTrue(cmd.execute(user, "acid", Collections.emptyList()));
|
||||
// Show help
|
||||
Mockito.verify(user).sendMessage("commands.help.header", TextVariables.LABEL, "commands.help.console");
|
||||
}
|
||||
|
||||
}
|
@ -1,240 +0,0 @@
|
||||
package world.bentobox.acidisland.commands;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
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;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.acidisland.AISettings;
|
||||
import world.bentobox.acidisland.AcidIsland;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.Settings;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.managers.BlueprintsManager;
|
||||
import world.bentobox.bentobox.managers.CommandsManager;
|
||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||
import world.bentobox.bentobox.managers.IslandsManager;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Bukkit.class, BentoBox.class, User.class })
|
||||
public class AiCommandTest {
|
||||
|
||||
private static final int NUMBER_OF_COMMANDS = 18;
|
||||
@Mock
|
||||
private User user;
|
||||
@Mock
|
||||
private IslandsManager im;
|
||||
@Mock
|
||||
private Island island;
|
||||
@Mock
|
||||
private AcidIsland addon;
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Set up plugin
|
||||
BentoBox plugin = mock(BentoBox.class);
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
|
||||
// Command manager
|
||||
CommandsManager cm = mock(CommandsManager.class);
|
||||
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||
|
||||
// Player
|
||||
Player p = mock(Player.class);
|
||||
// Sometimes use Mockito.withSettings().verboseLogging()
|
||||
when(user.isOp()).thenReturn(false);
|
||||
UUID uuid = UUID.randomUUID();
|
||||
when(user.getUniqueId()).thenReturn(uuid);
|
||||
when(user.getPlayer()).thenReturn(p);
|
||||
when(user.getName()).thenReturn("tastybento");
|
||||
when(user.isPlayer()).thenReturn(true);
|
||||
User.setPlugin(plugin);
|
||||
|
||||
// Island World Manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Settings
|
||||
Settings s = mock(Settings.class);
|
||||
when(plugin.getSettings()).thenReturn(s);
|
||||
|
||||
// Player has island to begin with
|
||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
|
||||
// Locales
|
||||
// Return the reference (USE THIS IN THE FUTURE)
|
||||
when(user.getTranslation(Mockito.anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
|
||||
// Addon settings
|
||||
AISettings settings = mock(AISettings.class);
|
||||
when(settings.getIslandCommand()).thenReturn("ai");
|
||||
when(addon.getSettings()).thenReturn(settings);
|
||||
|
||||
// Blueprints
|
||||
BlueprintsManager bpm = mock(BlueprintsManager.class);
|
||||
Map<String, BlueprintBundle> map = new HashMap<>();
|
||||
BlueprintBundle bun = mock(BlueprintBundle.class);
|
||||
when(bun.getDisplayName()).thenReturn("aaa", "bbb");
|
||||
map.put("aaa", bun);
|
||||
map.put("bbb", bun);
|
||||
when(bun.getUniqueId()).thenReturn("unique1", "unique2");
|
||||
when(bun.isRequirePermission()).thenReturn(true);
|
||||
when(bpm.getBlueprintBundles(Mockito.any())).thenReturn(map);
|
||||
when(plugin.getBlueprintsManager()).thenReturn(bpm);
|
||||
|
||||
// Bukkit
|
||||
PowerMockito.mockStatic(Bukkit.class);
|
||||
PluginManager pim = mock(PluginManager.class);
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
BukkitScheduler sch = mock(BukkitScheduler.class);
|
||||
when(Bukkit.getScheduler()).thenReturn(sch);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#AiCommand(world.bentobox.bentobox.api.addons.Addon, java.lang.String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAiCommand() {
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertEquals("ai", cmd.getLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#setup()}.
|
||||
*/
|
||||
@Test
|
||||
public void testSetup() {
|
||||
when(addon.getPermissionPrefix()).thenReturn("acidisland.");
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertEquals("acidisland.island", cmd.getPermission());
|
||||
assertTrue(cmd.isOnlyPlayer());
|
||||
assertEquals("commands.island.help.description", cmd.getDescription());
|
||||
// Number of commands = sub commands + help
|
||||
assertEquals("Number of sub commands registered", NUMBER_OF_COMMANDS, cmd.getSubCommands().values().size());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringNullUsers() {
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertFalse(cmd.execute(null, "island", Collections.emptyList()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringUnknownCommand() {
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertFalse(cmd.execute(user, "island", Collections.singletonList("unknown")));
|
||||
verify(user).sendMessage("general.errors.unknown-command", TextVariables.LABEL, "ai");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringNoArgsNoPermission() {
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertFalse(cmd.execute(user, "island", Collections.emptyList()));
|
||||
verify(user).sendMessage("general.errors.no-permission", "[permission]", "island.home");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringNoArgsSuccess() {
|
||||
when(user.hasPermission(anyString())).thenReturn(true);
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertTrue(cmd.execute(user, "island", Collections.emptyList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringNoArgsConsole() {
|
||||
when(user.isPlayer()).thenReturn(false);
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertFalse(cmd.execute(user, "island", Collections.emptyList()));
|
||||
verify(user).sendMessage("general.errors.use-in-game");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringNoArgsNoIslandConsole() {
|
||||
when(user.isPlayer()).thenReturn(false);
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(null);
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertFalse(cmd.execute(user, "island", Collections.emptyList()));
|
||||
verify(user).sendMessage("general.errors.use-in-game");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringNoArgsNoIslandNoPermission() {
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(null);
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertFalse(cmd.execute(user, "island", Collections.emptyList()));
|
||||
verify(user).sendMessage("general.errors.no-permission", "[permission]", "island.create");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.commands.AiCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUserStringListOfStringNoArgsNoIslandCreateSuccess() {
|
||||
when(im.getIsland(any(), any(UUID.class))).thenReturn(null);
|
||||
when(user.hasPermission(Mockito.eq("island.create"))).thenReturn(true);
|
||||
AiCommand cmd = new AiCommand(addon, "ai");
|
||||
assertTrue(cmd.execute(user, "island", Collections.emptyList()));
|
||||
verify(user).getTranslation("commands.island.create.pick");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user