Solved DIsplaying a text over (or under) player's nametag

Discussion in 'Plugin Development' started by nzkiwi.5000, Aug 13, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    nzkiwi.5000

    Hello forumers,
    I'm making a plugin showing damage dealt on hit, i looks like a red negative number showing amount of damage for a while, and some other information like "Critical!" (Who played TF2 knows what i'm talking about), so i have it working for LivingEntities (except Players) (setting custom name), but have a algorithm looked up from filoghost's HealthBar. Problem is I don't fully understand his way of displaying the custom text under nickname.
    Here's some code:
    Code:java
    1. public void onEnable(){
    2. //enable stuff
    3. sc = Bukkit.getScoreboardManager().getMainScoreboard();
    4.  
    5. dmgObjective = sc.registerNewObjective(scObjectiveName, "dummy");
    6. dmgObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
    7. dmgObjective.setDisplayName("HP");
    8. }
    9. public void onDisable(){
    10. sc.getObjective(DisplaySlot.BELOW_NAME).unregister();
    11. }

    Code:java
    1. public class Listeners implements Listener {
    2.  
    3. public int timeout = 20;
    4.  
    5. @EventHandler
    6. public void entityDamage(final EntityDamageByEntityEvent ede){
    7. System.out.println("FIRING EDE");
    8. if(ede.getEntityType().equals(EntityType.PLAYER)){
    9. System.out.println("player");
    10. SCtest.dmgObjective.getScore(((Player) ede.getDamager()).getName()).setScore(-9);
    11. Bukkit.getScheduler().runTaskLater(SCtest.instance, new Runnable(){
    12. @Override
    13. public void run() {
    14. SCtest.dmgObjective.getScore(((Player) ede.getDamager()).getName()).setScore(0);
    15.  
    16. }
    17. }, timeout);
    18. }else{
    19. final LivingEntity mob = (LivingEntity) ede.getEntity();
    20. mob.setCustomName(SCtest.cmsg("&4&o&l-"+ede.getDamage()+"/"+mob.getHealth()));
    21. mob.setCustomNameVisible(true);
    22. Bukkit.getScheduler().runTaskLater(SCtest.instance, new Runnable(){
    23. @Override
    24. public void run() {
    25. mob.setCustomName(null);
    26. mob.setCustomNameVisible(false);
    27. }
    28. }, timeout);
    29. }
    30. }
    31.  
    32. }


    Here's the error, coming up when replacing DisplaySlot with SIDEBAR:
    Code:
    [23:02:21 INFO]: FIRING EDE
    [23:02:21 INFO]: player
    [23:02:21 ERROR]: Could not pass event EntityDamageByEntityEvent to SCTest v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEvent(Craf
    tEventFactory.java:94) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityDama
    geEvent(CraftEventFactory.java:382) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974
    jnks]
            at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.handleEntityDa
    mageEvent(CraftEventFactory.java:410) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b29
    74jnks]
            at net.minecraft.server.v1_7_R1.EntityLiving.damageEntity(EntityLiving.j
    ava:656) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.EntityHuman.damageEntity(EntityHuman.jav
    a:746) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.EntityPlayer.damageEntity(EntityPlayer.j
    ava:446) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.EntityHuman.attack(EntityHuman.java:918)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :1092) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInUseEntity.a(SourceFile:55) [
    craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInUseEntity.handle(SourceFile:
    10) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    Caused by: java.lang.NoSuchMethodError: org.bukkit.scoreboard.Objective.getScore
    (Ljava/lang/String;)Lorg/bukkit/scoreboard/Score;
            at sctest.Listenery.entityDamage(Listenery.java:21) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
    _65]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
    _65]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_65]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_65]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            ... 20 more
    I'm using Craftbukkit, and here's the project's build path
    [​IMG]
     
  2. Offline

    bwfcwalshy Retired Staff

    nzkiwi.5000 Remove a bukkit jar you only want one. Also one is 1.7.2 and one is 1.7.10 remove the craftbukkit.jar.
     
  3. Offline

    nzkiwi.5000


    @bwfcwalshyWhat do you mean by that? Remove Craftbukkit from Build Path, and make same version oc BuildPath's bukkit jar and server engine?
     
  4. Offline

    Rocoty

    Just update your craftbukkit on your server. You are running an old version
     
    nzkiwi.5000 likes this.
  5. Offline

    Skulled

    Caused by: java.lang.NoSuchMethodError: org.bukkit.scoreboard.Objective.getScore
    (Ljava/lang/String;)Lorg/bukkit/scoreboard/Score;
     
  6. Offline

    nzkiwi.5000

Thread Status:
Not open for further replies.

Share This Page