From 250fb79344d03c9fc00752a5e3b8f7d56f48fd7f Mon Sep 17 00:00:00 2001 From: Austin Mayes Date: Thu, 24 Aug 2017 19:40:43 -0500 Subject: [PATCH] Apply coding conventions --- dependency-reduced-pom.xml | 4 +- pom.xml | 208 +++++++++--------- .../java/net/avicus/grave/GravePlugin.java | 17 +- .../grave/event/EntityDeathByEntityEvent.java | 34 +-- .../grave/event/EntityDeathByPlayerEvent.java | 24 +- .../avicus/grave/event/EntityDeathEvent.java | 59 ++--- .../grave/event/PlayerDeathByEntityEvent.java | 33 +-- .../grave/event/PlayerDeathByPlayerEvent.java | 24 +- .../avicus/grave/event/PlayerDeathEvent.java | 30 +-- .../avicus/grave/listener/PlayerListener.java | 108 +++++---- 10 files changed, 282 insertions(+), 259 deletions(-) diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 6ed29a4..50ad57c 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 net.avicus grave diff --git a/pom.xml b/pom.xml index 174be50..71ef7e2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,119 +1,119 @@ - - 4.0.0 + + 4.0.0 - net.avicus - grave - 1.8-SNAPSHOT + net.avicus + grave + 1.8-SNAPSHOT - - Grave - net.avicus.grave.GravePlugin - Track entity and player deaths. - UTF-8 - + + Grave + net.avicus.grave.GravePlugin + Track entity and player deaths. + UTF-8 + - - - scm:git://github.com/Avicus/Grave.git - scm:git:ssh://github.com/Avicus/Grave.git - https://github.com/Avicus/Grave - + + + scm:git://github.com/Avicus/Grave.git + scm:git:ssh://github.com/Avicus/Grave.git + https://github.com/Avicus/Grave + - - - - avicus-repo - https://repo.avicus.net/content/repositories/releases/ - - - avicus-repo - https://repo.avicus.net/content/repositories/snapshots/ - - + + + + avicus-repo + https://repo.avicus.net/content/repositories/releases/ + + + avicus-repo + https://repo.avicus.net/content/repositories/snapshots/ + + - - - - avicus-public - https://repo.avicus.net/content/groups/public/ - - + + + + avicus-public + https://repo.avicus.net/content/groups/public/ + + - - - - org.projectlombok - lombok - 1.16.6 - provided - + + + + org.projectlombok + lombok + 1.16.6 + provided + - - - net.avicus - magnet-api - 1.8.8-R0.1-SNAPSHOT - provided - + + + net.avicus + magnet-api + 1.8.8-R0.1-SNAPSHOT + provided + - - - joda-time - joda-time - 2.9.2 - + + + joda-time + joda-time + 2.9.2 + - - - tc.oc - tracker - 1.0.0-SNAPSHOT - provided - - + + + tc.oc + tracker + 1.0.0-SNAPSHOT + provided + + - - - ${basedir}/src/main/java/ + + + ${basedir}/src/main/java/ - - - - . - true - ${basedir}/src/main/resources/ - - + + + + . + true + ${basedir}/src/main/resources/ + + - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - - + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + - - - org.apache.maven.plugins - maven-shade-plugin - 2.1 - - - package - - shade - - - - - - + + + org.apache.maven.plugins + maven-shade-plugin + 2.1 + + + package + + shade + + + + + + diff --git a/src/main/java/net/avicus/grave/GravePlugin.java b/src/main/java/net/avicus/grave/GravePlugin.java index e289a07..b1d4f4f 100644 --- a/src/main/java/net/avicus/grave/GravePlugin.java +++ b/src/main/java/net/avicus/grave/GravePlugin.java @@ -5,13 +5,14 @@ import org.bukkit.plugin.java.JavaPlugin; public class GravePlugin extends JavaPlugin { - @Override - public void onEnable() { - this.getServer().getPluginManager().registerEvents(new PlayerListener(this), this); - } - public T callEvent(T event) { - this.getServer().getPluginManager().callEvent(event); - return event; - } + @Override + public void onEnable() { + this.getServer().getPluginManager().registerEvents(new PlayerListener(this), this); + } + + public T callEvent(T event) { + this.getServer().getPluginManager().callEvent(event); + return event; + } } diff --git a/src/main/java/net/avicus/grave/event/EntityDeathByEntityEvent.java b/src/main/java/net/avicus/grave/event/EntityDeathByEntityEvent.java index 559ec1b..4a55251 100644 --- a/src/main/java/net/avicus/grave/event/EntityDeathByEntityEvent.java +++ b/src/main/java/net/avicus/grave/event/EntityDeathByEntityEvent.java @@ -1,35 +1,35 @@ package net.avicus.grave.event; +import java.util.List; import lombok.ToString; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; import org.joda.time.Instant; import tc.oc.tracker.Lifetime; -import java.util.List; - @ToString(callSuper = true) public class EntityDeathByEntityEvent extends EntityDeathEvent { - private final T cause; - public EntityDeathByEntityEvent(Entity entity, Location location, Lifetime lifetime, Instant time, List drops, int droppedExp, T cause) { - super(entity, location, lifetime, time, drops, droppedExp); - this.cause = cause; - } + private final T cause; + + public EntityDeathByEntityEvent(Entity entity, Location location, Lifetime lifetime, Instant time, + List drops, int droppedExp, T cause) { + super(entity, location, lifetime, time, drops, droppedExp); + this.cause = cause; + } - public T getCause() { - return this.cause; - } + public static HandlerList getHandlerList() { + return handlers; + } - public static HandlerList getHandlerList() { - return handlers; - } + public T getCause() { + return this.cause; + } - public HandlerList getHandlers() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } } diff --git a/src/main/java/net/avicus/grave/event/EntityDeathByPlayerEvent.java b/src/main/java/net/avicus/grave/event/EntityDeathByPlayerEvent.java index a1f9953..e521259 100644 --- a/src/main/java/net/avicus/grave/event/EntityDeathByPlayerEvent.java +++ b/src/main/java/net/avicus/grave/event/EntityDeathByPlayerEvent.java @@ -1,28 +1,28 @@ package net.avicus.grave.event; +import java.util.List; import lombok.ToString; import org.bukkit.Location; import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; import org.joda.time.Instant; import tc.oc.tracker.Lifetime; -import java.util.List; - @ToString(callSuper = true) public class EntityDeathByPlayerEvent extends EntityDeathByEntityEvent { - public EntityDeathByPlayerEvent(Entity entity, Location location, Lifetime lifetime, Instant time, List drops, int droppedExp, Player cause) { - super(entity, location, lifetime, time, drops, droppedExp, cause); - } - public static HandlerList getHandlerList() { - return handlers; - } + public EntityDeathByPlayerEvent(Entity entity, Location location, Lifetime lifetime, Instant time, + List drops, int droppedExp, Player cause) { + super(entity, location, lifetime, time, drops, droppedExp, cause); + } + + public static HandlerList getHandlerList() { + return handlers; + } - public HandlerList getHandlers() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } } diff --git a/src/main/java/net/avicus/grave/event/EntityDeathEvent.java b/src/main/java/net/avicus/grave/event/EntityDeathEvent.java index d52dbea..27611c2 100644 --- a/src/main/java/net/avicus/grave/event/EntityDeathEvent.java +++ b/src/main/java/net/avicus/grave/event/EntityDeathEvent.java @@ -1,5 +1,6 @@ package net.avicus.grave.event; +import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -11,34 +12,40 @@ import org.joda.time.Instant; import tc.oc.tracker.Lifetime; -import java.util.List; - @ToString(callSuper = true) public class EntityDeathEvent extends EntityEvent { - @Getter private final Location location; - @Getter private final Lifetime lifetime; - @Getter private final Instant time; - @Getter @Setter private List drops; - @Getter @Setter private int droppedExp; - - public EntityDeathEvent(Entity entity, Location location, Lifetime lifetime, Instant time, List drops, int droppedExp) { - super(entity); - this.entity = entity; - this.location = location; - this.lifetime = lifetime; - this.time = time; - this.drops = drops; - this.droppedExp = droppedExp; - } - - protected static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() { - return handlers; - } - public HandlerList getHandlers() { - return handlers; - } + protected static final HandlerList handlers = new HandlerList(); + @Getter + private final Location location; + @Getter + private final Lifetime lifetime; + @Getter + private final Instant time; + @Getter + @Setter + private List drops; + @Getter + @Setter + private int droppedExp; + + public EntityDeathEvent(Entity entity, Location location, Lifetime lifetime, Instant time, + List drops, int droppedExp) { + super(entity); + this.entity = entity; + this.location = location; + this.lifetime = lifetime; + this.time = time; + this.drops = drops; + this.droppedExp = droppedExp; + } + + public static HandlerList getHandlerList() { + return handlers; + } + + public HandlerList getHandlers() { + return handlers; + } } diff --git a/src/main/java/net/avicus/grave/event/PlayerDeathByEntityEvent.java b/src/main/java/net/avicus/grave/event/PlayerDeathByEntityEvent.java index 287c20a..ec946a3 100644 --- a/src/main/java/net/avicus/grave/event/PlayerDeathByEntityEvent.java +++ b/src/main/java/net/avicus/grave/event/PlayerDeathByEntityEvent.java @@ -1,5 +1,6 @@ package net.avicus.grave.event; +import java.util.List; import lombok.ToString; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; @@ -9,26 +10,26 @@ import org.joda.time.Instant; import tc.oc.tracker.Lifetime; -import java.util.List; - @ToString(callSuper = true) public class PlayerDeathByEntityEvent extends PlayerDeathEvent { - private final T cause; - public PlayerDeathByEntityEvent(Player player, Location location, Lifetime lifetime, Instant time, List drops, int droppedExp, T cause) { - super(player, location, lifetime, time, drops, droppedExp); - this.cause = cause; - } + private final T cause; + + public PlayerDeathByEntityEvent(Player player, Location location, Lifetime lifetime, Instant time, + List drops, int droppedExp, T cause) { + super(player, location, lifetime, time, drops, droppedExp); + this.cause = cause; + } - public T getCause() { - return this.cause; - } + public static HandlerList getHandlerList() { + return handlers; + } - public static HandlerList getHandlerList() { - return handlers; - } + public T getCause() { + return this.cause; + } - public HandlerList getHandlers() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } } diff --git a/src/main/java/net/avicus/grave/event/PlayerDeathByPlayerEvent.java b/src/main/java/net/avicus/grave/event/PlayerDeathByPlayerEvent.java index 0485969..b887864 100644 --- a/src/main/java/net/avicus/grave/event/PlayerDeathByPlayerEvent.java +++ b/src/main/java/net/avicus/grave/event/PlayerDeathByPlayerEvent.java @@ -1,27 +1,27 @@ package net.avicus.grave.event; +import java.util.List; import lombok.ToString; import org.bukkit.Location; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; import org.joda.time.Instant; import tc.oc.tracker.Lifetime; -import java.util.List; - @ToString(callSuper = true) public class PlayerDeathByPlayerEvent extends PlayerDeathByEntityEvent { - public PlayerDeathByPlayerEvent(Player player, Location location, Lifetime lifetime, Instant time, List drops, int droppedExp, Player cause) { - super(player, location, lifetime, time, drops, droppedExp, cause); - } - public static HandlerList getHandlerList() { - return handlers; - } + public PlayerDeathByPlayerEvent(Player player, Location location, Lifetime lifetime, Instant time, + List drops, int droppedExp, Player cause) { + super(player, location, lifetime, time, drops, droppedExp, cause); + } + + public static HandlerList getHandlerList() { + return handlers; + } - public HandlerList getHandlers() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } } diff --git a/src/main/java/net/avicus/grave/event/PlayerDeathEvent.java b/src/main/java/net/avicus/grave/event/PlayerDeathEvent.java index ae0849c..8c6ca92 100644 --- a/src/main/java/net/avicus/grave/event/PlayerDeathEvent.java +++ b/src/main/java/net/avicus/grave/event/PlayerDeathEvent.java @@ -1,32 +1,32 @@ package net.avicus.grave.event; +import java.util.List; import lombok.Getter; import lombok.ToString; import org.bukkit.Location; -import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; -import org.bukkit.event.entity.EntityEvent; import org.bukkit.inventory.ItemStack; import org.joda.time.Instant; import tc.oc.tracker.Lifetime; -import java.util.List; - @ToString(callSuper = true) public class PlayerDeathEvent extends EntityDeathEvent { - @Getter private final Player player; - public PlayerDeathEvent(Player player, Location location, Lifetime lifetime, Instant time, List drops, int droppedExp) { - super(player, location, lifetime, time, drops, droppedExp); - this.player = player; - } + @Getter + private final Player player; + + public PlayerDeathEvent(Player player, Location location, Lifetime lifetime, Instant time, + List drops, int droppedExp) { + super(player, location, lifetime, time, drops, droppedExp); + this.player = player; + } - public static HandlerList getHandlerList() { - return handlers; - } + public static HandlerList getHandlerList() { + return handlers; + } - public HandlerList getHandlers() { - return handlers; - } + public HandlerList getHandlers() { + return handlers; + } } diff --git a/src/main/java/net/avicus/grave/listener/PlayerListener.java b/src/main/java/net/avicus/grave/listener/PlayerListener.java index 63dc7da..f230ccc 100644 --- a/src/main/java/net/avicus/grave/listener/PlayerListener.java +++ b/src/main/java/net/avicus/grave/listener/PlayerListener.java @@ -1,7 +1,14 @@ package net.avicus.grave.listener; +import java.util.ArrayList; +import java.util.List; import net.avicus.grave.GravePlugin; -import net.avicus.grave.event.*; +import net.avicus.grave.event.EntityDeathByEntityEvent; +import net.avicus.grave.event.EntityDeathByPlayerEvent; +import net.avicus.grave.event.EntityDeathEvent; +import net.avicus.grave.event.PlayerDeathByEntityEvent; +import net.avicus.grave.event.PlayerDeathByPlayerEvent; +import net.avicus.grave.event.PlayerDeathEvent; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -12,61 +19,66 @@ import tc.oc.tracker.Lifetime; import tc.oc.tracker.Lifetimes; -import java.util.ArrayList; -import java.util.List; - public class PlayerListener implements Listener { - private final GravePlugin grave; - public PlayerListener(GravePlugin grave) { - this.grave = grave; - } - - @EventHandler - public void onEntityDeath(org.bukkit.event.entity.EntityDeathEvent event) { - LivingEntity entity = event.getEntity(); - Lifetime lifetime = Lifetimes.getLifetime(entity); - Location location = entity.getLocation(); - Instant time = Instant.now(); + private final GravePlugin grave; - EntityDeathEvent call; + public PlayerListener(GravePlugin grave) { + this.grave = grave; + } - int droppedExp = event.getDroppedExp(); - List drops = new ArrayList<>(); - drops.addAll(event.getDrops()); + @EventHandler + public void onEntityDeath(org.bukkit.event.entity.EntityDeathEvent event) { + LivingEntity entity = event.getEntity(); + Lifetime lifetime = Lifetimes.getLifetime(entity); + Location location = entity.getLocation(); + Instant time = Instant.now(); - // EntityDeathEvent or EntityDeathBy____Event?? - if (lifetime.getLastDamage() == null || lifetime.getLastDamage().getInfo().getResolvedDamager() == null) { - if (entity instanceof Player) - call = new PlayerDeathEvent((Player) entity, location, lifetime, time, drops, droppedExp); - else - call = new EntityDeathEvent(entity, location, lifetime, time, drops, droppedExp); - } - else { - LivingEntity cause = lifetime.getLastDamage().getInfo().getResolvedDamager(); + EntityDeathEvent call; + + int droppedExp = event.getDroppedExp(); + List drops = new ArrayList<>(); + drops.addAll(event.getDrops()); + + // EntityDeathEvent or EntityDeathBy____Event?? + if (lifetime.getLastDamage() == null + || lifetime.getLastDamage().getInfo().getResolvedDamager() == null) { + if (entity instanceof Player) { + call = new PlayerDeathEvent((Player) entity, location, lifetime, time, drops, droppedExp); + } else { + call = new EntityDeathEvent(entity, location, lifetime, time, drops, droppedExp); + } + } else { + LivingEntity cause = lifetime.getLastDamage().getInfo().getResolvedDamager(); - if (entity instanceof Player) { - if (cause instanceof Player) - call = new PlayerDeathByPlayerEvent((Player) entity, location, lifetime, time, drops, droppedExp, (Player) cause); - else - call = new PlayerDeathByEntityEvent<>((Player) entity, location, lifetime, time, drops, droppedExp, cause); - } - else { - if (cause instanceof Player) - call = new EntityDeathByPlayerEvent(entity, location, lifetime, time, drops, droppedExp, (Player) cause); - else - call = new EntityDeathByEntityEvent<>(entity, location, lifetime, time, drops, droppedExp, cause); - } + if (entity instanceof Player) { + if (cause instanceof Player) { + call = new PlayerDeathByPlayerEvent((Player) entity, location, lifetime, time, drops, + droppedExp, (Player) cause); + } else { + call = new PlayerDeathByEntityEvent<>((Player) entity, location, lifetime, time, drops, + droppedExp, cause); } + } else { + if (cause instanceof Player) { + call = new EntityDeathByPlayerEvent(entity, location, lifetime, time, drops, droppedExp, + (Player) cause); + } else { + call = new EntityDeathByEntityEvent<>(entity, location, lifetime, time, drops, droppedExp, + cause); + } + } + } - // Call event! - grave.callEvent(call); - - // Apply changes in drops - event.getDrops().clear(); - event.setDroppedExp(call.getDroppedExp()); - for (ItemStack itemStack : call.getDrops()) - location.getWorld().dropItemNaturally(location, itemStack); + // Call event! + grave.callEvent(call); + // Apply changes in drops + event.getDrops().clear(); + event.setDroppedExp(call.getDroppedExp()); + for (ItemStack itemStack : call.getDrops()) { + location.getWorld().dropItemNaturally(location, itemStack); } + + } }