Compare commits

..

15 Commits

Author SHA1 Message Date
d3adf205d4 fellkesz crystal kit 2025-03-06 23:54:55 +01:00
757cdc86b6 asd 2025-03-06 21:07:32 +01:00
838c002a8c mace axe diasmp kit, + updateik c: 2025-03-06 20:16:05 +01:00
987994aab4 leave command + boxcart update + mapreset 2025-03-03 18:16:56 +01:00
fcabc53b07 quick fix 2025-03-02 21:07:28 +01:00
d4caba3538 quick fix 2025-02-25 19:19:55 +01:00
979ffdfba2 esku utolso 2025-02-24 17:03:56 +01:00
89cc8612d9 nem tom miert vannak 1 line commitok 2025-02-24 17:01:22 +01:00
d5a45d68ab blast prot 2025-02-24 16:55:08 +01:00
2fe2d3fa81 nemtom 2025-02-24 16:36:10 +01:00
f678965238 v 2025-02-23 23:19:34 +01:00
0505b89f75 a 2025-02-23 23:18:24 +01:00
dc72222f40 Delete .gitignore 2025-02-23 23:07:30 +01:00
2b5b840cbf mondtam ma megcsinalom 2025-02-23 23:06:12 +01:00
dc0072ae62 holnap folytatom 2025-02-22 00:02:21 +01:00
26 changed files with 1449 additions and 223 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
target/

1
.idea/.gitignore generated vendored
View File

@@ -1,3 +1,4 @@
# Default ignored files # Default ignored files
/shelf/ /shelf/
/workspace.xml /workspace.xml

View File

@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="RemoteRepositoriesConfiguration"> <component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="enginehub-repo" />
<option name="name" value="enginehub-repo" />
<option name="url" value="https://maven.enginehub.org/repo/" />
</remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="central" /> <option name="id" value="central" />
<option name="name" value="Central Repository" /> <option name="name" value="Central Repository" />

26
pom.xml
View File

