Skip to content

Commit

Permalink
EliteMobs 8.7.0
Browse files Browse the repository at this point in the history
- [New] Added FreeMinecraftModels as a drop-in replacement for ModelEngine! ModelEngine R3 will still work for now, but support will be dropped in the future
- [New] Arenas are now able to spawn Mythic Mobs as wave bosses!
- [New] Added the elitemobs-explosion-block-damage flag, which when denied makes fireballs still do damage but not damage the terrain
- [Fix/Revert] Fixed issue where players couldn't pick up elite currency. This reverts a previous compatibility fix for plugins that change item pickup behavior
- [Fix] Fireballs now do damage correctly when appropriate
- [Fix] Custom boss spawn with level command will now work correctly for bosses with a dynamic level
- [Tweak] Remove command stops removing if you relog
- [Tweak] Thoroughly optimized the PlasmaBlaster power based on feedback
- ...and more

Signed-off-by: MagmaGuy <tiagoarnaut@gmail.com>
  • Loading branch information
MagmaGuy committed Nov 27, 2023
1 parent beb9328 commit 3cc1e5f
Show file tree
Hide file tree
Showing 44 changed files with 605 additions and 210 deletions.
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ dependencies {
//Model Engine
compileOnly "com.ticxo.modelengine:api:R3.1.7"

implementation group: 'com.magmaguy', name: 'EasyMinecraftGoals-dist', version: '1.6.1'
//Advanced AI goals
implementation group: 'com.magmaguy', name: 'EasyMinecraftGoals-dist', version: '1.7.0'

//Local test, you can ignore this
//implementation files('C:\\Users\\Tiago\\Documents\\MineCraftProjects\\EasyMinecraftGoals\\EasyMinecraftGoals\\dist\\target\\EasyMinecraftGoals-dist-1.6.0-shaded.jar')
//Free Minecraft Models
compileOnly group: 'com.magmaguy', name: 'FreeMinecraftModels', version: '1.1.0-SNAPSHOT'

// Mythic Mobs integration
compileOnly group: 'io.lumine', name: 'Mythic-Dist', version: '5.3.5'
}

