/*
 * Copyright 2017 Ali Moghnieh
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.blurengine.blur.session;

import com.google.common.base.Preconditions;

import com.blurengine.blur.framework.InternalModule;
import com.blurengine.blur.framework.Module;
import com.blurengine.blur.framework.ModuleInfo;
import com.blurengine.blur.framework.ModuleManager;
import com.blurengine.blur.framework.metadata.playerdata.PlayerData;
import com.blurengine.blur.inventory.InventoryLayout;

import javax.annotation.Nonnull;

@ModuleInfo(name = "BlurCore")
@InternalModule
public class BlurCoreModule extends Module {

    public BlurCoreModule(ModuleManager moduleManager) {
        super(moduleManager);
        getPlayerMetadataCreator().registerClass(BlurPlayerCoreData.class);
    }

    public static final class BlurPlayerCoreData implements PlayerData {

        private final BlurPlayer blurPlayer;
        private boolean alive;
        private InventoryLayout inventoryLayout;
        private int kills;
        private int deaths;

        public BlurPlayerCoreData(@Nonnull BlurPlayer blurPlayer) {
            Preconditions.checkNotNull(blurPlayer, "blurPlayer cannot be null.");
            this.blurPlayer = blurPlayer;
            this.inventoryLayout = new InventoryLayout(blurPlayer.getPlayer().getInventory());
        }

        public boolean isAlive() {
            return alive;
        }

        public void setAlive(boolean alive) {
            this.alive = alive;
        }

        public InventoryLayout getInventoryLayout() {
            return inventoryLayout;
        }

        public void setInventoryLayout(InventoryLayout inventoryLayout) {
            this.inventoryLayout = inventoryLayout;
        }

        public int getKills() {
            return kills;
        }

        public void setKills(int kills) {
            this.kills = kills;
        }

        public int getDeaths() {
            return deaths;
        }

        public void setDeaths(int deaths) {
            this.deaths = deaths;
        }
    }
}

@@ -997,16 +997,43 @@
 ayout;%0A%0A
+import java.time.Instant;%0A%0A
 import j
@@ -1057,16 +1057,16 @@
 onnull;%0A
-
 %0A@Module
@@ -1574,16 +1574,63 @@
  deaths;
+%0A        private final Instant sessionJoinTime;
 %0A%0A      
@@ -1909,16 +1909,170 @@
 tory());
+%0A%0A            // Assumes this class is created as soon as the player joins the session. Can be placed better.%0A            sessionJoinTime = Instant.now();
 %0A       
@@ -2739,24 +2739,24 @@
 t deaths) %7B%0A
-
             
@@ -2786,16 +2786,109 @@
        %7D
+%0A%0A        public Instant getSessionJoinTime() %7B%0A            return sessionJoinTime;%0A        %7D
 %0A    %7D%0A%7D

Add sessionJoinTime to BlurCoreModule.