Skip to content

Instantly share code, notes, and snippets.

View ItsDoot's full-sized avatar

Christian Hughes ItsDoot

  • United States
  • 01:18 (UTC -05:00)
View GitHub Profile
@ItsDoot
ItsDoot / PlayerSetView.kt
Created June 16, 2019 22:25
Store Players easily without having to check if they are still valid.
class PlayerSetView(private val delegate: MutableSet<UUID>) : MutableSet<Player> {
override val size: Int
get() = delegate.size
override fun isEmpty(): Boolean =
delegate.isEmpty()
override fun contains(element: Player): Boolean =
delegate.contains(element.uniqueId)
@ItsDoot
ItsDoot / DataHolder.java
Created June 7, 2019 20:11
Asynchronous and Synchronous data access
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@ItsDoot
ItsDoot / doot-grayhub.css
Created May 8, 2019 07:41
gray the github up
body, h1, .gh-header, .discussion-timeline-actions, .btn-link.user-has-reacted, p.reason, .pr-toolbar, .diffbar, .conversation-list-heading .inner {
background-color: #eee;
}
code {
background-color: transparent !important;
border-color: transparent !important;
}
.bg-gray, div.dashboard-sidebar, .commit-icon .octicon {
@ItsDoot
ItsDoot / APCommand.kt
Last active May 5, 2019 23:45
Sponge fully type-safe command api
object APCommand {
fun register(plugin: Any) {
val command = CommandRoot("ap", "aperms") {
"collection" then {
"list" execute ::collectionList
subjectCollection("collection") then {
"delete" execute executor(::collectionDelete)
"info" execute executor(::collectionInfo)
package frontier.skcexample
import frontier.skc.KClassCallable
import frontier.skc.annotation.Command
import frontier.skc.annotation.Source
import frontier.skc.match.SKCMatcher
import frontier.skc.value.commandSource
import frontier.skc.value.player
import frontier.skc.value.string
import frontier.ske.server
@ItsDoot
ItsDoot / Ability.kt
Last active December 29, 2018 08:14
Custom Data problems
interface Ability : CatalogType {
override fun getId(): String
override fun getName(): String
// ...
}
@ItsDoot
ItsDoot / CoroutineTask.kt
Last active December 17, 2018 22:18
Kotlin Coroutines using Sponge Tasks as a backend. Inspired by Skedule: https://github.com/okkero/Skedule/
package arven.core.api.task
import org.spongepowered.api.scheduler.Task
interface CoroutineTask {
val plugin: Any
val currentTask: Task?
@ItsDoot
ItsDoot / HealArgumentList.kt
Created December 12, 2018 02:24
WIP Kotlin-based command system
class HealArgumentList(ctx: CommandContext) : ArgumentList(ctx) {
val player by ValueParser.PLAYER
companion object {
val command = command(::HealArgumentList) {
player.health().set(player.maxHealth().get())
player.sendMessage("You have been healed!".green)
suspend fun AbilityContext.runIt() {
// do stuff...
val event = listenForTargeted<DestructEntityEvent>(player) // Player died!
// end ability since dead
}
import org.spongepowered.api.event.Event;
import org.spongepowered.api.event.Listener;
public class MyEventHandler<T extends Event> {
@Listener
public void onEvent(T event) {
}
}