Removed code smells

This commit is contained in:
tastybento 2018-08-26 08:21:41 -07:00
parent 85c28f8a70
commit f686060e54
15 changed files with 87 additions and 129 deletions

View File

@ -55,7 +55,7 @@ public class Level extends Addon {
/** /**
* Get level from cache for a player * Get level from cache for a player
* @param targetPlayer * @param targetPlayer - target player
* @return Level of player * @return Level of player
*/ */
public long getIslandLevel(World world, UUID targetPlayer) { public long getIslandLevel(World world, UUID targetPlayer) {
@ -92,7 +92,7 @@ public class Level extends Addon {
public void onDisable(){ public void onDisable(){
// Save the cache // Save the cache
if (levelsCache != null) { if (levelsCache != null) {
save(false); save();
} }
if (topTen != null) { if (topTen != null) {
topTen.saveTopTen(); topTen.saveTopTen();
@ -147,18 +147,17 @@ public class Level extends Addon {
/** /**
* Save the levels to the database * Save the levels to the database
* @param async - if true, saving will be done async
*/ */
public void save(boolean async){ private void save(){
// No async for now // No async for now
levelsCache.values().forEach(handler::saveObject); levelsCache.values().forEach(handler::saveObject);
} }
/** /**
* Sets the player's level to a value * Sets the player's level to a value
* @param world * @param world - world
* @param targetPlayer * @param targetPlayer - target player
* @param level * @param level - level
*/ */
public void setIslandLevel(World world, UUID targetPlayer, long level) { public void setIslandLevel(World world, UUID targetPlayer, long level) {
LevelsData ld = getLevelsData(targetPlayer); LevelsData ld = getLevelsData(targetPlayer);

View File

@ -10,14 +10,14 @@ import bentobox.addon.level.calculators.PlayerLevel;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.api.user.User;
public class LevelPresenter { class LevelPresenter {
private int levelWait; private int levelWait;
private final Level addon; private final Level addon;
private final BentoBox plugin; private final BentoBox plugin;
// Level calc cool down // Level calc cool down
private HashMap<UUID, Long> levelWaitTime = new HashMap<UUID, Long>(); private final HashMap<UUID, Long> levelWaitTime = new HashMap<>();
public LevelPresenter(Level addon, BentoBox plugin) { public LevelPresenter(Level addon, BentoBox plugin) {
this.addon = addon; this.addon = addon;
@ -28,10 +28,9 @@ public class LevelPresenter {
* Calculates the island level * Calculates the island level
* @param world - world to check * @param world - world to check
* @param sender - asker of the level info * @param sender - asker of the level info
* @param targetPlayer * @param targetPlayer - target player
* @return - false if this is cannot be done
*/ */
public boolean calculateIslandLevel(World world, final User sender, UUID targetPlayer) { public void calculateIslandLevel(World world, final User sender, UUID targetPlayer) {
// Get permission prefix for this world // Get permission prefix for this world
String permPrefix = plugin.getIWM().getPermissionPrefix(world); String permPrefix = plugin.getIWM().getPermissionPrefix(world);
// Check if target has island // Check if target has island
@ -43,7 +42,7 @@ public class LevelPresenter {
inTeam = true; inTeam = true;
} else { } else {
sender.sendMessage("general.errors.player-has-no-island"); sender.sendMessage("general.errors.player-has-no-island");
return false; return;
} }
} }
// Player asking for their own island calc // Player asking for their own island calc
@ -62,25 +61,21 @@ public class LevelPresenter {
// Asking for the level of another player // Asking for the level of another player
sender.sendMessage("island.level.island-level-is","[level]", String.valueOf(addon.getIslandLevel(world, targetPlayer))); sender.sendMessage("island.level.island-level-is","[level]", String.valueOf(addon.getIslandLevel(world, targetPlayer)));
} }
return true;
} }
/** /**
* Sets cool down for the level command * Sets cool down for the level command
* *
* @param player * @param user - user
*/ */
private void setLevelWaitTime(final User player) { private void setLevelWaitTime(final User user) {
levelWaitTime.put(player.getUniqueId(), Long.valueOf(Calendar.getInstance().getTimeInMillis() + levelWait * 1000)); levelWaitTime.put(user.getUniqueId(), Calendar.getInstance().getTimeInMillis() + levelWait * 1000);
} }
private boolean onLevelWaitTime(final User sender) { private boolean onLevelWaitTime(final User sender) {
if (levelWaitTime.containsKey(sender.getUniqueId())) { if (levelWaitTime.containsKey(sender.getUniqueId())) {
if (levelWaitTime.get(sender.getUniqueId()).longValue() > Calendar.getInstance().getTimeInMillis()) { return levelWaitTime.get(sender.getUniqueId()) > Calendar.getInstance().getTimeInMillis();
return true;
}
return false;
} }
return false; return false;
@ -88,8 +83,8 @@ public class LevelPresenter {
private long getLevelWaitTime(final User sender) { private long getLevelWaitTime(final User sender) {
if (levelWaitTime.containsKey(sender.getUniqueId())) { if (levelWaitTime.containsKey(sender.getUniqueId())) {
if (levelWaitTime.get(sender.getUniqueId()).longValue() > Calendar.getInstance().getTimeInMillis()) { if (levelWaitTime.get(sender.getUniqueId()) > Calendar.getInstance().getTimeInMillis()) {
return (levelWaitTime.get(sender.getUniqueId()).longValue() - Calendar.getInstance().getTimeInMillis()) / 1000; return (levelWaitTime.get(sender.getUniqueId()) - Calendar.getInstance().getTimeInMillis()) / 1000;
} }
return 0L; return 0L;

View File

@ -28,11 +28,11 @@ import world.bentobox.bentobox.database.Database;
* *
*/ */
public class TopTen implements Listener { public class TopTen implements Listener {
private Level addon; private final Level addon;
// Top ten list of players // Top ten list of players
private Map<World,TopTenData> topTenList; private Map<World,TopTenData> topTenList;
private final int[] SLOTS = new int[] {4, 12, 14, 19, 20, 21, 22, 23, 24, 25}; private final int[] SLOTS = new int[] {4, 12, 14, 19, 20, 21, 22, 23, 24, 25};
private Database<TopTenData> handler; private final Database<TopTenData> handler;
public TopTen(Level addon) { public TopTen(Level addon) {
this.addon = addon; this.addon = addon;
@ -45,8 +45,8 @@ public class TopTen implements Listener {
/** /**
* Adds a player to the top ten, if the level is good enough * Adds a player to the top ten, if the level is good enough
* *
* @param ownerUUID * @param ownerUUID - owner UUID
* @param l * @param l - level
*/ */
public void addEntry(World world, UUID ownerUUID, long l) { public void addEntry(World world, UUID ownerUUID, long l) {
// Check if player is an island owner or not // Check if player is an island owner or not
@ -68,13 +68,10 @@ public class TopTen implements Listener {
/** /**
* Displays the Top Ten list * Displays the Top Ten list
* @param world * @param world - world
* * @param user - the requesting player
* @param user
* - the requesting player
* @return - true if successful, false if no Top Ten list exists
*/ */
public boolean getGUI(World world, final User user, String permPrefix) { public void getGUI(World world, final User user, String permPrefix) {
// Check world // Check world
topTenList.putIfAbsent(world, new TopTenData()); topTenList.putIfAbsent(world, new TopTenData());
topTenList.get(world).setUniqueId(world.getName()); topTenList.get(world).setUniqueId(world.getName());
@ -103,7 +100,6 @@ public class TopTen implements Listener {
} }
} }
panel.build(); panel.build();
return true;
} }
/** /**
@ -142,7 +138,7 @@ public class TopTen implements Listener {
/** /**
* Loads all the top tens from the database * Loads all the top tens from the database
*/ */
public void loadTopTen() { private void loadTopTen() {
topTenList = new HashMap<>(); topTenList = new HashMap<>();
handler.loadObjects().forEach(tt -> topTenList.put(Bukkit.getWorld(tt.getUniqueId()), tt)); handler.loadObjects().forEach(tt -> topTenList.put(Bukkit.getWorld(tt.getUniqueId()), tt));
} }
@ -150,7 +146,7 @@ public class TopTen implements Listener {
/** /**
* Removes ownerUUID from the top ten list * Removes ownerUUID from the top ten list
* *
* @param ownerUUID * @param ownerUUID - uuid to remove
*/ */
public void removeEntry(World world, UUID ownerUUID) { public void removeEntry(World world, UUID ownerUUID) {
topTenList.putIfAbsent(world, new TopTenData()); topTenList.putIfAbsent(world, new TopTenData());

View File

@ -30,19 +30,19 @@ public class CalcIslandLevel {
private static final int MAX_CHUNKS = 200; private static final int MAX_CHUNKS = 200;
private static final long SPEED = 1; private static final long SPEED = 1;
private static final String LINE_BREAK = "=================================="; private static final String LINE_BREAK = "==================================";
private boolean checking = true; private boolean checking;
private BukkitTask task; private final BukkitTask task;
private Level addon; private final Level addon;
private Set<Pair<Integer, Integer>> chunksToScan; private final Set<Pair<Integer, Integer>> chunksToScan;
private Island island; private final Island island;
private World world; private final World world;
private Results result; private final Results result;
private Runnable onExit; private final Runnable onExit;
// Copy the limits hashmap // Copy the limits hashmap
HashMap<Material, Integer> limitCount; private final HashMap<Material, Integer> limitCount;
/** /**
@ -123,7 +123,7 @@ public class CalcIslandLevel {
for (int y = 0; y < island.getCenter().getWorld().getMaxHeight(); y++) { for (int y = 0; y < island.getCenter().getWorld().getMaxHeight(); y++) {
Material blockData = chunk.getBlockType(x, y, z); Material blockData = chunk.getBlockType(x, y, z);
boolean belowSeaLevel = (addon.getSettings().getSeaHeight() > 0 && y<=addon.getSettings().getSeaHeight()) ? true : false; boolean belowSeaLevel = addon.getSettings().getSeaHeight() > 0 && y <= addon.getSettings().getSeaHeight();
// Air is free // Air is free
if (!blockData.equals(Material.AIR)) { if (!blockData.equals(Material.AIR)) {
checkBlock(blockData, belowSeaLevel); checkBlock(blockData, belowSeaLevel);
@ -146,7 +146,7 @@ public class CalcIslandLevel {
/** /**
* Checks if a block has been limited or not and whether a block has any value or not * Checks if a block has been limited or not and whether a block has any value or not
* @param md * @param md - Material to check
* @return value of the block if can be counted * @return value of the block if can be counted
*/ */
private int limitCount(Material md) { private int limitCount(Material md) {
@ -170,7 +170,7 @@ public class CalcIslandLevel {
/** /**
* Get value of a material * Get value of a material
* World blocks trump regular block values * World blocks trump regular block values
* @param md * @param md - Material to check
* @return value of a material * @return value of a material
*/ */
private int getValue(Material md) { private int getValue(Material md) {
@ -182,8 +182,8 @@ public class CalcIslandLevel {
/** /**
* Get a set of all the chunks in island * Get a set of all the chunks in island
* @param island * @param island - island
* @return * @return - set of pairs of x,z coordinates to check
*/ */
private Set<Pair<Integer, Integer>> getChunksToScan(Island island) { private Set<Pair<Integer, Integer>> getChunksToScan(Island island) {
Set<Pair<Integer, Integer>> chunkSnapshot = new HashSet<>(); Set<Pair<Integer, Integer>> chunkSnapshot = new HashSet<>();
@ -267,9 +267,7 @@ public class CalcIslandLevel {
private Collection<String> sortedReport(int total, Multiset<Material> MaterialCount) { private Collection<String> sortedReport(int total, Multiset<Material> MaterialCount) {
Collection<String> r = new ArrayList<>(); Collection<String> r = new ArrayList<>();
Iterable<Multiset.Entry<Material>> entriesSortedByCount = Multisets.copyHighestCountFirst(MaterialCount).entrySet(); Iterable<Multiset.Entry<Material>> entriesSortedByCount = Multisets.copyHighestCountFirst(MaterialCount).entrySet();
Iterator<Entry<Material>> it = entriesSortedByCount.iterator(); for (Entry<Material> en : entriesSortedByCount) {
while (it.hasNext()) {
Entry<Material> en = it.next();
Material type = en.getElement(); Material type = en.getElement();
int value = 0; int value = 0;
@ -278,7 +276,7 @@ public class CalcIslandLevel {
value = addon.getSettings().getBlockValues().get(type); value = addon.getSettings().getBlockValues().get(type);
} }
r.add(type.toString() + ":" r.add(type.toString() + ":"
+ String.format("%,d",en.getCount()) + " blocks x " + value + " = " + (value * en.getCount())); + String.format("%,d", en.getCount()) + " blocks x " + value + " = " + (value * en.getCount()));
total += (value * en.getCount()); total += (value * en.getCount());
} }
r.add("Subtotal = " + total); r.add("Subtotal = " + total);
@ -299,10 +297,10 @@ public class CalcIslandLevel {
*/ */
public class Results { public class Results {
private List<String> report; private List<String> report;
private Multiset<Material> mdCount = HashMultiset.create(); private final Multiset<Material> mdCount = HashMultiset.create();
private Multiset<Material> uwCount = HashMultiset.create(); private final Multiset<Material> uwCount = HashMultiset.create();
private Multiset<Material> ncCount = HashMultiset.create(); private final Multiset<Material> ncCount = HashMultiset.create();
private Multiset<Material> ofCount = HashMultiset.create(); private final Multiset<Material> ofCount = HashMultiset.create();
private long rawBlockCount = 0; private long rawBlockCount = 0;
private long underWaterBlockCount = 0; private long underWaterBlockCount = 0;
private long level = 0; private long level = 0;
@ -314,12 +312,7 @@ public class CalcIslandLevel {
public int getDeathHandicap() { public int getDeathHandicap() {
return deathHandicap; return deathHandicap;
} }
/**
* @param deathHandicap the deathHandicap to set
*/
public void setDeathHandicap(int deathHandicap) {
this.deathHandicap = deathHandicap;
}
/** /**
* @return the report * @return the report
*/ */
@ -338,24 +331,6 @@ public class CalcIslandLevel {
public long getPointsToNextLevel() { public long getPointsToNextLevel() {
return pointsToNextLevel; return pointsToNextLevel;
} }
/**
* @param report the report to set
*/
public void setReport(List<String> report) {
this.report = report;
}
/**
* @param level the level to set
*/
public void setLevel(long level) {
this.level = level;
}
/**
* @param pointsToNextLevel the pointsToNextLevel to set
*/
public void setPointsToNextLevel(long pointsToNextLevel) {
this.pointsToNextLevel = pointsToNextLevel;
}
} }
} }

View File

@ -19,14 +19,14 @@ import world.bentobox.bentobox.database.objects.Island;
*/ */
public class PlayerLevel { public class PlayerLevel {
private Level addon; private final Level addon;
private Island island; private final Island island;
private World world; private final World world;
private User asker; private final User asker;
private UUID targetPlayer; private final UUID targetPlayer;
private long oldLevel; private final long oldLevel;
private CalcIslandLevel calc; private CalcIslandLevel calc;
@ -34,7 +34,7 @@ public class PlayerLevel {
public PlayerLevel(final Level addon, final Island island, final UUID targetPlayer, final User asker) { public PlayerLevel(final Level addon, final Island island, final UUID targetPlayer, final User asker) {
this.addon = addon; this.addon = addon;
this.island = island; this.island = island;
this.world = island != null ? island.getCenter().getWorld() : null; this.world = island.getCenter().getWorld();
this.asker = asker; this.asker = asker;
this.targetPlayer = targetPlayer; this.targetPlayer = targetPlayer;
this.oldLevel = addon.getIslandLevel(world, targetPlayer); this.oldLevel = addon.getIslandLevel(world, targetPlayer);
@ -44,7 +44,7 @@ public class PlayerLevel {
addon.getServer().getPluginManager().callEvent(e); addon.getServer().getPluginManager().callEvent(e);
if (!e.isCancelled()) { if (!e.isCancelled()) {
// Calculate if not cancelled // Calculate if not cancelled
calc = new CalcIslandLevel(addon, island, ()-> fireIslandLevelCalcEvent()); calc = new CalcIslandLevel(addon, island, this::fireIslandLevelCalcEvent);
} }
} }

View File

@ -23,7 +23,7 @@ public class AdminTop extends CompositeCommand {
@Override @Override
public boolean execute(User user, String label, List<String> args) { public boolean execute(User user, String label, List<String> args) {
// Get world // Get world
World world = null; World world;
if (args.isEmpty()) { if (args.isEmpty()) {
if (getPlugin().getIWM().getOverWorlds().size() == 1) { if (getPlugin().getIWM().getOverWorlds().size() == 1) {
world = getPlugin().getIWM().getOverWorlds().get(0); world = getPlugin().getIWM().getOverWorlds().get(0);

View File

@ -16,7 +16,7 @@ public class Settings {
private int seaHeight; private int seaHeight;
private Map<Material, Integer> blockLimits = new HashMap<>(); private Map<Material, Integer> blockLimits = new HashMap<>();
private Map<Material, Integer> blockValues = new HashMap<>(); private Map<Material, Integer> blockValues = new HashMap<>();
private Map<World, Map<Material, Integer>> worldBlockValues = new HashMap<>(); private final Map<World, Map<Material, Integer>> worldBlockValues = new HashMap<>();
private double underWaterMultiplier; private double underWaterMultiplier;
private int deathpenalty; private int deathpenalty;
private long levelCost; private long levelCost;
@ -103,7 +103,7 @@ public class Settings {
/** /**
* @param sumTeamDeaths the sumTeamDeaths to set * @param sumTeamDeaths the sumTeamDeaths to set
*/ */
public final void setSumTeamDeaths(boolean sumTeamDeaths) { private void setSumTeamDeaths(boolean sumTeamDeaths) {
this.sumTeamDeaths = sumTeamDeaths; this.sumTeamDeaths = sumTeamDeaths;
} }
/** /**
@ -127,7 +127,7 @@ public class Settings {
/** /**
* @param blockLimits2 the blockLimits to set * @param blockLimits2 the blockLimits to set
*/ */
public final void setBlockLimits(HashMap<Material, Integer> blockLimits2) { private void setBlockLimits(HashMap<Material, Integer> blockLimits2) {
this.blockLimits = blockLimits2; this.blockLimits = blockLimits2;
} }
/** /**
@ -139,7 +139,7 @@ public class Settings {
/** /**
* @param blockValues2 the blockValues to set * @param blockValues2 the blockValues to set
*/ */
public final void setBlockValues(Map<Material, Integer> blockValues2) { private void setBlockValues(Map<Material, Integer> blockValues2) {
this.blockValues = blockValues2; this.blockValues = blockValues2;
} }
/** /**
@ -151,7 +151,7 @@ public class Settings {
/** /**
* @param underWaterMultiplier the underWaterMultiplier to set * @param underWaterMultiplier the underWaterMultiplier to set
*/ */
public final void setUnderWaterMultiplier(double underWaterMultiplier) { private void setUnderWaterMultiplier(double underWaterMultiplier) {
this.underWaterMultiplier = underWaterMultiplier; this.underWaterMultiplier = underWaterMultiplier;
} }
/** /**
@ -163,7 +163,7 @@ public class Settings {
/** /**
* @param deathpenalty the deathpenalty to set * @param deathpenalty the deathpenalty to set
*/ */
public final void setDeathpenalty(int deathpenalty) { private void setDeathpenalty(int deathpenalty) {
this.deathpenalty = deathpenalty; this.deathpenalty = deathpenalty;
} }
/** /**
@ -175,7 +175,7 @@ public class Settings {
/** /**
* @param levelCost the levelCost to set * @param levelCost the levelCost to set
*/ */
public final void setLevelCost(long levelCost) { private void setLevelCost(long levelCost) {
this.levelCost = levelCost; this.levelCost = levelCost;
} }
/** /**
@ -193,16 +193,17 @@ public class Settings {
/** /**
* @return the levelWait * @return the levelWait
*/ */
public final int getLevelWait() { private int getLevelWait() {
return levelWait; return levelWait;
} }
/** /**
* @param levelWait the levelWait to set * @param levelWait the levelWait to set
*/ */
public final void setLevelWait(int levelWait) { private void setLevelWait(int levelWait) {
this.levelWait = levelWait; this.levelWait = levelWait;
} }
/** /**
* TODO: Use max deaths
* @return the maxDeaths * @return the maxDeaths
*/ */
public final int getMaxDeaths() { public final int getMaxDeaths() {
@ -211,7 +212,7 @@ public class Settings {
/** /**
* @param maxDeaths the maxDeaths to set * @param maxDeaths the maxDeaths to set
*/ */
public final void setMaxDeaths(int maxDeaths) { private void setMaxDeaths(int maxDeaths) {
this.maxDeaths = maxDeaths; this.maxDeaths = maxDeaths;
} }
/** /**
@ -223,7 +224,7 @@ public class Settings {
/** /**
* @param islandResetDeathReset the islandResetDeathReset to set * @param islandResetDeathReset the islandResetDeathReset to set
*/ */
public final void setIslandResetDeathReset(boolean islandResetDeathReset) { private void setIslandResetDeathReset(boolean islandResetDeathReset) {
this.islandResetDeathReset = islandResetDeathReset; this.islandResetDeathReset = islandResetDeathReset;
} }
/** /**
@ -235,7 +236,7 @@ public class Settings {
/** /**
* @param teamJoinDeathReset the teamJoinDeathReset to set * @param teamJoinDeathReset the teamJoinDeathReset to set
*/ */
public final void setTeamJoinDeathReset(boolean teamJoinDeathReset) { private void setTeamJoinDeathReset(boolean teamJoinDeathReset) {
this.teamJoinDeathReset = teamJoinDeathReset; this.teamJoinDeathReset = teamJoinDeathReset;
} }

View File

@ -26,9 +26,9 @@ public class LevelsData implements DataObject {
/** /**
* Create a level entry for target player * Create a level entry for target player
* @param targetPlayer * @param targetPlayer - target player
* @param level * @param level - level
* @param world * @param world - world
*/ */
public LevelsData(UUID targetPlayer, long level, World world) { public LevelsData(UUID targetPlayer, long level, World world) {
uniqueId = targetPlayer.toString(); uniqueId = targetPlayer.toString();

View File

@ -55,7 +55,7 @@ public class TopTenData implements DataObject {
/** /**
* Get the level for this UUID, or zero if the UUID is not found * Get the level for this UUID, or zero if the UUID is not found
* @param uuid * @param uuid - UUID to check
* @return island level * @return island level
*/ */
public long getLevel(UUID uuid) { public long getLevel(UUID uuid) {
@ -66,7 +66,7 @@ public class TopTenData implements DataObject {
/** /**
* Removes ownerUUID from the top ten * Removes ownerUUID from the top ten
* @param ownerUUID * @param ownerUUID - UUID to remove
*/ */
public void remove(UUID ownerUUID) { public void remove(UUID ownerUUID) {
this.topTen.remove(ownerUUID); this.topTen.remove(ownerUUID);

View File

@ -18,9 +18,9 @@ public class IslandLevelCalculatedEvent extends IslandBaseEvent {
private UUID targetPlayer; private UUID targetPlayer;
/** /**
* @param targetPlayer * @param targetPlayer - target player
* @param island * @param island - island
* @param results * @param results - results object to set
*/ */
public IslandLevelCalculatedEvent(UUID targetPlayer, Island island, Results results) { public IslandLevelCalculatedEvent(UUID targetPlayer, Island island, Results results) {
super(island); super(island);

View File

@ -12,7 +12,7 @@ import world.bentobox.bentobox.database.objects.Island;
*/ */
public class IslandPreLevelEvent extends IslandBaseEvent { public class IslandPreLevelEvent extends IslandBaseEvent {
private UUID targetPlayer; private final UUID targetPlayer;
/** /**

View File

@ -9,7 +9,7 @@ import org.bukkit.event.HandlerList;
* *
* @author tastybento * @author tastybento
*/ */
public class TopTenClick extends Event implements Cancellable { class TopTenClick extends Event implements Cancellable {
private boolean cancelled; private boolean cancelled;
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@ -43,7 +43,7 @@ public class TopTenClick extends Event implements Cancellable {
return getHandlerList(); return getHandlerList();
} }
public static HandlerList getHandlerList() { private static HandlerList getHandlerList() {
return handlers; return handlers;
} }

View File

@ -15,10 +15,10 @@ import bentobox.addon.level.Level;
*/ */
public class JoinLeaveListener implements Listener { public class JoinLeaveListener implements Listener {
private Level addon; private final Level addon;
/** /**
* @param addon * @param addon - addon
*/ */
public JoinLeaveListener(Level addon) { public JoinLeaveListener(Level addon) {
this.addon = addon; this.addon = addon;

View File

@ -20,11 +20,11 @@ import world.bentobox.bentobox.database.objects.Island;
*/ */
public class NewIslandListener implements Listener { public class NewIslandListener implements Listener {
private Level addon; private final Level addon;
private Map<Island, CalcIslandLevel> cil; private final Map<Island, CalcIslandLevel> cil;
/** /**
* @param addon * @param addon - addon
*/ */
public NewIslandListener(Level addon) { public NewIslandListener(Level addon) {
this.addon = addon; this.addon = addon;

View File

@ -1,9 +1,5 @@
/**
*
*/
package bentobox.addon.level; package bentobox.addon.level;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -35,12 +31,8 @@ public class LevelPresenterTest {
private BentoBox plugin; private BentoBox plugin;
private Level addon; private Level addon;
private IslandsManager im;
private PlayerLevel pl; private PlayerLevel pl;
/**
* @throws java.lang.Exception
*/
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
plugin = mock(BentoBox.class); plugin = mock(BentoBox.class);
@ -48,7 +40,7 @@ public class LevelPresenterTest {
IslandWorldManager iwm = mock(IslandWorldManager.class); IslandWorldManager iwm = mock(IslandWorldManager.class);
when(plugin.getIWM()).thenReturn(iwm); when(plugin.getIWM()).thenReturn(iwm);
when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("world"); when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("world");
im = mock(IslandsManager.class); IslandsManager im = mock(IslandsManager.class);
when(plugin.getIslands()).thenReturn(im); when(plugin.getIslands()).thenReturn(im);
// Has island // Has island
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true); when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
@ -67,7 +59,7 @@ public class LevelPresenterTest {
*/ */
@Test @Test
public void testLevelPresenter() { public void testLevelPresenter() {
assertNotNull(new LevelPresenter(addon, plugin)); new LevelPresenter(addon, plugin);
} }
/** /**