mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Compatibility with MyPet plugin to give out money when players pet kills
mobs
This commit is contained in:
parent
4d461584c6
commit
8ce06bcffc
@ -11,5 +11,6 @@
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/craftconomy3-3.3.1-20160221.070622-13.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-4.1.0.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MythicMobs-2.1.8.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Arte/Desktop/Jobs/lib/MyPet-2.3.0-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="output" path=""/>
|
||||
</classpath>
|
||||
|
@ -40,9 +40,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.gamingmesh.jobs.Gui.GuiManager;
|
||||
import com.gamingmesh.jobs.MyPet.MyPetManager;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobInterface;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs2;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs2Listener;
|
||||
import com.gamingmesh.jobs.MythicMobs.MythicMobs4;
|
||||
import com.gamingmesh.jobs.Signs.SignUtil;
|
||||
import com.gamingmesh.jobs.api.JobsExpGainEvent;
|
||||
@ -116,6 +116,7 @@ public class Jobs extends JavaPlugin {
|
||||
private static McMMOlistener McMMOlistener = null;
|
||||
|
||||
private static MythicMobInterface MythicManager;
|
||||
private static MyPetManager myPetManager;
|
||||
|
||||
private static ConfigManager configManager;
|
||||
private static GeneralConfigManager GconfigManager;
|
||||
@ -162,15 +163,21 @@ public class Jobs extends JavaPlugin {
|
||||
return PistonProtectionListener;
|
||||
}
|
||||
|
||||
public void setMyPetManager() {
|
||||
myPetManager = new MyPetManager();
|
||||
}
|
||||
|
||||
public static MyPetManager getMyPetManager() {
|
||||
return myPetManager;
|
||||
}
|
||||
|
||||
public void setMythicManager() {
|
||||
try {
|
||||
Class.forName("net.elseland.xikage.MythicMobs.API.MythicMobsAPI");
|
||||
Debug.D("one");
|
||||
MythicManager = new MythicMobs2(this);
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
Class.forName("io.lumine.xikage.mythicmobs.api.bukkit.BukkitAPIHelper");
|
||||
Debug.D("two");
|
||||
MythicManager = new MythicMobs4(this);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
|
||||
@ -746,6 +753,8 @@ public class Jobs extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(McMMOlistener, this);
|
||||
}
|
||||
|
||||
setMyPetManager();
|
||||
|
||||
setMythicManager();
|
||||
if (MythicManager.Check() && GconfigManager.MythicMobsEnabled) {
|
||||
MythicManager.registerListener();
|
||||
|
59
com/gamingmesh/jobs/MyPet/MyPetManager.java
Normal file
59
com/gamingmesh/jobs/MyPet/MyPetManager.java
Normal file
@ -0,0 +1,59 @@
|
||||
package com.gamingmesh.jobs.MyPet;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
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)
|
||||
return;
|
||||
mp = MyPetApi.getPlayerManager();
|
||||
mppm = MyPetApi.getMyPetManager();
|
||||
enabled = true;
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', "&e[Jobs] &6MyPet was found - Enabling capabilities."));
|
||||
}
|
||||
|
||||
}
|
@ -757,7 +757,7 @@ public class PlayerManager {
|
||||
if (Jobs.getMcMMOlistener().mcMMOPresent)
|
||||
boost.add(BoostOf.McMMO, new BoostMultiplier().add(Jobs.getMcMMOlistener().getMultiplier(player.getPlayer())));
|
||||
|
||||
if (ent != null && ent instanceof Tameable) {
|
||||
if (ent != null && (ent instanceof Tameable)) {
|
||||
Tameable t = (Tameable) ent;
|
||||
if (t.isTamed() && t.getOwner() instanceof Player) {
|
||||
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay");
|
||||
@ -766,6 +766,12 @@ public class PlayerManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (ent != null && Jobs.getMyPetManager().isMyPet(ent)) {
|
||||
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay");
|
||||
if (amount != null)
|
||||
boost.add(BoostOf.PetPay, new BoostMultiplier().add(amount));
|
||||
}
|
||||
|
||||
if (victim != null && victim.hasMetadata(this.getMobSpawnerMetadata())) {
|
||||
Double amount = Jobs.getPermissionManager().getMaxPermission(player, "jobs.nearspawner");
|
||||
if (amount != null)
|
||||
|
@ -11,7 +11,6 @@ import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.Perm;
|
||||
|
||||
public class browse implements Cmd {
|
||||
|
@ -11,7 +11,6 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.ExploreChunk;
|
||||
import com.gamingmesh.jobs.container.ExploreRegion;
|
||||
import com.gamingmesh.jobs.container.ExploreRespond;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
|
||||
public class ExploreManager {
|
||||
|
||||
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.container.LocaleReader;
|
||||
|
@ -14,7 +14,6 @@ import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.LocaleReader;
|
||||
import com.gamingmesh.jobs.container.NameList;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
|
||||
public class NameTranslatorManager {
|
||||
|
||||
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -815,6 +816,9 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
// make sure plugin is enabled
|
||||
if (!this.plugin.isEnabled())
|
||||
return;
|
||||
//disabling plugin in world
|
||||
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
@ -846,15 +850,16 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure plugin is enabled
|
||||
if (!this.plugin.isEnabled())
|
||||
return;
|
||||
|
||||
Player pDamager = null;
|
||||
|
||||
// Checking if killer is player
|
||||
if (e.getDamager() instanceof Player) {
|
||||
pDamager = (Player) e.getDamager();
|
||||
// Checking if killer is MyPet animal
|
||||
} else if (Jobs.getMyPetManager().isMyPet(e.getDamager())) {
|
||||
UUID uuid = Jobs.getMyPetManager().getOwnerOfPet(e.getDamager());
|
||||
if (uuid != null)
|
||||
pDamager = Bukkit.getPlayer(uuid);
|
||||
// Checking if killer is tamed animal
|
||||
} else if (e.getDamager() instanceof Tameable) {
|
||||
Tameable t = (Tameable) e.getDamager();
|
||||
|
Loading…
Reference in New Issue
Block a user