Skip to content

Commit

Permalink
Fix meta, add server.list_files
Browse files Browse the repository at this point in the history
Gotta be careful what file access we give, but this much should be safe
  • Loading branch information
mcmonkey4eva committed Jan 24, 2016
1 parent 248f235 commit dae0eef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Expand Up @@ -1868,7 +1868,7 @@ public void registerCoreMembers() {
// This will fully load a midi song file stored in the '../plugins/Denizen/midi/' folder. The file
// must be a valid midi file with the extension '.mid'. It will continuously play the song as
// noteblock songs at the given location or group of players until the song ends. If no location or
// entitiy is specified, by default this will play for the attached player.
// entity is specified, by default this will play for the attached player.
//
// Also, an example Midi song file has been included: "Denizen" by Black Coyote. He made it just for us!
// Check out more of his amazing work at: http://www.youtube.com/user/BlaCoyProductions
Expand All @@ -1877,15 +1877,15 @@ public void registerCoreMembers() {
// None

// @Usage
// Use to play a midi song file on the current player
// Use to play a midi song file on the current player/
// - midi file:Denizen

// @Usage
// Use to play a midi song file at a given location
// Use to play a midi song file at a given location/
// - midi file:Denizen <player.location>

// @Usage
// Use to play a midi song file at a given location to the specified player, and wait for it to finish.
// Use to play a midi song file at a given location to the specified player(s), and wait for it to finish.
// - ~midi file:Denizen <server.list_online_players>

// -->
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/net/aufdemrand/denizen/tags/core/ServerTags.java
Expand Up @@ -437,6 +437,25 @@ public void serverTag(ReplaceableTagEvent event) {
return;
}

// <--[tag]
// @attribute <server.list_files[<path>]>
// @returns dList
// @description
// Returns a list of all files in the specified directory. The starting path is /plugins/Denizen.
// -->
if (attribute.startsWith("list_files") && attribute.hasContext(1)) {
File[] files = DenizenAPI.getCurrentInstance().getDataFolder().listFiles();
if (files == null) {
return;
}
dList list = new dList();
for (File file: files) {
list.add(file.getName());
}
event.setReplaced(list.getAttribute(attribute.fulfill(1)));
return;
}

// <--[tag]
// @attribute <server.has_permissions>
// @returns Element(Boolean)
Expand Down

0 comments on commit dae0eef

Please sign in to comment.