mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2025-01-08 09:27:39 +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;
|
short currentLineNumber=1;
|
||||||
while (sc.hasNextLine()) {
|
while (sc.hasNextLine()) {
|
||||||
String currentLine = sc.nextLine();
|
String currentLine = sc.nextLine();
|
||||||
|
if(currentLine.contains(" ") || currentLine.contains("#")) {
|
||||||
lines.add(new TypeMatchPositionPair(currentLine,currentLineNumber));
|
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++;
|
currentLineNumber++;
|
||||||
}
|
}
|
||||||
TypeMatchPositionPair[] result = lines.toArray(new TypeMatchPositionPair[0]);
|
TypeMatchPositionPair[] result = lines.toArray(new TypeMatchPositionPair[0]);
|
||||||
@ -216,7 +222,9 @@ public class JeffChestSortOrganizer {
|
|||||||
String[] typeAndColor = getTypeAndColor(item.getType().name());
|
String[] typeAndColor = getTypeAndColor(item.getType().name());
|
||||||
String typeName = typeAndColor[0];
|
String typeName = typeAndColor[0];
|
||||||
String color = typeAndColor[1];
|
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;
|
String customName = (plugin.debug) ? "~customName~" : emptyPlaceholderString;
|
||||||
if(item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName()!=null) {
|
if(item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName()!=null) {
|
||||||
customName=item.getItemMeta().getDisplayName();
|
customName=item.getItemMeta().getDisplayName();
|
||||||
@ -236,7 +244,7 @@ public class JeffChestSortOrganizer {
|
|||||||
sortableString = sortableString.replaceAll("\\{blocksFirst\\}", String.valueOf(blocksFirst));
|
sortableString = sortableString.replaceAll("\\{blocksFirst\\}", String.valueOf(blocksFirst));
|
||||||
sortableString = sortableString.replaceAll("\\{name\\}", typeName);
|
sortableString = sortableString.replaceAll("\\{name\\}", typeName);
|
||||||
sortableString = sortableString.replaceAll("\\{color\\}", color);
|
sortableString = sortableString.replaceAll("\\{color\\}", color);
|
||||||
sortableString = sortableString.replaceAll("\\{category\\}", category);
|
sortableString = sortableString.replaceAll("\\{category\\}", categorySticky);
|
||||||
sortableString = sortableString.replaceAll("\\{line\\}", lineNumber);
|
sortableString = sortableString.replaceAll("\\{line\\}", lineNumber);
|
||||||
sortableString = sortableString.replaceAll("\\{customName\\}", customName);
|
sortableString = sortableString.replaceAll("\\{customName\\}", customName);
|
||||||
sortableString = sortableString.replaceAll("\\{lore\\}", lore);
|
sortableString = sortableString.replaceAll("\\{lore\\}", lore);
|
||||||
|
@ -4,12 +4,23 @@ package de.jeffclan.utils;
|
|||||||
public class CategoryLinePair {
|
public class CategoryLinePair {
|
||||||
String categoryName;
|
String categoryName;
|
||||||
String formattedPosition;
|
String formattedPosition;
|
||||||
|
boolean sticky = false;
|
||||||
short position;
|
short position;
|
||||||
|
|
||||||
public CategoryLinePair(String categoryName,short position) {
|
public CategoryLinePair(String categoryName,short position) {
|
||||||
|
this(categoryName,position,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CategoryLinePair(String categoryName,short position,boolean sticky) {
|
||||||
this.categoryName=categoryName;
|
this.categoryName=categoryName;
|
||||||
this.formattedPosition=Utils.shortToStringWithLeadingZeroes(position);
|
this.formattedPosition=Utils.shortToStringWithLeadingZeroes(position);
|
||||||
this.position=position;
|
this.position=position;
|
||||||
|
this.sticky=sticky;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategoryNameSticky() {
|
||||||
|
if(sticky) return getCategoryName() + "~" + getFormattedPosition();
|
||||||
|
return getCategoryName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCategoryName() {
|
public String getCategoryName() {
|
||||||
|
@ -4,10 +4,17 @@ public class TypeMatchPositionPair {
|
|||||||
|
|
||||||
String typeMatch;
|
String typeMatch;
|
||||||
String formattedPosition;
|
String formattedPosition;
|
||||||
|
boolean sticky=false;
|
||||||
|
|
||||||
public String getTypeMatch() {
|
public String getTypeMatch() {
|
||||||
return typeMatch;
|
return typeMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTypeMatchWithSticky() {
|
||||||
|
if(sticky) return getTypeMatch() + "~" + getFormattedPosition();
|
||||||
|
return getTypeMatch();
|
||||||
|
}
|
||||||
|
|
||||||
public short getPosition() {
|
public short getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
@ -19,9 +26,14 @@ public class TypeMatchPositionPair {
|
|||||||
short position;
|
short position;
|
||||||
|
|
||||||
public TypeMatchPositionPair(String typeMatch,short position) {
|
public TypeMatchPositionPair(String typeMatch,short position) {
|
||||||
|
this(typeMatch,position,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeMatchPositionPair(String typeMatch, short position, boolean appendLineNumber) {
|
||||||
this.typeMatch=typeMatch;
|
this.typeMatch=typeMatch;
|
||||||
this.position=position;
|
this.position=position;
|
||||||
this.formattedPosition=Utils.shortToStringWithLeadingZeroes(position);
|
this.formattedPosition=Utils.shortToStringWithLeadingZeroes(position);
|
||||||
|
this.sticky=appendLineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user