Add 'hideifshadow' and 'hideifundercover' option for client update: hides player position/health if they are at location below given light level (hideifshadow) or not under open sky (hideifundercover)
This commit is contained in:
parent
51d4d07adc
commit
aa001746ac
2 changed files with 25 additions and 3 deletions
|
|
@ -6,8 +6,10 @@ import static org.dynmap.JSONUtils.s;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
@ -28,6 +30,8 @@ public class ClientUpdateComponent extends Component {
|
||||||
JSONObject u = e.update;
|
JSONObject u = e.update;
|
||||||
long since = e.timestamp;
|
long since = e.timestamp;
|
||||||
String worldName = world.getName();
|
String worldName = world.getName();
|
||||||
|
int hideifshadow = configuration.getInteger("hideifshadow", 15);
|
||||||
|
int hideifunder = configuration.getInteger("hideifundercover", 15);
|
||||||
|
|
||||||
s(u, "servertime", world.getTime() % 24000);
|
s(u, "servertime", world.getTime() % 24000);
|
||||||
s(u, "hasStorm", world.hasStorm());
|
s(u, "hasStorm", world.hasStorm());
|
||||||
|
|
@ -39,14 +43,26 @@ public class ClientUpdateComponent extends Component {
|
||||||
Player p = players[i];
|
Player p = players[i];
|
||||||
Location pl = p.getLocation();
|
Location pl = p.getLocation();
|
||||||
JSONObject jp = new JSONObject();
|
JSONObject jp = new JSONObject();
|
||||||
|
boolean hide = false;
|
||||||
|
|
||||||
s(jp, "type", "player");
|
s(jp, "type", "player");
|
||||||
s(jp, "name", ChatColor.stripColor(p.getDisplayName()));
|
s(jp, "name", ChatColor.stripColor(p.getDisplayName()));
|
||||||
s(jp, "account", p.getName());
|
s(jp, "account", p.getName());
|
||||||
|
if(hideifshadow < 15) {
|
||||||
|
if(pl.getBlock().getLightLevel() <= hideifshadow)
|
||||||
|
hide = true;
|
||||||
|
}
|
||||||
|
if(hideifunder < 15) {
|
||||||
|
/*TODO: when pull accepted for getSkyLightLevel(), switch to that */
|
||||||
|
if(pl.getWorld().getHighestBlockYAt(pl) > pl.getBlockY())
|
||||||
|
hide = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Don't leak player location for world not visible on maps, or if sendposition disbaled */
|
/* Don't leak player location for world not visible on maps, or if sendposition disbaled */
|
||||||
DynmapWorld pworld = MapManager.mapman.worldsLookup.get(p.getWorld().getName());
|
DynmapWorld pworld = MapManager.mapman.worldsLookup.get(p.getWorld().getName());
|
||||||
/* Fix typo on 'sendpositon' to 'sendposition', keep bad one in case someone used it */
|
/* Fix typo on 'sendpositon' to 'sendposition', keep bad one in case someone used it */
|
||||||
if(configuration.getBoolean("sendposition", true) && configuration.getBoolean("sendpositon", true) &&
|
if(configuration.getBoolean("sendposition", true) && configuration.getBoolean("sendpositon", true) &&
|
||||||
(pworld != null) && pworld.sendposition) {
|
(pworld != null) && pworld.sendposition && (!hide)) {
|
||||||
s(jp, "world", p.getWorld().getName());
|
s(jp, "world", p.getWorld().getName());
|
||||||
s(jp, "x", pl.getX());
|
s(jp, "x", pl.getX());
|
||||||
s(jp, "y", pl.getY());
|
s(jp, "y", pl.getY());
|
||||||
|
|
@ -59,7 +75,7 @@ public class ClientUpdateComponent extends Component {
|
||||||
s(jp, "z", 0.0);
|
s(jp, "z", 0.0);
|
||||||
}
|
}
|
||||||
/* Only send health if enabled AND we're on visible world */
|
/* Only send health if enabled AND we're on visible world */
|
||||||
if (configuration.getBoolean("sendhealth", false) && (pworld != null) && pworld.sendhealth) {
|
if (configuration.getBoolean("sendhealth", false) && (pworld != null) && pworld.sendhealth && (!hide)) {
|
||||||
s(jp, "health", p.getHealth());
|
s(jp, "health", p.getHealth());
|
||||||
s(jp, "armor", Armor.getArmorPoints(p));
|
s(jp, "armor", Armor.getArmorPoints(p));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,10 @@ components:
|
||||||
hidewebchatip: false
|
hidewebchatip: false
|
||||||
trustclientname: false
|
trustclientname: false
|
||||||
includehiddenplayers: false
|
includehiddenplayers: false
|
||||||
|
# # Optional - make players hidden when they are inside/underground/in shadows (#=light level: 0=full shadow,15=sky)
|
||||||
|
# hideifshadow: 4
|
||||||
|
# # Optional - make player hidden when they are under cover (#=sky light level,0=underground,15=open to sky)
|
||||||
|
# hideifundercover: 14
|
||||||
#- class: org.dynmap.JsonFileClientUpdateComponent
|
#- class: org.dynmap.JsonFileClientUpdateComponent
|
||||||
# writeinterval: 1
|
# writeinterval: 1
|
||||||
# sendhealth: true
|
# sendhealth: true
|
||||||
|
|
@ -30,6 +34,8 @@ components:
|
||||||
# webchat-interval: 5
|
# webchat-interval: 5
|
||||||
# hidewebchatip: false
|
# hidewebchatip: false
|
||||||
# includehiddenplayers: false
|
# includehiddenplayers: false
|
||||||
|
# hideifshadow: 4
|
||||||
|
# hideifundercover: 14
|
||||||
|
|
||||||
- class: org.dynmap.SimpleWebChatComponent
|
- class: org.dynmap.SimpleWebChatComponent
|
||||||
allowchat: true
|
allowchat: true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue