diff --git a/pom.xml b/pom.xml
index 15c2c5c4..42f13d59 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
Jobs
jobs
- 5.0.1.4
+ 5.0.2.1
Jobs
http://maven.apache.org
@@ -77,9 +77,15 @@
io.lumine.xikage
MythicMobs
- 4.9.1
+ 4.11.0
provided
+
+ io.lumine
+ Mythic-Dist
+ 5.0.1-SNAPSHOT
+ provided
+
com.sk89q
@@ -191,7 +197,7 @@
CMILib
latest
system
- ${basedir}/libs/CMILib1.1.0.2.jar
+ ${basedir}/libs/CMILib1.1.2.3.jar
diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java
index ede083c0..4a36e80f 100644
--- a/src/main/java/com/gamingmesh/jobs/Jobs.java
+++ b/src/main/java/com/gamingmesh/jobs/Jobs.java
@@ -92,7 +92,6 @@ import com.gamingmesh.jobs.economy.BufferedEconomy;
import com.gamingmesh.jobs.economy.BufferedPayment;
import com.gamingmesh.jobs.economy.Economy;
import com.gamingmesh.jobs.economy.PaymentData;
-import com.gamingmesh.jobs.economy.PointsData;
import com.gamingmesh.jobs.hooks.HookManager;
import com.gamingmesh.jobs.i18n.Language;
import com.gamingmesh.jobs.listeners.JobsListener;
diff --git a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java
index 2cfd4e4c..13152a3a 100644
--- a/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java
+++ b/src/main/java/com/gamingmesh/jobs/hooks/HookManager.java
@@ -10,10 +10,13 @@ import com.gamingmesh.jobs.hooks.McMMO.McMMOManager;
import com.gamingmesh.jobs.hooks.MyPet.MyPetManager;
import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobInterface;
import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs4;
+import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs5;
import com.gamingmesh.jobs.hooks.WorldGuard.WorldGuardManager;
import com.gamingmesh.jobs.hooks.stackMob.StackMobHandler;
import com.gamingmesh.jobs.hooks.wildStacker.WildStackerHandler;
+import net.Zrips.CMILib.Logs.CMIDebug;
+
public class HookManager {
private static McMMOManager McMMOManager;
@@ -39,8 +42,9 @@ public class HookManager {
setStackMobHandler();
setWildStackerHandler();
- if (checkMythicMobs())
+ if (checkMythicMobs()) {
MythicManager.registerListener();
+ }
}
public static StackMobHandler getStackMobHandler() {
@@ -59,7 +63,7 @@ public class HookManager {
return wildStackerHandler;
}
- public static MyPetManager getMyPetManager() {
+ public static MyPetManager getMyPetManager() {
if (myPetManager == null) {
setMyPetManager();
}
@@ -82,7 +86,7 @@ public class HookManager {
return McMMOManager;
}
- public static MythicMobInterface getMythicManager() {
+ public static MythicMobInterface getMythicManager() {
return MythicManager;
}
@@ -101,18 +105,22 @@ public class HookManager {
}
private static void setMythicManager() {
- if (!JobsHook.MythicMobs.isEnabled())
+ if (!JobsHook.MythicMobs.isPresent())
return;
try {
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
MythicManager = new MythicMobs4(PLUGIN);
+ Jobs.consoleMsg("&e[Jobs] MythicMobs 4.x detected.");
} catch (ClassNotFoundException ex) {
- Jobs.consoleMsg("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+");
- return;
+ try {
+ Class.forName("io.lumine.mythic.bukkit.BukkitAPIHelper");
+ MythicManager = new MythicMobs5(PLUGIN);
+ Jobs.consoleMsg("&e[Jobs] MythicMobs 5.x detected.");
+ } catch (ClassNotFoundException e) {
+ Jobs.consoleMsg("&cYour MythicMobs version is not supported by Jobs! Supported versions: 4.9.1+");
+ }
}
-
- Jobs.consoleMsg("&e[Jobs] MythicMobs detected.");
}
public static void setMcMMOlistener() {
diff --git a/src/main/java/com/gamingmesh/jobs/hooks/JobsHook.java b/src/main/java/com/gamingmesh/jobs/hooks/JobsHook.java
index 51432c15..11640804 100644
--- a/src/main/java/com/gamingmesh/jobs/hooks/JobsHook.java
+++ b/src/main/java/com/gamingmesh/jobs/hooks/JobsHook.java
@@ -13,6 +13,7 @@ public enum JobsHook {
mcMMO;
private Boolean enabled;
+ private Boolean present;
public boolean isEnabled() {
if (enabled == null) {
@@ -21,4 +22,12 @@ public enum JobsHook {
return enabled;
}
+
+ public boolean isPresent() {
+ if (present == null) {
+ present = JavaPlugin.getPlugin(Jobs.class).getServer().getPluginManager().getPlugin(name()) != null;
+ }
+
+ return present;
+ }
}
diff --git a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5.java b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5.java
new file mode 100644
index 00000000..b842ab2d
--- /dev/null
+++ b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5.java
@@ -0,0 +1,78 @@
+package com.gamingmesh.jobs.hooks.MythicMobs;
+
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.plugin.Plugin;
+
+import com.gamingmesh.jobs.Jobs;
+
+import io.lumine.mythic.api.mobs.MythicMob;
+import io.lumine.mythic.bukkit.BukkitAPIHelper;
+import io.lumine.mythic.bukkit.MythicBukkit;
+
+//import io.lumine.xikage.mythicmobs.MythicMobs;
+//import io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper;
+//import io.lumine.xikage.mythicmobs.mobs.MythicMob;
+
+public class MythicMobs5 implements MythicMobInterface {
+
+ public BukkitAPIHelper apiHelper;
+ private Jobs plugin;
+
+ public MythicMobs5(Jobs plugin) {
+ this.plugin = plugin;
+ }
+
+ @Override
+ public void registerListener() {
+ plugin.getServer().getPluginManager().registerEvents(new MythicMobs5Listener(), plugin);
+ }
+
+ @Override
+ public boolean isMythicMob(LivingEntity lVictim) {
+ return apiHelper != null && lVictim != null && apiHelper.isMythicMob(lVictim);
+ }
+
+ @Override
+ public boolean check() {
+ Plugin mm = plugin.getServer().getPluginManager().getPlugin("MythicMobs");
+ if (mm == null)
+ return false;
+
+ try {
+ Class.forName("io.lumine.mythic.api.mobs.MythicMob");
+ Class.forName("io.lumine.mythic.bukkit.BukkitAPIHelper");
+ Class.forName("io.lumine.mythic.bukkit.events.MythicMobDeathEvent");
+ } catch (ClassNotFoundException e) {
+ // Disabling
+ Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support.");
+ return false;
+ }
+
+ apiHelper = ((MythicBukkit) mm).getAPIHelper();
+ Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - Enabling capabilities.");
+ return true;
+ }
+
+ static boolean failed = false;
+
+ @Override
+ public String getDisplayName(String id) {
+ if (failed || apiHelper == null)
+ return "";
+
+ MythicMob mm = apiHelper.getMythicMob(id);
+ try {
+ if (mm != null && mm.getDisplayName() != null)
+ return mm.getDisplayName().toString();
+ } catch (Throwable e) {
+ if (!failed) {
+ failed = true;
+ e.printStackTrace();
+ Jobs.consoleMsg("&cEncountered error when checking MythicMob entity name. Support for mythicMobs will be suspended for time beying. Please report this issue.");
+ }
+ }
+
+ return "";
+ }
+
+}
diff --git a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5Listener.java b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5Listener.java
new file mode 100644
index 00000000..d9269778
--- /dev/null
+++ b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5Listener.java
@@ -0,0 +1,61 @@
+package com.gamingmesh.jobs.hooks.MythicMobs;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import com.gamingmesh.jobs.Jobs;
+import com.gamingmesh.jobs.actions.MMKillInfo;
+import com.gamingmesh.jobs.container.ActionType;
+import com.gamingmesh.jobs.container.JobsPlayer;
+import com.gamingmesh.jobs.listeners.JobsPaymentListener;
+
+import io.lumine.mythic.api.mobs.MythicMob;
+import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
+
+public final class MythicMobs5Listener implements Listener {
+
+ @EventHandler
+ public void onMythicMobDeath(MythicMobDeathEvent event) {
+ // Entity that died must be living
+ if (!(event.getEntity() instanceof LivingEntity))
+ return;
+
+ if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
+ return;
+
+ Player pDamager = null;
+
+ // Checking if killer is player
+ Entity ent = null;
+ if (event.getKiller() instanceof Player)
+ pDamager = (Player) event.getKiller();
+ // Checking if killer is tamed animal
+ else if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
+ ent = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
+ } else
+ return;
+
+ if (pDamager == null)
+ return;
+
+ // check if in creative
+ if (!JobsPaymentListener.payIfCreative(pDamager))
+ return;
+
+ if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
+ return;
+
+ JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
+ if (jDamager == null)
+ return;
+
+ // pay
+ MythicMob lVictim = event.getMobType();
+ if (lVictim != null) {
+ Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
+ }
+ }
+}