@@ -0,0 +1,3201 @@
+package com.skcraft.plume.module;%0A%0Aimport com.google.common.base.Optional;%0Aimport com.google.inject.Inject;%0Aimport com.skcraft.plume.common.UserId;%0Aimport com.skcraft.plume.common.auth.Context;%0Aimport com.skcraft.plume.common.auth.User;%0Aimport com.skcraft.plume.common.auth.UserCache;%0Aimport com.skcraft.plume.common.config.Config;%0Aimport com.skcraft.plume.common.config.InjectConfig;%0Aimport com.skcraft.plume.common.extension.InjectService;%0Aimport com.skcraft.plume.common.extension.Service;%0Aimport com.skcraft.plume.common.extension.module.Module;%0Aimport com.skcraft.plume.common.util.Environment;%0Aimport com.skcraft.plume.event.network.PlayerAuthenticateEvent;%0Aimport com.skcraft.plume.util.Profiles;%0Aimport cpw.mods.fml.common.eventhandler.SubscribeEvent;%0Aimport cpw.mods.fml.common.gameevent.PlayerEvent;%0Aimport ninja.leaping.configurate.objectmapping.Setting;%0A%0Aimport java.util.Date;%0A%0A@Module(name = %22user-loader%22, hidden = true)%0Apublic class UserLoader %7B%0A%0A    @InjectConfig(%22users%22)%0A    private Config%3CUsersConfig%3E config;%0A    @InjectService%0A    private Service%3CUserCache%3E userCache;%0A    @Inject%0A    private Environment environment;%0A%0A    @SubscribeEvent%0A    public void onAuthenticate(PlayerAuthenticateEvent event) %7B%0A        Optional%3CUserCache%3E optional = userCache.get();%0A        if (optional.isPresent()) %7B%0A            Date now = new Date();%0A            UserCache userCache = optional.get();%0A            UserId userId = Profiles.fromProfile(event.getProfile());%0A            User user = userCache.getUser(userId);%0A%0A            if (user != null) %7B%0A                if (user.getSubject().hasPermission(%22whitelist%22, environment.update(new Context.Builder()).build())) %7B%0A                    user.setLastOnline(now);%0A                    userCache.getHive().saveUser(user, false);%0A                %7D else %7B%0A                    event.getNetHandler().func_147322_a(config.get().notWhitelistedMessage);%0A                %7D%0A            %7D else %7B%0A                // TODO: Allow user creation via config%0A                event.getNetHandler().func_147322_a(config.get().noUserMessage);%0A            %7D%0A        %7D%0A    %7D%0A%0A    @SubscribeEvent%0A    public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) %7B%0A        Optional%3CUserCache%3E optional = userCache.get();%0A        if (optional.isPresent()) %7B%0A            UserId userId = Profiles.fromPlayer(event.player);%0A            optional.get().pin(userId); // Should already be loaded%0A        %7D%0A    %7D%0A%0A    @SubscribeEvent%0A    public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) %7B%0A        Optional%3CUserCache%3E optional = userCache.get();%0A        if (optional.isPresent()) %7B%0A            UserId userId = Profiles.fromPlayer(event.player);%0A            optional.get().unpin(userId);%0A        %7D%0A    %7D%0A%0A    private static class UsersConfig %7B%0A        @Setting(comment = %22The message the user gets disconnected with if the user is not in the database%22)%0A        private String noUserMessage = %22You are not whitelisted. Ask a friend to /invite you.%22;%0A%0A        @Setting(comment = %22The message the user gets disconnected with if the user is not whitelisted%22)%0A        private String notWhitelistedMessage = %22You are not whitelisted to this server.%22;%0A    %7D%0A%0A%7D%0A

Implement user instance loading and whitelisting.