-
Notifications
You must be signed in to change notification settings - Fork 7
Add InventoryEffectItem class #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/item/base/InventoryEffectItem.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think an abstraction like this should be in core. This seems like it would be more fitting for a Talisman base class in pylon-base. Any other thoughts?
| private val effectKey = NamespacedKey(key.namespace, key.key + "_effect") | ||
|
|
||
| companion object { | ||
| private val tasks = HashMap<NamespacedKey, WeakHashMap<UUID, BukkitTask>>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think this needs to be weak
| /** | ||
| * Remove the effect from the player. | ||
| */ | ||
| protected abstract fun removeEffect(player: Player, stack: ItemStack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should note in doc that there is no guarantee that this current pylon item instance is up to date with the itemstack when it runs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better abstraction could be made here: instead of 'effects' jst have this as on removed from inventory, and on added to inventory. will need to document that on remove is a best-effort, might be called after player leaves or smth
It's not just for talismans tho, its for any item that has an effect in an inventory, such as the bloom damaging you if you hold it without tongs |
|
we discussed this in VC later hence why I made another comment contradicting that one |
Such an abstraction would be unapplicable to my earlier example of the bloom |
|
Wait I'm confused. How? It's effectively exactly the same class with the methods renamed |
|
AFAICT currently |
Fair. If there's no way to make this an on inventory add/remove thing (which I don't think there is?) happy to just go with this, though I do think it should be made an interface not a class |
what? doesn't because onAddedToInventory is only called if pdc doesn't already have the effect key. otherwise it just postpones the cancel task again. If you wanted to damage the player every x ticks they have it in their inventory, just use PylonInventoryItem. |
renamed the stuff, but kept the InventoryEffectName as it's still accurate and it sounds better than InventoryOnAddedOrRemovedItem |
Hold on so just to clarify, the new names are accurate and Seggan is incorrect that the added method would be called every tick? Alternative name suggestion: InventoryTrackedItem |
yes seggan is incorrect about the added method being called every tick. InventoryTrackedItem sounds okay, but it's not really better than InventoryTrackedItem so I'll just keep the current name out of laziness, but if you think it's better, I can use it |
|
not sure why tests failing, they passed on my machine, restarting them in CI and we'll see if that works |
Sorry thought this was gonna replace PylonInventoryItem/whatever we are calling it now |
Abstracts away the ugly scheduler implementation of a simple inventory effect item. Note that base will still use the talisman class for the talismans because this one doesn't have the concept of levels to make it more generally applicable