package com.forgeessentials.util.selections;

import com.forgeessentials.commons.network.Packet1SelectionUpdate;
import net.minecraft.entity.player.EntityPlayerMP;

import com.forgeessentials.commons.network.NetworkUtils;
import com.forgeessentials.core.moduleLauncher.ModuleLauncher;
import com.forgeessentials.util.OutputHandler;

public class SelectionHandler
{

    public static ISelectionProvider selectionProvider = pickBestSelectionProvider();

    private static ISelectionProvider pickBestSelectionProvider()
    {
        if (ModuleLauncher.getModuleList().contains("WEIntegrationTools"))
        {
            try
            {
                Class<?> weprovider = Class.forName("com.forgeessentials.compat.worldedit.WESelectionHandler");
                return (ISelectionProvider) weprovider.newInstance();
            }
            catch (ClassNotFoundException | InstantiationException | IllegalAccessException e3)
            {
                OutputHandler.felog.warning("There was a problem starting the WorldEdit selection provider. Switching to FE's own provider.");
            }
        }
        return new PlayerInfoSelectionProvider();
    }

    public static void sendUpdate(EntityPlayerMP player)
    {
        NetworkUtils.netHandler.sendTo(new Packet1SelectionUpdate(selectionProvider.getSelection(player)), player);
    }

}

@@ -106,16 +106,17 @@
 Update;%0A
+%0A
 import n
@@ -325,16 +325,60 @@
 Handler;
+%0Aimport com.forgeessentials.util.PlayerInfo;
 %0A%0Apublic
@@ -1263,32 +1263,133 @@
 P player)%0A    %7B%0A
+        if (PlayerInfo.get(player).getHasFEClient())%0A        %7B%0A            try%0A            %7B%0A        
         NetworkU
@@ -1488,16 +1488,199 @@
 layer);%0A
+            %7D%0A            catch (NullPointerException e)%0A            %7B%0A                OutputHandler.felog.severe(%22Error sending selection update to player%22);%0A            %7D%0A        %7D%0A
     %7D%0A%0A%7D

Fix for selection updates