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,93 +1,92 @@
|
||||
package com.gamingmesh.jobs.McMMO;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
|
||||
public class McMMO1_X_listener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
|
||||
public McMMO1_X_listener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
ItemStack resultStack = event.getRepairedObject();
|
||||
|
||||
if (resultStack == null)
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative())
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
|
||||
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
if (InfoMap == null) {
|
||||
InfoMap = new HashMap<>();
|
||||
Jobs.getMcMMOManager().getMap().put(event.getPlayer().getUniqueId(), InfoMap);
|
||||
}
|
||||
|
||||
try {
|
||||
Object ab = event.getClass().getMethod("getAbility").invoke(event);
|
||||
// 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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOff(McMMOPlayerAbilityDeactivateEvent event) {
|
||||
HashMap<String, Long> InfoMap = Jobs.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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.McMMO;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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;
|
||||
|
||||
public class McMMO1_X_listener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
|
||||
public McMMO1_X_listener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnItemrepair(McMMOPlayerRepairCheckEvent event) {
|
||||
// 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;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative())
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
|
||||
HashMap<String, Long> InfoMap = HookManager.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
if (InfoMap == null) {
|
||||
InfoMap = new HashMap<>();
|
||||
HookManager.getMcMMOManager().getMap().put(event.getPlayer().getUniqueId(), InfoMap);
|
||||
}
|
||||
|
||||
try {
|
||||
Object ab = event.getClass().getMethod("getAbility").invoke(event);
|
||||
// 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 (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOff(McMMOPlayerAbilityDeactivateEvent event) {
|
||||
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())
|
||||
HookManager.getMcMMOManager().getMap().remove(event.getPlayer().getUniqueId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,78 +1,78 @@
|
||||
package com.gamingmesh.jobs.McMMO;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
||||
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
|
||||
public class McMMO2_X_listener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
|
||||
public McMMO2_X_listener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
ItemStack resultStack = event.getRepairedObject();
|
||||
|
||||
if (resultStack == null)
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative())
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
|
||||
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
if (InfoMap == null) {
|
||||
InfoMap = new HashMap<>();
|
||||
Jobs.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());
|
||||
if (InfoMap != null) {
|
||||
InfoMap.remove(event.getAbility().toString());
|
||||
if (InfoMap.isEmpty())
|
||||
Jobs.getMcMMOManager().getMap().remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.McMMO;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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;
|
||||
|
||||
public class McMMO2_X_listener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
|
||||
public McMMO2_X_listener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnItemrepair(McMMOPlayerRepairCheckEvent event) {
|
||||
// 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;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE) && !player.hasPermission("jobs.paycreative") && !Jobs.getGCManager().payInCreative())
|
||||
return;
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
|
||||
HashMap<String, Long> InfoMap = HookManager.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
if (InfoMap == null) {
|
||||
InfoMap = new HashMap<>();
|
||||
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 = HookManager.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());
|
||||
if (InfoMap != null) {
|
||||
InfoMap.remove(event.getAbility().toString());
|
||||
if (InfoMap.isEmpty())
|
||||
HookManager.getMcMMOManager().getMap().remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,111 +1,115 @@
|
||||
package com.gamingmesh.jobs.McMMO;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
|
||||
public class McMMOManager {
|
||||
|
||||
public boolean mcMMOPresent = false;
|
||||
public boolean mcMMOOverHaul = false;
|
||||
|
||||
private HashMap<UUID, HashMap<String, Long>> map = new HashMap<>();
|
||||
|
||||
public double getMultiplier(Player player) {
|
||||
if (player == null)
|
||||
return 0D;
|
||||
|
||||
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) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().TreeFellerMultiplier);
|
||||
InfoMap.remove(SuperAbilityType.TREE_FELLER.toString());
|
||||
}
|
||||
|
||||
t = InfoMap.get(SuperAbilityType.GIGA_DRILL_BREAKER.toString());
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().gigaDrillMultiplier);
|
||||
InfoMap.remove(SuperAbilityType.GIGA_DRILL_BREAKER.toString());
|
||||
}
|
||||
|
||||
t = InfoMap.get(SuperAbilityType.SUPER_BREAKER.toString());
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
|
||||
InfoMap.remove(SuperAbilityType.SUPER_BREAKER.toString());
|
||||
}
|
||||
} else if (mcMMOPresent) {
|
||||
Long t = InfoMap.get("TREE_FELLER");
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().TreeFellerMultiplier);
|
||||
InfoMap.remove("TREE_FELLER");
|
||||
}
|
||||
|
||||
t = InfoMap.get("GIGA_DRILL_BREAKER");
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().gigaDrillMultiplier);
|
||||
InfoMap.remove("GIGA_DRILL_BREAKER");
|
||||
}
|
||||
|
||||
t = InfoMap.get("SUPER_BREAKER");
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
|
||||
InfoMap.remove("SUPER_BREAKER");
|
||||
}
|
||||
}
|
||||
|
||||
return 0D;
|
||||
}
|
||||
|
||||
public boolean CheckmcMMO() {
|
||||
Plugin McMMO = Bukkit.getPluginManager().getPlugin("mcMMO");
|
||||
if (McMMO != null) {
|
||||
try {
|
||||
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
|
||||
mcMMOOverHaul = true;
|
||||
} catch (ClassNotFoundException c) {
|
||||
// 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;
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Disabling skill API check;
|
||||
mcMMOPresent = false;
|
||||
Jobs.consoleMsg("&e[Jobs] &6mcMMO was found - &cBut your McMMO version is outdated, please update for full support.");
|
||||
// Still enabling event listener for repair
|
||||
return true;
|
||||
}
|
||||
// Still enabling event listener for repair
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.McMMO;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
|
||||
public class McMMOManager {
|
||||
|
||||
public boolean mcMMOPresent = false;
|
||||
public boolean mcMMOOverHaul = false;
|
||||
|
||||
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;
|
||||
|
||||
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) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().TreeFellerMultiplier);
|
||||
InfoMap.remove(SuperAbilityType.TREE_FELLER.toString());
|
||||
}
|
||||
|
||||
t = InfoMap.get(SuperAbilityType.GIGA_DRILL_BREAKER.toString());
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().gigaDrillMultiplier);
|
||||
InfoMap.remove(SuperAbilityType.GIGA_DRILL_BREAKER.toString());
|
||||
}
|
||||
|
||||
t = InfoMap.get(SuperAbilityType.SUPER_BREAKER.toString());
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
|
||||
InfoMap.remove(SuperAbilityType.SUPER_BREAKER.toString());
|
||||
}
|
||||
} else if (mcMMOPresent) {
|
||||
Long t = InfoMap.get("TREE_FELLER");
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().TreeFellerMultiplier);
|
||||
InfoMap.remove("TREE_FELLER");
|
||||
}
|
||||
|
||||
t = InfoMap.get("GIGA_DRILL_BREAKER");
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().gigaDrillMultiplier);
|
||||
InfoMap.remove("GIGA_DRILL_BREAKER");
|
||||
}
|
||||
|
||||
t = InfoMap.get("SUPER_BREAKER");
|
||||
if (t != null) {
|
||||
if (t > System.currentTimeMillis())
|
||||
return -(1 - Jobs.getGCManager().superBreakerMultiplier);
|
||||
InfoMap.remove("SUPER_BREAKER");
|
||||
}
|
||||
}
|
||||
|
||||
return 0D;
|
||||
}
|
||||
|
||||
public boolean CheckmcMMO() {
|
||||
Plugin McMMO = Bukkit.getPluginManager().getPlugin("mcMMO");
|
||||
if (McMMO != null) {
|
||||
try {
|
||||
Class.forName("com.gmail.nossr50.datatypes.skills.SuperAbilityType");
|
||||
mcMMOOverHaul = true;
|
||||
} catch (ClassNotFoundException c) {
|
||||
// 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;
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Disabling skill API check;
|
||||
mcMMOPresent = false;
|
||||
Jobs.consoleMsg("&e[Jobs] &6mcMMO was found - &cBut your McMMO version is outdated, please update for full support.");
|
||||
// Still enabling event listener for repair
|
||||
return true;
|
||||
}
|
||||
|
||||
// Still enabling event listener for repair
|
||||
return true;
|
||||
}
|
||||
|
||||
Jobs.consoleMsg("&e[Jobs] &6mcMMO" + McMMO.getDescription().getVersion() + " was found - Enabling capabilities.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,61 +1,46 @@
|
||||
package com.gamingmesh.jobs.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;
|
||||
import de.Keyle.MyPet.api.repository.PlayerManager;
|
||||
|
||||
public class MyPetManager {
|
||||
|
||||
PlayerManager mp;
|
||||
de.Keyle.MyPet.api.repository.MyPetManager mppm;
|
||||
private boolean enabled = false;
|
||||
|
||||
public MyPetManager() {
|
||||
setup();
|
||||
}
|
||||
|
||||
public boolean isMyPet(Object ent) {
|
||||
if (!enabled || ent == null)
|
||||
return false;
|
||||
if (!(ent instanceof MyPetBukkitEntity))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public UUID getOwnerOfPet(Object ent) {
|
||||
if (!enabled || ent == null)
|
||||
return null;
|
||||
if (!(ent instanceof MyPetBukkitEntity))
|
||||
return null;
|
||||
|
||||
MyPet myPet = ((MyPetBukkitEntity) ent).getMyPet();
|
||||
|
||||
try {
|
||||
UUID uuid = myPet.getOwner().getPlayer().getUniqueId();
|
||||
return uuid;
|
||||
} catch (Exception e) {
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.MyPet;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import de.Keyle.MyPet.MyPetApi;
|
||||
import de.Keyle.MyPet.api.entity.MyPet;
|
||||
import de.Keyle.MyPet.api.entity.MyPetBukkitEntity;
|
||||
import de.Keyle.MyPet.api.repository.PlayerManager;
|
||||
|
||||
public class MyPetManager {
|
||||
|
||||
PlayerManager mp;
|
||||
de.Keyle.MyPet.api.repository.MyPetManager mppm;
|
||||
private boolean enabled = false;
|
||||
|
||||
public MyPetManager() {
|
||||
mp = MyPetApi.getPlayerManager();
|
||||
mppm = MyPetApi.getMyPetManager();
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public boolean isMyPet(Object ent) {
|
||||
if (!enabled || ent == null)
|
||||
return false;
|
||||
if (!(ent instanceof MyPetBukkitEntity))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public UUID getOwnerOfPet(Object ent) {
|
||||
if (!enabled || ent == null)
|
||||
return null;
|
||||
if (!(ent instanceof MyPetBukkitEntity))
|
||||
return null;
|
||||
|
||||
MyPet myPet = ((MyPetBukkitEntity) ent).getMyPet();
|
||||
|
||||
try {
|
||||
UUID uuid = myPet.getOwner().getPlayer().getUniqueId();
|
||||
return uuid;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,14 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public interface MythicMobInterface {
|
||||
|
||||
boolean Check();
|
||||
|
||||
boolean isMythicMob(LivingEntity lVictim);
|
||||
|
||||
void registerListener();
|
||||
|
||||
String getDisplayName(String id);
|
||||
|
||||
|
||||
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
public interface MythicMobInterface {
|
||||
|
||||
boolean Check();
|
||||
|
||||
boolean isMythicMob(LivingEntity lVictim);
|
||||
|
||||
void registerListener();
|
||||
|
||||
String getDisplayName(String id);
|
||||
}
|
@ -1,71 +1,72 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
import net.elseland.xikage.MythicMobs.API.Exceptions.InvalidMobTypeException;
|
||||
import net.elseland.xikage.MythicMobs.Mobs.MythicMob;
|
||||
|
||||
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 == null || lVictim == null)
|
||||
return false;
|
||||
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
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MMAPI = ((MythicMobs) mm).getAPI();
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs2 was found - Enabling capabilities.");
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String id) {
|
||||
try {
|
||||
MythicMob mm = MMAPI.getMobAPI().getMythicMob(id);
|
||||
if (mm != null)
|
||||
return mm.getDisplayName();
|
||||
} catch (InvalidMobTypeException e) {
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
import net.elseland.xikage.MythicMobs.API.Exceptions.InvalidMobTypeException;
|
||||
import net.elseland.xikage.MythicMobs.Mobs.MythicMob;
|
||||
|
||||
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 == null || lVictim == null)
|
||||
return false;
|
||||
|
||||
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
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MMAPI = ((MythicMobs) mm).getAPI();
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs2 was found - Enabling capabilities.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String id) {
|
||||
try {
|
||||
MythicMob mm = MMAPI.getMobAPI().getMythicMob(id);
|
||||
if (mm != null)
|
||||
return mm.getDisplayName();
|
||||
} catch (InvalidMobTypeException e) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
@ -1,68 +1,73 @@
|
||||
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 net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent;
|
||||
import net.elseland.xikage.MythicMobs.Mobs.MythicMob;
|
||||
|
||||
public class MythicMobs2Listener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
|
||||
public MythicMobs2Listener(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) && !pDamager.hasPermission("jobs.paycreative") && !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);
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.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 net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent;
|
||||
import net.elseland.xikage.MythicMobs.Mobs.MythicMob;
|
||||
|
||||
public class MythicMobs2Listener implements Listener {
|
||||
|
||||
private Jobs plugin;
|
||||
|
||||
public MythicMobs2Listener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
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) && !pDamager.hasPermission("jobs.paycreative") && !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;
|
||||
|
||||
MythicMob lVictim = event.getMobType();
|
||||
if (lVictim == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
|
||||
}
|
||||
}
|
@ -1,80 +1,82 @@
|
||||
package com.gamingmesh.jobs.MythicMobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
|
||||
|
||||
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 == null || lVictim == null)
|
||||
return false;
|
||||
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
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MMAPI = ((MythicMobs) mm).getAPIHelper();
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs4 was found - Enabling capabilities.");
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
static boolean failed = false;
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String id) {
|
||||
if (failed)
|
||||
return "";
|
||||
MythicMob mm = MMAPI.getMythicMob(id);
|
||||
try {
|
||||
if (mm != null)
|
||||
return mm.getDisplayName().toString();
|
||||
} catch (Exception | Error e) {
|
||||
if (!failed) {
|
||||
failed = true;
|
||||
Jobs.consoleMsg("&cEncountered error when checking MythicMob entity name. Support for mythicMobs will be suspended for time beying. Please report this issue.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.MythicMobs;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
|
||||
|
||||
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 == null || lVictim == null)
|
||||
return false;
|
||||
|
||||
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
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs was found - &cBut your version is outdated, please update for full support.");
|
||||
return false;
|
||||
}
|
||||
|
||||
MMAPI = ((MythicMobs) mm).getAPIHelper();
|
||||
Jobs.consoleMsg("&e[Jobs] &6MythicMobs4 was found - Enabling capabilities.");
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean failed = false;
|
||||
|
||||
@Override
|
||||
public String getDisplayName(String id) {
|
||||
if (failed)
|
||||
return "";
|
||||
|
||||
MythicMob mm = MMAPI.getMythicMob(id);
|
||||
try {
|
||||
if (mm != null)
|
||||
return mm.getDisplayName().toString();
|
||||
} catch (Exception | Error e) {
|
||||
if (!failed) {
|
||||
failed = true;
|
||||
Jobs.consoleMsg("&cEncountered error when checking MythicMob entity name. Support for mythicMobs will be suspended for time beying. Please report this issue.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
@ -1,69 +1,74 @@
|
||||
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) && !pDamager.hasPermission("jobs.paycreative") && !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);
|
||||
}
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.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) {
|
||||
// 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;
|
||||
|
||||
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) && !pDamager.hasPermission("jobs.paycreative") && !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;
|
||||
|
||||
MythicMob lVictim = event.getMobType();
|
||||
if (lVictim == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), ent);
|
||||
}
|
||||
}
|
@ -1,103 +1,104 @@
|
||||
package com.gamingmesh.jobs.WorldGuard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
|
||||
public class WorldGuardManager {
|
||||
|
||||
private WorldGuardPlugin wg;
|
||||
private boolean useOld = false;
|
||||
|
||||
public WorldGuardManager() {
|
||||
Plugin pl = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
if (pl != null && (pl instanceof WorldGuardPlugin)) {
|
||||
if (pl.getDescription().getVersion().equals("6.1")) {
|
||||
wg = (WorldGuardPlugin) pl;
|
||||
useOld = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<RestrictedArea> getArea(Location loc) {
|
||||
try {
|
||||
if (useOld) {
|
||||
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
||||
for (ProtectedRegion one : regions.getRegions()) {
|
||||
if (!Jobs.getRestrictedAreaManager().isExist(one.getId()))
|
||||
continue;
|
||||
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||
}
|
||||
} else {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||
if (!Jobs.getRestrictedAreaManager().isExist(one.getId()))
|
||||
continue;
|
||||
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
return new ArrayList<RestrictedArea>();
|
||||
}
|
||||
|
||||
public boolean inArea(Location loc, String name) {
|
||||
if (useOld) {
|
||||
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
||||
for (ProtectedRegion one : regions.getRegions()) {
|
||||
if (!one.getId().equalsIgnoreCase(name))
|
||||
continue;
|
||||
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||
if (!one.getId().equalsIgnoreCase(name))
|
||||
continue;
|
||||
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getNameByName(String name) {
|
||||
for (World one : Bukkit.getWorlds()) {
|
||||
Map<String, ProtectedRegion> regions = null;
|
||||
if (useOld) {
|
||||
regions = wg.getRegionContainer().get(one).getRegions();
|
||||
} else {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
regions = container.get(BukkitAdapter.adapt(one)).getRegions();
|
||||
}
|
||||
for (Entry<String, ProtectedRegion> oneR : regions.entrySet()) {
|
||||
if (!oneR.getKey().equalsIgnoreCase(name))
|
||||
continue;
|
||||
return oneR.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
package com.gamingmesh.jobs.hooks.WorldGuard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.RestrictedArea;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
|
||||
public class WorldGuardManager {
|
||||
|
||||
private WorldGuardPlugin wg;
|
||||
private boolean useOld = false;
|
||||
|
||||
public WorldGuardManager() {
|
||||
Plugin pl = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
if (pl != null && (pl instanceof WorldGuardPlugin)) {
|
||||
if (pl.getDescription().getVersion().equals("6.1")) {
|
||||
wg = (WorldGuardPlugin) pl;
|
||||
useOld = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<RestrictedArea> getArea(Location loc) {
|
||||
try {
|
||||
if (useOld) {
|
||||
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
||||
for (ProtectedRegion one : regions.getRegions()) {
|
||||
if (!Jobs.getRestrictedAreaManager().isExist(one.getId()))
|
||||
continue;
|
||||
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||
}
|
||||
} else {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||
if (!Jobs.getRestrictedAreaManager().isExist(one.getId()))
|
||||
continue;
|
||||
return Jobs.getRestrictedAreaManager().getRestrictedAreasByName(one.getId());
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
return new ArrayList<RestrictedArea>();
|
||||
}
|
||||
|
||||
public boolean inArea(Location loc, String name) {
|
||||
if (useOld) {
|
||||
ApplicableRegionSet regions = wg.getRegionContainer().get(loc.getWorld()).getApplicableRegions(loc);
|
||||
for (ProtectedRegion one : regions.getRegions()) {
|
||||
if (!one.getId().equalsIgnoreCase(name))
|
||||
continue;
|
||||
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager regions = container.get(BukkitAdapter.adapt(loc.getWorld()));
|
||||
for (ProtectedRegion one : regions.getRegions().values()) {
|
||||
if (!one.getId().equalsIgnoreCase(name))
|
||||
continue;
|
||||
if (!one.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()))
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getNameByName(String name) {
|
||||
for (World one : Bukkit.getWorlds()) {
|
||||
Map<String, ProtectedRegion> regions = null;
|
||||
if (useOld) {
|
||||
regions = wg.getRegionContainer().get(one).getRegions();
|
||||
} else {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
regions = container.get(BukkitAdapter.adapt(one)).getRegions();
|
||||
}
|
||||
for (Entry<String, ProtectedRegion> oneR : regions.entrySet()) {
|
||||
if (!oneR.getKey().equalsIgnoreCase(name))
|
||||
continue;
|
||||
return oneR.getKey();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -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