mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 05:55:27 +01:00
Option to ignore bosses from damage amount check
This commit is contained in:
parent
a2018cb7c9
commit
99ff0a3400
@ -105,7 +105,7 @@ public class GeneralConfigManager {
|
||||
EmptyServerAccountActionBar, ActionBarsMessageByDefault, aBarSilentMode, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
|
||||
JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, ShowActionNames, hideItemAttributes,
|
||||
DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UsePerPermissionForLeaving,
|
||||
EnableConfirmation, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve, blockOwnershipTakeOver,
|
||||
EnableConfirmation, jobsInfoOpensBrowse, MonsterDamageUse, MonsterDamageIgnoreBosses, useMaxPaymentCurve, blockOwnershipTakeOver,
|
||||
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel, RomanNumbers,
|
||||
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, ExploreSaveIntoDatabase = false, DBCleaningJobsUse, DBCleaningUsersUse,
|
||||
DisabledWorldsUse, UseAsWhiteListWorldList, MythicMobsEnabled,
|
||||
@ -910,6 +910,9 @@ public class GeneralConfigManager {
|
||||
"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.addComment("ExploitProtections.General.MonsterDamage.IgnoreBosses", "When enabled we will avoid checking damage done to ender dragon, wither and warden",
|
||||
"This can help out in case you have server with custom damage sources which might not be registered and payouts might not be given out");
|
||||
MonsterDamageIgnoreBosses = c.get("ExploitProtections.General.MonsterDamage.IgnoreBosses", true);
|
||||
|
||||
c.addComment("ExploitProtections.McMMO", "McMMO abilities");
|
||||
c.addComment("ExploitProtections.McMMO.TreeFellerMultiplier", "Players will get part of money from cutting trees with treefeller ability enabled.",
|
||||
|
@ -153,9 +153,9 @@ public final class JobsPaymentListener implements Listener {
|
||||
.build();
|
||||
|
||||
private final Cache<UUID, Player> entityLastDamager = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
||||
.weakKeys()
|
||||
.build();
|
||||
.expireAfterWrite(5, TimeUnit.MINUTES)
|
||||
.weakKeys()
|
||||
.build();
|
||||
private Cache<UUID, Long> cowMilkingTimer;
|
||||
|
||||
public JobsPaymentListener(Jobs plugin) {
|
||||
@ -1246,7 +1246,8 @@ public final class JobsPaymentListener implements Listener {
|
||||
//Gross but works
|
||||
entityLastDamager.put(ent.getUniqueId(), (Player) ((EntityDamageByEntityEvent) event).getDamager());
|
||||
|
||||
if(!Jobs.getGCManager().MonsterDamageUse) return;
|
||||
if (!Jobs.getGCManager().MonsterDamageUse)
|
||||
return;
|
||||
|
||||
double damage = event.getFinalDamage();
|
||||
double s = ((Damageable) ent).getHealth();
|
||||
@ -1296,14 +1297,15 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
if(!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
LivingEntity lVictim = event.getEntity();
|
||||
Entity killer;
|
||||
|
||||
if(!(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent)) {
|
||||
if(entityLastDamager.getIfPresent(event.getEntity().getUniqueId()) == null) return;
|
||||
if (!(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent)) {
|
||||
if (entityLastDamager.getIfPresent(event.getEntity().getUniqueId()) == null)
|
||||
return;
|
||||
killer = entityLastDamager.getIfPresent(event.getEntity().getUniqueId());
|
||||
} else {
|
||||
killer = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
|
||||
@ -1324,16 +1326,31 @@ public final class JobsPaymentListener implements Listener {
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().MonsterDamageUse) {
|
||||
UUID lVictimUUID = lVictim.getUniqueId();
|
||||
Double damage = damageDealtByPlayers.getIfPresent(lVictimUUID);
|
||||
|
||||
if (damage != null) {
|
||||
double perc = (damage * 100D) / Util.getMaxHealth(lVictim);
|
||||
boolean ignore = false;
|
||||
if (Jobs.getGCManager().MonsterDamageIgnoreBosses) {
|
||||
CMIEntityType etype = CMIEntityType.getByType(lVictim.getType());
|
||||
switch (etype) {
|
||||
case ENDER_DRAGON:
|
||||
case WITHER:
|
||||
case WARDEN:
|
||||
ignore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
damageDealtByPlayers.invalidate(lVictimUUID);
|
||||
if (!ignore) {
|
||||
UUID lVictimUUID = lVictim.getUniqueId();
|
||||
Double damage = damageDealtByPlayers.getIfPresent(lVictimUUID);
|
||||
|
||||
if (perc < Jobs.getGCManager().MonsterDamagePercentage)
|
||||
return;
|
||||
if (damage != null) {
|
||||
double perc = (damage * 100D) / Util.getMaxHealth(lVictim);
|
||||
|
||||
damageDealtByPlayers.invalidate(lVictimUUID);
|
||||
|
||||
if (perc < Jobs.getGCManager().MonsterDamagePercentage)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user