Пример #1
0
def getItemLastUpdate(itemOrName):
    item = _getItem(itemOrName)
    lastUpdate = PersistenceExtensions.lastUpdate(item)
    if lastUpdate is None:
        return ZonedDateTime.ofInstant(Instant.ofEpochMilli(0),
                                       ZoneId.systemDefault())
        #raise NotInitialisedException("Item lastUpdate for '" + item.getName() + "' not found")
    return lastUpdate
Пример #2
0
 def apply(self,client,args):
     target = DAO.getPlayers().getCharacter(args[0]);
     if target is None or target.getClient() is None :
         client.send(ConsoleMessage(0, "The target is missing"));
     else:
         time = Instant.now().plus(int(args[1]), ChronoUnit.HOURS).toEpochMilli();
         Main.getInterClient().send(PlayerSuspendedMessage(time,target.getAccount().getId()));
         target.getClient().timeOut();
         client.send(ConsoleMessage(0, "The target has been banned for "+ args[1] +" hours"));
Пример #3
0
    def onConfigure(self):
        self.withLabel("Type date-time arg action")
        self.withArgs([
            DateTimeType("arg").withLabel("Date-time non nullable").withDefaultValue(LocalDateTime.of(2020, 1, 1, 12, 0)),
            DateTimeType("argNullable").withLabel("Date-time nullable").withNullable(),
            DateTimeType("argDefault").withLabel("Date-time with default").withDefaultValue(LocalDateTime.of(2020, 1, 1, 12, 0)),
            DateTimeType("argReadOnlyNullable").withLabel("Date-time read only nullable").withReadOnly().withNullable()
                .withDefaultValue(LocalDateTime.of(2020, 1, 1, 12, 0)),
            DateTimeType("argReadOnlyNonNullable").withLabel("Date-time read only non nullable").withReadOnly()
                .withDefaultValue(LocalDateTime.of(2020, 1, 1, 12, 0)),

            DateTimeType("argDate").withDate().withLabel("Date non nullable").withDefaultValue(LocalDate.of(2020, 1, 1)),
            DateTimeType("argDateNullable").withDate().withLabel("Date nullable").withNullable(),
            DateTimeType("argDateDefault").withDate().withLabel("Date with default").withDefaultValue(LocalDate.of(2020, 1, 1)),
            DateTimeType("argDateReadOnlyNullable").withDate().withLabel("Date read only nullable").withReadOnly().withNullable()
                .withDefaultValue(LocalDate.of(2020, 1, 1)),
            DateTimeType("argDateReadOnlyNonNullable").withDate().withLabel("Date read only non nullable").withReadOnly()
                .withDefaultValue(LocalDate.of(2020, 1, 1)),

            DateTimeType("argTime").withTime().withFormat("HH:mm").withLabel("Time non nullable").withDefaultValue(LocalTime.of(12, 0)),
            DateTimeType("argTimeNullable").withTime().withFormat("HH:mm").withLabel("Time nullable").withNullable(),
            DateTimeType("argTimeDefault").withTime().withFormat("HH:mm").withLabel("Time with default").withDefaultValue(LocalTime.of(12, 0)),
            DateTimeType("argTimeReadOnlyNullable").withTime().withFormat("HH:mm").withLabel("Time read only nullable").withReadOnly().withNullable()
                .withDefaultValue(LocalTime.of(12, 0)),
            DateTimeType("argTimeReadOnlyNonNullable").withTime().withFormat("HH:mm").withLabel("Time read only non nullable").withReadOnly()
                .withDefaultValue(LocalTime.of(12, 0)),

            DateTimeType("argDateTimeZoneReadOnlyNullable").withDateTimeZone().withLabel("Date-time-zone read only nullable").withReadOnly().withNullable()
                .withDefaultValue(ZonedDateTime.of(LocalDateTime.of(2020, 1, 1, 12, 0), ZoneId.of("America/Detroit"))),
            DateTimeType("argDateTimeZoneReadOnlyNonNullable").withDateTimeZone().withLabel("Date-time-zone read only non nullable").withReadOnly()
                .withDefaultValue(ZonedDateTime.of(LocalDateTime.of(2020, 1, 1, 12, 0), ZoneId.of("America/Detroit"))),

            DateTimeType("argInstantReadOnlyNullable").withInstant().withLabel("Instant read only nullable").withReadOnly().withNullable()
                .withDefaultValue(Instant.now()),
            DateTimeType("argInstantReadOnlyNonNullable").withInstant().withLabel("Instant read only non nullable").withReadOnly()
                .withDefaultValue(Instant.now()),

            # DATE_TIME_ZONE and INSTANT editing is not supported yet.
        ]).withResult(StringType())
Пример #4
0
 def apply(self, client, args):
     target = DAO.getPlayers().getCharacter(args[0])
     if target is None or target.getClient() is None:
         client.send(ConsoleMessage(0, "The target is missing"))
     else:
         time = Instant.now().plus(int(args[1]),
                                   ChronoUnit.MINUTES).toEpochMilli()
         PlayerInst.getPlayerInst(target.getID()).setMutedTime(time)
         target.send(TextInformationMessage(1, 123, str(int(args[1]) * 60)))
         client.send(
             ConsoleMessage(
                 0,
                 "The target has been muted for " + args[1] + " minutes"))
