Merge branch 'master' of https://github.com/F0Xde/KSpigot into pr/2
This commit is contained in:
2
gradlew
vendored
Executable file → Normal file
2
gradlew
vendored
Executable file → Normal file
@@ -82,7 +82,6 @@ esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
@@ -130,7 +129,6 @@ fi
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
|
4
gradlew.bat
vendored
4
gradlew.bat
vendored
@@ -29,9 +29,6 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@@ -84,7 +81,6 @@ set CMD_LINE_ARGS=%*
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
|
@@ -11,40 +11,40 @@ class GamePhaseSystem(vararg gamePhases: GamePhase) {
|
||||
}
|
||||
|
||||
fun buildCounterMessageCallback(
|
||||
beforeTime: String? = null,
|
||||
afterTime: String? = null,
|
||||
hours: String = "h",
|
||||
minutes: String = "m",
|
||||
seconds: String = "s"
|
||||
beforeTime: String? = null,
|
||||
afterTime: String? = null,
|
||||
hourPlural: String = "h",
|
||||
minutePlural: String = "m",
|
||||
secondPlural: String = "s",
|
||||
hourSingular: String = hourPlural,
|
||||
minuteSingular: String = minutePlural,
|
||||
secondSingular: String = secondPlural
|
||||
): (Long) -> String = { curSeconds ->
|
||||
|
||||
StringBuilder().apply {
|
||||
append(beforeTime)
|
||||
if (beforeTime != null)
|
||||
append(beforeTime)
|
||||
|
||||
val hourTime = (curSeconds / 3600)
|
||||
val minuteTime = ((curSeconds % 3600) / 60)
|
||||
val secondsTime = (curSeconds % 60)
|
||||
|
||||
if (hourTime != 0L)
|
||||
append("${hourTime.toString().run { if (length < 2) "0$this" else this }}:")
|
||||
if (hourTime != 0L) {
|
||||
append("$hourTime ${if (hourTime == 1L) hourSingular else hourPlural}")
|
||||
if (minuteTime != 0L) append(" ")
|
||||
}
|
||||
|
||||
if ((hourTime != 0L && secondsTime != 0L) || (minuteTime != 0L && secondsTime != 0L))
|
||||
append("${minuteTime.toString().run { if (length < 2) "0$this" else this }}:")
|
||||
else if (minuteTime != 0L)
|
||||
append(minuteTime.toString().run { if (length < 2) "0$this" else this })
|
||||
if (minuteTime != 0L) {
|
||||
append("$minuteTime ${if (minuteTime == 1L) minuteSingular else minutePlural}")
|
||||
if (secondsTime != 0L) append(" ")
|
||||
}
|
||||
|
||||
if (secondsTime != 0L)
|
||||
append(secondsTime.toString().run { if (length < 2) "0$this" else this })
|
||||
if (secondsTime != 0L || (hourTime == 0L && minuteTime == 0L)) {
|
||||
append("$secondsTime ${if (secondsTime == 1L) secondSingular else secondPlural}")
|
||||
}
|
||||
|
||||
append(" ").append(kotlin.run {
|
||||
return@run when {
|
||||
secondsTime != 0L -> seconds
|
||||
minuteTime != 0L -> minutes
|
||||
else -> hours
|
||||
}
|
||||
})
|
||||
|
||||
append(afterTime)
|
||||
if (afterTime != null)
|
||||
append(afterTime)
|
||||
}.toString()
|
||||
|
||||
}
|
||||
|
@@ -23,80 +23,4 @@ abstract class InventoryGUIElement<T : ForInventory>(
|
||||
|
||||
protected abstract fun onClickElement(clickEvent: InventoryGUIClickEvent<T>)
|
||||
|
||||
}
|
||||
|
||||
// Element implementations
|
||||
|
||||
open class InventoryGUIButton<T : ForInventory>(
|
||||
inventoryGUIElementData: InventoryGUIElementData,
|
||||
val action: (InventoryGUIClickEvent<T>) -> Unit,
|
||||
) : InventoryGUIElement<T>(inventoryGUIElementData) {
|
||||
|
||||
override fun onClickElement(clickEvent: InventoryGUIClickEvent<T>) {
|
||||
clickEvent.bukkitEvent.isCancelled = true
|
||||
action(clickEvent)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class InventoryGUIPlaceholder<T : ForInventory>(
|
||||
inventoryGUIElementData: InventoryGUIElementData
|
||||
) : InventoryGUIElement<T>(inventoryGUIElementData) {
|
||||
|
||||
override fun onClickElement(clickEvent: InventoryGUIClickEvent<T>) {
|
||||
clickEvent.bukkitEvent.isCancelled = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class InventoryGUIButtonPageChange<T : ForInventory>(
|
||||
inventoryGUIElementData: InventoryGUIElementData,
|
||||
calculator: InventoryGUIPageChangeCalculator,
|
||||
onChange: ((InventoryGUIClickEvent<T>) -> Unit)?
|
||||
)
|
||||
: InventoryGUIButton<T>(inventoryGUIElementData, {
|
||||
|
||||
val currentPage = it.gui.currentPage
|
||||
val newPage = it.gui.getPage(calculator.calculateNewPage(it.gui.currentPageInt, it.gui.data.pages.keys))
|
||||
if (newPage != null) {
|
||||
|
||||
val effect = (newPage.transitionTo ?: currentPage.transitionFrom)
|
||||
?: PageChangeEffect.INSTANT
|
||||
|
||||
it.gui.changePage(effect, currentPage, newPage)
|
||||
|
||||
onChange?.invoke(it)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
class InventoryGUIButtonInventoryChange<T : ForInventory>(
|
||||
inventoryGUIElementData: InventoryGUIElementData,
|
||||
changeToGUICallback: () -> InventoryGUI<*>,
|
||||
changeToPageInt: Int?,
|
||||
onChange: ((InventoryGUIClickEvent<T>) -> Unit)?
|
||||
)
|
||||
: InventoryGUIButton<T>(inventoryGUIElementData, {
|
||||
|
||||
val changeToGUI = changeToGUICallback.invoke()
|
||||
|
||||
val effect = (changeToGUI.data.transitionTo ?: it.gui.data.transitionFrom)
|
||||
?: InventoryChangeEffect.INSTANT
|
||||
|
||||
val changeToPage = changeToGUI.getPage(changeToPageInt) ?: changeToGUI.currentPage
|
||||
|
||||
changeToGUI.changeGUI(effect, it.gui.currentPage, changeToPage)
|
||||
|
||||
it.bukkitEvent.whoClicked.openGUI(changeToGUI)
|
||||
|
||||
onChange?.invoke(it)
|
||||
|
||||
})
|
||||
|
||||
|
||||
// FREE SLOT
|
||||
|
||||
class InventoryGUIFreeSlot<T : ForInventory> : InventoryGUISlot<T>() {
|
||||
override fun onClick(clickEvent: InventoryGUIClickEvent<T>) { /* do nothing */ }
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package net.axay.kspigot.inventory.elements
|
||||
|
||||
import net.axay.kspigot.inventory.ForInventory
|
||||
import net.axay.kspigot.inventory.InventoryGUIClickEvent
|
||||
import net.axay.kspigot.inventory.InventoryGUIElement
|
||||
import net.axay.kspigot.inventory.InventoryGUIElementData
|
||||
|
||||
open class InventoryGUIButton<T : ForInventory>(
|
||||
inventoryGUIElementData: InventoryGUIElementData,
|
||||
val action: (InventoryGUIClickEvent<T>) -> Unit,
|
||||
) : InventoryGUIElement<T>(inventoryGUIElementData) {
|
||||
|
||||
override fun onClickElement(clickEvent: InventoryGUIClickEvent<T>) {
|
||||
clickEvent.bukkitEvent.isCancelled = true
|
||||
action(clickEvent)
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package net.axay.kspigot.inventory.elements
|
||||
|
||||
import net.axay.kspigot.inventory.*
|
||||
|
||||
class InventoryGUIButtonInventoryChange<T : ForInventory>(
|
||||
inventoryGUIElementData: InventoryGUIElementData,
|
||||
changeToGUICallback: () -> InventoryGUI<*>,
|
||||
changeToPageInt: Int?,
|
||||
onChange: ((InventoryGUIClickEvent<T>) -> Unit)?
|
||||
)
|
||||
: InventoryGUIButton<T>(inventoryGUIElementData, {
|
||||
|
||||
val changeToGUI = changeToGUICallback.invoke()
|
||||
|
||||
val effect = (changeToGUI.data.transitionTo ?: it.gui.data.transitionFrom)
|
||||
?: InventoryChangeEffect.INSTANT
|
||||
|
||||
val changeToPage = changeToGUI.getPage(changeToPageInt) ?: changeToGUI.currentPage
|
||||
|
||||
changeToGUI.changeGUI(effect, it.gui.currentPage, changeToPage)
|
||||
|
||||
it.bukkitEvent.whoClicked.openGUI(changeToGUI)
|
||||
|
||||
onChange?.invoke(it)
|
||||
|
||||
})
|
@@ -0,0 +1,25 @@
|
||||
package net.axay.kspigot.inventory.elements
|
||||
|
||||
import net.axay.kspigot.inventory.*
|
||||
|
||||
class InventoryGUIButtonPageChange<T : ForInventory>(
|
||||
inventoryGUIElementData: InventoryGUIElementData,
|
||||
calculator: InventoryGUIPageChangeCalculator,
|
||||
onChange: ((InventoryGUIClickEvent<T>) -> Unit)?
|
||||
)
|
||||
: InventoryGUIButton<T>(inventoryGUIElementData, {
|
||||
|
||||
val currentPage = it.gui.currentPage
|
||||
val newPage = it.gui.getPage(calculator.calculateNewPage(it.gui.currentPageInt, it.gui.data.pages.keys))
|
||||
if (newPage != null) {
|
||||
|
||||
val effect = (newPage.transitionTo ?: currentPage.transitionFrom)
|
||||
?: PageChangeEffect.INSTANT
|
||||
|
||||
it.gui.changePage(effect, currentPage, newPage)
|
||||
|
||||
onChange?.invoke(it)
|
||||
|
||||
}
|
||||
|
||||
})
|
@@ -0,0 +1,9 @@
|
||||
package net.axay.kspigot.inventory.elements
|
||||
|
||||
import net.axay.kspigot.inventory.ForInventory
|
||||
import net.axay.kspigot.inventory.InventoryGUIClickEvent
|
||||
import net.axay.kspigot.inventory.InventoryGUISlot
|
||||
|
||||
class InventoryGUIFreeSlot<T : ForInventory> : InventoryGUISlot<T>() {
|
||||
override fun onClick(clickEvent: InventoryGUIClickEvent<T>) { /* do nothing */ }
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package net.axay.kspigot.inventory.elements
|
||||
|
||||
import net.axay.kspigot.inventory.ForInventory
|
||||
import net.axay.kspigot.inventory.InventoryGUIClickEvent
|
||||
import net.axay.kspigot.inventory.InventoryGUIElement
|
||||
import net.axay.kspigot.inventory.InventoryGUIElementData
|
||||
|
||||
class InventoryGUIPlaceholder<T : ForInventory>(
|
||||
inventoryGUIElementData: InventoryGUIElementData
|
||||
) : InventoryGUIElement<T>(inventoryGUIElementData) {
|
||||
|
||||
override fun onClickElement(clickEvent: InventoryGUIClickEvent<T>) {
|
||||
clickEvent.bukkitEvent.isCancelled = true
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user