More lombok

This commit is contained in:
Runemoro 2017-12-07 00:58:19 -05:00
parent 1e6ceda064
commit 79cc174daf
4 changed files with 25 additions and 99 deletions

View file

@ -10,6 +10,8 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@ -24,27 +26,26 @@ public class DDConfig {
public static final boolean HAVE_CONFIG_DEFAULTS_BEEN_CHECKED_FOR_CORRECTNESS = false; //@todo check this at each non-alpha release. This field does not have a use in the mod itself, but should ensure that the developers of this mod, don't forget to reset the config defaults to the right values before releasing a non-alpha release
public static File configurationFolder;
private static int pocketGridSize = 32;
private static int maxPocketSize = 15;
private static int privatePocketSize = 3;
private static int publicPocketSize = 2;
private static int baseDimID = 684;
@Getter private static int pocketGridSize = 32;
@Getter private static int maxPocketSize = 15;
@Getter private static int privatePocketSize = 3;
@Getter private static int publicPocketSize = 2;
@Getter private static int baseDimID = 684;
private static String[] dungeonSchematicNames = {
"default_dungeon_normal",
"default_dungeon_nether"
}; //@todo set default dungeon names
private static int maxDungeonDepth = 8;
private static int owCoordinateOffsetBase = 64;
private static double owCoordinateOffsetPower = 1.3;
private static int[] doorRelativeDepths = {-1, 0, 1};
private static int[] doorRelativeDepthWeights = {20, 30, 50};
@Getter private static int maxDungeonDepth = 100;
@Getter private static int owCoordinateOffsetBase = 64;
@Getter private static double owCoordinateOffsetPower = 1.3;
@Getter private static int[] doorRelativeDepths = {-1, 0, 1};
@Getter private static int[] doorRelativeDepthWeights = {20, 30, 50};
private static boolean dangerousLimboMonolithsEnabled = false;
private static boolean monolithTeleportationEnabled = true;
@Getter private static boolean dangerousLimboMonolithsEnabled = false;
@Getter private static boolean monolithTeleportationEnabled = true;
private static int setConfigIntWithMaxAndMin(Configuration config, String category, String key, int defaultValue, String comment, int minValue, int maxValue) {
Property prop = config.get(category, key, defaultValue,
comment, minValue, maxValue);
Property prop = config.get(category, key, defaultValue, comment, minValue, maxValue);
int value = prop.getInt(defaultValue);
if (value < minValue) {
value = minValue;
@ -56,7 +57,6 @@ public class DDConfig {
}
public static void loadConfig(FMLPreInitializationEvent event) {
// Load config
configurationFolder = new File(event.getModConfigurationDirectory(), "/DimDoors");
if (!configurationFolder.exists()) {
@ -99,11 +99,11 @@ public class DDConfig {
//Monoliths
config.addCustomCategoryComment("monoliths", "How dangerous are Monoliths");
prop = config.get("monoliths", "dangerousLimboMonolithsDisabled", dangerousLimboMonolithsEnabled,
prop = config.get("monoliths", "dangerousLimboMonoliths", dangerousLimboMonolithsEnabled,
"Are Monoliths in Limbo Dangerous? [default: false]");
dangerousLimboMonolithsEnabled = prop.getBoolean();
prop = config.get("monoliths", "monolithTeleportationEnabled", monolithTeleportationEnabled,
prop = config.get("monoliths", "monolithTeleportation", monolithTeleportationEnabled,
"Is Monolith Teleportation enabled? [default: true]");
monolithTeleportationEnabled = prop.getBoolean();
@ -117,10 +117,10 @@ public class DDConfig {
"Sets how deep and wide any pocket can be. [min: 0, max: pocketGridSize/2, default: 4]", 0, (int) ((double) pocketGridSize / 2 - 0.5));
privatePocketSize = setConfigIntWithMaxAndMin(config, "pocket_dimension", "privatePocketSize", privatePocketSize,
"Sets how deep and wide any personal pocket can be. [min: 0, max: maxPocketsSize, default: 3]", 0, maxPocketSize);
"Sets how deep and wide any personal pocket can be. [min: 0, max: maxPocketSize, default: 3]", 0, maxPocketSize);
publicPocketSize = setConfigIntWithMaxAndMin(config, "pocket_dimension", "publicPocketSize", publicPocketSize,
"Sets how deep and wide any public pocket can be. [min: 0, max: maxPocketsSize, default: 2]", 0, maxPocketSize);
"Sets how deep and wide any public pocket can be. [min: 0, max: maxPocketSize, default: 2]", 0, maxPocketSize);
// Save config
config.save();
@ -142,73 +142,4 @@ public class DDConfig {
}
}
}
public static int getPocketGridSize() {
return pocketGridSize;
}
public static int getMaxPocketsSize() {
return maxPocketSize;
}
public static int getPrivatePocketSize() {
return privatePocketSize;
}
public static int getPublicPocketSize() {
return publicPocketSize;
}
public static List<String> getDungeonSchematicNames() {
List<String> dungeonSchematicNamesArrayList = new ArrayList<>();
Collections.addAll(dungeonSchematicNamesArrayList, dungeonSchematicNames);
return dungeonSchematicNamesArrayList;
}
public static int getBaseDimID() {
return baseDimID;
}
/**
* @return the owCoordinateOffsetBase
*/
public static int getOwCoordinateOffsetBase() {
return owCoordinateOffsetBase;
}
/**
* @return the owCoordinateOffsetPower
*/
public static double getOwCoordinateOffsetPower() {
return owCoordinateOffsetPower;
}
/**
* @return the doorRelativeDepths
*/
public static int[] getDoorRelativeDepths() {
return doorRelativeDepths;
}
/**
* @return the doorRelativeDepthWeights
*/
public static int[] getDoorRelativeDepthWeights() {
return doorRelativeDepthWeights;
}
/**
* @return the maxDungeonDepth
*/
public static int getMaxDungeonDepth() {
return maxDungeonDepth;
}
public static boolean isDangerousLimboMonolithsDisabled() {
return dangerousLimboMonolithsEnabled;
}
public static boolean isMonolithTeleportationEnabled() {
return monolithTeleportationEnabled;
}
}

View file

@ -8,7 +8,6 @@ package com.zixiken.dimdoors.shared;
import com.zixiken.dimdoors.shared.util.Location;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.shared.util.RandomUtils;
import com.zixiken.dimdoors.shared.util.Schematic;
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
import java.util.ArrayList;
import java.util.HashMap;
@ -61,14 +60,14 @@ public class PocketRegistry {
pocketLists.get(pocketType).clear();
}
gridSize = DDConfig.getPocketGridSize();
maxPocketSize = DDConfig.getMaxPocketsSize();
maxPocketSize = DDConfig.getMaxPocketSize();
privatePocketSize = DDConfig.getPrivatePocketSize();
publicPocketSize = DDConfig.getPublicPocketSize();
PocketSavedData.get(DimDoors.getDefWorld()).markDirty();
}
public void readFromNBT(NBTTagCompound nbt) {
if (nbt.hasKey("gridSize")) { //if this info has been saved before
if (nbt.hasKey("gridSize")) {
gridSize = nbt.getInteger("gridSize");
maxPocketSize = nbt.getInteger("maxPocketSize");
privatePocketSize = nbt.getInteger("privatePocketSize");

View file

@ -5,9 +5,7 @@
*/
package com.zixiken.dimdoors.shared;
import com.zixiken.dimdoors.shared.util.DefaultSchematicGenerator;
import com.zixiken.dimdoors.shared.util.MathUtils;
import com.zixiken.dimdoors.shared.util.RandomUtils;
import com.zixiken.dimdoors.shared.util.Schematic;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@ -22,7 +20,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.*;
@ -31,7 +28,6 @@ import java.util.logging.Logger;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.CompressedStreamTools;
import org.apache.commons.io.IOUtils;
import scala.tools.nsc.Global;
/**
*
@ -285,17 +281,17 @@ public class SchematicHandler {
}
public PocketTemplate getPersonalPocketTemplate() {
return getRandomTemplate("private", -1, DDConfig.getMaxPocketsSize(), true); // TODO: config option for getLargest
return getRandomTemplate("private", -1, DDConfig.getMaxPocketSize(), true); // TODO: config option for getLargest
}
public PocketTemplate getPublicPocketTemplate() {
return getRandomTemplate("private", -1, DDConfig.getMaxPocketsSize(), true); // TODO: config option for getLargest
return getRandomTemplate("private", -1, DDConfig.getMaxPocketSize(), true); // TODO: config option for getLargest
}
public PocketTemplate getDungeonTemplate(float netherProbability, int depth) {
Random random = new Random();
String group = (random.nextFloat() < netherProbability) ? "nether" : "ruins";
return getRandomTemplate(group, depth, DDConfig.getMaxPocketsSize(), false);
return getRandomTemplate(group, depth, DDConfig.getMaxPocketSize(), false);
}
public void saveSchematic(Schematic schematic, String name) {

View file

@ -55,7 +55,7 @@ public class MobMonolith extends EntityFlying implements IMob {
}
public boolean isDangerous() {
return DDConfig.isMonolithTeleportationEnabled() && (world.provider instanceof WorldProviderLimbo || !DDConfig.isDangerousLimboMonolithsDisabled());
return DDConfig.isMonolithTeleportationEnabled() && (world.provider instanceof WorldProviderLimbo || DDConfig.isDangerousLimboMonolithsEnabled());
}
@Override