mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Removed installer
The code was mainly for forge and it was built using swing instead of javafx
This commit is contained in:
parent
cd88e513a8
commit
fb0bb62180
@ -1,44 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.util.prefs.Preferences;
|
||||
import javafx.application.Platform;
|
||||
import javafx.embed.swing.JFXPanel;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
|
||||
public abstract class BrowseButton extends InteractiveButton {
|
||||
private final String id;
|
||||
|
||||
public BrowseButton(String id) {
|
||||
super("Browse");
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public abstract void onSelect(File folder);
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Preferences prefs = Preferences.userRoot().node(Fawe.class.getName());
|
||||
String lastUsed = prefs.get("LAST_USED_FOLDER", null);
|
||||
final File lastFile = lastUsed == null ? null : new File(lastUsed).getParentFile();
|
||||
browse(lastFile);
|
||||
}
|
||||
|
||||
public void browse(File from) {
|
||||
DirectoryChooser folderChooser = new DirectoryChooser();
|
||||
folderChooser.setInitialDirectory(from);
|
||||
|
||||
new JFXPanel(); // Init JFX Platform
|
||||
Platform.runLater(() -> {
|
||||
File file = folderChooser.showDialog(null);
|
||||
if (file != null && file.exists()) {
|
||||
File parent = file.getParentFile();
|
||||
if (parent == null) parent = file;
|
||||
Preferences.userRoot().node(Fawe.class.getName()).put("LAST_USED_FOLDER" + id, parent.getPath());
|
||||
onSelect(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
public class CloseButton extends InteractiveButton {
|
||||
public CloseButton() {
|
||||
super("X");
|
||||
setColor(new Color(0x66, 0x33, 0x33));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class ImagePanel extends JPanel {
|
||||
|
||||
private BufferedImage image;
|
||||
|
||||
public ImagePanel(BufferedImage image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setRenderingHint(
|
||||
RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setComposite(AlphaComposite.getInstance(
|
||||
AlphaComposite.SRC_OVER, 0.6f));
|
||||
g.drawImage(image, 0, 0, getWidth(), getWidth(), this); // see javadoc for more info on the parameters
|
||||
}
|
||||
|
||||
}
|
@ -1,341 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import com.boydti.fawe.FaweVersion;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
public class InstallerFrame extends JFrame {
|
||||
private final InvisiblePanel loggerPanel;
|
||||
private Color DARKER_GRAY;
|
||||
private Color INVISIBLE = new Color(0, 0, 0, 0);
|
||||
|
||||
private JTextArea loggerTextArea;
|
||||
private BrowseButton browse;
|
||||
|
||||
public InstallerFrame() throws Exception {
|
||||
final MovablePanel movable = new MovablePanel(this);
|
||||
Container content = this.getContentPane();
|
||||
content.add(movable);
|
||||
this.setSize(480, 320);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setUndecorated(true);
|
||||
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
int x = (int) ((dimension.getWidth() - this.getWidth()) / 2);
|
||||
int y = (int) ((dimension.getHeight() - this.getHeight()) / 2);
|
||||
this.setLocation(x, y);
|
||||
this.setVisible(true);
|
||||
this.setOpacity(0);
|
||||
movable.setBackground(Color.darkGray);
|
||||
movable.setLayout(new BorderLayout());
|
||||
|
||||
fadeIn();
|
||||
|
||||
JPanel topBar = new InvisiblePanel(new BorderLayout());
|
||||
JPanel topBarLeft = new InvisiblePanel();
|
||||
JPanel topBarRight = new InvisiblePanel();
|
||||
|
||||
JLabel title = new JLabel("FastAsyncWorldEdit Installer");
|
||||
title.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
title.setAlignmentX(Component.RIGHT_ALIGNMENT);
|
||||
title.setForeground(Color.lightGray);
|
||||
|
||||
MinimizeButton minimize = new MinimizeButton(this);
|
||||
CloseButton exit = new CloseButton();
|
||||
|
||||
topBarLeft.add(title);
|
||||
topBarRight.add(minimize);
|
||||
topBarRight.add(exit);
|
||||
|
||||
topBar.add(topBarLeft, BorderLayout.CENTER);
|
||||
topBar.add(topBarRight, BorderLayout.EAST);
|
||||
final JPanel mainContent = new InvisiblePanel(new BorderLayout());
|
||||
DARKER_GRAY = new Color(0x26, 0x26, 0x28);
|
||||
final JPanel browseContent = new InvisiblePanel(new BorderLayout());
|
||||
File dir = MainUtil.getWorkingDirectory("minecraft");
|
||||
JLabel folder = new JLabel("Folder: ");
|
||||
folder.setForeground(Color.white);
|
||||
final InteractiveButton text = new InteractiveButton(dir.getPath(), DARKER_GRAY) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
browse.actionPerformed(e);
|
||||
}
|
||||
};
|
||||
text.setForeground(Color.white);
|
||||
text.setBackground(DARKER_GRAY);
|
||||
text.setOpaque(true);
|
||||
text.setBorder(new EmptyBorder(4, 4, 4, 4));
|
||||
browse = new BrowseButton("") {
|
||||
@Override
|
||||
public void onSelect(File folder) {
|
||||
text.setText(folder.getPath());
|
||||
movable.repaint();
|
||||
}
|
||||
};
|
||||
InteractiveButton install = new InteractiveButton(">> Create Profile <<", DARKER_GRAY) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
install(text.getText());
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
browseContent.add(folder, BorderLayout.WEST);
|
||||
browseContent.add(text, BorderLayout.CENTER);
|
||||
browseContent.add(browse, BorderLayout.EAST);
|
||||
final JPanel installContent = new InvisiblePanel(new FlowLayout());
|
||||
install.setPreferredSize(new Dimension(416, 32));
|
||||
installContent.add(install);
|
||||
installContent.setBorder(new EmptyBorder(10, 0, 10, 0));
|
||||
this.loggerPanel = new InvisiblePanel(new BorderLayout());
|
||||
this.loggerPanel.setBackground(Color.GREEN);
|
||||
loggerPanel.setPreferredSize(new Dimension(416, 160));
|
||||
loggerTextArea = new JTextArea(12, 52);
|
||||
Color GRAY = new Color(0x44, 0x44, 0x46);
|
||||
loggerTextArea.setBackground(GRAY);
|
||||
loggerTextArea.setForeground(DARKER_GRAY);
|
||||
loggerTextArea.setFont(new Font(loggerTextArea.getFont().getName(), Font.PLAIN, 9));
|
||||
JScrollPane scroll = new JScrollPane(loggerTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scroll.setBackground(Color.darkGray);
|
||||
scroll.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
loggerPanel.add(scroll);
|
||||
loggerPanel.setVisible(false);
|
||||
|
||||
mainContent.setBorder(new EmptyBorder(6, 32, 6, 32));
|
||||
mainContent.add(browseContent, BorderLayout.NORTH);
|
||||
mainContent.add(installContent, BorderLayout.CENTER);
|
||||
mainContent.add(loggerPanel, BorderLayout.SOUTH);
|
||||
JPanel bottomBar = new InvisiblePanel();
|
||||
try {
|
||||
FaweVersion version = null;
|
||||
String date = new Date(100 + version.year, version.month, version.day).toGMTString();
|
||||
String build = "https://ci.athion.net/job/FastAsyncWorldEdit/" + version.build;
|
||||
String commit = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash);
|
||||
String footerMessage = "FAWE v" + version.year + "." + version.month + "." + version.day + " by Empire92 (c) 2017 (GPL v3.0)";
|
||||
URL licenseUrl = new URL("https://github.com/boy0001/FastAsyncWorldedit/blob/master/LICENSE");
|
||||
URLButton licenseButton = new URLButton(licenseUrl, footerMessage);
|
||||
bottomBar.add(licenseButton);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
URL chat = new URL("https://discord.gg/ngZCzbU");
|
||||
URLButton chatButton = new URLButton(chat, "Chat");
|
||||
bottomBar.add(chatButton);
|
||||
URL wiki = new URL("https://github.com/boy0001/FastAsyncWorldedit/wiki");
|
||||
URLButton wikiButton = new URLButton(wiki, "Wiki");
|
||||
bottomBar.add(wikiButton);
|
||||
URL issue = new URL("https://github.com/boy0001/FastAsyncWorldedit/issues/new");
|
||||
URLButton issueButton = new URLButton(issue, "Report Issue");
|
||||
bottomBar.add(issueButton);
|
||||
|
||||
// We want to add these a bit later
|
||||
movable.add(topBar, BorderLayout.NORTH);
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
movable.add(mainContent, BorderLayout.CENTER);
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
movable.add(bottomBar, BorderLayout.SOUTH);
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private boolean newLine = false;
|
||||
|
||||
public void prompt(String message) {
|
||||
JOptionPane.showMessageDialog(null, message);
|
||||
}
|
||||
|
||||
public void debug(String m) {
|
||||
System.out.println(m);
|
||||
}
|
||||
|
||||
public void install(String name) throws Exception {
|
||||
if (!loggerPanel.isVisible()) {
|
||||
loggerPanel.setVisible(true);
|
||||
this.repaint();
|
||||
System.setOut(new TextAreaOutputStream(loggerTextArea));
|
||||
}
|
||||
if (name == null || name.isEmpty()) {
|
||||
prompt("No folder selection");
|
||||
return;
|
||||
}
|
||||
final File dirMc = new File(name);
|
||||
if (!dirMc.exists()) {
|
||||
prompt("Folder does not exist");
|
||||
return;
|
||||
}
|
||||
if (!dirMc.isDirectory()) {
|
||||
prompt("You must select a folder, not a file");
|
||||
return;
|
||||
}
|
||||
Thread installThread = new Thread(() -> {
|
||||
List<String> supported = Arrays.asList("v1710", "v189", "v194", "v110", "v111");
|
||||
String supportedString = null;
|
||||
for (String version : supported) {
|
||||
try {
|
||||
Class.forName("com.boydti.fawe.forge." + version + ".ForgeChunk_All");
|
||||
supportedString = version;
|
||||
break;
|
||||
} catch (ClassNotFoundException ignore) {
|
||||
}
|
||||
}
|
||||
if (supportedString == null) {
|
||||
prompt("This version of FAWE cannot be installed this way.");
|
||||
return;
|
||||
}
|
||||
debug("Selected version " + supportedString);
|
||||
URL forgeUrl;
|
||||
URL worldEditUrl;
|
||||
URL worldEditCuiUrl;
|
||||
try {
|
||||
switch (supportedString) {
|
||||
case "v111":
|
||||
forgeUrl = new URL("https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.11.2-13.20.0.2201/forge-1.11.2-13.20.0.2201-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9593/download/worldedit-forge-mc1.11-6.1.6-SNAPSHOT-dist.jar");
|
||||
worldEditCuiUrl = new URL("https://addons-origin.cursecdn.com/files/2361/241/worldeditcuife-v1.0.6-mf-1.11.2-13.20.0.2201.jar");
|
||||
break;
|
||||
case "v110":
|
||||
forgeUrl = new URL("http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.10.2-12.18.3.2185/forge-1.10.2-12.18.3.2185-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9395/download/worldedit-forge-mc1.10.2-6.1.4-SNAPSHOT-dist.jar");
|
||||
worldEditCuiUrl = new URL("https://addons-origin.cursecdn.com/files/2361/239/WorldEditCuiFe-v1.0.6-mf-1.10.2-12.18.2.2125.jar");
|
||||
break;
|
||||
case "v194":
|
||||
forgeUrl = new URL("https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.9.4-12.17.0.2051/forge-1.9.4-12.17.0.2051-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9171/download/worldedit-forge-mc1.9.4-6.1.3-SNAPSHOT-dist.jar");
|
||||
worldEditCuiUrl = new URL("https://addons-origin.cursecdn.com/files/2361/236/WorldEditCuiFe-v1.0.6-mf-1.9.4-12.17.0.1976.jar");
|
||||
break;
|
||||
case "v189":
|
||||
forgeUrl = new URL("https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.8.9-11.15.1.1902-1.8.9/forge-1.8.9-11.15.1.1902-1.8.9-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/8755/download/worldedit-forge-mc1.8.9-6.1.1-dist.jar");
|
||||
worldEditCuiUrl = new URL("https://addons-origin.cursecdn.com/files/2361/235/WorldEditCuiFe-v1.0.6-mf-1.8.9-11.15.1.1855.jar");
|
||||
break;
|
||||
case "v1710":
|
||||
forgeUrl = new URL("https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.7.10-10.13.4.1614-1.7.10/forge-1.7.10-10.13.4.1614-1.7.10-installer.jar");
|
||||
worldEditUrl = new URL("http://builds.enginehub.org/job/worldedit/9194/download/worldedit-forge-mc1.7.10-6.1.2-SNAPSHOT-dist.jar");
|
||||
worldEditCuiUrl = new URL("https://addons-origin.cursecdn.com/files/2361/234/WorldEditCuiFe-v1.0.6-mf-1.7.10-10.13.4.1566.jar");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try { // install forge
|
||||
debug("Downloading forge installer from:\n - https://files.minecraftforge.net/");
|
||||
URLClassLoader loader = new URLClassLoader(new URL[]{forgeUrl});
|
||||
debug("Connected");
|
||||
Class<?> forgeInstallClass = loader.loadClass("net.minecraftforge.installer.ClientInstall");
|
||||
debug("Found ClientInstall class");
|
||||
Object forgeInstallInstance = forgeInstallClass.newInstance();
|
||||
debug(forgeInstallInstance + " | " + forgeInstallClass + " | " + StringMan.getString(forgeInstallClass.getMethods()));
|
||||
debug("Created instance " + forgeInstallInstance);
|
||||
Method methodRun = forgeInstallClass.getDeclaredMethods()[0];//("run", File.class, Predicate.class);
|
||||
Object alwaysTrue = loader.loadClass("com.google.common.base.Predicates").getDeclaredMethod("alwaysTrue").invoke(null);
|
||||
methodRun.invoke(forgeInstallInstance, dirMc, alwaysTrue);
|
||||
debug("Forge profile created, now installing WorldEdit");
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
prompt("[ERROR] Forge install failed, download from:\nhttps://files.minecraftforge.net/");
|
||||
}
|
||||
File mods = new File(dirMc, "mods");
|
||||
if (!mods.exists()) {
|
||||
debug("Creating mods directory");
|
||||
mods.mkdirs();
|
||||
} else {
|
||||
for (File file : mods.listFiles()) {
|
||||
String name1 = file.getName().toLowerCase();
|
||||
if ((name1.contains("worldedit") || name1.contains("fawe"))) {
|
||||
debug("Delete existing: " + file.getName());
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
try { // install worldedit
|
||||
debug("Downloading WE-CUI from:\n - https://minecraft.curseforge.com/projects/worldeditcui-forge-edition");
|
||||
try (ReadableByteChannel rbc = Channels.newChannel(worldEditCuiUrl.openStream())) {
|
||||
try (FileOutputStream fos = new FileOutputStream(new File(mods, "WorldEditCUI.jar"))) {
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
debug("Successfully downloaded WorldEdit-CUI");
|
||||
} catch (Throwable e) {
|
||||
prompt("[ERROR] WorldEdit install failed, download from:\nhttp://builds.enginehub.org/job/worldedit");
|
||||
}
|
||||
try { // install worldedit
|
||||
debug("Downloading WorldEdit from:\n - http://builds.enginehub.org/job/worldedit");
|
||||
try (ReadableByteChannel rbc = Channels.newChannel(worldEditUrl.openStream())) {
|
||||
try (FileOutputStream fos = new FileOutputStream(new File(mods, "WorldEdit.jar"))) {
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
|
||||
}
|
||||
}
|
||||
debug("Successfully downloaded WorldEdit");
|
||||
} catch (Throwable e) {
|
||||
prompt("[ERROR] WorldEdit install failed, download from:\nhttp://builds.enginehub.org/job/worldedit");
|
||||
}
|
||||
try { // install FAWE
|
||||
debug("Copying FastAsyncWorldEdit to mods directory");
|
||||
File file = new File(InstallerFrame.class.getProtectionDomain().getCodeSource().getLocation().getPath());
|
||||
debug(" - " + file.getPath());
|
||||
MainUtil.copyFile(file, new File(mods, "FastAsyncWorldEdit.jar"));
|
||||
debug("Installation complete!");
|
||||
} catch (Throwable e) {
|
||||
prompt("[ERROR] Copy installer failed, please copy this installer jar manually");
|
||||
}
|
||||
prompt("Installation complete!\nLaunch the game using the forge profile.");
|
||||
});
|
||||
installThread.start();
|
||||
}
|
||||
|
||||
public void fadeIn() {
|
||||
Thread thread = new Thread(() -> {
|
||||
for (float i = 0; i <= 1; i += 0.001) {
|
||||
InstallerFrame.this.setOpacity(i);
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
InstallerFrame window = new InstallerFrame();
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class InteractiveButton extends JButton implements ActionListener, MouseListener {
|
||||
private Color background;
|
||||
|
||||
public InteractiveButton(String text) {
|
||||
this(text, new Color(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
public InteractiveButton(String text, Color background) {
|
||||
setText(text);
|
||||
setBorderPainted(false);
|
||||
setVisible(true);
|
||||
setForeground(new Color(200, 200, 200));
|
||||
addActionListener(this);
|
||||
addMouseListener(this);
|
||||
setFocusable(false);
|
||||
if (background.getAlpha() != 0) {
|
||||
this.background = background;
|
||||
} else {
|
||||
this.background = new Color(0x38, 0x38, 0x39);
|
||||
}
|
||||
setBackground(this.background);
|
||||
}
|
||||
|
||||
public void setColor(Color background) {
|
||||
setBackground(background);
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
setBackground(new Color(0x44, 0x44, 0x44));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
setBackground(this.background);
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
setBackground(new Color(0x77, 0x77, 0x77));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
setBackground(new Color(0x33, 0x33, 0x36));
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.LayoutManager;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class InvisiblePanel extends JPanel {
|
||||
public InvisiblePanel(LayoutManager layout) {
|
||||
super(layout);
|
||||
setBackground(new Color(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
public InvisiblePanel() {
|
||||
this(new FlowLayout());
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import sun.swing.FilePane;
|
||||
|
||||
public class JSystemFileChooser extends JFileChooser {
|
||||
public void updateUI(){
|
||||
LookAndFeel old = UIManager.getLookAndFeel();
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
old = null;
|
||||
}
|
||||
|
||||
super.updateUI();
|
||||
|
||||
if(old != null){
|
||||
FilePane filePane = findFilePane(this);
|
||||
filePane.setViewType(FilePane.VIEWTYPE_DETAILS);
|
||||
filePane.setViewType(FilePane.VIEWTYPE_LIST);
|
||||
|
||||
Color background = UIManager.getColor("Label.background");
|
||||
setBackground(background);
|
||||
setOpaque(true);
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel(old);
|
||||
}
|
||||
catch (UnsupportedLookAndFeelException ignored) {} // shouldn't get here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static FilePane findFilePane(Container parent){
|
||||
for(Component comp: parent.getComponents()){
|
||||
if(comp instanceof FilePane){
|
||||
return (FilePane)comp;
|
||||
}
|
||||
if(comp instanceof Container){
|
||||
Container cont = (Container)comp;
|
||||
if(cont.getComponentCount() > 0){
|
||||
FilePane found = findFilePane(cont);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Frame;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
public class MinimizeButton extends InteractiveButton {
|
||||
private final JFrame window;
|
||||
|
||||
public MinimizeButton(JFrame window) {
|
||||
super("-");
|
||||
this.window = window;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
window.setState(Frame.ICONIFIED);
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class MovablePanel extends JPanel {
|
||||
private Point initialClick;
|
||||
private JFrame parent;
|
||||
|
||||
public MovablePanel(final JFrame parent) {
|
||||
this.parent = parent;
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
initialClick = e.getPoint();
|
||||
getComponentAt(initialClick);
|
||||
}
|
||||
});
|
||||
|
||||
addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
|
||||
// get location of Window
|
||||
int thisX = parent.getLocation().x;
|
||||
int thisY = parent.getLocation().y;
|
||||
|
||||
// Determine how much the mouse moved since the initial click
|
||||
int xMoved = (thisX + e.getX()) - (thisX + initialClick.x);
|
||||
int yMoved = (thisY + e.getY()) - (thisY + initialClick.y);
|
||||
|
||||
// Move window to this position
|
||||
int X = thisX + xMoved;
|
||||
int Y = thisY + yMoved;
|
||||
parent.setLocation(X, Y);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
public class TextAreaOutputStream extends PrintStream {
|
||||
|
||||
public TextAreaOutputStream(final JTextArea textArea) {
|
||||
super(new OutputStream() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
AtomicBoolean updated = new AtomicBoolean();
|
||||
AtomicBoolean waiting = new AtomicBoolean();
|
||||
boolean lineColor = false;
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
buffer.append((char) b);
|
||||
if (b == '\n') {
|
||||
updated.set(true);
|
||||
if (waiting.compareAndSet(false, true)) {
|
||||
executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
updated.set(false);
|
||||
int len = buffer.length();
|
||||
textArea.append(BBC.stripColor(buffer.substring(0, len)));
|
||||
buffer.delete(0, len);
|
||||
textArea.setVisible(true);
|
||||
textArea.repaint();
|
||||
} finally {
|
||||
waiting.set(false);
|
||||
if (updated.get() && waiting.compareAndSet(false, true)) {
|
||||
executor.submit(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
updated.lazySet(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.boydti.fawe.installer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
public class URLButton extends InteractiveButton {
|
||||
private final URL url;
|
||||
|
||||
public URLButton(URL url, String text) {
|
||||
super("<HTML>" + text + "</HTML>");
|
||||
this.url = url;
|
||||
setFont(new Font(getFont().getName(), Font.PLAIN, 9));
|
||||
setForeground(new Color(0x77, 0x77, 0x77));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(url.toURI());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
|
||||
Clipboard systemClipboard = defaultToolkit.getSystemClipboard();
|
||||
systemClipboard.setContents(new StringSelection(url.toString()), null);
|
||||
}
|
||||
}
|
@ -72,6 +72,7 @@ import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
@ -222,9 +223,7 @@ public class LocalSession implements TextureHolder {
|
||||
SparseBitSet set = new SparseBitSet();
|
||||
final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid);
|
||||
if (folder.isDirectory()) {
|
||||
folder.listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
folder.listFiles(pathname -> {
|
||||
String name = pathname.getName();
|
||||
Integer val = null;
|
||||
if (pathname.isDirectory()) {
|
||||
@ -236,7 +235,6 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
if (val != null) set.set(val);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!set.isEmpty()) {
|
||||
@ -256,10 +254,8 @@ public class LocalSession implements TextureHolder {
|
||||
}
|
||||
File file = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid + File.separator + "index");
|
||||
if (file.exists()) {
|
||||
try {
|
||||
FaweInputStream is = new FaweInputStream(new FileInputStream(file));
|
||||
try (FaweInputStream is = new FaweInputStream(new FileInputStream(file))) {
|
||||
historyNegativeIndex = Math.min(Math.max(0, is.readInt()), history.size());
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -279,9 +275,9 @@ public class LocalSession implements TextureHolder {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
}
|
||||
FaweOutputStream os = new FaweOutputStream(new FileOutputStream(file));
|
||||
try (FaweOutputStream os = new FaweOutputStream(new FileOutputStream(file))) {
|
||||
os.writeInt(getHistoryNegativeIndex());
|
||||
os.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user