Gun

Discussion in 'Plugin Development' started by NoSpanMan, Oct 4, 2015.

Thread Status:
Not open for further replies.
  1. You have to add it by yourself.
     
  2. Offline

    NoSpanMan

    @MaTaMoR_ But how can i find the shooter and the one where the snowball is hitting with getSomething(); ?
     
  3. See my code, there i get the damager and the damaged.
     
  4. Offline

    NoSpanMan

    @MaTaMoR_ Yes i read it but i don't understand in your code how i can check if he is in the red team the shooter and the one that gets shooted en then cancel the damage. Can you please help :D?
     
  5. On my code you have two players, damager and damaged, check if them are on the same list.
     
  6. Offline

    NoSpanMan

    @MaTaMoR_ But you name it all damager..... So what is the shooter and what is the one that get shooted.
     
  7. mb, i fixed it.
     
  8. Offline

    NoSpanMan

    I registered my on spigotmc and i have the right answer in 10 minutes....
     
  9. Offline

    boomboompower

    Zombie_Striker likes this.
  10. Offline

    NoSpanMan

    I have an error when i shoot somebody?
    Code:
    03.11 20:47:55 [Server] INFO ... 23 more
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45]
    03.11 20:47:55 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45]
    03.11 20:47:55 [Server] INFO at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source) ~[?:?]
    03.11 20:47:55 [Server] INFO at me.koekjeee.debugger.Main.PlayerDamageReceive(Main.java:591) ~[?:?]
    03.11 20:47:55 [Server] INFO Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.entity.CraftSnowball cannot be cast to org.bukkit.entity.Player
    03.11 20:47:55 [Server] INFO at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:536) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:628) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:726) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.WorldServer.tickEntities(WorldServer.java:560) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.World.tickEntities(World.java:1269) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.World.g(World.java:1398) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.World.entityJoinedWorld(World.java:1420) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityProjectile.t_(EntityProjectile.java:154) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntitySnowball.a(SourceFile:30) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityPlayer.damageEntity(EntityPlayer.java:481) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityHuman.damageEntity(EntityHuman.java:794) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityLiving.damageEntity(EntityLiving.java:732) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityHuman.d(EntityHuman.java:853) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityLiving.d(EntityLiving.java:1091) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.handleLivingEntityDamageEvent(CraftEventFactory.java:567) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.handleEntityDamageEvent(CraftEventFactory.java:448) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEntityDamageEvent(CraftEventFactory.java:535) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEvent(CraftEventFactory.java:85) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO org.bukkit.event.EventException
    03.11 20:47:55 [Server] ERROR Could not pass event EntityDamageByEntityEvent to Debugger v1.0
    03.11 20:47:55 [Server] INFO ... 23 more
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45]
    03.11 20:47:55 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45]
    03.11 20:47:55 [Server] INFO at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) ~[?:?]
    03.11 20:47:55 [Server] INFO at me.koekjeee.debugger.Main.onDamage(Main.java:624) ~[?:?]
    03.11 20:47:55 [Server] INFO Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.entity.CraftSnowball cannot be cast to org.bukkit.entity.Player
    03.11 20:47:55 [Server] INFO at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:536) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:628) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:726) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.WorldServer.tickEntities(WorldServer.java:560) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.World.tickEntities(World.java:1269) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.World.g(World.java:1398) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.World.entityJoinedWorld(World.java:1420) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityProjectile.t_(EntityProjectile.java:154) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntitySnowball.a(SourceFile:30) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityPlayer.damageEntity(EntityPlayer.java:481) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityHuman.damageEntity(EntityHuman.java:794) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityLiving.damageEntity(EntityLiving.java:732) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityHuman.d(EntityHuman.java:853) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at net.minecraft.server.v1_8_R3.EntityLiving.d(EntityLiving.java:1091) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.handleLivingEntityDamageEvent(CraftEventFactory.java:567) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.handleEntityDamageEvent(CraftEventFactory.java:448) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEntityDamageEvent(CraftEventFactory.java:535) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEvent(CraftEventFactory.java:85) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[craftbukkit-1.8.8.jar:git-Bukkit-de5c261]
    03.11 20:47:55 [Server] INFO org.bukkit.event.EventException
    03.11 20:47:55 [Server] ERROR Could not pass event EntityDamageByEntityEvent to Debugger v1.0
    
    And the code:
    Code:
      @EventHandler(priority = EventPriority.NORMAL)
      public void PlayerDamageReceive(EntityDamageByEntityEvent e) {
      if(e.getEntity() instanceof Player) {
      Player damaged = (Player) e.getEntity();
       
      if(e.getDamager() instanceof Player || e.getDamager() instanceof Snowball) {
      Player damager = (Player) e.getDamager();
       
      if((damaged.getHealth()-e.getDamage()) < 5) {
       
      //Killed
       
      if(inBuggs.contains(damaged.getName())) {
             World w = Bukkit.getServer().getWorld(getConfig().getString("spawnB.world"));
             int x = getConfig().getInt("spawnB.x");
             int y = getConfig().getInt("spawnB.y");
             int z = getConfig().getInt("spawnB.z");
             damaged.teleport(new Location(w, x, y, z));
      e.setCancelled(true);
      damaged.setHealth(20);
      sendMessage(DB + damaged.getName() + " was killed by " + damager.getName());
      } else if(inDevs.contains(damaged.getName())) {
             World w = Bukkit.getServer().getWorld(getConfig().getString("spawnD.world"));
             int x = getConfig().getInt("spawnD.x");
             int y = getConfig().getInt("spawnD.y");
             int z = getConfig().getInt("spawnD.z");
             damaged.teleport(new Location(w, x, y, z));
             buggscore--;
      e.setCancelled(true);
      damaged.setHealth(20);
      sendMessage(DB + damaged.getName() + " was killed by " + damager.getName());
      }
      }
      }
      }
      }
    
     
  11. Offline

    Zombie_Striker

    03.11 20:47:55 [Server] INFO at me.koekjeee.debugger.Main.PlayerDamageReceive(Main.java:591) ~[?:?]

    What is line 591 of the "Main" (SO MANY PEOPLE NAMING THEIR CLASS MAIN. WHY?!!?)
     
  12. Offline

    87pen

  13. Offline

    RoboticPlayer

    @87pen Just because people use it in tutorials doesn't mean that it's right. People should know Java before getting into Bukkit. In learning Java you should learn the Java Naming Conventions. Straight from oracle about class naming:

    Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).

    Source: http://www.oracle.com/technetwork/java/codeconventions-135099.html
     
    Zombie_Striker likes this.
  14. Offline

    Zombie_Striker

    @87pen
    As @henderry2019 said, they are wrong. You know what else tutorials do? Here's a list (and if you do something that is on this list, you might want to change that ):
    • Create plugins called "plugin"
    • Have Upper case letters in the Package
    • Have a class called "main"
    • STEAL THE LOGGER (big no no)
    • Create their OWN enable/disable messages
    • Have onDisabled that is empty
    • Use an instance only once.
    • Store player fields in hashmaps, or arrays. And then not clear them out.
     
  15. Offline

    RoboticPlayer

    * Use a field/variable only once
    * Store player object in HashMaps/ArrayLists

    Also, I often see a creation of two local variables which are identical instead of just creating a field. For example:
    Code:java
    1. // Many "tutorials" will do this
    2. public void onEnable() {
    3. Logger log = Bukkit.getServer().getLogger("Minecraft");
    4. log.info("[Pluginname] has been enabled!");
    5. }
    6.  
    7. public void onDisable() {
    8. Logger log = Bukkit.getServer().getLogger("Minecraft");
    9. log.info("[Pluginname] has been disabled!");
    10. }
    11. // Instead of just doing this
    12. Logger log = this.getLogger();
    13. public void onEnable() {
    14. log.info("[Pluginname] has been enabled!");
    15. }
    16.  
    17. public void onDisable() {
    18. log.info("[Pluginname] has been disabled!");
    19. }

    The first example is so wrong and it's just a little sliver of many things.
    1) onEnable and onDisable can be overriden
    2) Create a field instead of two identical local variables!
    3) Stop stealing Minecraft's logger!
    4) No need to log onEnable/Disable messages, BUKKIT ALREADY DOES THIS!
    5) Due to part 4, no need for the onEnable or onDisable methods at all in this case

    I also often see onCommand methods returning false, not overriding the method, checking commandLabel instead of cmd.getName(), etc.
     
  16. Offline

    87pen

    @henderry2019
    ahhhhhhhhhhhhhhhhhhhhhhhhh Woah calm down, I didn't say bad naming convention are good. -.- I just pointed out that video tutorials are the source of the naming their classes Main. I did not approve of it just pointed out the source. All those are just bad programming habbits. I would suggest reading what my original message said rather than automatically assuming I am supporting bad programming and naming habbits.
     
    Last edited: Nov 3, 2015
  17. Offline

    Scimiguy

    @87pen
    I would assume the same thing based on what you said. It did seem to be supporting it
     
  18. Offline

    87pen

    A lot of tutorials (Video Tutorials) for the bukkit API seem to use main as their class name.

    This was the question I responded to, To me my answer does not even reference supporting bad programming and naming conventions. I simply stated that video tutorials use main as their class name.
     
  19. Offline

    NoSpanMan

    Code:
    Player damager = (Player) e.getDamager();
    
     
  20. Offline

    87pen

    You are casting Type player to a snowball
     
  21. Offline

    NoSpanMan

    Yeah but how can i let it happen now that this code runs without errors :/.
     
  22. Offline

    Zombie_Striker

    @NoSpanMan
    Well, when you want something to be a player, but you don't know if it is a player, you check it.
     
  23. Offline

    NoSpanMan

    Code:
    Player damaged = ((Player) e.getEntity());
    
    This line isn't good but i don't kwow what? (i think i see over it :p)
     
  24. Offline

    Zombie_Striker

    @NoSpanMan
    Well, how do you know that entity is a player? Does your code check if that entity is an instance of a Player?
     
  25. Offline

    NoSpanMan

    Code:
      @EventHandler
      public void onEntityDamage(EntityDamageByEntityEvent e) {
      if (e.getDamager() instanceof Snowball) {
      Snowball s = (Snowball) e.getDamager();
      if (s.getShooter() instanceof Player) {
         Player damaged = ((Player) e.getEntity());
         Player shooter = ((Player) s.getShooter());
           if(inDevs.contains(shooter.getName())) {
             if(inDevs.contains(damaged.getName()) ){
               shooter.sendMessage(DB + "Dont hurt your teammates!");
               e.setCancelled(true);
             } else {
               e.setDamage(8.0);
             }
           }
      }
      }
    }
    
    Code:
    [07:41:39 ERROR]: Could not pass event EntityDamageByEntityEvent to Debugger v1.0
    org.bukkit.event.EventException
      at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[craftbukkit.jar:git-Bukkit-f27339c]
      at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-f27339c]
      at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit.jar:git-Bukkit-f27339c]
      at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-f27339c]
      at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEvent(CraftEventFactory.java:85) [craftbukkit.jar:git-Bukkit-f27339c]
      at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callEntityDamageEvent(CraftEventFactory.java:522) [craftbukkit.jar:git-Bukkit-f27339c]
      at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.handleEntityDamageEvent(CraftEventFactory.java:435) [craftbukkit.jar:git-Bukkit-f27339c]
      at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.handleLivingEntityDamageEvent(CraftEventFactory.java:554) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.EntityLiving.d(EntityLiving.java:1091) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.EntityLiving.damageEntity(EntityLiving.java:732) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.EntityHuman.attack(EntityHuman.java:995) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.EntityPlayer.attack(EntityPlayer.java:1048) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1262) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.a(SourceFile:52) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.a(SourceFile:11) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit.jar:git-Bukkit-f27339c]
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_65]
      at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_65]
      at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:19) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:676) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:632) [craftbukkit.jar:git-Bukkit-f27339c]
      at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:540) [craftbukkit.jar:git-Bukkit-f27339c]
      at java.lang.Thread.run(Unknown Source) [?:1.8.0_65]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R3.entity.CraftPig cannot be cast to org.bukkit.entity.Player
      at me.koekjeee.debugger.Main.onDamage(Main.java:629) ~[?:?]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65]
      at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65]
      at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[craftbukkit.jar:git-Bukkit-f27339c]
    
    
    Yeah i check. After that is the wrong line.
     
  26. Offline

    Lordloss

    Code:
    Player damaged = ((Player) e.getEntity());
    You are casting the entity hit to a player without checking if it is a player.
    In this case youre trying to cast a pig to a player, which seems to not work so well. Check if e.getEntity() is an instanceof Player, and if not return;

    And please learn to read stacktraces, its not as hard as most people think it is.
     
  27. Offline

    mcdorli

    You literally said no to scimiguy, because you only check the entity, not the player. Blind casting is very dangerous, always check the return type of the methods.
     
  28. Offline

    NoSpanMan

    But if i check it if its a player can i still use it then for my p.sendmessage with the players name?
     
  29. Offline

    Scimiguy

Thread Status:
Not open for further replies.

Share This Page