diff --git a/VirtualComputer/.classpath b/VirtualComputer/.classpath
new file mode 100644
index 0000000..5ee2d21
--- /dev/null
+++ b/VirtualComputer/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/VirtualComputer/.project b/VirtualComputer/.project
new file mode 100644
index 0000000..6543625
--- /dev/null
+++ b/VirtualComputer/.project
@@ -0,0 +1,17 @@
+
+
+ VirtualComputer
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/VirtualComputer/.settings/org.eclipse.jdt.core.prefs b/VirtualComputer/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..7341ab1
--- /dev/null
+++ b/VirtualComputer/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/VirtualComputer/VirtualComputerSender.j4n.jar b/VirtualComputer/VirtualComputerSender.j4n.jar
new file mode 100644
index 0000000..4d2694a
Binary files /dev/null and b/VirtualComputer/VirtualComputerSender.j4n.jar differ
diff --git a/VirtualComputer/jni4net.j-0.8.8.0.jar b/VirtualComputer/jni4net.j-0.8.8.0.jar
new file mode 100644
index 0000000..922c2ad
Binary files /dev/null and b/VirtualComputer/jni4net.j-0.8.8.0.jar differ
diff --git a/VirtualComputer/jni4net.n-0.8.8.0.dll b/VirtualComputer/jni4net.n-0.8.8.0.dll
new file mode 100644
index 0000000..2c7dc61
Binary files /dev/null and b/VirtualComputer/jni4net.n-0.8.8.0.dll differ
diff --git a/VirtualComputer/jni4net.n.w64.v40-0.8.8.0.dll b/VirtualComputer/jni4net.n.w64.v40-0.8.8.0.dll
new file mode 100644
index 0000000..6ff98f1
Binary files /dev/null and b/VirtualComputer/jni4net.n.w64.v40-0.8.8.0.dll differ
diff --git a/VirtualComputer/plugin.yml b/VirtualComputer/plugin.yml
new file mode 100644
index 0000000..f1684fd
--- /dev/null
+++ b/VirtualComputer/plugin.yml
@@ -0,0 +1,8 @@
+name: VirtualComputer
+main: sznp.virtualcomputer.PluginMain
+version: 1.0
+commands:
+ computer:
+ usage: Use /computer start|stop
+ alias: c
+depend: [Movecraft]
diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapAPI.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapAPI.java
new file mode 100644
index 0000000..c2a38da
--- /dev/null
+++ b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapAPI.java
@@ -0,0 +1,217 @@
+package com.mcplugindev.slipswhitley.sketchmap;
+
+/*
+ * This file was originally taken from https://github.com/slipswhitley/SketchMap
+ */
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+import com.mcplugindev.slipswhitley.sketchmap.file.SketchMapFileException;
+import com.mcplugindev.slipswhitley.sketchmap.map.RelativeLocation;
+import com.mcplugindev.slipswhitley.sketchmap.map.SketchMap;
+
+//import com.mcplugindev.slipswhitley.sketchmap.map.SketchMap.BaseFormat;
+
+public class SketchMapAPI
+{
+
+ public static SketchMap getMapByID(String id)
+ {
+ for (SketchMap map : SketchMap.getLoadedMaps())
+ {
+ if (map.getID().equalsIgnoreCase(id))
+ {
+ return map;
+ }
+ }
+
+ return null;
+ }
+
+ public static List getOrderedItemSet(SketchMap map)
+ {
+ List items = new ArrayList();
+
+ for (int y = 0; y < map.getLengthY(); y++)
+ {
+ for (int x = 0; x < map.getLengthX(); x++)
+ {
+ for (RelativeLocation loc : map.getMapCollection().keySet())
+ {
+ if (loc.getX() != x || loc.getY() != y)
+ {
+ continue;
+ }
+
+ ItemStack iStack = new ItemStack(Material.MAP, 1);
+ iStack.setDurability(SketchMapUtils.getMapID(map
+ .getMapCollection().get(loc)));
+
+ ItemMeta iMeta = iStack.getItemMeta();
+ iMeta.setDisplayName(ChatColor.GREEN + "SketchMap ID: "
+ + ChatColor.GOLD + map.getID() + ChatColor.GREEN
+ + " Pos-X: " + ChatColor.GOLD + (x + 1)
+ + ChatColor.GREEN + " Pos-Y: " + ChatColor.GOLD
+ + (y + 1));
+
+ iMeta.setLore(Arrays.asList(new String[] { ChatColor.GRAY
+ + "SketchMap ID: " + map.getID()
+
+ }));
+
+ iStack.setItemMeta(iMeta);
+ items.add(iStack);
+
+ }
+ }
+ }
+
+ return items;
+ }
+
+ public static SketchMap loadSketchMapFromFile(File file)
+ throws SketchMapFileException
+ {
+
+ YamlConfiguration config = null;
+ try
+ {
+ config = YamlConfiguration.loadConfiguration(file);
+ } catch (Exception ex)
+ {
+ throw new SketchMapFileException("Invalid SketchMap File \""
+ + file.getName() + "\"");
+ }
+
+ String[] fieldSet = { "x-panes", "y-panes", "public-protected",
+ "map-collection", "base-format", "map-image", };
+
+ for (String field : fieldSet)
+ {
+ if (!config.isSet(field))
+ {
+ throw new SketchMapFileException(
+ "Unable to load SketchMap file \"" + file.getName()
+ + "\" missing field \"" + field + "\"");
+ }
+ }
+
+ Integer xPanes = config.getInt("x-panes");
+ if (xPanes == null || xPanes < 1)
+ {
+ throw new SketchMapFileException("Unable to load SketchMap file \""
+ + file.getName() + "\" invalid field \"x-panes\"");
+ }
+
+ Integer yPanes = config.getInt("y-panes");
+ if (yPanes == null || yPanes < 1)
+ {
+ throw new SketchMapFileException("Unable to load SketchMap file \""
+ + file.getName() + "\" invalid field \"y-panes\"");
+ }
+
+ Boolean publicProtected = config.getBoolean("public-protected");
+ if (publicProtected == null)
+ {
+ throw new SketchMapFileException("Unable to load SketchMap file \""
+ + file.getName() + "\" invalid field \"public-protected\"");
+ }
+
+ List mapList = config.getStringList("map-collection");
+ if (mapList == null)
+ {
+ throw new SketchMapFileException("Unable to load SketchMap file \""
+ + file.getName() + "\" invalid field \"map-collection\"");
+ }
+
+ Map mapCollection = new HashMap();
+
+ for (String map : mapList)
+ {
+ String[] split = map.split(" ");
+ if (split.length != 2)
+ {
+ throw new SketchMapFileException(
+ "Unable to load SketchMap file \"" + file.getName()
+ + "\" cannot parse field in \"map-colection\"");
+ }
+
+ RelativeLocation loc = RelativeLocation.fromString(split[0]);
+
+ if (loc == null)
+ {
+ throw new SketchMapFileException(
+ "Unable to load SketchMap file \"" + file.getName()
+ + "\" cannot parse field in \"map-colection\"");
+ }
+
+ Short id = null;
+ try
+ {
+ id = Short.parseShort(split[1]);
+ } catch (Exception ex)
+ {
+ throw new SketchMapFileException(
+ "Unable to load SketchMap file \"" + file.getName()
+ + "\" cannot parse field in \"map-colection\"");
+ }
+
+ mapCollection.put(id, loc);
+ }
+
+ //BaseFormat format = null;
+ /*
+ * try {
+ * format = BaseFormat.valueOf(config.getString("base-format"));
+ * }
+ * catch (Exception ex) {
+ * throw new SketchMapFileException("Unable to load SketchMap file \"" +
+ * file.getName()
+ * + "\" cannot parse BaseFormat from field \"base-format\"");
+ * }
+ */
+
+ String b64Img = config.getString("map-image");
+ if (b64Img == null)
+ {
+ throw new SketchMapFileException("Unable to load SketchMap file \""
+ + file.getName() + "\" invalid field \"map-image\"");
+ }
+
+ BufferedImage image = null;
+
+ try
+ {
+ image = SketchMapUtils.base64StringToImg(b64Img);
+ } catch (Exception ex)
+ {
+ throw new SketchMapFileException("Unable to load SketchMap file \""
+ + file.getName()
+ + "\" parse image from field \"map-image\"");
+ }
+
+ String imageID = file.getName().substring(0,
+ file.getName().lastIndexOf("."));
+ if (getMapByID(imageID) != null)
+ {
+ throw new SketchMapFileException("Unable to load SketchMap file \""
+ + file.getName()
+ + "\" A SketchMap by that ID already exists.");
+ }
+
+ return new SketchMap(image, imageID, yPanes, yPanes, publicProtected);
+ }
+
+}
diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapPlugin.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapPlugin.java
new file mode 100644
index 0000000..5a46bc8
--- /dev/null
+++ b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapPlugin.java
@@ -0,0 +1,54 @@
+package com.mcplugindev.slipswhitley.sketchmap;
+
+/*
+ * This file was originally taken from https://github.com/slipswhitley/SketchMap
+ */
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import com.mcplugindev.slipswhitley.sketchmap.listener.PlayerListener;
+
+public class SketchMapPlugin extends JavaPlugin
+{
+ private static SketchMapPlugin plugin;
+
+ public void onEnable()
+ {
+ plugin = this;
+
+ setupListeners();
+
+ sendEnabledMessage();
+ }
+
+ private void sendEnabledMessage()
+ {
+ SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN
+ + "| |");
+
+ SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN + "| "
+ + ChatColor.AQUA + "SketchMap "
+ + this.getDescription().getVersion() + " has been Enabled!"
+ + ChatColor.GREEN + " |");
+
+ SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN + "| "
+ + ChatColor.AQUA + " Authors: SlipsWhitley & Fyrinlight"
+ + ChatColor.GREEN + " |");
+
+ SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN
+ + "| |");
+ }
+
+ private void setupListeners()
+ {
+ Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
+ }
+
+ public static SketchMapPlugin getPlugin()
+ {
+ return plugin;
+ }
+
+}
diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapUtils.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapUtils.java
new file mode 100644
index 0000000..68358ac
--- /dev/null
+++ b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/SketchMapUtils.java
@@ -0,0 +1,109 @@
+package com.mcplugindev.slipswhitley.sketchmap;
+
+/*
+ * This file was originally taken from https://github.com/slipswhitley/SketchMap
+ */
+
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.Base64;
+import java.util.HashSet;
+
+import javax.imageio.ImageIO;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.map.MapView;
+
+public class SketchMapUtils
+{
+
+ /**
+ *
+ * Image Utils
+ *
+ */
+
+ public static BufferedImage resize(Image img, Integer width, Integer height)
+ {
+
+ img = img.getScaledInstance(width, height, Image.SCALE_SMOOTH);
+
+ if (img instanceof BufferedImage)
+ {
+ return (BufferedImage) img;
+ }
+
+ BufferedImage bimage = new BufferedImage(img.getWidth(null),
+ img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
+
+ Graphics2D bGr = bimage.createGraphics();
+ bGr.drawImage(img, 0, 0, null);
+ bGr.dispose();
+
+ return bimage;
+ }
+
+ public static BufferedImage base64StringToImg(final String base64String)
+ {
+ try
+ {
+ return ImageIO.read(new ByteArrayInputStream(Base64.getDecoder()
+ .decode(base64String)));
+ } catch (final IOException ioe)
+ {
+ throw new UncheckedIOException(ioe);
+ }
+ }
+
+ public static void sendColoredConsoleMessage(String msg)
+ {
+ ConsoleCommandSender sender = Bukkit.getConsoleSender();
+ sender.sendMessage(msg);
+ }
+
+ /**
+ * Deprecated Methods Here :'c
+ */
+
+ @SuppressWarnings("deprecation")
+ public static short getMapID(MapView map)
+ {
+ return map.getId();
+ }
+
+ @SuppressWarnings("deprecation")
+ public static MapView getMapView(short id)
+ {
+ MapView map = Bukkit.getMap(id);
+ if (map != null)
+ {
+ return map;
+ }
+
+ return Bukkit.createMap(getDefaultWorld());
+ }
+
+ /**
+ *
+ */
+
+ public static Block getTargetBlock(Player player, int i)
+ {
+ return player.getTargetBlock((HashSet) null, i);
+ }
+
+ public static World getDefaultWorld()
+ {
+ return Bukkit.getWorlds().get(0);
+ }
+
+}
diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/file/SketchMapFileException.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/file/SketchMapFileException.java
new file mode 100644
index 0000000..ab385e7
--- /dev/null
+++ b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/file/SketchMapFileException.java
@@ -0,0 +1,14 @@
+package com.mcplugindev.slipswhitley.sketchmap.file;
+
+public class SketchMapFileException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public SketchMapFileException(String message) {
+ super(message);
+ }
+
+}
diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/listener/PlayerListener.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/listener/PlayerListener.java
new file mode 100644
index 0000000..2a267de
--- /dev/null
+++ b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/listener/PlayerListener.java
@@ -0,0 +1,69 @@
+package com.mcplugindev.slipswhitley.sketchmap.listener;
+
+import org.bukkit.ChatColor;
+import org.bukkit.GameMode;
+import org.bukkit.Material;
+import org.bukkit.entity.ItemFrame;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerInteractEntityEvent;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class PlayerListener implements Listener {
+
+ @EventHandler
+ public void onPlayerInteract(PlayerInteractEntityEvent event) {
+ if(!(event.getRightClicked() instanceof ItemFrame)) {
+ return;
+ }
+
+ ItemFrame iFrame = (ItemFrame) event.getRightClicked();
+ ItemStack iHand = event.getPlayer().getItemInHand();
+
+ if(iHand.getType() != Material.MAP) {
+ return;
+ }
+
+ String lore = iHand.getItemMeta().getLore().get(0);
+
+ if(!ChatColor.stripColor(lore).startsWith("SketchMap ID:")) {
+ return;
+ }
+
+ if(iFrame.getItem().getType() != Material.AIR) {
+ return;
+ }
+
+ if(event.isCancelled()) {
+ return;
+ }
+
+ event.setCancelled(true);
+
+
+ ItemStack frameItem = iHand.clone();
+ frameItem.setAmount(1);
+ ItemMeta frameIMeta = frameItem.getItemMeta();
+
+ frameIMeta.setDisplayName("");
+ frameItem.setItemMeta(frameIMeta);
+
+ iFrame.setItem(frameItem);
+
+ Player player = event.getPlayer();
+ if(player.getGameMode() == GameMode.CREATIVE) {
+ return;
+ }
+
+ if(iHand.getAmount() == 1) {
+ player.getInventory().setItemInHand(new ItemStack(Material.AIR));
+ return;
+ }
+
+ iHand.setAmount(iHand.getAmount() - 1);
+
+
+ }
+}
diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/ImageRenderer.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/ImageRenderer.java
new file mode 100644
index 0000000..30eb045
--- /dev/null
+++ b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/ImageRenderer.java
@@ -0,0 +1,77 @@
+package com.mcplugindev.slipswhitley.sketchmap.map;
+
+import java.awt.image.BufferedImage;
+import java.util.concurrent.TimeUnit;
+
+import org.bukkit.entity.Player;
+import org.bukkit.map.MapCanvas;
+import org.bukkit.map.MapRenderer;
+import org.bukkit.map.MapView;
+
+public class ImageRenderer extends MapRenderer
+{
+
+ private BufferedImage image;
+
+ //private Boolean imageRendered;
+
+ public ImageRenderer(BufferedImage image)
+ {
+ this.image = image;
+ //this.imageRendered = false;
+ }
+
+ private int progress = 0;
+ //private final int updatepixels = 20;
+ public static int updatepixels = 15;
+
+ @Override
+ public void render(MapView view, MapCanvas canvas, Player player)
+ {
+ /*
+ * if(imageRendered) {
+ * return;
+ * }
+ */
+
+ long time = System.nanoTime();
+
+ try
+ {
+ //if (progress != 128 / updatepixels) //<-- Never had an issue with this before 2016.02.20. because I wasn't using 16 as updatepixels
+ canvas.drawImage(0, progress * updatepixels, image.getSubimage(0,
+ progress * updatepixels, 128, (progress * updatepixels
+ + updatepixels >= 128 ? 128 - progress
+ * updatepixels : updatepixels)));
+ if (progress < 128 / updatepixels)
+ progress++;
+ else
+ progress = 0;
+ //this.imageRendered = true;
+
+ long diff = System.nanoTime() - time;
+ if (TimeUnit.NANOSECONDS.toMillis(diff) > 40)
+ {
+ System.out.println("Map rendering took "
+ + TimeUnit.NANOSECONDS.toMillis(diff) + " ms");
+ /*
+ * if (progress == 0 && updatepixels > 5)
+ * updatepixels--;
+ */
+ } /*
+ * else if (TimeUnit.NANOSECONDS.toMillis(diff) < 25)
+ * if (progress == 0 && updatepixels < 50)
+ * updatepixels++;
+ */
+ /*
+ * if (progress >= 128 / updatepixels)
+ * progress = 0;
+ */
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ System.out.println("Progess: " + progress);
+ System.out.println("UpdatePixels: " + updatepixels);
+ }
+ }
+}
diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/RelativeLocation.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/RelativeLocation.java
new file mode 100644
index 0000000..2030b3a
--- /dev/null
+++ b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/RelativeLocation.java
@@ -0,0 +1,53 @@
+package com.mcplugindev.slipswhitley.sketchmap.map;
+
+public class RelativeLocation {
+
+ private int x;
+ private int y;
+
+ public RelativeLocation (int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+
+ public String toString() {
+ return x + ":" + y;
+ }
+
+ public static RelativeLocation fromString(String str) {
+ String[] args = str.split(":");
+ if(args.length != 2) {
+ return null;
+ }
+
+ int x = 0;
+ int y = 0;
+
+ try {
+ x = Integer.parseInt(args[0]);
+ y = Integer.parseInt(args[1]);
+ }
+ catch (Exception ex) {
+ return null;
+ }
+
+ return new RelativeLocation (x, y);
+ }
+
+
+ public int getX() {
+ return x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+
+
+
+
+
+
+}
diff --git a/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/SketchMap.java b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/SketchMap.java
new file mode 100644
index 0000000..76bac6a
--- /dev/null
+++ b/VirtualComputer/src/com/mcplugindev/slipswhitley/sketchmap/map/SketchMap.java
@@ -0,0 +1,220 @@
+package com.mcplugindev.slipswhitley.sketchmap.map;
+
+/*
+ * This file was originally taken from https://github.com/slipswhitley/SketchMap
+ */
+
+import java.awt.image.BufferedImage;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.bukkit.Bukkit;
+import org.bukkit.map.MapView;
+
+import com.mcplugindev.slipswhitley.sketchmap.SketchMapUtils;
+
+public class SketchMap
+{
+
+ public BufferedImage image;
+ private String mapID;
+ private Integer xPanes;
+ private Integer yPanes;
+ private Boolean publicProtected;
+ //private BaseFormat format;
+
+ private Map mapCollection;
+
+ /**
+ *
+ * Create SketchMap using New Maps
+ *
+ */
+
+ public SketchMap(BufferedImage image, String mapID, int xPanes, int yPanes,
+ boolean publicProtected)
+ {
+
+ this.image = SketchMapUtils.resize(image, xPanes * 128, yPanes * 128);
+ this.mapID = mapID;
+ this.xPanes = xPanes;
+ this.yPanes = yPanes;
+ this.publicProtected = publicProtected;
+ //this.format = format;
+
+ this.mapCollection = new HashMap();
+
+ getLoadedMaps().add(this);
+ loadSketchMap();
+ }
+
+ private void loadSketchMap()
+ {
+ for (int x = 0; x < xPanes; x++)
+ {
+ for (int y = 0; y < yPanes; y++)
+ {
+ initMap(x, y,
+ Bukkit.createMap(SketchMapUtils.getDefaultWorld()));
+ }
+ }
+ }
+
+ /**
+ *
+ * Create SketchMap using Specified Maps
+ *
+ */
+
+ public SketchMap(BufferedImage image, String mapID, int xPanes, int yPanes,
+ boolean publicProtected, Map mapCollection)
+ {
+
+ this.image = SketchMapUtils.resize(image, xPanes * 128, yPanes * 128);
+ this.mapID = mapID;
+ this.xPanes = xPanes;
+ this.yPanes = yPanes;
+ this.publicProtected = publicProtected;
+ //this.format = format;
+
+ this.mapCollection = new HashMap();
+
+ getLoadedMaps().add(this);
+ loadSketchMap(mapCollection);
+ }
+
+ private void loadSketchMap(Map mapCollection)
+ {
+ for (Short mapID : mapCollection.keySet())
+ {
+ RelativeLocation loc = mapCollection.get(mapID);
+
+ initMap(loc.getX(), loc.getY(), SketchMapUtils.getMapView(mapID));
+ }
+ }
+
+ /**
+ *
+ *
+ *
+ */
+
+ private void initMap(int x, int y, MapView mapView)
+ {
+ BufferedImage subImage = image.getSubimage(x * 128, y * 128, 128, 128);
+ mapView.getRenderers().clear();
+ mapView.addRenderer(new ImageRenderer(subImage));
+
+ mapCollection.put(new RelativeLocation(x, y), mapView);
+ }
+
+ /**
+ *
+ * Get Object information
+ *
+ */
+
+ public String getID()
+ {
+ return mapID;
+ }
+
+ public BufferedImage getImage()
+ {
+ return image;
+ }
+
+ public int getLengthX()
+ {
+ return xPanes;
+ }
+
+ public int getLengthY()
+ {
+ return yPanes;
+ }
+
+ public boolean isPublicProtected()
+ {
+ return publicProtected;
+ }
+
+ public Map getMapCollection()
+ {
+ return mapCollection;
+ }
+
+ /*
+ * public BaseFormat getBaseFormat() {
+ * return format;
+ * }
+ */
+
+ /**
+ *
+ * Map Functions
+ *
+ *
+ */
+
+ public void delete()
+ {
+ getLoadedMaps().remove(this);
+
+ try
+ {
+ this.finalize();
+ } catch (Throwable e)
+ {
+ }
+ }
+
+ /**
+ *
+ * Static Methods
+ *
+ */
+
+ private static Set sketchMaps;
+
+ public static Set getLoadedMaps()
+ {
+ if (sketchMaps == null)
+ {
+ sketchMaps = new HashSet();
+ }
+
+ return sketchMaps;
+ }
+
+ /*
+ * public enum BaseFormat {
+ * PNG,
+ * JPEG;
+ *
+ * public String getExtension() {
+ * if(this == BaseFormat.PNG) {
+ * return "png";
+ * }
+ * if(this == BaseFormat.JPEG) {
+ * return "jpg";
+ * }
+ * return null;
+ * }
+ *
+ * public static BaseFormat fromExtension(String ext) {
+ * if(ext.equalsIgnoreCase("png")) {
+ * return BaseFormat.PNG;
+ *
+ * }
+ * if(ext.equalsIgnoreCase("jpg")) {
+ * return BaseFormat.JPEG;
+ * }
+ * return null;
+ * }
+ * }
+ */
+
+}
diff --git a/VirtualComputer/src/sznp/virtualcomputer/Commands.java b/VirtualComputer/src/sznp/virtualcomputer/Commands.java
new file mode 100644
index 0000000..f26f59a
--- /dev/null
+++ b/VirtualComputer/src/sznp/virtualcomputer/Commands.java
@@ -0,0 +1,193 @@
+package sznp.virtualcomputer;
+
+import net.countercraft.movecraft.craft.Craft;
+import net.countercraft.movecraft.craft.CraftManager;
+
+import org.bukkit.Bukkit;
+import org.bukkit.World;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class Commands implements CommandExecutor
+{
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label,
+ String[] args)
+ {
+ switch (cmd.getName().toLowerCase())
+ {
+ case "computer":
+ {
+ if (args.length == 0)
+ return false;
+ switch (args[0].toLowerCase())
+ {
+ case "start":
+ PluginMain.getPlugin(PluginMain.class).Start(sender);
+ break;
+ case "stop":
+ PluginMain.getPlugin(PluginMain.class).Stop(sender);
+ break;
+ case "debug":
+ /*
+ * sender.sendMessage("Screen length1: "
+ * + PluginMain.Instance.Screen.length);
+ * sender.sendMessage("Screen length2: "
+ * + PluginMain.Instance.Screen[0].length);
+ * sender.sendMessage("Screen length3: "
+ * + PluginMain.Instance.Screen[0][0].length);
+ */
+ /*
+ * sender.sendMessage("UpdatePixels: "
+ * + ImageRenderer.updatepixels);
+ */
+ World w = Bukkit.getWorlds().get(0);
+ Craft[] crafts = CraftManager.getInstance().getCraftsInWorld(w);
+ sender.sendMessage("World: " + w);
+ sender.sendMessage("Crafts: " + crafts);
+ sender.sendMessage("Craft type: "
+ + crafts[0].getType().getCraftName());
+ sender.sendMessage("DX: " + crafts[0].getLastDX());
+ sender.sendMessage("DY: " + crafts[0].getLastDY());
+ sender.sendMessage("DZ: " + crafts[0].getLastDZ());
+ sender.sendMessage("MouseSpeed: " + PluginMain.MouseSpeed);
+ sender.sendMessage("Block: "
+ + Bukkit.getWorlds()
+ .get(0)
+ .getBlockAt(crafts[0].getMinX(),
+ crafts[0].getMinY() - 1,
+ crafts[0].getMinZ()).getType()); //Block: AIR
+ break;
+ case "powerbutton":
+ PluginMain.getPlugin(PluginMain.class).PowerButton(sender);
+ break;
+ case "reset":
+ PluginMain.getPlugin(PluginMain.class).Reset(sender);
+ break;
+ case "fix":
+ PluginMain.getPlugin(PluginMain.class).FixScreen(sender);
+ break;
+ case "key":
+ if (args.length < 2)
+ {
+ sender.sendMessage("§cUsage: /computer key [down/up|interval]");
+ return true;
+ }
+ if (args.length < 3)
+ PluginMain.getPlugin(PluginMain.class).PressKey(sender,
+ args[1], "");
+ else
+ PluginMain.getPlugin(PluginMain.class).PressKey(sender,
+ args[1], args[2]);
+ break;
+ case "mouse":
+ boolean showusage = true;
+ if (args.length < 6)
+ {
+ //Command overloading, because I can :P
+ if (args.length > 4) // 4 ");
+ sender.sendMessage("§cOr: /computer mouse