artifacts { // task 'build' runs generates uberjar
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/magmaguy/elitemobs/EliteMobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@
import com.magmaguy.elitemobs.quests.DynamicQuest;
import com.magmaguy.elitemobs.quests.QuestTracking;
import com.magmaguy.elitemobs.thirdparty.bstats.CustomCharts;
import com.magmaguy.elitemobs.thirdparty.custommodels.CustomModel;
import com.magmaguy.elitemobs.thirdparty.custommodels.modelengine.ModelEngineReservedAddresses;
import com.magmaguy.elitemobs.thirdparty.libsdisguises.DisguiseEntity;
import com.magmaguy.elitemobs.thirdparty.modelengine.ModelEngineReservedAddresses;
import com.magmaguy.elitemobs.thirdparty.placeholderapi.Placeholders;
import com.magmaguy.elitemobs.thirdparty.worldguard.WorldGuardCompatibility;
import com.magmaguy.elitemobs.treasurechest.TreasureChest;
Expand Down Expand Up @@ -171,6 +172,8 @@ public void onEnable() {

if (Bukkit.getPluginManager().isPluginEnabled("LibsDisguises")) DisguiseEntity.initialize();

//Initializes custom models
CustomModel.initialize();
//Reserves ModelEngine addresses if present
ModelEngineReservedAddresses.reserve();

Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/magmaguy/elitemobs/EventsRegistrer.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
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.CustomModel;
import com.magmaguy.elitemobs.thirdparty.custommodels.CustomModel;
import com.magmaguy.elitemobs.thirdparty.worldguard.WorldGuardDungeonFlag;
import com.magmaguy.elitemobs.thirdparty.worldguard.WorldGuardEliteMobOnlySpawnFlag;
import com.magmaguy.elitemobs.thirdparty.worldguard.WorldGuardExplosionBlockDamageFlag;
import com.magmaguy.elitemobs.thirdparty.worldguard.WorldGuardSpawnEventBypasser;
import com.magmaguy.elitemobs.treasurechest.TreasureChest;
import com.magmaguy.elitemobs.versionnotifier.VersionChecker;
Expand Down Expand Up @@ -362,9 +363,12 @@ public static void registerEvents() {
register(new NPCProximitySensor());
register(new NPCEntity.NPCEntityEvents());
register(new FindNewWorlds());
register(new WorldGuardSpawnEventBypasser());
register(new WorldGuardEliteMobOnlySpawnFlag());
register(new WorldGuardDungeonFlag());
if (EliteMobs.worldGuardIsEnabled) {
register(new WorldGuardSpawnEventBypasser());
register(new WorldGuardEliteMobOnlySpawnFlag());
register(new WorldGuardDungeonFlag());
register(new WorldGuardExplosionBlockDamageFlag());
}

register(new EntityTransformHandler());
register(new EliteBlazeWaterDamagePrevention());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ else if (event.getCause().equals(EntityDamageEvent.DamageCause.PROJECTILE))
eliteEntity.syncPluginHealth(((LivingEntity) event.getEntity()).getHealth());

//No antiexploit checks for dungeons
if (!(EliteMobs.worldGuardIsEnabled && !WorldGuardFlagChecker.checkFlag(eliteEntity.getLocation(), WorldGuardCompatibility.getEliteMobsAntiExploitFlag())) && event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK) && !eliteEntity.isInAntiExploitCooldown() && eliteEntity.getLivingEntity() != null)
if (!(EliteMobs.worldGuardIsEnabled && !WorldGuardFlagChecker.checkFlag(eliteEntity.getLocation(), WorldGuardCompatibility.getELITEMOBS_ANTIEXPLOIT())) && event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK) && !eliteEntity.isInAntiExploitCooldown() && eliteEntity.getLivingEntity() != null)
Bukkit.getServer().getPluginManager().callEvent(new EliteMobDamagedByPlayerAntiExploitEvent(eliteEntity, eliteMobDamagedByPlayerEvent));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void onEntityDamagedEvent(EntityDamageEvent event) {
if (!eliteEntity.isValid()) return;

if (EliteMobs.worldGuardIsEnabled && !WorldGuardFlagChecker.checkFlag(eliteEntity.getLivingEntity().getLocation(),
WorldGuardCompatibility.getEliteMobsAntiExploitFlag()))
WorldGuardCompatibility.getELITEMOBS_ANTIEXPLOIT()))
return;

