Skip to content

Commit f7ae02f

Browse files
authored
Merge pull request #159 from BentoBoxWorld/develop
Release 1.19.0
2 parents eb1ef35 + 284e7e9 commit f7ae02f

File tree

10 files changed

+215
-23
lines changed

10 files changed

+215
-23
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@
5959
<powermock.version>2.0.9</powermock.version>
6060
<!-- More visible way how to change dependency versions -->
6161
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
62-
<bentobox.version>2.0.0-SNAPSHOT</bentobox.version>
62+
<bentobox.version>2.5.0-SNAPSHOT</bentobox.version>
6363
<!-- Revision variable removes warning about dynamic version -->
6464
<revision>${build.version}-SNAPSHOT</revision>
6565
<!-- Do not change unless you want different name for local builds. -->
6666
<build.number>-LOCAL</build.number>
6767
<!-- This allows to change between versions. -->
68-
<build.version>1.18.2</build.version>
68+
<build.version>1.19.0</build.version>
6969
<!-- Sonar Cloud -->
7070
<sonar.projectKey>BentoBoxWorld_AcidIsland</sonar.projectKey>
7171
<sonar.organization>bentobox-world</sonar.organization>

src/main/java/world/bentobox/acidisland/AISettings.java

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import com.google.common.base.Enums;
1313

