1 |
package dk.thoerup.bukkit.whois; |
2 |
|
3 |
import org.bukkit.command.Command; |
4 |
import org.bukkit.command.CommandExecutor; |
5 |
import org.bukkit.command.CommandSender; |
6 |
import org.bukkit.entity.Player; |
7 |
import org.bukkit.ChatColor; |
8 |
|
9 |
import org.bukkit.util.config.Configuration; |
10 |
|
11 |
|
12 |
public class SetwhoisCommand implements CommandExecutor { |
13 |
Configuration config; |
14 |
|
15 |
public SetwhoisCommand(Configuration config) { |
16 |
this.config = config; |
17 |
} |
18 |
|
19 |
@Override |
20 |
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) { |
21 |
|
22 |
if (!(sender instanceof Player)) { |
23 |
return false; |
24 |
} |
25 |
Player p = (Player) sender; |
26 |
|
27 |
if (args.length == 0) { |
28 |
p.sendMessage(ChatColor.GREEN + "Usage: /setwhois <whois info>"); |
29 |
return true; |
30 |
} |
31 |
|
32 |
|
33 |
String name = p.getName().toLowerCase(); |
34 |
String whois = WhoisMain.concatStrings(args, 0 ); |
35 |
|
36 |
config.setProperty( name + ".whois", whois ); |
37 |
config.save(); |
38 |
|
39 |
p.sendMessage(ChatColor.GREEN + "done"); |
40 |
|
41 |
return true; |
42 |
} |
43 |
} |