From a81b2b18929d2cc4cac20d41aedfdf0d44034130 Mon Sep 17 00:00:00 2001 From: TBEA <74006945+RealTBEA@users.noreply.github.com> Date: Sat, 14 Sep 2024 22:18:39 -0400 Subject: [PATCH] Update AbstractControlCar.java * Quick change to use enum --- .../train/common/api/AbstractControlCar.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/train/common/api/AbstractControlCar.java b/src/main/java/train/common/api/AbstractControlCar.java index de3d1b6f3..fe42cf8a4 100644 --- a/src/main/java/train/common/api/AbstractControlCar.java +++ b/src/main/java/train/common/api/AbstractControlCar.java @@ -115,11 +115,10 @@ protected void readEntityFromNBT(NBTTagCompound ntc) lightingDetailsJSONObject = lightingDetailsAsJSON(); } - isLightsEnabled = lightingDetailsJSONObject.get("isLightsEnabled").getAsBoolean(); - isBeaconEnabled = lightingDetailsJSONObject.get("isBeaconEnabled").getAsBoolean(); - ditchLightMode = lightingDetailsJSONObject.get("ditchLightMode").getAsByte(); - beaconCycleIndex = lightingDetailsJSONObject.get("beaconCycleIndex").getAsByte(); - + isLightsEnabled = lightingDetailsJSONObject.get(DataMemberName.isLightsEnabled.AsString()).getAsBoolean(); + isBeaconEnabled = lightingDetailsJSONObject.get(DataMemberName.isBeaconEnabled.AsString()).getAsBoolean(); + ditchLightMode = lightingDetailsJSONObject.get(DataMemberName.ditchLightMode.AsString()).getAsByte(); + beaconCycleIndex = lightingDetailsJSONObject.get(DataMemberName.beaconCycleIndex.AsString()).getAsByte(); dataWatcher.updateObject(28, lightingDetailsJSONString()); } @@ -439,10 +438,10 @@ public String lightingDetailsJSONString() public JsonObject lightingDetailsAsJSON() { JsonObject lightingDetailsJSON = new JsonObject(); - lightingDetailsJSON.addProperty("isLightsEnabled", isLightsEnabled); - lightingDetailsJSON.addProperty("isBeaconEnabled", isBeaconEnabled); - lightingDetailsJSON.addProperty("beaconCycleIndex", beaconCycleIndex); - lightingDetailsJSON.addProperty("ditchLightMode", ditchLightMode); + lightingDetailsJSON.addProperty(DataMemberName.isLightsEnabled.AsString(), isLightsEnabled); + lightingDetailsJSON.addProperty(DataMemberName.isBeaconEnabled.AsString(), isBeaconEnabled); + lightingDetailsJSON.addProperty(DataMemberName.beaconCycleIndex.AsString(), beaconCycleIndex); + lightingDetailsJSON.addProperty(DataMemberName.ditchLightMode.AsString(), ditchLightMode); return lightingDetailsJSON; } @@ -480,22 +479,22 @@ public int getLocomotiveBeingControlledEntityID() public boolean isLightsEnabled() { - return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get("isLightsEnabled").getAsBoolean(); + return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get(DataMemberName.isLightsEnabled.AsString()).getAsBoolean(); } public boolean isBeaconEnabled() { - return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get("isBeaconEnabled").getAsBoolean(); + return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get(DataMemberName.isBeaconEnabled.AsString()).getAsBoolean(); } public byte getBeaconCycleIndex() { - return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get("beaconCycleIndex").getAsByte(); + return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get(DataMemberName.beaconCycleIndex.AsString()).getAsByte(); } public boolean isDitchLightsEnabled() { - return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get("ditchLightMode").getAsByte() > 0; + return AsJsonObject(dataWatcher.getWatchableObjectString(28)).get(DataMemberName.ditchLightMode.AsString()).getAsByte() > 0; } private JsonObject AsJsonObject(String string)