-
Notifications
You must be signed in to change notification settings - Fork 8
add inventory ticker #391
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
Merged
Merged
add inventory ticker #391
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d1daabb
add inventory ticker
OhmV-IR 516922e
make not internal
OhmV-IR d361eab
kotlin kult kan not win
OhmV-IR c2d97dc
Apply suggestion from @Seggan
OhmV-IR 8963fff
kdoc thy classes
OhmV-IR 5c09c00
fixup
OhmV-IR b7758e4
Merge branch 'add-inventory-ticker' of https://github.com/pylonmc/pyl…
OhmV-IR 6c2db56
Update pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/item/b…
OhmV-IR d88737e
don't pass stack
OhmV-IR 46a61f9
Merge branch 'add-inventory-ticker' of https://github.com/pylonmc/pyl…
OhmV-IR 8368095
pr comments
OhmV-IR 4f2631f
add to cfg file
OhmV-IR 963b620
Merge branch 'master' into add-inventory-ticker
OhmV-IR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/item/PylonInventoryTicker.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package io.github.pylonmc.pylon.core.item | ||
|
|
||
| import io.github.pylonmc.pylon.core.item.base.PylonInventoryTicker | ||
| import org.bukkit.Bukkit | ||
|
|
||
| internal class PylonInventoryTicker() : Runnable { | ||
| private var count = 0L | ||
| override fun run() { | ||
| for (player in Bukkit.getOnlinePlayers()) { | ||
| for (item in player.inventory) { | ||
| val pylonItem = PylonItem.fromStack(item) | ||
| if (pylonItem is PylonInventoryTicker && count % pylonItem.tickInterval == 0L) { | ||
| pylonItem.onTick(player) | ||
| } | ||
| } | ||
| } | ||
| count += 1L | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
pylon-core/src/main/kotlin/io/github/pylonmc/pylon/core/item/base/PylonInventoryTicker.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||||||||||
| package io.github.pylonmc.pylon.core.item.base | ||||||||||||||
|
|
||||||||||||||
| import io.github.pylonmc.pylon.core.config.PylonConfig | ||||||||||||||
| import org.bukkit.entity.Player | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * An item should implement this interface to tick when a player has the item in their inventory | ||||||||||||||
| */ | ||||||||||||||
| interface PylonInventoryTicker { | ||||||||||||||
| /** | ||||||||||||||
| * Called when the item is detected in the player's inventory. | ||||||||||||||
| * will be called at [tickInterval] * [PylonConfig.inventoryTickerBaseRate | ||||||||||||||
| * @param player The player whose inventory the item was in | ||||||||||||||
| */ | ||||||||||||||
| fun onTick(player: Player) | ||||||||||||||
|
|
||||||||||||||
| /** Determines the rate at which the [onTick] method will be called. | ||||||||||||||
| * [onTick] will be called at [tickInterval] * [PylonConfig.inventoryTickerBaseRate] */ | ||||||||||||||
|
Comment on lines
+17
to
+18
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| val tickInterval: Long | ||||||||||||||
| } | ||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.