Added a character limit to the NBT display of the advanced info so that it doesn't crash on really long NBT tags

This commit is contained in:
Ellpeck 2016-08-03 17:17:52 +02:00
parent 9b7652e6bc
commit 2eaccba3e3
2 changed files with 15 additions and 2 deletions

View file

@ -23,7 +23,8 @@ public enum ConfigIntValues{
BLACK_LOTUS_AMOUNT("Black Lotus: Amount", ConfigCategories.WORLD_GEN, 14, 1, 50, "The Amount of Black Lotus generating"),
LUSH_CAVE_CHANCE("Lush Caves: Chance", ConfigCategories.WORLD_GEN, 20, 1, 100, "The chance for lush caves to generate. The lower the number, the likelier."),
TILE_ENTITY_UPDATE_INTERVAL("Tile Entities: Update Interval", ConfigCategories.OTHER, 5, 1, 100, "The amount of ticks waited before a TileEntity sends an additional Update to the Client");
TILE_ENTITY_UPDATE_INTERVAL("Tile Entities: Update Interval", ConfigCategories.OTHER, 5, 1, 100, "The amount of ticks waited before a TileEntity sends an additional Update to the Client"),
CTRL_INFO_NBT_CHAR_LIMIT("Advanced Info NBT Character Limit", ConfigCategories.OTHER, 1000, 0, 100000000, "The maximum amount of characters that is displayed by the NBT view of the CTRL Advanced Info. Set to a zero to have no limit");
public final String name;
public final String category;

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.event;
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.inventory.gui.EnergyDisplay;
import de.ellpeck.actuallyadditions.mod.tile.IEnergyDisplay;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
@ -99,7 +100,18 @@ public class ClientEvents{
if(compound != null && !compound.hasNoTags()){
event.getToolTip().add(ADVANCED_INFO_HEADER_PRE+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".nbt.desc")+":");
if(GuiScreen.isShiftKeyDown()){
event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+compound.toString());
int limit = ConfigIntValues.CTRL_INFO_NBT_CHAR_LIMIT.getValue();
String compoundStrg = compound.toString();
int compoundStrgLength = compoundStrg.length();
String compoundDisplay;
if(limit > 0 && compoundStrgLength > limit){
compoundDisplay = compoundStrg.substring(0, limit)+TextFormatting.GRAY+" ("+(compoundStrgLength-limit)+" more characters...)";
}
else{
compoundDisplay = compoundStrg;
}
event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+compoundDisplay);
}
else{
event.getToolTip().add(ADVANCED_INFO_TEXT_PRE+TextFormatting.ITALIC+"["+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".pressShift.desc")+"]");