1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-27 19:37:48 +01:00

Fix dependencies and fix entities that die due to fire damage,magma blocks,cactus, or other after being hit not rewarding job payouts.

This commit is contained in:
DersWasTaken 2023-11-29 11:05:53 -07:00
parent d03d53d7e5
commit ed86b70d60
4 changed files with 34 additions and 30 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
src/main/resources/locale/messages_en.yml src/main/resources/locale/messages_en.yml
.classpath .classpath
.project .project
/build/

View File

@ -226,11 +226,6 @@
<!-- Temporary solution for replacing repository --> <!-- Temporary solution for replacing repository -->
<systemPath>${basedir}/libs/mypet-3.11-20210318.180552-1.jar</systemPath> <systemPath>${basedir}/libs/mypet-3.11-20210318.180552-1.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>CMILib</groupId>
<artifactId>CMILib</artifactId>
<version>1.4.3.1</version>
</dependency>
</dependencies> </dependencies>
<repositories> <repositories>
<!-- MythicMobs --> <!-- MythicMobs -->
@ -293,7 +288,7 @@
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version> <version>2.3.1</version>
<configuration> <configuration>
<outputDirectory>D:\MC\Server 1.20\plugins\</outputDirectory> <outputDirectory>build/jar</outputDirectory>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -787,6 +787,7 @@ public final class Jobs extends JavaPlugin {
getDBManager().getDB().triggerTableIdUpdate(); getDBManager().getDB().triggerTableIdUpdate();
CMIMessages.consoleMessage("&ePlugin has been enabled successfully."); CMIMessages.consoleMessage("&ePlugin has been enabled successfully.");
CMIMessages.consoleMessage("&eAAAAAAAAAAAAAAAAAAA");
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled."); System.out.println("There was some issues when starting plugin. Please contact dev about this. Plugin will be disabled.");

View File

@ -151,6 +151,11 @@ public final class JobsPaymentListener implements Listener {
.expireAfterWrite(10, TimeUnit.SECONDS) .expireAfterWrite(10, TimeUnit.SECONDS)
.weakKeys() .weakKeys()
.build(); .build();
private final Cache<UUID, Player> entityLastDamager = CacheBuilder.newBuilder()
.expireAfterWrite(5, TimeUnit.MINUTES)
.weakKeys()
.build();
private Cache<UUID, Long> cowMilkingTimer; private Cache<UUID, Long> cowMilkingTimer;
public JobsPaymentListener(Jobs plugin) { public JobsPaymentListener(Jobs plugin) {
@ -1227,7 +1232,7 @@ public final class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamageByPlayer(EntityDamageEvent event) { public void onEntityDamageByPlayer(EntityDamageEvent event) {
if (!Jobs.getGCManager().MonsterDamageUse || !(event instanceof EntityDamageByEntityEvent) if (!(event instanceof EntityDamageByEntityEvent)
|| !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) || !Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
@ -1238,6 +1243,11 @@ public final class JobsPaymentListener implements Listener {
if (!(((EntityDamageByEntityEvent) event).getDamager() instanceof Player)) if (!(((EntityDamageByEntityEvent) event).getDamager() instanceof Player))
return; return;
//Gross but works
entityLastDamager.put(ent.getUniqueId(), (Player) ((EntityDamageByEntityEvent) event).getDamager());
if(!Jobs.getGCManager().MonsterDamageUse) return;
double damage = event.getFinalDamage(); double damage = event.getFinalDamage();
double s = ((Damageable) ent).getHealth(); double s = ((Damageable) ent).getHealth();
if (damage > s) if (damage > s)
@ -1274,6 +1284,7 @@ public final class JobsPaymentListener implements Listener {
damage = s; damage = s;
if (((Projectile) event.getDamager()).getShooter() instanceof Player) { if (((Projectile) event.getDamager()).getShooter() instanceof Player) {
entityLastDamager.put(ent.getUniqueId(), (Player) ((Projectile) event.getDamager()).getShooter());
Double damageDealt = damageDealtByPlayers.getIfPresent(entUUID); Double damageDealt = damageDealtByPlayers.getIfPresent(entUUID);
if (damageDealt != null) { if (damageDealt != null) {
damageDealtByPlayers.put(entUUID, damageDealt + damage); damageDealtByPlayers.put(entUUID, damageDealt + damage);
@ -1285,17 +1296,18 @@ public final class JobsPaymentListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
if (!(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) || if(!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
return; return;
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event.getEntity().getLastDamageCause(); LivingEntity lVictim = event.getEntity();
Entity killer;
// Entity that died must be living if(!(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent)) {
if (!(e.getEntity() instanceof LivingEntity)) if(entityLastDamager.getIfPresent(event.getEntity().getUniqueId()) == null) return;
return; killer = entityLastDamager.getIfPresent(event.getEntity().getUniqueId());
} else {
LivingEntity lVictim = (LivingEntity) e.getEntity(); killer = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
}
// mob spawner, no payment or experience // mob spawner, no payment or experience
if (!Jobs.getGCManager().payNearSpawner() && lVictim.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) { if (!Jobs.getGCManager().payNearSpawner() && lVictim.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
@ -1326,7 +1338,7 @@ public final class JobsPaymentListener implements Listener {
} }
//extra check for Citizens 2 sentry kills //extra check for Citizens 2 sentry kills
if (e.getDamager() instanceof Player && e.getDamager().hasMetadata("NPC")) if (killer.hasMetadata("NPC"))
return; return;
if (Jobs.getGCManager().MythicMobsEnabled && HookManager.getMythicManager() != null if (Jobs.getGCManager().MythicMobsEnabled && HookManager.getMythicManager() != null
@ -1336,26 +1348,21 @@ public final class JobsPaymentListener implements Listener {
Player pDamager = null; Player pDamager = null;
boolean isTameable = e.getDamager() instanceof Tameable; boolean isTameable = killer instanceof Tameable;
boolean isMyPet = HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager(), null); boolean isMyPet = HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(killer, null);
if (e.getDamager() instanceof Player) { // Checking if killer is player if (killer instanceof Player) { // Checking if killer is player
pDamager = (Player) e.getDamager(); pDamager = (Player) killer;
} else if (isMyPet) { // Checking if killer is MyPet animal } else if (isMyPet) { // Checking if killer is MyPet animal
UUID uuid = HookManager.getMyPetManager().getOwnerOfPet(e.getDamager()); UUID uuid = HookManager.getMyPetManager().getOwnerOfPet(killer);
if (uuid != null) if (uuid != null)
pDamager = Bukkit.getPlayer(uuid); pDamager = Bukkit.getPlayer(uuid);
} else if (isTameable) { // Checking if killer is tamed animal } else if (isTameable) { // Checking if killer is tamed animal
Tameable t = (Tameable) e.getDamager(); Tameable t = (Tameable) killer;
if (t.isTamed() && t.getOwner() instanceof Player) if (t.isTamed() && t.getOwner() instanceof Player)
pDamager = (Player) t.getOwner(); pDamager = (Player) t.getOwner();
} else if (e.getDamager() instanceof Projectile) {
Projectile pr = (Projectile) e.getDamager();
if (pr.getShooter() instanceof Player)
pDamager = (Player) pr.getShooter();
} }
if (pDamager == null) if (pDamager == null)
@ -1396,18 +1403,18 @@ public final class JobsPaymentListener implements Listener {
if (Jobs.getGCManager().payForStackedEntities) { if (Jobs.getGCManager().payForStackedEntities) {
if (JobsHook.WildStacker.isEnabled()) { if (JobsHook.WildStacker.isEnabled()) {
for (int i = 0; i < HookManager.getWildStackerHandler().getEntityAmount(lVictim) - 1; i++) { for (int i = 0; i < HookManager.getWildStackerHandler().getEntityAmount(lVictim) - 1; i++) {
Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), e.getDamager(), lVictim); Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), killer, lVictim);
} }
} else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked(lVictim)) { } else if (JobsHook.StackMob.isEnabled() && HookManager.getStackMobHandler().isStacked(lVictim)) {
for (uk.antiperson.stackmob.entity.StackEntity stacked : HookManager.getStackMobHandler().getStackEntities()) { for (uk.antiperson.stackmob.entity.StackEntity stacked : HookManager.getStackMobHandler().getStackEntities()) {
if (stacked.getEntity().getType() == lVictim.getType()) { if (stacked.getEntity().getType() == lVictim.getType()) {
Jobs.action(jDamager, new EntityActionInfo(stacked.getEntity(), ActionType.KILL), e.getDamager(), stacked.getEntity()); Jobs.action(jDamager, new EntityActionInfo(stacked.getEntity(), ActionType.KILL), killer, stacked.getEntity());
} }
} }
} }
} }
Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), e.getDamager(), lVictim); Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), killer, lVictim);
// Payment for killing player with particular job, except NPC's // Payment for killing player with particular job, except NPC's
if (notNpc) { if (notNpc) {