@Command(
      name = "pickpocket",
      aliases = {},
      player = true,
      permission = "masters.pickpocket",
      description = "Pickpocket a Player's inventory or Ender Chest",
      usage = "/<command> [-e] <player>")
  public void openInventory(CommandSender sender, String[] args) {
    if (args.length < 1) throw new CommandArgumentException();

    boolean enderChest = args.length == 2 && args[0].equals("-e");

    if (enderChest && args.length < 2) throw new CommandArgumentException();

    String targetName = enderChest ? args[1] : args[0];
    OfflinePlayer target = Bukkit.getOfflinePlayer(targetName);
    Player p = Bukkit.getPlayer(sender.getName()).getPlayer();

    try {
      if (enderChest) p.openInventory(((HumanEntity) target).getEnderChest());
      else p.openInventory(((HumanEntity) target).getInventory());
    } catch (ClassCastException e) {
      p.sendMessage(ChatColor.RED + "Can't open this inventory");
    }
  }
Exemple #2
0
  /**
   * Shows the skill tree for the player. If the player has multiple trees, this will show the list
   * of skill trees they can view.
   *
   * @param player player to show the skill tree for
   * @return true if able to show the player, false otherwise
   */
  public boolean showSkills(Player player) {
    // Cannot show an invalid player, and cannot show no skills
    if (player == null || classes.size() == 0 || skills.size() == 0) {
      return false;
    }

    // Show skill tree of only class
    if (classes.size() == 1) {
      PlayerClass playerClass = classes.get(classes.keySet().toArray(new String[1])[0]);
      if (playerClass.getData().getSkills().size() == 0) {
        return false;
      }

      player.openInventory(
          ((InventoryTree) playerClass.getData().getSkillTree()).getInventory(this));
      return true;
    }

    // Show list of classes that have skill trees
    else {
      Inventory inv =
          InventoryManager.createInventory(
              TreeListener.CLASS_LIST_KEY, (classes.size() + 8) / 9, player.getName());
      for (PlayerClass c : classes.values()) {
        inv.addItem(c.getData().getIcon());
      }
      player.openInventory(inv);
      return true;
    }
  }
Exemple #3
0
 public void open() {
   if (!HashMaps.personalGui.containsKey(p)) {
     p.openInventory(i);
   } else {
     Inventory i = HashMaps.personalGui.get(p);
     if (i != null) {
       p.openInventory(i);
     }
   }
 }
 public WebInventory(Player p) {
   if (p == null) return;
   playerName = p.getName();
   chest = Bukkit.getServer().createInventory(null, 54, "WebAuction+ MailBox");
   loadInventory();
   p.openInventory(chest);
 }
Exemple #5
0
 public void showGui(Player player, int num) {
   ShopCategory catetory = ShopCategory.getCategoryByID(num);
   if (catetory.getInventory() != null) {
     player.openInventory(catetory.getInventory());
     return;
   }
 }
Exemple #6
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String laber, String[] args) {

    if (sender instanceof Player) {
      p = (Player) sender;
      if (!Manager.config.getBoolean("commands.CommandOi")) {
        disComm(p);
        return true;
      }
    } else {
      return false;
    }

    if (p.hasPermission("survival.oi")) {
      if (args.length == 0) {
        correctUse(p, "oi <player>");
      } else {
        Player foropen = conPlayer(p, args[0], true);
        if (foropen != null) {
          if (!foropen.hasPermission("survival.nooi")) {
            p.openInventory(foropen.getInventory());
          } else {
            p.sendMessage(ChatColor.RED + "Al jugador mencionado no le puedes abrir el inventario");
          }
        }
      }
    } else {
      noPerm(p);
    }

    return true;
  }
 public static PlayerShopInventoryMenu open(
     PlayerShopSession session, PlayerShop shop, Player player) {
   PlayerShopInventoryMenu menu = new PlayerShopInventoryMenu(session, shop);
   session.setMenu(menu);
   menu.inventory = player.openInventory(menu.inventory).getTopInventory();
   return menu;
 }
  public static void openGomibako(CommandSender sender) {
    if (!(sender instanceof Player)) {
      Msg.warning(sender, "ゴミ箱コマンドはゲーム内からのみ実行できます");
    }

    Player player = (Player) sender;

    if (!(player.hasPermission(Permissions.getGomibakoPermisson()))) {
      Msg.noPermissionMessage(sender, Permissions.getGomibakoPermisson());
      return;
    }

    ItemStack item0 = new ItemStack(Material.BOOK);
    ItemMeta itemmeta0 = item0.getItemMeta();
    itemmeta0.setDisplayName(ChatColor.GOLD + "ゴミ箱の使い方");
    itemmeta0.setLore(
        Arrays.asList(ChatColor.WHITE + "ゴミ箱に不要なアイテムを収納し、", ChatColor.WHITE + "画面を閉じると処分が完了します。"));
    item0.setItemMeta(itemmeta0);

    ItemStack item1 = new ItemStack(Material.BED);
    ItemMeta itemmeta1 = item1.getItemMeta();
    itemmeta1.setDisplayName(ChatColor.GOLD + "画面を閉じる");
    itemmeta1.setLore(Arrays.asList(ChatColor.GRAY + "定食サーバオリジナルプラグイン!"));
    item1.setItemMeta(itemmeta1);

    Inventory inv = Bukkit.createInventory(player, 36, " ゴミ箱 ");
    inv.setItem(0, item0);
    inv.setItem(1, item1);
    player.openInventory(inv);
  }
Exemple #9
0
  public void open(Player player) {
    Inventory inv = Bukkit.createInventory(player, size, name);

    for (int i = 0; i < items.length; i++) {
      inv.setItem(i, items[i]);
    }
    player.openInventory(inv);
  }
Exemple #10
0
  /**
   * Opens the block's inventory's GUI
   *
   * @param block Block
   * @param player Player on whose screen the GUI is going to be shown
   * @return Was the opening successful?
   */
  public static boolean openBlockGUI(Block block, Player player) {
    if (!(block instanceof InventoryHolder)) {
      return false;
    }

    Inventory inventory = ((InventoryHolder) block).getInventory();
    player.openInventory(inventory);

    return true;
  }
 @Override
 public void run() {
   TARDISRegulatorInventory reg = new TARDISRegulatorInventory();
   ItemStack[] items = reg.getRegulator();
   Inventory inv = plugin.getServer().createInventory(player, 54, "Helmic Regulator");
   inv.setContents(items);
   player.openInventory(inv);
   // play inflight sound
   TARDISSounds.playTARDISSound(player.getLocation(), player, "interior_flight");
 }
 public static CommuFusion open(Player editor, Player receiver) {
   CommuFusion cf = new CommuFusion();
   cf.editing = editor;
   cf.receiver = receiver;
   cf.inventory = Bukkit.getServer().createInventory(editor, 9, "Commu Fusion (3 or 4 cards)");
   cf.recipe = new ArrayList<Integer>();
   editor.openInventory(cf.inventory);
   cf.updateInterface();
   return cf;
 }
 public static void open(Player p) {
   Inventory inv = Bukkit.createInventory(p, 54, getName());
   addItems(inv, 0, Items.SHOP_PISTOLS);
   addItems(inv, 1, Items.SHOP_SMGS);
   addItems(inv, 2, Items.SHOP_HEAVY_WEAPONS);
   addItems(inv, 3, Items.SHOP_RIFLES);
   addItems(inv, 4, Items.SHOP_EQUIPMENT);
   addItems(inv, 5, Items.SHOP_GRENADES);
   p.openInventory(inv);
 }
