added glowing berries

This commit is contained in:
Elias Müller 2024-09-14 20:36:04 +02:00
parent e11b3fd7bc
commit f49cca7f33
3 changed files with 51 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import eu.mhsl.craftattack.spawn.appliances.displayName.DisplayName;
import eu.mhsl.craftattack.spawn.appliances.doubeDoor.DoubleDoor; import eu.mhsl.craftattack.spawn.appliances.doubeDoor.DoubleDoor;
import eu.mhsl.craftattack.spawn.appliances.event.Event; import eu.mhsl.craftattack.spawn.appliances.event.Event;
import eu.mhsl.craftattack.spawn.appliances.fleischerchest.Fleischerchest; import eu.mhsl.craftattack.spawn.appliances.fleischerchest.Fleischerchest;
import eu.mhsl.craftattack.spawn.appliances.glowingBerries.GlowingBerries;
import eu.mhsl.craftattack.spawn.appliances.help.Help; import eu.mhsl.craftattack.spawn.appliances.help.Help;
import eu.mhsl.craftattack.spawn.appliances.hotbarRefill.HotbarRefill; import eu.mhsl.craftattack.spawn.appliances.hotbarRefill.HotbarRefill;
import eu.mhsl.craftattack.spawn.appliances.kick.Kick; import eu.mhsl.craftattack.spawn.appliances.kick.Kick;
@ -80,6 +81,8 @@ public final class Main extends JavaPlugin {
new ChatMention(), new ChatMention(),
new DoubleDoor(), new DoubleDoor(),
new KnockDoor() new KnockDoor()
new KnockDoor(),
new GlowingBerries()
); );
Main.logger.info("Loading appliances..."); Main.logger.info("Loading appliances...");

View File

@ -0,0 +1,35 @@
package eu.mhsl.craftattack.spawn.appliances.glowingBerries;
import eu.mhsl.craftattack.spawn.appliance.Appliance;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.util.Ticks;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class GlowingBerries extends Appliance {
private static final PotionEffect glowEffect = new PotionEffect(
PotionEffectType.GLOWING,
Ticks.TICKS_PER_SECOND * 15,
1,
false,
true,
true
);
public void letPlayerGlow(Player player) {
player.addPotionEffect(glowEffect);
Sound sound = Sound.sound(org.bukkit.Sound.BLOCK_AMETHYST_BLOCK_CHIME.key(), Sound.Source.PLAYER, 1f, 1f);
player.stopSound(sound);
player.playSound(sound, Sound.Emitter.self());
}
@Override
protected @NotNull List<Listener> listeners() {
return List.of(new OnBerryEaten());
}
}

View File

@ -0,0 +1,13 @@
package eu.mhsl.craftattack.spawn.appliances.glowingBerries;
import eu.mhsl.craftattack.spawn.appliance.ApplianceListener;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerItemConsumeEvent;
public class OnBerryEaten extends ApplianceListener<GlowingBerries> {
@EventHandler
public void onEat(PlayerItemConsumeEvent event) {
if(event.getItem().getType().equals(Material.GLOW_BERRIES)) getAppliance().letPlayerGlow(event.getPlayer());
}
}