2014-07-22 17:26:46 +02:00
|
|
|
package com.gmail.filoghost.test;
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.Effect;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.Sound;
|
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.event.entity.EntityDeathEvent;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import org.bukkit.potion.PotionEffect;
|
|
|
|
import org.bukkit.potion.PotionEffectType;
|
|
|
|
|
2014-12-20 18:25:35 +01:00
|
|
|
import com.gmail.filoghost.holographicdisplays.api.Hologram;
|
|
|
|
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
|
|
|
|
import com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler;
|
|
|
|
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
|
2014-07-22 17:26:46 +02:00
|
|
|
|
|
|
|
public class PowerUps extends JavaPlugin implements Listener {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
|
|
|
|
|
|
|
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
|
|
|
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
|
|
|
|
getLogger().severe("*** This plugin will be disabled. ***");
|
|
|
|
this.setEnabled(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bukkit.getPluginManager().registerEvents(this, this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void onEntityDeath(EntityDeathEvent event) {
|
|
|
|
|
|
|
|
if (event.getEntityType() == EntityType.ZOMBIE) {
|
|
|
|
|
|
|
|
// Remove normal drops and exp.
|
|
|
|
event.getDrops().clear();
|
|
|
|
event.setDroppedExp(0);
|
|
|
|
|
|
|
|
// Spawn the floating item with a label.
|
2014-12-20 18:25:35 +01:00
|
|
|
final Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getLocation().add(0.0, 0.9, 0.0));
|
|
|
|
hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp");
|
|
|
|
ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR));
|
2014-07-22 17:26:46 +02:00
|
|
|
|
2014-12-20 18:25:35 +01:00
|
|
|
icon.setPickupHandler(new PickupHandler() {
|
2014-07-22 17:26:46 +02:00
|
|
|
|
|
|
|
@Override
|
2014-12-20 18:25:35 +01:00
|
|
|
public void onPickup(Player player) {
|
2014-07-22 17:26:46 +02:00
|
|
|
|
|
|
|
// Play a sound.
|
|
|
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1F, 2F);
|
|
|
|
|
|
|
|
// Play an effect.
|
2014-12-20 18:25:35 +01:00
|
|
|
player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null);
|
2014-07-22 17:26:46 +02:00
|
|
|
|
|
|
|
// 30 seconds of speed II.
|
|
|
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true);
|
|
|
|
|
2014-12-20 18:25:35 +01:00
|
|
|
// Delete the hologram.
|
2014-07-22 17:26:46 +02:00
|
|
|
hologram.delete();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|