diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-29 19:55:05 +0000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-29 19:55:05 +0000 |
commit | 1d983706ef427b1d008787843ac23529e43cc659 (patch) | |
tree | 6c35cde372ac99d7dbe886de6565bb9dc647fac3 /src/main/java/gtPlusPlus/core | |
parent | 30d153e9552251a95bc0ba5fa8c6edc920c07941 (diff) | |
download | GT5-Unofficial-1d983706ef427b1d008787843ac23529e43cc659.tar.gz GT5-Unofficial-1d983706ef427b1d008787843ac23529e43cc659.tar.bz2 GT5-Unofficial-1d983706ef427b1d008787843ac23529e43cc659.zip |
Minor Clean-up/Regression.
Diffstat (limited to 'src/main/java/gtPlusPlus/core')
-rw-r--r-- | src/main/java/gtPlusPlus/core/handler/events/PlayerSleepEventHandler.java | 39 |
1 files changed, 3 insertions, 36 deletions
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<Potion> sPositiveEffects = new ArrayList<Potion>(); private static ArrayList<Potion> sNegativeEffects = new ArrayList<Potion>(); @@ -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<Integer> 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; - } - } |