Skip to content

Commit

Permalink
sync with sakura-ryoko/servux 1.21.3-0.4.1-sakura.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Dec 29, 2024
1 parent 00249bf commit ad5756c
Show file tree
Hide file tree
Showing 15 changed files with 309 additions and 299 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
## Change
- sync with `sakura-ryoko/servux` 0.4.0-sakura.5
- sync with `sakura-ryoko/servux` 1.21.3-0.4.1-sakura.2
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ For compiled builds (= downloads), see Releases
- Clone the repository
- Open a command prompt/terminal to the repository directory
- run 'gradlew build'
- The built jar file will be in build/libs/
- The built jar file will be in build/libs/

## Credits
- [maruohon/servux](https://github.com/maruohon/servux)
- [sakura-ryoko/servux](https://github.com/sakura-ryoko/servux)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package fi.dy.masa.servux.dataproviders;

import java.util.List;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import fi.dy.masa.servux.settings.IServuxSetting;
import fi.dy.masa.servux.util.JsonUtils;

import net.minecraft.util.Identifier;

import java.util.List;
import fi.dy.masa.servux.settings.IServuxSetting;

public abstract class DataProviderBase implements IDataProvider
{
Expand Down Expand Up @@ -99,10 +99,12 @@ public List<IServuxSetting<?>> getSettings()
public JsonObject toJson()
{
JsonObject object = new JsonObject();

for (IServuxSetting<?> setting : getSettings())
{
object.add(setting.name(), setting.writeToJson());
}

return object;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ public boolean setProviderEnabled(String providerName, boolean enabled)
public boolean setProviderEnabled(IDataProvider provider, boolean enabled)
{
boolean wasEnabled = provider.isEnabled();
enabled = true; // FIXME TODO remove debug

//System.out.printf("setProviderEnabled: %s (%s)\n", enabled, provider);
if (enabled || wasEnabled != enabled)
{
//System.out.printf("setProviderEnabled: %s (%s)\n", enabled, provider);
provider.setEnabled(enabled);
this.updatePacketHandlerRegistration(provider);

Expand Down Expand Up @@ -216,13 +215,35 @@ public void readFromConfig()
provider.fromJson(JsonUtils.getNestedObject(root, name, false));
}
}
}

for (IDataProvider provider : this.providersImmutable)
// If reading the config
for (IDataProvider provider : this.providersImmutable)
{
if (obj != null)
{
this.setProviderEnabled(provider, JsonUtils.getBooleanOrDefault(obj, provider.getName(), false));
}
else
{
this.setProviderEnabled(provider, false);
}
}
}
else
{
String name = provider.getName();
boolean enabled = obj != null && JsonUtils.getBooleanOrDefault(obj, name, false);
this.setProviderEnabled(provider, enabled);
// If writing a new config file (Disable the debug_data by default),
// and then respect the config afterward.
for (IDataProvider provider : this.providersImmutable)
{
if (!provider.getName().equals("debug_data"))
{
this.setProviderEnabled(provider, true);
}
else
{
this.setProviderEnabled(provider, false);
}
}
}
}

Expand Down
Loading

0 comments on commit ad5756c

Please sign in to comment.