2013-01-02 02:35:17 +01:00
|
|
|
/*
|
|
|
|
* To change this template, choose Tools | Templates
|
|
|
|
* and open the template in the editor.
|
|
|
|
*/
|
|
|
|
package net.spoothie.chairs;
|
|
|
|
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author cnaude
|
|
|
|
*/
|
|
|
|
public class ChairsCommand implements CommandExecutor {
|
|
|
|
|
|
|
|
private final Chairs plugin;
|
|
|
|
public ChairsIgnoreList ignoreList;
|
|
|
|
|
|
|
|
public ChairsCommand(Chairs instance, ChairsIgnoreList ignoreList) {
|
|
|
|
this.plugin = instance;
|
|
|
|
this.ignoreList = ignoreList;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
if (args.length == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("reload")) {
|
2013-01-05 03:38:11 +01:00
|
|
|
if (sender.hasPermission("chairs.reload") || !(sender instanceof Player)) {
|
2013-01-02 02:35:17 +01:00
|
|
|
plugin.reloadConfig();
|
|
|
|
plugin.loadConfig();
|
2013-03-15 21:55:09 +01:00
|
|
|
plugin.restartEffectsTask();
|
2013-03-24 06:50:17 +01:00
|
|
|
if (!plugin.msgReloaded.isEmpty()) {
|
|
|
|
sender.sendMessage(plugin.msgReloaded);
|
|
|
|
}
|
2013-01-02 02:35:17 +01:00
|
|
|
} else {
|
2013-03-24 06:50:17 +01:00
|
|
|
if (!plugin.msgNoPerm.isEmpty()) {
|
|
|
|
sender.sendMessage(plugin.msgNoPerm);
|
|
|
|
}
|
2013-01-02 02:35:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sender instanceof Player) {
|
|
|
|
Player p = (Player) sender;
|
|
|
|
if (args[0].equalsIgnoreCase("on")) {
|
2013-01-05 03:38:11 +01:00
|
|
|
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
2013-01-02 02:35:17 +01:00
|
|
|
ignoreList.removePlayer(p.getName());
|
2013-03-24 06:50:17 +01:00
|
|
|
if (!plugin.msgEnabled.isEmpty()) {
|
|
|
|
p.sendMessage(plugin.msgEnabled);
|
|
|
|
}
|
2013-01-02 02:35:17 +01:00
|
|
|
} else {
|
2013-03-24 06:50:17 +01:00
|
|
|
if (!plugin.msgNoPerm.isEmpty()) {
|
|
|
|
p.sendMessage(plugin.msgNoPerm);
|
|
|
|
}
|
2013-01-02 02:35:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("off")) {
|
2013-01-05 03:38:11 +01:00
|
|
|
if (p.hasPermission("chairs.self") || !plugin.permissions) {
|
2013-01-02 02:35:17 +01:00
|
|
|
ignoreList.addPlayer(p.getName());
|
2013-03-24 06:50:17 +01:00
|
|
|
if (!plugin.msgDisabled.isEmpty()) {
|
|
|
|
p.sendMessage(plugin.msgDisabled);
|
|
|
|
}
|
2013-01-02 02:35:17 +01:00
|
|
|
} else {
|
2013-03-24 06:50:17 +01:00
|
|
|
if (!plugin.msgNoPerm.isEmpty()) {
|
|
|
|
p.sendMessage(plugin.msgNoPerm);
|
|
|
|
}
|
2013-01-02 02:35:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|