Add advancements#760
Conversation
| RebarRegistry.ADVANCEMENTS.register(this) | ||
| } | ||
|
|
||
| fun vanilla(): Advancement = Bukkit.getAdvancement(key)!! |
There was a problem hiding this comment.
imo should be nullable, I don't think this should throw an exception if called before register()
There was a problem hiding this comment.
the config adapter calls register and I think I'd just end up null asserting everywhere else so not gonna bother
| val resourceKey = identifierFromKey(key) | ||
| val mapBuilder = ImmutableMap.builder<Identifier, AdvancementHolder>() | ||
| mapBuilder.putAll(MinecraftServer.getServer().advancements.advancements) | ||
| val advancementHolder = AdvancementHolder(resourceKey, nmsAdvancement) | ||
| mapBuilder.put(resourceKey, advancementHolder) | ||
| MinecraftServer.getServer().advancements.advancements = mapBuilder.build() | ||
| val tree = MinecraftServer.getServer().advancements.tree() | ||
| tree.addAll(listOf(advancementHolder)) | ||
| val node: AdvancementNode? = tree.get(resourceKey) | ||
| if (node != null) { | ||
| val root = node.root() | ||
| if (root.holder().value().display().isPresent) { | ||
| TreeNodePosition.run(root) | ||
| } | ||
| } |
There was a problem hiding this comment.
is there any way at all to make this more readable
JustAHuman-xD
left a comment
There was a problem hiding this comment.
I meant to make these comments like a week ago or something and never finished the review lol
| ) | ||
| val itemIsVanilla = RebarItem.isRebarItem(item) | ||
| item.amount = criteria.itemCount | ||
| for (player in Bukkit.getOnlinePlayers()) { |
There was a problem hiding this comment.
you don't check if the player has the advancement or pre-reqs already
|
|
||
| object Ticker : Runnable { | ||
| // I don't even want to think about the performance of this method... | ||
| override fun run() { |
There was a problem hiding this comment.
this method should be restructured a bit too, first get all of the advancements that have this criteria, if none, return early, then the player loop should be the top level & it should iterate over the inventory only once and gather all of the types (using the wrapper) -> counts, then iterate over the advancements, if they do not have the advancement and have its parents/pre-reqs, then check if they meet it
Tasklist:
I have a very high degree of confidence in this code getting roasted in CR