Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
joserobjr committed Oct 20, 2016
0 parents commit 793d9bc
Show file tree
Hide file tree
Showing 18 changed files with 673 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gradle
.idea
build
29 changes: 29 additions & 0 deletions KotlinFunBukkit/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repositories {
maven { url = bukkit_repo }
}

dependencies {
compile 'org.bukkit:bukkit:1.10.2-R0.1-SNAPSHOT'
compile project(':KotlinFunBungeeChat')
}


shadowJar {
dependencies {
include project(':KotlinFunBungeeChat')
}
}

processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include 'plugin.yml'

expand 'version':project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude 'plugin.yml'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@file:JvmName(name = "BukkitUtil")
package br.com.gamemods.kotlinfun.bukkit

import br.com.gamemods.kotlinfun.ColorizedBase
import org.bukkit.ChatColor
import org.bukkit.plugin.java.JavaPlugin
import java.util.*

class KotlinFun : JavaPlugin()

class Colorized(str: String) : ColorizedBase<ChatColor>(str) {
override val format : EnumSet<ChatColor> = EnumSet.noneOf(ChatColor::class.java)

fun currentFormat() = format.clone()

private fun setColor(c: ChatColor?) : Colorized {
color = c
return this
}

private fun addFormat(f: ChatColor) : Colorized {
format.add(f)
return this
}

override fun black() = setColor(ChatColor.BLACK)
override fun darkBlue() = setColor(ChatColor.DARK_BLUE)
override fun darkGreen() = setColor(ChatColor.DARK_GREEN)
override fun darkAqua() = setColor(ChatColor.DARK_AQUA)
override fun darkRed() = setColor(ChatColor.DARK_RED)
override fun darkPurple() = setColor(ChatColor.DARK_PURPLE)
override fun gold() = setColor(ChatColor.GOLD)
override fun gray() = setColor(ChatColor.GRAY)
override fun darkGray() = setColor(ChatColor.DARK_GRAY)
override fun blue() = setColor(ChatColor.BLUE)
override fun green() = setColor(ChatColor.GREEN)
override fun aqua() = setColor(ChatColor.AQUA)
override fun red() = setColor(ChatColor.RED)
override fun lightPurple() = setColor(ChatColor.LIGHT_PURPLE)
override fun yellow() = setColor(ChatColor.YELLOW)
override fun white() = setColor(ChatColor.WHITE)
override fun reset() = setColor(ChatColor.RESET)

override fun magic() = addFormat(ChatColor.MAGIC)
override fun bold() = addFormat(ChatColor.BOLD)
override fun strike() = addFormat(ChatColor.STRIKETHROUGH)
override fun underline() = addFormat(ChatColor.UNDERLINE)
override fun italic() = addFormat(ChatColor.ITALIC)
}

fun String.black() = Colorized(this).black()
fun String.darkBlue() = Colorized(this).darkBlue()
fun String.darkGreen() = Colorized(this).darkGreen()
fun String.darkAqua() = Colorized(this).darkAqua()
fun String.darkRed() = Colorized(this).darkRed()
fun String.darkPurple() = Colorized(this).darkPurple()
fun String.gold() = Colorized(this).gold()
fun String.gray() = Colorized(this).gray()
fun String.darkGray() = Colorized(this).darkGray()
fun String.blue() = Colorized(this).blue()
fun String.green() = Colorized(this).green()
fun String.aqua() = Colorized(this).aqua()
fun String.red() = Colorized(this).red()
fun String.lightPurple() = Colorized(this).lightPurple()
fun String.yellow() = Colorized(this).yellow()
fun String.white() = Colorized(this).white()
fun String.reset() = Colorized(this).reset()
fun String.magic() = Colorized(this).magic()
fun String.bold() = Colorized(this).bold()
fun String.strike() = Colorized(this).strike()
fun String.underline() = Colorized(this).underline()
fun String.italic() = Colorized(this).italic()

operator fun ChatColor.plus(str : String) = this.toString() + str
4 changes: 4 additions & 0 deletions KotlinFunBukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: KotlinFun
version: ${version}
author: joserobjr
main: br.com.gamemods.kotlinfun.bukkit.KotlinFun
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package br.com.gamemods.kotlinfun.bukkit

import org.junit.Assert.*
import org.junit.Test

class KotlinFunTest {

@Test
fun colors() {
assertEquals("§cTest", "Test".red().toString())
assertEquals("§cTest§9§l 123", "Test".red() + " 123".blue().bold())
assertEquals("§cTest§9§l 123", "Test".red() + " 123".bold().blue())
assertEquals("§l§oBold and Italic", "Bold and Italic".bold().italic().toString())
}
}
24 changes: 24 additions & 0 deletions KotlinFunBungee/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
dependencies {
compile 'net.md-5:bungeecord-api:1.10-SNAPSHOT'
compile project(':KotlinFunBungeeChat')
}

shadowJar {
dependencies {
include project(':KotlinFunBungeeChat')
}
}

processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include 'bungee.yml'

expand 'version':project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude 'bungee.yml'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@file:JvmName(name = "BungeeUtil")
package br.com.gamemods.kotlinfun.bungee

import net.md_5.bungee.api.plugin.Plugin