@@ -13,6 +13,7 @@
<properties> <properties>
<java.version>21</java.version> <java.version>21</java.version>
<fawe.version>2.13.0</fawe.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
@@ -59,6 +60,16 @@
<id>sonatype</id> <id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url> <url>https://oss.sonatype.org/content/groups/public/</url>
</repository> </repository>
<repository>
<id>enginehub-repo</id>
<url>https://maven.enginehub.org/repo/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@@ -68,5 +79,20 @@
<version>1.21.1-R0.1-SNAPSHOT</version> <version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.3.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fastasyncworldedit</groupId>
<artifactId>FastAsyncWorldEdit-Bukkit</artifactId>
<version>2.13.0</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -1,22 +1,31 @@
package hu.jgj52.wolfFFA.Commands; package hu.jgj52.wolfFFA.Commands;
import hu.jgj52.wolfFFA.Main; import hu.jgj52.wolfFFA.Main;
import hu.jgj52.wolfFFA.Utils.Kits;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.block.BlockState;
import org.bukkit.block.Container;
import org.bukkit.block.ShulkerBox;
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;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
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 {
@@ -40,11 +49,28 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
return -1; 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 cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (cmds.hasPermission("wolfffa.command.editkit")) { if (cmds.hasPermission("wolfffa.command.editkit")) {
if (cmds instanceof Player player) { if (cmds instanceof Player player) {
if (args.length > 0) { if (args.length > 0) {
Kits kitManager = new Kits(plugin);
Inventory gui = Bukkit.createInventory(null, 27, "Kit Editor"); Inventory gui = Bukkit.createInventory(null, 27, "Kit Editor");
ItemStack saveKit = new ItemStack(Material.GREEN_STAINED_GLASS_PANE); ItemStack saveKit = new ItemStack(Material.GREEN_STAINED_GLASS_PANE);
@@ -81,14 +107,64 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
Inventory inv = player.getInventory(); Inventory inv = player.getInventory();
switch (args[0]) { switch (args[0]) {
case "sword": case "sword":
ItemStack swordsword = new ItemStack(Material.DIAMOND_SWORD); inv.clear();
swordsword.addEnchantment(Enchantment.UNBREAKING, 3); inv.setContents(kitManager.getSwordKit(player).getContents());
infoMeta.setDisplayName("§fSword 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 "uhc":
inv.clear(); inv.clear();
inv.setContents(kitManager.getUhcKit(player).getContents());
inv.setItem(getItemSlot("sword", "sword", player), swordsword); 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);
infoMeta.setDisplayName("§fSword Kit"); player.openInventory(gui);
break;
case "cart":
inv.clear();
inv.setContents(kitManager.getCartKit(player).getContents());
infoMeta.setDisplayName("§fCart 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); infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem); gui.setItem(3, infoItem);
gui.setItem(4, infoItem); gui.setItem(4, infoItem);
@@ -102,85 +178,29 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
player.openInventory(gui); player.openInventory(gui);
break; break;
case "uhc": case "axe":
ItemStack uhchelmet = new ItemStack(Material.DIAMOND_HELMET);
ItemStack uhcchestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemStack uhcleggings = new ItemStack(Material.DIAMOND_LEGGINGS);
ItemStack uhcboots = new ItemStack(Material.DIAMOND_BOOTS);
ItemStack uhcaxe = new ItemStack(Material.DIAMOND_AXE);
ItemStack uhcsword = new ItemStack(Material.DIAMOND_SWORD);
ItemStack uhclava = new ItemStack(Material.LAVA_BUCKET);
ItemStack uhclava2 = new ItemStack(Material.LAVA_BUCKET);
ItemStack uhccobweb = new ItemStack(Material.COBWEB, 8);
ItemStack uhccobblestone = new ItemStack(Material.COBBLESTONE, 64);
ItemStack uhcgoldenapple = new ItemStack(Material.GOLDEN_APPLE, 13);
ItemStack uhcwater = new ItemStack(Material.WATER_BUCKET);
ItemStack uhcwater2 = new ItemStack(Material.WATER_BUCKET);
ItemStack uhcwater3 = new ItemStack(Material.WATER_BUCKET);
ItemStack uhcwater4 = new ItemStack(Material.WATER_BUCKET);
ItemStack uhccrossbow = new ItemStack(Material.CROSSBOW);
ItemStack uhcbow = new ItemStack(Material.BOW);
ItemStack uhcarrow = new ItemStack(Material.ARROW, 16);
ItemStack uhcshield = new ItemStack(Material.SHIELD);
ItemStack uhcshield2 = new ItemStack(Material.SHIELD);
ItemStack uhcplanks = new ItemStack(Material.OAK_PLANKS, 64);
ItemStack uhcpickaxe = new ItemStack(Material.DIAMOND_PICKAXE);
inv.clear(); inv.clear();
inv.setContents(kitManager.getAxeKit(player).getContents());
uhchelmet.addEnchantment(Enchantment.PROTECTION, 2); infoMeta.setDisplayName("§fAxe Kit");
uhcchestplate.addEnchantment(Enchantment.PROTECTION, 3); infoItem.setItemMeta(infoMeta);
uhcleggings.addEnchantment(Enchantment.PROTECTION, 3); gui.setItem(3, infoItem);
uhcboots.addEnchantment(Enchantment.PROTECTION, 3); gui.setItem(4, infoItem);
uhcaxe.addEnchantment(Enchantment.SHARPNESS, 1); gui.setItem(5, infoItem);
uhcaxe.addEnchantment(Enchantment.EFFICIENCY, 3); gui.setItem(12, infoItem);
uhcsword.addEnchantment(Enchantment.SHARPNESS, 4); gui.setItem(13, infoItem);
uhccrossbow.addEnchantment(Enchantment.PIERCING, 1); gui.setItem(14, infoItem);
uhcbow.addEnchantment(Enchantment.POWER, 1); gui.setItem(21, infoItem);
uhcpickaxe.addEnchantment(Enchantment.UNBREAKING,3); gui.setItem(22, infoItem);
uhcpickaxe.addEnchantment(Enchantment.EFFICIENCY, 3); gui.setItem(23, infoItem);
ItemMeta uhcmetalava2 = uhclava2.getItemMeta(); player.openInventory(gui);
ItemMeta uhcmetawater2 = uhcwater2.getItemMeta(); break;
ItemMeta uhcmetawater3 = uhcwater3.getItemMeta(); case "diasmp":
ItemMeta uhcmetawater4 = uhcwater4.getItemMeta(); inv.clear();
ItemMeta uhcmetashield2 = uhcshield2.getItemMeta(); inv.setContents(kitManager.getAxeKit(player).getContents());
uhcmetalava2.getPersistentDataContainer().set(new NamespacedKey("wolfffa", "lavab"), PersistentDataType.STRING, "lava2uuid"); infoMeta.setDisplayName("§fDiamondSmp Kit");
uhclava2.setItemMeta(uhcmetalava2);
uhcmetawater2.getPersistentDataContainer().set(new NamespacedKey("wolfffa", "waterb"), PersistentDataType.STRING, "water2uuid");
uhcwater2.setItemMeta(uhcmetawater2);
uhcmetawater3.getPersistentDataContainer().set(new NamespacedKey("wolfffa", "waterc"), PersistentDataType.STRING, "water3uuid");
uhcwater3.setItemMeta(uhcmetawater3);
uhcmetawater4.getPersistentDataContainer().set(new NamespacedKey("wolfffa", "waterd"), PersistentDataType.STRING, "water4uuid");
uhcwater4.setItemMeta(uhcmetawater4);
uhcmetashield2.getPersistentDataContainer().set(new NamespacedKey("wolfffa", "shieldb"), PersistentDataType.STRING, "shield2uuid");
uhcshield2.setItemMeta(uhcmetashield2);
inv.setItem(getItemSlot("axe", "uhc", player), uhcaxe);
inv.setItem(getItemSlot("sword", "uhc", player), uhcsword);
inv.setItem(getItemSlot("lava", "uhc", player), uhclava);
inv.setItem(getItemSlot("cobweb", "uhc", player), uhccobweb);
inv.setItem(getItemSlot("cobblestone", "uhc", player), uhccobblestone);
inv.setItem(getItemSlot("goldenapple", "uhc", player), uhcgoldenapple);
inv.setItem(getItemSlot("water", "uhc", player), uhcwater);
inv.setItem(getItemSlot("crossbow", "uhc", player), uhccrossbow);
inv.setItem(getItemSlot("bow", "uhc", player), uhcbow);
inv.setItem(getItemSlot("shield", "uhc", player), uhcshield);
inv.setItem(getItemSlot("arrow", "uhc", player), uhcarrow);
inv.setItem(getItemSlot("shield2", "uhc", player), uhcshield2);
inv.setItem(getItemSlot("planks", "uhc", player), uhcplanks);
inv.setItem(getItemSlot("pickaxe", "uhc", player), uhcpickaxe);
inv.setItem(getItemSlot("lava2", "uhc", player), uhclava2);
inv.setItem(getItemSlot("water2", "uhc", player), uhcwater2);
inv.setItem(getItemSlot("water3", "uhc", player), uhcwater3);
inv.setItem(getItemSlot("water4", "uhc", player), uhcwater4);
infoMeta.setDisplayName("§fUHC Kit");
infoItem.setItemMeta(infoMeta); infoItem.setItemMeta(infoMeta);
gui.setItem(3, infoItem); gui.setItem(3, infoItem);
gui.setItem(4, infoItem); gui.setItem(4, infoItem);
@@ -207,7 +227,7 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
@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 cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (args.length == 1) { if (args.length == 1) {
return List.of("sword", "uhc"); return List.of("sword", "uhc", "cart", "mace", "axe", "diasmp");
} }
return List.of(); return List.of();
} }

View File

@@ -0,0 +1,53 @@
package hu.jgj52.wolfFFA.Commands;
import hu.jgj52.wolfFFA.Main;
import org.bukkit.Bukkit;
import org.bukkit.Location;
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.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class LeaveCommand implements CommandExecutor, TabCompleter {
private final Main plugin;
public LeaveCommand(Main plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (cmds.hasPermission("wolfffa.command.leave")) {
if (cmds instanceof Player player) {
Player dameger = plugin.getPlayers().get(player);
if (dameger != null) {
player.setKiller(plugin.getPlayers().get(player));
plugin.getPlayers().remove(player);
player.setHealth(0);
} else {
player.teleport(new Location(Bukkit.getWorld("world"), 0.5, 1, 0.5));
player.getInventory().clear();
player.setHealth(20D);
player.setFoodLevel(20);
player.setSaturation(5);
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
player.removePotionEffect(potionEffect.getType());
}
}
}
}
return true;
}
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
return List.of();
}
}

View File

@@ -1,5 +1,6 @@
package hu.jgj52.wolfFFA.Commands; package hu.jgj52.wolfFFA.Commands;
import hu.jgj52.wolfFFA.Utils.Kits;
import hu.jgj52.wolfFFA.Main; import hu.jgj52.wolfFFA.Main;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@@ -12,10 +13,11 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.Collections;
import java.util.List; import java.util.List;
public class TpToFfaCommand implements CommandExecutor, TabCompleter { public class TpToFfaCommand implements CommandExecutor, TabCompleter {
@@ -40,30 +42,35 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
return -1; 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 cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (cmds.hasPermission("wolfffa.admin.tptoffa")) { if (cmds.hasPermission("wolfffa.admin.tptoffa")) {
if (args.length > 0) { if (args.length > 0) {
Kits kitManager = new Kits(plugin);
switch (args[0]) { switch (args[0]) {
case "sword": case "sword":
if (args.length > 1) { if (args.length > 1) {
Player target = Bukkit.getPlayer(args[1]); Player target = Bukkit.getPlayer(args[1]);
if (target instanceof Player player) { if (target instanceof Player player) {
player.getInventory().clear(); player.getInventory().clear();
ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET); player.getInventory().setContents(kitManager.getSwordKit(player).getContents());
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(getItemSlot("sword", "sword", player), sword);
World world = Bukkit.getWorld("world"); World world = Bukkit.getWorld("world");
double x = 0.5; double x = 0.5;
@@ -73,6 +80,12 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
float pitch = (float) 0; float pitch = (float) 0;
Location loc = new Location(world, x, y, z, yaw, pitch); Location loc = new Location(world, x, y, z, yaw, pitch);
player.teleport(loc); player.teleport(loc);
player.setHealth(20D);
player.setFoodLevel(20);
player.setSaturation(5);
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
player.removePotionEffect(potionEffect.getType());
}
} }
} }
break; break;
@@ -81,55 +94,7 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
Player target = Bukkit.getPlayer(args[1]); Player target = Bukkit.getPlayer(args[1]);
if (target instanceof Player player) { if (target instanceof Player player) {
player.getInventory().clear(); player.getInventory().clear();
ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET); player.getInventory().setContents(kitManager.getUhcKit(player).getContents());
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, 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);
pickaxe.addEnchantment(Enchantment.UNBREAKING,3);
pickaxe.addEnchantment(Enchantment.EFFICIENCY, 3);
player.getInventory().setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
player.getInventory().setItem(getItemSlot("axe", "uhc", player), axe);
player.getInventory().setItem(getItemSlot("sword", "uhc", player), sword);
player.getInventory().setItem(getItemSlot("lava", "uhc", player), lava);
player.getInventory().setItem(getItemSlot("cobweb", "uhc", player), cobweb);
player.getInventory().setItem(getItemSlot("cobblestone", "uhc", player), cobblestone);
player.getInventory().setItem(getItemSlot("goldenapple", "uhc", player), goldenapple);
player.getInventory().setItem(getItemSlot("water", "uhc", player), water);
player.getInventory().setItem(getItemSlot("crossbow", "uhc", player), crossbow);
player.getInventory().setItem(getItemSlot("bow", "uhc", player), bow);
player.getInventory().setItem(getItemSlot("arrow", "uhc", player), arrow);
player.getInventory().setItem(getItemSlot("shield2", "uhc", player), shield);
player.getInventory().setItem(getItemSlot("planks", "uhc", player), planks);
player.getInventory().setItem(getItemSlot("pickaxe", "uhc", player), pickaxe);
player.getInventory().setItem(getItemSlot("lava2", "uhc", player), lava);
player.getInventory().setItem(getItemSlot("water2", "uhc", player), water);
player.getInventory().setItem(getItemSlot("water3", "uhc", player), water);
player.getInventory().setItem(getItemSlot("water4", "uhc", player), water);
player.getInventory().setItem(getItemSlot("shield", "uhc", player), shield);
World world = Bukkit.getWorld("world"); World world = Bukkit.getWorld("world");
double x = 0.5; double x = 0.5;
@@ -139,6 +104,108 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
float pitch = (float) 0; float pitch = (float) 0;
Location loc = new Location(world, x, y, z, yaw, pitch); Location loc = new Location(world, x, y, z, yaw, pitch);
player.teleport(loc); player.teleport(loc);
player.setHealth(20D);
player.setFoodLevel(20);
player.setSaturation(5);
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
player.removePotionEffect(potionEffect.getType());
}
}
}
break;
case "cart":
if (args.length > 1) {
Player target = Bukkit.getPlayer(args[1]);
if (target instanceof Player player) {
player.getInventory().clear();
player.getInventory().setContents(kitManager.getCartKit(player).getContents());
World world = Bukkit.getWorld("world");
double x = -1000.5;
double y = 0.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);
player.setHealth(20D);
player.setFoodLevel(20);
player.setSaturation(5);
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
player.removePotionEffect(potionEffect.getType());
}
}
}
break;
case "mace":
if (args.length > 1) {
Player target = Bukkit.getPlayer(args[1]);
if (target instanceof Player player) {
player.getInventory().clear();
player.getInventory().setContents(kitManager.getMaceKit(player).getContents());
World world = Bukkit.getWorld("world");
double x = 1000.5;
double y = 3.0;
double z = -999.5;
float yaw = (float) 0;
float pitch = (float) 0;
Location loc = new Location(world, x, y, z, yaw, pitch);
player.teleport(loc);
player.setHealth(20D);
player.setFoodLevel(20);
player.setSaturation(5);
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
player.removePotionEffect(potionEffect.getType());
}
}
}
break;
case "axe":
if (args.length > 1) {
Player target = Bukkit.getPlayer(args[1]);
if (target instanceof Player player) {
player.getInventory().clear();
player.getInventory().setContents(kitManager.getAxeKit(player).getContents());
World world = Bukkit.getWorld("world");
double x = -1000.5;
double y = 0.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);
player.setHealth(20D);
player.setFoodLevel(20);
player.setSaturation(5);
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
player.removePotionEffect(potionEffect.getType());
}
}
}
break;
case "diasmp":
if (args.length > 1) {
Player target = Bukkit.getPlayer(args[1]);
if (target instanceof Player player) {
player.getInventory().clear();
player.getInventory().setContents(kitManager.getDiamondSmpKit(player).getContents());
World world = Bukkit.getWorld("world");
double x = -1000.5;
double y = 0.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);
player.setHealth(20D);
player.setFoodLevel(20);
player.setSaturation(5);
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
player.removePotionEffect(potionEffect.getType());
}
} }
} }
break; break;
@@ -152,10 +219,10 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
@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 cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (args.length == 1) { if (args.length == 1) {
return List.of("sword", "uhc"); return List.of("sword", "uhc", "cart", "mace", "axe", "diamp");
} else if (args.length == 2) { } else if (args.length == 2) {
return null; return null;
} }
return List.of(); return List.of();
} }

