Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Mar 24, 2020
2 parents 6548082 + e5f1539 commit 4579aff
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 141 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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.11.0</build.version>
<build.version>1.12.0</build.version>
</properties>

<!-- Profiles will allow to automatically change build version. -->
Expand Down
122 changes: 122 additions & 0 deletions src/main/java/world/bentobox/acidisland/AISettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public class AISettings implements WorldSettings {
@ConfigEntry(path = "acid.damage.effects")
@Adapter(PotionEffectListAdapter.class)
private List<PotionEffectType> acidEffects = new ArrayList<>();
@ConfigComment("Acid effect duration in seconds")
@ConfigEntry(path = "acid.damage.acid-effect-duration", since = "1.11.2")
private int acidEffectDuation = 30;

@ConfigComment("Potion effects from going into acid rain and snow.")
@ConfigComment("You can list multiple effects.")
Expand All @@ -110,6 +113,10 @@ public class AISettings implements WorldSettings {
@Adapter(PotionEffectListAdapter.class)
private List<PotionEffectType> acidRainEffects = new ArrayList<>();

@ConfigComment("Rain effect duration in seconds")
@ConfigEntry(path = "acid.damage.rain-effect-duration", since = "1.11.2")
private int rainEffectDuation = 10;

@ConfigComment("If player wears a helmet then they will not suffer from acid rain")
@ConfigEntry(path = "acid.damage.protection.helmet")
private boolean helmetProtection;
Expand All @@ -134,6 +141,25 @@ public class AISettings implements WorldSettings {
@ConfigEntry(path = "world.difficulty")
private Difficulty difficulty;

@ConfigComment("Spawn limits. These override the limits set in bukkit.yml")
@ConfigComment("If set to a negative number, the server defaults will be used")
@ConfigEntry(path = "world.spawn-limits.monsters", since = "1.11.2")
private int spawnLimitMonsters = -1;
@ConfigEntry(path = "world.spawn-limits.animals", since = "1.11.2")
private int spawnLimitAnimals = -1;
@ConfigEntry(path = "world.spawn-limits.water-animals", since = "1.11.2")
private int spawnLimitWaterAnimals = -1;
@ConfigEntry(path = "world.spawn-limits.ambient", since = "1.11.2")
private int spawnLimitAmbient = -1;
@ConfigComment("Setting to 0 will disable animal spawns, but this is not recommended. Minecraft default is 400.")
@ConfigComment("A negative value uses the server default")
@ConfigEntry(path = "world.spawn-limits.ticks-per-animal-spawns", since = "1.11.2")
private int ticksPerAnimalSpawns = -1;
@ConfigComment("Setting to 0 will disable monster spawns, but this is not recommended. Minecraft default is 400.")
@ConfigComment("A negative value uses the server default")
@ConfigEntry(path = "world.spawn-limits.ticks-per-monster-spawns", since = "1.11.2")
private int ticksPerMonsterSpawns = -1;

@ConfigComment("Radius of island in blocks. (So distance between islands is twice this)")
@ConfigComment("Will be rounded up to the nearest 16 blocks.")
@ConfigComment("It is the same for every dimension : Overworld, Nether and End.")
Expand Down Expand Up @@ -1571,4 +1597,100 @@ public List<PotionEffectType> getAcidRainEffects() {
public void setAcidRainEffects(List<PotionEffectType> acidRainEffects) {
this.acidRainEffects = acidRainEffects;
}
/**
* @return the rainEffectDuation
*/
public int getRainEffectDuation() {
return rainEffectDuation;
}
/**
* @param rainEffectDuation the rainEffectDuation to set
*/
public void setRainEffectDuation(int rainEffectDuation) {
this.rainEffectDuation = rainEffectDuation;
}
/**
* @return the acidEffectDuation
*/
public int getAcidEffectDuation() {
return acidEffectDuation;
}
/**
* @param acidEffectDuation the acidEffectDuation to set
*/
public void setAcidEffectDuation(int acidEffectDuation) {
this.acidEffectDuation = acidEffectDuation;
}
/**
* @return the spawnLimitMonsters
*/
public int getSpawnLimitMonsters() {
return spawnLimitMonsters;
}
/**
* @param spawnLimitMonsters the spawnLimitMonsters to set
*/
public void setSpawnLimitMonsters(int spawnLimitMonsters) {
this.spawnLimitMonsters = spawnLimitMonsters;
}
/**
* @return the spawnLimitAnimals
*/
public int getSpawnLimitAnimals() {
return spawnLimitAnimals;
}
/**
* @param spawnLimitAnimals the spawnLimitAnimals to set
*/
public void setSpawnLimitAnimals(int spawnLimitAnimals) {
this.spawnLimitAnimals = spawnLimitAnimals;
}
/**
* @return the spawnLimitWaterAnimals
*/
public int getSpawnLimitWaterAnimals() {
return spawnLimitWaterAnimals;
}
/**
* @param spawnLimitWaterAnimals the spawnLimitWaterAnimals to set
*/
public void setSpawnLimitWaterAnimals(int spawnLimitWaterAnimals) {
this.spawnLimitWaterAnimals = spawnLimitWaterAnimals;
}
/**
* @return the spawnLimitAmbient
*/
public int getSpawnLimitAmbient() {
return spawnLimitAmbient;
}
/**
* @param spawnLimitAmbient the spawnLimitAmbient to set
*/
public void setSpawnLimitAmbient(int spawnLimitAmbient) {
this.spawnLimitAmbient = spawnLimitAmbient;
}
/**
* @return the ticksPerAnimalSpawns
*/
public int getTicksPerAnimalSpawns() {
return ticksPerAnimalSpawns;
}
/**
* @param ticksPerAnimalSpawns the ticksPerAnimalSpawns to set
*/
public void setTicksPerAnimalSpawns(int ticksPerAnimalSpawns) {
this.ticksPerAnimalSpawns = ticksPerAnimalSpawns;
}
/**
* @return the ticksPerMonsterSpawns
*/
public int getTicksPerMonsterSpawns() {
return ticksPerMonsterSpawns;
}
/**
* @param ticksPerMonsterSpawns the ticksPerMonsterSpawns to set
*/
public void setTicksPerMonsterSpawns(int ticksPerMonsterSpawns) {
this.ticksPerMonsterSpawns = ticksPerMonsterSpawns;
}
}
45 changes: 30 additions & 15 deletions src/main/java/world/bentobox/acidisland/AcidIsland.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.World.Environment;
import org.bukkit.generator.ChunkGenerator;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -104,33 +105,47 @@ public void createWorlds() {
}
// Create the world if it does not exist
chunkGenerator = new ChunkGeneratorWorld(this);
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(chunkGenerator)
.createWorld();
islandWorld = getWorld(worldName, World.Environment.NORMAL, chunkGenerator);
// Make the nether if it does not exist
if (settings.isNetherGenerate()) {
if (getServer().getWorld(worldName + NETHER) == null) {
log("Creating AcidIsland's Nether...");
}
if (!settings.isNetherIslands()) {
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();

} else {
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(chunkGenerator)
.environment(World.Environment.NETHER).createWorld();
}
netherWorld = settings.isNetherIslands() ? getWorld(worldName, World.Environment.NETHER, chunkGenerator) : getWorld(worldName, World.Environment.NETHER, null);
}
// Make the end if it does not exist
if (settings.isEndGenerate()) {
if (getServer().getWorld(worldName + THE_END) == null) {
log("Creating AcidIsland's End World...");
}
if (!settings.isEndIslands()) {
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
} else {
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(chunkGenerator)
.environment(World.Environment.THE_END).createWorld();
}
endWorld = settings.isEndIslands() ? getWorld(worldName, World.Environment.THE_END, chunkGenerator) : getWorld(worldName, World.Environment.THE_END, null);
}
}

/**
* Gets a world or generates a new world if it does not exist
* @param worldName2 - the overworld name
* @param env - the environment
* @param chunkGenerator2 - the chunk generator. If <tt>null</tt> then the generator will not be specified
* @return world loaded or generated
*/
private World getWorld(String worldName2, Environment env, @Nullable ChunkGenerator chunkGenerator2) {
// Set world name
worldName2 = env.equals(World.Environment.NETHER) ? worldName2 + NETHER : worldName2;
worldName2 = env.equals(World.Environment.THE_END) ? worldName2 + THE_END : worldName2;
WorldCreator wc = WorldCreator.name(worldName2).type(WorldType.FLAT).environment(env);
World w = settings.isUseOwnGenerator() ? wc.createWorld() : wc.generator(chunkGenerator2).createWorld();
// Set spawn rates
if (w != null) {
w.setMonsterSpawnLimit(getSettings().getSpawnLimitMonsters());
w.setAmbientSpawnLimit(getSettings().getSpawnLimitAmbient());
w.setAnimalSpawnLimit(getSettings().getSpawnLimitAnimals());
w.setWaterAnimalSpawnLimit(getSettings().getSpawnLimitWaterAnimals());
w.setTicksPerAnimalSpawns(getSettings().getTicksPerAnimalSpawns());
w.setTicksPerMonsterSpawns(getSettings().getTicksPerMonsterSpawns());
}
return w;

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public class AcidEffect implements Listener {
PotionEffectType.HUNGER,
PotionEffectType.SLOW,
PotionEffectType.SLOW_DIGGING,
PotionEffectType.WEAKNESS);
PotionEffectType.WEAKNESS,
PotionEffectType.POISON);
private static final List<PotionEffectType> IMMUNE_EFFECTS = Arrays.asList(
PotionEffectType.WATER_BREATHING,
PotionEffectType.CONDUIT_POWER);
Expand Down Expand Up @@ -88,7 +89,6 @@ public void onPlayerMove(PlayerMoveEvent e) {
|| addon.getPlayers().isInTeleport(player.getUniqueId())
|| !Util.sameWorld(addon.getOverWorld(), player.getWorld())
|| (!player.isOp() && player.hasPermission("acidisland.mod.noburn"))
|| (!player.isOp() && player.hasPermission("admin.noburn"))
|| (player.isOp() && !addon.getSettings().isAcidDamageOp())) {
return;
}
Expand Down Expand Up @@ -120,8 +120,7 @@ public void run() {
AcidRainEvent event = new AcidRainEvent(player, totalDamage, protection, addon.getSettings().getAcidRainEffects());
addon.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
event.getPotionEffects().stream().filter(EFFECTS::contains).forEach(t -> player.addPotionEffect(new PotionEffect(t, 600, 1)));
event.getPotionEffects().stream().filter(e -> e.equals(PotionEffectType.POISON)).forEach(t -> player.addPotionEffect(new PotionEffect(t, 200, 1)));
event.getPotionEffects().stream().filter(EFFECTS::contains).forEach(t -> player.addPotionEffect(new PotionEffect(t, addon.getSettings().getRainEffectDuation() * 20, 1)));
// Apply damage if there is any
if (event.getRainDamage() > 0D) {
player.damage(event.getRainDamage());
Expand Down Expand Up @@ -159,8 +158,7 @@ public void run() {
AcidEvent acidEvent = new AcidEvent(player, totalDamage, protection, addon.getSettings().getAcidEffects());
addon.getServer().getPluginManager().callEvent(acidEvent);
if (!acidEvent.isCancelled()) {
acidEvent.getPotionEffects().stream().filter(EFFECTS::contains).forEach(t -> player.addPotionEffect(new PotionEffect(t, 600, 1)));
acidEvent.getPotionEffects().stream().filter(e -> e.equals(PotionEffectType.POISON)).forEach(t -> player.addPotionEffect(new PotionEffect(t, 200, 1)));
acidEvent.getPotionEffects().stream().filter(EFFECTS::contains).forEach(t -> player.addPotionEffect(new PotionEffect(t, addon.getSettings().getAcidEffectDuation() * 20, 1)));
// Apply damage if there is any
if (acidEvent.getTotalDamage() > 0D) {
player.damage(acidEvent.getTotalDamage());
Expand Down
Loading

0 comments on commit 4579aff

Please sign in to comment.