Skip to content

Commit

Permalink
add server.disk_free, disk_total, disk_usage, fixes #2057
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 19, 2019
1 parent f800f00 commit 9bfc5e9
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,48 @@ public void serverTag(ReplaceableTagEvent event) {
.getAttribute(attribute.fulfill(1)));
}

// <--[tag]
// @attribute <server.disk_free>
// @returns ElementTag(Number)
// @description
// How much remaining disk space is available to this server.
// This counts only the drive the server folder is on, not any other drives.
// This may be limited below the actual drive capacity by operating system settings.
// -->
if (attribute.startsWith("disk_free")) {
File folder = DenizenAPI.getCurrentInstance().getDataFolder();
event.setReplaced(new ElementTag(folder.getUsableSpace())
.getAttribute(attribute.fulfill(1)));
}

// <--[tag]
// @attribute <server.disk_total>
// @returns ElementTag(Number)
// @description
// How much total disk space is on the drive containing this server.
// This counts only the drive the server folder is on, not any other drives.
// -->
if (attribute.startsWith("disk_total")) {
File folder = DenizenAPI.getCurrentInstance().getDataFolder();
event.setReplaced(new ElementTag(folder.getTotalSpace())
.getAttribute(attribute.fulfill(1)));
}

// <--[tag]
// @attribute <server.disk_usage>
// @returns ElementTag(Number)
// @description
// How much space on the drive is already in use.
// This counts only the drive the server folder is on, not any other drives.
// This is approximately equivalent to "disk_total" minus "disk_free", but is not always exactly the same,
// as this tag will not include space "used" by operating system settings that simply deny the server write access.
// -->
if (attribute.startsWith("disk_usage")) {
File folder = DenizenAPI.getCurrentInstance().getDataFolder();
event.setReplaced(new ElementTag(folder.getTotalSpace() - folder.getFreeSpace())
.getAttribute(attribute.fulfill(1)));
}

// <--[tag]
// @attribute <server.ram_allocated>
// @returns ElementTag(Number)
Expand Down

0 comments on commit 9bfc5e9

Please sign in to comment.