mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2024-11-27 06:10:08 +08:00
Add an option to disable common path
This commit is contained in:
parent
f836afa2ea
commit
413854d1f1
@ -50,7 +50,7 @@ if (buildnumber == null)
|
||||
|
||||
def versionroot = System.getenv("VERSION_ROOT")
|
||||
if (versionroot == null)
|
||||
versionroot = "2.7.0"
|
||||
versionroot = "2.7.1"
|
||||
|
||||
String mavenGroupId = 'HMCL'
|
||||
String mavenVersion = versionroot + '.' + buildnumber
|
||||
|
@ -41,6 +41,8 @@ public final class Profile {
|
||||
private String selectedMinecraftVersion = "";
|
||||
@SerializedName("gameDir")
|
||||
private String gameDir;
|
||||
@SerializedName("noCommon")
|
||||
private boolean noCommon;
|
||||
@SerializedName("global")
|
||||
private VersionSetting global;
|
||||
|
||||
@ -169,6 +171,16 @@ public final class Profile {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNoCommon() {
|
||||
return noCommon;
|
||||
}
|
||||
|
||||
public void setNoCommon(boolean noCommon) {
|
||||
PropertyChangedEvent event = new PropertyChangedEvent(this, "noCommon", this.noCommon, noCommon);
|
||||
this.noCommon = noCommon;
|
||||
propertyChanged.fire(event);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -419,7 +419,9 @@
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkNoCommon" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="96" max="32767" attributes="0"/>
|
||||
<Component id="chkDontCheckGame" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
@ -469,6 +471,7 @@
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="chkNoJVMArgs" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkDontCheckGame" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkNoCommon" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -573,6 +576,19 @@
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkDontCheckGameItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkNoCommon">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hmcl/lang/I18N.properties" key="advancedsettings.no_common" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hmcl/lang/I18N.properties" key="launcher.commpath_tooltip" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkNoCommonItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="pnlModManagement">
|
||||
|
@ -314,6 +314,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
lblPrecalledCommand1 = new javax.swing.JLabel();
|
||||
txtWrapperLauncher = new javax.swing.JTextField();
|
||||
chkDontCheckGame = new javax.swing.JCheckBox();
|
||||
chkNoCommon = new javax.swing.JCheckBox();
|
||||
pnlModManagement = new Page();
|
||||
pnlModManagementContent = new Page();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
@ -610,6 +611,14 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
}
|
||||
});
|
||||
|
||||
chkNoCommon.setText(C.i18n("advancedsettings.no_common")); // NOI18N
|
||||
chkNoCommon.setToolTipText(C.i18n("launcher.commpath_tooltip")); // NOI18N
|
||||
chkNoCommon.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
chkNoCommonItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout pnlAdvancedSettingsLayout = new javax.swing.GroupLayout(pnlAdvancedSettings);
|
||||
pnlAdvancedSettings.setLayout(pnlAdvancedSettingsLayout);
|
||||
pnlAdvancedSettingsLayout.setHorizontalGroup(
|
||||
@ -632,7 +641,9 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(chkNoJVMArgs)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkNoCommon)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 96, Short.MAX_VALUE)
|
||||
.addComponent(chkDontCheckGame))
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@ -672,7 +683,8 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(chkNoJVMArgs)
|
||||
.addComponent(chkDontCheckGame))
|
||||
.addComponent(chkDontCheckGame)
|
||||
.addComponent(chkNoCommon))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@ -958,7 +970,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(pnlTop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(tabVersionEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
|
||||
.addComponent(tabVersionEdit)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnTestGame)
|
||||
@ -1218,26 +1230,32 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
profile.makeVersionSettingGlobal(mcVersion);
|
||||
}//GEN-LAST:event_lblUsesGlobalMouseClicked
|
||||
|
||||
private void chkNoCommonItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkNoCommonItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().setNoCommon(chkNoCommon.isSelected());
|
||||
}//GEN-LAST:event_chkNoCommonItemStateChanged
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold defaultstate="collapsed" desc="Load">
|
||||
void prepareVersionSetting(VersionSetting profile) {
|
||||
if (profile == null)
|
||||
void prepareVersionSetting(Profile profile, VersionSetting vs) {
|
||||
if (vs == null)
|
||||
return;
|
||||
isLoading = true;
|
||||
txtWidth.setText(profile.getWidth());
|
||||
txtHeight.setText(profile.getHeight());
|
||||
txtMaxMemory.setText(profile.getMaxMemory());
|
||||
txtPermSize.setText(profile.getPermSize());
|
||||
txtJavaArgs.setText(profile.getJavaArgs());
|
||||
txtMinecraftArgs.setText(profile.getMinecraftArgs());
|
||||
txtPrecalledCommand.setText(profile.getPrecalledCommand());
|
||||
txtServerIP.setText(profile.getServerIp());
|
||||
chkNoJVMArgs.setSelected(profile.isNoJVMArgs());
|
||||
chkDontCheckGame.setSelected(profile.isNotCheckGame());
|
||||
chkFullscreen.setSelected(profile.isFullscreen());
|
||||
cboLauncherVisibility.setSelectedIndex(profile.getLauncherVisibility().ordinal());
|
||||
cboRunDirectory.setSelectedIndex(profile.getGameDirType().ordinal());
|
||||
cboJava.setSelectedIndex(profile.getJavaIndexInAllJavas());
|
||||
txtWidth.setText(vs.getWidth());
|
||||
txtHeight.setText(vs.getHeight());
|
||||
txtMaxMemory.setText(vs.getMaxMemory());
|
||||
txtPermSize.setText(vs.getPermSize());
|
||||
txtJavaArgs.setText(vs.getJavaArgs());
|
||||
txtMinecraftArgs.setText(vs.getMinecraftArgs());
|
||||
txtPrecalledCommand.setText(vs.getPrecalledCommand());
|
||||
txtServerIP.setText(vs.getServerIp());
|
||||
chkNoJVMArgs.setSelected(vs.isNoJVMArgs());
|
||||
chkDontCheckGame.setSelected(vs.isNotCheckGame());
|
||||
chkNoCommon.setSelected(profile.isNoCommon());
|
||||
chkFullscreen.setSelected(vs.isFullscreen());
|
||||
cboLauncherVisibility.setSelectedIndex(vs.getLauncherVisibility().ordinal());
|
||||
cboRunDirectory.setSelectedIndex(vs.getGameDirType().ordinal());
|
||||
cboJava.setSelectedIndex(vs.getJavaIndexInAllJavas());
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
@ -1392,6 +1410,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
private javax.swing.JComboBox cboVersions;
|
||||
private javax.swing.JCheckBox chkDontCheckGame;
|
||||
private javax.swing.JCheckBox chkFullscreen;
|
||||
private javax.swing.JCheckBox chkNoCommon;
|
||||
private javax.swing.JCheckBox chkNoJVMArgs;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JLabel lblDimension;
|
||||
@ -1481,7 +1500,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
|
||||
this.mcVersion = version;
|
||||
reloadMods();
|
||||
prepareVersionSetting(Settings.getLastProfile().getVersionSetting(version));
|
||||
prepareVersionSetting(Settings.getLastProfile(), Settings.getLastProfile().getVersionSetting(version));
|
||||
loadMinecraftVersion(version);
|
||||
|
||||
lblUsesGlobal.setText(C.i18n(Settings.getLastProfile().isVersionSettingGlobe(version) ? "settings.type.global" : "settings.type.special"));
|
||||
|
@ -33,7 +33,7 @@ public class HMCLAssetService extends MinecraftAssetService {
|
||||
}
|
||||
|
||||
private boolean useSelf(String assetId) {
|
||||
return new File(service.baseDirectory(), "assets/indexes/" + assetId + ",json").exists();
|
||||
return new File(service.baseDirectory(), "assets/indexes/" + assetId + ",json").exists() || ((HMCLMinecraftService) service).p.isNoCommon();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,9 +18,9 @@
|
||||
package org.jackhuang.hmcl.util;
|
||||
|
||||
import java.io.File;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.api.event.version.MinecraftLibraryPathEvent;
|
||||
import org.jackhuang.hmcl.api.game.GameDirType;
|
||||
import org.jackhuang.hmcl.api.game.IMinecraftLibrary;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftVersionManager;
|
||||
import org.jackhuang.hmcl.setting.Settings;
|
||||
import org.jackhuang.hmcl.setting.VersionSetting;
|
||||
@ -33,11 +33,16 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
||||
|
||||
public HMCLGameProvider(HMCLMinecraftService p) {
|
||||
super(p);
|
||||
|
||||
HMCLApi.EVENT_BUS.channel(MinecraftLibraryPathEvent.class).register(t -> {
|
||||
if (!t.getFile().getValue().exists())
|
||||
t.getFile().setValue(new File(Settings.getInstance().getCommonpath(), t.getLocation()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getLibraryFile(MinecraftVersion version, IMinecraftLibrary lib) {
|
||||
VersionSetting vs = ((HMCLMinecraftService) service).getVersionSetting(version.id);
|
||||
File self = super.getLibraryFile(version, lib);
|
||||
if (self.exists() || (vs != null && ((HMCLMinecraftService) service).p.isNoCommon()))
|
||||
return self;
|
||||
else
|
||||
return lib.getFilePath(new File(Settings.getInstance().getCommonpath()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,8 +51,8 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
||||
if (vs == null)
|
||||
return super.getRunDirectory(id);
|
||||
else
|
||||
return ((HMCLMinecraftService) service).getVersionSetting(id).getGameDirType() == GameDirType.VERSION_FOLDER
|
||||
? service.version().versionRoot(id)
|
||||
: super.getRunDirectory(id);
|
||||
return vs.getGameDirType() == GameDirType.VERSION_FOLDER
|
||||
? service.version().versionRoot(id)
|
||||
: super.getRunDirectory(id);
|
||||
}
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Hello Minecraft! Launcher.
|
||||
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
*/
|
||||
package org.jackhuang.hmcl.api.event.version;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.EventObject;
|
||||
import org.jackhuang.hmcl.api.Wrapper;
|
||||
|
||||
/**
|
||||
* This event gets fired when we getting minecraft library path.
|
||||
* <br>
|
||||
* This event is fired on the {@link org.jackhuang.hmcl.api.HMCLApi#EVENT_BUS}
|
||||
* @param source {@link org.jackhuang.hmcl.core.version.MinecraftLibrary}
|
||||
* @param {@code Wrapper<File>} modify this thing to change to your wanted mc lib.
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class MinecraftLibraryPathEvent extends EventObject {
|
||||
|
||||
String location;
|
||||
Wrapper<File> file;
|
||||
|
||||
public MinecraftLibraryPathEvent(Object source, String location, Wrapper<File> value) {
|
||||
super(source);
|
||||
this.location = location;
|
||||
this.file = value;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public Wrapper<File> getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -29,6 +29,11 @@ public interface IMinecraftLibrary extends Cloneable {
|
||||
|
||||
Extract getDecompressExtractRules();
|
||||
|
||||
/**
|
||||
* Only used for IMinecraftProvider
|
||||
* @param gameDir
|
||||
* @return
|
||||
*/
|
||||
File getFilePath(File gameDir);
|
||||
|
||||
String getName();
|
||||
|
@ -57,7 +57,7 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
|
||||
MinecraftVersion v = mv.resolve(service.version());
|
||||
for (IMinecraftLibrary l : v.getLibraries())
|
||||
if (l != null && l.allow() && l.getDownloadURL(service.getDownloadType().name()) != null) {
|
||||
File ff = l.getFilePath(service.baseDirectory());
|
||||
File ff = service.version().getLibraryFile(mv, l);
|
||||
if (!ff.exists()) {
|
||||
String libURL = l.getDownloadURL(service.getDownloadType().name());
|
||||
if (libURL != null)
|
||||
|
@ -23,8 +23,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.api.event.version.MinecraftLibraryPathEvent;
|
||||
import org.jackhuang.hmcl.util.C;
|
||||
import org.jackhuang.hmcl.api.HMCLog;
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftService;
|
||||
@ -32,7 +30,6 @@ import org.jackhuang.hmcl.util.task.Task;
|
||||
import org.jackhuang.hmcl.util.sys.FileUtils;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftLibrary;
|
||||
import org.jackhuang.hmcl.util.MessageBox;
|
||||
import org.jackhuang.hmcl.api.Wrapper;
|
||||
import org.jackhuang.hmcl.util.sys.IOUtils;
|
||||
|
||||
/**
|
||||
@ -81,11 +78,9 @@ public class ForgeInstaller extends Task {
|
||||
entry = zipFile.getEntry(profile.install.getFilePath());
|
||||
InputStream is = zipFile.getInputStream(entry);
|
||||
MinecraftLibrary forge = new MinecraftLibrary(profile.install.getPath());
|
||||
|
||||
String path = "libraries/" + forge.getDownloadInfo().path;
|
||||
MinecraftLibraryPathEvent event = new MinecraftLibraryPathEvent(this, path, new Wrapper<>(new File(gameDir, path)));
|
||||
HMCLApi.EVENT_BUS.fireChannel(event);
|
||||
File file = event.getFile().getValue();
|
||||
|
||||
// We use options from the old vanilla version.
|
||||
File file = mp.version().getLibraryFile(mp.version().getVersionById(profile.install.getMinecraft()), forge);
|
||||
|
||||
if (!FileUtils.makeDirectory(file.getParentFile()))
|
||||
HMCLog.warn("Failed to make library directory " + file.getParent());
|
||||
|
@ -20,8 +20,6 @@ package org.jackhuang.hmcl.core.install.liteloader;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.api.event.version.MinecraftLibraryPathEvent;
|
||||
import org.jackhuang.hmcl.util.C;
|
||||
import org.jackhuang.hmcl.api.HMCLog;
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftService;
|
||||
@ -31,7 +29,6 @@ import org.jackhuang.hmcl.util.task.comm.PreviousResultRegistrar;
|
||||
import org.jackhuang.hmcl.util.sys.FileUtils;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftLibrary;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hmcl.api.Wrapper;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -69,13 +66,11 @@ public class LiteLoaderInstaller extends Task implements PreviousResultRegistrar
|
||||
mv.libraries = new ArrayList<>(Arrays.asList(version.libraries));
|
||||
|
||||
MinecraftLibrary ml = new MinecraftLibrary("com.mumfrey:liteloader:" + version.selfVersion);
|
||||
//ml.url = "http://dl.liteloader.com/versions/com/mumfrey/liteloader/" + version.mcVersion + "/liteloader-" + version.selfVersion + ".jar";
|
||||
ml.url = "http://dl.liteloader.com/versions";
|
||||
mv.libraries.add(0, ml);
|
||||
|
||||
String path = "libraries/com/mumfrey/liteloader/" + version.selfVersion + "/liteloader-" + version.selfVersion + ".jar";
|
||||
MinecraftLibraryPathEvent event = new MinecraftLibraryPathEvent(this, path, new Wrapper<>(new File(service.baseDirectory(), path)));
|
||||
HMCLApi.EVENT_BUS.fireChannel(event);
|
||||
FileUtils.copyFile(installer, event.getFile().getValue());
|
||||
|
||||
// We use options from the old vanilla version.
|
||||
FileUtils.copyFile(installer, service.version().getLibraryFile(mv, ml));
|
||||
|
||||
mv.id += "-LiteLoader" + version.selfVersion;
|
||||
|
||||
|
@ -20,8 +20,6 @@ package org.jackhuang.hmcl.core.install.optifine;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.zip.ZipFile;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.api.event.version.MinecraftLibraryPathEvent;
|
||||
import org.jackhuang.hmcl.util.C;
|
||||
import org.jackhuang.hmcl.core.install.InstallerVersionList;
|
||||
import org.jackhuang.hmcl.core.service.IMinecraftService;
|
||||
@ -33,7 +31,6 @@ import org.jackhuang.hmcl.util.task.comm.PreviousResultRegistrar;
|
||||
import org.jackhuang.hmcl.util.sys.FileUtils;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftLibrary;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hmcl.api.Wrapper;
|
||||
import org.jackhuang.hmcl.api.HMCLog;
|
||||
|
||||
/**
|
||||
@ -72,9 +69,8 @@ public class OptiFineInstaller extends Task implements PreviousResultRegistrar<F
|
||||
library.downloads.artifact.size = 0;
|
||||
mv.libraries.add(0, library);
|
||||
|
||||
MinecraftLibraryPathEvent event = new MinecraftLibraryPathEvent(this, "libraries/" + library.downloads.artifact.path, new Wrapper<>(new File(service.baseDirectory(), "libraries/" + library.downloads.artifact.path)));
|
||||
HMCLApi.EVENT_BUS.fireChannel(event);
|
||||
FileUtils.copyFile(installer, event.getFile().getValue());
|
||||
// We use options from the old vanilla version.
|
||||
FileUtils.copyFile(installer, service.version().getLibraryFile(service.version().getVersionById(installId), library));
|
||||
|
||||
mv.id += "-" + selfId;
|
||||
try (ZipFile zipFile = new ZipFile(installer)) {
|
||||
|
@ -52,13 +52,13 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
||||
opt.add(l);
|
||||
continue;
|
||||
}
|
||||
File f = l.getFilePath(gameDir);
|
||||
File f = service.version().getLibraryFile(version, l);
|
||||
if (f == null)
|
||||
continue;
|
||||
library.append(f.getAbsolutePath()).append(File.pathSeparator);
|
||||
}
|
||||
for (MinecraftLibrary l : opt) {
|
||||
File f = l.getFilePath(gameDir);
|
||||
File f = service.version().getLibraryFile(version, l);
|
||||
if (f == null)
|
||||
continue;
|
||||
library.append(f.getAbsolutePath()).append(File.pathSeparator);
|
||||
|
@ -22,9 +22,9 @@ import java.util.Collection;
|
||||
import org.jackhuang.hmcl.core.GameException;
|
||||
import org.jackhuang.hmcl.api.game.DecompressLibraryJob;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hmcl.api.event.EventHandler;
|
||||
import org.jackhuang.hmcl.api.func.Consumer;
|
||||
import org.jackhuang.hmcl.api.func.Predicate;
|
||||
import org.jackhuang.hmcl.api.game.IMinecraftLibrary;
|
||||
|
||||
/**
|
||||
* Provide everything of the Minecraft of a Profile.
|
||||
@ -158,5 +158,7 @@ public abstract class IMinecraftProvider {
|
||||
public File baseDirectory() {
|
||||
return service.baseDirectory();
|
||||
}
|
||||
|
||||
public abstract File getLibraryFile(MinecraftVersion version, IMinecraftLibrary library);
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.api.event.version.MinecraftLibraryPathEvent;
|
||||
import org.jackhuang.hmcl.util.sys.OS;
|
||||
import org.jackhuang.hmcl.util.sys.Platform;
|
||||
import org.jackhuang.hmcl.util.StrUtils;
|
||||
@ -108,9 +107,7 @@ public class MinecraftLibrary extends AbstractMinecraftLibrary {
|
||||
LibraryDownloadInfo info = getDownloadInfo();
|
||||
if (info == null)
|
||||
return null;
|
||||
MinecraftLibraryPathEvent event = new MinecraftLibraryPathEvent(this, "libraries/" + info.path, new Wrapper<>(new File(gameDir, "libraries/" + info.path)));
|
||||
HMCLApi.EVENT_BUS.fireChannel(event);
|
||||
return event.getFile().getValue();
|
||||
return new File(gameDir, "libraries/" + info.path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,19 +77,19 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
HMCLApi.EVENT_BUS.fireChannel(new RefreshingVersionsEvent(this));
|
||||
|
||||
try {
|
||||
MCUtils.tryWriteProfile(service.baseDirectory());
|
||||
MCUtils.tryWriteProfile(baseDirectory());
|
||||
} catch (IOException ex) {
|
||||
HMCLog.warn("Failed to create launcher_profiles.json, Forge/LiteLoader installer will not work.", ex);
|
||||
}
|
||||
|
||||
versions.clear();
|
||||
File oldDir = new File(service.baseDirectory(), "bin");
|
||||
File oldDir = new File(baseDirectory(), "bin");
|
||||
if (oldDir.exists()) {
|
||||
MinecraftClassicVersion v = new MinecraftClassicVersion();
|
||||
versions.put(v.id, v);
|
||||
}
|
||||
|
||||
File version = new File(service.baseDirectory(), "versions");
|
||||
File version = new File(baseDirectory(), "versions");
|
||||
File[] files = version.listFiles();
|
||||
if (files != null && files.length > 0)
|
||||
for (File dir : files) {
|
||||
@ -154,7 +154,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public File versionRoot(String id) {
|
||||
return new File(service.baseDirectory(), "versions/" + id);
|
||||
return new File(baseDirectory(), "versions/" + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -220,6 +220,11 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
SwingUtils.openFolder((name == null) ? getRunDirectory(mv) : new File(getRunDirectory(mv), name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getLibraryFile(MinecraftVersion version, IMinecraftLibrary lib) {
|
||||
return lib.getFilePath(baseDirectory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecompressLibraryJob getDecompressLibraries(MinecraftVersion v) throws GameException {
|
||||
if (v.libraries == null)
|
||||
@ -228,7 +233,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
ArrayList<Extract> extractRules = new ArrayList<>();
|
||||
for (IMinecraftLibrary l : v.libraries)
|
||||
if (l.isRequiredToUnzip() && v.isAllowedToUnpackNatives()) {
|
||||
unzippings.add(IOUtils.tryGetCanonicalFile(l.getFilePath(service.baseDirectory())));
|
||||
unzippings.add(IOUtils.tryGetCanonicalFile(getLibraryFile(v, l)));
|
||||
extractRules.add(l.getDecompressExtractRules());
|
||||
}
|
||||
return new DecompressLibraryJob(unzippings.toArray(new File[unzippings.size()]), extractRules.toArray(new Extract[extractRules.size()]), getDecompressNativesToLocation(v));
|
||||
@ -236,13 +241,13 @@ public class MinecraftVersionManager extends IMinecraftProvider {
|
||||
|
||||
@Override
|
||||
public File getDecompressNativesToLocation(MinecraftVersion v) {
|
||||
return v == null ? null : v.getNatives(service.baseDirectory());
|
||||
return v == null ? null : v.getNatives(baseDirectory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getMinecraftJar(String id) {
|
||||
if (versions.containsKey(id))
|
||||
return versions.get(id).getJar(service.baseDirectory());
|
||||
return versions.get(id).getJar(baseDirectory());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
@ -291,6 +291,7 @@ advancedsettings.launcher_visibility.keep=Keep the launcher visible.
|
||||
advancedsettings.game_dir.default=Default (.minecraft/)
|
||||
advancedsettings.game_dir.independent=Independent (.minecraft/versions/<version name>/, except assets,libraries)
|
||||
advancedsettings.no_jvm_args=No Default JVM Args
|
||||
advancedsettings.no_common=Not using common path
|
||||
advancedsettings.java_args_default=Default java args: -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
|
||||
advancedsettings.wrapper_launcher=Wrapper Launcher(like optirun...)
|
||||
advancedsettings.precall_command=Precalling command(will be executed before game launching)
|
||||
|
@ -291,6 +291,7 @@ advancedsettings.launcher_visibility.keep=Keep the launcher visible.
|
||||
advancedsettings.game_dir.default=Default (.minecraft/)
|
||||
advancedsettings.game_dir.independent=Independent (.minecraft/versions/<version name>/, except assets,libraries)
|
||||
advancedsettings.no_jvm_args=No Default JVM Args
|
||||
advancedsettings.no_common=Not using common path
|
||||
advancedsettings.java_args_default=Default java args: -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
|
||||
advancedsettings.wrapper_launcher=Wrapper Launcher(like optirun...)
|
||||
advancedsettings.precall_command=Precalling command(will be executed before game launching)
|
||||
|
@ -289,6 +289,7 @@ advancedsettings.launcher_visibility.keep=Để cho launcher hiển thị.
|
||||
advancedsettings.game_dir.default=Mặc định (.minecraft/)
|
||||
advancedsettings.game_dir.independent=Independent (.minecraft/versions/<version name>/, trừ thư mục assets,libraries)
|
||||
advancedsettings.no_jvm_args=Không có arguments mặc định cho máy ảo java
|
||||
advancedsettings.no_common=Not using common path
|
||||
advancedsettings.java_args_default=Java arguments mặc định: -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
|
||||
advancedsettings.wrapper_launcher=Wrapper Launcher(dạng như optirun...)
|
||||
advancedsettings.precall_command=Câu lệnh được chạy trước khi game mở
|
||||
|
@ -289,6 +289,7 @@ advancedsettings.launcher_visibility.keep=\u0110\u1ec3 cho launcher hi\u1ec3n th
|
||||
advancedsettings.game_dir.default=M\u1eb7c \u0111\u1ecbnh (.minecraft/)
|
||||
advancedsettings.game_dir.independent=Independent (.minecraft/versions/<version name>/, tr\u1eeb th\u01b0 m\u1ee5c assets,libraries)
|
||||
advancedsettings.no_jvm_args=Kh\u00f4ng c\u00f3 arguments m\u1eb7c \u0111\u1ecbnh cho m\u00e1y \u1ea3o java
|
||||
advancedsettings.no_common=Not using common path
|
||||
advancedsettings.java_args_default=Java arguments m\u1eb7c \u0111\u1ecbnh: -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
|
||||
advancedsettings.wrapper_launcher=Wrapper Launcher(d\u1ea1ng nh\u01b0 optirun...)
|
||||
advancedsettings.precall_command=C\u00e2u l\u1ec7nh \u0111\u01b0\u1ee3c ch\u1ea1y tr\u01b0\u1edbc khi game m\u1edf
|
||||
|
@ -291,6 +291,7 @@ advancedsettings.launcher_visibility.keep=保持启动器可见
|
||||
advancedsettings.game_dir.default=默认(.minecraft/)
|
||||
advancedsettings.game_dir.independent=各版本独立(.minecraft/versions/<版本名>/,除assets,libraries)
|
||||
advancedsettings.no_jvm_args=不添加默认的JVM参数(使用Java9时必勾)
|
||||
advancedsettings.no_common=不使用公共路径
|
||||
advancedsettings.java_args_default=启动器默认添加的参数(请不要重复添加):-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
|
||||
advancedsettings.wrapper_launcher=前置指令(不必填写,如optirun)
|
||||
advancedsettings.precall_command=启动前执行命令(不必填写,将在游戏启动前调用)
|
||||
|
@ -291,6 +291,7 @@ advancedsettings.launcher_visibility.keep=\u4fdd\u6301\u542f\u52a8\u5668\u53ef\u
|
||||
advancedsettings.game_dir.default=\u9ed8\u8ba4(.minecraft/)
|
||||
advancedsettings.game_dir.independent=\u5404\u7248\u672c\u72ec\u7acb(.minecraft/versions/<\u7248\u672c\u540d>/,\u9664assets,libraries)
|
||||
advancedsettings.no_jvm_args=\u4e0d\u6dfb\u52a0\u9ed8\u8ba4\u7684JVM\u53c2\u6570(\u4f7f\u7528Java9\u65f6\u5fc5\u52fe)
|
||||
advancedsettings.no_common=\u4e0d\u4f7f\u7528\u516c\u5171\u8def\u5f84
|
||||
advancedsettings.java_args_default=\u542f\u52a8\u5668\u9ed8\u8ba4\u6dfb\u52a0\u7684\u53c2\u6570\uff08\u8bf7\u4e0d\u8981\u91cd\u590d\u6dfb\u52a0\uff09\uff1a-XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:MaxPermSize=???m -Xmx???m -Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true
|
||||
advancedsettings.wrapper_launcher=\u524d\u7f6e\u6307\u4ee4(\u4e0d\u5fc5\u586b\u5199,\u5982optirun)
|
||||
advancedsettings.precall_command=\u542f\u52a8\u524d\u6267\u884c\u547d\u4ee4(\u4e0d\u5fc5\u586b\u5199\uff0c\u5c06\u5728\u6e38\u620f\u542f\u52a8\u524d\u8c03\u7528)
|
||||
|
Loading…
Reference in New Issue
Block a user