mirror of
https://github.com/JEFF-Media-GbR/ChestSort.git
synced 2024-11-27 04:55:31 +01:00
.
This commit is contained in:
parent
caacea9a6b
commit
37dfc3ca85
@ -12,10 +12,36 @@ public class JeffChestSortCategory {
|
||||
|
||||
public boolean matches(String itemname) {
|
||||
|
||||
boolean asteriskBefore = false;
|
||||
boolean asteriskAfter = false;
|
||||
|
||||
for(String typeMatch : typeMatches) {
|
||||
if(typeMatch.startsWith("*")) {
|
||||
asteriskBefore = true;
|
||||
typeMatch=typeMatch.substring(1);
|
||||
}
|
||||
if(typeMatch.endsWith("*")) {
|
||||
asteriskAfter = true;
|
||||
typeMatch=typeMatch.substring(0, typeMatch.length()-1);
|
||||
}
|
||||
|
||||
if(asteriskBefore == false && asteriskAfter == false) {
|
||||
if(itemname.equalsIgnoreCase(typeMatch)) {
|
||||
return true;
|
||||
}
|
||||
} else if(asteriskBefore == true && asteriskAfter == true) {
|
||||
if(itemname.contains(typeMatch)) {
|
||||
return true;
|
||||
}
|
||||
} else if(asteriskBefore == true && asteriskAfter == false) {
|
||||
if(itemname.endsWith(typeMatch)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if(itemname.startsWith(typeMatch)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -16,25 +16,19 @@ public class JeffChestSortOrganizer {
|
||||
|
||||
String[] colors = { "white", "orange", "magenta", "light_blue", "light_gray", "yellow", "lime", "pink", "gray",
|
||||
"cyan", "purple", "blue", "brown", "green", "red", "black" };
|
||||
String[] woodNames = { "acacia", "birch", "jungle", "oak", "spruce", "dark_oak" };
|
||||
|
||||
ArrayList<JeffChestSortCategory> categories = new ArrayList<JeffChestSortCategory>();
|
||||
|
||||
String[] woodBlocks = { "_log", "_wood", "_planks", "acacia_", "oak_", "birch_", "jungle_", "dark_oak_",
|
||||
"spruce_" };
|
||||
String[] redstone = { "dispenser","note_block","sticky_piston","piston","tnt","lever","_pressure_plate","redstone", "_button","tripwire","trapped_chest","daylight_detector","hopper","dropper","observer","iron_trapdoor","iron_door","repeater","comparator","powered_rail","detector_rail","rail","activator_rail","minecart" };
|
||||
String[] food = { "apple", "baked_potato", "beef", "beetroot", "beetroot_soup", "bread", "mushroom_stew",
|
||||
"porkchop", "cooked_porkchop", "cod", "salmon", "cooked_cod", "cooked_salmon", "cake", "cookie",
|
||||
"melon_slice", "dried_kelp", "cooked_beef", "chicken", "cooked_chicken", "carrot", "potato", "pumpkin_pie",
|
||||
"rabbit", "cooked_rabbit", "rabbit_stew", "mutton", "cooked_mutton" };
|
||||
String[] combat = { "turtle_helmet","bow","arrow","_sword","_helmet","_chestplate","_leggings","_boots","spectral_arrow","tipped_arrow","shield","totem_of_undying","trident"};
|
||||
|
||||
String[] plants = { "_sapling","_leaves","grass","fern","dead_bush","seagrass","sea_pickle","dandelion","poppy","blue_orchid","allium","azure_bluet","red_tulip","orange_tulip","white_tulip","pink_tulip","oxeye_daisy","brown_mushroom","red_mushroom","chorus_plant","chorus_flower","cactus","brown_mushroom_block","red_mushroom_block","mushroom_stem","vine","lily_pad","sunflower","lilac","rose_bush","peony","tall_grass","large_fern","_coral","flower_pot"};
|
||||
public JeffChestSortOrganizer(JeffChestSortPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
//categories.add(new JeffChestSortCategory("tools", tools));
|
||||
//categories.add(new JeffChestSortCategory("loot", loot));
|
||||
//categories.add(new JeffChestSortCategory("wood_blocks", woodBlocks));
|
||||
|
||||
// Load Categories
|
||||
File categoriesFolder = new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "categories" + File.separator);
|
||||
@ -60,8 +54,10 @@ public class JeffChestSortOrganizer {
|
||||
Scanner sc = new Scanner(file);
|
||||
List<String> lines = new ArrayList<String>();
|
||||
while (sc.hasNextLine()) {
|
||||
if(!sc.nextLine().startsWith("#")) {
|
||||
lines.add(sc.nextLine());
|
||||
}
|
||||
}
|
||||
|
||||
String[] arr = lines.toArray(new String[0]);
|
||||
sc.close();
|
||||
@ -71,6 +67,9 @@ public class JeffChestSortOrganizer {
|
||||
|
||||
String[] getTypeAndColor(String typeName) {
|
||||
|
||||
// [0] = TypeName
|
||||
// [1] = Color
|
||||
|
||||
String myColor = "<none>";
|
||||
typeName = typeName.toLowerCase();
|
||||
|
||||
@ -81,6 +80,13 @@ public class JeffChestSortOrganizer {
|
||||
}
|
||||
}
|
||||
|
||||
for(String woodName : woodNames) {
|
||||
if(typeName.startsWith(woodName)) {
|
||||
typeName = typeName.replaceFirst(woodName+"_", "");
|
||||
myColor = woodName;
|
||||
}
|
||||
}
|
||||
|
||||
// Wool (sort by color)
|
||||
/*
|
||||
* if(typeName.endsWith("_wool")) {
|
||||
|
@ -9,6 +9,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -29,6 +30,9 @@ public class JeffChestSortPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
for(Material mat : Material.values()) {
|
||||
System.out.println(mat.name().toLowerCase());
|
||||
}
|
||||
createConfig();
|
||||
saveDefaultCategories();
|
||||
messages = new JeffChestSortMessages(this);
|
||||
|
@ -1,3 +1,7 @@
|
||||
# Names have to match exactly, except one exception:
|
||||
# Color names HAVE to be ommited!
|
||||
# Do not write white_bed, but just bed.
|
||||
# Lines starting with a hashtag are ignored.
|
||||
diamond
|
||||
emerald
|
||||
diamond_ore
|
||||
|
Loading…
Reference in New Issue
Block a user