added utils and prettyfied code
parent
2cbae59c92
commit
3302365852
|
@ -27,7 +27,7 @@ public class ChunkManager extends Thread
|
|||
private boolean active;
|
||||
private static Class<?> iBiome, iCache, s12w03a;
|
||||
private Method getData, clearCache;
|
||||
private ArrayList<Player> players;
|
||||
private List<Player> players;
|
||||
private static boolean firstRun = true;
|
||||
private SkinManager m;
|
||||
public ChunkManager(long seed) {
|
||||
|
@ -38,13 +38,13 @@ public class ChunkManager extends Thread
|
|||
Type t = null;
|
||||
if (ReflectionInfo.versionID >= 9) {
|
||||
Method cs[] = iBiome.getDeclaredMethods();
|
||||
for (int i = 0; i < cs.length; i++) {
|
||||
Class<?>[] types = cs[i].getParameterTypes();
|
||||
|
||||
if ((types.length == 2)&&(types[1]!=long.class)) {
|
||||
t = types[1];
|
||||
}
|
||||
}
|
||||
for (Method c : cs) {
|
||||
Class<?>[] types = c.getParameterTypes();
|
||||
|
||||
if ((types.length == 2) && (types[1] != long.class)) {
|
||||
t = types[1];
|
||||
}
|
||||
}
|
||||
System.out.println("Err: " + t.toString());
|
||||
s12w03a = ClassLoader.getSystemClassLoader().loadClass(t.toString().split(" ")[1]);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class ChunkManager extends Thread
|
|||
|
||||
firstRun = false;
|
||||
}
|
||||
Object[] ret = null;
|
||||
Object[] ret;
|
||||
Method init;
|
||||
clearCache = iCache.getDeclaredMethod("a");
|
||||
if (ReflectionInfo.versionID >= 9) {
|
||||
|
@ -103,9 +103,8 @@ public class ChunkManager extends Thread
|
|||
private int[] ba(int a, int b, int c, int d) {
|
||||
try {
|
||||
clearCache.invoke(iCache);
|
||||
int[] temp = (int[])getData.invoke(this.b, a,b,c,d);
|
||||
|
||||
return temp;
|
||||
return (int[]) getData.invoke(this.b, a,b,c,d);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -153,8 +152,7 @@ public class ChunkManager extends Thread
|
|||
}
|
||||
|
||||
private void getPlayerData(Fragment frag) {
|
||||
for (int i = 0; i < players.size(); i++) {
|
||||
Player p = players.get(i);
|
||||
for (Player p : players) {
|
||||
if (frag.isInside(p.x, p.y)) {
|
||||
frag.addMapObject(p);
|
||||
}
|
||||
|
@ -164,11 +162,10 @@ public class ChunkManager extends Thread
|
|||
players.add(p);
|
||||
m.addPlayer(p);
|
||||
}
|
||||
public void setPlayerData(ArrayList<Player> ar) {
|
||||
public void setPlayerData(List<Player> ar) {
|
||||
players = ar;
|
||||
for (int i = 0; i < ar.size(); i++) {
|
||||
m.addPlayer(ar.get(i));
|
||||
}
|
||||
for (Player player : ar)
|
||||
m.addPlayer(player);
|
||||
}
|
||||
|
||||
private void getSlimeData(Fragment frag) {
|
||||
|
|
|
@ -9,17 +9,12 @@ import java.awt.BorderLayout;
|
|||
import java.awt.Container;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
|
@ -30,8 +25,6 @@ import javax.swing.JMenu;
|
|||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
public class FinderWindow extends JFrame {
|
||||
|
@ -120,10 +113,10 @@ public class FinderWindow extends JFrame {
|
|||
fileMenu.setMnemonic(KeyEvent.VK_F);
|
||||
JMenu newMenu = new JMenu("New");
|
||||
newMenu.setMnemonic(KeyEvent.VK_N);
|
||||
JMenuItem fromSeedMenu = new JMenuItem("From Seed"); fromSeedMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
|
||||
JMenuItem fromSeedMenu = new JMenuItem("From Seed"); fromSeedMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK));
|
||||
JMenuItem fromFileMenu = new JMenuItem("From File");
|
||||
JMenuItem fromServerMenu = new JMenuItem("From Server");
|
||||
JMenuItem saveMenu = new JMenuItem("Save Player Locations"); saveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
|
||||
JMenuItem saveMenu = new JMenuItem("Save Player Locations"); saveMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
|
||||
JMenuItem exitMenu = new JMenuItem("Exit");
|
||||
JMenu scriptMenu = new JMenu("Script");
|
||||
JMenuItem newScriptMenu = new JMenuItem("New");
|
||||
|
@ -135,20 +128,20 @@ public class FinderWindow extends JFrame {
|
|||
JMenu findMenu = new JMenu("Find");
|
||||
JMenuItem findBiomeMenu = new JMenuItem("Biome");
|
||||
JMenuItem findVillageMenu = new JMenuItem("Village");
|
||||
JMenuItem findStrongholdMenu = new JMenuItem("Stronghold");findStrongholdMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK));
|
||||
JMenuItem findStrongholdMenu = new JMenuItem("Stronghold");findStrongholdMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK));
|
||||
JMenu gotoMenu = new JMenu("Go To");
|
||||
JMenuItem gotoCoordMenu = new JMenuItem("Coordinate"); gotoCoordMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK));
|
||||
JMenuItem gotoCoordMenu = new JMenuItem("Coordinate"); gotoCoordMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.CTRL_DOWN_MASK));
|
||||
JMenuItem gotoPlayerMenu = new JMenuItem("Player");
|
||||
JMenuItem gotoSpawnMenu = new JMenuItem("Spawn");
|
||||
JMenuItem gotoChunkMenu = new JMenuItem("Chunk");
|
||||
JMenu layersMenu = new JMenu("Layers");
|
||||
layerSlimeMenu = new JCheckBoxMenuItem("Slimes"); layerSlimeMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.CTRL_MASK));
|
||||
layerGridMenu = new JCheckBoxMenuItem("Grid"); layerGridMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.CTRL_MASK));
|
||||
layerNetherMenu = new JCheckBoxMenuItem("Netherholds"); layerNetherMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, ActionEvent.CTRL_MASK));
|
||||
layerSlimeMenu = new JCheckBoxMenuItem("Slimes"); layerSlimeMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, InputEvent.CTRL_DOWN_MASK));
|
||||
layerGridMenu = new JCheckBoxMenuItem("Grid"); layerGridMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, InputEvent.CTRL_DOWN_MASK));
|
||||
layerNetherMenu = new JCheckBoxMenuItem("Netherholds"); layerNetherMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.CTRL_DOWN_MASK));
|
||||
layerNetherMenu.setModel(Options.instance.showNetherFortresses);
|
||||
layerIconMenu = new JCheckBoxMenuItem("Icons"); layerIconMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, ActionEvent.CTRL_MASK));
|
||||
layerIconMenu = new JCheckBoxMenuItem("Icons"); layerIconMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, InputEvent.CTRL_DOWN_MASK));
|
||||
layerIconMenu.setModel(Options.instance.showIcons);
|
||||
JMenuItem captureMenu = new JMenuItem("Capture"); captureMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
|
||||
JMenuItem captureMenu = new JMenuItem("Capture"); captureMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK));
|
||||
JMenu helpMenu = new JMenu("Help");
|
||||
JMenuItem checkMenu = new JMenuItem("Check for updates");
|
||||
JMenuItem aboutMenu = new JMenuItem("About");
|
||||
|
@ -208,9 +201,7 @@ public class FinderWindow extends JFrame {
|
|||
return true;
|
||||
}
|
||||
String[] st = f.getName().split("/.");
|
||||
if (st[st.length-1].toLowerCase().equals("png"))
|
||||
return true;
|
||||
return false;
|
||||
return st[st.length - 1].equalsIgnoreCase("png");
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
@ -260,11 +251,10 @@ public class FinderWindow extends JFrame {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (curProject.saveLoaded) {
|
||||
ArrayList<Player> ar = curProject.save.getPlayers();
|
||||
for (int i = 0; i < ar.size(); i++) {
|
||||
if (ar.get(i).needSave) {
|
||||
curProject.save.movePlayer(ar.get(i).getName(), ar.get(i).x, ar.get(i).y);
|
||||
ar.get(i).needSave = false;
|
||||
for (Player player : curProject.save.getPlayers()) {
|
||||
if (player.needSave) {
|
||||
curProject.save.movePlayer(player.getName(), player.x, player.y);
|
||||
player.needSave = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,10 +264,10 @@ public class FinderWindow extends JFrame {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (curProject.saveLoaded) {
|
||||
ArrayList<Player> ar = curProject.save.getPlayers();
|
||||
Object[] options = new Object[ar.size()];
|
||||
List<Player> players = curProject.save.getPlayers();
|
||||
Object[] options = new Object[players.size()];
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
options[i] = "Player \"" + ar.get(i).getName() + "\" at (" + ar.get(i).x + ", " + ar.get(i).y + ")";
|
||||
options[i] = "Player \"" + players.get(i).getName() + "\" at (" + players.get(i).x + ", " + players.get(i).y + ")";
|
||||
}
|
||||
String s = (String)JOptionPane.showInputDialog(
|
||||
window,
|
||||
|
@ -289,7 +279,7 @@ public class FinderWindow extends JFrame {
|
|||
options[0]);
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
if (s.equals(options[i])) {
|
||||
curProject.moveMapTo(ar.get(i).x >> 2, ar.get(i).y >> 2);
|
||||
curProject.moveMapTo(players.get(i).x >> 2, players.get(i).y >> 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -327,13 +317,13 @@ public class FinderWindow extends JFrame {
|
|||
fc = new JFileChooser();
|
||||
fc.addChoosableFileFilter(SaveLoader.getFilter());
|
||||
fc.setAcceptAllFileFilterUsed(false);
|
||||
fc.setCurrentDirectory(SaveLoader.getPath("saves/"));
|
||||
fc.setCurrentDirectory(SaveLoader.getPath("saves"));
|
||||
int returnVal = fc.showOpenDialog(window);
|
||||
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File f = fc.getSelectedFile();
|
||||
SaveLoader s = new SaveLoader(f);
|
||||
setProject(new Project(s, window));
|
||||
setProject(new Project(s));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -341,7 +331,7 @@ public class FinderWindow extends JFrame {
|
|||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
//Create the JOptionPane.
|
||||
String s = JOptionPane.showInputDialog(null, "Enter seed...", "New Project", 1);
|
||||
String s = JOptionPane.showInputDialog(null, "Enter seed...", "New Project", JOptionPane.QUESTION_MESSAGE);
|
||||
if (s!=null) {
|
||||
Object[] possibilities = {"default","flat", "largeBiomes"};
|
||||
String worldType = (String)JOptionPane.showInputDialog(
|
||||
|
@ -363,7 +353,7 @@ public class FinderWindow extends JFrame {
|
|||
gotoCoordMenu.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
String s = JOptionPane.showInputDialog(null, "Enter coordinates: (Ex. 123,456)", "Go To", 1);
|
||||
String s = JOptionPane.showInputDialog(null, "Enter coordinates: (Ex. 123,456)", "Go To", JOptionPane.QUESTION_MESSAGE);
|
||||
if (s!=null) {
|
||||
String[] c = s.split(",");
|
||||
long x = 0, y = 0;
|
||||
|
@ -409,7 +399,7 @@ public class FinderWindow extends JFrame {
|
|||
private void loadMinecraft() {
|
||||
fc = new JFileChooser();
|
||||
Class<?> mc = null;
|
||||
String s = null;
|
||||
File s = null;
|
||||
|
||||
//Temporary fix -- Should be removed in a few patches.
|
||||
if (pref.getBoolean("osxMistake", true)) {
|
||||
|
@ -418,8 +408,9 @@ public class FinderWindow extends JFrame {
|
|||
}
|
||||
|
||||
try {
|
||||
s = SaveLoader.getDefaultPath() + "bin/minecraft.jar";
|
||||
ClasspathHacker.addFile(pref.get("jar", s));
|
||||
s = SaveLoader.getPath("bin/minecraft.jar");
|
||||
String jar = pref.get("jar", null);
|
||||
ClasspathHacker.addFile((jar != null) ? new File(jar) : s);
|
||||
mc = ClassLoader.getSystemClassLoader().loadClass("net.minecraft.client.Minecraft");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -439,7 +430,7 @@ public class FinderWindow extends JFrame {
|
|||
int returnVal = fc.showOpenDialog(this);
|
||||
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
s = fc.getSelectedFile().toString();
|
||||
s = fc.getSelectedFile();
|
||||
try {
|
||||
ClasspathHacker.addFile(s);
|
||||
mc = ClassLoader.getSystemClassLoader().loadClass("net.minecraft.client.Minecraft");
|
||||
|
@ -452,7 +443,7 @@ public class FinderWindow extends JFrame {
|
|||
}
|
||||
}
|
||||
try {
|
||||
pref.put("jar", s);
|
||||
pref.put("jar", s.getCanonicalPath());
|
||||
|
||||
String typeDump = "";
|
||||
Field fields[] = mc.getDeclaredFields();
|
||||
|
@ -735,7 +726,11 @@ public class FinderWindow extends JFrame {
|
|||
ReflectionInfo.version = "unknown";
|
||||
ReflectionInfo.versionID = -1;
|
||||
intCache = "ab";
|
||||
String st = JOptionPane.showInputDialog(null, "Unsupported version of minecraft detected!\nEnter code to continue:\n(Name of the IntCache class)", "Error", 1);
|
||||
String st = JOptionPane.showInputDialog(
|
||||
null,
|
||||
"Unsupported version of minecraft detected!\nEnter code to continue:\n(Name of the IntCache class)",
|
||||
"Error",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
if (st==null) {
|
||||
System.exit(0);
|
||||
} else {
|
||||
|
@ -757,11 +752,4 @@ public class FinderWindow extends JFrame {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private void setLookAndFeel() {
|
||||
try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
|
||||
catch (ClassNotFoundException e1) { e1.printStackTrace(); }
|
||||
catch (InstantiationException e1) { e1.printStackTrace(); }
|
||||
catch (IllegalAccessException e1) { e1.printStackTrace(); }
|
||||
catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ public class MapListener implements ActionListener {
|
|||
this.name = name;
|
||||
map = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
map.movePlayer(name, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.awt.image.BufferedImage;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JComponent;
|
||||
|
@ -82,11 +83,11 @@ public class MapViewer extends JComponent implements MouseListener, MouseWheelLi
|
|||
this.addMouseWheelListener(this);
|
||||
menu = new JPopupMenu();
|
||||
if (proj.saveLoaded) {
|
||||
ArrayList<Player> pl = proj.save.getPlayers();
|
||||
for (int i = 0; i < pl.size(); i++) {
|
||||
JMenuItem tj = new JMenuItem("Move " + pl.get(i).getName() + " here.");
|
||||
List<Player> pl = proj.save.getPlayers();
|
||||
for (Player player : pl) {
|
||||
JMenuItem tj = new JMenuItem("Move " + player.getName() + " here.");
|
||||
|
||||
tj.addActionListener(new MapListener(this, pl.get(i).getName()));
|
||||
tj.addActionListener(new MapListener(this, player.getName()));
|
||||
menu.add(tj);
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +101,6 @@ public class MapViewer extends JComponent implements MouseListener, MouseWheelLi
|
|||
g2d.setColor(Color.black);
|
||||
g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
updateFragments();
|
||||
ArrayList<MapObject> markers = null;
|
||||
if (firstRun) {
|
||||
centerAt(0,0);
|
||||
firstRun = false;
|
||||
|
@ -128,8 +128,7 @@ public class MapViewer extends JComponent implements MouseListener, MouseWheelLi
|
|||
for (int ey = 0; ey < fragYMax; ey++) {
|
||||
for (int ex = 0; ex < fragXMax; ex++) {
|
||||
Fragment tempFrag = frags.get(ey).get(ex);
|
||||
markers = tempFrag.objects;
|
||||
for (MapObject m : markers) {
|
||||
for (MapObject m : tempFrag.objects) {
|
||||
g2d.drawImage(m.getImage(),
|
||||
(int) (tempFrag.tempX + m.rx * scale - (m.getWidth() >> 1)),
|
||||
(int) (tempFrag.tempY + m.ry * scale - (m.getHeight() >> 1)),
|
||||
|
@ -259,16 +258,12 @@ public class MapViewer extends JComponent implements MouseListener, MouseWheelLi
|
|||
|
||||
return p;
|
||||
}
|
||||
|
||||
public PixelInfo getCursorInformation() {
|
||||
|
||||
Point c = this.getMousePosition();
|
||||
PixelInfo p = null;
|
||||
|
||||
p = getCursorInformation(c);
|
||||
|
||||
return p;
|
||||
|
||||
return getCursorInformation(c);
|
||||
}
|
||||
|
||||
private void updateFragments() {
|
||||
double fragSize = scale*Project.FRAGMENT_SIZE;
|
||||
if (mX > fragSize) {
|
||||
|
@ -443,7 +438,6 @@ public class MapViewer extends JComponent implements MouseListener, MouseWheelLi
|
|||
PixelInfo p = getCursorInformation(new Point(tempX, tempY));
|
||||
|
||||
proj.movePlayer(name, p);
|
||||
|
||||
}
|
||||
|
||||
public void saveToFile(File f) {
|
||||
|
@ -453,17 +447,17 @@ public class MapViewer extends JComponent implements MouseListener, MouseWheelLi
|
|||
g2d.setColor(Color.black);
|
||||
g2d.fillRect(0, 0, img.getWidth(), img.getHeight());
|
||||
|
||||
ArrayList<MapObject> markers = null;
|
||||
List<MapObject> markers;
|
||||
for (int ey = 0; ey < fragYMax; ey++) {
|
||||
for (int ex = 0; ex < fragXMax; ex++) {
|
||||
Fragment tempFrag = frags.get(ey).get(ex);
|
||||
tempFrag.tempX = (int)((tempFrag.x - fragX)*Project.FRAGMENT_SIZE);
|
||||
tempFrag.tempY = (int)((tempFrag.y - fragY)*Project.FRAGMENT_SIZE);
|
||||
tempFrag.tempX = (tempFrag.x - fragX)*Project.FRAGMENT_SIZE;
|
||||
tempFrag.tempY = (tempFrag.y - fragY)*Project.FRAGMENT_SIZE;
|
||||
tempFrag.paint(g2d,
|
||||
tempFrag.tempX,
|
||||
tempFrag.tempY,
|
||||
(int)(Project.FRAGMENT_SIZE),
|
||||
(int)(Project.FRAGMENT_SIZE));
|
||||
tempFrag.tempY,
|
||||
Project.FRAGMENT_SIZE,
|
||||
Project.FRAGMENT_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
package MoF;
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
|
||||
public class Project extends JPanel {
|
||||
private static final long serialVersionUID = 1132526465987018165L;
|
||||
private long seed;
|
||||
|
@ -30,8 +28,9 @@ public class Project extends JPanel {
|
|||
public Project(long seed, FinderWindow window) {
|
||||
this(seed, window, "default");
|
||||
}
|
||||
|
||||
public Project(long seed, FinderWindow window, String type) {
|
||||
SaveLoader.genType=type;
|
||||
SaveLoader.genType = type;
|
||||
saveLoaded = false;
|
||||
//Enter seed data:
|
||||
this.setSeed(seed);
|
||||
|
@ -43,18 +42,21 @@ public class Project extends JPanel {
|
|||
map.repaint();
|
||||
minfo.repaint();
|
||||
}
|
||||
|
||||
public Project(String seed, FinderWindow window, String type) {
|
||||
this(stringToLong(seed), window, type);
|
||||
this.seedText = "Seed: \"" + seed + "\" (" + this.seed + ")";
|
||||
|
||||
|
||||
Google.track("seed/" + seed + "/" + this.seed);
|
||||
}
|
||||
|
||||
public Project(String seed, FinderWindow window) {
|
||||
this(stringToLong(seed), window);
|
||||
this.seedText = "Seed: \"" + seed + "\" (" + this.seed + ")";
|
||||
|
||||
|
||||
Google.track("seed/" + seed + "/" + this.seed);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
map.dispose();
|
||||
map = null;
|
||||
|
@ -69,16 +71,16 @@ public class Project extends JPanel {
|
|||
|
||||
}
|
||||
|
||||
public Project(SaveLoader file, FinderWindow window) {
|
||||
public Project(SaveLoader file) {
|
||||
saveLoaded = true;
|
||||
save = file;
|
||||
//Enter seed data:
|
||||
this.setSeed(file.seed);
|
||||
this.seedText = "Seed: " + seed;
|
||||
init();
|
||||
|
||||
|
||||
Google.track("seed/file/" + this.seed);
|
||||
ArrayList<Player> players = file.getPlayers();
|
||||
List<Player> players = file.getPlayers();
|
||||
manager.setPlayerData(players);
|
||||
|
||||
}
|
||||
|
@ -97,20 +99,20 @@ public class Project extends JPanel {
|
|||
//Debug
|
||||
this.setBackground(Color.BLUE);
|
||||
|
||||
|
||||
|
||||
//Timer:
|
||||
timer = new Timer();
|
||||
|
||||
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
public void run() {
|
||||
tick();
|
||||
}
|
||||
}, 20, 20);
|
||||
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
public void run() {
|
||||
tick();
|
||||
}
|
||||
}, 20, 20);
|
||||
}
|
||||
|
||||
private static long stringToLong(String seed) {
|
||||
long ret = 0L;
|
||||
long ret;
|
||||
try {
|
||||
ret = Long.parseLong(seed);
|
||||
} catch (NumberFormatException err) {
|
||||
|
|
|
@ -5,11 +5,13 @@ import amidst.nbt.TagCompound;
|
|||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
public class SaveLoader {
|
||||
public static String genType = "default";
|
||||
|
||||
public static FileFilter getFilter() {
|
||||
return (new FileFilter() {
|
||||
public boolean accept(File f) {
|
||||
|
@ -26,31 +28,31 @@ public class SaveLoader {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static File getPath(String post) {
|
||||
return new File(getDefaultPath() + post);
|
||||
return new File(getMinecraftDirectory(), post);
|
||||
}
|
||||
public static String getDefaultPath() {
|
||||
String defaultPath = System.getProperty("user.home", ".");
|
||||
|
||||
public static File getMinecraftDirectory() {
|
||||
File homeDirectory = new File(System.getProperty("user.home", "."));
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
if (os.contains("win")) {
|
||||
String appdata = System.getenv("APPDATA");
|
||||
if (appdata!=null) {
|
||||
return appdata + "/.minecraft/";
|
||||
} else {
|
||||
return defaultPath + "/.minecraft/";
|
||||
}
|
||||
} else if (os.contains("mac")) {
|
||||
return defaultPath + "/Library/Application Support/minecraft/";
|
||||
}
|
||||
return defaultPath + "/.minecraft/";
|
||||
|
||||
if (os.contains("win")) {
|
||||
File appData = new File(System.getenv("APPDATA"));
|
||||
if (appData.isDirectory())
|
||||
return new File(appData, ".minecraft");
|
||||
} else if (os.contains("mac"))
|
||||
return new File(homeDirectory, "Library/Application Support/minecraft");
|
||||
|
||||
return new File(homeDirectory, ".minecraft");
|
||||
}
|
||||
|
||||
private File file;
|
||||
private ArrayList<Player> players;
|
||||
private List<Player> players;
|
||||
public long seed;
|
||||
private boolean multi;
|
||||
private ArrayList<String> back;
|
||||
public ArrayList<Player> getPlayers() {
|
||||
private List<String> back;
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
public void movePlayer(String name, int x, int y) {
|
||||
|
@ -87,6 +89,7 @@ public class SaveLoader {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void backupFile(File inputFile) {
|
||||
File outputFile = new File(inputFile.toString() + ".moth");
|
||||
if (!back.contains(outputFile.toString())) {
|
||||
|
@ -115,29 +118,26 @@ public class SaveLoader {
|
|||
seed = (Long) t.findTagByName("RandomSeed").getValue();
|
||||
genType = (String) t.findTagByName("generatorName").getValue();
|
||||
System.out.println("Gen Type: " + genType);
|
||||
if (pTag != null) {
|
||||
multi = false;
|
||||
Tag pos = pTag.findTagByName("Pos");
|
||||
Tag<Double>[] pa = (Tag[]) pos.getValue();
|
||||
double x = pa[0].getValue();
|
||||
double z = pa[2].getValue();
|
||||
players.add(new Player("Player", (int) x, (int) z));
|
||||
multi = pTag == null;
|
||||
if (!multi) {
|
||||
addPlayer("Player", pTag);
|
||||
} else {
|
||||
multi = true;
|
||||
File[] listing = new File(f.getParent() + "/players").listFiles();
|
||||
TagCompound ps;
|
||||
File[] listing = new File(f.getParent(), "players").listFiles();
|
||||
for (int i = 0; i < (listing != null ? listing.length : 0); i++) {
|
||||
ps = Tag.readFrom(new FileInputStream(listing[i]));
|
||||
Tag pos = ps.findTagByName("Pos");
|
||||
Tag<Double>[] pa = (Tag[]) pos.getValue();
|
||||
double x = pa[0].getValue();
|
||||
double z = pa[2].getValue();
|
||||
players.add(new Player(listing[i].getName().split("\\.")[0], (int) x, (int) z));
|
||||
|
||||
TagCompound ps = Tag.readFrom(new FileInputStream(listing[i]));
|
||||
addPlayer(listing[i].getName().split("\\.")[0], ps);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Util.showError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayer(String name, TagCompound ps) {
|
||||
Tag pos = ps.findTagByName("Pos");
|
||||
Tag<Double>[] pa = (Tag[]) pos.getValue();
|
||||
double x = pa[0].getValue();
|
||||
double z = pa[2].getValue();
|
||||
players.add(new Player(name, (int) x, (int) z));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ public class Amidst {
|
|||
public final static int version_minor = 0;
|
||||
|
||||
public static void main(String args[]) throws IOException {
|
||||
Util.setLookAndFeel();
|
||||
Google.startTracking();
|
||||
Google.track("Run");
|
||||
//TODO: load options
|
||||
|
|
|
@ -23,6 +23,12 @@ public class Util {
|
|||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
public static void setLookAndFeel() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// try {
|
||||
// int infinity = 1 / 0;
|
||||
|
|
Loading…
Reference in New Issue