View File

@@ -3,7 +3,7 @@ package hu.jgj52.wolfFFA.Listeners;
import hu.jgj52.wolfFFA.Main; import hu.jgj52.wolfFFA.Main;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@@ -12,10 +12,10 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
import org.checkerframework.checker.units.qual.N;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
public class KitListener implements Listener { public class KitListener implements Listener {
@@ -28,32 +28,126 @@ public class KitListener implements Listener {
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent event) { public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!player.hasPlayedBefore()) { if (plugin.getConfig().getString("kits.sword." + player.getUniqueId()) == null) {
Map <String, Object> swordkit = new HashMap<>(); Map<String, Object> kit = new HashMap<>();
swordkit.put("sword", 0); kit.put("sword", 0);
plugin.getConfig().set("kits.sword." + player.getUniqueId(), swordkit); plugin.getConfig().set("kits.sword." + player.getUniqueId(), kit);
plugin.saveConfig(); plugin.saveConfig();
plugin.reloadConfig(); plugin.reloadConfig();
Map <String, Object> uhcKit = new HashMap<>(); }
uhcKit.put("axe", 0); if (plugin.getConfig().getString("kits.uhc." + player.getUniqueId()) == null) {
uhcKit.put("sword", 1); Map<String, Object> kit = new HashMap<>();
uhcKit.put("lava", 2); int[] shield = new int[]{13, 40};
uhcKit.put("cobweb", 3); int[] water = new int[]{6, 22, 23, 24};
uhcKit.put("cobblestone", 4); int[] lava = new int[]{2, 21};
uhcKit.put("goldenapple", 5); kit.put("axe", 0);
uhcKit.put("water", 6); kit.put("sword", 1);
uhcKit.put("crossbow", 7); kit.put("lava", lava);
uhcKit.put("bow", 8); kit.put("cobweb", 3);
uhcKit.put("arrow", 9); kit.put("cobblestone", 4);
uhcKit.put("shield2", 13); kit.put("goldenapple", 5);
uhcKit.put("planks", 17); kit.put("water", water);
uhcKit.put("pickaxe", 20); kit.put("crossbow", 7);
uhcKit.put("lava2", 21); kit.put("bow", 8);
uhcKit.put("water2", 22); kit.put("arrow", 9);
uhcKit.put("water3", 23); kit.put("planks", 17);
uhcKit.put("water4", 24); kit.put("pickaxe", 20);
uhcKit.put("shield", 40); kit.put("shield", shield);
plugin.getConfig().set("kits.uhc." + player.getUniqueId(), uhcKit); plugin.getConfig().set("kits.uhc." + player.getUniqueId(), kit);
plugin.saveConfig();
plugin.reloadConfig();
}
if (plugin.getConfig().getString("kits.cart." + player.getUniqueId()) == null) {
Map<String, Object> kit = new HashMap<>();
int[] strength = new int[]{16, 25, 34};
int[] speed = new int[]{17, 26, 35};
int[] fireresistance = new int[]{24, 33};
int[] cart = new int[]{4, 12, 21, 30, 13, 22, 31, 14, 23, 32, 15};
int[] enderpearl = new int[]{2, 11, 20, 29};
kit.put("axe", 0);
kit.put("sword", 1);
kit.put("enderpearl", enderpearl);
kit.put("rail", 3);
kit.put("cart", cart);
kit.put("goldenapple", 5);
kit.put("cobweb", 6);
kit.put("shield", 7);
kit.put("bow", 8);
kit.put("arrow", 9);
kit.put("strength", strength);
kit.put("speed", speed);
kit.put("fireresistance", fireresistance);
kit.put("cherrylog", 10);
kit.put("pickaxe", 18);
kit.put("crossbow", 19);
kit.put("shulker", 27);
kit.put("flintandsteel", 28);
kit.put("totem", 40);
plugin.getConfig().set("kits.cart." + 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("jumpboost", 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.saveConfig();
plugin.reloadConfig(); plugin.reloadConfig();
} }
@@ -68,6 +162,26 @@ 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;
List<Integer> uhcwaterSlots = null;
List<Integer> uhcshieldSlots = null;
List<Integer> boxcartstrenghtSlots = null;
List<Integer> boxcartspeedSlots = null;
List<Integer> boxcartfireresistanceSlots = null;
List<Integer> boxcartcartSlots = null;
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")) { if (gui.getItem(13).getItemMeta().getDisplayName().equals("§fSword Kit")) {
for (int i = 0; i < inv.length; i++) { for (int i = 0; i < inv.length; i++) {
ItemStack item = inv[i]; ItemStack item = inv[i];
@@ -79,6 +193,10 @@ public class KitListener implements Listener {
} }
} }
} else if (gui.getItem(13).getItemMeta().getDisplayName().equals("§fUHC Kit")) { } else if (gui.getItem(13).getItemMeta().getDisplayName().equals("§fUHC Kit")) {
uhclavaSlots = new ArrayList<>();
uhcwaterSlots = new ArrayList<>();
uhcshieldSlots = new ArrayList<>();
for (int i = 0; i < inv.length; i++) { for (int i = 0; i < inv.length; i++) {
ItemStack item = inv[i]; ItemStack item = inv[i];
@@ -88,11 +206,7 @@ public class KitListener implements Listener {
} else if (item.getType() == Material.DIAMOND_SWORD) { } else if (item.getType() == Material.DIAMOND_SWORD) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".sword", i); plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".sword", i);
} else if (item.getType() == Material.LAVA_BUCKET) { } else if (item.getType() == Material.LAVA_BUCKET) {
if (item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey("wolfffa", "lavab"), PersistentDataType.STRING)) { uhclavaSlots.add(i);
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".lava2", i);
} else {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".lava", i);
}
} else if (item.getType() == Material.COBWEB) { } else if (item.getType() == Material.COBWEB) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".cobweb", i); plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".cobweb", i);
} else if (item.getType() == Material.COBBLESTONE) { } else if (item.getType() == Material.COBBLESTONE) {
@@ -100,15 +214,7 @@ public class KitListener implements Listener {
} else if (item.getType() == Material.GOLDEN_APPLE) { } else if (item.getType() == Material.GOLDEN_APPLE) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".goldenapple", i); plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".goldenapple", i);
} else if (item.getType() == Material.WATER_BUCKET) { } else if (item.getType() == Material.WATER_BUCKET) {
if (item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey("wolfffa", "waterb"), PersistentDataType.STRING)) { uhcwaterSlots.add(i);
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".water2", i);
} else if (item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey("wolfffa", "waterc"), PersistentDataType.STRING)) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".water3", i);
} else if (item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey("wolfffa", "waterd"), PersistentDataType.STRING)) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".water4", i);
} else {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".water", i);
}
} else if (item.getType() == Material.CROSSBOW) { } else if (item.getType() == Material.CROSSBOW) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".crossbow", i); plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".crossbow", i);
} else if (item.getType() == Material.BOW) { } else if (item.getType() == Material.BOW) {
@@ -120,11 +226,183 @@ public class KitListener implements Listener {
} else if (item.getType() == Material.DIAMOND_PICKAXE) { } else if (item.getType() == Material.DIAMOND_PICKAXE) {
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".pickaxe", i); plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".pickaxe", i);
} else if (item.getType() == Material.SHIELD) { } else if (item.getType() == Material.SHIELD) {
if (item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey("wolfffa", "shieldb"), PersistentDataType.STRING)) { uhcshieldSlots.add(i);
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".shield2", i); }
} else { }
plugin.getConfig().set("kits.uhc." + player.getUniqueId() + ".shield", 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("§fBoxCart Kit")) {
boxcartstrenghtSlots = new ArrayList<>();
boxcartspeedSlots = new ArrayList<>();
boxcartfireresistanceSlots = new ArrayList<>();
boxcartcartSlots = new ArrayList<>();
boxcartenderpearlSlots = 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.cart." + player.getUniqueId() + ".axe", i);
} else if (item.getType() == Material.NETHERITE_SWORD) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".sword", i);
} else if (item.getType() == Material.ENDER_PEARL) {
boxcartenderpearlSlots.add(i);
} else if (item.getType() == Material.RAIL) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".rail", i);
} else if (item.getType() == Material.TNT_MINECART) {
boxcartcartSlots.add(i);
} else if (item.getType() == Material.GOLDEN_APPLE) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".goldenapple", i);
} else if (item.getType() == Material.COBWEB) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".cobweb", i);
} else if (item.getType() == Material.SHIELD) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".shield", i);
} else if (item.getType() == Material.BOW) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".bow", i);
} else if (item.getType() == Material.ARROW) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".arrow", i);
} else if (item.getType() == Material.CHERRY_LOG) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".cherrylog", i);
} else if (item.getType() == Material.CROSSBOW) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".crossbow", i);
} else if (item.getType() == Material.FLINT_AND_STEEL) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".flintandsteel", i);
} else if (item.getType() == Material.SPLASH_POTION) {
if (item.getItemMeta().getDisplayName().equals("§fSplash Potion of Strength")) {
boxcartstrenghtSlots.add(i);
} else if (item.getItemMeta().getDisplayName().equals("§fSplash Potion of Swiftness")) {
boxcartspeedSlots.add(i);
} else if (item.getItemMeta().getDisplayName().equals("§fSplash Potion of Fire Resistance")) {
boxcartfireresistanceSlots.add(i);
} }
} else if (item.getType() == Material.RED_SHULKER_BOX) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".shulker", i);
} else if (item.getType() == Material.NETHERITE_PICKAXE) {
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".pickaxe", i);
}
}
}
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".enderpearl", boxcartenderpearlSlots);
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".cart", boxcartcartSlots);
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".strength", boxcartstrenghtSlots);
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".speed", boxcartspeedSlots);
plugin.getConfig().set("kits.cart." + player.getUniqueId() + ".fireresistance", boxcartfireresistanceSlots);
} 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("§fSplash Potion of Strength")) {
macestrengthSlots.add(i);
} else if (item.getItemMeta().getDisplayName().equals("§fSplash 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("§fSplash Potion of Strength")) {
diasmpstrengthSlots.add(i);
} else if (item.getItemMeta().getDisplayName().equals("§fSplash Potion of Swiftness")) {
diasmpspeedSlots.add(i);
} else if (item.getItemMeta().getDisplayName().equals("§fSplash 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);
} }
} }
} }
@@ -133,6 +411,7 @@ public class KitListener implements Listener {
plugin.reloadConfig(); plugin.reloadConfig();
player.sendMessage("§aSikeresen elmentetted a kitedet!"); player.sendMessage("§aSikeresen elmentetted a kitedet!");
player.closeInventory(); player.closeInventory();
} 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

