Updated Power Ups (markdown)

filoghost 2021-04-10 14:14:16 +02:00
parent 0d0ba153ae
commit b4f8ab5816

@ -1,6 +1,6 @@
![](http://i.imgur.com/tDR0TcA.jpg) ![](http://i.imgur.com/tDR0TcA.jpg)
Also check [this example plugin](https://github.com/filoghost/HolographicDisplays/blob/master/Example_PowerUps/src/com/gmail/filoghost/test/PowerUps.java) to learn how to create power ups. Also check [this example plugin](https://github.com/filoghost/HolographicDisplays/blob/master/Example/PowerUps/src/main/java/com/gmail/filoghost/example/powerups/PowerUps.java) to learn how to create power ups.
A power up is very simple, is made of a hologram with two lines. You can assign a PickupHandler to the floating item, that is triggered when a player picks it up. A power up is very simple, is made of a hologram with two lines. You can assign a PickupHandler to the floating item, that is triggered when a player picks it up.
@ -17,23 +17,19 @@ final Hologram hologram = HologramsAPI.createHologram(this, where.add(0.0, 0.6,
hologram.appendTextLine(text); hologram.appendTextLine(text);
ItemLine itemLine = hologram.appendItemLine(icon); ItemLine itemLine = hologram.appendItemLine(icon);
itemLine.setPickupHandler(new PickupHandler() { itemLine.setPickupHandler((Player player) -> {
// Play a sound
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1F, 2F);
@Override // Play an effect
public void onPickup(Player player) { player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
// Play a sound // 1 minute of fire resistance
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1F, 2F); player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 60 * 20, 0));
// Play an effect // Delete the hologram
player.playEffect(floatingItem.getLocation(), Effect.MOBSPAWNER_FLAMES, null); hologram.delete();
// 1 minute of fire resistance
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 60 * 20, 0));
// Delete the hologram
hologram.delete();
}
}); });
``` ```