public IntegratedServer( Minecraft par1Minecraft, String par2Str, String par3Str, WorldSettings par4WorldSettings) { super(new File(par1Minecraft.mcDataDir, "saves"), par1Minecraft.getProxy()); this.setServerOwner(par1Minecraft.getSession().getUsername()); this.setFolderName(par2Str); this.setWorldName(par3Str); this.setDemo(par1Minecraft.isDemo()); this.canCreateBonusChest(par4WorldSettings.isBonusChestEnabled()); this.setBuildLimit(256); this.setConfigurationManager(new IntegratedPlayerList(this)); this.mc = par1Minecraft; this.theWorldSettings = par4WorldSettings; Reflector.callVoid(Reflector.ModLoader_registerServer, new Object[] {this}); }
public ListenableFuture func_180601_a(String p_180601_1_, String p_180601_2_) { String s2; if (p_180601_2_.matches("^[a-f0-9]{40}$")) { s2 = p_180601_2_; } else { s2 = p_180601_1_.substring(p_180601_1_.lastIndexOf("/") + 1); if (s2.contains("?")) { s2 = s2.substring(0, s2.indexOf("?")); } if (!s2.endsWith(".zip")) { return Futures.immediateFailedFuture( new IllegalArgumentException("Invalid filename; must end in .zip")); } s2 = "legacy_" + s2.replaceAll("\\W", ""); } final File file1 = new File(this.dirServerResourcepacks, s2); this.field_177321_h.lock(); try { this.func_148529_f(); if (file1.exists() && p_180601_2_.length() == 40) { try { String s3 = Hashing.sha1().hashBytes(Files.toByteArray(file1)).toString(); if (s3.equals(p_180601_2_)) { ListenableFuture listenablefuture1 = this.func_177319_a(file1); return listenablefuture1; } logger.warn( "File " + file1 + " had wrong hash (expected " + p_180601_2_ + ", found " + s3 + "). Deleting it."); FileUtils.deleteQuietly(file1); } catch (IOException ioexception) { logger.warn("File " + file1 + " couldn\'t be hashed. Deleting it.", ioexception); FileUtils.deleteQuietly(file1); } } final GuiScreenWorking guiscreenworking = new GuiScreenWorking(); Map map = Minecraft.getSessionInfo(); final Minecraft minecraft = Minecraft.getMinecraft(); Futures.getUnchecked( minecraft.addScheduledTask( new Runnable() { private static final String __OBFID = "CL_00001089"; public void run() { minecraft.displayGuiScreen(guiscreenworking); } })); final SettableFuture settablefuture = SettableFuture.create(); this.field_177322_i = HttpUtil.func_180192_a( file1, p_180601_1_, map, 52428800, guiscreenworking, minecraft.getProxy()); Futures.addCallback( this.field_177322_i, new FutureCallback() { private static final String __OBFID = "CL_00002394"; public void onSuccess(Object p_onSuccess_1_) { ResourcePackRepository.this.func_177319_a(file1); settablefuture.set((Object) null); } public void onFailure(Throwable p_onFailure_1_) { settablefuture.setException(p_onFailure_1_); } }); ListenableFuture listenablefuture = this.field_177322_i; return listenablefuture; } finally { this.field_177321_h.unlock(); } }