Updated Power Ups (markdown)

filoghost 2014-07-26 13:33:22 -07:00
parent bcf19edc14
commit 856cbb5d02

@ -3,3 +3,34 @@
Feature available from 1.8.5+ Feature available from 1.8.5+
For the moment you can 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. For the moment you can 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.
A power up is very simple, is made of a floating item (the icon) and a hologram. You can assign a PickupHandler to the floating item, that is triggered when a player is near. If you want, you can use [this](...) helper class in your plugin.
**Example**: a power up that gives fire resistance when is collected.
``` java
String text = ChatColor.GOLD + "" + ChatColor.BOLD + "Fire Resistance"
Location where = ... // Suppose you have a random location in your minigame
FloatingItem floatingItem = HolographicDisplaysAPI.createFloatingItem(this, where.add(0.0, 0.2, 0.0), new ItemStack(Material.SUGAR));
final Hologram hologram = HolographicDisplaysAPI.createHologram(this, where.add(0.0, 0.6, 0.0), text);
floatingItem.setPickupHandler(new PickupHandler() {
@Override
public void onPickup(FloatingItem floatingItem, 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, 1));
// Delete the hologram and the floating item.
floatingItem.delete();
hologram.delete();
}
});
```