Examples of Shop


Examples of com.kellerkindt.scs.shops.Shop

   * Is called, if items should be added to a shop
   * @param sciae  ShowCaseItemAddEvent with needed information about the shop and player
   */
  @EventHandler (ignoreCancelled=true, priority=EventPriority.MONITOR)
  public void onShowCaseItemAddEvent (ShowCaseItemAddEvent sciae) {
    Shop      shop  = sciae.getShop();
    ExchangeShop  shopEx  = shop instanceof ExchangeShop ? ((ExchangeShop)shop) : null;
    int        amount  = sciae.getAmount();
   
    if (shop.getItemStack().isSimilar(sciae.getItemStack())) {
      // add the amount
      shop.setAmount(shop.getAmount() + amount);
     
      // set the message
      sciae.setMsgSuccessfully(Term.INVENTORY_UPDATE.get(""+amount, ""+shop.getAmount()));
   
    } else if (shopEx != null && shopEx.getExchangeItemStack().isSimilar(sciae.getItemStack())) {
   
      // add the amount
      shopEx.setExchangeAmount(shopEx.getExchangeAmount() + amount);
View Full Code Here

Examples of com.kellerkindt.scs.shops.Shop

   * Is called, if a member should be added to a shop
   * @param scmae  ShowCaseMemberAddEvent with needed information about the shop and the member to add
   */
  @EventHandler (ignoreCancelled=true, priority=EventPriority.MONITOR)
  public void onShowCaseMemberAddEvent (ShowCaseMemberAddEvent scmae) {
    Shop  shop  = scmae.getShop();
    String  member  = scmae.getMember();
   
    shop.addMember(member);
  }
View Full Code Here

Examples of com.kellerkindt.scs.shops.Shop

   * @param scce  ShowCaseCreateEvent with needed information about the shop and player
   */
  @EventHandler (ignoreCancelled=true, priority=EventPriority.MONITOR)
  public void onShowCaseCreateEvent (ShowCaseCreateEvent scce) {
    // get the shop to add
    Shop  shop  = scce.getShop();
    double  cost  = scs.getCreatePrice(shop.getClass());
   
    // add the shop
    scs.getShopHandler().addShop(scce.getShop());
    scs.getShopHandler().show  (scce.getShop());
   
View Full Code Here

Examples of com.kellerkindt.scs.shops.Shop

   * @param scire  ShowCaseItemRemoveEvent with needed information about the shop and player
   */
  @EventHandler (ignoreCancelled=true, priority=EventPriority.MONITOR)
  public void onShowCaseItemRemoveEvent (ShowCaseItemRemoveEvent scire) {
   
    Shop      shop  = scire.getShop();
    ExchangeShop  shopEx  = shop instanceof ExchangeShop ? ((ExchangeShop)shop) : null;
    int        amount  = scire.getAmount();
   
    if (shop.getItemStack().isSimilar(scire.getItemStack())) {
     
      // add the amount
      shop.setAmount(shop.getAmount() - amount);
     
      // set the message
      scire.setMsgSuccessfully(Term.INVENTORY_UPDATE.get(""+amount, ""+shop.getAmount()));
   
    } else if (shopEx != null && shopEx.getExchangeItemStack().isSimilar(scire.getItemStack())) {
   
      // add the amount
      shopEx.setExchangeAmount(shopEx.getExchangeAmount() - amount);
View Full Code Here

Examples of com.kellerkindt.scs.shops.Shop

   */
  @Override
  @EventHandler (ignoreCancelled=true, priority=EventPriority.MONITOR)
  public void onShowCasePlayerBuyEvent(ShowCasePlayerBuyEvent scpbe) {
   
    Shop  shop  = scpbe.getShop();
   
    int   added = ItemStackUtilities.addToInventory(scpbe.getPlayer().getInventory(), shop.getItemStack(), scpbe.getQuantity());
    double  price = added * shop.getPrice();
   
    scs.getBalanceHandler().sub(scpbe.getPlayer(), price);
    scs.getBalanceHandler().add(shop.getOwner(),   price);
   
    // ignore unlimited - later you can see how many were sold ^^
    shop.setAmount(shop.getAmount() - added);

    // set successfully message
    scpbe.setMsgSuccessfully(Term.MESSAGE_SELL_COSTUMER.get(MaterialNames.getItemName(shop.getItemStack()), ""+added, ""+price));
  }
View Full Code Here

Examples of com.knowgate.hipergate.Shop

    if (DBBind.exists(oConn, DB.k_shops, "U")) {
      oItems = new DBSubset (DB.k_shops, DB.gu_shop, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int s=0;s<iItems; s++)
        new Shop(oConn, oItems.getString(0,s)).delete(oConn);
    }

    // -----------------------------------------------------------------------------------
    // Nuevos para la v4.0, borrar los eventos
View Full Code Here

Examples of com.righettod.jee6jpa.entity.Shop

            for (int i = 0; i < 4; i++) {
                Sample03.main(args);
            }

            //Load father object
            Shop shop = em.find(Shop.class, 4);
            //Remove it in a explicit transaction
            //--Begin a new transaction
            em.getTransaction().begin();
            try {
                //--Try to remove object
View Full Code Here

Examples of com.righettod.jee6jpa.entity.Shop

    public static void main(String[] args) {
        EntityManagerFactory emFactory = null;
        EntityManager em = null;
        TypedQuery<Shop> queryShop = null;
        List<Shop> shops = null;
        Shop shop = null;

        try {
            //Create a EntityManager instance using EntityManagerFactory
            emFactory = Persistence.createEntityManagerFactory(persistenceUnitName);
            em = emFactory.createEntityManager();


            //Select all shops
            System.out.println("*** SELECT ALL SHOPS");
            queryShop = em.createQuery("SELECT s FROM Shop s", Shop.class);
            shops = queryShop.getResultList();
            for (Shop s : shops) {
                System.out.printf("[%s] : %s\n", s.getId(), s.getName());
            }


            //Select a shop using is id
            System.out.println("*** SELECT A SHOP USING IS ID");
            System.out.println("** NAMED PARAMETER VERSION");
            queryShop = em.createQuery("SELECT s FROM Shop s WHERE s.id = :id", Shop.class);
            try {
                shop = queryShop.setParameter("id", 2).getSingleResult();
                System.out.printf("[%s] : %s\n", shop.getId(), shop.getName());
            } catch (NoResultException nre) {
                //Exception throw by "getSingleResult()" if no result is returned by the query
                System.out.println("No shop found !");
            } catch (NonUniqueResultException nure) {
                //Exception throw by "getSingleResult()" if several record is found by the query
                System.out.println("More than one record exists for this ID !");
            }
            System.out.println("** ORDINAL PARAMETER VERSION");
            queryShop = em.createQuery("SELECT s FROM Shop s WHERE s.id = ?1", Shop.class);
            try {
                shop = queryShop.setParameter(1, 2).getSingleResult();
                System.out.printf("[%s] : %s\n", shop.getId(), shop.getName());
            } catch (NoResultException nre) {
                //Exception throw by "getSingleResult()" if no result is returned by the query
                System.out.println("No shop found !");
            } catch (NonUniqueResultException nure) {
                //Exception throw by "getSingleResult()" if several record is found by the query
                System.out.println("More than one record exists for this ID !");
            }


            //Select shops with a range restriction
            System.out.println("*** SELECT SHOPS WITH A RANGE RESTRICTION");
            queryShop = em.createQuery("SELECT s FROM Shop s", Shop.class);
            shops = queryShop.setFirstResult(1).setMaxResults(2).getResultList();
            for (Shop s : shops) {
                System.out.printf("[%s] : %s\n", s.getId(), s.getName());
            }


            //Select all shops using a predefined Named Query
            System.out.println("*** SELECT SHOPS USING A PREDEFINED NAMED QUERY");
            queryShop = em.createNamedQuery("Shop.findAll", Shop.class);
            shops = queryShop.getResultList();
            for (Shop s : shops) {
                System.out.printf("[%s] : %s\n", s.getId(), s.getName());
            }


            //Select a shop using a pessimistic lock
            System.out.println("*** SELECT A SHOPS USING PESSIMISTIC LOCK");
            try {
                shop = em.find(Shop.class, 2, LockModeType.PESSIMISTIC_READ);
                System.out.printf("[%s] : %s\n", shop.getId(), shop.getName());
            } catch (PessimisticLockException ple) {
                System.out.println("Unable to obtains lock on record !");
            }

        } catch (Exception e) {
View Full Code Here

Examples of com.righettod.jee6jpa.entity.Shop

            em = emFactory.createEntityManager();


            /*Shop table*/
            //Load a shop entity instance
            Shop shop = em.find(Shop.class, 1);
            //Try to update values
            try {
                em.getTransaction().begin();
                //This value will activate the check on max size
                shop.setName("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
                //In AUTO flush mode (default) the update on entity will be send at commit....
                em.getTransaction().commit();
            } catch (PersistenceException pe) {
                //No need to rollback because the exception have rollbacked and closed the transaction...
                if (pe.getCause() instanceof ConstraintViolationException) {
View Full Code Here

Examples of com.righettod.jee6jpa.entity.Shop

            //The lifetime of the EntityManager is restricted to the scope of the main method,
            //thus the attached (managed) entities managed by this EM are managed for the same lifetime...

            //Add a new shop
            Shop shop = em.find(Shop.class, 4);
            System.out.println("*** INSERT A NEW SHOP");
            //--Check that the shop do not exist
            if (shop == null) {
                //--Create a new object
                shop = new Shop();
                shop.setId(4);
                shop.setName("LIDLE");
                //--Begin a new transaction
                em.getTransaction().begin();
                try {
                    //--Try to persist object
                    em.persist(shop);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.