From 793d9bcd31bd751dbb003aa35a126789bc9321c5 Mon Sep 17 00:00:00 2001 From: joserobjr Date: Thu, 20 Oct 2016 11:24:57 -0300 Subject: [PATCH] Initial import --- .gitignore | 3 + KotlinFunBukkit/build.gradle | 29 ++++ .../com/gamemods/kotlinfun/bukkit/bukkit.kt | 74 ++++++++ KotlinFunBukkit/src/main/resources/plugin.yml | 4 + .../kotlinfun/bukkit/KotlinFunTest.kt | 15 ++ KotlinFunBungee/build.gradle | 24 +++ .../com/gamemods/kotlinfun/bungee/bungee.kt | 6 + KotlinFunBungee/src/main/resources/bungee.yml | 4 + .../gamemods/kotlinfun/bungee/Colorized.kt | 71 ++++++++ build.gradle | 99 +++++++++++ gradle/wrapper/.gitignore | 1 + gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 164 ++++++++++++++++++ gradlew.bat | 90 ++++++++++ settings.gradle | 2 + .../br/com/gamemods/kotlinfun/common.kt | 55 ++++++ .../LICENSE-JetBrains-Annotations.txt | 13 ++ src/main/resources/LICENSE-Kotlin.txt | 13 ++ 18 files changed, 673 insertions(+) create mode 100644 .gitignore create mode 100644 KotlinFunBukkit/build.gradle create mode 100644 KotlinFunBukkit/src/main/kotlin/br/com/gamemods/kotlinfun/bukkit/bukkit.kt create mode 100644 KotlinFunBukkit/src/main/resources/plugin.yml create mode 100644 KotlinFunBukkit/src/test/kotlin/br/com/gamemods/kotlinfun/bukkit/KotlinFunTest.kt create mode 100644 KotlinFunBungee/build.gradle create mode 100644 KotlinFunBungee/src/main/kotlin/br/com/gamemods/kotlinfun/bungee/bungee.kt create mode 100644 KotlinFunBungee/src/main/resources/bungee.yml create mode 100644 KotlinFunBungeeChat/src/main/kotlin/br/com/gamemods/kotlinfun/bungee/Colorized.kt create mode 100644 build.gradle create mode 100644 gradle/wrapper/.gitignore create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle create mode 100644 src/main/kotlin/br/com/gamemods/kotlinfun/common.kt create mode 100644 src/main/resources/LICENSE-JetBrains-Annotations.txt create mode 100644 src/main/resources/LICENSE-Kotlin.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e0d53d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.gradle +.idea +build diff --git a/KotlinFunBukkit/build.gradle b/KotlinFunBukkit/build.gradle new file mode 100644 index 0000000..d12635a --- /dev/null +++ b/KotlinFunBukkit/build.gradle @@ -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' + } +} diff --git a/KotlinFunBukkit/src/main/kotlin/br/com/gamemods/kotlinfun/bukkit/bukkit.kt b/KotlinFunBukkit/src/main/kotlin/br/com/gamemods/kotlinfun/bukkit/bukkit.kt new file mode 100644 index 0000000..6def063 --- /dev/null +++ b/KotlinFunBukkit/src/main/kotlin/br/com/gamemods/kotlinfun/bukkit/bukkit.kt @@ -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(str) { + override val format : EnumSet = 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 diff --git a/KotlinFunBukkit/src/main/resources/plugin.yml b/KotlinFunBukkit/src/main/resources/plugin.yml new file mode 100644 index 0000000..d8edff3 --- /dev/null +++ b/KotlinFunBukkit/src/main/resources/plugin.yml @@ -0,0 +1,4 @@ +name: KotlinFun +version: ${version} +author: joserobjr +main: br.com.gamemods.kotlinfun.bukkit.KotlinFun diff --git a/KotlinFunBukkit/src/test/kotlin/br/com/gamemods/kotlinfun/bukkit/KotlinFunTest.kt b/KotlinFunBukkit/src/test/kotlin/br/com/gamemods/kotlinfun/bukkit/KotlinFunTest.kt new file mode 100644 index 0000000..23c1758 --- /dev/null +++ b/KotlinFunBukkit/src/test/kotlin/br/com/gamemods/kotlinfun/bukkit/KotlinFunTest.kt @@ -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()) + } +} diff --git a/KotlinFunBungee/build.gradle b/KotlinFunBungee/build.gradle new file mode 100644 index 0000000..6d0a941 --- /dev/null +++ b/KotlinFunBungee/build.gradle @@ -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' + } +} diff --git a/KotlinFunBungee/src/main/kotlin/br/com/gamemods/kotlinfun/bungee/bungee.kt b/KotlinFunBungee/src/main/kotlin/br/com/gamemods/kotlinfun/bungee/bungee.kt new file mode 100644 index 0000000..106d974 --- /dev/null +++ b/KotlinFunBungee/src/main/kotlin/br/com/gamemods/kotlinfun/bungee/bungee.kt @@ -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() diff --git a/KotlinFunBungee/src/main/resources/bungee.yml b/KotlinFunBungee/src/main/resources/bungee.yml new file mode 100644 index 0000000..1be1e2c --- /dev/null +++ b/KotlinFunBungee/src/main/resources/bungee.yml @@ -0,0 +1,4 @@ +name: KotlinFun +version: ${version} +author: joserobjr +main: br.com.gamemods.kotlinfun.bungee.KotlinFun diff --git a/KotlinFunBungeeChat/src/main/kotlin/br/com/gamemods/kotlinfun/bungee/Colorized.kt b/KotlinFunBungeeChat/src/main/kotlin/br/com/gamemods/kotlinfun/bungee/Colorized.kt new file mode 100644 index 0000000..0825f27 --- /dev/null +++ b/KotlinFunBungeeChat/src/main/kotlin/br/com/gamemods/kotlinfun/bungee/Colorized.kt @@ -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(str) { + override val format : EnumSet = 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 diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..a998b0b --- /dev/null +++ b/build.gradle @@ -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') + } + } +} diff --git a/gradle/wrapper/.gitignore b/gradle/wrapper/.gitignore new file mode 100644 index 0000000..7536258 --- /dev/null +++ b/gradle/wrapper/.gitignore @@ -0,0 +1 @@ +gradle-wrapper.jar \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..90ba45e --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..27309d9 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..832fdb6 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..d7ef646 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'KotlinFun' +include 'KotlinFunBukkit', 'KotlinFunBungee', 'KotlinFunBungeeChat', 'KotlinFunUniversal' diff --git a/src/main/kotlin/br/com/gamemods/kotlinfun/common.kt b/src/main/kotlin/br/com/gamemods/kotlinfun/common.kt new file mode 100644 index 0000000..7de8559 --- /dev/null +++ b/src/main/kotlin/br/com/gamemods/kotlinfun/common.kt @@ -0,0 +1,55 @@ +package br.com.gamemods.kotlinfun + +fun Any?.str() = this?.toString() ?: "" + +val toStringOrEmpty : ((Any?) -> CharSequence) = { it.str() } + +abstract class ColorizedBase(private val str: String) { + var color : E? = null + protected set + + protected abstract val format : MutableSet + + override fun toString(): String { + return (color?.toString() ?: "") + format.joinToString(separator = "", transform = toStringOrEmpty) + str + } + + abstract fun black() : ColorizedBase + abstract fun darkBlue() : ColorizedBase + abstract fun darkGreen() : ColorizedBase + abstract fun darkAqua() : ColorizedBase + abstract fun darkRed() : ColorizedBase + abstract fun darkPurple() : ColorizedBase + abstract fun gold() : ColorizedBase + abstract fun gray() : ColorizedBase + abstract fun darkGray() : ColorizedBase + abstract fun blue() : ColorizedBase + abstract fun green() : ColorizedBase + abstract fun aqua() : ColorizedBase + abstract fun red() : ColorizedBase + abstract fun lightPurple() : ColorizedBase + abstract fun yellow() : ColorizedBase + abstract fun white() : ColorizedBase + abstract fun reset() : ColorizedBase + abstract fun magic() : ColorizedBase + abstract fun bold() : ColorizedBase + abstract fun strike() : ColorizedBase + abstract fun underline() : ColorizedBase + abstract fun italic() : ColorizedBase + + fun noColor(): ColorizedBase { + color = null + return this + } + fun noFormat() : ColorizedBase { + format.clear() + return this + } + + private fun addFormat(f: E) : ColorizedBase { + format.add(f) + return this + } + + operator fun plus(o: Any?) = this.toString() + o +} diff --git a/src/main/resources/LICENSE-JetBrains-Annotations.txt b/src/main/resources/LICENSE-JetBrains-Annotations.txt new file mode 100644 index 0000000..e0bf86f --- /dev/null +++ b/src/main/resources/LICENSE-JetBrains-Annotations.txt @@ -0,0 +1,13 @@ +Copyright 2010-2016 JetBrains s.r.o. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/src/main/resources/LICENSE-Kotlin.txt b/src/main/resources/LICENSE-Kotlin.txt new file mode 100644 index 0000000..e0bf86f --- /dev/null +++ b/src/main/resources/LICENSE-Kotlin.txt @@ -0,0 +1,13 @@ +Copyright 2010-2016 JetBrains s.r.o. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.