implemented /ds defaults
This commit is contained in:
		| @@ -157,6 +157,15 @@ public class DiscoParty { | |||||||
| 		return this; | 		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 | 	// Spawn some number of sheep next to given player | ||||||
| 	void spawnSheep(int num, int sheepSpawnRadius) { | 	void spawnSheep(int num, int sheepSpawnRadius) { | ||||||
| 		Location loc; | 		Location loc; | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ public final class DiscoSheep extends JavaPlugin { | |||||||
| 	static final String PERMISSION_RELOAD = "discosheep.reload"; | 	static final String PERMISSION_RELOAD = "discosheep.reload"; | ||||||
| 	static final String PERMISSION_OTHER = "discosheep.other"; | 	static final String PERMISSION_OTHER = "discosheep.other"; | ||||||
| 	static final String PERMISSION_CHANGEPERIOD = "discosheep.changeperiod"; | 	static final String PERMISSION_CHANGEPERIOD = "discosheep.changeperiod"; | ||||||
|  | 	static final String PERMISSION_CHANGEDEFAULTS = "discosheep.changedefaults"; | ||||||
|  |  | ||||||
| 	Map<String, DiscoParty> parties = new HashMap<String, DiscoParty>(); | 	Map<String, DiscoParty> parties = new HashMap<String, DiscoParty>(); | ||||||
| 	private BaaBaaBlockSheepEvents blockEvents = new BaaBaaBlockSheepEvents(this); | 	private BaaBaaBlockSheepEvents blockEvents = new BaaBaaBlockSheepEvents(this); | ||||||
| @@ -131,16 +132,16 @@ public final class DiscoSheep extends JavaPlugin { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	 boolean stopAllCommand(CommandSender sender) { | 	 boolean stopAllCommand(CommandSender sender) { | ||||||
| 		if (sender.hasPermission(DiscoSheep.PERMISSION_STOPALL)) { | 		if (sender.hasPermission(PERMISSION_STOPALL)) { | ||||||
| 			stopAllParties(); | 			stopAllParties(); | ||||||
| 			return true; | 			return true; | ||||||
| 		} else { | 		} else { | ||||||
| 			return noPermsMessage(sender, DiscoSheep.PERMISSION_STOPALL); | 			return noPermsMessage(sender, PERMISSION_STOPALL); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	 boolean partyCommand(Player player, DiscoParty party) { | 	 boolean partyCommand(Player player, DiscoParty party) { | ||||||
| 		if (player.hasPermission(DiscoSheep.PERMISSION_PARTY)) { | 		if (player.hasPermission(PERMISSION_PARTY)) { | ||||||
| 			if (!hasParty(player.getName())) { | 			if (!hasParty(player.getName())) { | ||||||
| 				party.setPlayer(player); | 				party.setPlayer(player); | ||||||
| 				party.startDisco(); | 				party.startDisco(); | ||||||
| @@ -149,22 +150,22 @@ public final class DiscoSheep extends JavaPlugin { | |||||||
| 			} | 			} | ||||||
| 			return true; | 			return true; | ||||||
| 		} else { | 		} else { | ||||||
| 			return noPermsMessage(player, DiscoSheep.PERMISSION_PARTY); | 			return noPermsMessage(player, PERMISSION_PARTY); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	 boolean reloadCommand(CommandSender sender) { | 	 boolean reloadCommand(CommandSender sender) { | ||||||
| 		if (sender.hasPermission(DiscoSheep.PERMISSION_RELOAD)) { | 		if (sender.hasPermission(PERMISSION_RELOAD)) { | ||||||
| 			reloadConfigFromDisk(); | 			reloadConfigFromDisk(); | ||||||
| 			sender.sendMessage(ChatColor.GREEN + "DiscoSheep config reloaded from disk"); | 			sender.sendMessage(ChatColor.GREEN + "DiscoSheep config reloaded from disk"); | ||||||
| 			return true; | 			return true; | ||||||
| 		} else { | 		} else { | ||||||
| 			return noPermsMessage(sender, DiscoSheep.PERMISSION_RELOAD); | 			return noPermsMessage(sender, PERMISSION_RELOAD); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	 boolean partyOtherCommand(String[] players, CommandSender sender, DiscoParty party) { | 	 boolean partyOtherCommand(String[] players, CommandSender sender, DiscoParty party) { | ||||||
| 		if (sender.hasPermission(DiscoSheep.PERMISSION_OTHER)) { | 		if (sender.hasPermission(PERMISSION_OTHER)) { | ||||||
| 			Player p; | 			Player p; | ||||||
| 			for (String playerName : players) { | 			for (String playerName : players) { | ||||||
| 				p = Bukkit.getServer().getPlayer(playerName); | 				p = Bukkit.getServer().getPlayer(playerName); | ||||||
| @@ -179,12 +180,12 @@ public final class DiscoSheep extends JavaPlugin { | |||||||
| 			} | 			} | ||||||
| 			return true; | 			return true; | ||||||
| 		} else { | 		} else { | ||||||
| 			return noPermsMessage(sender, DiscoSheep.PERMISSION_OTHER); | 			return noPermsMessage(sender, PERMISSION_OTHER); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	 boolean partyAllCommand(CommandSender sender, DiscoParty party) { | 	 boolean partyAllCommand(CommandSender sender, DiscoParty party) { | ||||||
| 		if (sender.hasPermission(DiscoSheep.PERMISSION_ALL)) { | 		if (sender.hasPermission(PERMISSION_ALL)) { | ||||||
| 			for (Player p : Bukkit.getServer().getOnlinePlayers()) { | 			for (Player p : Bukkit.getServer().getOnlinePlayers()) { | ||||||
| 				if (!hasParty(p.getName())) { | 				if (!hasParty(p.getName())) { | ||||||
| 					DiscoParty individualParty = party.DiscoParty(p); | 					DiscoParty individualParty = party.DiscoParty(p); | ||||||
| @@ -194,10 +195,18 @@ public final class DiscoSheep extends JavaPlugin { | |||||||
| 			} | 			} | ||||||
| 			return true; | 			return true; | ||||||
| 		} else { | 		} 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) { | 	 boolean noPermsMessage(CommandSender sender, String permission) { | ||||||
| 		sender.sendMessage(ChatColor.RED + "You do not have the permission node " + ChatColor.GRAY + permission); | 		sender.sendMessage(ChatColor.RED + "You do not have the permission node " + ChatColor.GRAY + permission); | ||||||
| 		return false; | 		return false; | ||||||
|   | |||||||
| @@ -148,7 +148,10 @@ public class DiscoSheepCommandExecutor implements CommandExecutor { | |||||||
| 				return parent.partyCommand(player, mainParty); | 				return parent.partyCommand(player, mainParty); | ||||||
| 			} else if (args[0].equalsIgnoreCase("other")) { | 			} else if (args[0].equalsIgnoreCase("other")) { | ||||||
| 				return parent.partyOtherCommand(parsePlayerList(args, 1), sender, mainParty); | 				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)."); | 				sender.sendMessage(ChatColor.RED + "Invalid argument (certain commands do not work from console)."); | ||||||
| 				return false; | 				return false; | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ permissions: | |||||||
|       discosheep.reload: true |       discosheep.reload: true | ||||||
|       discosheep.other: true |       discosheep.other: true | ||||||
|       discosheep.changeperiod: true |       discosheep.changeperiod: true | ||||||
|  |       discosheep.changedefaults: true | ||||||
|   discosheep.party: |   discosheep.party: | ||||||
|     description: Allows a player to have a party of one |     description: Allows a player to have a party of one | ||||||
|     default: op |     default: op | ||||||
| @@ -45,3 +46,7 @@ permissions: | |||||||
|   discosheep.changeperiod: |   discosheep.changeperiod: | ||||||
|     description: Allows a player to use the -p switch |     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 | ||||||
|  |    | ||||||
		Reference in New Issue
	
	Block a user
	 Gibstick
					Gibstick