Merge branch 'develop' of

https://github.com/BentoBoxWorld/acidisland.git into develop

Conflicts:
	pom.xml
This commit is contained in:
tastybento 2019-01-26 16:36:05 -08:00
commit 95eb5dafe9

View File

@ -7,8 +7,11 @@ import java.util.WeakHashMap;
import java.util.stream.Stream;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Drowned;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
@ -16,6 +19,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.MagmaCube;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Squid;
import org.bukkit.entity.Turtle;
import world.bentobox.acidisland.AcidIsland;
@ -36,14 +40,14 @@ public class AcidTask {
}
/**
* Start the entity buring task
* Start the entity burning task
*/
private void burnEntities() {
// This part will kill monsters if they fall into the water because it is acid
entityBurnTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(addon.getPlugin(), () -> getEntityStream()
.filter(e -> !(e instanceof Guardian || e instanceof Squid))
// TODO: remove backwards compatibility hack
.filter(w -> w.getLocation().getBlock().getType().name().contains("WATER"))
// These entities are immune to acid
.filter(e -> !(e instanceof Guardian || e instanceof Squid || e instanceof Turtle || e instanceof Drowned))
.filter(w -> w.getLocation().getBlock().getType().equals(Material.WATER))
.forEach(e -> {
if ((e instanceof Monster || e instanceof MagmaCube) && addon.getSettings().getAcidDamageMonster() > 0D) {
((LivingEntity) e).damage(addon.getSettings().getAcidDamageMonster());
@ -54,6 +58,9 @@ public class AcidTask {
}), 0L, 20L);
}
/**
* @return a stream of all entities in this world and the nether and end if those are island worlds too.
*/
private Stream<Entity> getEntityStream() {
Stream<Entity> entityStream = addon.getOverWorld().getEntities().stream();
// Nether and end
@ -75,9 +82,10 @@ public class AcidTask {
}
itemBurnTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(addon.getPlugin(), () -> {
Set<Entity> newItemsInWater = new HashSet<>();
getEntityStream().filter(e -> e.getType().equals(EntityType.DROPPED_ITEM)
&& (e.getLocation().getBlock().getType().name().contains("WATER"))
)
getEntityStream()
.filter(e -> e.getType().equals(EntityType.DROPPED_ITEM))
.filter(e -> e.getLocation().getBlock().getType().equals(Material.WATER)
|| (e.getLocation().getY() > 0 && e.getLocation().getBlock().getRelative(BlockFace.DOWN).getType().equals(Material.WATER)))
.forEach(e -> {
if (itemsInWater.contains(e)) {
e.getWorld().playSound(e.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 3F, 3F);