本文整理汇总了Java中org.bukkit.entity.Player.openInventory方法的典型用法代码示例。如果您正苦于以下问题:Java Player.openInventory方法的具体用法?Java Player.openInventory怎么用?Java Player.openInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.openInventory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupEditMenu
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void setupEditMenu(Player player) {
Inventory inv = Bukkit.createInventory(player, Convert.getInventorySize(plugin.getChallengesFile().getChallengesAmount()), ChatColor.BOLD + "Edit Challenge");
for(int i = 1; i <= plugin.getChallengesFile().getChallengesAmount(); i++){
Material mat;
if(plugin.getChallengesFile().getType(i).equalsIgnoreCase("parkour")){
mat = Material.GOLD_BOOTS;
}
else if(plugin.getChallengesFile().getType(i).equalsIgnoreCase("maze")){
mat = Material.TORCH;
}else{
mat = Material.GOLD_SWORD;
}
inv.addItem(ItemStackGenerator.createItem(mat, 0, 0,
ChatColor.GRAY + "" + i + Convert.getOrdinalFor(i) + " Challenge", null, true));
}
player.openInventory(inv);
}
示例2: accept
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void accept(Player player, List<String> args) {
org.bukkit.inventory.ItemStack itemInMainHand = player.getInventory().getItemInMainHand();
if (itemInMainHand == null) {
player.sendMessage(ChatColor.RED + "Put the result of the recipe in your main hand when executing this command.");
return;
}
if (args.isEmpty()) {
player.sendMessage(ChatColor.RED + "Usage: /addrecipe NBT <key> [<group>]");
return;
}
String keyString = args.get(0);
String group = args.size() >= 2 ? args.get(1) : "";
NamespacedKey bukkitKey = plugin.getKey(keyString);
ItemStack result = CraftItemStack.asNMSCopy(itemInMainHand);
MinecraftKey key = CraftNamespacedKey.toMinecraft(bukkitKey);
player.openInventory(new NBTRecipeHolder(plugin, result, key, group, player).getInventory());
}
示例3: accept
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void accept(Player player, List<String> args) {
org.bukkit.inventory.ItemStack itemInMainHand = player.getInventory().getItemInMainHand();
if (itemInMainHand == null) {
player.sendMessage(ChatColor.RED + "Put the result of the recipe in your main hand when executing this command.");
return;
}
if (args.size() < 2) {
player.sendMessage(ChatColor.RED + "Usage: /addrecipe permission <key> <permission> [<group>]");
return;
}
String keyString = args.get(0);
String permission = args.get(1);
String group = args.size() >= 3 ? args.get(2) : "";
NamespacedKey bukkitKey = plugin.getKey(keyString);
ItemStack result = CraftItemStack.asNMSCopy(itemInMainHand);
MinecraftKey key = CraftNamespacedKey.toMinecraft(bukkitKey);
player.openInventory(new PermissionRecipeHolder(plugin, result, key, group, player, permission).getInventory());
}
示例4: setupRunesMenu
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void setupRunesMenu(Player player) {
Inventory inventory = Bukkit.createInventory(player, 9, ChatColor.BOLD + "Runes");
for(Rune rune : plugin.getRuneManager().getRunes()) {
List<String> description = new ArrayList<>(rune.getDescription());
if(rune.getDuration() != -1) {
description.add(ChatColor.GRAY + "Duration: " + ChatColor.RED + rune.getDuration() + " seconds");
}
description.add(ChatColor.GRAY + "Price: " + ChatColor.RED + rune.getPrice() + " GT");
inventory.addItem(ItemStackGenerator.createItem(rune.getIcon(), ChatColor.RED + rune.getName(),
description));
}
player.openInventory(inventory);
}
示例5: onCommand
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
if(!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
Inventory inv = Bukkit.createInventory(player, Convert.getInventorySize(GodFoodFile.getEffectAmount()), ChatColor.BOLD + "FoG");
for(int i = 1; i <= GodFoodFile.getEffectAmount(); i++) {
List<String> effects = new ArrayList<>();
for(String str : GodFoodFile.GetEffects(i)) {
String[] values = str.split(", ");
effects.add(ChatColor.RED + values[0] + " " + Convert.arabicToRome(Integer.parseInt(values[2])) + ChatColor.LIGHT_PURPLE + " " + values[1] + " sec.");
}
inv.addItem(ItemStackGenerator.createItem(
GodFoodFile.getFoodType(i), GodFoodFile.getAmount(i), GodFoodFile.getData(i), ChatColor.LIGHT_PURPLE + GodFoodFile.getName(i), effects));
}
player.openInventory(inv);
return true;
}
示例6: open
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void open(Player player) {
PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);
if (profile.getParty() == null) {
player.sendMessage(ChatColor.RED + "You must be in a party to open the event menu.");
return;
}
if (profile.getParty().getPlayers().size() < 2) {
player.sendMessage(ChatColor.RED + "You must have more than 2 players in your party to start an event.");
player.closeInventory();
return;
}
Inventory inv = Bukkit.createInventory(null, ManagerHandler.getLadderManager().getLadderAmount(), ChatColor.AQUA + "Party Events - Select an event");
inv.setItem(2, new ItemBuilder(Material.DIAMOND, ChatColor.AQUA + "Team Deathmatch", ChatColor.GRAY + "Click to select the", ChatColor.GRAY + "Team Deathmatch event.").getItem());
inv.setItem(6, new ItemBuilder(Material.DIAMOND, ChatColor.AQUA + "Free-for-All", ChatColor.GRAY + "Click to select the", ChatColor.GRAY + "Free-for-All event.").getItem());
player.openInventory(inv);
}
示例7: open
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void open(Player p)
{
int size = 9;
for (int i = 1; i <= 6; i++)
{
if (9 * i > items.size())
size = 9 * i;
}
Inventory inv = Bukkit.createInventory(null, size, ChatColor.translateAlternateColorCodes('&', title));
p.openInventory(inv);
}
示例8: accept
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void accept(Player player, List<String> args) {
org.bukkit.inventory.ItemStack itemInMainHand = player.getInventory().getItemInMainHand();
if (itemInMainHand == null) {
player.sendMessage(ChatColor.RED + "Put the result of the recipe in your main hand when executing this command.");
return;
}
if (args.isEmpty()) {
player.sendMessage(ChatColor.RED + "Usage: /addrecipe world <key> [<world name>] [<group>]");
return;
}
UUID world = player.getWorld().getUID();
if (args.size() >= 2) {
World bukkitWorld = plugin.getServer().getWorld(args.get(1));
if (bukkitWorld != null) world = bukkitWorld.getUID();
}
String keyString = args.get(0);
String group = args.size() >= 3 ? args.get(2) : "";
NamespacedKey bukkitKey = plugin.getKey(keyString);
ItemStack result = CraftItemStack.asNMSCopy(itemInMainHand);
MinecraftKey key = CraftNamespacedKey.toMinecraft(bukkitKey);
player.openInventory(new WorldRecipeHolder(plugin, result, key, group, player, world).getInventory());
}
示例9: openKitsInventory
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void openKitsInventory(Player player) {
inventory.setItem(11, titaniumKitGlass(player));
inventory.setItem(13, diamondKitGlass(player));
inventory.setItem(15, bardKitGlass(player));
inventory.setItem(29, archerKitGlass(player));
inventory.setItem(31, minerKitGlass(player));
inventory.setItem(33, starterKitGlass(player));
player.playSound(player.getLocation(), Sound.NOTE_SNARE_DRUM, 20, 1);
player.openInventory(inventory);
}
示例10: open
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Opens the gui for a player
*
* @param player player
*/
public void open(Player player) {
if (!this.manager.inventories.containsKey(player)) {
if (player.getOpenInventory() != null) {
player.closeInventory();
}
if (this.manager.headDatabasePlayers.contains(player)) {
this.manager.headDatabasePlayers.remove(player);
}
final Inventory inventory = Bukkit.getServer().createInventory(player, 54, Config.getInstance().getGUITitle());
this.manager.inventories.put(player, inventory);
player.openInventory(inventory);
}
}
示例11: getKnowledgeMain
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public Menu getKnowledgeMain() {
Menu m = new Menu(ChatColor.GOLD + "Book of Knowledge", 45);
Button crafting = new Button(new ItemConstruct(Material.WORKBENCH).getMeta().setName("Recipes").getItem()) {
@Override
public void onClick(Player p, Inventory i) {
p.openInventory(getCraftMainMenu().inv);
}
};
m.addButton(crafting);
m.addItem(crafting.getItem());
Registry.registerListener(m);
return m;
}
示例12: open
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Open the inventory to a player.
*
* @param p The player.
*/
public Inventory open(Player p) {
Inventory inventory = Bukkit.createInventory(null, slots, displayName);
for (Map.Entry<Integer, ItemStack> items : getItems().entrySet())
inventory.setItem(items.getKey(), items.getValue());
p.openInventory(inventory);
return inventory;
}
示例13: setupTypeSelectionMenu
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void setupTypeSelectionMenu(Player player) {
Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BOLD + "Select Tribe Type");
inv.setItem(3, ItemStackGenerator.createItem(Material.DIAMOND_SWORD, 0, 0,
ChatColor.YELLOW + "" + ChatColor.BOLD + "Aesir",
Arrays.asList("Punch damage to everyone in front.")));
inv.setItem(5, ItemStackGenerator.createItem(Material.FIREBALL, 0, 0,
ChatColor.RED + "" + ChatColor.BOLD + "Vanir",
Arrays.asList("Shoots massive damage, but slow fireball.")));
player.openInventory(inv);
}
示例14: openShop
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void openShop(Player player, Gizmo gizmo) {
Inventory inventory = Bukkit.createInventory(player, 54, StringUtils.truncate(ChatColor.GOLD + LobbyTranslations.get().t("gizmos.shopFor", player, gizmo.getColoredName(player)), 32));
inventory.setItem(4, Utils.getGhastTear(player, RaindropsListener.raindrops.get(player)));
inventory.setItem(22, gizmo.getItemStack(player));
ItemStack accept = new ItemStack(Material.DIAMOND);
ItemMeta acceptMeta = accept.getItemMeta();
acceptMeta.setDisplayName(ChatColor.GREEN + LobbyTranslations.get().t("purchase.purchase", player, gizmo.getColoredName(player)));
acceptMeta.setLore(Lists.newArrayList(gizmo.getCostText(player)));
accept.setItemMeta(acceptMeta);
ItemStack exit = new ItemStack(Material.REDSTONE_BLOCK);
ItemMeta exitMeta = exit.getItemMeta();
exitMeta.setDisplayName(ChatColor.RED + LobbyTranslations.get().t("purchase.cancel", player));
exit.setItemMeta(exitMeta);
for(int i = 3; i < 6; i++) {
for(int x = 0; x < 3; x++) {
inventory.setItem(i * 9 + x, accept);
}
for(int y = 6; y < 9; y++) {
inventory.setItem(i * 9 + y, exit);
}
}
player.openInventory(inventory);
}
示例15: openChest
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void openChest(Chest chest, Player p){
AllItems items = new AllItems();
if (cooldown.isCoolingDown(chest)) {
WCTWD.getPlayer(p).sendMessage("&cEste cofre está en cooldown. Tiempo &6" + cooldown.getTimeLeft(chest));
return;
}
cooldown.setOnCooldown(chest);
Inventory inv = Bukkit.createInventory(null, 36, ChatColor.RED + "Cofre de Recursos");
//Ajustar cantidad
int i1 = r.nextInt(3);
int i2 = r.nextInt(3);
int i3 = r.nextInt(2);
ArrayList<ItemStack> aleatorios = new ArrayList<>();
for (int i = 0; i < i1; i++) {
if (r.nextInt(4) > 1) aleatorios.add(items.weapons.get(r.nextInt(items.weapons.size())));
}
for (int i = 0; i < i2; i++) {
if (r.nextInt(4) > 1) aleatorios.add(items.health.get(r.nextInt(items.health.size())));
}
for (int i = 0; i < i3; i++) {
if (r.nextInt(3) == 2) aleatorios.add(items.weapons2.get(r.nextInt(items.weapons2.size())));
}
aleatorios.forEach(i -> setItem(inv, getSlot(r, inv), i));
p.closeInventory();
p.openInventory(inv);
}