Skip to content

Commit

Permalink
config: Add a vanilla environment key
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Aug 22, 2020
1 parent 8772692 commit 0672b7d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.spongepowered.common.config.core.SpongeConfigs;
import org.spongepowered.plugin.PluginEnvironment;

@ConfigSerializable
public class OptimizationCategory {
Expand Down Expand Up @@ -121,7 +123,7 @@ public class OptimizationCategory {
public OptimizationCategory() {
// Enabled by default on SpongeVanilla, disabled by default on SpongeForge.
// Because of how early this constructor gets called, we can't use SpongeImplHooks or even Game
this.preItemDropMerge = true; //Launcher.getInstance().isVanilla(); // TODO: expose this in the PluginEnvironment if necessary
this.preItemDropMerge = SpongeConfigs.getPluginEnvironment().getBlackboard().get(SpongeConfigs.IS_VANILLA_PLATFORM).orElse(true);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.spongepowered.common.config.core.SpongeConfigs;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -177,7 +178,7 @@ public Map<String, Boolean> getAutoFixedTiles() {
}

private boolean isVanilla() {
return true; //Launcher.getInstance().isVanilla(); // TODO: expose this in the PluginEnvironment if necessary
return SpongeConfigs.getPluginEnvironment().getBlackboard().get(SpongeConfigs.IS_VANILLA_PLATFORM).orElse(true);
}

public void setAutoFixedTiles(Map<String, Boolean> autoFixedTiles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.spongepowered.common.config.common.CommonConfig;
import org.spongepowered.common.config.inheritable.GlobalConfig;
import org.spongepowered.common.config.inheritable.WorldConfig;
import org.spongepowered.plugin.Blackboard;
import org.spongepowered.plugin.PluginEnvironment;
import org.spongepowered.plugin.PluginKeys;

Expand All @@ -45,6 +46,8 @@
*/
public class SpongeConfigs {

public static final Blackboard.Key<Boolean> IS_VANILLA_PLATFORM = Blackboard.Key.of("is_vanilla", Boolean.class);

public static final String METRICS_NAME = "metrics.conf";

static final String HEADER = "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.spongepowered.common.config.core.SpongeConfigs;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -119,7 +120,7 @@ public WorldCategory() {
try {
// Enabled by default on SpongeVanilla, disabled by default on SpongeForge.
// Because of how early this constructor gets called, we can't use SpongeImplHooks or even Game
this.denyChunkRequests = true; //Launcher.getInstance().isVanilla(); // TODO: expose this in the plugin environment if necessary
this.denyChunkRequests = SpongeConfigs.getPluginEnvironment().getBlackboard().get(SpongeConfigs.IS_VANILLA_PLATFORM).orElse(true);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static void main(final String[] args) throws IOException {
}
// TODO Read in plugin directories from CLI/Config
pluginEnvironment.getBlackboard().getOrCreate(PluginKeys.PLUGIN_DIRECTORIES, () -> Arrays.asList(modsDirectory, gameDirectory.resolve("plugins")));
pluginEnvironment.getBlackboard().getOrCreate(SpongeConfigs.IS_VANILLA_PLATFORM, () -> true);

SpongeConfigs.initialize(pluginEnvironment);
Main.pluginEngine = new VanillaPluginEngine(pluginEnvironment);
Expand Down

0 comments on commit 0672b7d

Please sign in to comment.