SHOW:
|
|
- or go back to the newest paste.
1 | package me.comniemeer.funinator; | |
2 | ||
3 | import org.bukkit.ChatColor; | |
4 | import org.bukkit.Location; | |
5 | import org.bukkit.World; | |
6 | import org.bukkit.command.Command; | |
7 | import org.bukkit.command.CommandExecutor; | |
8 | import org.bukkit.command.CommandSender; | |
9 | import org.bukkit.enchantments.Enchantment; | |
10 | import org.bukkit.entity.Player; | |
11 | import org.bukkit.inventory.ItemStack; | |
12 | ||
13 | public class CommandPingusmash implements CommandExecutor { | |
14 | ||
15 | private Funinator plugin; | |
16 | public CommandPingusmash (Funinator funinator) { | |
17 | plugin = funinator; | |
18 | } | |
19 | ||
20 | @Override | |
21 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | |
22 | ||
23 | if (cmd.getName().equalsIgnoreCase("pingusmash")) { | |
24 | if (args.length > 2) { | |
25 | sender.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.RED + "Zu viele Argumente!"); | |
26 | return false; | |
27 | } | |
28 | if (args.length == 0) { | |
29 | sender.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.RED + "Zu wenig Argumente!"); | |
30 | return false; | |
31 | } | |
32 | if (args.length == 1 && args[0].equalsIgnoreCase("join")) { | |
33 | // Soll von Spielern verwendet werden können, um am Spiel teilzunehmen. | |
34 | if (!(sender instanceof Player)) { | |
35 | System.out.println("Dieser Befehl ist nur für Spieler!"); | |
36 | return true; | |
37 | } | |
38 | Player player = (Player) sender; | |
39 | player.setHealth(20); | |
40 | ||
41 | player.getInventory().clear(); | |
42 | player.getInventory().setHelmet(new ItemStack(310, 1)); | |
43 | - | player.getInventory().getHelmet().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); |
43 | + | player.getInventory().getHelmet().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); |
44 | - | player.getInventory().setChestplate(new ItemStack(311, 1)); |
44 | + | player.getInventory().setChestplate(new ItemStack(311, 1)); |
45 | - | player.getInventory().getChestplate().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); |
45 | + | player.getInventory().getChestplate().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); |
46 | - | player.getInventory().setLeggings(new ItemStack(312, 1)); |
46 | + | player.getInventory().setLeggings(new ItemStack(312, 1)); |
47 | - | player.getInventory().getLeggings().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); |
47 | + | player.getInventory().getLeggings().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); |
48 | - | player.getInventory().setBoots(new ItemStack(313, 1)); |
48 | + | player.getInventory().setBoots(new ItemStack(313, 1)); |
49 | - | player.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); |
49 | + | player.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); |
50 | - | player.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_FALL, 4); |
50 | + | player.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_FALL, 4); |
51 | - | player.getInventory().setItemInHand(new ItemStack(268, 64)); |
51 | + | player.getInventory().setItemInHand(new ItemStack(268, 64)); |
52 | - | player.getInventory().getItemInHand().addEnchantment(Enchantment.KNOCKBACK, 2); |
52 | + | player.getInventory().getItemInHand().addEnchantment(Enchantment.KNOCKBACK, 2); |
53 | - | player.getInventory().addItem(new ItemStack(350, 64)); |
53 | + | player.getInventory().addItem(new ItemStack(350, 64)); |
54 | ||
55 | double x = plugin.getConfig().getDouble("PingusmashArena.x"); | |
56 | double y = plugin.getConfig().getDouble("PingusmashArena.y"); | |
57 | double z = plugin.getConfig().getDouble("PingusmashArena.z"); | |
58 | World w = plugin.getServer().getWorld(plugin.getConfig().getString("PingusmashArena.welt")); | |
59 | float yaw = (float) plugin.getConfig().get("PingusmashArena.yaw"); | |
60 | float pitch = (float) plugin.getConfig().get("PingusmashArena.pitch"); | |
61 | Location PingusmashArena = new Location(w, x, y, z, yaw, pitch); | |
62 | player.teleport(PingusmashArena); | |
63 | ||
64 | player.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.GREEN + "Du nimmst nun am Spiel teil!"); | |
65 | return true; | |
66 | } | |
67 | ||
68 | if (args.length == 2 && args[0].equalsIgnoreCase("join")) { | |
69 | // Soll das Spiel auch für z.B. Command-Blocks zugänglich machen. | |
70 | try { | |
71 | Player ziel = plugin.getServer().getPlayer(args[1]); | |
72 | ziel.setHealth(20); | |
73 | ||
74 | ziel.getInventory().clear(); | |
75 | ziel.getInventory().setHelmet(new ItemStack(310, 1)); | |
76 | ziel.getInventory().getHelmet().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4);; | |
77 | ziel.getInventory().setChestplate(new ItemStack(311, 1)); | |
78 | ziel.getInventory().getChestplate().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); | |
79 | ziel.getInventory().setLeggings(new ItemStack(312, 1)); | |
80 | ziel.getInventory().getLeggings().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); | |
81 | ziel.getInventory().setBoots(new ItemStack(313, 1)); | |
82 | ziel.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4); | |
83 | ziel.getInventory().getBoots().addEnchantment(Enchantment.PROTECTION_FALL, 4); | |
84 | ziel.getInventory().setItemInHand(new ItemStack(268, 64)); | |
85 | ziel.getInventory().getItemInHand().addEnchantment(Enchantment.KNOCKBACK, 2); | |
86 | ziel.getInventory().addItem(new ItemStack(350, 64)); | |
87 | ||
88 | double x = plugin.getConfig().getDouble("PingusmashArena.x"); | |
89 | double y = plugin.getConfig().getDouble("PingusmashArena.y"); | |
90 | double z = plugin.getConfig().getDouble("PingusmashArena.z"); | |
91 | World w = plugin.getServer().getWorld(plugin.getConfig().getString("PingusmashArena.welt")); | |
92 | float yaw = (float) plugin.getConfig().get("PingusmashArena.yaw"); | |
93 | float pitch = (float) plugin.getConfig().get("PingusmashArena.pitch"); | |
94 | Location PingusmashArena = new Location(w, x, y, z, yaw, pitch); | |
95 | ziel.teleport(PingusmashArena); | |
96 | ||
97 | ziel.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.GREEN + "Du nimmst nun an Pingusmash teil!"); | |
98 | return true; | |
99 | } | |
100 | catch (Exception e) { | |
101 | sender.sendMessage(ChatColor.GOLD + "[Pingusmash] " + ChatColor.RED + "Spieler nicht gefunden!"); | |
102 | return true; | |
103 | } | |
104 | } | |
105 | Player player = (Player) sender; | |
106 | if (args.length == 1 && args[0].equalsIgnoreCase("set")) { | |
107 | // Soll die aktuellen Koordinaten in die Config speichern. | |
108 | if (!(sender instanceof Player)) { | |
109 | System.out.println("Dieser Befehl ist nur für Spieler!"); | |
110 | return true; | |
111 | } | |
112 | plugin.getConfig().set("PingusmashArena.x", player.getLocation().getX()); | |
113 | plugin.getConfig().set("PingusmashArena.y", player.getLocation().getY()); | |
114 | plugin.getConfig().set("PingusmashArena.z", player.getLocation().getZ()); | |
115 | plugin.getConfig().set("PingusmashArena.welt", player.getLocation().getWorld().getName()); | |
116 | plugin.getConfig().set("PingusmashArena.yaw", player.getLocation().getYaw()); | |
117 | plugin.getConfig().set("PingusmashArena.pitch", player.getLocation().getPitch()); | |
118 | } | |
119 | } | |
120 | return false; | |
121 | } | |
122 | } |