Skip to content

Commit d525b62

Browse files
committed
Improve so get existing map only works when BuildMapView wrapper is set.
1 parent c80bbd5 commit d525b62

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Item Creator/src/main/java/org/broken/arrow/library/itemcreator/meta/MapWrapperMeta.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,10 @@ public BuildMapView createMapView(@Nonnull final World world, @Nonnull final Con
8585
public BuildMapView getExistingMapView(@Nonnull final Consumer<BuildMapView> action) {
8686
final BuildMapView builtMapView = this.getMapViewBuilder();
8787
if(builtMapView == null) return null;
88-
final MapView mapView = (builtMapView.getId() >= 0) ? ItemCreator.getMapById(builtMapView.getId()) : null;
89-
if (mapView == null) return null;
88+
final int id = builtMapView.getId();
9089

9190
action.accept(builtMapView);
92-
return builtMapView;
91+
return getExistingMapView(id, action);
9392
}
9493

9594
/**
@@ -107,7 +106,15 @@ public BuildMapView getExistingMapView(@Nonnull final Consumer<BuildMapView> act
107106
*/
108107
@Nullable
109108
public BuildMapView getExistingMapView(final int id, @Nonnull final Consumer<BuildMapView> action) {
110-
return this.createOrRetrieveMapView(null, id, action);
109+
final MapView mapView = (id >= 0) ? ItemCreator.getMapById(id) : null;
110+
if (mapView == null) return null;
111+
112+
BuildMapView builtMapView = this.getMapViewBuilder();
113+
if(builtMapView == null) {
114+
builtMapView = this.assignMapView(new BuildMapView(mapView));
115+
}
116+
action.accept(builtMapView);
117+
return builtMapView;
111118
}
112119

113120
/**

0 commit comments

Comments
 (0)