Outputting something than expected!

Discussion in 'Plugin Development' started by DJ_Amos123, Jul 7, 2013.

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


    It should say '[PW] SnowBallGuy has hit HitPlayer'
    but it says:
    'HitPlayer has died'
    '[PW] CraftPlayer{name=RealNameHere} has hit HitPlayer'

    1. How do I get the 'CraftPlayer{name=RealNameHere}' to become JustTheirName.
    2. Stop double message. Sometimes this becomes 3 messages...
    Updated on 08/07/2013: http://screencloud.net/v/yLU8

    UPDATE: Added your code TheTrixsta, but now it doesn't print anything out in-game.
    No errors. It just does nothing. (Updated code below in GitHub)

    Here's the GitPage:
    (I'm new at Java so please make 'easy-to-follow' help :))
    Thanks, Amos.
  2. Offline


    Cancel the death message through the PlayerDeathEvent, then just set the death message to null.

    Where does the '0.0' come from?

    Edit: Ok I see

    2. @EventHandler
    3. public void onPaintballHit(EntityDamageByEntityEvent event) {
    4. if (e.getEntity() instanceof Player && e.getDamager() instanceof Snowball) {
    5. Player ent = (Player) e.getEntity();
    6. Snowball damager = (Player) e.getDamager();
    7. if (damager.getShooter() instanceof Player) {
    8. Player shooter = (Player) damager.getShooter();
    9. ent.setHealth(0);
    10. ent.getServer().broadcastMessage(ChatColor.GREEN + "[PW]" + ChatColor.RED + shooter.getName() + ChatColor.GRAY + " Has hit " + ChatColor.RED + ent.getName());
    11. }
    12. }
    13. }
  3. Offline


    The 0.0 used to come from the get.Damage() I fixed it, by replacing it with get.Damager()

    Got a fix for the 'CraftSnowBall' issue?
  4. Offline


    what do you want to do with CraftSnowBall? Why not just use Snowball
    Minnymin3 likes this.
  5. Offline


    I want it to say somthing like:
    [PW] DJ_Amos123 has hit The_Ms
    But 'DJ_Amos123' is replaced with CraftSnowBall, I have no idea why..
  6. Offline


    Instead of e.getDamager() you need to do something along the lines of e.getDamager().getType().toString() which should give you 'snowball'

    To get the thrower's name, you need projectile.getShooter().getName() (after making sure the shooter is in fact a player)
  7. Offline


  8. Offline


  9. Offline


    You could also set the death message to what you are trying to broadcast.
    For the problem that it prints Craftplayer{etc}, that shouldn't happen and might be a bug in bukkit ?

    You should also register your class as a listener like this in your onEnable method:
    this.getServer().getPluginManager().registerEvents(this, this);
    EDIT: I send a pull request on github that will probably solve your problems. (not sure though, it has been a while since I actively developed plugins)
  10. Offline


    Thanks man, plugin works perfectly.
    Couldn't have done it without ya' :)
Thread Status:
Not open for further replies.

Share This Page