Package l2p.gameserver.model.instances

Examples of l2p.gameserver.model.instances.L2SummonInstance$Lifetime


        if (player == null || object == null || !player.getPlayerAccess().CanViewChar) {
            return false;
        }
        if (object.isSummon()) {
            String dialog;
            L2SummonInstance summon = (L2SummonInstance) object;
            dialog = Files.read("data/scripts/actions/admin.L2SummonInstance.onActionShift.htm");
            dialog = dialog.replaceFirst("%name%", String.valueOf(summon.getName()));
            dialog = dialog.replaceFirst("%level%", String.valueOf(summon.getLevel()));
            dialog = dialog.replaceFirst("%class%", String.valueOf(summon.getClass().getSimpleName().replaceFirst("L2", "").replaceFirst("Instance", "")));
            dialog = dialog.replaceFirst("%xyz%", summon.getLoc().x + " " + summon.getLoc().y + " " + summon.getLoc().z);
            dialog = dialog.replaceFirst("%heading%", String.valueOf(summon.getLoc().h));

            dialog = dialog.replaceFirst("%owner%", String.valueOf(summon.getPlayer().getName()));
            dialog = dialog.replaceFirst("%ownerId%", String.valueOf(summon.getPlayer().getObjectId()));

            dialog = dialog.replaceFirst("%npcId%", String.valueOf(summon.getNpcId()));
            dialog = dialog.replaceFirst("%expPenalty%", String.valueOf(summon.getExpPenalty()));

            dialog = dialog.replaceFirst("%maxHp%", String.valueOf(summon.getMaxHp()));
            dialog = dialog.replaceFirst("%maxMp%", String.valueOf(summon.getMaxMp()));
            dialog = dialog.replaceFirst("%currHp%", String.valueOf((int) summon.getCurrentHp()));
            dialog = dialog.replaceFirst("%currMp%", String.valueOf((int) summon.getCurrentMp()));

            dialog = dialog.replaceFirst("%pDef%", String.valueOf(summon.getPDef(null)));
            dialog = dialog.replaceFirst("%mDef%", String.valueOf(summon.getMDef(null, null)));
            dialog = dialog.replaceFirst("%pAtk%", String.valueOf(summon.getPAtk(null)));
            dialog = dialog.replaceFirst("%mAtk%", String.valueOf(summon.getMAtk(null, null)));
            dialog = dialog.replaceFirst("%accuracy%", String.valueOf(summon.getAccuracy()));
            dialog = dialog.replaceFirst("%evasionRate%", String.valueOf(summon.getEvasionRate(null)));
            dialog = dialog.replaceFirst("%crt%", String.valueOf(summon.getCriticalHit(null, null)));
            dialog = dialog.replaceFirst("%runSpeed%", String.valueOf(summon.getRunSpeed()));
            dialog = dialog.replaceFirst("%walkSpeed%", String.valueOf(summon.getWalkSpeed()));
            dialog = dialog.replaceFirst("%pAtkSpd%", String.valueOf(summon.getPAtkSpd()));
            dialog = dialog.replaceFirst("%mAtkSpd%", String.valueOf(summon.getMAtkSpd()));
            dialog = dialog.replaceFirst("%dist%", String.valueOf((int) summon.getRealDistance(player)));

            dialog = dialog.replaceFirst("%STR%", String.valueOf(summon.getSTR()));
            dialog = dialog.replaceFirst("%DEX%", String.valueOf(summon.getDEX()));
            dialog = dialog.replaceFirst("%CON%", String.valueOf(summon.getCON()));
            dialog = dialog.replaceFirst("%INT%", String.valueOf(summon.getINT()));
            dialog = dialog.replaceFirst("%WIT%", String.valueOf(summon.getWIT()));
            dialog = dialog.replaceFirst("%MEN%", String.valueOf(summon.getMEN()));

            show(dialog, player);
        }
        return true;
    }
