66 lines
2.7 KiB
Java
66 lines
2.7 KiB
Java
/*
|
|
* Copyright (C) 2011-2014 lishid. All rights reserved.
|
|
*
|
|
* 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;
|
|
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.Material;
|
|
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;
|
|
|
|
@SuppressWarnings("deprecation")
|
|
public class ToggleOpenInvPluginCommand implements CommandExecutor {
|
|
@Override
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
if (command.getName().equalsIgnoreCase("toggleopeninv")) {
|
|
if (!(sender instanceof Player)) {
|
|
sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
|
|
return true;
|
|
}
|
|
if (!OpenInv.hasPermission(sender, Permissions.PERM_OPENINV)) {
|
|
sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
|
|
return true;
|
|
}
|
|
|
|
Player player = (Player) sender;
|
|
if (args.length > 0) {
|
|
if (args[0].equalsIgnoreCase("check")) {
|
|
if (OpenInv.getPlayerItemOpenInvStatus(player.getName()))
|
|
player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.getItemOpenInvItem()).toString() + " is ON.");
|
|
else
|
|
player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.getItemOpenInvItem()).toString() + " is OFF.");
|
|
}
|
|
}
|
|
if (OpenInv.getPlayerItemOpenInvStatus(player.getName())) {
|
|
OpenInv.setPlayerItemOpenInvStatus(player.getName(), false);
|
|
player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.getItemOpenInvItem()).toString() + " is OFF.");
|
|
}
|
|
else {
|
|
OpenInv.setPlayerItemOpenInvStatus(player.getName(), true);
|
|
player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.getItemOpenInvItem()).toString() + " is ON.");
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|