Compare commits
1 Commits
master
...
develop-bl
Author | SHA1 | Date | |
---|---|---|---|
4955e94306 |
@@ -0,0 +1,54 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener.BloodmoonMonsterDeathListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class Bloodmoon extends Appliance {
|
||||
// für alle Dimensionen? einstellbar machen?
|
||||
|
||||
public final Set<EntityType> affectedMobs = Set.of(
|
||||
EntityType.ZOMBIE,
|
||||
EntityType.SKELETON,
|
||||
EntityType.SPIDER,
|
||||
EntityType.CREEPER,
|
||||
EntityType.HUSK,
|
||||
EntityType.DROWNED,
|
||||
EntityType.WITCH,
|
||||
EntityType.ZOMBIE_VILLAGER,
|
||||
EntityType.PHANTOM,
|
||||
EntityType.ENDERMAN
|
||||
);
|
||||
public final int expMultiplier = 4;
|
||||
public final boolean summonLightning = true;
|
||||
|
||||
private final int minBonusDrops = 1;
|
||||
private final int maxBonusDrops = 4;
|
||||
|
||||
public boolean bloodmoonIsActive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Set<ItemStack> getRandomBonusDrops() {
|
||||
int itemCount = ThreadLocalRandom.current().nextInt(this.minBonusDrops, this.maxBonusDrops + 1);
|
||||
return Set.of(
|
||||
new ItemStack(Material.DIAMOND_BLOCK, 2),
|
||||
new ItemStack(Material.IRON_BARS, 3)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull List<Listener> listeners() {
|
||||
return List.of(
|
||||
new BloodmoonMonsterDeathListener()
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.listener;
|
||||
|
||||
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||
import eu.mhsl.craftattack.spawn.craftattack.appliances.gameplay.bloodmoon.Bloodmoon;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
public class BloodmoonMonsterDeathListener extends ApplianceListener<Bloodmoon> {
|
||||
@EventHandler
|
||||
public void onMonsterDeath(EntityDeathEvent event) {
|
||||
if(!this.getAppliance().bloodmoonIsActive()) return;
|
||||
LivingEntity entity = event.getEntity();
|
||||
if(!this.getAppliance().affectedMobs.contains(entity.getType())) return;
|
||||
|
||||
event.setDroppedExp(event.getDroppedExp() * this.getAppliance().expMultiplier);
|
||||
event.getDrops().addAll(this.getAppliance().getRandomBonusDrops());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user