Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<groupId>com.scarabcoder</groupId>
<artifactId>space-raiders</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>


Expand Down Expand Up @@ -49,6 +50,10 @@
<name>FastAsyncWorldEdit</name>
<url>http://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/</url>
</repository>
<repository>
<id>scarab-repo</id>
<url>https://mymavenrepo.com/repo/DSmbMenBusi4gORiPrHo/</url>
</repository>

<repository>
<id>sk89q-snapshots</id>
Expand All @@ -70,6 +75,23 @@
</properties>

<dependencies>
<dependency>
<groupId>com.scarabcoder</groupId>
<artifactId>input-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>0.22.5</version>
</dependency>


<dependency>
<groupId>com.scarabcoder</groupId>
<artifactId>command-api2</artifactId>
<version>1.1.6-SNAPSHOT</version>
</dependency>

<!--Spigot API-->
<dependency>
Expand Down Expand Up @@ -131,12 +153,6 @@
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>


</dependencies>
Expand Down Expand Up @@ -223,6 +239,8 @@
<include>org.jetbrains.kotlin</include>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>com.scarabcoder:command-api2:*</include>
<include>com.scarabcoder:input-api:*</include>
</includes>
</artifactSet>
</configuration>
Expand Down
81 changes: 81 additions & 0 deletions src/main/kotlin/com/scarabcoder/Util.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2018 Nicholas Harris (ScarabCoder)
*
* 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 copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
* OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.scarabcoder

import com.boydti.fawe.`object`.schematic.Schematic
import com.scarabcoder.spaceraiders.SpaceRaiders
import com.sk89q.worldedit.Vector
import org.bukkit.scheduler.BukkitRunnable

fun async(runnable: () -> Unit) {
object: BukkitRunnable() {
override fun run() {
runnable()
}

}.runTaskAsynchronously(SpaceRaiders.getPlugin())
}

fun doLater(delay: Long, func: () -> Unit) {
object: BukkitRunnable() {
override fun run() {
func()
}
}.runTaskLater(SpaceRaiders.getPlugin(), delay)
}

fun <E> Collection<E>.nextElement(current: E): Pair<Int, E> {
if(!this.contains(current)) throw IllegalArgumentException("Collection does not contain element $current!")
return Pair(indexOf(current) % size, elementAt((indexOf(current) + 1) % size))
}

fun <E> Collection<E>.previousElement(current: E): Pair<Int, E> {
if(!this.contains(current)) throw IllegalArgumentException("Collection does not contain element $current!")
return Pair(indexOf(current) % size, elementAt((indexOf(current) - 1) % size))
}

fun Vector.toBukkitVector(): org.bukkit.util.Vector = org.bukkit.util.Vector(this.x, this.y, this.z)

fun org.bukkit.util.Vector.fawe(): Vector = Vector(this.x, this.y, this.z)

fun Vector.iterate(max: Vector): Iterator<Vector> {
val items = ArrayList<Vector>()
for(x in this.x.toInt()..max.x.toInt()){
for(y in this.y.toInt()..max.y.toInt()){
for(z in this.z.toInt()..max.z.toInt()){
items.add(Vector(x, y, z))
}
}
}
return items.iterator()
}

fun Schematic.mergeWith(other: Schematic, thisPoint: Vector = this.clipboard!!.origin, otherPoint: Vector = other.clipboard!!.origin): Schematic {
val schem1 = this.clipboard!!
val schem2 = other.clipboard!!

val offset = schem1.origin!!

for(bPos in schem2.minimumPoint.iterate(schem2.maximumPoint)){
val b = schem2.getBlock(bPos)
schem1.setBlock(bPos + offset, b)
}
return Schematic(schem1)
}

private operator fun Vector.plus(other: Vector): Vector {
return this.add(other)
}
19 changes: 0 additions & 19 deletions src/main/kotlin/com/scarabcoder/gamecore/commandapi/Argument.kt

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions src/main/kotlin/com/scarabcoder/gamecore/commandapi/Command.kt

This file was deleted.

This file was deleted.

Loading