Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.comniemeer.funinator;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.ItemStack;
- public class CommandPingusmash implements CommandExecutor {
- private Funinator plugin;
- public CommandPingusmash (Funinator funinator) {
- plugin = funinator;
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (cmd.getName().equalsIgnoreCase("pingusmash")) {
- if (args.length > 2) {
- sender.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.RED + "Zu viele Argumente!");
- return false;
- }
- if (args.length == 0) {
- sender.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.RED + "Zu wenig Argumente!");
- return false;
- }
- if (args.length == 1 && args[0].equalsIgnoreCase("join")) {
- // Soll von Spielern verwendet werden können, um am Spiel teilzunehmen.
- if (!(sender instanceof Player)) {
- System.out.println("Dieser Befehl ist nur für Spieler!");
- return true;
- }
- Player player = (Player) sender;
- player.setHealth(20);
- player.getInventory().clear();
- player.getInventory().setHelmet(new ItemStack(310, 1));
- player.getInventory().getHelmet().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
- player.getInventory().setChestplate(new ItemStack(311, 1));
- player.getInventory().getChestplate().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
- player.getInventory().setLeggings(new ItemStack(312, 1));
- player.getInventory().getLeggings().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
- player.getInventory().setBoots(new ItemStack(313, 1));
- player.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
- player.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_FALL, 4);
- player.getInventory().setItemInHand(new ItemStack(268, 64));
- player.getInventory().getItemInHand().addEnchantment(Enchantment.KNOCKBACK, 2);
- player.getInventory().addItem(new ItemStack(350, 64));
- double x = plugin.getConfig().getDouble("PingusmashArena.x");
- double y = plugin.getConfig().getDouble("PingusmashArena.y");
- double z = plugin.getConfig().getDouble("PingusmashArena.z");
- World w = plugin.getServer().getWorld(plugin.getConfig().getString("PingusmashArena.welt"));
- float yaw = (float) plugin.getConfig().get("PingusmashArena.yaw");
- float pitch = (float) plugin.getConfig().get("PingusmashArena.pitch");
- Location PingusmashArena = new Location(w, x, y, z, yaw, pitch);
- player.teleport(PingusmashArena);
- player.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.GREEN + "Du nimmst nun am Spiel teil!");
- return true;
- }
- if (args.length == 2 && args[0].equalsIgnoreCase("join")) {
- // Soll das Spiel auch für z.B. Command-Blocks zugänglich machen.
- try {
- Player ziel = plugin.getServer().getPlayer(args[1]);
- ziel.setHealth(20);
- ziel.getInventory().clear();
- ziel.getInventory().setHelmet(new ItemStack(310, 1));
- ziel.getInventory().getHelmet().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);;
- ziel.getInventory().setChestplate(new ItemStack(311, 1));
- ziel.getInventory().getChestplate().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
- ziel.getInventory().setLeggings(new ItemStack(312, 1));
- ziel.getInventory().getLeggings().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
- ziel.getInventory().setBoots(new ItemStack(313, 1));
- ziel.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);
- ziel.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_FALL, 4);
- ziel.getInventory().setItemInHand(new ItemStack(268, 64));
- ziel.getInventory().getItemInHand().addEnchantment(Enchantment.KNOCKBACK, 2);
- ziel.getInventory().addItem(new ItemStack(350, 64));
- double x = plugin.getConfig().getDouble("PingusmashArena.x");
- double y = plugin.getConfig().getDouble("PingusmashArena.y");
- double z = plugin.getConfig().getDouble("PingusmashArena.z");
- World w = plugin.getServer().getWorld(plugin.getConfig().getString("PingusmashArena.welt"));
- float yaw = (float) plugin.getConfig().get("PingusmashArena.yaw");
- float pitch = (float) plugin.getConfig().get("PingusmashArena.pitch");
- Location PingusmashArena = new Location(w, x, y, z, yaw, pitch);
- ziel.teleport(PingusmashArena);
- ziel.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.GREEN + "Du nimmst nun an Pingusmash teil!");
- return true;
- }
- catch (Exception e) {
- sender.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.RED + "Spieler nicht gefunden!");
- return true;
- }
- }
- Player player = (Player) sender;
- if (args.length == 1 && args[0].equalsIgnoreCase("set")) {
- // Soll die aktuellen Koordinaten in die Config speichern.
- if (!(sender instanceof Player)) {
- System.out.println("Dieser Befehl ist nur für Spieler!");
- return true;
- }
- plugin.getConfig().set("PingusmashArena.x", player.getLocation().getX());
- plugin.getConfig().set("PingusmashArena.y", player.getLocation().getY());
- plugin.getConfig().set("PingusmashArena.z", player.getLocation().getZ());
- plugin.getConfig().set("PingusmashArena.welt", player.getLocation().getWorld().getName());
- plugin.getConfig().set("PingusmashArena.yaw", player.getLocation().getYaw());
- plugin.getConfig().set("PingusmashArena.pitch", player.getLocation().getPitch());
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement