mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
Reworked the initialization of dependencies
This commit is contained in:
parent
066c0dd2b6
commit
0b43b7e91a
Binary file not shown.
@ -24,18 +24,17 @@ import com.gamingmesh.jobs.CMILib.Reflections;
|
||||
import com.gamingmesh.jobs.CMILib.VersionChecker;
|
||||
import com.gamingmesh.jobs.CMILib.VersionChecker.Version;
|
||||
import com.gamingmesh.jobs.Gui.GuiManager;
|
||||
import com.gamingmesh.jobs.McMMO.McMMO1_X_listener;
|
||||
import com.gamingmesh.jobs.McMMO.McMMO2_X_listener;
|
||||
import com.gamingmesh.jobs.McMMO.McMMOManager;
|
||||
import com.gamingmesh.jobs.MyPet.MyPetManager;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobInterface;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs2;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs4;
|
||||
import com.gamingmesh.jobs.Placeholders.NewPlaceholderAPIHook;
|
||||
import com.gamingmesh.jobs.Placeholders.Placeholder;
|
||||
import com.gamingmesh.jobs.Placeholders.PlaceholderAPIHook;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
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.MythicMobs2;
|
||||
import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs4;
|
||||
import com.gamingmesh.jobs.hooks.WorldGuard.WorldGuardManager;
|
||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.WorldGuard.WorldGuardManager;
|
||||
import com.gamingmesh.jobs.api.JobsExpGainEvent;
|
||||
import com.gamingmesh.jobs.api.JobsPrePaymentEvent;
|
||||
import com.gamingmesh.jobs.commands.JobsCommands;
|
||||
@ -63,7 +62,6 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
@ -73,7 +71,9 @@ import java.util.Map.Entry;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Jobs extends JavaPlugin {
|
||||
|
||||
private static String version = "";
|
||||
|
||||
private static PlayerManager pManager = null;
|
||||
private static JobsCommands cManager = null;
|
||||
private static Language lManager = null;
|
||||
@ -91,14 +91,17 @@ public class Jobs extends JavaPlugin {
|
||||
private static ShopManager shopManager = null;
|
||||
private static Loging loging = null;
|
||||
private static BlockProtectionManager BpManager = null;
|
||||
|
||||
private static JobsManager DBManager = null;
|
||||
|
||||
private static PistonProtectionListener PistonProtectionListener = null;
|
||||
private static McMMOManager McMMOManager = null;
|
||||
|
||||
@Deprecated
|
||||
private static McMMOManager McMMOManager = null;
|
||||
@Deprecated
|
||||
private static MythicMobInterface MythicManager = null;
|
||||
@Deprecated
|
||||
private static MyPetManager myPetManager = null;
|
||||
@Deprecated
|
||||
private static WorldGuardManager worldGuardManager = null;
|
||||
|
||||
private static ConfigManager configManager = null;
|
||||
@ -136,17 +139,7 @@ public class Jobs extends JavaPlugin {
|
||||
|
||||
private static PointsData pointsDatabase = null;
|
||||
|
||||
private void setMcMMOlistener() {
|
||||
try {
|
||||
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
|
||||
getServer().getPluginManager().registerEvents(new McMMO2_X_listener(this), this);
|
||||
consoleMsg("&e[Jobs] Registered McMMO 2.x listener");
|
||||
} catch (ClassNotFoundException e) {
|
||||
getServer().getPluginManager().registerEvents(new McMMO1_X_listener(this), this);
|
||||
consoleMsg("&e[Jobs] Registered McMMO 1.x listener");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static McMMOManager getMcMMOManager() {
|
||||
if (McMMOManager == null)
|
||||
McMMOManager = new McMMOManager();
|
||||
@ -161,10 +154,7 @@ public class Jobs extends JavaPlugin {
|
||||
return PistonProtectionListener;
|
||||
}
|
||||
|
||||
private void setMyPetManager() {
|
||||
myPetManager = new MyPetManager();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static MyPetManager getMyPetManager() {
|
||||
if (myPetManager == null && getInstance().getServer().getPluginManager().getPlugin("MyPet") != null) {
|
||||
myPetManager = new MyPetManager();
|
||||
@ -206,10 +196,12 @@ public class Jobs extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static WorldGuardManager getWorldGuardManager() {
|
||||
return worldGuardManager;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMythicManager() {
|
||||
try {
|
||||
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
|
||||
@ -225,16 +217,7 @@ public class Jobs extends JavaPlugin {
|
||||
consoleMsg("&e[Jobs] MythicMobs detected.");
|
||||
}
|
||||
|
||||
private boolean setWorldGuard() {
|
||||
Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if (plugin != null) {
|
||||
worldGuardManager = new WorldGuardManager();
|
||||
consoleMsg("&e[Jobs] WorldGuard detected.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static MythicMobInterface getMythicManager() {
|
||||
return MythicManager;
|
||||
}
|
||||
@ -626,13 +609,8 @@ public class Jobs extends JavaPlugin {
|
||||
if (GconfigManager.useBlockProtection)
|
||||
pm.registerEvents(PistonProtectionListener, instance);
|
||||
|
||||
if (getMcMMOManager().CheckmcMMO()) {
|
||||
try {
|
||||
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
|
||||
pm.registerEvents(new McMMO2_X_listener(instance), instance);
|
||||
} catch (ClassNotFoundException e) {
|
||||
pm.registerEvents(new McMMO1_X_listener(instance), instance);
|
||||
}
|
||||
if (HookManager.getMcMMOManager().CheckmcMMO()) {
|
||||
HookManager.setMcMMOlistener();
|
||||
}
|
||||
}
|
||||
|
||||
@ -888,17 +866,7 @@ public class Jobs extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new JobsPayment14Listener(), this);
|
||||
}
|
||||
|
||||
if (getMcMMOManager().CheckmcMMO())
|
||||
setMcMMOlistener();
|
||||
|
||||
if (getServer().getPluginManager().isPluginEnabled("MyPet")) {
|
||||
setMyPetManager();
|
||||
}
|
||||
setWorldGuard();
|
||||
|
||||
setMythicManager();
|
||||
if (GconfigManager.MythicMobsEnabled && MythicManager != null && MythicManager.Check())
|
||||
MythicManager.registerListener();
|
||||
HookManager.loadHooks();
|
||||
|
||||
setPistonProtectionListener();
|
||||
if (GconfigManager.useBlockProtection) {
|
||||
|
@ -1 +0,0 @@
|
||||
/MyPetManager.class
|
@ -1,6 +0,0 @@
|
||||
/MythicMobs2Listener.class
|
||||
/MythicMobsManager.class
|
||||
/MythicMobInterface.class
|
||||
/MythicMobs2.class
|
||||
/MythicMobs4.class
|
||||
/MythicMobs4Listener.class
|
@ -65,6 +65,7 @@ import com.gamingmesh.jobs.dao.JobsDAO;
|
||||
import com.gamingmesh.jobs.dao.JobsDAOData;
|
||||
import com.gamingmesh.jobs.economy.PaymentData;
|
||||
import com.gamingmesh.jobs.economy.PointsData;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.stuff.PerformCommands;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
@ -985,8 +986,8 @@ public class PlayerManager {
|
||||
if (player == null || prog == null)
|
||||
return boost;
|
||||
|
||||
if (Jobs.getMcMMOManager().mcMMOPresent || Jobs.getMcMMOManager().mcMMOOverHaul)
|
||||
boost.add(BoostOf.McMMO, new BoostMultiplier().add(Jobs.getMcMMOManager().getMultiplier(player.getPlayer())));
|
||||
if (HookManager.getMcMMOManager().mcMMOPresent || HookManager.getMcMMOManager().mcMMOOverHaul)
|
||||
boost.add(BoostOf.McMMO, new BoostMultiplier().add(HookManager.getMcMMOManager().getMultiplier(player.getPlayer())));
|
||||
|
||||
if (ent != null && (ent instanceof Tameable)) {
|
||||
Tameable t = (Tameable) ent;
|
||||
@ -997,7 +998,7 @@ public class PlayerManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (ent != null && Jobs.getMyPetManager() != null && Jobs.getMyPetManager().isMyPet(ent)) {
|
||||
if (ent != null && HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(ent)) {
|
||||
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay");
|
||||
if (amount != null)
|
||||
boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount));
|
||||
|
@ -1,6 +0,0 @@
|
||||
/MythicMobs2Listener.class
|
||||
/MythicMobsManager.class
|
||||
/MythicMobInterface.class
|
||||
/MythicMobs2.class
|
||||
/MythicMobs4.class
|
||||
/MythicMobs4Listener.class
|
@ -14,6 +14,7 @@ import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.config.RestrictedAreaManager;
|
||||
import com.gamingmesh.jobs.container.CuboidArea;
|
||||
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
|
||||
public class area implements Cmd {
|
||||
|
||||
@ -58,8 +59,8 @@ public class area implements Cmd {
|
||||
"%tool%", CMIMaterial.get(Jobs.getGCManager().getSelectionTool()).getName()));
|
||||
return true;
|
||||
}
|
||||
if (wg && Jobs.getWorldGuardManager() != null) {
|
||||
name = Jobs.getWorldGuardManager().getNameByName(name);
|
||||
if (wg && HookManager.getWorldGuardManager() != null) {
|
||||
name = HookManager.getWorldGuardManager().getNameByName(name);
|
||||
if (name == null) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.area.output.wgDontExist"));
|
||||
return true;
|
||||
|
@ -11,6 +11,7 @@ import com.gamingmesh.jobs.container.Boost;
|
||||
import com.gamingmesh.jobs.container.CurrencyType;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
|
||||
public class bonus implements Cmd {
|
||||
@ -53,7 +54,8 @@ public class bonus implements Cmd {
|
||||
printBoost(sender, boost, BoostOf.NearSpawner);
|
||||
printBoost(sender, boost, BoostOf.PetPay);
|
||||
|
||||
if (Jobs.getMcMMOManager().mcMMOPresent || Jobs.getMcMMOManager().mcMMOOverHaul && boost.get(BoostOf.McMMO, CurrencyType.EXP) != 0D)
|
||||
if (HookManager.getMcMMOManager().mcMMOPresent ||
|
||||
HookManager.getMcMMOManager().mcMMOOverHaul && boost.get(BoostOf.McMMO, CurrencyType.EXP) != 0D)
|
||||
printBoost(sender, boost, BoostOf.McMMO);
|
||||
|
||||
player.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
|
||||
|
@ -18,6 +18,7 @@ import com.gamingmesh.jobs.CMILib.ConfigReader;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.NameList;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.stuff.Util;
|
||||
|
||||
public class NameTranslatorManager {
|
||||
@ -101,9 +102,7 @@ public class NameTranslatorManager {
|
||||
NameList got = ListOfMMEntities.get(materialName.toLowerCase());
|
||||
if (got != null && got.getName() != null)
|
||||
return got.getName();
|
||||
if (Jobs.getMythicManager() == null)
|
||||
return materialName;
|
||||
return Jobs.getMythicManager().getDisplayName(materialName);
|
||||
return HookManager.getMythicManager() == null ? materialName : HookManager.getMythicManager().getDisplayName(materialName);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.entity.Player;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.CuboidArea;
|
||||
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
|
||||
public class RestrictedAreaManager {
|
||||
|
||||
@ -110,7 +111,8 @@ public class RestrictedAreaManager {
|
||||
for (RestrictedArea area : getRestrictedAreasByLoc(player.getLocation())) {
|
||||
if (area.inRestrictedArea(player.getLocation()))
|
||||
return area.getMultiplier();
|
||||
if (area.getWgName() != null && Jobs.getWorldGuardManager() != null && Jobs.getWorldGuardManager().inArea(player.getLocation(), area.getWgName()))
|
||||
if (area.getWgName() != null && HookManager.getWorldGuardManager() != null
|
||||
&& HookManager.getWorldGuardManager().inArea(player.getLocation(), area.getWgName()))
|
||||
return area.getMultiplier();
|
||||
|
||||
}
|
||||
@ -124,8 +126,8 @@ public class RestrictedAreaManager {
|
||||
areas.add(area.getValue());
|
||||
}
|
||||
|
||||
if (Jobs.getWorldGuardManager() != null)
|
||||
areas.addAll(Jobs.getWorldGuardManager().getArea(loc));
|
||||
if (HookManager.getWorldGuardManager() != null)
|
||||
areas.addAll(HookManager.getWorldGuardManager().getArea(loc));
|
||||
|
||||
return areas;
|
||||
}
|
||||
|
113
src/main/java/com/gamingmesh/jobs/hooks/HookManager.java
Normal file
113
src/main/java/com/gamingmesh/jobs/hooks/HookManager.java
Normal file
@ -0,0 +1,113 @@
|
||||
package com.gamingmesh.jobs.hooks;
|
||||
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.hooks.McMMO.McMMO1_X_listener;
|
||||
import com.gamingmesh.jobs.hooks.McMMO.McMMO2_X_listener;
|
||||
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.MythicMobs2;
|
||||
import com.gamingmesh.jobs.hooks.MythicMobs.MythicMobs4;
|
||||
import com.gamingmesh.jobs.hooks.WorldGuard.WorldGuardManager;
|
||||
|
||||
public class HookManager {
|
||||
|
||||
private static McMMOManager McMMOManager = null;
|
||||
private static MythicMobInterface MythicManager = null;
|
||||
private static MyPetManager myPetManager = null;
|
||||
private static WorldGuardManager worldGuardManager = null;
|
||||
|
||||
private static PluginManager pm = null;
|
||||
|
||||
public static void loadHooks() {
|
||||
pm = Jobs.getInstance().getServer().getPluginManager();
|
||||
|
||||
if (getMcMMOManager().CheckmcMMO())
|
||||
setMcMMOlistener();
|
||||
|
||||
setMyPetManager();
|
||||
setWorldGuard();
|
||||
setMythicManager();
|
||||
|
||||
if (Jobs.getGCManager().MythicMobsEnabled && MythicManager != null && MythicManager.Check())
|
||||
MythicManager.registerListener();
|
||||
}
|
||||
|
||||
public static MyPetManager getMyPetManager() {
|
||||
if (myPetManager == null) {
|
||||
setMyPetManager();
|
||||
}
|
||||
|
||||
return myPetManager;
|
||||
}
|
||||
|
||||
public static WorldGuardManager getWorldGuardManager() {
|
||||
if (worldGuardManager == null) {
|
||||
worldGuardManager = new WorldGuardManager();
|
||||
}
|
||||
|
||||
return worldGuardManager;
|
||||
}
|
||||
|
||||
public static McMMOManager getMcMMOManager() {
|
||||
if (McMMOManager == null)
|
||||
McMMOManager = new McMMOManager();
|
||||
|
||||
return McMMOManager;
|
||||
}
|
||||
|
||||
public static MythicMobInterface getMythicManager() {
|
||||
return MythicManager;
|
||||
}
|
||||
|
||||
private static boolean setWorldGuard() {
|
||||
if (pm.getPlugin("WorldGuard") != null && pm.isPluginEnabled("WorldGuard")) {
|
||||
worldGuardManager = new WorldGuardManager();
|
||||
Jobs.consoleMsg("&e[Jobs] WorldGuard detected.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void setMythicManager() {
|
||||
try {
|
||||
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
|
||||
MythicManager = new MythicMobs2(Jobs.getInstance());
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
||||
MythicManager = new MythicMobs4(Jobs.getInstance());
|
||||
} catch (ClassNotFoundException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
if (MythicManager == null) {
|
||||
Jobs.consoleMsg("&cYour MythicMobs version is not supported by Jobs! Supported versions: 2.4.5+, 4.6.5");
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.consoleMsg("&e[Jobs] MythicMobs detected.");
|
||||
}
|
||||
|
||||
public static void setMcMMOlistener() {
|
||||
Jobs ins = Jobs.getInstance();
|
||||
try {
|
||||
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
|
||||
pm.registerEvents(new McMMO2_X_listener(ins), ins);
|
||||
Jobs.consoleMsg("&e[Jobs] Registered McMMO 2.x listener");
|
||||
} catch (ClassNotFoundException e) {
|
||||
pm.registerEvents(new McMMO1_X_listener(ins), ins);
|
||||
Jobs.consoleMsg("&e[Jobs] Registered McMMO 1.x listener");
|
||||
}
|
||||
}
|
||||
|
||||
private static void setMyPetManager() {
|
||||
if (pm.getPlugin("MyPet") != null && pm.isPluginEnabled("MyPet")) {
|
||||
myPetManager = new MyPetManager();
|
||||
Jobs.consoleMsg("&e[Jobs] MyPet detected.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.gamingmesh.jobs.McMMO;
|
||||
package com.gamingmesh.jobs.hooks.McMMO;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
@ -14,6 +13,7 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
@ -28,17 +28,16 @@ public class McMMO1_X_listener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void OnItemrepair(McMMOPlayerRepairCheckEvent event) {
|
||||
//disabling plugin in world
|
||||
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
|
||||
return;
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
//disabling plugin in world
|
||||
if (player == null || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
|
||||
return;
|
||||
|
||||
ItemStack resultStack = event.getRepairedObject();
|
||||
|
||||
if (resultStack == null)
|
||||
return;
|
||||
|
||||
@ -58,10 +57,10 @@ public class McMMO1_X_listener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
|
||||
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
HashMap<String, Long> InfoMap = HookManager.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
if (InfoMap == null) {
|
||||
InfoMap = new HashMap<>();
|
||||
Jobs.getMcMMOManager().getMap().put(event.getPlayer().getUniqueId(), InfoMap);
|
||||
HookManager.getMcMMOManager().getMap().put(event.getPlayer().getUniqueId(), InfoMap);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -69,7 +68,7 @@ public class McMMO1_X_listener implements Listener {
|
||||
// Lets use fixed timer as this tend to return 0
|
||||
// int maxLenght = (int) ab.getClass().getMethod("getMaxLength").invoke(ab);
|
||||
InfoMap.put(String.valueOf(ab), System.currentTimeMillis() + (30 * 1000));
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -77,14 +76,14 @@ public class McMMO1_X_listener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOff(McMMOPlayerAbilityDeactivateEvent event) {
|
||||
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
HashMap<String, Long> InfoMap = HookManager.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
if (InfoMap != null) {
|
||||
try {
|
||||
Object ab = event.getClass().getMethod("getAbility").invoke(event);
|
||||
InfoMap.remove(String.valueOf(ab));
|
||||
if (InfoMap.isEmpty())
|
||||
Jobs.getMcMMOManager().getMap().remove(event.getPlayer().getUniqueId());
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
HookManager.getMcMMOManager().getMap().remove(event.getPlayer().getUniqueId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.gamingmesh.jobs.McMMO;
|
||||
package com.gamingmesh.jobs.hooks.McMMO;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -13,6 +13,7 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
@ -27,17 +28,16 @@ public class McMMO2_X_listener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void OnItemrepair(McMMOPlayerRepairCheckEvent event) {
|
||||
//disabling plugin in world
|
||||
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
|
||||
return;
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
// disabling plugin in world
|
||||
if (player == null || !Jobs.getGCManager().canPerformActionInWorld(player.getWorld()))
|
||||
return;
|
||||
|
||||
ItemStack resultStack = event.getRepairedObject();
|
||||
|
||||
if (resultStack == null)
|
||||
return;
|
||||
|
||||
@ -57,22 +57,22 @@ public class McMMO2_X_listener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
|
||||
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
HashMap<String, Long> InfoMap = HookManager.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
if (InfoMap == null) {
|
||||
InfoMap = new HashMap<>();
|
||||
Jobs.getMcMMOManager().getMap().put(event.getPlayer().getUniqueId(), InfoMap);
|
||||
HookManager.getMcMMOManager().getMap().put(event.getPlayer().getUniqueId(), InfoMap);
|
||||
}
|
||||
|
||||
InfoMap.put(event.getAbility().toString(), System.currentTimeMillis() + (30 * 1000));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOff(McMMOPlayerAbilityDeactivateEvent event) {
|
||||
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
HashMap<String, Long> InfoMap = HookManager.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
if (InfoMap != null) {
|
||||
InfoMap.remove(event.getAbility().toString());
|
||||
if (InfoMap.isEmpty())
|
||||
Jobs.getMcMMOManager().getMap().remove(event.getPlayer().getUniqueId());
|
||||
HookManager.getMcMMOManager().getMap().remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.gamingmesh.jobs.McMMO;
|
||||
package com.gamingmesh.jobs.hooks.McMMO;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
@ -17,6 +17,14 @@ public class McMMOManager {
|
||||
|
||||
private HashMap<UUID, HashMap<String, Long>> map = new HashMap<>();
|
||||
|
||||
public HashMap<UUID, HashMap<String, Long>> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(HashMap<UUID, HashMap<String, Long>> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
public double getMultiplier(Player player) {
|
||||
if (player == null)
|
||||
return 0D;
|
||||
@ -24,6 +32,7 @@ public class McMMOManager {
|
||||
HashMap<String, Long> InfoMap = map.get(player.getUniqueId());
|
||||
if (InfoMap == null)
|
||||
return 0D;
|
||||
|
||||
if (mcMMOOverHaul) {
|
||||
Long t = InfoMap.get(SuperAbilityType.TREE_FELLER.toString());
|
||||
if (t != null) {
|
||||
@ -81,6 +90,7 @@ public class McMMOManager {
|
||||
// Disabling skill API check;
|
||||
mcMMOOverHaul = false;
|
||||
Jobs.consoleMsg("&e[Jobs] &6mcMMO was found - &cBut your McMMO version is outdated, please update for full support.");
|
||||
|
||||
try {
|
||||
Class.forName("com.gmail.nossr50.api.AbilityAPI");
|
||||
mcMMOPresent = true;
|
||||
@ -91,6 +101,7 @@ public class McMMOManager {
|
||||
// Still enabling event listener for repair
|
||||
return true;
|
||||
}
|
||||
|
||||
// Still enabling event listener for repair
|
||||
return true;
|
||||
}
|
||||
@ -98,14 +109,7 @@ public class McMMOManager {
|
||||
Jobs.consoleMsg("&e[Jobs] &6mcMMO" + McMMO.getDescription().getVersion() + " was found - Enabling capabilities.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public HashMap<UUID, HashMap<String, Long>> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(HashMap<UUID, HashMap<String, Long>> map) {
|
||||
this.map = map;
|
||||
}
|
||||
}
|
@ -1,12 +1,7 @@
|
||||
package com.gamingmesh.jobs.MyPet;
|
||||
package com.gamingmesh.jobs.hooks.MyPet;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
|
||||
import de.Keyle.MyPet.MyPetApi;
|
||||
import de.Keyle.MyPet.api.entity.MyPet;
|
||||
import de.Keyle.MyPet.api.entity.MyPetBukkitEntity;
|
||||
@ -19,7 +14,9 @@ public class MyPetManager {
|
||||
private boolean enabled = false;
|
||||
|
||||
public MyPetManager() {
|
||||
setup();
|
||||
mp = MyPetApi.getPlayerManager();
|
||||
mppm = MyPetApi.getMyPetManager();
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public boolean isMyPet(Object ent) {
|
||||
@ -46,16 +43,4 @@ public class MyPetManager {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
Plugin pl = Bukkit.getPluginManager().getPlugin("MyPet");
|
||||
if (pl == null || !Bukkit.getPluginManager().isPluginEnabled("MyPet"))
|
||||
return;
|
||||
|
||||
mp = MyPetApi.getPlayerManager();
|
||||
mppm = MyPetApi.getMyPetManager();
|
||||
enabled = true;
|
||||
Jobs.consoleMsg("&e[Jobs] &6MyPet detected");
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
@ -11,7 +11,4 @@ public interface MythicMobInterface {
|
||||
void registerListener();
|
||||
|
||||
String getDisplayName(String id);
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -18,7 +18,6 @@ public class MythicMobs2 implements MythicMobInterface {
|
||||
|
||||
public MythicMobs2(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,8 +29,10 @@ public class MythicMobs2 implements MythicMobInterface {
|
||||
public boolean isMythicMob(LivingEntity lVictim) {
|
||||
if (MMAPI == null || lVictim == null)
|
||||
return false;
|
||||
|
||||
if (MMAPI.getMobAPI().isMythicMob(lVictim))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -54,7 +55,6 @@ public class MythicMobs2 implements MythicMobInterface {
|
||||
MMAPI = ((MythicMobs) mm).getAPI();
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs2 was found - Enabling capabilities.");
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,6 +66,7 @@ public class MythicMobs2 implements MythicMobInterface {
|
||||
} catch (InvalidMobTypeException e) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -24,17 +24,17 @@ public class MythicMobs2Listener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void OnMythicMobDeath(MythicMobDeathEvent event) {
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
//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;
|
||||
|
||||
@ -50,6 +50,7 @@ public class MythicMobs2Listener implements Listener {
|
||||
|
||||
if (pDamager == null)
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !pDamager.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative())
|
||||
return;
|
||||
@ -59,10 +60,14 @@ public class MythicMobs2Listener implements Listener {
|
||||
|
||||
// pay
|
||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
|
||||
|
||||
if (jDamager == null)
|
||||
return;
|
||||
|
||||
MythicMob lVictim = event.getMobType();
|
||||
if (lVictim == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -17,7 +17,6 @@ public class MythicMobs4 implements MythicMobInterface {
|
||||
|
||||
public MythicMobs4(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -29,8 +28,10 @@ public class MythicMobs4 implements MythicMobInterface {
|
||||
public boolean isMythicMob(LivingEntity lVictim) {
|
||||
if (MMAPI == null || lVictim == null)
|
||||
return false;
|
||||
|
||||
if (MMAPI.isMythicMob(lVictim))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -54,7 +55,6 @@ public class MythicMobs4 implements MythicMobInterface {
|
||||
MMAPI = ((MythicMobs) mm).getAPIHelper();
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs4 was found - Enabling capabilities.");
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
static boolean failed = false;
|
||||
@ -63,6 +63,7 @@ public class MythicMobs4 implements MythicMobInterface {
|
||||
public String getDisplayName(String id) {
|
||||
if (failed)
|
||||
return "";
|
||||
|
||||
MythicMob mm = MMAPI.getMythicMob(id);
|
||||
try {
|
||||
if (mm != null)
|
||||
@ -74,6 +75,7 @@ public class MythicMobs4 implements MythicMobInterface {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -25,17 +25,17 @@ public class MythicMobs4Listener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void OnMythicMobDeath(MythicMobDeathEvent event) {
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
//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;
|
||||
|
||||
@ -51,6 +51,7 @@ public class MythicMobs4Listener implements Listener {
|
||||
|
||||
if (pDamager == null)
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !pDamager.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative())
|
||||
return;
|
||||
@ -60,10 +61,14 @@ public class MythicMobs4Listener implements Listener {
|
||||
|
||||
// pay
|
||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
|
||||
|
||||
if (jDamager == null)
|
||||
return;
|
||||
|
||||
MythicMob lVictim = event.getMobType();
|
||||
if (lVictim == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.gamingmesh.jobs.WorldGuard;
|
||||
package com.gamingmesh.jobs.hooks.WorldGuard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -55,6 +55,7 @@ public class WorldGuardManager {
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
return new ArrayList<RestrictedArea>();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.*;
|
||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||
import com.gamingmesh.jobs.container.*;
|
||||
import com.gamingmesh.jobs.hooks.HookManager;
|
||||
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling;
|
||||
import com.gamingmesh.jobs.stuff.FurnaceBrewingHandling.ownershipFeedback;
|
||||
import com.google.common.base.Objects;
|
||||
@ -1123,8 +1124,8 @@ public class JobsPaymentListener implements Listener {
|
||||
if (e.getDamager().hasMetadata("NPC"))
|
||||
return;
|
||||
|
||||
if (Jobs.getGCManager().MythicMobsEnabled && Jobs.getMythicManager() != null) {
|
||||
if (Jobs.getMythicManager().isMythicMob(lVictim))
|
||||
if (Jobs.getGCManager().MythicMobsEnabled && HookManager.getMythicManager() != null
|
||||
&& HookManager.getMythicManager().isMythicMob(lVictim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1144,8 +1145,8 @@ public class JobsPaymentListener implements Listener {
|
||||
if (e.getDamager() instanceof Player) {
|
||||
pDamager = (Player) e.getDamager();
|
||||
// Checking if killer is MyPet animal
|
||||
} else if (Jobs.getMyPetManager() != null && Jobs.getMyPetManager().isMyPet(e.getDamager())) {
|
||||
UUID uuid = Jobs.getMyPetManager().getOwnerOfPet(e.getDamager());
|
||||
} else if (HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager())) {
|
||||
UUID uuid = HookManager.getMyPetManager().getOwnerOfPet(e.getDamager());
|
||||
if (uuid != null)
|
||||
pDamager = Bukkit.getPlayer(uuid);
|
||||
// Checking if killer is tamed animal
|
||||
|
Loading…
Reference in New Issue
Block a user