Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.cravercraft.skypvp;
- import java.io.File;
- import java.io.IOException;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.PlayerDeathEvent;
- import org.bukkit.event.player.PlayerDropItemEvent;
- import org.bukkit.event.player.PlayerPickupItemEvent;
- import org.bukkit.inventory.ItemStack;
- public class KillEvents implements Listener {
- private SkyPvP plugin;
- int kills = 0;
- public KillEvents(SkyPvP plugin) {
- this.plugin = plugin;
- plugin.getServer().getPluginManager().registerEvents(this, plugin);
- }
- @EventHandler
- public void onPlayerDeath(PlayerDeathEvent e) {
- String killedm = e.getEntity().getName();
- String killerm = e.getEntity().getKiller().getName();
- Player killer = e.getEntity().getKiller().getPlayer();
- Player killed = e.getEntity().getPlayer();
- if(plugin.inJump.contains(killed.getName())) {
- if(plugin.inJump.contains(killer.getName())) {
- killer.sendMessage(plugin.prefix + "§3Du hast §c" + killedm + " §3getötet");
- killed.sendMessage(plugin.prefix + "§3Du wurdest von §e" + killerm + " §3getötet");
- FileConfiguration cfgp = plugin.getConfig();
- String world = cfgp.getString("World");
- double x = cfgp.getDouble("PosX");
- double y = cfgp.getDouble("PosY");
- double z = cfgp.getDouble("PosZ");
- double yaw = cfgp.getDouble("PosYaw");
- double pitch = cfgp.getDouble("PosPitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- loc.setPitch((float) pitch);
- loc.setYaw((float) yaw);
- killed.teleport(loc);
- addKill(killer, killerm);
- Level1(killed);
- if(plugin.Level1.contains(killer.getName())) {
- Level2(killer);
- }
- }
- }
- }
- //Level1
- @SuppressWarnings("deprecation")
- public void Level1(Player p) {
- plugin.Level1.add(p.getName());
- ItemStack Level1 = new ItemStack(Material.WOOD_AXE);
- p.getInventory().setItem(0, Level1);
- p.updateInventory();
- }
- //Level2
- @SuppressWarnings("deprecation")
- public void Level2(Player p) {
- plugin.Level2.add(p.getName());
- p.getInventory().clear();
- ItemStack Level2 = new ItemStack(Material.WOOD_SWORD);
- p.getInventory().setItem(0, Level2);
- p.updateInventory();
- }
- //Verhinderungen
- @EventHandler
- public void onItemDrop(PlayerDropItemEvent e) {
- Player p = e.getPlayer();
- if(plugin.inJump.contains(p.getName())) {
- e.setCancelled(true);
- }
- }
- @EventHandler
- public void onItemPickup(PlayerPickupItemEvent e) {
- Player p = e.getPlayer();
- if(plugin.inJump.contains(p.getName())) {
- e.setCancelled(true);
- }
- }
- public void addKill(Player killer, String name) {
- File file = new File("plugins/SkyPvP", "kills.yml");
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- int kills = cfg.getInt(name + ".kills");
- kills=kills+1;
- cfg.set(name + ".kills", kills);
- try {
- cfg.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment