New formatting.
This commit is contained in:
@@ -29,105 +29,90 @@ import com.lishid.openinv.Permissions;
|
||||
import com.lishid.openinv.internal.ISpecialEnderChest;
|
||||
import com.lishid.openinv.internal.InternalAccessor;
|
||||
|
||||
public class OpenEnderPluginCommand implements CommandExecutor
|
||||
{
|
||||
public class OpenEnderPluginCommand implements CommandExecutor {
|
||||
private final OpenInv plugin;
|
||||
public static HashMap<Player, String> openEnderHistory = new HashMap<Player, String>();
|
||||
|
||||
public OpenEnderPluginCommand(OpenInv plugin)
|
||||
{
|
||||
|
||||
public OpenEnderPluginCommand(OpenInv plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST))
|
||||
{
|
||||
|
||||
if (!OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST)) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to access player enderchest");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("?"))
|
||||
{
|
||||
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
|
||||
OpenInv.ShowHelp((Player) sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Player player = (Player) sender;
|
||||
boolean offline = false;
|
||||
|
||||
|
||||
// History management
|
||||
String history = openEnderHistory.get(player);
|
||||
|
||||
if (history == null || history == "")
|
||||
{
|
||||
|
||||
if (history == null || history == "") {
|
||||
history = player.getName();
|
||||
openEnderHistory.put(player, history);
|
||||
}
|
||||
|
||||
|
||||
// Target selecting
|
||||
Player target;
|
||||
|
||||
|
||||
String name = "";
|
||||
|
||||
|
||||
// Read from history if target is not named
|
||||
if (args.length < 1)
|
||||
{
|
||||
if (history != null && history != "")
|
||||
{
|
||||
if (args.length < 1) {
|
||||
if (history != null && history != "") {
|
||||
name = history;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
sender.sendMessage(ChatColor.RED + "OpenEnder history is empty!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
name = args[0];
|
||||
}
|
||||
|
||||
|
||||
target = this.plugin.getServer().getPlayer(name);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
|
||||
if (target == null) {
|
||||
// Try loading the player's data
|
||||
target = OpenInv.playerLoader.loadPlayer(name);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
|
||||
if (target == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Player " + name + " not found!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (target != sender && !OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST_ALL))
|
||||
{
|
||||
|
||||
if (target != sender && !OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST_ALL)) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to access other player's enderchest");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Record the target
|
||||
history = target.getName();
|
||||
openEnderHistory.put(player, history);
|
||||
|
||||
|
||||
// Create the inventory
|
||||
ISpecialEnderChest chest = OpenInv.enderChests.get(target.getName().toLowerCase());
|
||||
if (chest == null)
|
||||
{
|
||||
if (chest == null) {
|
||||
chest = InternalAccessor.Instance.newSpecialEnderChest(target, !offline);
|
||||
}
|
||||
|
||||
|
||||
// Open the inventory
|
||||
player.openInventory(chest.getBukkitInventory());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user