mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2025-01-06 00:17:52 +01:00
sticky option for category files
This commit is contained in:
parent
6ce0e98a58
commit
c7a9200da1
@ -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);
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user