save category files readme

This commit is contained in:
mfnalex 2019-05-03 03:38:08 +02:00
parent 2f2bb35618
commit 433c6a9bbd
4 changed files with 56 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package de.jeffclan.JeffChestSort;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@ -47,7 +48,18 @@ public class JeffChestSortOrganizer {
// Load Categories
File categoriesFolder = new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "categories" + File.separator);
File[] listOfCategoryFiles = categoriesFolder.listFiles();
File[] listOfCategoryFiles = categoriesFolder.listFiles(new FilenameFilter() {
public boolean accept(File directory, String fileName) {
if (!fileName.endsWith(".txt")) {
return false;
}
if (fileName.matches("(?i)^\\d\\d\\d.*\\.txt$")) // Category between 900 and 999-... are default categories
{
return true;
}
return false;
}
});
for (File file : listOfCategoryFiles) {
if (file.isFile()) {
// Category name is the filename without .txt

View File

@ -32,6 +32,7 @@ package de.jeffclan.JeffChestSort;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@ -299,7 +300,39 @@ public class JeffChestSortPlugin extends JavaPlugin {
// Isn't there a smarter way to find all the 9** files in the .jar?
String[] defaultCategories = { "900-tools", "910-valuables", "920-combat", "930-brewing", "940-food",
"950-redstone", "960-wood", "970-stone", "980-plants", "981-corals" };
"950-redstone", "960-wood", "970-stone", "980-plants", "981-corals","_ReadMe - Category files" };
// Delete all files starting with 9..
for (File file : new File(getDataFolder().getAbsolutePath() + File.separator + "categories" + File.separator)
.listFiles(new FilenameFilter() {
public boolean accept(File directory, String fileName) {
if (!fileName.endsWith(".txt")) {
return false;
}
if (fileName.matches("(?i)9\\d\\d.*\\.txt$")) // Category between 900 and 999-... are default
// categories
{
return true;
}
return false;
}
})) {
boolean delete = true;
for (String name : defaultCategories) {
name=name+".txt";
if (name.equalsIgnoreCase(file.getName())) {
delete = false;
break;
}
}
if (delete) {
file.delete();
getLogger().warning("Deleting deprecated default category file " + file.getName());
}
}
for (String category : defaultCategories) {

View File

@ -3,14 +3,21 @@
#############
You can define custom category files for ChestSort using simple .txt files.
If you have {category} in your sorting-method, it will get replaced with the category name.
Category names are determined by the file names. The name must start with a number ranging
from 000 to 899 and end with .txt
Default categories are prefixed with 900 to 999. Please do not edit the default categories.
You can instead copy or rename the default files and edit those instead.
WARNING: All files with names starting between 900 and 999 will be deleted on start.
If you put {keepCategoryOrder} behind {category} in the sorting-method, the items will be
ordered exactly as listed in the category files. Otherwise, they will be grouped by category
and then sorted according to the remaining variables in your sorting-method.
Category files can contain asterisks (*) as wildcard character at the beginning and/or end
of an expression, but not in the middle.
Category files can also contain comments using the hashtag (#) symbol

View File

@ -39,6 +39,8 @@ show-message-again-after-logout: true
# If you wish to edit those, you can disable the generation of these
# files, because otherwise all your changes in the pregenerated
# files will be overwritten on each server startup.
# However, a much smarter option is to copy the default files
# and rename them to from 900... to 800... and edit those instead.
auto-generate-category-files: true
# you can choose when ChestSort should sort chests.