This commit is contained in:
2025-09-08 20:47:09 +02:00
parent a3d9ad5e2c
commit 4db735ca82
33 changed files with 368 additions and 897 deletions

View File

@@ -24,6 +24,7 @@ import net.kyori.adventure.title.Title;
import java.time.Duration; import java.time.Duration;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
import static java.util.Collections.min; import static java.util.Collections.min;
@@ -38,145 +39,170 @@ public class AcceptDuelCommand implements CommandExecutor, TabCompleter {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (sender instanceof Player player) { if (sender instanceof Player player) {
if (player.hasMetadata("DueledBy")) { if (args.length != 1) {
Kits kitManager = new Kits(plugin); player.sendMessage("§cHasználat: /acceptduel <játékos>");
SchematicManager schematic = new SchematicManager(plugin); return true;
UUID targetUUID = UUID.fromString(player.getMetadata("DueledBy").get(0).asString());
Player enemy = Bukkit.getPlayer(targetUUID);
String gamemode = player.getMetadata("DueledWithGamemode").get(0).asString();
player.removeMetadata("DueledBy", plugin);
player.getInventory().clear();
enemy.getInventory().clear();
int x = 0;
String arena = "";
boolean survival = false;
if (gamemode.equals("uhc")) {
x = 1000;
arena = "football";
survival = true;
player.getInventory().setContents(kitManager.getUhcKit(player).getContents());
enemy.getInventory().setContents(kitManager.getUhcKit(player).getContents());
} else if (gamemode.equals("pot")) {
x = 0;
arena = "";
} else if (gamemode.equals("nethpot")) {
x = 0;
arena = "";
} else if (gamemode.equals("smp")) {
x = 0;
arena = "";
} else if (gamemode.equals("sword")) {
x = 1400;
arena = "football";
player.getInventory().setContents(kitManager.getSwordKit(player).getContents());
enemy.getInventory().setContents(kitManager.getSwordKit(player).getContents());
} else if (gamemode.equals("axe")) {
x = 1500;
arena = "football";
player.getInventory().setContents(kitManager.getAxeKit(player).getContents());
enemy.getInventory().setContents(kitManager.getAxeKit(player).getContents());
} else if (gamemode.equals("mace")) {
x = 0;
arena = "";
player.getInventory().setContents(kitManager.getMaceKit(player).getContents());
enemy.getInventory().setContents(kitManager.getMaceKit(player).getContents());
} else if (gamemode.equals("cart")) {
x = 0;
arena = "";
survival = true;
} else if (gamemode.equals("diasmp")) {
x = 1800;
arena = "football";
survival = true;
player.getInventory().setContents(kitManager.getDiaSMPKit(player).getContents());
enemy.getInventory().setContents(kitManager.getDiaSMPKit(player).getContents());
} else if (gamemode.equals("shieldlessuhc")) {
x = 0;
arena = "";
survival = true;
}
World world = Bukkit.getWorld("arenas");
int y = 0;
int z;
if (plugin.usedArenas.isEmpty()) {
z = -2000;
} else {
z = min(plugin.usedArenas) - 100;
}
plugin.usedArenas.add(z);
schematic.placeSchematic(world, x, y, z, arena, true);
Location playerLoc = new Location(world, x + 19.5, y, z + 0.5, 90, 0);
Location enemyLoc = new Location(world, x - 17.5, y, 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(survival ? GameMode.SURVIVAL : GameMode.ADVENTURE);
enemy.setGameMode(survival ? GameMode.SURVIVAL : GameMode.ADVENTURE);
player.setMetadata("DuelingWith", new FixedMetadataValue(plugin, enemy.getUniqueId()));
enemy.setMetadata("DuelingWith", new FixedMetadataValue(plugin, player.getUniqueId()));
player.setMetadata("ArenaLoc", new FixedMetadataValue(plugin, new Location(world, x, y, z)));
enemy.setMetadata("ArenaLoc", new FixedMetadataValue(plugin, new Location(world, x, y, z)));
player.setMetadata("Frozen", new FixedMetadataValue(plugin, true));
enemy.setMetadata("Frozen", new FixedMetadataValue(plugin, true));
new BukkitRunnable() {
int countdown = 3;
@Override
public void run() {
if (countdown > 0) {
Component titleText = Component.text(String.valueOf(countdown), NamedTextColor.AQUA);
Title title = Title.title(
titleText,
Component.empty(),
Title.Times.times(Duration.ZERO, Duration.ofSeconds(1), Duration.ZERO)
);
player.showTitle(title);
enemy.showTitle(title);
countdown--;
} else {
Title startTitle = Title.title(
Component.text("§eA párbaj megkezdődött!"),
Component.empty(),
Title.Times.times(Duration.ZERO, Duration.ofSeconds(2), Duration.ofSeconds(1))
);
player.showTitle(startTitle);
enemy.showTitle(startTitle);
player.removeMetadata("Frozen", plugin);
enemy.removeMetadata("Frozen", plugin);
cancel();
}
}
}.runTaskTimer(plugin, 0L, 20L);
} }
Map<UUID, Main.DuelRequestData> requests = plugin.duelRequests.get(player.getUniqueId());
if (requests == null) {
player.sendMessage("§cNincs párbajkérelmed.");
return true;
}
Player enemy = Bukkit.getPlayer(args[0]);
if (enemy == null) {
player.sendMessage("§cA megadott játékos nem található.");
return true;
}
Main.DuelRequestData requestData = requests.get(enemy.getUniqueId());
if (requestData == null) {
player.sendMessage("§cNincs párbajkérelmed ettől a játékostól.");
return true;
}
if ((System.currentTimeMillis() - requestData.timestamp()) > 60000) {
requests.remove(enemy.getUniqueId());
if (requests.isEmpty()) {
plugin.duelRequests.remove(player.getUniqueId());
}
player.sendMessage("§cEz a párbajkérelem lejárt.");
return true;
}
Kits kitManager = new Kits(plugin);
SchematicManager schematic = new SchematicManager(plugin);
String gamemode = requestData.gamemode();
plugin.duelRequests.remove(player.getUniqueId());
plugin.duelRequests.remove(enemy.getUniqueId());
player.getInventory().clear();
enemy.getInventory().clear();
int x = 0;
String arena = "";
boolean survival = false;
if (gamemode.equals("uhc")) {
x = 1000;
arena = "football";
survival = true;
} else if (gamemode.equals("pot")) {
x = 0;
arena = "";
} else if (gamemode.equals("nethpot")) {
x = 0;
arena = "";
} else if (gamemode.equals("smp")) {
x = 0;
arena = "";
} else if (gamemode.equals("sword")) {
x = 1400;
arena = "football";
} else if (gamemode.equals("axe")) {
x = 1500;
arena = "football";
} else if (gamemode.equals("mace")) {
x = 0;
arena = "";
} else if (gamemode.equals("cart")) {
x = 0;
arena = "";
survival = true;
} else if (gamemode.equals("diasmp")) {
x = 1800;
arena = "football";
survival = true;
} else if (gamemode.equals("shieldlessuhc")) {
x = 0;
arena = "";
survival = true;
}
player.getInventory().setContents(kitManager.getKit(gamemode, player));
enemy.getInventory().setContents(kitManager.getKit(gamemode, enemy));
World world = Bukkit.getWorld("arenas");
int y = 0;
int z;
if (plugin.usedArenas.isEmpty()) {
z = -2000;
} else {
z = min(plugin.usedArenas) - 100;
}
plugin.usedArenas.add(z);
schematic.placeSchematic(world, x, y, z, arena, true);
Location playerLoc = new Location(world, x + 19.5, y, z + 0.5, 90, 0);
Location enemyLoc = new Location(world, x - 17.5, y, 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(survival ? GameMode.SURVIVAL : GameMode.ADVENTURE);
enemy.setGameMode(survival ? GameMode.SURVIVAL : GameMode.ADVENTURE);
player.setMetadata("DuelingWith", new FixedMetadataValue(plugin, enemy.getUniqueId()));
enemy.setMetadata("DuelingWith", new FixedMetadataValue(plugin, player.getUniqueId()));
player.setMetadata("ArenaLoc", new FixedMetadataValue(plugin, new Location(world, x, y, z)));
enemy.setMetadata("ArenaLoc", new FixedMetadataValue(plugin, new Location(world, x, y, z)));
player.setMetadata("Frozen", new FixedMetadataValue(plugin, true));
enemy.setMetadata("Frozen", new FixedMetadataValue(plugin, true));
new BukkitRunnable() {
int countdown = 3;
@Override
public void run() {
if (countdown > 0) {
Component titleText = Component.text(String.valueOf(countdown), NamedTextColor.AQUA);
Title title = Title.title(
titleText,
Component.empty(),
Title.Times.times(Duration.ZERO, Duration.ofSeconds(1), Duration.ZERO)
);
player.showTitle(title);
enemy.showTitle(title);
countdown--;
} else {
Title startTitle = Title.title(
Component.text("§eA párbaj megkezdődött!"),
Component.empty(),
Title.Times.times(Duration.ZERO, Duration.ofSeconds(2), Duration.ofSeconds(1))
);
player.showTitle(startTitle);
enemy.showTitle(startTitle);
player.removeMetadata("Frozen", plugin);
enemy.removeMetadata("Frozen", plugin);
cancel();
}
}
}.runTaskTimer(plugin, 0L, 20L);
} else { } else {
sender.sendMessage("nem vagy player nem fog sikerulni"); sender.sendMessage("nem vagy player nem fog sikerulni");
} }

View File

@@ -0,0 +1,38 @@
package lnmpro.Commands;
import lnmpro.Main;
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.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class CreateKitCommand implements CommandExecutor, TabCompleter {
private final Main plugin;
public CreateKitCommand(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 (args.length == 1) {
plugin.getConfig().set("default.kits." + args[0], player.getInventory().getContents());
plugin.saveConfig();
plugin.reloadConfig();
player.sendMessage("§aKit saved as " + args[0]);
}
}
return true;
}
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
return List.of();
}
}

View File

@@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class DenyDuelCommand implements CommandExecutor, TabCompleter { public class DenyDuelCommand implements CommandExecutor, TabCompleter {
@@ -23,12 +24,31 @@ public class DenyDuelCommand implements CommandExecutor, TabCompleter {
@Override @Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (sender instanceof Player player) { if (sender instanceof Player player) {
if (player.hasMetadata("DueledBy")) { if (args.length != 1) {
UUID targetUUID = UUID.fromString(player.getMetadata("DueledBy").get(0).asString()); player.sendMessage("§cHasználat: /denyduel <játékos>");
Player enemy = Bukkit.getPlayer(targetUUID); return true;
String gamemode = player.getMetadata("DueledWithGamemode").get(0).asString(); }
player.removeMetadata("DueledBy", plugin);
player.removeMetadata("DueledWithGamemode", plugin); Map<UUID, Main.DuelRequestData> requests = plugin.duelRequests.get(player.getUniqueId());
if (requests == null) {
player.sendMessage("§cNincs párbajkérelmed.");
return true;
}
Player enemy = Bukkit.getPlayer(args[0]);
if (enemy == null) {
player.sendMessage("§cA megadott játékos nem található.");
return true;
}
if (requests.remove(enemy.getUniqueId()) != null) {
if (requests.isEmpty()) {
plugin.duelRequests.remove(player.getUniqueId());
}
player.sendMessage("§aPárbajkérelem elutasítva.");
enemy.sendMessage("§c" + player.getName() + " elutasította a párbajkérelmedet.");
} else {
player.sendMessage("§cNincs párbajkérelmed ettől a játékostól.");
} }
} else { } else {
sender.sendMessage("nem vagy player nem fog sikerulni"); sender.sendMessage("nem vagy player nem fog sikerulni");

View File

@@ -48,6 +48,12 @@ public class DuelCommand implements CommandExecutor, TabCompleter {
player.sendMessage("§7[§9§lInsane§e§lDuels§7] §7» §cA megadott játékos nem elérhető"); player.sendMessage("§7[§9§lInsane§e§lDuels§7] §7» §cA megadott játékos nem elérhető");
return true; return true;
} }
if (player.equals(target)) {
player.sendMessage("§7[§9§lInsane§e§lDuels§7] §7» §cMagaddal nem párbajozhatsz!");
return true;
}
if (target.hasMetadata("DueledBy") && target.getMetadata("DueledBy").get(0).asString().equals(player.getUniqueId().toString())) { if (target.hasMetadata("DueledBy") && target.getMetadata("DueledBy").get(0).asString().equals(player.getUniqueId().toString())) {
player.sendMessage("§7[§9§lInsane§e§lDuels§7] §7» §e" + target.getName() + "§9 játékosnak már küldtél párbaj kérelmet."); player.sendMessage("§7[§9§lInsane§e§lDuels§7] §7» §e" + target.getName() + "§9 játékosnak már küldtél párbaj kérelmet.");
return true; return true;

View File

@@ -8,6 +8,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -15,7 +16,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List; import java.util.List;
public class EditKitCommand implements CommandExecutor, TabCompleter { public class EditKitCommand implements CommandExecutor, TabCompleter {
@@ -25,40 +25,10 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
this.plugin = plugin; this.plugin = plugin;
} }
private int getItemSlot(String key, String kit, Player player) {
String path = "kits." + kit + "." + player.getUniqueId() + "." + key;
if (plugin.getConfig().contains(path)) {
try {
return plugin.getConfig().getInt(path);
} catch (NumberFormatException e) {
plugin.getLogger().warning("Invalid slot number in config for " + path);
}
}
return -1;
}
private @NotNull List<Integer> getItemSlotArray(String key, String kit, Player player) {
String path = "kits." + kit + "." + player.getUniqueId() + "." + key;
if (plugin.getConfig().contains(path)) {
List<Integer> slots = plugin.getConfig().getIntegerList(path);
if (!slots.isEmpty()) {
return slots;
} else {
plugin.getLogger().warning("Invalid or empty slot numbers in config for " + path);
}
}
return Collections.singletonList(-1);
}
@Override @Override
public boolean onCommand(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) { public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
/*if (cmds.hasPermission("wolfffa.command.editkit")) { if (sender.hasPermission("insaneduels.editkit")) {
if (cmds instanceof Player player) { if (sender instanceof Player player) {
if (args.length > 0) { if (args.length > 0) {
Kits kitManager = new Kits(plugin); Kits kitManager = new Kits(plugin);
Inventory gui = Bukkit.createInventory(null, 27, "Kit Editor"); Inventory gui = Bukkit.createInventory(null, 27, "Kit Editor");
@@ -68,6 +38,8 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
ItemStack infoItem = new ItemStack(Material.WHITE_STAINED_GLASS_PANE); ItemStack infoItem = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
ItemMeta infoMeta = infoItem.getItemMeta(); ItemMeta infoMeta = infoItem.getItemMeta();
infoMeta.setDisplayName("§fEdit Kit: " + args[0]);
infoItem.setItemMeta(infoMeta);
ItemStack undoKit = new ItemStack(Material.RED_STAINED_GLASS_PANE); ItemStack undoKit = new ItemStack(Material.RED_STAINED_GLASS_PANE);
ItemMeta undoMeta = undoKit.getItemMeta(); ItemMeta undoMeta = undoKit.getItemMeta();
@@ -94,112 +66,40 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
gui.setItem(24, undoKit); gui.setItem(24, undoKit);
gui.setItem(25, undoKit); gui.setItem(25, undoKit);
gui.setItem(26, undoKit); gui.setItem(26, undoKit);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
Inventory inv = player.getInventory(); Inventory inv = player.getInventory();
switch (args[0]) { inv.clear();
case "sword":
inv.clear();
inv.setContents(kitManager.getSwordKit(player).getContents());
infoMeta.setDisplayName("§fSword Kit"); inv.setContents(kitManager.getKit(args[0], player));
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
player.openInventory(gui); player.openInventory(gui);
break;
case "uhc":
inv.clear();
inv.setContents(kitManager.getUhcKit(player).getContents());
infoMeta.setDisplayName("§fUHC Kit");
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
player.openInventory(gui);
break;
case "mace":
inv.clear();
inv.setContents(kitManager.getMaceKit(player).getContents());
infoMeta.setDisplayName("§fMace Kit");
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
player.openInventory(gui);
break;
case "axe":
inv.clear();
inv.setContents(kitManager.getAxeKit(player).getContents());
infoMeta.setDisplayName("§fAxe Kit");
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
player.openInventory(gui);
break;
case "diasmp":
inv.clear();
inv.setContents(kitManager.getAxeKit(player).getContents());
infoMeta.setDisplayName("§fDiamondSmp Kit");
infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem);
gui.setItem(4, infoItem);
gui.setItem(5, infoItem);
gui.setItem(12, infoItem);
gui.setItem(13, infoItem);
gui.setItem(14, infoItem);
gui.setItem(21, infoItem);
gui.setItem(22, infoItem);
gui.setItem(23, infoItem);
player.openInventory(gui);
break;
default:
player.sendMessage("§cNincs ilyen FFA típus!");
break;
}
} }
} }
}*/ }
return true; return true;
} }
@Override @Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) { public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (args.length == 1) { if (args.length == 1) {
return List.of("sword", "uhc", "mace", "axe", "diasmp"); ConfigurationSection kitsSection = plugin.getConfig().getConfigurationSection("default.kits");
if (kitsSection != null) {
String current = args[0].toLowerCase();
List<String> matches = kitsSection.getKeys(false).stream()
.filter(kit -> kit.toLowerCase().startsWith(current))
.toList();
return matches.isEmpty() ? List.of() : List.of(matches.toArray(new String[0]));
}
} }
return List.of(); return List.of();
} }

View File

@@ -1,7 +1,6 @@
package lnmpro.Commands; package lnmpro.Commands;
import lnmpro.Main; import lnmpro.Main;
import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -11,7 +10,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
import java.util.UUID;
public class LeaveCommand implements CommandExecutor, TabCompleter { public class LeaveCommand implements CommandExecutor, TabCompleter {
private final Main plugin; private final Main plugin;
@@ -26,6 +24,9 @@ public class LeaveCommand implements CommandExecutor, TabCompleter {
if (player.hasMetadata("DuelingWith")) { if (player.hasMetadata("DuelingWith")) {
player.setHealth(0); player.setHealth(0);
} }
if (player.getMetadata("IsSpectating").get(0).asBoolean()) {
plugin.removePlayerFromDuel(player);
}
} }
return true; return true;
} }

View File

@@ -1,5 +1,6 @@
package lnmpro.Commands; package lnmpro.Commands;
import lnmpro.Main;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@@ -8,7 +9,11 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class SpectateCommand implements CommandExecutor { public class SpectateCommand implements CommandExecutor {
private final Main plugin;
public SpectateCommand(Main plugin) {
this.plugin = plugin;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

View File

@@ -63,13 +63,18 @@ public class DuelRequestListener implements Listener {
player.removeMetadata("DuelRequest", plugin); player.removeMetadata("DuelRequest", plugin);
String gamemode = ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName().toLowerCase());
plugin.duelRequests.computeIfAbsent(target.getUniqueId(), k -> new java.util.HashMap<>())
.put(player.getUniqueId(), new Main.DuelRequestData(System.currentTimeMillis(), gamemode));
TextComponent accept = new TextComponent("§a[✔ Elfogadás]"); TextComponent accept = new TextComponent("§a[✔ Elfogadás]");
accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/acceptduel")); accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/acceptduel " + player.getName()));
accept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, accept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new ComponentBuilder("§a✔ Nyomj rá az elfogadáshoz!").create())); new ComponentBuilder("§a✔ Nyomj rá az elfogadáshoz!").create()));
TextComponent decline = new TextComponent("§c[❌ Elutasítás]"); TextComponent decline = new TextComponent("§c[❌ Elutasítás]");
decline.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/denyduel")); decline.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/denyduel " + player.getName()));
decline.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, decline.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new ComponentBuilder("§c❌ Nyomj rá az elutasításhoz!").create())); new ComponentBuilder("§c❌ Nyomj rá az elutasításhoz!").create()));
@@ -96,9 +101,6 @@ public class DuelRequestListener implements Listener {
target.spigot().sendMessage(fullMessage); target.spigot().sendMessage(fullMessage);
target.sendMessage("§8-----------------------------------------------------"); target.sendMessage("§8-----------------------------------------------------");
target.setMetadata("DueledBy", new FixedMetadataValue(plugin, player.getUniqueId().toString()));
target.setMetadata("DueledWithGamemode", new FixedMetadataValue(plugin, ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName().toLowerCase())));
player.closeInventory(); player.closeInventory();
} }
} }

