parent
16439c5afb
commit
4d233480fe
@ -0,0 +1,6 @@
|
||||
gradle
|
||||
.gradle
|
||||
.idea
|
||||
build
|
||||
out
|
||||
gradlew*
|
@ -0,0 +1,49 @@
|
||||
|
||||
plugins {
|
||||
id 'idea'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.50'
|
||||
id 'com.github.johnrengelman.shadow' version '2.0.4'
|
||||
}
|
||||
|
||||
idea {
|
||||
module {
|
||||
downloadJavadoc = true
|
||||
downloadSources = true
|
||||
}
|
||||
}
|
||||
|
||||
group "net.trivernis"
|
||||
version "1.0-SNAPSHOT"
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url "https://hub.spigotmc.org/nexus/content/repositories/snapshots"
|
||||
}
|
||||
maven {
|
||||
url 'https://papermc.io/repo/repository/maven-public/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
compileOnly "org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
jar {
|
||||
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
compileKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
kotlin.code.style=official
|
@ -0,0 +1,2 @@
|
||||
rootProject.name = 'chunkmaster'
|
||||
|
@ -0,0 +1,18 @@
|
||||
package net.trivernis.chunkmaster
|
||||
|
||||
import net.trivernis.chunkmaster.lib.Spiral
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
|
||||
class Chunkmaster: JavaPlugin() {
|
||||
override fun onEnable() {
|
||||
configure()
|
||||
}
|
||||
|
||||
override fun onDisable() {
|
||||
|
||||
}
|
||||
|
||||
private fun configure() {
|
||||
config.options().copyDefaults(true)
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package net.trivernis.chunkmaster.lib
|
||||
|
||||
import kotlin.math.abs
|
||||
|
||||
class Spiral(private val center: Pair<Int, Int>, private val start: Pair<Int, Int>) {
|
||||
var currentPos = start
|
||||
var direction = 0
|
||||
var count = 0
|
||||
|
||||
/**
|
||||
* Returns the next value in the spiral
|
||||
*/
|
||||
fun next(): Pair<Int, Int> {
|
||||
if (count == 1) { // because of the center behaviour
|
||||
count ++
|
||||
return currentPos
|
||||
}
|
||||
if (currentPos == center) { // the center has to be handled exclusively
|
||||
currentPos = Pair(center.first, center.second + 1)
|
||||
count ++
|
||||
return center
|
||||
} else {
|
||||
val distances = getDistances(center, currentPos)
|
||||
if (abs(distances.first) == abs(distances.second)) {
|
||||
direction = (direction + 1)%5
|
||||
}
|
||||
}
|
||||
when(direction) {
|
||||
0 -> {
|
||||
currentPos = Pair(currentPos.first + 1, currentPos.second)
|
||||
}
|
||||
1 -> {
|
||||
currentPos = Pair(currentPos.first, currentPos.second - 1)
|
||||
}
|
||||
2 -> {
|
||||
currentPos = Pair(currentPos.first - 1, currentPos.second)
|
||||
}
|
||||
3 -> {
|
||||
currentPos = Pair(currentPos.first, currentPos.second + 1)
|
||||
}
|
||||
4 -> {
|
||||
currentPos = Pair(currentPos.first, currentPos.second + 1)
|
||||
direction = 0
|
||||
}
|
||||
}
|
||||
count ++
|
||||
return currentPos
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distances between 2 coordinates
|
||||
*/
|
||||
private fun getDistances(pos1: Pair<Int, Int>, pos2: Pair<Int, Int>): Pair<Int, Int> {
|
||||
return Pair(pos2.first - pos1.first, pos2.second - pos1.second)
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
main: net.trivernis.chunkmaster.Chunkmaster
|
||||
name: Chunkmaster
|
||||
version: '1.0 SNAPSHOT'
|
||||
description: Chunk commands plugin.
|
||||
author: Trivernis
|
||||
website: trivernis.net
|
||||
commands:
|
||||
|
||||
permissions:
|
||||
chunkmaster.*:
|
||||
description: Wildcard permission
|
||||
default: op
|
Loading…
Reference in New Issue