Skip to content

Commit 1ea85b8

Browse files
committed
just some cleanups in the code
1 parent acb590b commit 1ea85b8

File tree

2 files changed

+37
-34
lines changed

2 files changed

+37
-34
lines changed

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -579,23 +579,6 @@ private static void setSkin(@Nonnull final GameProfile profile, @Nullable final
579579

580580
}
581581

582-
583-
/**
584-
* Retrieves a Material by name, logging a warning if not found.
585-
*
586-
* @param name The name of the Material.
587-
* @return The Material if found; null otherwise.
588-
*/
589-
@Nullable
590-
private static Material getMaterial(final String name) {
591-
try {
592-
return Material.getMaterial(name);
593-
} catch (Exception e) {
594-
LOG.log(() -> "Could not find this material: " + name);
595-
}
596-
return null;
597-
}
598-
599582
/**
600583
* Sets the owning player of the SkullMeta using the appropriate method depending on Bukkit API version.
601584
*
@@ -836,5 +819,22 @@ private Material createMaterial() {
836819
return skull;
837820
}
838821

822+
/**
823+
* Retrieves a Material by name, logging a warning if not found.
824+
*
825+
* @param name The name of the Material.
826+
* @return The Material if found; null otherwise.
827+
*/
828+
@Nullable
829+
private static Material getMaterial(final String name) {
830+
try {
831+
return Material.getMaterial(name);
832+
} catch (Exception e) {
833+
LOG.log(() -> "Could not find this material: " + name);
834+
}
835+
return null;
836+
}
837+
838+
839839
}
840840
}

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.List;
2525
import java.util.Map;
2626
import java.util.Objects;
27-
import java.util.function.Consumer;
2827
import java.util.stream.Collectors;
2928

3029
/**
@@ -507,27 +506,31 @@ public static MapRendererData deserialize(Map<String, Object> map) {
507506
if (pixels instanceof List<?>) {
508507
for (Object pixel : (List<?>) pixels) {
509508
Map<String, Object> pixelMap = (Map<String, Object>) pixel;
510-
for (Map.Entry<String, Object> mapPixels : pixelMap.entrySet()) {
511-
Map<String, Object> mapPixelsValue = (Map<String, Object>) mapPixels.getValue();
512-
String type = (String) mapPixelsValue.get("type");
513-
int layer;
514-
try {
515-
layer = Integer.parseInt(mapPixels.getKey());
516-
} catch (NumberFormatException ignore) {
517-
layer = 0;
518-
}
519-
if (type.equals("MapColoredPixel"))
520-
mapRendererData.addPixel(layer, MapColoredPixel.deserialize(mapPixelsValue));
521-
if (type.equals("TextOverlay"))
522-
mapRendererData.addText(layer, TextOverlay.deserialize(mapPixelsValue));
523-
if (type.equals("ImageOverlay"))
524-
mapRendererData.addImage(layer, ImageOverlay.deserialize(mapPixelsValue));
525-
}
509+
retrievePixels(pixelMap, mapRendererData);
526510
}
527511
}
528512
return mapRendererData;
529513
}
530514

515+
private static void retrievePixels(final Map<String, Object> pixelMap, final MapRendererData mapRendererData) {
516+
for (Map.Entry<String, Object> mapPixels : pixelMap.entrySet()) {
517+
Map<String, Object> mapPixelsValue = (Map<String, Object>) mapPixels.getValue();
518+
String type = (String) mapPixelsValue.get("type");
519+
int layer;
520+
try {
521+
layer = Integer.parseInt(mapPixels.getKey());
522+
} catch (NumberFormatException ignore) {
523+
layer = 0;
524+
}
525+
if (type.equals("MapColoredPixel"))
526+
mapRendererData.addPixel(layer, MapColoredPixel.deserialize(mapPixelsValue));
527+
if (type.equals("TextOverlay"))
528+
mapRendererData.addText(layer, TextOverlay.deserialize(mapPixelsValue));
529+
if (type.equals("ImageOverlay"))
530+
mapRendererData.addImage(layer, ImageOverlay.deserialize(mapPixelsValue));
531+
}
532+
}
533+
531534
@Override
532535
public String toString() {
533536
return "MapRendererData{" +

0 commit comments

Comments
 (0)