2019-02-11 05:57:45 +01:00
|
|
|
package com.massivecraft.factions.util;
|
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
public class VisualizeUtil {
|
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
protected static Map<UUID, Set<Location>> playerLocations = new HashMap<>();
|
2019-02-11 05:57:45 +01:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
public static Set<Location> getPlayerLocations(Player player) {
|
|
|
|
return getPlayerLocations(player.getUniqueId());
|
|
|
|
}
|
2019-02-11 05:57:45 +01:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
public static Set<Location> getPlayerLocations(UUID uuid) {
|
|
|
|
Set<Location> ret = playerLocations.get(uuid);
|
|
|
|
if (ret == null) {
|
|
|
|
ret = new HashSet<>();
|
|
|
|
playerLocations.put(uuid, ret);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2019-02-11 05:57:45 +01:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void addLocation(Player player, Location location, Material type, byte data) {
|
|
|
|
getPlayerLocations(player).add(location);
|
|
|
|
player.sendBlockChange(location, type, data);
|
|
|
|
}
|
2019-02-11 05:57:45 +01:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void addLocation(Player player, Location location, Material material) {
|
|
|
|
getPlayerLocations(player).add(location);
|
|
|
|
player.sendBlockChange(location, material, (byte) 0);
|
|
|
|
}
|
2019-02-11 05:57:45 +01:00
|
|
|
|
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void addLocations(Player player, Collection<Location> locations, Material material) {
|
|
|
|
Set<Location> ploc = getPlayerLocations(player);
|
|
|
|
for (Location location : locations) {
|
|
|
|
ploc.add(location);
|
|
|
|
player.sendBlockChange(location, material, (byte) 0);
|
|
|
|
}
|
|
|
|
}
|
2019-02-11 05:57:45 +01:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void addBlocks(Player player, Collection<Block> blocks, Material material) {
|
|
|
|
Set<Location> ploc = getPlayerLocations(player);
|
|
|
|
for (Block block : blocks) {
|
|
|
|
Location location = block.getLocation();
|
|
|
|
ploc.add(location);
|
|
|
|
player.sendBlockChange(location, material, (byte) 0);
|
|
|
|
}
|
|
|
|
}
|
2019-02-11 05:57:45 +01:00
|
|
|
|
2019-03-03 04:51:21 +01:00
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public static void clear(Player player) {
|
|
|
|
Set<Location> locations = getPlayerLocations(player);
|
|
|
|
if (locations == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (Location location : locations) {
|
|
|
|
Block block = location.getWorld().getBlockAt(location);
|
|
|
|
player.sendBlockChange(location, block.getType(), block.getData());
|
|
|
|
}
|
|
|
|
locations.clear();
|
|
|
|
}
|
2019-02-11 05:57:45 +01:00
|
|
|
|
|
|
|
}
|