Compare commits
18 Commits
e3bb98f623
...
df273d9a81
Author | SHA1 | Date |
---|---|---|
tastybento | df273d9a81 | |
tastybento | 8c9626b9aa | |
tastybento | 4a1642f403 | |
mt-gitlocalize | 6f3da07886 | |
tastybento | 8ee933f2f2 | |
tastybento | ac999a044a | |
tastybento | 7384711a64 | |
tastybento | a689d36f57 | |
tastybento | 39a7df44ee | |
tastybento | 1d3be20237 | |
tastybento | 533aee12cb | |
tastybento | 48e1923fbb | |
4o4E | 1dd3b1bf85 | |
tastybento | 85835a40b9 | |
tastybento | 817ae62130 | |
tastybento | 9db846a76e | |
tastybento | 9647338a2f | |
tastybento | 46b0c89d3e |
|
@ -11,22 +11,22 @@ jobs:
|
|||
name: Build and analyze
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'adopt'
|
||||
java-version: 17
|
||||
- name: Cache SonarCloud packages
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.sonar/cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
restore-keys: ${{ runner.os }}-sonar
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
|
|
|
@ -16,6 +16,8 @@ You're on an island, in a sea of acid! If you like Skyblock, try the AcidIsland
|
|||
|
||||
Instead of falling you must contend with acid water when expanding your island, and players can boat to each other's islands.
|
||||
|
||||
<img width="512" alt="acidislandart" src="https://github.com/BentoBoxWorld/AcidIsland/assets/4407265/60e97bba-2b7d-425e-9130-cffef73cf76e">
|
||||
|
||||
## Download
|
||||
|
||||
You can download from GitHub, or ready made plugin packs from [https://download.bentobox.world](https://download.bentobox.world).
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -58,14 +58,14 @@
|
|||
<!-- Non-minecraft related dependencies -->
|
||||
<powermock.version>2.0.9</powermock.version>
|
||||
<!-- More visible way how to change dependency versions -->
|
||||
<spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
|
||||
<bentobox.version>1.23.0</bentobox.version>
|
||||
<spigot.version>1.20.2-R0.1-SNAPSHOT</spigot.version>
|
||||
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
|
||||
<!-- Revision variable removes warning about dynamic version -->
|
||||
<revision>${build.version}-SNAPSHOT</revision>
|
||||
<!-- Do not change unless you want different name for local builds. -->
|
||||
<build.number>-LOCAL</build.number>
|
||||
<!-- This allows to change between versions. -->
|
||||
<build.version>1.18.0</build.version>
|
||||
<build.version>1.18.1</build.version>
|
||||
<!-- Sonar Cloud -->
|
||||
<sonar.projectKey>BentoBoxWorld_AcidIsland</sonar.projectKey>
|
||||
<sonar.organization>bentobox-world</sonar.organization>
|
||||
|
@ -341,7 +341,7 @@
|
|||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.7</version>
|
||||
<version>0.8.10</version>
|
||||
<configuration>
|
||||
<append>true</append>
|
||||
<excludes>
|
||||
|
|
|
@ -159,6 +159,11 @@ public class AcidEffect implements Listener {
|
|||
}.runTaskTimer(addon.getPlugin(), 0L, 20L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if it is still raining or player is safe or dead or there is no damage
|
||||
* @param player player
|
||||
* @return true if the acid raid damage should stop
|
||||
*/
|
||||
protected boolean checkForRain(Player player) {
|
||||
if (!addon.getOverWorld().hasStorm() || player.isDead() || isSafeFromRain(player) || addon.getSettings().getAcidRainDamage() <= 0D) {
|
||||
wetPlayers.remove(player);
|
||||
|
@ -168,7 +173,7 @@ public class AcidEffect implements Listener {
|
|||
double protection = addon.getSettings().getAcidRainDamage() * getDamageReduced(player);
|
||||
double totalDamage = Math.max(0, addon.getSettings().getAcidRainDamage() - protection);
|
||||
AcidRainEvent event = new AcidRainEvent(player, totalDamage, protection, addon.getSettings().getAcidRainEffects());
|
||||
addon.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
event.getPotionEffects().stream().filter(EFFECTS::contains).forEach(t -> player.addPotionEffect(new PotionEffect(t, addon.getSettings().getRainEffectDuation() * 20, 1)));
|
||||
// Apply damage if there is any
|
||||
|
@ -324,7 +329,7 @@ public class AcidEffect implements Listener {
|
|||
private static boolean damage(ItemStack item) {
|
||||
ItemMeta im = item.getItemMeta();
|
||||
|
||||
if (im instanceof Damageable d) {
|
||||
if (im instanceof Damageable d && !im.isUnbreakable()) {
|
||||
d.setDamage(d.getDamage() + 1);
|
||||
item.setItemMeta(d);
|
||||
return d.getDamage() >= item.getType().getMaxDurability();
|
||||
|
|
|
@ -9,147 +9,332 @@ icon: "OAK_BOAT"
|
|||
authors: tastybento
|
||||
|
||||
permissions:
|
||||
acidisland.admin.clearresetall:
|
||||
default: op
|
||||
description: "Allow clearing of island reset limit of all players"
|
||||
acidisland.admin.delete:
|
||||
default: op
|
||||
description: "Let a player completely remove a player (including island)"
|
||||
acidisland.admin.noban:
|
||||
default: op
|
||||
description: "Player cannot be banned from an island"
|
||||
acidisland.admin.noexpel:
|
||||
default: op
|
||||
description: "Player cannot be expelled from an island"
|
||||
acidisland.admin.register:
|
||||
default: op
|
||||
description: "Let a player register the nearest island to another player."
|
||||
acidisland.admin.reload:
|
||||
default: op
|
||||
description: "Reload the config.yml"
|
||||
acidisland.admin.setlanguage:
|
||||
default: op
|
||||
description: "Resets all player languages and sets the default language"
|
||||
acidisland.admin.setrange:
|
||||
default: op
|
||||
description: "Allows setting of island protection range"
|
||||
acidisland.admin.setspawn:
|
||||
default: op
|
||||
description: "Allows use of spawn tools"
|
||||
acidisland.admin.settingsreset:
|
||||
default: op
|
||||
description: "Resets all the islands to default protection settings"
|
||||
acidisland.admin.tp:
|
||||
default: op
|
||||
description: "Allows teleport to an island"
|
||||
acidisland.admin.unregister:
|
||||
default: op
|
||||
description: "Removes a player from an island without deleting the island blocks."
|
||||
acidisland.island:
|
||||
# Non-command permissions
|
||||
acidisland.island.lock:
|
||||
description: Allows island locking in settings
|
||||
default: true
|
||||
description: "Allow island command usage"
|
||||
acidisland.island.ban:
|
||||
acidisland.settings.*:
|
||||
description: Allow use of settings on island
|
||||
default: true
|
||||
description: "Allows banning of visitors"
|
||||
acidisland.island.create:
|
||||
default: true
|
||||
description: "Allow island creation"
|
||||
acidisland.island.expel:
|
||||
default: true
|
||||
description: "Allows expelling of visitors"
|
||||
acidisland.island.home:
|
||||
default: true
|
||||
description: "Allow teleporting to player island"
|
||||
acidisland.island.info:
|
||||
default: true
|
||||
description: "Let the player check other players info"
|
||||
acidisland.island.language:
|
||||
default: true
|
||||
description: "Player can select a language"
|
||||
acidisland.island.lock:
|
||||
default: true
|
||||
description: "Allows island locking"
|
||||
acidisland.island.name:
|
||||
default: true
|
||||
description: "Player can set the name of their island"
|
||||
acidisland.island.near:
|
||||
default: true
|
||||
description: "Players can see nearby island names"
|
||||
acidisland.island.reset:
|
||||
default: true
|
||||
description: "Player can use the island reset or restart command"
|
||||
acidisland.island.sethome:
|
||||
default: true
|
||||
description: "Let the player use the sethome command"
|
||||
acidisland.island.settings:
|
||||
default: true
|
||||
description: "Player can see server settings"
|
||||
acidisland.island.spawn:
|
||||
default: true
|
||||
description: "Player can use the island spawn command if spawn exists"
|
||||
acidisland.island.team:
|
||||
default: true
|
||||
description: "Let a player use team command"
|
||||
acidisland.island.team.accept:
|
||||
default: true
|
||||
description: "Let a player accept invitations"
|
||||
acidisland.island.team.coop:
|
||||
default: true
|
||||
description: "Let a player use team coop commands"
|
||||
acidisland.island.team.invite:
|
||||
default: true
|
||||
description: "Let a player invite others"
|
||||
acidisland.island.team.kick:
|
||||
default: true
|
||||
description: "Let a player kick team members"
|
||||
acidisland.island.team.leave:
|
||||
default: true
|
||||
description: "Let a player leave the team"
|
||||
acidisland.island.team.promote:
|
||||
default: true
|
||||
description: "Let a player use promote commands"
|
||||
acidisland.island.team.reject:
|
||||
default: true
|
||||
description: "Let a player reject invites"
|
||||
acidisland.island.team.setowner:
|
||||
default: true
|
||||
description: "Let a player change the team owner"
|
||||
acidisland.island.team.trust:
|
||||
default: true
|
||||
description: "Let a player use team trust commands"
|
||||
acidisland.mod.bypassban:
|
||||
default: op
|
||||
description: "Bypasses island ban"
|
||||
acidisland.mod.bypasscooldowns:
|
||||
default: op
|
||||
description: "Allow moderator to bypass cooldowns"
|
||||
acidisland.mod.bypassdelays:
|
||||
default: op
|
||||
description: "Allow moderator to bypass delays"
|
||||
acidisland.mod.bypassexpel:
|
||||
default: op
|
||||
description: "Allow moderator to bypass island expulsion"
|
||||
acidisland.mod.bypasslock:
|
||||
default: op
|
||||
description: "Bypasses an island lock"
|
||||
acidisland.mod.bypassprotect:
|
||||
default: op
|
||||
description: "Allow moderator to bypass island protection"
|
||||
acidisland.mod.clearreset:
|
||||
acidisland.mod.clearreset:
|
||||
description: Allow clearing of island reset limit
|
||||
default: false
|
||||
description: "Allow clearing of island reset limit"
|
||||
acidisland.mod.info:
|
||||
acidisland.mod.bypasscooldowns:
|
||||
description: Allow moderator to bypass cooldowns
|
||||
default: op
|
||||
description: "Let a moderator see info on a player"
|
||||
acidisland.mod.lock:
|
||||
acidisland.mod.bypassdelays:
|
||||
description: Allow moderator to bypass delays
|
||||
default: op
|
||||
acidisland.mod.bypassprotect:
|
||||
description: Allow moderator to bypass island protection
|
||||
default: op
|
||||
acidisland.mod.bypassexpel:
|
||||
description: Allow moderator to bypass island expulsion
|
||||
default: op
|
||||
acidisland.mod.lock:
|
||||
description: Allows lock or unlock of an island
|
||||
default: op
|
||||
acidisland.mod.bypasslock:
|
||||
description: Bypasses an island lock
|
||||
default: op
|
||||
acidisland.mod.bypassban:
|
||||
description: Bypasses island ban
|
||||
default: op
|
||||
description: "Locks or unlocks an island"
|
||||
acidisland.mod.noburn:
|
||||
default: op
|
||||
description: "Give mod acid protection"
|
||||
acidisland.mod.team:
|
||||
default: false
|
||||
description: "Enables modification of teams via kick and add commands"
|
||||
acidisland.settings.*:
|
||||
default: true
|
||||
description: "Allow use of settings on island"
|
||||
acidisland.admin.noban:
|
||||
description: Player cannot be banned from an island
|
||||
default: op
|
||||
acidisland.admin.noexpel:
|
||||
description: Player cannot be expelled from an island
|
||||
default: op
|
||||
# Command permissions
|
||||
acidisland.island:
|
||||
description: Allow use of '/ai' command - the main island command
|
||||
default: TRUE
|
||||
acidisland.island.home:
|
||||
description: Allow use of '/ai go' command - teleport you to your island
|
||||
default: TRUE
|
||||
acidisland.island.spawn:
|
||||
description: Allow use of '/ai spawn' command - teleport you to the spawn
|
||||
default: TRUE
|
||||
acidisland.island.create:
|
||||
description: Allow use of '/ai create' command - create an island, using optional blueprint (requires permission)
|
||||
default: TRUE
|
||||
acidisland.island.reset:
|
||||
description: Allow use of '/ai reset' command - restart your island and remove the old one
|
||||
default: TRUE
|
||||
acidisland.island.info:
|
||||
description: Allow use of '/ai info' command - display info about your island or the player's island
|
||||
default: TRUE
|
||||
acidisland.island.settings:
|
||||
description: Allow use of '/ai settings' command - display island settings
|
||||
default: TRUE
|
||||
acidisland.island.name:
|
||||
description: Allow use of '/ai setname' command - set a name for your island
|
||||
default: TRUE
|
||||
acidisland.island.name:
|
||||
description: Allow use of '/ai resetname' command - reset your island name
|
||||
default: TRUE
|
||||
acidisland.island.language:
|
||||
description: Allow use of '/ai language' command - select language
|
||||
default: TRUE
|
||||
acidisland.island.ban:
|
||||
description: Allow use of '/ai ban' command - ban a player from your island
|
||||
default: TRUE
|
||||
acidisland.island.ban:
|
||||
description: Allow use of '/ai unban' command - unban a player from your island
|
||||
default: TRUE
|
||||
acidisland.island.ban:
|
||||
description: Allow use of '/ai banlist' command - list banned players
|
||||
default: TRUE
|
||||
acidisland.island.expel:
|
||||
description: Allow use of '/ai expel' command - expel a player from your island
|
||||
default: TRUE
|
||||
acidisland.island.near:
|
||||
description: Allow use of '/ai near' command - show the name of neighboring islands around you
|
||||
default: TRUE
|
||||
acidisland.island.team:
|
||||
description: Allow use of '/ai team' command - manage your team
|
||||
default: TRUE
|
||||
acidisland.island.team.invite:
|
||||
description: Allow use of '/ai team invite' command - invite a player to join your island
|
||||
default: TRUE
|
||||
acidisland.island.team.leave:
|
||||
description: Allow use of '/ai team leave' command - leave your island
|
||||
default: TRUE
|
||||
acidisland.island.team.setowner:
|
||||
description: Allow use of '/ai team setowner' command - transfer your island ownership to a member
|
||||
default: TRUE
|
||||
acidisland.island.team.kick:
|
||||
description: Allow use of '/ai team kick' command - remove a member from your island
|
||||
default: TRUE
|
||||
acidisland.island.team.accept:
|
||||
description: Allow use of '/ai team accept' command - accept an invitation
|
||||
default: TRUE
|
||||
acidisland.island.team.reject:
|
||||
description: Allow use of '/ai team reject' command - reject an invitation
|
||||
default: TRUE
|
||||
acidisland.island.team.coop:
|
||||
description: Allow use of '/ai team coop' command - make a player coop rank on your island
|
||||
default: TRUE
|
||||
acidisland.island.team.coop:
|
||||
description: Allow use of '/ai team uncoop' command - remove a coop rank from player
|
||||
default: TRUE
|
||||
acidisland.island.team.trust:
|
||||
description: Allow use of '/ai team trust' command - give a player trusted rank on your island
|
||||
default: TRUE
|
||||
acidisland.island.team.trust:
|
||||
description: Allow use of '/ai team untrust' command - remove trusted player rank from player
|
||||
default: TRUE
|
||||
acidisland.island.team.promote:
|
||||
description: Allow use of '/ai team promote' command - promote a player on your island up a rank
|
||||
default: TRUE
|
||||
acidisland.island.team.promote:
|
||||
description: Allow use of '/ai team demote' command - demote a player on your island down a rank
|
||||
default: TRUE
|
||||
acidisland.island.sethome:
|
||||
description: Allow use of '/ai sethome' command - set your home teleport point
|
||||
default: TRUE
|
||||
acidisland.island.deletehome:
|
||||
description: Allow use of '/ai deletehome' command - delete a home location
|
||||
default: OP
|
||||
acidisland.island.renamehome:
|
||||
description: Allow use of '/ai renamehome' command - rename a home location
|
||||
default: OP
|
||||
acidisland.island.homes:
|
||||
description: Allow use of '/ai homes' command - list your homes
|
||||
default: OP
|
||||
acidisland.admin:
|
||||
description: Allow use of '/acid' command - admin command
|
||||
default: OP
|
||||
acidisland.admin.version:
|
||||
description: Allow use of '/acid version' command - display BentoBox and addons versions
|
||||
default: OP
|
||||
acidisland.admin.tp:
|
||||
description: Allow use of '/acid tp' command - teleport to a player's island
|
||||
default: OP
|
||||
acidisland.admin.tp:
|
||||
description: Allow use of '/acid tpnether' command - teleport to a player's island
|
||||
default: OP
|
||||
acidisland.admin.tp:
|
||||
description: Allow use of '/acid tpend' command - teleport to a player's island
|
||||
default: OP
|
||||
acidisland.admin.getrank:
|
||||
description: Allow use of '/acid getrank' command - get a player's rank on their island or the island of the owner
|
||||
default: OP
|
||||
acidisland.admin.setrank:
|
||||
description: Allow use of '/acid setrank' command - set a player's rank on their island or the island of the owner
|
||||
default: OP
|
||||
acidisland.mod.info:
|
||||
description: Allow use of '/acid info' command - get info on where you are or player's island
|
||||
default: OP
|
||||
acidisland.mod.team:
|
||||
description: Allow use of '/acid team' command - manage teams
|
||||
default: FALSE
|
||||
acidisland.mod.team.add:
|
||||
description: Allow use of '/acid team add' command - add player to owner's team
|
||||
default: OP
|
||||
acidisland.mod.team.disband:
|
||||
description: Allow use of '/acid team disband' command - disband owner's team
|
||||
default: OP
|
||||
acidisland.mod.team.fix:
|
||||
description: Allow use of '/acid team fix' command - scans and fixes cross island membership in database
|
||||
default: OP
|
||||
acidisland.mod.team.kick:
|
||||
description: Allow use of '/acid team kick' command - kick a player from a team
|
||||
default: OP
|
||||
acidisland.mod.team.setowner:
|
||||
description: Allow use of '/acid team setowner' command - transfers island ownership to the player
|
||||
default: OP
|
||||
acidisland.mod.team.add:
|
||||
description: Allow use of '/acid add' command - add player to owner's team
|
||||
default: OP
|
||||
acidisland.mod.team.kick:
|
||||
description: Allow use of '/acid kick' command - kick a player from a team
|
||||
default: OP
|
||||
acidisland.mod.team.disband:
|
||||
description: Allow use of '/acid disband' command - disband owner's team
|
||||
default: OP
|
||||
acidisland.mod.team.setowner:
|
||||
description: Allow use of '/acid setowner' command - transfers island ownership to the player
|
||||
default: OP
|
||||
acidisland.mod.team.fix:
|
||||
description: Allow use of '/acid fix' command - scans and fixes cross island membership in database
|
||||
default: OP
|
||||
acidisland.admin.blueprint:
|
||||
description: Allow use of '/acid blueprint' command - manipulate blueprints
|
||||
default: OP
|
||||
acidisland.admin.blueprint.load:
|
||||
description: Allow use of '/acid blueprint load' command - load blueprint into the clipboard
|
||||
default: OP
|
||||
acidisland.admin.blueprint.paste:
|
||||
description: Allow use of '/acid blueprint paste' command - paste the clipboard to your location
|
||||
default: OP
|
||||
acidisland.admin.blueprint.origin:
|
||||
description: Allow use of '/acid blueprint origin' command - set the blueprint's origin to your position
|
||||
default: OP
|
||||
acidisland.admin.blueprint.copy:
|
||||
description: Allow use of '/acid blueprint copy' command - copy the clipboard set by pos1 and pos2 and optionally the air blocks
|
||||
default: OP
|
||||
acidisland.admin.blueprint.save:
|
||||
description: Allow use of '/acid blueprint save' command - save the copied clipboard
|
||||
default: OP
|
||||
acidisland.admin.blueprint.rename:
|
||||
description: Allow use of '/acid blueprint rename' command - rename a blueprint
|
||||
default: OP
|
||||
acidisland.admin.blueprint.delete:
|
||||
description: Allow use of '/acid blueprint delete' command - delete the blueprint
|
||||
default: OP
|
||||
acidisland.admin.blueprint.pos1:
|
||||
description: Allow use of '/acid blueprint pos1' command - set 1st corner of cuboid clipboard
|
||||
default: OP
|
||||
acidisland.admin.blueprint.pos2:
|
||||
description: Allow use of '/acid blueprint pos2' command - set 2nd corner of cuboid clipboard
|
||||
default: OP
|
||||
acidisland.admin.blueprint.list:
|
||||
description: Allow use of '/acid blueprint list' command - list available blueprints
|
||||
default: OP
|
||||
acidisland.admin.register:
|
||||
description: Allow use of '/acid register' command - register player to unowned island you are on
|
||||
default: OP
|
||||
acidisland.admin.unregister:
|
||||
description: Allow use of '/acid unregister' command - unregister owner from island, but keep island blocks
|
||||
default: OP
|
||||
acidisland.admin.range:
|
||||
description: Allow use of '/acid range' command - admin island range command
|
||||
default: OP
|
||||
acidisland.admin.range.display:
|
||||
description: Allow use of '/acid range display' command - show/hide island range indicators
|
||||
default: OP
|
||||
acidisland.admin.range.set:
|
||||
description: Allow use of '/acid range set' command - sets the island protected range
|
||||
default: OP
|
||||
acidisland.admin.range.reset:
|
||||
description: Allow use of '/acid range reset' command - resets the island protected range to the world default
|
||||
default: OP
|
||||
acidisland.admin.range.add:
|
||||
description: Allow use of '/acid range add' command - increases the island protected range
|
||||
default: OP
|
||||
acidisland.admin.range.remove:
|
||||
description: Allow use of '/acid range remove' command - decreases the island protected range
|
||||
default: OP
|
||||
acidisland.admin.resets:
|
||||
description: Allow use of '/acid resets' command - edit player reset values
|
||||
default: OP
|
||||
acidisland.admin.resets.set:
|
||||
description: Allow use of '/acid resets set' command - sets how many times this player has reset his island
|
||||
default: OP
|
||||
acidisland.admin.resets.remove:
|
||||
description: Allow use of '/acid resets reset' command - sets the player's island reset count to 0
|
||||
default: OP
|
||||
acidisland.admin.resets.add:
|
||||
description: Allow use of '/acid resets add' command - adds this player's island reset count
|
||||
default: OP
|
||||
acidisland.admin.resets.remove:
|
||||
description: Allow use of '/acid resets remove' command - reduces the player's island reset count
|
||||
default: OP
|
||||
acidisland.admin.delete:
|
||||
description: Allow use of '/acid delete' command - deletes a player's island
|
||||
default: OP
|
||||
acidisland.admin.why:
|
||||
description: Allow use of '/acid why' command - toggle console protection debug reporting
|
||||
default: OP
|
||||
acidisland.admin.deaths:
|
||||
description: Allow use of '/acid deaths' command - edit deaths of players
|
||||
default: OP
|
||||
acidisland.admin.deaths.reset:
|
||||
description: Allow use of '/acid deaths reset' command - resets deaths of the player
|
||||
default: OP
|
||||
acidisland.admin.deaths.set:
|
||||
description: Allow use of '/acid deaths set' command - sets deaths of the player
|
||||
default: OP
|
||||
acidisland.admin.deaths.add:
|
||||
description: Allow use of '/acid deaths add' command - adds deaths to the player
|
||||
default: OP
|
||||
acidisland.admin.deaths.remove:
|
||||
description: Allow use of '/acid deaths remove' command - removes deaths to the player
|
||||
default: OP
|
||||
acidisland.admin.reload:
|
||||
description: Allow use of '/acid reload' command - reload
|
||||
default: OP
|
||||
acidisland.admin.setspawn:
|
||||
description: Allow use of '/acid setspawn' command - set an island as spawn for this gamemode
|
||||
default: OP
|
||||
acidisland.admin.setspawnpoint:
|
||||
description: Allow use of '/acid setspawnpoint' command - set current location as spawn point for this island
|
||||
default: OP
|
||||
acidisland.admin.resetflags:
|
||||
description: Allow use of '/acid resetflags' command - Reset all islands to default flag settings in config.yml
|
||||
default: OP
|
||||
acidisland.mod.switch:
|
||||
description: Allow use of '/acid switch' command - switch on/off protection bypass
|
||||
default: OP
|
||||
acidisland.admin.purge:
|
||||
description: Allow use of '/acid purge' command - purge islands abandoned for more than [days]
|
||||
default: OP
|
||||
acidisland.admin.purge.status:
|
||||
description: Allow use of '/acid purge status' command - displays the status of the purge
|
||||
default: OP
|
||||
acidisland.admin.purge.stop:
|
||||
description: Allow use of '/acid purge stop' command - stop a purge in progress
|
||||
default: OP
|
||||
acidisland.admin.purge.unowned:
|
||||
description: Allow use of '/acid purge unowned' command - purge unowned islands
|
||||
default: OP
|
||||
acidisland.admin.purge.protect:
|
||||
description: Allow use of '/acid purge protect' command - toggle island purge protection
|
||||
default: OP
|
||||
acidisland.admin.settings:
|
||||
description: Allow use of '/acid settings' command - open settings GUI or set settings
|
||||
default: OP
|
||||
acidisland.admin.setprotectionlocation:
|
||||
description: Allow use of '/acid setprotectionlocation' command - set current location or [x y z] as center of island's protection area
|
||||
default: OP
|
||||
acidisland.mod.deletehomes:
|
||||
description: Allow use of '/acid deletehomes' command - deletes all named homes from an island
|
||||
default: OP
|
||||
acidisland.mod.resetname:
|
||||
description: Allow use of '/acid resetname' command - reset player island name
|
||||
default: OP
|
|
@ -124,21 +124,21 @@ world:
|
|||
offset-z: 0
|
||||
# Island height - Lowest is 5.
|
||||
# It is the y coordinate of the bedrock block in the schem.
|
||||
island-height: 50
|
||||
island-height: 60
|
||||
# Use your own world generator for this world.
|
||||
# In this case, the plugin will not generate anything.
|
||||
# /!\ This feature is experimental and might not work as expected or might not work at all.
|
||||
use-own-generator: false
|
||||
# Sea height (don't changes this mid-game unless you delete the world)
|
||||
# Minimum is 0, which means you are playing Skyblock!
|
||||
sea-height: 54
|
||||
sea-height: 64
|
||||
# Water block. This should usually stay as WATER, but may be LAVA for fun
|
||||
# /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds.
|
||||
water-block: WATER
|
||||
# Ocean Floor
|
||||
# This creates an ocean floor environment, with vanilla elements.
|
||||
# /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds.
|
||||
ocean-floor: false
|
||||
ocean-floor: true
|
||||
# Maximum number of islands in the world. Set to -1 or 0 for unlimited.
|
||||
# If the number of islands is greater than this number, no new island will be created.
|
||||
max-islands: 0
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
acidisland:
|
||||
sign:
|
||||
line0: "&1Кислотний острів"
|
||||
line1: "[name]"
|
||||
line2: Вода кислотна!
|
||||
line3: Будь обережний! &c<3
|
|
@ -7,21 +7,27 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -32,6 +38,7 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.plugin.PluginManager;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
|
@ -48,222 +55,255 @@ import world.bentobox.bentobox.Settings;
|
|||
import world.bentobox.bentobox.api.addons.AddonDescription;
|
||||
import world.bentobox.bentobox.api.configuration.Config;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.AbstractDatabaseHandler;
|
||||
import world.bentobox.bentobox.database.DatabaseSetup;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
import world.bentobox.bentobox.managers.AddonsManager;
|
||||
import world.bentobox.bentobox.managers.CommandsManager;
|
||||
import world.bentobox.bentobox.managers.FlagsManager;
|
||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||
import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Bukkit.class, BentoBox.class, User.class, Config.class })
|
||||
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, Config.class, DatabaseSetup.class })
|
||||
public class AcidIslandTest {
|
||||
|
||||
/**
|
||||
* Class under test
|
||||
*/
|
||||
private AcidIsland addon;
|
||||
/**
|
||||
* Class under test
|
||||
*/
|
||||
private AcidIsland addon;
|
||||
|
||||
@Mock
|
||||
private User user;
|
||||
@Mock
|
||||
private IslandsManager im;
|
||||
@Mock
|
||||
private Island island;
|
||||
@Mock
|
||||
private BentoBox plugin;
|
||||
@Mock
|
||||
private FlagsManager fm;
|
||||
@Mock
|
||||
private Settings settings;
|
||||
@Mock
|
||||
private User user;
|
||||
@Mock
|
||||
private IslandsManager im;
|
||||
@Mock
|
||||
private Island island;
|
||||
@Mock
|
||||
private BentoBox plugin;
|
||||
@Mock
|
||||
private FlagsManager fm;
|
||||
@Mock
|
||||
private Settings settings;
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
when(plugin.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
// Command manager
|
||||
CommandsManager cm = mock(CommandsManager.class);
|
||||
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||
private static AbstractDatabaseHandler<Object> h;
|
||||
|
||||
// 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);
|
||||
@SuppressWarnings("unchecked")
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws IllegalAccessException, InvocationTargetException, IntrospectionException {
|
||||
// This has to be done beforeClass otherwise the tests will interfere with each
|
||||
// other
|
||||
h = mock(AbstractDatabaseHandler.class);
|
||||
// Database
|
||||
PowerMockito.mockStatic(DatabaseSetup.class);
|
||||
DatabaseSetup dbSetup = mock(DatabaseSetup.class);
|
||||
when(DatabaseSetup.getDatabase()).thenReturn(dbSetup);
|
||||
when(dbSetup.getHandler(any())).thenReturn(h);
|
||||
when(h.saveObject(any())).thenReturn(CompletableFuture.completedFuture(true));
|
||||
}
|
||||
|
||||
// Island World Manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
@After
|
||||
public void tearDown() throws IOException {
|
||||
User.clearUsers();
|
||||
Mockito.framework().clearInlineMocks();
|
||||
deleteAll(new File("database"));
|
||||
deleteAll(new File("database_backup"));
|
||||
deleteAll(new File("addon.jar"));
|
||||
deleteAll(new File("config.yml"));
|
||||
deleteAll(new File("addons"));
|
||||
|
||||
}
|
||||
|
||||
// Player has island to begin with
|
||||
island = mock(Island.class);
|
||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
private void deleteAll(File file) throws IOException {
|
||||
if (file.exists()) {
|
||||
Files.walk(file.toPath()).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
|
||||
}
|
||||
|
||||
// Locales
|
||||
// Return the reference (USE THIS IN THE FUTURE)
|
||||
when(user.getTranslation(Mockito.anyString())).thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
}
|
||||
|
||||
// Server
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
Server server = mock(Server.class);
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||
when(Bukkit.getWorld(anyString())).thenReturn(null);
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Set up plugin
|
||||
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
|
||||
when(plugin.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
// Command manager
|
||||
CommandsManager cm = mock(CommandsManager.class);
|
||||
when(plugin.getCommandsManager()).thenReturn(cm);
|
||||
|
||||
// Addon
|
||||
addon = new AcidIsland();
|
||||
File jFile = new File("addon.jar");
|
||||
List<String> lines = Arrays.asList("# AcidIsland Configuration", "uniqueId: config");
|
||||
Path path = Paths.get("config.yml");
|
||||
Files.write(path, lines, Charset.forName("UTF-8"));
|
||||
try (JarOutputStream tempJarOutputStream = new JarOutputStream(new FileOutputStream(jFile))) {
|
||||
//Added the new files to the jar.
|
||||
try (FileInputStream fis = new FileInputStream(path.toFile())) {
|
||||
// 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);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead = 0;
|
||||
JarEntry entry = new JarEntry(path.toString());
|
||||
tempJarOutputStream.putNextEntry(entry);
|
||||
while((bytesRead = fis.read(buffer)) != -1) {
|
||||
tempJarOutputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
File dataFolder = new File("addons/AcidIsland");
|
||||
addon.setDataFolder(dataFolder);
|
||||
addon.setFile(jFile);
|
||||
AddonDescription desc = new AddonDescription.Builder("bentobox", "AcidIsland", "1.3").description("test").authors("tasty").build();
|
||||
addon.setDescription(desc);
|
||||
// Addons manager
|
||||
AddonsManager am = mock(AddonsManager.class);
|
||||
when(plugin.getAddonsManager()).thenReturn(am);
|
||||
// Island World Manager
|
||||
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
|
||||
// Flags manager
|
||||
when(plugin.getFlagsManager()).thenReturn(fm);
|
||||
when(fm.getFlags()).thenReturn(Collections.emptyList());
|
||||
// Player has island to begin with
|
||||
island = mock(Island.class);
|
||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(island);
|
||||
when(plugin.getIslands()).thenReturn(im);
|
||||
|
||||
// Settings
|
||||
when(plugin.getSettings()).thenReturn(settings);
|
||||
// Locales
|
||||
// Return the reference (USE THIS IN THE FUTURE)
|
||||
when(user.getTranslation(Mockito.anyString()))
|
||||
.thenAnswer((Answer<String>) invocation -> invocation.getArgument(0, String.class));
|
||||
|
||||
}
|
||||
// Server
|
||||
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
|
||||
Server server = mock(Server.class);
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
|
||||
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
|
||||
when(Bukkit.getWorld(anyString())).thenReturn(null);
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
new File("addon.jar").delete();
|
||||
new File("config.yml").delete();
|
||||
new File("addons/acidisland","config.yml").delete();
|
||||
new File("addons/acidisland").delete();
|
||||
new File("addons").delete();
|
||||
}
|
||||
// Addon
|
||||
addon = new AcidIsland();
|
||||
File jFile = new File("addon.jar");
|
||||
List<String> lines = Arrays.asList("# AcidIsland Configuration", "uniqueId: config");
|
||||
Path path = Paths.get("config.yml");
|
||||
Files.write(path, lines, Charset.forName("UTF-8"));
|
||||
try (JarOutputStream tempJarOutputStream = new JarOutputStream(new FileOutputStream(jFile))) {
|
||||
// Added the new files to the jar.
|
||||
try (FileInputStream fis = new FileInputStream(path.toFile())) {
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#onLoad()}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnLoad() {
|
||||
addon.onLoad();
|
||||
// Check that config.yml file has been saved
|
||||
File check = new File("addons/AcidIsland","config.yml");
|
||||
assertTrue(check.exists());
|
||||
}
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead = 0;
|
||||
JarEntry entry = new JarEntry(path.toString());
|
||||
tempJarOutputStream.putNextEntry(entry);
|
||||
while ((bytesRead = fis.read(buffer)) != -1) {
|
||||
tempJarOutputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
File dataFolder = new File("addons/AcidIsland");
|
||||
addon.setDataFolder(dataFolder);
|
||||
addon.setFile(jFile);
|
||||
AddonDescription desc = new AddonDescription.Builder("bentobox", "AcidIsland", "1.3").description("test")
|
||||
.authors("tasty").build();
|
||||
addon.setDescription(desc);
|
||||
// Addons manager
|
||||
AddonsManager am = mock(AddonsManager.class);
|
||||
when(plugin.getAddonsManager()).thenReturn(am);
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#onEnable()}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnEnable() {
|
||||
testOnLoad();
|
||||
addon.onEnable();
|
||||
assertTrue(addon.getPlayerCommand().isPresent());
|
||||
assertTrue(addon.getAdminCommand().isPresent());
|
||||
}
|
||||
// Flags manager
|
||||
when(plugin.getFlagsManager()).thenReturn(fm);
|
||||
when(fm.getFlags()).thenReturn(Collections.emptyList());
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#onReload()}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnReload() {
|
||||
addon.onReload();
|
||||
// Check that config.yml file has been saved
|
||||
File check = new File("addons/AcidIsland","config.yml");
|
||||
assertTrue(check.exists());
|
||||
}
|
||||
// Settings
|
||||
when(plugin.getSettings()).thenReturn(settings);
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#createWorlds()}.
|
||||
*/
|
||||
@Test
|
||||
public void testCreateWorlds() {
|
||||
addon.onLoad();
|
||||
addon.createWorlds();
|
||||
Mockito.verify(plugin).log("[AcidIsland] Creating AcidIsland...");
|
||||
Mockito.verify(plugin).log("[AcidIsland] Creating AcidIsland's Nether...");
|
||||
Mockito.verify(plugin).log("[AcidIsland] Creating AcidIsland's End World...");
|
||||
}
|
||||
// RanksManager
|
||||
RanksManager rm = new RanksManager();
|
||||
when(plugin.getRanksManager()).thenReturn(rm);
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#getSettings()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetSettings() {
|
||||
addon.onLoad();
|
||||
assertNotNull(addon.getSettings());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#getWorldSettings()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetWorldSettings() {
|
||||
addon.onLoad();
|
||||
assertEquals(addon.getSettings(), addon.getWorldSettings());
|
||||
}
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#onLoad()}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnLoad() {
|
||||
addon.onLoad();
|
||||
// Check that config.yml file has been saved
|
||||
File check = new File("addons/AcidIsland", "config.yml");
|
||||
assertTrue(check.exists());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#getDefaultWorldGenerator(java.lang.String, java.lang.String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetDefaultWorldGeneratorStringString() {
|
||||
assertNull(addon.getDefaultWorldGenerator("", ""));
|
||||
addon.onLoad();
|
||||
addon.createWorlds();
|
||||
assertNotNull(addon.getDefaultWorldGenerator("", ""));
|
||||
assertTrue(addon.getDefaultWorldGenerator("", "") instanceof ChunkGeneratorWorld);
|
||||
}
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#onEnable()}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnEnable() {
|
||||
testOnLoad();
|
||||
addon.onEnable();
|
||||
assertTrue(addon.getPlayerCommand().isPresent());
|
||||
assertTrue(addon.getAdminCommand().isPresent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#allLoaded()}.
|
||||
*/
|
||||
@Test
|
||||
public void testAllLoaded() {
|
||||
addon.allLoaded();
|
||||
}
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#onReload()}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnReload() {
|
||||
addon.onReload();
|
||||
// Check that config.yml file has been saved
|
||||
File check = new File("addons/AcidIsland", "config.yml");
|
||||
assertTrue(check.exists());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#createWorlds()}.
|
||||
*/
|
||||
@Test
|
||||
public void testCreateWorlds() {
|
||||
addon.onLoad();
|
||||
addon.createWorlds();
|
||||
Mockito.verify(plugin).log("[AcidIsland] Creating AcidIsland...");
|
||||
Mockito.verify(plugin).log("[AcidIsland] Creating AcidIsland's Nether...");
|
||||
Mockito.verify(plugin).log("[AcidIsland] Creating AcidIsland's End World...");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#saveWorldSettings()}.
|
||||
*/
|
||||
@Test
|
||||
public void testSaveWorldSettings() {
|
||||
addon.saveWorldSettings();
|
||||
}
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#getSettings()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetSettings() {
|
||||
addon.onLoad();
|
||||
assertNotNull(addon.getSettings());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link world.bentobox.acidisland.AcidIsland#getWorldSettings()}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetWorldSettings() {
|
||||
addon.onLoad();
|
||||
assertEquals(addon.getSettings(), addon.getWorldSettings());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link world.bentobox.acidisland.AcidIsland#getDefaultWorldGenerator(java.lang.String, java.lang.String)}.
|
||||
*/
|
||||
@Test
|
||||
public void testGetDefaultWorldGeneratorStringString() {
|
||||
assertNull(addon.getDefaultWorldGenerator("", ""));
|
||||
addon.onLoad();
|
||||
addon.createWorlds();
|
||||
assertNotNull(addon.getDefaultWorldGenerator("", ""));
|
||||
assertTrue(addon.getDefaultWorldGenerator("", "") instanceof ChunkGeneratorWorld);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.AcidIsland#allLoaded()}.
|
||||
*/
|
||||
@Test
|
||||
public void testAllLoaded() {
|
||||
addon.allLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link world.bentobox.acidisland.AcidIsland#saveWorldSettings()}.
|
||||
*/
|
||||
@Test
|
||||
public void testSaveWorldSettings() {
|
||||
addon.saveWorldSettings();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package world.bentobox.acidisland.listeners;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
|
@ -18,6 +19,7 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
@ -69,7 +71,7 @@ import world.bentobox.bentobox.util.Util;
|
|||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Bukkit.class, Util.class})
|
||||
public class AcidEffectTest {
|
||||
|
||||
|
||||
@Mock
|
||||
private AcidIsland addon;
|
||||
@Mock
|
||||
|
@ -112,7 +114,9 @@ public class AcidEffectTest {
|
|||
private IslandWorldManager iwm;
|
||||
@Mock
|
||||
private IslandsManager im;
|
||||
|
||||
@Mock
|
||||
private Server server;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -122,12 +126,12 @@ public class AcidEffectTest {
|
|||
when(Bukkit.getScheduler()).thenReturn(scheduler);
|
||||
when(addon.getSettings()).thenReturn(settings);
|
||||
when(addon.getOverWorld()).thenReturn(world);
|
||||
|
||||
|
||||
// Essentials
|
||||
when(Bukkit.getPluginManager()).thenReturn(pim);
|
||||
when(pim.getPlugin(eq("Essentials"))).thenReturn(essentials);
|
||||
when(essentials.getUser(any(Player.class))).thenReturn(essentialsUser);
|
||||
|
||||
|
||||
// Player
|
||||
when(player.getGameMode()).thenReturn(GameMode.SURVIVAL);
|
||||
when(player.getWorld()).thenReturn(world);
|
||||
|
@ -136,12 +140,12 @@ public class AcidEffectTest {
|
|||
when(player.getInventory()).thenReturn(inv);
|
||||
ItemStack[] armor = { new ItemStack(Material.CHAINMAIL_HELMET) };
|
||||
when(inv.getArmorContents()).thenReturn(armor);
|
||||
|
||||
|
||||
// Location
|
||||
when(location.getBlockY()).thenReturn(-66);
|
||||
when(location.getWorld()).thenReturn(world);
|
||||
when(location.getBlock()).thenReturn(block);
|
||||
|
||||
|
||||
// Blocks
|
||||
when(block.getType()).thenReturn(Material.WATER);
|
||||
when(block.getTemperature()).thenReturn(0.5D);
|
||||
|
@ -149,42 +153,43 @@ public class AcidEffectTest {
|
|||
when(block.getRelative(any())).thenReturn(block);
|
||||
when(airBlock.getType()).thenReturn(Material.AIR);
|
||||
when(solidBlock.getType()).thenReturn(Material.CHISELED_RED_SANDSTONE);
|
||||
|
||||
|
||||
// Settings
|
||||
when(settings.getAcidDestroyItemTime()).thenReturn(0L);
|
||||
when(settings.getAcidRainDamage()).thenReturn(10);
|
||||
when(settings.getAcidDamage()).thenReturn(10);
|
||||
when(settings.getAcidDamageDelay()).thenReturn(60L);
|
||||
|
||||
|
||||
// Players Manager
|
||||
when(addon.getPlayers()).thenReturn(pm);
|
||||
|
||||
|
||||
// Mock item factory (for itemstacks)
|
||||
ItemFactory itemFactory = mock(ItemFactory.class);
|
||||
when(Bukkit.getItemFactory()).thenReturn(itemFactory);
|
||||
when(itemFactory.getItemMeta(any())).thenReturn(itemMeta);
|
||||
|
||||
|
||||
// Util
|
||||
PowerMockito.mockStatic(Util.class);
|
||||
when(Util.sameWorld(any(), any())).thenReturn(true);
|
||||
|
||||
|
||||
// World
|
||||
when(world.hasStorm()).thenReturn(true);
|
||||
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(airBlock);
|
||||
when(world.getMaxHeight()).thenReturn(5);
|
||||
when(world.getMinHeight()).thenReturn(-65);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
|
||||
|
||||
// Plugin
|
||||
when(addon.getPlugin()).thenReturn(plugin);
|
||||
when(plugin.getIWM()).thenReturn(iwm);
|
||||
// CUSTOM damage protection
|
||||
when(iwm.getIvSettings(any())).thenReturn(Collections.singletonList("CUSTOM"));
|
||||
|
||||
|
||||
// Island manager
|
||||
when(addon.getIslands()).thenReturn(im);
|
||||
when(im.userIsOnIsland(any(), any())).thenReturn(true);
|
||||
|
||||
|
||||
|
||||
ae = new AcidEffect(addon);
|
||||
}
|
||||
|
||||
|
@ -215,7 +220,7 @@ public class AcidEffectTest {
|
|||
verify(player).setVelocity(argument.capture());
|
||||
assertTrue(argument.getValue().getBlockY() == 1D);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onSeaBounce(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -226,7 +231,7 @@ public class AcidEffectTest {
|
|||
ae.onSeaBounce(e);
|
||||
verify(player, never()).setVelocity(any());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onSeaBounce(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -237,7 +242,7 @@ public class AcidEffectTest {
|
|||
ae.onSeaBounce(e);
|
||||
verify(player, never()).setVelocity(any());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onSeaBounce(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -248,7 +253,7 @@ public class AcidEffectTest {
|
|||
ae.onSeaBounce(e);
|
||||
verify(player, never()).setVelocity(any());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onSeaBounce(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -269,7 +274,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, times(2)).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -280,7 +285,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, never()).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -292,7 +297,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, times(2)).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -303,7 +308,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, never()).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -314,7 +319,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -326,7 +331,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, times(2)).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -338,7 +343,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -351,7 +356,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -364,7 +369,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, times(2)).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -375,7 +380,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -383,15 +388,15 @@ public class AcidEffectTest {
|
|||
public void testOnPlayerMoveAcidRainWrongWorld() {
|
||||
World nether = mock(World.class);
|
||||
when(nether.getName()).thenReturn("world_nether");
|
||||
when(nether.getEnvironment()).thenReturn(Environment.NETHER);
|
||||
when(nether.getEnvironment()).thenReturn(Environment.NETHER);
|
||||
when(player.getWorld()).thenReturn(nether);
|
||||
|
||||
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(player, from, to);
|
||||
ae.onPlayerMove(e);
|
||||
// 3 times only
|
||||
verify(addon, times(3)).getPlugin();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -399,15 +404,15 @@ public class AcidEffectTest {
|
|||
public void testOnPlayerMoveAcidRainWrongWorldEnd() {
|
||||
World end = mock(World.class);
|
||||
when(end.getName()).thenReturn("world_end");
|
||||
when(end.getEnvironment()).thenReturn(Environment.THE_END);
|
||||
when(end.getEnvironment()).thenReturn(Environment.THE_END);
|
||||
when(player.getWorld()).thenReturn(end);
|
||||
|
||||
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(player, from, to);
|
||||
ae.onPlayerMove(e);
|
||||
// 3 times only
|
||||
verify(addon, times(3)).getPlugin();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -418,7 +423,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -430,7 +435,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, never()).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -442,7 +447,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -455,7 +460,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -468,7 +473,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, never()).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -482,7 +487,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, never()).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -508,7 +513,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, never()).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -522,7 +527,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -535,7 +540,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, never()).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -548,7 +553,7 @@ public class AcidEffectTest {
|
|||
ae.onPlayerMove(e);
|
||||
verify(settings, never()).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
@ -579,7 +584,66 @@ public class AcidEffectTest {
|
|||
when(player.getEquipment()).thenReturn(equip);
|
||||
double a = AcidEffect.getDamageReduced(player);
|
||||
assertTrue(a == 0.8);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#checkForRain(Player)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCheckForRain() {
|
||||
when(world.hasStorm()).thenReturn(true);
|
||||
when(player.isDead()).thenReturn(false);
|
||||
when(settings.getAcidRainDamage()).thenReturn(10);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
assertFalse(ae.checkForRain(player));
|
||||
when(world.hasStorm()).thenReturn(false);
|
||||
when(player.isDead()).thenReturn(false);
|
||||
when(settings.getAcidRainDamage()).thenReturn(10);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
assertTrue(ae.checkForRain(player));
|
||||
when(world.hasStorm()).thenReturn(true);
|
||||
when(player.isDead()).thenReturn(true);
|
||||
when(settings.getAcidRainDamage()).thenReturn(10);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
assertTrue(ae.checkForRain(player));
|
||||
when(world.hasStorm()).thenReturn(true);
|
||||
when(player.isDead()).thenReturn(false);
|
||||
when(settings.getAcidRainDamage()).thenReturn(0);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
assertTrue(ae.checkForRain(player));
|
||||
when(world.hasStorm()).thenReturn(true);
|
||||
when(player.isDead()).thenReturn(false);
|
||||
when(settings.getAcidRainDamage()).thenReturn(10);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NETHER);
|
||||
assertTrue(ae.checkForRain(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#checkForRain(Player)}.
|
||||
*/
|
||||
@Test
|
||||
public void testCheckForRainWetPlayer() {
|
||||
AttributeInstance value = mock(AttributeInstance.class);
|
||||
when(value.getValue()).thenReturn(20D);
|
||||
// Diamond armor
|
||||
when(player.getAttribute(eq(Attribute.GENERIC_ARMOR))).thenReturn(value);
|
||||
EntityEquipment equip = mock(EntityEquipment.class);
|
||||
when(equip.getBoots()).thenReturn(new ItemStack(Material.DIAMOND_BOOTS));
|
||||
when(equip.getHelmet()).thenReturn(new ItemStack(Material.DIAMOND_HELMET));
|
||||
when(equip.getLeggings()).thenReturn(new ItemStack(Material.DIAMOND_LEGGINGS));
|
||||
when(equip.getChestplate()).thenReturn(new ItemStack(Material.DIAMOND_CHESTPLATE));
|
||||
when(player.getEquipment()).thenReturn(equip);
|
||||
|
||||
when(settings.getAcidDamageDelay()).thenReturn(0L);
|
||||
when(world.hasStorm()).thenReturn(true);
|
||||
when(player.isDead()).thenReturn(false);
|
||||
when(settings.getAcidRainDamage()).thenReturn(10);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
testOnPlayerMoveAcidAndRainDamage();
|
||||
|
||||
assertFalse(ae.checkForRain(player));
|
||||
verify(player).damage(2.0d); // Reduced due to armor
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue