Помогите Предмет содержит имя...

  • Автор темы Автор темы Kurumi
  • Дата начала Дата начала
Статус
Закрыто для дальнейших ответов.

Kurumi

Активный участник
Пользователь
Баллы
76
Имя в Minecraft
Kurumi
Всем привет. Например у меня есть предмет, и если его имя test тогда игроку который держит предмет дается эффект. Но мне надо добавить к предмету какое-нибудь еще название, которые проверятся не будет. Это примерно так должно выглядеть "test палка", тобишь если в названии есть надпись test, тогда этот предмет подходит под условие, независимо от того, что написано после test. Как это реализовать?
 
Ну... проверяй есть ли в названии определённое слово.
Код:
if (name.contains("test")){}
Допустим, есть переменная A типа string, ей присваивается из имя из конфига, а потому я уже проверяю
if(p.getEquipment().getHelmet().getItemMeta().getDisplayName().contains(a))
Но все равно, если название палки test палка ничего не работает, а если просто test, тогда работает
 
Скидываю код...
PHP:
 public boolean checkArmor(final String string) {
        return this.plugin.getConfig().getConfigurationSection("Sets." + string) != null;
    }
    
    public void AddEffect() {
        final ItemStack helm = this.player.getEquipment().getHelmet();
        final ItemStack legs = this.player.getEquipment().getLeggings();
        final ItemStack boot = this.player.getEquipment().getBoots();
        final ItemStack chest = this.player.getEquipment().getChestplate();
        if (helm != null && legs != null && boot != null && chest != null) {
            final String[] eff = null;
            final int[] pow = null;
            final String a = helm.getItemMeta().getDisplayName();
            final boolean s = this.checkArmor(a);
            final List<String> a2 = (List<String>)this.plugin.getConfig().getStringList("Sets." + a + ".effects");
            if (s && helm.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".helmet") && helm.getItemMeta().getDisplayName().contains(a) && legs.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".leggings") && legs.getItemMeta().getDisplayName().contains(a) && boot.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".boots") && boot.getItemMeta().getDisplayName().contains(a) && chest.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".chestplate") && chest.getItemMeta().getDisplayName().contains(a)) {
                for (final String a3 : this.plugin.getConfig().getStringList("Sets." + a + ".effects")) {
                    final String fa = a3;
                    final String d = " ";
                    final String[] a4 = a3.split(d);
                    this.player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(a4[0]), 120, Integer.parseInt(a4[1])), true);
                }
            }
        }
    }
 
Скидываю код...
PHP:
 public boolean checkArmor(final String string) {
        return this.plugin.getConfig().getConfigurationSection("Sets." + string) != null;
    }
   
    public void AddEffect() {
        final ItemStack helm = this.player.getEquipment().getHelmet();
        final ItemStack legs = this.player.getEquipment().getLeggings();
        final ItemStack boot = this.player.getEquipment().getBoots();
        final ItemStack chest = this.player.getEquipment().getChestplate();
        if (helm != null && legs != null && boot != null && chest != null) {
            final String[] eff = null;
            final int[] pow = null;
            final String a = helm.getItemMeta().getDisplayName();
            final boolean s = this.checkArmor(a);
            final List<String> a2 = (List<String>)this.plugin.getConfig().getStringList("Sets." + a + ".effects");
            if (s && helm.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".helmet") && helm.getItemMeta().getDisplayName().contains(a) && legs.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".leggings") && legs.getItemMeta().getDisplayName().contains(a) && boot.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".boots") && boot.getItemMeta().getDisplayName().contains(a) && chest.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".chestplate") && chest.getItemMeta().getDisplayName().contains(a)) {
                for (final String a3 : this.plugin.getConfig().getStringList("Sets." + a + ".effects")) {
                    final String fa = a3;
                    final String d = " ";
                    final String[] a4 = a3.split(d);
                    this.player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(a4[0]), 120, Integer.parseInt(a4[1])), true);
                }
            }
        }
    }
Ну ты и говноед конечно
 
Он прав, тут у тебя реально дико.
Скинь ТОЛЬКО часть, ответственную за анализ имени предмета
PHP:
 public boolean checkArmor(final String string) {
        return this.plugin.getConfig().getConfigurationSection("Sets." + string) != null;
    }
        final ItemStack helm = this.player.getEquipment().getHelmet();
        final ItemStack legs = this.player.getEquipment().getLeggings();
        final ItemStack boot = this.player.getEquipment().getBoots();
        final ItemStack chest = this.player.getEquipment().getChestplate();
        final String a = helm.getItemMeta().getDisplayName();
        final boolean s = this.checkArmor(a);

if (s && helm.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".helmet") && helm.getItemMeta().getDisplayName().contains(a) && legs.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".leggings") && legs.getItemMeta().getDisplayName().contains(a) && boot.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".boots") && boot.getItemMeta().getDisplayName().contains(a) && chest.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".chestplate") && chest.getItemMeta().getDisplayName().contains(a)) {
 
PHP:
 public boolean checkArmor(final String string) {
        return this.plugin.getConfig().getConfigurationSection("Sets." + string) != null;
    }
        final ItemStack helm = this.player.getEquipment().getHelmet();
        final ItemStack legs = this.player.getEquipment().getLeggings();
        final ItemStack boot = this.player.getEquipment().getBoots();
        final ItemStack chest = this.player.getEquipment().getChestplate();
        final String a = helm.getItemMeta().getDisplayName();
        final boolean s = this.checkArmor(a);

if (s && helm.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".helmet") && helm.getItemMeta().getDisplayName().contains(a) && legs.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".leggings") && legs.getItemMeta().getDisplayName().contains(a) && boot.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".boots") && boot.getItemMeta().getDisplayName().contains(a) && chest.getTypeId() == this.plugin.getConfig().getInt("Sets." + a + ".chestplate") && chest.getItemMeta().getDisplayName().contains(a)) {
А нет equals использовать для проверки строк ? Так же можешь разбивать строки и сравнивать определенную часть строки
 
Статус
Закрыто для дальнейших ответов.
Назад
Верх