Code smell reduction (#100)

This commit is contained in:
tastybento 2020-09-12 12:06:49 -07:00 committed by GitHub
parent fc84ea32bb
commit 7f2216da8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 31 deletions

View File

@ -30,7 +30,7 @@ public class AcidIsland extends GameModeAddon {
private @Nullable AISettings settings;
private @Nullable AcidTask acidTask;
private @Nullable ChunkGenerator chunkGenerator;
private Config<AISettings> config = new Config<>(this, AISettings.class);
private final Config<AISettings> config = new Config<>(this, AISettings.class);
private static final String NETHER = "_nether";
private static final String THE_END = "_the_end";

View File

@ -27,7 +27,7 @@ public class AcidTask {
private final AcidIsland addon;
private static final List<EntityType> IMMUNE = Arrays.asList(EntityType.TURTLE, EntityType.POLAR_BEAR, EntityType.DROWNED);
private Map<Entity, Long> itemsInWater = new ConcurrentHashMap<>();
private BukkitTask findMobsTask;
private final BukkitTask findMobsTask;
/**
* Runs repeating tasks to deliver acid damage to mobs, etc.
@ -35,7 +35,7 @@ public class AcidTask {
*/
public AcidTask(AcidIsland addon) {
this.addon = addon;
findMobsTask = Bukkit.getScheduler().runTaskTimerAsynchronously(addon.getPlugin(), () -> findEntities(), 0L, 20L);
findMobsTask = Bukkit.getScheduler().runTaskTimerAsynchronously(addon.getPlugin(), this::findEntities, 0L, 20L);
}
void findEntities() {
@ -60,7 +60,7 @@ public class AcidTask {
}
}
// Remove any entities not on the burn list
itemsInWater.keySet().removeIf(i -> !burnList.keySet().contains(i));
itemsInWater.keySet().removeIf(i -> !burnList.containsKey(i));
if (!burnList.isEmpty()) {
Bukkit.getScheduler().runTask(addon.getPlugin(), () ->

View File

@ -27,8 +27,8 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
private final AcidIsland addon;
private final Random rand = new Random();
private Map<Environment, Integer> seaHeight = new EnumMap<>(Environment.class);
private Map<Vector, Material> roofChunk = new HashMap<>();
private final Map<Environment, Integer> seaHeight = new EnumMap<>(Environment.class);
private final Map<Vector, Material> roofChunk = new HashMap<>();
/**
* @param addon - addon

View File

@ -21,12 +21,11 @@ public class AcidEventTest {
@Mock
private Player player;
private List<PotionEffectType> effects;
private AcidEvent e;
@Before
public void setUp() throws Exception {
effects = Arrays.asList(PotionEffectType.values());
public void setUp() {
List<PotionEffectType> effects = Arrays.asList(PotionEffectType.values());
e = new AcidEvent(player, 10, 5, effects);
}

View File

@ -21,12 +21,11 @@ public class AcidRainEventTest {
@Mock
private Player player;
private List<PotionEffectType> effects;
private AcidRainEvent e;
@Before
public void setUp() throws Exception {
effects = Arrays.asList(PotionEffectType.values());
public void setUp() {
List<PotionEffectType> effects = Arrays.asList(PotionEffectType.values());
e = new AcidRainEvent(player, 10, 5, effects);
}

View File

@ -115,10 +115,9 @@ public class AcidEffectTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
public void setUp() {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
when(Bukkit.getScheduler()).thenReturn(scheduler);
when(addon.getSettings()).thenReturn(settings);
@ -189,10 +188,9 @@ public class AcidEffectTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
public void tearDown() {
}
/**

View File

@ -88,10 +88,9 @@ public class LavaCheckTest {
private LavaCheck lc;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
public void setUp() {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
when(Bukkit.getScheduler()).thenReturn(scheduler);
settings = new AISettings();
@ -107,10 +106,9 @@ public class LavaCheckTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
public void tearDown() {
}
/**

View File

@ -64,8 +64,6 @@ public class AcidTaskTest {
@Mock
private World world;
private List<Entity> mob;
@Mock
private @Nullable World nether;
@Mock
@ -81,10 +79,9 @@ public class AcidTaskTest {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
public void setUp() {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
when(Bukkit.getScheduler()).thenReturn(scheduler);
when(scheduler.runTaskTimerAsynchronously(any(), any(Runnable.class), anyLong(), anyLong())).thenReturn(task);
@ -101,7 +98,7 @@ public class AcidTaskTest {
// Default squid
mob = new ArrayList<>();
List<Entity> mob = new ArrayList<>();
Squid squid = mock(Squid.class);
when(squid.getType()).thenReturn(EntityType.SQUID);
when(squid.getLocation()).thenReturn(l);
@ -141,10 +138,9 @@ public class AcidTaskTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
public void tearDown() {
}
/**

View File

@ -54,10 +54,9 @@ public class ChunkGeneratorWorldTest {
private ChunkData data;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
public void setUp() {
// Bukkit
PowerMockito.mockStatic(Bukkit.class);
Server server = mock(Server.class);
@ -76,10 +75,9 @@ public class ChunkGeneratorWorldTest {
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
public void tearDown() {
}
/**