This commit is contained in:
mfnalex 2018-08-23 17:42:48 +02:00
parent 8574c300cc
commit 77776c8c7a
10 changed files with 82 additions and 35 deletions

View File

@ -40,10 +40,12 @@ check-for-updates: true
##########################
# Advanced: how to sort things! See below for examples.
# Only change this if you know what you are doing.
#
# Available variables:
# {itemsFirst} put items before blocks (must be at the beginning)
# {blocksFirst} put blocks before items (must be at the beginning)
# {category} order stuff by category as defined in plugins/ChestSort/categories/<category>.txt
# {itemsFirst} put items before blocks
# {blocksFirst} put blocks before items
# {name} returns the name (e.g. DIRT, GRASS_BLOCK, BIRCH_LOG, DIAMOND_SWORD, ...)
# {color} returns the color, e.g. light_blue for wool. Empty if block/item is not dyeable
#
@ -59,7 +61,10 @@ check-for-updates: true
# sort by name and color, but put blocks before items:
# '{blocksFirst},{name},{color}'
#
sorting-method: '{itemsFirst},{name},{color}'
# sort by category, then put items before blocks and sort by name and color
# '{category},{itemsFirst},{name},{color}'
#
sorting-method: '{category},{itemsFirst},{name},{color}'
#########################
##### localization ######
@ -125,4 +130,4 @@ message-error-players-only: "&cError: This command can only be run by players."
#########################
# please do not change the following line manually!
config-version: 4
config-version: 5

View File

@ -1,6 +1,6 @@
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
name: ChestSort
version: 1.7.5
version: 2.0-pre1
api-version: 1.13
description: Allows automatic chest sorting
author: mfnalex

View File

@ -88,6 +88,30 @@ public class JeffChestSortOrganizer {
myColor = woodName;
}
}
// Egg has to be put in front to group spawn eggs
// E.g. cow_spawn_egg -> egg_cow_spawn
if(typeName.endsWith("_egg")) {
typeName = typeName.replaceFirst("_egg", "");
typeName = "egg_" + typeName;
}
// Sort armor: helmet, chestplate, leggings, boots
if(typeName.endsWith("helmet")) {
typeName = typeName.replaceFirst("helmet", "1_helmet");
} else if(typeName.endsWith("chestplate")) {
typeName = typeName.replaceFirst("chestplate", "2_chestplate");
} else if(typeName.endsWith("leggings")) {
typeName = typeName.replaceFirst("leggings", "3_leggings");
} else if(typeName.endsWith("boots")) {
typeName = typeName.replaceFirst("boots", "4_boots");
}
// Group horse armor
if(typeName.endsWith("horse_armor")) {
typeName = typeName.replaceFirst("_horse_armor", "");
typeName = "horse_armor_" + typeName;
}
// Wool (sort by color)
/*
@ -122,13 +146,9 @@ public class JeffChestSortOrganizer {
if (item.getType().isBlock()) {
blocksFirst = '!';
itemsFirst = '#';
if (plugin.debug)
System.out.println(item.getType().name() + " is a block.");
} else {
blocksFirst = '#';
itemsFirst = '!';
if (plugin.debug)
System.out.println(item.getType().name() + " is an item.");
}
String[] typeAndColor = getTypeAndColor(item.getType().name());

View File

@ -23,7 +23,8 @@ public class JeffChestSortPlugin extends JavaPlugin {
JeffChestSortOrganizer organizer;
JeffChestSortUpdateChecker updateChecker;
String sortingMethod;
int currentConfigVersion = 4;
int currentConfigVersion = 5;
boolean usingMatchingConfig = true;
boolean debug = false;
long updateCheckInterval = 86400; // in seconds. We check on startup and every 24 hours (if you never restart your
// server)
@ -52,6 +53,33 @@ public class JeffChestSortPlugin extends JavaPlugin {
getLogger().info("Current sorting method: " + sortingMethod);
if (getConfig().getInt("config-version", 0) != currentConfigVersion) {
getLogger().warning("========================================================");
getLogger().warning("YOU ARE USING AN OLD CONFIG FILE!");
getLogger().warning("This is not a problem, as ChestSort will just use the");
getLogger().warning("default settings for unset values. However, if you want");
getLogger().warning("to configure the new options, please go to");
getLogger().warning("https://www.spigotmc.org/resources/1-13-chestsort.59773/");
getLogger().warning("and replace your config.yml with the new one. You can");
getLogger().warning("then insert your old changes into the new file.");
getLogger().warning("========================================================");
usingMatchingConfig = false;
}
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
if (getConfig().getBoolean("check-for-updates", true)) {
updateChecker.checkForUpdate();
}
}
}, 0L, updateCheckInterval * 20);
@SuppressWarnings("unused")
Metrics metrics = new Metrics(this);
@ -68,33 +96,13 @@ public class JeffChestSortPlugin extends JavaPlugin {
() -> Boolean.toString(getConfig().getBoolean("show-message-again-after-logout"))));
metrics.addCustomChart(new Metrics.SimplePie("sorting_enabled_by_default",
() -> Boolean.toString(getConfig().getBoolean("sorting-enabled-by-default"))));
getLogger().info("Current sorting method: " + sortingMethod);
if (getConfig().getInt("config-version", 0) != currentConfigVersion) {
getLogger().warning("========================================================");
getLogger().warning("YOU ARE USING AN OLD CONFIG FILE!");
getLogger().warning("This is not a problem, as ChestSort will just use the");
getLogger().warning("default settings for unset values. However, if you want");
getLogger().warning("to configure the new options, please go to");
getLogger().warning("https://www.spigotmc.org/resources/1-13-chestsort.59773/");
getLogger().warning("and replace your config.yml with the new one. You can");
getLogger().warning("then insert your old changes into the new file.");
getLogger().warning("========================================================");
}
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
if (getConfig().getBoolean("check-for-updates", true)) {
updateChecker.checkForUpdate();
}
}
}, 0L, updateCheckInterval * 20);
metrics.addCustomChart(new Metrics.SimplePie("using_matching_config_version",
() ->Boolean.toString(usingMatchingConfig)));
}
private void saveDefaultCategories() {
String[] defaultCategories = { "900-valuables","902-brewing","905-tools","907-combat","910-food","920-redstone" };
String[] defaultCategories = { "900-valuables","910-tools","920-combat","930-brewing","940-food","950-redstone" };
for (String category : defaultCategories) {
@ -165,7 +173,7 @@ public class JeffChestSortPlugin extends JavaPlugin {
getConfig().addDefault("show-message-when-using-chest", true);
getConfig().addDefault("show-message-when-using-chest-and-sorting-is-enabled", false);
getConfig().addDefault("show-message-again-after-logout", true);
getConfig().addDefault("sorting-method", "{itemsFirst},{name},{color}");
getConfig().addDefault("sorting-method", "{category},{itemsFirst},{name},{color}");
getConfig().addDefault("check-for-updates", true);
}

View File

@ -10,4 +10,18 @@ gold_block
diamond_block
iron_block
lapis_lazuli
lapis_block
lapis_block
obsidian
beacon
conduit
scute
elytra
ender_pearl
ender_eye
*_horse_armor
music_disc_*
heart_of_the_sea
nautilus_shell
gold_nugget
iron_nugget
enchanted_book