Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.21.0</build.version>
<build.version>1.22.0</build.version>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_AcidIsland</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down
48 changes: 32 additions & 16 deletions src/main/java/world/bentobox/acidisland/AISettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ public class AISettings implements WorldSettings {
@ConfigEntry(path = "acid.purified-water.enabled", since = "1.21")
private boolean purifiedWaterEnabled = true;

@ConfigComment("Damage dealt to a player who drinks an acid water bottle (in half-hearts)")
@ConfigEntry(path = "acid.purified-water.drink-damage", since = "1.21")
private double acidDrinkDamage = 4.0;

@ConfigComment("Health restored to a player who drinks a purified water bottle (in half-hearts)")
@ConfigEntry(path = "acid.purified-water.heal-amount", since = "1.21")
private double purifiedWaterHeal = 4.0;
Expand All @@ -163,6 +159,14 @@ public class AISettings implements WorldSettings {
@ConfigEntry(path = "acid.purified-water.bucket-furnace-enabled", since = "1.21")
private boolean purifiedBucketFurnaceEnabled = true;

@ConfigComment("Run the purified water mechanic in the addon's Nether world (island or vanilla).")
@ConfigEntry(path = "acid.purified-water.nether-enabled", since = "1.22")
private boolean purifiedWaterNetherEnabled = true;

@ConfigComment("Run the purified water mechanic in the addon's End world (island or vanilla).")
@ConfigEntry(path = "acid.purified-water.end-enabled", since = "1.22")
private boolean purifiedWaterEndEnabled = true;


/* WORLD */
@ConfigComment("Friendly name for this world. Used in admin commands. Must be a single word")
Expand Down Expand Up @@ -693,12 +697,6 @@ public int getAcidDamageMonster() {
public long getAcidDestroyItemTime() {
return acidDestroyItemTime;
}
/**
* @return damage dealt when drinking an acid water bottle (half-hearts)
*/
public double getAcidDrinkDamage() {
return acidDrinkDamage;
}
/**
* @return the acidEffects
*/
Expand Down Expand Up @@ -729,6 +727,18 @@ public boolean isPurifiedWaterEnabled() {
public boolean isPurifiedBucketFurnaceEnabled() {
return purifiedBucketFurnaceEnabled;
}
/**
* @return true if the purified water mechanic runs in the island Nether
*/
public boolean isPurifiedWaterNetherEnabled() {
return purifiedWaterNetherEnabled;
}
/**
* @return true if the purified water mechanic runs in the island End
*/
public boolean isPurifiedWaterEndEnabled() {
return purifiedWaterEndEnabled;
}

@Override
public int getBanLimit() {
Expand Down Expand Up @@ -1206,12 +1216,6 @@ public boolean isWaterUnsafe() {
public void setAcidDamage(int acidDamage) {
this.acidDamage = acidDamage;
}
/**
* @param acidDrinkDamage damage dealt when drinking an acid water bottle (half-hearts)
*/
public void setAcidDrinkDamage(double acidDrinkDamage) {
this.acidDrinkDamage = acidDrinkDamage;
}
/**
* @param purifiedWaterEnabled true to enable the purified water mechanic
*/
Expand All @@ -1230,6 +1234,18 @@ public void setPurifiedWaterHeal(double purifiedWaterHeal) {
public void setPurifiedBucketFurnaceEnabled(boolean purifiedBucketFurnaceEnabled) {
this.purifiedBucketFurnaceEnabled = purifiedBucketFurnaceEnabled;
}
/**
* @param purifiedWaterNetherEnabled true to run the mechanic in the island Nether
*/
public void setPurifiedWaterNetherEnabled(boolean purifiedWaterNetherEnabled) {
this.purifiedWaterNetherEnabled = purifiedWaterNetherEnabled;
}
/**
* @param purifiedWaterEndEnabled true to run the mechanic in the island End
*/
public void setPurifiedWaterEndEnabled(boolean purifiedWaterEndEnabled) {
this.purifiedWaterEndEnabled = purifiedWaterEndEnabled;
}
/**
* @param acidDamageAnimal the acidDamageAnimal to set
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionType;

import world.bentobox.acidisland.AISettings;
import world.bentobox.acidisland.AcidIsland;
import world.bentobox.acidisland.events.ItemFillWithAcidEvent;
import world.bentobox.acidisland.events.PlayerDrinkPurifiedWaterEvent;
Expand Down Expand Up @@ -226,7 +227,7 @@ private Component lore(String key) {
@EventHandler(ignoreCancelled = true)
public void onCauldronChange(CauldronLevelChangeEvent e) {
if (!addon.getSettings().isPurifiedWaterEnabled()) return;
if (!e.getBlock().getWorld().equals(addon.getOverWorld())) return;
if (!isAcidIslandWorld(e.getBlock().getWorld())) return;

Location loc = e.getBlock().getLocation();
ChangeReason reason = e.getReason();
Expand Down Expand Up @@ -276,7 +277,7 @@ public void onBottleFill(PlayerInteractEvent e) {
if (!addon.getSettings().isPurifiedWaterEnabled()) return;

Player player = e.getPlayer();
if (!player.getWorld().equals(addon.getOverWorld())) return;
if (!isAcidIslandWorld(player.getWorld())) return;

ItemStack item = e.getItem();
if (item == null || item.getType() != Material.GLASS_BOTTLE) return;
Expand Down Expand Up @@ -337,7 +338,7 @@ public void onBottleFill(PlayerInteractEvent e) {
@EventHandler(ignoreCancelled = true)
public void onBucketFill(PlayerBucketFillEvent e) {
if (!addon.getSettings().isPurifiedWaterEnabled()) return;
if (!e.getPlayer().getWorld().equals(addon.getOverWorld())) return;
if (!isAcidIslandWorld(e.getPlayer().getWorld())) return;

ItemStack result = e.getItemStack();
if (result == null || result.getType() != Material.WATER_BUCKET) return;
Expand Down Expand Up @@ -451,6 +452,25 @@ private Optional<Island> getIsland(Player player) {
return addon.getIslands().getIslandAt(player.getLocation());
}

/**
* @return {@code true} if the purified water mechanic should operate in the given world.
* The mechanic always runs in the AcidIsland overworld. It also runs in the addon's Nether
* and End worlds (whether they are island or vanilla) when the per-dimension config toggle
* is enabled.
*/
private boolean isAcidIslandWorld(World world) {
if (world == null) return false;
if (world.equals(addon.getOverWorld())) return true;
AISettings s = addon.getSettings();
if (world.equals(addon.getNetherWorld()) && s.isPurifiedWaterNetherEnabled()) {
return true;
}
if (world.equals(addon.getEndWorld()) && s.isPurifiedWaterEndEnabled()) {
return true;
}
return false;
}

/**
* Returns {@code true} if there is a downward-pointing dripstone stalactite tip
* within 12 blocks directly above the given block.
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ acid:
purified-water:
# Enable or disable the entire purified water mechanic.
enabled: true
# Damage (in half-hearts) dealt to a player who drinks an acid water bottle.
drink-damage: 4.0
# Health (in half-hearts) restored to a player who drinks a purified water bottle.
heal-amount: 4.0
# Allow purifying a water bucket by smelting it in a furnace.
# Cook time is 2000 ticks (100 seconds) to balance the effort.
# Disable if this feels too easy for your server's balance.
bucket-furnace-enabled: true
# Run the purified water mechanic in the addon's Nether world (island or vanilla).
nether-enabled: true
# Run the purified water mechanic in the addon's End world (island or vanilla).
end-enabled: true
world:
# Friendly name for this world. Used in admin commands. Must be a single word
# /!\ 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.
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/locales/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ acidisland:
line1: "[name]"
line2: "Voda je kyselina!"
line3: "Buď opatrný! <red><3"


purified-water:
lore-acid: "<red>Kyselá voda"
lore-purified: "<green>Čistá voda"
3 changes: 3 additions & 0 deletions src/main/resources/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: Achtung! Das Wasser
line3: "ist vergiftet! <red><3"
purified-water:
lore-acid: "<red>Säurewasser"
lore-purified: "<green>Gereinigtes Wasser"
3 changes: 3 additions & 0 deletions src/main/resources/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ acidisland:
line1: "[name]"
line2: "El Agua es acida!"
line3: "Ten cuidado! <red><3"
purified-water:
lore-acid: "<red>Agua ácida"
lore-purified: "<green>Agua purificada"
3 changes: 3 additions & 0 deletions src/main/resources/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: L'eau est acide!
line3: "Faites attention! <red><3"
purified-water:
lore-acid: "<red>Eau acide"
lore-purified: "<green>Eau purifiée"
3 changes: 3 additions & 0 deletions src/main/resources/locales/hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: Voda je kiselina!
line3: "Budi oprezan! <red><3"
purified-water:
lore-acid: "<red>Kisela voda"
lore-purified: "<green>Pročišćena voda"
3 changes: 3 additions & 0 deletions src/main/resources/locales/hu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ acidisland:
line2: "A víz savas!"
line3: "Légy óvatos! <red><3"

purified-water:
lore-acid: "<red>Savas víz"
lore-purified: "<green>Tisztított víz"
3 changes: 3 additions & 0 deletions src/main/resources/locales/id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ acidisland:
line2: Airnya Asam!
line3: "Hati-hati! <red><3"

purified-water:
lore-acid: "<red>Air asam"
lore-purified: "<green>Air murni"
3 changes: 3 additions & 0 deletions src/main/resources/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ acidisland:
line1: "[name]"
line2: "L''acqua è acida!"
line3: "Stai attento! <red><3"
purified-water:
lore-acid: "<red>Acqua acida"
lore-purified: "<green>Acqua purificata"
3 changes: 3 additions & 0 deletions src/main/resources/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: 水は酸性です!
line3: "注意してください! <red><3"
purified-water:
lore-acid: "<red>酸性の水"
lore-purified: "<green>浄化された水"
3 changes: 3 additions & 0 deletions src/main/resources/locales/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: 물은 산성 입니다!
line3: "조심하세요! <red><3"
purified-water:
lore-acid: "<red>산성 물"
lore-purified: "<green>정화된 물"
3 changes: 3 additions & 0 deletions src/main/resources/locales/lv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: Ūdens satur skābi!
line3: "Esi uzmanīgs! <red><3"
purified-water:
lore-acid: "<red>Skābes ūdens"
lore-purified: "<green>Attīrīts ūdens"
3 changes: 3 additions & 0 deletions src/main/resources/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: Woda jest kwaśna!
line3: "Bądź ostrożny! <red><3"
purified-water:
lore-acid: "<red>Kwaśna woda"
lore-purified: "<green>Oczyszczona woda"
3 changes: 3 additions & 0 deletions src/main/resources/locales/ro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ acidisland:
line2: Apa este acida!
line3: "Ai grija! <red><3"

purified-water:
lore-acid: "<red>Apă acidă"
lore-purified: "<green>Apă purificată"
3 changes: 3 additions & 0 deletions src/main/resources/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: Выживание в море!
line3: "Удачной игры! <red><3"
purified-water:
lore-acid: "<red>Кислотная вода"
lore-purified: "<green>Очищенная вода"
3 changes: 3 additions & 0 deletions src/main/resources/locales/tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: Su asitli!
line3: "Dikkat et! <red><3"
purified-water:
lore-acid: "<red>Asitli Su"
lore-purified: "<green>Arıtılmış Su"
3 changes: 3 additions & 0 deletions src/main/resources/locales/uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: Вода кислотна!
line3: "Будь обережний! <red><3"
purified-water:
lore-acid: "<red>Кислотна вода"
lore-purified: "<green>Очищена вода"
3 changes: 3 additions & 0 deletions src/main/resources/locales/vi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ acidisland:
line1: "[name]"
line2: Nước là axit!
line3: "Hãy cẩn thận! <red><3"
purified-water:
lore-acid: "<red>Nước axit"
lore-purified: "<green>Nước tinh khiết"
5 changes: 4 additions & 1 deletion src/main/resources/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ acidisland:
line1: "[name]"
line2: "水是酸的!"
line3: "要小心哟!<red><3"


purified-water:
lore-acid: "<red>酸水"
lore-purified: "<green>纯净水"
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ void setUp() {

when(settings.isPurifiedWaterEnabled()).thenReturn(true);
when(settings.isPurifiedBucketFurnaceEnabled()).thenReturn(true);
when(settings.getAcidDrinkDamage()).thenReturn(4.0);
when(settings.getPurifiedWaterHeal()).thenReturn(4.0);

when(player.getWorld()).thenReturn(world);
Expand Down
Loading