Added NonNull to all listeners constructors

This commit is contained in:
Florian CUNY 2019-02-16 10:58:25 +01:00
parent 16c4c9b0be
commit 9803a02471
7 changed files with 16 additions and 18 deletions

View File

@ -5,6 +5,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
@ -21,7 +22,7 @@ public class BannedVisitorCommands implements Listener {
/**
* @param plugin - plugin
*/
public BannedVisitorCommands(BentoBox plugin) {
public BannedVisitorCommands(@NonNull BentoBox plugin) {
this.plugin = plugin;
}

View File

@ -9,15 +9,15 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.lists.Flags;
public class BlockEndDragon implements Listener {
private BentoBox plugin;
public BlockEndDragon(BentoBox plugin) {
public BlockEndDragon(@NonNull BentoBox plugin) {
this.plugin = plugin;
}

View File

@ -5,6 +5,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
/**
@ -16,13 +17,13 @@ public class DeathListener implements Listener {
private BentoBox plugin;
public DeathListener(BentoBox plugin) {
public DeathListener(@NonNull BentoBox plugin) {
super();
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerDeathEvent(PlayerDeathEvent e) {
public void onPlayerDeath(PlayerDeathEvent e) {
if (plugin.getIWM().inWorld(e.getEntity().getLocation()) && plugin.getIWM().getWorldSettings(e.getEntity().getLocation().getWorld()).isDeathsCounted()) {
plugin.getPlayers().addDeath(e.getEntity().getWorld(), e.getEntity().getUniqueId());
}

View File

@ -12,6 +12,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
@ -29,7 +30,7 @@ public class JoinLeaveListener implements Listener {
/**
* @param plugin - plugin object
*/
public JoinLeaveListener(BentoBox plugin) {
public JoinLeaveListener(@NonNull BentoBox plugin) {
this.plugin = plugin;
players = plugin.getPlayers();
}

View File

@ -21,6 +21,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
@ -32,7 +33,7 @@ public class NetherPortals implements Listener {
private static final String SPAWN_PROTECTED = "protection.spawn-protected";
private final BentoBox plugin;
public NetherPortals(BentoBox plugin) {
public NetherPortals(@NonNull BentoBox plugin) {
this.plugin = plugin;
}

View File

@ -8,6 +8,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.StructureGrowEvent;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.WorldSettings;
@ -20,7 +21,7 @@ public class NetherTreesListener implements Listener {
private BentoBox plugin;
public NetherTreesListener(BentoBox plugin) {
public NetherTreesListener(@NonNull BentoBox plugin) {
this.plugin = plugin;
}

View File

@ -70,20 +70,13 @@ public class DeathListenerTest {
}
@Test
public void testDeathListener() {
assertNotNull(new DeathListener(mock(BentoBox.class)));
}
@Test
public void testOnPlayerDeathEventDeathsCounted() {
// Test
DeathListener dl = new DeathListener(plugin);
PlayerDeathEvent e = new PlayerDeathEvent(player, new ArrayList<>(), 0, 0, 0, 0, "died");
dl.onPlayerDeathEvent(e);
dl.onPlayerDeath(e);
Mockito.verify(pm).addDeath(world, uuid);
}
@ -94,7 +87,7 @@ public class DeathListenerTest {
DeathListener dl = new DeathListener(plugin);
PlayerDeathEvent e = new PlayerDeathEvent(player, new ArrayList<>(), 0, 0, 0, 0, "died");
dl.onPlayerDeathEvent(e);
dl.onPlayerDeath(e);
Mockito.verify(pm, Mockito.never()).addDeath(world, uuid);
}
@ -105,7 +98,7 @@ public class DeathListenerTest {
DeathListener dl = new DeathListener(plugin);
PlayerDeathEvent e = new PlayerDeathEvent(player, new ArrayList<>(), 0, 0, 0, 0, "died");
dl.onPlayerDeathEvent(e);
dl.onPlayerDeath(e);
Mockito.verify(pm, Mockito.never()).addDeath(world, uuid);
}