class KotlinFun : Plugin()
4 changes: 4 additions & 0 deletions KotlinFunBungee/src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: KotlinFun
version: ${version}
author: joserobjr
main: br.com.gamemods.kotlinfun.bungee.KotlinFun
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@file:JvmName(name = "BungeeColorUtil")
package br.com.gamemods.kotlinfun.bungee

import br.com.gamemods.kotlinfun.ColorizedBase
import net.md_5.bungee.api.ChatColor
import java.util.*

class Colorized(str: String) : ColorizedBase<ChatColor>(str) {
override val format : EnumSet<ChatColor> = EnumSet.noneOf(ChatColor::class.java)

fun currentFormat() = format.clone()

private fun setColor(c: ChatColor?) : Colorized {
color = c
return this
}

private fun addFormat(f: ChatColor) : Colorized {
format.add(f)
return this
}

override fun black() = setColor(ChatColor.BLACK)
override fun darkBlue() = setColor(ChatColor.DARK_BLUE)
override fun darkGreen() = setColor(ChatColor.DARK_GREEN)
override fun darkAqua() = setColor(ChatColor.DARK_AQUA)
override fun darkRed() = setColor(ChatColor.DARK_RED)
override fun darkPurple() = setColor(ChatColor.DARK_PURPLE)
override fun gold() = setColor(ChatColor.GOLD)
override fun gray() = setColor(ChatColor.GRAY)
override fun darkGray() = setColor(ChatColor.DARK_GRAY)
override fun blue() = setColor(ChatColor.BLUE)
override fun green() = setColor(ChatColor.GREEN)
override fun aqua() = setColor(ChatColor.AQUA)
override fun red() = setColor(ChatColor.RED)
override fun lightPurple() = setColor(ChatColor.LIGHT_PURPLE)
override fun yellow() = setColor(ChatColor.YELLOW)
override fun white() = setColor(ChatColor.WHITE)
override fun reset() = setColor(ChatColor.RESET)

override fun magic() = addFormat(ChatColor.MAGIC)
override fun bold() = addFormat(ChatColor.BOLD)
override fun strike() = addFormat(ChatColor.STRIKETHROUGH)
override fun underline() = addFormat(ChatColor.UNDERLINE)
override fun italic() = addFormat(ChatColor.ITALIC)
}

fun String.black() = Colorized(this).black()
fun String.darkBlue() = Colorized(this).darkBlue()
fun String.darkGreen() = Colorized(this).darkGreen()
fun String.darkAqua() = Colorized(this).darkAqua()
fun String.darkRed() = Colorized(this).darkRed()
fun String.darkPurple() = Colorized(this).darkPurple()
fun String.gold() = Colorized(this).gold()
fun String.gray() = Colorized(this).gray()
fun String.darkGray() = Colorized(this).darkGray()
fun String.blue() = Colorized(this).blue()
fun String.green() = Colorized(this).green()
fun String.aqua() = Colorized(this).aqua()
fun String.red() = Colorized(this).red()
fun String.lightPurple() = Colorized(this).lightPurple()
fun String.yellow() = Colorized(this).yellow()
fun String.white() = Colorized(this).white()
fun String.reset() = Colorized(this).reset()
fun String.magic() = Colorized(this).magic()
fun String.bold() = Colorized(this).bold()
fun String.strike() = Colorized(this).strike()
fun String.underline() = Colorized(this).underline()
fun String.italic() = Colorized(this).italic()

operator fun ChatColor.plus(str : String) = this.toString() + str
99 changes: 99 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
allprojects {
group 'br.com.gamemods.kotlinfun'
version '1.0-SNAPSHOT'
}

buildscript {
ext.kotlin_version = '1.0.3'
ext.bukkit_repo = 'https://hub.spigotmc.org/nexus/content/groups/public/'

repositories {
mavenCentral()
jcenter()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}

apply plugin: 'kotlin'

repositories {
mavenCentral()
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

subprojects {
apply plugin: 'kotlin'
apply plugin: 'com.github.johnrengelman.shadow'

sourceCompatibility = 1.6
targetCompatibility = 1.6
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

repositories {
mavenCentral()
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-runtime:$kotlin_version"
compile rootProject
testCompile group: 'junit', name: 'junit', version: '4.11'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

shadowJar {
dependencies {
include dependency("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
include dependency("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
include dependency("org.jetbrains.kotlin:kotlin-runtime:$kotlin_version")
include dependency(rootProject)
}

classifier = null
// relocate 'kotlin', 'br.com.gamemods.kotlinfun.kotlin'
}

build.finalizedBy shadowJar
}

project(':KotlinFunBungeeChat') {
dependencies {
compile 'net.md-5:bungeecord-chat:1.10-SNAPSHOT'
}
}

project(':KotlinFunUniversal') {
repositories {
maven { url = bukkit_repo }
}

dependencies {
compile project(':KotlinFunBungee')
compile project(':KotlinFunBukkit')
}

shadowJar {
dependencies {
include project(':KotlinFunBungee')
include project(':KotlinFunBukkit')
}
}
}
1 change: 1 addition & 0 deletions gradle/wrapper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gradle-wrapper.jar
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Wed Oct 19 20:45:31 BRT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
Loading

0 comments on commit 793d9bc

Please sign in to comment.