OpenInv/src/main/java/com/lishid/openinv/commands/AnyChestCommand.java

63 lines
2.3 KiB
Java
Raw Normal View History

2012-02-20 20:09:44 +00:00
/*
2013-12-07 09:49:15 +00:00
* Copyright (C) 2011-2014 lishid. All rights reserved.
2012-02-20 20:09:44 +00:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.commands;
2012-01-17 03:20:25 +00:00
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
2015-06-23 03:31:26 +00:00
public class AnyChestCommand implements CommandExecutor {
2015-06-22 02:03:03 +00:00
@Override
2013-12-07 09:47:02 +00:00
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
2015-06-22 02:03:03 +00:00
if (command.getName().equalsIgnoreCase("anychest")) {
if (!(sender instanceof Player)) {
2015-06-23 03:31:26 +00:00
sender.sendMessage(ChatColor.RED + "You can't use this command from the console.");
2015-06-22 02:03:03 +00:00
return true;
}
2015-06-23 03:31:26 +00:00
2015-06-22 02:03:03 +00:00
if (!OpenInv.hasPermission(sender, Permissions.PERM_ANYCHEST)) {
2015-06-23 03:31:26 +00:00
sender.sendMessage(ChatColor.RED + "You do not have permission to use any chest.");
2015-06-22 02:03:03 +00:00
return true;
}
2013-12-07 09:47:02 +00:00
2015-06-23 03:31:26 +00:00
Player player = (Player) sender;
2015-06-22 02:03:03 +00:00
if (args.length > 0) {
if (args[0].equalsIgnoreCase("check")) {
2015-06-23 03:31:26 +00:00
String status = OpenInv.getPlayerAnyChestStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
OpenInv.sendMessage(player, "Any Chest is " + status + ChatColor.RESET + ".");
return true;
2015-06-22 02:03:03 +00:00
}
}
2013-12-07 09:47:02 +00:00
2015-06-23 03:31:26 +00:00
OpenInv.setPlayerAnyChestStatus(player, !OpenInv.getPlayerAnyChestStatus(player));
String status = OpenInv.getPlayerAnyChestStatus(player) ? ChatColor.GREEN + "ON" : ChatColor.RED + "OFF";
OpenInv.sendMessage(player, "Any Chest is now " + status + ChatColor.RESET + ".");
2015-06-22 02:03:03 +00:00
return true;
}
2013-12-07 09:47:02 +00:00
2015-06-22 02:03:03 +00:00
return false;
2012-01-17 03:20:25 +00:00
}
}