1. Этот сайт использует файлы cookie. Продолжая пользоваться данным сайтом, Вы соглашаетесь на использование нами Ваших файлов cookie. Узнать больше.
  2. Вы находитесь в сообществе Rubukkit. Мы - администраторы серверов Minecraft, разрабатываем собственные плагины и переводим на различные языки плагины наших коллег из других стран.
    Скрыть объявление
Скрыть объявление
В преддверии глобального обновления, мы проводим исследования, которые помогут нам сделать опыт пользования форумом ещё удобнее. Помогите нам, примите участие!

Помогите Ошибка :(

Тема в разделе "Разработка плагинов для новичков", создана пользователем AxmeD, 11 июн 2013.

Статус темы:
Закрыта.
  1. Автор темы
    AxmeD

    AxmeD Старожил Пользователь

    Баллы:
    103
    Выдаёт ошибку, когда кто-то убивает мобов, либо просто так.
    Ошибка:
    Код:
    15:54:56 [SEVERE] Could not pass event EntityDeathEvent to AxmeDRP v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:363)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:479)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:464)
            at org.bukkit.craftbukkit.v1_5_R3.event.CraftEventFactory.callEntityDeat
    hEvent(CraftEventFactory.java:304)
            at net.minecraft.entity.passive.EntityCow.func_70628_a(EntityCow.java:12
    3)
            at net.minecraft.entity.EntityLiving.func_70645_a(EntityLiving.java:1386
    )
            at net.minecraft.entity.EntityLiving.func_70097_a(EntityLiving.java:1166
    )
            at net.minecraft.entity.passive.EntityAnimal.func_70097_a(SourceFile:119
    )
            at net.minecraft.entity.player.EntityPlayer.func_71059_n(EntityPlayer.ja
    va:1411)
            at net.minecraft.network.NetServerHandler.func_72507_a(NetServerHandler.
    java:1574)
            at net.minecraft.network.packet.Packet7UseEntity.func_73279_a(SourceFile
    :36)
            at org.spigotmc.netty.NettyNetworkManager.func_74428_b(NettyNetworkManag
    er.java:191)
            at net.minecraft.network.NetServerHandler.func_72570_d(NetServerHandler.
    java:213)
            at net.minecraft.network.NetworkListenThread.func_71747_b(NetworkListenT
    hread.java:53)
            at org.spigotmc.netty.NettyServerConnection.func_71747_b(NettyServerConn
    ection.java:68)
            at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.jav
    a:926)
            at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(Dedicated
    Server.java:324)
            at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.jav
    a:794)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:678)
            at net.minecraft.server.ThreadMinecraftServer.run(SourceFile:573)
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_5_R3.entity.C
    raftCow cannot be cast to org.bukkit.entity.Player
            at ru.axmed.rp.AxmeDRP.onEntityDeathByEntity(AxmeDRP.java:82)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:361)
            ... 20 more
    >
    Код:
    Код:
        @EventHandler
        public void onEntityDeath(EntityDeathEvent e){
            Entity ent = e.getEntity();
            Entity killer = e.getEntity().getKiller();
            if (ent instanceof Player && killer instanceof Player) {
            final Player kil = (Player)killer;
            final File fileConf = new File(getDataFolder(), "config.yml");
            final FileConfiguration conf = YamlConfiguration.loadConfiguration(fileConf);
            if(this.getConfig().getInt("Guards.wanted." + kil.getName()) < 4){
            kil.sendMessage(ChatColor.YELLOW + "Вы попали в розыск!");
            this.getConfig().set("Guards.wanted." + kil.getName(), 4);
            this.saveConfig();
            Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask(this, new Runnable(){
                @Override
                public void run(){
                    if(kil.isOnline()){
                    this.getConfig().set("Guards.wanted." + kil.getName(), 0);
                    kil.sendMessage(ChatColor.YELLOW + "Вы скрылись от стражи!");
                    this.saveConfig();
                    }
                }
                    private void saveConfig() {
                        try {
                            conf.save(fileConf);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
     
                private MemorySection getConfig() {
                    conf.get("fileConf");
                    return conf;
                }
            }, 800 * 10);
            }
        }
        }
     
  2. Den_Abr

    Den_Abr Старожил Девелопер Пользователь

    Баллы:
    173
    Skype:
    Den_Abr
    Имя в Minecraft:
    Den_Abr
    Ты не тот метод скинул. Ошибка в onEntityDeathByEntity
     
  3. Автор темы
    AxmeD

    AxmeD Старожил Пользователь

    Баллы:
    103

    Код:
    @EventHandler
        public void onEntityDeathByEntity(EntityDeathEvent e) {
            Entity ent = e.getEntity();
            Player killer = ((Player)ent).getKiller();
            if (ent instanceof Player && killer instanceof Player) {
            if(this.getConfig().getBoolean("Assassins.targets." + ((Player)ent).getName()) == true){
                ((Player)ent).sendMessage(ChatColor.YELLOW + "Вы были убиты Ассасином по заказу.");
                killer.sendMessage(ChatColor.YELLOW + "Вы выполнили заказ!");
                ItemStack Assassc = new ItemStack(GoldCoin, 1);
                killer.getInventory().addItem(Assassc);
                this.getConfig().set("Assassins.targets." + ((Player)ent).getName(), false);
                this.saveConfig();
                  }
            }
        }

    И вот вторая ошибка
    Код:
    17:31:34 [SEVERE] Could not pass event EntityDeathEvent to AxmeDRP v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:363)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:479)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:464)
            at org.bukkit.craftbukkit.v1_5_R3.event.CraftEventFactory.callEntityDeat
    hEvent(CraftEventFactory.java:304)
            at net.minecraft.entity.EntityLiving.func_70628_a(EntityLiving.java:1473
    )
            at net.minecraft.entity.EntityLiving.func_70645_a(EntityLiving.java:1386
    )
            at net.minecraft.entity.EntityLiving.func_70097_a(EntityLiving.java:1166
    )
            at net.minecraft.entity.passive.EntityAnimal.func_70097_a(SourceFile:119
    )
            at simplyhorses.common.entities.horses.EntityHorseSH.func_70652_k(Entity
    HorseSH.java:501)
            at simplyhorses.common.entities.horses.EntityAIDefendHerdSH.attackEntity
    (EntityAIDefendHerdSH.java:160)
            at simplyhorses.common.entities.horses.EntityAIDefendHerdSH.func_75246_d
    (EntityAIDefendHerdSH.java:81)
            at net.minecraft.entity.ai.EntityAITasks.func_75774_a(EntityAITasks.java
    :131)
            at net.minecraft.entity.EntityLiving.func_70619_bc(EntityLiving.java:224
    4)
            at simplyhorses.common.entities.horses.EntityHorseSH.func_70619_bc(Entit
    yHorseSH.java:178)
            at net.minecraft.entity.EntityLiving.func_70636_d(EntityLiving.java:1947
    )
            at net.minecraft.entity.EntityAgeable.func_70636_d(EntityAgeable.java:11
    5)
            at net.minecraft.entity.passive.EntityAnimal.func_70636_d(SourceFile:30)
     
            at simplyhorses.common.entities.horses.EntityHorseSH.func_70636_d(Entity
    HorseSH.java:201)
            at simplyhorses.common.entities.horses.EntityHorseWildSH.func_70636_d(En
    tityHorseWildSH.java:119)
            at net.minecraft.entity.EntityLiving.func_70071_h_(EntityLiving.java:866
    )
            at net.minecraft.world.World.func_72866_a(World.java:2432)
            at net.minecraft.world.WorldServer.func_72866_a(WorldServer.java:922)
            at net.minecraft.world.World.func_72870_g(World.java:2385)
            at net.minecraft.world.World.func_72939_s(World.java:2197)
            at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:787)
            at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.jav
    a:898)
            at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(Dedicated
    Server.java:324)
            at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.jav
    a:794)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:678)
            at net.minecraft.server.ThreadMinecraftServer.run(SourceFile:573)
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_5_R3.entity.C
    raftAnimals cannot be cast to org.bukkit.entity.Player
            at ru.axmed.rp.AxmeDRP.onEntityDeath(AxmeDRP.java:98)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:361)
            ... 30 more

    Всё, от ошибки избавился :D
    Надо было сначала проверить игрок ли ent, а потом уже прописывать Player killer = ((Player)ent.getKiller();
    И после этого проверять игрок ли killer.
     
Статус темы:
Закрыта.

Поделиться этой страницей