diff --git a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java index aa9f3ab..32940a0 100644 --- a/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java +++ b/src/main/java/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java @@ -87,8 +87,14 @@ public class JeffChestSortOrganizer { short currentLineNumber=1; while (sc.hasNextLine()) { String currentLine = sc.nextLine(); - - lines.add(new TypeMatchPositionPair(currentLine,currentLineNumber)); + if(currentLine.contains(" ") || currentLine.contains("#")) { + currentLine = currentLine.trim().split("#")[0].split(" ")[0]; // Remove everything after the first # and space + } + if(currentLine.toLowerCase().startsWith("sticky=") && currentLine.toLowerCase().endsWith("=true")) { + appendLineNumber = true; + } else { + lines.add(new TypeMatchPositionPair(currentLine,currentLineNumber,appendLineNumber)); + } currentLineNumber++; } TypeMatchPositionPair[] result = lines.toArray(new TypeMatchPositionPair[0]); @@ -216,7 +222,9 @@ public class JeffChestSortOrganizer { String[] typeAndColor = getTypeAndColor(item.getType().name()); String typeName = typeAndColor[0]; String color = typeAndColor[1]; - String category = getCategoryLinePair(item.getType().name()).getCategoryName(); + CategoryLinePair categoryLinePair = getCategoryLinePair(item.getType().name()); + //String categoryName = categoryLinePair.getCategoryName(); + String categorySticky = categoryLinePair.getCategoryNameSticky(); String customName = (plugin.debug) ? "~customName~" : emptyPlaceholderString; if(item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName()!=null) { customName=item.getItemMeta().getDisplayName(); @@ -236,7 +244,7 @@ public class JeffChestSortOrganizer { sortableString = sortableString.replaceAll("\\{blocksFirst\\}", String.valueOf(blocksFirst)); sortableString = sortableString.replaceAll("\\{name\\}", typeName); sortableString = sortableString.replaceAll("\\{color\\}", color); - sortableString = sortableString.replaceAll("\\{category\\}", category); + sortableString = sortableString.replaceAll("\\{category\\}", categorySticky); sortableString = sortableString.replaceAll("\\{line\\}", lineNumber); sortableString = sortableString.replaceAll("\\{customName\\}", customName); sortableString = sortableString.replaceAll("\\{lore\\}", lore); diff --git a/src/main/java/de/jeffclan/utils/CategoryLinePair.java b/src/main/java/de/jeffclan/utils/CategoryLinePair.java index 3c3c62f..f81129d 100644 --- a/src/main/java/de/jeffclan/utils/CategoryLinePair.java +++ b/src/main/java/de/jeffclan/utils/CategoryLinePair.java @@ -4,12 +4,23 @@ package de.jeffclan.utils; public class CategoryLinePair { String categoryName; String formattedPosition; + boolean sticky = false; short position; public CategoryLinePair(String categoryName,short position) { + this(categoryName,position,false); + } + + public CategoryLinePair(String categoryName,short position,boolean sticky) { this.categoryName=categoryName; this.formattedPosition=Utils.shortToStringWithLeadingZeroes(position); this.position=position; + this.sticky=sticky; + } + + public String getCategoryNameSticky() { + if(sticky) return getCategoryName() + "~" + getFormattedPosition(); + return getCategoryName(); } public String getCategoryName() { diff --git a/src/main/java/de/jeffclan/utils/TypeMatchPositionPair.java b/src/main/java/de/jeffclan/utils/TypeMatchPositionPair.java index afc9feb..8487782 100644 --- a/src/main/java/de/jeffclan/utils/TypeMatchPositionPair.java +++ b/src/main/java/de/jeffclan/utils/TypeMatchPositionPair.java @@ -4,9 +4,16 @@ public class TypeMatchPositionPair { String typeMatch; String formattedPosition; + boolean sticky=false; + public String getTypeMatch() { return typeMatch; } + + public String getTypeMatchWithSticky() { + if(sticky) return getTypeMatch() + "~" + getFormattedPosition(); + return getTypeMatch(); + } public short getPosition() { return position; @@ -19,9 +26,14 @@ public class TypeMatchPositionPair { short position; public TypeMatchPositionPair(String typeMatch,short position) { + this(typeMatch,position,false); + } + + public TypeMatchPositionPair(String typeMatch, short position, boolean appendLineNumber) { this.typeMatch=typeMatch; this.position=position; this.formattedPosition=Utils.shortToStringWithLeadingZeroes(position); + this.sticky=appendLineNumber; } }