Hello so I have this config sample Code (Java): Config: s: true String parent = // how to get the String "Config" as s parent ?
well at this config sample the parent config tree of s is the Config I wanted to get the parent of s as a string. String sample = // must be return to "Config";
What are you trying to do, Are you just trying to get all of the keys of a config? Like, What keys do you want out of this config. Code (Text): Ob1: tag1: data: "datatest1" Ob2: tag2: data: "testdata"
yeah like that Code (Java): Ob1: tag1: ItemStack: value tag2: ItemStack: value well I'm getting the value of Ob1 config section + ".ItemStack"; // just to check if the result on the crafting event is the itemstack in the config. now I'm trying to get the Ob1 (Parent) as a string so I can do permission something like craft.<ParentName>
yes in craft event I want to check if the result is equals to Code (Java): Set<String> set = Config#getConfigurationSection(Ob1).getKeys(false); then getting the ItemStack by using Code (Java): ItemStack stack = set + ".ItemStack"; then checking if they have permission craft.Ob1; this is what I'm trying to do.
You can get the file path, so if you have your Configuration Section object still you can use Code (Text): config.getConfigurationSection("foo.foo2").getCurrentPath(); and if you need to split out just your ob1 use String#.split('.'); and it converts it to an array.
Code (Java): config.getConfigurationSection("foo.foo2").getCurrentPath(); foo.foo2 returns to the path where they are ? example Code (Java): Obj1: // is this where the config section foo.foo2 currentpath? foo: foo2:
You Already have the Ob1 path when you search for the keys, I am still unsure what you are asking, Because .getParent() was not what you where looking for or .getRoot();
let me try that how about this ? Code (Java): Set<String> s : Config#getConfigurationSection(" ").getKeys(false); ConfigurationSection section = Config#getConfigurationSection(s + ".ItemStack").getParent(); String parentname section.toString(); // config.yml Code (Java): Name: ItemStack: value
Config Code (Text): Items: Name1: Item: Name2: Item: Code (Text): Set<String> s = config.getConfigurationSection("Items").getKeys(false); for(String key :s){ if(isItem(s)){ System.out.println(key); System.out.println(config.getItemStack("Items."+ key +"Item")); } } Is this what you are asking, ?
well I have this kind of config Code (Java): MadMax: Input: ==: org.bukkit.inventory.ItemStack type: LOG amount: 4 Product: ==: org.bukkit.inventory.ItemStack type: STONE Enabled: true Type: Furnace craft: Slot4: ==: org.bukkit.inventory.ItemStack type: CHEST Slot5: ==: org.bukkit.inventory.ItemStack type: CHEST Slot6: ==: org.bukkit.inventory.ItemStack type: CHEST Product: ==: org.bukkit.inventory.ItemStack type: WORKBENCH amount: 2 Enabled: true Type: Shaped woodpecker: Slot2: ==: org.bukkit.inventory.ItemStack type: WOOD damage: 1 Slot4: ==: org.bukkit.inventory.ItemStack type: WOOD damage: 1 Slot5: ==: org.bukkit.inventory.ItemStack type: WOOD damage: 1 Slot6: ==: org.bukkit.inventory.ItemStack type: WOOD damage: 1 Slot8: ==: org.bukkit.inventory.ItemStack type: WOOD damage: 1 Product: ==: org.bukkit.inventory.ItemStack type: WOOD damage: 1 amount: 2 meta: ==: ItemMeta meta-type: UNSPECIFIC display-name: WoodPecker Enabled: true Type: Shaped redblock: Slot4: ==: org.bukkit.inventory.ItemStack type: REDSTONE_BLOCK amount: 2 Slot5: ==: org.bukkit.inventory.ItemStack type: REDSTONE_BLOCK amount: 2 Product: ==: org.bukkit.inventory.ItemStack type: REDSTONE amount: 4 Enabled: true Type: Shaped Set<String> s = Config#getKeys(false); then I'm checking at the craft event if the result is equals to the itemstack s + ".Product"; and has the permission for example craft.redblock