public static String[] fetchNames(UUID[] uuids) { PlayerProfileCache cache = WorldBorder.SERVER.getPlayerProfileCache(); String[] names = new String[uuids.length]; // Makes sure server reads from cache first cache.load(); for (int i = 0; i < uuids.length; i++) { GameProfile profile = cache.getProfileByUUID(uuids[i]); names[i] = (profile != null) ? profile.getName() : "<unknown:" + uuids[i].toString() + ">"; } return names; }
public DedicatedServer(File anvilFileIn, DataFixer dataFixerIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn) { super(anvilFileIn, Proxy.NO_PROXY, dataFixerIn, authServiceIn, sessionServiceIn, profileRepoIn, profileCacheIn); Thread thread = new Thread("Server Infinisleeper") { { this.setDaemon(true); this.start(); } public void run() { while (true) { try { Thread.sleep(2147483647L); } catch (InterruptedException var2) { ; } } } }; }
public static String[] fetchNames(UUID[] uuids) { PlayerProfileCache cache = WorldBorder.SERVER.func_152358_ax(); String[] names = new String[uuids.length]; // Makes sure server reads from cache first cache.func_152657_b(); for (int i = 0; i < uuids.length; i++) { GameProfile profile = cache.func_152652_a(uuids[i]); names[i] = (profile != null) ? profile.getName() : "<unknown:" + uuids[i].toString() + ">"; } return names; }
public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_) { this.field_152366_X = new PlayerProfileCache(this, field_152367_a); mcServer = this; this.serverProxy = p_i45281_2_; this.anvilFile = p_i45281_1_; this.field_147144_o = new NetworkSystem(this); this.commandManager = new ServerCommandManager(); this.anvilConverterForAnvilFile = new AnvilSaveConverter(p_i45281_1_); this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString()); this.field_147143_S = this.field_152364_T.createMinecraftSessionService(); this.field_152365_W = this.field_152364_T.createProfileRepository(); this.primaryThread = new Thread(this, "Server thread"); // CraftBukkit this.cauldronConfig = new CauldronConfig("cauldron.yml", "cauldron"); this.tileEntityConfig = new TileEntityConfig("tileentities.yml", "cauldron_te"); }
@Override public UUID getUUID() { if (cache != null) return cache; Minecraft mc = Minecraft.getMinecraft(); Session session = mc.getSession(); boolean online = true; if (session.getToken().length() != 32 || session.getPlayerID().length() != 32) { online = false; } UUID uuid; if (online) { PlayerProfileCache playerprofilecache = new PlayerProfileCache(MinecraftServer.getServer(), new File(mc.mcDataDir, MinecraftServer.field_152367_a.getName())); uuid = playerprofilecache.func_152655_a(Minecraft.getMinecraft().getSession().getUsername()).getId(); } else { uuid = EntityPlayer.func_146094_a(new GameProfile(null, session.getUsername().toLowerCase())); } cache = uuid; return uuid; }
@Override public UUID getUUID() { if (cache != null) return cache; Minecraft mc = Minecraft.getMinecraft(); Session session = mc.getSession(); boolean online = true; if (session.getToken().length() != 32 || session.getPlayerID().length() != 32) { online = false; } UUID uuid; if (online) { YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(mc.getProxy(), UUID.randomUUID().toString()); GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, new File(mc.mcDataDir, MinecraftServer.USER_CACHE_FILE.getName())); uuid = playerprofilecache.getGameProfileForUsername(Minecraft.getMinecraft().getSession().getUsername()).getId(); } else { uuid = EntityPlayer.getOfflineUUID(session.getUsername().toLowerCase()); } cache = uuid; return uuid; }
public MinecraftServer(File workDir, Proxy proxy, File profileCacheDir) { this.serverProxy = proxy; mcServer = this; this.anvilFile = workDir; this.networkSystem = new NetworkSystem(this); this.profileCache = new PlayerProfileCache(this, profileCacheDir); this.commandManager = this.createNewCommandManager(); this.anvilConverterForAnvilFile = new AnvilSaveConverter(workDir); this.authService = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString()); this.sessionService = this.authService.createMinecraftSessionService(); this.profileRepo = this.authService.createProfileRepository(); }
public MinecraftServer(Proxy proxy, File workDir) { this.serverProxy = proxy; mcServer = this; this.anvilFile = null; this.networkSystem = null; this.profileCache = new PlayerProfileCache(this, workDir); this.commandManager = null; this.anvilConverterForAnvilFile = null; this.authService = new YggdrasilAuthenticationService(proxy, UUID.randomUUID().toString()); this.sessionService = this.authService.createMinecraftSessionService(); this.profileRepo = this.authService.createProfileRepository(); }
public IntegratedServer(Minecraft clientIn, String folderNameIn, String worldNameIn, WorldSettings worldSettingsIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn) { super(new File(clientIn.mcDataDir, "saves"), clientIn.getProxy(), clientIn.getDataFixer(), authServiceIn, sessionServiceIn, profileRepoIn, profileCacheIn); this.setServerOwner(clientIn.getSession().getUsername()); this.setFolderName(folderNameIn); this.setWorldName(worldNameIn); this.setDemo(clientIn.isDemo()); this.canCreateBonusChest(worldSettingsIn.isBonusChestEnabled()); this.setBuildLimit(256); this.setPlayerList(new IntegratedPlayerList(this)); this.mc = clientIn; this.theWorldSettings = this.isDemo() ? DemoWorldServer.DEMO_WORLD_SETTINGS : worldSettingsIn; }
public MinecraftServer(File anvilFileIn, Proxy proxyIn, DataFixer dataFixerIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn) { this.serverProxy = proxyIn; this.authService = authServiceIn; this.sessionService = sessionServiceIn; this.profileRepo = profileRepoIn; this.profileCache = profileCacheIn; this.anvilFile = anvilFileIn; this.networkSystem = new NetworkSystem(this); this.commandManager = this.createNewCommandManager(); this.anvilConverterForAnvilFile = new AnvilSaveConverter(anvilFileIn, dataFixerIn); this.dataFixer = dataFixerIn; }
@Nonnull private DedicatedServer constructServerInstance(@Nonnull BundleContext ctx) { logger.info("Initializing Minecraft %s", FaucetVersion.API_VERSION); Bootstrap.register(); // apparently this is how the registries work ... don't question it // log some environment information logger.info("Running on Java v%s supplied by %s", System.getProperty("java.version", "Unknown"), System.getProperty("java.vendor")); // TODO: Integrate with plugins here? YggdrasilAuthenticationService var15 = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString()); MinecraftSessionService var16 = var15.createMinecraftSessionService(); GameProfileRepository var17 = var15.createProfileRepository(); PlayerProfileCache var18 = new PlayerProfileCache(var17, new File(".", "usercache.json")); DedicatedServer server = new DedicatedServer(new File("."), DataFixesManager.createFixer(), var15, var16, var17, var18); // TODO: Re-introduce configuration if (!GraphicsEnvironment.isHeadless()) { logger.info("Server GUI has been disabled or is unavailable in this environment"); // TODO: Custom GUI } else { logger .info("Server GUI has been disabled or is not available within the current environment"); } return server; }
public FakeServer(Minecraft clientIn, String folderNameIn, String worldNameIn, WorldSettings worldSettingsIn, YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn, GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn) { super(new File(clientIn.mcDataDir, "saves"), null, clientIn.getDataFixer(), authServiceIn, sessionServiceIn, profileRepoIn, profileCacheIn); this.setPlayerList(new FakePlayerList(this)); }
public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_) { this.field_152366_X = new PlayerProfileCache(this, field_152367_a); mcServer = this; this.serverProxy = p_i45281_2_; this.anvilFile = p_i45281_1_; this.field_147144_o = new NetworkSystem(this); this.commandManager = new ServerCommandManager(); this.anvilConverterForAnvilFile = new AnvilSaveConverter(p_i45281_1_); this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString()); this.field_147143_S = this.field_152364_T.createMinecraftSessionService(); this.field_152365_W = this.field_152364_T.createProfileRepository(); }
@Override public void setGameProfileLookupService() { YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Minecraft.getMinecraft().getProxy(), UUID.randomUUID().toString()); EntityHelper.sessionService = yggdrasilauthenticationservice.createMinecraftSessionService(); GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); EntityHelper.profileCache = new PlayerProfileCache(gameprofilerepository, new File(Minecraft.getMinecraft().mcDataDir, MinecraftServer.USER_CACHE_FILE.getName())); }
/** * Read this village's data from NBT. */ public void readVillageDataFromNBT(NBTTagCompound p_82690_1_) { this.numVillagers = p_82690_1_.getInteger("PopSize"); this.villageRadius = p_82690_1_.getInteger("Radius"); this.numIronGolems = p_82690_1_.getInteger("Golems"); this.lastAddDoorTimestamp = p_82690_1_.getInteger("Stable"); this.tickCounter = p_82690_1_.getInteger("Tick"); this.noBreedTicks = p_82690_1_.getInteger("MTick"); this.center = new BlockPos(p_82690_1_.getInteger("CX"), p_82690_1_.getInteger("CY"), p_82690_1_.getInteger("CZ")); this.centerHelper = new BlockPos(p_82690_1_.getInteger("ACX"), p_82690_1_.getInteger("ACY"), p_82690_1_.getInteger("ACZ")); NBTTagList nbttaglist = p_82690_1_.getTagList("Doors", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); VillageDoorInfo villagedoorinfo = new VillageDoorInfo(new BlockPos(nbttagcompound.getInteger("X"), nbttagcompound.getInteger("Y"), nbttagcompound.getInteger("Z")), nbttagcompound.getInteger("IDX"), nbttagcompound.getInteger("IDZ"), nbttagcompound.getInteger("TS")); this.villageDoorInfoList.add(villagedoorinfo); } NBTTagList nbttaglist1 = p_82690_1_.getTagList("Players", 10); for (int j = 0; j < nbttaglist1.tagCount(); ++j) { NBTTagCompound nbttagcompound1 = nbttaglist1.getCompoundTagAt(j); if (nbttagcompound1.hasKey("UUID")) { PlayerProfileCache playerprofilecache = MinecraftServer.getServer().getPlayerProfileCache(); GameProfile gameprofile = playerprofilecache.getProfileByUUID(UUID.fromString(nbttagcompound1.getString("UUID"))); if (gameprofile != null) { this.playerReputation.put(gameprofile.getName(), Integer.valueOf(nbttagcompound1.getInteger("S"))); } } else { this.playerReputation.put(nbttagcompound1.getString("Name"), Integer.valueOf(nbttagcompound1.getInteger("S"))); } } }
/** * Write this village's data to NBT. */ public void writeVillageDataToNBT(NBTTagCompound p_82689_1_) { p_82689_1_.setInteger("PopSize", this.numVillagers); p_82689_1_.setInteger("Radius", this.villageRadius); p_82689_1_.setInteger("Golems", this.numIronGolems); p_82689_1_.setInteger("Stable", this.lastAddDoorTimestamp); p_82689_1_.setInteger("Tick", this.tickCounter); p_82689_1_.setInteger("MTick", this.noBreedTicks); p_82689_1_.setInteger("CX", this.center.getX()); p_82689_1_.setInteger("CY", this.center.getY()); p_82689_1_.setInteger("CZ", this.center.getZ()); p_82689_1_.setInteger("ACX", this.centerHelper.getX()); p_82689_1_.setInteger("ACY", this.centerHelper.getY()); p_82689_1_.setInteger("ACZ", this.centerHelper.getZ()); NBTTagList nbttaglist = new NBTTagList(); for (VillageDoorInfo villagedoorinfo : this.villageDoorInfoList) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("X", villagedoorinfo.getDoorBlockPos().getX()); nbttagcompound.setInteger("Y", villagedoorinfo.getDoorBlockPos().getY()); nbttagcompound.setInteger("Z", villagedoorinfo.getDoorBlockPos().getZ()); nbttagcompound.setInteger("IDX", villagedoorinfo.getInsideOffsetX()); nbttagcompound.setInteger("IDZ", villagedoorinfo.getInsideOffsetZ()); nbttagcompound.setInteger("TS", villagedoorinfo.getInsidePosY()); nbttaglist.appendTag(nbttagcompound); } p_82689_1_.setTag("Doors", nbttaglist); NBTTagList nbttaglist1 = new NBTTagList(); for (String s : this.playerReputation.keySet()) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); PlayerProfileCache playerprofilecache = MinecraftServer.getServer().getPlayerProfileCache(); GameProfile gameprofile = playerprofilecache.getGameProfileForUsername(s); if (gameprofile != null) { nbttagcompound1.setString("UUID", gameprofile.getId().toString()); nbttagcompound1.setInteger("S", ((Integer)this.playerReputation.get(s)).intValue()); nbttaglist1.appendTag(nbttagcompound1); } } p_82689_1_.setTag("Players", nbttaglist1); }
public PlayerProfileCache getPlayerProfileCache() { return this.profileCache; }
public static void setProfileCache(PlayerProfileCache profileCacheIn) { profileCache = profileCacheIn; Main.logger.info("PROFILE CACHE FOUND"); }
/** * Read this village's data from NBT. */ public void readVillageDataFromNBT(NBTTagCompound compound) { this.numVillagers = compound.getInteger("PopSize"); this.villageRadius = compound.getInteger("Radius"); this.numIronGolems = compound.getInteger("Golems"); this.lastAddDoorTimestamp = compound.getInteger("Stable"); this.tickCounter = compound.getInteger("Tick"); this.noBreedTicks = compound.getInteger("MTick"); this.center = new BlockPos(compound.getInteger("CX"), compound.getInteger("CY"), compound.getInteger("CZ")); this.centerHelper = new BlockPos(compound.getInteger("ACX"), compound.getInteger("ACY"), compound.getInteger("ACZ")); NBTTagList nbttaglist = compound.getTagList("Doors", 10); for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); VillageDoorInfo villagedoorinfo = new VillageDoorInfo(new BlockPos(nbttagcompound.getInteger("X"), nbttagcompound.getInteger("Y"), nbttagcompound.getInteger("Z")), nbttagcompound.getInteger("IDX"), nbttagcompound.getInteger("IDZ"), nbttagcompound.getInteger("TS")); this.villageDoorInfoList.add(villagedoorinfo); } NBTTagList nbttaglist1 = compound.getTagList("Players", 10); for (int j = 0; j < nbttaglist1.tagCount(); ++j) { NBTTagCompound nbttagcompound1 = nbttaglist1.getCompoundTagAt(j); if (nbttagcompound1.hasKey("UUID") && this.worldObj != null && this.worldObj.getMinecraftServer() != null) { PlayerProfileCache playerprofilecache = this.worldObj.getMinecraftServer().getPlayerProfileCache(); GameProfile gameprofile = playerprofilecache.getProfileByUUID(UUID.fromString(nbttagcompound1.getString("UUID"))); if (gameprofile != null) { this.playerReputation.put(gameprofile.getName(), Integer.valueOf(nbttagcompound1.getInteger("S"))); } } else { this.playerReputation.put(nbttagcompound1.getString("Name"), Integer.valueOf(nbttagcompound1.getInteger("S"))); } } }
/** * Write this village's data to NBT. */ public void writeVillageDataToNBT(NBTTagCompound compound) { compound.setInteger("PopSize", this.numVillagers); compound.setInteger("Radius", this.villageRadius); compound.setInteger("Golems", this.numIronGolems); compound.setInteger("Stable", this.lastAddDoorTimestamp); compound.setInteger("Tick", this.tickCounter); compound.setInteger("MTick", this.noBreedTicks); compound.setInteger("CX", this.center.getX()); compound.setInteger("CY", this.center.getY()); compound.setInteger("CZ", this.center.getZ()); compound.setInteger("ACX", this.centerHelper.getX()); compound.setInteger("ACY", this.centerHelper.getY()); compound.setInteger("ACZ", this.centerHelper.getZ()); NBTTagList nbttaglist = new NBTTagList(); for (VillageDoorInfo villagedoorinfo : this.villageDoorInfoList) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("X", villagedoorinfo.getDoorBlockPos().getX()); nbttagcompound.setInteger("Y", villagedoorinfo.getDoorBlockPos().getY()); nbttagcompound.setInteger("Z", villagedoorinfo.getDoorBlockPos().getZ()); nbttagcompound.setInteger("IDX", villagedoorinfo.getInsideOffsetX()); nbttagcompound.setInteger("IDZ", villagedoorinfo.getInsideOffsetZ()); nbttagcompound.setInteger("TS", villagedoorinfo.getInsidePosY()); nbttaglist.appendTag(nbttagcompound); } compound.setTag("Doors", nbttaglist); NBTTagList nbttaglist1 = new NBTTagList(); for (String s : this.playerReputation.keySet()) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); PlayerProfileCache playerprofilecache = this.worldObj.getMinecraftServer().getPlayerProfileCache(); try { GameProfile gameprofile = playerprofilecache.getGameProfileForUsername(s); if (gameprofile != null) { nbttagcompound1.setString("UUID", gameprofile.getId().toString()); nbttagcompound1.setInteger("S", ((Integer)this.playerReputation.get(s)).intValue()); nbttaglist1.appendTag(nbttagcompound1); } } catch (RuntimeException var9) { ; } } compound.setTag("Players", nbttaglist1); }
public static void setProfileCache(PlayerProfileCache profileCacheIn) { profileCache = profileCacheIn; }