repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
Nedelosk/OreRegistry
src/main/java/oreregistry/util/ProductUtils.java
// Path: src/main/java/oreregistry/OreRegistry.java // @Mod(modid = Constants.MOD_ID, name = Constants.NAME, version = Constants.VERSION, acceptedMinecraftVersions = "[1.11]") // public class OreRegistry { // // @Nullable // @Mod.Instance(Constants.MOD_ID) // public static OreRegistry instance; // // public static final ResourceRegistry registry; // public static final ResourceInfo helper; // public static final List<ItemStack> unusedItems = new ArrayList<>(); // @Nullable // public static File configFile; // // static { // OreRegistryApi.registry = registry = new ResourceRegistry(); // OreRegistryApi.info = helper = new ResourceInfo(); // } // // @Mod.EventHandler // public void preInit(FMLPreInitializationEvent event) { // registerVanilla(OreRegistryApi.registry); // MinecraftForge.EVENT_BUS.register(new EventHandler()); // new PacketHandler(); // configFile = event.getSuggestedConfigurationFile(); // } // // @Mod.EventHandler // public void init(FMLInitializationEvent event) { // Config.load(event.getSide()); // } // // private void registerVanilla(IResourceRegistry resourceRegistry) { // final IResource iron = resourceRegistry.registerResource(ResourceTypes.IRON); // iron.registerProduct(INGOT, new ItemStack(Items.IRON_INGOT)); // iron.registerProduct(NUGGET, new ItemStack(Items.field_191525_da)); // iron.registerProduct(BLOCK, new ItemStack(Blocks.IRON_BLOCK)); // iron.registerProduct(ORE, new ItemStack(Blocks.IRON_ORE)); // // final IResource gold = resourceRegistry.registerResource(ResourceTypes.GOLD); // gold.registerProduct(INGOT, new ItemStack(Items.GOLD_INGOT)); // gold.registerProduct(NUGGET, new ItemStack(Items.GOLD_NUGGET)); // gold.registerProduct(BLOCK, new ItemStack(Blocks.GOLD_BLOCK)); // gold.registerProduct(ORE, new ItemStack(Blocks.GOLD_ORE)); // // final IResource emerald = resourceRegistry.registerResource(ResourceTypes.EMERALD); // emerald.registerProduct(GEM, new ItemStack(Items.EMERALD)); // emerald.registerProduct(BLOCK, new ItemStack(Blocks.EMERALD_BLOCK)); // emerald.registerProduct(ORE, new ItemStack(Blocks.EMERALD_ORE)); // // final IResource diamond = resourceRegistry.registerResource(ResourceTypes.DIAMOND); // diamond.registerProduct(GEM, new ItemStack(Items.DIAMOND)); // diamond.registerProduct(BLOCK, new ItemStack(Blocks.DIAMOND_BLOCK)); // diamond.registerProduct(ORE, new ItemStack(Blocks.DIAMOND_ORE)); // // final IResource lapis = resourceRegistry.registerResource(ResourceTypes.LAPIS); // lapis.registerProduct(GEM, new ItemStack(Items.DYE, 1, EnumDyeColor.BLUE.getDyeDamage())); // lapis.registerProduct(BLOCK, new ItemStack(Blocks.LAPIS_BLOCK)); // lapis.registerProduct(ORE, new ItemStack(Blocks.LAPIS_ORE)); // // final IResource redstone = resourceRegistry.registerResource(ResourceTypes.REDSTONE); // redstone.registerProduct(DUST, new ItemStack(Items.REDSTONE)); // redstone.registerProduct(BLOCK, new ItemStack(Blocks.REDSTONE_BLOCK)); // redstone.registerProduct(ORE, new ItemStack(Blocks.REDSTONE_ORE)); // // final IResource quartz = resourceRegistry.registerResource(ResourceTypes.QUARTZ); // quartz.registerProduct(GEM, new ItemStack(Items.QUARTZ)); // quartz.registerProduct(BLOCK, new ItemStack(Blocks.QUARTZ_BLOCK)); // quartz.registerProduct(ORE, new ItemStack(Blocks.QUARTZ_ORE)); // // final IResource coal = resourceRegistry.registerResource(ResourceTypes.COAL); // coal.registerProduct(GEM, new ItemStack(Items.COAL)); // coal.registerProduct(BLOCK, new ItemStack(Blocks.COAL_BLOCK)); // coal.registerProduct(ORE, new ItemStack(Blocks.COAL_ORE)); // } // // public File getConfigFile(){ // return configFile; // } // }
import net.minecraft.item.ItemStack; import oreregistry.OreRegistry; import java.util.List;
/* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.util; public class ProductUtils { public static void chooseProduct(Product product, int variantIndex){ List<ItemStack> variants = product.getVariants(); if(variantIndex >= variants.size()){ variantIndex = variants.size(); } for(int i = 0;i < variants.size();i++){ ItemStack variant = variants.get(i); if(i == variantIndex){ product.choseProduct(variant, variantIndex); }else {
// Path: src/main/java/oreregistry/OreRegistry.java // @Mod(modid = Constants.MOD_ID, name = Constants.NAME, version = Constants.VERSION, acceptedMinecraftVersions = "[1.11]") // public class OreRegistry { // // @Nullable // @Mod.Instance(Constants.MOD_ID) // public static OreRegistry instance; // // public static final ResourceRegistry registry; // public static final ResourceInfo helper; // public static final List<ItemStack> unusedItems = new ArrayList<>(); // @Nullable // public static File configFile; // // static { // OreRegistryApi.registry = registry = new ResourceRegistry(); // OreRegistryApi.info = helper = new ResourceInfo(); // } // // @Mod.EventHandler // public void preInit(FMLPreInitializationEvent event) { // registerVanilla(OreRegistryApi.registry); // MinecraftForge.EVENT_BUS.register(new EventHandler()); // new PacketHandler(); // configFile = event.getSuggestedConfigurationFile(); // } // // @Mod.EventHandler // public void init(FMLInitializationEvent event) { // Config.load(event.getSide()); // } // // private void registerVanilla(IResourceRegistry resourceRegistry) { // final IResource iron = resourceRegistry.registerResource(ResourceTypes.IRON); // iron.registerProduct(INGOT, new ItemStack(Items.IRON_INGOT)); // iron.registerProduct(NUGGET, new ItemStack(Items.field_191525_da)); // iron.registerProduct(BLOCK, new ItemStack(Blocks.IRON_BLOCK)); // iron.registerProduct(ORE, new ItemStack(Blocks.IRON_ORE)); // // final IResource gold = resourceRegistry.registerResource(ResourceTypes.GOLD); // gold.registerProduct(INGOT, new ItemStack(Items.GOLD_INGOT)); // gold.registerProduct(NUGGET, new ItemStack(Items.GOLD_NUGGET)); // gold.registerProduct(BLOCK, new ItemStack(Blocks.GOLD_BLOCK)); // gold.registerProduct(ORE, new ItemStack(Blocks.GOLD_ORE)); // // final IResource emerald = resourceRegistry.registerResource(ResourceTypes.EMERALD); // emerald.registerProduct(GEM, new ItemStack(Items.EMERALD)); // emerald.registerProduct(BLOCK, new ItemStack(Blocks.EMERALD_BLOCK)); // emerald.registerProduct(ORE, new ItemStack(Blocks.EMERALD_ORE)); // // final IResource diamond = resourceRegistry.registerResource(ResourceTypes.DIAMOND); // diamond.registerProduct(GEM, new ItemStack(Items.DIAMOND)); // diamond.registerProduct(BLOCK, new ItemStack(Blocks.DIAMOND_BLOCK)); // diamond.registerProduct(ORE, new ItemStack(Blocks.DIAMOND_ORE)); // // final IResource lapis = resourceRegistry.registerResource(ResourceTypes.LAPIS); // lapis.registerProduct(GEM, new ItemStack(Items.DYE, 1, EnumDyeColor.BLUE.getDyeDamage())); // lapis.registerProduct(BLOCK, new ItemStack(Blocks.LAPIS_BLOCK)); // lapis.registerProduct(ORE, new ItemStack(Blocks.LAPIS_ORE)); // // final IResource redstone = resourceRegistry.registerResource(ResourceTypes.REDSTONE); // redstone.registerProduct(DUST, new ItemStack(Items.REDSTONE)); // redstone.registerProduct(BLOCK, new ItemStack(Blocks.REDSTONE_BLOCK)); // redstone.registerProduct(ORE, new ItemStack(Blocks.REDSTONE_ORE)); // // final IResource quartz = resourceRegistry.registerResource(ResourceTypes.QUARTZ); // quartz.registerProduct(GEM, new ItemStack(Items.QUARTZ)); // quartz.registerProduct(BLOCK, new ItemStack(Blocks.QUARTZ_BLOCK)); // quartz.registerProduct(ORE, new ItemStack(Blocks.QUARTZ_ORE)); // // final IResource coal = resourceRegistry.registerResource(ResourceTypes.COAL); // coal.registerProduct(GEM, new ItemStack(Items.COAL)); // coal.registerProduct(BLOCK, new ItemStack(Blocks.COAL_BLOCK)); // coal.registerProduct(ORE, new ItemStack(Blocks.COAL_ORE)); // } // // public File getConfigFile(){ // return configFile; // } // } // Path: src/main/java/oreregistry/util/ProductUtils.java import net.minecraft.item.ItemStack; import oreregistry.OreRegistry; import java.util.List; /* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.util; public class ProductUtils { public static void chooseProduct(Product product, int variantIndex){ List<ItemStack> variants = product.getVariants(); if(variantIndex >= variants.size()){ variantIndex = variants.size(); } for(int i = 0;i < variants.size();i++){ ItemStack variant = variants.get(i); if(i == variantIndex){ product.choseProduct(variant, variantIndex); }else {
OreRegistry.unusedItems.add(variant.copy());
Nedelosk/OreRegistry
src/main/java/oreregistry/api/registry/IResourceRegistry.java
// Path: src/main/java/oreregistry/api/IUnificationHandler.java // @FunctionalInterface // public interface IUnificationHandler { // // void onUnifyItem(ItemStack oldStack, ItemStack newStack, IProduct product); // } // // Path: src/main/java/oreregistry/api/OreRegistryApi.java // public class OreRegistryApi { // // /** // * Register resources and get the chosen resource for each type. // */ // public static IResourceRegistry registry; // // /** // * Get information about registered products. // */ // public static IResourceInfo info; // // } // // Path: src/main/java/oreregistry/api/OreRegistryState.java // public enum OreRegistryState { // /** // * This state is active if in the pre init phase of fml. // */ // ACTIVE, // /** // * This state is always active after the pre init phase of fml except the mod chooses currently his products or its currently synchronises with the server. // */ // INACTIVE, // /** // * This state is active if the client currently synchronises with the server. // */ // SYNCHRONIZE, // /** // * This state is active if the mod currently chooses the products. // */ // CHOOSE // // }
import java.util.Collection; import java.util.Map; import oreregistry.api.IUnificationHandler; import oreregistry.api.OreRegistryApi; import oreregistry.api.OreRegistryState;
/* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.api.registry; /** * Register resources and get the chosen resource for each type. * <p> * Get the instance from {@link OreRegistryApi#registry}. */ public interface IResourceRegistry { /** * Register a type of resource added by your mod. */ IResource registerResource(String resourceType); /** * Returns a read-only map containing resource names and their associated * resources. */ Map<String, IResource> getRegisteredResources(); /** * Register a {@link IUnificationHandler}. */
// Path: src/main/java/oreregistry/api/IUnificationHandler.java // @FunctionalInterface // public interface IUnificationHandler { // // void onUnifyItem(ItemStack oldStack, ItemStack newStack, IProduct product); // } // // Path: src/main/java/oreregistry/api/OreRegistryApi.java // public class OreRegistryApi { // // /** // * Register resources and get the chosen resource for each type. // */ // public static IResourceRegistry registry; // // /** // * Get information about registered products. // */ // public static IResourceInfo info; // // } // // Path: src/main/java/oreregistry/api/OreRegistryState.java // public enum OreRegistryState { // /** // * This state is active if in the pre init phase of fml. // */ // ACTIVE, // /** // * This state is always active after the pre init phase of fml except the mod chooses currently his products or its currently synchronises with the server. // */ // INACTIVE, // /** // * This state is active if the client currently synchronises with the server. // */ // SYNCHRONIZE, // /** // * This state is active if the mod currently chooses the products. // */ // CHOOSE // // } // Path: src/main/java/oreregistry/api/registry/IResourceRegistry.java import java.util.Collection; import java.util.Map; import oreregistry.api.IUnificationHandler; import oreregistry.api.OreRegistryApi; import oreregistry.api.OreRegistryState; /* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.api.registry; /** * Register resources and get the chosen resource for each type. * <p> * Get the instance from {@link OreRegistryApi#registry}. */ public interface IResourceRegistry { /** * Register a type of resource added by your mod. */ IResource registerResource(String resourceType); /** * Returns a read-only map containing resource names and their associated * resources. */ Map<String, IResource> getRegisteredResources(); /** * Register a {@link IUnificationHandler}. */
void registerUnificationHandler(String resourceType, IUnificationHandler unificationHandler);
Nedelosk/OreRegistry
src/main/java/oreregistry/api/registry/IResourceRegistry.java
// Path: src/main/java/oreregistry/api/IUnificationHandler.java // @FunctionalInterface // public interface IUnificationHandler { // // void onUnifyItem(ItemStack oldStack, ItemStack newStack, IProduct product); // } // // Path: src/main/java/oreregistry/api/OreRegistryApi.java // public class OreRegistryApi { // // /** // * Register resources and get the chosen resource for each type. // */ // public static IResourceRegistry registry; // // /** // * Get information about registered products. // */ // public static IResourceInfo info; // // } // // Path: src/main/java/oreregistry/api/OreRegistryState.java // public enum OreRegistryState { // /** // * This state is active if in the pre init phase of fml. // */ // ACTIVE, // /** // * This state is always active after the pre init phase of fml except the mod chooses currently his products or its currently synchronises with the server. // */ // INACTIVE, // /** // * This state is active if the client currently synchronises with the server. // */ // SYNCHRONIZE, // /** // * This state is active if the mod currently chooses the products. // */ // CHOOSE // // }
import java.util.Collection; import java.util.Map; import oreregistry.api.IUnificationHandler; import oreregistry.api.OreRegistryApi; import oreregistry.api.OreRegistryState;
/* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.api.registry; /** * Register resources and get the chosen resource for each type. * <p> * Get the instance from {@link OreRegistryApi#registry}. */ public interface IResourceRegistry { /** * Register a type of resource added by your mod. */ IResource registerResource(String resourceType); /** * Returns a read-only map containing resource names and their associated * resources. */ Map<String, IResource> getRegisteredResources(); /** * Register a {@link IUnificationHandler}. */ void registerUnificationHandler(String resourceType, IUnificationHandler unificationHandler); /** * Returns a read-only map containing all {@link IUnificationHandler}s of the resource of this type. */ Collection<IUnificationHandler> getUnificationHandlers(String resourceType); /** * The current state of the registry process. * * You only can register resources and products in the active state. */
// Path: src/main/java/oreregistry/api/IUnificationHandler.java // @FunctionalInterface // public interface IUnificationHandler { // // void onUnifyItem(ItemStack oldStack, ItemStack newStack, IProduct product); // } // // Path: src/main/java/oreregistry/api/OreRegistryApi.java // public class OreRegistryApi { // // /** // * Register resources and get the chosen resource for each type. // */ // public static IResourceRegistry registry; // // /** // * Get information about registered products. // */ // public static IResourceInfo info; // // } // // Path: src/main/java/oreregistry/api/OreRegistryState.java // public enum OreRegistryState { // /** // * This state is active if in the pre init phase of fml. // */ // ACTIVE, // /** // * This state is always active after the pre init phase of fml except the mod chooses currently his products or its currently synchronises with the server. // */ // INACTIVE, // /** // * This state is active if the client currently synchronises with the server. // */ // SYNCHRONIZE, // /** // * This state is active if the mod currently chooses the products. // */ // CHOOSE // // } // Path: src/main/java/oreregistry/api/registry/IResourceRegistry.java import java.util.Collection; import java.util.Map; import oreregistry.api.IUnificationHandler; import oreregistry.api.OreRegistryApi; import oreregistry.api.OreRegistryState; /* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.api.registry; /** * Register resources and get the chosen resource for each type. * <p> * Get the instance from {@link OreRegistryApi#registry}. */ public interface IResourceRegistry { /** * Register a type of resource added by your mod. */ IResource registerResource(String resourceType); /** * Returns a read-only map containing resource names and their associated * resources. */ Map<String, IResource> getRegisteredResources(); /** * Register a {@link IUnificationHandler}. */ void registerUnificationHandler(String resourceType, IUnificationHandler unificationHandler); /** * Returns a read-only map containing all {@link IUnificationHandler}s of the resource of this type. */ Collection<IUnificationHandler> getUnificationHandlers(String resourceType); /** * The current state of the registry process. * * You only can register resources and products in the active state. */
OreRegistryState getState();
Nedelosk/OreRegistry
src/main/java/oreregistry/api/IUnificationHandler.java
// Path: src/main/java/oreregistry/api/registry/IProduct.java // public interface IProduct { // // /** // * The type of the product. For examples see {@link ProductTypes}. // */ // String getType(); // // /** // * @return A list with all registered variants of this product. // */ // List<ItemStack> getVariants(); // // /** // * @return A copy of the chosen product. // */ // ItemStack getChosenProduct(); // // /** // * @return The resource of this product. // */ // IResource getResource(); // // } // // Path: src/main/java/oreregistry/api/registry/IResourceRegistry.java // public interface IResourceRegistry { // // /** // * Register a type of resource added by your mod. // */ // IResource registerResource(String resourceType); // // /** // * Returns a read-only map containing resource names and their associated // * resources. // */ // Map<String, IResource> getRegisteredResources(); // // /** // * Register a {@link IUnificationHandler}. // */ // void registerUnificationHandler(String resourceType, IUnificationHandler unificationHandler); // // /** // * Returns a read-only map containing all {@link IUnificationHandler}s of the resource of this type. // */ // Collection<IUnificationHandler> getUnificationHandlers(String resourceType); // // /** // * The current state of the registry process. // * // * You only can register resources and products in the active state. // */ // OreRegistryState getState(); // // }
import oreregistry.api.registry.IProduct; import oreregistry.api.registry.IResourceRegistry; import net.minecraft.item.ItemStack;
/* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.api; /** * This can be used to unify items. * <p> * You can register this handler with {@link IResourceRegistry#registerUnificationHandler(String, IUnificationHandler)} * and get all handlers of a resource with {@link IResourceRegistry#getUnificationHandlers(String)}. */ @FunctionalInterface public interface IUnificationHandler {
// Path: src/main/java/oreregistry/api/registry/IProduct.java // public interface IProduct { // // /** // * The type of the product. For examples see {@link ProductTypes}. // */ // String getType(); // // /** // * @return A list with all registered variants of this product. // */ // List<ItemStack> getVariants(); // // /** // * @return A copy of the chosen product. // */ // ItemStack getChosenProduct(); // // /** // * @return The resource of this product. // */ // IResource getResource(); // // } // // Path: src/main/java/oreregistry/api/registry/IResourceRegistry.java // public interface IResourceRegistry { // // /** // * Register a type of resource added by your mod. // */ // IResource registerResource(String resourceType); // // /** // * Returns a read-only map containing resource names and their associated // * resources. // */ // Map<String, IResource> getRegisteredResources(); // // /** // * Register a {@link IUnificationHandler}. // */ // void registerUnificationHandler(String resourceType, IUnificationHandler unificationHandler); // // /** // * Returns a read-only map containing all {@link IUnificationHandler}s of the resource of this type. // */ // Collection<IUnificationHandler> getUnificationHandlers(String resourceType); // // /** // * The current state of the registry process. // * // * You only can register resources and products in the active state. // */ // OreRegistryState getState(); // // } // Path: src/main/java/oreregistry/api/IUnificationHandler.java import oreregistry.api.registry.IProduct; import oreregistry.api.registry.IResourceRegistry; import net.minecraft.item.ItemStack; /* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.api; /** * This can be used to unify items. * <p> * You can register this handler with {@link IResourceRegistry#registerUnificationHandler(String, IUnificationHandler)} * and get all handlers of a resource with {@link IResourceRegistry#getUnificationHandlers(String)}. */ @FunctionalInterface public interface IUnificationHandler {
void onUnifyItem(ItemStack oldStack, ItemStack newStack, IProduct product);
Nedelosk/OreRegistry
src/main/java/oreregistry/util/Log.java
// Path: src/main/java/oreregistry/config/Constants.java // public class Constants { // // public static final String NAME = "Ore Registry"; // public static final String MOD_ID = "oreregistry"; // // public static final String VERSION = "@VERSION@"; // public static final String BUILD_NUMBER = "@BUILD_NUMBER@"; // // }
import org.apache.logging.log4j.LogManager; import oreregistry.config.Constants; import org.apache.logging.log4j.Level;
/* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.util; public class Log { private static void log(Level logLevel, String message, Object... params) {
// Path: src/main/java/oreregistry/config/Constants.java // public class Constants { // // public static final String NAME = "Ore Registry"; // public static final String MOD_ID = "oreregistry"; // // public static final String VERSION = "@VERSION@"; // public static final String BUILD_NUMBER = "@BUILD_NUMBER@"; // // } // Path: src/main/java/oreregistry/util/Log.java import org.apache.logging.log4j.LogManager; import oreregistry.config.Constants; import org.apache.logging.log4j.Level; /* * Copyright (c) 2017 Nedelosk, Mezz * * This work (the MOD) is licensed under the "MIT" License, see LICENSE for details. */ package oreregistry.util; public class Log { private static void log(Level logLevel, String message, Object... params) {
LogManager.getLogger(Constants.MOD_ID).log(logLevel, message, params);
algorhythms/LeetCode-Java
src/BinaryTreeMaximumPathSum/Solution.java
// Path: src/commons/datastructures/TreeNode.java // public class TreeNode { // public int val; // public TreeNode left; // public TreeNode right; // public TreeNode(int x) { // val = x; // } // // @Override // public String toString() { // return "TreeNode{" + // "val=" + val + // '}'; // } // }
import commons.datastructures.TreeNode;
package BinaryTreeMaximumPathSum; /** * User: Danyang * Date: 1/27/2015 * Time: 21:18 * * Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / \ 2 3 Return 6. */ public class Solution { int gmax = Integer.MIN_VALUE; /** * Notice: * 1. max path end with a node * 2. global max may cross a node * @param root * @return */
// Path: src/commons/datastructures/TreeNode.java // public class TreeNode { // public int val; // public TreeNode left; // public TreeNode right; // public TreeNode(int x) { // val = x; // } // // @Override // public String toString() { // return "TreeNode{" + // "val=" + val + // '}'; // } // } // Path: src/BinaryTreeMaximumPathSum/Solution.java import commons.datastructures.TreeNode; package BinaryTreeMaximumPathSum; /** * User: Danyang * Date: 1/27/2015 * Time: 21:18 * * Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / \ 2 3 Return 6. */ public class Solution { int gmax = Integer.MIN_VALUE; /** * Notice: * 1. max path end with a node * 2. global max may cross a node * @param root * @return */
public int maxPathSum(TreeNode root) {
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/slimecrucible/TileEntitySlimeCrucible.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import javax.annotation.Nullable; import net.darkhax.bookshelf.block.tileentity.TileEntityBasicTickable; import net.darkhax.bookshelf.util.WorldUtils; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.Block; import net.minecraft.block.ComposterBlock; import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.INameable; import net.minecraft.util.IWorldPosCallable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants.NBT;
package net.darkhax.darkutils.features.slimecrucible; public class TileEntitySlimeCrucible extends TileEntityBasicTickable implements INamedContainerProvider, INameable { /** * A custom display name for the slime crucible. */ private ITextComponent customName; /** * The stored amount of slime points. */ private int slimePoints = 0; /** * The direction the slime entity should be facing. */ private Direction sideToFace = Direction.SOUTH; /** * The height offset of the contained slime entity. */ private double slimeHeightOffset = 0.2f; /** * The squish factor of the slime entity. */ private float squishFactor = 0f; /** * The previous squish factor. */ private float prevSquishFactor = 0f; /** * The remaining amount of squish. */ private float squishAmount = 0f; /** * The contained slime entity. */ private SlimeEntity entity; public TileEntitySlimeCrucible() {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/TileEntitySlimeCrucible.java import javax.annotation.Nullable; import net.darkhax.bookshelf.block.tileentity.TileEntityBasicTickable; import net.darkhax.bookshelf.util.WorldUtils; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.Block; import net.minecraft.block.ComposterBlock; import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.INameable; import net.minecraft.util.IWorldPosCallable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants.NBT; package net.darkhax.darkutils.features.slimecrucible; public class TileEntitySlimeCrucible extends TileEntityBasicTickable implements INamedContainerProvider, INameable { /** * A custom display name for the slime crucible. */ private ITextComponent customName; /** * The stored amount of slime points. */ private int slimePoints = 0; /** * The direction the slime entity should be facing. */ private Direction sideToFace = Direction.SOUTH; /** * The height offset of the contained slime entity. */ private double slimeHeightOffset = 0.2f; /** * The squish factor of the slime entity. */ private float squishFactor = 0f; /** * The previous squish factor. */ private float prevSquishFactor = 0f; /** * The remaining amount of squish. */ private float squishAmount = 0f; /** * The contained slime entity. */ private SlimeEntity entity; public TileEntitySlimeCrucible() {
super(DarkUtils.content.tileSlimeCrucible);
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/slimecrucible/BlockSlimeCrucible.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.block.ContainerBlock; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.particles.ItemParticleData; import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.shapes.IBooleanFunction; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld;
@Override public boolean onBlockActivated (BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { final TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileEntitySlimeCrucible) { final TileEntitySlimeCrucible crucible = (TileEntitySlimeCrucible) tile; final ItemStack heldItem = player.getHeldItem(handIn); final int points = TileEntitySlimeCrucible.getSlimePointsForItem(world, heldItem, this.type); // If the item can be eaten, try to eat the item and modify the state of the // crucible. if (points > 0 && crucible.getContainedSlimePoints() <= this.getCrucibleType().getMaxSlimePoints()) { // Increases the slime points. crucible.addSlimePoints(points); if (world instanceof ServerWorld) { final ServerWorld serverWorld = (ServerWorld) world; // Spawns food eating particles. for (int i = 0; i < 16; i++) { serverWorld.spawnParticle(new ItemParticleData(ParticleTypes.ITEM, heldItem), pos.getX() + 0.5d, pos.getY() + 1.25d, pos.getZ() + 0.5d, 1, world.rand.nextDouble() * 0.45 - 0.45, 0d, world.rand.nextDouble() * 0.45 - 0.45, 0d); }
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/BlockSlimeCrucible.java import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; import net.minecraft.block.ContainerBlock; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.particles.ItemParticleData; import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.shapes.IBooleanFunction; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; @Override public boolean onBlockActivated (BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { final TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileEntitySlimeCrucible) { final TileEntitySlimeCrucible crucible = (TileEntitySlimeCrucible) tile; final ItemStack heldItem = player.getHeldItem(handIn); final int points = TileEntitySlimeCrucible.getSlimePointsForItem(world, heldItem, this.type); // If the item can be eaten, try to eat the item and modify the state of the // crucible. if (points > 0 && crucible.getContainedSlimePoints() <= this.getCrucibleType().getMaxSlimePoints()) { // Increases the slime points. crucible.addSlimePoints(points); if (world instanceof ServerWorld) { final ServerWorld serverWorld = (ServerWorld) world; // Spawns food eating particles. for (int i = 0; i < 16; i++) { serverWorld.spawnParticle(new ItemParticleData(ParticleTypes.ITEM, heldItem), pos.getX() + 0.5d, pos.getY() + 1.25d, pos.getZ() + 0.5d, 1, world.rand.nextDouble() * 0.45 - 0.45, 0d, world.rand.nextDouble() * 0.45 - 0.45, 0d); }
player.addStat(DarkUtils.content.statSlimeCrucibleFeed);
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/flatblocks/TileEntityTickingEffect.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import net.darkhax.darkutils.DarkUtils; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos;
package net.darkhax.darkutils.features.flatblocks; public class TileEntityTickingEffect extends TileEntity implements ITickableTileEntity { private byte timer; public TileEntityTickingEffect() {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/flatblocks/TileEntityTickingEffect.java import net.darkhax.darkutils.DarkUtils; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; package net.darkhax.darkutils.features.flatblocks; public class TileEntityTickingEffect extends TileEntity implements ITickableTileEntity { private byte timer; public TileEntityTickingEffect() {
super(DarkUtils.content.tileTickingEffect);
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/flatblocks/BlockFlatTile.java
// Path: src/main/java/net/darkhax/darkutils/features/flatblocks/collision/CollisionEffect.java // @FunctionalInterface // public interface CollisionEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. They are applied // * to an entity when that entity collides with the block. // * // * @param state The state of the block. // * @param world Instance of the world. // * @param pos The current block position. // * @param entity The entity that collided with the block. // */ // void apply (BlockState state, World world, BlockPos pos, Entity entity); // }
import net.darkhax.darkutils.features.flatblocks.collision.CollisionEffect; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.IBucketPickupHandler; import net.minecraft.block.ILiquidContainer; import net.minecraft.block.material.Material; import net.minecraft.block.material.MaterialColor; import net.minecraft.entity.Entity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.fluid.IFluidState; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World;
package net.darkhax.darkutils.features.flatblocks; public class BlockFlatTile extends Block implements IBucketPickupHandler, ILiquidContainer { public static final Properties BLOCK_PROPERTIES = Properties.create(Material.ROCK, MaterialColor.BLACK).hardnessAndResistance(3f, 10f); public static final VoxelShape BOUNDS = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D); public static final VoxelShape EFFECT_BOUNDS = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D);
// Path: src/main/java/net/darkhax/darkutils/features/flatblocks/collision/CollisionEffect.java // @FunctionalInterface // public interface CollisionEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. They are applied // * to an entity when that entity collides with the block. // * // * @param state The state of the block. // * @param world Instance of the world. // * @param pos The current block position. // * @param entity The entity that collided with the block. // */ // void apply (BlockState state, World world, BlockPos pos, Entity entity); // } // Path: src/main/java/net/darkhax/darkutils/features/flatblocks/BlockFlatTile.java import net.darkhax.darkutils.features.flatblocks.collision.CollisionEffect; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.IBucketPickupHandler; import net.minecraft.block.ILiquidContainer; import net.minecraft.block.material.Material; import net.minecraft.block.material.MaterialColor; import net.minecraft.entity.Entity; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.Fluids; import net.minecraft.fluid.IFluidState; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.StateContainer; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; package net.darkhax.darkutils.features.flatblocks; public class BlockFlatTile extends Block implements IBucketPickupHandler, ILiquidContainer { public static final Properties BLOCK_PROPERTIES = Properties.create(Material.ROCK, MaterialColor.BLACK).hardnessAndResistance(3f, 10f); public static final VoxelShape BOUNDS = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D); public static final VoxelShape EFFECT_BOUNDS = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D);
private final CollisionEffect collisionEffect;
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/slimecrucible/ContainerSlimeCrucible.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/SlimeCrucibleEvents.java // public static class RecipeCraftedEvent extends Event { // // /** // * The recipe being crafted. // */ // private final RecipeSlimeCrafting recipe; // // /** // * The player crafting the recipe. // */ // private final PlayerEntity player; // // /** // * The world instance. // */ // private final World world; // // /** // * The position of the slime crucible. // */ // private final BlockPos pos; // // /** // * The original output item before modifications. // */ // private final ItemStack originalOutput; // // /** // * The output item that will be used. // */ // private ItemStack output; // // public RecipeCraftedEvent(RecipeSlimeCrafting recipe, PlayerEntity player, World world, BlockPos pos, ItemStack originalOutput) { // // this.recipe = recipe; // this.player = player; // this.world = world; // this.pos = pos; // this.originalOutput = originalOutput; // this.output = originalOutput.copy(); // } // // /** // * Gets the stack instance that will actually be created. // * // * @return The actual recipe output. // */ // public ItemStack getOutput () { // // return this.output; // } // // /** // * Sets the output to a different item stack. // * // * @param output The new output stack. // */ // public void setOutput (ItemStack output) { // // this.output = output; // } // // /** // * Gets the recipe being crafted. // * // * @return The recipe being crafted. // */ // public RecipeSlimeCrafting getRecipe () { // // return this.recipe; // } // // /** // * Gets the player crafting the recipe. // * // * @return The player crafting the recipe. // */ // public PlayerEntity getPlayer () { // // return this.player; // } // // /** // * Gets the world instance. // * // * @return The world instance. // */ // public World getWorld () { // // return this.world; // } // // /** // * Gets the position of the crucible block. // * // * @return The position of the crucible block. // */ // public BlockPos getPos () { // // return this.pos; // } // // /** // * Gets the original and unmodified output stack. // * // * @return The original and unmodified output stack. // */ // public ItemStack getOriginalOutput () { // // return this.originalOutput; // } // }
import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.function.Consumer; import java.util.stream.Collectors; import javax.annotation.Nullable; import com.google.common.collect.Lists; import net.darkhax.bookshelf.inventory.InventoryListenable; import net.darkhax.bookshelf.inventory.SlotOutput; import net.darkhax.bookshelf.util.WorldUtils; import net.darkhax.darkutils.DarkUtils; import net.darkhax.darkutils.features.slimecrucible.SlimeCrucibleEvents.RecipeCraftedEvent; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.CraftResultInventory; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IWorldPosCallable; import net.minecraft.util.IntReferenceHolder; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge;
this.detectAndSendChanges(); } /** * Gets the recipe that has been selected by the user. * * @return The current selected recipe. */ public RecipeSlimeCrafting getSelectedRecipe () { return this.availableRecipes.get(this.getSelectedRecipeId()); } private ItemStack tempCraftingStack = ItemStack.EMPTY; /** * Handles the output slot being changed by the player. * * @param player The player who changed the slot. * @param stack The newly created ItemStack. */ private ItemStack onOutputSlotChanged (PlayerEntity player, ItemStack stack) { final RecipeSlimeCrafting recipe = this.getSelectedRecipe(); final ItemStack inputStack = this.slotInput.decrStackSize(recipe.getInputCount()); final ItemStack outputCopy = stack; // Remove the consumed slime points from the tile and from the container. this.worldPosition.consume( (world, pos) -> {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/SlimeCrucibleEvents.java // public static class RecipeCraftedEvent extends Event { // // /** // * The recipe being crafted. // */ // private final RecipeSlimeCrafting recipe; // // /** // * The player crafting the recipe. // */ // private final PlayerEntity player; // // /** // * The world instance. // */ // private final World world; // // /** // * The position of the slime crucible. // */ // private final BlockPos pos; // // /** // * The original output item before modifications. // */ // private final ItemStack originalOutput; // // /** // * The output item that will be used. // */ // private ItemStack output; // // public RecipeCraftedEvent(RecipeSlimeCrafting recipe, PlayerEntity player, World world, BlockPos pos, ItemStack originalOutput) { // // this.recipe = recipe; // this.player = player; // this.world = world; // this.pos = pos; // this.originalOutput = originalOutput; // this.output = originalOutput.copy(); // } // // /** // * Gets the stack instance that will actually be created. // * // * @return The actual recipe output. // */ // public ItemStack getOutput () { // // return this.output; // } // // /** // * Sets the output to a different item stack. // * // * @param output The new output stack. // */ // public void setOutput (ItemStack output) { // // this.output = output; // } // // /** // * Gets the recipe being crafted. // * // * @return The recipe being crafted. // */ // public RecipeSlimeCrafting getRecipe () { // // return this.recipe; // } // // /** // * Gets the player crafting the recipe. // * // * @return The player crafting the recipe. // */ // public PlayerEntity getPlayer () { // // return this.player; // } // // /** // * Gets the world instance. // * // * @return The world instance. // */ // public World getWorld () { // // return this.world; // } // // /** // * Gets the position of the crucible block. // * // * @return The position of the crucible block. // */ // public BlockPos getPos () { // // return this.pos; // } // // /** // * Gets the original and unmodified output stack. // * // * @return The original and unmodified output stack. // */ // public ItemStack getOriginalOutput () { // // return this.originalOutput; // } // } // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/ContainerSlimeCrucible.java import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.function.Consumer; import java.util.stream.Collectors; import javax.annotation.Nullable; import com.google.common.collect.Lists; import net.darkhax.bookshelf.inventory.InventoryListenable; import net.darkhax.bookshelf.inventory.SlotOutput; import net.darkhax.bookshelf.util.WorldUtils; import net.darkhax.darkutils.DarkUtils; import net.darkhax.darkutils.features.slimecrucible.SlimeCrucibleEvents.RecipeCraftedEvent; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.inventory.CraftResultInventory; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IWorldPosCallable; import net.minecraft.util.IntReferenceHolder; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; this.detectAndSendChanges(); } /** * Gets the recipe that has been selected by the user. * * @return The current selected recipe. */ public RecipeSlimeCrafting getSelectedRecipe () { return this.availableRecipes.get(this.getSelectedRecipeId()); } private ItemStack tempCraftingStack = ItemStack.EMPTY; /** * Handles the output slot being changed by the player. * * @param player The player who changed the slot. * @param stack The newly created ItemStack. */ private ItemStack onOutputSlotChanged (PlayerEntity player, ItemStack stack) { final RecipeSlimeCrafting recipe = this.getSelectedRecipe(); final ItemStack inputStack = this.slotInput.decrStackSize(recipe.getInputCount()); final ItemStack outputCopy = stack; // Remove the consumed slime points from the tile and from the container. this.worldPosition.consume( (world, pos) -> {
final RecipeCraftedEvent event = new RecipeCraftedEvent(recipe, player, world, pos, outputCopy);
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/slimecrucible/SlimeCrucibleType.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.function.Function; import javax.annotation.Nullable; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.BlockState; import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World;
package net.darkhax.darkutils.features.slimecrucible; public class SlimeCrucibleType { /** * An internal map that holds all known slime types. Entries will be added to this map * automatically when they are constructed. To retrieve an entry use * {@link #getType(ResourceLocation)}. */ private static final Map<ResourceLocation, SlimeCrucibleType> REGISTRY_MAP = new HashMap<>(); /** * Gets the ID of the entity. This is used for serialization of types in recipes. */ private final ResourceLocation id; /** * The sound event to play when an item is crafted by a crucible of the type. */ private final SoundEvent craftingSound; /** * The sound event to play when a slime is fed a food it likes, or whenever the slime is * happy. */ private final SoundEvent happySound; /** * The default name for the crucible's container GUI. */ private final ITextComponent containerName; /** * The name of the material generated by the slime crucible. */ private final ITextComponent materialName; /** * The maximum number of slime that can be held by a crucible. */ private final int maxSlimePoints; /** * A color used in the slime crucible when the mouse is over a potential recipe. */ private final int overlayColor; /** * A function that is used to build the slime in the crucible. This is primarily used on * the client for the tile entity renderer but can safely be used on both sides. */ private final Function<World, SlimeEntity> entityBuilder; public SlimeCrucibleType(ResourceLocation id, int maxSlimePoints, Function<World, SlimeEntity> entityBuilder, SoundEvent craftingSound, SoundEvent happySound, int overlayColor) { this.id = id; this.maxSlimePoints = maxSlimePoints; this.entityBuilder = entityBuilder; this.craftingSound = craftingSound; this.happySound = happySound; this.overlayColor = overlayColor; this.containerName = new TranslationTextComponent("container." + id.getNamespace() + ".slime_crucible." + id.getPath()); this.materialName = new TranslationTextComponent("tooltips." + id.getNamespace() + ".slime_crucible.material." + id.getPath()); REGISTRY_MAP.put(id, this); } /** * Gets the registry name used by the slime type. This should be usable with * {@link #getType(ResourceLocation)} to provide the same object. * * @return The registry name for the slime type. */ public ResourceLocation getRegistryName () { return this.id; } /** * Creates the slime entity represented by this type. Note that ALL is an internal type * used for matching and will try to crash if you call this on it. * * @param world An instance of the world. The entity will not be spawned into the world, * but is required for constructing entity objects. * @return A slime entity that this type represents. */ public SlimeEntity createSlime (World world) { if (this.entityBuilder == null) {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/SlimeCrucibleType.java import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.function.Function; import javax.annotation.Nullable; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.BlockState; import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; package net.darkhax.darkutils.features.slimecrucible; public class SlimeCrucibleType { /** * An internal map that holds all known slime types. Entries will be added to this map * automatically when they are constructed. To retrieve an entry use * {@link #getType(ResourceLocation)}. */ private static final Map<ResourceLocation, SlimeCrucibleType> REGISTRY_MAP = new HashMap<>(); /** * Gets the ID of the entity. This is used for serialization of types in recipes. */ private final ResourceLocation id; /** * The sound event to play when an item is crafted by a crucible of the type. */ private final SoundEvent craftingSound; /** * The sound event to play when a slime is fed a food it likes, or whenever the slime is * happy. */ private final SoundEvent happySound; /** * The default name for the crucible's container GUI. */ private final ITextComponent containerName; /** * The name of the material generated by the slime crucible. */ private final ITextComponent materialName; /** * The maximum number of slime that can be held by a crucible. */ private final int maxSlimePoints; /** * A color used in the slime crucible when the mouse is over a potential recipe. */ private final int overlayColor; /** * A function that is used to build the slime in the crucible. This is primarily used on * the client for the tile entity renderer but can safely be used on both sides. */ private final Function<World, SlimeEntity> entityBuilder; public SlimeCrucibleType(ResourceLocation id, int maxSlimePoints, Function<World, SlimeEntity> entityBuilder, SoundEvent craftingSound, SoundEvent happySound, int overlayColor) { this.id = id; this.maxSlimePoints = maxSlimePoints; this.entityBuilder = entityBuilder; this.craftingSound = craftingSound; this.happySound = happySound; this.overlayColor = overlayColor; this.containerName = new TranslationTextComponent("container." + id.getNamespace() + ".slime_crucible." + id.getPath()); this.materialName = new TranslationTextComponent("tooltips." + id.getNamespace() + ".slime_crucible.material." + id.getPath()); REGISTRY_MAP.put(id, this); } /** * Gets the registry name used by the slime type. This should be usable with * {@link #getType(ResourceLocation)} to provide the same object. * * @return The registry name for the slime type. */ public ResourceLocation getRegistryName () { return this.id; } /** * Creates the slime entity represented by this type. Note that ALL is an internal type * used for matching and will try to crash if you call this on it. * * @param world An instance of the world. The entity will not be spawned into the world, * but is required for constructing entity objects. * @return A slime entity that this type represents. */ public SlimeEntity createSlime (World world) { if (this.entityBuilder == null) {
throw new IllegalArgumentException(this == DarkUtils.content.crucibleTypeAll ? "Someone tried to create an instance of the ALL slime type. This is an unsupported operation." : "The slime type " + this.id + " does not have an entityBuilder. This is not allowed.");
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/slimecrucible/RecipeSlimeCrafting.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.Set; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.darkhax.darkutils.DarkUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.network.PacketBuffer; import net.minecraft.util.JSONUtils; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry;
@Override @Deprecated public boolean matches (IInventory inv, World worldIn) { // This method is not intended to be used. Use the various isValid methods instead. return this.input.test(inv.getStackInSlot(0)); } @Override public ItemStack getCraftingResult (IInventory inv) { return this.output.copy(); } @Override public ItemStack getRecipeOutput () { return this.output; } @Override public ResourceLocation getId () { return this.id; } @Override public IRecipeSerializer<?> getSerializer () {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/RecipeSlimeCrafting.java import java.util.Arrays; import java.util.HashSet; import java.util.Set; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.darkhax.darkutils.DarkUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.ShapedRecipe; import net.minecraft.network.PacketBuffer; import net.minecraft.util.JSONUtils; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry; @Override @Deprecated public boolean matches (IInventory inv, World worldIn) { // This method is not intended to be used. Use the various isValid methods instead. return this.input.test(inv.getStackInSlot(0)); } @Override public ItemStack getCraftingResult (IInventory inv) { return this.output.copy(); } @Override public ItemStack getRecipeOutput () { return this.output; } @Override public ResourceLocation getId () { return this.id; } @Override public IRecipeSerializer<?> getSerializer () {
return DarkUtils.content.recipeSerializerSlimeCrafting;
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/flatblocks/BlockFlatTileRotatingTicking.java
// Path: src/main/java/net/darkhax/darkutils/features/flatblocks/collision/CollisionEffect.java // @FunctionalInterface // public interface CollisionEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. They are applied // * to an entity when that entity collides with the block. // * // * @param state The state of the block. // * @param world Instance of the world. // * @param pos The current block position. // * @param entity The entity that collided with the block. // */ // void apply (BlockState state, World world, BlockPos pos, Entity entity); // } // // Path: src/main/java/net/darkhax/darkutils/features/flatblocks/tick/TickEffect.java // @FunctionalInterface // public interface TickEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. This tick effect // * will be applied based on the specified tick rate. // * // * @param state The current blocks tate. // * @param world The world the block is in. // * @param pos The position of the block. // */ // void apply (BlockState state, World world, BlockPos pos); // }
import java.util.Random; import net.darkhax.darkutils.features.flatblocks.collision.CollisionEffect; import net.darkhax.darkutils.features.flatblocks.tick.TickEffect; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World;
package net.darkhax.darkutils.features.flatblocks; @SuppressWarnings("deprecation") public class BlockFlatTileRotatingTicking extends BlockFlatTileRotating {
// Path: src/main/java/net/darkhax/darkutils/features/flatblocks/collision/CollisionEffect.java // @FunctionalInterface // public interface CollisionEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. They are applied // * to an entity when that entity collides with the block. // * // * @param state The state of the block. // * @param world Instance of the world. // * @param pos The current block position. // * @param entity The entity that collided with the block. // */ // void apply (BlockState state, World world, BlockPos pos, Entity entity); // } // // Path: src/main/java/net/darkhax/darkutils/features/flatblocks/tick/TickEffect.java // @FunctionalInterface // public interface TickEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. This tick effect // * will be applied based on the specified tick rate. // * // * @param state The current blocks tate. // * @param world The world the block is in. // * @param pos The position of the block. // */ // void apply (BlockState state, World world, BlockPos pos); // } // Path: src/main/java/net/darkhax/darkutils/features/flatblocks/BlockFlatTileRotatingTicking.java import java.util.Random; import net.darkhax.darkutils.features.flatblocks.collision.CollisionEffect; import net.darkhax.darkutils.features.flatblocks.tick.TickEffect; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; package net.darkhax.darkutils.features.flatblocks; @SuppressWarnings("deprecation") public class BlockFlatTileRotatingTicking extends BlockFlatTileRotating {
private final TickEffect tickEffect;
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/flatblocks/BlockFlatTileRotatingTicking.java
// Path: src/main/java/net/darkhax/darkutils/features/flatblocks/collision/CollisionEffect.java // @FunctionalInterface // public interface CollisionEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. They are applied // * to an entity when that entity collides with the block. // * // * @param state The state of the block. // * @param world Instance of the world. // * @param pos The current block position. // * @param entity The entity that collided with the block. // */ // void apply (BlockState state, World world, BlockPos pos, Entity entity); // } // // Path: src/main/java/net/darkhax/darkutils/features/flatblocks/tick/TickEffect.java // @FunctionalInterface // public interface TickEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. This tick effect // * will be applied based on the specified tick rate. // * // * @param state The current blocks tate. // * @param world The world the block is in. // * @param pos The position of the block. // */ // void apply (BlockState state, World world, BlockPos pos); // }
import java.util.Random; import net.darkhax.darkutils.features.flatblocks.collision.CollisionEffect; import net.darkhax.darkutils.features.flatblocks.tick.TickEffect; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World;
package net.darkhax.darkutils.features.flatblocks; @SuppressWarnings("deprecation") public class BlockFlatTileRotatingTicking extends BlockFlatTileRotating { private final TickEffect tickEffect; private final int tickRate;
// Path: src/main/java/net/darkhax/darkutils/features/flatblocks/collision/CollisionEffect.java // @FunctionalInterface // public interface CollisionEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. They are applied // * to an entity when that entity collides with the block. // * // * @param state The state of the block. // * @param world Instance of the world. // * @param pos The current block position. // * @param entity The entity that collided with the block. // */ // void apply (BlockState state, World world, BlockPos pos, Entity entity); // } // // Path: src/main/java/net/darkhax/darkutils/features/flatblocks/tick/TickEffect.java // @FunctionalInterface // public interface TickEffect { // // /** // * This functional interface is used by the flat tile blocks in this mod. This tick effect // * will be applied based on the specified tick rate. // * // * @param state The current blocks tate. // * @param world The world the block is in. // * @param pos The position of the block. // */ // void apply (BlockState state, World world, BlockPos pos); // } // Path: src/main/java/net/darkhax/darkutils/features/flatblocks/BlockFlatTileRotatingTicking.java import java.util.Random; import net.darkhax.darkutils.features.flatblocks.collision.CollisionEffect; import net.darkhax.darkutils.features.flatblocks.tick.TickEffect; import net.minecraft.block.BlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; package net.darkhax.darkutils.features.flatblocks; @SuppressWarnings("deprecation") public class BlockFlatTileRotatingTicking extends BlockFlatTileRotating { private final TickEffect tickEffect; private final int tickRate;
public BlockFlatTileRotatingTicking(CollisionEffect collisionEffect, TickEffect tickEffect, int tickRate) {
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/addons/AddonManager.java
// Path: src/main/java/net/darkhax/darkutils/addons/curio/CurioAddon.java // public class CurioAddon implements ICurioAddon { // // @Override // public boolean isCurioApiAvailable () { // // return true; // } // // @Override // public boolean hasCurioItem (Item item, LivingEntity user) { // // return !this.getCurioOfType(item, user).isEmpty(); // } // // @Override // public ItemStack getCurioOfType (Item item, LivingEntity user) { // // final Optional<ImmutableTriple<String, Integer, ItemStack>> curio = CuriosAPI.getCurioEquipped(item, user); // return curio.isPresent() ? curio.get().getRight() : ItemStack.EMPTY; // } // // @Override // public void enqueCommunication () { // // InterModComms.sendTo("curios", "register_type", () -> new CurioIMCMessage("charm").setSize(2).setEnabled(true).setHidden(false)); // } // } // // Path: src/main/java/net/darkhax/darkutils/addons/curio/ICurioAddon.java // public interface ICurioAddon { // // public static final ICurioAddon DEFAULT = new ICurioAddon() { // }; // // default boolean isCurioApiAvailable () { // // return false; // } // // default boolean hasCurioItem (Item item, LivingEntity user) { // // return false; // } // // default ItemStack getCurioOfType (Item item, LivingEntity user) { // // return ItemStack.EMPTY; // } // // default void enqueCommunication () { // // } // }
import net.darkhax.bookshelf.util.ModUtils; import net.darkhax.darkutils.addons.curio.CurioAddon; import net.darkhax.darkutils.addons.curio.ICurioAddon; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
package net.darkhax.darkutils.addons; public class AddonManager { private ICurioAddon curio; public AddonManager() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); } private void onCommonSetup (FMLCommonSetupEvent event) {
// Path: src/main/java/net/darkhax/darkutils/addons/curio/CurioAddon.java // public class CurioAddon implements ICurioAddon { // // @Override // public boolean isCurioApiAvailable () { // // return true; // } // // @Override // public boolean hasCurioItem (Item item, LivingEntity user) { // // return !this.getCurioOfType(item, user).isEmpty(); // } // // @Override // public ItemStack getCurioOfType (Item item, LivingEntity user) { // // final Optional<ImmutableTriple<String, Integer, ItemStack>> curio = CuriosAPI.getCurioEquipped(item, user); // return curio.isPresent() ? curio.get().getRight() : ItemStack.EMPTY; // } // // @Override // public void enqueCommunication () { // // InterModComms.sendTo("curios", "register_type", () -> new CurioIMCMessage("charm").setSize(2).setEnabled(true).setHidden(false)); // } // } // // Path: src/main/java/net/darkhax/darkutils/addons/curio/ICurioAddon.java // public interface ICurioAddon { // // public static final ICurioAddon DEFAULT = new ICurioAddon() { // }; // // default boolean isCurioApiAvailable () { // // return false; // } // // default boolean hasCurioItem (Item item, LivingEntity user) { // // return false; // } // // default ItemStack getCurioOfType (Item item, LivingEntity user) { // // return ItemStack.EMPTY; // } // // default void enqueCommunication () { // // } // } // Path: src/main/java/net/darkhax/darkutils/addons/AddonManager.java import net.darkhax.bookshelf.util.ModUtils; import net.darkhax.darkutils.addons.curio.CurioAddon; import net.darkhax.darkutils.addons.curio.ICurioAddon; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; package net.darkhax.darkutils.addons; public class AddonManager { private ICurioAddon curio; public AddonManager() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); } private void onCommonSetup (FMLCommonSetupEvent event) {
this.curio = ModUtils.callIfPresent("curios", () -> () -> new CurioAddon(), () -> () -> ICurioAddon.DEFAULT);
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/DarkUtils.java
// Path: src/main/java/net/darkhax/darkutils/addons/AddonManager.java // public class AddonManager { // // private ICurioAddon curio; // // public AddonManager() { // // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); // } // // private void onCommonSetup (FMLCommonSetupEvent event) { // // this.curio = ModUtils.callIfPresent("curios", () -> () -> new CurioAddon(), () -> () -> ICurioAddon.DEFAULT); // } // // private void enqueIMC (InterModEnqueueEvent event) { // // this.curio.enqueCommunication(); // } // // public ICurioAddon curios () { // // return this.curio; // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/MessageSyncCrucibleType.java // public class MessageSyncCrucibleType { // // /** // * The Id of the crucible to sync. // */ // private final ResourceLocation crucibleId; // // public MessageSyncCrucibleType(ResourceLocation crucibleId) { // // this.crucibleId = crucibleId; // } // // /** // * Gets the type of slime crucible being synced to the client. // * // * @return The Id of the slime crucible type being synced. // */ // public ResourceLocation getCrucibleId () { // // return this.crucibleId; // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerClient.java // public class NetworkHandlerClient { // // public static MessageSyncCrucibleType decodeStageMessage (PacketBuffer buffer) { // // return new MessageSyncCrucibleType(buffer.readResourceLocation()); // } // // public static void processSyncStagesMessage (MessageSyncCrucibleType message, Supplier<Context> context) { // // final Container openedContainer = Minecraft.getInstance().player.openContainer; // final SlimeCrucibleType type = SlimeCrucibleType.getType(message.getCrucibleId()); // // if (openedContainer instanceof ContainerSlimeCrucible && type != null) { // // ((ContainerSlimeCrucible) openedContainer).setCrucibleType(type); // } // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerServer.java // public class NetworkHandlerServer { // // public static void encodeStageMessage (MessageSyncCrucibleType packet, PacketBuffer buffer) { // // buffer.writeResourceLocation(packet.getCrucibleId()); // } // }
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.darkhax.bookshelf.item.ItemGroupBase; import net.darkhax.bookshelf.network.NetworkHelper; import net.darkhax.bookshelf.registry.RegistryHelper; import net.darkhax.bookshelf.registry.RegistryHelperClient; import net.darkhax.darkutils.addons.AddonManager; import net.darkhax.darkutils.features.slimecrucible.MessageSyncCrucibleType; import net.darkhax.darkutils.network.NetworkHandlerClient; import net.darkhax.darkutils.network.NetworkHandlerServer; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
package net.darkhax.darkutils; @Mod(DarkUtils.MOD_ID) public class DarkUtils { public static final String MOD_ID = "darkutils"; public static final String MOD_NAME = "Dark Utilities"; public static final Logger LOG = LogManager.getLogger(MOD_NAME); public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); public static RegistryHelper registry; public static Content content;
// Path: src/main/java/net/darkhax/darkutils/addons/AddonManager.java // public class AddonManager { // // private ICurioAddon curio; // // public AddonManager() { // // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); // } // // private void onCommonSetup (FMLCommonSetupEvent event) { // // this.curio = ModUtils.callIfPresent("curios", () -> () -> new CurioAddon(), () -> () -> ICurioAddon.DEFAULT); // } // // private void enqueIMC (InterModEnqueueEvent event) { // // this.curio.enqueCommunication(); // } // // public ICurioAddon curios () { // // return this.curio; // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/MessageSyncCrucibleType.java // public class MessageSyncCrucibleType { // // /** // * The Id of the crucible to sync. // */ // private final ResourceLocation crucibleId; // // public MessageSyncCrucibleType(ResourceLocation crucibleId) { // // this.crucibleId = crucibleId; // } // // /** // * Gets the type of slime crucible being synced to the client. // * // * @return The Id of the slime crucible type being synced. // */ // public ResourceLocation getCrucibleId () { // // return this.crucibleId; // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerClient.java // public class NetworkHandlerClient { // // public static MessageSyncCrucibleType decodeStageMessage (PacketBuffer buffer) { // // return new MessageSyncCrucibleType(buffer.readResourceLocation()); // } // // public static void processSyncStagesMessage (MessageSyncCrucibleType message, Supplier<Context> context) { // // final Container openedContainer = Minecraft.getInstance().player.openContainer; // final SlimeCrucibleType type = SlimeCrucibleType.getType(message.getCrucibleId()); // // if (openedContainer instanceof ContainerSlimeCrucible && type != null) { // // ((ContainerSlimeCrucible) openedContainer).setCrucibleType(type); // } // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerServer.java // public class NetworkHandlerServer { // // public static void encodeStageMessage (MessageSyncCrucibleType packet, PacketBuffer buffer) { // // buffer.writeResourceLocation(packet.getCrucibleId()); // } // } // Path: src/main/java/net/darkhax/darkutils/DarkUtils.java import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.darkhax.bookshelf.item.ItemGroupBase; import net.darkhax.bookshelf.network.NetworkHelper; import net.darkhax.bookshelf.registry.RegistryHelper; import net.darkhax.bookshelf.registry.RegistryHelperClient; import net.darkhax.darkutils.addons.AddonManager; import net.darkhax.darkutils.features.slimecrucible.MessageSyncCrucibleType; import net.darkhax.darkutils.network.NetworkHandlerClient; import net.darkhax.darkutils.network.NetworkHandlerServer; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; package net.darkhax.darkutils; @Mod(DarkUtils.MOD_ID) public class DarkUtils { public static final String MOD_ID = "darkutils"; public static final String MOD_NAME = "Dark Utilities"; public static final Logger LOG = LogManager.getLogger(MOD_NAME); public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); public static RegistryHelper registry; public static Content content;
public static AddonManager addons;
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/DarkUtils.java
// Path: src/main/java/net/darkhax/darkutils/addons/AddonManager.java // public class AddonManager { // // private ICurioAddon curio; // // public AddonManager() { // // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); // } // // private void onCommonSetup (FMLCommonSetupEvent event) { // // this.curio = ModUtils.callIfPresent("curios", () -> () -> new CurioAddon(), () -> () -> ICurioAddon.DEFAULT); // } // // private void enqueIMC (InterModEnqueueEvent event) { // // this.curio.enqueCommunication(); // } // // public ICurioAddon curios () { // // return this.curio; // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/MessageSyncCrucibleType.java // public class MessageSyncCrucibleType { // // /** // * The Id of the crucible to sync. // */ // private final ResourceLocation crucibleId; // // public MessageSyncCrucibleType(ResourceLocation crucibleId) { // // this.crucibleId = crucibleId; // } // // /** // * Gets the type of slime crucible being synced to the client. // * // * @return The Id of the slime crucible type being synced. // */ // public ResourceLocation getCrucibleId () { // // return this.crucibleId; // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerClient.java // public class NetworkHandlerClient { // // public static MessageSyncCrucibleType decodeStageMessage (PacketBuffer buffer) { // // return new MessageSyncCrucibleType(buffer.readResourceLocation()); // } // // public static void processSyncStagesMessage (MessageSyncCrucibleType message, Supplier<Context> context) { // // final Container openedContainer = Minecraft.getInstance().player.openContainer; // final SlimeCrucibleType type = SlimeCrucibleType.getType(message.getCrucibleId()); // // if (openedContainer instanceof ContainerSlimeCrucible && type != null) { // // ((ContainerSlimeCrucible) openedContainer).setCrucibleType(type); // } // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerServer.java // public class NetworkHandlerServer { // // public static void encodeStageMessage (MessageSyncCrucibleType packet, PacketBuffer buffer) { // // buffer.writeResourceLocation(packet.getCrucibleId()); // } // }
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.darkhax.bookshelf.item.ItemGroupBase; import net.darkhax.bookshelf.network.NetworkHelper; import net.darkhax.bookshelf.registry.RegistryHelper; import net.darkhax.bookshelf.registry.RegistryHelperClient; import net.darkhax.darkutils.addons.AddonManager; import net.darkhax.darkutils.features.slimecrucible.MessageSyncCrucibleType; import net.darkhax.darkutils.network.NetworkHandlerClient; import net.darkhax.darkutils.network.NetworkHandlerServer; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
package net.darkhax.darkutils; @Mod(DarkUtils.MOD_ID) public class DarkUtils { public static final String MOD_ID = "darkutils"; public static final String MOD_NAME = "Dark Utilities"; public static final Logger LOG = LogManager.getLogger(MOD_NAME); public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); public static RegistryHelper registry; public static Content content; public static AddonManager addons; public DarkUtils() { registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry));
// Path: src/main/java/net/darkhax/darkutils/addons/AddonManager.java // public class AddonManager { // // private ICurioAddon curio; // // public AddonManager() { // // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); // } // // private void onCommonSetup (FMLCommonSetupEvent event) { // // this.curio = ModUtils.callIfPresent("curios", () -> () -> new CurioAddon(), () -> () -> ICurioAddon.DEFAULT); // } // // private void enqueIMC (InterModEnqueueEvent event) { // // this.curio.enqueCommunication(); // } // // public ICurioAddon curios () { // // return this.curio; // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/MessageSyncCrucibleType.java // public class MessageSyncCrucibleType { // // /** // * The Id of the crucible to sync. // */ // private final ResourceLocation crucibleId; // // public MessageSyncCrucibleType(ResourceLocation crucibleId) { // // this.crucibleId = crucibleId; // } // // /** // * Gets the type of slime crucible being synced to the client. // * // * @return The Id of the slime crucible type being synced. // */ // public ResourceLocation getCrucibleId () { // // return this.crucibleId; // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerClient.java // public class NetworkHandlerClient { // // public static MessageSyncCrucibleType decodeStageMessage (PacketBuffer buffer) { // // return new MessageSyncCrucibleType(buffer.readResourceLocation()); // } // // public static void processSyncStagesMessage (MessageSyncCrucibleType message, Supplier<Context> context) { // // final Container openedContainer = Minecraft.getInstance().player.openContainer; // final SlimeCrucibleType type = SlimeCrucibleType.getType(message.getCrucibleId()); // // if (openedContainer instanceof ContainerSlimeCrucible && type != null) { // // ((ContainerSlimeCrucible) openedContainer).setCrucibleType(type); // } // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerServer.java // public class NetworkHandlerServer { // // public static void encodeStageMessage (MessageSyncCrucibleType packet, PacketBuffer buffer) { // // buffer.writeResourceLocation(packet.getCrucibleId()); // } // } // Path: src/main/java/net/darkhax/darkutils/DarkUtils.java import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.darkhax.bookshelf.item.ItemGroupBase; import net.darkhax.bookshelf.network.NetworkHelper; import net.darkhax.bookshelf.registry.RegistryHelper; import net.darkhax.bookshelf.registry.RegistryHelperClient; import net.darkhax.darkutils.addons.AddonManager; import net.darkhax.darkutils.features.slimecrucible.MessageSyncCrucibleType; import net.darkhax.darkutils.network.NetworkHandlerClient; import net.darkhax.darkutils.network.NetworkHandlerServer; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; package net.darkhax.darkutils; @Mod(DarkUtils.MOD_ID) public class DarkUtils { public static final String MOD_ID = "darkutils"; public static final String MOD_NAME = "Dark Utilities"; public static final Logger LOG = LogManager.getLogger(MOD_NAME); public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); public static RegistryHelper registry; public static Content content; public static AddonManager addons; public DarkUtils() { registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry));
NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u));
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/DarkUtils.java
// Path: src/main/java/net/darkhax/darkutils/addons/AddonManager.java // public class AddonManager { // // private ICurioAddon curio; // // public AddonManager() { // // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); // } // // private void onCommonSetup (FMLCommonSetupEvent event) { // // this.curio = ModUtils.callIfPresent("curios", () -> () -> new CurioAddon(), () -> () -> ICurioAddon.DEFAULT); // } // // private void enqueIMC (InterModEnqueueEvent event) { // // this.curio.enqueCommunication(); // } // // public ICurioAddon curios () { // // return this.curio; // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/MessageSyncCrucibleType.java // public class MessageSyncCrucibleType { // // /** // * The Id of the crucible to sync. // */ // private final ResourceLocation crucibleId; // // public MessageSyncCrucibleType(ResourceLocation crucibleId) { // // this.crucibleId = crucibleId; // } // // /** // * Gets the type of slime crucible being synced to the client. // * // * @return The Id of the slime crucible type being synced. // */ // public ResourceLocation getCrucibleId () { // // return this.crucibleId; // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerClient.java // public class NetworkHandlerClient { // // public static MessageSyncCrucibleType decodeStageMessage (PacketBuffer buffer) { // // return new MessageSyncCrucibleType(buffer.readResourceLocation()); // } // // public static void processSyncStagesMessage (MessageSyncCrucibleType message, Supplier<Context> context) { // // final Container openedContainer = Minecraft.getInstance().player.openContainer; // final SlimeCrucibleType type = SlimeCrucibleType.getType(message.getCrucibleId()); // // if (openedContainer instanceof ContainerSlimeCrucible && type != null) { // // ((ContainerSlimeCrucible) openedContainer).setCrucibleType(type); // } // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerServer.java // public class NetworkHandlerServer { // // public static void encodeStageMessage (MessageSyncCrucibleType packet, PacketBuffer buffer) { // // buffer.writeResourceLocation(packet.getCrucibleId()); // } // }
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.darkhax.bookshelf.item.ItemGroupBase; import net.darkhax.bookshelf.network.NetworkHelper; import net.darkhax.bookshelf.registry.RegistryHelper; import net.darkhax.bookshelf.registry.RegistryHelperClient; import net.darkhax.darkutils.addons.AddonManager; import net.darkhax.darkutils.features.slimecrucible.MessageSyncCrucibleType; import net.darkhax.darkutils.network.NetworkHandlerClient; import net.darkhax.darkutils.network.NetworkHandlerServer; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
package net.darkhax.darkutils; @Mod(DarkUtils.MOD_ID) public class DarkUtils { public static final String MOD_ID = "darkutils"; public static final String MOD_NAME = "Dark Utilities"; public static final Logger LOG = LogManager.getLogger(MOD_NAME); public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); public static RegistryHelper registry; public static Content content; public static AddonManager addons; public DarkUtils() { registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry));
// Path: src/main/java/net/darkhax/darkutils/addons/AddonManager.java // public class AddonManager { // // private ICurioAddon curio; // // public AddonManager() { // // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); // } // // private void onCommonSetup (FMLCommonSetupEvent event) { // // this.curio = ModUtils.callIfPresent("curios", () -> () -> new CurioAddon(), () -> () -> ICurioAddon.DEFAULT); // } // // private void enqueIMC (InterModEnqueueEvent event) { // // this.curio.enqueCommunication(); // } // // public ICurioAddon curios () { // // return this.curio; // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/MessageSyncCrucibleType.java // public class MessageSyncCrucibleType { // // /** // * The Id of the crucible to sync. // */ // private final ResourceLocation crucibleId; // // public MessageSyncCrucibleType(ResourceLocation crucibleId) { // // this.crucibleId = crucibleId; // } // // /** // * Gets the type of slime crucible being synced to the client. // * // * @return The Id of the slime crucible type being synced. // */ // public ResourceLocation getCrucibleId () { // // return this.crucibleId; // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerClient.java // public class NetworkHandlerClient { // // public static MessageSyncCrucibleType decodeStageMessage (PacketBuffer buffer) { // // return new MessageSyncCrucibleType(buffer.readResourceLocation()); // } // // public static void processSyncStagesMessage (MessageSyncCrucibleType message, Supplier<Context> context) { // // final Container openedContainer = Minecraft.getInstance().player.openContainer; // final SlimeCrucibleType type = SlimeCrucibleType.getType(message.getCrucibleId()); // // if (openedContainer instanceof ContainerSlimeCrucible && type != null) { // // ((ContainerSlimeCrucible) openedContainer).setCrucibleType(type); // } // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerServer.java // public class NetworkHandlerServer { // // public static void encodeStageMessage (MessageSyncCrucibleType packet, PacketBuffer buffer) { // // buffer.writeResourceLocation(packet.getCrucibleId()); // } // } // Path: src/main/java/net/darkhax/darkutils/DarkUtils.java import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.darkhax.bookshelf.item.ItemGroupBase; import net.darkhax.bookshelf.network.NetworkHelper; import net.darkhax.bookshelf.registry.RegistryHelper; import net.darkhax.bookshelf.registry.RegistryHelperClient; import net.darkhax.darkutils.addons.AddonManager; import net.darkhax.darkutils.features.slimecrucible.MessageSyncCrucibleType; import net.darkhax.darkutils.network.NetworkHandlerClient; import net.darkhax.darkutils.network.NetworkHandlerServer; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; package net.darkhax.darkutils; @Mod(DarkUtils.MOD_ID) public class DarkUtils { public static final String MOD_ID = "darkutils"; public static final String MOD_NAME = "Dark Utilities"; public static final Logger LOG = LogManager.getLogger(MOD_NAME); public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); public static RegistryHelper registry; public static Content content; public static AddonManager addons; public DarkUtils() { registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry));
NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u));
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/DarkUtils.java
// Path: src/main/java/net/darkhax/darkutils/addons/AddonManager.java // public class AddonManager { // // private ICurioAddon curio; // // public AddonManager() { // // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); // } // // private void onCommonSetup (FMLCommonSetupEvent event) { // // this.curio = ModUtils.callIfPresent("curios", () -> () -> new CurioAddon(), () -> () -> ICurioAddon.DEFAULT); // } // // private void enqueIMC (InterModEnqueueEvent event) { // // this.curio.enqueCommunication(); // } // // public ICurioAddon curios () { // // return this.curio; // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/MessageSyncCrucibleType.java // public class MessageSyncCrucibleType { // // /** // * The Id of the crucible to sync. // */ // private final ResourceLocation crucibleId; // // public MessageSyncCrucibleType(ResourceLocation crucibleId) { // // this.crucibleId = crucibleId; // } // // /** // * Gets the type of slime crucible being synced to the client. // * // * @return The Id of the slime crucible type being synced. // */ // public ResourceLocation getCrucibleId () { // // return this.crucibleId; // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerClient.java // public class NetworkHandlerClient { // // public static MessageSyncCrucibleType decodeStageMessage (PacketBuffer buffer) { // // return new MessageSyncCrucibleType(buffer.readResourceLocation()); // } // // public static void processSyncStagesMessage (MessageSyncCrucibleType message, Supplier<Context> context) { // // final Container openedContainer = Minecraft.getInstance().player.openContainer; // final SlimeCrucibleType type = SlimeCrucibleType.getType(message.getCrucibleId()); // // if (openedContainer instanceof ContainerSlimeCrucible && type != null) { // // ((ContainerSlimeCrucible) openedContainer).setCrucibleType(type); // } // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerServer.java // public class NetworkHandlerServer { // // public static void encodeStageMessage (MessageSyncCrucibleType packet, PacketBuffer buffer) { // // buffer.writeResourceLocation(packet.getCrucibleId()); // } // }
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.darkhax.bookshelf.item.ItemGroupBase; import net.darkhax.bookshelf.network.NetworkHelper; import net.darkhax.bookshelf.registry.RegistryHelper; import net.darkhax.bookshelf.registry.RegistryHelperClient; import net.darkhax.darkutils.addons.AddonManager; import net.darkhax.darkutils.features.slimecrucible.MessageSyncCrucibleType; import net.darkhax.darkutils.network.NetworkHandlerClient; import net.darkhax.darkutils.network.NetworkHandlerServer; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
package net.darkhax.darkutils; @Mod(DarkUtils.MOD_ID) public class DarkUtils { public static final String MOD_ID = "darkutils"; public static final String MOD_NAME = "Dark Utilities"; public static final Logger LOG = LogManager.getLogger(MOD_NAME); public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); public static RegistryHelper registry; public static Content content; public static AddonManager addons; public DarkUtils() { registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry));
// Path: src/main/java/net/darkhax/darkutils/addons/AddonManager.java // public class AddonManager { // // private ICurioAddon curio; // // public AddonManager() { // // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); // FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueIMC); // } // // private void onCommonSetup (FMLCommonSetupEvent event) { // // this.curio = ModUtils.callIfPresent("curios", () -> () -> new CurioAddon(), () -> () -> ICurioAddon.DEFAULT); // } // // private void enqueIMC (InterModEnqueueEvent event) { // // this.curio.enqueCommunication(); // } // // public ICurioAddon curios () { // // return this.curio; // } // } // // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/MessageSyncCrucibleType.java // public class MessageSyncCrucibleType { // // /** // * The Id of the crucible to sync. // */ // private final ResourceLocation crucibleId; // // public MessageSyncCrucibleType(ResourceLocation crucibleId) { // // this.crucibleId = crucibleId; // } // // /** // * Gets the type of slime crucible being synced to the client. // * // * @return The Id of the slime crucible type being synced. // */ // public ResourceLocation getCrucibleId () { // // return this.crucibleId; // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerClient.java // public class NetworkHandlerClient { // // public static MessageSyncCrucibleType decodeStageMessage (PacketBuffer buffer) { // // return new MessageSyncCrucibleType(buffer.readResourceLocation()); // } // // public static void processSyncStagesMessage (MessageSyncCrucibleType message, Supplier<Context> context) { // // final Container openedContainer = Minecraft.getInstance().player.openContainer; // final SlimeCrucibleType type = SlimeCrucibleType.getType(message.getCrucibleId()); // // if (openedContainer instanceof ContainerSlimeCrucible && type != null) { // // ((ContainerSlimeCrucible) openedContainer).setCrucibleType(type); // } // } // } // // Path: src/main/java/net/darkhax/darkutils/network/NetworkHandlerServer.java // public class NetworkHandlerServer { // // public static void encodeStageMessage (MessageSyncCrucibleType packet, PacketBuffer buffer) { // // buffer.writeResourceLocation(packet.getCrucibleId()); // } // } // Path: src/main/java/net/darkhax/darkutils/DarkUtils.java import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.darkhax.bookshelf.item.ItemGroupBase; import net.darkhax.bookshelf.network.NetworkHelper; import net.darkhax.bookshelf.registry.RegistryHelper; import net.darkhax.bookshelf.registry.RegistryHelperClient; import net.darkhax.darkutils.addons.AddonManager; import net.darkhax.darkutils.features.slimecrucible.MessageSyncCrucibleType; import net.darkhax.darkutils.network.NetworkHandlerClient; import net.darkhax.darkutils.network.NetworkHandlerServer; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; package net.darkhax.darkutils; @Mod(DarkUtils.MOD_ID) public class DarkUtils { public static final String MOD_ID = "darkutils"; public static final String MOD_NAME = "Dark Utilities"; public static final Logger LOG = LogManager.getLogger(MOD_NAME); public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); public static RegistryHelper registry; public static Content content; public static AddonManager addons; public DarkUtils() { registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry));
NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u));
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/dust/DustHandler.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import net.darkhax.bookshelf.util.WorldUtils; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.state.IProperty; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.Event.Result;
package net.darkhax.darkutils.features.dust; public class DustHandler { public static void onPlayerUseItem (PlayerInteractEvent.RightClickBlock event) { final boolean didConvert = tryBlockConversion(event.getWorld(), event.getPos(), event.getItemStack()); if (didConvert) { event.setUseBlock(Result.DENY); event.setUseItem(Result.DENY); } } public static boolean tryBlockConversion (World world, BlockPos pos, ItemStack item) { final BlockState oldState = world.getBlockState(pos); // Loop through all dust recipes
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/dust/DustHandler.java import net.darkhax.bookshelf.util.WorldUtils; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.state.IProperty; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.Event.Result; package net.darkhax.darkutils.features.dust; public class DustHandler { public static void onPlayerUseItem (PlayerInteractEvent.RightClickBlock event) { final boolean didConvert = tryBlockConversion(event.getWorld(), event.getPos(), event.getItemStack()); if (didConvert) { event.setUseBlock(Result.DENY); event.setUseItem(Result.DENY); } } public static boolean tryBlockConversion (World world, BlockPos pos, ItemStack item) { final BlockState oldState = world.getBlockState(pos); // Loop through all dust recipes
for (final RecipeDustChange recipe : WorldUtils.getRecipeList(DarkUtils.content.recipeTypeDustChange, world.getRecipeManager())) {
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/slimecrucible/RecipeSlimeFood.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import java.util.Arrays; import java.util.HashSet; import java.util.Set; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.darkhax.darkutils.DarkUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; import net.minecraft.util.JSONUtils; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry;
// This method is not used internally. return this.input.test(inv.getStackInSlot(0)); } @Override @Deprecated public ItemStack getCraftingResult (IInventory inv) { // This recipe has no output return ItemStack.EMPTY; } @Override @Deprecated public ItemStack getRecipeOutput () { // This recipe has no output. return ItemStack.EMPTY; } @Override public ResourceLocation getId () { return this.id; } @Override public IRecipeSerializer<?> getSerializer () {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/RecipeSlimeFood.java import java.util.Arrays; import java.util.HashSet; import java.util.Set; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.darkhax.darkutils.DarkUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; import net.minecraft.util.JSONUtils; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry; // This method is not used internally. return this.input.test(inv.getStackInSlot(0)); } @Override @Deprecated public ItemStack getCraftingResult (IInventory inv) { // This recipe has no output return ItemStack.EMPTY; } @Override @Deprecated public ItemStack getRecipeOutput () { // This recipe has no output. return ItemStack.EMPTY; } @Override public ResourceLocation getId () { return this.id; } @Override public IRecipeSerializer<?> getSerializer () {
return DarkUtils.content.recipeSerializerSlimeFood;
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/dust/RecipeDustChange.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import java.util.Random; import com.google.gson.JsonObject; import net.darkhax.bookshelf.crafting.block.BlockIngredient; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry;
@Override @Deprecated public boolean matches (IInventory inv, World worldIn) { return false; } @Override @Deprecated public ItemStack getCraftingResult (IInventory inv) { return ItemStack.EMPTY; } @Override @Deprecated public ItemStack getRecipeOutput () { return ItemStack.EMPTY; } @Override public ResourceLocation getId () { return this.id; } @Override public IRecipeSerializer<?> getSerializer () {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/dust/RecipeDustChange.java import java.util.Random; import com.google.gson.JsonObject; import net.darkhax.bookshelf.crafting.block.BlockIngredient; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.Ingredient; import net.minecraft.network.PacketBuffer; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.registries.ForgeRegistryEntry; @Override @Deprecated public boolean matches (IInventory inv, World worldIn) { return false; } @Override @Deprecated public ItemStack getCraftingResult (IInventory inv) { return ItemStack.EMPTY; } @Override @Deprecated public ItemStack getRecipeOutput () { return ItemStack.EMPTY; } @Override public ResourceLocation getId () { return this.id; } @Override public IRecipeSerializer<?> getSerializer () {
return DarkUtils.content.recipeSerializerDustChange;
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/charms/CharmEffects.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import net.darkhax.bookshelf.util.PlayerUtils; import net.darkhax.darkutils.DarkUtils; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.ServerStatisticsManager; import net.minecraft.stats.Stat; import net.minecraft.stats.Stats; import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; import net.minecraftforge.event.entity.living.LivingExperienceDropEvent; import net.minecraftforge.event.world.BlockEvent;
package net.darkhax.darkutils.features.charms; public class CharmEffects { public static void applySleepCharmEffect (Entity user, ItemStack item) { if (user instanceof PlayerEntity) { // Set sleep timer above threshold for instant sleeping. if (((PlayerEntity) user).isSleeping()) { ((PlayerEntity) user).sleepTimer = 100; } // Passively decrease the time since last rest stat. This is what phantom spawning // looks at. if (user instanceof ServerPlayerEntity) { final Stat<?> sleepStat = Stats.CUSTOM.get(Stats.TIME_SINCE_REST); final ServerStatisticsManager statsManager = ((ServerPlayerEntity) user).getStats(); final int timeSinceLastSlept = statsManager.getValue(sleepStat); statsManager.setValue((PlayerEntity) user, sleepStat, Math.max(timeSinceLastSlept - 100, 0)); } } } public static void applyPortalCharmEffect (Entity user, ItemStack item) { if (user instanceof PlayerEntity) { // Set portal counter above the threshold for instant entry. ((PlayerEntity) user).portalCounter = 100; } } public static void applyExperienceCharmTickEffect (Entity user, ItemStack item) { if (user instanceof PlayerEntity) { // Completely disable the xp cooldown counter. ((PlayerEntity) user).xpCooldown = 0; } } public static void handleExpCharmEntity (LivingExperienceDropEvent event) { if (event.getAttackingPlayer() != null) {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/charms/CharmEffects.java import net.darkhax.bookshelf.util.PlayerUtils; import net.darkhax.darkutils.DarkUtils; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.ServerStatisticsManager; import net.minecraft.stats.Stat; import net.minecraft.stats.Stats; import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; import net.minecraftforge.event.entity.living.LivingExperienceDropEvent; import net.minecraftforge.event.world.BlockEvent; package net.darkhax.darkutils.features.charms; public class CharmEffects { public static void applySleepCharmEffect (Entity user, ItemStack item) { if (user instanceof PlayerEntity) { // Set sleep timer above threshold for instant sleeping. if (((PlayerEntity) user).isSleeping()) { ((PlayerEntity) user).sleepTimer = 100; } // Passively decrease the time since last rest stat. This is what phantom spawning // looks at. if (user instanceof ServerPlayerEntity) { final Stat<?> sleepStat = Stats.CUSTOM.get(Stats.TIME_SINCE_REST); final ServerStatisticsManager statsManager = ((ServerPlayerEntity) user).getStats(); final int timeSinceLastSlept = statsManager.getValue(sleepStat); statsManager.setValue((PlayerEntity) user, sleepStat, Math.max(timeSinceLastSlept - 100, 0)); } } } public static void applyPortalCharmEffect (Entity user, ItemStack item) { if (user instanceof PlayerEntity) { // Set portal counter above the threshold for instant entry. ((PlayerEntity) user).portalCounter = 100; } } public static void applyExperienceCharmTickEffect (Entity user, ItemStack item) { if (user instanceof PlayerEntity) { // Completely disable the xp cooldown counter. ((PlayerEntity) user).xpCooldown = 0; } } public static void handleExpCharmEntity (LivingExperienceDropEvent event) { if (event.getAttackingPlayer() != null) {
final Item charm = DarkUtils.content.experienceCharm;
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/slimecrucible/ScreenSlimeCrucible.java
// Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/SlimeCrucibleEvents.java // @OnlyIn(Dist.CLIENT) // public static class RecipeVisibleEvent extends Event { // // /** // * The recipe being tested for visibility. // */ // private final RecipeSlimeCrafting recipe; // // /** // * The player trying to view the recipe. // */ // private final PlayerEntity player; // // /** // * Whether or not the recipe is visible under normal circumstances. // */ // private final boolean originallyVisible; // // /** // * Whether or not the recipe will be visible. // */ // private boolean isVisible; // // public RecipeVisibleEvent(RecipeSlimeCrafting recipe, PlayerEntity player, boolean isVisible) { // // this.recipe = recipe; // this.player = player; // this.originallyVisible = isVisible; // this.isVisible = isVisible; // } // // /** // * Checks if the recipe would originally be visible to the player. // * // * @return Whether or not the recipe would normally be visible. // */ // public boolean wasOriginallyVisible () { // // return this.originallyVisible; // } // // /** // * Checks if the recipe is currently visible. // * // * @return Whether or not the recipe is currently visible. // */ // public boolean isVisible () { // // return this.isVisible; // } // // /** // * Sets the visibility of the recipe. Allows the recipe to be hidden or made visible. // * // * @param isVisible Whether or not the recipe should be visible. // */ // public void setVisible (boolean isVisible) { // // this.isVisible = isVisible; // } // // /** // * The recipe being tested. // * // * @return The recipe being tested. // */ // public RecipeSlimeCrafting getRecipe () { // // return this.recipe; // } // // /** // * The player trying to view the recipe. // * // * @return The player trying to view the recipe. // */ // public PlayerEntity getPlayer () { // // return this.player; // } // }
import java.util.ArrayList; import java.util.List; import com.mojang.blaze3d.platform.GlStateManager; import net.darkhax.bookshelf.util.MathsUtils; import net.darkhax.bookshelf.util.RenderUtils; import net.darkhax.bookshelf.util.RenderUtils.IQuadColorHandler; import net.darkhax.darkutils.features.slimecrucible.SlimeCrucibleEvents.RecipeVisibleEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.SimpleSound; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.gui.screen.inventory.InventoryScreen; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.resources.I18n; import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge;
// Render the recipe output item icons. this.renderRecipeOutputs(mouseX, mouseY, selectionBoxX, selectionBoxY, lastRecipeIndex); } /** * Renders the button backgrounds for the recipe outputs. * * @param mouseX The x position of the mouse. * @param mouseY The y position of the mouse. * @param selectionBoxX The starting x position of the selection box. * @param selectionBoxY The starting y position of the selection box. * @param lastRecipeIndex The last recipe index to display. */ private void renderRecipeOutputButtons (int mouseX, int mouseY, int selectionBoxX, int selectionBoxY, int lastRecipeIndex) { // Iterate through the first 12 or less recipes to show. for (int i = this.recipeIndexOffset; i < lastRecipeIndex && i < this.container.getAvailableRecipesSize(); i++) { final int recipeIndex = i - this.recipeIndexOffset; final int recipeX = selectionBoxX + recipeIndex % 4 * 16; final int recipeRow = recipeIndex / 4; final int recipeY = selectionBoxY + recipeRow * 18 + 2; final boolean canCraftRecipe = this.container.canCraft(i); final RecipeSlimeCrafting recipe = this.container.getAvailableRecipes().get(i); int textureY = this.ySize; int color = 0xffffffff; boolean isRecipeVisible = recipe.isHidden() ? canCraftRecipe : true;
// Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/SlimeCrucibleEvents.java // @OnlyIn(Dist.CLIENT) // public static class RecipeVisibleEvent extends Event { // // /** // * The recipe being tested for visibility. // */ // private final RecipeSlimeCrafting recipe; // // /** // * The player trying to view the recipe. // */ // private final PlayerEntity player; // // /** // * Whether or not the recipe is visible under normal circumstances. // */ // private final boolean originallyVisible; // // /** // * Whether or not the recipe will be visible. // */ // private boolean isVisible; // // public RecipeVisibleEvent(RecipeSlimeCrafting recipe, PlayerEntity player, boolean isVisible) { // // this.recipe = recipe; // this.player = player; // this.originallyVisible = isVisible; // this.isVisible = isVisible; // } // // /** // * Checks if the recipe would originally be visible to the player. // * // * @return Whether or not the recipe would normally be visible. // */ // public boolean wasOriginallyVisible () { // // return this.originallyVisible; // } // // /** // * Checks if the recipe is currently visible. // * // * @return Whether or not the recipe is currently visible. // */ // public boolean isVisible () { // // return this.isVisible; // } // // /** // * Sets the visibility of the recipe. Allows the recipe to be hidden or made visible. // * // * @param isVisible Whether or not the recipe should be visible. // */ // public void setVisible (boolean isVisible) { // // this.isVisible = isVisible; // } // // /** // * The recipe being tested. // * // * @return The recipe being tested. // */ // public RecipeSlimeCrafting getRecipe () { // // return this.recipe; // } // // /** // * The player trying to view the recipe. // * // * @return The player trying to view the recipe. // */ // public PlayerEntity getPlayer () { // // return this.player; // } // } // Path: src/main/java/net/darkhax/darkutils/features/slimecrucible/ScreenSlimeCrucible.java import java.util.ArrayList; import java.util.List; import com.mojang.blaze3d.platform.GlStateManager; import net.darkhax.bookshelf.util.MathsUtils; import net.darkhax.bookshelf.util.RenderUtils; import net.darkhax.bookshelf.util.RenderUtils.IQuadColorHandler; import net.darkhax.darkutils.features.slimecrucible.SlimeCrucibleEvents.RecipeVisibleEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.SimpleSound; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.gui.screen.inventory.InventoryScreen; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.resources.I18n; import net.minecraft.entity.monster.SlimeEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; // Render the recipe output item icons. this.renderRecipeOutputs(mouseX, mouseY, selectionBoxX, selectionBoxY, lastRecipeIndex); } /** * Renders the button backgrounds for the recipe outputs. * * @param mouseX The x position of the mouse. * @param mouseY The y position of the mouse. * @param selectionBoxX The starting x position of the selection box. * @param selectionBoxY The starting y position of the selection box. * @param lastRecipeIndex The last recipe index to display. */ private void renderRecipeOutputButtons (int mouseX, int mouseY, int selectionBoxX, int selectionBoxY, int lastRecipeIndex) { // Iterate through the first 12 or less recipes to show. for (int i = this.recipeIndexOffset; i < lastRecipeIndex && i < this.container.getAvailableRecipesSize(); i++) { final int recipeIndex = i - this.recipeIndexOffset; final int recipeX = selectionBoxX + recipeIndex % 4 * 16; final int recipeRow = recipeIndex / 4; final int recipeY = selectionBoxY + recipeRow * 18 + 2; final boolean canCraftRecipe = this.container.canCraft(i); final RecipeSlimeCrafting recipe = this.container.getAvailableRecipes().get(i); int textureY = this.ySize; int color = 0xffffffff; boolean isRecipeVisible = recipe.isHidden() ? canCraftRecipe : true;
final RecipeVisibleEvent event = new RecipeVisibleEvent(recipe, Minecraft.getInstance().player, isRecipeVisible);
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/addons/jei/JEIAddon.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.registration.IRecipeRegistration; import net.darkhax.darkutils.DarkUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation;
package net.darkhax.darkutils.addons.jei; @JeiPlugin public class JEIAddon implements IModPlugin { private static final ResourceLocation ID = new ResourceLocation("darkutils", "jei_support"); @Override public void registerRecipes (IRecipeRegistration registration) {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/addons/jei/JEIAddon.java import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.registration.IRecipeRegistration; import net.darkhax.darkutils.DarkUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; package net.darkhax.darkutils.addons.jei; @JeiPlugin public class JEIAddon implements IModPlugin { private static final ResourceLocation ID = new ResourceLocation("darkutils", "jei_support"); @Override public void registerRecipes (IRecipeRegistration registration) {
for (final Item item : DarkUtils.registry.getItems()) {
Darkhax-Minecraft/Dark-Utilities
src/main/java/net/darkhax/darkutils/features/enderhopper/TileEntityEnderHopper.java
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // }
import java.util.List; import net.darkhax.bookshelf.Bookshelf; import net.darkhax.bookshelf.util.InventoryUtils; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.BlockState; import net.minecraft.entity.EntityType; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.particles.ParticleTypes; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.items.IItemHandler;
package net.darkhax.darkutils.features.enderhopper; public class TileEntityEnderHopper extends TileEntity implements ITickableTileEntity { private BlockPos lastPos; protected AxisAlignedBB collectionBounds; public TileEntityEnderHopper() {
// Path: src/main/java/net/darkhax/darkutils/DarkUtils.java // @Mod(DarkUtils.MOD_ID) // public class DarkUtils { // // public static final String MOD_ID = "darkutils"; // // public static final String MOD_NAME = "Dark Utilities"; // // public static final Logger LOG = LogManager.getLogger(MOD_NAME); // // public static final ItemGroup ITEM_GROUP = new ItemGroupBase(MOD_ID, () -> new ItemStack(DarkUtils.content.vectorPlate)); // // public static final NetworkHelper NETWORK = new NetworkHelper(new ResourceLocation(MOD_ID, "main"), "2.0.X"); // // public static RegistryHelper registry; // // public static Content content; // // public static AddonManager addons; // // public DarkUtils() { // // registry = DistExecutor.runForDist( () -> () -> new RegistryHelperClient(MOD_ID, LOG, ITEM_GROUP), () -> () -> new RegistryHelper(MOD_ID, LOG, ITEM_GROUP)); // content = DistExecutor.runForDist( () -> () -> new ContentClient(registry), () -> () -> new Content(registry)); // NETWORK.registerEnqueuedMessage(MessageSyncCrucibleType.class, NetworkHandlerServer::encodeStageMessage, t -> NetworkHandlerClient.decodeStageMessage(t), (t, u) -> NetworkHandlerClient.processSyncStagesMessage(t, u)); // registry.initialize(FMLJavaModLoadingContext.get().getModEventBus()); // // // Addons // addons = new AddonManager(); // } // } // Path: src/main/java/net/darkhax/darkutils/features/enderhopper/TileEntityEnderHopper.java import java.util.List; import net.darkhax.bookshelf.Bookshelf; import net.darkhax.bookshelf.util.InventoryUtils; import net.darkhax.darkutils.DarkUtils; import net.minecraft.block.BlockState; import net.minecraft.entity.EntityType; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.particles.ParticleTypes; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.items.IItemHandler; package net.darkhax.darkutils.features.enderhopper; public class TileEntityEnderHopper extends TileEntity implements ITickableTileEntity { private BlockPos lastPos; protected AxisAlignedBB collectionBounds; public TileEntityEnderHopper() {
super(DarkUtils.content.tileEnderHopper);
CraftedCart/SMBLevelWorkshop
src/main/java/com/owens/oobjloader/lwjgl/VBO.java
// Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // } // // Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // }
import com.owens.oobjloader.builder.Material; import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import java.nio.IntBuffer;
package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class VBO { // sizeof float/sizeof int public final static int FL_SIZE = 4; public final static int INDICE_SIZE_BYTES = 4; // Vertex Attribute Data - i.e. x,y,z then normalx, normaly, normalz, then texture u,v - so 8 floats. public final static int ATTR_V_FLOATS_PER = 3; public final static int ATTR_N_FLOATS_PER = 3; public final static int ATTR_T_FLOATS_PER = 2; public final static int ATTR_SZ_FLOATS = ATTR_V_FLOATS_PER + ATTR_N_FLOATS_PER + ATTR_T_FLOATS_PER; public final static int ATTR_SZ_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_V_OFFSET_BYTES = 0; public final static int ATTR_V_OFFSET_FLOATS = 0; public final static int ATTR_N_OFFSET_FLOATS = ATTR_V_FLOATS_PER; public final static int ATTR_N_OFFSET_BYTES = ATTR_N_OFFSET_FLOATS * FL_SIZE; ; public final static int ATTR_T_OFFSET_FLOATS = ATTR_V_FLOATS_PER + ATTR_N_FLOATS_PER; public final static int ATTR_T_OFFSET_BYTES = ATTR_T_OFFSET_FLOATS * FL_SIZE; public final static int ATTR_V_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_N_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_T_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; private int textId = 0; private int verticeAttributesID = 0; // Vertex Attributes VBO ID private int indicesID = 0; // indice VBO ID private int indicesCount = 0;
// Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // } // // Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // } // Path: src/main/java/com/owens/oobjloader/lwjgl/VBO.java import com.owens.oobjloader.builder.Material; import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import java.nio.IntBuffer; package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class VBO { // sizeof float/sizeof int public final static int FL_SIZE = 4; public final static int INDICE_SIZE_BYTES = 4; // Vertex Attribute Data - i.e. x,y,z then normalx, normaly, normalz, then texture u,v - so 8 floats. public final static int ATTR_V_FLOATS_PER = 3; public final static int ATTR_N_FLOATS_PER = 3; public final static int ATTR_T_FLOATS_PER = 2; public final static int ATTR_SZ_FLOATS = ATTR_V_FLOATS_PER + ATTR_N_FLOATS_PER + ATTR_T_FLOATS_PER; public final static int ATTR_SZ_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_V_OFFSET_BYTES = 0; public final static int ATTR_V_OFFSET_FLOATS = 0; public final static int ATTR_N_OFFSET_FLOATS = ATTR_V_FLOATS_PER; public final static int ATTR_N_OFFSET_BYTES = ATTR_N_OFFSET_FLOATS * FL_SIZE; ; public final static int ATTR_T_OFFSET_FLOATS = ATTR_V_FLOATS_PER + ATTR_N_FLOATS_PER; public final static int ATTR_T_OFFSET_BYTES = ATTR_T_OFFSET_FLOATS * FL_SIZE; public final static int ATTR_V_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_N_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_T_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; private int textId = 0; private int verticeAttributesID = 0; // Vertex Attributes VBO ID private int indicesID = 0; // indice VBO ID private int indicesCount = 0;
public Material material;
CraftedCart/SMBLevelWorkshop
src/main/java/com/owens/oobjloader/lwjgl/VBO.java
// Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // } // // Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // }
import com.owens.oobjloader.builder.Material; import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import java.nio.IntBuffer;
public final static int ATTR_SZ_FLOATS = ATTR_V_FLOATS_PER + ATTR_N_FLOATS_PER + ATTR_T_FLOATS_PER; public final static int ATTR_SZ_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_V_OFFSET_BYTES = 0; public final static int ATTR_V_OFFSET_FLOATS = 0; public final static int ATTR_N_OFFSET_FLOATS = ATTR_V_FLOATS_PER; public final static int ATTR_N_OFFSET_BYTES = ATTR_N_OFFSET_FLOATS * FL_SIZE; ; public final static int ATTR_T_OFFSET_FLOATS = ATTR_V_FLOATS_PER + ATTR_N_FLOATS_PER; public final static int ATTR_T_OFFSET_BYTES = ATTR_T_OFFSET_FLOATS * FL_SIZE; public final static int ATTR_V_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_N_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_T_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; private int textId = 0; private int verticeAttributesID = 0; // Vertex Attributes VBO ID private int indicesID = 0; // indice VBO ID private int indicesCount = 0; public Material material; public VBO(int textId, Material material, int verticeAttributesID, int indicesID, int indicesCount) { this.textId = textId; this.verticeAttributesID = verticeAttributesID; this.indicesID = indicesID; this.indicesCount = indicesCount; this.material = material; }
// Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // } // // Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // } // Path: src/main/java/com/owens/oobjloader/lwjgl/VBO.java import com.owens.oobjloader.builder.Material; import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL15; import org.lwjgl.opengl.GL20; import java.nio.IntBuffer; public final static int ATTR_SZ_FLOATS = ATTR_V_FLOATS_PER + ATTR_N_FLOATS_PER + ATTR_T_FLOATS_PER; public final static int ATTR_SZ_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_V_OFFSET_BYTES = 0; public final static int ATTR_V_OFFSET_FLOATS = 0; public final static int ATTR_N_OFFSET_FLOATS = ATTR_V_FLOATS_PER; public final static int ATTR_N_OFFSET_BYTES = ATTR_N_OFFSET_FLOATS * FL_SIZE; ; public final static int ATTR_T_OFFSET_FLOATS = ATTR_V_FLOATS_PER + ATTR_N_FLOATS_PER; public final static int ATTR_T_OFFSET_BYTES = ATTR_T_OFFSET_FLOATS * FL_SIZE; public final static int ATTR_V_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_N_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; public final static int ATTR_T_STRIDE2_BYTES = ATTR_SZ_FLOATS * FL_SIZE; private int textId = 0; private int verticeAttributesID = 0; // Vertex Attributes VBO ID private int indicesID = 0; // indice VBO ID private int indicesCount = 0; public Material material; public VBO(int textId, Material material, int verticeAttributesID, int indicesID, int indicesCount) { this.textId = textId; this.verticeAttributesID = verticeAttributesID; this.indicesID = indicesID; this.indicesCount = indicesCount; this.material = material; }
public void render(ResourceShaderProgram shaderProgram, boolean setTexture) {
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/util/WSItemGroup.java
// Path: src/main/java/craftedcart/smblevelworkshop/asset/Placeable.java // public class Placeable implements Cloneable, ITransformable { // // @NotNull private IAsset asset; // // @NotNull private PosXYZ position = new PosXYZ(); // @NotNull private PosXYZ rotation = new PosXYZ(); // @NotNull private PosXYZ scale = new PosXYZ(1, 1, 1); // // public Placeable(@NotNull IAsset asset) { // this.asset = asset; // } // // public Placeable(@NotNull Goal goal) { // asset = new AssetGoal(); // position = new PosXYZ(goal.pos); // rotation = new PosXYZ(goal.rot); // // String type; // switch (goal.type) { // case BLUE: // type = "blueGoal"; // break; // case GREEN: // type = "greenGoal"; // break; // case RED: // type = "redGoal"; // break; // default: // //This shouldn't happen! Default to blue // type = "blueGoal"; // } // // asset.setType(type); // } // // public Placeable(@NotNull Bumper bumper) { // asset = new AssetBumper(); // position = new PosXYZ(bumper.pos); // rotation = new PosXYZ(bumper.rot); // scale = new PosXYZ(bumper.scl); // } // // public Placeable(@NotNull Jamabar jamabar) { // asset = new AssetJamabar(); // position = new PosXYZ(jamabar.pos); // rotation = new PosXYZ(jamabar.rot); // scale = new PosXYZ(jamabar.scl); // } // // public Placeable(@NotNull Banana banana) { // asset = new AssetBanana(); // position = new PosXYZ(banana.pos); // // String type; // switch (banana.type) { // case SINGLE: // type = "singleBanana"; // break; // case BUNCH: // type = "bunchBanana"; // break; // default: // //This shouldn't happen! Default to single // type = "singleBanana"; // } // // asset.setType(type); // } // // public Placeable(@NotNull Wormhole wormhole) { // AssetWormhole aWormhole = new AssetWormhole(); // asset = aWormhole; // position = new PosXYZ(wormhole.pos); // rotation = new PosXYZ(wormhole.rot); // aWormhole.setDestinationName(wormhole.destinationName); // } // // public void setAsset(@NotNull IAsset asset) { // this.asset = asset; // } // // @NotNull // public IAsset getAsset() { // return asset; // } // // public void setPosition(@NotNull PosXYZ position) { // this.position = position; // } // // @NotNull // public PosXYZ getPosition() { // return position; // } // // @Override // public boolean canMoveX() { // return getAsset().canGrabX(); // } // // @Override // public boolean canMoveY() { // return getAsset().canGrabY(); // } // // @Override // public boolean canMoveZ() { // return getAsset().canGrabZ(); // } // // @Override // public boolean canRotate() { // return getAsset().canRotate(); // } // // @Override // public boolean canScale() { // return getAsset().canScale(); // } // // public void setRotation(@NotNull PosXYZ rotation) { // this.rotation = rotation; // } // // @NotNull // public PosXYZ getRotation() { // return rotation; // } // // public void setScale(@NotNull PosXYZ scale) { // this.scale = scale; // } // // @NotNull // public PosXYZ getScale() { // return scale; // } // // public Placeable getCopy() { // try { // IAsset newAsset = asset.getCopy(); // Placeable newPlaceable = (Placeable) clone(); // newPlaceable.setAsset(newAsset); // return newPlaceable; // } catch (CloneNotSupportedException e) { // LogHelper.error(getClass(), "Failed to clone Placeable"); // LogHelper.error(getClass(), e); // return null; // } // } // // }
import craftedcart.smblevelworkshop.asset.Placeable; import io.github.craftedcart.fluidui.util.UIColor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*;
package craftedcart.smblevelworkshop.util; /** * @author CraftedCart * Created on 11/04/2017 (DD/MM/YYYY) */ public class WSItemGroup { @NotNull private UIColor color = UIColor.matGrey(); //Used in the UI @NotNull private Set<String> objectNames = new HashSet<>();
// Path: src/main/java/craftedcart/smblevelworkshop/asset/Placeable.java // public class Placeable implements Cloneable, ITransformable { // // @NotNull private IAsset asset; // // @NotNull private PosXYZ position = new PosXYZ(); // @NotNull private PosXYZ rotation = new PosXYZ(); // @NotNull private PosXYZ scale = new PosXYZ(1, 1, 1); // // public Placeable(@NotNull IAsset asset) { // this.asset = asset; // } // // public Placeable(@NotNull Goal goal) { // asset = new AssetGoal(); // position = new PosXYZ(goal.pos); // rotation = new PosXYZ(goal.rot); // // String type; // switch (goal.type) { // case BLUE: // type = "blueGoal"; // break; // case GREEN: // type = "greenGoal"; // break; // case RED: // type = "redGoal"; // break; // default: // //This shouldn't happen! Default to blue // type = "blueGoal"; // } // // asset.setType(type); // } // // public Placeable(@NotNull Bumper bumper) { // asset = new AssetBumper(); // position = new PosXYZ(bumper.pos); // rotation = new PosXYZ(bumper.rot); // scale = new PosXYZ(bumper.scl); // } // // public Placeable(@NotNull Jamabar jamabar) { // asset = new AssetJamabar(); // position = new PosXYZ(jamabar.pos); // rotation = new PosXYZ(jamabar.rot); // scale = new PosXYZ(jamabar.scl); // } // // public Placeable(@NotNull Banana banana) { // asset = new AssetBanana(); // position = new PosXYZ(banana.pos); // // String type; // switch (banana.type) { // case SINGLE: // type = "singleBanana"; // break; // case BUNCH: // type = "bunchBanana"; // break; // default: // //This shouldn't happen! Default to single // type = "singleBanana"; // } // // asset.setType(type); // } // // public Placeable(@NotNull Wormhole wormhole) { // AssetWormhole aWormhole = new AssetWormhole(); // asset = aWormhole; // position = new PosXYZ(wormhole.pos); // rotation = new PosXYZ(wormhole.rot); // aWormhole.setDestinationName(wormhole.destinationName); // } // // public void setAsset(@NotNull IAsset asset) { // this.asset = asset; // } // // @NotNull // public IAsset getAsset() { // return asset; // } // // public void setPosition(@NotNull PosXYZ position) { // this.position = position; // } // // @NotNull // public PosXYZ getPosition() { // return position; // } // // @Override // public boolean canMoveX() { // return getAsset().canGrabX(); // } // // @Override // public boolean canMoveY() { // return getAsset().canGrabY(); // } // // @Override // public boolean canMoveZ() { // return getAsset().canGrabZ(); // } // // @Override // public boolean canRotate() { // return getAsset().canRotate(); // } // // @Override // public boolean canScale() { // return getAsset().canScale(); // } // // public void setRotation(@NotNull PosXYZ rotation) { // this.rotation = rotation; // } // // @NotNull // public PosXYZ getRotation() { // return rotation; // } // // public void setScale(@NotNull PosXYZ scale) { // this.scale = scale; // } // // @NotNull // public PosXYZ getScale() { // return scale; // } // // public Placeable getCopy() { // try { // IAsset newAsset = asset.getCopy(); // Placeable newPlaceable = (Placeable) clone(); // newPlaceable.setAsset(newAsset); // return newPlaceable; // } catch (CloneNotSupportedException e) { // LogHelper.error(getClass(), "Failed to clone Placeable"); // LogHelper.error(getClass(), e); // return null; // } // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/util/WSItemGroup.java import craftedcart.smblevelworkshop.asset.Placeable; import io.github.craftedcart.fluidui.util.UIColor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; package craftedcart.smblevelworkshop.util; /** * @author CraftedCart * Created on 11/04/2017 (DD/MM/YYYY) */ public class WSItemGroup { @NotNull private UIColor color = UIColor.matGrey(); //Used in the UI @NotNull private Set<String> objectNames = new HashSet<>();
@NotNull private Map<String, Placeable> placeables = new HashMap<>();
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/ui/AskReplaceObjOverlayUIScreen.java
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // }
import craftedcart.smblevelworkshop.resource.LangManager; import craftedcart.smbworkshopexporter.util.LogHelper; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.Label; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.component.TextButton; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.util.UIColor;
backgroundPanel.setBackgroundColor(UIColor.pureBlack(0)); PluginSmoothAnimatePanelBackgroundColor backgroundPanelAnimColor = new PluginSmoothAnimatePanelBackgroundColor(); backgroundPanelAnimColor.setTargetBackgroundColor(UIColor.pureBlack(0.75)); backgroundPanel.addPlugin(backgroundPanelAnimColor); }); addChildComponent("backgroundPanel", backgroundPanel); final Panel mainPanel = new Panel(); mainPanel.setOnInitAction(() -> { mainPanel.setTopLeftPos(-256, -128); mainPanel.setBottomRightPos(256, 128); mainPanel.setTopLeftAnchor(0.5, 1.5); mainPanel.setBottomRightAnchor(0.5, 1.5); PluginSmoothAnimateAnchor mainPanelAnimAnchor = new PluginSmoothAnimateAnchor(); mainPanelAnimAnchor.setTargetTopLeftAnchor(0.5, 0.5); mainPanelAnimAnchor.setTargetBottomRightAnchor(0.5, 0.5); mainPanel.addPlugin(mainPanelAnimAnchor); }); backgroundPanel.addChildComponent("mainPanel", mainPanel); final Label titleLabel = new Label(); titleLabel.setOnInitAction(() -> { titleLabel.setTopLeftPos(24, 24); titleLabel.setBottomRightPos(-24, 72); titleLabel.setTopLeftAnchor(0, 0); titleLabel.setBottomRightAnchor(1, 0); titleLabel.setTextColor(UIColor.matGrey900());
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/ui/AskReplaceObjOverlayUIScreen.java import craftedcart.smblevelworkshop.resource.LangManager; import craftedcart.smbworkshopexporter.util.LogHelper; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.Label; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.component.TextButton; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.util.UIColor; backgroundPanel.setBackgroundColor(UIColor.pureBlack(0)); PluginSmoothAnimatePanelBackgroundColor backgroundPanelAnimColor = new PluginSmoothAnimatePanelBackgroundColor(); backgroundPanelAnimColor.setTargetBackgroundColor(UIColor.pureBlack(0.75)); backgroundPanel.addPlugin(backgroundPanelAnimColor); }); addChildComponent("backgroundPanel", backgroundPanel); final Panel mainPanel = new Panel(); mainPanel.setOnInitAction(() -> { mainPanel.setTopLeftPos(-256, -128); mainPanel.setBottomRightPos(256, 128); mainPanel.setTopLeftAnchor(0.5, 1.5); mainPanel.setBottomRightAnchor(0.5, 1.5); PluginSmoothAnimateAnchor mainPanelAnimAnchor = new PluginSmoothAnimateAnchor(); mainPanelAnimAnchor.setTargetTopLeftAnchor(0.5, 0.5); mainPanelAnimAnchor.setTargetBottomRightAnchor(0.5, 0.5); mainPanel.addPlugin(mainPanelAnimAnchor); }); backgroundPanel.addChildComponent("mainPanel", mainPanel); final Label titleLabel = new Label(); titleLabel.setOnInitAction(() -> { titleLabel.setTopLeftPos(24, 24); titleLabel.setBottomRightPos(-24, 72); titleLabel.setTopLeftAnchor(0, 0); titleLabel.setBottomRightAnchor(1, 0); titleLabel.setTextColor(UIColor.matGrey900());
titleLabel.setText(LangManager.getItem("importObj"));
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/ui/component/KeyDisplay.java
// Path: src/main/java/craftedcart/smblevelworkshop/util/MathUtils.java // public class MathUtils { // // public static double lerp(double a, double b, double f) { // return a + f * (b - a); // } // // /** // * Linearly interpolates between two {@link UIColor}s // * // * @param a The starting {@link UIColor} // * @param b The ending {@link UIColor} // * @param f The percentage between the two {@link UIColor} // * @return The {@link UIColor} which if f% between a and b // */ // public static UIColor lerpUIColor(UIColor a, UIColor b, float f) { // return new UIColor(a.r * 255 + f * (b.r * 255 - a.r * 255), // a.g * 255 + f * (b.g * 255 - a.g * 255), // a.b * 255 + f * (b.b * 255 - a.b * 255), // a.a * 255 + f * (b.a * 255 - a.a * 255)); // } // // public static double clamp(double val, double min, double max) { // return Math.max(min, Math.min(max, val)); // } // // public static PosXYZ normalizeRotation(PosXYZ rot) { // while (rot.x >= 360) { // rot.x -= 360; // } // // while (rot.y >= 360) { // rot.y -= 360; // } // // while (rot.z >= 360) { // rot.z -= 360; // } // // while (rot.x < 0) { // rot.x += 360; // } // // while (rot.y < 0) { // rot.y += 360; // } // // while (rot.z < 0) { // rot.z += 360; // } // // return rot; // } // // public static boolean isInRange(double val, double min, double max) { // return val >= min && val <= max; // } // // public static float snapTo(float val, float snapTo) { // float roundMultiplier = 1.0f / snapTo; // return Math.round(val * roundMultiplier) / roundMultiplier; // } // // /** // * @param t A value from 0 to 1 // * @return Quadratic interpolated value between 0 and 1 // */ // public static float cubicEaseInOut(float t) { // return t < 0.5f ? 4 * t * t * t : (t - 1f) * (2f * t - 2f) * (2f * t - 2f) + 1f; // } // // }
import craftedcart.smblevelworkshop.util.MathUtils; import io.github.craftedcart.fluidui.component.Label; import io.github.craftedcart.fluidui.component.ListBox; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.theme.UITheme; import io.github.craftedcart.fluidui.util.EnumHAlignment; import io.github.craftedcart.fluidui.util.EnumVAlignment; import io.github.craftedcart.fluidui.util.UIColor; import io.github.craftedcart.fluidui.util.UIUtils; import org.jetbrains.annotations.NotNull;
this.string = string; } @Override public void postInit() { super.postInit(); label = new Label(); label.setOnInitAction(() -> { label.setTopLeftPos(0, 0); label.setBottomRightPos(0, 0); label.setTopLeftAnchor(0, 0); label.setBottomRightAnchor(1, 1); label.setVerticalAlign(EnumVAlignment.centre); label.setHorizontalAlign(EnumHAlignment.right); label.setText(string); label.setFont(theme.headerFont); }); addChildComponent("label", label); } @Override public void draw() { super.draw(); if (flashTimerPercent > 0) { flashTimerPercent -= UIUtils.getDelta() * 4; //Lasts for 0.25 seconds flashTimerPercent = Math.max(flashTimerPercent, 0);
// Path: src/main/java/craftedcart/smblevelworkshop/util/MathUtils.java // public class MathUtils { // // public static double lerp(double a, double b, double f) { // return a + f * (b - a); // } // // /** // * Linearly interpolates between two {@link UIColor}s // * // * @param a The starting {@link UIColor} // * @param b The ending {@link UIColor} // * @param f The percentage between the two {@link UIColor} // * @return The {@link UIColor} which if f% between a and b // */ // public static UIColor lerpUIColor(UIColor a, UIColor b, float f) { // return new UIColor(a.r * 255 + f * (b.r * 255 - a.r * 255), // a.g * 255 + f * (b.g * 255 - a.g * 255), // a.b * 255 + f * (b.b * 255 - a.b * 255), // a.a * 255 + f * (b.a * 255 - a.a * 255)); // } // // public static double clamp(double val, double min, double max) { // return Math.max(min, Math.min(max, val)); // } // // public static PosXYZ normalizeRotation(PosXYZ rot) { // while (rot.x >= 360) { // rot.x -= 360; // } // // while (rot.y >= 360) { // rot.y -= 360; // } // // while (rot.z >= 360) { // rot.z -= 360; // } // // while (rot.x < 0) { // rot.x += 360; // } // // while (rot.y < 0) { // rot.y += 360; // } // // while (rot.z < 0) { // rot.z += 360; // } // // return rot; // } // // public static boolean isInRange(double val, double min, double max) { // return val >= min && val <= max; // } // // public static float snapTo(float val, float snapTo) { // float roundMultiplier = 1.0f / snapTo; // return Math.round(val * roundMultiplier) / roundMultiplier; // } // // /** // * @param t A value from 0 to 1 // * @return Quadratic interpolated value between 0 and 1 // */ // public static float cubicEaseInOut(float t) { // return t < 0.5f ? 4 * t * t * t : (t - 1f) * (2f * t - 2f) * (2f * t - 2f) + 1f; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/ui/component/KeyDisplay.java import craftedcart.smblevelworkshop.util.MathUtils; import io.github.craftedcart.fluidui.component.Label; import io.github.craftedcart.fluidui.component.ListBox; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.theme.UITheme; import io.github.craftedcart.fluidui.util.EnumHAlignment; import io.github.craftedcart.fluidui.util.EnumVAlignment; import io.github.craftedcart.fluidui.util.UIColor; import io.github.craftedcart.fluidui.util.UIUtils; import org.jetbrains.annotations.NotNull; this.string = string; } @Override public void postInit() { super.postInit(); label = new Label(); label.setOnInitAction(() -> { label.setTopLeftPos(0, 0); label.setBottomRightPos(0, 0); label.setTopLeftAnchor(0, 0); label.setBottomRightAnchor(1, 1); label.setVerticalAlign(EnumVAlignment.centre); label.setHorizontalAlign(EnumHAlignment.right); label.setText(string); label.setFont(theme.headerFont); }); addChildComponent("label", label); } @Override public void draw() { super.draw(); if (flashTimerPercent > 0) { flashTimerPercent -= UIUtils.getDelta() * 4; //Lasts for 0.25 seconds flashTimerPercent = Math.max(flashTimerPercent, 0);
label.setTextColor(MathUtils.lerpUIColor(UIColor.matWhite(), UIColor.matBlue(), flashTimerPercent).alpha(timerPercent == -1 ? 1 : timerPercent));
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/resource/ResourceShader.java
// Path: src/main/java/craftedcart/smblevelworkshop/exception/GLSLCompileException.java // public class GLSLCompileException extends Exception { // // public GLSLCompileException(String message) { // super("\n" + message); // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/Window.java // public static SharedDrawable drawable;
import craftedcart.smblevelworkshop.exception.GLSLCompileException; import craftedcart.smblevelworkshop.util.LogHelper; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import java.io.*; import static craftedcart.smblevelworkshop.Window.drawable;
package craftedcart.smblevelworkshop.resource; /** * @author CraftedCart * Created on 06/04/2016 (DD/MM/YYYY) */ public class ResourceShader implements IResource { private int shaderID; /** * @param shaderType The OpenGL id for the type of shader ({@link GL20#GL_VERTEX_SHADER} or {@link GL20#GL_FRAGMENT_SHADER}) * @param file the file where the shader is stored */
// Path: src/main/java/craftedcart/smblevelworkshop/exception/GLSLCompileException.java // public class GLSLCompileException extends Exception { // // public GLSLCompileException(String message) { // super("\n" + message); // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/Window.java // public static SharedDrawable drawable; // Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShader.java import craftedcart.smblevelworkshop.exception.GLSLCompileException; import craftedcart.smblevelworkshop.util.LogHelper; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import java.io.*; import static craftedcart.smblevelworkshop.Window.drawable; package craftedcart.smblevelworkshop.resource; /** * @author CraftedCart * Created on 06/04/2016 (DD/MM/YYYY) */ public class ResourceShader implements IResource { private int shaderID; /** * @param shaderType The OpenGL id for the type of shader ({@link GL20#GL_VERTEX_SHADER} or {@link GL20#GL_FRAGMENT_SHADER}) * @param file the file where the shader is stored */
public ResourceShader(int shaderType, File file) throws IOException, LWJGLException, GLSLCompileException {
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/resource/ResourceShader.java
// Path: src/main/java/craftedcart/smblevelworkshop/exception/GLSLCompileException.java // public class GLSLCompileException extends Exception { // // public GLSLCompileException(String message) { // super("\n" + message); // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/Window.java // public static SharedDrawable drawable;
import craftedcart.smblevelworkshop.exception.GLSLCompileException; import craftedcart.smblevelworkshop.util.LogHelper; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import java.io.*; import static craftedcart.smblevelworkshop.Window.drawable;
package craftedcart.smblevelworkshop.resource; /** * @author CraftedCart * Created on 06/04/2016 (DD/MM/YYYY) */ public class ResourceShader implements IResource { private int shaderID; /** * @param shaderType The OpenGL id for the type of shader ({@link GL20#GL_VERTEX_SHADER} or {@link GL20#GL_FRAGMENT_SHADER}) * @param file the file where the shader is stored */ public ResourceShader(int shaderType, File file) throws IOException, LWJGLException, GLSLCompileException {
// Path: src/main/java/craftedcart/smblevelworkshop/exception/GLSLCompileException.java // public class GLSLCompileException extends Exception { // // public GLSLCompileException(String message) { // super("\n" + message); // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/Window.java // public static SharedDrawable drawable; // Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShader.java import craftedcart.smblevelworkshop.exception.GLSLCompileException; import craftedcart.smblevelworkshop.util.LogHelper; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import java.io.*; import static craftedcart.smblevelworkshop.Window.drawable; package craftedcart.smblevelworkshop.resource; /** * @author CraftedCart * Created on 06/04/2016 (DD/MM/YYYY) */ public class ResourceShader implements IResource { private int shaderID; /** * @param shaderType The OpenGL id for the type of shader ({@link GL20#GL_VERTEX_SHADER} or {@link GL20#GL_FRAGMENT_SHADER}) * @param file the file where the shader is stored */ public ResourceShader(int shaderType, File file) throws IOException, LWJGLException, GLSLCompileException {
drawable.makeCurrent();
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/resource/ResourceShader.java
// Path: src/main/java/craftedcart/smblevelworkshop/exception/GLSLCompileException.java // public class GLSLCompileException extends Exception { // // public GLSLCompileException(String message) { // super("\n" + message); // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/Window.java // public static SharedDrawable drawable;
import craftedcart.smblevelworkshop.exception.GLSLCompileException; import craftedcart.smblevelworkshop.util.LogHelper; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import java.io.*; import static craftedcart.smblevelworkshop.Window.drawable;
package craftedcart.smblevelworkshop.resource; /** * @author CraftedCart * Created on 06/04/2016 (DD/MM/YYYY) */ public class ResourceShader implements IResource { private int shaderID; /** * @param shaderType The OpenGL id for the type of shader ({@link GL20#GL_VERTEX_SHADER} or {@link GL20#GL_FRAGMENT_SHADER}) * @param file the file where the shader is stored */ public ResourceShader(int shaderType, File file) throws IOException, LWJGLException, GLSLCompileException { drawable.makeCurrent(); shaderID = GL20.glCreateShader(shaderType); StringBuilder source = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line; while ((line = reader.readLine()) != null) { source.append(line).append('\n'); } reader.close(); GL20.glShaderSource(shaderID, source); GL20.glCompileShader(shaderID); if (GL20.glGetShaderi(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { //If it failed to compile
// Path: src/main/java/craftedcart/smblevelworkshop/exception/GLSLCompileException.java // public class GLSLCompileException extends Exception { // // public GLSLCompileException(String message) { // super("\n" + message); // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/Window.java // public static SharedDrawable drawable; // Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShader.java import craftedcart.smblevelworkshop.exception.GLSLCompileException; import craftedcart.smblevelworkshop.util.LogHelper; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL20; import java.io.*; import static craftedcart.smblevelworkshop.Window.drawable; package craftedcart.smblevelworkshop.resource; /** * @author CraftedCart * Created on 06/04/2016 (DD/MM/YYYY) */ public class ResourceShader implements IResource { private int shaderID; /** * @param shaderType The OpenGL id for the type of shader ({@link GL20#GL_VERTEX_SHADER} or {@link GL20#GL_FRAGMENT_SHADER}) * @param file the file where the shader is stored */ public ResourceShader(int shaderType, File file) throws IOException, LWJGLException, GLSLCompileException { drawable.makeCurrent(); shaderID = GL20.glCreateShader(shaderType); StringBuilder source = new StringBuilder(); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line; while ((line = reader.readLine()) != null) { source.append(line).append('\n'); } reader.close(); GL20.glShaderSource(shaderID, source); GL20.glCompileShader(shaderID); if (GL20.glGetShaderi(shaderID, GL20.GL_COMPILE_STATUS) == GL11.GL_FALSE) { //If it failed to compile
LogHelper.error(getClass(), String.format("Failed to compile the shader at \"%s\"", file.getPath()));
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/ui/TypeSelectorOverlayScreen.java
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // }
import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.component.ListBox; import io.github.craftedcart.fluidui.component.TextButton; import java.util.List;
package craftedcart.smblevelworkshop.ui; /** * @author CraftedCart * Created on 14/09/2016 (DD/MM/YYYY) */ public class TypeSelectorOverlayScreen extends FluidUIScreen { public TypeSelectorOverlayScreen(double mousePercentY, List<String> options) { init(mousePercentY, options); } private void init(double mousePercentY, List<String> options) { setTheme(new DefaultUITheme()); final ListBox listBox = new ListBox(); listBox.setOnInitAction(() -> { listBox.setTopLeftPos(-256, -38); listBox.setBottomRightPos(0, 38); listBox.setTopLeftAnchor(1, mousePercentY); listBox.setBottomRightAnchor(1, mousePercentY); }); addChildComponent("listBox", listBox); for (String string : options) { final TextButton button = new TextButton(); button.setOnInitAction(() -> {
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/ui/TypeSelectorOverlayScreen.java import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.component.ListBox; import io.github.craftedcart.fluidui.component.TextButton; import java.util.List; package craftedcart.smblevelworkshop.ui; /** * @author CraftedCart * Created on 14/09/2016 (DD/MM/YYYY) */ public class TypeSelectorOverlayScreen extends FluidUIScreen { public TypeSelectorOverlayScreen(double mousePercentY, List<String> options) { init(mousePercentY, options); } private void init(double mousePercentY, List<String> options) { setTheme(new DefaultUITheme()); final ListBox listBox = new ListBox(); listBox.setOnInitAction(() -> { listBox.setTopLeftPos(-256, -38); listBox.setBottomRightPos(0, 38); listBox.setTopLeftAnchor(1, mousePercentY); listBox.setBottomRightAnchor(1, mousePercentY); }); addChildComponent("listBox", listBox); for (String string : options) { final TextButton button = new TextButton(); button.setOnInitAction(() -> {
button.setText(LangManager.getItem(string));
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/animation/AnimData.java
// Path: src/main/java/craftedcart/smblevelworkshop/util/MathUtils.java // public class MathUtils { // // public static double lerp(double a, double b, double f) { // return a + f * (b - a); // } // // /** // * Linearly interpolates between two {@link UIColor}s // * // * @param a The starting {@link UIColor} // * @param b The ending {@link UIColor} // * @param f The percentage between the two {@link UIColor} // * @return The {@link UIColor} which if f% between a and b // */ // public static UIColor lerpUIColor(UIColor a, UIColor b, float f) { // return new UIColor(a.r * 255 + f * (b.r * 255 - a.r * 255), // a.g * 255 + f * (b.g * 255 - a.g * 255), // a.b * 255 + f * (b.b * 255 - a.b * 255), // a.a * 255 + f * (b.a * 255 - a.a * 255)); // } // // public static double clamp(double val, double min, double max) { // return Math.max(min, Math.min(max, val)); // } // // public static PosXYZ normalizeRotation(PosXYZ rot) { // while (rot.x >= 360) { // rot.x -= 360; // } // // while (rot.y >= 360) { // rot.y -= 360; // } // // while (rot.z >= 360) { // rot.z -= 360; // } // // while (rot.x < 0) { // rot.x += 360; // } // // while (rot.y < 0) { // rot.y += 360; // } // // while (rot.z < 0) { // rot.z += 360; // } // // return rot; // } // // public static boolean isInRange(double val, double min, double max) { // return val >= min && val <= max; // } // // public static float snapTo(float val, float snapTo) { // float roundMultiplier = 1.0f / snapTo; // return Math.round(val * roundMultiplier) / roundMultiplier; // } // // /** // * @param t A value from 0 to 1 // * @return Quadratic interpolated value between 0 and 1 // */ // public static float cubicEaseInOut(float t) { // return t < 0.5f ? 4 * t * t * t : (t - 1f) * (2f * t - 2f) * (2f * t - 2f) + 1f; // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/PosXYZ.java // public class PosXYZ { // // public double x; // public double y; // public double z; // // public PosXYZ() {} // // public PosXYZ(double x, double y, double z) { // this.x = x; // this.y = y; // this.z = z; // } // // public PosXYZ(craftedcart.smbworkshopexporter.util.Vec3f vec3f) { // this.x = vec3f.x; // this.y = vec3f.y; // this.z = vec3f.z; // } // // public PosXYZ add(PosXYZ pos) { // return new PosXYZ(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public PosXYZ add(double x, double y, double z) { // return new PosXYZ(this.x + x, this.y + y, this.z + z); // } // // public PosXYZ subtract(PosXYZ pos) { // return new PosXYZ(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public PosXYZ subtract(double x, double y, double z) { // return new PosXYZ(this.x - x, this.y - y, this.z - z); // } // // public PosXYZ multiply(double factor) { // return new PosXYZ(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof PosXYZ) { // PosXYZ posObj = (PosXYZ) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public PosXYZ getCopy() { // return new PosXYZ(x, y, z); // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/QuickMapEntry.java // public class QuickMapEntry<K, V> implements Map.Entry<K, V> { // // private K key; // private V value; // // public QuickMapEntry(K key, V value) { // this.key = key; // this.value = value; // } // // @Override // public K getKey() { // return key; // } // // @Override // public V getValue() { // return value; // } // // @Override // public V setValue(V value) { // return null; // } // // }
import craftedcart.smblevelworkshop.util.MathUtils; import craftedcart.smblevelworkshop.util.PosXYZ; import craftedcart.smblevelworkshop.util.QuickMapEntry; import craftedcart.smbworkshopexporter.ConfigAnimData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.Objects; import java.util.TreeMap;
package craftedcart.smblevelworkshop.animation; /** * @author CraftedCart * Created on 30/10/2016 (DD/MM/YYYY) */ @Deprecated public class AnimData {
// Path: src/main/java/craftedcart/smblevelworkshop/util/MathUtils.java // public class MathUtils { // // public static double lerp(double a, double b, double f) { // return a + f * (b - a); // } // // /** // * Linearly interpolates between two {@link UIColor}s // * // * @param a The starting {@link UIColor} // * @param b The ending {@link UIColor} // * @param f The percentage between the two {@link UIColor} // * @return The {@link UIColor} which if f% between a and b // */ // public static UIColor lerpUIColor(UIColor a, UIColor b, float f) { // return new UIColor(a.r * 255 + f * (b.r * 255 - a.r * 255), // a.g * 255 + f * (b.g * 255 - a.g * 255), // a.b * 255 + f * (b.b * 255 - a.b * 255), // a.a * 255 + f * (b.a * 255 - a.a * 255)); // } // // public static double clamp(double val, double min, double max) { // return Math.max(min, Math.min(max, val)); // } // // public static PosXYZ normalizeRotation(PosXYZ rot) { // while (rot.x >= 360) { // rot.x -= 360; // } // // while (rot.y >= 360) { // rot.y -= 360; // } // // while (rot.z >= 360) { // rot.z -= 360; // } // // while (rot.x < 0) { // rot.x += 360; // } // // while (rot.y < 0) { // rot.y += 360; // } // // while (rot.z < 0) { // rot.z += 360; // } // // return rot; // } // // public static boolean isInRange(double val, double min, double max) { // return val >= min && val <= max; // } // // public static float snapTo(float val, float snapTo) { // float roundMultiplier = 1.0f / snapTo; // return Math.round(val * roundMultiplier) / roundMultiplier; // } // // /** // * @param t A value from 0 to 1 // * @return Quadratic interpolated value between 0 and 1 // */ // public static float cubicEaseInOut(float t) { // return t < 0.5f ? 4 * t * t * t : (t - 1f) * (2f * t - 2f) * (2f * t - 2f) + 1f; // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/PosXYZ.java // public class PosXYZ { // // public double x; // public double y; // public double z; // // public PosXYZ() {} // // public PosXYZ(double x, double y, double z) { // this.x = x; // this.y = y; // this.z = z; // } // // public PosXYZ(craftedcart.smbworkshopexporter.util.Vec3f vec3f) { // this.x = vec3f.x; // this.y = vec3f.y; // this.z = vec3f.z; // } // // public PosXYZ add(PosXYZ pos) { // return new PosXYZ(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public PosXYZ add(double x, double y, double z) { // return new PosXYZ(this.x + x, this.y + y, this.z + z); // } // // public PosXYZ subtract(PosXYZ pos) { // return new PosXYZ(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public PosXYZ subtract(double x, double y, double z) { // return new PosXYZ(this.x - x, this.y - y, this.z - z); // } // // public PosXYZ multiply(double factor) { // return new PosXYZ(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof PosXYZ) { // PosXYZ posObj = (PosXYZ) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public PosXYZ getCopy() { // return new PosXYZ(x, y, z); // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/QuickMapEntry.java // public class QuickMapEntry<K, V> implements Map.Entry<K, V> { // // private K key; // private V value; // // public QuickMapEntry(K key, V value) { // this.key = key; // this.value = value; // } // // @Override // public K getKey() { // return key; // } // // @Override // public V getValue() { // return value; // } // // @Override // public V setValue(V value) { // return null; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/animation/AnimData.java import craftedcart.smblevelworkshop.util.MathUtils; import craftedcart.smblevelworkshop.util.PosXYZ; import craftedcart.smblevelworkshop.util.QuickMapEntry; import craftedcart.smbworkshopexporter.ConfigAnimData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.Objects; import java.util.TreeMap; package craftedcart.smblevelworkshop.animation; /** * @author CraftedCart * Created on 30/10/2016 (DD/MM/YYYY) */ @Deprecated public class AnimData {
@NotNull protected PosXYZ rotationCenter = new PosXYZ();
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/resource/model/OBJObject.java
// Path: src/main/java/craftedcart/smblevelworkshop/util/Vec3f.java // public class Vec3f { // // public float x; // public float y; // public float z; // // public Vec3f() {} // // public Vec3f(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // } // // public Vec3f add(Vec3f pos) { // return new Vec3f(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public Vec3f add(float x, float y, float z) { // return new Vec3f(this.x + x, this.y + y, this.z + z); // } // // public Vec3f subtract(Vec3f pos) { // return new Vec3f(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public Vec3f subtract(float x, float y, float z) { // return new Vec3f(this.x - x, this.y - y, this.z - z); // } // // public Vec3f multiply(float factor) { // return new Vec3f(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof Vec3f) { // Vec3f posObj = (Vec3f) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public Vec3f getCopy() { // return new Vec3f(x, y, z); // } // // }
import craftedcart.smblevelworkshop.util.Vec3f; import java.util.ArrayList; import java.util.List;
package craftedcart.smblevelworkshop.resource.model; /** * @author CraftedCart * Created on 10/10/2016 (DD/MM/YYYY) */ public class OBJObject { public String name; public List<OBJFacesByMaterial> facesByMaterialList = new ArrayList<>();
// Path: src/main/java/craftedcart/smblevelworkshop/util/Vec3f.java // public class Vec3f { // // public float x; // public float y; // public float z; // // public Vec3f() {} // // public Vec3f(float x, float y, float z) { // this.x = x; // this.y = y; // this.z = z; // } // // public Vec3f add(Vec3f pos) { // return new Vec3f(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public Vec3f add(float x, float y, float z) { // return new Vec3f(this.x + x, this.y + y, this.z + z); // } // // public Vec3f subtract(Vec3f pos) { // return new Vec3f(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public Vec3f subtract(float x, float y, float z) { // return new Vec3f(this.x - x, this.y - y, this.z - z); // } // // public Vec3f multiply(float factor) { // return new Vec3f(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof Vec3f) { // Vec3f posObj = (Vec3f) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public Vec3f getCopy() { // return new Vec3f(x, y, z); // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/resource/model/OBJObject.java import craftedcart.smblevelworkshop.util.Vec3f; import java.util.ArrayList; import java.util.List; package craftedcart.smblevelworkshop.resource.model; /** * @author CraftedCart * Created on 10/10/2016 (DD/MM/YYYY) */ public class OBJObject { public String name; public List<OBJFacesByMaterial> facesByMaterialList = new ArrayList<>();
private Vec3f centerPoint;
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/resource/model/ResourceModel.java
// Path: src/main/java/craftedcart/smblevelworkshop/resource/IResource.java // public interface IResource {} // // Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // }
import craftedcart.smblevelworkshop.resource.IResource; import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.opengl.GL11;
package craftedcart.smblevelworkshop.resource.model; /** * Created by CraftedCart on 25/02/2016 (DD/MM/YYYY) */ public class ResourceModel implements IResource { public OBJScene scene; public ResourceModel(OBJScene scene) { this.scene = scene; }
// Path: src/main/java/craftedcart/smblevelworkshop/resource/IResource.java // public interface IResource {} // // Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // } // Path: src/main/java/craftedcart/smblevelworkshop/resource/model/ResourceModel.java import craftedcart.smblevelworkshop.resource.IResource; import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.opengl.GL11; package craftedcart.smblevelworkshop.resource.model; /** * Created by CraftedCart on 25/02/2016 (DD/MM/YYYY) */ public class ResourceModel implements IResource { public OBJScene scene; public ResourceModel(OBJScene scene) { this.scene = scene; }
public void drawModel(ResourceShaderProgram shaderProgram, boolean setTexture) {
CraftedCart/SMBLevelWorkshop
src/main/java/com/owens/oobjloader/lwjgl/VBOFactory.java
// Path: src/main/java/com/owens/oobjloader/builder/Face.java // public class Face { // // public ArrayList<FaceVertex> vertices = new ArrayList<FaceVertex>(); // public Material material = null; // public Material map = null; // public VertexNormal faceNormal = new VertexNormal(0, 0, 0); // public String objectName; // // public Face() { // } // // public void add(FaceVertex vertex) { // vertices.add(vertex); // } // // // @TODO: This code assumes the face is a triangle. // public void calculateTriangleNormal() { // float[] edge1 = new float[3]; // float[] edge2 = new float[3]; // float[] normal = new float[3]; // VertexGeometric v1 = vertices.get(0).v; // VertexGeometric v2 = vertices.get(1).v; // VertexGeometric v3 = vertices.get(2).v; // float[] p1 = {v1.x, v1.y, v1.z}; // float[] p2 = {v2.x, v2.y, v2.z}; // float[] p3 = {v3.x, v3.y, v3.z}; // // edge1[0] = p2[0] - p1[0]; // edge1[1] = p2[1] - p1[1]; // edge1[2] = p2[2] - p1[2]; // // edge2[0] = p3[0] - p2[0]; // edge2[1] = p3[1] - p2[1]; // edge2[2] = p3[2] - p2[2]; // // normal[0] = edge1[1] * edge2[2] - edge1[2] * edge2[1]; // normal[1] = edge1[2] * edge2[0] - edge1[0] * edge2[2]; // normal[2] = edge1[0] * edge2[1] - edge1[1] * edge2[0]; // // faceNormal.x = normal[0]; // faceNormal.y = normal[1]; // faceNormal.z = normal[2]; // } // // public String toString() { // String result = "\tvertices: "+vertices.size()+" :\n"; // for(FaceVertex f : vertices) { // result += " \t\t( "+f.toString()+" )\n"; // } // return result; // } // // } // // Path: src/main/java/com/owens/oobjloader/builder/FaceVertex.java // public class FaceVertex { // // int index = -1; // public VertexGeometric v = null; // public VertexTexture t = null; // public VertexNormal n = null; // // public String toString() { // return v + "|" + n + "|" + t; // } // } // // Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // }
import com.owens.oobjloader.builder.Face; import com.owens.oobjloader.builder.FaceVertex; import com.owens.oobjloader.builder.Material; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.ARBVertexBufferObject; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Logger; import static java.util.logging.Level.INFO; import static java.util.logging.Level.SEVERE;
package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class VBOFactory { private static Logger log = Logger.getLogger(VBOFactory.class.getName());
// Path: src/main/java/com/owens/oobjloader/builder/Face.java // public class Face { // // public ArrayList<FaceVertex> vertices = new ArrayList<FaceVertex>(); // public Material material = null; // public Material map = null; // public VertexNormal faceNormal = new VertexNormal(0, 0, 0); // public String objectName; // // public Face() { // } // // public void add(FaceVertex vertex) { // vertices.add(vertex); // } // // // @TODO: This code assumes the face is a triangle. // public void calculateTriangleNormal() { // float[] edge1 = new float[3]; // float[] edge2 = new float[3]; // float[] normal = new float[3]; // VertexGeometric v1 = vertices.get(0).v; // VertexGeometric v2 = vertices.get(1).v; // VertexGeometric v3 = vertices.get(2).v; // float[] p1 = {v1.x, v1.y, v1.z}; // float[] p2 = {v2.x, v2.y, v2.z}; // float[] p3 = {v3.x, v3.y, v3.z}; // // edge1[0] = p2[0] - p1[0]; // edge1[1] = p2[1] - p1[1]; // edge1[2] = p2[2] - p1[2]; // // edge2[0] = p3[0] - p2[0]; // edge2[1] = p3[1] - p2[1]; // edge2[2] = p3[2] - p2[2]; // // normal[0] = edge1[1] * edge2[2] - edge1[2] * edge2[1]; // normal[1] = edge1[2] * edge2[0] - edge1[0] * edge2[2]; // normal[2] = edge1[0] * edge2[1] - edge1[1] * edge2[0]; // // faceNormal.x = normal[0]; // faceNormal.y = normal[1]; // faceNormal.z = normal[2]; // } // // public String toString() { // String result = "\tvertices: "+vertices.size()+" :\n"; // for(FaceVertex f : vertices) { // result += " \t\t( "+f.toString()+" )\n"; // } // return result; // } // // } // // Path: src/main/java/com/owens/oobjloader/builder/FaceVertex.java // public class FaceVertex { // // int index = -1; // public VertexGeometric v = null; // public VertexTexture t = null; // public VertexNormal n = null; // // public String toString() { // return v + "|" + n + "|" + t; // } // } // // Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // } // Path: src/main/java/com/owens/oobjloader/lwjgl/VBOFactory.java import com.owens.oobjloader.builder.Face; import com.owens.oobjloader.builder.FaceVertex; import com.owens.oobjloader.builder.Material; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.ARBVertexBufferObject; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Logger; import static java.util.logging.Level.INFO; import static java.util.logging.Level.SEVERE; package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class VBOFactory { private static Logger log = Logger.getLogger(VBOFactory.class.getName());
public static VBO build(int textureID, Material material, ArrayList<Face> triangles) {
CraftedCart/SMBLevelWorkshop
src/main/java/com/owens/oobjloader/lwjgl/VBOFactory.java
// Path: src/main/java/com/owens/oobjloader/builder/Face.java // public class Face { // // public ArrayList<FaceVertex> vertices = new ArrayList<FaceVertex>(); // public Material material = null; // public Material map = null; // public VertexNormal faceNormal = new VertexNormal(0, 0, 0); // public String objectName; // // public Face() { // } // // public void add(FaceVertex vertex) { // vertices.add(vertex); // } // // // @TODO: This code assumes the face is a triangle. // public void calculateTriangleNormal() { // float[] edge1 = new float[3]; // float[] edge2 = new float[3]; // float[] normal = new float[3]; // VertexGeometric v1 = vertices.get(0).v; // VertexGeometric v2 = vertices.get(1).v; // VertexGeometric v3 = vertices.get(2).v; // float[] p1 = {v1.x, v1.y, v1.z}; // float[] p2 = {v2.x, v2.y, v2.z}; // float[] p3 = {v3.x, v3.y, v3.z}; // // edge1[0] = p2[0] - p1[0]; // edge1[1] = p2[1] - p1[1]; // edge1[2] = p2[2] - p1[2]; // // edge2[0] = p3[0] - p2[0]; // edge2[1] = p3[1] - p2[1]; // edge2[2] = p3[2] - p2[2]; // // normal[0] = edge1[1] * edge2[2] - edge1[2] * edge2[1]; // normal[1] = edge1[2] * edge2[0] - edge1[0] * edge2[2]; // normal[2] = edge1[0] * edge2[1] - edge1[1] * edge2[0]; // // faceNormal.x = normal[0]; // faceNormal.y = normal[1]; // faceNormal.z = normal[2]; // } // // public String toString() { // String result = "\tvertices: "+vertices.size()+" :\n"; // for(FaceVertex f : vertices) { // result += " \t\t( "+f.toString()+" )\n"; // } // return result; // } // // } // // Path: src/main/java/com/owens/oobjloader/builder/FaceVertex.java // public class FaceVertex { // // int index = -1; // public VertexGeometric v = null; // public VertexTexture t = null; // public VertexNormal n = null; // // public String toString() { // return v + "|" + n + "|" + t; // } // } // // Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // }
import com.owens.oobjloader.builder.Face; import com.owens.oobjloader.builder.FaceVertex; import com.owens.oobjloader.builder.Material; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.ARBVertexBufferObject; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Logger; import static java.util.logging.Level.INFO; import static java.util.logging.Level.SEVERE;
package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class VBOFactory { private static Logger log = Logger.getLogger(VBOFactory.class.getName());
// Path: src/main/java/com/owens/oobjloader/builder/Face.java // public class Face { // // public ArrayList<FaceVertex> vertices = new ArrayList<FaceVertex>(); // public Material material = null; // public Material map = null; // public VertexNormal faceNormal = new VertexNormal(0, 0, 0); // public String objectName; // // public Face() { // } // // public void add(FaceVertex vertex) { // vertices.add(vertex); // } // // // @TODO: This code assumes the face is a triangle. // public void calculateTriangleNormal() { // float[] edge1 = new float[3]; // float[] edge2 = new float[3]; // float[] normal = new float[3]; // VertexGeometric v1 = vertices.get(0).v; // VertexGeometric v2 = vertices.get(1).v; // VertexGeometric v3 = vertices.get(2).v; // float[] p1 = {v1.x, v1.y, v1.z}; // float[] p2 = {v2.x, v2.y, v2.z}; // float[] p3 = {v3.x, v3.y, v3.z}; // // edge1[0] = p2[0] - p1[0]; // edge1[1] = p2[1] - p1[1]; // edge1[2] = p2[2] - p1[2]; // // edge2[0] = p3[0] - p2[0]; // edge2[1] = p3[1] - p2[1]; // edge2[2] = p3[2] - p2[2]; // // normal[0] = edge1[1] * edge2[2] - edge1[2] * edge2[1]; // normal[1] = edge1[2] * edge2[0] - edge1[0] * edge2[2]; // normal[2] = edge1[0] * edge2[1] - edge1[1] * edge2[0]; // // faceNormal.x = normal[0]; // faceNormal.y = normal[1]; // faceNormal.z = normal[2]; // } // // public String toString() { // String result = "\tvertices: "+vertices.size()+" :\n"; // for(FaceVertex f : vertices) { // result += " \t\t( "+f.toString()+" )\n"; // } // return result; // } // // } // // Path: src/main/java/com/owens/oobjloader/builder/FaceVertex.java // public class FaceVertex { // // int index = -1; // public VertexGeometric v = null; // public VertexTexture t = null; // public VertexNormal n = null; // // public String toString() { // return v + "|" + n + "|" + t; // } // } // // Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // } // Path: src/main/java/com/owens/oobjloader/lwjgl/VBOFactory.java import com.owens.oobjloader.builder.Face; import com.owens.oobjloader.builder.FaceVertex; import com.owens.oobjloader.builder.Material; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.ARBVertexBufferObject; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Logger; import static java.util.logging.Level.INFO; import static java.util.logging.Level.SEVERE; package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class VBOFactory { private static Logger log = Logger.getLogger(VBOFactory.class.getName());
public static VBO build(int textureID, Material material, ArrayList<Face> triangles) {
CraftedCart/SMBLevelWorkshop
src/main/java/com/owens/oobjloader/lwjgl/VBOFactory.java
// Path: src/main/java/com/owens/oobjloader/builder/Face.java // public class Face { // // public ArrayList<FaceVertex> vertices = new ArrayList<FaceVertex>(); // public Material material = null; // public Material map = null; // public VertexNormal faceNormal = new VertexNormal(0, 0, 0); // public String objectName; // // public Face() { // } // // public void add(FaceVertex vertex) { // vertices.add(vertex); // } // // // @TODO: This code assumes the face is a triangle. // public void calculateTriangleNormal() { // float[] edge1 = new float[3]; // float[] edge2 = new float[3]; // float[] normal = new float[3]; // VertexGeometric v1 = vertices.get(0).v; // VertexGeometric v2 = vertices.get(1).v; // VertexGeometric v3 = vertices.get(2).v; // float[] p1 = {v1.x, v1.y, v1.z}; // float[] p2 = {v2.x, v2.y, v2.z}; // float[] p3 = {v3.x, v3.y, v3.z}; // // edge1[0] = p2[0] - p1[0]; // edge1[1] = p2[1] - p1[1]; // edge1[2] = p2[2] - p1[2]; // // edge2[0] = p3[0] - p2[0]; // edge2[1] = p3[1] - p2[1]; // edge2[2] = p3[2] - p2[2]; // // normal[0] = edge1[1] * edge2[2] - edge1[2] * edge2[1]; // normal[1] = edge1[2] * edge2[0] - edge1[0] * edge2[2]; // normal[2] = edge1[0] * edge2[1] - edge1[1] * edge2[0]; // // faceNormal.x = normal[0]; // faceNormal.y = normal[1]; // faceNormal.z = normal[2]; // } // // public String toString() { // String result = "\tvertices: "+vertices.size()+" :\n"; // for(FaceVertex f : vertices) { // result += " \t\t( "+f.toString()+" )\n"; // } // return result; // } // // } // // Path: src/main/java/com/owens/oobjloader/builder/FaceVertex.java // public class FaceVertex { // // int index = -1; // public VertexGeometric v = null; // public VertexTexture t = null; // public VertexNormal n = null; // // public String toString() { // return v + "|" + n + "|" + t; // } // } // // Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // }
import com.owens.oobjloader.builder.Face; import com.owens.oobjloader.builder.FaceVertex; import com.owens.oobjloader.builder.Material; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.ARBVertexBufferObject; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Logger; import static java.util.logging.Level.INFO; import static java.util.logging.Level.SEVERE;
package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class VBOFactory { private static Logger log = Logger.getLogger(VBOFactory.class.getName()); public static VBO build(int textureID, Material material, ArrayList<Face> triangles) { // log.log(INFO, "building a vbo!"); if (triangles.size() <= 0) { throw new RuntimeException("Can not build a VBO if we have no triangles with which to build it."); } // Now sort out the triangle/vertex indices, so we can use a // VertexArray in our VBO. Note the following is NOT the most efficient way // to do this, but hopefully it is clear. // First build a map of the unique FaceVertex objects, since Faces may share FaceVertex objects. // And while we're at it, assign each unique FaceVertex object an index as we run across them, storing // this index in the map, for use later when we build the "index" buffer that refers to the vertice buffer. // And lastly, keep a list of the unique vertice objects, in the order that we find them in.
// Path: src/main/java/com/owens/oobjloader/builder/Face.java // public class Face { // // public ArrayList<FaceVertex> vertices = new ArrayList<FaceVertex>(); // public Material material = null; // public Material map = null; // public VertexNormal faceNormal = new VertexNormal(0, 0, 0); // public String objectName; // // public Face() { // } // // public void add(FaceVertex vertex) { // vertices.add(vertex); // } // // // @TODO: This code assumes the face is a triangle. // public void calculateTriangleNormal() { // float[] edge1 = new float[3]; // float[] edge2 = new float[3]; // float[] normal = new float[3]; // VertexGeometric v1 = vertices.get(0).v; // VertexGeometric v2 = vertices.get(1).v; // VertexGeometric v3 = vertices.get(2).v; // float[] p1 = {v1.x, v1.y, v1.z}; // float[] p2 = {v2.x, v2.y, v2.z}; // float[] p3 = {v3.x, v3.y, v3.z}; // // edge1[0] = p2[0] - p1[0]; // edge1[1] = p2[1] - p1[1]; // edge1[2] = p2[2] - p1[2]; // // edge2[0] = p3[0] - p2[0]; // edge2[1] = p3[1] - p2[1]; // edge2[2] = p3[2] - p2[2]; // // normal[0] = edge1[1] * edge2[2] - edge1[2] * edge2[1]; // normal[1] = edge1[2] * edge2[0] - edge1[0] * edge2[2]; // normal[2] = edge1[0] * edge2[1] - edge1[1] * edge2[0]; // // faceNormal.x = normal[0]; // faceNormal.y = normal[1]; // faceNormal.z = normal[2]; // } // // public String toString() { // String result = "\tvertices: "+vertices.size()+" :\n"; // for(FaceVertex f : vertices) { // result += " \t\t( "+f.toString()+" )\n"; // } // return result; // } // // } // // Path: src/main/java/com/owens/oobjloader/builder/FaceVertex.java // public class FaceVertex { // // int index = -1; // public VertexGeometric v = null; // public VertexTexture t = null; // public VertexNormal n = null; // // public String toString() { // return v + "|" + n + "|" + t; // } // } // // Path: src/main/java/com/owens/oobjloader/builder/Material.java // public class Material { // // public String name; // public ReflectivityTransmiss ka = new ReflectivityTransmiss(); // public ReflectivityTransmiss kd = new ReflectivityTransmiss(); // public ReflectivityTransmiss ks = new ReflectivityTransmiss(); // public ReflectivityTransmiss tf = new ReflectivityTransmiss(); // public int illumModel = 0; // public boolean dHalo = false; // public double dFactor = 0.0; // public double nsExponent = 0.0; // public double sharpnessValue = 0.0; // public double niOpticalDensity = 0.0; // public String mapKaFilename = null; // public String mapKdFilename = null; // public String mapKsFilename = null; // public String mapNsFilename = null; // public String mapDFilename = null; // public String decalFilename = null; // public String dispFilename = null; // public String bumpFilename = null; // public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN; // public String reflFilename = null; // // public Material(String name) { // this.name = name; // } // } // Path: src/main/java/com/owens/oobjloader/lwjgl/VBOFactory.java import com.owens.oobjloader.builder.Face; import com.owens.oobjloader.builder.FaceVertex; import com.owens.oobjloader.builder.Material; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.ARBVertexBufferObject; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Logger; import static java.util.logging.Level.INFO; import static java.util.logging.Level.SEVERE; package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class VBOFactory { private static Logger log = Logger.getLogger(VBOFactory.class.getName()); public static VBO build(int textureID, Material material, ArrayList<Face> triangles) { // log.log(INFO, "building a vbo!"); if (triangles.size() <= 0) { throw new RuntimeException("Can not build a VBO if we have no triangles with which to build it."); } // Now sort out the triangle/vertex indices, so we can use a // VertexArray in our VBO. Note the following is NOT the most efficient way // to do this, but hopefully it is clear. // First build a map of the unique FaceVertex objects, since Faces may share FaceVertex objects. // And while we're at it, assign each unique FaceVertex object an index as we run across them, storing // this index in the map, for use later when we build the "index" buffer that refers to the vertice buffer. // And lastly, keep a list of the unique vertice objects, in the order that we find them in.
HashMap<FaceVertex, Integer> indexMap = new HashMap<FaceVertex, Integer>();
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/ui/DialogOverlayUIScreen.java
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // }
import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.Label; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.component.TextButton; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.util.UIColor;
final Label titleLabel = new Label(); titleLabel.setOnInitAction(() -> { titleLabel.setTopLeftPos(24, 24); titleLabel.setBottomRightPos(-24, 72); titleLabel.setTopLeftAnchor(0, 0); titleLabel.setBottomRightAnchor(1, 0); titleLabel.setTextColor(UIColor.matGrey900()); titleLabel.setText(title); titleLabel.setFont(FontCache.getUnicodeFont("Roboto-Regular", 24)); }); mainPanel.addChildComponent("titleLabel", titleLabel); final Label label = new Label(); label.setOnInitAction(() -> { label.setTopLeftPos(24, 72); label.setBottomRightPos(-24, -72); label.setTopLeftAnchor(0, 0); label.setBottomRightAnchor(1, 1); label.setTextColor(UIColor.matGrey900()); label.setText(message); }); mainPanel.addChildComponent("label", label); final TextButton okButton = new TextButton(); okButton.setOnInitAction(() -> { okButton.setTopLeftPos(-152, -48); okButton.setBottomRightPos(-24, -24); okButton.setTopLeftAnchor(1, 1); okButton.setBottomRightAnchor(1, 1);
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/ui/DialogOverlayUIScreen.java import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.Label; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.component.TextButton; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.util.UIColor; final Label titleLabel = new Label(); titleLabel.setOnInitAction(() -> { titleLabel.setTopLeftPos(24, 24); titleLabel.setBottomRightPos(-24, 72); titleLabel.setTopLeftAnchor(0, 0); titleLabel.setBottomRightAnchor(1, 0); titleLabel.setTextColor(UIColor.matGrey900()); titleLabel.setText(title); titleLabel.setFont(FontCache.getUnicodeFont("Roboto-Regular", 24)); }); mainPanel.addChildComponent("titleLabel", titleLabel); final Label label = new Label(); label.setOnInitAction(() -> { label.setTopLeftPos(24, 72); label.setBottomRightPos(-24, -72); label.setTopLeftAnchor(0, 0); label.setBottomRightAnchor(1, 1); label.setTextColor(UIColor.matGrey900()); label.setText(message); }); mainPanel.addChildComponent("label", label); final TextButton okButton = new TextButton(); okButton.setOnInitAction(() -> { okButton.setTopLeftPos(-152, -48); okButton.setBottomRightPos(-24, -24); okButton.setTopLeftAnchor(1, 1); okButton.setBottomRightAnchor(1, 1);
okButton.setText(LangManager.getItem("ok"));
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/util/DepthSortedPlaceable.java
// Path: src/main/java/craftedcart/smblevelworkshop/asset/Placeable.java // public class Placeable implements Cloneable, ITransformable { // // @NotNull private IAsset asset; // // @NotNull private PosXYZ position = new PosXYZ(); // @NotNull private PosXYZ rotation = new PosXYZ(); // @NotNull private PosXYZ scale = new PosXYZ(1, 1, 1); // // public Placeable(@NotNull IAsset asset) { // this.asset = asset; // } // // public Placeable(@NotNull Goal goal) { // asset = new AssetGoal(); // position = new PosXYZ(goal.pos); // rotation = new PosXYZ(goal.rot); // // String type; // switch (goal.type) { // case BLUE: // type = "blueGoal"; // break; // case GREEN: // type = "greenGoal"; // break; // case RED: // type = "redGoal"; // break; // default: // //This shouldn't happen! Default to blue // type = "blueGoal"; // } // // asset.setType(type); // } // // public Placeable(@NotNull Bumper bumper) { // asset = new AssetBumper(); // position = new PosXYZ(bumper.pos); // rotation = new PosXYZ(bumper.rot); // scale = new PosXYZ(bumper.scl); // } // // public Placeable(@NotNull Jamabar jamabar) { // asset = new AssetJamabar(); // position = new PosXYZ(jamabar.pos); // rotation = new PosXYZ(jamabar.rot); // scale = new PosXYZ(jamabar.scl); // } // // public Placeable(@NotNull Banana banana) { // asset = new AssetBanana(); // position = new PosXYZ(banana.pos); // // String type; // switch (banana.type) { // case SINGLE: // type = "singleBanana"; // break; // case BUNCH: // type = "bunchBanana"; // break; // default: // //This shouldn't happen! Default to single // type = "singleBanana"; // } // // asset.setType(type); // } // // public Placeable(@NotNull Wormhole wormhole) { // AssetWormhole aWormhole = new AssetWormhole(); // asset = aWormhole; // position = new PosXYZ(wormhole.pos); // rotation = new PosXYZ(wormhole.rot); // aWormhole.setDestinationName(wormhole.destinationName); // } // // public void setAsset(@NotNull IAsset asset) { // this.asset = asset; // } // // @NotNull // public IAsset getAsset() { // return asset; // } // // public void setPosition(@NotNull PosXYZ position) { // this.position = position; // } // // @NotNull // public PosXYZ getPosition() { // return position; // } // // @Override // public boolean canMoveX() { // return getAsset().canGrabX(); // } // // @Override // public boolean canMoveY() { // return getAsset().canGrabY(); // } // // @Override // public boolean canMoveZ() { // return getAsset().canGrabZ(); // } // // @Override // public boolean canRotate() { // return getAsset().canRotate(); // } // // @Override // public boolean canScale() { // return getAsset().canScale(); // } // // public void setRotation(@NotNull PosXYZ rotation) { // this.rotation = rotation; // } // // @NotNull // public PosXYZ getRotation() { // return rotation; // } // // public void setScale(@NotNull PosXYZ scale) { // this.scale = scale; // } // // @NotNull // public PosXYZ getScale() { // return scale; // } // // public Placeable getCopy() { // try { // IAsset newAsset = asset.getCopy(); // Placeable newPlaceable = (Placeable) clone(); // newPlaceable.setAsset(newAsset); // return newPlaceable; // } catch (CloneNotSupportedException e) { // LogHelper.error(getClass(), "Failed to clone Placeable"); // LogHelper.error(getClass(), e); // return null; // } // } // // }
import craftedcart.smblevelworkshop.asset.Placeable; import java.util.Map;
package craftedcart.smblevelworkshop.util; /** * @author CraftedCart * Created on 25/09/2016 (DD/MM/YYYY) */ public class DepthSortedPlaceable { public double depth;
// Path: src/main/java/craftedcart/smblevelworkshop/asset/Placeable.java // public class Placeable implements Cloneable, ITransformable { // // @NotNull private IAsset asset; // // @NotNull private PosXYZ position = new PosXYZ(); // @NotNull private PosXYZ rotation = new PosXYZ(); // @NotNull private PosXYZ scale = new PosXYZ(1, 1, 1); // // public Placeable(@NotNull IAsset asset) { // this.asset = asset; // } // // public Placeable(@NotNull Goal goal) { // asset = new AssetGoal(); // position = new PosXYZ(goal.pos); // rotation = new PosXYZ(goal.rot); // // String type; // switch (goal.type) { // case BLUE: // type = "blueGoal"; // break; // case GREEN: // type = "greenGoal"; // break; // case RED: // type = "redGoal"; // break; // default: // //This shouldn't happen! Default to blue // type = "blueGoal"; // } // // asset.setType(type); // } // // public Placeable(@NotNull Bumper bumper) { // asset = new AssetBumper(); // position = new PosXYZ(bumper.pos); // rotation = new PosXYZ(bumper.rot); // scale = new PosXYZ(bumper.scl); // } // // public Placeable(@NotNull Jamabar jamabar) { // asset = new AssetJamabar(); // position = new PosXYZ(jamabar.pos); // rotation = new PosXYZ(jamabar.rot); // scale = new PosXYZ(jamabar.scl); // } // // public Placeable(@NotNull Banana banana) { // asset = new AssetBanana(); // position = new PosXYZ(banana.pos); // // String type; // switch (banana.type) { // case SINGLE: // type = "singleBanana"; // break; // case BUNCH: // type = "bunchBanana"; // break; // default: // //This shouldn't happen! Default to single // type = "singleBanana"; // } // // asset.setType(type); // } // // public Placeable(@NotNull Wormhole wormhole) { // AssetWormhole aWormhole = new AssetWormhole(); // asset = aWormhole; // position = new PosXYZ(wormhole.pos); // rotation = new PosXYZ(wormhole.rot); // aWormhole.setDestinationName(wormhole.destinationName); // } // // public void setAsset(@NotNull IAsset asset) { // this.asset = asset; // } // // @NotNull // public IAsset getAsset() { // return asset; // } // // public void setPosition(@NotNull PosXYZ position) { // this.position = position; // } // // @NotNull // public PosXYZ getPosition() { // return position; // } // // @Override // public boolean canMoveX() { // return getAsset().canGrabX(); // } // // @Override // public boolean canMoveY() { // return getAsset().canGrabY(); // } // // @Override // public boolean canMoveZ() { // return getAsset().canGrabZ(); // } // // @Override // public boolean canRotate() { // return getAsset().canRotate(); // } // // @Override // public boolean canScale() { // return getAsset().canScale(); // } // // public void setRotation(@NotNull PosXYZ rotation) { // this.rotation = rotation; // } // // @NotNull // public PosXYZ getRotation() { // return rotation; // } // // public void setScale(@NotNull PosXYZ scale) { // this.scale = scale; // } // // @NotNull // public PosXYZ getScale() { // return scale; // } // // public Placeable getCopy() { // try { // IAsset newAsset = asset.getCopy(); // Placeable newPlaceable = (Placeable) clone(); // newPlaceable.setAsset(newAsset); // return newPlaceable; // } catch (CloneNotSupportedException e) { // LogHelper.error(getClass(), "Failed to clone Placeable"); // LogHelper.error(getClass(), e); // return null; // } // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/util/DepthSortedPlaceable.java import craftedcart.smblevelworkshop.asset.Placeable; import java.util.Map; package craftedcart.smblevelworkshop.util; /** * @author CraftedCart * Created on 25/09/2016 (DD/MM/YYYY) */ public class DepthSortedPlaceable { public double depth;
public Map.Entry<String, Placeable> entry;
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/ui/ProjectSettingsOverlayUIScreen.java
// Path: src/main/java/craftedcart/smblevelworkshop/project/ProjectManager.java // public class ProjectManager { // // private static Project currentProject; // // public static void setCurrentProject(Project currentProject) { // ProjectManager.currentProject = currentProject; // } // // public static Project getCurrentProject() { // return currentProject; // } // // public static LevelData getCurrentLevelData() { // return getCurrentProject().clientLevelData.getLevelData(); // } // // public static ClientLevelData getCurrentClientLevelData() { // return getCurrentProject().clientLevelData; // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // }
import craftedcart.smblevelworkshop.project.ProjectManager; import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.*; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.uiaction.UIAction; import io.github.craftedcart.fluidui.util.UIColor; import java.io.File;
backgroundPanel.setBackgroundColor(UIColor.pureBlack(0)); PluginSmoothAnimatePanelBackgroundColor backgroundPanelAnimColor = new PluginSmoothAnimatePanelBackgroundColor(); backgroundPanelAnimColor.setTargetBackgroundColor(UIColor.pureBlack(0.75)); backgroundPanel.addPlugin(backgroundPanelAnimColor); }); addChildComponent("backgroundPanel", backgroundPanel); final Panel mainPanel = new Panel(); mainPanel.setOnInitAction(() -> { mainPanel.setTopLeftPos(64, 64); mainPanel.setBottomRightPos(-64, -64); mainPanel.setTopLeftAnchor(0, 1); mainPanel.setBottomRightAnchor(1, 2); PluginSmoothAnimateAnchor mainPanelAnimAnchor = new PluginSmoothAnimateAnchor(); mainPanelAnimAnchor.setTargetTopLeftAnchor(0, 0); mainPanelAnimAnchor.setTargetBottomRightAnchor(1, 1); mainPanel.addPlugin(mainPanelAnimAnchor); }); backgroundPanel.addChildComponent("mainPanel", mainPanel); final Label settingsLabel = new Label(); settingsLabel.setOnInitAction(() -> { settingsLabel.setTopLeftPos(24, 24); settingsLabel.setBottomRightPos(-24, 72); settingsLabel.setTopLeftAnchor(0, 0); settingsLabel.setBottomRightAnchor(1, 0); settingsLabel.setTextColor(UIColor.matGrey900());
// Path: src/main/java/craftedcart/smblevelworkshop/project/ProjectManager.java // public class ProjectManager { // // private static Project currentProject; // // public static void setCurrentProject(Project currentProject) { // ProjectManager.currentProject = currentProject; // } // // public static Project getCurrentProject() { // return currentProject; // } // // public static LevelData getCurrentLevelData() { // return getCurrentProject().clientLevelData.getLevelData(); // } // // public static ClientLevelData getCurrentClientLevelData() { // return getCurrentProject().clientLevelData; // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/ui/ProjectSettingsOverlayUIScreen.java import craftedcart.smblevelworkshop.project.ProjectManager; import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.*; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.uiaction.UIAction; import io.github.craftedcart.fluidui.util.UIColor; import java.io.File; backgroundPanel.setBackgroundColor(UIColor.pureBlack(0)); PluginSmoothAnimatePanelBackgroundColor backgroundPanelAnimColor = new PluginSmoothAnimatePanelBackgroundColor(); backgroundPanelAnimColor.setTargetBackgroundColor(UIColor.pureBlack(0.75)); backgroundPanel.addPlugin(backgroundPanelAnimColor); }); addChildComponent("backgroundPanel", backgroundPanel); final Panel mainPanel = new Panel(); mainPanel.setOnInitAction(() -> { mainPanel.setTopLeftPos(64, 64); mainPanel.setBottomRightPos(-64, -64); mainPanel.setTopLeftAnchor(0, 1); mainPanel.setBottomRightAnchor(1, 2); PluginSmoothAnimateAnchor mainPanelAnimAnchor = new PluginSmoothAnimateAnchor(); mainPanelAnimAnchor.setTargetTopLeftAnchor(0, 0); mainPanelAnimAnchor.setTargetBottomRightAnchor(1, 1); mainPanel.addPlugin(mainPanelAnimAnchor); }); backgroundPanel.addChildComponent("mainPanel", mainPanel); final Label settingsLabel = new Label(); settingsLabel.setOnInitAction(() -> { settingsLabel.setTopLeftPos(24, 24); settingsLabel.setBottomRightPos(-24, 72); settingsLabel.setTopLeftAnchor(0, 0); settingsLabel.setBottomRightAnchor(1, 0); settingsLabel.setTextColor(UIColor.matGrey900());
settingsLabel.setText(LangManager.getItem("projectSettings"));
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/ui/ProjectSettingsOverlayUIScreen.java
// Path: src/main/java/craftedcart/smblevelworkshop/project/ProjectManager.java // public class ProjectManager { // // private static Project currentProject; // // public static void setCurrentProject(Project currentProject) { // ProjectManager.currentProject = currentProject; // } // // public static Project getCurrentProject() { // return currentProject; // } // // public static LevelData getCurrentLevelData() { // return getCurrentProject().clientLevelData.getLevelData(); // } // // public static ClientLevelData getCurrentClientLevelData() { // return getCurrentProject().clientLevelData; // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // }
import craftedcart.smblevelworkshop.project.ProjectManager; import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.*; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.uiaction.UIAction; import io.github.craftedcart.fluidui.util.UIColor; import java.io.File;
final ListBox listBox = new ListBox(); listBox.setOnInitAction(() -> { listBox.setTopLeftPos(24, 72); listBox.setBottomRightPos(-24, -72); listBox.setTopLeftAnchor(0, 0); listBox.setBottomRightAnchor(1, 1); }); mainPanel.addChildComponent("listBox", listBox); populateListBox(listBox); final TextButton okButton = new TextButton(); okButton.setOnInitAction(() -> { okButton.setTopLeftPos(-152, -48); okButton.setBottomRightPos(-24, -24); okButton.setTopLeftAnchor(1, 1); okButton.setBottomRightAnchor(1, 1); okButton.setText(LangManager.getItem("ok")); }); okButton.setOnLMBAction(() -> { assert parentComponent instanceof FluidUIScreen; ((FluidUIScreen) parentComponent).setOverlayUiScreen(null); //Hide on OK }); mainPanel.addChildComponent("okButton", okButton); } private void populateListBox(ListBox listBox) { //Model sources listBox.addChildComponent("modelSourcesLabel", getLabel(LangManager.getItem("modelSources")));
// Path: src/main/java/craftedcart/smblevelworkshop/project/ProjectManager.java // public class ProjectManager { // // private static Project currentProject; // // public static void setCurrentProject(Project currentProject) { // ProjectManager.currentProject = currentProject; // } // // public static Project getCurrentProject() { // return currentProject; // } // // public static LevelData getCurrentLevelData() { // return getCurrentProject().clientLevelData.getLevelData(); // } // // public static ClientLevelData getCurrentClientLevelData() { // return getCurrentProject().clientLevelData; // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/ui/ProjectSettingsOverlayUIScreen.java import craftedcart.smblevelworkshop.project.ProjectManager; import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.*; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.uiaction.UIAction; import io.github.craftedcart.fluidui.util.UIColor; import java.io.File; final ListBox listBox = new ListBox(); listBox.setOnInitAction(() -> { listBox.setTopLeftPos(24, 72); listBox.setBottomRightPos(-24, -72); listBox.setTopLeftAnchor(0, 0); listBox.setBottomRightAnchor(1, 1); }); mainPanel.addChildComponent("listBox", listBox); populateListBox(listBox); final TextButton okButton = new TextButton(); okButton.setOnInitAction(() -> { okButton.setTopLeftPos(-152, -48); okButton.setBottomRightPos(-24, -24); okButton.setTopLeftAnchor(1, 1); okButton.setBottomRightAnchor(1, 1); okButton.setText(LangManager.getItem("ok")); }); okButton.setOnLMBAction(() -> { assert parentComponent instanceof FluidUIScreen; ((FluidUIScreen) parentComponent).setOverlayUiScreen(null); //Hide on OK }); mainPanel.addChildComponent("okButton", okButton); } private void populateListBox(ListBox listBox) { //Model sources listBox.addChildComponent("modelSourcesLabel", getLabel(LangManager.getItem("modelSources")));
for (File file : ProjectManager.getCurrentLevelData().getModelObjSources()) {
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/asset/Placeable.java
// Path: src/main/java/craftedcart/smblevelworkshop/util/ITransformable.java // public interface ITransformable { // // default void setPosition(PosXYZ position) { throw new UnsupportedOperationException(); } // default PosXYZ getPosition() { throw new UnsupportedOperationException(); } // // default boolean canMoveX() { return true; } // default boolean canMoveY() { return true; } // default boolean canMoveZ() { return true; } // // default void setRotation(PosXYZ rotation) { throw new UnsupportedOperationException(); } // default PosXYZ getRotation() { throw new UnsupportedOperationException(); } // // default boolean canRotate() { return true; } // // default void setScale(PosXYZ scale) { throw new UnsupportedOperationException(); } // default PosXYZ getScale() { throw new UnsupportedOperationException(); } // // default boolean canScale() { return true; } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/PosXYZ.java // public class PosXYZ { // // public double x; // public double y; // public double z; // // public PosXYZ() {} // // public PosXYZ(double x, double y, double z) { // this.x = x; // this.y = y; // this.z = z; // } // // public PosXYZ(craftedcart.smbworkshopexporter.util.Vec3f vec3f) { // this.x = vec3f.x; // this.y = vec3f.y; // this.z = vec3f.z; // } // // public PosXYZ add(PosXYZ pos) { // return new PosXYZ(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public PosXYZ add(double x, double y, double z) { // return new PosXYZ(this.x + x, this.y + y, this.z + z); // } // // public PosXYZ subtract(PosXYZ pos) { // return new PosXYZ(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public PosXYZ subtract(double x, double y, double z) { // return new PosXYZ(this.x - x, this.y - y, this.z - z); // } // // public PosXYZ multiply(double factor) { // return new PosXYZ(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof PosXYZ) { // PosXYZ posObj = (PosXYZ) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public PosXYZ getCopy() { // return new PosXYZ(x, y, z); // } // // }
import craftedcart.smblevelworkshop.util.ITransformable; import craftedcart.smblevelworkshop.util.LogHelper; import craftedcart.smblevelworkshop.util.PosXYZ; import craftedcart.smbworkshopexporter.placeables.*; import org.jetbrains.annotations.NotNull;
package craftedcart.smblevelworkshop.asset; /** * @author CraftedCart * Created on 10/09/2016 (DD/MM/YYYY) */ public class Placeable implements Cloneable, ITransformable { @NotNull private IAsset asset;
// Path: src/main/java/craftedcart/smblevelworkshop/util/ITransformable.java // public interface ITransformable { // // default void setPosition(PosXYZ position) { throw new UnsupportedOperationException(); } // default PosXYZ getPosition() { throw new UnsupportedOperationException(); } // // default boolean canMoveX() { return true; } // default boolean canMoveY() { return true; } // default boolean canMoveZ() { return true; } // // default void setRotation(PosXYZ rotation) { throw new UnsupportedOperationException(); } // default PosXYZ getRotation() { throw new UnsupportedOperationException(); } // // default boolean canRotate() { return true; } // // default void setScale(PosXYZ scale) { throw new UnsupportedOperationException(); } // default PosXYZ getScale() { throw new UnsupportedOperationException(); } // // default boolean canScale() { return true; } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/PosXYZ.java // public class PosXYZ { // // public double x; // public double y; // public double z; // // public PosXYZ() {} // // public PosXYZ(double x, double y, double z) { // this.x = x; // this.y = y; // this.z = z; // } // // public PosXYZ(craftedcart.smbworkshopexporter.util.Vec3f vec3f) { // this.x = vec3f.x; // this.y = vec3f.y; // this.z = vec3f.z; // } // // public PosXYZ add(PosXYZ pos) { // return new PosXYZ(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public PosXYZ add(double x, double y, double z) { // return new PosXYZ(this.x + x, this.y + y, this.z + z); // } // // public PosXYZ subtract(PosXYZ pos) { // return new PosXYZ(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public PosXYZ subtract(double x, double y, double z) { // return new PosXYZ(this.x - x, this.y - y, this.z - z); // } // // public PosXYZ multiply(double factor) { // return new PosXYZ(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof PosXYZ) { // PosXYZ posObj = (PosXYZ) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public PosXYZ getCopy() { // return new PosXYZ(x, y, z); // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/asset/Placeable.java import craftedcart.smblevelworkshop.util.ITransformable; import craftedcart.smblevelworkshop.util.LogHelper; import craftedcart.smblevelworkshop.util.PosXYZ; import craftedcart.smbworkshopexporter.placeables.*; import org.jetbrains.annotations.NotNull; package craftedcart.smblevelworkshop.asset; /** * @author CraftedCart * Created on 10/09/2016 (DD/MM/YYYY) */ public class Placeable implements Cloneable, ITransformable { @NotNull private IAsset asset;
@NotNull private PosXYZ position = new PosXYZ();
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/asset/Placeable.java
// Path: src/main/java/craftedcart/smblevelworkshop/util/ITransformable.java // public interface ITransformable { // // default void setPosition(PosXYZ position) { throw new UnsupportedOperationException(); } // default PosXYZ getPosition() { throw new UnsupportedOperationException(); } // // default boolean canMoveX() { return true; } // default boolean canMoveY() { return true; } // default boolean canMoveZ() { return true; } // // default void setRotation(PosXYZ rotation) { throw new UnsupportedOperationException(); } // default PosXYZ getRotation() { throw new UnsupportedOperationException(); } // // default boolean canRotate() { return true; } // // default void setScale(PosXYZ scale) { throw new UnsupportedOperationException(); } // default PosXYZ getScale() { throw new UnsupportedOperationException(); } // // default boolean canScale() { return true; } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/PosXYZ.java // public class PosXYZ { // // public double x; // public double y; // public double z; // // public PosXYZ() {} // // public PosXYZ(double x, double y, double z) { // this.x = x; // this.y = y; // this.z = z; // } // // public PosXYZ(craftedcart.smbworkshopexporter.util.Vec3f vec3f) { // this.x = vec3f.x; // this.y = vec3f.y; // this.z = vec3f.z; // } // // public PosXYZ add(PosXYZ pos) { // return new PosXYZ(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public PosXYZ add(double x, double y, double z) { // return new PosXYZ(this.x + x, this.y + y, this.z + z); // } // // public PosXYZ subtract(PosXYZ pos) { // return new PosXYZ(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public PosXYZ subtract(double x, double y, double z) { // return new PosXYZ(this.x - x, this.y - y, this.z - z); // } // // public PosXYZ multiply(double factor) { // return new PosXYZ(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof PosXYZ) { // PosXYZ posObj = (PosXYZ) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public PosXYZ getCopy() { // return new PosXYZ(x, y, z); // } // // }
import craftedcart.smblevelworkshop.util.ITransformable; import craftedcart.smblevelworkshop.util.LogHelper; import craftedcart.smblevelworkshop.util.PosXYZ; import craftedcart.smbworkshopexporter.placeables.*; import org.jetbrains.annotations.NotNull;
@Override public boolean canScale() { return getAsset().canScale(); } public void setRotation(@NotNull PosXYZ rotation) { this.rotation = rotation; } @NotNull public PosXYZ getRotation() { return rotation; } public void setScale(@NotNull PosXYZ scale) { this.scale = scale; } @NotNull public PosXYZ getScale() { return scale; } public Placeable getCopy() { try { IAsset newAsset = asset.getCopy(); Placeable newPlaceable = (Placeable) clone(); newPlaceable.setAsset(newAsset); return newPlaceable; } catch (CloneNotSupportedException e) {
// Path: src/main/java/craftedcart/smblevelworkshop/util/ITransformable.java // public interface ITransformable { // // default void setPosition(PosXYZ position) { throw new UnsupportedOperationException(); } // default PosXYZ getPosition() { throw new UnsupportedOperationException(); } // // default boolean canMoveX() { return true; } // default boolean canMoveY() { return true; } // default boolean canMoveZ() { return true; } // // default void setRotation(PosXYZ rotation) { throw new UnsupportedOperationException(); } // default PosXYZ getRotation() { throw new UnsupportedOperationException(); } // // default boolean canRotate() { return true; } // // default void setScale(PosXYZ scale) { throw new UnsupportedOperationException(); } // default PosXYZ getScale() { throw new UnsupportedOperationException(); } // // default boolean canScale() { return true; } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/LogHelper.java // public class LogHelper { // // public static List<LogEntry> log = new ArrayList<>(); // // private static void log(Class clazz, Level logLevel, Object object) { // LogManager.getLogger(clazz).log(logLevel, object); // log.add(new LogEntry(clazz, logLevel, object)); // if (log.size() > 1024) { // log.remove(0); // } // } // // public static void all(Class clazz, Object object) { // log(clazz, Level.ALL, object); // } // // public static void fatal(Class clazz, Object object) { // log(clazz, Level.FATAL, object); // } // // public static void error(Class clazz, Object object) { // log(clazz, Level.ERROR, object); // } // // public static void warn(Class clazz, Object object) { // log(clazz, Level.WARN, object); // } // // public static void info(Class clazz, Object object) { // log(clazz, Level.INFO, object); // } // // public static void debug(Class clazz, Object object) { // log(clazz, Level.DEBUG, object); // } // // public static void trace(Class clazz, Object object) { // log(clazz, Level.TRACE, object); // } // // public static void off(Class clazz, Object object) { // log(clazz, Level.OFF, object); // } // // public static String stackTraceToString(Throwable e) { // StringBuilder sb = new StringBuilder(); // for (StackTraceElement element : e.getStackTrace()) { // sb.append(" at "); // sb.append(element.toString()); // sb.append("\n"); // } // return sb.toString(); // } // // public static class LogEntry { // // public Class clazz; // public Level logLevel; // public Object object; // // public LogEntry(Class clazz, Level logLevel, Object object) { // this.clazz = clazz; // this.logLevel = logLevel; // this.object = object; // } // // } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/PosXYZ.java // public class PosXYZ { // // public double x; // public double y; // public double z; // // public PosXYZ() {} // // public PosXYZ(double x, double y, double z) { // this.x = x; // this.y = y; // this.z = z; // } // // public PosXYZ(craftedcart.smbworkshopexporter.util.Vec3f vec3f) { // this.x = vec3f.x; // this.y = vec3f.y; // this.z = vec3f.z; // } // // public PosXYZ add(PosXYZ pos) { // return new PosXYZ(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public PosXYZ add(double x, double y, double z) { // return new PosXYZ(this.x + x, this.y + y, this.z + z); // } // // public PosXYZ subtract(PosXYZ pos) { // return new PosXYZ(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public PosXYZ subtract(double x, double y, double z) { // return new PosXYZ(this.x - x, this.y - y, this.z - z); // } // // public PosXYZ multiply(double factor) { // return new PosXYZ(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof PosXYZ) { // PosXYZ posObj = (PosXYZ) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public PosXYZ getCopy() { // return new PosXYZ(x, y, z); // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/asset/Placeable.java import craftedcart.smblevelworkshop.util.ITransformable; import craftedcart.smblevelworkshop.util.LogHelper; import craftedcart.smblevelworkshop.util.PosXYZ; import craftedcart.smbworkshopexporter.placeables.*; import org.jetbrains.annotations.NotNull; @Override public boolean canScale() { return getAsset().canScale(); } public void setRotation(@NotNull PosXYZ rotation) { this.rotation = rotation; } @NotNull public PosXYZ getRotation() { return rotation; } public void setScale(@NotNull PosXYZ scale) { this.scale = scale; } @NotNull public PosXYZ getScale() { return scale; } public Placeable getCopy() { try { IAsset newAsset = asset.getCopy(); Placeable newPlaceable = (Placeable) clone(); newPlaceable.setAsset(newAsset); return newPlaceable; } catch (CloneNotSupportedException e) {
LogHelper.error(getClass(), "Failed to clone Placeable");
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/animation/BufferedAnimData.java
// Path: src/main/java/craftedcart/smblevelworkshop/util/MathUtils.java // public class MathUtils { // // public static double lerp(double a, double b, double f) { // return a + f * (b - a); // } // // /** // * Linearly interpolates between two {@link UIColor}s // * // * @param a The starting {@link UIColor} // * @param b The ending {@link UIColor} // * @param f The percentage between the two {@link UIColor} // * @return The {@link UIColor} which if f% between a and b // */ // public static UIColor lerpUIColor(UIColor a, UIColor b, float f) { // return new UIColor(a.r * 255 + f * (b.r * 255 - a.r * 255), // a.g * 255 + f * (b.g * 255 - a.g * 255), // a.b * 255 + f * (b.b * 255 - a.b * 255), // a.a * 255 + f * (b.a * 255 - a.a * 255)); // } // // public static double clamp(double val, double min, double max) { // return Math.max(min, Math.min(max, val)); // } // // public static PosXYZ normalizeRotation(PosXYZ rot) { // while (rot.x >= 360) { // rot.x -= 360; // } // // while (rot.y >= 360) { // rot.y -= 360; // } // // while (rot.z >= 360) { // rot.z -= 360; // } // // while (rot.x < 0) { // rot.x += 360; // } // // while (rot.y < 0) { // rot.y += 360; // } // // while (rot.z < 0) { // rot.z += 360; // } // // return rot; // } // // public static boolean isInRange(double val, double min, double max) { // return val >= min && val <= max; // } // // public static float snapTo(float val, float snapTo) { // float roundMultiplier = 1.0f / snapTo; // return Math.round(val * roundMultiplier) / roundMultiplier; // } // // /** // * @param t A value from 0 to 1 // * @return Quadratic interpolated value between 0 and 1 // */ // public static float cubicEaseInOut(float t) { // return t < 0.5f ? 4 * t * t * t : (t - 1f) * (2f * t - 2f) * (2f * t - 2f) + 1f; // } // // }
import craftedcart.smblevelworkshop.util.MathUtils; import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.TreeMap;
} public float getKeyframeBufferScale() { return keyframeBufferScale; } public float getKeyframeBufferScaleCenter() { return keyframeBufferScaleCenter; } public void setKeyframeBufferTranslation(float keyframeBufferTranslation) { this.keyframeBufferTranslation = keyframeBufferTranslation; } public void setKeyframeBufferScale(float keyframeBufferScale) { this.keyframeBufferScale = keyframeBufferScale; } public void setKeyframeBufferScaleCenter(float keyframeBufferScaleCenter) { this.keyframeBufferScaleCenter = keyframeBufferScaleCenter; } public void setSnapToTranslation(@Nullable Float snapToTranslation) { this.snapToTranslation = snapToTranslation; } public float getSnappedTranslationValue(float in) { if (snapToTranslation == null) { return in; } else {
// Path: src/main/java/craftedcart/smblevelworkshop/util/MathUtils.java // public class MathUtils { // // public static double lerp(double a, double b, double f) { // return a + f * (b - a); // } // // /** // * Linearly interpolates between two {@link UIColor}s // * // * @param a The starting {@link UIColor} // * @param b The ending {@link UIColor} // * @param f The percentage between the two {@link UIColor} // * @return The {@link UIColor} which if f% between a and b // */ // public static UIColor lerpUIColor(UIColor a, UIColor b, float f) { // return new UIColor(a.r * 255 + f * (b.r * 255 - a.r * 255), // a.g * 255 + f * (b.g * 255 - a.g * 255), // a.b * 255 + f * (b.b * 255 - a.b * 255), // a.a * 255 + f * (b.a * 255 - a.a * 255)); // } // // public static double clamp(double val, double min, double max) { // return Math.max(min, Math.min(max, val)); // } // // public static PosXYZ normalizeRotation(PosXYZ rot) { // while (rot.x >= 360) { // rot.x -= 360; // } // // while (rot.y >= 360) { // rot.y -= 360; // } // // while (rot.z >= 360) { // rot.z -= 360; // } // // while (rot.x < 0) { // rot.x += 360; // } // // while (rot.y < 0) { // rot.y += 360; // } // // while (rot.z < 0) { // rot.z += 360; // } // // return rot; // } // // public static boolean isInRange(double val, double min, double max) { // return val >= min && val <= max; // } // // public static float snapTo(float val, float snapTo) { // float roundMultiplier = 1.0f / snapTo; // return Math.round(val * roundMultiplier) / roundMultiplier; // } // // /** // * @param t A value from 0 to 1 // * @return Quadratic interpolated value between 0 and 1 // */ // public static float cubicEaseInOut(float t) { // return t < 0.5f ? 4 * t * t * t : (t - 1f) * (2f * t - 2f) * (2f * t - 2f) + 1f; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/animation/BufferedAnimData.java import craftedcart.smblevelworkshop.util.MathUtils; import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.TreeMap; } public float getKeyframeBufferScale() { return keyframeBufferScale; } public float getKeyframeBufferScaleCenter() { return keyframeBufferScaleCenter; } public void setKeyframeBufferTranslation(float keyframeBufferTranslation) { this.keyframeBufferTranslation = keyframeBufferTranslation; } public void setKeyframeBufferScale(float keyframeBufferScale) { this.keyframeBufferScale = keyframeBufferScale; } public void setKeyframeBufferScaleCenter(float keyframeBufferScaleCenter) { this.keyframeBufferScaleCenter = keyframeBufferScaleCenter; } public void setSnapToTranslation(@Nullable Float snapToTranslation) { this.snapToTranslation = snapToTranslation; } public float getSnappedTranslationValue(float in) { if (snapToTranslation == null) { return in; } else {
return MathUtils.snapTo(in, snapToTranslation);
CraftedCart/SMBLevelWorkshop
src/main/java/com/owens/oobjloader/builder/Material.java
// Path: src/main/java/com/owens/oobjloader/parser/BuilderInterface.java // public interface BuilderInterface { // // public final int NO_SMOOTHING_GROUP = 0; // public final int EMPTY_VERTEX_VALUE = Integer.MIN_VALUE; // public final int MTL_KA = 0; // public final int MTL_KD = 1; // public final int MTL_KS = 2; // public final int MTL_TF = 3; // public final int MTL_MAP_KA = 0; // public final int MTL_MAP_KD = 1; // public final int MTL_MAP_KS = 2; // public final int MTL_MAP_NS = 3; // public final int MTL_MAP_D = 4; // public final int MTL_DECAL = 5; // public final int MTL_DISP = 6; // public final int MTL_BUMP = 7; // public final int MTL_REFL_TYPE_UNKNOWN = -1; // public final int MTL_REFL_TYPE_SPHERE = 0; // public final int MTL_REFL_TYPE_CUBE_TOP = 1; // public final int MTL_REFL_TYPE_CUBE_BOTTOM = 2; // public final int MTL_REFL_TYPE_CUBE_FRONT = 3; // public final int MTL_REFL_TYPE_CUBE_BACK = 4; // public final int MTL_REFL_TYPE_CUBE_LEFT = 5; // public final int MTL_REFL_TYPE_CUBE_RIGHT = 6; // // public void setObjFilename(String filename); // // public void addVertexGeometric(float x, float y, float z); // // public void addVertexTexture(float u, float v); // // public void addVertexNormal(float x, float y, float z); // // public void addPoints(int values[]); // // public void addLine(int values[]); // // // The param for addFace is an array of vertex indices. This array should have a length that is a multiple of 3. // // // // For each triplet of values; // // // // The first value is an absolute or relative index to a geometric vertex. (VertexGeometric) // // The second value is an absolute or relative index to a vertex texture coordinate. (VertexTexture) // // The third vertex is an absolute or relative index to a vertex normal. (VertexNormal) // // // // The indices for the texture and normal MAY be empty in which case they will be set equal to the special // // value defined in BuilderInterface, EMPTY_VERTEX_VALUE. // // // // Absolute indices are positive values that specify a vertex/texture/normal by it's absolute position within the OBJ file. // // // // Relative indices are negative values that specify a vertex/texture/normal by it's position relative to the line the index // // is on, i.e. a line specifying a face (triangle) may specify an geometry vertex as -5 which means the 5 most recently seen // // geometry vertex. // public void addFace(int vertexIndices[]); // // public void addObjectName(String name); // // public void addMapLib(String[] names); // // public void setCurrentGroupNames(String[] names); // // public void setCurrentSmoothingGroup(int groupNumber); // // public void setCurrentUseMap(String name); // // public void setCurrentUseMaterial(String name); // // public void newMtl(String name); // // public void setXYZ(int type, float x, float y, float z); // // public void setRGB(int type, float r, float g, float b); // // public void setIllum(int illumModel); // // public void setD(boolean halo, float factor); // // public void setNs(float exponent); // // public void setSharpness(float value); // // public void setNi(float opticalDensity); // // public void setMapDecalDispBump(int type, String filename); // // public void setRefl(int type, String filename); // // public void doneParsingMaterial(); // // public void doneParsingObj(String filename); // }
import com.owens.oobjloader.parser.BuilderInterface;
package com.owens.oobjloader.builder; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class Material { public String name; public ReflectivityTransmiss ka = new ReflectivityTransmiss(); public ReflectivityTransmiss kd = new ReflectivityTransmiss(); public ReflectivityTransmiss ks = new ReflectivityTransmiss(); public ReflectivityTransmiss tf = new ReflectivityTransmiss(); public int illumModel = 0; public boolean dHalo = false; public double dFactor = 0.0; public double nsExponent = 0.0; public double sharpnessValue = 0.0; public double niOpticalDensity = 0.0; public String mapKaFilename = null; public String mapKdFilename = null; public String mapKsFilename = null; public String mapNsFilename = null; public String mapDFilename = null; public String decalFilename = null; public String dispFilename = null; public String bumpFilename = null;
// Path: src/main/java/com/owens/oobjloader/parser/BuilderInterface.java // public interface BuilderInterface { // // public final int NO_SMOOTHING_GROUP = 0; // public final int EMPTY_VERTEX_VALUE = Integer.MIN_VALUE; // public final int MTL_KA = 0; // public final int MTL_KD = 1; // public final int MTL_KS = 2; // public final int MTL_TF = 3; // public final int MTL_MAP_KA = 0; // public final int MTL_MAP_KD = 1; // public final int MTL_MAP_KS = 2; // public final int MTL_MAP_NS = 3; // public final int MTL_MAP_D = 4; // public final int MTL_DECAL = 5; // public final int MTL_DISP = 6; // public final int MTL_BUMP = 7; // public final int MTL_REFL_TYPE_UNKNOWN = -1; // public final int MTL_REFL_TYPE_SPHERE = 0; // public final int MTL_REFL_TYPE_CUBE_TOP = 1; // public final int MTL_REFL_TYPE_CUBE_BOTTOM = 2; // public final int MTL_REFL_TYPE_CUBE_FRONT = 3; // public final int MTL_REFL_TYPE_CUBE_BACK = 4; // public final int MTL_REFL_TYPE_CUBE_LEFT = 5; // public final int MTL_REFL_TYPE_CUBE_RIGHT = 6; // // public void setObjFilename(String filename); // // public void addVertexGeometric(float x, float y, float z); // // public void addVertexTexture(float u, float v); // // public void addVertexNormal(float x, float y, float z); // // public void addPoints(int values[]); // // public void addLine(int values[]); // // // The param for addFace is an array of vertex indices. This array should have a length that is a multiple of 3. // // // // For each triplet of values; // // // // The first value is an absolute or relative index to a geometric vertex. (VertexGeometric) // // The second value is an absolute or relative index to a vertex texture coordinate. (VertexTexture) // // The third vertex is an absolute or relative index to a vertex normal. (VertexNormal) // // // // The indices for the texture and normal MAY be empty in which case they will be set equal to the special // // value defined in BuilderInterface, EMPTY_VERTEX_VALUE. // // // // Absolute indices are positive values that specify a vertex/texture/normal by it's absolute position within the OBJ file. // // // // Relative indices are negative values that specify a vertex/texture/normal by it's position relative to the line the index // // is on, i.e. a line specifying a face (triangle) may specify an geometry vertex as -5 which means the 5 most recently seen // // geometry vertex. // public void addFace(int vertexIndices[]); // // public void addObjectName(String name); // // public void addMapLib(String[] names); // // public void setCurrentGroupNames(String[] names); // // public void setCurrentSmoothingGroup(int groupNumber); // // public void setCurrentUseMap(String name); // // public void setCurrentUseMaterial(String name); // // public void newMtl(String name); // // public void setXYZ(int type, float x, float y, float z); // // public void setRGB(int type, float r, float g, float b); // // public void setIllum(int illumModel); // // public void setD(boolean halo, float factor); // // public void setNs(float exponent); // // public void setSharpness(float value); // // public void setNi(float opticalDensity); // // public void setMapDecalDispBump(int type, String filename); // // public void setRefl(int type, String filename); // // public void doneParsingMaterial(); // // public void doneParsingObj(String filename); // } // Path: src/main/java/com/owens/oobjloader/builder/Material.java import com.owens.oobjloader.parser.BuilderInterface; package com.owens.oobjloader.builder; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class Material { public String name; public ReflectivityTransmiss ka = new ReflectivityTransmiss(); public ReflectivityTransmiss kd = new ReflectivityTransmiss(); public ReflectivityTransmiss ks = new ReflectivityTransmiss(); public ReflectivityTransmiss tf = new ReflectivityTransmiss(); public int illumModel = 0; public boolean dHalo = false; public double dFactor = 0.0; public double nsExponent = 0.0; public double sharpnessValue = 0.0; public double niOpticalDensity = 0.0; public String mapKaFilename = null; public String mapKdFilename = null; public String mapKsFilename = null; public String mapNsFilename = null; public String mapDFilename = null; public String decalFilename = null; public String dispFilename = null; public String bumpFilename = null;
public int reflType = BuilderInterface.MTL_REFL_TYPE_UNKNOWN;
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/resource/model/OBJScene.java
// Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // }
import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.opengl.GL11; import java.util.List; import java.util.Objects;
package craftedcart.smblevelworkshop.resource.model; /** * @author CraftedCart * Created on 10/10/2016 (DD/MM/YYYY) */ public class OBJScene { private List<OBJObject> objectList; public void setObjectList(List<OBJObject> objectList) { this.objectList = objectList; }
// Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // } // Path: src/main/java/craftedcart/smblevelworkshop/resource/model/OBJScene.java import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.opengl.GL11; import java.util.List; import java.util.Objects; package craftedcart.smblevelworkshop.resource.model; /** * @author CraftedCart * Created on 10/10/2016 (DD/MM/YYYY) */ public class OBJScene { private List<OBJObject> objectList; public void setObjectList(List<OBJObject> objectList) { this.objectList = objectList; }
public void renderAll(ResourceShaderProgram shaderProgram, boolean setTexture) {
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/ui/ColorPickerOverlayUIScreen.java
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // }
import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.component.Button; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.component.TextButton; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.uiaction.UIAction1; import io.github.craftedcart.fluidui.util.AnchorPoint; import io.github.craftedcart.fluidui.util.PosXY; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.opengl.Display;
UIColor.matDeepPurple(), UIColor.matIndigo(), UIColor.matBlue(), UIColor.matLightBlue(), UIColor.matCyan(), UIColor.matTeal(), UIColor.matGreen(), UIColor.matLightGreen(), UIColor.matLime(), UIColor.matYellow(), UIColor.matAmber(), UIColor.matOrange(), UIColor.matDeepOrange(), UIColor.matBrown(), UIColor.matGrey(), UIColor.matBlueGrey() }; int i = 0; for (UIColor col : colorButtons) { mainPanel.addChildComponent("colBtn" + String.valueOf(i), getColorButton(col, i)); i++; } final TextButton cancelButton = new TextButton(); cancelButton.setOnInitAction(() -> { cancelButton.setTopLeftPos(-152, -48); cancelButton.setBottomRightPos(-24, -24); cancelButton.setTopLeftAnchor(1, 1); cancelButton.setBottomRightAnchor(1, 1);
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/ui/ColorPickerOverlayUIScreen.java import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.component.Button; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.component.TextButton; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.uiaction.UIAction1; import io.github.craftedcart.fluidui.util.AnchorPoint; import io.github.craftedcart.fluidui.util.PosXY; import io.github.craftedcart.fluidui.util.UIColor; import org.lwjgl.opengl.Display; UIColor.matDeepPurple(), UIColor.matIndigo(), UIColor.matBlue(), UIColor.matLightBlue(), UIColor.matCyan(), UIColor.matTeal(), UIColor.matGreen(), UIColor.matLightGreen(), UIColor.matLime(), UIColor.matYellow(), UIColor.matAmber(), UIColor.matOrange(), UIColor.matDeepOrange(), UIColor.matBrown(), UIColor.matGrey(), UIColor.matBlueGrey() }; int i = 0; for (UIColor col : colorButtons) { mainPanel.addChildComponent("colBtn" + String.valueOf(i), getColorButton(col, i)); i++; } final TextButton cancelButton = new TextButton(); cancelButton.setOnInitAction(() -> { cancelButton.setTopLeftPos(-152, -48); cancelButton.setBottomRightPos(-24, -24); cancelButton.setTopLeftAnchor(1, 1); cancelButton.setBottomRightAnchor(1, 1);
cancelButton.setText(LangManager.getItem("cancel"));
CraftedCart/SMBLevelWorkshop
src/main/java/com/owens/oobjloader/lwjgl/DisplayModel.java
// Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // }
import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import java.util.ArrayList;
package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class DisplayModel { public ArrayList<VBO> vboList = new ArrayList<VBO>(); public DisplayModel() { } public void addVBO(VBO r) { vboList.add(r); }
// Path: src/main/java/craftedcart/smblevelworkshop/resource/ResourceShaderProgram.java // public class ResourceShaderProgram implements IResource { // // private int programID; // // public ResourceShaderProgram(ResourceShader vertShader, ResourceShader fragShader) throws Exception { // Window.drawable.makeCurrent(); // // try { // programID = GL20.glCreateProgram(); // GL20.glAttachShader(programID, vertShader.getShaderID()); // GL20.glAttachShader(programID, fragShader.getShaderID()); // GL20.glLinkProgram(programID); // GL20.glValidateProgram(programID); // } catch (NullPointerException e) { // throw new Exception(e); // } // // Window.drawable.releaseContext(); // } // // public int getProgramID() { // return programID; // } // } // Path: src/main/java/com/owens/oobjloader/lwjgl/DisplayModel.java import craftedcart.smblevelworkshop.resource.ResourceShaderProgram; import io.github.craftedcart.fluidui.util.UIColor; import java.util.ArrayList; package com.owens.oobjloader.lwjgl; // This code was written by myself, Sean R. Owens, sean at guild dot net, // and is released to the public domain. Share and enjoy. Since some // people argue that it is impossible to release software to the public // domain, you are also free to use this code under any version of the // GPL, LPGL, Apache, or BSD licenses, or contact me for use of another // license. (I generally don't care so I'll almost certainly say yes.) // In addition this code may also be used under the "unlicense" described // at http://unlicense.org/ . See the file UNLICENSE in the repo. public class DisplayModel { public ArrayList<VBO> vboList = new ArrayList<VBO>(); public DisplayModel() { } public void addVBO(VBO r) { vboList.add(r); }
public void render(ResourceShaderProgram shaderProgram, boolean setTexture) {
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/ui/component/FPSOverlay.java
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // }
import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.component.Label; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.plugin.AbstractComponentPlugin; import io.github.craftedcart.fluidui.util.UIUtils; import java.util.ArrayList; import java.util.List;
package craftedcart.smblevelworkshop.ui.component; /** * @author CraftedCart * Created on 04/02/2017 (DD/MM/YYYY) */ public class FPSOverlay extends Panel { @Override public void postInit() { super.postInit(); Label fpsLabel = new Label(); fpsLabel.setOnInitAction(() -> { fpsLabel.setTopLeftPos(0, 0); fpsLabel.setBottomRightPos(0, 0); fpsLabel.setTopLeftAnchor(0, 0); fpsLabel.setBottomRightAnchor(1, 1); fpsLabel.addPlugin(new FPSLabelPlugin()); }); addChildComponent("fpsLabel", fpsLabel); } private class FPSLabelPlugin extends AbstractComponentPlugin { private String fpsLoc; private String avgLoc; private List<Double> deltaAvgList = new ArrayList<>(); FPSLabelPlugin() {
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/ui/component/FPSOverlay.java import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.component.Label; import io.github.craftedcart.fluidui.component.Panel; import io.github.craftedcart.fluidui.plugin.AbstractComponentPlugin; import io.github.craftedcart.fluidui.util.UIUtils; import java.util.ArrayList; import java.util.List; package craftedcart.smblevelworkshop.ui.component; /** * @author CraftedCart * Created on 04/02/2017 (DD/MM/YYYY) */ public class FPSOverlay extends Panel { @Override public void postInit() { super.postInit(); Label fpsLabel = new Label(); fpsLabel.setOnInitAction(() -> { fpsLabel.setTopLeftPos(0, 0); fpsLabel.setBottomRightPos(0, 0); fpsLabel.setTopLeftAnchor(0, 0); fpsLabel.setBottomRightAnchor(1, 1); fpsLabel.addPlugin(new FPSLabelPlugin()); }); addChildComponent("fpsLabel", fpsLabel); } private class FPSLabelPlugin extends AbstractComponentPlugin { private String fpsLoc; private String avgLoc; private List<Double> deltaAvgList = new ArrayList<>(); FPSLabelPlugin() {
fpsLoc = LangManager.getItem("fps");
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/ui/ExportProgressOverlayUIScreen.java
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // }
import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.*; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.uiaction.UIAction; import io.github.craftedcart.fluidui.util.UIColor; import org.jetbrains.annotations.Nullable;
backgroundPanel.setTopLeftPos(0, 0); backgroundPanel.setBottomRightPos(0, 0); backgroundPanel.setTopLeftAnchor(0, 0); backgroundPanel.setBottomRightAnchor(1, 1); backgroundPanel.setBackgroundColor(UIColor.transparent()); }); addChildComponent("backgroundPanel", backgroundPanel); final Panel mainPanel = new Panel(); mainPanel.setOnInitAction(() -> { mainPanel.setTopLeftPos(-256, -256); mainPanel.setBottomRightPos(256, 256); mainPanel.setTopLeftAnchor(0.5, 1.5); mainPanel.setBottomRightAnchor(0.5, 1.5); PluginSmoothAnimateAnchor mainPanelAnimAnchor = new PluginSmoothAnimateAnchor(); mainPanelAnimAnchor.setTargetTopLeftAnchor(0.5, 0.5); mainPanelAnimAnchor.setTargetBottomRightAnchor(0.5, 0.5); mainPanel.addPlugin(mainPanelAnimAnchor); }); backgroundPanel.addChildComponent("mainPanel", mainPanel); final Label exportLabel = new Label(); exportLabel.setOnInitAction(() -> { exportLabel.setTopLeftPos(24, 24); exportLabel.setBottomRightPos(-24, 72); exportLabel.setTopLeftAnchor(0, 0); exportLabel.setBottomRightAnchor(1, 0); exportLabel.setTextColor(UIColor.matGrey900());
// Path: src/main/java/craftedcart/smblevelworkshop/resource/LangManager.java // public class LangManager { // // // <Locale, <Key , Value >> // @NotNull private static Map<String, Map<String, String>> localeMap = new HashMap<>(); // @NotNull private static String selectedLang = "en_US"; // // /** // * Add an item given a locale, key and value // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @param value The translated string // */ // public static void addItem(String locale, String key, String value) { // if (localeMap.containsKey(locale)) { // Map<String, String> langMap = localeMap.get(locale); // langMap.put(key, value); // localeMap.put(locale, langMap); // } else { // Map<String, String> langMap = new HashMap<>(); // langMap.put(key, value); // localeMap.put(locale, langMap); // } // } // // /** // * Get a translated string, given a locale and key // * // * @param locale The language locale (eg: en_US) // * @param key The identifier // * @return The translated string, or the key if the entry wasn't found // */ // public static String getItem(String locale, String key) { // if (localeMap.containsKey(locale)) { // if (localeMap.get(locale).containsKey(key)) { // return localeMap.get(locale).get(key); // } else { // return key; // } // } else { // return key; // } // } // // public static String getItem(String key) { // return getItem(selectedLang, key); // } // // public static void setSelectedLang(@NotNull String selectedLang) { // LangManager.selectedLang = selectedLang; // } // // @NotNull // public static String getSelectedLang() { // return selectedLang; // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/ui/ExportProgressOverlayUIScreen.java import craftedcart.smblevelworkshop.resource.LangManager; import io.github.craftedcart.fluidui.FluidUIScreen; import io.github.craftedcart.fluidui.FontCache; import io.github.craftedcart.fluidui.component.*; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimateAnchor; import io.github.craftedcart.fluidui.plugin.PluginSmoothAnimatePanelBackgroundColor; import io.github.craftedcart.fluidui.uiaction.UIAction; import io.github.craftedcart.fluidui.util.UIColor; import org.jetbrains.annotations.Nullable; backgroundPanel.setTopLeftPos(0, 0); backgroundPanel.setBottomRightPos(0, 0); backgroundPanel.setTopLeftAnchor(0, 0); backgroundPanel.setBottomRightAnchor(1, 1); backgroundPanel.setBackgroundColor(UIColor.transparent()); }); addChildComponent("backgroundPanel", backgroundPanel); final Panel mainPanel = new Panel(); mainPanel.setOnInitAction(() -> { mainPanel.setTopLeftPos(-256, -256); mainPanel.setBottomRightPos(256, 256); mainPanel.setTopLeftAnchor(0.5, 1.5); mainPanel.setBottomRightAnchor(0.5, 1.5); PluginSmoothAnimateAnchor mainPanelAnimAnchor = new PluginSmoothAnimateAnchor(); mainPanelAnimAnchor.setTargetTopLeftAnchor(0.5, 0.5); mainPanelAnimAnchor.setTargetBottomRightAnchor(0.5, 0.5); mainPanel.addPlugin(mainPanelAnimAnchor); }); backgroundPanel.addChildComponent("mainPanel", mainPanel); final Label exportLabel = new Label(); exportLabel.setOnInitAction(() -> { exportLabel.setTopLeftPos(24, 24); exportLabel.setBottomRightPos(-24, 72); exportLabel.setTopLeftAnchor(0, 0); exportLabel.setBottomRightAnchor(1, 0); exportLabel.setTextColor(UIColor.matGrey900());
exportLabel.setText(LangManager.getItem("export"));
CraftedCart/SMBLevelWorkshop
src/main/java/craftedcart/smblevelworkshop/animation/NamedTransform.java
// Path: src/main/java/craftedcart/smblevelworkshop/util/ITransformable.java // public interface ITransformable { // // default void setPosition(PosXYZ position) { throw new UnsupportedOperationException(); } // default PosXYZ getPosition() { throw new UnsupportedOperationException(); } // // default boolean canMoveX() { return true; } // default boolean canMoveY() { return true; } // default boolean canMoveZ() { return true; } // // default void setRotation(PosXYZ rotation) { throw new UnsupportedOperationException(); } // default PosXYZ getRotation() { throw new UnsupportedOperationException(); } // // default boolean canRotate() { return true; } // // default void setScale(PosXYZ scale) { throw new UnsupportedOperationException(); } // default PosXYZ getScale() { throw new UnsupportedOperationException(); } // // default boolean canScale() { return true; } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/PosXYZ.java // public class PosXYZ { // // public double x; // public double y; // public double z; // // public PosXYZ() {} // // public PosXYZ(double x, double y, double z) { // this.x = x; // this.y = y; // this.z = z; // } // // public PosXYZ(craftedcart.smbworkshopexporter.util.Vec3f vec3f) { // this.x = vec3f.x; // this.y = vec3f.y; // this.z = vec3f.z; // } // // public PosXYZ add(PosXYZ pos) { // return new PosXYZ(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public PosXYZ add(double x, double y, double z) { // return new PosXYZ(this.x + x, this.y + y, this.z + z); // } // // public PosXYZ subtract(PosXYZ pos) { // return new PosXYZ(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public PosXYZ subtract(double x, double y, double z) { // return new PosXYZ(this.x - x, this.y - y, this.z - z); // } // // public PosXYZ multiply(double factor) { // return new PosXYZ(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof PosXYZ) { // PosXYZ posObj = (PosXYZ) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public PosXYZ getCopy() { // return new PosXYZ(x, y, z); // } // // }
import craftedcart.smblevelworkshop.util.ITransformable; import craftedcart.smblevelworkshop.util.PosXYZ;
package craftedcart.smblevelworkshop.animation; /** * @author CraftedCart * Created on 03/11/2016 (DD/MM/YYYY) */ public class NamedTransform implements ITransformable { private String name;
// Path: src/main/java/craftedcart/smblevelworkshop/util/ITransformable.java // public interface ITransformable { // // default void setPosition(PosXYZ position) { throw new UnsupportedOperationException(); } // default PosXYZ getPosition() { throw new UnsupportedOperationException(); } // // default boolean canMoveX() { return true; } // default boolean canMoveY() { return true; } // default boolean canMoveZ() { return true; } // // default void setRotation(PosXYZ rotation) { throw new UnsupportedOperationException(); } // default PosXYZ getRotation() { throw new UnsupportedOperationException(); } // // default boolean canRotate() { return true; } // // default void setScale(PosXYZ scale) { throw new UnsupportedOperationException(); } // default PosXYZ getScale() { throw new UnsupportedOperationException(); } // // default boolean canScale() { return true; } // // } // // Path: src/main/java/craftedcart/smblevelworkshop/util/PosXYZ.java // public class PosXYZ { // // public double x; // public double y; // public double z; // // public PosXYZ() {} // // public PosXYZ(double x, double y, double z) { // this.x = x; // this.y = y; // this.z = z; // } // // public PosXYZ(craftedcart.smbworkshopexporter.util.Vec3f vec3f) { // this.x = vec3f.x; // this.y = vec3f.y; // this.z = vec3f.z; // } // // public PosXYZ add(PosXYZ pos) { // return new PosXYZ(this.x + pos.x, this.y + pos.y, this.z + pos.z); // } // // public PosXYZ add(double x, double y, double z) { // return new PosXYZ(this.x + x, this.y + y, this.z + z); // } // // public PosXYZ subtract(PosXYZ pos) { // return new PosXYZ(this.x - pos.x, this.y - pos.y, this.z - pos.z); // } // // public PosXYZ subtract(double x, double y, double z) { // return new PosXYZ(this.x - x, this.y - y, this.z - z); // } // // public PosXYZ multiply(double factor) { // return new PosXYZ(x * factor, y * factor, z * factor); // } // // @Override // public boolean equals(Object obj) { // if (obj instanceof PosXYZ) { // PosXYZ posObj = (PosXYZ) obj; // return posObj.x == x && posObj.y == y && posObj.z == z; // } else { // return false; // } // } // // public PosXYZ getCopy() { // return new PosXYZ(x, y, z); // } // // } // Path: src/main/java/craftedcart/smblevelworkshop/animation/NamedTransform.java import craftedcart.smblevelworkshop.util.ITransformable; import craftedcart.smblevelworkshop.util.PosXYZ; package craftedcart.smblevelworkshop.animation; /** * @author CraftedCart * Created on 03/11/2016 (DD/MM/YYYY) */ public class NamedTransform implements ITransformable { private String name;
private PosXYZ position = new PosXYZ();
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/TestBean.java // @Named // @RequestScoped // public class TestBean { // // @Property("hello.world") // private String helloWorld; // // @Property(value = "system.linux.box", parameters = { "Linux", "16" }) // private String systemBox; // // @Property(value = "other.message", resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String other; // // @Property(value = "other.parameter", parameters = { "B" }, resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String otherAbc; // // @Inject // private InjectedBean injectedBean; // // @SuppressWarnings("unused") // @PostConstruct // private void init() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // } // // public String getHelloWorld() { // return helloWorld; // } // // public String getSystemBox() { // return systemBox; // } // // public String getOther() { // return other; // } // // public String getOtherAbc() { // return otherAbc; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.common.TestBean; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which use the default property resolver method * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarDefaultPropertyMethod { protected static WebArchive createArchive() throws IOException {
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/TestBean.java // @Named // @RequestScoped // public class TestBean { // // @Property("hello.world") // private String helloWorld; // // @Property(value = "system.linux.box", parameters = { "Linux", "16" }) // private String systemBox; // // @Property(value = "other.message", resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String other; // // @Property(value = "other.parameter", parameters = { "B" }, resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String otherAbc; // // @Inject // private InjectedBean injectedBean; // // @SuppressWarnings("unused") // @PostConstruct // private void init() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // } // // public String getHelloWorld() { // return helloWorld; // } // // public String getSystemBox() { // return systemBox; // } // // public String getOther() { // return other; // } // // public String getOtherAbc() { // return otherAbc; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.common.TestBean; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which use the default property resolver method * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarDefaultPropertyMethod { protected static WebArchive createArchive() throws IOException {
WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(TestBean.class,
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/TestBean.java // @Named // @RequestScoped // public class TestBean { // // @Property("hello.world") // private String helloWorld; // // @Property(value = "system.linux.box", parameters = { "Linux", "16" }) // private String systemBox; // // @Property(value = "other.message", resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String other; // // @Property(value = "other.parameter", parameters = { "B" }, resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String otherAbc; // // @Inject // private InjectedBean injectedBean; // // @SuppressWarnings("unused") // @PostConstruct // private void init() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // } // // public String getHelloWorld() { // return helloWorld; // } // // public String getSystemBox() { // return systemBox; // } // // public String getOther() { // return other; // } // // public String getOtherAbc() { // return otherAbc; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.common.TestBean; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which use the default property resolver method * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarDefaultPropertyMethod { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(TestBean.class,
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/TestBean.java // @Named // @RequestScoped // public class TestBean { // // @Property("hello.world") // private String helloWorld; // // @Property(value = "system.linux.box", parameters = { "Linux", "16" }) // private String systemBox; // // @Property(value = "other.message", resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String other; // // @Property(value = "other.parameter", parameters = { "B" }, resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String otherAbc; // // @Inject // private InjectedBean injectedBean; // // @SuppressWarnings("unused") // @PostConstruct // private void init() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // } // // public String getHelloWorld() { // return helloWorld; // } // // public String getSystemBox() { // return systemBox; // } // // public String getOther() { // return other; // } // // public String getOtherAbc() { // return otherAbc; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.common.TestBean; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which use the default property resolver method * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarDefaultPropertyMethod { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(TestBean.class,
InjectedBean.class);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/TestBean.java // @Named // @RequestScoped // public class TestBean { // // @Property("hello.world") // private String helloWorld; // // @Property(value = "system.linux.box", parameters = { "Linux", "16" }) // private String systemBox; // // @Property(value = "other.message", resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String other; // // @Property(value = "other.parameter", parameters = { "B" }, resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String otherAbc; // // @Inject // private InjectedBean injectedBean; // // @SuppressWarnings("unused") // @PostConstruct // private void init() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // } // // public String getHelloWorld() { // return helloWorld; // } // // public String getSystemBox() { // return systemBox; // } // // public String getOther() { // return other; // } // // public String getOtherAbc() { // return otherAbc; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.common.TestBean; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which use the default property resolver method * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarDefaultPropertyMethod { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(TestBean.class, InjectedBean.class);
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/TestBean.java // @Named // @RequestScoped // public class TestBean { // // @Property("hello.world") // private String helloWorld; // // @Property(value = "system.linux.box", parameters = { "Linux", "16" }) // private String systemBox; // // @Property(value = "other.message", resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String other; // // @Property(value = "other.parameter", parameters = { "B" }, resourceBundleBaseName = TestConstants.OTHER_RESOURCE_BUNDLE_NAME) // private String otherAbc; // // @Inject // private InjectedBean injectedBean; // // @SuppressWarnings("unused") // @PostConstruct // private void init() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // } // // public String getHelloWorld() { // return helloWorld; // } // // public String getSystemBox() { // return systemBox; // } // // public String getOther() { // return other; // } // // public String getOtherAbc() { // return otherAbc; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.common.TestBean; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which use the default property resolver method * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarDefaultPropertyMethod { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(TestBean.class, InjectedBean.class);
DeploymentAppenderFactory
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/edm/TestEjbDefaultBean.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // }
import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.edm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @Named @RequestScoped public class TestEjbDefaultBean { @Inject
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/edm/TestEjbDefaultBean.java import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.edm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @Named @RequestScoped public class TestEjbDefaultBean { @Inject
private InjectedBean injectedBean;
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/edm/TestEjbDefaultBean.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // }
import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.edm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @Named @RequestScoped public class TestEjbDefaultBean { @Inject private InjectedBean injectedBean; @EJB(lookup = "java:global/cdiproperties/cdipropertiesejb/ServiceEjbDefaultMethodBean") private ServiceEjbDefaultMethod serviceEjbDefaultMethod; @SuppressWarnings("unused") @PostConstruct private void init() {
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/edm/TestEjbDefaultBean.java import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.edm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @Named @RequestScoped public class TestEjbDefaultBean { @Inject private InjectedBean injectedBean; @EJB(lookup = "java:global/cdiproperties/cdipropertiesejb/ServiceEjbDefaultMethodBean") private ServiceEjbDefaultMethod serviceEjbDefaultMethod; @SuppressWarnings("unused") @PostConstruct private void init() {
Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/SessionScopedBean.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // }
import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @SessionScoped public class SessionScopedBean implements Serializable { private static final long serialVersionUID = 1L; @Inject
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/SessionScopedBean.java import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @SessionScoped public class SessionScopedBean implements Serializable { private static final long serialVersionUID = 1L; @Inject
private InjectedBean injectedBean;
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/SessionScopedBean.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // }
import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @SessionScoped public class SessionScopedBean implements Serializable { private static final long serialVersionUID = 1L; @Inject private InjectedBean injectedBean; public String getText() {
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/SessionScopedBean.java import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @SessionScoped public class SessionScopedBean implements Serializable { private static final long serialVersionUID = 1L; @Inject private InjectedBean injectedBean; public String getText() {
Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarProvidedLocaleMethodSessionPTIT.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodSession.java // public abstract class AbstractWarProvidedLocaleMethodSession { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses( // ProvidedLocaleMethodResolverSession.class, OtherService.class, OtherServiceBean.class, // TestServlet.class, UserSession.class); // DeploymentAppenderFactory.create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/simpleWeb.xml") // .appendWebResource("../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/test.jsp") // .appendCDIPropertiesLib() // .appendBeansXml().appendLogging().appendProperties(); // return webArchive; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // }
import com.byteslounge.cdi.test.utils.MessageBundleUtils; import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.it.common.AbstractWarProvidedLocaleMethodSession;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ @RunWith(Arquillian.class) public class WarProvidedLocaleMethodSessionPTIT extends AbstractWarProvidedLocaleMethodSession { @Drone private WebDriver browser; @FindBy(id = "result") private WebElement result; @FindBy(id = "integer") private WebElement integer; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarProvidedLocaleMethodSessionPT.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "testservlet"); Assert.assertEquals(result.getText(),
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodSession.java // public abstract class AbstractWarProvidedLocaleMethodSession { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses( // ProvidedLocaleMethodResolverSession.class, OtherService.class, OtherServiceBean.class, // TestServlet.class, UserSession.class); // DeploymentAppenderFactory.create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/simpleWeb.xml") // .appendWebResource("../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/test.jsp") // .appendCDIPropertiesLib() // .appendBeansXml().appendLogging().appendProperties(); // return webArchive; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // } // Path: cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarProvidedLocaleMethodSessionPTIT.java import com.byteslounge.cdi.test.utils.MessageBundleUtils; import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.it.common.AbstractWarProvidedLocaleMethodSession; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ @RunWith(Arquillian.class) public class WarProvidedLocaleMethodSessionPTIT extends AbstractWarProvidedLocaleMethodSession { @Drone private WebDriver browser; @FindBy(id = "result") private WebElement result; @FindBy(id = "integer") private WebElement integer; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarProvidedLocaleMethodSessionPT.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "testservlet"); Assert.assertEquals(result.getText(),
MessageBundleUtils.resolveProperty("hello.world", "bl.messages", new Locale("pt", "PT")));
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverThreadLocal.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // }
import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.test.common.LocaleThreadLocal;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolverThreadLocal implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver public Locale resolveLocale() {
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverThreadLocal.java import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.test.common.LocaleThreadLocal; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolverThreadLocal implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver public Locale resolveLocale() {
return LocaleThreadLocal.localeThreadLocal.get().getLocale();
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // }
import java.io.Serializable; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.configuration.TestConstants;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.common; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class ApplicationScopedBean implements Serializable { private static final long serialVersionUID = 1L; @Inject private InjectedBean injectedBean; public String getText() {
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java import java.io.Serializable; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.configuration.TestConstants; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.common; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class ApplicationScopedBean implements Serializable { private static final long serialVersionUID = 1L; @Inject private InjectedBean injectedBean; public String getText() {
Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarProvidedLocaleMethodThreadLocalPT.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/filter/LocaleFilterPT.java // @WebFilter(urlPatterns = "/*") // public class LocaleFilterPT implements Filter { // // @Override // public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, // ServletException { // try { // LocaleThreadLocal.localeThreadLocal.set(new LocaleThreadLocal(new Locale("pt", "PT"))); // chain.doFilter(request, response); // } finally { // LocaleThreadLocal.localeThreadLocal.remove(); // } // } // // @Override // public void init(FilterConfig config) throws ServletException { // } // // @Override // public void destroy() { // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodThreadLocal.java // public abstract class AbstractWarProvidedLocaleMethodThreadLocal { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses( // ProvidedLocaleMethodResolverThreadLocal.class, OtherService.class, OtherServiceBean.class, // TestServlet.class, LocaleThreadLocal.class); // DeploymentAppenderFactory.create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/simpleWeb.xml") // .appendWebResource("../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/test.jsp") // .appendBeansXml() // .appendCDIPropertiesLib() // .appendLogging().appendProperties(); // return webArchive; // } // // }
import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.filter.LocaleFilterPT; import com.byteslounge.cdi.test.it.common.AbstractWarProvidedLocaleMethodThreadLocal; import java.io.IOException;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarProvidedLocaleMethodThreadLocalPT extends AbstractWarProvidedLocaleMethodThreadLocal { public static WebArchive createArchive() throws IOException { WebArchive webArchive = AbstractWarProvidedLocaleMethodThreadLocal.createArchive().addClasses(
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/filter/LocaleFilterPT.java // @WebFilter(urlPatterns = "/*") // public class LocaleFilterPT implements Filter { // // @Override // public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, // ServletException { // try { // LocaleThreadLocal.localeThreadLocal.set(new LocaleThreadLocal(new Locale("pt", "PT"))); // chain.doFilter(request, response); // } finally { // LocaleThreadLocal.localeThreadLocal.remove(); // } // } // // @Override // public void init(FilterConfig config) throws ServletException { // } // // @Override // public void destroy() { // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodThreadLocal.java // public abstract class AbstractWarProvidedLocaleMethodThreadLocal { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses( // ProvidedLocaleMethodResolverThreadLocal.class, OtherService.class, OtherServiceBean.class, // TestServlet.class, LocaleThreadLocal.class); // DeploymentAppenderFactory.create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/simpleWeb.xml") // .appendWebResource("../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/test.jsp") // .appendBeansXml() // .appendCDIPropertiesLib() // .appendLogging().appendProperties(); // return webArchive; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarProvidedLocaleMethodThreadLocalPT.java import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.filter.LocaleFilterPT; import com.byteslounge.cdi.test.it.common.AbstractWarProvidedLocaleMethodThreadLocal; import java.io.IOException; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarProvidedLocaleMethodThreadLocalPT extends AbstractWarProvidedLocaleMethodThreadLocal { public static WebArchive createArchive() throws IOException { WebArchive webArchive = AbstractWarProvidedLocaleMethodThreadLocal.createArchive().addClasses(
LocaleFilterPT.class);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarProvidedLocaleMethodSessionIT.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodSession.java // public abstract class AbstractWarProvidedLocaleMethodSession { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses( // ProvidedLocaleMethodResolverSession.class, OtherService.class, OtherServiceBean.class, // TestServlet.class, UserSession.class); // DeploymentAppenderFactory.create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/simpleWeb.xml") // .appendWebResource("../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/test.jsp") // .appendCDIPropertiesLib() // .appendBeansXml().appendLogging().appendProperties(); // return webArchive; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // }
import com.byteslounge.cdi.test.utils.MessageBundleUtils; import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.it.common.AbstractWarProvidedLocaleMethodSession;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ @RunWith(Arquillian.class) public class WarProvidedLocaleMethodSessionIT extends AbstractWarProvidedLocaleMethodSession { @Drone private WebDriver browser; @FindBy(id = "result") private WebElement result; @FindBy(id = "integer") private WebElement integer; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarProvidedLocaleMethodSession.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "testservlet"); Assert.assertEquals(result.getText(),
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodSession.java // public abstract class AbstractWarProvidedLocaleMethodSession { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses( // ProvidedLocaleMethodResolverSession.class, OtherService.class, OtherServiceBean.class, // TestServlet.class, UserSession.class); // DeploymentAppenderFactory.create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/simpleWeb.xml") // .appendWebResource("../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/test.jsp") // .appendCDIPropertiesLib() // .appendBeansXml().appendLogging().appendProperties(); // return webArchive; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // } // Path: cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarProvidedLocaleMethodSessionIT.java import com.byteslounge.cdi.test.utils.MessageBundleUtils; import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.it.common.AbstractWarProvidedLocaleMethodSession; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ @RunWith(Arquillian.class) public class WarProvidedLocaleMethodSessionIT extends AbstractWarProvidedLocaleMethodSession { @Drone private WebDriver browser; @FindBy(id = "result") private WebElement result; @FindBy(id = "integer") private WebElement integer; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarProvidedLocaleMethodSession.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "testservlet"); Assert.assertEquals(result.getText(),
MessageBundleUtils.resolveProperty("hello.world", "bl.messages", Locale.getDefault()));
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/filter/LocaleSessionFilter.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/session/UserSession.java // @SessionScoped // public class UserSession implements Serializable { // // private static final long serialVersionUID = 1L; // private Locale locale; // // public Locale getLocale() { // return locale; // } // // public void setLocale(Locale locale) { // this.locale = locale; // } // // }
import java.io.IOException; import java.util.Locale; import javax.inject.Inject; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import com.byteslounge.cdi.test.common.session.UserSession;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.common.filter; /** * Filter that sets the current session locale as the system default * * @author Gonçalo Marques * @since 1.1.0 */ @WebFilter(urlPatterns = "/*") public class LocaleSessionFilter implements Filter { @Inject
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/session/UserSession.java // @SessionScoped // public class UserSession implements Serializable { // // private static final long serialVersionUID = 1L; // private Locale locale; // // public Locale getLocale() { // return locale; // } // // public void setLocale(Locale locale) { // this.locale = locale; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/filter/LocaleSessionFilter.java import java.io.IOException; import java.util.Locale; import javax.inject.Inject; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import com.byteslounge.cdi.test.common.session.UserSession; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.common.filter; /** * Filter that sets the current session locale as the system default * * @author Gonçalo Marques * @since 1.1.0 */ @WebFilter(urlPatterns = "/*") public class LocaleSessionFilter implements Filter { @Inject
private UserSession userSession;
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolver.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // }
import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.junit.Assert; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolver implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolver.java import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.junit.Assert; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolver implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver
public Locale resolveLocale(DependentScopedBean dependentScopedBean, RequestScopedBean requestScopedBean,
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolver.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // }
import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.junit.Assert; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolver implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver public Locale resolveLocale(DependentScopedBean dependentScopedBean, RequestScopedBean requestScopedBean, SessionScopedBean sessionScopedBean, @PropertyBundle String bundleName,
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolver.java import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.junit.Assert; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolver implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver public Locale resolveLocale(DependentScopedBean dependentScopedBean, RequestScopedBean requestScopedBean, SessionScopedBean sessionScopedBean, @PropertyBundle String bundleName,
ApplicationScopedBean applicationScopedBean, @PropertyKey String key, Service service) {
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolver.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // }
import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.junit.Assert; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolver implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver public Locale resolveLocale(DependentScopedBean dependentScopedBean, RequestScopedBean requestScopedBean, SessionScopedBean sessionScopedBean, @PropertyBundle String bundleName, ApplicationScopedBean applicationScopedBean, @PropertyKey String key, Service service) { service.remove(1L);
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolver.java import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.junit.Assert; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolver implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver public Locale resolveLocale(DependentScopedBean dependentScopedBean, RequestScopedBean requestScopedBean, SessionScopedBean sessionScopedBean, @PropertyBundle String bundleName, ApplicationScopedBean applicationScopedBean, @PropertyKey String key, Service service) { service.remove(1L);
TestEntity testEntity = new TestEntity();
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolver.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // }
import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.junit.Assert; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolver implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver public Locale resolveLocale(DependentScopedBean dependentScopedBean, RequestScopedBean requestScopedBean, SessionScopedBean sessionScopedBean, @PropertyBundle String bundleName, ApplicationScopedBean applicationScopedBean, @PropertyKey String key, Service service) { service.remove(1L); TestEntity testEntity = new TestEntity(); testEntity.setId(1L); testEntity.setDescription("Description"); testEntity = service.merge(testEntity); TestEntity other = service.findById(1L); Assert.assertEquals(new Long(1L), other.getId());
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolver.java import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.junit.Assert; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolver implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver public Locale resolveLocale(DependentScopedBean dependentScopedBean, RequestScopedBean requestScopedBean, SessionScopedBean sessionScopedBean, @PropertyBundle String bundleName, ApplicationScopedBean applicationScopedBean, @PropertyKey String key, Service service) { service.remove(1L); TestEntity testEntity = new TestEntity(); testEntity.setId(1L); testEntity.setDescription("Description"); testEntity = service.merge(testEntity); TestEntity other = service.findById(1L); Assert.assertEquals(new Long(1L), other.getId());
Assert.assertEquals(dependentScopedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE);
gonmarques/cdi-properties
cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/verifier/PropertyResolverMethodParametersVerifier.java
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/exception/ExtensionInitializationException.java // public class ExtensionInitializationException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ExtensionInitializationException(String message) { // super(message); // } // // public ExtensionInitializationException(Throwable cause) { // super(cause); // } // // public ExtensionInitializationException(String message, Throwable cause) { // super(message, cause); // } // // }
import java.lang.annotation.Annotation; import javax.enterprise.inject.spi.AnnotatedMethod; import javax.enterprise.inject.spi.AnnotatedParameter; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.exception.ExtensionInitializationException;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.resolver.verifier; /** * Checks if the custom injected property method resolver parameters are * properly configured * * @author Gonçalo Marques * @since 1.1.0 */ public class PropertyResolverMethodParametersVerifier implements ResolverMethodVerifier { private final AnnotatedMethod<?> propertyResolverMethod; public PropertyResolverMethodParametersVerifier(AnnotatedMethod<?> propertyResolverMethod) { this.propertyResolverMethod = propertyResolverMethod; } /** * See {@link ResolverMethodVerifier#verify()} */ @Override public void verify() { checkPropertyKeyExists(); checkRepeatedParameterType(PropertyKey.class); checkRepeatedParameterType(PropertyLocale.class); checkRepeatedParameterType(PropertyBundle.class); checkMultipleAnnotationParameter(); } /** * Checks if there is at least one property resolver method parameter annotated with {@link PropertyKey} */ private void checkPropertyKeyExists() { boolean foundKeyProperty = false; for (final AnnotatedParameter<?> parameter : propertyResolverMethod.getParameters()) { if (parameter.isAnnotationPresent(PropertyKey.class)) { foundKeyProperty = true; break; } } if (!foundKeyProperty) {
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/exception/ExtensionInitializationException.java // public class ExtensionInitializationException extends RuntimeException { // // private static final long serialVersionUID = 1L; // // public ExtensionInitializationException(String message) { // super(message); // } // // public ExtensionInitializationException(Throwable cause) { // super(cause); // } // // public ExtensionInitializationException(String message, Throwable cause) { // super(message, cause); // } // // } // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/verifier/PropertyResolverMethodParametersVerifier.java import java.lang.annotation.Annotation; import javax.enterprise.inject.spi.AnnotatedMethod; import javax.enterprise.inject.spi.AnnotatedParameter; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.exception.ExtensionInitializationException; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.resolver.verifier; /** * Checks if the custom injected property method resolver parameters are * properly configured * * @author Gonçalo Marques * @since 1.1.0 */ public class PropertyResolverMethodParametersVerifier implements ResolverMethodVerifier { private final AnnotatedMethod<?> propertyResolverMethod; public PropertyResolverMethodParametersVerifier(AnnotatedMethod<?> propertyResolverMethod) { this.propertyResolverMethod = propertyResolverMethod; } /** * See {@link ResolverMethodVerifier#verify()} */ @Override public void verify() { checkPropertyKeyExists(); checkRepeatedParameterType(PropertyKey.class); checkRepeatedParameterType(PropertyLocale.class); checkRepeatedParameterType(PropertyBundle.class); checkMultipleAnnotationParameter(); } /** * Checks if there is at least one property resolver method parameter annotated with {@link PropertyKey} */ private void checkPropertyKeyExists() { boolean foundKeyProperty = false; for (final AnnotatedParameter<?> parameter : propertyResolverMethod.getParameters()) { if (parameter.isAnnotationPresent(PropertyKey.class)) { foundKeyProperty = true; break; } } if (!foundKeyProperty) {
throw new ExtensionInitializationException(
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/filter/LocaleFilter.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // }
import java.io.IOException; import java.util.Locale; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import com.byteslounge.cdi.test.common.LocaleThreadLocal;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.common.filter; /** * Filter that sets the current locale as the system default * * @author Gonçalo Marques * @since 1.1.0 */ @WebFilter(urlPatterns = "/*") public class LocaleFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try {
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/filter/LocaleFilter.java import java.io.IOException; import java.util.Locale; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import com.byteslounge.cdi.test.common.LocaleThreadLocal; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.common.filter; /** * Filter that sets the current locale as the system default * * @author Gonçalo Marques * @since 1.1.0 */ @WebFilter(urlPatterns = "/*") public class LocaleFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try {
LocaleThreadLocal.localeThreadLocal.set(new LocaleThreadLocal(Locale.getDefault()));
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarDefaultPropertyMethodNoFacesIT.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // }
import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.utils.MessageBundleUtils;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ @RunWith(Arquillian.class) public class WarDefaultPropertyMethodNoFacesIT { @Drone private WebDriver browser; @FindBy(id = "result") private WebElement result; @FindBy(id = "integer") private WebElement integer; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarDefaultPropertyMethodNoFaces.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "testservlet"); Assert.assertEquals(result.getText(),
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // } // Path: cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarDefaultPropertyMethodNoFacesIT.java import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.utils.MessageBundleUtils; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ @RunWith(Arquillian.class) public class WarDefaultPropertyMethodNoFacesIT { @Drone private WebDriver browser; @FindBy(id = "result") private WebElement result; @FindBy(id = "integer") private WebElement integer; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarDefaultPropertyMethodNoFaces.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "testservlet"); Assert.assertEquals(result.getText(),
MessageBundleUtils.resolveProperty("hello.world", "bl.messages", Locale.getDefault()));
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/Service.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // }
import javax.ejb.Local; import com.byteslounge.cdi.test.model.TestEntity; import java.io.Serializable;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @Local public interface Service extends Serializable { String getText();
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/Service.java import javax.ejb.Local; import com.byteslounge.cdi.test.model.TestEntity; import java.io.Serializable; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @Local public interface Service extends Serializable { String getText();
TestEntity merge(TestEntity testEntity);
gonmarques/cdi-properties
cdi-properties-main/src/main/java/com/byteslounge/cdi/extension/param/BundlePropertyResolverParameter.java
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/context/ResolverContext.java // public class ResolverContext { // // private final String key; // private final String bundleName; // private Bean<?> resolverBean; // private BeanManager beanManager; // // private ResolverContext(String key, String bundleName) { // this.key = key; // this.bundleName = bundleName; // } // // /** // * Creates a {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance. // * // * @param key the property key to be associated with the created context // * @param bundleName the resource bundle name to be associated with the created context // * // * @return the newly created {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public static ResolverContext create(String key, String bundleName) { // return new ResolverContext(key, bundleName); // } // // /** // * Gets the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getKey() { // return key; // } // // /** // * Gets the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getBundleName() { // return bundleName; // } // // /** // * Sets the resolver bean associated with the current resolving execution // * // * @param resolverBean the property key to be associated with the created context // */ // public void setResolverBean(Bean<?> resolverBean) { // this.resolverBean = resolverBean; // } // // /** // * Gets the resolver bean associated with the current resolving execution // * // * @return the resolver bean associated with the current resolving execution // */ // public Bean<?> getResolverBean() { // return resolverBean; // } // // /** // * Gets the bean manager associated with the current resolving execution // * // * @return the bean manager associated with the current resolving execution // */ // public BeanManager getBeanManager() { // return beanManager; // } // // /** // * Sets the bean manager associated with the current resolving execution // * // * @param beanManager the bean manager associated with the current resolving execution // */ // public void setBeanManager(BeanManager beanManager) { // this.beanManager = beanManager; // } // // }
import com.byteslounge.cdi.resolver.context.ResolverContext; import javax.enterprise.context.spi.CreationalContext;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.extension.param; /** * Represents a resolver that will be used to evaluate a * parameter of the property resolver method of type Bundle * * @author Gonçalo Marques * @since 1.1.0 */ public class BundlePropertyResolverParameter implements ResolverParameter<String> { /** * see {@link ResolverParameter#resolve(String, String, CreationalContext)} */ @Override
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/context/ResolverContext.java // public class ResolverContext { // // private final String key; // private final String bundleName; // private Bean<?> resolverBean; // private BeanManager beanManager; // // private ResolverContext(String key, String bundleName) { // this.key = key; // this.bundleName = bundleName; // } // // /** // * Creates a {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance. // * // * @param key the property key to be associated with the created context // * @param bundleName the resource bundle name to be associated with the created context // * // * @return the newly created {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public static ResolverContext create(String key, String bundleName) { // return new ResolverContext(key, bundleName); // } // // /** // * Gets the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getKey() { // return key; // } // // /** // * Gets the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getBundleName() { // return bundleName; // } // // /** // * Sets the resolver bean associated with the current resolving execution // * // * @param resolverBean the property key to be associated with the created context // */ // public void setResolverBean(Bean<?> resolverBean) { // this.resolverBean = resolverBean; // } // // /** // * Gets the resolver bean associated with the current resolving execution // * // * @return the resolver bean associated with the current resolving execution // */ // public Bean<?> getResolverBean() { // return resolverBean; // } // // /** // * Gets the bean manager associated with the current resolving execution // * // * @return the bean manager associated with the current resolving execution // */ // public BeanManager getBeanManager() { // return beanManager; // } // // /** // * Sets the bean manager associated with the current resolving execution // * // * @param beanManager the bean manager associated with the current resolving execution // */ // public void setBeanManager(BeanManager beanManager) { // this.beanManager = beanManager; // } // // } // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/extension/param/BundlePropertyResolverParameter.java import com.byteslounge.cdi.resolver.context.ResolverContext; import javax.enterprise.context.spi.CreationalContext; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.extension.param; /** * Represents a resolver that will be used to evaluate a * parameter of the property resolver method of type Bundle * * @author Gonçalo Marques * @since 1.1.0 */ public class BundlePropertyResolverParameter implements ResolverParameter<String> { /** * see {@link ResolverParameter#resolve(String, String, CreationalContext)} */ @Override
public <T> String resolve(ResolverContext resolverContext, CreationalContext<T> ctx) {
gonmarques/cdi-properties
cdi-properties-main/src/main/java/com/byteslounge/cdi/configuration/ExtensionInitializer.java
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/JSFLocaleResolver.java // public class JSFLocaleResolver implements LocaleResolver { // // /** // * See {@link LocaleResolver#getLocale()} // */ // @Override // public Locale getLocale() { // try { // return FacesContext.getCurrentInstance().getViewRoot().getLocale(); // }catch(NoClassDefFoundError e) { // return Locale.getDefault(); // } catch (Exception e) { // return Locale.getDefault(); // } // } // // } // // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/LocaleResolverFactory.java // public class LocaleResolverFactory { // // private static volatile LocaleResolver localeResolver; // // private LocaleResolverFactory() { // } // // /** // * Gets the configured extension locale resolver // * // * @return The extension configured locale resolver // */ // public static LocaleResolver getLocaleResolver() { // return localeResolver; // } // // /** // * Sets the configured extension locale resolver // * // * @param localeResolver // * The configured extension locale resolver // */ // public static void setLocaleResolver(LocaleResolver localeResolver) { // LocaleResolverFactory.localeResolver = localeResolver; // } // // }
import java.util.Set; import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContext; import javax.servlet.ServletException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.byteslounge.cdi.resolver.locale.JSFLocaleResolver; import com.byteslounge.cdi.resolver.locale.LocaleResolverFactory;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.configuration; /** * Initializer which will configure the extension in a web application context. * * @author Gonçalo Marques * @since 1.0.0 */ public class ExtensionInitializer implements ServletContainerInitializer { public static final String DEFAULT_RESOURCE_BUNDLE_BASE_NAME_PARAM = "defaultResourceBundleBaseName"; private static final Logger logger = LoggerFactory.getLogger(ExtensionInitializer.class); /** * See {@link ServletContainerInitializer#onStartup(Set, ServletContext)} */ @Override public void onStartup(Set<Class<?>> c, ServletContext context) throws ServletException { ExtensionConfiguration.INSTANCE.init(); String defaultResourceBundleBaseName = context.getInitParameter(DEFAULT_RESOURCE_BUNDLE_BASE_NAME_PARAM); if (defaultResourceBundleBaseName != null) { logger.info("Found a default resource bundle name in web application context parameters. Will set it as: " + defaultResourceBundleBaseName); ExtensionConfiguration.INSTANCE.setResourceBundleDefaultBaseName(defaultResourceBundleBaseName); } try { Class.forName("javax.faces.context.FacesContext");
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/JSFLocaleResolver.java // public class JSFLocaleResolver implements LocaleResolver { // // /** // * See {@link LocaleResolver#getLocale()} // */ // @Override // public Locale getLocale() { // try { // return FacesContext.getCurrentInstance().getViewRoot().getLocale(); // }catch(NoClassDefFoundError e) { // return Locale.getDefault(); // } catch (Exception e) { // return Locale.getDefault(); // } // } // // } // // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/LocaleResolverFactory.java // public class LocaleResolverFactory { // // private static volatile LocaleResolver localeResolver; // // private LocaleResolverFactory() { // } // // /** // * Gets the configured extension locale resolver // * // * @return The extension configured locale resolver // */ // public static LocaleResolver getLocaleResolver() { // return localeResolver; // } // // /** // * Sets the configured extension locale resolver // * // * @param localeResolver // * The configured extension locale resolver // */ // public static void setLocaleResolver(LocaleResolver localeResolver) { // LocaleResolverFactory.localeResolver = localeResolver; // } // // } // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/configuration/ExtensionInitializer.java import java.util.Set; import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContext; import javax.servlet.ServletException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.byteslounge.cdi.resolver.locale.JSFLocaleResolver; import com.byteslounge.cdi.resolver.locale.LocaleResolverFactory; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.configuration; /** * Initializer which will configure the extension in a web application context. * * @author Gonçalo Marques * @since 1.0.0 */ public class ExtensionInitializer implements ServletContainerInitializer { public static final String DEFAULT_RESOURCE_BUNDLE_BASE_NAME_PARAM = "defaultResourceBundleBaseName"; private static final Logger logger = LoggerFactory.getLogger(ExtensionInitializer.class); /** * See {@link ServletContainerInitializer#onStartup(Set, ServletContext)} */ @Override public void onStartup(Set<Class<?>> c, ServletContext context) throws ServletException { ExtensionConfiguration.INSTANCE.init(); String defaultResourceBundleBaseName = context.getInitParameter(DEFAULT_RESOURCE_BUNDLE_BASE_NAME_PARAM); if (defaultResourceBundleBaseName != null) { logger.info("Found a default resource bundle name in web application context parameters. Will set it as: " + defaultResourceBundleBaseName); ExtensionConfiguration.INSTANCE.setResourceBundleDefaultBaseName(defaultResourceBundleBaseName); } try { Class.forName("javax.faces.context.FacesContext");
LocaleResolverFactory.setLocaleResolver(new JSFLocaleResolver());
gonmarques/cdi-properties
cdi-properties-main/src/main/java/com/byteslounge/cdi/configuration/ExtensionInitializer.java
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/JSFLocaleResolver.java // public class JSFLocaleResolver implements LocaleResolver { // // /** // * See {@link LocaleResolver#getLocale()} // */ // @Override // public Locale getLocale() { // try { // return FacesContext.getCurrentInstance().getViewRoot().getLocale(); // }catch(NoClassDefFoundError e) { // return Locale.getDefault(); // } catch (Exception e) { // return Locale.getDefault(); // } // } // // } // // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/LocaleResolverFactory.java // public class LocaleResolverFactory { // // private static volatile LocaleResolver localeResolver; // // private LocaleResolverFactory() { // } // // /** // * Gets the configured extension locale resolver // * // * @return The extension configured locale resolver // */ // public static LocaleResolver getLocaleResolver() { // return localeResolver; // } // // /** // * Sets the configured extension locale resolver // * // * @param localeResolver // * The configured extension locale resolver // */ // public static void setLocaleResolver(LocaleResolver localeResolver) { // LocaleResolverFactory.localeResolver = localeResolver; // } // // }
import java.util.Set; import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContext; import javax.servlet.ServletException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.byteslounge.cdi.resolver.locale.JSFLocaleResolver; import com.byteslounge.cdi.resolver.locale.LocaleResolverFactory;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.configuration; /** * Initializer which will configure the extension in a web application context. * * @author Gonçalo Marques * @since 1.0.0 */ public class ExtensionInitializer implements ServletContainerInitializer { public static final String DEFAULT_RESOURCE_BUNDLE_BASE_NAME_PARAM = "defaultResourceBundleBaseName"; private static final Logger logger = LoggerFactory.getLogger(ExtensionInitializer.class); /** * See {@link ServletContainerInitializer#onStartup(Set, ServletContext)} */ @Override public void onStartup(Set<Class<?>> c, ServletContext context) throws ServletException { ExtensionConfiguration.INSTANCE.init(); String defaultResourceBundleBaseName = context.getInitParameter(DEFAULT_RESOURCE_BUNDLE_BASE_NAME_PARAM); if (defaultResourceBundleBaseName != null) { logger.info("Found a default resource bundle name in web application context parameters. Will set it as: " + defaultResourceBundleBaseName); ExtensionConfiguration.INSTANCE.setResourceBundleDefaultBaseName(defaultResourceBundleBaseName); } try { Class.forName("javax.faces.context.FacesContext");
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/JSFLocaleResolver.java // public class JSFLocaleResolver implements LocaleResolver { // // /** // * See {@link LocaleResolver#getLocale()} // */ // @Override // public Locale getLocale() { // try { // return FacesContext.getCurrentInstance().getViewRoot().getLocale(); // }catch(NoClassDefFoundError e) { // return Locale.getDefault(); // } catch (Exception e) { // return Locale.getDefault(); // } // } // // } // // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/LocaleResolverFactory.java // public class LocaleResolverFactory { // // private static volatile LocaleResolver localeResolver; // // private LocaleResolverFactory() { // } // // /** // * Gets the configured extension locale resolver // * // * @return The extension configured locale resolver // */ // public static LocaleResolver getLocaleResolver() { // return localeResolver; // } // // /** // * Sets the configured extension locale resolver // * // * @param localeResolver // * The configured extension locale resolver // */ // public static void setLocaleResolver(LocaleResolver localeResolver) { // LocaleResolverFactory.localeResolver = localeResolver; // } // // } // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/configuration/ExtensionInitializer.java import java.util.Set; import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContext; import javax.servlet.ServletException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.byteslounge.cdi.resolver.locale.JSFLocaleResolver; import com.byteslounge.cdi.resolver.locale.LocaleResolverFactory; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.configuration; /** * Initializer which will configure the extension in a web application context. * * @author Gonçalo Marques * @since 1.0.0 */ public class ExtensionInitializer implements ServletContainerInitializer { public static final String DEFAULT_RESOURCE_BUNDLE_BASE_NAME_PARAM = "defaultResourceBundleBaseName"; private static final Logger logger = LoggerFactory.getLogger(ExtensionInitializer.class); /** * See {@link ServletContainerInitializer#onStartup(Set, ServletContext)} */ @Override public void onStartup(Set<Class<?>> c, ServletContext context) throws ServletException { ExtensionConfiguration.INSTANCE.init(); String defaultResourceBundleBaseName = context.getInitParameter(DEFAULT_RESOURCE_BUNDLE_BASE_NAME_PARAM); if (defaultResourceBundleBaseName != null) { logger.info("Found a default resource bundle name in web application context parameters. Will set it as: " + defaultResourceBundleBaseName); ExtensionConfiguration.INSTANCE.setResourceBundleDefaultBaseName(defaultResourceBundleBaseName); } try { Class.forName("javax.faces.context.FacesContext");
LocaleResolverFactory.setLocaleResolver(new JSFLocaleResolver());
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarDefaultPropertyMethodIT.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java // public abstract class AbstractWarDefaultPropertyMethod { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(TestBean.class, // InjectedBean.class); // DeploymentAppenderFactory // .create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/web.xml") // .appendWebResource( // "../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/cditest.xhtml", // "../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/cditestpt.xhtml") // .appendFacesConfig() // .appendBeansXml().appendCDIPropertiesLib().appendLogging().appendProperties().appendOtherProperties(); // return webArchive; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // }
import com.byteslounge.cdi.test.it.common.AbstractWarDefaultPropertyMethod; import com.byteslounge.cdi.test.utils.MessageBundleUtils; import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.configuration.TestConstants;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.0.0 */ @RunWith(Arquillian.class) public class WarDefaultPropertyMethodIT extends AbstractWarDefaultPropertyMethod { @Drone private WebDriver browser; @FindBy(id = "hello") private WebElement hello; @FindBy(id = "system") private WebElement system; @FindBy(id = "other") private WebElement other; @FindBy(id = "otherabc") private WebElement otherAbc; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarDefaultPropertyMethod.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "cditest.xhtml");
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java // public abstract class AbstractWarDefaultPropertyMethod { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(TestBean.class, // InjectedBean.class); // DeploymentAppenderFactory // .create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/web.xml") // .appendWebResource( // "../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/cditest.xhtml", // "../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/cditestpt.xhtml") // .appendFacesConfig() // .appendBeansXml().appendCDIPropertiesLib().appendLogging().appendProperties().appendOtherProperties(); // return webArchive; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // } // Path: cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarDefaultPropertyMethodIT.java import com.byteslounge.cdi.test.it.common.AbstractWarDefaultPropertyMethod; import com.byteslounge.cdi.test.utils.MessageBundleUtils; import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.configuration.TestConstants; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.0.0 */ @RunWith(Arquillian.class) public class WarDefaultPropertyMethodIT extends AbstractWarDefaultPropertyMethod { @Drone private WebDriver browser; @FindBy(id = "hello") private WebElement hello; @FindBy(id = "system") private WebElement system; @FindBy(id = "other") private WebElement other; @FindBy(id = "otherabc") private WebElement otherAbc; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarDefaultPropertyMethod.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "cditest.xhtml");
Assert.assertEquals(hello.getText(), MessageBundleUtils.resolveProperty("hello.world", "bl.messages", Locale.getDefault()));
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarDefaultPropertyMethodIT.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java // public abstract class AbstractWarDefaultPropertyMethod { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(TestBean.class, // InjectedBean.class); // DeploymentAppenderFactory // .create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/web.xml") // .appendWebResource( // "../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/cditest.xhtml", // "../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/cditestpt.xhtml") // .appendFacesConfig() // .appendBeansXml().appendCDIPropertiesLib().appendLogging().appendProperties().appendOtherProperties(); // return webArchive; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // }
import com.byteslounge.cdi.test.it.common.AbstractWarDefaultPropertyMethod; import com.byteslounge.cdi.test.utils.MessageBundleUtils; import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.configuration.TestConstants;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.0.0 */ @RunWith(Arquillian.class) public class WarDefaultPropertyMethodIT extends AbstractWarDefaultPropertyMethod { @Drone private WebDriver browser; @FindBy(id = "hello") private WebElement hello; @FindBy(id = "system") private WebElement system; @FindBy(id = "other") private WebElement other; @FindBy(id = "otherabc") private WebElement otherAbc; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarDefaultPropertyMethod.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "cditest.xhtml"); Assert.assertEquals(hello.getText(), MessageBundleUtils.resolveProperty("hello.world", "bl.messages", Locale.getDefault())); Assert.assertEquals(system.getText(), MessageBundleUtils.resolveProperty("system.linux.box", "bl.messages", Locale.getDefault(), "Linux", "16"));
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarDefaultPropertyMethod.java // public abstract class AbstractWarDefaultPropertyMethod { // // protected static WebArchive createArchive() throws IOException { // // WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(TestBean.class, // InjectedBean.class); // DeploymentAppenderFactory // .create(webArchive) // .appendWebXml("../cdi-properties-test-common/src/test/resources/assets/warCommon/WEB-INF/web.xml") // .appendWebResource( // "../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/cditest.xhtml", // "../cdi-properties-test-common/src/test/resources/assets/warCommon/webapp/cditestpt.xhtml") // .appendFacesConfig() // .appendBeansXml().appendCDIPropertiesLib().appendLogging().appendProperties().appendOtherProperties(); // return webArchive; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/utils/MessageBundleUtils.java // public class MessageBundleUtils { // // private MessageBundleUtils() { // } // // public static String resolveProperty(String key, String bundleName, Locale locale, Object... args) { // String value = ResourceBundle.getBundle(bundleName, locale).getString(key); // if (args != null && args.length > 0) { // value = MessageFormat.format(value, args); // } // return value; // } // // } // Path: cdi-properties-test/cdi-properties-test-wildfly82/src/test/java/com/byteslounge/cdi/test/it/WarDefaultPropertyMethodIT.java import com.byteslounge.cdi.test.it.common.AbstractWarDefaultPropertyMethod; import com.byteslounge.cdi.test.utils.MessageBundleUtils; import java.io.IOException; import java.net.URL; import java.util.Locale; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import com.byteslounge.cdi.test.configuration.TestConstants; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.0.0 */ @RunWith(Arquillian.class) public class WarDefaultPropertyMethodIT extends AbstractWarDefaultPropertyMethod { @Drone private WebDriver browser; @FindBy(id = "hello") private WebElement hello; @FindBy(id = "system") private WebElement system; @FindBy(id = "other") private WebElement other; @FindBy(id = "otherabc") private WebElement otherAbc; @Deployment public static WebArchive createArchive() throws IOException { WebArchive webArchive = CommonWarDefaultPropertyMethod.createArchive(); return webArchive; } @Test @RunAsClient public void test(@ArquillianResource URL contextPath) { browser.get(contextPath + "cditest.xhtml"); Assert.assertEquals(hello.getText(), MessageBundleUtils.resolveProperty("hello.world", "bl.messages", Locale.getDefault())); Assert.assertEquals(system.getText(), MessageBundleUtils.resolveProperty("system.linux.box", "bl.messages", Locale.getDefault(), "Linux", "16"));
Assert.assertEquals(other.getText(), MessageBundleUtils.resolveProperty("other.message", TestConstants.OTHER_RESOURCE_BUNDLE_NAME, Locale.getDefault()));
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/filter/LocaleFilterPT.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // }
import java.io.IOException; import java.util.Locale; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import com.byteslounge.cdi.test.common.LocaleThreadLocal;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.common.filter; /** * Filter that sets the current locale as PT * * @author Gonçalo Marques * @since 1.1.0 */ @WebFilter(urlPatterns = "/*") public class LocaleFilterPT implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try {
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/filter/LocaleFilterPT.java import java.io.IOException; import java.util.Locale; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import com.byteslounge.cdi.test.common.LocaleThreadLocal; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.common.filter; /** * Filter that sets the current locale as PT * * @author Gonçalo Marques * @since 1.1.0 */ @WebFilter(urlPatterns = "/*") public class LocaleFilterPT implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { try {
LocaleThreadLocal.localeThreadLocal.set(new LocaleThreadLocal(new Locale("pt", "PT")));
gonmarques/cdi-properties
cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/bean/ResolverBean.java
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/context/ResolverContext.java // public class ResolverContext { // // private final String key; // private final String bundleName; // private Bean<?> resolverBean; // private BeanManager beanManager; // // private ResolverContext(String key, String bundleName) { // this.key = key; // this.bundleName = bundleName; // } // // /** // * Creates a {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance. // * // * @param key the property key to be associated with the created context // * @param bundleName the resource bundle name to be associated with the created context // * // * @return the newly created {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public static ResolverContext create(String key, String bundleName) { // return new ResolverContext(key, bundleName); // } // // /** // * Gets the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getKey() { // return key; // } // // /** // * Gets the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getBundleName() { // return bundleName; // } // // /** // * Sets the resolver bean associated with the current resolving execution // * // * @param resolverBean the property key to be associated with the created context // */ // public void setResolverBean(Bean<?> resolverBean) { // this.resolverBean = resolverBean; // } // // /** // * Gets the resolver bean associated with the current resolving execution // * // * @return the resolver bean associated with the current resolving execution // */ // public Bean<?> getResolverBean() { // return resolverBean; // } // // /** // * Gets the bean manager associated with the current resolving execution // * // * @return the bean manager associated with the current resolving execution // */ // public BeanManager getBeanManager() { // return beanManager; // } // // /** // * Sets the bean manager associated with the current resolving execution // * // * @param beanManager the bean manager associated with the current resolving execution // */ // public void setBeanManager(BeanManager beanManager) { // this.beanManager = beanManager; // } // // }
import javax.enterprise.inject.spi.BeanManager; import com.byteslounge.cdi.resolver.context.ResolverContext; import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.inject.spi.AnnotatedType;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.resolver.bean; /** * Interface used to define an extension's resolver method. * * @author Gonçalo Marques * @since 1.1.0 */ public interface ResolverBean<T> { /** * Processes a CDI managed bean and checks if it defines an extension's resolver method * * @param at the CDI managed bean to check for an extension's resolver method */ void process(AnnotatedType<?> at); /** * Initializes the extension's resolver method * * @param beanManager the CDI container Bean Manager */ void initialize(BeanManager beanManager); /** * Invokes the extension's resolver method represented by this bean * * @param resolverContext the Resolver Context * @param ctx The CDI creational context * * @return the value returned by this extension's resolver method */
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/context/ResolverContext.java // public class ResolverContext { // // private final String key; // private final String bundleName; // private Bean<?> resolverBean; // private BeanManager beanManager; // // private ResolverContext(String key, String bundleName) { // this.key = key; // this.bundleName = bundleName; // } // // /** // * Creates a {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance. // * // * @param key the property key to be associated with the created context // * @param bundleName the resource bundle name to be associated with the created context // * // * @return the newly created {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public static ResolverContext create(String key, String bundleName) { // return new ResolverContext(key, bundleName); // } // // /** // * Gets the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getKey() { // return key; // } // // /** // * Gets the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getBundleName() { // return bundleName; // } // // /** // * Sets the resolver bean associated with the current resolving execution // * // * @param resolverBean the property key to be associated with the created context // */ // public void setResolverBean(Bean<?> resolverBean) { // this.resolverBean = resolverBean; // } // // /** // * Gets the resolver bean associated with the current resolving execution // * // * @return the resolver bean associated with the current resolving execution // */ // public Bean<?> getResolverBean() { // return resolverBean; // } // // /** // * Gets the bean manager associated with the current resolving execution // * // * @return the bean manager associated with the current resolving execution // */ // public BeanManager getBeanManager() { // return beanManager; // } // // /** // * Sets the bean manager associated with the current resolving execution // * // * @param beanManager the bean manager associated with the current resolving execution // */ // public void setBeanManager(BeanManager beanManager) { // this.beanManager = beanManager; // } // // } // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/bean/ResolverBean.java import javax.enterprise.inject.spi.BeanManager; import com.byteslounge.cdi.resolver.context.ResolverContext; import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.inject.spi.AnnotatedType; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.resolver.bean; /** * Interface used to define an extension's resolver method. * * @author Gonçalo Marques * @since 1.1.0 */ public interface ResolverBean<T> { /** * Processes a CDI managed bean and checks if it defines an extension's resolver method * * @param at the CDI managed bean to check for an extension's resolver method */ void process(AnnotatedType<?> at); /** * Initializes the extension's resolver method * * @param beanManager the CDI container Bean Manager */ void initialize(BeanManager beanManager); /** * Invokes the extension's resolver method represented by this bean * * @param resolverContext the Resolver Context * @param ctx The CDI creational context * * @return the value returned by this extension's resolver method */
T invoke(ResolverContext resolverContext, CreationalContext<?> ctx);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverSession.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/session/UserSession.java // @SessionScoped // public class UserSession implements Serializable { // // private static final long serialVersionUID = 1L; // private Locale locale; // // public Locale getLocale() { // return locale; // } // // public void setLocale(Locale locale) { // this.locale = locale; // } // // }
import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.test.common.session.UserSession;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolverSession implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/session/UserSession.java // @SessionScoped // public class UserSession implements Serializable { // // private static final long serialVersionUID = 1L; // private Locale locale; // // public Locale getLocale() { // return locale; // } // // public void setLocale(Locale locale) { // this.locale = locale; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverSession.java import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.test.common.session.UserSession; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; @ApplicationScoped public class ProvidedLocaleMethodResolverSession implements Serializable { private static final long serialVersionUID = 1L; @LocaleResolver
public Locale resolveLocale(UserSession userSession) {
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/RequestScopedBean.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // }
import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @RequestScoped public class RequestScopedBean { @Inject
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/RequestScopedBean.java import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @RequestScoped public class RequestScopedBean { @Inject
private InjectedBean injectedBean;
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/RequestScopedBean.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // }
import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @RequestScoped public class RequestScopedBean { @Inject private InjectedBean injectedBean; public String getText() {
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/InjectedBean.java // public class InjectedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // public String getText() { // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/RequestScopedBean.java import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import org.junit.Assert; import com.byteslounge.cdi.test.common.InjectedBean; import com.byteslounge.cdi.test.configuration.TestConstants; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.wpm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @RequestScoped public class RequestScopedBean { @Inject private InjectedBean injectedBean; public String getText() {
Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarDefaultPropertyMethodNoFaces.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarDefaultPropertyMethodNoFaces { public static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarDefaultPropertyMethodNoFaces.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarDefaultPropertyMethodNoFaces { public static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
OtherService.class, OtherServiceBean.class, TestServlet.class);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarDefaultPropertyMethodNoFaces.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarDefaultPropertyMethodNoFaces { public static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarDefaultPropertyMethodNoFaces.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarDefaultPropertyMethodNoFaces { public static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
OtherService.class, OtherServiceBean.class, TestServlet.class);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarDefaultPropertyMethodNoFaces.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarDefaultPropertyMethodNoFaces { public static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarDefaultPropertyMethodNoFaces.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarDefaultPropertyMethodNoFaces { public static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
OtherService.class, OtherServiceBean.class, TestServlet.class);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarDefaultPropertyMethodNoFaces.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarDefaultPropertyMethodNoFaces { public static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses( OtherService.class, OtherServiceBean.class, TestServlet.class);
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/CommonWarDefaultPropertyMethodNoFaces.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it; /** * Integration Test * * @author Gonçalo Marques * @since 1.1.0 */ public class CommonWarDefaultPropertyMethodNoFaces { public static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses( OtherService.class, OtherServiceBean.class, TestServlet.class);
DeploymentAppenderFactory.create(webArchive)
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/epm/EjbProvidedMethodResolver.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // }
import java.io.Serializable; import java.util.Locale; import java.util.ResourceBundle; import javax.enterprise.context.ApplicationScoped; import javax.naming.InitialContext; import javax.naming.NamingException; import org.junit.Assert; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.annotation.PropertyResolver; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.epm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class EjbProvidedMethodResolver implements Serializable { private static final long serialVersionUID = 1L; // Lets provide a set of completely mixed up parameters in what matters to "logical" definition order @PropertyResolver
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/epm/EjbProvidedMethodResolver.java import java.io.Serializable; import java.util.Locale; import java.util.ResourceBundle; import javax.enterprise.context.ApplicationScoped; import javax.naming.InitialContext; import javax.naming.NamingException; import org.junit.Assert; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.annotation.PropertyResolver; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.epm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class EjbProvidedMethodResolver implements Serializable { private static final long serialVersionUID = 1L; // Lets provide a set of completely mixed up parameters in what matters to "logical" definition order @PropertyResolver
public String resolveProperty(@PropertyBundle String bundleName, DependentScopedBean dependentScopedBean,
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/epm/EjbProvidedMethodResolver.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // }
import java.io.Serializable; import java.util.Locale; import java.util.ResourceBundle; import javax.enterprise.context.ApplicationScoped; import javax.naming.InitialContext; import javax.naming.NamingException; import org.junit.Assert; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.annotation.PropertyResolver; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.epm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class EjbProvidedMethodResolver implements Serializable { private static final long serialVersionUID = 1L; // Lets provide a set of completely mixed up parameters in what matters to "logical" definition order @PropertyResolver public String resolveProperty(@PropertyBundle String bundleName, DependentScopedBean dependentScopedBean,
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/epm/EjbProvidedMethodResolver.java import java.io.Serializable; import java.util.Locale; import java.util.ResourceBundle; import javax.enterprise.context.ApplicationScoped; import javax.naming.InitialContext; import javax.naming.NamingException; import org.junit.Assert; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.annotation.PropertyResolver; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.epm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class EjbProvidedMethodResolver implements Serializable { private static final long serialVersionUID = 1L; // Lets provide a set of completely mixed up parameters in what matters to "logical" definition order @PropertyResolver public String resolveProperty(@PropertyBundle String bundleName, DependentScopedBean dependentScopedBean,
@PropertyLocale Locale locale, ApplicationScopedBean applicationScopedBean, @PropertyKey String key) {
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/epm/EjbProvidedMethodResolver.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // }
import java.io.Serializable; import java.util.Locale; import java.util.ResourceBundle; import javax.enterprise.context.ApplicationScoped; import javax.naming.InitialContext; import javax.naming.NamingException; import org.junit.Assert; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.annotation.PropertyResolver; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.epm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class EjbProvidedMethodResolver implements Serializable { private static final long serialVersionUID = 1L; // Lets provide a set of completely mixed up parameters in what matters to "logical" definition order @PropertyResolver public String resolveProperty(@PropertyBundle String bundleName, DependentScopedBean dependentScopedBean, @PropertyLocale Locale locale, ApplicationScopedBean applicationScopedBean, @PropertyKey String key) {
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/epm/EjbProvidedMethodResolver.java import java.io.Serializable; import java.util.Locale; import java.util.ResourceBundle; import javax.enterprise.context.ApplicationScoped; import javax.naming.InitialContext; import javax.naming.NamingException; import org.junit.Assert; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.annotation.PropertyResolver; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.epm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class EjbProvidedMethodResolver implements Serializable { private static final long serialVersionUID = 1L; // Lets provide a set of completely mixed up parameters in what matters to "logical" definition order @PropertyResolver public String resolveProperty(@PropertyBundle String bundleName, DependentScopedBean dependentScopedBean, @PropertyLocale Locale locale, ApplicationScopedBean applicationScopedBean, @PropertyKey String key) {
Assert.assertEquals(dependentScopedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE);
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/epm/EjbProvidedMethodResolver.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // }
import java.io.Serializable; import java.util.Locale; import java.util.ResourceBundle; import javax.enterprise.context.ApplicationScoped; import javax.naming.InitialContext; import javax.naming.NamingException; import org.junit.Assert; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.annotation.PropertyResolver; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.epm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class EjbProvidedMethodResolver implements Serializable { private static final long serialVersionUID = 1L; // Lets provide a set of completely mixed up parameters in what matters to "logical" definition order @PropertyResolver public String resolveProperty(@PropertyBundle String bundleName, DependentScopedBean dependentScopedBean, @PropertyLocale Locale locale, ApplicationScopedBean applicationScopedBean, @PropertyKey String key) { Assert.assertEquals(dependentScopedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); Assert.assertEquals(applicationScopedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); ServiceEjbProvidedMethod serviceEjbProvidedMethod = null; try { serviceEjbProvidedMethod = (ServiceEjbProvidedMethod) new InitialContext() .lookup("java:global/cdiproperties/cdipropertiesejb/ServiceEjbProvidedMethodBean"); } catch (NamingException e) { throw new RuntimeException(e); } Assert.assertEquals(serviceEjbProvidedMethod.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); serviceEjbProvidedMethod.remove(1L);
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/ApplicationScopedBean.java // @ApplicationScoped // public class ApplicationScopedBean implements Serializable { // // private static final long serialVersionUID = 1L; // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/DependentScopedBean.java // public class DependentScopedBean { // // @Inject // private InjectedBean injectedBean; // // public String getText() { // Assert.assertEquals(injectedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); // return TestConstants.BEAN_TEST_RETURN_VALUE; // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/configuration/TestConstants.java // public class TestConstants { // // private TestConstants() { // } // // public static final String OTHER_RESOURCE_BUNDLE_NAME = "bl.other"; // public static final String BEAN_TEST_RETURN_VALUE = "getTextResult"; // public static final String PROVIDED_RESOLVER_SUFFIX = "provided"; // public static final String EXTERNAL_CLASSES_DIRECTORY = "target/external"; // public static final String TEST_TARGET_CLASSES_DIRECTORY = "target/test-classes"; // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/model/TestEntity.java // @Entity // @Table(name = "TEST_ENTITY") // public class TestEntity implements Serializable { // // private static final long serialVersionUID = 1L; // // @Id // @Column(name = "ID", nullable = false) // @GeneratedValue(strategy = GenerationType.AUTO, generator = "IdGenerator") // @GenericGenerator(name = "IdGenerator", strategy = "com.byteslounge.cdi.test.model.IdGenerator") // private Long id; // // @Column(name = "DESCRIPTION", nullable = false) // private String description; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/epm/EjbProvidedMethodResolver.java import java.io.Serializable; import java.util.Locale; import java.util.ResourceBundle; import javax.enterprise.context.ApplicationScoped; import javax.naming.InitialContext; import javax.naming.NamingException; import org.junit.Assert; import com.byteslounge.cdi.annotation.PropertyBundle; import com.byteslounge.cdi.annotation.PropertyKey; import com.byteslounge.cdi.annotation.PropertyLocale; import com.byteslounge.cdi.annotation.PropertyResolver; import com.byteslounge.cdi.test.common.ApplicationScopedBean; import com.byteslounge.cdi.test.common.DependentScopedBean; import com.byteslounge.cdi.test.configuration.TestConstants; import com.byteslounge.cdi.test.model.TestEntity; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.epm; /** * Used in CDI Properties integration tests. See WarDefaultMethodIT.java, * WarProvidedMethodIT.java, EjbDefaultMethodIT.java and * EjbProvidedMethodIT.java. * * @author Gonçalo Marques * @since 1.0.0 */ @ApplicationScoped public class EjbProvidedMethodResolver implements Serializable { private static final long serialVersionUID = 1L; // Lets provide a set of completely mixed up parameters in what matters to "logical" definition order @PropertyResolver public String resolveProperty(@PropertyBundle String bundleName, DependentScopedBean dependentScopedBean, @PropertyLocale Locale locale, ApplicationScopedBean applicationScopedBean, @PropertyKey String key) { Assert.assertEquals(dependentScopedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); Assert.assertEquals(applicationScopedBean.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); ServiceEjbProvidedMethod serviceEjbProvidedMethod = null; try { serviceEjbProvidedMethod = (ServiceEjbProvidedMethod) new InitialContext() .lookup("java:global/cdiproperties/cdipropertiesejb/ServiceEjbProvidedMethodBean"); } catch (NamingException e) { throw new RuntimeException(e); } Assert.assertEquals(serviceEjbProvidedMethod.getText(), TestConstants.BEAN_TEST_RETURN_VALUE); serviceEjbProvidedMethod.remove(1L);
TestEntity testEntity = new TestEntity();
gonmarques/cdi-properties
cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/DefaultLocaleResolverMethod.java
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/LocaleResolverFactory.java // public class LocaleResolverFactory { // // private static volatile LocaleResolver localeResolver; // // private LocaleResolverFactory() { // } // // /** // * Gets the configured extension locale resolver // * // * @return The extension configured locale resolver // */ // public static LocaleResolver getLocaleResolver() { // return localeResolver; // } // // /** // * Sets the configured extension locale resolver // * // * @param localeResolver // * The configured extension locale resolver // */ // public static void setLocaleResolver(LocaleResolver localeResolver) { // LocaleResolverFactory.localeResolver = localeResolver; // } // // }
import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.resolver.locale.LocaleResolverFactory;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.resolver; /** * The default locale resolver method. * * @author Gonçalo Marques * @since 1.1.0 */ @ApplicationScoped public class DefaultLocaleResolverMethod implements Serializable { private static final long serialVersionUID = 1L; private static final Logger logger = LoggerFactory.getLogger(DefaultLocaleResolverMethod.class); /** * The default locale resolver method. * * @return The resolved locale */ @LocaleResolver public Locale resolveLocale() { if (logger.isDebugEnabled()) { logger.debug("Resolving locale"); }
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/locale/LocaleResolverFactory.java // public class LocaleResolverFactory { // // private static volatile LocaleResolver localeResolver; // // private LocaleResolverFactory() { // } // // /** // * Gets the configured extension locale resolver // * // * @return The extension configured locale resolver // */ // public static LocaleResolver getLocaleResolver() { // return localeResolver; // } // // /** // * Sets the configured extension locale resolver // * // * @param localeResolver // * The configured extension locale resolver // */ // public static void setLocaleResolver(LocaleResolver localeResolver) { // LocaleResolverFactory.localeResolver = localeResolver; // } // // } // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/DefaultLocaleResolverMethod.java import java.io.Serializable; import java.util.Locale; import javax.enterprise.context.ApplicationScoped; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.byteslounge.cdi.annotation.LocaleResolver; import com.byteslounge.cdi.resolver.locale.LocaleResolverFactory; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.resolver; /** * The default locale resolver method. * * @author Gonçalo Marques * @since 1.1.0 */ @ApplicationScoped public class DefaultLocaleResolverMethod implements Serializable { private static final long serialVersionUID = 1L; private static final Logger logger = LoggerFactory.getLogger(DefaultLocaleResolverMethod.class); /** * The default locale resolver method. * * @return The resolved locale */ @LocaleResolver public Locale resolveLocale() { if (logger.isDebugEnabled()) { logger.debug("Resolving locale"); }
return LocaleResolverFactory.getLocaleResolver().getLocale();
gonmarques/cdi-properties
cdi-properties-main/src/main/java/com/byteslounge/cdi/extension/param/KeyPropertyResolverParameter.java
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/context/ResolverContext.java // public class ResolverContext { // // private final String key; // private final String bundleName; // private Bean<?> resolverBean; // private BeanManager beanManager; // // private ResolverContext(String key, String bundleName) { // this.key = key; // this.bundleName = bundleName; // } // // /** // * Creates a {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance. // * // * @param key the property key to be associated with the created context // * @param bundleName the resource bundle name to be associated with the created context // * // * @return the newly created {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public static ResolverContext create(String key, String bundleName) { // return new ResolverContext(key, bundleName); // } // // /** // * Gets the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getKey() { // return key; // } // // /** // * Gets the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getBundleName() { // return bundleName; // } // // /** // * Sets the resolver bean associated with the current resolving execution // * // * @param resolverBean the property key to be associated with the created context // */ // public void setResolverBean(Bean<?> resolverBean) { // this.resolverBean = resolverBean; // } // // /** // * Gets the resolver bean associated with the current resolving execution // * // * @return the resolver bean associated with the current resolving execution // */ // public Bean<?> getResolverBean() { // return resolverBean; // } // // /** // * Gets the bean manager associated with the current resolving execution // * // * @return the bean manager associated with the current resolving execution // */ // public BeanManager getBeanManager() { // return beanManager; // } // // /** // * Sets the bean manager associated with the current resolving execution // * // * @param beanManager the bean manager associated with the current resolving execution // */ // public void setBeanManager(BeanManager beanManager) { // this.beanManager = beanManager; // } // // }
import com.byteslounge.cdi.resolver.context.ResolverContext; import javax.enterprise.context.spi.CreationalContext;
/* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.extension.param; /** * Represents a resolver that will be used to evaluate a * parameter of the property resolver method of type Key * * @author Gonçalo Marques * @since 1.1.0 */ public class KeyPropertyResolverParameter implements ResolverParameter<String> { /** * see {@link ResolverParameter#resolve(String, String, CreationalContext)} */ @Override
// Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/resolver/context/ResolverContext.java // public class ResolverContext { // // private final String key; // private final String bundleName; // private Bean<?> resolverBean; // private BeanManager beanManager; // // private ResolverContext(String key, String bundleName) { // this.key = key; // this.bundleName = bundleName; // } // // /** // * Creates a {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance. // * // * @param key the property key to be associated with the created context // * @param bundleName the resource bundle name to be associated with the created context // * // * @return the newly created {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public static ResolverContext create(String key, String bundleName) { // return new ResolverContext(key, bundleName); // } // // /** // * Gets the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the key associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getKey() { // return key; // } // // /** // * Gets the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // * // * @return the resource bundle name associated with this {@link com.byteslounge.cdi.resolver.context.ResolverContext} instance // */ // public String getBundleName() { // return bundleName; // } // // /** // * Sets the resolver bean associated with the current resolving execution // * // * @param resolverBean the property key to be associated with the created context // */ // public void setResolverBean(Bean<?> resolverBean) { // this.resolverBean = resolverBean; // } // // /** // * Gets the resolver bean associated with the current resolving execution // * // * @return the resolver bean associated with the current resolving execution // */ // public Bean<?> getResolverBean() { // return resolverBean; // } // // /** // * Gets the bean manager associated with the current resolving execution // * // * @return the bean manager associated with the current resolving execution // */ // public BeanManager getBeanManager() { // return beanManager; // } // // /** // * Sets the bean manager associated with the current resolving execution // * // * @param beanManager the bean manager associated with the current resolving execution // */ // public void setBeanManager(BeanManager beanManager) { // this.beanManager = beanManager; // } // // } // Path: cdi-properties-main/src/main/java/com/byteslounge/cdi/extension/param/KeyPropertyResolverParameter.java import com.byteslounge.cdi.resolver.context.ResolverContext; import javax.enterprise.context.spi.CreationalContext; /* * Copyright 2014 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.extension.param; /** * Represents a resolver that will be used to evaluate a * parameter of the property resolver method of type Key * * @author Gonçalo Marques * @since 1.1.0 */ public class KeyPropertyResolverParameter implements ResolverParameter<String> { /** * see {@link ResolverParameter#resolve(String, String, CreationalContext)} */ @Override
public <T> String resolve(ResolverContext resolverContext, CreationalContext<T> ctx) {
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodThreadLocal.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverThreadLocal.java // @ApplicationScoped // public class ProvidedLocaleMethodResolverThreadLocal implements Serializable { // // private static final long serialVersionUID = 1L; // // @LocaleResolver // public Locale resolveLocale() { // return LocaleThreadLocal.localeThreadLocal.get().getLocale(); // } // // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.LocaleThreadLocal; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; import com.byteslounge.cdi.test.wpm.ProvidedLocaleMethodResolverThreadLocal;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which resolve the current locale from a ThreadLocal variable * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarProvidedLocaleMethodThreadLocal { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverThreadLocal.java // @ApplicationScoped // public class ProvidedLocaleMethodResolverThreadLocal implements Serializable { // // private static final long serialVersionUID = 1L; // // @LocaleResolver // public Locale resolveLocale() { // return LocaleThreadLocal.localeThreadLocal.get().getLocale(); // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodThreadLocal.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.LocaleThreadLocal; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; import com.byteslounge.cdi.test.wpm.ProvidedLocaleMethodResolverThreadLocal; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which resolve the current locale from a ThreadLocal variable * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarProvidedLocaleMethodThreadLocal { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
ProvidedLocaleMethodResolverThreadLocal.class, OtherService.class, OtherServiceBean.class,
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodThreadLocal.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverThreadLocal.java // @ApplicationScoped // public class ProvidedLocaleMethodResolverThreadLocal implements Serializable { // // private static final long serialVersionUID = 1L; // // @LocaleResolver // public Locale resolveLocale() { // return LocaleThreadLocal.localeThreadLocal.get().getLocale(); // } // // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.LocaleThreadLocal; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; import com.byteslounge.cdi.test.wpm.ProvidedLocaleMethodResolverThreadLocal;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which resolve the current locale from a ThreadLocal variable * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarProvidedLocaleMethodThreadLocal { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverThreadLocal.java // @ApplicationScoped // public class ProvidedLocaleMethodResolverThreadLocal implements Serializable { // // private static final long serialVersionUID = 1L; // // @LocaleResolver // public Locale resolveLocale() { // return LocaleThreadLocal.localeThreadLocal.get().getLocale(); // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodThreadLocal.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.LocaleThreadLocal; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; import com.byteslounge.cdi.test.wpm.ProvidedLocaleMethodResolverThreadLocal; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which resolve the current locale from a ThreadLocal variable * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarProvidedLocaleMethodThreadLocal { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
ProvidedLocaleMethodResolverThreadLocal.class, OtherService.class, OtherServiceBean.class,
gonmarques/cdi-properties
cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodThreadLocal.java
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverThreadLocal.java // @ApplicationScoped // public class ProvidedLocaleMethodResolverThreadLocal implements Serializable { // // private static final long serialVersionUID = 1L; // // @LocaleResolver // public Locale resolveLocale() { // return LocaleThreadLocal.localeThreadLocal.get().getLocale(); // } // // }
import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.LocaleThreadLocal; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; import com.byteslounge.cdi.test.wpm.ProvidedLocaleMethodResolverThreadLocal;
/* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which resolve the current locale from a ThreadLocal variable * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarProvidedLocaleMethodThreadLocal { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
// Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/LocaleThreadLocal.java // public class LocaleThreadLocal { // // public static final ThreadLocal<LocaleThreadLocal> localeThreadLocal = new ThreadLocal<>(); // private final Locale locale; // // public LocaleThreadLocal(Locale locale) { // this.locale = locale; // } // // public Locale getLocale() { // return locale; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/common/servlet/TestServlet.java // @WebServlet(urlPatterns = "/testservlet") // public class TestServlet extends HttpServlet { // // private static final long serialVersionUID = 1L; // // @EJB // private OtherService otherService; // // @Override // protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Assert.assertEquals(Integer.class, otherService.getInteger().getClass()); // Assert.assertEquals(new Integer(2), otherService.getInteger()); // req.setAttribute("result", otherService.getText()); // req.setAttribute("integer", otherService.getInteger()); // req.getRequestDispatcher("test.jsp").forward(req, resp); // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/IntegrationTestDeploymentUtils.java // public static class DeploymentAppenderFactory { // // private DeploymentAppenderFactory() { // } // // public static WebDeploymentAppender create(WebArchive archive) { // return new WebDeploymentAppender(archive); // } // // public static JavaDeploymentAppender create(JavaArchive archive) { // return new JavaDeploymentAppender(archive); // } // // public static EnterpriseDeploymentAppender create(EnterpriseArchive archive) { // return new EnterpriseDeploymentAppender(archive); // } // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherService.java // @Local // public interface OtherService extends Serializable { // // String getText(); // // Integer getInteger(); // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/OtherServiceBean.java // @Stateless // public class OtherServiceBean implements OtherService { // // private static final long serialVersionUID = 1L; // // @Property("hello.world") // private String text; // // @Property("some.integer") // private Integer integer; // // @Override // public String getText() { // return text; // } // // @Override // public Integer getInteger() { // return integer; // } // // } // // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/wpm/ProvidedLocaleMethodResolverThreadLocal.java // @ApplicationScoped // public class ProvidedLocaleMethodResolverThreadLocal implements Serializable { // // private static final long serialVersionUID = 1L; // // @LocaleResolver // public Locale resolveLocale() { // return LocaleThreadLocal.localeThreadLocal.get().getLocale(); // } // // } // Path: cdi-properties-test/cdi-properties-test-common/src/main/java/com/byteslounge/cdi/test/it/common/AbstractWarProvidedLocaleMethodThreadLocal.java import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import com.byteslounge.cdi.test.common.LocaleThreadLocal; import com.byteslounge.cdi.test.common.servlet.TestServlet; import com.byteslounge.cdi.test.it.common.IntegrationTestDeploymentUtils.DeploymentAppenderFactory; import com.byteslounge.cdi.test.wpm.OtherService; import com.byteslounge.cdi.test.wpm.OtherServiceBean; import com.byteslounge.cdi.test.wpm.ProvidedLocaleMethodResolverThreadLocal; /* * Copyright 2015 byteslounge.com (Gonçalo Marques). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.byteslounge.cdi.test.it.common; /** * Base class for Integration Tests which resolve the current locale from a ThreadLocal variable * * @author Gonçalo Marques * @since 1.1.0 */ public abstract class AbstractWarProvidedLocaleMethodThreadLocal { protected static WebArchive createArchive() throws IOException { WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "cdipropertiestest.war").addClasses(
ProvidedLocaleMethodResolverThreadLocal.class, OtherService.class, OtherServiceBean.class,