diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..e9b3e1b --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,43 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Gradle build + +on: + push: + branches: [ "master", "dev" ] + pull_request: + branches: [ "master", "dev" ] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + + - name: Build with Gradle Wrapper + run: ./gradlew build -PcommitHash=$(git rev-parse --short "$GITHUB_SHA") + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: '${{ github.event.repository.name }}' + path: build/libs diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index de6fc32..0000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,31 +0,0 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Java CI with Maven - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: maven - - name: Build with Maven - run: mvn -B package --file pom.xml diff --git a/.gitignore b/.gitignore index faf0f23..c8fb68a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,4 @@ -### Java template -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* -replay_pid* - -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Covers JetBrains IDEs: IntelliJ, GoLand, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # User-specific stuff @@ -50,10 +23,6 @@ replay_pid* .idea/**/uiDesigner.xml .idea/**/dbnavigator.xml -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - # Gradle and Maven with auto-import # When using Gradle or Maven with auto-import, you should exclude module files, # since they will be recreated, and may cause churn. Uncomment if using @@ -67,41 +36,66 @@ replay_pid* # *.iml # *.ipr -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - # File-based project format *.iws # IntelliJ out/ -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# SonarLint plugin -.idea/sonarlint/ - # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties crashlytics-build.properties fabric.properties -# Editor-based Rest Client -.idea/httpRequests +/.idea/ + + +# Java +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +# Gradle +.gradle +**/build/ +!**/src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Avoid ignore Gradle wrappper properties +!gradle-wrapper.properties -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser +# Cache of project +.gradletasknamecache -.idea/* -target/* \ No newline at end of file +# Eclipse Gradle plugin generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath \ No newline at end of file diff --git a/.idea/artifacts/LoginPlugin.xml b/.idea/artifacts/LoginPlugin.xml deleted file mode 100644 index 3476911..0000000 --- a/.idea/artifacts/LoginPlugin.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - $PROJECT_DIR$/../1.20.2 server for testing joutak login/plugins - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 0be571f..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 21801a9..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.run/build_release.run.xml b/.run/build_release.run.xml new file mode 100644 index 0000000..491d63f --- /dev/null +++ b/.run/build_release.run.xml @@ -0,0 +1,24 @@ + + + + + + + true + true + false + false + + + diff --git a/.run/build_snapshot.run.xml b/.run/build_snapshot.run.xml new file mode 100644 index 0000000..e2cdddf --- /dev/null +++ b/.run/build_snapshot.run.xml @@ -0,0 +1,29 @@ + + + + + + + + true + true + false + false + + + diff --git a/JouTakTemplate.iml b/JouTakTemplate.iml deleted file mode 100644 index 4519087..0000000 --- a/JouTakTemplate.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index f65145e..1f30075 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,52 @@ -# Template Plugin для новичков с java! +# JouTak Plugin Template (Java Edition) -Что нужно сделать: -1) склонить проект себе по ssh -2) открыть в любой удобной ide(vs code | inteliji idea) -3) разобраться с расположением папочек и синтаксисом, почитать про используемые библиотеки, прописать базовую логику, которая описана в issues. (креативность поощрается) -4) собрать его с помощью Maven -5) запустить у себя на компе Purpur 1.21.4 сервер и закинуть на него этот плагин -6) подключиться со своего майна, проверить, что оно заработало -7) отправить пулл реквест обратно на гитхаб, закрыв issue -8) пингануть кого-нибудь, чтобы реквест посмотрели и приняли :) +Заготовка для плагина на JouTak (ДжоуТек) (joutak.ru) -если всё работает, то пулл реквест автоматически сбилдит такой же jarник, который будет так же работать на твоём локальном сервере. -сначала всё можно писать в один файлик, но тогда потом создай небольшую структуру. Главное - не стесняйся спрашивать! +# Перед использованием -# Полезное: +1. Отредактируйте: + - `gradle.properties` — укажите **версию** и **название** плагина, а также **ссылку на репозиторий** с вашим плагином + - `src/main/java/ru/joutak/` — переименуйте **основной класс** под название вашего плагина + - `src/main/resources/plugin.yml` — укажите **правильный путь** до основного класса плагина и укажите себя как **автора** + - `gradle/libs.versions.toml` — измените **версии** **JDK**, **ядра** и **других библиотек** по необходимости + - Укажите **полный путь до тестового сервера** в переменной окружения системы `SERVER_PATH` +> [!TIP] +> Указав путь до тестового сервера, можно собирать плагин с помощью конфигурации `[Snapshot] Build`, тогда jar-архив с вашим плагином сразу будет создаваться в нужной папке автоматически. + + +# Сборка плагина + +1. Открыть проект в **IntelliJ IDEA** +2. Нажать кнопку `Run` справа сверху для сборки: + - `[Snapshot]` создает архив с плагином в папке `plugins/` тестового сервера (путь до которого нужно указать в переменной окружения `SERVER_PATH`) + - `[Release]` создает архив с плагином в папке `build/` проекта + + +# Перед началом выполнения тестового задания +> [!NOTE] +> Данный параграф предназначен для тех, кто захотел попробовать себя в роли разработчка плагинов для Minecraft серверов в составе команды JouTak. + +Базовое описание, что нужно сделать: +1) Сделать собственный **fork** данного репозитория +2) Склонировать созданный репозиторий себе по **SSH** (`git clone`) +3) Открыть проект в любой удобной для вас **IDE** +> [!TIP] +> Рекомендуем использовать **IntelliJ IDEA**, так как в ней есть полноценная поддержка **Java** со всеми фишками и плюшками, но выбор за вами +4) Разобраться с расположением папочек и синтаксисом **Java**, затем прописать базовую логику, которая была описана в вашем задании в issues (Любая креативность поощряется) +5) Собрать плагин с помощью **Gradle** +> [!TIP] +> Конфиги уже заранее прописаны (один для тестовых целей, второй для полноценного релиза), вам самим ничего прописывать не надо. Для тестов лучше использовать `[Snapshot]` версию, чтобы каждый раз не перекидывать вручную плагин в папку сервера, главное не забудьте создать переменную окружения `SERVER_PATH`! +6) Запустить на своем компьютере локальный [**Purpur**](https://purpurmc.org) сервер +7) Подключиться на свой локальный сервер и проверить, что плагин работает исправно +8) Отправить **pull request** на **GitHub** и дождаться ответа +> [!TIP] +> Если долго никто не отвечает, то можно пингануть кого-нибудь, чтобы реквест отсмотрели и приняли :) + +Если плагин написан без базовых ошибок (синтаксических и т. п.), то на **GitHub**'е автоматически соберется такой же jar-архив, который будет так же работать на твоем локальном сервере. + +Поначалу всё можно писать в основном классе, но потом все вещи по типу команд, listener'ов и различные event'ы нужно выделить в отдельные классы и пакеты. + +> [!IMPORTANT] +> Главное, если есть какие-то вопросы - не стесняйся спрашивать! diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..d18c647 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,81 @@ +val group: String by project +val version: String by project +val repo: String by project + +project.group = group +project.version = version + +plugins { + java +} + +repositories { + mavenCentral() + maven("https://repo.papermc.io/repository/maven-public/") { + name = "papermc-repo" + } + maven("https://oss.sonatype.org/content/groups/public/") { + name = "sonatype" + } +} + +dependencies { + compileOnly(libs.paper) + compileOnly(libs.lombok) + + testImplementation(libs.bundles.junit) +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(libs.versions.jdk.get()) + } +} + +tasks.test { + useJUnitPlatform() +} + +tasks.processResources { + val minecraftVersion = + libs.versions.paper + .get() + .substringBefore("-") + + val commitHash = project.findProperty("commitHash") as String? + + val website = + if (repo.isBlank()) { + "https://joutak.ru" + } else { + if (commitHash.isNullOrBlank()) repo else "$repo/tree/$commitHash" + } + + val props = + mapOf( + "NAME" to project.name, + "VERSION" to project.version, + "MINECRAFT_VERSION" to minecraftVersion, + "WEBSITE" to website, + "LOMBOK_VERSION" to libs.versions.lombok.get(), + ) + + inputs.properties(props) + filteringCharset = "UTF-8" + filesMatching("plugin.yml") { + expand(props) + } +} + +tasks.jar { + archiveFileName.set("${project.name}-${project.version}.jar") + + if (System.getenv("TEST_PLUGIN_BUILD") != null) { + val serverPath = System.getenv("SERVER_PATH") + if (serverPath != null) { + destinationDirectory.set(file("$serverPath\\plugins")) + } else { + logger.warn("SERVER_PATH property is not set!") + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..cf51ce0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,8 @@ +# Plugin properties +repo=https://github.com/JouTak/TemplatePlugin-Java +group=ru.joutak +name=Template-Java +version=1.0.0 + +# Gradle properties +org.gradle.parallel=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..7b40284 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,18 @@ +[versions] +jdk = "21" +paper = "1.21.5-R0.1-SNAPSHOT" +lombok = "1.18.32" +junit = "5.13.4" + +[libraries] +paper = { module = "io.papermc.paper:paper-api", version.ref = "paper" } +lombok = { module = "org.projectlombok:lombok", version.ref = "lombok" } +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit"} +junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } +junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } +junit-launcher = { module = "org.junit.platform:junit-platform-launcher" } + +[plugins] + +[bundles] +junit = [ "junit-jupiter", "junit-api", "junit-engine", "junit-launcher" ] \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8bdaf60 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2a84e18 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..ef07e01 --- /dev/null +++ b/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# 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 +# +# https://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. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# 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 ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# 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 + if ! command -v java >/dev/null 2>&1 + then + 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 +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..db3a6ac --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@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=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 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! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 1354717..0000000 --- a/pom.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - 4.0.0 - - org.joutak - JouTakTemplate - 1.0-SNAPSHOT - jar - - JouTakTemplate - - - 1.8 - UTF-8 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - 11 - 11 - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - false - - - - - - - - src/main/resources - true - - - - - - - papermc-repo - https://repo.papermc.io/repository/maven-public/ - - - sonatype - https://oss.sonatype.org/content/groups/public/ - - - - - - org.projectlombok - lombok - 1.18.32 - provided - - - io.papermc.paper - paper-api - 1.20.2-R0.1-SNAPSHOT - provided - - - com.google.code.gson - gson - 2.10.1 - - - org.apache.logging.log4j - log4j-core - 2.23.1 - - - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..b610ec2 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,3 @@ +val name: String by settings + +rootProject.name = name \ No newline at end of file diff --git a/src/main/java/org/joutak/joutaktemplate/JouTakTemplate.java b/src/main/java/org/joutak/joutaktemplate/JouTakTemplate.java deleted file mode 100644 index ec00d71..0000000 --- a/src/main/java/org/joutak/joutaktemplate/JouTakTemplate.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.joutak.joutaktemplate; - -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.bukkit.plugin.java.JavaPlugin; - - -@Slf4j -public final class JouTakTemplate extends JavaPlugin { - - @Getter - private static JouTakTemplate instance; - - @Override - public void onEnable() { - - } - - @Override - public void onDisable() { - // Plugin shutdown logic - } - -} diff --git a/src/main/java/ru/joutak/template/EmptyPlugin.java b/src/main/java/ru/joutak/template/EmptyPlugin.java new file mode 100644 index 0000000..d93430e --- /dev/null +++ b/src/main/java/ru/joutak/template/EmptyPlugin.java @@ -0,0 +1,23 @@ +package ru.joutak.template; + +import lombok.Getter; +import org.bukkit.plugin.java.JavaPlugin; + +public final class EmptyPlugin extends JavaPlugin { + @Getter + private static EmptyPlugin instance; + + @Override + public void onEnable() { + instance = this; + + getLogger().info( + String.format("Плагин %s версии %s включен!", getPluginMeta().getName(), getPluginMeta().getVersion()) + ); + } + + @Override + public void onDisable() { + + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index bb6c591..4428874 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,12 @@ -name: JouTakTemplate -version: '${project.version}' -main: org.joutak.joutaktemplate.JouTakTemplate -api-version: '1.20' -commands: - joutest: {} +name: ${NAME} +version: ${VERSION} +api-version: ${MINECRAFT_VERSION} +main: ru.joutak.template.EmptyPlugin +description: 'A template plugin' +authors: ['EnderDissa', 'Stunnerer', 's4dnex'] +contributors: ['technosimp'] +website: ${WEBSITE} + +depend: [] +libraries: + - 'org.projectlombok:lombok:${LOMBOK_VERSION}' \ No newline at end of file diff --git a/src/test/java/ru/joutak/test/ExampleTest.java b/src/test/java/ru/joutak/test/ExampleTest.java new file mode 100644 index 0000000..3d24ac1 --- /dev/null +++ b/src/test/java/ru/joutak/test/ExampleTest.java @@ -0,0 +1,36 @@ +package ru.joutak.test; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ExampleTest { + @BeforeAll + static void setup() { + System.out.println("@BeforeAll executed"); + } + + @BeforeEach + void setupThis() { + System.out.println("@BeforeEach executed"); + } + + @AfterEach + void tearThis() { + System.out.println("@AfterEach executed"); + } + + @Test + void test() { + Assertions.assertTrue(true); + System.out.println("@Test executed"); + } + + @AfterAll + static void tear() { + System.out.println("@AfterAll executed"); + } +}