diff --git a/pom.xml b/pom.xml index 8ca0dfe..b4cfe5a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ betterbox.mine.game BetterElo - 3.2.61-SNAPSHOT + 3.2.63-SNAPSHOT jar BetterElo diff --git a/src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java b/src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java index 9127043..2bbea53 100644 --- a/src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java +++ b/src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java @@ -72,7 +72,22 @@ public boolean onCommand(CommandSender sender, Command command, String label, St break; case 1: switch (args[0].toLowerCase()) { - + case "addelytra": + if (sender instanceof Player) { + Player player = (Player) sender; + if(!player.isOp()){ + sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED + " You don't have permission to use that command!"); + break; + } + ItemStack itemInHand = player.getInventory().getItemInMainHand(); + if(itemInHand.getType() != Material.AIR && itemInHand.getType().toString().contains("CHESTPLATE")) { + addElytraLore(player,itemInHand); + sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Elytra effect added."); + } + }else{ + sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED + " This command can be used only by as a player."); + } + break; case "stopevent": if(sender.isOp()){ sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Event stopped,data removed."); @@ -571,6 +586,8 @@ private void handleHelpCommand(CommandSender sender){ sender.sendMessage(ChatColor.AQUA + "/be holo " + ChatColor.GREEN + "- creates holo at your position."); sender.sendMessage(ChatColor.AQUA + "/be holo delete " + ChatColor.GREEN + "- delete given holo"); sender.sendMessage(ChatColor.AQUA + "/be antyweb " + ChatColor.GREEN + "- creates antyweb effect with given radius"); + sender.sendMessage(ChatColor.AQUA + "/be addelytra " + ChatColor.GREEN + "- adds Elytra Effect to the chestplate (works only with infinite Infinite Firework)"); + sender.sendMessage(ChatColor.AQUA + "/be firework " + ChatColor.GREEN + "- creates an Infinite Firework with given power"); } } private void handleTimeLeft(CommandSender sender){ @@ -616,7 +633,6 @@ public void addAntywebLore(Player player, ItemStack itemStack, int radius) { if (itemMeta == null) { return; // Przerwij, jeśli nie można pobrać metadanych przedmiotu } - String antywebLore = ChatColor.GOLD + "" + ChatColor.BOLD + "Antyweb " + radius; List lore = itemMeta.getLore(); if (lore == null) { @@ -624,23 +640,26 @@ public void addAntywebLore(Player player, ItemStack itemStack, int radius) { } lore.add(antywebLore); itemMeta.setLore(lore); - /* itemStack.setItemMeta(itemMeta); - if (itemMeta.hasLore()) { - // Jeśli istnieje już lore, dodaj nową linię - itemMeta.getLore().add(lore); - } else { - // Jeśli nie ma jeszcze lore, utwórz nową listę - itemMeta.setLore(Collections.singletonList(lore)); - } + player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Added Antyweb lore with radius "+radius); - */ + } + public void addElytraLore(Player player, ItemStack itemStack) { + ItemMeta itemMeta = itemStack.getItemMeta(); + if (itemMeta == null) { + return; // Przerwij, jeśli nie można pobrać metadanych przedmiotu + } + String antywebLore = ChatColor.GOLD + "" + ChatColor.BOLD + "Elytra effect" ; + List lore = itemMeta.getLore(); + if (lore == null) { + lore = new ArrayList<>(); + } + lore.add(antywebLore); + itemMeta.setLore(lore); itemStack.setItemMeta(itemMeta); + player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Added Elytra effect"); - // Informuj gracza o dodaniu lore - player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Added Antyweb lore with radius "+radius); - //player.sendMessage("Added Antyweb lore with radius " + radius + " to the item."); } diff --git a/src/main/java/betterbox/mine/game/betterelo/Event.java b/src/main/java/betterbox/mine/game/betterelo/Event.java index bb9b2cb..8d6effc 100644 --- a/src/main/java/betterbox/mine/game/betterelo/Event.java +++ b/src/main/java/betterbox/mine/game/betterelo/Event.java @@ -514,18 +514,25 @@ public void onPlayerInteract(PlayerInteractEvent event) { double fireworkCooldown = (double) (configManager.fireworkCooldown) /1000; if (item != null && item.getType() == Material.FIREWORK_ROCKET) { - if(event.getAction() == Action.RIGHT_CLICK_AIR){ + if(event.getAction() != Action.RIGHT_CLICK_AIR) { + event.setCancelled(true); + return; + } Location location = player.getLocation(); Location blockBelowLocation = location.clone().subtract(0, 1, 0); boolean isNotOnGround = blockBelowLocation.getBlock().isPassable(); ItemStack chestplate = player.getInventory().getChestplate(); - if (chestplate == null || !chestplate.getType().toString().contains("ELYTRA")) { + if(chestplate == null ){ event.setCancelled(true); - pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.onPlayerInteract player is not wearing Elytra!"); return; - } + if (chestplate.getType().toString().contains("ELYTRA") || hasElytraLore(chestplate)) { + + pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.onPlayerInteract player is not wearing Elytra!"); + + + @@ -573,6 +580,28 @@ private static void applyBoosterEffect(Player player,int power) { Vector velocity = player.getLocation().getDirection().multiply(power); // Przykładowa prędkość (można dostosować) player.setVelocity(velocity); } + public boolean hasElytraLore(ItemStack itemStack) { + pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasElytraLore called"); + if (itemStack == null || !itemStack.hasItemMeta()) { + pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasElytraLore itemmeta check failed"); + return false; + } + + ItemMeta itemMeta = itemStack.getItemMeta(); + if (itemMeta == null || !itemMeta.hasLore()) { + pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasElytraLore lore check failed"); + return false; + } + + for (String lore : itemMeta.getLore()) { + pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasElytraLore Elytra check triggered, checking lore and foramtting"); + if (lore != null && lore.contains("§6§lElytra effect")) { + return true; + } + } + + return false; + } public boolean hasAntywebLore(ItemStack itemStack) { pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasAntywebLore called"); if (itemStack == null || !itemStack.hasItemMeta()) {