diff --git a/src/ca/gibstick/discosheep/DiscoParty.java b/src/ca/gibstick/discosheep/DiscoParty.java index c97011d..0893fb4 100644 --- a/src/ca/gibstick/discosheep/DiscoParty.java +++ b/src/ca/gibstick/discosheep/DiscoParty.java @@ -156,6 +156,15 @@ public class DiscoParty { this.doFireworks = doFireworks; return this; } + + // use current settings as new defaults + public DiscoParty setDefaultsFromCurrent() { + DiscoParty.defaultDuration = this.duration; + DiscoParty.defaultPeriod = this.period; + DiscoParty.defaultRadius = this.radius; + DiscoParty.defaultSheep = this.sheep; + return this; + } // Spawn some number of sheep next to given player void spawnSheep(int num, int sheepSpawnRadius) { diff --git a/src/ca/gibstick/discosheep/DiscoSheep.java b/src/ca/gibstick/discosheep/DiscoSheep.java index ef5ec0f..05cbdb5 100644 --- a/src/ca/gibstick/discosheep/DiscoSheep.java +++ b/src/ca/gibstick/discosheep/DiscoSheep.java @@ -20,6 +20,7 @@ public final class DiscoSheep extends JavaPlugin { static final String PERMISSION_RELOAD = "discosheep.reload"; static final String PERMISSION_OTHER = "discosheep.other"; static final String PERMISSION_CHANGEPERIOD = "discosheep.changeperiod"; + static final String PERMISSION_CHANGEDEFAULTS = "discosheep.changedefaults"; Map parties = new HashMap(); private BaaBaaBlockSheepEvents blockEvents = new BaaBaaBlockSheepEvents(this); @@ -131,16 +132,16 @@ public final class DiscoSheep extends JavaPlugin { } boolean stopAllCommand(CommandSender sender) { - if (sender.hasPermission(DiscoSheep.PERMISSION_STOPALL)) { + if (sender.hasPermission(PERMISSION_STOPALL)) { stopAllParties(); return true; } else { - return noPermsMessage(sender, DiscoSheep.PERMISSION_STOPALL); + return noPermsMessage(sender, PERMISSION_STOPALL); } } boolean partyCommand(Player player, DiscoParty party) { - if (player.hasPermission(DiscoSheep.PERMISSION_PARTY)) { + if (player.hasPermission(PERMISSION_PARTY)) { if (!hasParty(player.getName())) { party.setPlayer(player); party.startDisco(); @@ -149,22 +150,22 @@ public final class DiscoSheep extends JavaPlugin { } return true; } else { - return noPermsMessage(player, DiscoSheep.PERMISSION_PARTY); + return noPermsMessage(player, PERMISSION_PARTY); } } boolean reloadCommand(CommandSender sender) { - if (sender.hasPermission(DiscoSheep.PERMISSION_RELOAD)) { + if (sender.hasPermission(PERMISSION_RELOAD)) { reloadConfigFromDisk(); sender.sendMessage(ChatColor.GREEN + "DiscoSheep config reloaded from disk"); return true; } else { - return noPermsMessage(sender, DiscoSheep.PERMISSION_RELOAD); + return noPermsMessage(sender, PERMISSION_RELOAD); } } boolean partyOtherCommand(String[] players, CommandSender sender, DiscoParty party) { - if (sender.hasPermission(DiscoSheep.PERMISSION_OTHER)) { + if (sender.hasPermission(PERMISSION_OTHER)) { Player p; for (String playerName : players) { p = Bukkit.getServer().getPlayer(playerName); @@ -179,12 +180,12 @@ public final class DiscoSheep extends JavaPlugin { } return true; } else { - return noPermsMessage(sender, DiscoSheep.PERMISSION_OTHER); + return noPermsMessage(sender, PERMISSION_OTHER); } } boolean partyAllCommand(CommandSender sender, DiscoParty party) { - if (sender.hasPermission(DiscoSheep.PERMISSION_ALL)) { + if (sender.hasPermission(PERMISSION_ALL)) { for (Player p : Bukkit.getServer().getOnlinePlayers()) { if (!hasParty(p.getName())) { DiscoParty individualParty = party.DiscoParty(p); @@ -194,9 +195,17 @@ public final class DiscoSheep extends JavaPlugin { } return true; } else { - return noPermsMessage(sender, DiscoSheep.PERMISSION_ALL); + return noPermsMessage(sender, PERMISSION_ALL); } } + + boolean setDefaultsCommand(CommandSender sender, DiscoParty party) { + if (sender.hasPermission(PERMISSION_CHANGEDEFAULTS)) { + party.setDefaultsFromCurrent(); + return true; + } + else return noPermsMessage(sender, PERMISSION_CHANGEDEFAULTS); + } boolean noPermsMessage(CommandSender sender, String permission) { sender.sendMessage(ChatColor.RED + "You do not have the permission node " + ChatColor.GRAY + permission); diff --git a/src/ca/gibstick/discosheep/DiscoSheepCommandExecutor.java b/src/ca/gibstick/discosheep/DiscoSheepCommandExecutor.java index 362e94b..7ff315b 100644 --- a/src/ca/gibstick/discosheep/DiscoSheepCommandExecutor.java +++ b/src/ca/gibstick/discosheep/DiscoSheepCommandExecutor.java @@ -148,7 +148,10 @@ public class DiscoSheepCommandExecutor implements CommandExecutor { return parent.partyCommand(player, mainParty); } else if (args[0].equalsIgnoreCase("other")) { return parent.partyOtherCommand(parsePlayerList(args, 1), sender, mainParty); - } else { + } else if (args[0].equalsIgnoreCase("defaults")) { + return parent.setDefaultsCommand(sender, mainParty); + } + else { sender.sendMessage(ChatColor.RED + "Invalid argument (certain commands do not work from console)."); return false; } diff --git a/src/plugin.yml b/src/plugin.yml index 449db0d..e18c046 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -22,6 +22,7 @@ permissions: discosheep.reload: true discosheep.other: true discosheep.changeperiod: true + discosheep.changedefaults: true discosheep.party: description: Allows a player to have a party of one default: op @@ -44,4 +45,8 @@ permissions: discosheep.party: true discosheep.changeperiod: description: Allows a player to use the -p switch - default: op \ No newline at end of file + default: op + discosheep.changedefaults: + description: Allows a player to change the default settings + default: op + \ No newline at end of file