14+
import world.bentobox.bentobox.BentoBox;
1415
import world.bentobox.bentobox.api.configuration.ConfigComment;
1516
import world.bentobox.bentobox.api.configuration.ConfigEntry;
1617
import world.bentobox.bentobox.api.configuration.StoreAt;
@@ -201,6 +202,15 @@ public class AISettings implements WorldSettings {
201202
@ConfigEntry(path = "world.island-height")
202203
private int islandHeight = 50;
203204

205+
@ConfigComment("The number of concurrent islands a player can have in the world")
206+
@ConfigComment("A value of 0 will use the BentoBox config.yml default")
207+
@ConfigEntry(path = "world.concurrent-islands")
208+
private int concurrentIslands = 0;
209+
210+
@ConfigComment("Disallow players to have other islands if they are in a team.")
211+
@ConfigEntry(path = "world.disallow-team-member-islands")
212+
boolean disallowTeamMemberIslands = true;
213+
204214
@ConfigComment("Use your own world generator for this world.")
205215
@ConfigComment("In this case, the plugin will not generate anything.")
206216
@ConfigEntry(path = "world.use-own-generator", experimental = true)
@@ -220,6 +230,21 @@ public class AISettings implements WorldSettings {
220230
@ConfigEntry(path = "world.ocean-floor", needsReset = true)
221231
private boolean oceanFloor = false;
222232

233+
@ConfigComment("Structures")
234+
@ConfigComment("This creates an vanilla structures in the worlds.")
235+
@ConfigEntry(path = "world.make-structures", needsReset = true)
236+
private boolean makeStructures = false;
237+
238+
@ConfigComment("Caves")
239+
@ConfigComment("This creates an vanilla caves in the worlds.")
240+
@ConfigEntry(path = "world.make-caves", needsReset = true)
241+
private boolean makeCaves = false;
242+
243+
@ConfigComment("Decorations")
244+
@ConfigComment("This creates an vanilla decorations in the worlds.")
245+
@ConfigEntry(path = "world.make-decorations", needsReset = true)
246+
private boolean makeDecorations = true;
247+
223248
@ConfigComment("Maximum number of islands in the world. Set to -1 or 0 for unlimited. ")
224249
@ConfigComment("If the number of islands is greater than this number, no new island will be created.")
225250
@ConfigEntry(path = "world.max-islands")
@@ -2024,4 +2049,79 @@ public boolean isOceanFloor() {
20242049
public void setOceanFloor(boolean oceanFloor) {
20252050
this.oceanFloor = oceanFloor;
20262051
}
2052+
2053+
/**
2054+
* @return the makeStructures
2055+
*/
2056+
public boolean isMakeStructures() {
2057+
return makeStructures;
2058+
}
2059+
2060+
/**
2061+
* @param makeStructures the makeStructures to set
2062+
*/
2063+
public void setMakeStructures(boolean makeStructures) {
2064+
this.makeStructures = makeStructures;
2065+
}
2066+
2067+
/**
2068+
* @return the makeCaves
2069+
*/
2070+
public boolean isMakeCaves() {
2071+
return makeCaves;
2072+
}
2073+
2074+
/**
2075+
* @param makeCaves the makeCaves to set
2076+
*/
2077+
public void setMakeCaves(boolean makeCaves) {
2078+
this.makeCaves = makeCaves;
2079+
}
2080+
2081+
/**
2082+
* @return the makeDecorations
2083+
*/
2084+
public boolean isMakeDecorations() {
2085+
return makeDecorations;
2086+
}
2087+
2088+
/**
2089+
* @param makeDecorations the makeDecorations to set
2090+
*/
2091+
public void setMakeDecorations(boolean makeDecorations) {
2092+
this.makeDecorations = makeDecorations;
2093+
}
2094+
2095+
/**
2096+
* @return the disallowTeamMemberIslands
2097+
*/
2098+
@Override
2099+
public boolean isDisallowTeamMemberIslands() {
2100+
return disallowTeamMemberIslands;
2101+
}
2102+
2103+
/**
2104+
* @param disallowTeamMemberIslands the disallowTeamMemberIslands to set
2105+
*/
2106+
public void setDisallowTeamMemberIslands(boolean disallowTeamMemberIslands) {
2107+
this.disallowTeamMemberIslands = disallowTeamMemberIslands;
2108+
}
2109+
2110+
/**
2111+
* @return the concurrentIslands
2112+
*/
2113+
@Override
2114+
public int getConcurrentIslands() {
2115+
if (concurrentIslands <= 0) {
2116+
return BentoBox.getInstance().getSettings().getIslandNumber();
2117+
}
2118+
return concurrentIslands;
2119+
}
2120+
2121+
/**
2122+
* @param concurrentIslands the concurrentIslands to set
2123+
*/
2124+
public void setConcurrentIslands(int concurrentIslands) {
2125+
this.concurrentIslands = concurrentIslands;
2126+
}
20272127
}

src/main/java/world/bentobox/acidisland/AcidIslandPladdon.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33

44
import world.bentobox.bentobox.api.addons.Addon;
5+
import world.bentobox.bentobox.api.addons.GameModeAddon;
56
import world.bentobox.bentobox.api.addons.Pladdon;
67

78
public class AcidIslandPladdon extends Pladdon {
89

10+
private GameModeAddon addon;
11+
912
@Override
1013
public Addon getAddon() {
11-
return new AcidIsland();
14+
if (addon == null) {
15+
addon = new AcidIsland();
16+
}
17+
return addon;
1218
}
1319
}

src/main/java/world/bentobox/acidisland/events/EntityDamageByAcidEvent.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
package world.bentobox.acidisland.events;
22

33
import org.bukkit.entity.Entity;
4+
import org.bukkit.event.Cancellable;
45
import org.bukkit.event.Event;
56
import org.bukkit.event.HandlerList;
67

78
/**
89
* Fired when an entity (items excluded) receives damage from acid
9-
* @author Poslovitch
10+
* @author Poslovitch, tastybento
1011
* @since 1.0
1112
*/
12-
public class EntityDamageByAcidEvent extends Event {
13+
public class EntityDamageByAcidEvent extends Event implements Cancellable {
1314

1415
private final Entity entity;
1516
private double damage;
1617

1718
public enum Acid { RAIN, WATER }
1819
private final Acid cause;
20+
private boolean cancelled;
1921
private static final HandlerList handlers = new HandlerList();
2022

2123
@Override
@@ -64,4 +66,15 @@ public void setDamage(double damage) {
6466
public Acid getCause() {
6567
return cause;
6668
}
69+
70+
@Override
71+
public boolean isCancelled() {
72+
return cancelled;
73+
}
74+
75+
@Override
76+
public void setCancelled(boolean cancel) {
77+
this.cancelled = cancel;
78+
79+
}
6780
}

src/main/java/world/bentobox/acidisland/listeners/AcidEffect.java

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,14 @@ protected boolean checkForRain(Player player) {
178178
// Check they are still in this world
179179
} else if (wetPlayers.containsKey(player) && wetPlayers.get(player) < System.currentTimeMillis()) {
180180
double protection = addon.getSettings().getAcidRainDamage() * getDamageReduced(player);
181-
double totalDamage = Math.max(0, addon.getSettings().getAcidRainDamage() - protection);
181+
182+
User user = User.getInstance(player);
183+
// Get the percentage reduction and ensure the value is between 0 and 100
184+
double percent = (100
185+
- Math.max(0, Math.min(100, user.getPermissionValue("acidisland.protection.rain", 0)))) / 100D;
186+
187+
double totalDamage = Math.max(0, addon.getSettings().getAcidRainDamage() - protection) * percent;
188+
182189
AcidRainEvent event = new AcidRainEvent(player, totalDamage, protection,
183190
addon.getSettings().getAcidRainEffects());
184191
Bukkit.getPluginManager().callEvent(event);
@@ -187,11 +194,13 @@ protected boolean checkForRain(Player player) {
187194
.addPotionEffect(new PotionEffect(t, addon.getSettings().getRainEffectDuation() * 20, 1)));
188195
// Apply damage if there is any
189196
if (event.getRainDamage() > 0D) {
190-
player.damage(event.getRainDamage());
191-
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 3F, 3F);
192197
EntityDamageByAcidEvent e = new EntityDamageByAcidEvent(player, event.getRainDamage(), Acid.RAIN);
193198
// Fire event
194199
Bukkit.getPluginManager().callEvent(e);
200+
if (!e.isCancelled()) {
201+
player.damage(event.getRainDamage());
202+
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 3F, 3F);
203+
}
195204
}
196205
}
197206
}
@@ -204,19 +213,28 @@ protected boolean continuouslyHurtPlayer(Player player) {
204213
return true;
205214
} else if (burningPlayers.containsKey(player) && burningPlayers.get(player) < System.currentTimeMillis()) {
206215
double protection = addon.getSettings().getAcidDamage() * getDamageReduced(player);
207-
double totalDamage = Math.max(0, addon.getSettings().getAcidDamage() - protection);
216+
217+
User user = User.getInstance(player);
218+
// Get the percentage reduction and ensure the value is between 0 and 100
219+
double percent = (100
220+
- Math.max(0, Math.min(100, user.getPermissionValue("acidisland.protection.acid", 0)))) / 100D;
221+
222+
double totalDamage = Math.max(0, addon.getSettings().getAcidDamage() - protection) * percent;
223+
208224
AcidEvent event = new AcidEvent(player, totalDamage, protection, addon.getSettings().getAcidEffects());
209225
addon.getServer().getPluginManager().callEvent(event);
210226
if (!event.isCancelled()) {
211227
event.getPotionEffects().stream().filter(EFFECTS::contains).forEach(t -> player
212228
.addPotionEffect(new PotionEffect(t, addon.getSettings().getAcidEffectDuation() * 20, 1)));
213229
// Apply damage if there is any
214-
if (event.getTotalDamage() > 0D) {
215-
player.damage(event.getTotalDamage());
216-
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 3F, 3F);
230+
if (event.getTotalDamage() > 0D) {
217231
EntityDamageByAcidEvent e = new EntityDamageByAcidEvent(player, event.getTotalDamage(), Acid.WATER);
218232
// Fire event
219233
Bukkit.getPluginManager().callEvent(e);
234+
if (!e.isCancelled()) {
235+
player.damage(event.getTotalDamage());
236+
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 3F, 3F);
237+
}
220238
}
221239
}
222240
}
@@ -230,9 +248,10 @@ protected boolean continuouslyHurtPlayer(Player player) {
230248
*/
231249
private boolean isSafeFromRain(Player player) {
232250
if (isEssentialsGodMode(player) || player.getWorld().getEnvironment().equals(Environment.NETHER)
251+
|| player.getGameMode() != GameMode.SURVIVAL
233252
|| player.getWorld().getEnvironment().equals(Environment.THE_END)
234253
|| (addon.getSettings().isHelmetProtection() && (player.getInventory().getHelmet() != null
235-
&& player.getInventory().getHelmet().getType().name().contains("HELMET")))
254+
&& player.getInventory().getHelmet().getType().name().contains("HELMET")))
236255
|| (!addon.getSettings().isAcidDamageSnow() && player.getLocation().getBlock().getTemperature() < 0.1) // snow falls
237256
|| player.getLocation().getBlock().getHumidity() == 0 // dry
238257
|| (player.getActivePotionEffects().stream().map(PotionEffect::getType)
@@ -260,7 +279,7 @@ private boolean isSafeFromRain(Player player) {
260279
*/
261280
boolean isSafeFromAcid(Player player) {
262281
// Check for GodMode
263-
if (isEssentialsGodMode(player)
282+
if (isEssentialsGodMode(player) || player.getGameMode() != GameMode.SURVIVAL
264283
// Protect visitors
265284
|| (addon.getPlugin().getIWM().getIvSettings(player.getWorld()).contains(DamageCause.CUSTOM.name())
266285
&& !addon.getIslands().userIsOnIsland(player.getWorld(), User.getInstance(player)))) {

src/main/java/world/bentobox/acidisland/world/AcidTask.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class AcidTask {
3737
i.add(EntityType.POLAR_BEAR);
3838
i.add(EntityType.TURTLE);
3939
i.add(EntityType.DROWNED);
40+
i.add(EntityType.GUARDIAN);
41+
i.add(EntityType.ELDER_GUARDIAN);
4042
Enums.getIfPresent(EntityType.class, "AXOLOTL").toJavaUtil().ifPresent(i::add);
4143
IMMUNE = Collections.unmodifiableList(i);
4244
}
@@ -86,10 +88,12 @@ void findEntities() {
8688
void applyDamage(Entity e, long damage) {
8789
if (e instanceof LivingEntity) {
8890
double actualDamage = Math.max(0, damage - damage * AcidEffect.getDamageReduced((LivingEntity)e));
89-
((LivingEntity)e).damage(actualDamage);
9091
EntityDamageByAcidEvent event = new EntityDamageByAcidEvent(e, actualDamage, Acid.WATER);
9192
// Fire event
9293
Bukkit.getPluginManager().callEvent(event);
94+
if (!event.isCancelled()) {
95+
((LivingEntity)e).damage(actualDamage);
96+
}
9397
} else if (addon.getSettings().getAcidDestroyItemTime() > 0 && e instanceof Item){
9498
// Item
9599
if (e.getLocation().getBlock().getType().equals(Material.WATER)) {

src/main/java/world/bentobox/acidisland/world/ChunkGeneratorWorld.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@
2727
*/
2828
public class ChunkGeneratorWorld extends ChunkGenerator {
2929

30+
private record FloorMats(Material base, Material top) {
31+
}
32+
3033
private final AcidIsland addon;
3134
private final Random rand = new Random();
3235
private final Map<Environment, WorldConfig> seaHeight = new EnumMap<>(Environment.class);
3336
private final Map<Vector, Material> roofChunk = new HashMap<>();
37+
private static final Map<Environment, FloorMats> floorMats = Map.of(Environment.NETHER,
38+
new FloorMats(Material.NETHERRACK, Material.SOUL_SAND), Environment.NORMAL,
39+
new FloorMats(Material.SANDSTONE, Material.SAND), Environment.THE_END,
40+
new FloorMats(Material.END_STONE, Material.END_STONE));
3441
private PerlinOctaveGenerator gen;
3542

3643
private record WorldConfig(int seaHeight, Material waterBlock) {}
@@ -72,7 +79,8 @@ private void addNoise(@NonNull WorldInfo worldInfo, int chunkX, int chunkZ, @Non
7279
for (int z = 0; z < 16; z++) {
7380
int n = (int)(25 * gen.noise((chunkX << 4) + (double)x, (chunkZ << 4) + (double)z, 0.5, 0.5, true));
7481
for (int y = worldInfo.getMinHeight(); y < 25 + n; y++) {
75-
chunkData.setBlock(x, y, z, rand.nextBoolean() ? Material.SAND : Material.SANDSTONE);
82+
chunkData.setBlock(x, y, z, rand.nextBoolean() ? floorMats.get(worldInfo.getEnvironment()).top()
83+
: floorMats.get(worldInfo.getEnvironment()).base());
7684
}
7785
}
7886
}
@@ -90,19 +98,19 @@ public boolean shouldGenerateSurface() {
9098
}
9199
@Override
92100
public boolean shouldGenerateCaves() {
93-
return addon.getSettings().isOceanFloor();
101+
return addon.getSettings().isMakeCaves();
94102
}
95103
@Override
96104
public boolean shouldGenerateDecorations() {
97-
return addon.getSettings().isOceanFloor();
105+
return addon.getSettings().isMakeDecorations();
98106
}
99107
@Override
100108
public boolean shouldGenerateMobs() {
101109
return true;
102110
}
103111
@Override
104112
public boolean shouldGenerateStructures() {
105-
return addon.getSettings().isOceanFloor();
113+
return addon.getSettings().isMakeStructures();
106114
}
107115

108116
@Override

src/main/resources/addon.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: AcidIsland
22
main: world.bentobox.acidisland.AcidIsland
33
version: ${version}${build.number}
4-
api-version: 1.22.1
4+
api-version: 2.4.0
55
metrics: true
66
repository: "BentoBoxWorld/AcidIsland"
77
icon: "OAK_BOAT"

0 commit comments

Comments
 (0)