Add support for multiple world event markers

This commit is contained in:
Sam 2017-02-26 17:13:35 +00:00
parent dc66a79ef7
commit 31efd50489
1 changed files with 31 additions and 31 deletions

View File

@ -79,7 +79,7 @@ public class ItemMapRenderer extends MapRenderer
int scale = info.getScale(); int scale = info.getScale();
int zoom = _itemMap.getZoom(scale); int zoom = _itemMap.getZoom(scale);
Byte[][] map = _itemMap.getMap(scale); Byte[][] map = _itemMap.getMap(scale);
int centerX = info.getX() / zoom; int centerX = info.getX() / zoom;
@ -113,12 +113,12 @@ public class ItemMapRenderer extends MapRenderer
Location location = new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ); Location location = new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ);
boolean safezone = _safezone.isInSafeZone(location); boolean safezone = _safezone.isInSafeZone(location);
if (safezone) if (safezone)
{ {
boolean colorAll = scale > 0; boolean colorAll = scale > 0;
Color areaColor = Color.GREEN; Color areaColor = Color.GREEN;
if (areaColor != null) if (areaColor != null)
{ {
if (!((color <= -113 || color >= 0) && color <= 127)) if (!((color <= -113 || color >= 0) && color <= 127))
@ -128,15 +128,11 @@ public class ItemMapRenderer extends MapRenderer
} }
else else
{ {
// int chunkBX = blockX & 0xF; // int chunkBX = blockX & 0xF;
// int chunkBZ = blockZ & 0xF; // int chunkBZ = blockZ & 0xF;
// Border // Border
if ( if (_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX - 1, STANDARD_Y, blockZ)) || _safezone.isInSafeZone(new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ - 1)) || _safezone.isInSafeZone(new Location(mapView.getWorld(), blockX + 16, STANDARD_Y, blockZ)) || _safezone.isInSafeZone(new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ + 1)))
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX - 1, STANDARD_Y, blockZ)) ||
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ - 1)) ||
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX + 16, STANDARD_Y, blockZ)) ||
_safezone.isInSafeZone(new Location(mapView.getWorld(), blockX, STANDARD_Y, blockZ + 1)))
{ {
Color cColor = MapPalette.getColor(color); Color cColor = MapPalette.getColor(color);
double clans = colorAll ? 1 : 0.8; double clans = colorAll ? 1 : 0.8;
@ -157,7 +153,8 @@ public class ItemMapRenderer extends MapRenderer
double clans = 0.065; double clans = 0.065;
// Stripes // Stripes
//boolean checker = (mapX + (mapZ % 4)) % 4 == 0; // boolean checker = (mapX + (mapZ % 4))
// % 4 == 0;
double base = 1 - clans; double base = 1 - clans;
int r = (int) ((cColor.getRed() * base) + (areaColor.getRed() * clans)); int r = (int) ((cColor.getRed() * base) + (areaColor.getRed() * clans));
@ -194,34 +191,37 @@ public class ItemMapRenderer extends MapRenderer
for (WorldEvent event : _worldEvent.getActiveEvents()) for (WorldEvent event : _worldEvent.getActiveEvents())
{ {
if (!event.isInProgress()) if (!event.isInProgress() || event.getEventLocations() == null)
{ {
continue; continue;
} }
Location point = event.getCurrentLocation();
double mapX = (point.getX() - info.getX()) / zoom;
double mapZ = (point.getZ() - info.getZ()) / zoom;
// To make these appear at the edges of the map, just change it from for (Location point : event.getEventLocations())
// 64 to something like 128 for double the map size
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
{ {
byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D); double mapX = (point.getX() - info.getX()) / zoom;
byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D); double mapZ = (point.getZ() - info.getZ()) / zoom;
byte cursorType = 5; // http://i.imgur.com/wpH6PT8.png // To make these appear at the edges of the map, just change it
// Those are byte 5 and 6 // from
byte rotation = (byte) (int) ((point.getYaw() * 16D) / 360D); // 64 to something like 128 for double the map size
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
{
byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D);
byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D);
MapCursor cursor = new MapCursor(b0, b1, rotation, cursorType, true); byte cursorType = 5; // http://i.imgur.com/wpH6PT8.png
// Those are byte 5 and 6
byte rotation = (byte) (int) (((point.getYaw() + 180) * 16D) / 360D);
cursors.addCursor(cursor); MapCursor cursor = new MapCursor(b0, b1, rotation, cursorType, true);
cursors.addCursor(cursor);
}
} }
} }
SupplyDrop supplyDrop = _supply.getActive(); SupplyDrop supplyDrop = _supply.getActive();
if (_supply.isActive()) if (_supply.isActive())
{ {
Location point = supplyDrop.getCurrentLocation(); Location point = supplyDrop.getCurrentLocation();
@ -247,7 +247,7 @@ public class ItemMapRenderer extends MapRenderer
Party party = _party.getPartyByPlayer(player); Party party = _party.getPartyByPlayer(player);
Set<UUID> shownPlayers = _loot.getShownPlayers(); Set<UUID> shownPlayers = _loot.getShownPlayers();
for (Player other : Bukkit.getOnlinePlayers()) for (Player other : Bukkit.getOnlinePlayers())
{ {
if (player.canSee(other) && other.isValid()) if (player.canSee(other) && other.isValid())
@ -258,7 +258,7 @@ public class ItemMapRenderer extends MapRenderer
double mapZ = (l.getZ() - info.getZ()) / zoom; double mapZ = (l.getZ() - info.getZ()) / zoom;
if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64) if (mapX > -64 && mapX < 64 && mapZ > -64 && mapZ < 64)
{ {
MapCursor.Type cursorDisplay = null; MapCursor.Type cursorDisplay = null;
if (player.equals(other)) if (player.equals(other))
@ -273,7 +273,7 @@ public class ItemMapRenderer extends MapRenderer
{ {
cursorDisplay = MapCursor.Type.GREEN_POINTER; cursorDisplay = MapCursor.Type.GREEN_POINTER;
} }
if (cursorDisplay == null) if (cursorDisplay == null)
{ {
continue; continue;