Initial commit
This commit is contained in:
commit
f23a010a02
12
.gitattributes
vendored
Normal file
12
.gitattributes
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# https://help.github.com/articles/dealing-with-line-endings/
|
||||||
|
#
|
||||||
|
# Linux start script should use lf
|
||||||
|
/gradlew text eol=lf
|
||||||
|
|
||||||
|
# These are Windows script files and should use crlf
|
||||||
|
*.bat text eol=crlf
|
||||||
|
|
||||||
|
# Binary files should be left untouched
|
||||||
|
*.jar binary
|
||||||
|
|
4
.gitignore
vendored
Executable file
4
.gitignore
vendored
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
/bin/
|
||||||
|
.gradle
|
||||||
|
build
|
||||||
|
.idea
|
11
README.md
Executable file
11
README.md
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
# InfernalMobs
|
||||||
|
|
||||||
|
This is the Infernal Mobs source code.
|
||||||
|
|
||||||
|
Released under the License: (CC BY-NC-SA 2.5 CA)
|
||||||
|
https://creativecommons.org/licenses/by-nc-sa/2.5/ca/
|
||||||
|
|
||||||
|
You can use it for private purposes or for non-commercial purposes if you give the author credit.
|
||||||
|
You MUST also link your changed source.
|
||||||
|
|
||||||
|
Thank you.
|
91
build.gradle.kts
Normal file
91
build.gradle.kts
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import java.util.*
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("jvm") version "2.0.10"
|
||||||
|
kotlin("kapt") version "1.7.0"
|
||||||
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
|
id ("com.google.devtools.ksp") version "2.0.20-1.0.25"
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "io.github.thehrz.infernalmobs"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||||
|
maven("https://papermc.io/repo/repository/maven-public/")
|
||||||
|
maven("https://oss.sonatype.org/content/groups/public/")
|
||||||
|
maven("https://repo.codemc.org/repository/maven-public/")
|
||||||
|
maven("https://plugins.gradle.org/m2/")
|
||||||
|
maven("https://maven.enginehub.org/repo/")
|
||||||
|
maven("https://repo.triumphteam.dev/snapshots/")
|
||||||
|
maven("https://repo.dustplanet.de/artifactory/libs-release-local")
|
||||||
|
maven("https://jitpack.io")
|
||||||
|
maven("https://repo.dmulloy2.net/repository/public/")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("stdlib-jdk8"))
|
||||||
|
// implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.6.2"))
|
||||||
|
// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
|
||||||
|
implementation("com.github.cryptomorin:XSeries:8.8.0")
|
||||||
|
implementation("me.mattstudios:triumph-msg-adventure:2.2.4-SNAPSHOT")
|
||||||
|
implementation("de.exlll:configlib-paper:4.5.0")
|
||||||
|
|
||||||
|
// implementation("io.insert-koin:koin-core:4.0.2")
|
||||||
|
implementation("io.insert-koin:koin-core-jvm:4.0.2")
|
||||||
|
implementation("io.insert-koin:koin-annotations:1.4.0")
|
||||||
|
ksp("io.insert-koin:koin-ksp-compiler:1.3.1")
|
||||||
|
|
||||||
|
compileOnly("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT")
|
||||||
|
compileOnly("org.apache.logging.log4j:log4j-core:2.17.2")
|
||||||
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.3.0")
|
||||||
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.5")
|
||||||
|
compileOnly("com.github.TownyAdvanced:Towny:0.97.1.0")
|
||||||
|
compileOnly("de.dustplanet:silkspawners:7.1.0") {
|
||||||
|
exclude(group = "*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.build {
|
||||||
|
dependsOn("shadowJar")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.shadowJar {
|
||||||
|
val dependencyPackage = "${rootProject.group}.dependencies.${rootProject.name.lowercase(Locale.getDefault())}"
|
||||||
|
relocate("com.cryptomorin.xseries", "${dependencyPackage}.xseries")
|
||||||
|
relocate("javax.inject", "${dependencyPackage}.javax.inject")
|
||||||
|
|
||||||
|
relocate("me.mattstudios.msg", "${dependencyPackage}.mfmsg")
|
||||||
|
relocate("org.jetbrains", "${dependencyPackage}.jetbrains")
|
||||||
|
relocate("org.intellij", "${dependencyPackage}.jetbrains.intellij")
|
||||||
|
relocate("toothpick", "${dependencyPackage}.toothpick")
|
||||||
|
exclude("ScopeJVMKt.class")
|
||||||
|
exclude("DebugProbesKt.bin")
|
||||||
|
exclude("META-INF/**")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<ProcessResources> {
|
||||||
|
filesMatching("plugin.yml") {
|
||||||
|
expand("version" to version)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val targetJavaVersion = 17
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain(targetJavaVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
//tasks.withType<JavaCompile> {
|
||||||
|
// sourceCompatibility = javaVersion
|
||||||
|
// targetCompatibility = javaVersion
|
||||||
|
// options.encoding = "UTF-8"
|
||||||
|
//}
|
||||||
|
|
||||||
|
//tasks.processResources {
|
||||||
|
// outputs.upToDateWhen { false }
|
||||||
|
// val main_class = "${project.group}.${project.name.toLowerCase()}.${project.name}"
|
||||||
|
// expand("name" to project.name, "version" to project.version, "mainClass" to main_class)
|
||||||
|
//}
|
3
gradle.properties
Normal file
3
gradle.properties
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# This file was generated by the Gradle 'init' task.
|
||||||
|
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
|
||||||
|
|
10
gradle/libs.versions.toml
Normal file
10
gradle/libs.versions.toml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# This file was generated by the Gradle 'init' task.
|
||||||
|
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
|
||||||
|
|
||||||
|
[versions]
|
||||||
|
guava = "33.3.1-jre"
|
||||||
|
junit-jupiter = "5.11.1"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
||||||
|
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
251
gradlew
vendored
Executable file
251
gradlew
vendored
Executable file
@ -0,0 +1,251 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 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=$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
|
||||||
|
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, 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" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# 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" "$@"
|
94
gradlew.bat
vendored
Normal file
94
gradlew.bat
vendored
Normal file
@ -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=%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 %*
|
||||||
|
|
||||||
|
: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
|
8
settings.gradle.kts
Normal file
8
settings.gradle.kts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
rootProject.name = "InfernalMobs"
|
||||||
|
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
gradlePluginPortal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
142
src/main/kotlin/io/github/thehrz/infernalmobs/InfernalMobs.kt
Executable file
142
src/main/kotlin/io/github/thehrz/infernalmobs/InfernalMobs.kt
Executable file
@ -0,0 +1,142 @@
|
|||||||
|
package io.github.thehrz.infernalmobs
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.handler.EffectHandle
|
||||||
|
import io.github.thehrz.infernalmobs.koin.pluginModule
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.ItemUtils
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.NamespacedKey
|
||||||
|
import org.bukkit.enchantments.Enchantment
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.ShapedRecipe
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
import org.koin.core.KoinApplication
|
||||||
|
import org.koin.dsl.koinApplication
|
||||||
|
import org.koin.ksp.generated.defaultModule
|
||||||
|
import java.io.File
|
||||||
|
import java.util.logging.Level
|
||||||
|
|
||||||
|
class InfernalMobs : JavaPlugin() {
|
||||||
|
var serverTime: Long = 0L
|
||||||
|
|
||||||
|
lateinit var koinApp: KoinApplication
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
lateinit var instance: InfernalMobs
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onEnable() {
|
||||||
|
koinApp = koinApplication {
|
||||||
|
modules(
|
||||||
|
pluginModule(this@InfernalMobs),
|
||||||
|
defaultModule
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registering event
|
||||||
|
logger.info("Registering event listeners...")
|
||||||
|
val listeners = koinApp.koin.getAll<Listener>()
|
||||||
|
logger.info("Total possible listeners: ${listeners.size}")
|
||||||
|
listeners.forEach {
|
||||||
|
logger.info("Registering event listener: ${it::class.simpleName}")
|
||||||
|
Bukkit.getPluginManager().registerEvents(it, this)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("Registered Events.")
|
||||||
|
|
||||||
|
|
||||||
|
//Folder
|
||||||
|
val dir = File(dataFolder.parentFile.path, this.name)
|
||||||
|
if (!dir.exists()) dir.mkdir()
|
||||||
|
|
||||||
|
|
||||||
|
//Old config check
|
||||||
|
// if (File(dataFolder, "config.yml").exists()) {
|
||||||
|
// if (config.getString("configVersion") == null) {
|
||||||
|
// logger.log(Level.INFO, "No config version found!")
|
||||||
|
// config["configVersion"] = Bukkit.getVersion()
|
||||||
|
// .split(":".toRegex())
|
||||||
|
// .dropLastWhile { it.isEmpty() }
|
||||||
|
// .toTypedArray()[1]
|
||||||
|
// .replace(")", "")
|
||||||
|
// .trim { it <= ' ' }
|
||||||
|
// saveConfig()
|
||||||
|
// }
|
||||||
|
// if (Bukkit.getVersion() != config.getString("configVersion")) {
|
||||||
|
// println(Bukkit.getVersion() + " contains " + config.getString("configVersion"))
|
||||||
|
// logger.log(Level.INFO, "Old config found, deleting!")
|
||||||
|
// File(dataFolder.toString() + File.separator + "config.yml").delete()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//Register Config
|
||||||
|
|
||||||
|
// if (!File(dataFolder, "config.yml").exists()) {
|
||||||
|
// logger.log(Level.INFO, "No config.yml found, generating...")
|
||||||
|
// saveConfig()
|
||||||
|
// reloadConfig()
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// //Register Loots
|
||||||
|
// if (!lootYML.exists()) {
|
||||||
|
// logger.log(Level.INFO, "No loot.yml found, generating...")
|
||||||
|
// reloadLoot()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //Register Save File
|
||||||
|
// if (!saveYML.exists()) {
|
||||||
|
// try {
|
||||||
|
// saveYML.createNewFile()
|
||||||
|
// } catch (e: IOException) {
|
||||||
|
// e.printStackTrace()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
koinApp.koin.get<ConfigService>().loadConfigs()
|
||||||
|
|
||||||
|
koinApp.koin.get<EffectHandle>().applyEffect()
|
||||||
|
|
||||||
|
koinApp.koin.get<InfernalMobService>().reloadPowers()
|
||||||
|
|
||||||
|
koinApp.koin.get<EffectHandle>().showEffect()
|
||||||
|
|
||||||
|
addRecipes()
|
||||||
|
}
|
||||||
|
|
||||||
|
// fun reloadLoot() {
|
||||||
|
// if (this.lootYML == null) {
|
||||||
|
// this.lootYML = File(dataFolder, "loot.yml")
|
||||||
|
// }
|
||||||
|
// this.configService.lootConfig = YamlConfiguration.loadConfiguration(this.lootYML)
|
||||||
|
//
|
||||||
|
// val defConfig = YamlConfiguration.loadConfiguration(lootYML)
|
||||||
|
// configService.lootConfig.setDefaults(defConfig)
|
||||||
|
// }
|
||||||
|
|
||||||
|
val diviningStaff: ItemStack
|
||||||
|
get() {
|
||||||
|
val s = ItemUtils.getItem(
|
||||||
|
Material.BLAZE_ROD,
|
||||||
|
"§6§lDivining Rod",
|
||||||
|
1,
|
||||||
|
mutableListOf("Click to find infernal mobs.")
|
||||||
|
)
|
||||||
|
val m = s.itemMeta
|
||||||
|
m.addEnchant(Enchantment.CHANNELING, 1, true)
|
||||||
|
s.setItemMeta(m)
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addRecipes() {
|
||||||
|
val staff = diviningStaff
|
||||||
|
val key = NamespacedKey(this, "divining_staff")
|
||||||
|
val sr = ShapedRecipe(key, staff)
|
||||||
|
sr.shape("ANA", "ASA", "ASA")
|
||||||
|
sr.setIngredient('N', Material.NETHER_STAR)
|
||||||
|
sr.setIngredient('S', Material.BLAZE_ROD)
|
||||||
|
Bukkit.addRecipe(sr)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,669 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.commands
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.enums.Abilitiy
|
||||||
|
import io.github.thehrz.infernalmobs.gui.GUI
|
||||||
|
import io.github.thehrz.infernalmobs.handler.InfernalMobHandler
|
||||||
|
import io.github.thehrz.infernalmobs.handler.LootHandler
|
||||||
|
import io.github.thehrz.infernalmobs.models.InfernalMob
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.*
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.World
|
||||||
|
import org.bukkit.command.Command
|
||||||
|
import org.bukkit.command.CommandExecutor
|
||||||
|
import org.bukkit.command.CommandSender
|
||||||
|
import org.bukkit.command.TabCompleter
|
||||||
|
import org.bukkit.entity.*
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.util.*
|
||||||
|
import java.util.function.Consumer
|
||||||
|
import java.util.logging.Level
|
||||||
|
import java.util.stream.Collectors
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class Command(
|
||||||
|
val plugin: InfernalMobs,
|
||||||
|
val configService: ConfigService,
|
||||||
|
val infernalMobService: InfernalMobService,
|
||||||
|
val lootHandler: LootHandler,
|
||||||
|
val infernalMobHandler: InfernalMobHandler,
|
||||||
|
val gui: GUI
|
||||||
|
) : CommandExecutor, TabCompleter {
|
||||||
|
var errorList = mutableListOf<Player>()
|
||||||
|
private val loops = 0
|
||||||
|
|
||||||
|
init {
|
||||||
|
plugin.getCommand("im")?.let { cmd ->
|
||||||
|
cmd.setExecutor(this)
|
||||||
|
cmd.tabCompleter = this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val randomMob: String
|
||||||
|
get() {
|
||||||
|
val mobList = configService.mainConfig.enabledMobs
|
||||||
|
if (mobList.isEmpty()) {
|
||||||
|
return "Zombie"
|
||||||
|
}
|
||||||
|
val mob = mobList[MathUtils.rand(1, mobList.size) - 1]
|
||||||
|
return mob
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCommand(sender: CommandSender, cmd: Command, label: String, args: Array<String>?): Boolean {
|
||||||
|
if ((cmd.name.equals("infernalmobs", ignoreCase = true)) || (cmd.name.equals("im", ignoreCase = true))) {
|
||||||
|
try {
|
||||||
|
if (sender !is Player) {
|
||||||
|
if (!args.isNullOrEmpty() && (!args[0].equals(
|
||||||
|
"cspawn",
|
||||||
|
ignoreCase = true
|
||||||
|
)) && (!args[0].equals("pspawn", ignoreCase = true)) && (!args[0].equals(
|
||||||
|
"giveloot",
|
||||||
|
ignoreCase = true
|
||||||
|
)) && (!args[0].equals("reload", ignoreCase = true)) && (!args[0].equals(
|
||||||
|
"killall",
|
||||||
|
ignoreCase = true
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
sender.sendMessage("This command can only be run by a player!")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val player = sender as Player
|
||||||
|
if (sender.hasPermission("infernal_mobs.commands")) {
|
||||||
|
if (args!!.isEmpty()) {
|
||||||
|
throwError(sender)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (args[0].equals("slotTest", ignoreCase = true)) {
|
||||||
|
for (i in configService.mainConfig.enabledCharmSlots) {
|
||||||
|
player.inventory.setItem(
|
||||||
|
i, ItemStack(
|
||||||
|
Material.RED_STAINED_GLASS_PANE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ((args.size == 1) && (args[0].equals("fixloot", ignoreCase = true))) {
|
||||||
|
//TODO: ? what is items
|
||||||
|
// val list =
|
||||||
|
// configService.mainConfig.items.getKeys(false)
|
||||||
|
//
|
||||||
|
// for (i in configService.lootConfig.getConfigurationSection("loot")!!.getKeys(false)) {
|
||||||
|
// val oid = configService.lootConfig.getInt("loot.$i.item").toString() + ""
|
||||||
|
// println("loot.$i.item")
|
||||||
|
// println(oid + ": " + list.contains(oid))
|
||||||
|
// if (list.contains(oid)) {
|
||||||
|
// configService.lootConfig["loot.$i.item"] = config.getString("items.$oid")
|
||||||
|
// } else println("ERROR: $oid")
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// configService.lootConfig.save(this.lootYML)
|
||||||
|
// } catch (ignored: IOException) {
|
||||||
|
// }
|
||||||
|
// sender.sendMessage("§eLoot Fixed!")
|
||||||
|
} else if ((args.size == 1) && (args[0].equals("reload", ignoreCase = true))) {
|
||||||
|
configService.reloadLoot()
|
||||||
|
sender.sendMessage("§eConfig reloaded!")
|
||||||
|
} else if (args[0] == "mobList") {
|
||||||
|
sender.sendMessage("§6Mob List:")
|
||||||
|
for (et in EntityType.entries) if (et.getName() != null) sender.sendMessage("§e" + et.getName())
|
||||||
|
return true
|
||||||
|
} else if ((args.size == 1) && (args[0].equals("error", ignoreCase = true))) {
|
||||||
|
errorList.add(player)
|
||||||
|
sender.sendMessage("§eClick on a mob to send an error report about it.")
|
||||||
|
} else if ((args.size == 1) && (args[0].equals("info", ignoreCase = true))) {
|
||||||
|
sender.sendMessage("§eMounts: " + infernalMobService.mountList.size)
|
||||||
|
sender.sendMessage("§eLoops: " + this.loops)
|
||||||
|
sender.sendMessage("§eInfernals: " + infernalMobService.infernalList.size)
|
||||||
|
} else if ((args.size == 1) && (args[0].equals("worldInfo", ignoreCase = true))) {
|
||||||
|
val enWorldList = configService.mainConfig.mobWorlds
|
||||||
|
val world = player.world
|
||||||
|
var enabled = "is not"
|
||||||
|
if (enWorldList.contains(world.name) || enWorldList.contains("<all>")) {
|
||||||
|
enabled = "is"
|
||||||
|
}
|
||||||
|
sender.sendMessage("The world you are currently in, $world $enabled enabled.")
|
||||||
|
sender.sendMessage("All the worlds that are enabled are: $enWorldList")
|
||||||
|
} else if ((args.size == 1) && (args[0].equals("help", ignoreCase = true))) {
|
||||||
|
throwError(sender)
|
||||||
|
} else if ((args.size == 1) && (args[0].equals("getloot", ignoreCase = true))) {
|
||||||
|
val min = configService.mainConfig.minpowers
|
||||||
|
val max = configService.mainConfig.maxpowers
|
||||||
|
val powers = MathUtils.rand(min, max)
|
||||||
|
val gottenLoot = lootHandler.getRandomLoot(player!!, randomMob, powers)
|
||||||
|
if (gottenLoot != null) {
|
||||||
|
player.inventory.addItem(gottenLoot)
|
||||||
|
}
|
||||||
|
sender.sendMessage("§eGave you some random loot!")
|
||||||
|
} else if ((args.size == 2) && (args[0].equals("getloot", ignoreCase = true))) {
|
||||||
|
try {
|
||||||
|
val index = args[1].toInt()
|
||||||
|
val i = lootHandler.getLoot(player, index)
|
||||||
|
if (i != null) {
|
||||||
|
player.inventory.addItem(i)
|
||||||
|
sender.sendMessage("§eGave you the loot at index §9$index")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
sender.sendMessage("§cUnable to get that loot!")
|
||||||
|
} else if ((args.size == 3) && (args[0].equals("giveloot", ignoreCase = true))) {
|
||||||
|
try {
|
||||||
|
val p = plugin.server.getPlayer(args[1])
|
||||||
|
if (p != null) {
|
||||||
|
val index = args[2].toInt()
|
||||||
|
val i = lootHandler.getLoot(p, index)
|
||||||
|
if (i != null) {
|
||||||
|
p.inventory.addItem(i)
|
||||||
|
sender.sendMessage("§eGave the player the loot at index §9$index")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§cPlayer not found!!")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
sender.sendMessage("§cUnable to get that loot!")
|
||||||
|
} else if (((args.size == 2) && (args[0].equals(
|
||||||
|
"spawn",
|
||||||
|
ignoreCase = true
|
||||||
|
))) || ((args[0].equals("cspawn", ignoreCase = true)) && (args.size == 6))
|
||||||
|
) {
|
||||||
|
if ((EntityType.fromName(args[1]) != null)) {
|
||||||
|
val exmsg: Boolean
|
||||||
|
val world: World?
|
||||||
|
val ent: Entity
|
||||||
|
if ((args[0].equals(
|
||||||
|
"cspawn",
|
||||||
|
ignoreCase = true
|
||||||
|
)) && (args[2] != null) && (args[3] != null) && (args[4] != null) && (args[5] != null)
|
||||||
|
) {
|
||||||
|
if (Bukkit.getServer().getWorld(args[2]) == null) {
|
||||||
|
sender.sendMessage(args[2] + " dose not exist!")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
world = Bukkit.getServer().getWorld(args[2])
|
||||||
|
val spoint = Location(
|
||||||
|
Bukkit.getServer().getWorld(
|
||||||
|
args[2]
|
||||||
|
),
|
||||||
|
args[3].toInt().toDouble(), args[4].toInt().toDouble(),
|
||||||
|
args[5].toInt().toDouble()
|
||||||
|
)
|
||||||
|
ent = world!!.spawnEntity(
|
||||||
|
spoint,
|
||||||
|
EntityType.fromName(args[1])!!
|
||||||
|
)
|
||||||
|
exmsg = true
|
||||||
|
} else {
|
||||||
|
val farSpawnLoc = player.getTargetBlock(null, 200).location
|
||||||
|
farSpawnLoc.y += 1.0
|
||||||
|
ent = player.world.spawnEntity(
|
||||||
|
farSpawnLoc, EntityType.fromName(
|
||||||
|
args[1]
|
||||||
|
)!!
|
||||||
|
)
|
||||||
|
exmsg = false
|
||||||
|
}
|
||||||
|
val abList = infernalMobHandler.getAbilitiesAmount(ent)
|
||||||
|
val newMob: InfernalMob
|
||||||
|
val id = ent.uniqueId
|
||||||
|
newMob = if (abList.contains("oneup")) {
|
||||||
|
InfernalMob(ent, id, true, abList, 2, infernalMobService.effect)
|
||||||
|
} else {
|
||||||
|
InfernalMob(ent, id, true, abList, 1, infernalMobService.effect)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abList.contains("flying")) {
|
||||||
|
EntityUtils.makeFly(ent)
|
||||||
|
}
|
||||||
|
infernalMobService.infernalList.add(newMob)
|
||||||
|
gui!!.setName(ent)
|
||||||
|
|
||||||
|
infernalMobService.giveMobGear(ent, false)
|
||||||
|
infernalMobService.addHealth(ent, abList)
|
||||||
|
if (!exmsg) {
|
||||||
|
sender.sendMessage("Spawned a " + args[1])
|
||||||
|
} else if (sender is Player) {
|
||||||
|
sender.sendMessage("Spawned a " + args[1] + " in " + args[2] + " at " + args[3] + ", " + args[4] + ", " + args[5])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Can't spawn a " + args[1] + "!")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} else if (((args.size >= 3) && (args[0].equals(
|
||||||
|
"spawn",
|
||||||
|
ignoreCase = true
|
||||||
|
))) || ((args[0].equals(
|
||||||
|
"cspawn",
|
||||||
|
ignoreCase = true
|
||||||
|
)) && (args.size >= 6)) || ((args[0].equals("pspawn", ignoreCase = true)) && (args.size >= 3))
|
||||||
|
) {
|
||||||
|
if (args[0].equals("spawn", ignoreCase = true)) {
|
||||||
|
if ((EntityType.fromName(args[1]) != null)) {
|
||||||
|
val farSpawnLoc = player!!.getTargetBlock(null, 200).location
|
||||||
|
farSpawnLoc.y += 1.0
|
||||||
|
val ent = player.world.spawnEntity(
|
||||||
|
farSpawnLoc, EntityType.fromName(
|
||||||
|
args[1]
|
||||||
|
)!!
|
||||||
|
)
|
||||||
|
val spesificAbList = mutableListOf<String>()
|
||||||
|
for (i in 0..(args.size - 3)) {
|
||||||
|
if (Abilitiy.entries.map { it.value }.contains(args[(i + 2)])) {
|
||||||
|
spesificAbList.add(args[(i + 2)])
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(args[(i + 2)] + " is not a valid ability!")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val newMob: InfernalMob
|
||||||
|
val id = ent.uniqueId
|
||||||
|
newMob = if (spesificAbList.contains("oneup")) {
|
||||||
|
InfernalMob(ent, id, true, spesificAbList, 2, infernalMobService.effect)
|
||||||
|
} else {
|
||||||
|
InfernalMob(ent, id, true, spesificAbList, 1, infernalMobService.effect)
|
||||||
|
}
|
||||||
|
if (spesificAbList.contains("flying")) {
|
||||||
|
EntityUtils.makeFly(ent)
|
||||||
|
}
|
||||||
|
infernalMobService.infernalList.add(newMob)
|
||||||
|
gui.setName(ent)
|
||||||
|
infernalMobService.giveMobGear(ent, false)
|
||||||
|
|
||||||
|
infernalMobService.addHealth(ent, spesificAbList)
|
||||||
|
|
||||||
|
sender.sendMessage("Spawned a " + args[1] + " with the abilities:")
|
||||||
|
sender.sendMessage(spesificAbList.toString())
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Can't spawn a " + args[1] + "!")
|
||||||
|
}
|
||||||
|
} else if (args[0].equals("cspawn", ignoreCase = true)) {
|
||||||
|
//cspawn <mob> <world> <x> <y> <z> <ability> <ability>
|
||||||
|
if (Bukkit.getServer().getWorld(args[2]) == null) {
|
||||||
|
sender.sendMessage(args[2] + " dose not exist!")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val world = Bukkit.getServer().getWorld(args[2])
|
||||||
|
val spoint = Location(
|
||||||
|
world,
|
||||||
|
args[3].toInt().toDouble(), args[4].toInt().toDouble(),
|
||||||
|
args[5].toInt().toDouble()
|
||||||
|
)
|
||||||
|
val abList = listOf(*args).subList(6, args.size)
|
||||||
|
if (cSpawn(sender, args[1], spoint, abList)) {
|
||||||
|
sender.sendMessage("Spawned a " + args[1] + " in " + args[2] + " at " + args[3] + ", " + args[4] + ", " + args[5] + " with the abilities:")
|
||||||
|
sender.sendMessage(abList.toString())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//pspawn <mob> <player> <ability> <ability>
|
||||||
|
val p = plugin.server.getPlayer(args[2])
|
||||||
|
if (p == null) {
|
||||||
|
sender.sendMessage(args[2] + " is not online!")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val abList = listOf(*args).subList(3, args.size)
|
||||||
|
if (cSpawn(sender, args[1], p.location, abList)) {
|
||||||
|
sender.sendMessage("Spawned a " + args[1] + " at " + p.name + " with the abilities:")
|
||||||
|
sender.sendMessage(abList.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((args.size == 1) && (args[0].equals("abilities", ignoreCase = true))) {
|
||||||
|
sender.sendMessage("--Infernal Mobs Abilities--")
|
||||||
|
sender.sendMessage("mama, molten, weakness, vengeance, webber, storm, sprint, lifesteal, ghastly, ender, cloaked, berserk, oneup, sapper, rust, bullwark, quicksand, thief, tosser, withering, blinding, armoured, poisonous, potions, explode, gravity, archer, necromancer, firework, flying, mounted, morph, ghost, confusing")
|
||||||
|
} else {
|
||||||
|
val oldMobAbilityList: List<String?>?
|
||||||
|
if ((args.size == 1) && (args[0].equals("showAbilities", ignoreCase = true))) {
|
||||||
|
if (PlayerUtils.getTarget(player) != null) {
|
||||||
|
val targeted = PlayerUtils.getTarget(player)
|
||||||
|
val mobId = targeted!!.uniqueId
|
||||||
|
if (infernalMobService.idSearch(mobId) != -1) {
|
||||||
|
oldMobAbilityList = infernalMobService.findMobAbilities(mobId)
|
||||||
|
if (!targeted.isDead) {
|
||||||
|
sender.sendMessage("--Targeted InfernalMob's Abilities--")
|
||||||
|
sender.sendMessage(oldMobAbilityList.toString())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§cThis " + targeted.type.getName() + " §cis not an infernal mob!")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§cUnable to find mob!")
|
||||||
|
}
|
||||||
|
} else if ((args[0].equals("setInfernal", ignoreCase = true)) && (args.size == 2)) {
|
||||||
|
if (player!!.getTargetBlock(null, 25).type == Material.SPAWNER) {
|
||||||
|
val delay = args[1].toInt()
|
||||||
|
|
||||||
|
val name = LocationUtils.getLocationName(player.getTargetBlock(null, 25).location)
|
||||||
|
|
||||||
|
configService.mobSaveConfig["infernalSpanwers.$name"] = delay
|
||||||
|
configService.saveSave()
|
||||||
|
sender.sendMessage("§cSpawner set to infernal with a $delay second delay!")
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§cYou must be looking a spawner to make it infernal!")
|
||||||
|
}
|
||||||
|
} else if ((args[0].equals("kill", ignoreCase = true)) && (args.size == 2)) {
|
||||||
|
val size = args[1].toInt()
|
||||||
|
for (e in player.getNearbyEntities(size.toDouble(), size.toDouble(), size.toDouble())) {
|
||||||
|
val id = infernalMobService.idSearch(e.uniqueId)
|
||||||
|
if (id != -1) {
|
||||||
|
removeMob(id)
|
||||||
|
e.remove()
|
||||||
|
plugin.logger.log(Level.INFO, "Entity remove due to /kill")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sender.sendMessage("§eKilled all infernal mobs near you!")
|
||||||
|
} else if ((args[0].equals(
|
||||||
|
"killall",
|
||||||
|
ignoreCase = true
|
||||||
|
)) && (args.size == 1 || args.size == 2)
|
||||||
|
) {
|
||||||
|
var w: World? = null
|
||||||
|
if (args.size == 1 && sender is Player) {
|
||||||
|
w = sender.world
|
||||||
|
} else if (args.size == 2) {
|
||||||
|
w = plugin.server.getWorld(args[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w != null) {
|
||||||
|
for (e in w.entities) {
|
||||||
|
val id = infernalMobService.idSearch(e.uniqueId)
|
||||||
|
if (id != -1) {
|
||||||
|
removeMob(id)
|
||||||
|
if (e is LivingEntity) {
|
||||||
|
e.customName = null
|
||||||
|
}
|
||||||
|
plugin.logger.log(Level.INFO, "Entity remove due to /killall")
|
||||||
|
e.remove()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sender.sendMessage("§eKilled all loaded infernal mobs in that world!")
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§cWorld not found!")
|
||||||
|
}
|
||||||
|
} else if (args[0].equals("mobs", ignoreCase = true)) {
|
||||||
|
sender.sendMessage("§6List of Mobs:")
|
||||||
|
for (e in EntityType.values()) if (e != null) sender.sendMessage(e.toString())
|
||||||
|
} else if (args[0].equals("setloot", ignoreCase = true)) {
|
||||||
|
configService.setItem(
|
||||||
|
player.inventory.itemInMainHand,
|
||||||
|
"loot." + args[1],
|
||||||
|
configService.lootConfig
|
||||||
|
)
|
||||||
|
sender.sendMessage("§eSet loot at index " + args[1] + " §eto item in hand.")
|
||||||
|
} else {
|
||||||
|
throwError(sender)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§cYou don't have permission to use this command!")
|
||||||
|
}
|
||||||
|
} catch (x: Exception) {
|
||||||
|
throwError(sender)
|
||||||
|
x.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun removeMob(id: Any) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTabComplete(sender: CommandSender, cmd: Command, label: String, args: Array<String>): List<String>? {
|
||||||
|
val allAbilitiesList: List<String> = ArrayList(
|
||||||
|
mutableListOf(
|
||||||
|
"confusing",
|
||||||
|
"ghost",
|
||||||
|
"morph",
|
||||||
|
"mounted",
|
||||||
|
"flying",
|
||||||
|
"gravity",
|
||||||
|
"firework",
|
||||||
|
"necromancer",
|
||||||
|
"archer",
|
||||||
|
"molten",
|
||||||
|
"mama",
|
||||||
|
"potions",
|
||||||
|
"explode",
|
||||||
|
"berserk",
|
||||||
|
"weakness",
|
||||||
|
"vengeance",
|
||||||
|
"webber",
|
||||||
|
"storm",
|
||||||
|
"sprint",
|
||||||
|
"lifesteal",
|
||||||
|
"ghastly",
|
||||||
|
"ender",
|
||||||
|
"cloaked",
|
||||||
|
"oneup",
|
||||||
|
"sapper",
|
||||||
|
"rust",
|
||||||
|
"bullwark",
|
||||||
|
"quicksand",
|
||||||
|
"thief",
|
||||||
|
"tosser",
|
||||||
|
"withering",
|
||||||
|
"blinding",
|
||||||
|
"armoured",
|
||||||
|
"poisonous"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val commands: Set<String> = HashSet(
|
||||||
|
mutableListOf(
|
||||||
|
"reload",
|
||||||
|
"worldInfo",
|
||||||
|
"error",
|
||||||
|
"getloot",
|
||||||
|
"setloot",
|
||||||
|
"giveloot",
|
||||||
|
"abilities",
|
||||||
|
"showAbilities",
|
||||||
|
"setInfernal",
|
||||||
|
"spawn",
|
||||||
|
"cspawn",
|
||||||
|
"pspawn",
|
||||||
|
"kill",
|
||||||
|
"killall"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if (sender.hasPermission("infernal_mobs.commands")) {
|
||||||
|
val newTab: MutableList<String> = ArrayList()
|
||||||
|
if (args.size == 1) {
|
||||||
|
if (args[0].isEmpty()) return ArrayList(commands)
|
||||||
|
commands.forEach(Consumer { tab: String ->
|
||||||
|
if (tab.lowercase(Locale.getDefault()).startsWith(
|
||||||
|
args[0].lowercase(Locale.getDefault())
|
||||||
|
)
|
||||||
|
) newTab.add(tab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (args[0].equals("getloot", ignoreCase = true) || args[0].equals("setloot", ignoreCase = true)) {
|
||||||
|
if (args.size == 2) {
|
||||||
|
newTab.add("1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args[0].equals("giveloot", ignoreCase = true)) {
|
||||||
|
if (args.size == 2) {
|
||||||
|
newTab.addAll(
|
||||||
|
Bukkit.getOnlinePlayers().stream().map { obj: HumanEntity -> obj.name }.collect(
|
||||||
|
Collectors.toList()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (args.size == 3) {
|
||||||
|
newTab.add("1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args[0].equals("setinfernal", ignoreCase = true)) {
|
||||||
|
if (args.size == 2) {
|
||||||
|
newTab.add("10")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args.size == 2) {
|
||||||
|
if (args[0].equals("spawn", ignoreCase = true) || args[0].equals(
|
||||||
|
"cspawn",
|
||||||
|
ignoreCase = true
|
||||||
|
) || args[0].equals("pspawn", ignoreCase = true)
|
||||||
|
) {
|
||||||
|
if (args[1].isEmpty()) newTab.addAll(
|
||||||
|
Arrays.stream(EntityType.values()).filter { m: EntityType -> m.isSpawnable && m.isAlive }
|
||||||
|
.map { obj: EntityType -> obj.name }.collect(
|
||||||
|
Collectors.toList()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else Arrays.stream(EntityType.values()).filter { m: EntityType -> m.isSpawnable && m.isAlive }
|
||||||
|
.map { obj: EntityType -> obj.name }.collect(
|
||||||
|
Collectors.toList()
|
||||||
|
).forEach(
|
||||||
|
Consumer { tab: String ->
|
||||||
|
if (tab.lowercase(Locale.getDefault()).startsWith(
|
||||||
|
args[1].lowercase(Locale.getDefault())
|
||||||
|
)
|
||||||
|
) newTab.add(tab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (args[0].equals("killall", ignoreCase = true)) {
|
||||||
|
if (args[args.size - 1].isEmpty()) newTab.addAll(
|
||||||
|
Bukkit.getWorlds().stream().map { obj: World -> obj.name }.collect(
|
||||||
|
Collectors.toList()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else Bukkit.getWorlds().stream().map { obj: World -> obj.name }.collect(Collectors.toList())
|
||||||
|
.forEach(
|
||||||
|
Consumer { tab: String ->
|
||||||
|
if (tab.lowercase(Locale.getDefault()).startsWith(
|
||||||
|
args[args.size - 1].lowercase(Locale.getDefault())
|
||||||
|
)
|
||||||
|
) newTab.add(tab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (args[0].equals("kill", ignoreCase = true)) {
|
||||||
|
newTab.add("1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args[0].equals("cspawn", ignoreCase = true)) {
|
||||||
|
if (args.size == 3) {
|
||||||
|
if (args[args.size - 1].isEmpty()) newTab.addAll(
|
||||||
|
Bukkit.getWorlds().stream().map { obj: World -> obj.name }.collect(
|
||||||
|
Collectors.toList()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else Bukkit.getWorlds().stream().map { obj: World -> obj.name }.collect(Collectors.toList())
|
||||||
|
.forEach(
|
||||||
|
Consumer { tab: String ->
|
||||||
|
if (tab.lowercase(Locale.getDefault()).startsWith(
|
||||||
|
args[args.size - 1].lowercase(Locale.getDefault())
|
||||||
|
)
|
||||||
|
) newTab.add(tab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (args.size in 4..6) {
|
||||||
|
newTab.add("~")
|
||||||
|
}
|
||||||
|
if (args.size >= 7) {
|
||||||
|
if (args[args.size - 1].isEmpty()) newTab.addAll(allAbilitiesList)
|
||||||
|
else allAbilitiesList.forEach(Consumer { tab: String ->
|
||||||
|
if (tab.lowercase(Locale.getDefault()).startsWith(
|
||||||
|
args[args.size - 1].lowercase(Locale.getDefault())
|
||||||
|
)
|
||||||
|
) newTab.add(tab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args[0].equals("pspawn", ignoreCase = true)) {
|
||||||
|
if (args.size == 3) {
|
||||||
|
if (args[args.size - 1].isEmpty()) newTab.addAll(
|
||||||
|
Bukkit.getOnlinePlayers().stream().map { obj: HumanEntity -> obj.name }.collect(
|
||||||
|
Collectors.toList()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else Bukkit.getOnlinePlayers().stream().map { obj: HumanEntity -> obj.name }
|
||||||
|
.collect(Collectors.toList()).forEach(
|
||||||
|
Consumer { tab: String ->
|
||||||
|
if (tab.lowercase(Locale.getDefault()).startsWith(
|
||||||
|
args[args.size - 1].lowercase(Locale.getDefault())
|
||||||
|
)
|
||||||
|
) newTab.add(tab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (args.size > 3) {
|
||||||
|
if (args[args.size - 1].isEmpty()) newTab.addAll(allAbilitiesList)
|
||||||
|
else allAbilitiesList.forEach(Consumer { tab: String ->
|
||||||
|
if (tab.lowercase(Locale.getDefault()).startsWith(
|
||||||
|
args[args.size - 1].lowercase(Locale.getDefault())
|
||||||
|
)
|
||||||
|
) newTab.add(tab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args.size >= 3) {
|
||||||
|
if (args[0].equals("spawn", ignoreCase = true)) {
|
||||||
|
if (args[args.size - 1].isEmpty()) newTab.addAll(allAbilitiesList)
|
||||||
|
else allAbilitiesList.forEach(Consumer { tab: String ->
|
||||||
|
if (tab.lowercase(Locale.getDefault()).startsWith(
|
||||||
|
args[args.size - 1].lowercase(Locale.getDefault())
|
||||||
|
)
|
||||||
|
) newTab.add(tab)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newTab
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun throwError(sender: CommandSender) {
|
||||||
|
// sender.sendMessage("--Infernal Mobs v" + description.version + "--")
|
||||||
|
sender.sendMessage("Usage: /im reload")
|
||||||
|
sender.sendMessage("Usage: /im worldInfo")
|
||||||
|
sender.sendMessage("Usage: /im error")
|
||||||
|
sender.sendMessage("Usage: /im getloot <index>")
|
||||||
|
sender.sendMessage("Usage: /im setloot <index>")
|
||||||
|
sender.sendMessage("Usage: /im giveloot <player> <index>")
|
||||||
|
sender.sendMessage("Usage: /im abilities")
|
||||||
|
sender.sendMessage("Usage: /im showAbilities")
|
||||||
|
sender.sendMessage("Usage: /im setInfernal <time delay>")
|
||||||
|
sender.sendMessage("Usage: /im spawn <mob> <ability> <ability>")
|
||||||
|
sender.sendMessage("Usage: /im cspawn <mob> <world> <x> <y> <z> <ability> <ability>")
|
||||||
|
sender.sendMessage("Usage: /im pspawn <mob> <player> <ability> <ability>")
|
||||||
|
sender.sendMessage("Usage: /im kill <size>")
|
||||||
|
sender.sendMessage("Usage: /im killall <world>")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cSpawn(sender: CommandSender, mob: String, l: Location, abList: List<String>): Boolean {
|
||||||
|
//cspawn <mob> <world> <x> <y> <z> <ability> <ability>
|
||||||
|
if ((EntityType.fromName(mob) != null)) {
|
||||||
|
val ent = l.world.spawnEntity(
|
||||||
|
l,
|
||||||
|
EntityType.fromName(mob)!!
|
||||||
|
)
|
||||||
|
val newMob: InfernalMob
|
||||||
|
val id = ent.uniqueId
|
||||||
|
newMob = if (abList.contains("oneup")) {
|
||||||
|
InfernalMob(ent, id, true, abList, 2, infernalMobService.effect)
|
||||||
|
} else {
|
||||||
|
InfernalMob(ent, id, true, abList, 1, infernalMobService.effect)
|
||||||
|
}
|
||||||
|
if (abList.contains("flying")) {
|
||||||
|
EntityUtils.makeFly(ent)
|
||||||
|
}
|
||||||
|
infernalMobService.infernalList.add(newMob)
|
||||||
|
gui!!.setName(ent)
|
||||||
|
|
||||||
|
infernalMobService.giveMobGear(ent, false)
|
||||||
|
infernalMobService.addHealth(ent, abList)
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Can't spawn a $mob!")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.config
|
||||||
|
|
||||||
|
import de.exlll.configlib.Configuration
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class LootConfig {
|
||||||
|
//TODO: lootconfig
|
||||||
|
private val potionEffects = emptyArray<Any>()
|
||||||
|
private val consumeEffects = emptyArray<Any>()
|
||||||
|
private val loot = emptyList<ItemStack>()
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.config
|
||||||
|
|
||||||
|
import de.exlll.configlib.Configuration
|
||||||
|
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class MainConfig {
|
||||||
|
var chance = 20
|
||||||
|
var mobChances = emptyMap<String, Int>()
|
||||||
|
var levelChance = emptyMap<String, Int>()
|
||||||
|
|
||||||
|
var namePrefix = "&fInfernal"
|
||||||
|
var levelPrefixs = emptyMap<String, String>()
|
||||||
|
|
||||||
|
var nameTags = NameTags(1, "&f<prefix> <mobName>")
|
||||||
|
var nameTagsLevel = emptyMap<String, String>()
|
||||||
|
|
||||||
|
var bossBarSettings = BossBarSettings(true, "&fLevel <mobLevel> &f<prefix> <mobName>", "PINK", "SOLID")
|
||||||
|
|
||||||
|
var scoreBoard = ScoreBoard(enable = false, showHealth = true)
|
||||||
|
var effectAllPlayerAttacks = true
|
||||||
|
var enableParticles = true
|
||||||
|
var enableDeathMessages = false
|
||||||
|
var enableSpawnMessages = false
|
||||||
|
var spawnMessageRadius = 64
|
||||||
|
var noCreativeDrops = false
|
||||||
|
|
||||||
|
var mobWorlds = listOf("<all>")
|
||||||
|
var effectWorlds = listOf("<all>")
|
||||||
|
var enabledMobs = emptyList<String>()
|
||||||
|
var enabledCharmSlots = emptyList<Int>()
|
||||||
|
var enabledAbilities = emptyList<String>()
|
||||||
|
|
||||||
|
var mamaSpawnAmount = 3
|
||||||
|
var vengeanceDamage = 6
|
||||||
|
var berserkDamage = 3
|
||||||
|
var moltenBurnLength = 5
|
||||||
|
var gravityLevitateLength = 6
|
||||||
|
var horseMountsHaveSaddles = true
|
||||||
|
var armouredMountsHaveArmour = true
|
||||||
|
var fireworkColour = FireworkColour(255, 10, 10)
|
||||||
|
var enabledSpawnReasons = emptyList<String>()
|
||||||
|
var mobParticles = listOf("lavaSpark:1:10")
|
||||||
|
var mountFate = "nothing"
|
||||||
|
|
||||||
|
var enabledMounts = emptyList<String>()
|
||||||
|
var enabledRiders = emptyList<String>()
|
||||||
|
var disabledBabyMobs = emptyList<String>()
|
||||||
|
|
||||||
|
var minpowers = 3
|
||||||
|
var maxpowers = 7
|
||||||
|
var healthMultiplier = 4
|
||||||
|
var healthByPower = false
|
||||||
|
var healthByDistance = false
|
||||||
|
var powerByDistance = false
|
||||||
|
var healthToAdd = 5
|
||||||
|
var powerToAdd = 1
|
||||||
|
var xpMultiplier = 8
|
||||||
|
var addDistance = 200
|
||||||
|
var enableDrops = true
|
||||||
|
var dropChance = 1
|
||||||
|
var enableFarmingDrops = false
|
||||||
|
var naturalSpawnHeight = 0
|
||||||
|
|
||||||
|
var debug = false
|
||||||
|
var items = emptyList<String>()
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class NameTags(var level: Int = 1, var name: String = "&f<prefix> <mobName>")
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class BossBarSettings(
|
||||||
|
var enable: Boolean = true,
|
||||||
|
var name: String = "&fLevel <mobLevel> &f<prefix> <mobName>",
|
||||||
|
var color: String = "PINK",
|
||||||
|
var style: String = "SOLID"
|
||||||
|
)
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class ScoreBoard(var enable: Boolean = false, var showHealth: Boolean = true)
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class FireworkColour(var red: Int = 255, var green: Int = 10, var blue: Int = 10)
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.config
|
||||||
|
|
||||||
|
import de.exlll.configlib.Configuration
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class MessagesConfig {
|
||||||
|
var deathMessages = emptyList<String>()
|
||||||
|
var spawnMessages = emptyList<String>()
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.config
|
||||||
|
|
||||||
|
class SaveConfig {
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.enums
|
||||||
|
|
||||||
|
enum class Abilitiy(val value: String) {
|
||||||
|
Confusing("confusing"),
|
||||||
|
Ghost("ghost"),
|
||||||
|
Morph("morph"),
|
||||||
|
Mounted("mounted"),
|
||||||
|
Flying("flying"),
|
||||||
|
Gravity("gravity"),
|
||||||
|
Firework("firework"),
|
||||||
|
Necromancer("necromancer"),
|
||||||
|
Archer("archer"),
|
||||||
|
Molten("molten"),
|
||||||
|
Mama("mama"),
|
||||||
|
Potions("potions"),
|
||||||
|
Explode("explode"),
|
||||||
|
Berserk("berserk"),
|
||||||
|
Weakness("weakness"),
|
||||||
|
Vengeance("vengeance"),
|
||||||
|
Webber("webber"),
|
||||||
|
Storm("storm"),
|
||||||
|
Sprint("sprint"),
|
||||||
|
Lifesteal("lifesteal"),
|
||||||
|
Ghastly("ghastly"),
|
||||||
|
Ender("ender"),
|
||||||
|
Cloaked("cloaked"),
|
||||||
|
Oneup("oneup"),
|
||||||
|
Sapper("sapper"),
|
||||||
|
Rust("rust"),
|
||||||
|
Bullwark("bullwark"),
|
||||||
|
Quicksand("quicksand"),
|
||||||
|
Thief("thief"),
|
||||||
|
Tosser("tosser"),
|
||||||
|
Withering("withering"),
|
||||||
|
Blinding("blinding"),
|
||||||
|
Armoured("armoured"),
|
||||||
|
Poisonous("poisonous")
|
||||||
|
}
|
27
src/main/kotlin/io/github/thehrz/infernalmobs/events/InfernalSpawnEvent.kt
Executable file
27
src/main/kotlin/io/github/thehrz/infernalmobs/events/InfernalSpawnEvent.kt
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.events
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.models.InfernalMob
|
||||||
|
import org.bukkit.entity.Entity
|
||||||
|
import org.bukkit.event.Cancellable
|
||||||
|
import org.bukkit.event.Event
|
||||||
|
import org.bukkit.event.HandlerList
|
||||||
|
|
||||||
|
class InfernalSpawnEvent(val entity: Entity, val infernal: InfernalMob) : Event(), Cancellable {
|
||||||
|
private var cancelled = false
|
||||||
|
|
||||||
|
override fun isCancelled(): Boolean {
|
||||||
|
return cancelled
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setCancelled(b: Boolean) {
|
||||||
|
this.cancelled = b
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getHandlers(): HandlerList {
|
||||||
|
return handlerList
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val handlerList: HandlerList = HandlerList()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.gui
|
||||||
|
|
||||||
|
class BossBarGUI {
|
||||||
|
}
|
275
src/main/kotlin/io/github/thehrz/infernalmobs/gui/GUI.kt
Executable file
275
src/main/kotlin/io/github/thehrz/infernalmobs/gui/GUI.kt
Executable file
@ -0,0 +1,275 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.gui
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.handler.InfernalMobHandler
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.StringUtils
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.ChatColor
|
||||||
|
import org.bukkit.boss.BarColor
|
||||||
|
import org.bukkit.boss.BarFlag
|
||||||
|
import org.bukkit.boss.BarStyle
|
||||||
|
import org.bukkit.boss.BossBar
|
||||||
|
import org.bukkit.entity.*
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.scoreboard.DisplaySlot
|
||||||
|
import org.bukkit.scoreboard.Objective
|
||||||
|
import org.bukkit.scoreboard.Scoreboard
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class GUI internal constructor(
|
||||||
|
private val plugin: InfernalMobs,
|
||||||
|
private val infernalMobService: InfernalMobService,
|
||||||
|
private val infernalMobHandler: InfernalMobHandler,
|
||||||
|
private val configService: ConfigService
|
||||||
|
) : Listener {
|
||||||
|
fun setName(ent: Entity) {
|
||||||
|
try {
|
||||||
|
//System.out.println("SN1 " + ent);
|
||||||
|
if (configService.mainConfig.nameTags.level != 0) {
|
||||||
|
val tittle = getMobNameTag(ent)
|
||||||
|
ent.customName = tittle
|
||||||
|
if (configService.mainConfig.nameTags.level == 2) {
|
||||||
|
ent.isCustomNameVisible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (x: Exception) {
|
||||||
|
println("Error in setName: ")
|
||||||
|
x.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getMobNameTag(entity: Entity): String {
|
||||||
|
val oldMobAbilityList: List<String?> = infernalMobService.findMobAbilities(entity.uniqueId)
|
||||||
|
var tittle: String? = null
|
||||||
|
|
||||||
|
tittle = configService.mainConfig.nameTags.name
|
||||||
|
|
||||||
|
val mobName = entity.type.getName()!!.replace("_", " ")
|
||||||
|
|
||||||
|
tittle = tittle.replace(
|
||||||
|
"<mobName>",
|
||||||
|
mobName.substring(0, 1).uppercase(Locale.getDefault()) + mobName.substring(1)
|
||||||
|
)
|
||||||
|
tittle = tittle.replace("<mobLevel>", "" + oldMobAbilityList.size)
|
||||||
|
var abilities: String
|
||||||
|
var count = 4
|
||||||
|
do {
|
||||||
|
abilities = StringUtils.generateString(count, oldMobAbilityList)
|
||||||
|
count--
|
||||||
|
} while ((tittle.length + abilities.length + mobName.length) > 64)
|
||||||
|
tittle = tittle.replace(
|
||||||
|
"<abilities>",
|
||||||
|
abilities.substring(0, 1).uppercase(Locale.getDefault()) + abilities.substring(1)
|
||||||
|
)
|
||||||
|
//Prefix
|
||||||
|
var prefix: String = configService.mainConfig.namePrefix
|
||||||
|
//todo: levelPrefixs
|
||||||
|
// if (plugin.config.getString("levelPrefixs." + oldMobAbilityList.size) != null)
|
||||||
|
// prefix = plugin.getConfig().getString("levelPrefixs." + oldMobAbilityList.size)
|
||||||
|
tittle = tittle.replace("<prefix>", prefix.substring(0, 1).uppercase(Locale.getDefault()) + prefix.substring(1))
|
||||||
|
tittle = ChatColor.translateAlternateColorCodes('&', tittle)
|
||||||
|
|
||||||
|
return tittle
|
||||||
|
}
|
||||||
|
|
||||||
|
private val playerScoreBoard = HashMap<String, Scoreboard?>()
|
||||||
|
private val bossBars = HashMap<Entity, Any>()
|
||||||
|
|
||||||
|
|
||||||
|
fun fixBar(p: Player) {
|
||||||
|
//System.out.println("fixBar");
|
||||||
|
val b = infernalMobService.getNearbyBoss(p)
|
||||||
|
if (b != null) {
|
||||||
|
//System.out.println("Dead: " + b.isDead());
|
||||||
|
//System.out.println("HP: " + ((Damageable)b).getHealth());
|
||||||
|
if (b.isDead || (b as Damageable).health <= 0) {
|
||||||
|
if (configService.mainConfig.bossBarSettings.enable) {
|
||||||
|
try {
|
||||||
|
for (p2 in (bossBars[b] as BossBar).players) (bossBars[b] as BossBar).removePlayer(p2)
|
||||||
|
bossBars.remove(b)
|
||||||
|
} catch (x: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val mobIndex: Int = infernalMobService.idSearch(b.uniqueId)
|
||||||
|
try {
|
||||||
|
if (mobIndex != -1) infernalMobHandler.removeMob(mobIndex)
|
||||||
|
} catch (e: IOException) {
|
||||||
|
}
|
||||||
|
clearInfo(p)
|
||||||
|
} else {
|
||||||
|
if (configService.mainConfig.bossBarSettings.enable) {
|
||||||
|
showBossBar(p, b)
|
||||||
|
}
|
||||||
|
if (configService.mainConfig.scoreBoard.enable) {
|
||||||
|
fixScoreboard(p, b, infernalMobService.findMobAbilities(b.getUniqueId()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else clearInfo(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showBossBar(p: Player, e: Entity) {
|
||||||
|
val oldMobAbilityList: List<String?> = infernalMobService.findMobAbilities(e.uniqueId)
|
||||||
|
var tittle: String = configService.mainConfig.bossBarSettings.name
|
||||||
|
var mobName = e.type.getName()!!.replace("_", " ")
|
||||||
|
if (e.type == EntityType.SKELETON) {
|
||||||
|
val sk = e as Skeleton
|
||||||
|
if (sk.skeletonType == Skeleton.SkeletonType.WITHER) {
|
||||||
|
mobName = "WitherSkeleton"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var prefix: String = configService.mainConfig.namePrefix
|
||||||
|
//TODO: levelPrefixs
|
||||||
|
// if (plugin.getConfig().getString("levelPrefixs." + oldMobAbilityList.size) != null) {
|
||||||
|
// prefix = plugin.getConfig().getString("levelPrefixs." + oldMobAbilityList.size)
|
||||||
|
// }
|
||||||
|
tittle =
|
||||||
|
tittle.replace("<prefix>", prefix.substring(0, 1).uppercase(Locale.getDefault()) + prefix.substring(1))
|
||||||
|
tittle = tittle.replace(
|
||||||
|
"<mobName>",
|
||||||
|
mobName.substring(0, 1).uppercase(Locale.getDefault()) + mobName.substring(1)
|
||||||
|
)
|
||||||
|
tittle = tittle.replace("<mobLevel>", oldMobAbilityList.size.toString() + "")
|
||||||
|
var abilities: String = StringUtils.generateString(5, oldMobAbilityList)
|
||||||
|
var count = 4
|
||||||
|
try {
|
||||||
|
do {
|
||||||
|
abilities = StringUtils.generateString(count, oldMobAbilityList)
|
||||||
|
count--
|
||||||
|
if (count <= 0) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} while (tittle.length + abilities.length + mobName.length > 64)
|
||||||
|
} catch (x: Exception) {
|
||||||
|
println("showBossBar error: ")
|
||||||
|
x.printStackTrace()
|
||||||
|
}
|
||||||
|
tittle = tittle.replace(
|
||||||
|
"<abilities>",
|
||||||
|
abilities.substring(0, 1).uppercase(Locale.getDefault()) + abilities.substring(1)
|
||||||
|
)
|
||||||
|
tittle = ChatColor.translateAlternateColorCodes('&', tittle)
|
||||||
|
|
||||||
|
if (!bossBars.containsKey(e)) {
|
||||||
|
var bc = BarColor.valueOf(configService.mainConfig.bossBarSettings.color)
|
||||||
|
var bs = BarStyle.valueOf(configService.mainConfig.bossBarSettings.style)
|
||||||
|
|
||||||
|
//TODO:Per Level Setings
|
||||||
|
// val lc: String = plugin.getConfig()
|
||||||
|
// .getString("bossBarSettings.perLevel." + oldMobAbilityList.size + ".color")
|
||||||
|
// if (lc != null) bc = BarColor.valueOf(lc)
|
||||||
|
// val ls: String = plugin.getConfig()
|
||||||
|
// .getString("bossBarSettings.perLevel." + oldMobAbilityList.size + ".style")
|
||||||
|
// if (ls != null) bs = BarStyle.valueOf(ls)
|
||||||
|
//TODO:Per InfernalMob Setings
|
||||||
|
// val mc: String =
|
||||||
|
// plugin.getConfig().getString("bossBarSettings.perMob." + e.type.getName() + ".color")
|
||||||
|
// if (mc != null) bc = BarColor.valueOf(mc)
|
||||||
|
// val ms: String =
|
||||||
|
// plugin.getConfig().getString("bossBarSettings.perMob." + e.type.getName() + ".style")
|
||||||
|
// if (ms != null) bs = BarStyle.valueOf(ms)
|
||||||
|
val bar = Bukkit.createBossBar(tittle, bc, bs, BarFlag.CREATE_FOG)
|
||||||
|
bar.isVisible = true
|
||||||
|
bossBars[e] = bar
|
||||||
|
}
|
||||||
|
if (!(bossBars[e] as BossBar).players.contains(p)) (bossBars[e] as BossBar).addPlayer(p)
|
||||||
|
val health = (e as Damageable).health.toFloat()
|
||||||
|
val maxHealth = e.maxHealth.toFloat()
|
||||||
|
val setHealth = (health * 100.0f) / maxHealth
|
||||||
|
(bossBars[e] as BossBar).progress = (setHealth / 100.0f).toDouble()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun clearInfo(player: Player) {
|
||||||
|
if (configService.mainConfig.bossBarSettings.enable) {
|
||||||
|
//BossBarAPI.removeBar(player);
|
||||||
|
for ((_, value) in bossBars) if ((value as BossBar).players.contains(player)) value.removePlayer(player)
|
||||||
|
}
|
||||||
|
if (configService.mainConfig.scoreBoard.enable) {
|
||||||
|
try {
|
||||||
|
player.scoreboard.resetScores(player)
|
||||||
|
player.scoreboard.getObjective(DisplaySlot.SIDEBAR)!!.unregister()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fixScoreboard(player: Player, e: Entity, abilityList: List<String?>) {
|
||||||
|
if (configService.mainConfig.scoreBoard.enable && (e is Damageable)) {
|
||||||
|
//String name = getMobNameTag(e);
|
||||||
|
//Get Display
|
||||||
|
//System.out.println("sb1");
|
||||||
|
if (playerScoreBoard[player.name] == null) {
|
||||||
|
//System.out.println("Creating ScoreBoard");
|
||||||
|
val manager = Bukkit.getScoreboardManager()
|
||||||
|
val board = manager.newScoreboard
|
||||||
|
playerScoreBoard[player.name] = board
|
||||||
|
}
|
||||||
|
//System.out.println("sb2");
|
||||||
|
val o: Objective
|
||||||
|
val board = playerScoreBoard[player.name]
|
||||||
|
//System.out.println("Board = " + board);
|
||||||
|
if (board!!.getObjective(DisplaySlot.SIDEBAR) == null) {
|
||||||
|
o = board.registerNewObjective(player.name, "dummy")
|
||||||
|
o.displaySlot = DisplaySlot.SIDEBAR
|
||||||
|
} else {
|
||||||
|
o = board.getObjective(DisplaySlot.SIDEBAR)!!
|
||||||
|
}
|
||||||
|
//System.out.println("sb3");
|
||||||
|
//Name
|
||||||
|
//System.out.println("Name: " + e.getType().getName());
|
||||||
|
//System.out.println("OBJ = " + o);
|
||||||
|
o.displayName = e.getType().getName()!!
|
||||||
|
//System.out.println("Set ScoreBoard Name");
|
||||||
|
//Remove Old
|
||||||
|
//for(OfflinePlayer p : board.getPlayers())
|
||||||
|
// board.resetScores(p);
|
||||||
|
for (s in board.entries) board.resetScores(s)
|
||||||
|
//Power Display
|
||||||
|
var score = 1
|
||||||
|
//System.out.println("sb4");
|
||||||
|
for (ability in abilityList) {
|
||||||
|
//Score pointsDisplayScore = o.getScore(Bukkit.getOfflinePlayer("§r" + ability));
|
||||||
|
//pointsDisplayScore.setScore(score);
|
||||||
|
o.getScore("§r$ability").score = score
|
||||||
|
score += 1
|
||||||
|
}
|
||||||
|
//Score abDisplayScore = o.getScore(Bukkit.getOfflinePlayer("§e§lAbilities:"));
|
||||||
|
//abDisplayScore.setScore(score);
|
||||||
|
o.getScore("§e§lAbilities:").score = score
|
||||||
|
//Health
|
||||||
|
//System.out.println("sb5");
|
||||||
|
if (configService.mainConfig.scoreBoard.showHealth) {
|
||||||
|
//System.out.println("shosb");
|
||||||
|
//Display HP
|
||||||
|
score += 1
|
||||||
|
val health = e.health.toFloat()
|
||||||
|
val maxHealth = e.maxHealth.toFloat()
|
||||||
|
val roundOff = Math.round(health * 100.0) / 100.0
|
||||||
|
//Score hDisplayScore = o.getScore(Bukkit.getOfflinePlayer(roundOff + "/" + maxHealth));
|
||||||
|
//hDisplayScore.setScore(score);
|
||||||
|
o.getScore("$roundOff/$maxHealth").score = score
|
||||||
|
score += 1
|
||||||
|
//Score htDisplayScore = o.getScore(Bukkit.getOfflinePlayer("§e§lHealth:"));
|
||||||
|
//htDisplayScore.setScore(score);
|
||||||
|
o.getScore("§e§lHealth:").score = score
|
||||||
|
}
|
||||||
|
//System.out.println("sb6");
|
||||||
|
//Display
|
||||||
|
if ((player.scoreboard == null) || (player.scoreboard.getObjective(DisplaySlot.SIDEBAR) == null) || (player.scoreboard
|
||||||
|
.getObjective(DisplaySlot.SIDEBAR)!!
|
||||||
|
.name == null) || (player.scoreboard
|
||||||
|
.getObjective(DisplaySlot.SIDEBAR)!!
|
||||||
|
.name != board.getObjective(DisplaySlot.SIDEBAR)!!.name)
|
||||||
|
) {
|
||||||
|
//System.out.println("Set SB");
|
||||||
|
player.scoreboard = board
|
||||||
|
}
|
||||||
|
//System.out.println("sb7");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.gui
|
||||||
|
|
||||||
|
class ScoreBoardGUI {
|
||||||
|
}
|
@ -0,0 +1,458 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.handler
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.gui.GUI
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.EntityUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.ItemUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.ParticleUtils
|
||||||
|
import org.bukkit.*
|
||||||
|
import org.bukkit.attribute.Attribute
|
||||||
|
import org.bukkit.entity.*
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.potion.PotionEffect
|
||||||
|
import org.bukkit.potion.PotionEffectType
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.util.*
|
||||||
|
import java.util.logging.Level
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class EffectHandle(
|
||||||
|
private val configService: ConfigService,
|
||||||
|
private val plugin: InfernalMobs,
|
||||||
|
private val infernalMobService: InfernalMobService,
|
||||||
|
private val magicHandler: MagicHandler,
|
||||||
|
private val lootHandler: LootHandler,
|
||||||
|
private val gui: GUI
|
||||||
|
) {
|
||||||
|
var fertileList = mutableListOf<Player>()
|
||||||
|
|
||||||
|
fun applyEffect() {
|
||||||
|
//Check Players
|
||||||
|
for (p in plugin.server.onlinePlayers) {
|
||||||
|
val world = p.world
|
||||||
|
if (configService.mainConfig.effectWorlds.contains(world.name)
|
||||||
|
|| configService.mainConfig.effectWorlds.contains("<all>")
|
||||||
|
) {
|
||||||
|
val itemMap = HashMap<Int, ItemStack?>()
|
||||||
|
for (i in configService.mainConfig.enabledCharmSlots) {
|
||||||
|
val item = p.inventory.getItem(i)
|
||||||
|
itemMap[i] = item
|
||||||
|
}
|
||||||
|
var ai = 100
|
||||||
|
for (ar in p.inventory.armorContents) {
|
||||||
|
itemMap[ai] = ar
|
||||||
|
ai += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
//for(int i = 0; i < 256; i++){
|
||||||
|
if (configService.lootConfig.getConfigurationSection("potionEffects") != null) for (id in configService.lootConfig.getConfigurationSection(
|
||||||
|
"potionEffects"
|
||||||
|
)!!
|
||||||
|
.getKeys(false)) if ((configService.lootConfig.getString("potionEffects.$id") != null) && (configService.lootConfig.getString(
|
||||||
|
"potionEffects.$id.attackEffect"
|
||||||
|
) == null) && (configService.lootConfig.getString(
|
||||||
|
"potionEffects.$id.attackHelpEffect"
|
||||||
|
) == null)
|
||||||
|
) {
|
||||||
|
val itemsPlayerHas = ArrayList<ItemStack?>()
|
||||||
|
for (neededItemIndex in configService.lootConfig.getIntegerList("potionEffects.$id.requiredItems")) {
|
||||||
|
val neededItem = lootHandler.getItem(neededItemIndex)
|
||||||
|
for ((key, check) in itemMap) {
|
||||||
|
try {
|
||||||
|
if ((neededItem!!.itemMeta == null) || (check!!.itemMeta.displayName == neededItem.itemMeta.displayName)) {
|
||||||
|
if (check!!.type == neededItem.type) {
|
||||||
|
//if ((neededItem.getType().getMaxDurability() > 0) || ((Damageable)check).getDamage() == (((Damageable)neededItem).getDamage())) {
|
||||||
|
if (!ItemUtils.isArmor(neededItem) || key >= 100) itemsPlayerHas.add(neededItem)
|
||||||
|
//}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
/**System.out.println("Error: " + e); */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemsPlayerHas.size >= configService.lootConfig.getIntegerList("potionEffects.$id.requiredItems").size) {
|
||||||
|
applyEffects(p, id.toInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(
|
||||||
|
plugin,
|
||||||
|
{ this.applyEffect() }, (10 * 20).toLong()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun doEffect(player: Player, mob: Entity, playerIsVictom: Boolean) {
|
||||||
|
//Do Player Loot Effects
|
||||||
|
if (!playerIsVictom) {
|
||||||
|
//Get Player Item In Hand
|
||||||
|
val itemUsed = player.inventory.itemInMainHand
|
||||||
|
//Get Player Items
|
||||||
|
val items = ArrayList<ItemStack>()
|
||||||
|
for (i in 0..8) {
|
||||||
|
val `in` = player.inventory.getItem(i)
|
||||||
|
if (`in` != null) items.add(`in`)
|
||||||
|
}
|
||||||
|
for (ar in player.inventory.armorContents) items.add(ar)
|
||||||
|
for (i in 0..255) {
|
||||||
|
if (configService.lootConfig.getString("potionEffects.$i") != null) {
|
||||||
|
if (configService.lootConfig.getString("potionEffects.$i.attackEffect") != null) {
|
||||||
|
var effectsPlayer = true
|
||||||
|
if (configService.lootConfig.getString(
|
||||||
|
"potionEffects.$i.attackEffect",
|
||||||
|
"target"
|
||||||
|
) == "target"
|
||||||
|
) effectsPlayer =
|
||||||
|
false
|
||||||
|
for (neededItemIndex in configService.lootConfig.getIntegerList("potionEffects.$i.requiredItems")) {
|
||||||
|
val neededItem = lootHandler.getItem(neededItemIndex)
|
||||||
|
try {
|
||||||
|
if ((neededItem!!.itemMeta == null) || (itemUsed.itemMeta.displayName == neededItem.itemMeta.displayName)) {
|
||||||
|
if (itemUsed.type == neededItem.type) {
|
||||||
|
//if ((neededItem.getType().getMaxDurability() > 0) || (itemUsed.getDurability() == (neededItem.getDurability()))) {
|
||||||
|
//Player Using Item
|
||||||
|
if (effectsPlayer) {
|
||||||
|
applyEffects(player, i)
|
||||||
|
} else {
|
||||||
|
if (mob is LivingEntity) applyEffects(mob, i)
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
/**System.out.println("Error: " + e); */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (configService.lootConfig.getString("potionEffects.$i.attackHelpEffect") != null) {
|
||||||
|
var effectsPlayer = true
|
||||||
|
if (configService.lootConfig.getString(
|
||||||
|
"potionEffects.$i.attackHelpEffect",
|
||||||
|
"target"
|
||||||
|
) == "target"
|
||||||
|
) effectsPlayer = false
|
||||||
|
val itemsPlayerHas = ArrayList<ItemStack?>()
|
||||||
|
for (neededItemIndex in configService.lootConfig.getIntegerList("potionEffects.$i.requiredItems")) {
|
||||||
|
val neededItem = lootHandler.getItem(neededItemIndex)
|
||||||
|
for (check in items) {
|
||||||
|
try {
|
||||||
|
if ((neededItem!!.itemMeta == null) || (check.itemMeta.displayName == neededItem.itemMeta.displayName)) {
|
||||||
|
if (check.type == neededItem.type) {
|
||||||
|
//if ((neededItem.getType().getMaxDurability() > 0) || (check.getDurability() == (neededItem.getDurability()))) {
|
||||||
|
if (!itemsPlayerHas.contains(neededItem)) {
|
||||||
|
itemsPlayerHas.add(neededItem)
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
/**System.out.println("Error: " + e); */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (itemsPlayerHas.size >= configService.lootConfig.getIntegerList("potionEffects.$i.requiredItems").size) {
|
||||||
|
//Player Using Item
|
||||||
|
if (effectsPlayer) {
|
||||||
|
applyEffects(player, i)
|
||||||
|
} else {
|
||||||
|
if (mob is LivingEntity) applyEffects(mob, i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Do InfernalMob Effects
|
||||||
|
try {
|
||||||
|
val id = mob.uniqueId
|
||||||
|
if (infernalMobService.idSearch(id) != -1) {
|
||||||
|
val abilityList = infernalMobService.findMobAbilities(id)
|
||||||
|
if ((!player.isDead) && (!mob.isDead)) {
|
||||||
|
for (ability in abilityList) {
|
||||||
|
magicHandler.doMagic(player, mob, playerIsVictom, ability, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
/**System.out.println("Do Effect Error: " + e); */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun applyEffects(e: LivingEntity, effectID: Int) {
|
||||||
|
val level = configService.lootConfig.getInt("potionEffects.$effectID.level")
|
||||||
|
val name = configService.lootConfig.getString("potionEffects.$effectID.potion")
|
||||||
|
if ((PotionEffectType.getByName(name!!) === PotionEffectType.HARM) || (PotionEffectType.getByName(
|
||||||
|
name!!
|
||||||
|
) === PotionEffectType.HEAL)
|
||||||
|
) {
|
||||||
|
e.addPotionEffect(PotionEffect(PotionEffectType.getByName(name!!)!!, 1, level - 1))
|
||||||
|
} else {
|
||||||
|
e.addPotionEffect(PotionEffect(PotionEffectType.getByName(name!!)!!, 400, level - 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
val effect = configService.lootConfig.getString("potionEffects.$effectID.particleEffect")
|
||||||
|
if (effect != null) {
|
||||||
|
showEffectParticles(e, effect, 15)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun applyEatEffects(e: LivingEntity, effectID: Int) {
|
||||||
|
for (s in configService.lootConfig.getList("consumeEffects.$effectID.potionEffects") as ArrayList<String>) {
|
||||||
|
val split = s.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
|
val name = split[0]
|
||||||
|
val level = split[1].toInt()
|
||||||
|
val time = split[2].toInt()
|
||||||
|
if ((name.equals("fertility", ignoreCase = true)) && (e is Player)) {
|
||||||
|
fertileList.add(e)
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(
|
||||||
|
plugin,
|
||||||
|
{ fertileList.remove(e) }, (time * 20).toLong()
|
||||||
|
)
|
||||||
|
} else e.addPotionEffect(PotionEffect(PotionEffectType.getByName(name)!!, time * 20, level - 1))
|
||||||
|
}
|
||||||
|
if (e is Player) e.sendMessage(
|
||||||
|
configService.lootConfig.getString(
|
||||||
|
"consumeEffects.$effectID.message"
|
||||||
|
)!!
|
||||||
|
.replace("&", "§")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showEffectParticles(p: Entity, e: String, time: Int) {
|
||||||
|
displayEffect(p.location, e)
|
||||||
|
val nt = time - 1
|
||||||
|
if (time > 0) {
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(
|
||||||
|
plugin,
|
||||||
|
{ showEffectParticles(p, e, nt) }, 20L
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun displayEffect(l: Location, effect: String = infernalMobService.effect) {
|
||||||
|
//Get Effect and Datas
|
||||||
|
val split = effect.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
|
|
||||||
|
val name = split[0]
|
||||||
|
val data1 = split[1].toInt()
|
||||||
|
val data2 = split[2].toInt()
|
||||||
|
try {
|
||||||
|
var f = "FLAME"
|
||||||
|
when (name) {
|
||||||
|
"potionBrake" -> f = Particle.SPELL.toString()
|
||||||
|
"smoke" -> f = Particle.SMOKE_NORMAL.toString()
|
||||||
|
"blockBrake" -> f = Particle.BLOCK_CRACK.toString()
|
||||||
|
"hugeExplode" -> f = Particle.EXPLOSION_HUGE.toString()
|
||||||
|
"angryVillager" -> f = Particle.VILLAGER_ANGRY.toString()
|
||||||
|
"cloud" -> f = Particle.CLOUD.toString()
|
||||||
|
"criticalHit" -> f = Particle.CRIT.toString()
|
||||||
|
"mobSpell" -> f = Particle.SPELL_MOB.toString()
|
||||||
|
"enchantmentTable" -> f = Particle.ENCHANTMENT_TABLE.toString()
|
||||||
|
"ender" -> f = Particle.PORTAL.toString()
|
||||||
|
"explode" -> f = Particle.EXPLOSION_NORMAL.toString()
|
||||||
|
"greenSparkle" -> f = Particle.VILLAGER_HAPPY.toString()
|
||||||
|
"heart" -> f = Particle.HEART.toString()
|
||||||
|
"largeExplode" -> f = Particle.EXPLOSION_LARGE.toString()
|
||||||
|
"splash" -> f = Particle.WATER_SPLASH.toString()
|
||||||
|
"largeSmoke" -> f = Particle.SMOKE_LARGE.toString()
|
||||||
|
"lavaSpark" -> f = Particle.LAVA.toString()
|
||||||
|
"magicCriticalHit" -> f = Particle.CRIT_MAGIC.toString()
|
||||||
|
"noteBlock" -> f = Particle.NOTE.toString()
|
||||||
|
"tileDust" -> f = Particle.BLOCK_DUST.toString()
|
||||||
|
"colouredDust" -> f = Particle.REDSTONE.toString()
|
||||||
|
"flame" -> f = Particle.FLAME.toString()
|
||||||
|
"witchMagic" -> f = Particle.SPELL_WITCH.toString()
|
||||||
|
}
|
||||||
|
ParticleUtils.displayParticle(f, l, 1.0, data1, data2)
|
||||||
|
} catch (x: Exception) {
|
||||||
|
//x.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun showEffect() {
|
||||||
|
try {
|
||||||
|
//GUI Bars And Stuff
|
||||||
|
scoreCheck()
|
||||||
|
//InfernalMob Stuff
|
||||||
|
// val tmp = infernalList.clone()
|
||||||
|
//TODO: ?
|
||||||
|
for (m in infernalMobService.infernalList) {
|
||||||
|
val mob = m.entity
|
||||||
|
val id = mob.uniqueId
|
||||||
|
val index = infernalMobService.idSearch(id)
|
||||||
|
if (mob.isValid && (!mob.isDead) && (index != -1) && (mob.location.chunk.isLoaded)) {
|
||||||
|
//System.out.println("PE2");
|
||||||
|
val feet = mob.location
|
||||||
|
val head = mob.location
|
||||||
|
head.y += 1
|
||||||
|
if (configService.mainConfig.enableParticles) {
|
||||||
|
displayEffect(feet, m.effect)
|
||||||
|
//mob.getWorld().playEffect(feet, Effect.ENDER_SIGNAL, 1);
|
||||||
|
if (!EntityUtils.isSmall(mob)) {
|
||||||
|
displayEffect(head, m.effect)
|
||||||
|
//mob.getWorld().playEffect(head, Effect.ENDER_SIGNAL, 1);
|
||||||
|
}
|
||||||
|
if ((mob.type == EntityType.ENDERMAN) || (mob.type == EntityType.IRON_GOLEM)) {
|
||||||
|
head.y += 1
|
||||||
|
displayEffect(head, m.effect)
|
||||||
|
//mob.getWorld().playEffect(head, Effect.ENDER_SIGNAL, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Ability's
|
||||||
|
val abilityList = infernalMobService.findMobAbilities(id)
|
||||||
|
if (!mob.isDead) {
|
||||||
|
for (ability in abilityList) {
|
||||||
|
val rand = Random()
|
||||||
|
val min = 1
|
||||||
|
val max = 10
|
||||||
|
val randomNum = rand.nextInt(max - min) + min
|
||||||
|
if (ability == "cloaked") {
|
||||||
|
(mob as LivingEntity).addPotionEffect(
|
||||||
|
PotionEffect(
|
||||||
|
PotionEffectType.INVISIBILITY,
|
||||||
|
40,
|
||||||
|
1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else if (ability == "armoured") {
|
||||||
|
if ((mob !is Skeleton) && (mob !is Zombie)) {
|
||||||
|
(mob as LivingEntity).addPotionEffect(
|
||||||
|
PotionEffect(
|
||||||
|
PotionEffectType.DAMAGE_RESISTANCE,
|
||||||
|
40,
|
||||||
|
1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else if (ability == "oneup") {
|
||||||
|
if ((mob as org.bukkit.entity.Damageable).health <= 5) {
|
||||||
|
val oneUpper = infernalMobService.infernalList[index]
|
||||||
|
if (oneUpper!!.lives > 1) {
|
||||||
|
//System.out.print("1");//-------------------------------Debug
|
||||||
|
// ((org.bukkit.entity.Damageable) mob).setHealth(((org.bukkit.entity.Damageable) mob).);
|
||||||
|
|
||||||
|
//System.out.print("UP!");//-------------------------------Debug
|
||||||
|
//InfernalMob newMob = new InfernalMob(mob, id, mob.getWorld(), oneUpper.infernal, abilityList, 1, getEffect());
|
||||||
|
//infernalList.set(index, newMob);
|
||||||
|
|
||||||
|
(mob as LivingEntity).health = mob.getAttribute(Attribute.GENERIC_MAX_HEALTH)!!
|
||||||
|
.baseValue
|
||||||
|
oneUpper.lives -= 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ability == "sprint") {
|
||||||
|
(mob as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.SPEED, 40, 1))
|
||||||
|
} else if (ability == "molten") {
|
||||||
|
(mob as LivingEntity).addPotionEffect(
|
||||||
|
PotionEffect(
|
||||||
|
PotionEffectType.FIRE_RESISTANCE,
|
||||||
|
40,
|
||||||
|
1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else if (ability == "tosser") {
|
||||||
|
if (randomNum < 6) {
|
||||||
|
val radius = 6.0
|
||||||
|
val near = mob.world.players as ArrayList<Player>
|
||||||
|
for (player in near) {
|
||||||
|
if (player.location.distance(mob.location) <= radius) {
|
||||||
|
if ((!player.isSneaking) && (player.gameMode != GameMode.CREATIVE)) {
|
||||||
|
player.velocity =
|
||||||
|
mob.location.toVector().subtract(player.location.toVector())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ability == "gravity") {
|
||||||
|
if (randomNum >= 9) {
|
||||||
|
val radius = 10.0
|
||||||
|
val near = mob.world.players as ArrayList<Player>
|
||||||
|
for (player in near) {
|
||||||
|
if (player.location.distance(mob.location) <= radius) {
|
||||||
|
val feetBlock = player.location
|
||||||
|
feetBlock.y -= 2
|
||||||
|
val block = feetBlock.world.getBlockAt(feetBlock)
|
||||||
|
if ((block.type != Material.AIR) && (player.gameMode != GameMode.CREATIVE)) {
|
||||||
|
var amount = 6
|
||||||
|
amount = configService.mainConfig.gravityLevitateLength
|
||||||
|
EntityUtils.levitate(player, amount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((ability == "ghastly") || (ability == "necromancer")) {
|
||||||
|
if ((randomNum == 6) && (!mob.isDead)) {
|
||||||
|
val radius = 20.0
|
||||||
|
val near = mob.world.players as ArrayList<Player>
|
||||||
|
for (player in near) {
|
||||||
|
if ((player.location.distance(mob.location) <= radius) && (player.gameMode != GameMode.CREATIVE)) {
|
||||||
|
var fb: Fireball?
|
||||||
|
if (ability == "ghastly") {
|
||||||
|
fb = (mob as LivingEntity).launchProjectile(
|
||||||
|
Fireball::class.java
|
||||||
|
)
|
||||||
|
player.world.playSound(player.location, Sound.AMBIENT_CAVE, 5f, 1f)
|
||||||
|
} else {
|
||||||
|
fb = (mob as LivingEntity).launchProjectile(
|
||||||
|
WitherSkull::class.java
|
||||||
|
)
|
||||||
|
}
|
||||||
|
//Location loc1 = player.getEyeLocation();
|
||||||
|
//Location loc2 = mob.getLocation();
|
||||||
|
//int arrowSpeed = 1;
|
||||||
|
//loc2.setY(loc2.getBlockY()+2);
|
||||||
|
//loc2.setX(loc2.getBlockX()+0.5);
|
||||||
|
//loc2.setZ(loc2.getBlockZ()+0.5);
|
||||||
|
//Arrow ar = mob.getWorld().spawnArrow(loc2, new Vector(loc1.getX()-loc2.getX(), loc1.getY()-loc2.getY(), loc1.getZ()-loc2.getZ()), arrowSpeed, 12);
|
||||||
|
//Vector vel = ar.getVelocity();
|
||||||
|
//fb.setVelocity(vel);
|
||||||
|
//ar.remove();
|
||||||
|
EntityUtils.moveToward(fb, player.location, 0.6)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (x: Exception) {
|
||||||
|
x.printStackTrace()
|
||||||
|
}
|
||||||
|
plugin.serverTime += 1
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(
|
||||||
|
plugin,
|
||||||
|
{ showEffect() }, 20
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun scoreCheck() {
|
||||||
|
for (p in plugin.server.onlinePlayers) {
|
||||||
|
gui.fixBar(p)
|
||||||
|
}
|
||||||
|
for ((key, value) in infernalMobService.mountList) {
|
||||||
|
if (!key.isDead) {
|
||||||
|
if ((value.isDead) && ((key is LivingEntity))) {
|
||||||
|
val fate = configService.mainConfig.mountFate
|
||||||
|
|
||||||
|
if (fate == "death") {
|
||||||
|
val le = key as LivingEntity?
|
||||||
|
le!!.damage(9.99999999E8)
|
||||||
|
infernalMobService.mountList.remove(key)
|
||||||
|
} else if (fate == "removal") {
|
||||||
|
key.remove()
|
||||||
|
plugin.logger.log(Level.INFO, "Entity remove due to Fate")
|
||||||
|
infernalMobService.mountList.remove(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
infernalMobService.mountList.remove(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.handler
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.models.InfernalMob
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.ItemUtils
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.Color
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.enchantments.Enchantment
|
||||||
|
import org.bukkit.entity.Entity
|
||||||
|
import org.bukkit.entity.EntityType
|
||||||
|
import org.bukkit.entity.Zombie
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.potion.PotionEffect
|
||||||
|
import org.bukkit.potion.PotionEffectType
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class GhostHandler(val plugin: InfernalMobs, val infernalMobService: InfernalMobService) {
|
||||||
|
fun spawnGhost(l: Location) {
|
||||||
|
var evil = false
|
||||||
|
if (Random().nextInt(3) == 1) {
|
||||||
|
evil = true
|
||||||
|
}
|
||||||
|
val g = l.world.spawnEntity(l, EntityType.ZOMBIE) as Zombie
|
||||||
|
g.addPotionEffect(PotionEffect(PotionEffectType.INVISIBILITY, 199999980, 1))
|
||||||
|
g.canPickupItems = false
|
||||||
|
|
||||||
|
val chest = ItemStack(Material.LEATHER_CHESTPLATE, 1)
|
||||||
|
val skull: ItemStack
|
||||||
|
if (evil) {
|
||||||
|
skull = ItemStack(Material.WITHER_SKELETON_SKULL, 1)
|
||||||
|
ItemUtils.dye(chest, Color.BLACK)
|
||||||
|
} else {
|
||||||
|
skull = ItemStack(Material.SKELETON_SKULL, 1)
|
||||||
|
ItemUtils.dye(chest, Color.WHITE)
|
||||||
|
}
|
||||||
|
chest.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, Random().nextInt(10) + 1)
|
||||||
|
val m = skull.itemMeta
|
||||||
|
m.setDisplayName("§fGhost Head")
|
||||||
|
skull.setItemMeta(m)
|
||||||
|
g.equipment.helmet = skull
|
||||||
|
g.equipment.chestplate = chest
|
||||||
|
g.equipment.helmetDropChance = 0.0f
|
||||||
|
g.equipment.chestplateDropChance = 0.0f
|
||||||
|
val min = 1
|
||||||
|
val max = 5
|
||||||
|
val rn = Random().nextInt(max - min) + min
|
||||||
|
if (rn == 1) {
|
||||||
|
g.equipment.setItemInMainHand(ItemStack(Material.STONE_HOE, 1))
|
||||||
|
g.equipment.itemInMainHandDropChance = 0.0f
|
||||||
|
}
|
||||||
|
ghostMove(g)
|
||||||
|
|
||||||
|
val aList = mutableListOf<String>()
|
||||||
|
aList.add("ender")
|
||||||
|
if (evil) {
|
||||||
|
aList.add("necromancer")
|
||||||
|
aList.add("withering")
|
||||||
|
aList.add("blinding")
|
||||||
|
} else {
|
||||||
|
aList.add("ghastly")
|
||||||
|
aList.add("sapper")
|
||||||
|
aList.add("confusing")
|
||||||
|
}
|
||||||
|
val newMob = if (evil) {
|
||||||
|
InfernalMob(g, g.uniqueId, false, aList, 1, "smoke:2:12")
|
||||||
|
} else {
|
||||||
|
InfernalMob(g, g.uniqueId, false, aList, 1, "cloud:0:8")
|
||||||
|
}
|
||||||
|
infernalMobService.infernalList.add(newMob)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ghostMove(g: Entity) {
|
||||||
|
if (g.isDead) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val v = g.location.direction.multiply(0.3)
|
||||||
|
g.velocity = v
|
||||||
|
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(plugin, {
|
||||||
|
try {
|
||||||
|
ghostMove(g)
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
}, 2L)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.handler
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.MathUtils
|
||||||
|
import org.bukkit.entity.Entity
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class InfernalMobHandler(private val configService: ConfigService, val plugin: InfernalMobs, private val infernalMobService: InfernalMobService) {
|
||||||
|
private fun getAbilities(amount: Int): List<String> {
|
||||||
|
val allAbilitiesList = configService.mainConfig.enabledAbilities.toMutableList()
|
||||||
|
require(amount <= allAbilitiesList.size) { "Sample size cannot be greater than the list size" }
|
||||||
|
return allAbilitiesList.shuffled().take(amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getAbilitiesAmount(e: Entity): List<String> {
|
||||||
|
val power: Int
|
||||||
|
if (configService.mainConfig.powerByDistance) {
|
||||||
|
val l = e.world.spawnLocation
|
||||||
|
var m = l.distance(e.location).toInt() / configService.mainConfig.addDistance
|
||||||
|
if (m < 1) {
|
||||||
|
m = 1
|
||||||
|
}
|
||||||
|
val add = configService.mainConfig.powerToAdd
|
||||||
|
power = m * add
|
||||||
|
} else {
|
||||||
|
val min = configService.mainConfig.minpowers
|
||||||
|
val max = configService.mainConfig.maxpowers
|
||||||
|
power = MathUtils.rand(min, max)
|
||||||
|
}
|
||||||
|
return getAbilities(power)
|
||||||
|
}
|
||||||
|
fun removeMob(mobIndex: Int) {
|
||||||
|
val id = infernalMobService.infernalList[mobIndex].id.toString()
|
||||||
|
infernalMobService.infernalList.removeAt(mobIndex)
|
||||||
|
configService.mobSaveConfig[id] = null
|
||||||
|
configService.saveSave()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,308 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.handler
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.models.LevelledEnchantment
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.ItemUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.MathUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.StringUtils
|
||||||
|
import org.bukkit.*
|
||||||
|
import org.bukkit.block.Banner
|
||||||
|
import org.bukkit.block.banner.Pattern
|
||||||
|
import org.bukkit.enchantments.Enchantment
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.*
|
||||||
|
import org.bukkit.potion.PotionData
|
||||||
|
import org.bukkit.potion.PotionType
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.util.*
|
||||||
|
import java.util.logging.Level
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class LootHandler(val plugin: InfernalMobs, val configService: ConfigService) {
|
||||||
|
fun getRandomLoot(player: Player, mob: String?, powers: Int): ItemStack {
|
||||||
|
val lootList = mutableListOf<Int>()
|
||||||
|
for (i in configService.lootConfig.getConfigurationSection("loot")?.getKeys(false)
|
||||||
|
?: return ItemStack(Material.AIR)) {
|
||||||
|
if ((configService.lootConfig.getString("loot.$i") != null) &&
|
||||||
|
((configService.lootConfig.getList("loot.$i.mobs") == null) ||
|
||||||
|
(configService.lootConfig.getList("loot.$i.mobs", ArrayList<Any>())!!.contains(mob))) &&
|
||||||
|
(configService.lootConfig.getString("loot.$i.chancePercentage") == null ||
|
||||||
|
MathUtils.rand(1, 100) <= configService.lootConfig.getInt("loot.$i.chancePercentage"))
|
||||||
|
) {
|
||||||
|
if (mobPowerLevelFine(i.toInt(), powers)) {
|
||||||
|
lootList.add(i.toInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (configService.mainConfig.debug) plugin.logger.log(
|
||||||
|
Level.INFO,
|
||||||
|
"Loot List $lootList"
|
||||||
|
)
|
||||||
|
return if (lootList.isNotEmpty()) {
|
||||||
|
getLoot(player, lootList[MathUtils.rand(1, lootList.size) - 1])
|
||||||
|
} else ItemStack(Material.AIR)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLoot(player: Player, loot: Int): ItemStack {
|
||||||
|
var i: ItemStack? = null
|
||||||
|
if (configService.lootConfig.getStringList("loot.$loot.commands").isNotEmpty()) {
|
||||||
|
val commandList = configService.lootConfig.getStringList("loot.$loot.commands")
|
||||||
|
for (command in commandList) {
|
||||||
|
Bukkit.getServer().dispatchCommand(
|
||||||
|
Bukkit.getConsoleSender(),
|
||||||
|
ChatColor.translateAlternateColorCodes('&', command).replace("player", player.name)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if (this.configService.lootConfig.getString("loot." + loot + ".staff.id") != null) {
|
||||||
|
// int id = this.configService.lootConfig.getInt("loot." + loot + ".staff.id");
|
||||||
|
// ArrayList<String> spells = new ArrayList();
|
||||||
|
// if (!this.configService.lootConfig.getStringList("loot." + loot + ".staff.spells").isEmpty()) {
|
||||||
|
// spells = (ArrayList) this.configService.lootConfig.getStringList("loot." + loot + ".staff.spells");
|
||||||
|
// }
|
||||||
|
// return this.wMagic.getStaffWithSpells(id, spells);
|
||||||
|
// }
|
||||||
|
|
||||||
|
return getItem(loot)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getItem(loot: Int): ItemStack {
|
||||||
|
//System.out.println("Get Loot: " + loot);
|
||||||
|
val setItem = configService.lootConfig.getString("loot.$loot.item")
|
||||||
|
|
||||||
|
val setAmountString = configService.lootConfig.getString("loot.$loot.amount")
|
||||||
|
val setAmount = if (setAmountString != null) {
|
||||||
|
StringUtils.getIntFromString(setAmountString)
|
||||||
|
} else 1
|
||||||
|
val stack = ItemStack(ItemUtils.getMaterial(setItem), setAmount)
|
||||||
|
//Name
|
||||||
|
var name: String? = null
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.name") != null && configService.lootConfig.isString("loot.$loot.name")) {
|
||||||
|
name = configService.lootConfig.getString("loot.$loot.name")
|
||||||
|
name = ItemUtils.prosessLootName(name!!, stack)
|
||||||
|
} else if (configService.lootConfig.isList("loot.$loot.name")) {
|
||||||
|
val names = configService.lootConfig.getStringList("loot.$loot.name")
|
||||||
|
if (names.isNotEmpty()) {
|
||||||
|
name = names[MathUtils.rand(1, names.size) - 1]
|
||||||
|
name = ItemUtils.prosessLootName(name, stack)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Lore
|
||||||
|
val loreList = mutableListOf<String>()
|
||||||
|
for (i in 0..32) {
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.lore$i") != null) {
|
||||||
|
var lore = configService.lootConfig.getString("loot.$loot.lore$i")
|
||||||
|
lore = ChatColor.translateAlternateColorCodes('&', lore!!)
|
||||||
|
loreList.add(lore)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (configService.lootConfig.getStringList("loot.$loot.lore").isNotEmpty()) {
|
||||||
|
val l = configService.lootConfig.getStringList("loot.$loot.lore")
|
||||||
|
var min = l.size
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.minLore") != null) min =
|
||||||
|
configService.lootConfig.getInt("loot.$loot.minLore")
|
||||||
|
var max = l.size
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.maxLore") != null) max =
|
||||||
|
configService.lootConfig.getInt("loot.$loot.maxLore")
|
||||||
|
if (l.isNotEmpty()) for (i in 0 until MathUtils.rand(min, max)) {
|
||||||
|
val lore = l[MathUtils.rand(1, l.size) - 1]
|
||||||
|
l.remove(lore)
|
||||||
|
loreList.add(ItemUtils.prosessLootName(lore, stack))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val meta = stack.itemMeta
|
||||||
|
//Durability
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.durability") != null) {
|
||||||
|
val durabilityString = configService.lootConfig.getString("loot.$loot.durability")
|
||||||
|
val durability = StringUtils.getIntFromString(durabilityString!!)
|
||||||
|
(meta as Damageable).damage = durability
|
||||||
|
//stack.setDurability((short) durability);
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
meta.setDisplayName(name)
|
||||||
|
}
|
||||||
|
if (loreList.isNotEmpty()) {
|
||||||
|
meta.lore = loreList
|
||||||
|
}
|
||||||
|
if (meta != null) {
|
||||||
|
stack.setItemMeta(meta)
|
||||||
|
}
|
||||||
|
//Colour
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.colour") != null && stack.type.toString()
|
||||||
|
.lowercase(Locale.getDefault())
|
||||||
|
.contains("leather")
|
||||||
|
) {
|
||||||
|
val c = configService.lootConfig.getString("loot.$loot.colour")
|
||||||
|
val split = c!!.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
|
val colour = Color.fromRGB(split[0].toInt(), split[1].toInt(), split[2].toInt())
|
||||||
|
ItemUtils.dye(stack, colour)
|
||||||
|
}
|
||||||
|
//Book
|
||||||
|
if ((stack.type == Material.WRITTEN_BOOK) || (stack.type == Material.WRITABLE_BOOK)) {
|
||||||
|
val bMeta = stack.itemMeta as BookMeta
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.author") != null) {
|
||||||
|
var author = configService.lootConfig.getString("loot.$loot.author")
|
||||||
|
author = ChatColor.translateAlternateColorCodes('&', author!!)
|
||||||
|
bMeta.author = author
|
||||||
|
}
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.title") != null) {
|
||||||
|
var title = configService.lootConfig.getString("loot.$loot.title")
|
||||||
|
title = ChatColor.translateAlternateColorCodes('&', title!!)
|
||||||
|
bMeta.setTitle(title)
|
||||||
|
}
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.pages") != null) {
|
||||||
|
for (i in configService.lootConfig.getConfigurationSection("loot.$loot.pages")!!
|
||||||
|
.getKeys(false)) {
|
||||||
|
var page = configService.lootConfig.getString("loot.$loot.pages.$i")
|
||||||
|
page = ChatColor.translateAlternateColorCodes('&', page!!)
|
||||||
|
bMeta.addPage(page)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stack.setItemMeta(bMeta)
|
||||||
|
}
|
||||||
|
//Banners
|
||||||
|
if (stack.type.toString().contains("BANNER")) {
|
||||||
|
val b = stack.itemMeta as BannerMeta
|
||||||
|
val patList = configService.lootConfig.getList("loot.$loot.patterns") as List<Pattern>?
|
||||||
|
if (!patList.isNullOrEmpty()) b.patterns = patList
|
||||||
|
stack.setItemMeta(b)
|
||||||
|
}
|
||||||
|
//Shield
|
||||||
|
if (stack.type == Material.SHIELD) {
|
||||||
|
val im = stack.itemMeta
|
||||||
|
val bmeta = im as BlockStateMeta
|
||||||
|
|
||||||
|
val b = bmeta.blockState as Banner
|
||||||
|
val patList = configService.lootConfig.getList("loot.$loot.patterns") as List<Pattern>?
|
||||||
|
b.baseColor = DyeColor.valueOf(configService.lootConfig.getString("loot.$loot.colour")!!)
|
||||||
|
b.patterns = patList!!
|
||||||
|
b.update()
|
||||||
|
bmeta.blockState = b
|
||||||
|
stack.setItemMeta(bmeta)
|
||||||
|
}
|
||||||
|
//Owner
|
||||||
|
if (stack.type == Material.PLAYER_HEAD) {
|
||||||
|
val owner = configService.lootConfig.getString("loot.$loot.owner")
|
||||||
|
val sm = stack.itemMeta as SkullMeta
|
||||||
|
sm.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(owner)))
|
||||||
|
stack.setItemMeta(sm)
|
||||||
|
}
|
||||||
|
//Potions
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.potion") != null) if (stack.type == Material.POTION || stack.type == Material.SPLASH_POTION || stack.type == Material.LINGERING_POTION) {
|
||||||
|
val pMeta = stack.itemMeta as PotionMeta
|
||||||
|
val pn = configService.lootConfig.getString("loot.$loot.potion")
|
||||||
|
pMeta.basePotionData =
|
||||||
|
PotionData(PotionType.valueOf(pn!!), false, false)
|
||||||
|
stack.setItemMeta(pMeta)
|
||||||
|
}
|
||||||
|
var enchAmount = 0
|
||||||
|
for (e in 0..10) {
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.enchantments.$e") != null) {
|
||||||
|
enchAmount++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//System.out.println("Enchantments Found: " + enchAmount);
|
||||||
|
if (enchAmount > 0) {
|
||||||
|
var enMin = enchAmount / 2
|
||||||
|
if (enMin < 1) {
|
||||||
|
enMin = 1
|
||||||
|
}
|
||||||
|
var enMax = enchAmount
|
||||||
|
if ((configService.lootConfig.getString("loot.$loot.minEnchantments") != null) && (configService.lootConfig.getString(
|
||||||
|
"loot.$loot.maxEnchantments"
|
||||||
|
) != null)
|
||||||
|
) {
|
||||||
|
enMin = configService.lootConfig.getInt("loot.$loot.minEnchantments")
|
||||||
|
enMax = configService.lootConfig.getInt("loot.$loot.maxEnchantments")
|
||||||
|
}
|
||||||
|
//int enchNeeded = new Random().nextInt(enMax + 1 - enMin) + enMin;
|
||||||
|
val enchNeeded = MathUtils.rand(enMin, enMax)
|
||||||
|
//System.out.println("Enchantments Needed: " + enchNeeded);
|
||||||
|
val enchList = mutableListOf<LevelledEnchantment>()
|
||||||
|
var safety = 0
|
||||||
|
var j = 0
|
||||||
|
var chance: Int
|
||||||
|
do {
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.enchantments.$j") != null) {
|
||||||
|
var enChance = 1
|
||||||
|
if (configService.lootConfig.getString("loot.$loot.enchantments.$j.chance") != null) {
|
||||||
|
enChance = configService.lootConfig.getInt("loot.$loot.enchantments.$j.chance")
|
||||||
|
}
|
||||||
|
chance = Random().nextInt(enChance - 1 + 1) + 1
|
||||||
|
if (chance == 1) {
|
||||||
|
val enchantment =
|
||||||
|
configService.lootConfig.getString("loot.$loot.enchantments.$j.enchantment")!!
|
||||||
|
.lowercase(Locale.getDefault())
|
||||||
|
val levelString = configService.lootConfig.getString("loot.$loot.enchantments.$j.level")
|
||||||
|
var level = StringUtils.getIntFromString(levelString!!)
|
||||||
|
//System.out.print("1: " + NamespacedKey.minecraft(enchantment));
|
||||||
|
//System.out.print("2: " + Enchantment.getByKey(NamespacedKey.minecraft(enchantment)));
|
||||||
|
if (Enchantment.getByKey(NamespacedKey.minecraft(enchantment)) != null) {
|
||||||
|
if (level < 1) {
|
||||||
|
level = 1
|
||||||
|
}
|
||||||
|
val le = LevelledEnchantment(
|
||||||
|
Enchantment.getByKey(NamespacedKey.minecraft(enchantment)),
|
||||||
|
level
|
||||||
|
)
|
||||||
|
|
||||||
|
var con = false
|
||||||
|
for (testE in enchList) {
|
||||||
|
if (testE.getEnchantment == le.getEnchantment) {
|
||||||
|
con = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!con) {
|
||||||
|
enchList.add(le)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println("Error: No valid drops found!")
|
||||||
|
println("Error: $enchantment is not a valid enchantment!")
|
||||||
|
return ItemStack(Material.AIR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
j++
|
||||||
|
if (j > enchAmount) {
|
||||||
|
j = 0
|
||||||
|
safety++
|
||||||
|
}
|
||||||
|
if (safety >= enchAmount * 100) {
|
||||||
|
//System.out.println("Error: No valid drops found!");
|
||||||
|
//System.out.println("Error: Please increase chance for enchantments on item " + loot);
|
||||||
|
//return null;
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} while (enchList.size != enchNeeded)
|
||||||
|
for (le in enchList) {
|
||||||
|
if (stack.type == Material.ENCHANTED_BOOK) {
|
||||||
|
val enchantMeta = stack.itemMeta as EnchantmentStorageMeta
|
||||||
|
enchantMeta.addStoredEnchant(le.getEnchantment!!, le.getLevel, true)
|
||||||
|
stack.setItemMeta(enchantMeta)
|
||||||
|
} else {
|
||||||
|
stack.addUnsafeEnchantment(le.getEnchantment!!, le.getLevel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stack
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun mobPowerLevelFine(lootId: Int, mobPowers: Int): Boolean {
|
||||||
|
var min = 0
|
||||||
|
var max = 99
|
||||||
|
if (configService.lootConfig.getString("loot.$lootId.powersMin") != null) {
|
||||||
|
min = configService.lootConfig.getInt("loot.$lootId.powersMin")
|
||||||
|
}
|
||||||
|
if (configService.lootConfig.getString("loot.$lootId.powersMax") != null) max =
|
||||||
|
configService.lootConfig.getInt("loot.$lootId.powersMax")
|
||||||
|
if (configService.mainConfig.debug) {
|
||||||
|
plugin.logger.log(
|
||||||
|
Level.INFO,
|
||||||
|
"Loot $lootId min = $min and max = $max"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return (mobPowers >= min) && (mobPowers <= max)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,474 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.handler
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.gui.GUI
|
||||||
|
import io.github.thehrz.infernalmobs.models.InfernalMob
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import io.github.thehrz.infernalmobs.tasks.ArrowHomingTask
|
||||||
|
import io.github.thehrz.infernalmobs.utils.BlockUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.EntityUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.LocationUtils
|
||||||
|
import org.bukkit.Color
|
||||||
|
import org.bukkit.GameMode
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.attribute.Attribute
|
||||||
|
import org.bukkit.entity.*
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.Damageable
|
||||||
|
import org.bukkit.inventory.meta.LeatherArmorMeta
|
||||||
|
import org.bukkit.inventory.meta.PotionMeta
|
||||||
|
import org.bukkit.potion.PotionEffect
|
||||||
|
import org.bukkit.potion.PotionEffectType
|
||||||
|
import org.bukkit.util.Vector
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.util.*
|
||||||
|
import java.util.logging.Level
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class MagicHandler(
|
||||||
|
val configService: ConfigService,
|
||||||
|
val infernalMobHandler: InfernalMobHandler,
|
||||||
|
val infernalMobService: InfernalMobService,
|
||||||
|
val plugin: InfernalMobs,
|
||||||
|
val gui: GUI
|
||||||
|
) {
|
||||||
|
fun doMagic(vic: Entity, atc: Entity, playerIsVictom: Boolean, ability: String, id: UUID) {
|
||||||
|
val min = 1
|
||||||
|
val max = 10
|
||||||
|
var randomNum = Random().nextInt(max - min) + min
|
||||||
|
if ((atc is Player)) {
|
||||||
|
randomNum = 1
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if ((atc is Player)) {
|
||||||
|
when (ability) {
|
||||||
|
"tosser" -> if ((vic !is Player) || ((!vic.isSneaking) && (vic.gameMode != GameMode.CREATIVE))) {
|
||||||
|
vic.velocity = atc.getLocation().toVector().subtract(vic.location.toVector())
|
||||||
|
}
|
||||||
|
|
||||||
|
"gravity" -> if ((vic !is Player) || ((!vic.isSneaking) && (vic.gameMode != GameMode.CREATIVE))) {
|
||||||
|
val feetBlock = vic.location
|
||||||
|
feetBlock.y -= 2.0
|
||||||
|
val block = feetBlock.world.getBlockAt(feetBlock)
|
||||||
|
if (block.type != Material.AIR) {
|
||||||
|
EntityUtils.levitate(
|
||||||
|
vic, configService.mainConfig.gravityLevitateLength
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"ghastly", "necromancer" -> if ((!vic.isDead) && ((vic !is Player) || ((!vic.isSneaking) && (vic.gameMode != GameMode.CREATIVE)))) {
|
||||||
|
val fb = if (ability == "ghastly") {
|
||||||
|
(atc as LivingEntity).launchProjectile(
|
||||||
|
Fireball::class.java
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(atc as LivingEntity).launchProjectile(
|
||||||
|
WitherSkull::class.java
|
||||||
|
)
|
||||||
|
}
|
||||||
|
EntityUtils.moveToward(fb, vic.location, 0.6)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ability == "ender") {
|
||||||
|
atc.teleport(vic.location)
|
||||||
|
} else if ((ability == "poisonous") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
(vic as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.POISON, 200, 1))
|
||||||
|
} else if ((ability == "morph") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
try {
|
||||||
|
var newEnt: Entity?
|
||||||
|
val mc = Random().nextInt(25) + 1
|
||||||
|
if (mc != 20) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val l = atc.location.clone()
|
||||||
|
val h = (atc as org.bukkit.entity.Damageable).health
|
||||||
|
val aList =
|
||||||
|
infernalMobService.infernalList[infernalMobService.idSearch(id)]!!.abilityList
|
||||||
|
//Remove old
|
||||||
|
val dis = 46.0
|
||||||
|
for (e in atc.getNearbyEntities(dis, dis, dis)) if (e is Player) {
|
||||||
|
gui.fixBar(
|
||||||
|
e
|
||||||
|
)
|
||||||
|
}
|
||||||
|
atc.teleport(Location(atc.getWorld(), l.x, 0.0, l.z))
|
||||||
|
atc.remove()
|
||||||
|
plugin.logger.log(Level.INFO, "Entity remove due to Morph")
|
||||||
|
val mList = configService.mainConfig.enabledMobs
|
||||||
|
val index = Random().nextInt(mList.size)
|
||||||
|
val mobName = mList[index]
|
||||||
|
|
||||||
|
newEnt = null
|
||||||
|
var arrayOfEntityType: Array<EntityType>
|
||||||
|
val j = (EntityType.values().also { arrayOfEntityType = it }).size
|
||||||
|
for (i in 0 until j) {
|
||||||
|
val e = arrayOfEntityType[i]
|
||||||
|
try {
|
||||||
|
if ((e.getName() != null) && (e.getName().equals(mobName, ignoreCase = true))) {
|
||||||
|
newEnt = vic.world.spawnEntity(l, e)
|
||||||
|
}
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newEnt == null) {
|
||||||
|
println("Infernal Mobs can't find mob type: $mobName!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val newMob = if (aList!!.contains("oneup")) {
|
||||||
|
InfernalMob(newEnt, newEnt.uniqueId, true, aList, 2, infernalMobService.effect)
|
||||||
|
} else {
|
||||||
|
InfernalMob(newEnt, newEnt.uniqueId, true, aList, 1, infernalMobService.effect)
|
||||||
|
}
|
||||||
|
if (aList.contains("flying")) {
|
||||||
|
EntityUtils.makeFly(newEnt)
|
||||||
|
}
|
||||||
|
infernalMobService.infernalList[infernalMobService.idSearch(id)] = newMob
|
||||||
|
gui!!.setName(newEnt)
|
||||||
|
|
||||||
|
infernalMobService.giveMobGear(newEnt, true)
|
||||||
|
|
||||||
|
infernalMobService.addHealth(newEnt, aList)
|
||||||
|
if (h >= (newEnt as LivingEntity).getAttribute(Attribute.GENERIC_MAX_HEALTH)!!
|
||||||
|
.baseValue
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
(newEnt as org.bukkit.entity.Damageable).health = h
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
print("Morph Error: ")
|
||||||
|
ex.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((ability == "molten") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
vic.fireTicks = configService.mainConfig.moltenBurnLength * 20
|
||||||
|
} else if ((ability == "blinding") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
(vic as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, 60, 1))
|
||||||
|
} else if ((ability == "confusing") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
(vic as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.CONFUSION, 80, 2))
|
||||||
|
} else if ((ability == "withering") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
(vic as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.WITHER, 180, 1))
|
||||||
|
} else if ((ability == "thief") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
if ((vic is Player)) {
|
||||||
|
if ((vic.inventory.itemInMainHand.type != Material.AIR) && ((randomNum <= 1) || (randomNum == 1))) {
|
||||||
|
vic.getWorld().dropItemNaturally(atc.location, vic.inventory.itemInMainHand)
|
||||||
|
val slot = vic.inventory.heldItemSlot
|
||||||
|
vic.inventory.setItem(slot, null)
|
||||||
|
}
|
||||||
|
} else if (vic is Zombie || vic is Skeleton) {
|
||||||
|
val eq = (vic as LivingEntity).equipment!!
|
||||||
|
vic.getWorld().dropItemNaturally(atc.location, eq.itemInMainHand)
|
||||||
|
eq.setItemInMainHand(null)
|
||||||
|
}
|
||||||
|
} else if ((ability == "quicksand") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
(vic as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.SLOW, 180, 1))
|
||||||
|
} else if ((ability == "bullwark") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
(atc as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 500, 2))
|
||||||
|
} else if ((ability == "rust") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
val damItem = (vic as Player).inventory.itemInMainHand
|
||||||
|
if (((randomNum <= 3) || (randomNum == 1)) && (damItem.maxStackSize == 1)) {
|
||||||
|
val cDur = (damItem.itemMeta as Damageable).damage
|
||||||
|
(damItem.itemMeta as Damageable).damage = cDur + 20
|
||||||
|
}
|
||||||
|
} else if ((ability == "sapper") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
(vic as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.HUNGER, 500, 1), true)
|
||||||
|
} else if ((ability != "oneup") || (!isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
val needAir2: Location
|
||||||
|
if ((ability == "ender") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
val targetLocation = vic.location
|
||||||
|
if (randomNum >= 8) {
|
||||||
|
val rand2 = Random()
|
||||||
|
val min2 = 1
|
||||||
|
val max2 = 4
|
||||||
|
val randomNum2 = rand2.nextInt(max2 - min2 + 1) + min2
|
||||||
|
if (randomNum2 == 1) {
|
||||||
|
targetLocation.z = targetLocation.z + 6.0
|
||||||
|
} else if (randomNum2 == 2) {
|
||||||
|
targetLocation.z = targetLocation.z - 5.0
|
||||||
|
} else if (randomNum2 == 3) {
|
||||||
|
targetLocation.x = targetLocation.x + 8.0
|
||||||
|
} else if (randomNum2 == 4) {
|
||||||
|
targetLocation.x = targetLocation.x - 10.0
|
||||||
|
}
|
||||||
|
needAir2 = targetLocation
|
||||||
|
needAir2.y = needAir2.y + 1.0
|
||||||
|
targetLocation.y = targetLocation.y + 2.0
|
||||||
|
if (((targetLocation.block.type == Material.AIR) || (targetLocation.block.type == Material.TORCH)) &&
|
||||||
|
((needAir2.block.type == Material.AIR) || (needAir2.block.type == Material.TORCH)) && ((targetLocation.block.type == Material.AIR) || (targetLocation.block.type == Material.TORCH))
|
||||||
|
) {
|
||||||
|
atc.teleport(targetLocation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((ability == "lifesteal") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
(atc as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.REGENERATION, 20, 1))
|
||||||
|
} else if ((ability != "cloaked") || (!isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
if ((ability == "storm") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
if (((randomNum <= 2) || (randomNum == 1)) && (!atc.isDead)) {
|
||||||
|
vic.world.strikeLightning(vic.location)
|
||||||
|
}
|
||||||
|
} else if ((ability != "sprint") || (!isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
if ((ability == "webber") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
if ((randomNum >= 8) || (randomNum == 1)) {
|
||||||
|
val feet = vic.location
|
||||||
|
feet.block.type = Material.COBWEB
|
||||||
|
LocationUtils.setAir(feet, 60)
|
||||||
|
|
||||||
|
val rNum = Random().nextInt(max - min) + min
|
||||||
|
if ((rNum == 5) && ((atc.type == EntityType.SPIDER) || (atc.type == EntityType.CAVE_SPIDER))) {
|
||||||
|
val l = atc.location
|
||||||
|
val b = l.block
|
||||||
|
val blocks = BlockUtils.getSphere(b)
|
||||||
|
for (bl in blocks) {
|
||||||
|
if (bl.type == Material.AIR) {
|
||||||
|
bl.type = Material.COBWEB
|
||||||
|
LocationUtils.setAir(bl.location, 30)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((ability == "vengeance") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
if ((randomNum >= 5) || (randomNum == 1)) {
|
||||||
|
if ((vic is LivingEntity)) {
|
||||||
|
vic.damage(Math.round(2.0 * configService.mainConfig.vengeanceDamage).toInt().toDouble())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((ability == "weakness") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
(vic as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.WEAKNESS, 500, 1))
|
||||||
|
} else if ((ability == "berserk") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
if ((randomNum >= 5) && (!atc.isDead)) {
|
||||||
|
val health = (atc as org.bukkit.entity.Damageable).health
|
||||||
|
atc.health = health - 1.0
|
||||||
|
if ((vic is LivingEntity)) {
|
||||||
|
vic.damage(Math.round(2.0 * configService.mainConfig.berserkDamage).toInt().toDouble())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((ability == "potions") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
val iStack = ItemStack(Material.POTION)
|
||||||
|
val potion = iStack.itemMeta as PotionMeta
|
||||||
|
when (randomNum) {
|
||||||
|
5 -> {
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.HARM, 1, 2), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.HARM, 1, 1), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.WEAKNESS, (20 * 15), 2), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.POISON, (20 * 5), 2), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.SLOW, (20 * 10), 2), true)
|
||||||
|
}
|
||||||
|
|
||||||
|
6 -> {
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.HARM, 1, 1), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.WEAKNESS, (20 * 15), 2), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.POISON, (20 * 5), 2), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.SLOW, (20 * 10), 2), true)
|
||||||
|
}
|
||||||
|
|
||||||
|
7 -> {
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.WEAKNESS, (20 * 15), 2), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.POISON, (20 * 5), 2), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.SLOW, (20 * 10), 2), true)
|
||||||
|
}
|
||||||
|
|
||||||
|
8 -> {
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.POISON, (20 * 5), 2), true)
|
||||||
|
potion.addCustomEffect(PotionEffect(PotionEffectType.SLOW, (20 * 10), 2), true)
|
||||||
|
}
|
||||||
|
|
||||||
|
9 -> potion.addCustomEffect(PotionEffect(PotionEffectType.SLOW, (20 * 10), 2), true)
|
||||||
|
}
|
||||||
|
iStack.setItemMeta(potion)
|
||||||
|
val sploc = atc.location
|
||||||
|
sploc.y = sploc.y + 3.0
|
||||||
|
val thrownPotion = vic.world.spawnEntity(sploc, EntityType.SPLASH_POTION) as ThrownPotion
|
||||||
|
thrownPotion.item = iStack
|
||||||
|
val direction = atc.location.direction
|
||||||
|
direction.normalize()
|
||||||
|
direction.add(Vector(0.0, 0.2, 0.0))
|
||||||
|
|
||||||
|
var dist = atc.location.distance(vic.location)
|
||||||
|
|
||||||
|
dist /= 15.0
|
||||||
|
direction.multiply(dist)
|
||||||
|
thrownPotion.velocity = direction
|
||||||
|
// }
|
||||||
|
} else if ((ability == "mama") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
if (randomNum == 1) {
|
||||||
|
val amount = configService.mainConfig.mamaSpawnAmount
|
||||||
|
if (atc.type == EntityType.MUSHROOM_COW) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion =
|
||||||
|
atc.world.spawnEntity(atc.location, EntityType.MUSHROOM_COW) as MushroomCow
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.COW) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion = atc.world.spawnEntity(atc.location, EntityType.COW) as Cow
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.SHEEP) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion = atc.world.spawnEntity(atc.location, EntityType.SHEEP) as Sheep
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.PIG) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion = atc.world.spawnEntity(atc.location, EntityType.PIG) as Pig
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.CHICKEN) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion = atc.world.spawnEntity(atc.location, EntityType.CHICKEN) as Chicken
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.WOLF) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion = atc.world.spawnEntity(atc.location, EntityType.WOLF) as Wolf
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.ZOMBIE) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion = atc.world.spawnEntity(atc.location, EntityType.ZOMBIE) as Zombie
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.PIGLIN) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion = atc.world.spawnEntity(atc.location, EntityType.PIGLIN) as PigZombie
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.OCELOT) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion = atc.world.spawnEntity(atc.location, EntityType.OCELOT) as Ocelot
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.HORSE) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion = atc.world.spawnEntity(atc.location, EntityType.HORSE) as Horse
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else if (atc.type == EntityType.VILLAGER) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val minion =
|
||||||
|
atc.world.spawnEntity(atc.location, EntityType.VILLAGER) as Villager
|
||||||
|
minion.setBaby()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
atc.world.spawnEntity(atc.location, atc.type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((ability == "archer") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
if ((randomNum > 7) || (randomNum == 1)) {
|
||||||
|
val arrowList = mutableListOf<Arrow>()
|
||||||
|
val loc1 = vic.location
|
||||||
|
val loc2 = atc.location
|
||||||
|
if (!EntityUtils.isSmall(atc)) {
|
||||||
|
loc2.y += 1.0
|
||||||
|
}
|
||||||
|
val a = (atc as LivingEntity).launchProjectile(
|
||||||
|
Arrow::class.java
|
||||||
|
)
|
||||||
|
val arrowSpeed = 1
|
||||||
|
loc2.y = (loc2.blockY + 2).toDouble()
|
||||||
|
loc2.x = loc2.blockX + 0.5
|
||||||
|
loc2.z = loc2.blockZ + 0.5
|
||||||
|
val a2 = a.world.spawnArrow(
|
||||||
|
loc2,
|
||||||
|
Vector(loc1.x - loc2.x, loc1.y - loc2.y, loc1.z - loc2.z),
|
||||||
|
arrowSpeed.toFloat(),
|
||||||
|
12.0f
|
||||||
|
)
|
||||||
|
a2.shooter = atc
|
||||||
|
loc2.y = (loc2.blockY + 2).toDouble()
|
||||||
|
loc2.x = (loc2.blockX - 1).toDouble()
|
||||||
|
loc2.z = (loc2.blockZ - 1).toDouble()
|
||||||
|
val a3 = a.world.spawnArrow(
|
||||||
|
loc2,
|
||||||
|
Vector(loc1.x - loc2.x, loc1.y - loc2.y, loc1.z - loc2.z),
|
||||||
|
arrowSpeed.toFloat(),
|
||||||
|
12.0f
|
||||||
|
)
|
||||||
|
a3.shooter = atc
|
||||||
|
arrowList.add(a)
|
||||||
|
arrowList.add(a2)
|
||||||
|
arrowList.add(a3)
|
||||||
|
for (ar in arrowList) {
|
||||||
|
var minAngle = 6.283185307179586
|
||||||
|
var minEntity: Entity? = null
|
||||||
|
for (entity in atc.getNearbyEntities(64.0, 64.0, 64.0)) {
|
||||||
|
if ((atc.hasLineOfSight(entity)) && ((entity is LivingEntity)) && (!entity.isDead())) {
|
||||||
|
val toTarget = entity.getLocation().toVector().clone()
|
||||||
|
.subtract(atc.getLocation().toVector())
|
||||||
|
val angle = ar.velocity.angle(toTarget).toDouble()
|
||||||
|
if (angle < minAngle) {
|
||||||
|
minAngle = angle
|
||||||
|
minEntity = entity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (minEntity != null) {
|
||||||
|
ArrowHomingTask(ar, minEntity as LivingEntity, plugin)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((ability == "firework") && (isLegitVictim(atc, playerIsVictom, ability))) {
|
||||||
|
val red = configService.mainConfig.fireworkColour.red
|
||||||
|
val green = configService.mainConfig.fireworkColour.green
|
||||||
|
val blue = configService.mainConfig.fireworkColour.blue
|
||||||
|
val tmpCol = ItemStack(Material.LEATHER_HELMET, 1)
|
||||||
|
val tmpCol2 = tmpCol.itemMeta as LeatherArmorMeta
|
||||||
|
tmpCol2.setColor(Color.fromRGB(red, green, blue))
|
||||||
|
|
||||||
|
val col = tmpCol2.color
|
||||||
|
EntityUtils.launchFirework(atc.location, col, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isLegitVictim(e: Entity, playerIsVictom: Boolean, ability: String): Boolean {
|
||||||
|
if ((e is Player)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (configService.mainConfig.effectAllPlayerAttacks) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val attackAbilityList = mutableListOf<String>()
|
||||||
|
attackAbilityList.add("poisonous")
|
||||||
|
attackAbilityList.add("blinding")
|
||||||
|
attackAbilityList.add("withering")
|
||||||
|
attackAbilityList.add("thief")
|
||||||
|
attackAbilityList.add("sapper")
|
||||||
|
attackAbilityList.add("lifesteal")
|
||||||
|
attackAbilityList.add("storm")
|
||||||
|
attackAbilityList.add("webber")
|
||||||
|
attackAbilityList.add("weakness")
|
||||||
|
attackAbilityList.add("berserk")
|
||||||
|
attackAbilityList.add("potions")
|
||||||
|
attackAbilityList.add("archer")
|
||||||
|
attackAbilityList.add("confusing")
|
||||||
|
if ((playerIsVictom) && (attackAbilityList.contains(ability))) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val defendAbilityList = mutableListOf<String>()
|
||||||
|
defendAbilityList.add("thief")
|
||||||
|
defendAbilityList.add("storm")
|
||||||
|
defendAbilityList.add("webber")
|
||||||
|
defendAbilityList.add("weakness")
|
||||||
|
defendAbilityList.add("potions")
|
||||||
|
defendAbilityList.add("archer")
|
||||||
|
defendAbilityList.add("quicksand")
|
||||||
|
defendAbilityList.add("bullwark")
|
||||||
|
defendAbilityList.add("rust")
|
||||||
|
defendAbilityList.add("ender")
|
||||||
|
defendAbilityList.add("vengeance")
|
||||||
|
defendAbilityList.add("mama")
|
||||||
|
defendAbilityList.add("firework")
|
||||||
|
defendAbilityList.add("morph")
|
||||||
|
return (!playerIsVictom) && (defendAbilityList.contains(ability))
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.koin
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import org.bukkit.plugin.Plugin
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
import org.koin.core.module.Module
|
||||||
|
import org.koin.dsl.binds
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
internal fun pluginModule(plugin: InfernalMobs): Module =
|
||||||
|
module {
|
||||||
|
single { plugin } binds arrayOf(InfernalMobs::class, JavaPlugin::class, Plugin::class)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal val integrationsModule =
|
||||||
|
module {
|
||||||
|
// single { HeadDatabaseAdapters.determineAdapter() }
|
||||||
|
// single { BukkitAudiences.create(get()) } withOptions {
|
||||||
|
// onClose { it?.close() }
|
||||||
|
// }
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.LocationUtils
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class BlockBreakListener(
|
||||||
|
private val plugin: InfernalMobs,
|
||||||
|
val configService: ConfigService
|
||||||
|
) : Listener {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onBlockBreak(e: BlockBreakEvent) {
|
||||||
|
if (e.block.type == Material.SPAWNER) {
|
||||||
|
val name: String = LocationUtils.getLocationName(e.block.location)
|
||||||
|
if (configService.mobSaveConfig.getString("infernalSpanwers.$name") != null) {
|
||||||
|
configService.mobSaveConfig.set("infernalSpanwers.$name", null)
|
||||||
|
configService.saveSave()
|
||||||
|
if (e.player.isOp) {
|
||||||
|
e.player.sendMessage("§cYou broke an infernal mob spawner!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import org.bukkit.entity.LivingEntity
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.world.ChunkLoadEvent
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class ChunkLoadListener(
|
||||||
|
private val plugin: InfernalMobs,
|
||||||
|
val configService: ConfigService,
|
||||||
|
val infernalMobService: InfernalMobService
|
||||||
|
) : Listener {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onChunkLoad(e: ChunkLoadEvent) {
|
||||||
|
for (ent in e.chunk.entities) {
|
||||||
|
if (((ent is LivingEntity)) && (ent.getCustomName() != null)
|
||||||
|
&& (configService.mobSaveConfig.getString(ent.getUniqueId().toString()) != null)
|
||||||
|
) {
|
||||||
|
infernalMobService.giveMobPowers(ent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.world.ChunkUnloadEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class ChunkUnloadListener(private val plugin: InfernalMobs, val infernalMobService: InfernalMobService) {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onChunkUnload(e: ChunkUnloadEvent) {
|
||||||
|
for (ent in e.chunk.entities) {
|
||||||
|
val s: Int = infernalMobService.idSearch(ent.uniqueId)
|
||||||
|
if (s != -1) {
|
||||||
|
infernalMobService.infernalList.remove(infernalMobService.infernalList[s])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,192 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.events.InfernalSpawnEvent
|
||||||
|
import io.github.thehrz.infernalmobs.gui.GUI
|
||||||
|
import io.github.thehrz.infernalmobs.handler.EffectHandle
|
||||||
|
import io.github.thehrz.infernalmobs.handler.InfernalMobHandler
|
||||||
|
import io.github.thehrz.infernalmobs.models.InfernalMob
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.BlockUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.EntityUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.LocationUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.MathUtils
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.ChatColor
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.entity.Ageable
|
||||||
|
import org.bukkit.entity.Entity
|
||||||
|
import org.bukkit.entity.EntityType
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.util.*
|
||||||
|
import java.util.logging.Level
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class CreatureSpawnEventListener(
|
||||||
|
val plugin: InfernalMobs,
|
||||||
|
private val configService: ConfigService,
|
||||||
|
private val infernalMobService: InfernalMobService,
|
||||||
|
val infernalMobHandler: InfernalMobHandler,
|
||||||
|
val effectHandle: EffectHandle,
|
||||||
|
val gui: GUI
|
||||||
|
) : Listener {
|
||||||
|
private val spawnerMap = HashMap<String, Long?>()
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onMobSpawn(event: CreatureSpawnEvent) {
|
||||||
|
val world = event.entity.world
|
||||||
|
if ((!event.entity.hasMetadata("NPC")) && (!event.entity.hasMetadata("shopkeeper")) && event.entity.customName == null) {
|
||||||
|
if (event.entity.type == EntityType.ENDER_DRAGON) plugin.logger
|
||||||
|
.log(Level.INFO, "Detected Entity Spawn: Ender Dragon")
|
||||||
|
if (event.spawnReason == CreatureSpawnEvent.SpawnReason.SPAWNER) {
|
||||||
|
val spawner = BlockUtils.blockNear(event.entity.location, Material.SPAWNER, 10)
|
||||||
|
if (spawner != null) {
|
||||||
|
val name: String = LocationUtils.getLocationName(spawner.location)
|
||||||
|
if (configService.mobSaveConfig.getString("infernalSpanwers.$name") != null) {
|
||||||
|
if (spawnerMap[name] == null) {
|
||||||
|
makeInfernal(event.entity, true)
|
||||||
|
spawnerMap[name] =
|
||||||
|
plugin.serverTime
|
||||||
|
} else {
|
||||||
|
val startTime = spawnerMap[name]!!
|
||||||
|
val endTime: Long = plugin.serverTime
|
||||||
|
val timePassed = endTime - startTime
|
||||||
|
val delay: Int = configService.mobSaveConfig.getInt(
|
||||||
|
"infernalSpanwers.$name"
|
||||||
|
)
|
||||||
|
if (timePassed >= delay) {
|
||||||
|
makeInfernal(event.entity, true)
|
||||||
|
spawnerMap[name] =
|
||||||
|
plugin.serverTime
|
||||||
|
} else {
|
||||||
|
event.isCancelled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} /*else if (!plugin.getConfig().getBoolean("enableFarmingDrops")) {
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//System.out.println("InfernalMob Spawn 2");
|
||||||
|
if ((event.entity.hasMetadata("NPC")) || (event.entity.hasMetadata("shopkeeper"))) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val entName = event.entity.type.name
|
||||||
|
if (((configService.mainConfig.mobWorlds
|
||||||
|
.contains(world.name)) || (configService.mainConfig.mobWorlds
|
||||||
|
.contains("<all>"))) &&
|
||||||
|
(configService.mainConfig.enabledMobs.contains(entName)) &&
|
||||||
|
(configService.mainConfig.naturalSpawnHeight < event.entity.location.y) &&
|
||||||
|
(configService.mainConfig.enabledSpawnReasons
|
||||||
|
.contains(event.spawnReason.toString()))
|
||||||
|
) {
|
||||||
|
makeInfernal(event.entity, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun makeInfernal(e: Entity, fixed: Boolean) {
|
||||||
|
val entName = e.type.name
|
||||||
|
if ((!e.hasMetadata("NPC")) && (!e.hasMetadata("shopkeeper"))) {
|
||||||
|
if (!fixed) {
|
||||||
|
val babyList = configService.mainConfig.disabledBabyMobs
|
||||||
|
if (e is Ageable) {
|
||||||
|
val baby = !e.isAdult
|
||||||
|
if (baby && babyList.contains(entName)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val id = e.uniqueId
|
||||||
|
val chance = configService.mainConfig.chance
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(plugin, {
|
||||||
|
val entName1 = e.type.name
|
||||||
|
if ((!e.isDead) && (e.isValid) && (((configService.mainConfig.enabledMobs
|
||||||
|
.contains(entName1))) || ((fixed) &&
|
||||||
|
(infernalMobService.idSearch(id) == -1)))
|
||||||
|
) {
|
||||||
|
//Default
|
||||||
|
val min = 1
|
||||||
|
var max = chance
|
||||||
|
//Pe InfernalMob
|
||||||
|
val mc = plugin.config.getInt("mobChances.$entName1")
|
||||||
|
if (mc > 0) max = mc
|
||||||
|
if (fixed) max = 1
|
||||||
|
//int randomNum = new Random().nextInt(max - min) + min;
|
||||||
|
val randomNum = MathUtils.rand(min, max)
|
||||||
|
if (randomNum == 1) {
|
||||||
|
val aList = infernalMobHandler.getAbilitiesAmount(e)
|
||||||
|
//todo: levelChance
|
||||||
|
// if (configService.getString("levelChance." + aList.size) != null) {
|
||||||
|
// val sc =
|
||||||
|
// config.getInt("levelChance." + aList.size)
|
||||||
|
// val randomNum2 = Random().nextInt(sc - min) + min
|
||||||
|
// if (randomNum2 != 1) {
|
||||||
|
// return@scheduleSyncDelayedTask
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
val newMob = if (aList.contains("oneup")) {
|
||||||
|
InfernalMob(e, id, true, aList, 2, infernalMobService.effect)
|
||||||
|
} else {
|
||||||
|
InfernalMob(e, id, true, aList, 1, infernalMobService.effect)
|
||||||
|
}
|
||||||
|
|
||||||
|
//fire event
|
||||||
|
val infernalEvent = InfernalSpawnEvent(e, newMob)
|
||||||
|
Bukkit.getPluginManager().callEvent(infernalEvent)
|
||||||
|
if (infernalEvent.isCancelled) {
|
||||||
|
return@scheduleSyncDelayedTask
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aList.contains("flying")) {
|
||||||
|
EntityUtils.makeFly(e)
|
||||||
|
}
|
||||||
|
infernalMobService.infernalList.add(newMob)
|
||||||
|
gui.setName(e)
|
||||||
|
infernalMobService.giveMobGear(e, true)
|
||||||
|
infernalMobService.addHealth(e, aList)
|
||||||
|
if (configService.mainConfig.enableSpawnMessages) {
|
||||||
|
val spawnMessageList = configService.messagesConfig.spawnMessages
|
||||||
|
val randomGenerator = Random()
|
||||||
|
val index = randomGenerator.nextInt(spawnMessageList.size)
|
||||||
|
var spawnMessage = spawnMessageList[index]
|
||||||
|
|
||||||
|
spawnMessage = ChatColor.translateAlternateColorCodes('&', spawnMessage)
|
||||||
|
spawnMessage = if (e.customName != null) {
|
||||||
|
spawnMessage.replace("mob", e.customName!!)
|
||||||
|
} else {
|
||||||
|
spawnMessage.replace("mob", e.type.toString().lowercase(Locale.getDefault()))
|
||||||
|
}
|
||||||
|
val r = configService.mainConfig.spawnMessageRadius
|
||||||
|
if (r == -1) {
|
||||||
|
for (p in e.world.players) {
|
||||||
|
p.sendMessage(spawnMessage)
|
||||||
|
}
|
||||||
|
} else if (r == -2) {
|
||||||
|
Bukkit.broadcastMessage(spawnMessage)
|
||||||
|
} else {
|
||||||
|
for (e1 in e.getNearbyEntities(
|
||||||
|
r.toDouble(),
|
||||||
|
r.toDouble(),
|
||||||
|
r.toDouble()
|
||||||
|
)) {
|
||||||
|
if ((e1 is Player)) {
|
||||||
|
e1.sendMessage(spawnMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 10L)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.handler.EffectHandle
|
||||||
|
import io.github.thehrz.infernalmobs.utils.MathUtils
|
||||||
|
import org.bukkit.entity.Ageable
|
||||||
|
import org.bukkit.entity.LivingEntity
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.entity.Sheep
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.entity.EntityBreedEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class EntityBreedListener(
|
||||||
|
val plugin: InfernalMobs,
|
||||||
|
val effectHandle: EffectHandle
|
||||||
|
) : Listener {
|
||||||
|
@EventHandler
|
||||||
|
fun onEntityBreed(e: EntityBreedEvent) {
|
||||||
|
if (e.breeder is Player) {
|
||||||
|
val p = e.breeder as Player?
|
||||||
|
if (effectHandle.fertileList.contains(p)) {
|
||||||
|
for (i in 0 until MathUtils.rand(1, 4)) {
|
||||||
|
val babe = e.entity.location.world.spawnEntity(e.entity.location, e.entityType) as LivingEntity
|
||||||
|
if (babe is Ageable) babe.setBaby()
|
||||||
|
if (e.entity is Sheep) (babe as Sheep).color = (e.entity as Sheep).color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.gui.GUI
|
||||||
|
import io.github.thehrz.infernalmobs.handler.EffectHandle
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import org.bukkit.entity.Arrow
|
||||||
|
import org.bukkit.entity.Entity
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.entity.Snowball
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.util.logging.Level
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class EntityDamageByEntityListener(
|
||||||
|
val effectHandle: EffectHandle,
|
||||||
|
val infernalMobService: InfernalMobService,
|
||||||
|
val gui: GUI,
|
||||||
|
val plugin: InfernalMobs
|
||||||
|
) {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onEntityAttack(event: EntityDamageByEntityEvent) {
|
||||||
|
try {
|
||||||
|
val attacker = event.damager
|
||||||
|
val victim = event.entity
|
||||||
|
val mob: Entity
|
||||||
|
if ((attacker is Arrow)) {
|
||||||
|
val arrow = event.damager as Arrow
|
||||||
|
if (((arrow.shooter is Player)) && (victim !is Player)) {
|
||||||
|
mob = victim
|
||||||
|
val player = arrow.shooter as Player
|
||||||
|
effectHandle.doEffect(player, mob, false)
|
||||||
|
} else if ((arrow.shooter !is Player) && ((victim is Player))) {
|
||||||
|
mob = arrow.shooter as Entity
|
||||||
|
effectHandle.doEffect(victim, mob, true)
|
||||||
|
}
|
||||||
|
} else if ((attacker is Snowball)) {
|
||||||
|
val snowBall = event.damager as Snowball
|
||||||
|
if (snowBall.shooter != null) {
|
||||||
|
if (((snowBall.shooter is Player)) && (victim !is Player)) {
|
||||||
|
mob = victim
|
||||||
|
val player = snowBall.shooter as Player
|
||||||
|
effectHandle.doEffect(player, mob, false)
|
||||||
|
} else if ((snowBall.shooter !is Player) && ((victim is Player))) {
|
||||||
|
mob = snowBall.shooter as Entity
|
||||||
|
effectHandle.doEffect(victim, mob, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (((attacker is Player)) && (victim !is Player)) {
|
||||||
|
mob = victim
|
||||||
|
effectHandle.doEffect(attacker, mob, false)
|
||||||
|
} else if ((attacker !is Player) && ((victim is Player))) {
|
||||||
|
mob = attacker
|
||||||
|
effectHandle.doEffect(victim, mob, true)
|
||||||
|
}
|
||||||
|
if (infernalMobService.idSearch(victim.uniqueId) != -1) {
|
||||||
|
for (entity in victim.getNearbyEntities(64.0, 64.0, 64.0)) {
|
||||||
|
if ((entity is Player)) {
|
||||||
|
gui.fixBar(entity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
plugin.logger.log(Level.SEVERE, e.message)
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.gui.GUI
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class EntityDamageListener(
|
||||||
|
val gui: GUI,
|
||||||
|
val infernalMobService: InfernalMobService
|
||||||
|
): Listener {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onEnitityDamaged(e: EntityDamageEvent) {
|
||||||
|
val mob = e.entity
|
||||||
|
if (infernalMobService.idSearch(mob.uniqueId) != -1) {
|
||||||
|
for (entity in mob.getNearbyEntities(64.0, 64.0, 64.0)) {
|
||||||
|
if ((entity is Player)) {
|
||||||
|
gui.fixBar(entity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.gui.GUI
|
||||||
|
import io.github.thehrz.infernalmobs.handler.GhostHandler
|
||||||
|
import io.github.thehrz.infernalmobs.handler.InfernalMobHandler
|
||||||
|
import io.github.thehrz.infernalmobs.handler.LootHandler
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import org.bukkit.*
|
||||||
|
import org.bukkit.entity.EntityType
|
||||||
|
import org.bukkit.entity.Item
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.entity.TNTPrimed
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class EntityDeathListener(
|
||||||
|
val plugin: InfernalMobs,
|
||||||
|
val configService: ConfigService,
|
||||||
|
val infernalMobService: InfernalMobService,
|
||||||
|
val ghostHandler: GhostHandler,
|
||||||
|
val lootHandler: LootHandler,
|
||||||
|
val infernalMobHandler: InfernalMobHandler,
|
||||||
|
val gui: GUI
|
||||||
|
) : Listener {
|
||||||
|
private val dropedLootList = mutableListOf<UUID>()
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onEntityDeath(event: EntityDeathEvent) {
|
||||||
|
val id = event.entity.uniqueId
|
||||||
|
val mobIndex = infernalMobService.idSearch(id)
|
||||||
|
if (mobIndex != -1) {
|
||||||
|
val aList = infernalMobService.findMobAbilities(id)
|
||||||
|
|
||||||
|
//ArrayList<String> aList;
|
||||||
|
if (aList.contains("explode")) {
|
||||||
|
val tnt = event.entity.world.spawnEntity(event.entity.location, EntityType.PRIMED_TNT) as TNTPrimed
|
||||||
|
tnt.fuseTicks = 1
|
||||||
|
}
|
||||||
|
var isGhost = false
|
||||||
|
if ((event.entity.equipment?.helmet?.itemMeta?.displayName ?: "") == "§fGhost Head") {
|
||||||
|
isGhost = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aList.contains("ghost")) {
|
||||||
|
ghostHandler.spawnGhost(event.entity.location)
|
||||||
|
}
|
||||||
|
val dropSpot: Location?
|
||||||
|
if (aList.contains("molten")) {
|
||||||
|
val lavaSpot = event.entity.location
|
||||||
|
dropSpot = lavaSpot
|
||||||
|
dropSpot.x -= 2.0
|
||||||
|
} else {
|
||||||
|
dropSpot = event.entity.location
|
||||||
|
}
|
||||||
|
if ((configService.mainConfig.enableDeathMessages) && ((event.entity.killer is Player)) && (!isGhost)
|
||||||
|
) {
|
||||||
|
val player = event.entity.killer
|
||||||
|
if (configService.messagesConfig.deathMessages.isNotEmpty()) {
|
||||||
|
val deathMessagesList = configService.messagesConfig.deathMessages
|
||||||
|
val randomGenerator = Random()
|
||||||
|
val index = randomGenerator.nextInt(deathMessagesList.size)
|
||||||
|
var deathMessage = deathMessagesList[index]
|
||||||
|
val tittle = gui.getMobNameTag(event.entity)
|
||||||
|
deathMessage = ChatColor.translateAlternateColorCodes('&', deathMessage)
|
||||||
|
deathMessage = deathMessage.replace("player", player!!.name)
|
||||||
|
deathMessage =
|
||||||
|
if (player.itemInHand.type != Material.AIR) {
|
||||||
|
deathMessage.replace("weapon", player.itemInHand.itemMeta.displayName)
|
||||||
|
} else {
|
||||||
|
deathMessage.replace("weapon", "fist")
|
||||||
|
}
|
||||||
|
deathMessage = if (event.entity.customName != null) {
|
||||||
|
deathMessage.replace("mob", event.entity.customName!!)
|
||||||
|
} else {
|
||||||
|
deathMessage.replace("mob", tittle)
|
||||||
|
}
|
||||||
|
Bukkit.broadcastMessage(deathMessage)
|
||||||
|
} else {
|
||||||
|
println("No valid death messages found!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((configService.mainConfig.enableDrops)
|
||||||
|
&&
|
||||||
|
((configService.mainConfig.enableFarmingDrops)
|
||||||
|
|| (event.entity.killer != null))
|
||||||
|
&&
|
||||||
|
((configService.mainConfig.enableFarmingDrops)
|
||||||
|
|| ((event.entity.killer is Player)))
|
||||||
|
) {
|
||||||
|
val player = event.entity.killer!!
|
||||||
|
|
||||||
|
if ((player.gameMode == GameMode.CREATIVE) && configService.mainConfig.noCreativeDrops) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val drop = lootHandler.getRandomLoot(player, event.entity.type.getName(), aList.size)
|
||||||
|
if (drop != null) {
|
||||||
|
val min = 1
|
||||||
|
val max: Int = configService.mainConfig.dropChance
|
||||||
|
val randomNum = Random().nextInt(max - min + 1) + min
|
||||||
|
if (randomNum == 1) {
|
||||||
|
val dropedItem = event.entity.world.dropItemNaturally(dropSpot, drop)
|
||||||
|
keepAlive(dropedItem)
|
||||||
|
}
|
||||||
|
val xpm: Int = configService.mainConfig.xpMultiplier
|
||||||
|
val xp = event.droppedExp * xpm
|
||||||
|
event.droppedExp = xp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
infernalMobHandler.removeMob(mobIndex)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Error: $e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun keepAlive(item: Item) {
|
||||||
|
val id = item.uniqueId
|
||||||
|
dropedLootList.add(id)
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(
|
||||||
|
plugin,
|
||||||
|
{ dropedLootList.remove(id) }, 300L
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.weather.LightningStrikeEvent
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class LightningStrikeListener(private val infernalMobService: InfernalMobService) : Listener {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onLightningStrike(e: LightningStrikeEvent) {
|
||||||
|
for (m in e.lightning.getNearbyEntities(6.0, 6.0, 6.0)) {
|
||||||
|
if (infernalMobService.idSearch(m.uniqueId) != -1) {
|
||||||
|
e.isCancelled = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.player.PlayerChangedWorldEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class PlayerChangedWorldLIstener(
|
||||||
|
val infernalMobService: InfernalMobService
|
||||||
|
) {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onPlayerChangedWorld(event: PlayerChangedWorldEvent) {
|
||||||
|
val world = event.player.world
|
||||||
|
infernalMobService.giveMobsPowers(world)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.commands.Command
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import org.bukkit.attribute.Attribute
|
||||||
|
import org.bukkit.entity.LivingEntity
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.player.PlayerInteractEntityEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class PlayerInteractEntityListener(
|
||||||
|
val configService: ConfigService,
|
||||||
|
val infernalMobService: InfernalMobService,
|
||||||
|
val command: Command
|
||||||
|
) : Listener {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onPlayerInteractEntity(e: PlayerInteractEntityEvent) {
|
||||||
|
val p = e.player
|
||||||
|
val ent = e.rightClicked
|
||||||
|
if (command.errorList.contains(p)) {
|
||||||
|
command.errorList.remove(p)
|
||||||
|
p.sendMessage("§6Error report:")
|
||||||
|
|
||||||
|
var name: String? = ""
|
||||||
|
try {
|
||||||
|
name = ent.customName
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
p.sendMessage("§eName: §f$name")
|
||||||
|
p.sendMessage("§eSaved: §f" + configService.mobSaveConfig.getString(ent.uniqueId.toString()))
|
||||||
|
p.sendMessage(
|
||||||
|
"§eHealth: §f" + (ent as LivingEntity).getAttribute(Attribute.GENERIC_MAX_HEALTH)!!
|
||||||
|
.value
|
||||||
|
)
|
||||||
|
p.sendMessage("§eInfernal: §f" + infernalMobService.idSearch(ent.getUniqueId()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.gui.GUI
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import io.github.thehrz.infernalmobs.utils.EntityUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.LocationUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.MathUtils
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.entity.Entity
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import kotlin.math.acos
|
||||||
|
import kotlin.math.atan2
|
||||||
|
import kotlin.math.cos
|
||||||
|
import kotlin.math.sin
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class PlayerInteractListener(val plugin: InfernalMobs, val infernalMobService: InfernalMobService) : Listener {
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onPlayerInteract(e: PlayerInteractEvent) {
|
||||||
|
val p = e.player
|
||||||
|
try {
|
||||||
|
val s: ItemStack = plugin.diviningStaff
|
||||||
|
if (p.inventory.itemInMainHand.itemMeta.displayName == s.itemMeta.displayName) {
|
||||||
|
val b = infernalMobService.getNearbyBoss(p)
|
||||||
|
//Make Look At
|
||||||
|
if (b != null) {
|
||||||
|
//Take Powder
|
||||||
|
var took = false
|
||||||
|
for (i in p.inventory) if (i != null && i.type == Material.BLAZE_POWDER) {
|
||||||
|
if (i.amount == 1) {
|
||||||
|
p.inventory.remove(i)
|
||||||
|
} else i.amount -= 1
|
||||||
|
took = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (!took) {
|
||||||
|
p.sendMessage("§cYou need blaze powder to use this!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//Change Looking
|
||||||
|
val source = b
|
||||||
|
val target: Entity = p
|
||||||
|
|
||||||
|
val direction = EntityUtils.getVector(target).subtract(EntityUtils.getVector(source)).normalize()
|
||||||
|
val x = direction.x
|
||||||
|
val y = direction.y
|
||||||
|
val z = direction.z
|
||||||
|
|
||||||
|
// Now change the angle
|
||||||
|
val changed = target.location.clone()
|
||||||
|
changed.yaw = 180 - MathUtils.toDegree(atan2(x, z))
|
||||||
|
changed.pitch = 90 - MathUtils.toDegree(acos(y))
|
||||||
|
target.teleport(changed)
|
||||||
|
//Beam
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(
|
||||||
|
plugin,
|
||||||
|
{ //Shoot Beam
|
||||||
|
val eyeLoc = p.eyeLocation
|
||||||
|
val px = eyeLoc.x
|
||||||
|
val py = eyeLoc.y
|
||||||
|
val pz = eyeLoc.z
|
||||||
|
val yaw = Math.toRadians((eyeLoc.yaw + 90).toDouble())
|
||||||
|
val pitch = Math.toRadians((eyeLoc.pitch + 90).toDouble())
|
||||||
|
val x = sin(pitch) * cos(yaw)
|
||||||
|
val y = sin(pitch) * sin(yaw)
|
||||||
|
val z = cos(pitch)
|
||||||
|
for (j in 1..10) {
|
||||||
|
for (i in 1..10) {
|
||||||
|
val loc = Location(p.world, px + (i * x), py + (i * z), pz + (i * y))
|
||||||
|
LocationUtils.beamParticles(loc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 5
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.handler.EffectHandle
|
||||||
|
import io.github.thehrz.infernalmobs.handler.LootHandler
|
||||||
|
import io.github.thehrz.infernalmobs.services.ConfigService
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.player.PlayerItemConsumeEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class PlayerItemConsumeListener(
|
||||||
|
val lootHandler: LootHandler,
|
||||||
|
val effectHandle: EffectHandle,
|
||||||
|
val configService: ConfigService
|
||||||
|
) : Listener {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onPlayerItemConsumeEvent(e: PlayerItemConsumeEvent) {
|
||||||
|
val p = e.player
|
||||||
|
val check = e.item
|
||||||
|
if (configService.lootConfig.getString("consumeEffects") != null) for (id in configService.lootConfig.getConfigurationSection("consumeEffects")!!
|
||||||
|
.getKeys(false)) if (configService.lootConfig.getString("consumeEffects.$id.requiredItem") != null) {
|
||||||
|
val neededItem = lootHandler.getItem(
|
||||||
|
configService.lootConfig.getInt(
|
||||||
|
"consumeEffects.$id.requiredItem"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if (neededItem != null && (neededItem.itemMeta != null) && (check.itemMeta.displayName == neededItem.itemMeta.displayName)) if (check.type == neededItem.type)
|
||||||
|
effectHandle.applyEatEffects(p, id.toInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class PlayerQuitListener() : Listener {
|
||||||
|
var levitateList = mutableListOf<Player>()
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onPlayerQuit(e: PlayerQuitEvent) {
|
||||||
|
val p = e.player
|
||||||
|
if (levitateList.contains(p)) {
|
||||||
|
p.allowFlight = false
|
||||||
|
levitateList.remove(p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.listeners
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.services.InfernalMobService
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class PlayerTeleportListener(val infernalMobService: InfernalMobService): Listener {
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onPlayerTeleport(event: PlayerTeleportEvent) {
|
||||||
|
val world = event.player.world
|
||||||
|
infernalMobService.giveMobsPowers(world)
|
||||||
|
}
|
||||||
|
}
|
17
src/main/kotlin/io/github/thehrz/infernalmobs/models/InfernalMob.kt
Executable file
17
src/main/kotlin/io/github/thehrz/infernalmobs/models/InfernalMob.kt
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.models
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class InfernalMob(
|
||||||
|
var entity: Entity,
|
||||||
|
var id: UUID,
|
||||||
|
private val infernal: Boolean,
|
||||||
|
var abilityList: List<String>,
|
||||||
|
var lives: Int,
|
||||||
|
var effect: String
|
||||||
|
) {
|
||||||
|
override fun toString(): String {
|
||||||
|
return "Name: " + entity.type.name + " Infernal: " + this.infernal + "Abilities:" + this.abilityList
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.models
|
||||||
|
|
||||||
|
import org.bukkit.enchantments.Enchantment
|
||||||
|
|
||||||
|
internal class LevelledEnchantment(var getEnchantment: Enchantment?, var getLevel: Int)
|
@ -0,0 +1,191 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.services
|
||||||
|
|
||||||
|
import de.exlll.configlib.ConfigLib
|
||||||
|
import de.exlll.configlib.NameFormatters
|
||||||
|
import de.exlll.configlib.YamlConfigurationProperties
|
||||||
|
import de.exlll.configlib.YamlConfigurations
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.config.MainConfig
|
||||||
|
import io.github.thehrz.infernalmobs.config.MessagesConfig
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.block.Banner
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration
|
||||||
|
import org.bukkit.enchantments.Enchantment
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.*
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.io.File
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class ConfigService(private val plugin: InfernalMobs) {
|
||||||
|
private val properties: YamlConfigurationProperties = ConfigLib.BUKKIT_DEFAULT_PROPERTIES.toBuilder()
|
||||||
|
.setNameFormatter(NameFormatters.IDENTITY)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
private val mobSaveYML = File(plugin.dataFolder, "save.yml")
|
||||||
|
private val lootYML = File(plugin.dataFolder, "loot.yml")
|
||||||
|
|
||||||
|
lateinit var mainConfig: MainConfig
|
||||||
|
lateinit var messagesConfig: MessagesConfig
|
||||||
|
lateinit var mobSaveConfig: YamlConfiguration
|
||||||
|
lateinit var lootConfig: YamlConfiguration
|
||||||
|
|
||||||
|
fun loadConfigs() {
|
||||||
|
val configFile = File(plugin.dataFolder, "config.yml").toPath()
|
||||||
|
|
||||||
|
mainConfig = YamlConfigurations.update(
|
||||||
|
configFile,
|
||||||
|
MainConfig::class.java,
|
||||||
|
properties
|
||||||
|
)
|
||||||
|
|
||||||
|
val messagesFile = File(plugin.dataFolder, "messages.yml").toPath()
|
||||||
|
messagesConfig = YamlConfigurations.update(
|
||||||
|
messagesFile,
|
||||||
|
MessagesConfig::class.java,
|
||||||
|
properties
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!mobSaveYML.exists()) {
|
||||||
|
plugin.saveResource("save.yml", false);
|
||||||
|
}
|
||||||
|
mobSaveConfig = YamlConfiguration.loadConfiguration(mobSaveYML)
|
||||||
|
|
||||||
|
if (!lootYML.exists()) {
|
||||||
|
plugin.saveResource("loot.yml", false);
|
||||||
|
}
|
||||||
|
lootConfig = YamlConfiguration.loadConfiguration(lootYML)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saveLoot() {
|
||||||
|
lootConfig.save(lootYML)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun saveSave() {
|
||||||
|
mobSaveConfig.save(mobSaveYML)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setItem(s: ItemStack?, path: String, fc: FileConfiguration) {
|
||||||
|
if (s != null) {
|
||||||
|
fc["$path.item"] = s.type.toString()
|
||||||
|
fc["$path.amount"] = s.amount
|
||||||
|
fc["$path.durability"] = (s as Damageable).damage
|
||||||
|
if (s.itemMeta != null) {
|
||||||
|
fc["$path.name"] = s.itemMeta.displayName
|
||||||
|
if (s.itemMeta.lore != null) {
|
||||||
|
for (l in s.itemMeta.lore!!.indices) {
|
||||||
|
if (s.itemMeta.lore!![l] != null) {
|
||||||
|
fc["$path.lore$l"] = s.itemMeta.lore!![l]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var e: Enchantment
|
||||||
|
for ((key, level) in s.enchantments) {
|
||||||
|
e = key
|
||||||
|
for (ei in 0..12) {
|
||||||
|
if (fc.getString("$path.enchantments.$ei") == null) {
|
||||||
|
fc["$path.enchantments.$ei.enchantment"] = e.key
|
||||||
|
fc["$path.enchantments.$ei.level"] = level
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (s.type == Material.ENCHANTED_BOOK) {
|
||||||
|
val em = s.itemMeta as EnchantmentStorageMeta
|
||||||
|
for (hm in em.storedEnchants.entries) {
|
||||||
|
e = (hm as Map.Entry<*, *>).key as Enchantment
|
||||||
|
val level = (hm as Map.Entry<*, *>).value as Int
|
||||||
|
for (ei in 0..12) {
|
||||||
|
if (fc.getString("$path.enchantments.$ei") == null) {
|
||||||
|
fc["$path.enchantments.$ei.enchantment"] = e.toString()
|
||||||
|
fc["$path.enchantments.$ei.level"] = level
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((s.type == Material.WRITTEN_BOOK) || (s.type == Material.WRITABLE_BOOK)) {
|
||||||
|
val meta = s.itemMeta as BookMeta
|
||||||
|
if (meta.author != null) {
|
||||||
|
fc["$path.author"] = meta.author
|
||||||
|
}
|
||||||
|
if (meta.title != null) {
|
||||||
|
fc["$path.title"] = meta.title
|
||||||
|
}
|
||||||
|
var i = 0
|
||||||
|
for (p in meta.pages) {
|
||||||
|
fc["$path.pages.$i"] = p
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Banner
|
||||||
|
if (s.type.toString().contains("BANNER")) {
|
||||||
|
val b = s.itemMeta as BannerMeta
|
||||||
|
if (b != null) {
|
||||||
|
val patList: List<*> = b.patterns
|
||||||
|
if (!patList.isEmpty()) fc["$path.patterns"] = patList
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Shield
|
||||||
|
if (s.type == Material.SHIELD) {
|
||||||
|
val im = s.itemMeta
|
||||||
|
val bmeta = im as BlockStateMeta
|
||||||
|
val b = bmeta.blockState as Banner
|
||||||
|
|
||||||
|
fc["$path.colour"] = b.baseColor.toString()
|
||||||
|
val patList: List<*> = b.patterns
|
||||||
|
if (!patList.isEmpty()) fc["$path.patterns"] = patList
|
||||||
|
}
|
||||||
|
//Potions
|
||||||
|
if (s.type == Material.POTION || s.type == Material.SPLASH_POTION || s.type == Material.LINGERING_POTION) {
|
||||||
|
val pMeta = s.itemMeta as PotionMeta
|
||||||
|
val pd = pMeta.basePotionData
|
||||||
|
fc["$path.potion"] = pd.type.effectType!!.name
|
||||||
|
}
|
||||||
|
if ((s.type == Material.LEATHER_BOOTS) || (s.type == Material.LEATHER_CHESTPLATE) || (s.type == Material.LEATHER_HELMET) || (s.type == Material.LEATHER_LEGGINGS)) {
|
||||||
|
val l = s.itemMeta as LeatherArmorMeta
|
||||||
|
val c = l.color
|
||||||
|
val color = c.red.toString() + "," + c.green + "," + c.blue
|
||||||
|
fc["$path.colour"] = color
|
||||||
|
}
|
||||||
|
if (s.type == Material.PLAYER_HEAD) {
|
||||||
|
val sm = s.itemMeta as SkullMeta
|
||||||
|
fc["$path.owner"] = sm.owningPlayer!!.uniqueId.toString()
|
||||||
|
}
|
||||||
|
val flags = ArrayList<String>()
|
||||||
|
for (f in s.itemMeta.itemFlags) if (f != null) flags.add(f.name)
|
||||||
|
if (flags.isNotEmpty()) fc["$path.flags"] = flags
|
||||||
|
} else {
|
||||||
|
println("Item is null!")
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
lootConfig.save(this.lootYML)
|
||||||
|
} catch (ignored: IOException) {
|
||||||
|
}
|
||||||
|
// plugin.saveConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun reloadLoot() {
|
||||||
|
val configFile = File(plugin.dataFolder, "config.yml").toPath()
|
||||||
|
|
||||||
|
mainConfig = YamlConfigurations.load(
|
||||||
|
configFile,
|
||||||
|
MainConfig::class.java,
|
||||||
|
properties
|
||||||
|
)
|
||||||
|
|
||||||
|
val messagesFile = File(plugin.dataFolder, "messages.yml").toPath()
|
||||||
|
messagesConfig = YamlConfigurations.load(
|
||||||
|
messagesFile,
|
||||||
|
MessagesConfig::class.java,
|
||||||
|
properties
|
||||||
|
)
|
||||||
|
|
||||||
|
mobSaveConfig = YamlConfiguration.loadConfiguration(mobSaveYML)
|
||||||
|
|
||||||
|
lootConfig = YamlConfiguration.loadConfiguration(lootYML)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,306 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.services
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import io.github.thehrz.infernalmobs.models.InfernalMob
|
||||||
|
import io.github.thehrz.infernalmobs.config.MainConfig
|
||||||
|
import io.github.thehrz.infernalmobs.utils.EntityUtils
|
||||||
|
import io.github.thehrz.infernalmobs.utils.MathUtils
|
||||||
|
import org.bukkit.DyeColor
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.World
|
||||||
|
import org.bukkit.attribute.Attribute
|
||||||
|
import org.bukkit.enchantments.Enchantment
|
||||||
|
import org.bukkit.entity.*
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
@Single
|
||||||
|
class InfernalMobService(private val configService: ConfigService, val plugin: InfernalMobs) {
|
||||||
|
var infernalList = mutableListOf<InfernalMob>()
|
||||||
|
val mountList = mutableMapOf<Entity, Entity>()
|
||||||
|
|
||||||
|
val effect: String
|
||||||
|
get() {
|
||||||
|
var effect = "mobSpawnerFire"
|
||||||
|
try {
|
||||||
|
//Get Enabled Particles
|
||||||
|
val partTypes = configService.mainConfig.mobParticles
|
||||||
|
//Get Random Particle
|
||||||
|
effect = partTypes[Random().nextInt(partTypes.size)]
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("Error: $e")
|
||||||
|
}
|
||||||
|
return effect
|
||||||
|
}
|
||||||
|
|
||||||
|
fun idSearch(id: UUID): Int {
|
||||||
|
var idMob: InfernalMob? = null
|
||||||
|
for (mob in this.infernalList) {
|
||||||
|
if (mob.id == id) {
|
||||||
|
idMob = mob
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (idMob != null) {
|
||||||
|
return infernalList.indexOf(idMob)
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun giveMobsPowers(world: World) {
|
||||||
|
for (ent in world.entities) {
|
||||||
|
if (((ent is LivingEntity)) && (configService.mobSaveConfig.getString(ent.getUniqueId().toString()) != null)) {
|
||||||
|
giveMobPowers(ent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun giveMobPowers(ent: Entity) {
|
||||||
|
val id = ent.uniqueId
|
||||||
|
if (idSearch(id) == -1) {
|
||||||
|
val metadata = ent.getMetadata("infernalMetadata")
|
||||||
|
if (metadata.isNotEmpty()) {
|
||||||
|
val aList = metadata.first().asString().split(",").filter { it.isNotEmpty() }
|
||||||
|
|
||||||
|
val newMob = if (aList.contains("oneup")) {
|
||||||
|
InfernalMob(ent, id, true, aList, 2, effect)
|
||||||
|
} else {
|
||||||
|
InfernalMob(ent, id, true, aList, 1, effect)
|
||||||
|
}
|
||||||
|
if (aList.contains("flying")) {
|
||||||
|
EntityUtils.makeFly(ent)
|
||||||
|
}
|
||||||
|
infernalList.add(newMob)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun findMobAbilities(id: UUID): List<String> {
|
||||||
|
for (mob in this.infernalList) {
|
||||||
|
if (mob.id == id) {
|
||||||
|
return mob.abilityList
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getNearbyBoss(p: Player): Entity? {
|
||||||
|
val dis = 26.0
|
||||||
|
for (m in infernalList) {
|
||||||
|
if (m.entity.world == p.world) {
|
||||||
|
val boss = m.entity
|
||||||
|
if (p.location.distance(boss.location) < dis) {
|
||||||
|
// dis = p.location.distance(boss.location)
|
||||||
|
return boss
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun reloadPowers() {
|
||||||
|
val wList = mutableListOf<World>()
|
||||||
|
for (p in plugin.server.onlinePlayers) {
|
||||||
|
if (!wList.contains(p.world)) {
|
||||||
|
wList.add(p.world)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (world in wList) {
|
||||||
|
giveMobsPowers(world)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addHealth(ent: Entity, powerList: List<String?>) {
|
||||||
|
//double maxHealth = ((org.bukkit.entity.Damageable) ent).getHealth();
|
||||||
|
val maxHealth = (ent as LivingEntity).getAttribute(Attribute.GENERIC_MAX_HEALTH)!!
|
||||||
|
.baseValue
|
||||||
|
var setHealth: Float
|
||||||
|
if (configService.mainConfig.healthByPower) {
|
||||||
|
val mobIndex = idSearch(ent.getUniqueId())
|
||||||
|
try {
|
||||||
|
val m = infernalList[mobIndex]
|
||||||
|
setHealth = (maxHealth * m.abilityList.size).toFloat()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
setHealth = (maxHealth * 5.0).toFloat()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (configService.mainConfig.healthByDistance) {
|
||||||
|
val l = ent.getWorld().spawnLocation
|
||||||
|
var m = l.distance(ent.getLocation()).toInt() / configService.mainConfig.addDistance
|
||||||
|
if (m < 1) {
|
||||||
|
m = 1
|
||||||
|
}
|
||||||
|
val add = configService.mainConfig.healthToAdd
|
||||||
|
setHealth = (m * add).toFloat()
|
||||||
|
} else {
|
||||||
|
val healthMultiplier = configService.mainConfig.healthMultiplier
|
||||||
|
setHealth = (maxHealth * healthMultiplier).toFloat()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (setHealth >= 1.0f) {
|
||||||
|
try {
|
||||||
|
ent.getAttribute(Attribute.GENERIC_MAX_HEALTH)!!.baseValue =
|
||||||
|
setHealth.toDouble()
|
||||||
|
ent.health = setHealth.toDouble()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("addHealth: $e")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val list = getPowerString(ent, powerList)
|
||||||
|
ent.setMetadata("infernalMetadata", FixedMetadataValue(plugin, list))
|
||||||
|
try {
|
||||||
|
configService.mobSaveConfig[ent.getUniqueId().toString()] = list
|
||||||
|
configService.saveSave()
|
||||||
|
} catch (ignored: IOException) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getPowerString(ent: Entity, powerList: List<String?>): String {
|
||||||
|
val list = StringBuilder()
|
||||||
|
for (s in powerList) {
|
||||||
|
if (powerList.indexOf(s) != powerList.size - 1) {
|
||||||
|
list.append(s).append(",")
|
||||||
|
} else {
|
||||||
|
list.append(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun giveMobGear(mob: Entity, naturalSpawn: Boolean) {
|
||||||
|
val mobId = mob.uniqueId
|
||||||
|
var mobAbilityList: List<String?>? = null
|
||||||
|
var armoured = false
|
||||||
|
if (idSearch(mobId) != -1) {
|
||||||
|
mobAbilityList = findMobAbilities(mobId)
|
||||||
|
if (mobAbilityList!!.contains("armoured")) {
|
||||||
|
armoured = true
|
||||||
|
(mob as LivingEntity).canPickupItems = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val helm = ItemStack(Material.DIAMOND_HELMET, 1)
|
||||||
|
val chest = ItemStack(Material.DIAMOND_CHESTPLATE, 1)
|
||||||
|
val pants = ItemStack(Material.DIAMOND_LEGGINGS, 1)
|
||||||
|
val boots = ItemStack(Material.DIAMOND_BOOTS, 1)
|
||||||
|
val sword = ItemStack(Material.DIAMOND_SWORD, 1)
|
||||||
|
sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 4)
|
||||||
|
val ee = (mob as LivingEntity).equipment
|
||||||
|
if (mob.getType() == EntityType.WITHER_SKELETON) {
|
||||||
|
if (armoured) {
|
||||||
|
ee!!.helmetDropChance = 0.0f
|
||||||
|
ee.chestplateDropChance = 0.0f
|
||||||
|
ee.leggingsDropChance = 0.0f
|
||||||
|
ee.bootsDropChance = 0.0f
|
||||||
|
ee.itemInMainHandDropChance = 0.0f
|
||||||
|
ee.helmet = helm
|
||||||
|
ee.chestplate = chest
|
||||||
|
ee.leggings = pants
|
||||||
|
ee.boots = boots
|
||||||
|
ee.setItemInMainHand(sword)
|
||||||
|
}
|
||||||
|
} else if (mob.getType() == EntityType.SKELETON) {
|
||||||
|
val bow = ItemStack(Material.BOW, 1)
|
||||||
|
ee!!.setItemInMainHand(bow)
|
||||||
|
if (armoured) {
|
||||||
|
ee.helmetDropChance = 0.0f
|
||||||
|
ee.chestplateDropChance = 0.0f
|
||||||
|
ee.helmet = helm
|
||||||
|
ee.chestplate = chest
|
||||||
|
if (!mobAbilityList!!.contains("cloaked")) {
|
||||||
|
ee.leggingsDropChance = 0.0f
|
||||||
|
ee.bootsDropChance = 0.0f
|
||||||
|
ee.leggings = pants
|
||||||
|
ee.boots = boots
|
||||||
|
}
|
||||||
|
ee.itemInMainHandDropChance = 0.0f
|
||||||
|
ee.setItemInMainHand(sword)
|
||||||
|
} else if (mobAbilityList!!.contains("cloaked")) {
|
||||||
|
val skull = ItemStack(Material.GLASS_BOTTLE, 1)
|
||||||
|
ee.helmet = skull
|
||||||
|
}
|
||||||
|
} else if (mob is Zombie) {
|
||||||
|
if (armoured) {
|
||||||
|
ee!!.helmetDropChance = 0.0f
|
||||||
|
ee.chestplateDropChance = 0.0f
|
||||||
|
ee.helmet = helm
|
||||||
|
ee.chestplate = chest
|
||||||
|
if (!mobAbilityList!!.contains("cloaked")) {
|
||||||
|
ee.leggings = pants
|
||||||
|
ee.boots = boots
|
||||||
|
}
|
||||||
|
ee.leggingsDropChance = 0.0f
|
||||||
|
ee.bootsDropChance = 0.0f
|
||||||
|
ee.itemInMainHandDropChance = 0.0f
|
||||||
|
ee.setItemInMainHand(sword)
|
||||||
|
} else if (mobAbilityList!!.contains("cloaked")) {
|
||||||
|
val skull = ItemStack(Material.GLASS_BOTTLE)
|
||||||
|
//skull.setDurability((short) 2);
|
||||||
|
ee!!.helmet = skull
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (((mobAbilityList!!.contains("mounted")) && (configService.mainConfig.enabledRiders
|
||||||
|
.contains(mob.getType().name))) || ((!naturalSpawn) && (mobAbilityList.contains("mounted")))
|
||||||
|
) {
|
||||||
|
val mounts = configService.mainConfig.enabledMounts
|
||||||
|
|
||||||
|
val randomGenerator = Random()
|
||||||
|
val index = randomGenerator.nextInt(mounts.size)
|
||||||
|
var mount = mounts[index]
|
||||||
|
//Type
|
||||||
|
var type: String? = null
|
||||||
|
if (mount.contains(":")) {
|
||||||
|
val s = mount.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
|
mount = s[0]
|
||||||
|
type = s[1]
|
||||||
|
}
|
||||||
|
if (EntityType.fromName(mount) != null && (EntityType.fromName(mount) != EntityType.ENDER_DRAGON)) {
|
||||||
|
val liveMount = mob.getWorld().spawnEntity(
|
||||||
|
mob.getLocation(),
|
||||||
|
EntityType.fromName(mount)!!
|
||||||
|
)
|
||||||
|
|
||||||
|
mountList[liveMount] = mob
|
||||||
|
liveMount.addPassenger(mob)
|
||||||
|
if (liveMount.type == EntityType.HORSE) {
|
||||||
|
val hm = liveMount as Horse
|
||||||
|
if (configService.mainConfig.horseMountsHaveSaddles) {
|
||||||
|
val saddle = ItemStack(Material.SADDLE)
|
||||||
|
hm.inventory.saddle = saddle
|
||||||
|
}
|
||||||
|
hm.isTamed = true
|
||||||
|
val randomNum3 = MathUtils.rand(1, 7)
|
||||||
|
if (randomNum3 == 1) {
|
||||||
|
hm.color = Horse.Color.BLACK
|
||||||
|
} else if (randomNum3 == 2) {
|
||||||
|
hm.color = Horse.Color.BROWN
|
||||||
|
} else if (randomNum3 == 3) {
|
||||||
|
hm.color = Horse.Color.CHESTNUT
|
||||||
|
} else if (randomNum3 == 4) {
|
||||||
|
hm.color = Horse.Color.CREAMY
|
||||||
|
} else if (randomNum3 == 5) {
|
||||||
|
hm.color = Horse.Color.DARK_BROWN
|
||||||
|
} else if (randomNum3 == 6) {
|
||||||
|
hm.color = Horse.Color.GRAY
|
||||||
|
} else {
|
||||||
|
hm.color = Horse.Color.WHITE
|
||||||
|
}
|
||||||
|
if ((armoured) && (configService.mainConfig.armouredMountsHaveArmour)) {
|
||||||
|
val armour = ItemStack(Material.DIAMOND_HORSE_ARMOR, 1)
|
||||||
|
hm.inventory.armor = armour
|
||||||
|
}
|
||||||
|
} else if (liveMount.type == EntityType.SHEEP) {
|
||||||
|
val sh = liveMount as Sheep
|
||||||
|
if (type != null) {
|
||||||
|
sh.color = DyeColor.valueOf(type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println("Can't spawn mount!")
|
||||||
|
println("$mount is not a valid Entity!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
50
src/main/kotlin/io/github/thehrz/infernalmobs/tasks/ArrowHomingTask.kt
Executable file
50
src/main/kotlin/io/github/thehrz/infernalmobs/tasks/ArrowHomingTask.kt
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.tasks
|
||||||
|
|
||||||
|
import org.bukkit.entity.Arrow
|
||||||
|
import org.bukkit.entity.LivingEntity
|
||||||
|
import org.bukkit.plugin.Plugin
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable
|
||||||
|
import org.bukkit.util.Vector
|
||||||
|
|
||||||
|
internal class ArrowHomingTask(
|
||||||
|
private val arrow: Arrow,
|
||||||
|
private val target: LivingEntity,
|
||||||
|
plugin: Plugin
|
||||||
|
) : BukkitRunnable() {
|
||||||
|
init {
|
||||||
|
runTaskTimer(plugin, 1L, 1L)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun run() {
|
||||||
|
try {
|
||||||
|
val speed = arrow.velocity.length()
|
||||||
|
if ((arrow.isOnGround) || (arrow.isDead) || (target.isDead)) {
|
||||||
|
cancel()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val toTarget = target.location.clone().add(Vector(0.0, 0.5, 0.0)).subtract(
|
||||||
|
arrow.location
|
||||||
|
).toVector()
|
||||||
|
|
||||||
|
val dirVelocity = arrow.velocity.clone().normalize()
|
||||||
|
val dirToTarget = toTarget.clone().normalize()
|
||||||
|
val angle = dirVelocity.angle(dirToTarget).toDouble()
|
||||||
|
|
||||||
|
val newSpeed = 0.9 * speed + 0.14
|
||||||
|
|
||||||
|
val newVelocity: Vector
|
||||||
|
if (angle < 0.12) {
|
||||||
|
newVelocity = dirVelocity.clone().multiply(newSpeed)
|
||||||
|
} else {
|
||||||
|
val newDir =
|
||||||
|
dirVelocity.clone().multiply((angle - 0.12) / angle).add(dirToTarget.clone().multiply(0.12 / angle))
|
||||||
|
newDir.normalize()
|
||||||
|
newVelocity = newDir.clone().multiply(newSpeed)
|
||||||
|
}
|
||||||
|
|
||||||
|
arrow.velocity = newVelocity.add(Vector(0.0, 0.03, 0.0))
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.utils
|
||||||
|
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.block.Block
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.math.cos
|
||||||
|
import kotlin.math.sin
|
||||||
|
|
||||||
|
object BlockUtils {
|
||||||
|
fun blockNear(l: Location, mat: Material, radius: Int): Block? {
|
||||||
|
val xTmp = l.x
|
||||||
|
val yTmp = l.y
|
||||||
|
val zTmp = l.z
|
||||||
|
val finalX = Math.round(xTmp).toInt()
|
||||||
|
val finalY = Math.round(yTmp).toInt()
|
||||||
|
val finalZ = Math.round(zTmp).toInt()
|
||||||
|
for (x in finalX - radius..(finalX + radius)) {
|
||||||
|
for (y in finalY - radius..(finalY + radius)) {
|
||||||
|
for (z in finalZ - radius..(finalZ + radius)) {
|
||||||
|
val loc = Location(l.world, x.toDouble(), y.toDouble(), z.toDouble())
|
||||||
|
val block = loc.block
|
||||||
|
if (block.type == mat) {
|
||||||
|
return block
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSphere(block1: Block): List<Block> {
|
||||||
|
val blocks = LinkedList<Block>()
|
||||||
|
val xi = block1.location.x + 0.5
|
||||||
|
val yi = block1.location.y + 0.5
|
||||||
|
val zi = block1.location.z + 0.5
|
||||||
|
for (v1 in 0..90) {
|
||||||
|
val y = sin(0.017453292519943295 * v1) * 4
|
||||||
|
var r = cos(0.017453292519943295 * v1) * 4
|
||||||
|
if (v1 == 90) {
|
||||||
|
r = 0.0
|
||||||
|
}
|
||||||
|
for (v2 in 0..90) {
|
||||||
|
val x = sin(0.017453292519943295 * v2) * r
|
||||||
|
var z = cos(0.017453292519943295 * v2) * r
|
||||||
|
if (v2 == 90) {
|
||||||
|
z = 0.0
|
||||||
|
}
|
||||||
|
if (!blocks.contains(
|
||||||
|
block1.world.getBlockAt(
|
||||||
|
(xi + x).toInt(),
|
||||||
|
(yi + y).toInt(),
|
||||||
|
(zi + z).toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
blocks.add(block1.world.getBlockAt((xi + x).toInt(), (yi + y).toInt(), (zi + z).toInt()))
|
||||||
|
}
|
||||||
|
if (!blocks.contains(
|
||||||
|
block1.world.getBlockAt(
|
||||||
|
(xi - x).toInt(),
|
||||||
|
(yi + y).toInt(),
|
||||||
|
(zi + z).toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
blocks.add(block1.world.getBlockAt((xi - x).toInt(), (yi + y).toInt(), (zi + z).toInt()))
|
||||||
|
}
|
||||||
|
if (!blocks.contains(
|
||||||
|
block1.world.getBlockAt(
|
||||||
|
(xi + x).toInt(),
|
||||||
|
(yi - y).toInt(),
|
||||||
|
(zi + z).toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
blocks.add(block1.world.getBlockAt((xi + x).toInt(), (yi - y).toInt(), (zi + z).toInt()))
|
||||||
|
}
|
||||||
|
if (!blocks.contains(
|
||||||
|
block1.world.getBlockAt(
|
||||||
|
(xi + x).toInt(),
|
||||||
|
(yi + y).toInt(),
|
||||||
|
(zi - z).toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
blocks.add(block1.world.getBlockAt((xi + x).toInt(), (yi + y).toInt(), (zi - z).toInt()))
|
||||||
|
}
|
||||||
|
if (!blocks.contains(
|
||||||
|
block1.world.getBlockAt(
|
||||||
|
(xi - x).toInt(),
|
||||||
|
(yi - y).toInt(),
|
||||||
|
(zi - z).toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
blocks.add(block1.world.getBlockAt((xi - x).toInt(), (yi - y).toInt(), (zi - z).toInt()))
|
||||||
|
}
|
||||||
|
if (!blocks.contains(
|
||||||
|
block1.world.getBlockAt(
|
||||||
|
(xi + x).toInt(),
|
||||||
|
(yi - y).toInt(),
|
||||||
|
(zi - z).toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
blocks.add(block1.world.getBlockAt((xi + x).toInt(), (yi - y).toInt(), (zi - z).toInt()))
|
||||||
|
}
|
||||||
|
if (!blocks.contains(
|
||||||
|
block1.world.getBlockAt(
|
||||||
|
(xi - x).toInt(),
|
||||||
|
(yi + y).toInt(),
|
||||||
|
(zi - z).toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
blocks.add(block1.world.getBlockAt((xi - x).toInt(), (yi + y).toInt(), (zi - z).toInt()))
|
||||||
|
}
|
||||||
|
if (!blocks.contains(
|
||||||
|
block1.world.getBlockAt(
|
||||||
|
(xi - x).toInt(),
|
||||||
|
(yi - y).toInt(),
|
||||||
|
(zi + z).toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
blocks.add(block1.world.getBlockAt((xi - x).toInt(), (yi - y).toInt(), (zi + z).toInt()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return blocks
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.utils
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.Color
|
||||||
|
import org.bukkit.FireworkEffect
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.entity.*
|
||||||
|
import org.bukkit.potion.PotionEffect
|
||||||
|
import org.bukkit.potion.PotionEffectType
|
||||||
|
import org.bukkit.util.Vector
|
||||||
|
|
||||||
|
object EntityUtils {
|
||||||
|
fun getVector(entity: Entity): Vector {
|
||||||
|
return if (entity is Player) entity.eyeLocation.toVector()
|
||||||
|
else entity.location.toVector()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun makeFly(ent: Entity) {
|
||||||
|
val bat = ent.world.spawnEntity(ent.location, EntityType.BAT)
|
||||||
|
bat.velocity = Vector(0, 1, 0)
|
||||||
|
bat.addPassenger(ent)
|
||||||
|
(bat as LivingEntity).addPotionEffect(PotionEffect(PotionEffectType.INVISIBILITY, 999999, 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isBaby(mob: Entity?): Boolean {
|
||||||
|
if (mob is Ageable) {
|
||||||
|
return !mob.isAdult
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isSmall(mob: Entity?): Boolean {
|
||||||
|
return (isBaby(mob)) && (mob!!.type == EntityType.BAT) && (mob.type == EntityType.CAVE_SPIDER) && (mob.type == EntityType.CHICKEN) && (mob.type == EntityType.COW) && (mob.type == EntityType.MUSHROOM_COW) && (mob.type == EntityType.PIG) && (mob.type == EntityType.OCELOT) && (mob.type == EntityType.SHEEP) && (mob.type == EntityType.SILVERFISH) && (mob.type == EntityType.SPIDER) && (mob.type == EntityType.WOLF)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun levitate(e: Entity, time: Int) {
|
||||||
|
if ((e is LivingEntity)) {
|
||||||
|
e.addPotionEffect(PotionEffect(PotionEffectType.LEVITATION, time * 20, 0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun launchFirework(l: Location, c: Color, speed: Int) {
|
||||||
|
val fw = l.world.spawn(l, Firework::class.java)
|
||||||
|
val meta = fw.fireworkMeta
|
||||||
|
meta.addEffect(FireworkEffect.builder().withColor(c).with(FireworkEffect.Type.BALL_LARGE).build())
|
||||||
|
fw.fireworkMeta = meta
|
||||||
|
fw.velocity = l.direction.multiply(speed)
|
||||||
|
detonate(fw)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun moveToward(e: Entity, to: Location, speed: Double) {
|
||||||
|
if (e.isDead) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val direction = to.toVector().subtract(e.location.toVector()).normalize()
|
||||||
|
e.velocity = direction.multiply(speed)
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(InfernalMobs.instance, {
|
||||||
|
moveToward(e, to, speed)
|
||||||
|
}, 1L)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun detonate(fw: Firework) {
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(InfernalMobs.instance, {
|
||||||
|
fw.detonate()
|
||||||
|
}, 2L)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.utils
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor
|
||||||
|
import org.bukkit.Color
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.block.Banner
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration
|
||||||
|
import org.bukkit.enchantments.Enchantment
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
import org.bukkit.inventory.meta.*
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object ItemUtils {
|
||||||
|
fun getItem(mat: Material, name: String?, amount: Int, loreList: List<String>?): ItemStack {
|
||||||
|
val item = ItemStack(mat, amount)
|
||||||
|
val m = item.itemMeta
|
||||||
|
if (name != null) m.setDisplayName(name)
|
||||||
|
if (loreList != null) m.lore = loreList
|
||||||
|
item.setItemMeta(m)
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
fun dye(item: ItemStack, color: Color) {
|
||||||
|
val meta = item.itemMeta as LeatherArmorMeta
|
||||||
|
meta.setColor(color)
|
||||||
|
item.setItemMeta(meta)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isArmor(s: ItemStack): Boolean {
|
||||||
|
val t = s.type.toString().lowercase(Locale.getDefault())
|
||||||
|
return t.contains("helm") || t.contains("plate") || t.contains("leg") || t.contains("boot")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun prosessLootName(name: String, stack: ItemStack): String {
|
||||||
|
var name = name
|
||||||
|
name = ChatColor.translateAlternateColorCodes('&', name)
|
||||||
|
var itemName = stack.type.name
|
||||||
|
itemName = itemName.replace("_", " ")
|
||||||
|
itemName = itemName.lowercase(Locale.getDefault())
|
||||||
|
name = name.replace("<itemName>", itemName)
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getMaterial(s: String?): Material {
|
||||||
|
return Material.valueOf(s!!)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.utils
|
||||||
|
|
||||||
|
import io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.Particle
|
||||||
|
|
||||||
|
object LocationUtils {
|
||||||
|
fun beamParticles(loc: Location) {
|
||||||
|
val speed = -1
|
||||||
|
val amount = 1
|
||||||
|
val r = 0.0
|
||||||
|
ParticleUtils.displayParticle(
|
||||||
|
Particle.DRIP_LAVA.toString(),
|
||||||
|
loc.world,
|
||||||
|
loc.x,
|
||||||
|
loc.y,
|
||||||
|
loc.z,
|
||||||
|
r,
|
||||||
|
speed,
|
||||||
|
amount
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getLocationName(l: Location): String {
|
||||||
|
return (l.x.toString() + "." + l.y + "." + l.z + l.world.name).replace(".", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getArea(l: Location, r: Double, t: Double): MutableList<Location> {
|
||||||
|
val ll = mutableListOf<Location>()
|
||||||
|
var x = l.x - r
|
||||||
|
while (x < l.x + r) {
|
||||||
|
var y = l.y - r
|
||||||
|
while (y < l.y + r) {
|
||||||
|
var z = l.z - r
|
||||||
|
while (z < l.z + r) {
|
||||||
|
ll.add(Location(l.world, x, y, z))
|
||||||
|
z += t
|
||||||
|
}
|
||||||
|
y += t
|
||||||
|
}
|
||||||
|
x += t
|
||||||
|
}
|
||||||
|
return ll
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setAir(block: Location, time: Int) {
|
||||||
|
Bukkit.getServer().scheduler.scheduleSyncDelayedTask(
|
||||||
|
InfernalMobs.instance,
|
||||||
|
{
|
||||||
|
if (block.block.type == Material.COBWEB) {
|
||||||
|
block.block.type = Material.AIR
|
||||||
|
}
|
||||||
|
}, (time * 20).toLong()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.utils
|
||||||
|
|
||||||
|
object MathUtils {
|
||||||
|
fun toDegree(angle: Double): Float {
|
||||||
|
return Math.toDegrees(angle).toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun rand(min: Int, max: Int): Int {
|
||||||
|
return min + (Math.random() * (1 + max - min)).toInt()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.utils
|
||||||
|
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.Particle
|
||||||
|
import org.bukkit.World
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object ParticleUtils {
|
||||||
|
fun displayParticle(
|
||||||
|
effect: String?,
|
||||||
|
w: World,
|
||||||
|
x: Double,
|
||||||
|
y: Double,
|
||||||
|
z: Double,
|
||||||
|
radius: Double,
|
||||||
|
speed: Int,
|
||||||
|
amount: Int
|
||||||
|
) {
|
||||||
|
var amount = amount
|
||||||
|
amount = if ((amount <= 0)) 1 else amount
|
||||||
|
val l = Location(w, x, y, z)
|
||||||
|
try {
|
||||||
|
if (radius <= 0) {
|
||||||
|
w.spawnParticle(Particle.valueOf(effect!!), l, 0, 0.0, 0.0, speed.toDouble(), amount.toDouble())
|
||||||
|
} else {
|
||||||
|
val ll = LocationUtils.getArea(l, radius, 0.2)
|
||||||
|
if (ll.size > 0) {
|
||||||
|
for (i in 0 until amount) {
|
||||||
|
val index = Random().nextInt(ll.size)
|
||||||
|
w.spawnParticle(Particle.valueOf(effect!!), ll[index]!!, 1, 0.0, 0.0, 0.0, 0.0)
|
||||||
|
ll.removeAt(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
// System.out.println("V: " + getServer().getVersion());
|
||||||
|
// ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun displayParticle(effect: String, l: Location, radius: Double, speed: Int, amount: Int) {
|
||||||
|
displayParticle(effect, l.world, l.x, l.y, l.z, radius, speed, amount)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.utils
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.util.BlockIterator
|
||||||
|
|
||||||
|
object PlayerUtils {
|
||||||
|
fun getTarget(player: Player): Entity? {
|
||||||
|
val iterator = BlockIterator(
|
||||||
|
player.world, player
|
||||||
|
.location.toVector(), player.eyeLocation
|
||||||
|
.direction, 0.0, 100
|
||||||
|
)
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
val item = iterator.next()
|
||||||
|
for (entity in player.getNearbyEntities(100.0, 100.0, 100.0)) {
|
||||||
|
val acc = 2
|
||||||
|
for (x in -acc until acc) for (z in -acc until acc) for (y in -acc until acc) if (entity.location.block
|
||||||
|
.getRelative(x, y, z) == item
|
||||||
|
) {
|
||||||
|
return entity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package io.github.thehrz.infernalmobs.utils
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object StringUtils {
|
||||||
|
|
||||||
|
fun generateString(maxNames: Int, names: List<String?>): String {
|
||||||
|
var maxNames = maxNames
|
||||||
|
val namesString = StringBuilder()
|
||||||
|
if (maxNames > names.size) {
|
||||||
|
maxNames = names.size
|
||||||
|
}
|
||||||
|
for (i in 0 until maxNames) {
|
||||||
|
namesString.append(names[i]).append(" ")
|
||||||
|
}
|
||||||
|
if (names.size > maxNames) {
|
||||||
|
namesString.append("... ")
|
||||||
|
}
|
||||||
|
return namesString.toString()
|
||||||
|
}
|
||||||
|
fun getIntFromString(setAmountString: String): Int {
|
||||||
|
var setAmount = 1
|
||||||
|
try {
|
||||||
|
if (setAmountString.contains("-")) {
|
||||||
|
val split = setAmountString.split("-".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
|
try {
|
||||||
|
val minSetAmount = split[0].toInt()
|
||||||
|
val maxSetAmount = split[1].toInt()
|
||||||
|
setAmount = Random().nextInt(maxSetAmount - minSetAmount + 1) + minSetAmount
|
||||||
|
} catch (e: Exception) {
|
||||||
|
println("getIntFromString: $e")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setAmount = setAmountString.toInt()
|
||||||
|
}
|
||||||
|
} catch (x: Exception) {
|
||||||
|
}
|
||||||
|
return setAmount
|
||||||
|
}
|
||||||
|
}
|
209
src/main/resources/config.yml
Executable file
209
src/main/resources/config.yml
Executable file
@ -0,0 +1,209 @@
|
|||||||
|
chance: 20
|
||||||
|
mobChances: {}
|
||||||
|
levelChance: {}
|
||||||
|
namePrefix: '精英'
|
||||||
|
nameTagsLevel: {}
|
||||||
|
nameTags:
|
||||||
|
level: 2
|
||||||
|
name: '&d<prefix> &7Lv.&a<mobLevel> &f<mobName>'
|
||||||
|
bossBarSettings:
|
||||||
|
enable: true
|
||||||
|
name: '&d<prefix> &7Lv.&a<mobLevel> &f<mobName>'
|
||||||
|
color: PINK
|
||||||
|
style: SOLID
|
||||||
|
scoreBoard:
|
||||||
|
enable: false
|
||||||
|
showHealth: true
|
||||||
|
effectAllPlayerAttacks: true
|
||||||
|
enableParticles: true
|
||||||
|
enableDeathMessages: false
|
||||||
|
enableSpawnMessages: false
|
||||||
|
spawnMessageRadius: 64
|
||||||
|
noCreativeDrops: false
|
||||||
|
mobWorlds:
|
||||||
|
- <all>
|
||||||
|
effectWorlds:
|
||||||
|
- <all>
|
||||||
|
enabledMobs:
|
||||||
|
- ELDER_GUARDIAN
|
||||||
|
- STRAY
|
||||||
|
- HUSK
|
||||||
|
- ZOMBIE_VILLAGER
|
||||||
|
- SKELETON_HORSE
|
||||||
|
- ZOMBIE_HORSE
|
||||||
|
- EVOKER
|
||||||
|
- VEX
|
||||||
|
- VINDICATOR
|
||||||
|
- CREEPER
|
||||||
|
- SKELETON
|
||||||
|
- SPIDER
|
||||||
|
- GIANT
|
||||||
|
- ZOMBIE
|
||||||
|
- SLIME
|
||||||
|
- GHAST
|
||||||
|
- CAVE_SPIDER
|
||||||
|
- SILVERFISH
|
||||||
|
- BLAZE
|
||||||
|
- MAGMA_CUBE
|
||||||
|
- ENDER_DRAGON
|
||||||
|
- WITHER
|
||||||
|
- BAT
|
||||||
|
- WITCH
|
||||||
|
- ENDERMITE
|
||||||
|
- GUARDIAN
|
||||||
|
- SHULKER
|
||||||
|
- ILLUSIONER
|
||||||
|
- PARROT
|
||||||
|
- POLAR_BEAR
|
||||||
|
- LLAMA
|
||||||
|
- DROWNED
|
||||||
|
- PHANTOM
|
||||||
|
- PUFFERFISH
|
||||||
|
- BEE
|
||||||
|
- PIGLIN
|
||||||
|
- HOGLIN
|
||||||
|
- ZOGLIN
|
||||||
|
- STRIDER
|
||||||
|
enabledCharmSlots:
|
||||||
|
- 0
|
||||||
|
- 1
|
||||||
|
- 2
|
||||||
|
- 3
|
||||||
|
- 4
|
||||||
|
- 5
|
||||||
|
- 6
|
||||||
|
- 7
|
||||||
|
- 8
|
||||||
|
- 40
|
||||||
|
- 36
|
||||||
|
- 37
|
||||||
|
- 38
|
||||||
|
- 39
|
||||||
|
enabledAbilities:
|
||||||
|
- poisonous
|
||||||
|
- armoured
|
||||||
|
- blinding
|
||||||
|
- withering
|
||||||
|
- tosser
|
||||||
|
- thief
|
||||||
|
- quicksand
|
||||||
|
- bullwark
|
||||||
|
- rust
|
||||||
|
- sapper
|
||||||
|
- oneup
|
||||||
|
- cloaked
|
||||||
|
- ender
|
||||||
|
- ghastly
|
||||||
|
- lifesteal
|
||||||
|
- sprint
|
||||||
|
- storm
|
||||||
|
- webber
|
||||||
|
- vengeance
|
||||||
|
- weakness
|
||||||
|
- berserk
|
||||||
|
- explode
|
||||||
|
- potions
|
||||||
|
- mama
|
||||||
|
- molten
|
||||||
|
- archer
|
||||||
|
- necromancer
|
||||||
|
- firework
|
||||||
|
- gravity
|
||||||
|
- flying
|
||||||
|
- mounted
|
||||||
|
- morph
|
||||||
|
- ghost
|
||||||
|
- confusing
|
||||||
|
mamaSpawnAmount: 3
|
||||||
|
vengeanceDamage: 6
|
||||||
|
berserkDamage: 3
|
||||||
|
moltenBurnLength: 5
|
||||||
|
gravityLevitateLength: 6
|
||||||
|
horseMountsHaveSaddles: true
|
||||||
|
armouredMountsHaveArmour: true
|
||||||
|
fireworkColour:
|
||||||
|
red: 255
|
||||||
|
green: 10
|
||||||
|
blue: 10
|
||||||
|
enabledSpawnReasons:
|
||||||
|
- BREEDING
|
||||||
|
- BUILD_WITHER
|
||||||
|
- CHUNK_GEN
|
||||||
|
- CUSTOM
|
||||||
|
- DEFAULT
|
||||||
|
- INFECTION
|
||||||
|
- SPAWNER_EGG
|
||||||
|
- LIGHTNING
|
||||||
|
- NATURAL
|
||||||
|
- NETHER_PORTAL
|
||||||
|
- OCELOT_BABY
|
||||||
|
- REINFORCEMENTS
|
||||||
|
- SILVERFISH_BLOCK
|
||||||
|
- SLIME_SPLIT
|
||||||
|
- VILLAGE_INVASION
|
||||||
|
mobParticles:
|
||||||
|
- lavaSpark:1:10
|
||||||
|
mountFate: nothing
|
||||||
|
enabledMounts:
|
||||||
|
- SPIDER
|
||||||
|
- SKELETON_HORSE
|
||||||
|
- ZOMBIE_HORSE
|
||||||
|
- DONKEY
|
||||||
|
- MULE
|
||||||
|
- SLIME
|
||||||
|
- GHAST
|
||||||
|
- MAGMA_CUBE
|
||||||
|
- ENDER_DRAGON
|
||||||
|
- BAT
|
||||||
|
- PIG
|
||||||
|
- SHEEP
|
||||||
|
- COW
|
||||||
|
- CHICKEN
|
||||||
|
- MUSHROOM_COW
|
||||||
|
- HORSE
|
||||||
|
- POLAR_BEAR
|
||||||
|
- LLAMA
|
||||||
|
- PHANTOM
|
||||||
|
- HOGLIN
|
||||||
|
- ZOGLIN
|
||||||
|
- STRIDER
|
||||||
|
enabledRiders:
|
||||||
|
- STRAY
|
||||||
|
- HUSK
|
||||||
|
- ZOMBIE_VILLAGER
|
||||||
|
- EVOKER
|
||||||
|
- VINDICATOR
|
||||||
|
- SKELETON
|
||||||
|
- ZOMBIE
|
||||||
|
- WITCH
|
||||||
|
- SNOWMAN
|
||||||
|
- VILLAGER
|
||||||
|
- ILLUSIONER
|
||||||
|
- DROWNED
|
||||||
|
- ZOMBIFIED_PIGLIN
|
||||||
|
- PIGLIN
|
||||||
|
disabledBabyMobs:
|
||||||
|
- WOLF
|
||||||
|
- MUSHROOM_COW
|
||||||
|
- COW
|
||||||
|
- SHEEP
|
||||||
|
- PIG
|
||||||
|
- CHICKEN
|
||||||
|
- OCELOT
|
||||||
|
- HORSE
|
||||||
|
minpowers: 3
|
||||||
|
maxpowers: 7
|
||||||
|
healthMultiplier: 4
|
||||||
|
healthByPower: false
|
||||||
|
healthByDistance: false
|
||||||
|
powerByDistance: false
|
||||||
|
healthToAdd: 5
|
||||||
|
powerToAdd: 1
|
||||||
|
xpMultiplier: 8
|
||||||
|
addDistance: 200
|
||||||
|
enableDrops: true
|
||||||
|
dropChance: 1
|
||||||
|
enableFarmingDrops: false
|
||||||
|
naturalSpawnHeight: 0
|
||||||
|
debug: false
|
||||||
|
items: []
|
3
src/main/resources/loot.yml
Executable file
3
src/main/resources/loot.yml
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
potionEffects: []
|
||||||
|
consumeEffects: []
|
||||||
|
loot: []
|
13
src/main/resources/messages.yml
Normal file
13
src/main/resources/messages.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
deathMessages:
|
||||||
|
- '&cplayer &chas killed an mob&c!'
|
||||||
|
- '&cAn mob &cwas slain by player&c!'
|
||||||
|
- '&cplayer &cowned an mob&c!'
|
||||||
|
- '&cAn mob &cwas beheaded by player&c''s weapon!'
|
||||||
|
- '&cplayer&c''s weapon &ckilled an mob&c!'
|
||||||
|
- '&cAn mob &cwas killed by player &cusing a weapon&c!'
|
||||||
|
spawnMessages:
|
||||||
|
- '&cAn Infernal mob has spawned near you!'
|
||||||
|
- '&cWatch out!'
|
||||||
|
- '&cYou hear a faint scream...'
|
||||||
|
- '&cSomething is coming...'
|
||||||
|
- '&cYou hear a mob nearby...'
|
14
src/main/resources/plugin.yml
Executable file
14
src/main/resources/plugin.yml
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
name: InfernalMobs
|
||||||
|
main: io.github.thehrz.infernalmobs.InfernalMobs
|
||||||
|
version: ${version}
|
||||||
|
softdepend: [ Vault ]
|
||||||
|
api-version: 1.13
|
||||||
|
authors: ["Eliminator", "thehrz"]
|
||||||
|
|
||||||
|
commands:
|
||||||
|
infernalmobs:
|
||||||
|
aliases: [ im ]
|
||||||
|
description: This is the infernal mobs base commands.
|
||||||
|
usage: /<command>
|
||||||
|
permission: infernal_mobs.commands
|
||||||
|
permission-message: You don't have <permission>
|
2
src/main/resources/save.yml
Executable file
2
src/main/resources/save.yml
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
kickQueue:
|
||||||
|
- "236246246-2462462-26264246"
|
Loading…
x
Reference in New Issue
Block a user