Closed revelation343 closed 10 months ago
You forgot to paste the crash message. Also I think for 2023 you'd want case 16:
.
I have not tested this code but I think a simple dynamic way of parsing and storing them is the the easiest, really:
[...]
private final Map<String, Integer> presentMap = new HashMap<>();
@Override
public void configure(Properties properties) {
for(String key : properties.stringPropertyNames()) {
if (key.startsWith("present")) {
Integer present = Integer.valueOf(properties.getProperty(key));
presentMap.put(key, present);
LOGGER.log(Level.INFO, key + ": " + present);
}
}
}
[...]
private GiftData createGiftData(byte auxdata) {
String presentString = "present" + (2007+auxdata);
if(presentMap.containsKey(presentString)) {
return new GiftData(presentMap.get(presentString));
} else {
return OpenPresentActionPerformer.getDefaultPresentData(auxdata);
}
}
[...]
case 14: return new OpenPresentActionPerformer.GiftData(this.present2023);
Ah sorry Tyoda, I meant to state that I did not add this line of code which is why it didn't work^
I was in a bit of a hurry and didn't catch the actual error as it was spamming the console until the server shut down gracefully. So I just replaced it with the old .jar for now. However, what you have suggested looks like a good way to handle future years without having to intialize variable per year and also not having to add the code to the action performer. I think you've nailed it on the head!
The upper limit is now 2134 (2007+127)
To the best of my review, christmasmod only configures up to the year 2020 due to the variables within the christmasmod.java class. I attempted to add 2023 and have it read from the christmasmod.config however, it would not compile with modlauncher 0.45 due to super.action not being available in the OpenPresentActionPerformer.java
I removed the super. from the code and it was able to compile from there.
I will likely work on fixing this for myself, but figured I would mention it since it is a popular mod.
I set the variable to the default in the code int present2023 = 972 and added the following:
I still received a farwalker amulet despite the .config edit. Then the server crashed due to the following: I believe it would also be required to add:
For it to work and not crash the server. However, the holidays are a busy time so I will manually handle gifts. Maybe an update to the code would help out people who do not/cannot figure out java, Maybe adding the next 5-10 years as a proactive approach would be positive. Also someway to remove setflag(62, true) across all players in a command as I've had mixed luck with update players set reimbursed=0; in players.db which was the suggested method so players could receive gifts again, I'm not sure if there has been a way to automatically reset this flag looking at source. Thanks!