Exemple #14
0
 public void open(Player player) {
   if (player.getOpenInventory() != null) player.closeInventory();
   Inventory inventory = Bukkit.createInventory(player, size, name);
   for (int i = 0; i < optionIcons.length; i++) {
     if (optionIcons[i] != null) {
       inventory.setItem(i, optionIcons[i]);
     }
   }
   player.openInventory(inventory);
 }
 public void open(Player player) {
   this.player = player;
   Inventory inventory = Bukkit.createInventory(player, this.size, this.name);
   for (int i = 0; i < this.optionIcons.length; i++) {
     if (this.optionIcons[i] != null) {
       inventory.setItem(i, this.optionIcons[i]);
     }
   }
   player.openInventory(inventory);
 }
 void arenaSelect(Player spectator) {
   Inventory gui = Bukkit.getServer().createInventory(spectator, 27, basePrefix);
   for (int i = 1; i < setup.getConfig().getInt("nextarena"); i++) {
     ItemStack arenaBook = new ItemStack(Material.BOOK, 1);
     ItemMeta meta = (ItemMeta) arenaBook.getItemMeta();
     meta.setDisplayName(setup.getConfig().getString("arena." + i + ".name"));
     arenaBook.setItemMeta(meta);
     gui.addItem(arenaBook);
   }
   spectator.openInventory(gui);
 }
 @Override
 public boolean onClick(InventoryClickEvent event) {
   if (event.getInventory() == null
       || event.getInventory().getTitle() == null
       || !stripFormatting(event.getInventory().getTitle())
           .contains(stripFormatting(getTitle()))) {
     return false;
   }
   if (event.getSlotType() != InventoryType.SlotType.CONTAINER) {
     return true;
   }
   Player player = (Player) event.getWhoClicked();
   Inventory menu = event.getInventory();
   ItemStack returnItem = menu.getItem(getIndex(5, 0));
   String configName = returnItem.getItemMeta().getLore().get(0);
   String path = returnItem.getItemMeta().getLore().get(1);
   int page = getPage(returnItem.getItemMeta().getLore().get(2));
   int slot = event.getSlot();
   int row = slot / 9;
   int col = slot % 9;
   ItemStack clickedItem = event.getCurrentItem();
   if (slot >= getIndex(3, 0) && slot <= getIndex(3, 8)) {
     // increment buttons
     YmlConfiguration config = FileUtil.getYmlConfiguration(configName);
     int value = config.getInt(path, 0);
     int increment = getDisplayNameAsInt(clickedItem);
     if (event.getClick() == ClickType.LEFT) {
       value += increment;
     } else if (event.getClick() == ClickType.RIGHT) {
       value = increment;
     }
     config.set(path, value);
     config.set("dirty", true);
   }
   if (slot != getIndex(5, 0)) {
     player.openInventory(createEditMenu(configName, path, page));
   } else {
     player.openInventory(parent.createEditMenu(configName, path, page));
   }
   return true;
 }
Exemple #18
0
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] a) {

    if (!(sender instanceof Player)) {
      return false;
    }

    Player player = (Player) sender;
    if (cmd.getName().equalsIgnoreCase("test")) {
      player.openInventory(inv);
    }
    return false;
  }
 public boolean execute(CommandSender sender, String[] args) {
   if (sender instanceof Player) {
     Player player = (Player) sender;
     if (args.length == 0) {
       if (player.hasPermission("kessentials.enderchest")) {
         Inventory inv = player.getEnderChest();
         player.openInventory(inv);
         player.sendMessage(GREEN + "You are now viewing your enderchest.");
       } else {
         noPermissionsMessage(player);
       }
     } else if (args.length == 1) {
       if (player.hasPermission("kessentials.enderchest")) {
         Player tplayer = Bukkit.getServer().getPlayer(args[0]);
         if (tplayer != null) {
           Inventory inv = tplayer.getEnderChest();
           player.openInventory(inv);
           player.sendMessage(
               GREEN
                   + "You are now viewing "
                   + YELLOW
                   + tplayer.getName()
                   + GREEN
                   + "'s enderchest.");
         } else {
           player.sendMessage(RED + args[0] + " is not online.");
         }
       } else {
         noPermissionsMessage(player);
       }
     } else {
       incorrectUsage(player, "/enderchest [player]");
     }
   } else {
     consoleError();
   }
   return false;
 }
