mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-30 21:07:48 +01:00
New option to prevent payment if player is not doing enough damage to
monster
This commit is contained in:
parent
798294070b
commit
2b14078860
@ -71,7 +71,6 @@ import com.gamingmesh.jobs.dao.JobsDAO;
|
||||
import com.gamingmesh.jobs.economy.BufferedEconomy;
|
||||
import com.gamingmesh.jobs.economy.BufferedPayment;
|
||||
import com.gamingmesh.jobs.economy.Economy;
|
||||
import com.gamingmesh.jobs.economy.PaymentData;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.listeners.JobsListener;
|
||||
import com.gamingmesh.jobs.listeners.JobsPaymentListener;
|
||||
@ -79,7 +78,6 @@ import com.gamingmesh.jobs.listeners.McMMOlistener;
|
||||
import com.gamingmesh.jobs.listeners.MythicMobsListener;
|
||||
import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.JobsClassLoader;
|
||||
import com.gamingmesh.jobs.stuff.Loging;
|
||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||
@ -131,10 +129,6 @@ public class Jobs extends JavaPlugin {
|
||||
public static BufferedPaymentThread paymentThread = null;
|
||||
private static DatabaseSaveThread saveTask = null;
|
||||
|
||||
public static HashMap<String, PaymentData> paymentLimit = new HashMap<String, PaymentData>();
|
||||
public static HashMap<String, PaymentData> ExpLimit = new HashMap<String, PaymentData>();
|
||||
public static HashMap<String, PaymentData> PointLimit = new HashMap<String, PaymentData>();
|
||||
|
||||
public static HashMap<String, FastPayment> FastPayment = new HashMap<String, FastPayment>();
|
||||
|
||||
private static NMS nms;
|
||||
|
@ -103,6 +103,9 @@ public class GeneralConfigManager {
|
||||
public double MinimumOveralPaymentLimit;
|
||||
public double MinimumOveralPointsLimit;
|
||||
|
||||
public boolean MonsterDamageUse = false;
|
||||
public double MonsterDamagePercentage;
|
||||
|
||||
public HashMap<CurrencyType, Double> Boost = new HashMap<CurrencyType, Double>();
|
||||
|
||||
public double DynamicPaymentMaxPenalty;
|
||||
@ -717,6 +720,11 @@ public class GeneralConfigManager {
|
||||
PetPay = c.get("ExploitProtections.General.PetPay", 0.1) - 1D;
|
||||
VipPetPay = c.get("ExploitProtections.General.VipPetPay", 1.0) - 1D;
|
||||
|
||||
c.getW().addComment("ExploitProtections.General.MonsterDamage.Use", "This section controls how much damage player should do to monster for player to get paid",
|
||||
"This prevents from killing monsters in one hit when they suffer in example fall damage");
|
||||
MonsterDamageUse = c.get("ExploitProtections.General.MonsterDamage.Use", false);
|
||||
MonsterDamagePercentage = c.get("ExploitProtections.General.MonsterDamage.Percentage", 60);
|
||||
|
||||
c.getW().addComment("ExploitProtections.McMMO", "McMMO abilities");
|
||||
c.getW().addComment("ExploitProtections.McMMO.TreeFellerMultiplier", "Players will get part of money from cutting trees with treefeller ability enabled.",
|
||||
"0.2 means 20% of original price");
|
||||
|
@ -29,6 +29,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Damageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
@ -46,6 +47,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
@ -67,6 +69,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.actions.BlockActionInfo;
|
||||
@ -84,17 +87,17 @@ import com.gamingmesh.jobs.container.FastPayment;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
public class JobsPaymentListener implements Listener {
|
||||
private Jobs plugin;
|
||||
private final String furnaceOwnerMetadata = "jobsFurnaceOwner";
|
||||
public final static String brewingOwnerMetadata = "jobsBrewingOwner";
|
||||
public static final String BlockMetadata = "BlockOwner";
|
||||
public static final String PlacedBlockMetadata = "JobsBlockOwner";
|
||||
private final String brewingOwnerMetadata = "jobsBrewingOwner";
|
||||
private final String BlockMetadata = "BlockOwner";
|
||||
public static final String VegyMetadata = "VegyTimer";
|
||||
public static final String GlobalMetadata = "GlobalTimer";
|
||||
public static final String CowMetadata = "CowTimer";
|
||||
private final String CowMetadata = "CowTimer";
|
||||
private final String entityDamageByPlayer = "JobsEntityDamagePlayer";
|
||||
|
||||
public JobsPaymentListener(Jobs plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -753,6 +756,59 @@ public class JobsPaymentListener implements Listener {
|
||||
Jobs.action(jPlayer, new ItemActionInfo(event.getResult(), ActionType.SMELT));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByPlayer(EntityDamageEvent event) {
|
||||
//disabling plugin in world
|
||||
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if (!Jobs.getGCManager().MonsterDamageUse)
|
||||
return;
|
||||
|
||||
Entity ent = event.getEntity();
|
||||
if (ent instanceof Player)
|
||||
return;
|
||||
if (!(event instanceof EntityDamageByEntityEvent))
|
||||
return;
|
||||
EntityDamageByEntityEvent attackevent = (EntityDamageByEntityEvent) event;
|
||||
Entity damager = attackevent.getDamager();
|
||||
if (!(damager instanceof Player))
|
||||
return;
|
||||
double damage = event.getFinalDamage();
|
||||
double s = ((Damageable) ent).getHealth();
|
||||
if (damage > s)
|
||||
damage = s;
|
||||
if (ent.hasMetadata(entityDamageByPlayer))
|
||||
damage += ent.getMetadata(entityDamageByPlayer).get(0).asDouble();
|
||||
ent.setMetadata(entityDamageByPlayer, new FixedMetadataValue(this.plugin, damage));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
|
||||
//disabling plugin in world
|
||||
if (event.getEntity() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
Entity ent = event.getEntity();
|
||||
Entity damager = event.getDamager();
|
||||
if (!(damager instanceof Projectile))
|
||||
return;
|
||||
Projectile projectile = (Projectile) damager;
|
||||
ProjectileSource shooter = projectile.getShooter();
|
||||
double damage = event.getFinalDamage();
|
||||
|
||||
double s = ((Damageable) ent).getHealth();
|
||||
|
||||
if (damage > s)
|
||||
damage = s;
|
||||
|
||||
if (shooter instanceof Player) {
|
||||
if (ent.hasMetadata(entityDamageByPlayer))
|
||||
damage += ent.getMetadata(entityDamageByPlayer).get(0).asDouble();
|
||||
ent.setMetadata(entityDamageByPlayer, new FixedMetadataValue(this.plugin, damage));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
//disabling plugin in world
|
||||
@ -828,6 +884,13 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().MonsterDamageUse && lVictim.hasMetadata(entityDamageByPlayer)) {
|
||||
double damage = lVictim.getMetadata(entityDamageByPlayer).get(0).asDouble();
|
||||
double perc = (damage * 100D) / lVictim.getMaxHealth();
|
||||
if (perc < Jobs.getGCManager().MonsterDamagePercentage)
|
||||
return;
|
||||
}
|
||||
|
||||
Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), e.getDamager(), lVictim);
|
||||
|
||||
// Payment for killing player with particular job, except NPC's
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Jobs
|
||||
description: Jobs Plugin for the BukkitAPI
|
||||
main: com.gamingmesh.jobs.Jobs
|
||||
version: 3.7.2
|
||||
version: 3.7.3
|
||||
author: phrstbrn
|
||||
softdepend: [Vault, iConomy, MythicMobs, McMMO]
|
||||
commands:
|
||||
|
Loading…
Reference in New Issue
Block a user