-
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 some things, currently in testing
- Loading branch information
Showing
14 changed files
with
277 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ plugins { | |
} | ||
|
||
group = "de.bypixeltv" | ||
version = "1.6" | ||
version = "1.7.0" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
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
72 changes: 72 additions & 0 deletions
72
.../kotlin/de/bypixeltv/skcloudnet/elements/expressions/players/ExprGetCloudnetPlayerTask.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,72 @@ | ||
package de.bypixeltv.skcloudnet.elements.expressions.players | ||
|
||
import ch.njol.skript.Skript | ||
import ch.njol.skript.doc.Description | ||
import ch.njol.skript.doc.Examples | ||
import ch.njol.skript.doc.Name | ||
import ch.njol.skript.doc.Since | ||
import ch.njol.skript.lang.Expression | ||
import ch.njol.skript.lang.ExpressionType | ||
import ch.njol.skript.lang.SkriptParser | ||
import ch.njol.skript.lang.util.SimpleExpression | ||
import ch.njol.util.Kleenean | ||
import eu.cloudnetservice.driver.inject.InjectionLayer | ||
import eu.cloudnetservice.driver.registry.ServiceRegistry | ||
import eu.cloudnetservice.modules.bridge.player.PlayerManager | ||
import org.bukkit.entity.Player | ||
import org.bukkit.event.Event | ||
|
||
|
||
@Name("CloudNet Task of Player") | ||
@Description("Returns the CloudNet task of a player.") | ||
@Examples("send cloudnet task of \"byPixelTV\" parsed as player") | ||
@Since("1.7") | ||
|
||
class ExprGetCloudnetPlayerTask : SimpleExpression<String>() { | ||
|
||
private val serviceRegistry: ServiceRegistry = InjectionLayer.ext().instance(ServiceRegistry::class.java) | ||
private val playerManager: PlayerManager = serviceRegistry.firstProvider(PlayerManager::class.java) | ||
|
||
companion object{ | ||
init { | ||
Skript.registerExpression( | ||
ExprGetCloudnetPlayerTask::class.java, String::class.java, | ||
ExpressionType.SIMPLE, "cloudnet task of [the] [player] %player%") | ||
} | ||
} | ||
|
||
private var player: Expression<Player>? = null | ||
|
||
override fun isSingle(): Boolean { | ||
return true | ||
} | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
override fun init( | ||
exprs: Array<Expression<*>>, | ||
matchedPattern: Int, | ||
isDelayed: Kleenean?, | ||
parseResult: SkriptParser.ParseResult? | ||
): Boolean { | ||
this.player = exprs[0] as Expression<Player>? | ||
return true | ||
} | ||
|
||
override fun get(e: Event?): Array<String?> { | ||
val player = this.player?.getSingle(e) | ||
if (player != null) { | ||
val serviceInfo = playerManager.onlinePlayer(player.uniqueId)?.connectedService()?.taskName() | ||
return arrayOf(serviceInfo) | ||
} | ||
return arrayOfNulls(0) | ||
} | ||
|
||
override fun getReturnType(): Class<out String> { | ||
return String::class.java | ||
} | ||
|
||
override fun toString(e: Event?, debug: Boolean): String { | ||
return "cloudnet task of ${player?.getSingle(e)}" | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
.../bypixeltv/skcloudnet/elements/expressions/services/ExprGetAllCloudnetPlayersOnService.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,71 @@ | ||
package de.bypixeltv.skcloudnet.elements.expressions.services | ||
|
||
import ch.njol.skript.Skript | ||
import ch.njol.skript.doc.Description | ||
import ch.njol.skript.doc.Examples | ||
import ch.njol.skript.doc.Name | ||
import ch.njol.skript.doc.Since | ||
import ch.njol.skript.lang.Expression | ||
import ch.njol.skript.lang.ExpressionType | ||
import ch.njol.skript.lang.SkriptParser | ||
import ch.njol.skript.lang.util.SimpleExpression | ||
import ch.njol.util.Kleenean | ||
import eu.cloudnetservice.driver.inject.InjectionLayer | ||
import eu.cloudnetservice.driver.provider.CloudServiceProvider | ||
import eu.cloudnetservice.driver.service.ServiceInfoSnapshot | ||
import eu.cloudnetservice.modules.bridge.BridgeDocProperties | ||
import eu.cloudnetservice.modules.bridge.BridgeServiceHelper | ||
import eu.cloudnetservice.modules.bridge.player.ServicePlayer | ||
import org.bukkit.event.Event | ||
import org.jetbrains.annotations.UnknownNullability | ||
|
||
|
||
@Name("All CloudNet players on service.") | ||
@Description("Returns all CloudNet players on a service.") | ||
@Examples("broadcast all cloudnet players on service \"Lobby\"") | ||
@Since("1.0") | ||
|
||
class ExprGetAllCloudnetPlayersOnService : SimpleExpression<String>() { | ||
|
||
private val cnServiceProvider: CloudServiceProvider = InjectionLayer.ext().instance(CloudServiceProvider::class.java) | ||
|
||
companion object{ | ||
init { | ||
Skript.registerExpression( | ||
ExprGetAllCloudnetPlayersOnService::class.java, String::class.java, | ||
ExpressionType.SIMPLE, "all [of the] cloudnet players on [the] service %string%") | ||
} | ||
} | ||
|
||
override fun isSingle(): Boolean { | ||
return false | ||
} | ||
|
||
private var service: Expression<String>? = null | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
override fun init( | ||
exprs: Array<Expression<*>>, | ||
matchedPattern: Int, | ||
isDelayed: Kleenean?, | ||
parseResult: SkriptParser.ParseResult? | ||
): Boolean { | ||
this.service = exprs[0] as Expression<String>? | ||
return true | ||
} | ||
|
||
override fun get(e: Event?): Array<String?>? { | ||
val service = this.service?.getSingle(e) | ||
val servicePlayers = service?.let { cnServiceProvider.serviceByName(it)!!.readProperty(BridgeDocProperties.PLAYERS) } | ||
return servicePlayers?.map { it.name }?.toTypedArray() | ||
} | ||
|
||
override fun getReturnType(): Class<out String> { | ||
return String::class.java | ||
} | ||
|
||
override fun toString(e: Event?, debug: Boolean): String { | ||
return "all cloudnet players on service ${this.service?.getSingle(e)}" | ||
} | ||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
...essions/services/ExprAllServicesOnTask.kt → ...xpressions/tasks/ExprAllServicesOnTask.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
67 changes: 67 additions & 0 deletions
67
...lin/de/bypixeltv/skcloudnet/elements/expressions/tasks/ExprGetAllCloudnetPlayersOnTask.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,67 @@ | ||
package de.bypixeltv.skcloudnet.elements.expressions.tasks | ||
|
||
import ch.njol.skript.Skript | ||
import ch.njol.skript.doc.Description | ||
import ch.njol.skript.doc.Examples | ||
import ch.njol.skript.doc.Name | ||
import ch.njol.skript.doc.Since | ||
import ch.njol.skript.lang.Expression | ||
import ch.njol.skript.lang.ExpressionType | ||
import ch.njol.skript.lang.SkriptParser | ||
import ch.njol.skript.lang.util.SimpleExpression | ||
import ch.njol.util.Kleenean | ||
import eu.cloudnetservice.driver.inject.InjectionLayer | ||
import eu.cloudnetservice.driver.registry.ServiceRegistry | ||
import eu.cloudnetservice.modules.bridge.player.PlayerManager | ||
import org.bukkit.event.Event | ||
|
||
|
||
@Name("All CloudNet players on task.") | ||
@Description("Returns all CloudNet players on a task.") | ||
@Examples("broadcast all cloudnet players on task \"Lobby\"") | ||
@Since("1.0") | ||
|
||
class ExprGetAllCloudnetPlayersOnTask : SimpleExpression<String>() { | ||
|
||
private val serviceRegistry: ServiceRegistry = InjectionLayer.ext().instance(ServiceRegistry::class.java) | ||
private val playerManager: PlayerManager = serviceRegistry.firstProvider(PlayerManager::class.java) | ||
|
||
companion object{ | ||
init { | ||
Skript.registerExpression( | ||
ExprGetAllCloudnetPlayersOnTask::class.java, String::class.java, | ||
ExpressionType.SIMPLE, "all [of the] cloudnet players on [the] task %string%") | ||
} | ||
} | ||
|
||
override fun isSingle(): Boolean { | ||
return false | ||
} | ||
|
||
private var task: Expression<String>? = null | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
override fun init( | ||
exprs: Array<Expression<*>>, | ||
matchedPattern: Int, | ||
isDelayed: Kleenean?, | ||
parseResult: SkriptParser.ParseResult? | ||
): Boolean { | ||
this.task = exprs[0] as Expression<String>? | ||
return true | ||
} | ||
|
||
override fun get(e: Event?): Array<String>? { | ||
val task = this.task?.getSingle(e) | ||
return task?.let { playerManager.taskOnlinePlayers(it).names().toTypedArray() } | ||
} | ||
|
||
override fun getReturnType(): Class<out String> { | ||
return String::class.java | ||
} | ||
|
||
override fun toString(e: Event?, debug: Boolean): String { | ||
return "all cloudnet players on task ${this.task?.getSingle(e)}" | ||
} | ||
|
||
} |
Oops, something went wrong.