-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added UIsModule entrypoint * removed UiClickEvent.kt in favor of kotlin functions * added BukkitExtensions.kt
- Loading branch information
Showing
5 changed files
with
141 additions
and
35 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...api/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/spigot/extensions/BukkitExtensions.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 xyz.theprogramsrc.simplecoreapi.spigot.extensions | ||
|
||
import org.bukkit.Bukkit | ||
import org.bukkit.event.Event | ||
import org.bukkit.event.Listener | ||
import org.bukkit.plugin.Plugin | ||
import org.bukkit.plugin.PluginManager | ||
|
||
/** | ||
* Registers an event listener | ||
* @param listener the listener to register | ||
* @param plugin the plugin to register the listener for | ||
* @see PluginManager.registerEvents | ||
*/ | ||
fun registerEvent(listener: Listener, plugin: Plugin) = | ||
Bukkit.getPluginManager().registerEvents(listener, plugin) | ||
|
||
/** | ||
* Calls an event | ||
* @param event the event to call | ||
* @see PluginManager.callEvent | ||
*/ | ||
fun callEvent(event: Event) = | ||
Bukkit.getPluginManager().callEvent(event) |
17 changes: 17 additions & 0 deletions
17
...api/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/spigot/modules/uismodule/UIsModule.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,17 @@ | ||
package xyz.theprogramsrc.simplecoreapi.spigot.modules.uismodule | ||
|
||
import xyz.theprogramsrc.simplecoreapi.global.module.Module | ||
import xyz.theprogramsrc.simplecoreapi.global.module.ModuleDescription | ||
|
||
class UIsModule : Module { | ||
|
||
override val description: ModuleDescription = ModuleDescription( | ||
name = "UIsModule", | ||
version = "1.0.0", | ||
authors = listOf("Im-Fran") | ||
) | ||
|
||
override fun onEnable() {} | ||
|
||
override fun onDisable() {} | ||
} |
26 changes: 26 additions & 0 deletions
26
...rc/main/kotlin/xyz/theprogramsrc/simplecoreapi/spigot/modules/uismodule/models/UiEntry.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,26 @@ | ||
package xyz.theprogramsrc.simplecoreapi.spigot.modules.uismodule.models | ||
|
||
import org.bukkit.entity.Player | ||
import org.bukkit.inventory.ItemStack | ||
import xyz.theprogramsrc.simplecoreapi.spigot.modules.uismodule.ui.Ui | ||
|
||
/** | ||
* Representation of an Ui Entry, which is an item in an Ui. | ||
* @param slot the slot of where the item should be placed | ||
* @param item the item that should be displayed in the slot (as a function, so it can be dynamic) | ||
* @param action the action that should be executed when a player clicks on the item. The action should return true if the UI should be closed after the action is executed, false otherwise. | ||
* @param dynamic if true, this item will be updated at least every tick (20 times per second) | ||
*/ | ||
data class UiEntry( | ||
val slot: Int, | ||
val item: () -> ItemStack, | ||
val action: (Ui, Player) -> Unit = { _, _ -> }, | ||
val dynamic: Boolean = false | ||
) { | ||
|
||
/** | ||
* The cached item, which is the item that will be displayed in the UI. | ||
* This is used to avoid calling the [item] function every time the UI is updated (unless it's dynamic). | ||
*/ | ||
val cachedItem = item.invoke() | ||
} |
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
28 changes: 0 additions & 28 deletions
28
...kotlin/xyz/theprogramsrc/simplecoreapi/spigot/modules/uismodule/ui/events/UiClickEvent.kt
This file was deleted.
Oops, something went wrong.