Skip to content

Commit

Permalink
Add a config option to disallow creating maps over 128x128 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver-makes-code authored Oct 25, 2024
1 parent a4c5fe0 commit db03122
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/space/essem/image2map/Image2Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,21 @@ private int createMap(CommandContext<ServerCommandSource> context) throws Comman
try {
width = IntegerArgumentType.getInteger(context, "width");
height = IntegerArgumentType.getInteger(context, "height");

LOGGER.info("{}, {}", width, height);

if (!CONFIG.allowTiledMaps && (width > 128 || height > 128)) {
source.sendFeedback(() -> Text.literal("The image is too large. Must be less than or equal to 128x128.")
.setStyle(Style.EMPTY.withColor(Formatting.RED)), false);
return null;
}
} catch (Throwable e) {
width = image.getWidth();
height = image.getHeight();
if (!CONFIG.allowTiledMaps && (width > 128 || height > 128)) {
width = 128;
height = 128;
}
}

int finalHeight = height;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class Image2MapConfig {

public boolean allowLocalFiles = false;

/**
* Allows maps to tile (>128x128 images)
* */
public boolean allowTiledMaps = true;

public int minPermLevel = 2;


Expand Down

0 comments on commit db03122

Please sign in to comment.