Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature in config to remove annoying console messages #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/java/io/github/terra121/EarthGeneratorSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.github.opencubicchunks.cubicchunks.cubicgen.preset.fixer.PresetLoadError;
import io.github.terra121.projection.GeographicProjection;
import io.github.terra121.projection.ScaleProjection;
import net.minecraftforge.fml.common.FMLCommonHandler;

public class EarthGeneratorSettings {

Expand All @@ -33,8 +34,8 @@ public static class JsonSettings {
private Gson gson;

public EarthGeneratorSettings(String generatorSettings) {
System.out.println(generatorSettings);

if (!TerraConfig.reducedConsoleMessages) TerraMod.LOGGER.info(generatorSettings);

gson = new GsonBuilder().create();

Expand Down Expand Up @@ -95,7 +96,7 @@ public GeographicProjection getProjection() {
return new ScaleProjection(p, 100000, 100000); //TODO: better default
}

if(settings.scaleX==1&&settings.scaleY==1) System.exit(-1);
if(settings.scaleX==1&&settings.scaleY==1) FMLCommonHandler.instance().exitJava(-1, false);

return new ScaleProjection(p, settings.scaleX, settings.scaleY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public EarthTerrainProcessor(World world) {

surfacePopulators = new HashSet<ICubicPopulator>();
if(doRoads || cfg.settings.osmwater)surfacePopulators.add(new RoadGenerator(osm, heights, projection));
if (TerraConfig.serverTreeEnabled) surfacePopulators.add(new EarthTreePopulator(projection));
if (!TerraConfig.serverTree.isEmpty()) surfacePopulators.add(new EarthTreePopulator(projection));
snow = new SnowPopulator(); //this will go after the rest

cubiccfg = cfg.getCustomCubic();
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/io/github/terra121/TerraConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,20 @@ public class TerraConfig {
@Name("overpass_interpreter")
@Comment({"Overpass interpreter for road and water OpenStreetMap data",
"Make sure you follow the instances guidelines",
"URL must be able to take interpreter input by adding a \'?\'",
"URL must be able to take interpreter input by adding a \"?\"",
"e.x. \"https://.../api/interpreter\""})
public static String serverOverpass = "https://overpass.kumi.systems/api/interpreter"; //"https://overpass-api.de/api/interpreter"

@Name("rest_tree_services")
@Comment({"An ArcGIS REST API instance with tree cover support",
"Should allow all tree data sources used (just TreeCover2000 right now)",
"End with a \"/\" e.x. \"https://.../arcgis/rest/services/\""})
"End with a \"/\" e.x. \"https://.../arcgis/rest/services/\"",
"If the tree cover is not functioning properly, or has errors, leave the value blank"})
public static String serverTree = "https://gis-treecover.wri.org/arcgis/rest/services/";
@Name("rest_tree_services_enabled")
@Comment({"If the ArcGIS TreeCover2000 should be used, if errors appear then disable it."})
public static boolean serverTreeEnabled = true;


@Name("terrarium_instance")
@Comment({"A Mapzen Terrain Tile terrarium instance allowing x/y.png queries",
"End with a \"/\" e.x. https://.../terrarium/"})
"End with a \"/\" e.x. \"https://.../terrarium/\""})
public static String serverTerrain = "https://s3.amazonaws.com/elevation-tiles-prod/terrarium/";

@Name("cache_size")
Expand Down Expand Up @@ -56,6 +54,11 @@ public class TerraConfig {
@Comment({"Allows caves in the Terra121 world, not recommended because it can ruin the look of most terrain."})
public static boolean caves = false;

@Name("reduced_console_messages")
@Comment({"Removes all of Terra121's messages which contain various links in the server console",
"This is just if it seems to spam the console, it is purely for appearance"})
public static boolean reducedConsoleMessages = false;

@SubscribeEvent
public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if(TerraMod.MODID.equals(event.getModID()))
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/io/github/terra121/control/TerraCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import io.github.opencubicchunks.cubicchunks.api.worldgen.ICubeGenerator;
import io.github.opencubicchunks.cubicchunks.core.server.CubeProviderServer;
import io.github.terra121.TerraConfig;
import io.github.terra121.TerraMod;
import net.minecraft.command.CommandBase;
import net.minecraft.entity.Entity;
import net.minecraft.command.CommandException;
Expand Down Expand Up @@ -202,8 +204,8 @@ private String doInvert(double[] pos, EarthTerrainProcessor terrain, boolean res

Water water = terrain.osm.water;
water.doingInverts = true;
System.out.println(region);

if (!TerraConfig.reducedConsoleMessages) TerraMod.LOGGER.info(region);

if( restore ? water.inverts.remove(region) : water.inverts.add(region) ) {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/github/terra121/dataset/Heights.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected int[] request(Coord place) {

try {
String urlText = url_prefix + place.x + "/" + place.y + ".png";
TerraMod.LOGGER.info(urlText);
if (!TerraConfig.reducedConsoleMessages) TerraMod.LOGGER.info(urlText);

URL url = new URL(urlText);
URLConnection con = url.openConnection();
Expand Down Expand Up @@ -81,11 +81,11 @@ protected int[] request(Coord place) {
} catch (IOException e) {}
}

TerraMod.LOGGER.error("Failed to get elevation " + place.x + " " + place.y + " : " + ioe);
if (!TerraConfig.reducedConsoleMessages) TerraMod.LOGGER.error("Failed to get elevation " + place.x + " " + place.y + " : " + ioe);
}
}

TerraMod.LOGGER.error("Failed too many times chunks will be set to 0");
TerraMod.LOGGER.error("Failed too many times, chunks will be set to 0.");
return out;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public boolean regiondownload(Region region) {
String urltext = URL_PREFACE + bbox + URL_A + bbox + URL_B;
if (doWater) urltext += URL_C + bottomleft + URL_SUFFIX;

TerraMod.LOGGER.info(urltext);
if (!TerraConfig.reducedConsoleMessages) TerraMod.LOGGER.info(urltext);

//kumi systems request a meaningful user-agent
URL url = new URL(urltext);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/io/github/terra121/dataset/SaturationTrees.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected int[] request(Coord place) {

try {
String urlText = URL_PREFIX + (place.x*REGION_SIZE - 180) + "," + (90-place.y*REGION_SIZE) + "," + ((place.x+1)*REGION_SIZE - 180) + "," + (90 - (place.y+1)*REGION_SIZE) +URL_SUFFIX;
TerraMod.LOGGER.info(urlText);
if (!TerraConfig.reducedConsoleMessages) TerraMod.LOGGER.info(urlText);
URL url = new URL(urlText);
is = url.openStream();
ByteSourceInputStream by = new ByteSourceInputStream(is, "shits and giggles");
Expand Down Expand Up @@ -68,11 +68,12 @@ protected int[] request(Coord place) {
} catch (IOException e) {}
}

TerraMod.LOGGER.error("Failed to get tree cover data " + place.x + " " + place.y + " : " + ioe);
if (!TerraConfig.reducedConsoleMessages) TerraMod.LOGGER.error("Failed to get tree cover data " + place.x + " " + place.y + " : " + ioe);
}
}

TerraMod.LOGGER.error("Failed too many times, trees will not spawn");
TerraMod.LOGGER.error("Tree cover has failed too many times, trees will not spawn. " +
"If this is a recurring issue then disable the tree cover in the config by leaving it blank.");
return out;
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/io/github/terra121/dataset/Trees.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected double dataToDouble(int data) {
protected int[] request(Coord place) {
int out[] = new int[256 * 256];

if (!TerraConfig.serverTreeEnabled) {
if (TerraConfig.serverTree.isEmpty()) {
return out;
}

Expand All @@ -43,7 +43,7 @@ protected int[] request(Coord place) {

try {
String urlText = URL_PREFIX + (place.x*REGION_SIZE - 180) + "," + (90-place.y*REGION_SIZE) + "," + ((place.x+1)*REGION_SIZE - 180) + "," + (90 - (place.y+1)*REGION_SIZE) +URL_SUFFIX;
TerraMod.LOGGER.info(urlText);
if (!TerraConfig.reducedConsoleMessages) TerraMod.LOGGER.info(urlText);

URL url = new URL(urlText);
URLConnection con = url.openConnection();
Expand Down Expand Up @@ -79,11 +79,12 @@ protected int[] request(Coord place) {
} catch (IOException e) {}
}

TerraMod.LOGGER.error("Failed to get tree cover data " + place.x + " " + place.y + " : " + ioe);
if (!TerraConfig.reducedConsoleMessages) TerraMod.LOGGER.error("Failed to get tree cover data " + place.x + " " + place.y + " : " + ioe);
}
}

TerraMod.LOGGER.error("Failed too many times, trees will not spawn. ");
TerraMod.LOGGER.error("Tree cover has failed too many times, trees will not spawn. " +
"If this is a recurring issue then disable the tree cover in the config by leaving it blank.");
return out;
}

Expand Down