File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
src/main/java/us/thezircon/play/autopickup/listeners
target/classes/us/thezircon/play/autopickup/listeners Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ public void run() {
208208
209209 }
210210
211- private static int mend (ItemStack item , int xp ) {
211+ public static int mend (ItemStack item , int xp ) {
212212
213213 if (item .containsEnchantment (Enchantment .MENDING )) {
214214 ItemMeta meta = item .getItemMeta ();
Original file line number Diff line number Diff line change 1212import java .util .Iterator ;
1313import java .util .List ;
1414
15+ import static us .thezircon .play .autopickup .listeners .BlockBreakEventListener .mend ;
16+
1517public class EntityDeathEventListener implements Listener {
1618
1719 private static final AutoPickup PLUGIN = AutoPickup .getPlugin (AutoPickup .class );
@@ -42,9 +44,21 @@ public void onDeath(EntityDeathEvent e) {
4244
4345 if (PLUGIN .autopickup_list_mobs .contains (player )) {
4446
45- // XP
46- player .giveExp (e .getDroppedExp ());
47- e .setDroppedExp (0 );
47+ // Mend Items & Give Player XP
48+ int xp = e .getDroppedExp ();
49+ player .giveExp (xp ); // Give player XP
50+
51+ // Mend
52+ mend (player .getInventory ().getItemInMainHand (), xp );
53+ mend (player .getInventory ().getItemInOffHand (), xp );
54+ ItemStack armor [] = player .getInventory ().getArmorContents ();
55+ for (ItemStack i : armor )
56+ {
57+ try {
58+ mend (i , xp );
59+ } catch (NullPointerException ignored ) {}
60+ }
61+ e .setDroppedExp (0 ); // Remove default XP
4862
4963 // Drops
5064 Iterator <ItemStack > iter = e .getDrops ().iterator ();
You can’t perform that action at this time.
0 commit comments