90 lines
3.6 KiB
Java
90 lines
3.6 KiB
Java
package lnmpro.Commands;
|
|
|
|
import lnmpro.Main;
|
|
import lnmpro.Utils.Kits;
|
|
import lnmpro.Utils.SchematicPlacer;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.GameMode;
|
|
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.command.TabCompleter;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.potion.PotionEffect;
|
|
import org.bukkit.potion.PotionEffectType;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
public class AcceptDuelCommand implements CommandExecutor, TabCompleter {
|
|
private final Main plugin;
|
|
|
|
public AcceptDuelCommand(Main plugin) {
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
@Override
|
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
|
|
if (sender instanceof Player player) {
|
|
if (player.hasMetadata("DueledBy")) {
|
|
Kits kitManager = new Kits(plugin);
|
|
SchematicPlacer schematic = new SchematicPlacer(plugin);
|
|
|
|
UUID targetUUID = UUID.fromString(player.getMetadata("DueledBy").get(0).asString());
|
|
Player enemy = Bukkit.getPlayer(targetUUID);
|
|
String gamemode = player.getMetadata("DueledWithGamemode").get(0).asString();
|
|
enemy.sendMessage("cica " + gamemode);
|
|
player.sendMessage("cica " + gamemode);
|
|
player.removeMetadata("DueledBy", plugin);
|
|
player.removeMetadata("DueledWithGamemode", plugin);
|
|
|
|
player.getInventory().clear();
|
|
enemy.getInventory().clear();
|
|
player.getInventory().setContents(kitManager.getAxeKit(player).getContents());
|
|
enemy.getInventory().setContents(kitManager.getAxeKit(player).getContents());
|
|
|
|
World world = Bukkit.getWorld("world");
|
|
int x = 1000;
|
|
int y = 0;
|
|
int z = -2000;
|
|
|
|
schematic.placeSchematic(world, x, y, z, "football");
|
|
Location playerLoc = new Location(world, x + 19.5, y + 0.5, z + 0.5, 90, 0);
|
|
Location enemyLoc = new Location(world, x - 17.5, y + 0.5, z + 0.5, -90, 0);
|
|
|
|
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
|
player.removePotionEffect(potionEffect.getType());
|
|
}
|
|
for (PotionEffect potionEffect : enemy.getActivePotionEffects()) {
|
|
enemy.removePotionEffect(potionEffect.getType());
|
|
}
|
|
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20, 1), true);
|
|
enemy.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20, 1), true);
|
|
player.teleport(playerLoc);
|
|
enemy.teleport(enemyLoc);
|
|
player.setHealth(20D);
|
|
enemy.setHealth(20D);
|
|
player.setFoodLevel(20);
|
|
enemy.setFoodLevel(20);
|
|
player.setSaturation(5);
|
|
enemy.setSaturation(5);
|
|
player.setGameMode(GameMode.ADVENTURE);
|
|
enemy.setGameMode(GameMode.ADVENTURE);
|
|
|
|
}
|
|
} else {
|
|
sender.sendMessage("nem vagy player nem fog sikerulni");
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
|
|
return List.of();
|
|
}
|
|
}
|