-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'RPKit-205' into release/v1.2
- Loading branch information
Showing
18 changed files
with
169 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
33 changes: 33 additions & 0 deletions
33
...t/rpk-food-bukkit/src/main/kotlin/com/rpkit/food/bukkit/listener/InventoryOpenListener.kt
This file contains 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,33 @@ | ||
package com.rpkit.food.bukkit.listener | ||
|
||
import com.rpkit.food.bukkit.RPKFoodBukkit | ||
import com.rpkit.food.bukkit.expiry.RPKExpiryProvider | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.Listener | ||
import org.bukkit.event.inventory.InventoryOpenEvent | ||
|
||
|
||
class InventoryOpenListener(private val plugin: RPKFoodBukkit): Listener { | ||
|
||
@EventHandler | ||
fun onInventoryOpen(event: InventoryOpenEvent) { | ||
val expiryProvider = plugin.core.serviceManager.getServiceProvider(RPKExpiryProvider::class) | ||
event.inventory.contents | ||
.filterNotNull() | ||
.filter { it.type.isEdible } | ||
.forEach { item -> | ||
if (expiryProvider.getExpiry(item) == null) { | ||
expiryProvider.setExpiry(item) | ||
} | ||
} | ||
event.player.inventory.contents | ||
.filterNotNull() | ||
.filter { it.type.isEdible } | ||
.forEach { item -> | ||
if (expiryProvider.getExpiry(item) == null) { | ||
expiryProvider.setExpiry(item) | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains 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 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
24 changes: 24 additions & 0 deletions
24
bukkit/rpk-food-bukkit/src/main/kotlin/com/rpkit/food/bukkit/listener/PlayerJoinListener.kt
This file contains 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,24 @@ | ||
package com.rpkit.food.bukkit.listener | ||
|
||
import com.rpkit.food.bukkit.RPKFoodBukkit | ||
import com.rpkit.food.bukkit.expiry.RPKExpiryProvider | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.Listener | ||
import org.bukkit.event.player.PlayerJoinEvent | ||
|
||
class PlayerJoinListener(private val plugin: RPKFoodBukkit): Listener { | ||
|
||
@EventHandler | ||
fun onPlayerJoin(event: PlayerJoinEvent) { | ||
val expiryProvider = plugin.core.serviceManager.getServiceProvider(RPKExpiryProvider::class) | ||
event.player.inventory.contents | ||
.filterNotNull() | ||
.filter { it.type.isEdible } | ||
.forEach { item -> | ||
if (expiryProvider.getExpiry(item) == null) { | ||
expiryProvider.setExpiry(item) | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains 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 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 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
6 changes: 6 additions & 0 deletions
6
bukkit/rpk-food-lib-bukkit/src/main/kotlin/com/rpkit/food/bukkit/RPKFoodLibBukkit.kt
This file contains 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,6 @@ | ||
package com.rpkit.food.bukkit | ||
|
||
import com.rpkit.core.bukkit.plugin.RPKBukkitPlugin | ||
|
||
|
||
class RPKFoodLibBukkit : RPKBukkitPlugin() |
14 changes: 14 additions & 0 deletions
14
bukkit/rpk-food-lib-bukkit/src/main/kotlin/com/rpkit/food/bukkit/expiry/RPKExpiryProvider.kt
This file contains 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,14 @@ | ||
package com.rpkit.food.bukkit.expiry | ||
|
||
import com.rpkit.core.service.ServiceProvider | ||
import org.bukkit.inventory.ItemStack | ||
import java.util.* | ||
|
||
interface RPKExpiryProvider: ServiceProvider { | ||
|
||
fun setExpiry(item: ItemStack, expiryDate: Date) | ||
fun setExpiry(item: ItemStack) | ||
fun getExpiry(item: ItemStack): Date? | ||
fun isExpired(item: ItemStack): Boolean | ||
|
||
} |
This file contains 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,6 @@ | ||
name: rpk-food-lib-bukkit | ||
author: alyphen | ||
version: @version@ | ||
main: com.rpkit.food.bukkit.RPKFoodLibBukkit | ||
depend: | ||
- rpk-core-bukkit |
Oops, something went wrong.