Exemple #20
0
  public void openKitMenu(ArcadePlayer player) {
    Player rawPlayer = player.getPlayer();
    Inventory inv =
        Bukkit.createInventory(
            null, ArcadeHandler.getInstance().getCurrentGame().getKits().size(), "Pick your kits!");

    for (Kit kit : ArcadeHandler.getInstance().getCurrentGame().getKits()) {
      inv.addItem(
          new ItemBuilder(
                  kit.getDisplayItem().getType(), 1, kit.getName(), (short) 0, kit.getDesc())
              .build());
    }
    rawPlayer.openInventory(inv);
  }
Exemple #21
0
 @SuppressWarnings("deprecation")
 public static void openInventory(Player p) {
   Inventory i = Bukkit.createInventory(null, MaxLobbyNumber, InventoryName);
   for (int n = 1; n <= MaxLobbyNumber; n++) {
     ItemStack lby = new ItemStack(Material.WOOL, n, (short) 0, getData(getPlayersInLobby(n)));
     if (n == getLobby(p)) lby.setType(Material.GOLD_BLOCK);
     ItemMeta lbym = lby.getItemMeta();
     lbym.setDisplayName("§d§lLobby: §6§l" + n);
     List<String> s = new ArrayList<String>();
     s.add("§8Players: §7" + getPlayersInLobby(n));
     lbym.setLore(s);
     lby.setItemMeta(lbym);
     i.setItem(n - 1, lby);
   }
   p.openInventory(i);
 }
 protected static void openGUI(Player player) {
   player.sendMessage(ChatColor.GREEN + "Opening Lobby Selector GUI");
   Inventory inventory = Bukkit.createInventory(null, 9, GUI_NAME);
   int lobbyNumber = 1;
   for (Lobby lobby : Lobby.getLobbies()) {
     ItemStack button;
     if (lobby.getState().equals(LobbyState.INACTIVE) || lobby.isFull())
       button = new ItemStack(Material.REDSTONE_BLOCK, 1);
     else button = new ItemStack(Material.EMERALD_BLOCK, 1);
     ItemMeta meta = button.getItemMeta();
     meta.setDisplayName("Lobby " + lobbyNumber);
     button.setItemMeta(meta);
     inventory.addItem();
   }
   player.openInventory(inventory);
 }
  /**
   * Parses through all of the previously created CustomItems, and places them into this newly
   * formed Inventory. The items will be displayed for the user.
   */
  public void createInventory() {
    if (page < 0) page = 0;
    if (displays.containsKey(player)) {
      Inventory inv = displays.get(player).inventory;
      if (inv.getViewers().size() > 0) return;
      else displays.remove(player);
    }

    Inventory inv = Bukkit.createInventory(null, INV_SIZE, "Bending Items");
    ArrayList<ItemStack> cistacks = new ArrayList<ItemStack>();
    for (CustomItem citem : CustomItem.itemList) {
      ItemStack istack = citem.generateItem();
      ItemMeta meta = istack.getItemMeta();
      if (showStats) {
        ArrayList<String> lore = new ArrayList<String>();
        for (Attribute att : citem.getAttributes()) {
          if (att.getValues().toString().length() < 40)
            lore.add(new String(att.getName() + ":" + att.getValues()));
          else lore.add(new String(att.getName()));
        }
        meta.setLore(lore);
      } else {
        List<String> lore = meta.getLore();
        if (lore == null) lore = new ArrayList<String>();

        String s = "";
        if (citem.getRecipe().size() == 0) s = ChatColor.RED + "Uncraftable";
        else if (citem.isUnshapedRecipe()) s = ChatColor.GREEN + "Craftable (unshaped)";
        else s = ChatColor.GREEN + "Craftable (shaped)";
        lore.add(s);
        meta.setLore(lore);
      }
      istack.setItemMeta(meta);
      cistacks.add(istack);
    }

    for (int i = (INV_SIZE - 9) * page; i < (INV_SIZE - 9) * (page + 1); i++) {
      if (i >= 0 && i < cistacks.size()) inv.addItem(cistacks.get(i));
      else break;
    }
    if (cistacks.size() > INV_ITEM_QTY) inv.setItem(INV_SIZE - 1, NEXT_BUTTON);
    if (page > 0) inv.setItem(INV_SIZE - 9, PREV_BUTTON);

    this.inventory = inv;
    displays.put(player, this);
    player.openInventory(inv);
  }
  @SuppressWarnings({"rawtypes", "unchecked"})
  private void openInventory(Player p, Location l) {
    Inventory inv = pl.getServer().createInventory(null, InventoryType.HOPPER, "Network Creator");

    inv.setItem(2, in2);

    ItemStack brea = new ItemStack(Material.ENDER_PORTAL_FRAME);
    ItemMeta im = brea.getItemMeta();
    im.setDisplayName(ChatColor.RESET + "Déassablage");
    List<String> lore = new ArrayList();
    lore.add(l.getBlockX() + "/" + l.getBlockY() + "/" + l.getBlockZ());
    im.setLore(lore);
    brea.setItemMeta(im);
    inv.setItem(4, brea);

    p.openInventory(inv);
  }
