Skip to content

Commit

Permalink
EliteMobs 7.3.12-SNAPSHOT-6
Browse files Browse the repository at this point in the history
- [New] Added the Primis Adventure to the setup menu
- [New] Added ModelEngine as a valid folder for the imports. Files in the ModelEngine will be moved to the blueprints folder of ModelEngine when imported and automatically reload ModelEngine to register the files and generate the texture pack.
- [New] Goats can now be valid elites (though they're not very good)
- [New] Llamas can now be valid elites
- [New] Elites with fire resistance are no longer set on fire when exposed to the sun
- [New] Added attack_melee and attack_ranged specific animations, will override the attack animation when present
- [New] Bosses with Custom Models now display their nametags correctly
- [New] Loading Lair / Minidungeon / Adventure worlds through EliteMobs now defaults their difficulty to hard
- [Tweak] Improvements to the stay angry mechanic
- [Fix] Fixed the aggro range for passive entities
- [Refactor] Minor Sonarlint improvements

Signed-off-by: MagmaGuy <tiagoarnaut@gmail.com>
  • Loading branch information
MagmaGuy committed Dec 31, 2021
1 parent c713efa commit 4231110
Show file tree
Hide file tree
Showing 23 changed files with 271 additions and 43 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"

group 'com.magmaguy'
version '7.3.12-SNAPSHOT-5'
version '7.3.12-SNAPSHOT-6'

repositories {
maven {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/magmaguy/elitemobs/EventsRegistrer.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import com.magmaguy.elitemobs.quests.objectives.DialogObjective;
import com.magmaguy.elitemobs.quests.objectives.KillObjective;
import com.magmaguy.elitemobs.quests.playercooldowns.PlayerQuestCooldownsLogout;
import com.magmaguy.elitemobs.thirdparty.modelengine.ModelEntity;
import com.magmaguy.elitemobs.thirdparty.modelengine.CustomModel;
import com.magmaguy.elitemobs.thirdparty.worldguard.WorldGuardDungeonFlag;
import com.magmaguy.elitemobs.thirdparty.worldguard.WorldGuardEliteMobOnlySpawnFlag;
import com.magmaguy.elitemobs.thirdparty.worldguard.WorldGuardSpawnEventBypasser;
Expand Down Expand Up @@ -222,7 +222,7 @@ public static void registerEvents() {
pluginManager.registerEvents(new AdvancedAggroManager(), plugin);
pluginManager.registerEvents(new TransitiveBossBlock(), plugin);
pluginManager.registerEvents(new TransitiveBlockCommand.TemporaryBossBlockCommandEvents(), plugin);
pluginManager.registerEvents(new ModelEntity.ModelEntityEvents(), plugin);
pluginManager.registerEvents(new CustomModel.ModelEntityEvents(), plugin);

//Metadata (player purger)
pluginManager.registerEvents(new MetadataHandler(), plugin);
Expand Down Expand Up @@ -346,6 +346,7 @@ public static void registerEvents() {
pluginManager.registerEvents(new EntityTransformHandler(), plugin);
pluginManager.registerEvents(new EliteBlazeWaterDamagePrevention(), plugin);
pluginManager.registerEvents(new PreventEliteEquipmentDrop(), plugin);
pluginManager.registerEvents(new CombustionPrevention(), plugin);

pluginManager.registerEvents(new TreasureChest.TreasureChestEvents(), plugin);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.magmaguy.elitemobs.collateralminecraftchanges;

import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.potion.PotionEffectType;

public class CombustionPrevention implements Listener {
@EventHandler
public void onCombust(EntityCombustEvent event) {
if (event.getEntity() instanceof LivingEntity &&
((LivingEntity) event.getEntity()).hasPotionEffect(PotionEffectType.FIRE_RESISTANCE))
event.setCancelled(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.magmaguy.elitemobs.MetadataHandler;
import com.magmaguy.elitemobs.mobconstructor.EliteEntity;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Mob;
Expand All @@ -12,35 +13,41 @@
import java.util.HashSet;
import java.util.Objects;

public class KeepPassivesAngry {
public class KeepNeutralsAngry {
private static final HashSet<EliteEntity> angryMobs = new HashSet<>();

private KeepPassivesAngry() {
private KeepNeutralsAngry() {
}

public static void showMeYouWarFace(EliteEntity eliteEntity) {
//might already contain
EntityType entityType = eliteEntity.getLivingEntity().getType();
if (angryMobs.contains(eliteEntity)) return;
new BukkitRunnable() {
@Override
public void run() {
//It is possible for entities to change type during combat, in which case they need to be wiped
if (!eliteEntity.isValid() || !eliteEntity.getLivingEntity().getType().equals(EntityType.WOLF)) {
if (!eliteEntity.isValid() || !entityType.equals(eliteEntity.getLivingEntity().getType())) {
cancel();
angryMobs.remove(eliteEntity);
return;
}

if (((Mob) eliteEntity.getLivingEntity()).getTarget() != null) return;
if (!eliteEntity.getLivingEntity().getType().equals(EntityType.LLAMA) &&
((Mob) eliteEntity.getLivingEntity()).getTarget() != null)
return;

for (Player player : Bukkit.getOnlinePlayers())
if (Objects.equals(player.getLocation().getWorld(), eliteEntity.getLocation().getWorld()) &&
player.getLocation().distanceSquared(eliteEntity.getLocation()) <
if (!player.getGameMode().equals(GameMode.SPECTATOR) && !player.getGameMode().equals(GameMode.CREATIVE) &&
Objects.equals(player.getLocation().getWorld(), eliteEntity.getLocation().getWorld()) &&
player.getLocation().distance(eliteEntity.getLocation()) <
Objects.requireNonNull(eliteEntity.getLivingEntity().getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue()) {
((Mob) eliteEntity.getLivingEntity()).setTarget(player);
return;
}

((Mob) eliteEntity.getLivingEntity()).setTarget(null);

}
}.runTaskTimer(MetadataHandler.PLUGIN, 0, 20);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.magmaguy.elitemobs.config.configurationimporter;

import com.magmaguy.elitemobs.MetadataHandler;
import com.magmaguy.elitemobs.thirdparty.modelengine.CustomModel;
import com.magmaguy.elitemobs.utils.InfoMessage;
import com.magmaguy.elitemobs.utils.UnzipFile;
import com.magmaguy.elitemobs.utils.WarningMessage;
Expand Down Expand Up @@ -37,6 +38,7 @@ public static void initializeConfigs() {

if (importsFile.listFiles().length == 0)
return;
boolean importedModels = false;

for (File zippedFile : importsFile.listFiles()) {
File unzippedFile;
Expand Down Expand Up @@ -79,6 +81,11 @@ public static void initializeConfigs() {
case "worldcontainer":
moveWorlds(file);
break;
case "ModelEngine":
if (Bukkit.getPluginManager().isPluginEnabled("ModelEngine")) {
moveDirectory(file, Paths.get(file.getParentFile().getParentFile().getParentFile().getParentFile().toString() + File.separatorChar + "ModelEngine" + File.separatorChar + "blueprints"));
importedModels = true;
} else new WarningMessage("You need ModelEngine to install schematic-based minidungeons!");
case "schematics":
if (Bukkit.getPluginManager().isPluginEnabled("FastAsyncWorldEdit")) {
moveDirectory(file, Paths.get(file.getParentFile().getParentFile().getParentFile().getParentFile().toString() + File.separatorChar + "FastAsyncWorldEdit" + File.separatorChar + "schematics"));
Expand Down Expand Up @@ -106,6 +113,10 @@ public static void initializeConfigs() {
}
}

if (importedModels) {
CustomModel.reloadModels();
}

}

private static void deleteDirectory(File file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ public TestCustomBossesConfig() {
setOnDamagedMessages(Collections.singletonList("I've been hit!"));
setOnDeathCommands(Collections.singletonList("broadcast $players has killed $name! That was level $level!"));
setAnnouncementPriority(3);
setCustomModel("showcase_boss");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.magmaguy.elitemobs.config.dungeonpackager.premade;

import com.magmaguy.elitemobs.config.dungeonpackager.DungeonPackagerConfigFields;
import com.magmaguy.elitemobs.utils.DiscordLinks;
import org.bukkit.World;
import org.bukkit.util.Vector;

import java.util.ArrayList;
import java.util.Arrays;

public class PrimisAdventure extends DungeonPackagerConfigFields {
public PrimisAdventure() {
super("primis_adventure",
false,
"&7Primis",
DungeonPackagerConfigFields.DungeonLocationType.WORLD,
Arrays.asList("&fA tutorial adventure for new players!",
"&6Credits: 69OzCanOfBepis, MagmaGuy"),
new ArrayList<>(),
new ArrayList<>(),
DiscordLinks.premiumMinidungeons,
DungeonPackagerConfigFields.DungeonSizeCategory.ADVENTURE,
"em_primis",
null,
World.Environment.NORMAL,
true,
new Vector(0, 0, 0),
new Vector(0, 0, 0),
new Vector(0, 0, 0),
0D,
0D,
0,
"Difficulty: &2Easy\n" +
"$bossCount bosses, from level $lowestTier to $highestTier\n" +
"&6A tutorial adventure for new players!",
"&8[EM] &6Primis awaits, strike the earth!",
"&8[EM] &6You have left Primis!");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public class MobPropertiesConfig {
new SuperMushroomCowConfig(),
new SuperPigConfig(),
new SuperSheepConfig(),
new EliteKillerBunnyConfig()
new EliteKillerBunnyConfig(),
new EliteLlamaConfig()
));

public static HashMap<EntityType, MobPropertiesConfigFields> getMobProperties() {
Expand All @@ -61,6 +62,9 @@ public static void addMobProperties(EntityType entityType, MobPropertiesConfigFi
}

public static void initializeConfigs() {
if (!VersionChecker.serverVersionOlderThan(17, 0)) {
mobPropertiesConfigFieldsList.add(new EliteGoatConfig());
}

if (!VersionChecker.serverVersionOlderThan(16, 0)) {
mobPropertiesConfigFieldsList.add(new EliteZombiefiedPiglin());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.magmaguy.elitemobs.config.mobproperties.premade;

import com.magmaguy.elitemobs.config.mobproperties.MobPropertiesConfigFields;
import org.bukkit.entity.EntityType;

import java.util.Arrays;

public class EliteGoatConfig extends MobPropertiesConfigFields {
public EliteGoatConfig(){
super("elite_goat",
EntityType.GOAT,
true,
"&fLvl &2$level &fElite &5Goat",
Arrays.asList("$player &cwas rammed by $entity&c!",
"$player &cwas run over by $entity&c!",
"$player &cwas trampled by $entity&c!",
"$player &cgot $entity&c horns!"),
3);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.magmaguy.elitemobs.config.mobproperties.premade;

import com.magmaguy.elitemobs.config.mobproperties.MobPropertiesConfigFields;
import org.bukkit.entity.EntityType;

import java.util.Arrays;

public class EliteLlamaConfig extends MobPropertiesConfigFields {
public EliteLlamaConfig(){
super("elite_llama",
EntityType.LLAMA,
true,
"&fLvl &2$level &fElite &5Llama",
Arrays.asList("$player &cwas spit on by $entity&c!",
"$player &cwas made $entity&c angry!"),
1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class NPCsConfigFields extends CustomConfigFields implements CustomConfig
@Getter
@Setter
private String customDisguiseData = null;
@Getter
@Setter
private String customModel = null;

public NPCsConfigFields(String fileName,
boolean isEnabled,
Expand Down Expand Up @@ -120,6 +123,7 @@ public void processConfigFields() {
this.questFilenames = processStringList("questFileName", questFilenames, new ArrayList<>(), false);
this.disguise = processString("disguise", disguise, null, false);
this.customDisguiseData = processString("customDisguiseData", customDisguiseData, null, false);
this.customModel = processString("customModel", customModel, null, false);
}

public void setEnabled(boolean enabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ private void worldButtonToggleBehavior(Player player) {
private void loadWorld(Player player) {
try {
world = MinidungeonWorldLoader.runtimeLoadWorld(this);
if (world == null){
player.sendMessage("Failed to get world " + this.dungeonPackagerConfigFields.getWorldName());
}
WorldGuardCompatibility.protectWorldMinidugeonArea(world.getSpawnLocation(), this);
player.teleport(world.getSpawnLocation());
player.sendMessage("Minidungeon " + dungeonPackagerConfigFields.getWorldName() +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.magmaguy.elitemobs.utils.InfoMessage;
import com.magmaguy.elitemobs.utils.WarningMessage;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.World;
import org.bukkit.WorldCreator;

Expand All @@ -27,11 +28,13 @@ public static World loadWorld(Minidungeon minidungeon) {
world.setKeepSpawnInMemory(false);
new InfoMessage("Minidungeons world " + minidungeon.getDungeonPackagerConfigFields().getWorldName() + " was loaded successfully!");
minidungeon.setInstalled(true);
world.setDifficulty(Difficulty.HARD);
//if (EliteMobs.worldGuardIsEnabled && minidungeon.dungeonPackagerConfigFields.isProtect())
// WorldGuardCompatibility.protectWorldMinidugeonArea(world.getSpawnLocation(), minidungeon);
return world;
} catch (Exception exception) {
new WarningMessage("Failed to load Minidungeon world " + minidungeon.getDungeonPackagerConfigFields().getWorldName() + " !");
exception.printStackTrace();
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.magmaguy.elitemobs.MetadataHandler;
import com.magmaguy.elitemobs.api.EliteMobHealEvent;
import com.magmaguy.elitemobs.api.internal.RemovalReason;
import com.magmaguy.elitemobs.collateralminecraftchanges.KeepPassivesAngry;
import com.magmaguy.elitemobs.collateralminecraftchanges.KeepNeutralsAngry;
import com.magmaguy.elitemobs.combatsystem.CombatSystem;
import com.magmaguy.elitemobs.combatsystem.antiexploit.AntiExploitMessage;
import com.magmaguy.elitemobs.config.AntiExploitConfig;
Expand All @@ -22,7 +22,6 @@
import com.magmaguy.elitemobs.powerstances.MajorPowerPowerStance;
import com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance;
import com.magmaguy.elitemobs.tagger.PersistentTagger;
import com.magmaguy.elitemobs.thirdparty.libsdisguises.DisguiseEntity;
import com.magmaguy.elitemobs.utils.EventCaller;
import com.magmaguy.elitemobs.utils.VersionChecker;
import com.magmaguy.elitemobs.utils.WarningMessage;
Expand Down Expand Up @@ -243,14 +242,26 @@ public void setLivingEntity(LivingEntity livingEntity, CreatureSpawnEvent.SpawnR
Wolf wolf = (Wolf) livingEntity;
wolf.setAngry(true);
wolf.setBreed(false);
KeepPassivesAngry.showMeYouWarFace(this);
KeepNeutralsAngry.showMeYouWarFace(this);
}

if (entityType.equals(EntityType.POLAR_BEAR)) {
KeepNeutralsAngry.showMeYouWarFace(this);
}

if (entityType.equals(EntityType.ENDER_DRAGON))
((EnderDragon) livingEntity).getBossBar().setTitle(getName());
Objects.requireNonNull(((EnderDragon) livingEntity).getBossBar()).setTitle(getName());

if (entityType.equals(EntityType.LLAMA)){
KeepNeutralsAngry.showMeYouWarFace(this);
}

if (!VersionChecker.serverVersionOlderThan(17, 0) && entityType.equals(EntityType.GOAT)) {
((Goat) livingEntity).setScreaming(true);
}

if (!VersionChecker.serverVersionOlderThan(15, 0) && livingEntity instanceof Bee) {
KeepPassivesAngry.showMeYouWarFace(this);
KeepNeutralsAngry.showMeYouWarFace(this);
((Bee) livingEntity).setCannotEnterHiveTicks(Integer.MAX_VALUE);
}
this.spawnReason = spawnReason;
Expand All @@ -275,8 +286,6 @@ public void setNameVisible(boolean isVisible) {
//Check if the boss is already dead
if (livingEntity == null) return;
livingEntity.setCustomNameVisible(isVisible);
if (isCustomBossEntity())
DisguiseEntity.setDisguiseNameVisibility(isVisible, livingEntity);
}

private void setMaxHealth() {
Expand Down Expand Up @@ -418,11 +427,7 @@ public void randomizePowers(EliteMobProperties eliteMobProperties) {
}

public void applyPowers(HashSet<ElitePower> elitePowers, int availablePowerAmount) {
for (Iterator<ElitePower> elitePowerIterator = elitePowers.iterator(); elitePowerIterator.hasNext(); ) {
ElitePower elitePower = elitePowerIterator.next();
if (!PowersConfig.getPower(elitePower.getFileName()).isEnabled())
elitePowerIterator.remove();
}
elitePowers.removeIf(elitePower -> !PowersConfig.getPower(elitePower.getFileName()).isEnabled());

if (availablePowerAmount < 1) return;

Expand Down
Loading

0 comments on commit 4231110

Please sign in to comment.