diff --git a/pom.xml b/pom.xml index 7430f73..b46aed8 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ betterbox.mine.game BetterElo - 4.3.28-SNAPSHOT + 4.3.47-SNAPSHOT jar BetterElo diff --git a/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java b/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java index a3ec613..1d3138b 100644 --- a/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java +++ b/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java @@ -43,12 +43,12 @@ static class CustomMob { //HashMap< Double,ItemStack> dropTable; List dropTable; double armor, speed, attackDamage, EMKSchance; - int hp,attackSpeed; + int hp,attackSpeed,defense; Map customMetadata; // Nowe pole do przechowywania niestandardowych metadanych JavaPlugin plugin; CustomMobsFileManager dropFileManager; - CustomMob(JavaPlugin plugin,CustomMobsFileManager dropFileManager, String mobName, EntityType entityType, ItemStack helmet, ItemStack chestplate, ItemStack leggings, ItemStack boots,ItemStack weapon, double armor, int hp, double speed, double attackDamage, int attackSpeed, Map customMetadata, String dropTableName, Boolean dropEMKS, double EMKSchance) { + CustomMob(JavaPlugin plugin,CustomMobsFileManager dropFileManager, String mobName, EntityType entityType, ItemStack helmet, ItemStack chestplate, ItemStack leggings, ItemStack boots,ItemStack weapon, double armor, int hp, double speed, double attackDamage, int attackSpeed, Map customMetadata, String dropTableName, Boolean dropEMKS, double EMKSchance, int defense) { this.plugin = plugin; this.dropEMKS = dropEMKS; this.EMKSchance = EMKSchance; @@ -82,11 +82,12 @@ static class CustomMob { this.hp = hp; this.attackSpeed = attackSpeed; this.speed = speed; + this.defense = defense; this.attackDamage = attackDamage; this.customMetadata = customMetadata; //setupMob(); } - CustomMob(JavaPlugin plugin,CustomMobsFileManager dropFileManager, String mobName, EntityType entityType, double armor, int hp, double speed, double attackDamage, int attackSpeed, Map customMetadata, String dropTableName, Boolean dropEMKS, double EMKSchance) { + CustomMob(JavaPlugin plugin,CustomMobsFileManager dropFileManager, String mobName, EntityType entityType, double armor, int hp, double speed, double attackDamage, int attackSpeed, Map customMetadata, String dropTableName, Boolean dropEMKS, double EMKSchance, int defense) { this.plugin = plugin; this.dropEMKS = dropEMKS; this.EMKSchance = EMKSchance; @@ -101,6 +102,7 @@ static class CustomMob { this.hp = hp; this.attackSpeed = attackSpeed; this.speed = speed; + this.defense = defense; this.attackDamage = attackDamage; this.customMetadata = customMetadata; //setupMob(); @@ -124,12 +126,12 @@ public CustomMob cloneForSpawn(Location spawnLocation, String mobType) { this.helmet.clone(), this.chestplate.clone(), this.leggings.clone(), this.boots.clone(), this.weapon.clone(), this.armor, this.hp, this.speed, - this.attackDamage, this.attackSpeed, new HashMap<>(this.customMetadata), this.dropTableName, this.dropEMKS, this.EMKSchance); + this.attackDamage, this.attackSpeed, new HashMap<>(this.customMetadata), this.dropTableName, this.dropEMKS, this.EMKSchance, this.defense); newMob.spawnMob(spawnLocation); }else{ newMob = new CustomMob(this.plugin, this.dropFileManager, this.mobName, this.entityType, this.armor, this.hp, this.speed, - this.attackDamage, this.attackSpeed, new HashMap<>(this.customMetadata), this.dropTableName, this.dropEMKS, this.EMKSchance); + this.attackDamage, this.attackSpeed, new HashMap<>(this.customMetadata), this.dropTableName, this.dropEMKS, this.EMKSchance, this.defense); newMob.spawnMob(spawnLocation); } return newMob; @@ -166,6 +168,8 @@ private void setupMob() { // Ustawianie niestandardowych metadanych customMetadata.forEach((key, value) -> entity.setMetadata(key, new FixedMetadataValue(plugin, value))); + entity.setMetadata("armor", new FixedMetadataValue(plugin, armor)); + entity.setMetadata("defense", new FixedMetadataValue(plugin, defense)); } public String getMobName() { return this.mobName; diff --git a/src/main/java/betterbox/mine/game/betterelo/CustomMobsFileManager.java b/src/main/java/betterbox/mine/game/betterelo/CustomMobsFileManager.java index 4ebdf78..980b9fa 100644 --- a/src/main/java/betterbox/mine/game/betterelo/CustomMobsFileManager.java +++ b/src/main/java/betterbox/mine/game/betterelo/CustomMobsFileManager.java @@ -255,13 +255,14 @@ public CustomMobs.CustomMob loadCustomMob(JavaPlugin plugin, FileRewardManager d weapon = loadItemStack(mobData, "equipment.weapon"); } // Wczytanie pozostałych danych - double armor = mobData.getDouble("armor"); + double armor = 1; int hp = mobData.getInt("hp"); double speed = mobData.getDouble("speed"); double attackDamage = mobData.getDouble("attackDamage"); double EKMSchance = 0.0d; boolean dropEMKS = false; int attackSpeed = 1; + int defense = 0; if(mobData.contains("dropEMKS")){ @@ -276,6 +277,14 @@ public CustomMobs.CustomMob loadCustomMob(JavaPlugin plugin, FileRewardManager d attackSpeed = mobData.getInt("attackSpeed"); pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "CustomMobsFileManager.loadCustomMob loaded AttackSpeed:" + attackSpeed); } + if(mobData.contains("defense")){ + defense = mobData.getInt("defense"); + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "CustomMobsFileManager.loadCustomMob loaded defense:" + defense); + } + if(mobData.contains("armor")){ + armor = mobData.getDouble("armor"); + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "CustomMobsFileManager.loadCustomMob loaded armor:" + armor); + } String mobName = mobData.getString("mobName"); String dropTableName = mobData.getString("dropTable"); @@ -292,10 +301,10 @@ public CustomMobs.CustomMob loadCustomMob(JavaPlugin plugin, FileRewardManager d CustomMobs.CustomMob customMob=null; if (entityTypeString.equals("SKELETON")||entityTypeString.equals("ZOMBIE")){ pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "CustomMobsFileManager.loadCustomMob mob is ZOMBIE or SKELETON"); - customMob = new CustomMobs.CustomMob(plugin, this, mobName, entityType, helmet, chestplate, leggings, boots,weapon, armor, hp, speed, attackDamage,attackSpeed, customMetadata, dropTableName, dropEMKS, EKMSchance); + customMob = new CustomMobs.CustomMob(plugin, this, mobName, entityType, helmet, chestplate, leggings, boots,weapon, armor, hp, speed, attackDamage,attackSpeed, customMetadata, dropTableName, dropEMKS, EKMSchance, defense); }else{ - customMob = new CustomMobs.CustomMob(plugin, this, mobName, entityType, armor, hp, speed, attackDamage,attackSpeed, customMetadata, dropTableName, dropEMKS, EKMSchance); + customMob = new CustomMobs.CustomMob(plugin, this, mobName, entityType, armor, hp, speed, attackDamage,attackSpeed, customMetadata, dropTableName, dropEMKS, EKMSchance, defense); } diff --git a/src/main/java/betterbox/mine/game/betterelo/Event.java b/src/main/java/betterbox/mine/game/betterelo/Event.java index fbb0d54..fe2e76d 100644 --- a/src/main/java/betterbox/mine/game/betterelo/Event.java +++ b/src/main/java/betterbox/mine/game/betterelo/Event.java @@ -8,6 +8,7 @@ import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.RegionContainer; import com.sk89q.worldguard.protection.ApplicableRegionSet; +import io.papermc.paper.event.entity.EntityMoveEvent; import net.kyori.adventure.text.Component; import net.kyori.adventure.title.Title; import org.bukkit.*; @@ -22,10 +23,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityDeathEvent; -import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.*; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -1061,11 +1059,12 @@ private ItemStack dropMobKillerSword(){ @EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { //pluginLogger.log(PluginLogger.LogLevel.KILL_EVENT, "Event.onEntityDamageByEntity onEntityDamageByEntity called"); - - if (event.getDamager() instanceof Player && event.getEntity() instanceof Player && !event.isCancelled()) { - + Entity damagerEntity = event.getDamager(); + Entity victimEntity = event.getEntity(); + if (damagerEntity instanceof Player && victimEntity instanceof Player && !event.isCancelled()) { Player damager = (Player) event.getDamager(); Player victim = (Player) event.getEntity(); + if (damager.hasMetadata("handledDamage")) { pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onEntityDamageByEntity event already handled!"); return; @@ -1092,20 +1091,52 @@ public void run() { damager.removeMetadata("handledDamage", plugin); } }, 1L); + return; } LivingEntity entity = (LivingEntity) event.getEntity(); - if (entity.hasMetadata("CustomMob")){ + if (victimEntity.hasMetadata("CustomMob")){ pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.onEntityDamageByEntity custom mob detected"); customEntityDamageEvent(event); //CustomMobs.CustomMob customMob = (CustomMobs.CustomMob) entity; //Zombie zombie = (Zombie) entity; pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.EntityDamageEvent calling customMobs.updateZombieCustomName(zombie)"); //customMobs.updateCustomMobName(zombie); + return; } + if (damagerEntity.hasMetadata("CustomMob") && victimEntity instanceof Player) { + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.EntityDamageEvent getFinalDamage: "+event.getFinalDamage()); + event.setDamage(event.getFinalDamage()*(1-(0.004*customArmorBonus((Player) victimEntity)))); + } } + public int customArmorBonus (Player player){ + int CustomArmorBonus=0; + List equippedItems = getPlayerEquippedItems(player); + if(equippedItems==null){ + return CustomArmorBonus; + } + for (ItemStack item : equippedItems){ + ItemMeta meta = item.getItemMeta(); + if (meta != null && meta.hasLore()) { + List lore = meta.getLore(); + for (String line : lore) { + if (line.startsWith("§6§lMob Defense ")) { + try { + String percentString = line.replace("§6§lMob Defense ", "").replace("%", ""); + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customArmorBonus percentString: " + percentString); + CustomArmorBonus += Integer.parseInt(percentString); + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customArmorBonus added CustomArmorBonus: " + CustomArmorBonus); + } catch (NumberFormatException e) { + pluginLogger.log(PluginLogger.LogLevel.ERROR, "Error parsing average damage bonus from lore: " + line); + } + } + } + } + } + return CustomArmorBonus; + } public void customEntityDamageEvent(EntityDamageByEntityEvent event){ pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent triggered"); @@ -1145,8 +1176,39 @@ public void customEntityDamageEvent(EntityDamageByEntityEvent event){ int bonusDamage = (int) (averageDamage * (averageDamageBonusPercent / 100.0)); // Obliczenie bonusu double totalDamage = minDamage + random.nextInt(maxDamage - minDamage + 1) + bonusDamage; // Całkowite obrażenia pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent minDamage: "+minDamage+", maxDamage: "+maxDamage+", averageDamage: "+averageDamage+", bonusAverageDamage: "+bonusDamage); - event.setDamage(totalDamage); - pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent totalDamage: " + totalDamage+", bonusDamage: "+bonusDamage); + double armor=1, defense=0; + if (event.getEntity().hasMetadata("armor")) { + List values = event.getEntity().getMetadata("armor"); + armor = values.get(0).asDouble(); // Uzyskanie wartości armor + if(armor==0){ + armor=1; + } + } + if (event.getEntity().hasMetadata("defense")) { + List values = event.getEntity().getMetadata("defense"); + defense = values.get(0).asDouble(); // Uzyskanie wartości defense + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent defense from metadata: "+defense); + if (defense>=100){ + pluginLogger.log(PluginLogger.LogLevel.WARNING, "Damage event: Mob has defense higher than 100! setting def=0:"); + defense=0; + } + }else{ + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent defense metadata not found for mob: "+event.getEntity().getMetadata("MobName")); + } + CustomMobs.CustomMob customMob = null; + customMob = betterElo.getCustomMobFromEntity(event.getEntity()); + if(customMob!=null) + { + defense = customMob.defense; + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent defense from customMob object: "+defense); + } + double defDmgReduction= (1-(0.01*defense)); + double finalDamage =((totalDamage-armor)*defDmgReduction); + if(finalDamage<=0) + finalDamage=0; + + event.setDamage(finalDamage); + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent finalDamage: "+finalDamage+", totalDamage: " + totalDamage+", bonusDamage: "+bonusDamage+", defDmgReduction(1-(0.01*defense)): "+defDmgReduction+", armor: "+armor); return; } @@ -1295,7 +1357,7 @@ public void onInventoryClick(InventoryClickEvent event) { case "Select Top": event.setCancelled(true); guiManager.rewardType = currentItem.getItemMeta().getDisplayName(); - pluginLogger.log("GuiManager.onInventoryClick: rewardType:" + guiManager.rewardType + " periodType:" + guiManager.periodType); + pluginLogger.log("Event.onInventoryClick: rewardType:" + guiManager.rewardType + " periodType:" + guiManager.periodType); fileRewardManager.setRewardType(guiManager.periodType, guiManager.rewardType); List currentRewards = fileRewardManager.loadRewards(); inv = Bukkit.createInventory(null, 36, "Add Items"); @@ -1307,31 +1369,31 @@ public void onInventoryClick(InventoryClickEvent event) { break; case "Add Items": //save button check - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick Add Items"); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick Add Items"); if (currentItem.getType() == Material.GREEN_WOOL && (event.getSlot() == 35 || event.getSlot() == 53)) { - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick Add Items - save called."); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick Add Items - save called."); event.setCancelled(true); Inventory inventory = event.getInventory(); List itemsToSave = new ArrayList<>(); for (int i = 0; i < inventory.getSize(); i++) { if (i == 35 || i == 53) { // Pomijamy slot przycisku "Save" - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick save button, skipping."); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick save button, skipping."); continue; } ItemStack item = inventory.getItem(i); - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick save: item: "+item); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick save: item: "+item); if (item != null && item.getType() != Material.AIR) { - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick no air save: item: "+item); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick no air save: item: "+item); itemsToSave.add(item); } } String fileName=guiManager.periodType+"_"+guiManager.rewardType; - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick calling fileRewardManager.saveRewards("+fileName+",itemsToSave)"); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick calling fileRewardManager.saveRewards("+fileName+",itemsToSave)"); if(guiManager.periodType.equals("dropTable")){ fileName=guiManager.dropTable; - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick droptable: "+fileName); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick droptable: "+fileName); fileRewardManager.saveCustomDrops(fileName, itemsToSave); }else{ fileRewardManager.saveRewards(fileName, itemsToSave); @@ -1340,22 +1402,22 @@ public void onInventoryClick(InventoryClickEvent event) { } break; case "AvgDmg bonus change": - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick Average Damage bonus re-roll"); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick Average Damage bonus re-roll"); if (currentItem.getType() == Material.GREEN_WOOL && event.getSlot() == 5){ playerInventory.setContents(savedInventory); event.setCancelled(true); - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick Average Damage bonus re-roll clicked"); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick Average Damage bonus re-roll clicked"); Inventory inventory = event.getInventory(); ItemStack item0 = inventory.getItem(3); if (item0 != null && item0.hasItemMeta()) { - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick reroll, item0: "+item0+", item0.hasItemMeta(): "+item0.hasItemMeta()); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick reroll, item0: "+item0+", item0.hasItemMeta(): "+item0.hasItemMeta()); ItemMeta meta0 = item0.getItemMeta(); boolean slot0Condition = meta0.getLore().stream().anyMatch(line -> line.contains("Average Damage")); ItemMeta meta = item0.getItemMeta(); //List lore = meta.getLore(); - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick reroll, slot0Condition: "+slot0Condition); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick reroll, slot0Condition: "+slot0Condition); if (slot0Condition) { ItemStack result = item0.clone(); @@ -1366,9 +1428,9 @@ public void onInventoryClick(InventoryClickEvent event) { if(lore.get(i).contains("Mob Damage")) mobDamage=true; if (lore.get(i).contains("Average Damage") && mobDamage) { - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick reroll, Average Damage lore line found i: " + i); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick reroll, Average Damage lore line found i: " + i); if( guiManager.checkAndRemoveEnchantItem(player)) { - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick reroll, player paid, re-rolling..." ); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick reroll, player paid, re-rolling..." ); lore.set(i, customMobs.dropAverageDamage()); player.setMetadata("avgDmgRerolled", new FixedMetadataValue(plugin, true)); Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @@ -1379,13 +1441,13 @@ public void run() { }, 1L); break; } - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick reroll, player has no money for the re-roll." ); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick reroll, player has no money for the re-roll." ); } } resultMeta.setLore(lore); result.setItemMeta(resultMeta); inventory.setItem(3, result); - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClick result placed back in slot 3"); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClick result placed back in slot 3"); } } @@ -1401,23 +1463,23 @@ public void onInventoryClose(InventoryCloseEvent event) { // Check if the closed inventory is the same one we're interested in if (event.getView().getTitle().equalsIgnoreCase("AvgDmg bonus change")) { - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Checking items in closed GUI"); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClose: Checking items in closed GUI"); ItemStack itemInSlot0 = closedInventory.getItem(3); if (itemInSlot0 != null) { ItemMeta meta = itemInSlot0.getItemMeta(); //if (meta.getLore().stream().anyMatch(line -> line.contains("Average Damage"))) { - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Item with 'Average damage' found in slot 0"); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClose: Item with 'Average damage' found in slot 0"); // Optional: Directly give back the item to the player's inventory if (player.getInventory().addItem(itemInSlot0).size() == 0) { // Item successfully added to player's inventory - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Item returned to player inventory"); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClose: Item returned to player inventory"); closedInventory.clear(3); // Clear the slot after returning item } else { // Inventory full, drop item at player's location player.getWorld().dropItem(player.getLocation(), itemInSlot0); - pluginLogger.log(PluginLogger.LogLevel.DEBUG, "GuiManager.onInventoryClose: Inventory full, item dropped at player's location"); + pluginLogger.log(PluginLogger.LogLevel.DEBUG, "Event.onInventoryClose: Inventory full, item dropped at player's location"); closedInventory.clear(3); // Clear the slot } //} @@ -1425,5 +1487,31 @@ public void onInventoryClose(InventoryCloseEvent event) { } } + + @EventHandler + public void onEntityMove(EntityMoveEvent event) { + + //pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.onEntityInteract called"); + if (!event.getEntity().hasMetadata("CustomMob")){ + return; + } + //pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.onEntityInteract: CustomMob CHECK PASSED"); + + // Pobieranie bloku, z którym wchodzi w interakcję mob + Block block = event.getTo().getBlock(); + if(!block.hasMetadata("placed_by_player")){ + return; + } + //pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.onEntityInteract: COMWEB placed_by_player CHECK PASSED"); + // Sprawdzanie, czy blok to pajęczyna + if (block.getType() == Material.COBWEB) { + // Usunięcie pajęczyny, gdy mob wejdzie w nią + block.setType(Material.AIR); + + // Można tutaj dodać dodatkowe działania, np. wysłanie informacji do logów serwera + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.onEntityInteract: Mob is removing player-placed cobweb"); + } + } + } diff --git a/src/main/java/betterbox/mine/game/betterelo/FileRewardManager.java b/src/main/java/betterbox/mine/game/betterelo/FileRewardManager.java index d4dc2dc..deb6d76 100644 --- a/src/main/java/betterbox/mine/game/betterelo/FileRewardManager.java +++ b/src/main/java/betterbox/mine/game/betterelo/FileRewardManager.java @@ -171,9 +171,10 @@ public void saveCustomDrops(String fileName, List rewards) { String itemNameString = item.getType().toString(); dropTableConfig.set("Item" + index + ".itemName", itemNameString); // Tutaj można ustawić faktyczną szansę na drop dropTableConfig.set("Item" + index + ".avgDmgBonus", false); // Tutaj można ustawić faktyczną szansę na drop + dropTableConfig.set("Item" + index + ".description", item.getItemMeta().lore().toString()); // Tutaj można ustawić faktyczną szansę na drop index++; } catch (IOException e) { - pluginLogger.log(PluginLogger.LogLevel.ERROR, "Nie można zapisać przedmiotu: " + e.getMessage()); + pluginLogger.log(PluginLogger.LogLevel.ERROR, "Cannot save the item : "+index +", error: "+ e.getMessage()); } }