mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Support for new MythicMobs4 API
This commit is contained in:
parent
e7b52d2ecf
commit
4d461584c6
@ -6,9 +6,10 @@
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/mcMMO#127.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/CoreProtect_2.12.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/CheckMyInventory/lib/spigot-1.11.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Residence/lib/iConomy7.0.6.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Residence/lib/worldedit-bukkit-6.1.1-SNAPSHOT-dist.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/craftconomy3-3.3.1-20160221.070622-13.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-4.1.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
||||
|
@ -40,6 +40,10 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.gamingmesh.jobs.Gui.GuiManager;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobInterface;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs2;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs2Listener;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs4;
|
||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.api.JobsExpGainEvent;
|
||||
import com.gamingmesh.jobs.commands.JobsCommands;
|
||||
@ -77,10 +81,10 @@ import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.listeners.JobsListener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
import com.gamingmesh.jobs.listeners.McMMOlistener;
|
||||
import com.gamingmesh.jobs.listeners.MythicMobsListener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.selection.SelectionManager;
|
||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.JobsClassLoader;
|
||||
import com.gamingmesh.jobs.stuff.Loging;
|
||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||
@ -111,7 +115,7 @@ public class Jobs extends JavaPlugin {
|
||||
private static PistonProtectionListener PistonProtectionListener = null;
|
||||
private static McMMOlistener McMMOlistener = null;
|
||||
|
||||
private static MythicMobsListener MythicManager;
|
||||
private static MythicMobInterface MythicManager;
|
||||
|
||||
private static ConfigManager configManager;
|
||||
private static GeneralConfigManager GconfigManager;
|
||||
@ -159,10 +163,22 @@ public class Jobs extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void setMythicManager() {
|
||||
MythicManager = new MythicMobsListener(this);
|
||||
try {
|
||||
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
|
||||
Debug.D("one");
|
||||
MythicManager = new MythicMobs2(this);
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
||||
Debug.D("two");
|
||||
MythicManager = new MythicMobs4(this);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MythicMobsListener getMythicManager() {
|
||||
public static MythicMobInterface getMythicManager() {
|
||||
return MythicManager;
|
||||
}
|
||||
|
||||
@ -732,7 +748,7 @@ public class Jobs extends JavaPlugin {
|
||||
|
||||
setMythicManager();
|
||||
if (MythicManager.Check() && GconfigManager.MythicMobsEnabled) {
|
||||
getServer().getPluginManager().registerEvents(MythicManager, this);
|
||||
MythicManager.registerListener();
|
||||
}
|
||||
|
||||
setPistonProtectionListener();
|
||||
|
13
com/gamingmesh/jobs/MythicMobs/MythicMobInterface.java
Normal file
13
com/gamingmesh/jobs/MythicMobs/MythicMobInterface.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public interface MythicMobInterface {
|
||||
|
||||
boolean Check();
|
||||
|
||||
boolean isMythicMob(LivingEntity lVictim);
|
||||
|
||||
void registerListener();
|
||||
|
||||
}
|
57
com/gamingmesh/jobs/MythicMobs/MythicMobs2.java
Normal file
57
com/gamingmesh/jobs/MythicMobs/MythicMobs2.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
|
||||
import net.elseland.xikage.MythicMobs.MythicMobs;
|
||||
import net.elseland.xikage.MythicMobs.API.MythicMobsAPI;
|
||||
|
||||
public class MythicMobs2 implements MythicMobInterface {
|
||||
|
||||
public MythicMobsAPI MMAPI = null;
|
||||
private Jobs plugin;
|
||||
|
||||
public MythicMobs2(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerListener() {
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new MythicMobs2Listener(plugin), plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMythicMob(LivingEntity lVictim) {
|
||||
if (MMAPI.getMobAPI().isMythicMob(lVictim))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean Check() {
|
||||
Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs");
|
||||
if (mm == null)
|
||||
return false;
|
||||
|
||||
try {
|
||||
Class.forName("net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent");
|
||||
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
|
||||
Class.forName("net.elseland.xikage.MythicMobs.Mobs.MythicMob");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Disabling
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
"&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."));
|
||||
return false;
|
||||
}
|
||||
|
||||
MMAPI = ((MythicMobs) mm).getAPI();
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MythicMobs2 was found - Enabling capabilities."));
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package com.gamingmesh.jobs.listeners;
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -9,23 +7,18 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.MMKillInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import net.elseland.xikage.MythicMobs.MythicMobs;
|
||||
import net.elseland.xikage.MythicMobs.API.MythicMobsAPI;
|
||||
import net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent;
|
||||
import net.elseland.xikage.MythicMobs.Mobs.MythicMob;
|
||||
|
||||
public class MythicMobsListener implements Listener {
|
||||
public class MythicMobs2Listener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
public MythicMobsAPI MMAPI = null;
|
||||
|
||||
public MythicMobsListener(Jobs plugin) {
|
||||
public MythicMobs2Listener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@ -73,25 +66,5 @@ public class MythicMobsListener implements Listener {
|
||||
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
|
||||
}
|
||||
|
||||
public boolean Check() {
|
||||
Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs");
|
||||
if (mm == null)
|
||||
return false;
|
||||
|
||||
try {
|
||||
Class.forName("net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent");
|
||||
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
|
||||
Class.forName("net.elseland.xikage.MythicMobs.Mobs.MythicMob");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Disabling
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
"&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."));
|
||||
return false;
|
||||
}
|
||||
|
||||
MMAPI = ((MythicMobs) mm).getAPI();
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MythicMobs was found - Enabling capabilities."));
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
57
com/gamingmesh/jobs/MythicMobs/MythicMobs4.java
Normal file
57
com/gamingmesh/jobs/MythicMobs/MythicMobs4.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper;
|
||||
|
||||
public class MythicMobs4 implements MythicMobInterface {
|
||||
|
||||
public BukkitAPIHelper MMAPI = null;
|
||||
private Jobs plugin;
|
||||
|
||||
public MythicMobs4(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerListener() {
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new MythicMobs4Listener(plugin), plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMythicMob(LivingEntity lVictim) {
|
||||
if (MMAPI.isMythicMob(lVictim))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean Check() {
|
||||
Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs");
|
||||
if (mm == null)
|
||||
return false;
|
||||
|
||||
try {
|
||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent");
|
||||
Class.forName("io.lumine.xikage.mythicmobs.mobs.MythicMob");
|
||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
||||
Class.forName("io.lumine.xikage.mythicmobs.MythicMobs");
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Disabling
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
"&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support."));
|
||||
return false;
|
||||
}
|
||||
|
||||
MMAPI = ((MythicMobs) mm).getAPIHelper();
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MythicMobs4 was found - Enabling capabilities."));
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
71
com/gamingmesh/jobs/MythicMobs/MythicMobs4Listener.java
Normal file
71
com/gamingmesh/jobs/MythicMobs/MythicMobs4Listener.java
Normal file
@ -0,0 +1,71 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
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 io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
|
||||
|
||||
public class MythicMobs4Listener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
|
||||
public MythicMobs4Listener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnMythicMobDeath(MythicMobDeathEvent event) {
|
||||
//disabling plugin in world
|
||||
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
// Entity that died must be living
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
MythicMob lVictim = event.getMobType();
|
||||
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
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 (pDamager.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative())
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// pay
|
||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
|
||||
|
||||
if (jDamager == null)
|
||||
return;
|
||||
|
||||
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -196,7 +196,6 @@ public class NameTranslatorManager {
|
||||
f = new File(plugin.getDataFolder(), "TranslatableWords" + File.separator + "Words_" + lang + ".yml");
|
||||
}
|
||||
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(lang + " " + (f.length() / 1024));
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
|
||||
CommentedYamlConfiguration writer = new CommentedYamlConfiguration();
|
||||
|
||||
|
2
com/gamingmesh/jobs/listeners/.gitignore
vendored
2
com/gamingmesh/jobs/listeners/.gitignore
vendored
@ -11,3 +11,5 @@
|
||||
/JobsListener$3.class
|
||||
/JobsListener$4.class
|
||||
/McMMOlistener$Skill.class
|
||||
/MythicMobsListener2.class
|
||||
/MythicMobs2Listener.class
|
||||
|
@ -835,8 +835,8 @@ public class JobsPaymentListener implements Listener {
|
||||
if (e.getDamager().hasMetadata("NPC"))
|
||||
return;
|
||||
|
||||
if (Jobs.getGCManager().MythicMobsEnabled && Jobs.getMythicManager().MMAPI != null) {
|
||||
if (Jobs.getMythicManager().MMAPI.getMobAPI().isMythicMob(lVictim))
|
||||
if (Jobs.getGCManager().MythicMobsEnabled && Jobs.getMythicManager() != null) {
|
||||
if (Jobs.getMythicManager().isMythicMob(lVictim))
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user