mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-12-02 15:43:22 +01:00
2.0.0
This commit is contained in:
parent
6c9f861bc6
commit
717c97528f
@ -35,6 +35,14 @@ show-message-again-after-logout: true
|
|||||||
# join the server
|
# join the server
|
||||||
check-for-updates: true
|
check-for-updates: true
|
||||||
|
|
||||||
|
# to sort by category, we need category files. ChestSort comes
|
||||||
|
# with a number of pregenerated category files, named
|
||||||
|
# 900-valuables.txt, 910-tools.txt, 920-combat.txt, ...
|
||||||
|
# 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.
|
||||||
|
auto-generate-category-files: true
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
##### Sorting Method #####
|
##### Sorting Method #####
|
||||||
##########################
|
##########################
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
|
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
|
||||||
name: ChestSort
|
name: ChestSort
|
||||||
version: 2.0-pre1
|
version: 2.0.0
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
description: Allows automatic chest sorting
|
description: Allows automatic chest sorting
|
||||||
author: mfnalex
|
author: mfnalex
|
||||||
|
@ -110,6 +110,20 @@ public class JeffChestSortOrganizer {
|
|||||||
typeName = "egg_" + typeName;
|
typeName = "egg_" + typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// polished_andesite -> andesite_polished
|
||||||
|
if(typeName.startsWith("polished_")) {
|
||||||
|
typeName = typeName.replaceFirst("polished_", "");
|
||||||
|
typeName = typeName + "_polished";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeName.equalsIgnoreCase("wet_sponge")) {
|
||||||
|
typeName = "sponge_wet";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeName.equalsIgnoreCase("carved_pumpkin")) {
|
||||||
|
typeName = "pumpkin_carved";
|
||||||
|
}
|
||||||
|
|
||||||
// Sort armor: helmet, chestplate, leggings, boots
|
// Sort armor: helmet, chestplate, leggings, boots
|
||||||
if(typeName.endsWith("helmet")) {
|
if(typeName.endsWith("helmet")) {
|
||||||
typeName = typeName.replaceFirst("helmet", "1_helmet");
|
typeName = typeName.replaceFirst("helmet", "1_helmet");
|
||||||
|
@ -10,6 +10,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -32,43 +33,29 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
if(debug) {
|
/*if(debug) {
|
||||||
System.out.println("======= ALL MATERIALS ======");
|
System.out.println("======= ALL MATERIALS ======");
|
||||||
for(Material mat : Material.values()) {
|
for(Material mat : Material.values()) {
|
||||||
|
|
||||||
System.out.println(mat.name().toLowerCase());
|
System.out.println(mat.name().toLowerCase());
|
||||||
}
|
}
|
||||||
System.out.println("============================");
|
System.out.println("============================");
|
||||||
}
|
}*/
|
||||||
|
|
||||||
createConfig();
|
createConfig();
|
||||||
saveDefaultCategories();
|
saveDefaultCategories();
|
||||||
messages = new JeffChestSortMessages(this);
|
messages = new JeffChestSortMessages(this);
|
||||||
organizer = new JeffChestSortOrganizer(this);
|
organizer = new JeffChestSortOrganizer(this);
|
||||||
updateChecker = new JeffChestSortUpdateChecker(this);
|
updateChecker = new JeffChestSortUpdateChecker(this);
|
||||||
sortingMethod = getConfig().getString("sorting-method", "{itemsFirst},{name},{color}");
|
sortingMethod = getConfig().getString("sorting-method");
|
||||||
getServer().getPluginManager().registerEvents(new JeffChestSortListener(this), this);
|
getServer().getPluginManager().registerEvents(new JeffChestSortListener(this), this);
|
||||||
JeffChestSortCommandExecutor commandExecutor = new JeffChestSortCommandExecutor(this);
|
JeffChestSortCommandExecutor commandExecutor = new JeffChestSortCommandExecutor(this);
|
||||||
this.getCommand("chestsort").setExecutor(commandExecutor);
|
this.getCommand("chestsort").setExecutor(commandExecutor);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
getLogger().info("Current sorting method: " + sortingMethod);
|
getLogger().info("Current sorting method: " + sortingMethod);
|
||||||
|
getLogger().info("Sorting enabled by default: " + getConfig().getBoolean("sorting-enabled-by-default"));
|
||||||
if (getConfig().getInt("config-version", 0) != currentConfigVersion) {
|
getLogger().info("Auto generate category files: "+getConfig().getBoolean("auto-generate-category-files"));
|
||||||
getLogger().warning("========================================================");
|
getLogger().info("Check for updates: "+getConfig().getBoolean("check-for-updates"));
|
||||||
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() {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -104,9 +91,15 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
|||||||
private void saveDefaultCategories() {
|
private void saveDefaultCategories() {
|
||||||
String[] defaultCategories = { "900-valuables","910-tools","920-combat","930-brewing","940-food","950-redstone","960-wood","970-stone","980-plants","981-corals" };
|
String[] defaultCategories = { "900-valuables","910-tools","920-combat","930-brewing","940-food","950-redstone","960-wood","970-stone","980-plants","981-corals" };
|
||||||
|
|
||||||
|
|
||||||
|
if(getConfig().getBoolean("auto-generate-category-files",true) != true) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (String category : defaultCategories) {
|
for (String category : defaultCategories) {
|
||||||
|
|
||||||
if(debug) getLogger().info("Trying to save default category file: " + category);
|
//getLogger().info("Saving default category file: " + category);
|
||||||
|
|
||||||
FileOutputStream fopDefault = null;
|
FileOutputStream fopDefault = null;
|
||||||
File fileDefault;
|
File fileDefault;
|
||||||
@ -160,12 +153,52 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
void createConfig() {
|
void createConfig() {
|
||||||
this.saveDefaultConfig();
|
this.saveDefaultConfig();
|
||||||
|
|
||||||
|
if (getConfig().getInt("config-version", 0) < 5) {
|
||||||
|
getLogger().warning("========================================================");
|
||||||
|
getLogger().warning("You are using a config file that has been generated");
|
||||||
|
getLogger().warning("prior to ChestSort version 2.0.0.");
|
||||||
|
getLogger().warning("To allow everyone to use the new features, your config");
|
||||||
|
getLogger().warning("has been renamed to config.old.yml and a new one has");
|
||||||
|
getLogger().warning("been generated. Please examine the new config file to");
|
||||||
|
getLogger().warning("see the new possibilities and adjust your settings.");
|
||||||
|
getLogger().warning("========================================================");
|
||||||
|
|
||||||
|
|
||||||
|
File configFile = new File(getDataFolder().getAbsolutePath()+File.separator+"config.yml");
|
||||||
|
File oldConfigFile = new File(getDataFolder().getAbsolutePath()+File.separator+"config.old.yml");
|
||||||
|
if(oldConfigFile.getAbsoluteFile().exists()) {
|
||||||
|
oldConfigFile.getAbsoluteFile().delete();
|
||||||
|
}
|
||||||
|
configFile.getAbsoluteFile().renameTo(oldConfigFile.getAbsoluteFile());
|
||||||
|
saveDefaultConfig();
|
||||||
|
try {
|
||||||
|
getConfig().load(configFile.getAbsoluteFile());
|
||||||
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
|
getLogger().warning("Could not load freshly generated config file!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else 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;
|
||||||
|
}
|
||||||
|
|
||||||
File playerDataFolder = new File(getDataFolder().getPath() + File.separator + "playerdata");
|
File playerDataFolder = new File(getDataFolder().getPath() + File.separator + "playerdata");
|
||||||
if (!playerDataFolder.exists()) {
|
if (!playerDataFolder.getAbsoluteFile().exists()) {
|
||||||
|
getLogger().info("playerdata directory does not exist, creating...");
|
||||||
playerDataFolder.mkdir();
|
playerDataFolder.mkdir();
|
||||||
}
|
}
|
||||||
File categoriesFolder = new File(getDataFolder().getPath() + File.separator + "categories");
|
File categoriesFolder = new File(getDataFolder().getPath() + File.separator + "categories");
|
||||||
if (!categoriesFolder.exists()) {
|
if (!categoriesFolder.getAbsoluteFile().exists()) {
|
||||||
|
getLogger().info("categories directory does not exist, creating...");
|
||||||
categoriesFolder.mkdir();
|
categoriesFolder.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +208,7 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
|||||||
getConfig().addDefault("show-message-again-after-logout", true);
|
getConfig().addDefault("show-message-again-after-logout", true);
|
||||||
getConfig().addDefault("sorting-method", "{category},{itemsFirst},{name},{color}");
|
getConfig().addDefault("sorting-method", "{category},{itemsFirst},{name},{color}");
|
||||||
getConfig().addDefault("check-for-updates", true);
|
getConfig().addDefault("check-for-updates", true);
|
||||||
|
getConfig().addDefault("auto-generate-category-files", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unregisterPlayer(Player p) {
|
void unregisterPlayer(Player p) {
|
||||||
|
@ -13,6 +13,7 @@ tripwire_hook
|
|||||||
trapped_chest
|
trapped_chest
|
||||||
daylight_detector
|
daylight_detector
|
||||||
redstone_block
|
redstone_block
|
||||||
|
redstone_ore
|
||||||
hopper
|
hopper
|
||||||
dropper
|
dropper
|
||||||
iron_trapdoor
|
iron_trapdoor
|
||||||
|
@ -1,6 +1,22 @@
|
|||||||
stone
|
stone
|
||||||
cobblestone
|
cobblestone
|
||||||
granite
|
granite
|
||||||
|
polished_granite
|
||||||
diorite
|
diorite
|
||||||
|
polished_diorite
|
||||||
andesite
|
andesite
|
||||||
|
polished_andesite
|
||||||
*stone_bricks
|
*stone_bricks
|
||||||
|
stone_slab
|
||||||
|
cobblestone_slab
|
||||||
|
stone_brick_slab
|
||||||
|
smooth_stone
|
||||||
|
mossy_cobblestone
|
||||||
|
cobblestone_stairs
|
||||||
|
*_stone_bricks
|
||||||
|
stone_brick_stairs
|
||||||
|
cobblestone_wall
|
||||||
|
mossy_cobblestone_wall
|
||||||
|
brick_stairs
|
||||||
|
bricks
|
||||||
|
brick_slab
|
@ -26,3 +26,6 @@ rose_bush
|
|||||||
peony
|
peony
|
||||||
tall_grass
|
tall_grass
|
||||||
large_fern
|
large_fern
|
||||||
|
pumpkin
|
||||||
|
carved_pumpkin
|
||||||
|
melon
|
Loading…
Reference in New Issue
Block a user