Add example sources back

This commit is contained in:
filoghost 2018-08-21 14:53:07 +02:00
parent 6d095f8165
commit 4237707b62
4 changed files with 123 additions and 0 deletions

View File

@ -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()));
}
}

View File

@ -0,0 +1,5 @@
name: DeathHolograms
main: com.gmail.filoghost.test.DeathHolograms
version: 1.0
softdepend: [HolographicDisplays]

View File

@ -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();
}
});
}
}
}

View File

@ -0,0 +1,5 @@
name: PowerUps
main: com.gmail.filoghost.test.PowerUps
version: 1.0
softdepend: [HolographicDisplays]