@@ -0,0 +1,29 @@
package hu.jgj52.wolfFFA.Listeners;
import hu.jgj52.wolfFFA.Main;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
public class LeaveCommandListener implements Listener {
private final Main plugin;
public LeaveCommandListener(Main plugin) {
this.plugin = plugin;
}
@EventHandler
public void onDamage(EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof Player player && e.getDamager() instanceof Player damager) {
plugin.getPlayers().put(player, damager);
}
}
@EventHandler
public void onDeath(PlayerDeathEvent e) {
if (e.getPlayer().getKiller() != null) {
plugin.getPlayers().remove(e.getPlayer());
}
}
}

View File

@@ -0,0 +1,38 @@
package hu.jgj52.wolfFFA.Listeners;
import hu.jgj52.wolfFFA.Main;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class RandomListener implements Listener {
private final Main plugin;
public RandomListener(Main plugin) {
this.plugin = plugin;
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if (!event.getPlayer().hasPermission("wolfffa.admin.bypass.netheriteblockbreak")) {
if (event.getBlock().getType() == Material.NETHERITE_BLOCK) {
event.setCancelled(true);
}
}
}
@EventHandler
public void onDeath(PlayerDeathEvent event) {
if (event.getPlayer() == event.getPlayer().getKiller()) {
new BukkitRunnable() {
@Override
public void run() {
event.getPlayer().chat("/leave");
}
}.runTaskLater(plugin, 10L);
}
}
}

