added PhantomReducer
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.phantomReducer;
|
||||||
|
|
||||||
|
import eu.mhsl.craftattack.spawn.core.appliance.Appliance;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PhantomReducer extends Appliance {
|
||||||
|
@Override
|
||||||
|
protected @NotNull List<Listener> listeners() {
|
||||||
|
return List.of(
|
||||||
|
new PhantomSpawnListener()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,16 @@
|
|||||||
|
package eu.mhsl.craftattack.spawn.craftattack.appliances.tweaks.phantomReducer;
|
||||||
|
|
||||||
|
import eu.mhsl.craftattack.spawn.core.appliance.ApplianceListener;
|
||||||
|
import org.bukkit.entity.Phantom;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
class PhantomSpawnListener extends ApplianceListener<PhantomReducer> {
|
||||||
|
@EventHandler
|
||||||
|
public void onPhantomSpawn(CreatureSpawnEvent event) {
|
||||||
|
if(!(event.getEntity() instanceof Phantom)) return;
|
||||||
|
if(ThreadLocalRandom.current().nextDouble() > 0.8) event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user