-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add events support: 'ITEM_INVENTORY_TICK', 'ITEM_INVENTORY_TICKED', 'ITEM_STACK_CLICK', 'ITEM_STACK_CLICKED'. Add context args: 'CURSOR_STACK', 'CLICK_TYPE', 'SLOT', 'SLOT_NUMBER', 'SELECT_STATUS'. Update version id to '1.0.0-alpha7'. Rename language translator to structuring translator. Supporting to some javascript stdlib. No longer using local variable to access bedrock system, importing now. Upgrade gradle to '8.11.1'.
- Loading branch information
Showing
24 changed files
with
275 additions
and
68 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
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
3 changes: 3 additions & 0 deletions
3
src/main/java/com/github/cao/awa/conium/annotation/script/javascript/JavaScriptApi.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,3 @@ | ||
package com.github.cao.awa.conium.annotation.script.javascript | ||
|
||
annotation class JavaScriptApi(vararg val refName: String) |
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,30 @@ | ||
package com.github.cao.awa.conium.bedrock | ||
|
||
import com.github.cao.awa.conium.bedrock.server.ServerIndexD | ||
import com.github.cao.awa.sinuatum.manipulate.QuickManipulate | ||
import com.github.cao.awa.sinuatum.util.collection.CollectionFactor | ||
import org.apache.logging.log4j.LogManager | ||
import org.apache.logging.log4j.Logger | ||
import java.util.function.Consumer | ||
|
||
abstract class IndexD { | ||
companion object { | ||
private val LOGGER: Logger = LogManager.getLogger("IndexD") | ||
private val packages: Map<String, IndexD> = QuickManipulate.operation(CollectionFactor.hashMap()) { packages: MutableMap<String, IndexD> -> | ||
packages["@minecraft/server"] = ServerIndexD() | ||
} | ||
|
||
@JvmStatic | ||
fun tryImport(packageName: String, refs: Collection<String>, action: Consumer<String>) { | ||
packages[packageName]?.also { indexD: IndexD -> | ||
refs.distinct().forEach { ref: String -> | ||
indexD.forName(ref, action) | ||
} | ||
} ?: { | ||
LOGGER.warn("The package '{}' are not found in conium IndexD", packageName) | ||
} | ||
} | ||
} | ||
|
||
abstract fun forName(refName: String, action: Consumer<String>) | ||
} |
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/github/cao/awa/conium/bedrock/server/ServerIndexD.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 com.github.cao.awa.conium.bedrock.server | ||
|
||
import com.github.cao.awa.conium.bedrock.IndexD | ||
import com.github.cao.awa.conium.bedrock.event.context.BedrockEventContext | ||
import com.github.cao.awa.sinuatum.manipulate.QuickManipulate | ||
import com.github.cao.awa.sinuatum.util.collection.CollectionFactor | ||
import org.apache.logging.log4j.LogManager | ||
import org.apache.logging.log4j.Logger | ||
import java.util.function.Consumer | ||
|
||
class ServerIndexD : IndexD() { | ||
companion object { | ||
private val LOGGER: Logger = LogManager.getLogger("ServerIndexD") | ||
private val mappings: Map<String, String> = QuickManipulate.operation(CollectionFactor.hashMap()) { mappings: MutableMap<String, String> -> | ||
mappings["system"] = "${BedrockEventContext::class.qualifiedName}.Companion.system" | ||
} | ||
} | ||
|
||
override fun forName(refName: String, action: Consumer<String>) { | ||
mappings[refName]?.also { ref: String -> | ||
action.accept(ref) | ||
} ?: { | ||
LOGGER.warn("The reference name '{}' are not found in conium ServerIndexD(@minecraft/server)", refName) | ||
} | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
...com/github/cao/awa/conium/script/javascript/std/collection/iterator/JavascriptIterator.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 com.github.cao.awa.conium.script.javascript.std.collection.iterator | ||
|
||
class JavascriptIterator<V>(private val delegate: MutableIterator<V>): MutableIterator<JavascriptIteratorResult<V>> { | ||
val done: Boolean get() = hasNext() | ||
|
||
override operator fun next(): JavascriptIteratorResult<V> { | ||
if (hasNext()) { | ||
return JavascriptIteratorResult(false, this.delegate.next()) | ||
} else { | ||
return JavascriptIteratorResult(true, null) | ||
} | ||
} | ||
|
||
override fun remove(): Unit = this.delegate.remove() | ||
|
||
override operator fun hasNext(): Boolean = this.delegate.hasNext() | ||
} |
3 changes: 3 additions & 0 deletions
3
...thub/cao/awa/conium/script/javascript/std/collection/iterator/JavascriptIteratorResult.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,3 @@ | ||
package com.github.cao.awa.conium.script.javascript.std.collection.iterator | ||
|
||
class JavascriptIteratorResult<V>(val done: Boolean, val value: V?) |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/github/cao/awa/conium/script/javascript/std/collection/set/Set.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,45 @@ | ||
package com.github.cao.awa.conium.script.javascript.std.collection.set | ||
|
||
import com.github.cao.awa.conium.annotation.script.javascript.JavaScriptApi | ||
import com.github.cao.awa.conium.script.javascript.std.collection.iterator.JavascriptIterator | ||
import com.github.cao.awa.sinuatum.util.collection.CollectionFactor | ||
|
||
@JavaScriptApi("Set") | ||
class Set<V> : MutableSet<V> { | ||
private val delegate: MutableSet<V> = CollectionFactor.hashSet() | ||
|
||
// Delegate properties. | ||
// Also 'size' in Javascript. | ||
@JavaScriptApi("Set", "#size") | ||
override val size: Int get() = this.delegate.size | ||
|
||
// Delegate operations. | ||
override fun iterator(): MutableIterator<V> = this.delegate.iterator() | ||
|
||
// Also 'add' in Javascript. | ||
@JavaScriptApi("Set", "add") | ||
override fun add(element: V): Boolean = this.delegate.add(element) | ||
override fun remove(element: V): Boolean = this.delegate.remove(element) | ||
override fun addAll(elements: Collection<V>): Boolean = this.delegate.addAll(elements) | ||
override fun removeAll(elements: Collection<V>): Boolean = this.delegate.removeAll(elements.toSet()) | ||
override fun retainAll(elements: Collection<V>): Boolean = this.delegate.retainAll(elements.toSet()) | ||
|
||
// Also 'clear' in Javascript. | ||
@JavaScriptApi("Set", "clear") | ||
override fun clear(): Unit = this.delegate.clear() | ||
override fun isEmpty(): Boolean = this.delegate.isEmpty() | ||
override fun contains(element: @UnsafeVariance V): Boolean = this.delegate.contains(element) | ||
override fun containsAll(elements: Collection<@UnsafeVariance V>): Boolean = this.delegate.containsAll(elements) | ||
|
||
// Javascript operations. | ||
@JavaScriptApi("Set", "delete") | ||
fun delete(element: V): Boolean = remove(element) | ||
@JavaScriptApi("Set", "forEach") | ||
fun forEach(action: (@UnsafeVariance V, V, Int) -> Unit): Unit = this.delegate.forEachIndexed { index: Int, value: V -> action(value, value, index) } | ||
@JavaScriptApi("Set", "has") | ||
fun has(element: @UnsafeVariance V): Boolean = contains(element) | ||
@JavaScriptApi("Set", "keys") | ||
fun keys(): JavascriptIterator<V> = values() | ||
@JavaScriptApi("Set", "values") | ||
fun values(): JavascriptIterator<V> = JavascriptIterator(iterator()) | ||
} |
2 changes: 1 addition & 1 deletion
2
.../script/typescript/TypescriptPrototype.kt → ...ascript/typescript/TypescriptPrototype.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
Oops, something went wrong.