View File

@@ -1,26 +1,51 @@
package hu.jgj52.wolfFFA; package hu.jgj52.wolfFFA;
import hu.jgj52.wolfFFA.Commands.EditKitCommand; import hu.jgj52.wolfFFA.Commands.EditKitCommand;
import hu.jgj52.wolfFFA.Commands.LeaveCommand;
import hu.jgj52.wolfFFA.Commands.TpToFfaCommand; import hu.jgj52.wolfFFA.Commands.TpToFfaCommand;
import hu.jgj52.wolfFFA.Listeners.RandomListener;
import hu.jgj52.wolfFFA.Listeners.KitListener; import hu.jgj52.wolfFFA.Listeners.KitListener;
import hu.jgj52.wolfFFA.Listeners.LeaveCommandListener;
import hu.jgj52.wolfFFA.Utils.MapReset;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.Map;
public final class Main extends JavaPlugin { public final class Main extends JavaPlugin {
private MapReset mapReset;
private final Map<Player, Player> players = new HashMap<>();
@Override @Override
public void onEnable() { public void onEnable() {
// Plugin startup logic // Plugin startup logic
getConfig().options().copyDefaults(true); getConfig().options().copyDefaults(true);
saveConfig();
getCommand("tptoffa").setExecutor(new TpToFfaCommand(this)); getCommand("tptoffa").setExecutor(new TpToFfaCommand(this));
getCommand("editkit").setExecutor(new EditKitCommand(this)); getCommand("editkit").setExecutor(new EditKitCommand(this));
getCommand("leave").setExecutor(new LeaveCommand(this));
getServer().getPluginManager().registerEvents(new KitListener(this), this); getServer().getPluginManager().registerEvents(new KitListener(this), this);
getServer().getPluginManager().registerEvents(new RandomListener(this), this);
getServer().getPluginManager().registerEvents(new LeaveCommandListener(this), this);
this.mapReset = new MapReset(this);
} }
@Override @Override
public void onDisable() { public void onDisable() {
// Plugin shutdown logic // Plugin shutdown logic
players.clear();
}
public static Main getInstance() {
return getPlugin(Main.class);
}
public Map<Player, Player> getPlayers() {
return this.players;
} }
} }

