Skip to content

Commit

Permalink
Allow unsafe server icons (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmuscaria committed Apr 3, 2022
1 parent 99b6547 commit 985cff4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/main/java/io/github/crucible/CrucibleConfigs.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import co.aikar.timings.Timings;
import co.aikar.timings.TimingsManager;
import net.cubespace.Yamler.Config.Comment;
import net.cubespace.Yamler.Config.ConfigMode;
import net.cubespace.Yamler.Config.InvalidConfigurationException;
import net.cubespace.Yamler.Config.YamlConfig;
import net.cubespace.Yamler.Config.*;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.WorldServer;

Expand Down Expand Up @@ -160,6 +157,12 @@ public class CrucibleConfigs extends YamlConfig {
@Comment("Sets the server max tick time, experimental, can cause problems!")
public int crucible_tickHandler_serverTickTime = 1000000000;

@Comments({"Removes some restrictions and safety checks, we will not offer support for this setting and it may cause problems.",
"Use it at your own risk!",
"Currently disabled checks by this:",
" * Server Icon max size check"})
public boolean crucible_unsafe = false;

@Comment("Let timings be turned on since the server statup!")
public boolean timings_enabledSinceServerStartup = false;

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/bukkit/craftbukkit/CraftServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.google.common.collect.MapMaker;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLLog;
import io.github.crucible.CrucibleConfigs;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.buffer.Unpooled;
Expand Down Expand Up @@ -259,8 +260,10 @@ static CraftIconCache loadServerIcon0(File file) throws Exception {
static CraftIconCache loadServerIcon0(BufferedImage image) throws Exception {
ByteBuf bytebuf = Unpooled.buffer();

Validate.isTrue(image.getWidth() == 64, "Must be 64 pixels wide");
Validate.isTrue(image.getHeight() == 64, "Must be 64 pixels high");
if (!CrucibleConfigs.configs.crucible_unsafe) {
Validate.isTrue(image.getWidth() == 64, "Must be 64 pixels wide");
Validate.isTrue(image.getHeight() == 64, "Must be 64 pixels high");
}
ImageIO.write(image, "PNG", new ByteBufOutputStream(bytebuf));
ByteBuf bytebuf1 = Base64.encode(bytebuf);

Expand Down

0 comments on commit 985cff4

Please sign in to comment.