Fix gradle file

This commit is contained in:
huangyuhui 2017-02-13 18:46:30 +08:00
parent 33ef03ef71
commit 5a6e1ffcd9
9 changed files with 81 additions and 62 deletions

View File

@ -15,11 +15,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
plugins {
id "edu.sc.seis.macAppBundle" version "2.1.6"
//id "me.tatarka.retrolambda" version "3.5.0"
id 'edu.sc.seis.launch4j' version '2.3.0'
}
buildscript {
repositories {
@ -31,6 +26,12 @@ buildscript {
}
}
plugins {
id "edu.sc.seis.macAppBundle" version "2.1.6"
//id "me.tatarka.retrolambda" version "3.5.0"
id 'edu.sc.seis.launch4j' version '2.3.0'
}
apply plugin: 'me.tatarka.retrolambda'
import java.util.jar.JarOutputStream

View File

@ -0,0 +1,34 @@
/*
* 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.hellominecraft.launcher.core.mod;
/**
*
* @author huang
*/
public interface ModAdviser {
ModSuggestion advise(String fileName, boolean isDirectory);
public static enum ModSuggestion {
SUGGESTED,
NORMAL,
HIDDEN
}
}

View File

@ -39,7 +39,6 @@ import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.util.func.BiFunction;
import org.jackhuang.hellominecraft.util.func.CallbackIO;
import org.jackhuang.hellominecraft.util.sys.CompressingUtils;
import org.jackhuang.hellominecraft.util.sys.FileUtils;
@ -73,14 +72,14 @@ public final class ModpackManager {
/**
* Install the compressed modpack.
*
* @param input modpack.zip
* @param input modpack.zip
* @param service MinecraftService, whose version service only supports
* MinecraftVersionManager.
* @param id new version id, if null, will use suggested name from
* modpack
* MinecraftVersionManager.
* @param id new version id, if null, will use suggested name from
* modpack
*
* @return The installing Task, may take long time, please consider
* TaskWindow.
* TaskWindow.
*/
public static Task install(JFrame parFrame, final File input, final IMinecraftService service, final String idFUCK) {
return new Task() {
@ -152,10 +151,10 @@ public final class ModpackManager {
final AtomicInteger b = new AtomicInteger(0);
HMCLog.log("Decompressing modpack");
CompressingUtils.unzip(input, versions, t -> {
if (t.equals("minecraft/pack.json"))
b.incrementAndGet();
return true;
}, true);
if (t.equals("minecraft/pack.json"))
b.incrementAndGet();
return true;
}, true);
// No pack.json here, illegal modpack.
if (b.get() < 1)
@ -208,40 +207,31 @@ public final class ModpackManager {
public static final List<String> MODPACK_BLACK_LIST = Arrays.asList(new String[] { "usernamecache.json", "asm", "logs", "backups", "versions", "assets", "usercache.json", "libraries", "crash-reports", "launcher_profiles.json", "NVIDIA", "AMD", "TCNodeTracker", "screenshots", "natives", "native", "$native", "pack.json", "launcher.jar", "minetweaker.log", "launcher.pack.lzma", "hmclmc.log" });
public static final List<String> MODPACK_SUGGESTED_BLACK_LIST = Arrays.asList(new String[] { "fonts", "saves", "servers.dat", "options.txt", "optionsof.txt", "journeymap", "optionsshaders.txt", "mods/VoxelMods" });
/**
* &lt; String, Boolean, Boolean &gt;: Folder/File name, Is Directory,
* Return 0: non blocked, 1: non shown, 2: suggested, checked.
*/
public static final BiFunction<String, Boolean, Integer> MODPACK_PREDICATE = (String x, Boolean y) -> {
if (ModpackManager.MODPACK_BLACK_LIST_PREDICATE.apply(x, y))
return 1;
if (ModpackManager.MODPACK_SUGGESTED_BLACK_LIST_PREDICATE.apply(x, y))
return 2;
return 0;
public static ModAdviser MODPACK_PREDICATE = (String fileName, boolean isDirectory) -> {
if (match(MODPACK_BLACK_LIST, fileName, isDirectory))
return ModAdviser.ModSuggestion.HIDDEN;
if (match(MODPACK_SUGGESTED_BLACK_LIST, fileName, isDirectory))
return ModAdviser.ModSuggestion.NORMAL;
return ModAdviser.ModSuggestion.SUGGESTED;
};
public static final BiFunction<String, Boolean, Boolean> MODPACK_BLACK_LIST_PREDICATE = modpackPredicateMaker(MODPACK_BLACK_LIST);
public static final BiFunction<String, Boolean, Boolean> MODPACK_SUGGESTED_BLACK_LIST_PREDICATE = modpackPredicateMaker(MODPACK_SUGGESTED_BLACK_LIST);
private static BiFunction<String, Boolean, Boolean> modpackPredicateMaker(final List<String> l) {
return (String x, Boolean y) -> {
for (String s : l)
if (y) {
if (x.startsWith(s + "/"))
return true;
} else if (x.equals(s))
private static boolean match(final List<String> l, String fileName, boolean isDirectory) {
for (String s : l)
if (isDirectory) {
if (fileName.startsWith(s + "/"))
return true;
return false;
};
} else if (fileName.equals(s))
return true;
return false;
}
/**
* Export the game to a mod pack file.
*
* @param output mod pack file.
* @param output mod pack file.
* @param baseFolder if the game dir type is ROOT_FOLDER, use ".minecraft",
* or use ".minecraft/versions/{MCVER}/"
* @param version to locate version.json
* or use ".minecraft/versions/{MCVER}/"
* @param version to locate version.json
*
* @throws IOException if create tmp directory failed
*/
@ -256,14 +246,14 @@ public final class ModpackManager {
try {
zip = new ZipEngine(output);
zip.putDirectory(provider.getRunDirectory(version), (String x, Boolean y) -> {
for (String s : b)
if (y) {
if (x.startsWith(s + "/"))
return null;
} else if (x.equals(s))
return null;
return "minecraft/" + x;
});
for (String s : b)
if (y) {
if (x.startsWith(s + "/"))
return null;
} else if (x.equals(s))
return null;
return "minecraft/" + x;
});
MinecraftVersion mv = provider.getVersionById(version).resolve(provider);
MinecraftVersionRequest r = MinecraftVersionRequest.minecraftVersion(provider.getMinecraftJar(version));

View File

@ -103,7 +103,6 @@ public final class Main implements Runnable {
private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
@SuppressWarnings({ "CallToPrintStackTrace", "UseSpecificCatch" })
public static void main(String[] args) throws IOException {
{
PluginManager.getPlugin(DefaultPlugin.class);

View File

@ -32,7 +32,6 @@ public class DraggableFrame extends JFrame
private int dragGripX;
private int dragGripY;
@SuppressWarnings("LeakingThisInConstructor")
public DraggableFrame() {
addMouseListener(this);
addMouseMotionListener(this);

View File

@ -23,9 +23,9 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.swing.tree.DefaultTreeModel;
import org.jackhuang.hellominecraft.launcher.core.mod.ModAdviser;
import org.jackhuang.hellominecraft.util.C;
import org.jackhuang.hellominecraft.util.Pair;
import org.jackhuang.hellominecraft.util.func.BiFunction;
import org.jackhuang.hellominecraft.util.sys.FileUtils;
import org.jackhuang.hellominecraft.util.ui.checktree.CheckBoxTreeCellRenderer;
import org.jackhuang.hellominecraft.util.ui.checktree.CheckBoxTreeNode;
@ -40,7 +40,7 @@ public class ModpackFileSelectionPanel extends javax.swing.JPanel {
private transient final WizardController controller;
private final Map wizardData;
private transient final BiFunction<String, Boolean, Integer> blackList;
private transient final ModAdviser blackList;
private final Set<String> bannedFiles = new HashSet<>();
/**
@ -49,7 +49,7 @@ public class ModpackFileSelectionPanel extends javax.swing.JPanel {
* @param blackList Return 0: non blocked, 1: non shown, 2: suggested,
* checked
*/
public ModpackFileSelectionPanel(WizardController controller, Map wizardData, File gameDir, BiFunction<String, Boolean, Integer> blackList) {
public ModpackFileSelectionPanel(WizardController controller, Map wizardData, File gameDir, ModAdviser blackList) {
initComponents();
this.controller = controller;
@ -83,12 +83,12 @@ public class ModpackFileSelectionPanel extends javax.swing.JPanel {
};
CheckBoxTreeNode create(File file, String basePath) {
int state = 0;
ModAdviser.ModSuggestion state = ModAdviser.ModSuggestion.NORMAL;
if (basePath.length() > "minecraft/".length())
if ((state = blackList.apply(basePath.substring("minecraft/".length()) + (file.isDirectory() ? "/" : ""), file.isDirectory())) == 1)
if ((state = blackList.advise(basePath.substring("minecraft/".length()) + (file.isDirectory() ? "/" : ""), file.isDirectory())) == ModAdviser.ModSuggestion.HIDDEN)
return null;
CheckBoxTreeNode node = new CheckBoxTreeNode(TRANSLATION.containsKey(basePath) ? new Pair<>(FileUtils.getName(basePath), TRANSLATION.get(basePath)) : FileUtils.getName(basePath));
if (state == 2)
if (state == ModAdviser.ModSuggestion.SUGGESTED)
node.setSelected(true);
if (file.isDirectory()) {

View File

@ -3528,7 +3528,6 @@ public final class MainWindow extends javax.swing.JFrame
Server.getInstance().sendCommand("save-all");
}//GEN-LAST:event_btnSaveActionPerformed
@SuppressWarnings("UseOfObsoleteCollectionType")
private void btnSaveExtModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveExtModActionPerformed
ArrayList<String> arrayList = new ArrayList<>();
Vector strings = ((DefaultTableModel) lstExternalMods.getModel()).getDataVector();
@ -3541,7 +3540,6 @@ public final class MainWindow extends javax.swing.JFrame
SettingsManager.save();
}//GEN-LAST:event_btnSaveExtModActionPerformed
@SuppressWarnings("UseOfObsoleteCollectionType")
private void btnSavePluginsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSavePluginsActionPerformed
ArrayList<String> arrayList = new ArrayList<>();
Vector strings = ((DefaultTableModel) lstCoreMods.getModel()).getDataVector();

View File

@ -1,7 +1,7 @@
/*
* Hello Minecraft!.
* 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
@ -22,6 +22,6 @@ package org.jackhuang.hellominecraft.util.func;
* @author huangyuhui
*/
public interface BiFunction<A, B, C> {
C apply(A a, B b);
}

View File

@ -20,7 +20,6 @@ package org.jackhuang.hellominecraft.util.sys;
import java.util.Arrays;
import java.util.HashSet;
import org.jackhuang.hellominecraft.util.CollectionUtils;
import org.jackhuang.hellominecraft.api.EventHandler;
import org.jackhuang.hellominecraft.api.HMCAPI;
import org.jackhuang.hellominecraft.api.event.process.JVMLaunchFailedEvent;
import org.jackhuang.hellominecraft.api.event.process.JavaProcessExitedAbnormallyEvent;
@ -57,7 +56,6 @@ public class JavaProcessMonitor {
this.tag = tag;
}
public void start() {
HMCAPI.EVENT_BUS.fireChannel(new JavaProcessStartingEvent(this, p));
ProcessThread a = new ProcessThread(p);