This repository has been archived on 2025-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
WolfFFA/src/main/java/hu/jgj52/wolfFFA/Commands/WolfFfaCommand.java
2025-02-16 19:49:17 +01:00

134 lines
7.2 KiB
Java

package hu.jgj52.wolfFFA.Commands;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class WolfFfaCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (cmds.hasPermission("wolfffa.admin.tptoffa")) {
if (args.length > 0) {
switch (args[0]) {
case "sword":
if (args.length > 1) {
Player target = Bukkit.getPlayer(args[1]);
if (target instanceof Player player) {
player.getInventory().clear();
ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
helmet.addEnchantment(Enchantment.PROTECTION, 3);
chestplate.addEnchantment(Enchantment.PROTECTION, 3);
leggings.addEnchantment(Enchantment.PROTECTION, 3);
boots.addEnchantment(Enchantment.PROTECTION, 3);
sword.addEnchantment(Enchantment.UNBREAKING, 3);
player.getInventory().setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
player.getInventory().setItem(0, sword);
World world = Bukkit.getWorld("world");
double x = 0.5;
double y = 1.0;
double z = 1000.5;
float yaw = (float) 0;
float pitch = (float) 0;
Location loc = new Location(world, x, y, z, yaw, pitch);
player.teleport(loc);
}
}
break;
case "uhc":
if (args.length > 1) {
Player target = Bukkit.getPlayer(args[1]);
if (target instanceof Player player) {
player.getInventory().clear();
ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
ItemStack axe = new ItemStack(Material.DIAMOND_AXE);
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
ItemStack lava = new ItemStack(Material.LAVA_BUCKET);
ItemStack cobweb = new ItemStack(Material.COBWEB, 8);
ItemStack cobblestone = new ItemStack(Material.COBBLESTONE, 64);
ItemStack goldenapple = new ItemStack(Material.GOLDEN_APPLE, 13);
ItemStack water = new ItemStack(Material.WATER_BUCKET);
ItemStack crossbow = new ItemStack(Material.CROSSBOW);
ItemStack bow = new ItemStack(Material.BOW);
ItemStack arrow = new ItemStack(Material.ARROW, 16);
ItemStack shield = new ItemStack(Material.SHIELD);
ItemStack planks = new ItemStack(Material.OAK_PLANKS, 64);
helmet.addEnchantment(Enchantment.PROTECTION, 2);
chestplate.addEnchantment(Enchantment.PROTECTION, 3);
leggings.addEnchantment(Enchantment.PROTECTION, 3);
boots.addEnchantment(Enchantment.PROTECTION, 3);
axe.addEnchantment(Enchantment.SHARPNESS, 1);
axe.addEnchantment(Enchantment.EFFICIENCY, 3);
sword.addEnchantment(Enchantment.SHARPNESS, 4);
crossbow.addEnchantment(Enchantment.PIERCING, 1);
bow.addEnchantment(Enchantment.POWER, 1);
player.getInventory().setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
player.getInventory().setItem(0, axe);
player.getInventory().setItem(1, sword);
player.getInventory().setItem(2, lava);
player.getInventory().setItem(3, cobweb);
player.getInventory().setItem(4, cobblestone);
player.getInventory().setItem(5, goldenapple);
player.getInventory().setItem(6, water);
player.getInventory().setItem(7, crossbow);
player.getInventory().setItem(8, bow);
player.getInventory().setItem(9, arrow);
player.getInventory().setItem(13, shield);
player.getInventory().setItem(17, planks);
player.getInventory().setItem(21, lava);
player.getInventory().setItem(22, water);
player.getInventory().setItem(23, water);
player.getInventory().setItem(24, water);
player.getInventory().setItem(40, shield);
}
}
break;
default:
cmds.sendMessage("§cNincs ilyen FFA típus.");
}
}
}
return true;
}
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (args.length == 1) {
List.of("sword", "uhc");
} else if (args.length == 2) {
List<String> playerNames = new ArrayList<>();
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
playerNames.add(onlinePlayer.getName());
}
}
return List.of();
}
}