From da10956da65996bf0a8d2610e13cedf3baaaebf2 Mon Sep 17 00:00:00 2001 From: Grzybol Date: Sat, 22 Jun 2024 00:02:49 +0200 Subject: [PATCH] - fixed customMobs!!! now spider works --- pom.xml | 2 +- .../mine/game/betterelo/CustomMobs.java | 30 ++++++++++++------- .../game/betterelo/CustomMobsFileManager.java | 2 ++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index e694c35..7430f73 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ betterbox.mine.game BetterElo - 4.3.25-SNAPSHOT + 4.3.28-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 f8b9bd1..a3ec613 100644 --- a/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java +++ b/src/main/java/betterbox/mine/game/betterelo/CustomMobs.java @@ -116,13 +116,22 @@ public void spawnMob(Location location) { setupMob(); // Teraz wywołujemy setupMob() po stworzeniu encji ((BetterElo) plugin).registerCustomMob(this.entity, this); } - public CustomMob cloneForSpawn(Location spawnLocation) { - CustomMob newMob = new CustomMob(this.plugin, this.dropFileManager, this.mobName, this.entityType, - 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); - newMob.spawnMob(spawnLocation); + public CustomMob cloneForSpawn(Location spawnLocation, String mobType) { + + CustomMob newMob = null; + if (mobType.equals("SKELETON")|| mobType.equals("ZOMBIE")) { + newMob = new CustomMob(this.plugin, this.dropFileManager, this.mobName, this.entityType, + 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); + 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); + newMob.spawnMob(spawnLocation); + } return newMob; } @@ -406,7 +415,7 @@ public void spawnCustomMob(Location location, String spawnerName, String mobName CustomMob templateMob = customMobsMap.get(mobName); if (templateMob != null) { Location adjustedLocation = adjustLocationToAirAbove(location); - CustomMob newMob = templateMob.cloneForSpawn(adjustedLocation); + CustomMob newMob = templateMob.cloneForSpawn(adjustedLocation, templateMob.entityType.toString()); newMob.customMetadata.put("SpawnerName", spawnerName); newMob.spawnerName = spawnerName; //newMob.dropTable = fileManager.loadCustomDrops(newMob.dropTableName); @@ -417,11 +426,12 @@ public void spawnCustomMob(Location location, String spawnerName, String mobName } } public void spawnCustomMob(Location location, String mobName) { - pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "CustomMobs.spawnCustomMob called, mobName: " + mobName+", location: "+location); + CustomMob templateMob = customMobsMap.get(mobName); + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "CustomMobs.spawnCustomMob called, mobName: " + mobName+", location: "+location+", mobtype: "+templateMob.entityType.toString()); if (templateMob != null) { Location adjustedLocation = adjustLocationToAirAbove(location); - CustomMob newMob = templateMob.cloneForSpawn(adjustedLocation); + CustomMob newMob = templateMob.cloneForSpawn(adjustedLocation, templateMob.entityType.toString()); //newMob.dropTable = fileManager.loadCustomDrops(newMob.dropTableName); pluginLogger.log(PluginLogger.LogLevel.DROP, "CustomMobs.spawnCustomMob newMob.dropTablename: "+newMob.dropTableName+", newMob.dropTable: "+newMob.dropTable); pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "CustomMobs.spawnCustomMob newMob.spawnerName: "+newMob.spawnerName); diff --git a/src/main/java/betterbox/mine/game/betterelo/CustomMobsFileManager.java b/src/main/java/betterbox/mine/game/betterelo/CustomMobsFileManager.java index 175646f..4ebdf78 100644 --- a/src/main/java/betterbox/mine/game/betterelo/CustomMobsFileManager.java +++ b/src/main/java/betterbox/mine/game/betterelo/CustomMobsFileManager.java @@ -247,6 +247,7 @@ public CustomMobs.CustomMob loadCustomMob(JavaPlugin plugin, FileRewardManager d ItemStack weapon=null; if (entityTypeString.equals("SKELETON")||entityTypeString.equals("ZOMBIE")) {// Wczytanie wyposażenia z pliku + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "CustomMobsFileManager.loadCustomMob mob is ZOMBIE or SKELETON"); helmet = loadItemStack(mobData, "equipment.helmet"); chestplate = loadItemStack(mobData, "equipment.chestplate"); leggings = loadItemStack(mobData, "equipment.leggings"); @@ -290,6 +291,7 @@ public CustomMobs.CustomMob loadCustomMob(JavaPlugin plugin, FileRewardManager d // Zakładamy, że LivingEntity jest nullem, ponieważ tworzymy moba bez konkretnej encji w świecie 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); }else{