2014-10-19 23:04:27 +02:00
|
|
|
package com.massivecraft.factions.util;
|
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
|
|
public class VisualizeUtil {
|
|
|
|
|
|
|
|
protected static Map<UUID, Set<Location>> playerLocations = new HashMap<UUID, Set<Location>>();
|
|
|
|
|
|
|
|
public static Set<Location> getPlayerLocations(Player player) {
|
|
|
|
return getPlayerLocations(player.getUniqueId());
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Set<Location> getPlayerLocations(UUID uuid) {
|
|
|
|
Set<Location> ret = playerLocations.get(uuid);
|
|
|
|
if (ret == null) {
|
|
|
|
ret = new HashSet<Location>();
|
|
|
|
playerLocations.put(uuid, ret);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void addLocation(Player player, Location location, int typeId, byte data) {
|
|
|
|
getPlayerLocations(player).add(location);
|
|
|
|
player.sendBlockChange(location, typeId, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void addLocation(Player player, Location location, int typeId) {
|
|
|
|
getPlayerLocations(player).add(location);
|
|
|
|
player.sendBlockChange(location, typeId, (byte) 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void addLocations(Player player, Map<Location, Integer> locationMaterialIds) {
|
|
|
|
Set<Location> ploc = getPlayerLocations(player);
|
|
|
|
for (Entry<Location, Integer> entry : locationMaterialIds.entrySet()) {
|
|
|
|
ploc.add(entry.getKey());
|
|
|
|
player.sendBlockChange(entry.getKey(), entry.getValue(), (byte) 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void addLocations(Player player, Collection<Location> locations, int typeId) {
|
|
|
|
Set<Location> ploc = getPlayerLocations(player);
|
|
|
|
for (Location location : locations) {
|
|
|
|
ploc.add(location);
|
|
|
|
player.sendBlockChange(location, typeId, (byte) 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void addBlocks(Player player, Collection<Block> blocks, int typeId) {
|
|
|
|
Set<Location> ploc = getPlayerLocations(player);
|
|
|
|
for (Block block : blocks) {
|
|
|
|
Location location = block.getLocation();
|
|
|
|
ploc.add(location);
|
|
|
|
player.sendBlockChange(location, typeId, (byte) 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void clear(Player player) {
|
|
|
|
Set<Location> locations = getPlayerLocations(player);
|
2014-11-06 01:36:47 +01:00
|
|
|
if (locations == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-19 23:04:27 +02:00
|
|
|
for (Location location : locations) {
|
|
|
|
Block block = location.getWorld().getBlockAt(location);
|
|
|
|
player.sendBlockChange(location, block.getTypeId(), block.getData());
|
|
|
|
}
|
|
|
|
locations.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|