mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-22 10:25:41 +01:00
Updated Power Ups (markdown)
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,23 +17,19 @@ final Hologram hologram = HologramsAPI.createHologram(this, where.add(0.0, 0.6,
|
||||
hologram.appendTextLine(text);
|
||||
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
|
||||
public void onPickup(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);
|
||||
|
||||
// 1 minute of fire resistance
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 60 * 20, 0));
|
||||
|
||||
// Delete the hologram
|
||||
hologram.delete();
|
||||
|
||||
}
|
||||
// Play an effect
|
||||
player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
|
||||
|
||||
// 1 minute of fire resistance
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 60 * 20, 0));
|
||||
|
||||
// Delete the hologram
|
||||
hologram.delete();
|
||||
|
||||
});
|
||||
```
|
Loading…
Reference in New Issue
Block a user