mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
MythicMobs support
This commit is contained in:
parent
3d05def4b6
commit
254900c79a
@ -22,6 +22,8 @@ import java.io.IOException;
|
||||
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.CoreProtectAPI;
|
||||
import net.elseland.xikage.MythicMobs.MythicMobs;
|
||||
import net.elseland.xikage.MythicMobs.API.MythicMobsAPI;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
@ -36,6 +38,7 @@ import com.gamingmesh.jobs.config.JobsConfiguration;
|
||||
import com.gamingmesh.jobs.listeners.JobsListener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
import com.gamingmesh.jobs.listeners.McMMOlistener;
|
||||
import com.gamingmesh.jobs.listeners.MythicMobsListener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.stuff.OfflinePlayerList;
|
||||
import com.gamingmesh.jobs.stuff.ScheduleUtil;
|
||||
@ -45,6 +48,7 @@ import com.gamingmesh.jobs.config.YmlMaker;
|
||||
public class JobsPlugin extends JavaPlugin {
|
||||
public static Plugin instance;
|
||||
public static CoreProtectAPI CPAPI;
|
||||
public static MythicMobsAPI MMAPI;
|
||||
public static boolean CPPresent = false;
|
||||
|
||||
@Override
|
||||
@ -86,12 +90,19 @@ public class JobsPlugin extends JavaPlugin {
|
||||
if (McMMOlistener.CheckmcMMO())
|
||||
getServer().getPluginManager().registerEvents(new McMMOlistener(this), this);
|
||||
|
||||
if (MythicMobsListener.Check())
|
||||
getServer().getPluginManager().registerEvents(new MythicMobsListener(this), this);
|
||||
|
||||
if (ConfigManager.getJobsConfiguration().useBlockProtection)
|
||||
getServer().getPluginManager().registerEvents(new PistonProtectionListener(this), this);
|
||||
|
||||
// register economy
|
||||
Bukkit.getScheduler().runTask(this, new HookEconomyTask(this));
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("MythicMobs") != null) {
|
||||
MMAPI = ((MythicMobs) getServer().getPluginManager().getPlugin("MythicMobs")).getAPI();
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("CoreProtect") != null) {
|
||||
CPPresent = true;
|
||||
CPAPI = ((CoreProtect) getServer().getPluginManager().getPlugin("CoreProtect")).getAPI();
|
||||
|
1
com/gamingmesh/jobs/actions/.gitignore
vendored
1
com/gamingmesh/jobs/actions/.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
/MaterialActionInfo.class
|
||||
/EnchantActionInfo.class
|
||||
/CustomKillInfo.class
|
||||
/MMKillInfo.class
|
||||
|
@ -29,39 +29,39 @@ import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.BaseActionInfo;
|
||||
|
||||
public class EntityActionInfo extends BaseActionInfo implements ActionInfo {
|
||||
private Entity entity;
|
||||
private Entity entity;
|
||||
|
||||
public EntityActionInfo(Entity entity, ActionType type) {
|
||||
super(type);
|
||||
this.entity = entity;
|
||||
public EntityActionInfo(Entity entity, ActionType type) {
|
||||
super(type);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (this.entity instanceof Skeleton) {
|
||||
Skeleton skeleton = (Skeleton) this.entity;
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||
return "WitherSkeleton";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (this.entity instanceof Skeleton) {
|
||||
Skeleton skeleton = (Skeleton) this.entity;
|
||||
if (skeleton.getSkeletonType() == SkeletonType.WITHER)
|
||||
return "WitherSkeleton";
|
||||
}
|
||||
|
||||
if (this.entity instanceof Zombie) {
|
||||
Zombie zombie = (Zombie) this.entity;
|
||||
if (zombie.isVillager())
|
||||
return "ZombieVillager";
|
||||
}
|
||||
|
||||
if (this.entity.getType().toString().toLowerCase().contains("guardian"))
|
||||
if (this.entity instanceof Guardian) {
|
||||
Guardian guardian = (Guardian) this.entity;
|
||||
if (guardian.isElder())
|
||||
return "ElderGuardian";
|
||||
}
|
||||
|
||||
return entity.getType().toString();
|
||||
if (this.entity instanceof Zombie) {
|
||||
Zombie zombie = (Zombie) this.entity;
|
||||
if (zombie.isVillager())
|
||||
return "ZombieVillager";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameWithSub() {
|
||||
return getName();
|
||||
}
|
||||
if (this.entity.getType().toString().toLowerCase().contains("guardian"))
|
||||
if (this.entity instanceof Guardian) {
|
||||
Guardian guardian = (Guardian) this.entity;
|
||||
if (guardian.isElder())
|
||||
return "ElderGuardian";
|
||||
}
|
||||
|
||||
return entity.getType().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameWithSub() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
42
com/gamingmesh/jobs/actions/MMKillInfo.java
Normal file
42
com/gamingmesh/jobs/actions/MMKillInfo.java
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Jobs Plugin for Bukkit
|
||||
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.gamingmesh.jobs.actions;
|
||||
|
||||
import com.gamingmesh.jobs.container.ActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.BaseActionInfo;
|
||||
|
||||
public class MMKillInfo extends BaseActionInfo implements ActionInfo {
|
||||
private String name;
|
||||
|
||||
public MMKillInfo(String name, ActionType type) {
|
||||
super(type);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameWithSub() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -420,8 +420,7 @@ public class JobConfig {
|
||||
if (enchant != null)
|
||||
id = enchant.getId();
|
||||
type = myKey;
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR) {
|
||||
|
||||
} else if (actionType == ActionType.CUSTOMKILL || actionType == ActionType.SHEAR || actionType == ActionType.MMKILL) {
|
||||
type = myKey;
|
||||
}
|
||||
|
||||
|
@ -1219,6 +1219,8 @@ public class JobsConfiguration {
|
||||
GetConfigString("command.info.output.place.none", "%jobname% does not get money for placing blocks.", writer, conf, true);
|
||||
GetConfigString("command.info.output.kill.info", "Kill", writer, conf, true);
|
||||
GetConfigString("command.info.output.kill.none", "%jobname% does not get money for killing monsters.", writer, conf, true);
|
||||
GetConfigString("command.info.output.mmkill.info", "MMKill", writer, conf, true);
|
||||
GetConfigString("command.info.output.mmkill.none", "%jobname% does not get money for killing Mythic monsters.", writer, conf, true);
|
||||
GetConfigString("command.info.output.fish.info", "Fish", writer, conf, true);
|
||||
GetConfigString("command.info.output.fish.none", "%jobname% does not get money from fishing.", writer, conf, true);
|
||||
GetConfigString("command.info.output.craft.info", "Craft", writer, conf, true);
|
||||
|
@ -22,6 +22,7 @@ public enum ActionType {
|
||||
BREAK("Break"),
|
||||
PLACE("Place"),
|
||||
KILL("Kill"),
|
||||
MMKILL("MMKill"),
|
||||
FISH("Fish"),
|
||||
CRAFT("Craft"),
|
||||
SMELT("Smelt"),
|
||||
|
1
com/gamingmesh/jobs/listeners/.gitignore
vendored
1
com/gamingmesh/jobs/listeners/.gitignore
vendored
@ -6,3 +6,4 @@
|
||||
/JobsPaymentListener$1.class
|
||||
/JobsListener$1.class
|
||||
/JobsPaymentListener$2.class
|
||||
/MythicMobsListener.class
|
||||
|
@ -854,6 +854,11 @@ public class JobsPaymentListener implements Listener {
|
||||
if (lVictim.getKiller().hasMetadata("NPC"))
|
||||
return;
|
||||
|
||||
if (MythicMobsListener.Present) {
|
||||
if (JobsPlugin.MMAPI.getMobAPI().isMythicMob(lVictim))
|
||||
return;
|
||||
}
|
||||
|
||||
// mob spawner, no payment or experience
|
||||
if (lVictim.hasMetadata(mobSpawnerMetadata) && !ConfigManager.getJobsConfiguration().payNearSpawner()) {
|
||||
//lVictim.removeMetadata(mobSpawnerMetadata, plugin);
|
||||
|
@ -19,54 +19,51 @@ import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||
|
||||
public class McMMOlistener implements Listener {
|
||||
|
||||
private JobsPlugin plugin;
|
||||
public static boolean mcMMOPresent = false;
|
||||
private JobsPlugin plugin;
|
||||
public static boolean mcMMOPresent = false;
|
||||
|
||||
public McMMOlistener(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnItemrepair(McMMOPlayerRepairCheckEvent event) {
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
if (!(event.getPlayer() instanceof Player))
|
||||
return;
|
||||
|
||||
Player 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) && !ConfigManager.getJobsConfiguration().payInCreative())
|
||||
return;
|
||||
|
||||
// Wearing armor
|
||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||
|
||||
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), multiplier, null, armor);
|
||||
}
|
||||
|
||||
public static boolean CheckmcMMO() {
|
||||
Plugin McMMO = Bukkit.getPluginManager().getPlugin("mcMMO");
|
||||
if (McMMO != null) {
|
||||
mcMMOPresent = true;
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "mcMMO was found - Enabling capabilities.");
|
||||
return true;
|
||||
} else {
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GOLD + "mcMMO was not found - Disabling capabilities.");
|
||||
mcMMOPresent = false;
|
||||
return false;
|
||||
}
|
||||
public McMMOlistener(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnItemrepair(McMMOPlayerRepairCheckEvent event) {
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
if (!(event.getPlayer() instanceof Player))
|
||||
return;
|
||||
|
||||
Player 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) && !ConfigManager.getJobsConfiguration().payInCreative())
|
||||
return;
|
||||
|
||||
// Wearing armor
|
||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||
|
||||
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), multiplier, null, armor);
|
||||
}
|
||||
|
||||
public static boolean CheckmcMMO() {
|
||||
Plugin McMMO = Bukkit.getPluginManager().getPlugin("mcMMO");
|
||||
if (McMMO != null) {
|
||||
mcMMOPresent = true;
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "mcMMO was found - Enabling capabilities.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
106
com/gamingmesh/jobs/listeners/MythicMobsListener.java
Normal file
106
com/gamingmesh/jobs/listeners/MythicMobsListener.java
Normal file
@ -0,0 +1,106 @@
|
||||
package com.gamingmesh.jobs.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.JobsPlugin;
|
||||
import com.gamingmesh.jobs.actions.MMKillInfo;
|
||||
import com.gamingmesh.jobs.config.ConfigManager;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.Perm;
|
||||
import net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent;
|
||||
import net.elseland.xikage.MythicMobs.Mobs.MythicMob;
|
||||
|
||||
public class MythicMobsListener implements Listener {
|
||||
|
||||
private JobsPlugin plugin;
|
||||
public static boolean Present = false;
|
||||
|
||||
public MythicMobsListener(JobsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnItemrepair(MythicMobDeathEvent event) {
|
||||
|
||||
// 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;
|
||||
|
||||
Double PetPayMultiplier = 1.0;
|
||||
// Checking if killer is player
|
||||
if (event.getKiller() instanceof Player)
|
||||
pDamager = (Player) event.getKiller();
|
||||
// Checking if killer is tamed animal
|
||||
else if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
||||
if (((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager() instanceof Tameable) {
|
||||
Tameable t = (Tameable) ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
|
||||
if (t.isTamed() && t.getOwner() instanceof Player) {
|
||||
pDamager = (Player) t.getOwner();
|
||||
if (Perm.hasPermission(pDamager, "jobs.petpay") || Perm.hasPermission(pDamager, "jobs.vippetpay"))
|
||||
PetPayMultiplier = ConfigManager.getJobsConfiguration().VipPetPay;
|
||||
else
|
||||
PetPayMultiplier = ConfigManager.getJobsConfiguration().PetPay;
|
||||
}
|
||||
}
|
||||
} else
|
||||
return;
|
||||
|
||||
if (pDamager == null)
|
||||
return;
|
||||
// check if in creative
|
||||
if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// restricted area multiplier
|
||||
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(pDamager);
|
||||
|
||||
// pay
|
||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
|
||||
|
||||
if (jDamager == null)
|
||||
return;
|
||||
|
||||
// Item in hand
|
||||
ItemStack item = pDamager.getItemInHand().hasItemMeta() ? pDamager.getItemInHand() : null;
|
||||
|
||||
// Wearing armor
|
||||
ItemStack[] armor = pDamager.getInventory().getArmorContents();
|
||||
|
||||
// Calulating multiplaier
|
||||
multiplier = multiplier * PetPayMultiplier;
|
||||
|
||||
Jobs.action(jDamager, new MMKillInfo(lVictim.getInternalName(), ActionType.MMKILL), multiplier, item, armor);
|
||||
}
|
||||
|
||||
public static boolean Check() {
|
||||
Plugin mm = Bukkit.getPluginManager().getPlugin("MythicMobs");
|
||||
if (mm != null) {
|
||||
Present = true;
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "MythicMobs was found - Enabling capabilities.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -17,6 +17,10 @@ public class OfflinePlayerList {
|
||||
for (OfflinePlayer one : Bukkit.getOfflinePlayers()) {
|
||||
if (one == null)
|
||||
continue;
|
||||
if (one.getName() == null)
|
||||
continue;
|
||||
if (one.getUniqueId() == null)
|
||||
continue;
|
||||
map.put(one.getName().toLowerCase(), one);
|
||||
uuidmap.put(one.getUniqueId(), one);
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ public class TranslateName {
|
||||
}
|
||||
break;
|
||||
case CUSTOMKILL:
|
||||
case MMKILL:
|
||||
break;
|
||||
case SHEAR:
|
||||
for (NameList one : ConfigManager.getJobsConfiguration().ListOfColors) {
|
||||
|
@ -136,6 +136,14 @@ Jobs:
|
||||
income: 7.5
|
||||
# base experience
|
||||
experience: 7.5
|
||||
# killing a MythicMob
|
||||
MMKill:
|
||||
# mob name
|
||||
CustomNameHere:
|
||||
# base income
|
||||
income: 7.5
|
||||
# base experience
|
||||
experience: 7.5
|
||||
# Killing player with certain job
|
||||
custom-kill:
|
||||
Woodcutter:
|
||||
|
@ -1,9 +1,9 @@
|
||||
name: Jobs
|
||||
description: Jobs Plugin for the BukkitAPI
|
||||
main: com.gamingmesh.jobs.JobsPlugin
|
||||
version: 2.51.4
|
||||
version: 2.52.0
|
||||
author: phrstbrn
|
||||
softdepend: [Vault]
|
||||
softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
|
||||
commands:
|
||||
jobs:
|
||||
description: Jobs
|
||||
|
Loading…
Reference in New Issue
Block a user