View File

@@ -25,104 +25,6 @@ public class KitListener implements Listener {
this.plugin = plugin; this.plugin = plugin;
} }
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (plugin.getConfig().getString("kits.sword." + player.getUniqueId()) == null) {
Map<String, Object> kit = new HashMap<>();
kit.put("sword", 0);
plugin.getConfig().set("kits.sword." + player.getUniqueId(), kit);
plugin.saveConfig();
plugin.reloadConfig();
}
if (plugin.getConfig().getString("kits.uhc." + player.getUniqueId()) == null) {
Map<String, Object> kit = new HashMap<>();
int[] shield = new int[]{13, 40};
int[] water = new int[]{6, 22, 23, 24};
int[] lava = new int[]{2, 21};
kit.put("axe", 0);
kit.put("sword", 1);
kit.put("lava", lava);
kit.put("cobweb", 3);
kit.put("cobblestone", 4);
kit.put("goldenapple", 5);
kit.put("water", water);
kit.put("crossbow", 7);
kit.put("bow", 8);
kit.put("arrow", 9);
kit.put("planks", 17);
kit.put("pickaxe", 20);
kit.put("shield", shield);
plugin.getConfig().set("kits.uhc." + player.getUniqueId(), kit);
plugin.saveConfig();
plugin.reloadConfig();
}
if (plugin.getConfig().getString("kits.mace." + player.getUniqueId()) == null) {
Map<String, Object> kit = new HashMap<>();
int[] strength = new int[]{10, 11, 12, 13, 14, 15, 16, 28, 29, 30};
int[] speed = new int[]{19, 20, 21, 22, 23, 24, 25, 31, 32, 33};
int[] totem = new int[]{35, 40};
int[] enderpearl = new int[]{2, 9, 18, 27};
int[] goldenapple = new int[]{5, 17};
int[] windcharge = new int[]{7, 34};
kit.put("axe", 0);
kit.put("sword", 1);
kit.put("enderpearl", enderpearl);
kit.put("shield", 3);
kit.put("density", 4);
kit.put("goldenapple", goldenapple);
kit.put("breach", 6);
kit.put("windcharge", windcharge);
kit.put("elytra", 8);
kit.put("strength", strength);
kit.put("speed", speed);
kit.put("totem", totem);
kit.put("shulker", 26);
plugin.getConfig().set("kits.mace." + player.getUniqueId(), kit);
plugin.saveConfig();
plugin.reloadConfig();
}
if (plugin.getConfig().getString("kits.axe." + player.getUniqueId()) == null) {
Map<String, Object> kit = new HashMap<>();
kit.put("axe", 0);
kit.put("sword", 1);
kit.put("crossbow", 2);
kit.put("bow", 3);
kit.put("arrow", 8);
kit.put("shield", 40);
plugin.getConfig().set("kits.axe." + player.getUniqueId(), kit);
plugin.saveConfig();
plugin.reloadConfig();
}
if (plugin.getConfig().getString("kits.diasmp." + player.getUniqueId()) == null) {
Map<String, Object> kit = new HashMap<>();
int[] goldenapple = new int[]{5, 32};
int[] strength = new int[]{7, 12, 13, 14, 15, 19, 20, 21, 22, 23, 24, 29, 30, 31, 33};
int[] speed = new int[]{16, 25, 34};
int[] fireresistance = new int[]{17, 26, 35};
int[] water = new int[]{4, 10, 11};
int[] xp = new int[]{18, 27};
kit.put("axe", 0);
kit.put("sword", 1);
kit.put("enderpearl", 2);
kit.put("log", 3);
kit.put("water", water);
kit.put("goldenapple", goldenapple);
kit.put("cobweb", 6);
kit.put("strength", strength);
kit.put("totem", 8);
kit.put("pickaxe", 9);
kit.put("speed", speed);
kit.put("fireresistance", fireresistance);
kit.put("xp", xp);
kit.put("chorusfruit", 28);
kit.put("shield", 40);
plugin.getConfig().set("kits.diasmp." + player.getUniqueId(), kit);
plugin.saveConfig();
plugin.reloadConfig();
}
}
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player player)) return; if (!(event.getWhoClicked() instanceof Player player)) return;
@@ -132,199 +34,51 @@ public class KitListener implements Listener {
if (event.getClickedInventory() == event.getView().getTopInventory() && event.getView().title().equals(Component.text("Kit Editor"))) { if (event.getClickedInventory() == event.getView().getTopInventory() && event.getView().title().equals(Component.text("Kit Editor"))) {
event.setCancelled(true); event.setCancelled(true);
if ((0 <= event.getSlot() && event.getSlot() <= 2) || (9 <= event.getSlot() && event.getSlot() <= 11) || (18 <= event.getSlot() && event.getSlot() <= 20)) { if ((0 <= event.getSlot() && event.getSlot() <= 2) || (9 <= event.getSlot() && event.getSlot() <= 11) || (18 <= event.getSlot() && event.getSlot() <= 20)) {
List<Integer> uhclavaSlots = null; String gamemode = event.getClickedInventory().getItem(13).getItemMeta().getDisplayName().split(" ")[2];
List<Integer> uhcwaterSlots = null; ItemStack[] kit = ((List<ItemStack>) plugin.getConfig().get("default.kits." + gamemode)).toArray(new ItemStack[0]);
List<Integer> uhcshieldSlots = null; Map<String, Integer> kitTotals = new HashMap<>();
List<Integer> boxcartstrenghtSlots = null; for (ItemStack kitItem : kit) {
List<Integer> boxcartspeedSlots = null; if (kitItem == null) continue;
List<Integer> boxcartfireresistanceSlots = null; String key = kitItem.getType().toString() + kitItem.getItemMeta().toString();
List<Integer> boxcartcartSlots = null; kitTotals.put(key, kitTotals.getOrDefault(key, 0) + kitItem.getAmount());
List<Integer> boxcartenderpearlSlots = null; }
List<Integer> macetotemSlots = null;
List<Integer> maceenderpearlSlots = null;
List<Integer> macestrengthSlots = null;
List<Integer> macespeedSlots = null;
List<Integer> macegoldenappleSlots = null;
List<Integer> macewindchargeSlots = null;
List<Integer> diasmpwaterSlots = null;
List<Integer> diasmpxpSlots = null;
List<Integer> diasmpstrengthSlots = null;
List<Integer> diasmpspeedSlots = null;
List<Integer> diasmpfireresistanceSlots = null;
List<Integer> diasmpgoldenappleSlots = null;
if (gui.getItem(13).getItemMeta().getDisplayName().equals("§fSword Kit")) {
for (int i = 0; i < inv.length; i++) {
ItemStack item = inv[i];
if (item != null) { Map<String, Integer> invTotals = new HashMap<>();
if (item.getType() == Material.DIAMOND_SWORD) { for (ItemStack invItem : inv) {
plugin.getConfig().set("kits.sword." + player.getUniqueId() + ".sword", i); if (invItem == null) continue;
} String key = invItem.getType().toString() + invItem.getItemMeta().toString();
} invTotals.put(key, invTotals.getOrDefault(key, 0) + invItem.getAmount());
} }
} else if (gui.getItem(13).getItemMeta().getDisplayName().equals("§fUHC Kit")) {
uhclavaSlots = new ArrayList<>(); boolean valid = true;
uhcwaterSlots = new ArrayList<>(); for (Map.Entry<String, Integer> entry : invTotals.entrySet()) {
uhcshieldSlots = new ArrayList<>(); String key = entry.getKey();
for (int i = 0; i < inv.length; i++) { int invAmount = entry.getValue();
ItemStack item = inv[i]; int kitAmount = kitTotals.getOrDefault(key, 0);
if (item != null) { if (invAmount > kitAmount) {
if (item.getType() == Material.DIAMOND_AXE) { valid = false;
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".axe", i); break;
} else if (item.getType() == Material.DIAMOND_SWORD) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".sword", i);
} else if (item.getType() == Material.LAVA_BUCKET) {
uhclavaSlots.add(i);
} else if (item.getType() == Material.COBWEB) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".cobweb", i);
} else if (item.getType() == Material.COBBLESTONE) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".cobblestone", i);
} else if (item.getType() == Material.GOLDEN_APPLE) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".goldenapple", i);
} else if (item.getType() == Material.WATER_BUCKET) {
uhcwaterSlots.add(i);
} else if (item.getType() == Material.CROSSBOW) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".crossbow", i);
} else if (item.getType() == Material.BOW) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".bow", i);
} else if (item.getType() == Material.ARROW) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".arrow", i);
} else if (item.getType() == Material.OAK_PLANKS) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".planks", i);
} else if (item.getType() == Material.DIAMOND_PICKAXE) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".pickaxe", i);
} else if (item.getType() == Material.SHIELD) {
uhcshieldSlots.add(i);
}
}
}
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".lava", uhclavaSlots);
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".water", uhcwaterSlots);
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".shield", uhcshieldSlots);
} else if (gui.getItem(13).getItemMeta().getDisplayName().equals("§fMace Kit")) {
macetotemSlots = new ArrayList<>();
maceenderpearlSlots = new ArrayList<>();
macestrengthSlots = new ArrayList<>();
macespeedSlots = new ArrayList<>();
macegoldenappleSlots = new ArrayList<>();
macewindchargeSlots = new ArrayList<>();
for (int i = 0; i < inv.length; i++) {
ItemStack item = inv[i];
if (item != null) {
if (item.getType() == Material.NETHERITE_AXE) {
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".axe", i);
} else if (item.getType() == Material.NETHERITE_SWORD) {
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".sword", i);
} else if (item.getType() == Material.ENDER_PEARL) {
maceenderpearlSlots.add(i);
} else if (item.getType() == Material.SPLASH_POTION) {
if (item.getItemMeta().getDisplayName().equals("§rSplash Potion of Strength")) {
macestrengthSlots.add(i);
} else if (item.getItemMeta().getDisplayName().equals("§rSplash Potion of Swiftness")) {
macespeedSlots.add(i);
}
} else if (item.getType() == Material.SHIELD) {
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".shield", i);
} else if (item.getType() == Material.MACE) {
if (item.getItemMeta().getEnchants().containsKey(Enchantment.DENSITY)) {
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".density", i);
} else if (item.getItemMeta().getEnchants().containsKey(Enchantment.BREACH)) {
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".breach", i);
}
} else if (item.getType() == Material.GOLDEN_APPLE) {
macegoldenappleSlots.add(i);
} else if (item.getType() == Material.WIND_CHARGE) {
macewindchargeSlots.add(i);
} else if (item.getType() == Material.POTION) {
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".jumpboost", i);
} else if (item.getType() == Material.ELYTRA) {
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".elytra", i);
} else if (item.getType() == Material.TOTEM_OF_UNDYING) {
macetotemSlots.add(i);
}
}
}
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".totem", macetotemSlots);
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".enderpearl", maceenderpearlSlots);
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".strength", macestrengthSlots);
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".speed", macespeedSlots);
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".goldenapple", macegoldenappleSlots);
plugin.getConfig().set("kits.mace." + player.getUniqueId() + ".windcharge", macewindchargeSlots);
} else if (gui.getItem(13).getItemMeta().getDisplayName().equals("§fAxe Kit")) {
for (int i = 0; i < inv.length; i++) {
ItemStack item = inv[i];
if (item != null) {
if (item.getType() == Material.DIAMOND_AXE) {
plugin.getConfig().set("kits.axe." + player.getUniqueId() + "axe.", i);
} else if (item.getType() == Material.DIAMOND_SWORD) {
plugin.getConfig().set("kits.axe." + player.getUniqueId() + ".sword", i);
} else if (item.getType() == Material.CROSSBOW) {
plugin.getConfig().set("kits.axe." + player.getUniqueId() + ".crossbow", i);
} else if (item.getType() == Material.BOW) {
plugin.getConfig().set("kits.axe." + player.getUniqueId() + ".bow", i);
} else if (item.getType() == Material.ARROW) {
plugin.getConfig().set("kits.axe." + player.getUniqueId() + ".arrow", i);
} else if (item.getType() == Material.SHIELD) {
plugin.getConfig().set("kits.axe." + player.getUniqueId() + ".shield", i);
}
}
}
} else if (gui.getItem(13).getItemMeta().getDisplayName().equals("§fDiamondSmp Kit")) {
diasmpwaterSlots = new ArrayList<>();
diasmpxpSlots = new ArrayList<>();
diasmpstrengthSlots = new ArrayList<>();
diasmpspeedSlots = new ArrayList<>();
diasmpfireresistanceSlots = new ArrayList<>();
diasmpgoldenappleSlots = new ArrayList<>();
for (int i = 0; i < inv.length; i++) {
ItemStack item = inv[i];
if (item != null) {
if (item.getType() == Material.DIAMOND_AXE) {
plugin.getConfig().set("kits.diasmp." + player.getUniqueId() + ".axe", i);
} else if (item.getType() == Material.DIAMOND_SWORD) {
plugin.getConfig().set("kits.diasmp." + player.getUniqueId() + ".sword", i);
} else if (item.getType() == Material.ENDER_PEARL) {
plugin.getConfig().set("kits.diasmp." + player.getUniqueId() + ".enderpearl", i);
} else if (item.getType() == Material.OAK_LOG) {
plugin.getConfig().set("kits.diasmp." + player.getUniqueId() + ".log", i);
} else if (item.getType() == Material.WATER_BUCKET) {
diasmpwaterSlots.add(i);
} else if (item.getType() == Material.GOLDEN_APPLE) {
diasmpgoldenappleSlots.add(i);
} else if (item.getType() == Material.COBWEB) {
plugin.getConfig().set("kits.diasmp." + player.getUniqueId() + ".cobweb", i);
} else if (item.getType() == Material.SPLASH_POTION) {
if (item.getItemMeta().getDisplayName().equals("§rSplash Potion of Strength")) {
diasmpstrengthSlots.add(i);
} else if (item.getItemMeta().getDisplayName().equals("§rSplash Potion of Swiftness")) {
diasmpspeedSlots.add(i);
} else if (item.getItemMeta().getDisplayName().equals("§rSplash Potion of Fire Resistance")) {
diasmpfireresistanceSlots.add(i);
}
} else if (item.getType() == Material.TOTEM_OF_UNDYING) {
plugin.getConfig().set("kits.diasmp." + player.getUniqueId() + ".totem", i);
} else if (item.getType() == Material.NETHERITE_PICKAXE) {
plugin.getConfig().set("kits.diasmp." + player.getUniqueId() + ".pickaxe", i);
} else if (item.getType() == Material.EXPERIENCE_BOTTLE) {
diasmpxpSlots.add(i);
} else if (item.getType() == Material.CHORUS_FRUIT) {
plugin.getConfig().set("kits.diasmp." + player.getUniqueId() + ".chorusfruit", i);
}
}
} }
} }
plugin.saveConfig();
plugin.reloadConfig();
player.sendMessage("§aSikeresen elmentetted a kitedet!");
player.closeInventory();
for (String key : invTotals.keySet()) {
if (!kitTotals.containsKey(key)) {
valid = false;
break;
}
}
if (valid) {
plugin.getConfig().set("kits." + player.getUniqueId() + "." + gamemode, inv);
plugin.saveConfig();
plugin.reloadConfig();
player.closeInventory();
player.sendMessage("§aA kit el lett mentve.");
} else {
player.closeInventory();
player.sendMessage("§cA kited nem került mentésre.");
}
} else if ((6 <= event.getSlot() && event.getSlot() <= 8) || (15 <= event.getSlot() && event.getSlot() <= 17) || (24 <= event.getSlot() && event.getSlot() <= 26)) { } else if ((6 <= event.getSlot() && event.getSlot() <= 8) || (15 <= event.getSlot() && event.getSlot() <= 17) || (24 <= event.getSlot() && event.getSlot() <= 26)) {
player.closeInventory(); player.closeInventory();
player.sendMessage("§cA kited nem került mentésre."); player.sendMessage("§cA kited nem került mentésre.");

View File

@@ -12,16 +12,23 @@ import lnmpro.Commands.*;
import lnmpro.Listeners.*; import lnmpro.Listeners.*;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.UUID;
public final class Main extends JavaPlugin { public final class Main extends JavaPlugin {
public final String[] metadatas = {"DuelingWith", "ArenaLoc", "Frozen", "DuelRequest", "DueledBy", "DueledWithGamemode"}; public final String[] metadatas = {"DuelingWith", "ArenaLoc", "Frozen", "DuelRequest", "DueledBy", "DueledWithGamemode", "IsSpectating"};
private static Main instance; private static Main instance;
public record DuelRequestData(long timestamp, String gamemode) {}
public Map<UUID, Map<UUID, DuelRequestData>> duelRequests = new HashMap<>();
public void removePlayerFromDuel(Player player) { public void removePlayerFromDuel(Player player) {
Location spawn = new Location(Bukkit.getWorld("world"), 0, 3, 0, 0, 0); Location spawn = new Location(Bukkit.getWorld("world"), 0, 3, 0, 0, 0);
for (PotionEffect potionEffect : player.getActivePotionEffects()) { for (PotionEffect potionEffect : player.getActivePotionEffects()) {
@@ -44,6 +51,10 @@ public final class Main extends JavaPlugin {
} }
} }
/*páblik statik vojd rimúvPléjerFromDuel() {;
;
};*/
@Override @Override
public void onEnable() { public void onEnable() {
getConfig().options().copyDefaults(true); getConfig().options().copyDefaults(true);
@@ -55,15 +66,25 @@ public final class Main extends JavaPlugin {
getCommand("denyduel").setExecutor(new DenyDuelCommand(this)); getCommand("denyduel").setExecutor(new DenyDuelCommand(this));
getCommand("editkit").setExecutor(new EditKitCommand(this)); getCommand("editkit").setExecutor(new EditKitCommand(this));
getCommand("resetarenas").setExecutor(new ResetArenasCommand(this)); getCommand("resetarenas").setExecutor(new ResetArenasCommand(this));
getCommand("spectate").setExecutor(new SpectateCommand()); getCommand("spectate").setExecutor(new SpectateCommand(this));
getCommand("leave").setExecutor(new LeaveCommand(this)); getCommand("leave").setExecutor(new LeaveCommand(this));
getCommand("createkit").setExecutor(new CreateKitCommand(this));
getServer().getPluginManager().registerEvents(new DuelRequestListener(this), this); getServer().getPluginManager().registerEvents(new DuelRequestListener(this), this);
getServer().getPluginManager().registerEvents(new KitListener(this), this); getServer().getPluginManager().registerEvents(new KitListener(this), this);
getServer().getPluginManager().registerEvents(new DuelEndListener(this), this); getServer().getPluginManager().registerEvents(new DuelEndListener(this), this);
getServer().getPluginManager().registerEvents(new FreezeListener(), this); getServer().getPluginManager().registerEvents(new FreezeListener(), this);
getServer().getPluginManager().registerEvents(new PlayerLeaveListener(this), this); getServer().getPluginManager().registerEvents(new PlayerLeaveListener(this), this);
getServer().getPluginManager().registerEvents(new SpectatorListener(), this); getServer().getPluginManager().registerEvents(new SpectatorListener(this), this);
new BukkitRunnable() {
@Override
public void run() {
long now = System.currentTimeMillis();
duelRequests.values().forEach(requests -> requests.entrySet().removeIf(entry -> (now - entry.getValue().timestamp()) > 60000));
duelRequests.entrySet().removeIf(entry -> entry.getValue().isEmpty());
}
}.runTaskTimer(this, 0L, 20L * 60); // Run every minute
WorldReset worldReset = new WorldReset(this); WorldReset worldReset = new WorldReset(this);
worldReset.recreateArenaWorld(); worldReset.recreateArenaWorld();

View File

@@ -25,329 +25,15 @@ public class Kits {
this.plugin = plugin; this.plugin = plugin;
} }
private int getItemSlot(String key, String kit, Player player) { public ItemStack[] getKit(String gamemode, Player player) {
String path = "kits." + kit + "." + player.getUniqueId() + "." + key; if (plugin.getConfig().get("kits." + player.getUniqueId() + "." + gamemode) != null) {
ItemStack[] kit = ((List<ItemStack>) plugin.getConfig().get("kits." + player.getUniqueId() + "." + gamemode)).toArray(new ItemStack[0]);
if (plugin.getConfig().contains(path)) { return kit;
try { } else {
return plugin.getConfig().getInt(path); ItemStack[] kit = ((List<ItemStack>) plugin.getConfig().get("default.kits." + gamemode)).toArray(new ItemStack[0]);
} catch (NumberFormatException e) {
plugin.getLogger().warning("Invalid slot number in config for " + path); return kit;
}
} }
return -1;
}
private @NotNull List<Integer> getItemSlotArray(String key, String kit, Player player) {
String path = "kits." + kit + "." + player.getUniqueId() + "." + key;
if (plugin.getConfig().contains(path)) {
List<Integer> slots = plugin.getConfig().getIntegerList(path);
if (!slots.isEmpty()) {
return slots;
} else {
plugin.getLogger().warning("Invalid or empty slot numbers in config for " + path);
}
}
return Collections.singletonList(-1);
}
public PlayerInventory getSwordKit(Player player) {
PlayerInventory inv = player.getInventory();
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.SWEEPING_EDGE, 3);
inv.setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
inv.setItem(getItemSlot("sword", "sword", player), sword);
return inv;
}
public PlayerInventory getUhcKit(Player player) {
PlayerInventory inv = player.getInventory();
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);
ItemStack pickaxe = new ItemStack(Material.DIAMOND_PICKAXE);
helmet.addEnchantment(Enchantment.PROTECTION, 3);
chestplate.addEnchantment(Enchantment.PROTECTION, 2);
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);
pickaxe.addEnchantment(Enchantment.UNBREAKING,3);
pickaxe.addEnchantment(Enchantment.EFFICIENCY, 3);
inv.setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
inv.setItem(getItemSlot("axe", "uhc", player), axe);
inv.setItem(getItemSlot("sword", "uhc", player), sword);
for (int slot : getItemSlotArray("lava", "uhc", player)) {
inv.setItem(slot, lava);
}
inv.setItem(getItemSlot("cobweb", "uhc", player), cobweb);
inv.setItem(getItemSlot("cobblestone", "uhc", player), cobblestone);
inv.setItem(getItemSlot("goldenapple", "uhc", player), goldenapple);
for (int slot : getItemSlotArray("water", "uhc", player)) {
inv.setItem(slot, water);
}
inv.setItem(getItemSlot("crossbow", "uhc", player), crossbow);
inv.setItem(getItemSlot("bow", "uhc", player), bow);
inv.setItem(getItemSlot("arrow", "uhc", player), arrow);
for (int slot : getItemSlotArray("shield", "uhc", player)) {
inv.setItem(slot, shield);
}
inv.setItem(getItemSlot("planks", "uhc", player), planks);
inv.setItem(getItemSlot("pickaxe", "uhc", player), pickaxe);
return inv;
}
public PlayerInventory getMaceKit(Player player) {
PlayerInventory inv = player.getInventory();
ItemStack helmet = new ItemStack(Material.NETHERITE_HELMET);
ItemStack chestplate = new ItemStack(Material.NETHERITE_CHESTPLATE);
ItemStack leggings = new ItemStack(Material.NETHERITE_LEGGINGS);
ItemStack boots = new ItemStack(Material.NETHERITE_BOOTS);
ItemStack axe = new ItemStack(Material.NETHERITE_AXE);
ItemStack sword = new ItemStack(Material.NETHERITE_SWORD);
ItemStack enderpearl = new ItemStack(Material.ENDER_PEARL, 16);
ItemStack shield = new ItemStack(Material.SHIELD);
ItemStack density = new ItemStack(Material.MACE);
ItemStack goldenapple = new ItemStack(Material.GOLDEN_APPLE, 64);
ItemStack breach = new ItemStack(Material.MACE);
ItemStack windchare = new ItemStack(Material.WIND_CHARGE, 64);
ItemStack elytra = new ItemStack(Material.ELYTRA);
ItemStack totem = new ItemStack(Material.TOTEM_OF_UNDYING);
ItemStack shulker = new ItemStack(Material.SHULKER_BOX);
ItemStack strength = new ItemStack(Material.SPLASH_POTION);
ItemStack speed = new ItemStack(Material.SPLASH_POTION);
helmet.addEnchantment(Enchantment.PROTECTION, 4);
chestplate.addEnchantment(Enchantment.PROTECTION, 4);
leggings.addEnchantment(Enchantment.PROTECTION, 4);
boots.addEnchantment(Enchantment.FEATHER_FALLING, 4);
boots.addEnchantment(Enchantment.PROTECTION, 4);
sword.addEnchantment(Enchantment.SHARPNESS, 5);
sword.addEnchantment(Enchantment.UNBREAKING, 3);
axe.addEnchantment(Enchantment.SHARPNESS, 5);
axe.addEnchantment(Enchantment.UNBREAKING, 3);
shield.addEnchantment(Enchantment.UNBREAKING, 3);
density.addEnchantment(Enchantment.WIND_BURST, 1);
density.addEnchantment(Enchantment.DENSITY, 5);
density.addEnchantment(Enchantment.UNBREAKING, 3);
breach.addEnchantment(Enchantment.BREACH, 4);
breach.addEnchantment(Enchantment.UNBREAKING, 3);
PotionMeta strengthmeta = (PotionMeta) strength.getItemMeta();
strengthmeta.addCustomEffect(new PotionEffect(PotionEffectType.STRENGTH, 1800, 1), true);
strengthmeta.setDisplayName("§rSplash Potion of Strength");
strengthmeta.setMainEffect(PotionEffectType.STRENGTH);
strength.setItemMeta(strengthmeta);
PotionMeta speedmeta = (PotionMeta) speed.getItemMeta();
speedmeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 1800, 1), true);
speedmeta.setDisplayName("§rSplash Potion of Speed");
speedmeta.setMainEffect(PotionEffectType.SPEED);
speed.setItemMeta(speedmeta);
BlockStateMeta shulkermeta = (BlockStateMeta) shulker.getItemMeta();
ShulkerBox shulkerbox = (ShulkerBox) shulkermeta.getBlockState();
Inventory shulkerinv = shulkerbox.getInventory();
for (int i = 0; i < 14; i++) {
shulkerinv.setItem(i, strength);
}
for (int i = 14; i < 27; i++) {
shulkerinv.setItem(i, speed);
}
shulkermeta.setBlockState(shulkerbox);
shulker.setItemMeta(shulkermeta);
inv.setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
inv.setItem(getItemSlot("axe", "mace", player), axe);
inv.setItem(getItemSlot("sword", "mace", player), sword);
for (int slot : getItemSlotArray("enderpearl", "mace", player)) {
inv.setItem(slot, enderpearl);
}
inv.setItem(getItemSlot("shield", "mace", player), shield);
inv.setItem(getItemSlot("density", "mace", player), density);
for (int slot : getItemSlotArray("goldenapple", "mace", player)) {
inv.setItem(slot, goldenapple);
}
inv.setItem(getItemSlot("breach", "mace", player), breach);
for (int slot : getItemSlotArray("windcharge", "mace", player)) {
inv.setItem(slot, windchare);
}
inv.setItem(getItemSlot("elytra", "mace", player), elytra);
inv.setItem(getItemSlot("shulker", "mace", player), shulker);
for (int slot : getItemSlotArray("strength", "mace", player)) {
inv.setItem(slot, strength);
}
for (int slot : getItemSlotArray("speed", "mace", player)) {
inv.setItem(slot, speed);
}
for (int slot : getItemSlotArray("totem", "mace", player)) {
inv.setItem(slot, totem);
}
return inv;
}
public PlayerInventory getAxeKit(Player player) {
PlayerInventory inv = player.getInventory();
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 crossbow = new ItemStack(Material.CROSSBOW);
ItemStack bow = new ItemStack(Material.BOW);
ItemStack arrow = new ItemStack(Material.ARROW, 6);
ItemStack shield = new ItemStack(Material.SHIELD);
inv.setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
inv.setItem(getItemSlot("axe", "axe", player), axe);
inv.setItem(getItemSlot("sword", "axe", player), sword);
inv.setItem(getItemSlot("crossbow", "axe", player), crossbow);
inv.setItem(getItemSlot("bow", "axe", player), bow);
inv.setItem(getItemSlot("arrow", "axe", player), arrow);
inv.setItem(getItemSlot("shield", "axe", player), shield);
return inv;
}
public PlayerInventory getDiaSMPKit(Player player) {
PlayerInventory inv = player.getInventory();
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 enderpearl = new ItemStack(Material.ENDER_PEARL, 16);
ItemStack log = new ItemStack(Material.OAK_LOG, 64);
ItemStack water = new ItemStack(Material.WATER_BUCKET);
ItemStack goldenapple = new ItemStack(Material.GOLDEN_APPLE, 64);
ItemStack cobweb = new ItemStack(Material.COBWEB, 64);
ItemStack strength = new ItemStack(Material.SPLASH_POTION);
ItemStack totem = new ItemStack(Material.TOTEM_OF_UNDYING);
ItemStack pickaxe = new ItemStack(Material.NETHERITE_PICKAXE);
ItemStack speed = new ItemStack(Material.SPLASH_POTION);
ItemStack fireresistance = new ItemStack(Material.SPLASH_POTION);
ItemStack xp = new ItemStack(Material.EXPERIENCE_BOTTLE, 64);
ItemStack chorusfruit = new ItemStack(Material.CHORUS_FRUIT, 64);
ItemStack shield = new ItemStack(Material.SHIELD);
helmet.addEnchantment(Enchantment.PROTECTION, 4);
helmet.addEnchantment(Enchantment.UNBREAKING, 3);
helmet.addEnchantment(Enchantment.MENDING, 1);
chestplate.addEnchantment(Enchantment.PROTECTION, 4);
chestplate.addEnchantment(Enchantment.UNBREAKING, 3);
chestplate.addEnchantment(Enchantment.MENDING, 1);
leggings.addEnchantment(Enchantment.PROTECTION, 4);
leggings.addEnchantment(Enchantment.SWIFT_SNEAK, 3);
leggings.addEnchantment(Enchantment.UNBREAKING, 3);
leggings.addEnchantment(Enchantment.MENDING, 1);
boots.addEnchantment(Enchantment.PROTECTION, 4);
boots.addEnchantment(Enchantment.FEATHER_FALLING, 4);
boots.addEnchantment(Enchantment.DEPTH_STRIDER, 3);
boots.addEnchantment(Enchantment.UNBREAKING, 3);
boots.addEnchantment(Enchantment.MENDING, 1);
axe.addEnchantment(Enchantment.SHARPNESS, 5);
axe.addEnchantment(Enchantment.UNBREAKING, 3);
sword.addEnchantment(Enchantment.SHARPNESS, 5);
sword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
sword.addEnchantment(Enchantment.UNBREAKING, 3);
pickaxe.addEnchantment(Enchantment.SILK_TOUCH, 1);
pickaxe.addEnchantment(Enchantment.EFFICIENCY, 5);
pickaxe.addEnchantment(Enchantment.UNBREAKING, 3);
pickaxe.addEnchantment(Enchantment.MENDING, 1);
shield.addEnchantment(Enchantment.UNBREAKING, 3);
shield.addEnchantment(Enchantment.MENDING, 1);
PotionMeta fireresistancemeta = (PotionMeta) fireresistance.getItemMeta();
fireresistancemeta.addCustomEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 9600, 0), true);
fireresistancemeta.setMainEffect(PotionEffectType.FIRE_RESISTANCE);
fireresistancemeta.setDisplayName("§rSplash Potion of Fire Resistance");
fireresistance.setItemMeta(fireresistancemeta);
PotionMeta strengthmeta = (PotionMeta) strength.getItemMeta();
strengthmeta.addCustomEffect(new PotionEffect(PotionEffectType.STRENGTH, 1800, 1), true);
strengthmeta.setDisplayName("§rSplash Potion of Strength");
strengthmeta.setMainEffect(PotionEffectType.STRENGTH);
strength.setItemMeta(strengthmeta);
PotionMeta speedmeta = (PotionMeta) speed.getItemMeta();
speedmeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 9600, 0), true);
speedmeta.setDisplayName("§rSplash Potion of Speed");
speedmeta.setMainEffect(PotionEffectType.SPEED);
speed.setItemMeta(speedmeta);
inv.setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
inv.setItem(getItemSlot("axe", "diasmp", player), axe);
inv.setItem(getItemSlot("sword", "diasmp", player), sword);
inv.setItem(getItemSlot("enderpearl", "diasmp", player), enderpearl);
inv.setItem(getItemSlot("log", "diasmp", player), log);
for (int slot : getItemSlotArray("water", "diasmp", player)) {
inv.setItem(slot, water);
}
for (int slot : getItemSlotArray("goldenapple", "diasmp", player)) {
inv.setItem(slot, goldenapple);
}
inv.setItem(getItemSlot("cobweb", "diasmp", player), cobweb);
for (int slot : getItemSlotArray("strength", "diasmp", player)) {
inv.setItem(slot, strength);
}
inv.setItem(getItemSlot("totem", "diasmp", player), totem);
inv.setItem(getItemSlot("pickaxe", "diasmp", player), pickaxe);
for (int slot : getItemSlotArray("speed", "diasmp", player)) {
inv.setItem(slot, speed);
}
for (int slot : getItemSlotArray("fireresistance", "diasmp", player)) {
inv.setItem(slot, fireresistance);
}
for (int slot : getItemSlotArray("xp", "diasmp", player)) {
inv.setItem(slot, xp);
}
inv.setItem(getItemSlot("chorusfruit", "diasmp", player), chorusfruit);
inv.setItem(getItemSlot("shield", "diasmp", player), shield);
return inv;
} }
} }

