diff --git a/Examples/DeathHolograms/src/main/java/com/gmail/filoghost/test/DeathHolograms.java b/Examples/DeathHolograms/src/main/java/com/gmail/filoghost/test/DeathHolograms.java new file mode 100644 index 00000000..7b37aa76 --- /dev/null +++ b/Examples/DeathHolograms/src/main/java/com/gmail/filoghost/test/DeathHolograms.java @@ -0,0 +1,41 @@ +package com.gmail.filoghost.test; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.plugin.java.JavaPlugin; + +import com.gmail.filoghost.holographicdisplays.api.Hologram; +import com.gmail.filoghost.holographicdisplays.api.HologramsAPI; + +public class DeathHolograms extends JavaPlugin implements Listener { + + 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 onPlayerDeath(PlayerDeathEvent event) { + + Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getEyeLocation()); + + hologram.appendTextLine(ChatColor.RED + "Player " + ChatColor.GOLD + event.getEntity().getName() + ChatColor.RED + " died here!"); + hologram.appendTextLine(ChatColor.GRAY + "Time of death: " + new SimpleDateFormat("H:m").format(new Date())); + + } +} diff --git a/Examples/DeathHolograms/src/main/resources/plugin.yml b/Examples/DeathHolograms/src/main/resources/plugin.yml new file mode 100644 index 00000000..9eecd290 --- /dev/null +++ b/Examples/DeathHolograms/src/main/resources/plugin.yml @@ -0,0 +1,5 @@ +name: DeathHolograms +main: com.gmail.filoghost.test.DeathHolograms +version: 1.0 + +softdepend: [HolographicDisplays] \ No newline at end of file diff --git a/Examples/PowerUps/src/main/java/com/gmail/filoghost/test/PowerUps.java b/Examples/PowerUps/src/main/java/com/gmail/filoghost/test/PowerUps.java new file mode 100644 index 00000000..06b696db --- /dev/null +++ b/Examples/PowerUps/src/main/java/com/gmail/filoghost/test/PowerUps.java @@ -0,0 +1,72 @@ +package com.gmail.filoghost.test; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Effect; +import org.bukkit.Material; +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; + +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; + +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. + 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)); + + icon.setPickupHandler(new PickupHandler() { + + @Override + public void onPickup(Player player) { + + // Play an effect. + player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null); + + // 30 seconds of speed II. + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true); + + // Delete the hologram. + hologram.delete(); + + } + }); + + } + } +} diff --git a/Examples/PowerUps/src/main/resources/plugin.yml b/Examples/PowerUps/src/main/resources/plugin.yml new file mode 100644 index 00000000..00701a22 --- /dev/null +++ b/Examples/PowerUps/src/main/resources/plugin.yml @@ -0,0 +1,5 @@ +name: PowerUps +main: com.gmail.filoghost.test.PowerUps +version: 1.0 + +softdepend: [HolographicDisplays] \ No newline at end of file