mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 00:06:10 +00:00
Cleanup
This commit is contained in:
@@ -21,9 +21,7 @@ package com.volmit.iris.engine.object.annotations;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@Retention(RUNTIME)
|
||||
|
||||
@@ -149,10 +149,8 @@ public class IrisBlockData extends IrisRegistrant {
|
||||
});
|
||||
}
|
||||
|
||||
private String keyify(String dat)
|
||||
{
|
||||
if(dat.contains(":"))
|
||||
{
|
||||
private String keyify(String dat) {
|
||||
if (dat.contains(":")) {
|
||||
return dat;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.volmit.iris.engine.object.carve.IrisCaveFluid;
|
||||
import com.volmit.iris.engine.object.carve.IrisCaveLayer;
|
||||
import com.volmit.iris.engine.object.carve.IrisCaverns;
|
||||
import com.volmit.iris.engine.object.deposits.IrisDepositGenerator;
|
||||
import com.volmit.iris.engine.object.villager.IrisVillagerOverride;
|
||||
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
|
||||
import com.volmit.iris.engine.object.feature.IrisFeaturePotential;
|
||||
import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructure;
|
||||
@@ -47,6 +46,7 @@ import com.volmit.iris.engine.object.objects.IrisObjectPlacement;
|
||||
import com.volmit.iris.engine.object.regional.IrisRegion;
|
||||
import com.volmit.iris.engine.object.spawners.IrisSpawner;
|
||||
import com.volmit.iris.engine.object.trees.IrisTreeSettings;
|
||||
import com.volmit.iris.engine.object.villager.IrisVillagerOverride;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.data.DataProvider;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
|
||||
@@ -28,14 +28,11 @@ public class IrisEngineChunkData {
|
||||
private long chunk;
|
||||
private KList<IrisEngineSpawnerCooldown> cooldowns = new KList<>();
|
||||
|
||||
public void cleanup(Engine engine)
|
||||
{
|
||||
for(IrisEngineSpawnerCooldown i : getCooldowns().copy())
|
||||
{
|
||||
public void cleanup(Engine engine) {
|
||||
for (IrisEngineSpawnerCooldown i : getCooldowns().copy()) {
|
||||
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
|
||||
|
||||
if(sp == null || i.canSpawn(sp.getMaximumRate()))
|
||||
{
|
||||
if (sp == null || i.canSpawn(sp.getMaximumRate())) {
|
||||
getCooldowns().remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ package com.volmit.iris.engine.object.engine;
|
||||
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.meta.IrisEnchantment;
|
||||
import com.volmit.iris.engine.object.spawners.IrisSpawner;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import lombok.Data;
|
||||
@@ -31,20 +30,16 @@ public class IrisEngineData {
|
||||
private KList<IrisEngineSpawnerCooldown> spawnerCooldowns = new KList<>();
|
||||
private KList<IrisEngineChunkData> chunks = new KList<>();
|
||||
|
||||
public void removeChunk(int x, int z)
|
||||
{
|
||||
public void removeChunk(int x, int z) {
|
||||
long k = Cache.key(x, z);
|
||||
chunks.removeWhere((i) -> i.getChunk() == k);
|
||||
}
|
||||
|
||||
public IrisEngineChunkData getChunk(int x, int z)
|
||||
{
|
||||
public IrisEngineChunkData getChunk(int x, int z) {
|
||||
long k = Cache.key(x, z);
|
||||
|
||||
for(IrisEngineChunkData i : chunks)
|
||||
{
|
||||
if(i.getChunk() == k)
|
||||
{
|
||||
for (IrisEngineChunkData i : chunks) {
|
||||
if (i.getChunk() == k) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -56,22 +51,18 @@ public class IrisEngineData {
|
||||
}
|
||||
|
||||
public void cleanup(Engine engine) {
|
||||
for(IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy())
|
||||
{
|
||||
for (IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) {
|
||||
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
|
||||
|
||||
if(sp == null || i.canSpawn(sp.getMaximumRate()))
|
||||
{
|
||||
if (sp == null || i.canSpawn(sp.getMaximumRate())) {
|
||||
getSpawnerCooldowns().remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisEngineChunkData i : chunks.copy())
|
||||
{
|
||||
for (IrisEngineChunkData i : chunks.copy()) {
|
||||
i.cleanup(engine);
|
||||
|
||||
if(i.isEmpty())
|
||||
{
|
||||
if (i.isEmpty()) {
|
||||
getChunks().remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,8 +348,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public void write(File file) throws IOException {
|
||||
if(file == null)
|
||||
{
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisVillagerOverride {
|
||||
@Desc("""
|
||||
Disable the trade altogether.
|
||||
If a cartographer villager gets a new explorer map trade:
|
||||
If this is enabled -> the trade is removed
|
||||
If this is disabled -> the trade is replaced with the "override" setting below
|
||||
Default is true, so if you omit this, trades will be removed.""")
|
||||
Disable the trade altogether.
|
||||
If a cartographer villager gets a new explorer map trade:
|
||||
If this is enabled -> the trade is removed
|
||||
If this is disabled -> the trade is replaced with the "override" setting below
|
||||
Default is true, so if you omit this, trades will be removed.""")
|
||||
private boolean disableTrade = true;
|
||||
|
||||
@DependsOn("disableTrade")
|
||||
@@ -44,7 +44,7 @@ public class IrisVillagerOverride {
|
||||
.setMinTrades(3)
|
||||
.setMaxTrades(5));
|
||||
|
||||
public KList<IrisVillagerTrade> getValidItems(){
|
||||
public KList<IrisVillagerTrade> getValidItems() {
|
||||
KList<IrisVillagerTrade> valid = new KList<>();
|
||||
getItems().stream().filter(IrisVillagerTrade::isValidItems).forEach(valid::add);
|
||||
return valid.size() == 0 ? null : valid;
|
||||
|
||||
@@ -4,9 +4,7 @@ package com.volmit.iris.engine.object.villager;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.scheduling.S;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -58,7 +56,7 @@ public class IrisVillagerTrade {
|
||||
* mintrades > 0, maxtrades > 0, maxtrades > mintrades, and<br>
|
||||
* ingredient 1, (if defined ingredient 2) and the result are valid items
|
||||
*/
|
||||
public boolean isValidItems(){
|
||||
public boolean isValidItems() {
|
||||
KList<String> warnings = new KList<>();
|
||||
if (ingredient1 == null) {
|
||||
warnings.add("Ingredient 1 is null");
|
||||
@@ -80,15 +78,15 @@ public class IrisVillagerTrade {
|
||||
warnings.add("More minimal than maximal trades");
|
||||
}
|
||||
|
||||
if (ingredient1 != null && !ingredient1.getType().isItem()){
|
||||
if (ingredient1 != null && !ingredient1.getType().isItem()) {
|
||||
warnings.add("Ingredient 1 is not an item");
|
||||
}
|
||||
|
||||
if (ingredient2 != null && !ingredient2.getType().isItem()){
|
||||
if (ingredient2 != null && !ingredient2.getType().isItem()) {
|
||||
warnings.add("Ingredient 2 is not an item");
|
||||
}
|
||||
|
||||
if (result != null && !result.getType().isItem()){
|
||||
if (result != null && !result.getType().isItem()) {
|
||||
warnings.add("Result is not an item");
|
||||
}
|
||||
|
||||
@@ -103,10 +101,11 @@ public class IrisVillagerTrade {
|
||||
|
||||
/**
|
||||
* Get the ingredients
|
||||
*
|
||||
* @return The list of 1 or 2 ingredients (depending on if ing2 is null)
|
||||
*/
|
||||
public List<ItemStack> getIngredients() {
|
||||
if (!isValidItems()){
|
||||
if (!isValidItems()) {
|
||||
return null;
|
||||
}
|
||||
return ingredient2 == null ? new KList<>(ingredient1) : new KList<>(ingredient1, ingredient2);
|
||||
@@ -122,7 +121,7 @@ public class IrisVillagerTrade {
|
||||
/**
|
||||
* @return the trade as a merchant recipe
|
||||
*/
|
||||
public MerchantRecipe convert(){
|
||||
public MerchantRecipe convert() {
|
||||
MerchantRecipe recipe = new MerchantRecipe(getResult(), getAmount());
|
||||
recipe.setIngredients(getIngredients());
|
||||
return recipe;
|
||||
|
||||
Reference in New Issue
Block a user