View File

@@ -0,0 +1,500 @@
package hu.jgj52.wolfFFA.Utils;
import hu.jgj52.wolfFFA.Main;
import org.bukkit.Material;
import org.bukkit.block.ShulkerBox;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
public class Kits {
private final Main plugin;
public Kits(Main 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);
}
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 getCartKit(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 rail = new ItemStack(Material.RAIL, 64);
ItemStack cart = new ItemStack(Material.TNT_MINECART);
ItemStack goldenapple = new ItemStack(Material.GOLDEN_APPLE, 64);
ItemStack cobweb = new ItemStack(Material.COBWEB, 64);
ItemStack shield = new ItemStack(Material.SHIELD);
ItemStack bow = new ItemStack(Material.BOW);
ItemStack arrow = new ItemStack(Material.ARROW, 64);
ItemStack fireresistance = new ItemStack(Material.SPLASH_POTION);
ItemStack strength = new ItemStack(Material.SPLASH_POTION);
ItemStack speed = new ItemStack(Material.SPLASH_POTION);
ItemStack cherrylog = new ItemStack(Material.CHERRY_LOG, 64);
ItemStack crossbow = new ItemStack(Material.CROSSBOW);
ItemStack flintandsteel = new ItemStack(Material.FLINT_AND_STEEL);
ItemStack totem = new ItemStack(Material.TOTEM_OF_UNDYING);
ItemStack pickaxe = new ItemStack(Material.NETHERITE_PICKAXE);
ItemStack shulker = new ItemStack(Material.RED_SHULKER_BOX);
helmet.addEnchantment(Enchantment.PROTECTION, 4);
helmet.addEnchantment(Enchantment.RESPIRATION, 3);
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.BLAST_PROTECTION, 4);
leggings.addEnchantment(Enchantment.UNBREAKING, 3);
leggings.addEnchantment(Enchantment.MENDING, 1);
boots.addEnchantment(Enchantment.FEATHER_FALLING, 4);
boots.addEnchantment(Enchantment.PROTECTION, 4);
boots.addEnchantment(Enchantment.UNBREAKING,3);
boots.addEnchantment(Enchantment.MENDING, 1);
sword.addEnchantment(Enchantment.SHARPNESS, 5);
sword.addEnchantment(Enchantment.SWEEPING_EDGE, 3);
sword.addEnchantment(Enchantment.FIRE_ASPECT, 2);
sword.addEnchantment(Enchantment.KNOCKBACK, 1);
sword.addEnchantment(Enchantment.UNBREAKING, 3);
sword.addEnchantment(Enchantment.MENDING, 1);
axe.addEnchantment(Enchantment.SHARPNESS, 5);
axe.addEnchantment(Enchantment.EFFICIENCY, 5);
axe.addEnchantment(Enchantment.UNBREAKING, 3);
axe.addEnchantment(Enchantment.MENDING, 1);
bow.addEnchantment(Enchantment.POWER, 5);
bow.addEnchantment(Enchantment.PUNCH, 2);
bow.addEnchantment(Enchantment.FLAME, 1);
bow.addEnchantment(Enchantment.UNBREAKING,3);
bow.addEnchantment(Enchantment.MENDING, 1);
crossbow.addEnchantment(Enchantment.PIERCING, 4);
crossbow.addEnchantment(Enchantment.QUICK_CHARGE, 3);
crossbow.addEnchantment(Enchantment.UNBREAKING, 3);
crossbow.addEnchantment(Enchantment.MENDING, 1);
flintandsteel.addEnchantment(Enchantment.UNBREAKING, 3);
flintandsteel.addEnchantment(Enchantment.MENDING, 1);
shield.addEnchantment(Enchantment.UNBREAKING, 3);
shield.addEnchantment(Enchantment.MENDING, 1);
pickaxe.addEnchantment(Enchantment.UNBREAKING, 3);
pickaxe.addEnchantment(Enchantment.MENDING, 1);
pickaxe.addEnchantment(Enchantment.EFFICIENCY, 5);
PotionMeta fireresistancemeta = (PotionMeta) fireresistance.getItemMeta();
fireresistancemeta.addCustomEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 9600, 0), true);
fireresistancemeta.setDisplayName("§fSplash Potion of Fire Resistance");
fireresistance.setItemMeta(fireresistancemeta);
PotionMeta strengthmeta = (PotionMeta) strength.getItemMeta();
strengthmeta.addCustomEffect(new PotionEffect(PotionEffectType.STRENGTH, 1800, 1), true);
strengthmeta.setDisplayName("§fSplash Potion of Strength");
strength.setItemMeta(strengthmeta);
PotionMeta speedmeta = (PotionMeta) speed.getItemMeta();
speedmeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 1800, 1), true);
speedmeta.setDisplayName("§fSplash Potion of Swiftness");
speed.setItemMeta(speedmeta);
BlockStateMeta shulkermeta = (BlockStateMeta) shulker.getItemMeta();
ShulkerBox shulkerbox = (ShulkerBox) shulkermeta.getBlockState();
Inventory shulkerinv = shulkerbox.getInventory();
for (int i = 0; i < 27; i++) {
shulkerinv.setItem(i, new ItemStack(Material.TNT_MINECART));
}
shulkermeta.setBlockState(shulkerbox);
shulker.setItemMeta(shulkermeta);
inv.setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
inv.setItem(getItemSlot("axe", "cart", player), axe);
inv.setItem(getItemSlot("sword", "cart", player), sword);
for (int slot : getItemSlotArray("enderpearl", "cart", player)) {
inv.setItem(slot, enderpearl);
}
inv.setItem(getItemSlot("rail", "cart", player), rail);
for (int slot : getItemSlotArray("cart", "cart", player)) {
inv.setItem(slot, cart);
}
inv.setItem(getItemSlot("goldenapple", "cart", player), goldenapple);
inv.setItem(getItemSlot("cobweb", "cart", player), cobweb);
inv.setItem(getItemSlot("shield", "cart", player), shield);
inv.setItem(getItemSlot("bow", "cart", player), bow);
inv.setItem(getItemSlot("arrow", "cart", player), arrow);
for (int slot : getItemSlotArray("fireresistance", "cart", player)) {
inv.setItem(slot, fireresistance);
}
for (int slot : getItemSlotArray("strength", "cart", player)) {
inv.setItem(slot, strength);
}
for (int slot : getItemSlotArray("speed", "cart", player)) {
inv.setItem(slot, speed);
}
inv.setItem(getItemSlot("cherrylog", "cart", player), cherrylog);
inv.setItem(getItemSlot("crossbow", "cart", player), crossbow);
inv.setItem(getItemSlot("flintandsteel", "cart", player), flintandsteel);
inv.setItem(getItemSlot("totem", "cart", player), totem);
inv.setItem(getItemSlot("pickaxe", "cart", player), pickaxe);
inv.setItem(getItemSlot("shulker", "cart", player), shulker);
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 jumpboost = new ItemStack(Material.POTION);
ItemStack strength = new ItemStack(Material.SPLASH_POTION);
ItemStack speed = new ItemStack(Material.SPLASH_POTION);
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.UNBREAKING, 3);
leggings.addEnchantment(Enchantment.MENDING, 1);
boots.addEnchantment(Enchantment.FEATHER_FALLING, 4);
boots.addEnchantment(Enchantment.PROTECTION, 4);
boots.addEnchantment(Enchantment.UNBREAKING,3);
boots.addEnchantment(Enchantment.MENDING, 1);
sword.addEnchantment(Enchantment.SHARPNESS, 5);
sword.addEnchantment(Enchantment.UNBREAKING, 3);
sword.addEnchantment(Enchantment.MENDING, 1);
axe.addEnchantment(Enchantment.SHARPNESS, 5);
axe.addEnchantment(Enchantment.UNBREAKING, 3);
axe.addEnchantment(Enchantment.MENDING, 1);
shield.addEnchantment(Enchantment.UNBREAKING, 3);
shield.addEnchantment(Enchantment.MENDING, 1);
density.addEnchantment(Enchantment.WIND_BURST, 1);
density.addEnchantment(Enchantment.DENSITY, 5);
density.addEnchantment(Enchantment.UNBREAKING, 3);
density.addEnchantment(Enchantment.MENDING, 1);
breach.addEnchantment(Enchantment.BREACH, 4);
breach.addEnchantment(Enchantment.UNBREAKING, 3);
breach.addEnchantment(Enchantment.MENDING, 1);
PotionMeta jumpboostmeta = (PotionMeta) speed.getItemMeta();
jumpboostmeta.addCustomEffect(new PotionEffect(PotionEffectType.JUMP_BOOST, 1800, 1), true);
jumpboostmeta.setDisplayName("§fPotion of Leaping");
jumpboost.setItemMeta(jumpboostmeta);
PotionMeta strengthmeta = (PotionMeta) strength.getItemMeta();
strengthmeta.addCustomEffect(new PotionEffect(PotionEffectType.STRENGTH, 1800, 1), true);
strengthmeta.setDisplayName("§fSplash Potion of Strength");
strength.setItemMeta(strengthmeta);
PotionMeta speedmeta = (PotionMeta) speed.getItemMeta();
speedmeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 1800, 1), true);
speedmeta.setDisplayName("§fSplash Potion of Swiftness");
speed.setItemMeta(speedmeta);
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("jumpboost", "mace", player), jumpboost);
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 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.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 getDiamondSmpKit(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.setDisplayName("§fSplash Potion of Fire Resistance");
fireresistance.setItemMeta(fireresistancemeta);
PotionMeta strengthmeta = (PotionMeta) strength.getItemMeta();
strengthmeta.addCustomEffect(new PotionEffect(PotionEffectType.STRENGTH, 1800, 1), true);
strengthmeta.setDisplayName("§fSplash Potion of Strength");
strength.setItemMeta(strengthmeta);
PotionMeta speedmeta = (PotionMeta) speed.getItemMeta();
speedmeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 9600, 0), true);
speedmeta.setDisplayName("§fSplash Potion of Swiftness");
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;
}
public PlayerInventory getCrystalKit(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 anchor = new ItemStack(Material.RESPAWN_ANCHOR, 64);
ItemStack glowstone = new ItemStack(Material.GLOWSTONE, 64);
ItemStack enderpearl = new ItemStack(Material.ENDER_PEARL, 16);
ItemStack shield = new ItemStack(Material.SHIELD);
ItemStack goldenapple = new ItemStack(Material.GOLDEN_APPLE, 64);
ItemStack obsidian = new ItemStack(Material.OBSIDIAN, 64);
ItemStack crystal = new ItemStack(Material.END_CRYSTAL, 64);
ItemStack sword = new ItemStack(Material.NETHERITE_SWORD);
ItemStack totem = new ItemStack(Material.TOTEM_OF_UNDYING);
ItemStack xp = new ItemStack(Material.EXPERIENCE_BOTTLE, 64);
ItemStack arrow = new ItemStack(Material.TIPPED_ARROW, 64);
ItemStack axe = new ItemStack(Material.NETHERITE_AXE);
ItemStack crossbow = new ItemStack(Material.CROSSBOW);
ItemStack pickaxe = new ItemStack(Material.NETHERITE_PICKAXE);
return inv;
}
}

