Fixed some code smells

This commit is contained in:
Florian CUNY 2019-01-03 17:09:27 +01:00
parent 160749c065
commit 9f676636e0
5 changed files with 8 additions and 17 deletions

View File

@ -106,7 +106,7 @@ public class BentoBox extends JavaPlugin {
return;
}
islandsManager = new IslandsManager(this);
ranksManager = new RanksManager(this);
ranksManager = new RanksManager();
// Start head getter
headGetter = new HeadGetter(this);

View File

@ -85,7 +85,7 @@ public class JoinLeaveListener implements Listener {
OfflinePlayer owner = Bukkit.getOfflinePlayer(island.getOwner());
// Converting the setting (in days) to milliseconds.
long inactivityThreshold = plugin.getSettings().getAutoOwnershipTransferInactivityThreshold() * 24 * 60 * 60 * 1000;
long inactivityThreshold = plugin.getSettings().getAutoOwnershipTransferInactivityThreshold() * 24 * 60 * 60 * 1000L;
long timestamp = System.currentTimeMillis() - inactivityThreshold;
// We make sure the current owner is inactive.

View File

@ -24,12 +24,11 @@ public class BlockInteractionListener extends FlagListener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEvent e) {
// For some items, we need to do a specific check for RIGHT_CLICK_BLOCK
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (e.getClickedBlock().getType().equals(Material.ITEM_FRAME)) {
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)
&& e.getClickedBlock().getType().equals(Material.ITEM_FRAME)) {
checkIsland(e, e.getClickedBlock().getLocation(), Flags.ITEM_FRAME);
return;
}
}
// Otherwise, we just don't care about the RIGHT_CLICK_BLOCK action.
if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {

View File

@ -29,17 +29,11 @@ public class RanksManager {
public static final int VISITOR_RANK = 0;
public static final int BANNED_RANK = -1;
private BentoBox plugin;
// The store of ranks
private LinkedHashMap<String, Integer> ranks = new LinkedHashMap<>();
/**
* @param plugin - plugin object
*/
public RanksManager(BentoBox plugin) {
public RanksManager() {
super();
this.plugin = plugin;
// Hard coded ranks
ranksPut(ADMIN_RANK_REF, ADMIN_RANK);
ranksPut(MOD_RANK_REF, MOD_RANK);

View File

@ -31,9 +31,7 @@ public class RanksManagerTest {
*/
@Before
public void setUp() throws Exception {
BentoBox plugin = mock(BentoBox.class);
ranksManager = new RanksManager(plugin);
ranksManager = new RanksManager();
}
/**