5
5
import java .util .HashSet ;
6
6
import java .util .Iterator ;
7
7
import java .util .Map ;
8
+ import java .util .Objects ;
8
9
import java .util .Random ;
9
10
import java .util .UUID ;
10
11
import javax .annotation .Nonnull ;
33
34
import net .evmodder .DropHeads .DropHeads ;
34
35
import net .evmodder .DropHeads .JunkUtils ;
35
36
import net .evmodder .DropHeads .TextureKeyLookup ;
37
+ import net .evmodder .DropHeads .commands .CommandDropRate ;
36
38
import net .evmodder .DropHeads .datatypes .EntitySetting ;
37
39
import net .evmodder .DropHeads .events .HeadRollEvent ;
38
40
import net .evmodder .EvLib .EvUtils ;
@@ -45,23 +47,24 @@ public class EntityDeathListener implements Listener{
45
47
private final Random rand ;
46
48
private final HashSet <UUID > explodingChargedCreepers ;
47
49
private final EventPriority PRIORITY ;
48
- private final boolean USE_RANGED_WEAPON_FOR_LOOTING ;
49
- private final EntitySetting <Boolean > allowNonPlayerKills , allowIndirectKills , allowProjectileKills ;//, useRangedWeaponForLooting;
50
+ private final EntitySetting <Boolean > allowNonPlayerKills , allowIndirectPlayerKills , allowProjectileKills ;//, useRangedWeaponForLooting;
50
51
//TODO: pkillonly config per-mob?
52
+ private final boolean USE_RANGED_WEAPON_FOR_LOOTING ;
51
53
private final boolean CHARGED_CREEPER_DROPS , VANILLA_WSKELE_HANDLING ;
52
54
private final long INDIRECT_KILL_THRESHOLD_MILLIS ;
53
55
private final boolean DEBUG_MODE ;
54
56
55
57
public static final class Friend {private Friend (){}}
56
58
57
- public EntityDeathListener (DeathMessagePacketIntercepter deathMessageBlocker ){
58
- pl = DropHeads . getPlugin ();
59
+ public EntityDeathListener (DeathMessagePacketIntercepter deathMessageBlocker ,
60
+ EntitySetting < Boolean > allowNonPlayerKills , EntitySetting < Boolean > allowIndirectPlayerKills , EntitySetting < Boolean > allowProjectileKills ){
59
61
this .deathMessageBlocker = deathMessageBlocker ;
62
+ this .allowNonPlayerKills = allowNonPlayerKills ;
63
+ this .allowIndirectPlayerKills = allowIndirectPlayerKills ;
64
+ this .allowProjectileKills = allowProjectileKills ;
65
+ pl = DropHeads .getPlugin ();
60
66
rand = new Random ();
61
67
USE_RANGED_WEAPON_FOR_LOOTING = pl .getConfig ().getBoolean ("use-ranged-weapon-for-looting" , true );
62
- allowNonPlayerKills = EntitySetting .fromConfig (pl , "drop-for-nonplayer-kills" , false , null );
63
- allowIndirectKills = EntitySetting .fromConfig (pl , "drop-for-indirect-kills" , false , null );
64
- allowProjectileKills = EntitySetting .fromConfig (pl , "drop-for-ranged-kills" , false , null );
65
68
66
69
CHARGED_CREEPER_DROPS = pl .getConfig ().getBoolean ("charged-creeper-drops" , true );
67
70
VANILLA_WSKELE_HANDLING = pl .getConfig ().getBoolean ("vanilla-wither-skeleton-skulls" , false );
@@ -157,6 +160,17 @@ boolean onEntityDeath(@Nonnull final Entity victim, final Entity killer, final E
157
160
}
158
161
}
159
162
// Check if killer qualifies to trigger a behead.
163
+ // if(killer != null){
164
+ // if(!allowProjectileKills.get(victim) && killer instanceof Projectile) return false;
165
+ // if(!allowNonPlayerKills.get(victim) && killer instanceof Player == false &&
166
+ // !(allowProjectileKills.get(victim) && killer instanceof Projectile proj && proj.getShooter() instanceof Player)
167
+ // ) return false;
168
+ // }
169
+ // else if(!allowNonPlayerKills.get(victim) &&
170
+ // (!allowIndirectPlayerKills.get(victim) || JunkUtils.timeSinceLastPlayerDamage(victim) > INDIRECT_KILL_THRESHOLD_MILLIS)
171
+ // ) return false;
172
+ //
173
+ // }
160
174
if (killer == null
161
175
? (!allowIndirectKills .get (victim ) ||
162
176
(INDIRECT_KILL_THRESHOLD_MILLIS >= 0 && JunkUtils .timeSinceLastPlayerDamage (victim ) > INDIRECT_KILL_THRESHOLD_MILLIS ))
@@ -166,14 +180,6 @@ boolean onEntityDeath(@Nonnull final Entity victim, final Entity killer, final E
166
180
!(allowProjectileKills .get (victim ) && killer instanceof Projectile proj && proj .getShooter () instanceof Player )
167
181
)
168
182
) return false ;
169
- // if(
170
- // // Note: Won't use timeSinceLastEntityDamage()... it would be expensive to keep track of
171
- // (killer == null && (!allowIndirectKills.get(victim) || JunkUtils.timeSinceLastPlayerDamage(victim) > INDIRECT_KILL_THRESHOLD_MILLIS)) ||
172
- // (killer != null && !allowProjectileKills.get(victim) && killer instanceof Projectile) ||
173
- // (killer != null && !allowNonPlayerKills.get(victim) &&
174
- // !(allowProjectileKills.get(victim) && killer instanceof Projectile proj && proj.getShooter() instanceof Player)
175
- // )
176
- // ) return false;
177
183
178
184
final ItemStack murderWeapon = getWeaponFromKiller (killer );
179
185
final Material murderWeaponType = murderWeapon == null ? Material .AIR : murderWeapon .getType ();
0 commit comments