mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Added wildStacker and stackMob support to pay for stacked entities
Closes #923
This commit is contained in:
parent
a85a54aa5d
commit
c91f88858a
12
pom.xml
12
pom.xml
@ -18,7 +18,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.3-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Boss -->
|
||||
@ -164,6 +164,16 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.OmerBenGera</groupId>
|
||||
<artifactId>WildStackerAPI</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.Nathat23</groupId>
|
||||
<artifactId>StackMob-5</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<!-- WorldGuard & WorldEdit -->
|
||||
|
@ -49,7 +49,7 @@ public class JobsCommands implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player && !Jobs.getGCManager().canPerformActionInWorld(((Player) sender).getWorld()) && !sender.hasPermission("jobs.disabledworld.commands")) {
|
||||
if (sender instanceof Player && !Jobs.getGCManager().canPerformActionInWorld(((Player) sender).getWorld())) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.worldisdisabled"));
|
||||
return true;
|
||||
}
|
||||
|
@ -52,10 +52,10 @@ public class GeneralConfigManager {
|
||||
*/
|
||||
@Deprecated public List<Schedule> BoostSchedule = new ArrayList<>();
|
||||
|
||||
public HashMap<CMIMaterial, HashMap<Enchantment, Integer>> whiteListedItems = new HashMap<>();
|
||||
private HashMap<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<>();
|
||||
private HashMap<CurrencyType, Double> generalMulti = new HashMap<>();
|
||||
private HashMap<String, List<String>> commandArgs = new HashMap<>();
|
||||
public final HashMap<CMIMaterial, HashMap<Enchantment, Integer>> whiteListedItems = new HashMap<>();
|
||||
private final HashMap<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<>();
|
||||
private final HashMap<CurrencyType, Double> generalMulti = new HashMap<>();
|
||||
private final HashMap<String, List<String>> commandArgs = new HashMap<>();
|
||||
|
||||
protected Locale locale;
|
||||
private ConfigReader c = null;
|
||||
@ -101,7 +101,7 @@ public class GeneralConfigManager {
|
||||
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel,
|
||||
BossBarEnabled, BossBarShowOnEachAction, BossBarsMessageByDefault, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
|
||||
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
|
||||
LoggingUse, payForCombiningItems, BlastFurnacesReassign, SmokerReassign;
|
||||
LoggingUse, payForCombiningItems, BlastFurnacesReassign, SmokerReassign, payForStackedEntities;
|
||||
|
||||
public ItemStack guiBackButton, guiNextButton, guiFiller;
|
||||
|
||||
@ -497,6 +497,9 @@ public class GeneralConfigManager {
|
||||
"This option is only related to: sugar_cane, cactus, kelp, bamboo");
|
||||
preventCropResizePayment = c.get("prevent-crop-resize-payment", false);
|
||||
|
||||
c.addComment("pay-for-stacked-entities", "Allows to pay for stacked entities for each one. Requires StackMob or WildStacker.");
|
||||
payForStackedEntities = c.get("pay-for-stacked-entities", false);
|
||||
|
||||
c.addComment("allow-pay-for-durability-loss", "Allows, when losing maximum durability of item then it does not pay the player until it is repaired.",
|
||||
"E.g. the player wants to enchant a item with enchanting table and the item has durability loss then not paying.");
|
||||
c.addComment("allow-pay-for-durability-loss.Use", "Do not disable this if you don't know what mean this option.");
|
||||
|
@ -12,16 +12,20 @@ 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.hooks.stackMob.StackMobHandler;
|
||||
import com.gamingmesh.jobs.hooks.wildStacker.WildStackerHandler;
|
||||
|
||||
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 BossManager bossManager = null;
|
||||
private static McMMOManager McMMOManager;
|
||||
private static MythicMobInterface MythicManager;
|
||||
private static MyPetManager myPetManager;
|
||||
private static WorldGuardManager worldGuardManager;
|
||||
private static BossManager bossManager;
|
||||
private static StackMobHandler stackMobHandler;
|
||||
private static WildStackerHandler wildStackerHandler;
|
||||
|
||||
private static PluginManager pm = null;
|
||||
private static PluginManager pm;
|
||||
|
||||
public static void loadHooks() {
|
||||
pm = Jobs.getInstance().getServer().getPluginManager();
|
||||
@ -33,11 +37,29 @@ public class HookManager {
|
||||
setWorldGuard();
|
||||
setMythicManager();
|
||||
setBossManager();
|
||||
setStackMobHandler();
|
||||
setWildStackerHandler();
|
||||
|
||||
if (checkMythicMobs())
|
||||
MythicManager.registerListener();
|
||||
}
|
||||
|
||||
public static StackMobHandler getStackMobHandler() {
|
||||
if (stackMobHandler == null) {
|
||||
setStackMobHandler();
|
||||
}
|
||||
|
||||
return stackMobHandler;
|
||||
}
|
||||
|
||||
public static WildStackerHandler getWildStackerHandler() {
|
||||
if (wildStackerHandler == null) {
|
||||
setWildStackerHandler();
|
||||
}
|
||||
|
||||
return wildStackerHandler;
|
||||
}
|
||||
|
||||
public static MyPetManager getMyPetManager() {
|
||||
if (myPetManager == null) {
|
||||
setMyPetManager();
|
||||
@ -77,7 +99,7 @@ public class HookManager {
|
||||
}
|
||||
|
||||
private static boolean setWorldGuard() {
|
||||
if (pm.getPlugin("WorldGuard") != null && pm.isPluginEnabled("WorldGuard")) {
|
||||
if (isPluginEnabled("WorldGuard")) {
|
||||
worldGuardManager = new WorldGuardManager();
|
||||
Jobs.consoleMsg("&e[Jobs] WorldGuard detected.");
|
||||
return true;
|
||||
@ -87,7 +109,7 @@ public class HookManager {
|
||||
}
|
||||
|
||||
private static void setMythicManager() {
|
||||
if (pm.getPlugin("MythicMobs") == null)
|
||||
if (!isPluginEnabled("MythicMobs"))
|
||||
return;
|
||||
|
||||
try {
|
||||
@ -122,16 +144,32 @@ public class HookManager {
|
||||
}
|
||||
|
||||
private static void setMyPetManager() {
|
||||
if (pm.getPlugin("MyPet") != null && pm.isPluginEnabled("MyPet")) {
|
||||
if (isPluginEnabled("MyPet")) {
|
||||
myPetManager = new MyPetManager();
|
||||
Jobs.consoleMsg("&e[Jobs] MyPet detected.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBossManager() {
|
||||
if (pm.getPlugin("Boss") != null && pm.isPluginEnabled("Boss")) {
|
||||
if (isPluginEnabled("Boss")) {
|
||||
bossManager = new BossManager();
|
||||
Jobs.consoleMsg("&e[Jobs] Boss detected.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void setStackMobHandler() {
|
||||
if (isPluginEnabled("StackMob")) {
|
||||
stackMobHandler = new StackMobHandler();
|
||||
}
|
||||
}
|
||||
|
||||
private static void setWildStackerHandler() {
|
||||
if (isPluginEnabled("WildStacker")) {
|
||||
wildStackerHandler = new WildStackerHandler();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPluginEnabled(String name) {
|
||||
return pm.getPlugin(name) != null && pm.isPluginEnabled(name);
|
||||
}
|
||||
}
|
||||
|
8
src/main/java/com/gamingmesh/jobs/hooks/HookPlugin.java
Normal file
8
src/main/java/com/gamingmesh/jobs/hooks/HookPlugin.java
Normal file
@ -0,0 +1,8 @@
|
||||
package com.gamingmesh.jobs.hooks;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class HookPlugin {
|
||||
|
||||
public abstract JavaPlugin getPlugin();
|
||||
}
|
@ -27,10 +27,7 @@ public class MythicMobs2 implements MythicMobInterface {
|
||||
|
||||
@Override
|
||||
public boolean isMythicMob(LivingEntity lVictim) {
|
||||
if (MMAPI == null || lVictim == null)
|
||||
return false;
|
||||
|
||||
return MMAPI.getMobAPI().isMythicMob(lVictim);
|
||||
return MMAPI != null && lVictim != null && MMAPI.getMobAPI().isMythicMob(lVictim);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,10 +26,7 @@ public class MythicMobs4 implements MythicMobInterface {
|
||||
|
||||
@Override
|
||||
public boolean isMythicMob(LivingEntity lVictim) {
|
||||
if (MMAPI == null || lVictim == null)
|
||||
return false;
|
||||
|
||||
return MMAPI.isMythicMob(lVictim);
|
||||
return MMAPI != null && lVictim != null && MMAPI.isMythicMob(lVictim);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.gamingmesh.jobs.hooks.stackMob;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.gamingmesh.jobs.hooks.HookPlugin;
|
||||
|
||||
import uk.antiperson.stackmob.StackMob;
|
||||
import uk.antiperson.stackmob.entity.StackEntity;
|
||||
|
||||
public class StackMobHandler extends HookPlugin {
|
||||
|
||||
public boolean isStacked(LivingEntity entity) {
|
||||
return getPlugin().getEntityManager().isStackedEntity(entity);
|
||||
}
|
||||
|
||||
public HashSet<StackEntity> getStackEntities() {
|
||||
return new HashSet<>();
|
||||
// waiting for the author to fix build issue
|
||||
//return getPlugin().getEntityManager().getStackEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StackMob getPlugin() {
|
||||
return JavaPlugin.getPlugin(StackMob.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.gamingmesh.jobs.hooks.wildStacker;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import com.bgsoftware.wildstacker.api.WildStackerAPI;
|
||||
import com.bgsoftware.wildstacker.api.objects.StackedEntity;
|
||||
|
||||
public class WildStackerHandler {
|
||||
|
||||
public boolean isStackedEntity(LivingEntity entity) {
|
||||
return WildStackerAPI.getStackedEntity(entity) != null;
|
||||
}
|
||||
|
||||
public List<StackedEntity> getStackedEntities() {
|
||||
return WildStackerAPI.getWildStacker().getSystemManager().getStackedEntities();
|
||||
}
|
||||
}
|
@ -87,8 +87,12 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
public class JobsPaymentListener implements Listener {
|
||||
|
||||
@ -278,6 +282,17 @@ public class JobsPaymentListener implements Listener {
|
||||
if (jDamager == null || sheep.getColor() == null)
|
||||
return;
|
||||
|
||||
if (Jobs.getGCManager().payForStackedEntities && HookManager.isPluginEnabled("WildStacker")
|
||||
&& HookManager.getWildStackerHandler().isStackedEntity(sheep)) {
|
||||
for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) {
|
||||
if (stacked.getType() == sheep.getType()) {
|
||||
Jobs.action(jDamager, new CustomKillInfo(((Sheep) stacked.getLivingEntity()).getColor().name(), ActionType.SHEAR));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.action(jDamager, new CustomKillInfo(sheep.getColor().name(), ActionType.SHEAR));
|
||||
}
|
||||
|
||||
@ -462,7 +477,7 @@ public class JobsPaymentListener implements Listener {
|
||||
if (!payForItemDurabilityLoss(player))
|
||||
return;
|
||||
|
||||
if (event.getState().equals(PlayerFishEvent.State.CAUGHT_FISH) && event.getCaught() instanceof Item) {
|
||||
if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH && event.getCaught() instanceof Item) {
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
@ -511,6 +526,17 @@ public class JobsPaymentListener implements Listener {
|
||||
if (jDamager == null)
|
||||
return;
|
||||
|
||||
if (Jobs.getGCManager().payForStackedEntities && HookManager.isPluginEnabled("WildStacker")
|
||||
&& HookManager.getWildStackerHandler().isStackedEntity(animal)) {
|
||||
for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) {
|
||||
if (stacked.getType() == animal.getType()) {
|
||||
Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.TAME));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.TAME));
|
||||
}
|
||||
|
||||
@ -851,7 +877,7 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().PayForEnchantingOnAnvil && inv.getItem(1) != null && inv.getItem(1).getType().equals(Material.ENCHANTED_BOOK)) {
|
||||
if (Jobs.getGCManager().PayForEnchantingOnAnvil && inv.getItem(1) != null && inv.getItem(1).getType() == Material.ENCHANTED_BOOK) {
|
||||
Map<Enchantment, Integer> enchants = resultStack.getEnchantments();
|
||||
for (Entry<Enchantment, Integer> oneEnchant : enchants.entrySet()) {
|
||||
Enchantment enchant = oneEnchant.getKey();
|
||||
@ -1090,10 +1116,7 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(damager instanceof Projectile))
|
||||
return;
|
||||
|
||||
if (!(ent instanceof Damageable))
|
||||
if (!(damager instanceof Projectile) || !(ent instanceof Damageable))
|
||||
return;
|
||||
|
||||
Projectile projectile = (Projectile) damager;
|
||||
@ -1205,6 +1228,17 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().payForStackedEntities && HookManager.isPluginEnabled("WildStacker")
|
||||
&& HookManager.getWildStackerHandler().isStackedEntity(lVictim)) {
|
||||
for (com.bgsoftware.wildstacker.api.objects.StackedEntity stacked : HookManager.getWildStackerHandler().getStackedEntities()) {
|
||||
if (stacked.getType() == lVictim.getType()) {
|
||||
Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.KILL), pDamager, stacked.getLivingEntity());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), pDamager, lVictim);
|
||||
|
||||
// Payment for killing player with particular job, except NPC's
|
||||
@ -1298,7 +1332,7 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
|
||||
Location loc = event.getLocation();
|
||||
Collection<Entity> ents = Version.isCurrentEqualOrLower(Version.v1_8_R1) || loc.getWorld() == null
|
||||
java.util.Collection<Entity> ents = Version.isCurrentEqualOrLower(Version.v1_8_R1) || loc.getWorld() == null
|
||||
? null : loc.getWorld().getNearbyEntities(loc, 4, 4, 4);
|
||||
if (ents == null) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user