|
|
@ -51,25 +51,25 @@ public class Messenger { |
|
|
|
playersToSendLogs().forEach(p -> p.sendMessage(message)); |
|
|
|
playersToSendLogs().forEach(p -> p.sendMessage(message)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void onPlayerGotDamageMessage(Player player, double damage, Entity damager){ |
|
|
|
void onPlayerGotDamageMessage(Player player, double damage, Entity damagingEntity){ |
|
|
|
String message = damageMessage(player, damage, damager); |
|
|
|
String message = damageMessage(player, damage, damagingEntity); |
|
|
|
playersToSendLogs().forEach(p -> p.sendMessage(message)); |
|
|
|
playersToSendLogs().forEach(p -> p.sendMessage(message)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void onPlayerGotDamageMessage(Player player, double damage, Block damager){ |
|
|
|
void onPlayerGotDamageMessage(Player player, double damage, Block damagingBlock){ |
|
|
|
String message = damageMessage(player, damage, damager); |
|
|
|
String message = damageMessage(player, damage, damagingBlock); |
|
|
|
playersToSendLogs().forEach(p -> p.sendMessage(message)); |
|
|
|
playersToSendLogs().forEach(p -> p.sendMessage(message)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String damageMessage(Player player, double damage, Entity damager){ |
|
|
|
private String damageMessage(Player player, double damage, Entity damagingEntity){ |
|
|
|
String name = damager.getName(); |
|
|
|
String damagingEntityName = damagingEntity.getName(); |
|
|
|
if (damager instanceof Projectile){ |
|
|
|
if (damagingEntity instanceof Projectile){ |
|
|
|
Projectile projectile = (Projectile) damager; |
|
|
|
Projectile projectile = (Projectile) damagingEntity; |
|
|
|
ProjectileSource source = projectile.getShooter(); |
|
|
|
ProjectileSource source = projectile.getShooter(); |
|
|
|
if (source != null){ |
|
|
|
if (source != null){ |
|
|
|
if (source instanceof Entity){ |
|
|
|
if (source instanceof Entity){ |
|
|
|
Entity shooterEntity = (Entity) source; |
|
|
|
Entity shooterEntity = (Entity) source; |
|
|
|
name = shooterEntity.getName(); |
|
|
|
damagingEntityName = shooterEntity.getName(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (source instanceof BlockProjectileSource){ |
|
|
|
if (source instanceof BlockProjectileSource){ |
|
|
|
BlockProjectileSource shooterBlock = (BlockProjectileSource) source; |
|
|
|
BlockProjectileSource shooterBlock = (BlockProjectileSource) source; |
|
|
@ -77,13 +77,13 @@ public class Messenger { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return damageMessage(player, damage, name); |
|
|
|
return damageMessage(player, damage, damagingEntityName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String damageMessage(Player player, double damage, Block damager){ |
|
|
|
private String damageMessage(Player player, double damage, Block damagingBlock){ |
|
|
|
String name; |
|
|
|
String name; |
|
|
|
try{ |
|
|
|
try{ |
|
|
|
name = damager.getType().name(); |
|
|
|
name = damagingBlock.getType().name(); |
|
|
|
} catch(NullPointerException e){ |
|
|
|
} catch(NullPointerException e){ |
|
|
|
name = "Unknown"; |
|
|
|
name = "Unknown"; |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
@ -105,12 +105,12 @@ public class Messenger { |
|
|
|
private String healMessage(Player player, double regainedHealth, RegainReason reason){ |
|
|
|
private String healMessage(Player player, double regainedHealth, RegainReason reason){ |
|
|
|
String playerS = getPlayerName(player); |
|
|
|
String playerS = getPlayerName(player); |
|
|
|
String healingS = String.format("%.2f", regainedHealth / 2); |
|
|
|
String healingS = String.format("%.2f", regainedHealth / 2); |
|
|
|
String causeS = reason.toString(); |
|
|
|
String reasonString = reason.toString(); |
|
|
|
return ChatColor.BLUE + playerS |
|
|
|
return ChatColor.BLUE + playerS |
|
|
|
+ ChatColor.WHITE + " - " |
|
|
|
+ ChatColor.WHITE + " - " |
|
|
|
+ ChatColor.GREEN + healingS |
|
|
|
+ ChatColor.GREEN + healingS |
|
|
|
+ ChatColor.WHITE + " - " |
|
|
|
+ ChatColor.WHITE + " - " |
|
|
|
+ ChatColor.YELLOW + causeS; |
|
|
|
+ ChatColor.YELLOW + reasonString; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String statisticsMessage(){ |
|
|
|
String statisticsMessage(){ |
|
|
@ -147,7 +147,7 @@ public class Messenger { |
|
|
|
|
|
|
|
|
|
|
|
private String getPlayerName(Player player){ |
|
|
|
private String getPlayerName(Player player){ |
|
|
|
//Papermc:
|
|
|
|
//Papermc:
|
|
|
|
//((TextComponent) player.displayName()).content();
|
|
|
|
//return ((TextComponent) player.displayName()).content();
|
|
|
|
|
|
|
|
|
|
|
|
//Spigot:
|
|
|
|
//Spigot:
|
|
|
|
return player.getDisplayName(); |
|
|
|
return player.getDisplayName(); |
|
|
|