Skip to content

Commit

Permalink
feat: add new option to bypass item length check
Browse files Browse the repository at this point in the history
StarWishsama committed Jan 16, 2025

Verified

This commit was signed with the committer’s verified signature.
StarWishsama NoRainCity
1 parent 538b66d commit a11f712
Showing 7 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -26,7 +26,6 @@
import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey;
import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;

import java.util.List;

public class MysqlAdapter extends SqlCommonAdapter<MysqlConfig> {
@@ -399,8 +398,8 @@ private void createTableInformationTable() {

if (Slimefun.isNewlyInstalled()) {
executeSql("INSERT INTO " + tableInformationTable + " (" + FIELD_TABLE_VERSION + ") SELECT '"
+ IDataSourceAdapter.DATABASE_VERSION + "' WHERE NOT EXISTS (SELECT 1 FROM " + tableInformationTable
+ ")");
+ IDataSourceAdapter.DATABASE_VERSION + "' WHERE NOT EXISTS (SELECT 1 FROM " + tableInformationTable
+ ")");
}
}
}
Original file line number Diff line number Diff line change
@@ -26,7 +26,6 @@
import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey;
import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@@ -415,8 +414,8 @@ private void createTableInformationTable() {

if (Slimefun.isNewlyInstalled()) {
executeSql("INSERT INTO " + tableInformationTable + " (" + FIELD_TABLE_VERSION + ") SELECT '"
+ IDataSourceAdapter.DATABASE_VERSION + "' WHERE NOT EXISTS (SELECT 1 FROM " + tableInformationTable
+ ")");
+ IDataSourceAdapter.DATABASE_VERSION + "' WHERE NOT EXISTS (SELECT 1 FROM " + tableInformationTable
+ ")");
}
}
}
Original file line number Diff line number Diff line change
@@ -394,8 +394,8 @@ private void createTableInformationTable() {

if (Slimefun.isNewlyInstalled()) {
executeSql("INSERT INTO " + tableInformationTable + " (" + FIELD_TABLE_VERSION + ") SELECT '"
+ IDataSourceAdapter.DATABASE_VERSION + "' WHERE NOT EXISTS (SELECT 1 FROM " + tableInformationTable
+ ")");
+ IDataSourceAdapter.DATABASE_VERSION + "' WHERE NOT EXISTS (SELECT 1 FROM " + tableInformationTable
+ ")");
}
}

Original file line number Diff line number Diff line change
@@ -29,7 +29,8 @@ public static String itemStack2String(ItemStack itemStack) {
bs.writeObject(itemStack);
var itemStr = Base64Coder.encodeLines(stream.toByteArray());

if (Slimefun.getDatabaseManager().getBlockDataStorageType() != StorageType.SQLITE
if (!Slimefun.getConfigManager().isBypassItemLengthCheck()
&& Slimefun.getDatabaseManager().getBlockDataStorageType() != StorageType.SQLITE
&& itemStr.length() > 65535) {
throw new IllegalArgumentException("检测到过大物品, 请联系物品对应插件开发者解决: " + StringUtil.itemStackToString(itemStack)
+ ", size = " + itemStr.length());
Original file line number Diff line number Diff line change
@@ -101,6 +101,11 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
builder.append("\n已禁用环境兼容性检查").color(ChatColor.RED);
}

if (Slimefun.getConfigManager().isBypassItemLengthCheck()) {
builder.append("\n").event((HoverEvent) null);
builder.append("\n已禁用物品长度检查").color(ChatColor.RED);
}

builder.append("\n").event((HoverEvent) null);
addPluginVersions(builder);

Original file line number Diff line number Diff line change
@@ -68,6 +68,9 @@ public class SlimefunConfigManager {
@Getter
private boolean bypassEnvironmentCheck;

@Getter
private boolean bypassItemLengthCheck;

public SlimefunConfigManager(@Nonnull Slimefun plugin) {
Validate.notNull(plugin, "The Plugin instance cannot be null");

@@ -118,6 +121,7 @@ public boolean load(boolean reload) {
showHiddenItemGroupsInSearch = pluginConfig.getBoolean("guide.show-hidden-item-groups-in-search");
autoUpdate = pluginConfig.getBoolean("options.auto-update");
bypassEnvironmentCheck = pluginConfig.getBoolean("options.bypass-environment-check");
bypassItemLengthCheck = pluginConfig.getBoolean("options.bypass-item-length-check");

researchesConfig.setDefaultValue("researches.currency-cost-convert-rate", 25.0);
researchCurrencyCostConvertRate = researchesConfig.getDouble("researches.currency-cost-convert-rate");
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ options:
backup-data: true
drop-block-creative: true
bypass-environment-check: false
bypass-item-length-check: false

guide:
# 是否在指南中展示原版物品合成配方

0 comments on commit a11f712

Please sign in to comment.