Search in sources :

Example 1 with ConfigFile

use of dte.employme.config.ConfigFile in project EmployMe by DavidTheExplorer.

the class SimplePlayerContainerService method loadContainers.

private static void loadContainers(ConfigFile containersConfig, Map<UUID, Inventory> containersMap, Supplier<Inventory> containerCreator) {
    containersConfig.getConfig().getKeys(false).stream().map(UUID::fromString).forEach(playerUUID -> {
        Map<Integer, ItemStack> playerItems = containersConfig.getConfig().getConfigurationSection(playerUUID.toString()).getKeys(false).stream().map(Integer::parseInt).collect(toMap(Function.identity(), index -> containersConfig.getConfig().getItemStack(playerUUID + "." + index)));
        Inventory container = containerCreator.get();
        playerItems.forEach(container::setItem);
        containersMap.put(playerUUID, container);
    });
}
Also used : IntStream(java.util.stream.IntStream) ConfigFile(dte.employme.config.ConfigFile) InventoryType(org.bukkit.event.inventory.InventoryType) REWARDS_CONTAINER_DESCRIPTION(dte.employme.messages.MessageKey.REWARDS_CONTAINER_DESCRIPTION) Set(java.util.Set) IOException(java.io.IOException) HashMap(java.util.HashMap) UUID(java.util.UUID) ITEMS(dte.employme.messages.MessageKey.ITEMS) Function(java.util.function.Function) Supplier(java.util.function.Supplier) Inventory(org.bukkit.inventory.Inventory) Sets(com.google.common.collect.Sets) CONTAINER_CLAIM_INSTRUCTION(dte.employme.messages.MessageKey.CONTAINER_CLAIM_INSTRUCTION) ItemStack(org.bukkit.inventory.ItemStack) InventoryView(org.bukkit.inventory.InventoryView) MessageService(dte.employme.messages.service.MessageService) ITEMS_CONTAINER_DESCRIPTION(dte.employme.messages.MessageKey.ITEMS_CONTAINER_DESCRIPTION) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Entry(java.util.Map.Entry) REWARDS(dte.employme.messages.MessageKey.REWARDS) PlayerContainerBuilder(dte.employme.containers.PlayerContainerBuilder) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory)

Aggregations

Sets (com.google.common.collect.Sets)1 ConfigFile (dte.employme.config.ConfigFile)1 PlayerContainerBuilder (dte.employme.containers.PlayerContainerBuilder)1 CONTAINER_CLAIM_INSTRUCTION (dte.employme.messages.MessageKey.CONTAINER_CLAIM_INSTRUCTION)1 ITEMS (dte.employme.messages.MessageKey.ITEMS)1 ITEMS_CONTAINER_DESCRIPTION (dte.employme.messages.MessageKey.ITEMS_CONTAINER_DESCRIPTION)1 REWARDS (dte.employme.messages.MessageKey.REWARDS)1 REWARDS_CONTAINER_DESCRIPTION (dte.employme.messages.MessageKey.REWARDS_CONTAINER_DESCRIPTION)1 MessageService (dte.employme.messages.service.MessageService)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 IntStream (java.util.stream.IntStream)1 InventoryType (org.bukkit.event.inventory.InventoryType)1