Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Mar 4, 2021
1 parent 816e1e8 commit 9c714e1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public AdvancementsManager(Boxed addon) {
*/
@NonNull
protected IslandAdvancements getIsland(Island island) {
return cache.computeIfAbsent(island.getUniqueId(), k -> getFromDb(k));
return cache.computeIfAbsent(island.getUniqueId(), this::getFromDb);

}

Expand Down
53 changes: 24 additions & 29 deletions src/main/java/world/bentobox/boxed/Boxed.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void onLoad() {
.getInstance(getPlugin(), 0, 5)
.createCustomGenerator(wordRef, generator -> {
// Set the noise generator
generator.setBaseNoiseGenerator(new BasicWorldGenerator(this, wordRef, getSettings().getSeed()));
generator.setBaseNoiseGenerator(new BasicWorldGenerator(this, getSettings().getSeed()));
if (getSettings().isAllowStructures()) {
generator.getWorldDecorator().withoutDefaultDecorations(DecorationType.SURFACE_STRUCTURES);
}
Expand All @@ -74,15 +74,8 @@ public void onLoad() {
generator.setBiomeGenerator(new BoxedBiomeGenerator(this));
});
// Register commands
playerCommand = new DefaultPlayerCommand(this)
playerCommand = new DefaultPlayerCommand(this) {};

{
@Override
public void setup()
{
super.setup();
}
};
adminCommand = new DefaultAdminCommand(this) {};

// Register listeners
Expand All @@ -104,8 +97,6 @@ private boolean loadSettings() {

@Override
public void onEnable(){
// Register this
//registerListener(new JoinListener(this));
// Advancements manager
advManager = new AdvancementsManager(this);
// Get delete chunk generator
Expand Down Expand Up @@ -180,29 +171,33 @@ private World getWorld(String worldName2, Environment env, ChunkGenerator chunkG
}
// Set spawn rates
if (w != null) {
if (getSettings().getSpawnLimitMonsters() > 0) {
w.setMonsterSpawnLimit(getSettings().getSpawnLimitMonsters());
}
if (getSettings().getSpawnLimitAmbient() > 0) {
w.setAmbientSpawnLimit(getSettings().getSpawnLimitAmbient());
}
if (getSettings().getSpawnLimitAnimals() > 0) {
w.setAnimalSpawnLimit(getSettings().getSpawnLimitAnimals());
}
if (getSettings().getSpawnLimitWaterAnimals() > 0) {
w.setWaterAnimalSpawnLimit(getSettings().getSpawnLimitWaterAnimals());
}
if (getSettings().getTicksPerAnimalSpawns() > 0) {
w.setTicksPerAnimalSpawns(getSettings().getTicksPerAnimalSpawns());
}
if (getSettings().getTicksPerMonsterSpawns() > 0) {
w.setTicksPerMonsterSpawns(getSettings().getTicksPerMonsterSpawns());
}
setSpawnRates(w);
}
return w;

}

private void setSpawnRates(World w) {
if (getSettings().getSpawnLimitMonsters() > 0) {
w.setMonsterSpawnLimit(getSettings().getSpawnLimitMonsters());
}
if (getSettings().getSpawnLimitAmbient() > 0) {
w.setAmbientSpawnLimit(getSettings().getSpawnLimitAmbient());
}
if (getSettings().getSpawnLimitAnimals() > 0) {
w.setAnimalSpawnLimit(getSettings().getSpawnLimitAnimals());
}
if (getSettings().getSpawnLimitWaterAnimals() > 0) {
w.setWaterAnimalSpawnLimit(getSettings().getSpawnLimitWaterAnimals());
}
if (getSettings().getTicksPerAnimalSpawns() > 0) {
w.setTicksPerAnimalSpawns(getSettings().getTicksPerAnimalSpawns());
}
if (getSettings().getTicksPerMonsterSpawns() > 0) {
w.setTicksPerMonsterSpawns(getSettings().getTicksPerMonsterSpawns());
}
}

@Override
public WorldSettings getWorldSettings() {
return getSettings();
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/world/bentobox/boxed/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1615,10 +1615,6 @@ public void setDefaultEndBiome(Biome defaultEndBiome) {
this.defaultEndBiome = defaultEndBiome;
}

public float getNoiseScaleHorizontal() {
return 10;
}

/**
* @return the seed
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import nl.rutgerkok.worldgeneratorapi.BaseNoiseGenerator;
import nl.rutgerkok.worldgeneratorapi.BiomeGenerator;
import nl.rutgerkok.worldgeneratorapi.WorldRef;
import world.bentobox.boxed.Boxed;

/**
Expand All @@ -22,7 +21,7 @@ public class BasicWorldGenerator implements BaseNoiseGenerator {
private final YamlConfiguration config;


public BasicWorldGenerator(Boxed addon, WorldRef world, long seed) {
public BasicWorldGenerator(Boxed addon, long seed) {
this.addon = addon;
// Initialize the noise generator based on the world seed
this.mainNoiseGenerator = new SimplexNoiseGenerator(seed);
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/world/bentobox/boxed/generators/DeleteGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public class DeleteGen extends ChunkGenerator {
public DeleteGen(Boxed addon) {
backMap = new HashMap<>();
backMap.put(addon.getOverWorld(), Bukkit.getWorld(addon.getOverWorld().getName() + "_bak"));
//backMap.put(addon.getNetherWorld(), Bukkit.getWorld(addon.getNetherWorld().getName() + "_bak"));
//backMap.put(addon.getEndWorld(), Bukkit.getWorld(addon.getEndWorld().getName() + "_bak"));
}

@Override
Expand Down

0 comments on commit 9c714e1

Please sign in to comment.