View File

@@ -0,0 +1,203 @@
package hu.jgj52.wolfFFA.Utils;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.session.ClipboardHolder;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class MapReset {
private final JavaPlugin plugin;
private BukkitTask resetTask;
private static final long RESET_INTERVAL = 12000L;
private static final int COUNTDOWN_SECONDS = 5;
private static final long SCHEMATIC_PLACEMENT_DELAY = 60L;
private static final Set<EntityType> ENTITIES_TO_REMOVE = EnumSet.of(
EntityType.TNT_MINECART,
EntityType.END_CRYSTAL,
EntityType.ITEM
);
private static final List<SchematicPlacement> SCHEMATICS = Arrays.asList(
new SchematicPlacement("world", -76, 91, -1076, "uhc"),
new SchematicPlacement("world", -924, 84, 1081, "boxcart")
);
public MapReset(JavaPlugin plugin) {
this.plugin = plugin;
startMapResetScheduler();
}
public boolean placeSchematic(World world, int x, int y, int z, String schematicName) {
File schematicFile = new File(plugin.getDataFolder() + File.separator + "schematics", schematicName + ".schem");
if (!schematicFile.exists()) {
plugin.getLogger().warning("Schematic file not found: " + schematicFile.getAbsolutePath());
return false;
}
ClipboardFormat format = ClipboardFormats.findByFile(schematicFile);
if (format == null) {
plugin.getLogger().warning("Unknown schematic format for file: " + schematicFile.getAbsolutePath());
return false;
}
try (FileInputStream fis = new FileInputStream(schematicFile);
ClipboardReader reader = format.getReader(fis)) {
Clipboard clipboard = reader.read();
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world);
try (EditSession editSession = WorldEdit.getInstance().newEditSession(weWorld)) {
Operation operation = new ClipboardHolder(clipboard)
.createPaste(editSession)
.to(BlockVector3.at(x, y, z))
.ignoreAirBlocks(false)
.build();
Operations.complete(operation);
editSession.flushSession();
return true;
}
} catch (IOException e) {
plugin.getLogger().severe("Error reading schematic file: " + e.getMessage());
e.printStackTrace();
} catch (Exception e) {
plugin.getLogger().severe("Error placing schematic: " + e.getMessage());
e.printStackTrace();
}
return false;
}
public boolean placeSchematic(Location location, String schematicName) {
return placeSchematic(
location.getWorld(),
location.getBlockX(),
location.getBlockY(),
location.getBlockZ(),
schematicName
);
}
public void placeSchematicsSequentially() {
new BukkitRunnable() {
int index = 0;
@Override
public void run() {
if (index < SCHEMATICS.size()) {
SchematicPlacement placement = SCHEMATICS.get(index);
World world = Bukkit.getWorld(placement.worldName);
if (world == null) {
index++;
return;
}
boolean success = placeSchematic(
world,
placement.x,
placement.y,
placement.z,
placement.name
);
index++;
} else {
removeEntities();
broadcastMessage("§cA mapok resetelve lettek!");
this.cancel();
}
}
}.runTaskTimer(plugin, 0L, SCHEMATIC_PLACEMENT_DELAY);
}
private void removeEntities() {
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getEntities()) {
if (ENTITIES_TO_REMOVE.contains(entity.getType())) {
entity.remove();
}
}
}
}
public void startMapResetScheduler() {
stopScheduler();
resetTask = new BukkitRunnable() {
@Override
public void run() {
startCountdown();
}
}.runTaskTimer(plugin, 0L, RESET_INTERVAL);
}
private void startCountdown() {
new BukkitRunnable() {
int countdown = COUNTDOWN_SECONDS;
@Override
public void run() {
if (countdown > 0) {
broadcastMessage("§cA mapok resetelődnek " + countdown + " másodperc múlva!");
countdown--;
} else {
placeSchematicsSequentially();
this.cancel();
}
}
}.runTaskTimer(plugin, 0L, 20L);
}
private void broadcastMessage(String message) {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(message);
}
}
public void stopScheduler() {
if (resetTask != null && !resetTask.isCancelled()) {
resetTask.cancel();
resetTask = null;
}
}
private static class SchematicPlacement {
final String worldName;
final int x, y, z;
final String name;
SchematicPlacement(String worldName, int x, int y, int z, String name) {
this.worldName = worldName;
this.x = x;
this.y = y;
this.z = z;
this.name = name;
}
}
}

