Skip to content

Commit

Permalink
sync with sakura-ryoko/servux 1.21-0.3.11-sakura.2, packaged badpac…
Browse files Browse the repository at this point in the history
…kets apis
  • Loading branch information
TexBlock committed Dec 29, 2024
1 parent addff3e commit b36ab29
Show file tree
Hide file tree
Showing 20 changed files with 504 additions and 368 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.3.9-sakura.1
- sync with `sakura-ryoko/servux` 1.21-0.3.11-sakura.2
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 b36ab29

Please sign in to comment.