Skip to content

Commit

Permalink
Update to 2.1.0
Browse files Browse the repository at this point in the history
- Fix issue that caused the join command to not function correctly
- Added 'lore list' command.
- Added 'lore.command.list' permission.

Signed-off-by: Steven Downer <grinch@outlook.com>
  • Loading branch information
Grinch committed Feb 5, 2014
1 parent c622891 commit 7d5b93b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ apply plugin: 'license'
// Basic project information
group = 'com.almuradev'
archivesBaseName = 'lore'
version = '2.0.2'
version = '2.1.0'

// Extended project information
ext.mainClass = 'com.almuradev.lore.LorePlugin'
Expand Down
43 changes: 27 additions & 16 deletions src/main/java/com/almuradev/lore/LoreCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class LoreCommands implements CommandExecutor {
private final String CREATE_PERMISSION_KEY = "lore.command.create";
private final String GIVE_PERMISSION_KEY = "lore.command.give";
private final String JOIN_PERMISSION_KEY = "lore.command.join";
private final String LIST_PERMISSION_KEY = "lore.command.list";
private final String PERMISSION_MESSAGE_KEY;
private final String REMOVE_PERMISSION_KEY = "lore.command.remove";
private final String RESPAWN_PERMISSION_KEY = "lore.command.respawn";
Expand Down Expand Up @@ -122,45 +123,55 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}
return true;

case "REMOVE":
if (args.length < 2) {
case "JOIN":
if (args.length < 3) {
return false;
}
if (player != null && !player.hasPermission(REMOVE_PERMISSION_KEY)) {
if (PERMISSION_MESSAGE_KEY != null && !PERMISSION_MESSAGE_KEY.isEmpty()) {
if (player != null && !player.hasPermission(JOIN_PERMISSION_KEY)) {
if (PERMISSION_MESSAGE_KEY != null && PERMISSION_MESSAGE_KEY.isEmpty()) {
sender.sendMessage(PERMISSION_MESSAGE_KEY);
}
return true;
}
try {
plugin.getConfiguration().delete(args[1]);
final YamlConfiguration config = plugin.getConfiguration().getConfig(args[1]);
config.set("join", Boolean.parseBoolean(args[2]));
config.save(Paths.get(BOOKS_PATH + File.separator + args[1] + ".yml").toFile());
sender.sendMessage(args[1] + " has had the join flag set to " + Boolean.parseBoolean(args[2]) + ".");
} catch (FileNotFoundException e) {
sender.sendMessage(args[1] + " does not exist in the library.");
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Unable to delete " + args[1] + ".", e);
plugin.getLogger().log(Level.SEVERE, "An error occurred when attempting to save " + args[1] + ".yml", e);
sender.sendMessage("An error occurred when attempting to save " + args[1] + ".yml, please inform your server administrator.");
}
return true;

case "JOIN":
if (args.length < 3) {
return false;
}
case "LIST":
if (player != null && !player.hasPermission(JOIN_PERMISSION_KEY)) {
if (PERMISSION_MESSAGE_KEY != null && PERMISSION_MESSAGE_KEY.isEmpty()) {
sender.sendMessage(PERMISSION_MESSAGE_KEY);
}
return true;
}
sender.sendMessage("Registered books of lore: " + plugin.getConfiguration().getMap().keySet().toString().replace("[", "").replace("]", "").trim());
return true;

case "REMOVE":
if (args.length < 2) {
return false;
}
if (player != null && !player.hasPermission(REMOVE_PERMISSION_KEY)) {
if (PERMISSION_MESSAGE_KEY != null && !PERMISSION_MESSAGE_KEY.isEmpty()) {
sender.sendMessage(PERMISSION_MESSAGE_KEY);
}
return true;
}
try {
final YamlConfiguration config = plugin.getConfiguration().getConfig(args[1]);
config.set("join", Boolean.parseBoolean(args[2]));
config.save(Paths.get(BOOKS_PATH + args[1] + ".yml").toFile());
sender.sendMessage(args[1] + " has had the join flag set to " + Boolean.parseBoolean(args[2]) + ".");
plugin.getConfiguration().delete(args[1]);
} catch (FileNotFoundException e) {
sender.sendMessage(args[1] + " does not exist in the library.");
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "An error occurred when attempting to save " + args[1] + ".yml", e);
sender.sendMessage("An error occurred when attempting to save " + args[1] + ".yml, please inform your server administrator.");
plugin.getLogger().log(Level.SEVERE, "Unable to delete " + args[1] + ".", e);
}
return true;

Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ commands:
description: Commands to manage Lore.
usage: |
/lore create [name]
/lore remove [book]
/lore give [player] [book]
/lore join [book] [true|false]
/lore list
/lore remove [book]
/lore respawn [book] [true|false]
/lore stick [book] [true|false]
Expand All @@ -25,6 +26,7 @@ permissions:
lore.command.create: true
lore.command.give: true
lore.command.join: true
lore.command.list: true
lore.command.remove: true
lore.command.respawn: true
lore.command.sticky: true
Expand All @@ -40,6 +42,9 @@ permissions:
lore.command.remove:
description: Allows the player to remove a book from Lore's book library.
default: false
lore.command.list:
description: Displays a list of registered books to the command sender.
default: false
lore.command.respawn:
description: Allows the player to set the flag for "respawn" on Lore books.
default: false
Expand Down

0 comments on commit 7d5b93b

Please sign in to comment.