package appeng.hooks; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.play.server.S29PacketSoundEffect; import appeng.core.AELog; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketCraftingCompleteNotification; import appeng.me.cluster.implementations.CraftingCPUCluster.CraftNotification; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; public class CraftingNotificationManager { private static final List>> notificationMaps = new ArrayList<>(); @SubscribeEvent public void onPlayerLogin(PlayerLoggedInEvent event) { final EntityPlayer player = event.player; final String playerName = player.getCommandSenderName(); for (Map> map : notificationMaps) { if (map.containsKey(playerName)) { List notifications = map.remove(playerName); for (CraftNotification notification : notifications) { try { NetworkHandler.instance .sendTo(new PacketCraftingCompleteNotification(notification), (EntityPlayerMP) player); } catch (IOException e) { AELog.debug(e); } player.addChatMessage(notification.createMessage()); } ((EntityPlayerMP) player).playerNetServerHandler.sendPacket( new S29PacketSoundEffect("random.levelup", player.posX, player.posY, player.posZ, 1f, 1f)); } } } public static void register(Map> map) { notificationMaps.add(map); } public static void unregister(Map> map) { notificationMaps.remove(map); } public static void clear() { notificationMaps.clear(); } }