implemented /ds defaults

This commit is contained in:
Gibstick 2013-07-22 09:09:09 -04:00
parent 4653521a39
commit 4e4ebc58f8
4 changed files with 38 additions and 12 deletions

View File

@ -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) {

View File

@ -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<String, DiscoParty> parties = new HashMap<String, DiscoParty>();
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);

View File

@ -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;
}

View File

@ -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
default: op
discosheep.changedefaults:
description: Allows a player to change the default settings
default: op