added a few comments, removed unnecessary function

master
Benjamin Kraft 3 years ago
parent 292c98bc18
commit 25c479f880
  1. 5
      src/main/java/com/benjocraeft/sharehealth/Commands.java
  2. 6
      src/main/java/com/benjocraeft/sharehealth/Messenger.java
  3. 13
      src/main/java/com/benjocraeft/sharehealth/PlayerListeners.java
  4. 1
      src/main/java/com/benjocraeft/sharehealth/Sharehealth.java

@ -5,7 +5,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.function.Consumer;
@ -70,7 +69,7 @@ public class Commands implements TabExecutor {
@Override
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, String[] strings) {
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
List<String> list = new ArrayList<>();
if (strings.length == 1){
@ -88,7 +87,7 @@ public class Commands implements TabExecutor {
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args){
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
List<String> argList = Arrays.asList(args);
Pair<Consumer<CommandSender>, String> command = commands.get(argList);

@ -47,7 +47,7 @@ public class Messenger {
}
void onPlayerGotDamageMessage(Player player, double damage, DamageCause cause){
String message = damageMessage(player, damage, cause);
String message = damageMessage(player, damage, cause.toString());
playersToSendLogs().forEach(p -> p.sendMessage(message));
}
@ -61,10 +61,6 @@ public class Messenger {
playersToSendLogs().forEach(p -> p.sendMessage(message));
}
private String damageMessage(Player player, double damage, DamageCause cause){
return damageMessage(player, damage, cause.toString());
}
private String damageMessage(Player player, double damage, Entity damager){
String name = damager.getName();
if (damager instanceof Projectile){

@ -14,6 +14,8 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.Arrays;
public class PlayerListeners implements Listener{
@ -33,7 +35,8 @@ public class PlayerListeners implements Listener{
double damage = event.getFinalDamage();
DamageCause cause = event.getCause();
// not allowed triggering message
// because these types trigger an extra event by entity or by block
DamageCause[] notAllowed = new DamageCause[]{
DamageCause.ENTITY_ATTACK,
DamageCause.ENTITY_EXPLOSION,
@ -42,13 +45,7 @@ public class PlayerListeners implements Listener{
};
if (entity instanceof Player){
boolean allowed = true;
for (DamageCause damageCause : notAllowed) {
if (cause.equals(damageCause)){
allowed = false;
break;
}
}
boolean allowed = !Arrays.asList(notAllowed).contains(cause);
double absorbedDamage = -event.getOriginalDamage(DamageModifier.ABSORPTION);
Sharehealth.Instance.onPlayerGotDamage((Player) entity, damage, cause, allowed, absorbedDamage);
}

@ -36,6 +36,7 @@ public class Sharehealth extends JavaPlugin {
return statistics;
}
//If isFailed, plugin changes no default behaviours
boolean isFailed = false;
private final Map<String, Object> defaultStatus = new HashMap<>();

Loading…
Cancel
Save