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)
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.
@ -17,16 +17,13 @@ final Hologram hologram = HologramsAPI.createHologram(this, where.add(0.0, 0.6,
hologram.appendTextLine(text);
ItemLine itemLine = hologram.appendItemLine(icon);
itemLine.setPickupHandler(new PickupHandler() {
@Override
public void onPickup(Player player) {
itemLine.setPickupHandler((Player player) -> {
// Play a sound
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1F, 2F);
// Play an effect
player.playEffect(floatingItem.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
// 1 minute of fire resistance
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 60 * 20, 0));
@ -34,6 +31,5 @@ itemLine.setPickupHandler(new PickupHandler() {
// Delete the hologram
hologram.delete();
}
});
```