-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/gabber235/TypeWriter int…
…o develop
- Loading branch information
Showing
79 changed files
with
2,119 additions
and
242 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
74 changes: 74 additions & 0 deletions
74
...dapter/src/main/kotlin/me/gabber235/typewriter/entries/audience/CinematicAudienceEntry.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,74 @@ | ||
package me.gabber235.typewriter.entries.audience | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import me.gabber235.typewriter.adapters.Colors | ||
import me.gabber235.typewriter.adapters.Entry | ||
import me.gabber235.typewriter.adapters.modifiers.Help | ||
import me.gabber235.typewriter.adapters.modifiers.Page | ||
import me.gabber235.typewriter.entry.PageType | ||
import me.gabber235.typewriter.entry.Ref | ||
import me.gabber235.typewriter.entry.cinematic.isPlayingCinematic | ||
import me.gabber235.typewriter.entry.entries.AudienceEntry | ||
import me.gabber235.typewriter.entry.entries.AudienceFilter | ||
import me.gabber235.typewriter.entry.entries.AudienceFilterEntry | ||
import me.gabber235.typewriter.entry.ref | ||
import me.gabber235.typewriter.events.AsyncCinematicEndEvent | ||
import me.gabber235.typewriter.events.AsyncCinematicStartEvent | ||
import org.bukkit.entity.Player | ||
import org.bukkit.event.EventHandler | ||
|
||
@Entry( | ||
"cinematic_audience", | ||
"Filters an audience based on if they are in a cinematic", | ||
Colors.MEDIUM_SEA_GREEN, | ||
"mdi:movie" | ||
) | ||
/** | ||
* The `Cinematic Audience` entry filters an audience based on if they are in a cinematic. | ||
* | ||
* If no cinematic is referenced, it will filter based on if any cinematic is active. | ||
* | ||
* ## How could this be used? | ||
* This could be used to hide the sidebar or boss bar when a cinematic is playing. | ||
*/ | ||
class CinematicAudienceEntry( | ||
override val id: String = "", | ||
override val name: String = "", | ||
override val children: List<Ref<AudienceEntry>> = emptyList(), | ||
@Help("When not set it will filter based on if any cinematic is active.") | ||
@Page(PageType.CINEMATIC) | ||
@SerializedName("cinematic") | ||
val pageId: String = "", | ||
@Help("When inverted, the audience will be filtered when not in a cinematic.") | ||
val inverted: Boolean = false | ||
) : AudienceFilterEntry { | ||
override fun display(): AudienceFilter = CinematicAudienceFilter( | ||
ref(), | ||
pageId, | ||
inverted, | ||
) | ||
} | ||
|
||
class CinematicAudienceFilter( | ||
ref: Ref<out AudienceFilterEntry>, | ||
private val pageId: String, | ||
private val inverted: Boolean, | ||
) : AudienceFilter(ref) { | ||
override fun filter(player: Player): Boolean { | ||
val inCinematic = if (pageId.isNotBlank()) player.isPlayingCinematic(pageId) else player.isPlayingCinematic() | ||
return if (inverted) !inCinematic else inCinematic | ||
} | ||
|
||
@EventHandler | ||
fun onCinematicStart(event: AsyncCinematicStartEvent) { | ||
if (pageId.isNotBlank() && event.pageId != pageId) return | ||
event.player.updateFilter(!inverted) | ||
} | ||
|
||
@EventHandler | ||
fun onCinematicEnd(event: AsyncCinematicEndEvent) { | ||
if (pageId.isNotBlank() && event.pageId != pageId) return | ||
event.player.updateFilter(inverted) | ||
} | ||
} | ||
|
53 changes: 53 additions & 0 deletions
53
...ers/BasicAdapter/src/main/kotlin/me/gabber235/typewriter/entries/audience/SidebarEntry.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,53 @@ | ||
package me.gabber235.typewriter.entries.audience | ||
|
||
import me.gabber235.typewriter.adapters.Colors | ||
import me.gabber235.typewriter.adapters.Entry | ||
import me.gabber235.typewriter.adapters.modifiers.Colored | ||
import me.gabber235.typewriter.adapters.modifiers.Help | ||
import me.gabber235.typewriter.adapters.modifiers.MultiLine | ||
import me.gabber235.typewriter.adapters.modifiers.Placeholder | ||
import me.gabber235.typewriter.entry.Ref | ||
import me.gabber235.typewriter.entry.entries.* | ||
import me.gabber235.typewriter.entry.ref | ||
import me.gabber235.typewriter.extensions.placeholderapi.parsePlaceholders | ||
import org.bukkit.entity.Player | ||
|
||
@Entry("sidebar", "Display a sidebar for players", Colors.DARK_ORANGE, "mdi:page-layout-sidebar-right") | ||
/** | ||
* The `SidebarEntry` is a display that shows a sidebar to players. | ||
* | ||
* To display lines on the sidebar, use the `SidebarLinesEntry` as its descendants. | ||
* | ||
* ## How could this be used? | ||
* This could be used to show a list of objectives, or the region a player is in. | ||
*/ | ||
class SimpleSidebarEntry( | ||
override val id: String = "", | ||
override val name: String = "", | ||
override val children: List<Ref<AudienceEntry>> = emptyList(), | ||
override val title: String = "", | ||
) : SidebarEntry { | ||
override fun display(): AudienceFilter = PassThroughFilter(ref()) | ||
} | ||
|
||
@Entry("simple_sidebar_lines", "Lines for a sidebar", Colors.ORANGE_RED, "bi:layout-text-sidebar") | ||
/** | ||
* The `SimpleSidebarLinesEntry` is a display that shows lines on a sidebar. | ||
* | ||
* Separating lines with a newline character will display them on separate lines. | ||
* | ||
* ## How could this be used? | ||
* This could be used to show a list of objectives, or the region a player is in. | ||
*/ | ||
class SimpleSidebarLinesEntry( | ||
override val id: String = "", | ||
override val name: String = "", | ||
@Help("The lines to display on the sidebar. Separate lines with a newline character.") | ||
@Colored | ||
@Placeholder | ||
@MultiLine | ||
val lines: String = "", | ||
) : SidebarLinesEntry { | ||
override fun lines(player: Player): String = lines.parsePlaceholders(player) | ||
override fun display(): AudienceDisplay = PassThroughDisplay() | ||
} |
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
Oops, something went wrong.