/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.common.data.processor.dual.entity;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.WorldSettings;
import org.spongepowered.api.data.DataHolder;
import org.spongepowered.api.data.DataTransactionResult;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.manipulator.immutable.entity.ImmutableGameModeData;
import org.spongepowered.api.data.manipulator.mutable.entity.GameModeData;
import org.spongepowered.api.data.value.ValueContainer;
import org.spongepowered.api.data.value.immutable.ImmutableValue;
import org.spongepowered.api.data.value.mutable.Value;
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
import org.spongepowered.api.entity.living.player.gamemode.GameModes;
import org.spongepowered.common.SpongeImpl;
import org.spongepowered.common.data.manipulator.mutable.entity.SpongeGameModeData;
import org.spongepowered.common.data.processor.common.AbstractEntitySingleDataProcessor;
import org.spongepowered.common.data.processor.dual.common.AbstractSingleTargetDualProcessor;
import org.spongepowered.common.data.value.immutable.ImmutableSpongeValue;
import org.spongepowered.common.data.value.mutable.SpongeValue;

import java.util.Optional;

public class GameModeDataProcessor extends
    AbstractSingleTargetDualProcessor<EntityPlayer, GameMode, Value<GameMode>, GameModeData, ImmutableGameModeData> {

    public GameModeDataProcessor() {
        super(EntityPlayer.class, Keys.GAME_MODE);
    }

    @Override
    protected GameModeData createManipulator() {
        return new SpongeGameModeData();
    }

    @Override
    protected boolean set(EntityPlayer entity, GameMode value) {
        if (SpongeImpl.getGame().getPlatform().getType().isServer()) {
            entity.setGameType((WorldSettings.GameType) (Object) value);
            return true;
        }
        return false;
    }

    @Override
    protected Optional<GameMode> getVal(EntityPlayer entity) {
        if (entity instanceof EntityPlayerMP) {
            return Optional.of((GameMode) (Object) ((EntityPlayerMP) entity).theItemInWorldManager.getGameType());
        }
        return Optional.empty();
    }

    @Override
    protected ImmutableValue<GameMode> constructImmutableValue(GameMode value) {
        return ImmutableSpongeValue.cachedOf(Keys.GAME_MODE, GameModes.SURVIVAL, value);
    }

    @Override
    protected Value<GameMode> constructValue(GameMode actualValue) {
        return new SpongeValue<>(Keys.GAME_MODE, GameModes.SURVIVAL, actualValue);
    }

    @Override
    public DataTransactionResult removeFrom(ValueContainer<?> container) {
        return DataTransactionResult.failNoData();
    }
}

@@ -1354,147 +1354,52 @@
 ayer
-;%0Aimport net.minecraft.entity.player.EntityPlayerMP;%0Aimport net.minecraft.world.WorldSettings;%0Aimport org.spongepowered.api.data.DataHolder
+MP;%0Aimport net.minecraft.world.WorldSettings
 ;%0Aim
@@ -1978,52 +1978,8 @@
 es;%0A
-import org.spongepowered.common.SpongeImpl;%0A
 impo
@@ -2062,97 +2062,8 @@
 ta;%0A
-import org.spongepowered.common.data.processor.common.AbstractEntitySingleDataProcessor;%0A
 impo
@@ -2363,16 +2363,20 @@
 extends%0A
+    
     Abst
@@ -2417,16 +2417,18 @@
 tyPlayer
+MP
 , GameMo
@@ -2551,16 +2551,18 @@
 tyPlayer
+MP
 .class, 
@@ -2744,24 +2744,26 @@
 EntityPlayer
+MP
  entity, Gam
@@ -2781,83 +2781,8 @@
 ) %7B%0A
-        if (SpongeImpl.getGame().getPlatform().getType().isServer()) %7B%0A    
     
@@ -2850,28 +2850,24 @@
 e);%0A        
-    
 return true;
@@ -2871,40 +2871,8 @@
 ue;%0A
-        %7D%0A        return false;%0A
     
@@ -2940,16 +2940,18 @@
 tyPlayer
+MP
  entity)
@@ -2957,60 +2957,8 @@
 ) %7B%0A
-        if (entity instanceof EntityPlayerMP) %7B%0A    
     
@@ -3003,34 +3003,15 @@
 ect)
- ((EntityPlayerMP)
  entity
-)
 .the
@@ -3049,51 +3049,8 @@
 ));%0A
-        %7D%0A        return Optional.empty();%0A
     

Make GameModeData work on client side