Java Code Examples for net.minecraftforge.common.config.Property#getString()

The following examples show how to use net.minecraftforge.common.config.Property#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TFCOptions.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static String getStringFor(Configuration config, String heading, String item, String value)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		return prop.getString();
	} catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add String, config wasn't loaded properly!");
	}
	return value;
}
 
Example 2
Source File: TFCOptions.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static String getStringFor(Configuration config, String heading, String item, String value, String comment)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		prop.setComment(comment);
		return prop.getString();
	} catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add String, config wasn't loaded properly!");
	}
	return value;
}
 
Example 3
Source File: Settings.java    From MediaMod with GNU General Public License v3.0 4 votes vote down vote up
private static void updateConfig(Configuration configuration, boolean load) {
    Property enabledProperty = configuration.get("General", "enabled", true);
    Property showPlayerProperty = configuration.get("General", "showPlayer", true);
    Property modernPlayerProperty = configuration.get("Player", "modernPlayer", true);
    Property albumArtProperty = configuration.get("Player", "showAlbumArt", true);
    Property autoColorProperty = configuration.get("Player", "automaticColorSelection", true);
    Property saveSpotifyTokenProperty = configuration.get("General", "saveSpotifyToken", true);
    Property announceTracksProperty = configuration.get("Player", "announceTracks", true);
    Property playerXProperty = configuration.get("Player", "playerX", 5.0);
    Property playerYProperty = configuration.get("Player", "playerY", 5.0);
    Property playerZoomProperty = configuration.get("Player", "playerZoom", 1.0);
    Property browserExtProperty = configuration.get("Player", "useBrowserExtension", true);
    Property progressStyleProperty = configuration.get("Player", "progressStyle", ProgressStyle.BAR_AND_NUMBERS_NEW.name());
    Property refreshTokenProperty = configuration.get("Spotify", "refreshToken", "");

    if (load) SAVE_SPOTIFY_TOKEN = saveSpotifyTokenProperty.getBoolean();
    else saveSpotifyTokenProperty.setValue(SAVE_SPOTIFY_TOKEN);

    if (load) REFRESH_TOKEN = refreshTokenProperty.getString();
    else {
        if(SAVE_SPOTIFY_TOKEN) {
            refreshTokenProperty.setValue(REFRESH_TOKEN);
        } else {
            refreshTokenProperty.setValue("");
        }
    }

    if (load) ENABLED = enabledProperty.getBoolean();
    else enabledProperty.setValue(ENABLED);

    if (load) ANNOUNCE_TRACKS = announceTracksProperty.getBoolean();
    else announceTracksProperty.setValue(ANNOUNCE_TRACKS);

    if (load) PROGRESS_STYLE = ProgressStyle.valueOf(progressStyleProperty.getString());
    else progressStyleProperty.setValue(PROGRESS_STYLE.name());

    if (load) SHOW_PLAYER = showPlayerProperty.getBoolean();
    else showPlayerProperty.setValue(SHOW_PLAYER);

    if (load) MODERN_PLAYER_STYLE = modernPlayerProperty.getBoolean();
    else modernPlayerProperty.setValue(MODERN_PLAYER_STYLE);

    if (load) SHOW_ALBUM_ART = albumArtProperty.getBoolean();
    else albumArtProperty.setValue(SHOW_ALBUM_ART);

    if (load) AUTO_COLOR_SELECTION = autoColorProperty.getBoolean();
    else autoColorProperty.setValue(AUTO_COLOR_SELECTION);

    if (load) PLAYER_X = playerXProperty.getDouble();
    else playerXProperty.setValue(PLAYER_X);

    if (load) PLAYER_Y = playerYProperty.getDouble();
    else playerYProperty.setValue(PLAYER_Y);

    if (load) PLAYER_ZOOM = playerZoomProperty.getDouble();
    else playerZoomProperty.setValue(PLAYER_ZOOM);

    if (load) EXTENSION_ENABLED = browserExtProperty.getBoolean();
    else browserExtProperty.setValue(EXTENSION_ENABLED);
}