Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit 2aa485a395a06c657fcc130675ea58002381c735 0 parents
@bakkdoor authored
7 .classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry exported="true" kind="lib" path="/Users/backtype/projects/BlueprintMCPlugin/libs/bukkit-0.0.1-SNAPSHOT.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
1  .gitignore
@@ -0,0 +1 @@
+*.class
17 .project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>BlueprintMCPlugin</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
12 .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+#Sat Jun 11 18:04:33 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+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.6
BIN  libs/bukkit-0.0.1-SNAPSHOT.jar
Binary file not shown
56 src/de/flasht/blueprint/BPBlockListener.java
@@ -0,0 +1,56 @@
+package de.flasht.blueprint;
+
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockFace;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.event.block.BlockCanBuildEvent;
+import org.bukkit.event.block.BlockListener;
+import org.bukkit.event.block.BlockPhysicsEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
+import org.bukkit.block.Chest;
+
+
+public class BPBlockListener extends BlockListener {
+ private final BlueprintPlugin plugin;
+
+ private Location startLoc;
+ private Blueprint blueprint;
+
+ public BPBlockListener(final BlueprintPlugin plugin) {
+ this.plugin = plugin;
+ }
+
+ @Override
+ public void onBlockPlace(BlockPlaceEvent event)
+ {
+ Material mat = event.getBlockPlaced().getType();
+
+ Location loc = event.getBlockPlaced().getLocation();
+
+ Player p = event.getPlayer();
+
+
+ if(mat == Material.TORCH)
+ if(startLoc == null)
+ {
+ startLoc = loc;
+ p.sendMessage("start location set");
+ }
+ else
+ {
+ p.sendMessage("drawing blueprint..");
+ blueprint = new Blueprint(this.plugin, startLoc, loc);
+ p.sendMessage("done!");
+ startLoc = null;
+ }
+ else if(mat == Material.REDSTONE_TORCH_ON)
+ {
+ p.sendMessage("building blueprint..");
+ blueprint.placeBlocks(p, loc);
+ p.sendMessage("done!");
+ }
+
+ }
+}
19 src/de/flasht/blueprint/BPPlayerListener.java
@@ -0,0 +1,19 @@
+package de.flasht.blueprint;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerChatEvent;
+import org.bukkit.event.player.PlayerEvent;
+import org.bukkit.event.player.PlayerListener;
+import org.bukkit.event.player.PlayerMoveEvent;
+
+
+public class BPPlayerListener extends PlayerListener {
+ private final BlueprintPlugin plugin;
+
+ public BPPlayerListener(BlueprintPlugin instance) {
+ plugin = instance;
+ }
+
+ //Insert Player related code here
+}
87 src/de/flasht/blueprint/Blueprint.java
@@ -0,0 +1,87 @@
+package de.flasht.blueprint;
+
+import java.util.logging.Logger;
+
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+
+public class Blueprint {
+
+ protected Material[][][] blocks;
+ protected int sx,sy,sz,ex,ez,dx,dz;
+ protected int height;
+ protected BlueprintPlugin plugin;
+ protected Logger log;
+
+
+ public Blueprint(BlueprintPlugin plugin, Location begin, Location end)
+ {
+ this.plugin = plugin;
+ log = plugin.getServer().getLogger();
+
+ sx = (int)Math.min(begin.getX(), end.getX());
+ sy = (int)Math.max(begin.getY(), end.getY());
+ sz = (int)Math.min(begin.getZ(), end.getZ());
+ ex = (int)Math.max(begin.getX(), end.getX());
+ ez = (int)Math.max(begin.getZ(), end.getZ());
+
+ dx = Math.abs(ex-sx) +1;
+ dz = Math.abs(ez-sz) +1;
+
+ blocks = new Material[dx][128][dz];
+
+ updateBlocks(begin.getWorld());
+ }
+
+ protected void updateBlocks(World world)
+ {
+ boolean empty = false;
+
+ height = -1;
+
+ for(int y = 0; !empty && y+sy < 128; y++)
+ {
+ empty = true;
+ height ++;
+ log.info("y="+y);
+
+ for(int x = 0; x < dx; x++) {
+ log.info("x="+x);
+ for(int z = 0; z < dz; z++)
+ {
+ log.info("z="+z);
+ Material mat =
+ world.getBlockAt(new Location(world,sx+x,sy+y,sz+z)).getType();
+ blocks[x][y][z] = mat;
+
+ empty &= (mat == Material.AIR);
+ }
+ }
+ }
+ }
+
+ public void placeBlocks(Player p, Location loc)
+ {
+ World world = loc.getWorld();
+
+ log.info(dx + ", " + sy + ", " + dz + ", " + height);
+
+ for(int y = 0; y < height; y++)
+ {
+ log.info("y=" + y);
+ for(int x = 0; x < dx; x++)
+ {
+ log.info("x=" + x +", y=" + y);
+ for(int z = 0; z < dz; z++)
+ {
+ log.info("x=" + x +", y=" + y + ", z=" + z);
+ world.getBlockAt(
+ new Location(world, loc.getX()+x, loc.getY()+y, loc.getZ()+z))
+ .setType(blocks[x][y][z]);
+ }
+ }
+ }
+ }
+}
65 src/de/flasht/blueprint/BlueprintPlugin.java
@@ -0,0 +1,65 @@
+package de.flasht.blueprint;
+
+import java.util.HashMap;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Priority;
+import org.bukkit.event.Event;
+import org.bukkit.plugin.PluginDescriptionFile;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.plugin.PluginManager;
+
+/**
+ * Sample plugin for Bukkit
+ *
+ * @author Dinnerbone
+ */
+public class BlueprintPlugin extends JavaPlugin {
+ private final BPPlayerListener playerListener = new BPPlayerListener(this);
+ private final BPBlockListener blockListener = new BPBlockListener(this);
+ private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
+
+ // NOTE: There should be no need to define a constructor any more for more info on moving from
+ // the old constructor see:
+ // http://forums.bukkit.org/threads/too-long-constructor.5032/
+
+ public void onDisable() {
+ // TODO: Place any custom disable code here
+
+ // NOTE: All registered events are automatically unregistered when a plugin is disabled
+
+ // EXAMPLE: Custom code, here we just output some info so we can check all is well
+ System.out.println("Goodbye world!");
+ }
+
+ public void onEnable() {
+ // TODO: Place any custom enable code here including the registration of any events
+
+ // Register our events
+ PluginManager pm = getServer().getPluginManager();
+ pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
+// pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
+// pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
+// pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
+// pm.registerEvent(Event.Type.BLOCK_CANBUILD, blockListener, Priority.Normal, this);
+
+ // Register our commands
+// getCommand("pos").setExecutor(new SamplePosCommand(this));
+// getCommand("debug").setExecutor(new SampleDebugCommand(this));
+
+ // EXAMPLE: Custom code, here we just output some info so we can check all is well
+ PluginDescriptionFile pdfFile = this.getDescription();
+ System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
+ }
+
+ public boolean isDebugging(final Player player) {
+ if (debugees.containsKey(player)) {
+ return debugees.get(player);
+ } else {
+ return false;
+ }
+ }
+
+ public void setDebugging(final Player player, final boolean value) {
+ debugees.put(player, value);
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.