Пример #5
0
def getStableMinMaxItemState(now, itemName, checkTimeRange):

    currentEndTime = now
    currentEndTimeMillis = currentEndTime.toInstant().toEpochMilli()
    minTimeMillis = currentEndTimeMillis - (checkTimeRange * 60 * 1000)

    minValue = None
    maxValue = None

    value = 0.0
    duration = 0

    # get and cache "real" item to speedup getHistoricItemEntry. Otherwise "getHistoricItemEntry" will lookup the item by its name every time
    item = getItem(itemName)

    entry = getHistoricItemEntry(item, now)

    while True:
        currentStartMillis = entry.getTimestamp().toInstant().toEpochMilli()

        if currentStartMillis < minTimeMillis:
            currentStartMillis = minTimeMillis

        _duration = currentEndTimeMillis - currentStartMillis
        _value = entry.getState().doubleValue()

        if minValue == None or minValue > _value:
            minValue = _value

        if maxValue == None or maxValue < _value:
            maxValue = _value

        duration = duration + _duration
        value = value + (_value * _duration)

        currentEndTimeMillis = currentStartMillis - 1

        if currentEndTimeMillis < minTimeMillis:
            break

        currentEndTime = ZonedDateTime.ofInstant(
            Instant.ofEpochMilli(currentEndTimeMillis), ZoneId.systemDefault())

        entry = getHistoricItemEntry(item, currentEndTime)

    value = (value / duration)

    return [value, minValue, maxValue]
Пример #6
0
    def getEncodedJWTForToken(self, softwareStatementId, clientScopes, aud, kid,signingKeyFile):
		jws = JsonWebSignature()
		claims = JwtClaims()
		claims.setClaim("iss", softwareStatementId)
		claims.setClaim("sub", softwareStatementId)
		claims.setClaim("scope", clientScopes)
		claims.setClaim("aud", aud)
		claims.setClaim("jti", UUID.randomUUID())
		unixTime = Instant.now().getEpochSecond()
		claims.setClaim("iat", unixTime)
		claims.setClaim("exp", unixTime + 1000) # 60000 one min
		jws.setPayload(claims.toJson())

		# dont change the order
		jws.getHeaders().setObjectHeaderValue("typ", "JWT");
		jws.setAlgorithmHeaderValue("RS256");
		jws.getHeaders().setObjectHeaderValue("kid", kid);

		privateKey = self.getPrivateKey(signingKeyFile);
		jws.setKey(privateKey);

		jwsCompactSerialization = jws.getCompactSerialization();
		return jwsCompactSerialization;
Пример #7
0
 def onCall(self, type):
     if type == "nonNullable":
         return DynamicValue(LocalDateTime.of(2020, 1, 1, 12, 0), DateTimeType().withLabel("Date-time non nullable"))
     elif type == "nullable":
         return DynamicValue(None, DateTimeType().withLabel("Date-time nullable").withNullable())
     elif type == "readOnlyNullable":
         return DynamicValue(None, DateTimeType().withLabel("Date-time read only nullable").withReadOnly().withNullable())
     elif type == "readOnlyNonNullable":
         return DynamicValue(LocalDateTime.of(2020, 1, 1, 12, 0), DateTimeType().withLabel("Date-time read only non nullable").withReadOnly())
     if type == "dateNonNullable":
         return DynamicValue(LocalDate.of(2020, 1, 1), DateTimeType().withDate().withLabel("Date non nullable"))
     elif type == "dateNullable":
         return DynamicValue(None, DateTimeType().withDate().withLabel("Date nullable").withNullable())
     elif type == "dateReadOnlyNullable":
         return DynamicValue(None, DateTimeType().withDate().withLabel("Date read only nullable").withReadOnly().withNullable())
     elif type == "dateReadOnlyNonNullable":
         return DynamicValue(LocalDate.of(2020, 1, 1), DateTimeType().withDate().withLabel("Date-time read only non nullable").withReadOnly())
     if type == "timeNonNullable":
         return DynamicValue(LocalTime.of(12, 0), DateTimeType().withTime().withFormat("HH:mm").withLabel("Time non nullable"))
     elif type == "timeNullable":
         return DynamicValue(None, DateTimeType().withTime().withFormat("HH:mm").withLabel("Time nullable").withNullable())
     elif type == "timeReadOnlyNullable":
         return DynamicValue(None, DateTimeType().withTime().withFormat("HH:mm").withLabel("Time read only nullable").withReadOnly().withNullable())
     elif type == "timeReadOnlyNonNullable":
         return DynamicValue(LocalTime.of(12, 0), DateTimeType().withTime().withFormat("HH:mm").withLabel("Time read only non nullable").withReadOnly())
     if type == "dateTimeZoneReadOnlyNullable":
         return DynamicValue(None,
                             DateTimeType().withDateTimeZone().withLabel("Date-time-zone read only nullable").withReadOnly().withNullable())
     elif type == "dateTimeZoneReadOnlyNonNullable":
         return DynamicValue(ZonedDateTime.of(LocalDateTime.of(2020, 1, 1, 12, 0), ZoneId.of("America/Detroit")),
                             DateTimeType().withDateTimeZone().withLabel("Date-time-zone read only non nullable").withReadOnly())
     if type == "instantReadOnlyNullable":
         return DynamicValue(None, DateTimeType().withInstant().withLabel("Instant read only nullable").withReadOnly().withNullable())
     elif type == "instantReadOnlyNonNullable":
         return DynamicValue(Instant.now(), DateTimeType().withInstant().withLabel("Instant read only non nullable").withReadOnly())
     else:
         return None