pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
+67 -86
View File
@@ -18,7 +18,6 @@
package appeng.util;
import java.util.EnumMap;
import java.util.Map;
import java.util.Set;
@@ -31,102 +30,84 @@ import appeng.api.config.StorageFilter;
import appeng.api.util.IConfigManager;
import appeng.core.AELog;
public final class ConfigManager implements IConfigManager {
private final Map<Settings, Enum<?>> settings = new EnumMap<>(Settings.class);
private final IConfigManagerHost target;
public final class ConfigManager implements IConfigManager
{
private final Map<Settings, Enum<?>> settings = new EnumMap<>( Settings.class );
private final IConfigManagerHost target;
public ConfigManager(final IConfigManagerHost tile) {
this.target = tile;
}
public ConfigManager( final IConfigManagerHost tile )
{
this.target = tile;
}
@Override
public Set<Settings> getSettings() {
return this.settings.keySet();
}
@Override
public Set<Settings> getSettings()
{
return this.settings.keySet();
}
@Override
public void registerSetting(final Settings settingName, final Enum defaultValue) {
this.settings.put(settingName, defaultValue);
}
@Override
public void registerSetting( final Settings settingName, final Enum defaultValue )
{
this.settings.put( settingName, defaultValue );
}
@Override
public Enum<?> getSetting(final Settings settingName) {
final Enum<?> oldValue = this.settings.get(settingName);
@Override
public Enum<?> getSetting( final Settings settingName )
{
final Enum<?> oldValue = this.settings.get( settingName );
if (oldValue != null) {
return oldValue;
}
if( oldValue != null )
{
return oldValue;
}
throw new IllegalStateException("Invalid Config setting. Expected a non-null value for " + settingName);
}
throw new IllegalStateException( "Invalid Config setting. Expected a non-null value for " + settingName );
}
@Override
public Enum<?> putSetting(final Settings settingName, final Enum newValue) {
final Enum<?> oldValue = this.getSetting(settingName);
this.settings.put(settingName, newValue);
this.target.updateSetting(this, settingName, newValue);
return oldValue;
}
@Override
public Enum<?> putSetting( final Settings settingName, final Enum newValue )
{
final Enum<?> oldValue = this.getSetting( settingName );
this.settings.put( settingName, newValue );
this.target.updateSetting( this, settingName, newValue );
return oldValue;
}
/**
* save all settings using config manager.
*
* @param tagCompound to be written to compound
*/
@Override
public void writeToNBT(final CompoundNBT tagCompound) {
for (final Map.Entry<Settings, Enum<?>> entry : this.settings.entrySet()) {
tagCompound.putString(entry.getKey().name(), this.settings.get(entry.getKey()).toString());
}
}
/**
* save all settings using config manager.
*
* @param tagCompound to be written to compound
*/
@Override
public void writeToNBT( final CompoundNBT tagCompound )
{
for( final Map.Entry<Settings, Enum<?>> entry : this.settings.entrySet() )
{
tagCompound.putString( entry.getKey().name(), this.settings.get( entry.getKey() ).toString() );
}
}
/**
* read all settings using config manager.
*
* @param tagCompound to be read from compound
*/
@Override
public void readFromNBT(final CompoundNBT tagCompound) {
for (final Map.Entry<Settings, Enum<?>> entry : this.settings.entrySet()) {
try {
if (tagCompound.contains(entry.getKey().name())) {
String value = tagCompound.getString(entry.getKey().name());
/**
* read all settings using config manager.
*
* @param tagCompound to be read from compound
*/
@Override
public void readFromNBT( final CompoundNBT tagCompound )
{
for( final Map.Entry<Settings, Enum<?>> entry : this.settings.entrySet() )
{
try
{
if( tagCompound.contains( entry.getKey().name() ) )
{
String value = tagCompound.getString( entry.getKey().name() );
// Provides an upgrade path for the rename of this value in the API between rv1
// and rv2
if (value.equals("EXTACTABLE_ONLY")) {
value = StorageFilter.EXTRACTABLE_ONLY.toString();
} else if (value.equals("STOREABLE_AMOUNT")) {
value = LevelEmitterMode.STORABLE_AMOUNT.toString();
}
// Provides an upgrade path for the rename of this value in the API between rv1 and rv2
if( value.equals( "EXTACTABLE_ONLY" ) )
{
value = StorageFilter.EXTRACTABLE_ONLY.toString();
}
else if( value.equals( "STOREABLE_AMOUNT" ) )
{
value = LevelEmitterMode.STORABLE_AMOUNT.toString();
}
final Enum<?> oldValue = this.settings.get(entry.getKey());
final Enum<?> oldValue = this.settings.get( entry.getKey() );
final Enum<?> newValue = Enum.valueOf(oldValue.getClass(), value);
final Enum<?> newValue = Enum.valueOf( oldValue.getClass(), value );
this.putSetting( entry.getKey(), newValue );
}
}
catch( final IllegalArgumentException e )
{
AELog.debug( e );
}
}
}
this.putSetting(entry.getKey(), newValue);
}
} catch (final IllegalArgumentException e) {
AELog.debug(e);
}
}
}
}