mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-14 14:25:21 +01:00
Add support for optional 'offline players' marker layer
This commit is contained in:
parent
150f3ae6f4
commit
99c38f0ee7
@ -1,7 +1,13 @@
|
||||
package org.dynmap;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.SpawnChangeEvent;
|
||||
import org.bukkit.event.world.WorldListener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
@ -19,8 +25,12 @@ public class MarkersComponent extends ClientComponent {
|
||||
private MarkerSignManager signmgr;
|
||||
private MarkerIcon spawnicon;
|
||||
private String spawnlbl;
|
||||
private MarkerSet offlineset;
|
||||
private MarkerIcon offlineicon;
|
||||
|
||||
public MarkersComponent(DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
private static final String OFFLINE_PLAYERS_SETID = "offline_players";
|
||||
|
||||
public MarkersComponent(final DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
/* Register API with plugin, if needed */
|
||||
if(plugin.markerAPIInitialized()) {
|
||||
@ -66,6 +76,52 @@ public class MarkersComponent extends ClientComponent {
|
||||
addUpdateWorld(world, loc);
|
||||
}
|
||||
}
|
||||
/* If showing offline players as markers */
|
||||
if(configuration.getBoolean("showofflineplayers", false)) {
|
||||
/* Make set, if needed */
|
||||
offlineset = api.getMarkerSet(OFFLINE_PLAYERS_SETID);
|
||||
if(offlineset == null) {
|
||||
offlineset = api.createMarkerSet(OFFLINE_PLAYERS_SETID, configuration.getString("offlinelabel", "Offline"), null, true);
|
||||
}
|
||||
offlineset.setHideByDefault(configuration.getBoolean("offlinehidebydefault", true));
|
||||
|
||||
offlineicon = api.getMarkerIcon(configuration.getString("offlineicon", "offlineuser"));
|
||||
|
||||
/* Add listener for players coming and going */
|
||||
PlayerListener pl = new PlayerListener() {
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
Marker m = offlineset.findMarker(p.getName());
|
||||
if(m != null) {
|
||||
m.deleteMarker();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
Marker m = offlineset.findMarker(p.getName());
|
||||
if(m != null) {
|
||||
m.deleteMarker();
|
||||
}
|
||||
if(plugin.playerList.isVisiblePlayer(p)) {
|
||||
Location loc = p.getLocation();
|
||||
m = offlineset.createMarker(p.getName(), ChatColor.stripColor(p.getDisplayName()), false,
|
||||
loc.getWorld().getName(), loc.getX(), loc.getY(), loc.getZ(),
|
||||
offlineicon, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
plugin.registerEvent(Type.PLAYER_JOIN, pl);
|
||||
plugin.registerEvent(Type.PLAYER_QUIT, pl);
|
||||
}
|
||||
else {
|
||||
/* Make set, if needed */
|
||||
offlineset = api.getMarkerSet(OFFLINE_PLAYERS_SETID);
|
||||
if(offlineset != null) {
|
||||
offlineset.deleteMarkerSet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addUpdateWorld(World w, Location loc) {
|
||||
|
@ -115,4 +115,9 @@ public class PlayerList {
|
||||
}
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public boolean isVisiblePlayer(Player p) {
|
||||
boolean useWhitelist = configuration.getBoolean("display-whitelist", false);
|
||||
return (!(useWhitelist ^ hiddenPlayerNames.contains(p.getName().toLowerCase())));
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
"left", "lightbulb", "lighthouse", "lock", "minecart", "orangeflag", "pin", "pinkflag", "pirateflag", "pointdown", "pointleft",
|
||||
"pointright", "pointup", "portal", "purpleflag", "queen", "redflag", "right", "ruby", "scales", "skull", "shield", "sign",
|
||||
"silvermedal", "silverstar", "star", "sun", "temple", "theater", "tornado", "tower", "tree", "truck", "up",
|
||||
"walk", "warning", "world", "wrench", "yellowflag"
|
||||
"walk", "warning", "world", "wrench", "yellowflag", "offlineuser"
|
||||
};
|
||||
|
||||
/* Component messages for client updates */
|
||||
|
BIN
src/main/resources/markers/offlineuser.png
Normal file
BIN
src/main/resources/markers/offlineuser.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 516 B |
@ -787,6 +787,10 @@
|
||||
margin-left: -8px;
|
||||
}
|
||||
|
||||
.dynmap .mapMarker .markerName_offline_players {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.dynmap .coord-control {
|
||||
color: #000;
|
||||
|
||||
|
@ -20,7 +20,7 @@ componentconstructors['markers'] = function(dynmap, configuration) {
|
||||
$.each(data.sets, function(name, markerset) {
|
||||
var ms = dynmapmarkersets[name];
|
||||
if(!ms) {
|
||||
ms = { label: markerset.label, hide: markerset.hide, layerprio: markerset.layerprio, markers: {} } ;
|
||||
ms = { id: name, label: markerset.label, hide: markerset.hide, layerprio: markerset.layerprio, markers: {} } ;
|
||||
createMarkerSet(ms, ts);
|
||||
}
|
||||
else {
|
||||
@ -63,11 +63,13 @@ componentconstructors['markers'] = function(dynmap, configuration) {
|
||||
if(marker.markup) {
|
||||
$(div).append($('<span/>')
|
||||
.addClass(configuration.showlabel?'markerName-show':'markerName')
|
||||
.addClass('markerName_' + set.id)
|
||||
.append(marker.label));
|
||||
}
|
||||
else
|
||||
$(div).append($('<span/>')
|
||||
.addClass(configuration.showlabel?'markerName-show':'markerName')
|
||||
.addClass('markerName_' + set.id)
|
||||
.text(marker.label));
|
||||
return div;
|
||||
}});
|
||||
@ -105,7 +107,7 @@ componentconstructors['markers'] = function(dynmap, configuration) {
|
||||
}
|
||||
else if(msg.msg == 'setupdated') {
|
||||
if(!dynmapmarkersets[msg.id]) {
|
||||
dynmapmarkersets[msg.id] = { label: msg.label, layerprio: msg.layerprio, markers:{} };
|
||||
dynmapmarkersets[msg.id] = { id: msg.id, label: msg.label, layerprio: msg.layerprio, markers:{} };
|
||||
createMarkerSet(dynmapmarkersets[msg.id]);
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user