C:/Program Files (x86)/Git/ma showregion now picks the arena the player is in, or the selected arena if none were found. Changed to client-side blocks, too.

This commit is contained in:
Garbage Mule
2011-10-09 02:08:57 +02:00
parent 7567d10dda
commit b4c8ad1d25
4 changed files with 31 additions and 24 deletions
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
name: MobArena name: MobArena
main: com.garbagemule.MobArena.MobArena main: com.garbagemule.MobArena.MobArena
version: 0.94.3.16 version: 0.94.3.17
softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells] softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells]
commands: commands:
ma: ma:
+14 -6
View File
@@ -7,6 +7,7 @@ import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
@@ -871,14 +872,19 @@ public class MACommands implements CommandExecutor
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS); MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
return true; return true;
} }
if (am.selectedArena.p1 == null || am.selectedArena.p2 == null)
Arena arena = am.getArenaAtLocation(p.getLocation());
if (arena == null)
arena = am.selectedArena;
if (arena.p1 == null || arena.p2 == null)
{ {
MAUtils.tellPlayer(sender, "The region is not defined for the selected arena."); MAUtils.tellPlayer(sender, "The region is not defined for the selected arena.");
return true; return true;
} }
if (showingRegion || !am.selectedArena.edit) if (showingRegion)
{ {
MAUtils.tellPlayer(sender, "Must be in edit mode."); MAUtils.tellPlayer(sender, "Already showing region.");
return true; return true;
} }
@@ -898,8 +904,9 @@ public class MACommands implements CommandExecutor
showingRegion = true; showingRegion = true;
// Show the frame. // Show the frame.
final World world = am.selectedArena.world; final World world = arena.world;
final Set<int[]> blocks = MAUtils.showRegion(world, am.selectedArena.p1, am.selectedArena.p2, mat.getId(), color); final Set<int[]> blocks = MAUtils.showRegion(p, world, arena.p1, arena.p2, mat.getId(), color);
final Player fp = p;
// And hide the frame. // And hide the frame.
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
@@ -908,7 +915,8 @@ public class MACommands implements CommandExecutor
public void run() public void run()
{ {
for (int[] buffer : blocks) for (int[] buffer : blocks)
world.getBlockAt(buffer[0], buffer[1], buffer[2]).setTypeIdAndData(buffer[3], (byte) 0, false); fp.sendBlockChange(new Location(world, buffer[0], buffer[1], buffer[2]), buffer[3], (byte) 0);
//world.getBlockAt(buffer[0], buffer[1], buffer[2]).setTypeIdAndData(buffer[3], (byte) 0, false);
showingRegion = false; showingRegion = false;
} }
}, 2*20); }, 2*20);
+16 -17
View File
@@ -678,8 +678,8 @@ public class MAUtils
/** /**
* Create a frame spanned by the two input coordinates. * Create a frame spanned by the two input coordinates.
* @return An int arry holding x,y,z and the original type IDs of each block. * @return An int arry holding x,y,z and the original type IDs of each block.
*/ */
public static Set<int[]> showRegion(World world, Location p1, Location p2, int id, byte color) public static Set<int[]> showRegion(Player p, World world, Location p1, Location p2, int id, byte color)
{ {
Set<int[]> result = new HashSet<int[]>(); Set<int[]> result = new HashSet<int[]>();
@@ -692,63 +692,62 @@ public class MAUtils
{ {
buffer = new int[] {i, y1, z1, world.getBlockTypeIdAt(i, y1, z1)}; buffer = new int[] {i, y1, z1, world.getBlockTypeIdAt(i, y1, z1)};
result.add(buffer); result.add(buffer);
world.getBlockAt(i, y1, z1).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, i, y1, z1), id, color);
buffer = new int[] {i, y2, z1, world.getBlockTypeIdAt(i, y2, z1)}; buffer = new int[] {i, y2, z1, world.getBlockTypeIdAt(i, y2, z1)};
result.add(buffer); result.add(buffer);
world.getBlockAt(i, y2, z1).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, i, y2, z1), id, color);
buffer = new int[] {i, y1, z2, world.getBlockTypeIdAt(i, y1, z2)}; buffer = new int[] {i, y1, z2, world.getBlockTypeIdAt(i, y1, z2)};
result.add(buffer); result.add(buffer);
world.getBlockAt(i, y1, z2).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, i, y1, z2), id, color);
buffer = new int[] {i, y2, z2, world.getBlockTypeIdAt(i, y2, z2)}; buffer = new int[] {i, y2, z2, world.getBlockTypeIdAt(i, y2, z2)};
result.add(buffer); result.add(buffer);
world.getBlockAt(i, y2, z2).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, i, y2, z2), id, color);
} }
for (int j = y1+1; j <= y2-1; j++) for (int j = y1+1; j <= y2-1; j++)
{ {
buffer = new int[] {x1, j, z1, world.getBlockTypeIdAt(x1, j, z1)}; buffer = new int[] {x1, j, z1, world.getBlockTypeIdAt(x1, j, z1)};
result.add(buffer); result.add(buffer);
world.getBlockAt(x1, j, z1).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, x1, j, z1), id, color);
buffer = new int[] {x2, j, z1, world.getBlockTypeIdAt(x2, j, z1)}; buffer = new int[] {x2, j, z1, world.getBlockTypeIdAt(x2, j, z1)};
result.add(buffer); result.add(buffer);
world.getBlockAt(x2, j, z1).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, x2, j, z1), id, color);
buffer = new int[] {x1, j, z2, world.getBlockTypeIdAt(x1, j, z2)}; buffer = new int[] {x1, j, z2, world.getBlockTypeIdAt(x1, j, z2)};
result.add(buffer); result.add(buffer);
world.getBlockAt(x1, j, z2).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, x1, j, z2), id, color);
buffer = new int[] {x2, j, z2, world.getBlockTypeIdAt(x2, j, z2)}; buffer = new int[] {x2, j, z2, world.getBlockTypeIdAt(x2, j, z2)};
result.add(buffer); result.add(buffer);
world.getBlockAt(x2, j, z2).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, x2, j, z2), id, color);
} }
for (int k = z1+1; k <= z2-1; k++) for (int k = z1+1; k <= z2-1; k++)
{ {
buffer = new int[] {x1, y1, k, world.getBlockTypeIdAt(x1, y1, k)}; buffer = new int[] {x1, y1, k, world.getBlockTypeIdAt(x1, y1, k)};
result.add(buffer); result.add(buffer);
world.getBlockAt(x1, y1, k).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, x1, y1, k), id, color);
buffer = new int[] {x2, y1, k, world.getBlockTypeIdAt(x2, y1, k)}; buffer = new int[] {x2, y1, k, world.getBlockTypeIdAt(x2, y1, k)};
result.add(buffer); result.add(buffer);
world.getBlockAt(x2, y1, k).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, x2, y1, k), id, color);
buffer = new int[] {x1, y2, k, world.getBlockTypeIdAt(x1, y2, k)}; buffer = new int[] {x1, y2, k, world.getBlockTypeIdAt(x1, y2, k)};
result.add(buffer); result.add(buffer);
world.getBlockAt(x1, y2, k).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, x1, y2, k), id, color);
buffer = new int[] {x2, y2, k, world.getBlockTypeIdAt(x2, y2, k)}; buffer = new int[] {x2, y2, k, world.getBlockTypeIdAt(x2, y2, k)};
result.add(buffer); result.add(buffer);
world.getBlockAt(x2, y2, k).setTypeIdAndData(id, color, false); p.sendBlockChange(new Location(world, x2, y2, k), id, color);
} }
return result; return result;
} }
public static Set<int[]> showRegion(World world, Location p1, Location p2, int id) public static Set<int[]> showRegion(Player p, World world, Location p1, Location p2, int id)
{ {
return showRegion(world, p1, p2, id, (byte) 0); return showRegion(p, world, p1, p2, id, (byte) 0);
} }
/** /**