Exemple #25
0
  @Override
  public boolean onCommand(CommandSender s, Command c, String l, String[] a) {
    if (!(s instanceof Player)) {
      s.sendMessage("This Command can only run by a player.");
      return true;
    }

    Player p = (Player) s;

    if (!p.hasPermission("customs.use.viewInventory")) {
      p.sendMessage(
          Language.getMessage(
              Customs.getPlugin(),
              p.getUniqueId(),
              "command.viewinventory.noPermission",
              "You dont have permission to show in the inventory of other players."));
      return true;
    }

    if (a.length < 1) {
      p.sendMessage(
          Language.getMessage(
              Customs.getPlugin(),
              p.getUniqueId(),
              "command.viewinventory.noPlayerGiven",
              "Please give a player name where you want to see the inventory."));
      return true;
    }

    if (Bukkit.getPlayer(a[0]) == null) {
      p.sendMessage(
          Language.getMessage(
              Customs.getPlugin(),
              p.getUniqueId(),
              "command.viewinventory.noPlayerFound",
              "Can't find the given Player online."));
      return true;
    }

    Player vp = Bukkit.getPlayer(a[0]);
    OfflinePlayer op = Bukkit.getOfflinePlayer(a[0]);

    p.openInventory(vp.getInventory());
    // _tasks.put(p.getName(), t);
    return true;
  }
Exemple #26
0
  private void openGUI(Player player) {
    Inventory inv = Bukkit.createInventory(null, 6, ChatColor.BLUE + "Offical MD Links");

    ItemStack twitter = new ItemStack(Material.BEACON);
    ItemMeta twitterMeta = twitter.getItemMeta();
    ItemStack youtube = new ItemStack(Material.ANVIL);
    ItemMeta youtubeMeta = youtube.getItemMeta();
    ItemStack resourcepack = new ItemStack(Material.MINECART);
    ItemMeta resourcepackMeta = resourcepack.getItemMeta();
    ItemStack mumble = new ItemStack(Material.DIAMOND);
    ItemMeta mumbleMeta = mumble.getItemMeta();
    ItemStack website = new ItemStack(Material.WOOL);
    ItemMeta websiteMeta = website.getItemMeta();
    ItemStack apply = new ItemStack(Material.COMPASS);
    ItemMeta applyMeta = apply.getItemMeta();

    twitterMeta.setDisplayName(ChatColor.AQUA + "Twitter");
    twitter.setItemMeta(twitterMeta);

    youtubeMeta.setDisplayName(ChatColor.AQUA + "YouTube");
    youtube.setItemMeta(youtubeMeta);

    resourcepackMeta.setDisplayName(ChatColor.AQUA + "ResourcePack");
    resourcepack.setItemMeta(resourcepackMeta);

    mumbleMeta.setDisplayName(ChatColor.AQUA + "Mumble");
    mumble.setItemMeta(mumbleMeta);

    websiteMeta.setDisplayName(ChatColor.AQUA + "Website");
    website.setItemMeta(websiteMeta);

    applyMeta.setDisplayName(ChatColor.AQUA + "Applications");
    apply.setItemMeta(applyMeta);

    inv.setItem(1, twitter);
    inv.setItem(2, youtube);
    inv.setItem(3, resourcepack);
    inv.setItem(4, mumble);
    inv.setItem(5, website);
    inv.setItem(6, apply);

    player.openInventory(inv);
  }
