- Баллы
- 123
.
Последнее редактирование:
Следуйте инструкциям в видео ниже, чтобы узнать, как установить наш сайт как веб-приложение на главный экран вашего устройства.
Примечание: Эта функция может быть недоступна в некоторых браузерах.
Да вроде подойдет...getBlock().getState()?
chest.getInventory().getName()
Вот, что я нашёл на англоведреДа вроде подойдет...
Но возникла другая проблема...
У этого сундука который я получил в Chest имя должно быть &aКейс
но когда я делаю такто метод возвращает не "&aКейс" а "container.chest" Как вернуть именно имя сундука?Код:chest.getInventory().getName()
CraftChest chest = (CraftChest) block.getState(); //block has to be a chest
try
{
Field inventoryField = chest.getClass().getDeclaredField("chest"); //This get's the CraftChest variable 'chest' which is the TileEntityChest that is stored within it
inventoryField.setAccessible(true); //Allows you to access that field since it's declared as private
TileEntityChest teChest = ((TileEntityChest) inventoryField.get(chest)); //obtains the field and casts it to a TileEntityChest
teChest.a("Name Goes Here"); //The a(String) method sets the title of the chest
}
catch (Exception e) //This has to be here as the getDeclaredField(String) throws an exception if the input doesn't exist in the given class
{
e.printStackTrace();
}
Сначала я ничего не понял,Вот, что я нашёл на англоведре
Java:CraftChest chest = (CraftChest) block.getState(); //block has to be a chest try { Field inventoryField = chest.getClass().getDeclaredField("chest"); //This get's the CraftChest variable 'chest' which is the TileEntityChest that is stored within it inventoryField.setAccessible(true); //Allows you to access that field since it's declared as private TileEntityChest teChest = ((TileEntityChest) inventoryField.get(chest)); //obtains the field and casts it to a TileEntityChest teChest.a("Name Goes Here"); //The a(String) method sets the title of the chest } catch (Exception e) //This has to be here as the getDeclaredField(String) throws an exception if the input doesn't exist in the given class { e.printStackTrace(); }
У меня всегда имя сундука возвращало :/Да вроде подойдет...
Но возникла другая проблема...
У этого сундука который я получил в Chest имя должно быть &aКейс
но когда я делаю такто метод возвращает не "&aКейс" а "container.chest" Как вернуть именно имя сундука?Код:chest.getInventory().getName()
Эм... Ну тогда я вообще ничего не понял...У меня всегда имя сундука возвращало :/
лучше бы понял) ничего особо сложного нет. просто у сундука тайлэнтити, видимо, приватная, этот код дает к ней доступ, достает ее и берет оттуда имя. только неужели нет нормального способа получить энтити сундука?)Эм... Ну тогда я вообще ничего не понял...
Эээ... Ага...лучше бы понял) ничего особо сложного нет. просто у сундука тайлэнтити, видимо, приватная, этот код дает к ней доступ, достает ее и берет оттуда имя. только неужели нет нормального способа получить энтити сундука?)
} else if (cmd.getName().equalsIgnoreCase("getCase")) {
if (player.hasPermission("opencase.getcase")) {
if (args.length == 0) {
ItemStack item = new ItemStack(Material.CHEST);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(chestCase);
ArrayList<String> lore = new ArrayList<String>();
lore.add(chestCaseLore);
meta.setLore(lore);
meta.addEnchant(Enchantment.DURABILITY, 1, true);
item.setItemMeta(meta);
player.getInventory().setItemInHand(item);
return true;
protected String chestCase = ChatColor.translateAlternateColorCodes('&', "&aКейс");
protected String chestCaseLore = ChatColor.translateAlternateColorCodes('&', "&a&lОружейный кейс");
Ну так ты ставишь displayName, а пытаешься получить Name...Ну в принципе выставлял... Если я правильно Вас понял, якейссундук с именем получаю командой, и мне прилетает сундук с установленным именем...
Код:} else if (cmd.getName().equalsIgnoreCase("getCase")) { if (player.hasPermission("opencase.getcase")) { if (args.length == 0) { ItemStack item = new ItemStack(Material.CHEST); ItemMeta meta = item.getItemMeta(); meta.setDisplayName(chestCase); ArrayList<String> lore = new ArrayList<String>(); lore.add(chestCaseLore); meta.setLore(lore); meta.addEnchant(Enchantment.DURABILITY, 1, true); item.setItemMeta(meta); player.getInventory().setItemInHand(item); return true;
Код:protected String chestCase = ChatColor.translateAlternateColorCodes('&', "&aКейс"); protected String chestCaseLore = ChatColor.translateAlternateColorCodes('&', "&a&lОружейный кейс");
Ну и в самом майне видно что у него имя есть...
Ыыы... Это не одно и тоже?...Ну так ты ставишь displayName, а пытаешься получить Name...
Сундук.getMetadata().getDisplayName()Ыыы... Это не одно и тоже?...
Метода setName я не нашел...
Ну и метода getDisplayName я не нашел также...
Возможно, но...Сундук.getMetadata().getDisplayName()
Так можете ответить?Сундук.getMetadata().getDisplayName()
displayName - это название предмета в инвентареЫыы... Это не одно и тоже?...
Метода setName я не нашел...
Ну и метода getDisplayName я не нашел также...
Chest ch = (Chest)block.getState();
ch.getBlockInventory().getTitle();
//или
ch.getBlockInventory().getName();
Второе возвращает "container.chest" первое попробую..displayName - это название предмета в инвентаре
попробуй:
JavaScript:Chest ch = (Chest)block.getState(); ch.getBlockInventory().getTitle(); //или ch.getBlockInventory().getName();
Омг, ты шутишь что-ли?Второе возвращает "container.chest" первое попробую..
И getTitle() и getName() возвращает "container.chest"...
Ну кааак мне получить DisplayName()?![]()
С русским запросом, или по английски?Омг, ты шутишь что-ли?
Сидеть несколько дней над такой херней когда в первой строке гугла есть ответ... Мде..
Конечно по-английски.С русским запросом, или по английски?