Skip to content

Changed getInfo("server") macro to use ServerPolicy.toJSON directly #738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.client.ui.token.BarTokenOverlay;
import net.rptools.maptool.client.ui.token.BooleanTokenOverlay;
import net.rptools.maptool.client.ui.tokenpanel.InitiativePanel;
import net.rptools.maptool.client.ui.zone.ZoneRenderer;
import net.rptools.maptool.client.walker.WalkerMetric;
import net.rptools.maptool.language.I18N;
import net.rptools.maptool.model.Campaign;
import net.rptools.maptool.model.CampaignProperties;
Expand Down Expand Up @@ -203,47 +201,10 @@ private String getTimeDate() {
* @return the server side preferences
*/
private JSONObject getServerInfo() {
Map<String, Object> sinfo = new HashMap<String, Object>();
ServerPolicy sp = MapTool.getServerPolicy();
JSONObject sinfo = sp.toJSON();

sinfo.put(
"tooltips for default roll format",
sp.getUseToolTipsForDefaultRollFormat() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"players can reveal", sp.getPlayersCanRevealVision() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"auto reveal on movement", sp.isAutoRevealOnMovement() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("movement locked", sp.isMovementLocked() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"restricted impersonation",
sp.isRestrictedImpersonation() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("individual views", sp.isUseIndividualViews() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("individual fow", sp.isUseIndividualFOW() ? BigDecimal.ONE : BigDecimal.ZERO);

sinfo.put(
"strict token management",
sp.useStrictTokenManagement() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"players receive campaign macros",
sp.playersReceiveCampaignMacros() ? BigDecimal.ONE : BigDecimal.ZERO);
WalkerMetric metric =
MapTool.isPersonalServer()
? AppPreferences.getMovementMetric()
: MapTool.getServerPolicy().getMovementMetric();
sinfo.put("movement metric", metric.toString());

sinfo.put("timeInMs", sp.getSystemTime());
sinfo.put("timeDate", sp.getTimeDate());

sinfo.put("gm", MapTool.getGMs());

InitiativePanel ip = MapTool.getFrame().getInitiativePanel();
if (ip != null) {
sinfo.put(
"initiative owner permissions",
ip.isOwnerPermissions() ? BigDecimal.ONE : BigDecimal.ZERO);
}
return JSONObject.fromObject(sinfo);
return (sinfo);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/rptools/maptool/server/ServerPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,13 @@ public JSONObject toJSON() {
"GM reveals vision for unowned tokens",
getGmRevealsVisionForUnownedTokens() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("players can reveal", getPlayersCanRevealVision() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"auto reveal on movement", isAutoRevealOnMovement() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("movement locked", isMovementLocked() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"restricted impersonation", isRestrictedImpersonation() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("individual views", isUseIndividualViews() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put("individual fow", isUseIndividualFOW() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
"strict token management", useStrictTokenManagement() ? BigDecimal.ONE : BigDecimal.ZERO);
sinfo.put(
Expand Down