Skip to content

Commit

Permalink
Attempted to resolve RPTools#4237
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdAnkles committed Sep 25, 2023
1 parent 9b7cb1d commit 4950c85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.rptools.maptool.language.I18N;
import net.rptools.maptool.model.GUID;
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.Zone;
import net.rptools.parser.ParserException;
import org.graalvm.polyglot.HostAccess;

Expand All @@ -33,6 +34,7 @@ public String serializeToString() {
private final Token token;
private Set<String> names;
private Iterator<String> names_iter;
private Zone map;

public JSAPIToken(Token token) {
this.token = token;
Expand Down Expand Up @@ -130,6 +132,7 @@ public void setProperty(String name, Object value) {
String playerId = MapTool.getPlayer().getName();
if (trusted || token.isOwner(playerId)) {
this.token.setProperty(name, value.toString());
this.map.putToken(this.token);
}
}

Expand Down Expand Up @@ -184,4 +187,14 @@ public boolean isOnCurrentMap() {
MapTool.getFrame().getCurrentZoneRenderer().getZone().getToken(new GUID(this.getId()));
return this.token == findToken;
}

@HostAccess.Export
public void setMap(Zone m) {
this.map = m;
}

@HostAccess.Export
public String getMapName() {
return this.map.getDisplayName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ public JSAPIToken getTokenByID(String uuid) {
MapTool.getFrame().getCurrentZoneRenderer().getZone().getToken(new GUID(uuid));
if (findToken != null) {
token = new JSAPIToken(findToken);
token.setMap(MapTool.getFrame().getCurrentZoneRenderer().getZone());
} else {
List<ZoneRenderer> zrenderers = MapTool.getFrame().getZoneRenderers();
for (ZoneRenderer zr : zrenderers) {
findToken = zr.getZone().resolveToken(uuid);
if (findToken != null) {
token = new JSAPIToken(findToken);
token.setMap(zr.getZone());
break;
}
}
Expand All @@ -122,6 +124,7 @@ public JSAPIToken getMapTokenByID(String uuid) {
if (findToken != null
&& (JSScriptEngine.inTrustedContext() || token.isOwner(MapTool.getPlayer().getName()))) {
token = new JSAPIToken(findToken);
token.setMap(MapTool.getFrame().getCurrentZoneRenderer().getZone());
}
return token;
}
Expand Down

0 comments on commit 4950c85

Please sign in to comment.