mirror of
https://github.com/BentoBoxWorld/AcidIsland.git
synced 2024-12-23 01:27:36 +01:00
Code smell reduction (#100)
This commit is contained in:
parent
fc84ea32bb
commit
7f2216da8a
@ -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";
|
||||
|
@ -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(), () ->
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user