From 1d983706ef427b1d008787843ac23529e43cc659 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Sat, 29 Jan 2022 19:55:05 +0000 Subject: Minor Clean-up/Regression. --- .../handler/events/PlayerSleepEventHandler.java | 39 ++-------------------- 1 file changed, 3 insertions(+), 36 deletions(-) (limited to 'src/main/java/gtPlusPlus/core/handler') diff --git a/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java b/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java index c36344d805..10677c12db 100644 --- a/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java @@ -1,8 +1,8 @@ package gtPlusPlus.core.handler.events; import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gtPlusPlus.api.objects.Logger; @@ -20,6 +20,7 @@ import net.minecraftforge.event.entity.player.PlayerWakeUpEvent; public class PlayerSleepEventHandler { + private static Field sEffectDuration = ReflectionUtils.getField(PotionEffect.class, "duration"); private static ArrayList sPositiveEffects = new ArrayList(); private static ArrayList sNegativeEffects = new ArrayList(); @@ -102,38 +103,4 @@ public class PlayerSleepEventHandler { PlayerUtils.messagePlayer(aPlayer, new ChatComponentTranslation(aChatKey, new Object[0])); } - private static Field sEffectDuration = ReflectionUtils.getField(PotionEffect.class, "duration"); - private static Field sActivePotionEffects = ReflectionUtils.getField(EntityPlayer.class, "activePotionsMap"); - private static Method sOnFinishedPotionEffect = ReflectionUtils.getMethod(EntityPlayer.class, "onFinishedPotionEffect", PotionEffect.class); - - public boolean curePotionEffect(EntityPlayer aPlayer, Potion aPotion) { - HashMap activePotionsMap = new HashMap(); - try { - activePotionsMap = ReflectionUtils.getFieldValue(sActivePotionEffects, aPlayer); - } - catch (Throwable t) { - t.printStackTrace(); - } - if (aPlayer != null && aPotion != null && activePotionsMap != null && activePotionsMap.size() > 0) { - Iterator potionKey = activePotionsMap.keySet().iterator(); - if (!aPlayer.worldObj.isRemote) { - while (potionKey.hasNext()) { - try { - Integer key = potionKey.next(); - PotionEffect effect = (PotionEffect) activePotionsMap.get(key); - if (effect.getPotionID() == aPotion.getId()) { - potionKey.remove(); - ReflectionUtils.invokeVoid(aPlayer, sOnFinishedPotionEffect, new Object[]{effect}); - return true; - } - } - catch (ConcurrentModificationException e) { - e.printStackTrace(); - } - } - } - } - return false; - } - } -- cgit