@@ -38,8 +38,8 @@ public static class ImageMapItemText extends ConfigurationPart {
3838
3939 private final Integer x_count ;
4040 private final Integer y_count ;
41- private final String [][] tile_b64_matrix ; // 0,0 is top left
42- private final String thumb_b64 ;
41+ private final byte [] [][] tile_b64_matrix ; // 0,0 is top left
42+ private final byte [] thumb_b64 ;
4343 private final World world ;
4444 private Integer mapview_id ;
4545
@@ -80,7 +80,7 @@ public ImageMapItem(World world, String url, Float scale) throws Exception {
8080 BufferedImage centered_image = ImageUtils .center (resized_image , new_width , new_height );
8181 image_width = centered_image .getWidth ();
8282 image_height = centered_image .getHeight ();
83- this .tile_b64_matrix = new String [this .y_count ][this .x_count ];
83+ this .tile_b64_matrix = new byte [this .y_count ][this .x_count ][ ];
8484 for (int y = 0 ; y < this .y_count ; y ++) {
8585 for (int x = 0 ; x < this .x_count ; x ++) {
8686 int width = Math .min (128 , image_width - x * 128 );
@@ -97,7 +97,7 @@ public ImageMapItem(World world, String url, Float scale) throws Exception {
9797
9898 MapMeta meta = (MapMeta ) this .getItemMeta ();
9999 // Store image tile matrix
100- meta .getPersistentDataContainer ().set (THUMB_KEY (), PersistentDataType .STRING , this .thumb_b64 );
100+ meta .getPersistentDataContainer ().set (THUMB_KEY (), PersistentDataType .BYTE_ARRAY , this .thumb_b64 );
101101 meta .getPersistentDataContainer ().set (MATRIX_X_KEY (), PersistentDataType .INTEGER , this .tile_b64_matrix [0 ].length );
102102 meta .getPersistentDataContainer ().set (MATRIX_Y_KEY (), PersistentDataType .INTEGER , this .tile_b64_matrix .length );
103103 // Set size info
@@ -155,10 +155,10 @@ public void setUpThumbnail() throws Exception {
155155 public ImageMapItem (ItemStack mapItem ) throws Exception {
156156 super (mapItem );
157157 MapMeta meta = (MapMeta ) mapItem .getItemMeta ();
158- if (!meta .getPersistentDataContainer ().has (THUMB_KEY (), PersistentDataType .STRING )) {
158+ if (!meta .getPersistentDataContainer ().has (THUMB_KEY (), PersistentDataType .BYTE_ARRAY )) {
159159 throw new Exception ("IGNORING: Not an ImageMapItem" );
160160 }
161- this .thumb_b64 = meta .getPersistentDataContainer ().get (THUMB_KEY (), PersistentDataType .STRING );
161+ this .thumb_b64 = meta .getPersistentDataContainer ().get (THUMB_KEY (), PersistentDataType .BYTE_ARRAY );
162162 this .x_count = meta .getPersistentDataContainer ().get (MATRIX_X_KEY (), PersistentDataType .INTEGER );
163163 this .y_count = meta .getPersistentDataContainer ().get (MATRIX_Y_KEY (), PersistentDataType .INTEGER );
164164 if (this .x_count == null || this .y_count == null ) {
@@ -169,7 +169,7 @@ public ImageMapItem(ItemStack mapItem) throws Exception {
169169 }
170170 this .world = meta .getMapView ().getWorld ();
171171 this .mapview_id = meta .getMapView ().getId ();
172- this .tile_b64_matrix = new String [this .y_count ][this .x_count ];
172+ this .tile_b64_matrix = new byte [this .y_count ][this .x_count ][ ];
173173 for (int y = 0 ; y < this .y_count ; y ++) {
174174 for (int x = 0 ; x < this .x_count ; x ++) {
175175 this .tile_b64_matrix [y ][x ] = getTileFromWorldPDC (x , y );
@@ -194,19 +194,19 @@ public Integer getYCount() {
194194 return y_count ;
195195 }
196196
197- public String getThumbBase64 () {
197+ public byte [] getThumbBase64 () {
198198 return thumb_b64 ;
199199 }
200200
201201 public Integer getMapviewId () {
202202 return mapview_id ;
203203 }
204204
205- public String getTileBase64 (int x , int y ) {
205+ public byte [] getTileBase64 (int x , int y ) {
206206 return tile_b64_matrix [y ][x ];
207207 }
208208
209- public void setTileBase64 (int x , int y , String base64 ) {
209+ public void setTileBase64 (int x , int y , byte [] base64 ) {
210210 tile_b64_matrix [y ][x ] = base64 ;
211211 }
212212
@@ -227,15 +227,15 @@ private static NamespacedKey IMAGE_TILE_KEY(int mapId, int x, int y) {
227227 }
228228
229229 public void saveTileToWorldPDC (int x , int y ) {
230- Objects .requireNonNull (world ).getPersistentDataContainer ().set (IMAGE_TILE_KEY (mapview_id , x , y ), PersistentDataType .STRING , tile_b64_matrix [y ][x ]);
230+ Objects .requireNonNull (world ).getPersistentDataContainer ().set (IMAGE_TILE_KEY (mapview_id , x , y ), PersistentDataType .BYTE_ARRAY , tile_b64_matrix [y ][x ]);
231231 }
232232
233233 public void removeTileFromWorldPDC (int x , int y ) {
234234 Objects .requireNonNull (world ).getPersistentDataContainer ().remove (IMAGE_TILE_KEY (mapview_id , x , y ));
235235 }
236236
237- public String getTileFromWorldPDC (int x , int y ) {
238- return Objects .requireNonNull (world ).getPersistentDataContainer ().get (IMAGE_TILE_KEY (mapview_id , x , y ), PersistentDataType .STRING );
237+ public byte [] getTileFromWorldPDC (int x , int y ) {
238+ return Objects .requireNonNull (world ).getPersistentDataContainer ().get (IMAGE_TILE_KEY (mapview_id , x , y ), PersistentDataType .BYTE_ARRAY );
239239 }
240240
241241
0 commit comments