mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-11-26 20:48:12 +01:00
5.0.1
This commit is contained in:
parent
b16b8e7a44
commit
f1ae5444e1
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.jeffclan</groupId>
|
||||
<artifactId>JeffChestSort</artifactId>
|
||||
<version>4.3.1-dev</version>
|
||||
<version>5.0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>JeffChestSort</name>
|
||||
|
@ -13,12 +13,22 @@ public class JeffChestSortCategory implements Comparable<JeffChestSortCategory>{
|
||||
// "COARSE_DIRT" will match the typeMatch "*dirt"
|
||||
|
||||
String name;
|
||||
boolean sticky = false;
|
||||
TypeMatchPositionPair[] typeMatches;
|
||||
|
||||
JeffChestSortCategory(String name, TypeMatchPositionPair[] typeMatchPositionPairs) {
|
||||
this.name = name;
|
||||
this.typeMatches = typeMatchPositionPairs;
|
||||
}
|
||||
|
||||
void setSticky() {
|
||||
this.sticky=true;
|
||||
}
|
||||
|
||||
boolean isSticky() {
|
||||
return this.sticky;
|
||||
}
|
||||
|
||||
|
||||
// Checks whether a the given itemname fits into this category and returns the line number. 0 means not found
|
||||
short matches(String itemname) {
|
||||
|
@ -1,9 +1,7 @@
|
||||
package de.jeffclan.JeffChestSort;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -44,6 +44,7 @@ public class JeffChestSortOrganizer {
|
||||
|
||||
// We store a list of all Category objects
|
||||
ArrayList<JeffChestSortCategory> categories = new ArrayList<JeffChestSortCategory>();
|
||||
ArrayList<String> stickyCategoryNames = new ArrayList<String>();
|
||||
|
||||
JeffChestSortOrganizer(JeffChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -85,6 +86,15 @@ public class JeffChestSortOrganizer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make categories sticky
|
||||
for(String catName : stickyCategoryNames) {
|
||||
for(JeffChestSortCategory cat : categories) {
|
||||
if(catName.equalsIgnoreCase(cat.name)) {
|
||||
cat.setSticky();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -118,6 +128,7 @@ public class JeffChestSortOrganizer {
|
||||
|
||||
if (currentLine.toLowerCase().endsWith("=true")) {
|
||||
appendLineNumber = true;
|
||||
makeCategoryStickyByFileName(file.getName());
|
||||
if (plugin.debug)
|
||||
plugin.getLogger().info("Sticky set to true in " + file.getName());
|
||||
}
|
||||
@ -136,6 +147,14 @@ public class JeffChestSortOrganizer {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void makeCategoryStickyByFileName(String name) {
|
||||
String catName = name.replaceAll("\\.txt$", "");
|
||||
|
||||
stickyCategoryNames.add(catName);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Convert the item name to what I call a "sortable item name".
|
||||
// Sorry, the method name is a bit misleading.
|
||||
// The array's [0] value contains the item name with a few fixes, see below
|
||||
@ -258,8 +277,13 @@ public class JeffChestSortOrganizer {
|
||||
String typeName = typeAndColor[0];
|
||||
String color = typeAndColor[1];
|
||||
CategoryLinePair categoryLinePair = getCategoryLinePair(item.getType().name());
|
||||
// String categoryName = categoryLinePair.getCategoryName();
|
||||
String categorySticky = categoryLinePair.getCategoryNameSticky();
|
||||
String categoryName = categoryLinePair.getCategoryName();
|
||||
String categorySticky = categoryName;
|
||||
String lineNumber = getCategoryLinePair(item.getType().name()).getFormattedPosition();
|
||||
if(stickyCategoryNames.contains(categoryName)) {
|
||||
categorySticky = categoryName+"~"+lineNumber;
|
||||
}
|
||||
|
||||
String customName = (plugin.debug) ? "~customName~" : emptyPlaceholderString;
|
||||
if (item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName() != null) {
|
||||
customName = item.getItemMeta().getDisplayName();
|
||||
@ -270,7 +294,7 @@ public class JeffChestSortOrganizer {
|
||||
String[] loreArray = item.getItemMeta().getLore().toArray(new String[0]);
|
||||
lore = String.join(",", loreArray);
|
||||
}
|
||||
String lineNumber = getCategoryLinePair(item.getType().name()).getFormattedPosition();
|
||||
|
||||
|
||||
// Generate the strings that finally are used for sorting.
|
||||
// They are generated according to the config.yml's sorting-method option
|
||||
@ -280,7 +304,7 @@ public class JeffChestSortOrganizer {
|
||||
sortableString = sortableString.replaceAll("\\{name\\}", typeName);
|
||||
sortableString = sortableString.replaceAll("\\{color\\}", color);
|
||||
sortableString = sortableString.replaceAll("\\{category\\}", categorySticky);
|
||||
sortableString = sortableString.replaceAll("\\{line\\}", lineNumber);
|
||||
sortableString = sortableString.replaceAll("\\{keepCategoryOrder\\}", lineNumber);
|
||||
sortableString = sortableString.replaceAll("\\{customName\\}", customName);
|
||||
sortableString = sortableString.replaceAll("\\{lore\\}", lore);
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
|
||||
name: ChestSort
|
||||
version: 4.3.1-dev
|
||||
version: 5.0.1
|
||||
api-version: 1.13
|
||||
description: Allows automatic chest sorting
|
||||
author: mfnalex
|
||||
|
Loading…
Reference in New Issue
Block a user