Completely redo config

This commit is contained in:
dfsek
2020-10-01 16:31:48 -07:00
parent a5c85a7e5d
commit 6f11222a88
36 changed files with 560 additions and 451 deletions

View File

@@ -1,9 +1,11 @@
package com.dfsek.terra.command;
import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.biome.TerraBiomeGrid;
import com.dfsek.terra.biome.UserDefinedBiome;
import com.dfsek.terra.command.type.PlayerCommand;
import com.dfsek.terra.config.genconfig.BiomeConfig;
import com.dfsek.terra.command.type.WorldCommand;
import com.dfsek.terra.config.base.WorldConfig;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@@ -12,16 +14,12 @@ import org.polydev.gaea.generation.GenerationPhase;
import java.util.Collections;
import java.util.List;
public class BiomeCommand extends PlayerCommand {
public class BiomeCommand extends WorldCommand {
@Override
public boolean onCommand(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
TerraBiomeGrid grid = TerraBiomeGrid.fromWorld(sender.getWorld());
if(grid == null) {
sender.sendMessage("Not a Terra world!");
return true;
}
public boolean onCommand(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World w) {
TerraBiomeGrid grid = TerraWorld.getWorld(sender.getWorld()).getGrid();
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome(sender.getLocation(), GenerationPhase.POPULATE);
sender.sendMessage("You are in " + BiomeConfig.fromBiome(biome).getID());
sender.sendMessage("You are in " + TerraWorld.getWorld(w).getConfig().getBiome(biome).getID());
return true;
}

View File

@@ -1,7 +1,11 @@
package com.dfsek.terra.command;
import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.command.type.PlayerCommand;
import com.dfsek.terra.command.type.WorldCommand;
import com.dfsek.terra.config.base.WorldConfig;
import com.dfsek.terra.config.genconfig.OreConfig;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
@@ -11,12 +15,12 @@ import java.util.Collections;
import java.util.List;
import java.util.Random;
public class OreCommand extends PlayerCommand {
public class OreCommand extends WorldCommand {
@Override
public boolean onCommand(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
public boolean onCommand(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World w) {
Block bl = sender.getTargetBlockExact(25);
if(args.length > 0) {
OreConfig ore = OreConfig.fromID(args[0]);
OreConfig ore = TerraWorld.getWorld(w).getConfig().getOre(args[0]);
if(ore == null) {
sender.sendMessage("Unable to find Ore");
return true;

View File

@@ -45,8 +45,8 @@ public class TerraCommand implements CommandExecutor, TabExecutor {
}
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(args[0].equals("tpbiome")) return BiomeConfig.getBiomeIDs();
/*if(args[0].equals("tpbiome")) return BiomeConfig.getBiomeIDs();
else if(args[0].equals("ore")) return OreConfig.getOreIDs();
else return Collections.emptyList();
else*/ return Collections.emptyList();
}
}

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.command.image.gui;
import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.command.type.WorldCommand;
import com.dfsek.terra.config.base.ConfigUtil;
import com.dfsek.terra.config.base.WorldConfig;
@@ -19,7 +20,7 @@ public class RawGUICommand extends WorldCommand {
sender.sendMessage("Debug mode must be enabled to use the debug GUI! The debug GUI is NOT PRODUCTION SAFE!");
return true;
}
ImageLoader loader = WorldConfig.fromWorld(world).imageLoader;
ImageLoader loader = TerraWorld.getWorld(world).getWorldConfig().imageLoader;
if(loader != null) loader.debug(false, sender.getWorld());
else ImageLoader.debugWorld(false, world);
return true;

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.command.image.gui;
import com.dfsek.terra.TerraWorld;
import com.dfsek.terra.command.type.WorldCommand;
import com.dfsek.terra.config.base.ConfigUtil;
import com.dfsek.terra.config.base.WorldConfig;
@@ -19,7 +20,7 @@ public class StepGUICommand extends WorldCommand {
sender.sendMessage("Debug mode must be enabled to use the debug GUI! The debug GUI is NOT PRODUCTION SAFE!");
return true;
}
ImageLoader loader = WorldConfig.fromWorld(world).imageLoader;
ImageLoader loader = TerraWorld.getWorld(world).getWorldConfig().imageLoader;
if(loader != null) loader.debug(true, sender.getWorld());
else ImageLoader.debugWorld(true, world);
return true;