Skip to content

Commit

Permalink
DurationTag->TimeTag
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 4, 2021
1 parent 798ada3 commit ea58db4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Expand Up @@ -1127,6 +1127,7 @@ else if (ban.getExpiration() == null) {
return new TimeTag(ban.getCreated().getTime());
});
registerTag("ban_created", (attribute, object) -> {
Deprecations.timeTagRewrite.warn(attribute.context);
BanEntry ban = Bukkit.getBanList(BanList.Type.NAME).getBanEntry(object.getName());
if (ban == null || (ban.getExpiration() != null && ban.getExpiration().before(new Date()))) {
return null;
Expand Down
Expand Up @@ -238,6 +238,7 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
// @group properties
// @description
// Returns whether the potion effect is ambient.
// "Ambient" effects in vanilla came from a beacon, while non-ambient came from a potion.
// -->
if (attribute.startsWith("is_ambient")) {
return new ElementTag(meta.getCustomEffects().get(potN).isAmbient())
Expand Down
Expand Up @@ -1884,13 +1884,18 @@ else if (ban.getExpiration() == null) {
}

// <--[tag]
// @attribute <server.ban_info[<address>].expiration>
// @returns DurationTag
// @attribute <server.ban_info[<address>].expiration_time>
// @returns TimeTag
// @description
// Returns the expiration of the ip address's ban, if it is banned.
// Potentially can be null.
// -->
if (attribute.startsWith("expiration") && ban.getExpiration() != null) {
if (attribute.startsWith("expiration_time") && ban.getExpiration() != null) {
event.setReplacedObject(new TimeTag(ban.getExpiration().getTime())
.getObjectAttribute(attribute.fulfill(1)));
}
else if (attribute.startsWith("expiration") && ban.getExpiration() != null) {
Deprecations.timeTagRewrite.warn(attribute.context);
event.setReplacedObject(new DurationTag(ban.getExpiration().getTime() / 50)
.getObjectAttribute(attribute.fulfill(1)));
}
Expand All @@ -1907,12 +1912,17 @@ else if (attribute.startsWith("reason")) {
}

// <--[tag]
// @attribute <server.ban_info[<address>].created>
// @returns DurationTag
// @attribute <server.ban_info[<address>].created_time>
// @returns TimeTag
// @description
// Returns when the ip address's ban was created, if it is banned.
// -->
else if (attribute.startsWith("created_time")) {
event.setReplacedObject(new TimeTag(ban.getCreated().getTime())
.getObjectAttribute(attribute.fulfill(1)));
}
else if (attribute.startsWith("created")) {
Deprecations.timeTagRewrite.warn(attribute.context);
event.setReplacedObject(new DurationTag(ban.getCreated().getTime() / 50)
.getObjectAttribute(attribute.fulfill(1)));
}
Expand Down

0 comments on commit ea58db4

Please sign in to comment.