From 75cfa0cef286e36b6c4506ead033dab92ea6a3c9 Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Sun, 24 Nov 2013 13:41:59 +0100 Subject: [PATCH] Added a extra permission for world generation. Moved strings for the generation commands into the Message class. --- .../de/craftinc/borderprotection/Messages.java | 15 +++++++++++++++ .../commands/CancelGenerateCommand.java | 6 +++--- .../commands/GenerateCommand.java | 9 ++++----- src/main/resources/plugin.yml | 5 ++++- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/craftinc/borderprotection/Messages.java b/src/main/java/de/craftinc/borderprotection/Messages.java index e98eca5..cc04cb3 100644 --- a/src/main/java/de/craftinc/borderprotection/Messages.java +++ b/src/main/java/de/craftinc/borderprotection/Messages.java @@ -137,6 +137,21 @@ public class Messages ChatColor.RED + "Error: Could not save border state on server. After the next reload this border state will be lost!"; + public static String generationCanceled = + ChatColor.GREEN + "World generation canceled!"; + + public static String generationNotCanceled = + ChatColor.RED + "No world generation happening. Cannot cancel!"; + + public static String generationAlreadyInProgress = + ChatColor.YELLOW + "World generation is already in progress. It will continue after all players are logged out."; + + public static String generationStarted = + ChatColor.GREEN + "World generation will start after all players left the server."; + + public static String generationCouldNotBeStarted = + ChatColor.RED + "Could not start world generation! Is there a border?"; + public static String updateMessage( String newVersion, String curVersion ) { return ChatColor.RED + pluginName + ": New version available!" + NEWLINE + diff --git a/src/main/java/de/craftinc/borderprotection/commands/CancelGenerateCommand.java b/src/main/java/de/craftinc/borderprotection/commands/CancelGenerateCommand.java index 1fc1d7f..2596ed1 100644 --- a/src/main/java/de/craftinc/borderprotection/commands/CancelGenerateCommand.java +++ b/src/main/java/de/craftinc/borderprotection/commands/CancelGenerateCommand.java @@ -31,7 +31,7 @@ public class CancelGenerateCommand implements SubCommand @Override public boolean execute(CommandSender sender, String[] parameters) { - if ( !sender.hasPermission("craftinc.borderprotection.set") ) // TODO: a new/different permission? + if ( !sender.hasPermission("craftinc.borderprotection.generate") ) { sender.sendMessage(Messages.noPermissionSet); return false; @@ -41,12 +41,12 @@ public class CancelGenerateCommand implements SubCommand if (!ChunkGenerator.isGenerating(world)) { - sender.sendMessage("nothing to cancel"); // TODO: put better message into Message class + sender.sendMessage(Messages.generationNotCanceled); } else { ChunkGenerator.cancelRender(world); - sender.sendMessage("generation canceled"); // TODO: put better message into Message class + sender.sendMessage(Messages.generationCanceled); } return true; diff --git a/src/main/java/de/craftinc/borderprotection/commands/GenerateCommand.java b/src/main/java/de/craftinc/borderprotection/commands/GenerateCommand.java index f61eb2f..29079c6 100644 --- a/src/main/java/de/craftinc/borderprotection/commands/GenerateCommand.java +++ b/src/main/java/de/craftinc/borderprotection/commands/GenerateCommand.java @@ -30,7 +30,7 @@ public class GenerateCommand implements SubCommand @Override public boolean execute(CommandSender sender, String[] parameters) { - if ( !sender.hasPermission("craftinc.borderprotection.set") ) // TODO: a new/different permission? + if ( !sender.hasPermission("craftinc.borderprotection.generate") ) { sender.sendMessage(Messages.noPermissionSet); return false; @@ -40,19 +40,18 @@ public class GenerateCommand implements SubCommand if (ChunkGenerator.isGenerating(world)) { - sender.sendMessage("already generating! will resume on logout"); // TODO: put better message into Message class + sender.sendMessage(Messages.generationAlreadyInProgress); } else { if (ChunkGenerator.generate(world)) { - sender.sendMessage("world marked for generation! will start on logout"); // TODO: put better message into Message class + sender.sendMessage(Messages.generationStarted); } else { - sender.sendMessage("could not start generation. is there a border?"); // TODO: put better message into Message class + sender.sendMessage(Messages.generationCouldNotBeStarted); } - } return true; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c7e21e4..f33410d 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -35,4 +35,7 @@ permissions: description: Allows to be everywhere on the map (ignoring the borders). craftinc.borderprotection.update: default: op - description: Allows to get notified on login, when a new update is available. \ No newline at end of file + description: Allows to get notified on login, when a new update is available. + craftinc.borderprotection.generate: + default: op + description: Allows to generate the complete world inside the border. \ No newline at end of file