View File

@@ -1,3 +1,4 @@
kits: kits:
sword: sword:
uhc: uhc:
boxcart:

View File

@@ -9,3 +9,6 @@ commands:
editkit: editkit:
permission: wolfffa.command.editkit permission: wolfffa.command.editkit
usage: /editkit <kit> usage: /editkit <kit>
leave:
permission: wolfffa.command.leave
usage: /leave

Binary file not shown.

View File

@@ -1,3 +0,0 @@
kits:
sword:
uhc:

View File

@@ -1,11 +0,0 @@
name: WolfFFA
version: '1.0'
main: hu.jgj52.wolfFFA.Main
api-version: '1.21'
commands:
tptoffa:
permission: wolfffa.admin.tptoffa
usage: /tptoffa <ffa> <player>
editkit:
permission: wolfffa.command.editkit
usage: /editkit <kit>

View File

@@ -1,3 +0,0 @@
artifactId=WolfFFA
groupId=hu.jgj52
version=1.0

View File

@@ -1,4 +0,0 @@
hu/jgj52/wolfFFA/Commands/TpToFfaCommand.class
hu/jgj52/wolfFFA/Commands/EditKitCommand.class
hu/jgj52/wolfFFA/Main.class
hu/jgj52/wolfFFA/Listeners/KitListener.class

View File

@@ -1,4 +0,0 @@
/home/jgj52/IdeaProjects/WolfFFA/src/main/java/hu/jgj52/wolfFFA/Commands/EditKitCommand.java
/home/jgj52/IdeaProjects/WolfFFA/src/main/java/hu/jgj52/wolfFFA/Commands/TpToFfaCommand.java
/home/jgj52/IdeaProjects/WolfFFA/src/main/java/hu/jgj52/wolfFFA/Listeners/KitListener.java
/home/jgj52/IdeaProjects/WolfFFA/src/main/java/hu/jgj52/wolfFFA/Main.java

Binary file not shown.