Ejemplo n.º 1
0
  private boolean performChestCommand(CommandSender sender, String[] args) {
    if (sender instanceof CraftPlayer) {
      if (args.length == 0) {
        if (sender.hasPermission("alphachest.chest")) {
          VirtualChest chest = chestManager.getChest(sender.getName());
          EntityPlayer player = ((CraftPlayer) sender).getHandle();
          player.openContainer(chest);
        } else {
          Teller.tell(sender, Type.Error, "You're not allowed to use this command.");
        }
        return true;
      } else if (args.length == 1) {
        if (sender.hasPermission("alphachest.admin")) {
          VirtualChest chest = chestManager.getChest(args[0]);
          EntityPlayer player = ((CraftPlayer) sender).getHandle();
          player.openContainer(chest);
        } else {
          Teller.tell(sender, Type.Error, "You're not allowed to open other user's chests.");
        }
        return true;

      } else {
        return false;
      }
    } else {
      Teller.tell(sender, Type.Error, "Only players are able to open chests.");
      return true;
    }
  }
Ejemplo n.º 2
0
 private boolean performSaveChestsCommand(CommandSender sender, String[] args) {
   if (sender.hasPermission("alphachest.save")) {
     int savedChests = chestManager.save(true);
     Teller.tell(sender, Type.Success, "Saved " + savedChests + " chests.");
   } else {
     Teller.tell(sender, Type.Error, "You're not allowed to use this command.");
   }
   return true;
 }
Ejemplo n.º 3
0
 private boolean performClearChestCommand(CommandSender sender, String[] args) {
   if (args.length == 0 && sender instanceof Player) {
     if (sender.hasPermission("alphachest.chest")) {
       chestManager.removeChest(sender.getName());
       Teller.tell(sender, Type.Success, "Successfully cleared your chest.");
     } else {
       Teller.tell(sender, Type.Error, "You're not allowed to use this command.");
     }
     return true;
   } else if (args.length == 1) {
     if (sender.hasPermission("alphachest.admin")) {
       chestManager.removeChest(args[0]);
       Teller.tell(sender, Type.Success, "Successfully cleared " + args[0] + "\'s chest.");
     } else {
       Teller.tell(sender, Type.Error, "You're not allowed to clear other user's chests.");
     }
     return true;
   } else {
     return false;
   }
 }