View Full Code Here


        if(summonTemplate == null)
        {
          System.out.println("Null summon template for skill " + this);
          return;
        }
        L2SummonInstance summon = new L2SummonInstance(IdFactory.getInstance().getNextId(), summonTemplate, activeChar, _lifeTime, _itemConsumeIdInTime, _itemConsumeCountInTime, _itemConsumeDelay);
        summon.setTitle(activeChar.getName());
        summon.setExpPenalty(_expPenalty);
        summon.setExp(Experience.LEVEL[Math.min(summon.getLevel(), Experience.LEVEL.length - 1)]);
        summon.setCurrentHp(summon.getMaxHp(), false);
        summon.setCurrentMp(summon.getMaxMp());
        summon.setHeading(activeChar.getHeading());
        summon.setRunning();
        activeChar.setPet(summon);
        summon.spawnMe(loc == null ? GeoEngine.findPointToStay(activeChar.getX(), activeChar.getY(), activeChar.getZ(), 100, 150, activeChar.getReflection().getGeoIndex()) : loc);
        if(summon.getSkillLevel(4140) > 0)
        {
          summon.altUseSkill(SkillTable.getInstance().getInfo(4140, summon.getSkillLevel(4140)), activeChar);
        }
        if(summon.getName().equalsIgnoreCase("Shadow"))
        {
          summon.addStatFunc(new FuncAdd(Stats.ABSORB_DAMAGE_PERCENT, 0x40, this, 15));
        }
        summon.setFollowStatus(true, true);
        break;
      case DECOY:
        if(activeChar.getPet() != null || activeChar.isMounted())
        {
          return;
View Full Code Here

                // Set the TokenType of the response. To make clients happy we'll return a token of the type they requested
                tokenResponse.setTokenType(tokenRequest.getTokenType());
       
                // Add a Lifetime element to indicate to clients the lifetime of the token we're sending
                // In this case, we're giving the client the lifetime they asked for
                Lifetime lifetime = tokenRequest.getLifetime();
                tokenResponse.setLifetime(lifetime);

                // Check if the request included a custom element named <TestElement>
                // Note that a list of custom elements can be obtained by calling getCustomElements();
                if (tokenRequest.getCustomElement("http://testElementNs.testElementNs", "TestElement") != null) {
View Full Code Here

        // Set the desired Lifetime of the token being requested in this case to 250 seconds
        Date start = new Date();
        Date end = new Date();
        end.setTime(start.getTime() + 250 * 1000);
        tokenRequest.setLifetime(new Lifetime(wssConfig, doc, start, end));

        // Add a custom element of our own creation
        tokenRequest.addCustomElementNS("http://testElementNs.testElementNs", "te:TestElement");

        // Create a SOAP body and set the XML element of the token request (a <RequestSecurityToken> element)
View Full Code Here

        // Set the desired Lifetime of the token being requested in this case to 250 seconds
        Date start = new Date();
        Date end = new Date();
        end.setTime(start.getTime() + 250 * 1000);
        tokenRequest.setLifetime(new Lifetime(wssConfig, doc, start, end));

        // Add a custom element of our own creation
        tokenRequest.addCustomElementNS("http://testElementNs.testElementNs", "te:TestElement");

        // Create a SOAP body and set the XML element of the token request (a <RequestSecurityToken> element)
View Full Code Here

                // Set the TokenType of the response. To make clients happy we'll return a token of the type they requested
                tokenResponse.setTokenType(tokenRequest.getTokenType());
       
                // Add a Lifetime element to indicate to clients the lifetime of the token we're sending
                // In this case, we're giving the client the lifetime they asked for
                Lifetime lifetime = tokenRequest.getLifetime();
                tokenResponse.setLifetime(lifetime);

                // Check if the request included a custom element named <TestElement>
                // Note that a list of custom elements can be obtained by calling getCustomElements();
                if (tokenRequest.getCustomElement("http://testElementNs.testElementNs", "TestElement") != null) {
View Full Code Here

      try
      {
         RegistrationLocal.setRegistration(registration);

         ExportContext exportContext;
         final Lifetime askedLifetime = exportPortlets.getLifetime();
         if (askedLifetime != null)
         {
            final XMLGregorianCalendar askedLifetimeCurrentTime = askedLifetime.getCurrentTime();
            long currentTime = toLongDate(askedLifetimeCurrentTime);
            long terminationTime = toLongDate(askedLifetime.getTerminationTime());
            long refreshDuration = askedLifetime.getRefreshDuration().getTimeInMillis(askedLifetimeCurrentTime.toGregorianCalendar());
            exportContext = exportManager.createExportContext(exportByValueRequired, currentTime, terminationTime, refreshDuration);
         }
         else
         {
            exportContext = exportManager.createExportContext(exportByValueRequired, -1, -1, -1);
         }

         for (PortletContext portletContext : portletContexts)
         {
            try
            {
               WSRP2ExceptionFactory.throwOperationFailedIfValueIsMissing(portletContext, "Portlet context");
               String portletHandle = portletContext.getPortletHandle();
               WSRP2ExceptionFactory.throwMissingParametersIfValueIsMissing(portletHandle, "Portlet handle", "PortletContext");

               org.gatein.pc.api.PortletContext portalPC = WSRPUtils.convertToPortalPortletContext(portletContext);

               org.gatein.pc.api.PortletContext exportedPortalPC = producer.getPortletInvoker().exportPortlet(PortletStateType.OPAQUE, portalPC);
               if (exportedPortalPC == null)
               {
                  WSRP2ExceptionFactory.throwWSException(InvalidHandle.class, "Could not find a portlet with handle " + portletHandle + " in the producer", null);
               }

               byte[] portletState = WSRPUtils.getStateOrNullFor(exportedPortalPC);

               //get the exportPortletData
               ExportPortletData exportPortletData = exportManager.createExportPortletData(exportContext, portletHandle, portletState);

               //Create the exportedPortlet
               byte[] exportPortletBytes = exportManager.encodeExportPortletData(exportContext, exportPortletData);
               ExportedPortlet exportedPortlet = WSRPTypeFactory.createExportedPortlet(portletHandle, exportPortletBytes);
               exportedPortlets.add(exportedPortlet);
            }

            catch (Exception e)
            {
               if (log.isWarnEnabled())
               {
                  log.warn("Error occured while trying to export a portlet.", e);
               }

               ErrorCodes.Codes errorCode;
               String reason;
               if (e instanceof NoSuchPortletException || e instanceof InvalidHandle)
               {
                  errorCode = ErrorCodes.Codes.INVALIDHANDLE;
                  reason = "The specified portlet handle is invalid";
               }
               else // default error message.
               {
                  errorCode = ErrorCodes.Codes.OPERATIONFAILED;
                  reason = "Error preparing portlet for export";
               }

               final String errorCodeName = errorCode.name();
               if (!failedPortletsMap.containsKey(errorCodeName))
               {
                  List<String> portletHandles = new ArrayList<String>();
                  portletHandles.add(portletContext.getPortletHandle());

                  FailedPortlets failedPortlets = WSRPTypeFactory.createFailedPortlets(portletHandles, errorCode, reason);
                  failedPortletsMap.put(errorCodeName, failedPortlets);
               }
               else
               {
                  FailedPortlets failedPortlets = failedPortletsMap.get(errorCodeName);
                  failedPortlets.getPortletHandles().add(portletContext.getPortletHandle());
               }
            }
         }

         //TODO: handle resourceLists better (should be using for things like errors)
         ResourceList resourceList = null;

         byte[] exportContextBytes = exportManager.encodeExportContextData(exportContext);

         Lifetime lifetime = null;

         if (exportContext.getCurrentTime() > 0)
         {
            lifetime = new Lifetime();
            lifetime.setCurrentTime(toXMLGregorianCalendar(exportContext.getCurrentTime()));
            lifetime.setTerminationTime(toXMLGregorianCalendar(exportContext.getTermintationTime()));
            lifetime.setRefreshDuration(toDuration(exportContext.getRefreshDuration()));
         }

         return WSRPTypeFactory.createExportPortletsResponse(exportContextBytes, exportedPortlets, new ArrayList<FailedPortlets>(failedPortletsMap.values()), lifetime, resourceList);
      }
      catch (Exception e)
View Full Code Here

      {
         RegistrationLocal.setRegistration(registration);

         byte[] importContext = importPortlets.getImportContext();

         Lifetime lifeTime = importPortlets.getLifetime();

         List<ImportedPortlet> importedPortlets = new ArrayList<ImportedPortlet>();
         Map<String, ImportPortletsFailed> failedPortletsMap = new HashMap<String, ImportPortletsFailed>();

         ExportContext exportContext;
         final ExportManager exportManager = producer.getExportManager();
         try
         {
            exportContext = exportManager.createExportContext(importContext);
         }
         catch (Exception e)
         {
            throw WSRPExceptionFactory.createWSException(OperationFailed.class, "Invalid ImportContext.", e);
         }

         for (ImportPortlet importPortlet : importPortletList)
         {
            try
            {
               byte[] portletData = importPortlet.getExportData();

               ExportPortletData exportPortletData;
               if (lifeTime != null)
               {
                  long currentTime = toLongDate(lifeTime.getCurrentTime());
                  long terminationTime = toLongDate(lifeTime.getTerminationTime());
                  long refreshDuration = lifeTime.getRefreshDuration().getTimeInMillis(lifeTime.getCurrentTime().toGregorianCalendar());
                  exportPortletData = exportManager.createExportPortletData(exportContext, currentTime, terminationTime, refreshDuration, portletData);
               }
               else
               {
                  exportPortletData = exportManager.createExportPortletData(exportContext, -1, -1, -1, portletData);
View Full Code Here

   private Lifetime getLifetime(ExportContext exportContext) throws DatatypeConfigurationException
   {
      if (exportContext.getCurrentTime() >= 0)
      {
         Lifetime lifetime = new Lifetime();

         XMLGregorianCalendar currentTime = toXMLGregorianCalendar(exportContext.getCurrentTime());
         XMLGregorianCalendar terminationTime = toXMLGregorianCalendar(exportContext.getTermintationTime());

         Duration duration = toDuration(exportContext.getRefreshDuration());

         lifetime.setCurrentTime(currentTime);
         lifetime.setTerminationTime(terminationTime);
         lifetime.setRefreshDuration(duration);

         return lifetime;
      }
      else
      {
View Full Code Here

                     errorCodeToHandle.put(failedPortletsForReason.getErrorCode(), failedPortletsForReason.getPortletHandles());
                  }
               }

               // todo: deal with expiration time
               Lifetime lifetime = lifetimeHolder.value;
               if (lifetime != null)
               {
                  XMLGregorianCalendar currentTime = lifetime.getCurrentTime();
                  Duration refreshDuration = lifetime.getRefreshDuration();
                  XMLGregorianCalendar terminationTime = lifetime.getTerminationTime();
               }

               ExportInfo exportInfo = new ExportInfo(System.currentTimeMillis(), errorCodeToHandle, handleToState, exportContextHolder.value);
               getConsumerRegistry().getMigrationService().add(exportInfo);
               return exportInfo;
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.instances.L2SummonInstance$Lifetime

Copyright © 2018 www.massapicom. 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.