Exemple #27
0
  @EventHandler(priority = EventPriority.LOW)
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Client client = Client.getClient(player);

    if (client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning()) {
      event.setCancelled(true);
      if (event.getClickedBlock() != null
          && event.getClickedBlock().getType() == Material.CHEST
          && event.getAction() == Action.RIGHT_CLICK_BLOCK)
        player.openInventory(((Chest) event.getClickedBlock().getState()).getBlockInventory());
      return;
    }
    /*	if(client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning()) {
    	event.setCancelled(true);
    	if(event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST && event.getAction() == Action.RIGHT_CLICK_BLOCK)
    		player.openInventory(((Chest) event.getClickedBlock().getState()).getBlockInventory());
    	return;
    }*/
  }
Exemple #28
0
 /** Opens the attribute menu */
 public void openAttributeMenu() {
   Player player = getPlayer();
   if (SkillAPI.getSettings().isAttributesEnabled() && player != null) {
     AttributeManager manager = SkillAPI.getAttributeManager();
     Inventory inv =
         InventoryManager.createInventory(
             AttributeListener.MENU_KEY,
             (manager.getKeys().size() + 8) / 9,
             "Attributes (" + attribPoints + " points)");
     int i = 0;
     for (String key : manager.getKeys()) {
       ItemStack icon = manager.getAttribute(key).getIcon().clone();
       ItemMeta meta = icon.getItemMeta();
       meta.setDisplayName(meta.getDisplayName().replace("{amount}", "" + getAttribute(key)));
       icon.setItemMeta(meta);
       inv.setItem(i++, icon);
     }
     player.openInventory(inv);
   }
 }
  public static void handleViewInventoryEvent(Player clicker, Player clicked) {
    String ownerShip = "'s ";
    if (clicked
        .getName()
        .substring(clicked.getName().length() - 1, clicked.getName().length())
        .equalsIgnoreCase("s")) ownerShip = "' ";
    Inventory playerInventory =
        Bukkit.createInventory(
            null, 54, ChatColor.GOLD + clicked.getName() + ownerShip + "Inventory");

    int i = 0; // Index in inventory
    for (ItemStack is : clicked.getInventory().getContents()) {
      playerInventory.setItem(i++, is);
    }
    i += 13; // Empty row, three empty before armor contents (centres it)
    for (ItemStack is : clicked.getInventory().getArmorContents()) {
      playerInventory.setItem(i++, is);
    }
    clicker.openInventory(playerInventory);
  }
Exemple #30
0
  // Events
  @EventHandler
  public void onPlayerUse(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    if (this.getConfig().getBoolean("backToHubItem")) {
      if (event.getAction().equals(Action.RIGHT_CLICK_AIR)
          || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        if (p.getItemInHand().getType() == Material.NETHER_STAR) {
          World world = Bukkit.getWorld(getConfig().getString("hubWorld"));
          Location spawn =
              new Location(
                  world,
                  getConfig().getInt("hubX"),
                  getConfig().getInt("hubY") + 5,
                  getConfig().getInt("hubZ"));

          p.teleport(spawn);

          p.sendMessage("You are now at spawn");
        }
      }
    }
    if (this.getConfig().getBoolean("quickWarpItem")) {
      if (event.getAction().equals(Action.RIGHT_CLICK_AIR)
          || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        if (p.getItemInHand().getType() == Material.COMPASS) {
          Inventory qw = Bukkit.createInventory(p, 9, ChatColor.BLACK + "Quick Warp");
          qw.clear();
          // ItemStacks For QW
          ItemStack wb = new ItemStack(Material.COMMAND, 0);
          ItemMeta wbMeta = wb.getItemMeta();
          wbMeta.setDisplayName(ChatColor.DARK_AQUA + "Admin Hub");
          wb.setItemMeta(wbMeta);
          // End

          qw.setItem(4, wb);
          p.openInventory(qw);
          p.closeInventory();
        }
      }
    }
  }