Make showBlock(s) thread-safe.

This commit is contained in:
garbagemule 2013-09-09 09:05:54 +02:00
parent acd441dd2e
commit 349172b3b6

View File

@ -644,7 +644,10 @@ public class ArenaRegion
showBlocks(p, map.values()); showBlocks(p, map.values());
} }
public void showBlock(final Player p, final Location loc, int id, byte data) { public void showBlock(final Player p, final Location loc, final int id, final byte data) {
arena.scheduleTask(new Runnable() {
@Override
public void run() {
p.sendBlockChange(loc, id, data); p.sendBlockChange(loc, id, data);
arena.scheduleTask(new Runnable() { arena.scheduleTask(new Runnable() {
@Override @Override
@ -656,8 +659,13 @@ public class ArenaRegion
} }
}, 100); }, 100);
} }
}, 0);
}
private void showBlocks(final Player p, Collection<Location> points) { private void showBlocks(final Player p, final Collection<Location> points) {
arena.scheduleTask(new Runnable() {
@Override
public void run() {
// Grab all the blocks, and send block change events. // Grab all the blocks, and send block change events.
final Map<Location,BlockState> blocks = new HashMap<Location,BlockState>(); final Map<Location,BlockState> blocks = new HashMap<Location,BlockState>();
for (Location l : points) { for (Location l : points) {
@ -665,7 +673,6 @@ public class ArenaRegion
blocks.put(l, b.getState()); blocks.put(l, b.getState());
p.sendBlockChange(l, 35, (byte) 14); p.sendBlockChange(l, 35, (byte) 14);
} }
arena.scheduleTask(new Runnable() { arena.scheduleTask(new Runnable() {
public void run() { public void run() {
// If the player isn't online, just forget it. // If the player isn't online, just forget it.
@ -685,6 +692,8 @@ public class ArenaRegion
} }
}, 100); }, 100);
} }
}, 0);
}
private List<Location> getFramePoints(Location loc1, Location loc2) { private List<Location> getFramePoints(Location loc1, Location loc2) {
List<Location> result = new ArrayList<Location>(); List<Location> result = new ArrayList<Location>();