View File

@@ -15,7 +15,7 @@ public class WorldReset {
this.plugin = plugin; this.plugin = plugin;
} }
public final String[] metadatas = {"DuelingWith", "ArenaLoc", "Frozen", "DuelRequest", "DueledBy", "DueledWithGamemode"}; public final String[] metadatas = {"DuelingWith", "ArenaLoc", "Frozen", "DuelRequest", "DueledBy", "DueledWithGamemode", "IsSpectating"};
public boolean recreateArenaWorld() { public boolean recreateArenaWorld() {
String worldName = "arenas"; String worldName = "arenas";

View File

@@ -1 +1,3 @@
kits: {} kits: {}
default:
kits: {}

View File

@@ -12,3 +12,5 @@ commands:
permission: insaneduels.resetarenas permission: insaneduels.resetarenas
spectate: spectate:
leave: leave:
createkit:
permission: insaneduels.createkit

Binary file not shown.

View File

@@ -1 +1,3 @@
kits: {} kits: {}
default:
kits: {}

Binary file not shown.

View File

@@ -12,3 +12,5 @@ commands:
permission: insaneduels.resetarenas permission: insaneduels.resetarenas
spectate: spectate:
leave: leave:
createkit:
permission: insaneduels.createkit

View File

@@ -1,4 +1,5 @@
lnmpro/Listeners/FreezeListener.class lnmpro/Listeners/FreezeListener.class
lnmpro/Main$DuelRequestData.class
lnmpro/Listeners/PlayerLeaveListener.class lnmpro/Listeners/PlayerLeaveListener.class
lnmpro/Commands/AcceptDuelCommand$1.class lnmpro/Commands/AcceptDuelCommand$1.class
lnmpro/Commands/ResetArenasCommand.class lnmpro/Commands/ResetArenasCommand.class
@@ -8,5 +9,7 @@ lnmpro/Commands/SpectateCommand.class
lnmpro/Utils/SchematicManager.class lnmpro/Utils/SchematicManager.class
lnmpro/Utils/WorldReset.class lnmpro/Utils/WorldReset.class
lnmpro/Listeners/SpectatorListener.class lnmpro/Listeners/SpectatorListener.class
lnmpro/Commands/CreateKitCommand.class
lnmpro/Commands/LeaveCommand.class lnmpro/Commands/LeaveCommand.class
lnmpro/Main$1.class
lnmpro/Commands/EditKitCommand.class lnmpro/Commands/EditKitCommand.class

View File

@@ -1,4 +1,5 @@
/home/jgj52/IdeaProjects/InsaneDuels/src/main/java/lnmpro/Commands/AcceptDuelCommand.java /home/jgj52/IdeaProjects/InsaneDuels/src/main/java/lnmpro/Commands/AcceptDuelCommand.java
/home/jgj52/IdeaProjects/InsaneDuels/src/main/java/lnmpro/Commands/CreateKitCommand.java
/home/jgj52/IdeaProjects/InsaneDuels/src/main/java/lnmpro/Commands/DenyDuelCommand.java /home/jgj52/IdeaProjects/InsaneDuels/src/main/java/lnmpro/Commands/DenyDuelCommand.java
/home/jgj52/IdeaProjects/InsaneDuels/src/main/java/lnmpro/Commands/DuelCommand.java /home/jgj52/IdeaProjects/InsaneDuels/src/main/java/lnmpro/Commands/DuelCommand.java
/home/jgj52/IdeaProjects/InsaneDuels/src/main/java/lnmpro/Commands/EditKitCommand.java /home/jgj52/IdeaProjects/InsaneDuels/src/main/java/lnmpro/Commands/EditKitCommand.java