Bukkit.getServer().getPluginManager().callEvent(new GenericAntiExploitEvent(eliteEntity, event));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public void onEliteMobDamage(PlayerDamagedByEliteMobEvent event) {
@EventHandler(ignoreCancelled = true)
public void onEliteMobTarget(EliteMobTargetPlayerEvent event) {
if (event.getEliteMobEntity().isInCombat()) return;
if (!(event.getEliteMobEntity().getLivingEntity() instanceof Mob)) return;
Bukkit.getServer().getPluginManager().callEvent(new EliteMobEnterCombatEvent(event.getEliteMobEntity(), event.getPlayer()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private static double eliteToPlayerDamageFormula(Player player, EliteEntity elit
finalDamage = Math.max(baseDamage + bonusDamage - damageReduction - potionEffectDamageReduction, 1) *
customBossDamageMultiplier * specialMultiplier * MobCombatSettingsConfig.getNormalizedDamageToPlayerMultiplier();
else
finalDamage= Math.max(baseDamage + bonusDamage - damageReduction - potionEffectDamageReduction, 1) *
finalDamage = Math.max(baseDamage + bonusDamage - damageReduction - potionEffectDamageReduction, 1) *
customBossDamageMultiplier * specialMultiplier * MobCombatSettingsConfig.getDamageToPlayerMultiplier();

if (specialMultiplier != 1) specialMultiplier = 1;
Expand All @@ -156,7 +156,8 @@ private void explosionEvent(EntityExplodeEvent event) {
public void onEliteDamagePlayer(EntityDamageByEntityEvent event) {
if (event.isCancelled()) {
bypass = false;
return;
if (!(event.getDamager() instanceof Explosive))
return;
}
if (!(event.getEntity() instanceof Player player)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -39,6 +40,11 @@ public static void remove(Player player) {
}

public static class RemoveCommandEvents implements Listener {
@EventHandler (ignoreCancelled = true)
public void quitEvent(PlayerQuitEvent event) {
removingPlayers.remove(event.getPlayer().getUniqueId());
}

@EventHandler(priority = EventPriority.LOWEST)
public void removeEliteEntity(EntityDamageByEntityEvent event) {
if (!removingPlayers.contains(event.getDamager().getUniqueId())) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.magmaguy.elitemobs.ChatColorConverter;
import com.magmaguy.elitemobs.MetadataHandler;
import com.magmaguy.elitemobs.thirdparty.custommodels.CustomModel;
import com.magmaguy.elitemobs.utils.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -44,42 +44,28 @@ public static void initializeConfigs() {
}

public static void createResourcePack(CommandSender commandSender) {
if (!Bukkit.getPluginManager().isPluginEnabled("ModelEngine")) {
if (!CustomModel.isUsingModels()) {
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&c Could not generate resource pack because ModelEngine is not installed! Install ModelEngine to use this feature."));
return;
}

File modelEngineResourcePackFile = new File(MetadataHandler.PLUGIN.getDataFolder().getParentFile().toString() + File.separatorChar + "ModelEngine" + File.separatorChar + "resource pack");
if (!modelEngineResourcePackFile.exists()) {
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&c Could not generate resource pack because ModelEngine is not installed! Install ModelEngine to use this feature."));
return;
}


try {
if (!Paths.get(MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack").toFile().exists())
Files.createDirectory(Paths.get(MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack"));
} catch (Exception ex) {
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&c Failed to generate target directory plugins/EliteMobs/exports/elitemobs_resource_pack required for storing the resource pack! Report this to the dev!"));
return;
if (CustomModel.getModelPlugin() == CustomModel.ModelPlugin.FREE_MINECRAFT_MODELS) {
copyResourcePack(commandSender, "FreeMinecraftModels", "output");
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&f Copied all files from Free Minecraft Models to " + MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack"));
} else {
copyResourcePack(commandSender, "ModelEngine", "resource pack");
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&f Copied all files from Model Engine to " + MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack"));
}

copyDirectory(modelEngineResourcePackFile, Paths.get(MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack"));
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&f Copied all files from Model Engine to " + MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack"));

if (ZipFile.zip(new File(MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack"),
MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack.zip"))
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&f Packaged texture pack into " +
MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack.zip") +
" , ready to distribute!");
if (ZipFile.zip(new File(MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack"), MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack.zip"))
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&f Packaged texture pack into " + MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack.zip") + " , ready to distribute!");
else {
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&c Failed to package the resource pack into a zipped file! Report this to the dev!"));
return;
}

if (commandSender instanceof Player) {
((Player) commandSender).spigot().sendMessage(SpigotMessage.commandHoverMessage(ChatColorConverter.convert("Done! &2You can click here to update your server.properties with the new SHA1 value of this texture pack!"),
"Click runs the /em updateresourcepack command!", "/em updateresourcepack"));
((Player) commandSender).spigot().sendMessage(SpigotMessage.commandHoverMessage(ChatColorConverter.convert("Done! &2You can click here to update your server.properties with the new SHA1 value of this texture pack!"), "Click runs the /em updateresourcepack command!", "/em updateresourcepack"));
commandSender.sendMessage("If you want to do it manually, your SHA1 code is " + generateResourcePackSHA1(commandSender));
} else {
commandSender.sendMessage("Done! You can run the command /em updateresourcepack in order to put the right SHA1 value into server.properties. Don't forget to upload the texture place to some place where players can get it!");
Expand All @@ -88,6 +74,25 @@ public static void createResourcePack(CommandSender commandSender) {

}

private static void copyResourcePack(CommandSender commandSender, String pluginDirectoryName, String resourcePackFolderName) {
File originalResourcePackFile = new File(MetadataHandler.PLUGIN.getDataFolder().getParentFile().toString() + File.separatorChar + pluginDirectoryName + File.separatorChar + resourcePackFolderName);
if (!originalResourcePackFile.exists()) {
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&c Could not generate resource pack because ModelEngine is not installed! Install ModelEngine to use this feature."));
return;
}


try {
if (!Paths.get(MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack").toFile().exists())
Files.createDirectory(Paths.get(MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack"));
} catch (Exception ex) {
commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs]&c Failed to generate target directory plugins/EliteMobs/exports/elitemobs_resource_pack required for storing the resource pack! Report this to the dev!"));
return;
}

copyDirectory(originalResourcePackFile, Paths.get(MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack"));
}

private static String generateResourcePackSHA1(CommandSender commandSender) {
File zippedResourcePack = Paths.get(MetadataHandler.PLUGIN.getDataFolder() + "" + File.separatorChar + "exports" + File.separatorChar + "elitemobs_resource_pack.zip").toFile();
if (!zippedResourcePack.exists()) {
Expand Down Expand Up @@ -115,8 +120,7 @@ public static String sha1Code(File file) throws IOException, NoSuchAlgorithmExce
DigestInputStream digestInputStream = new DigestInputStream(fileInputStream, digest);
byte[] bytes = new byte[1024];
// read all file content
while (digestInputStream.read(bytes) > 0)
digest = digestInputStream.getMessageDigest();
while (digestInputStream.read(bytes) > 0) digest = digestInputStream.getMessageDigest();
byte[] resultByteArry = digest.digest();
return bytesToHexString(resultByteArry);
}
Expand Down Expand Up @@ -154,12 +158,10 @@ private static void copyFile(File file, Path targetPath) {
for (File iteratedFile : file.listFiles())
copyFile(iteratedFile, Paths.get(targetPath + "" + File.separatorChar + file.getName()));
} else {
if (!Paths.get(targetPath + "" + File.separatorChar + file.getName()).toFile().exists() ||
!targetPath.toString().contains("pack.png") && !targetPath.toString().contains("pack.mcmeta")) {
if (!Paths.get(targetPath + "" + File.separatorChar + file.getName()).toFile().exists() || !targetPath.toString().contains("pack.png") && !targetPath.toString().contains("pack.mcmeta")) {
if (!targetPath.toFile().exists()) targetPath.toFile().mkdirs();
Files.copy(file.toPath(), Paths.get(targetPath + "" + File.separatorChar + file.getName()), StandardCopyOption.REPLACE_EXISTING);
}
else
} else
new InfoMessage("File " + targetPath + "" + File.separatorChar + file.getName() + " already existed and should not be overwritten, skipping!");
}
} catch (Exception exception) {
Expand Down Expand Up @@ -187,8 +189,7 @@ public static void overwriteSHA1(CommandSender commandSender) {
if (ServerPropertiesModifier.modify(commandSender, "resource-pack-sha1", sha1)) {

commandSender.sendMessage(ChatColor.GREEN + "[EliteMobs] Successfully set the value resource-pack-sha1=" + sha1 + " in server.properties!");
commandSender.sendMessage(ChatColor.RED + "[EliteMobs] Don't forget to update the downloadable resource pack at your online location of choice!" +
" If you don't update the version people download things won't work correctly!");
commandSender.sendMessage(ChatColor.RED + "[EliteMobs] Don't forget to update the downloadable resource pack at your online location of choice!" + " If you don't update the version people download things won't work correctly!");
commandSender.sendMessage(ChatColor.GREEN + "[EliteMobs] The server.properties modification will work starting with the next restart!");
} else {
commandSender.sendMessage(ChatColor.RED + "[EliteMobs] Failed to write SHA1 value! You will have to add this manually. For reference, you SHA1 value is " + sha1);
Expand Down
Loading

0 comments on commit 3cc1e5f

Please sign in to comment.