remremrem / HyperMerchant

Inventory GUI for HyperConomy and NPC trait for Citizens2
GNU General Public License v3.0
3 stars 11 forks source link

Hot fix for 1.12 support. #17

Closed k-jiang closed 7 years ago

k-jiang commented 7 years ago

It just a simple fix for supporting Bukkit / Spigot 1.12 due to changes of APIs. This fix will not work with 1.11 or lower, though you can still add some version detection into ConfigAccessor.java for backward compability.

k-jiang commented 7 years ago

credit to https://github.com/Abrasam/HyperMerchant/commit/203a2da3ee258a0d8c3b8519c3a9867d1eeafbec

PikaMug commented 7 years ago

@k-jiang All for the update, but could you elaborate on why this breaks compatibility with 1.11? Maybe I'm blind but I don't see any classes named "ConfigAccessor" either.

k-jiang commented 7 years ago

I'm sorry that message was a mistake. I copied it from other plugins :p there were so many like this.

In version 1.12, YamlConfiguration.loadConfiguration() is changed to take InputStreamReader instead of InputStream. If you want to have backward compatibility, a simple solution is you could modify your src/main/java/grokswell/util/MenuButtonData.java and src/main/java/grokswell/util/Blacklist.java, feed the loadConfiguration() method with different types of Stream according to craftbukkit version. Noticed that there should be no error while build no matter what version of spigot/craftbukkit you have in pom.xml.

But to be honest, I'm not a pro. I believe there should be some other nice decent way to do it, just not within my knowledge.

PikaMug commented 7 years ago

@k-jiang Ah okay, but InputStreamReader is a subclass of Reader, and YamlConfiguration.loadConfiguration() has accepted that since at least Bukkit 1.7.10 (source).

I was also guilty of ignoring the InputStream deprecation in Quests. An alternative would be to just use saveResource("npcblacklist.yml", false) but the end result is the same.

@remremrem @RegalOwl Looking forward to this merge <3

remremrem commented 7 years ago

Thank you very much for contributing to the development of HyperMerchant. I have merged the near identical commit by Abrasam since it was submitted first. I would merge your pom.xml file but I don't know of a simple way to cherry pick a single file, so I will edit that file by hand. Thanks again!