Final version of plugin
commit
e8a52f074a
@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
|
||||
id 'com.github.johnrengelman.shadow' version '4.0.4'
|
||||
}
|
||||
|
||||
group 'pw.hamzantal'
|
||||
version '1.0'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven { url "https://hub.spigotmc.org/nexus/content/groups/public" }
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url "http://repo.md-5.net/content/groups/public/" }
|
||||
maven { url "http://repo.dmulloy2.net/nexus/repository/public/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
implementation "com.github.hazae41:mc-kutils:master-SNAPSHOT"
|
||||
compileOnly files("libs/craftbukkit-1.12.2.jar")
|
||||
compileOnly "LibsDisguises:LibsDisguises:9.9.8"
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
baseName = "BloodMoon"
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
@ -0,0 +1 @@
|
||||
kotlin.code.style=official
|
@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
rootProject.name = 'BloodMoon'
|
||||
|
@ -0,0 +1,67 @@
|
||||
package pw.hamzantal.bloodmoon
|
||||
|
||||
import hazae41.minecraft.kutils.bukkit.msg
|
||||
import hazae41.minecraft.kutils.bukkit.schedule
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType
|
||||
import me.libraryaddict.disguise.disguisetypes.MobDisguise
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.entity.*
|
||||
|
||||
object BMData {
|
||||
var running = false
|
||||
|
||||
var bm = BloodMoon.pl
|
||||
val transformed = hashMapOf<MobDisguise, LivingEntity>()
|
||||
val creepers = mutableListOf<Creeper>()
|
||||
|
||||
fun ticksLeft(): Int {
|
||||
return (23460 - Config.world.time).toInt()
|
||||
}
|
||||
|
||||
fun begin() {
|
||||
stop()
|
||||
println(Config.enabledMobs)
|
||||
Config.world.entities.forEach { en ->
|
||||
if (!Config.enabledMobs.contains(en.type.toString().toUpperCase())) {
|
||||
return@forEach
|
||||
}
|
||||
en.remove()
|
||||
val blood = en.world.spawnEntity(en.location, EntityType.ZOMBIE).apply {
|
||||
(this as Zombie).isBaby = true
|
||||
customName = "§cBlood ${en.name}"
|
||||
isCustomNameVisible = true
|
||||
}
|
||||
val disguise = MobDisguise(DisguiseType.valueOf(en.type.name))
|
||||
disguise.entity = blood
|
||||
disguise.startDisguise()
|
||||
transformed[disguise] = en as LivingEntity
|
||||
}
|
||||
if (Config.chargedCreepers) Config.world.entities.filter { it is Creeper }.forEach {
|
||||
(it as Creeper).isPowered = true
|
||||
creepers += it
|
||||
}
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach { it.msg(Config.startMessage.c) }
|
||||
running = true
|
||||
bm.schedule(delay = ticksLeft() / 20L) {
|
||||
stop()
|
||||
Bukkit.getOnlinePlayers().forEach { it.msg(Config.endMessage.c) }
|
||||
}
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
println("stopping...")
|
||||
running = false
|
||||
transformed.forEach { (d, e) ->
|
||||
d.entity.remove()
|
||||
d.stopDisguise()
|
||||
d.entity.world.spawnEntity(d.entity.location, e.type).apply {
|
||||
(this as LivingEntity).health = e.health
|
||||
if (this is Sheep) color = (e as Sheep).color
|
||||
}
|
||||
}
|
||||
transformed.clear()
|
||||
creepers.forEach { it.isPowered = false }
|
||||
creepers.clear()
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package pw.hamzantal.bloodmoon
|
||||
|
||||
import hazae41.minecraft.kutils.bukkit.command
|
||||
import hazae41.minecraft.kutils.bukkit.listen
|
||||
import hazae41.minecraft.kutils.bukkit.msg
|
||||
import hazae41.minecraft.kutils.bukkit.schedule
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.entity.*
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
import pw.hamzantal.bloodmoon.listeners.*
|
||||
import kotlin.random.Random
|
||||
|
||||
class BloodMoon : JavaPlugin(), Listener {
|
||||
companion object {
|
||||
lateinit var pl: BloodMoon
|
||||
}
|
||||
|
||||
override fun onEnable() {
|
||||
pl = this
|
||||
saveDefaultConfig()
|
||||
|
||||
initListeners()
|
||||
|
||||
schedule(async = false, period = 1, delay = 1) {
|
||||
if (Bukkit.getWorlds().first().fullTime - 13000 in 0..20) {
|
||||
val chance = Random.nextDouble()
|
||||
if (!BMData.running && chance < Config.chance) BMData.begin()
|
||||
else Bukkit.getOnlinePlayers().filter { it.isOp }.forEach {
|
||||
it.msg("&c[!] &7Blood Moon chance did not meet threshold: ${String.format("%.02f", chance)} (must be between 0 and ${Config.chance}) ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
command("bloodmoon") { sender, _ ->
|
||||
if (BMData.running) sender.msg("&c&lThe Blood Moon is Active!\n&7${BMData.ticksLeft() / 20} seconds left.")
|
||||
else sender.msg("&a&lThe Blood Moon is not currently active.")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDisable() {
|
||||
BMData.stop()
|
||||
}
|
||||
|
||||
private fun initListeners() {
|
||||
listen<EntityDamageByEntityEvent> { zombieHit(it) }
|
||||
listen<EntityDamageEvent> { onFallDmg(it) }
|
||||
listen<ProjectileLaunchEvent> { onSkellyShoot(it) }
|
||||
listen<CreatureSpawnEvent> { onCreatureSpawn(it) }
|
||||
listen<EntityDeathEvent> { onDeath(it) }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package pw.hamzantal.bloodmoon
|
||||
|
||||
import hazae41.minecraft.kutils.bukkit.ConfigFile
|
||||
import hazae41.minecraft.kutils.get
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.ChatColor
|
||||
|
||||
object Config : ConfigFile(BloodMoon.pl.dataFolder["config.yml"]) {
|
||||
private val _world by string("world", "world")
|
||||
val world get() = Bukkit.getWorld(_world)
|
||||
val chance by double("chance", 0.2)
|
||||
|
||||
val enabledMobs by stringList("transformed_mobs")
|
||||
val zombieSwarm by boolean("zombieSwarm", true)
|
||||
val chargedCreepers by boolean("chargedCreepers", true)
|
||||
val strongSpiders by boolean("strongSpiders", true)
|
||||
|
||||
val startMessage by string("startMessage", "&c&lThe blood moon has now started".c)
|
||||
val endMessage by string("endMessage", "&cThe blood moon is now over".c)
|
||||
}
|
||||
|
||||
val String.c get() = ChatColor.translateAlternateColorCodes('&', this)
|
@ -0,0 +1,15 @@
|
||||
package pw.hamzantal.bloodmoon.listeners
|
||||
|
||||
import org.bukkit.event.entity.EntityDeathEvent
|
||||
import pw.hamzantal.bloodmoon.BMData
|
||||
|
||||
fun onDeath(e: EntityDeathEvent) {
|
||||
if (BMData.creepers.contains(e.entity)) {
|
||||
BMData.creepers.remove(e.entity)
|
||||
return
|
||||
}
|
||||
|
||||
val d = BMData.transformed.keys.firstOrNull { it.entity == e.entity } ?: return
|
||||
d.stopDisguise()
|
||||
BMData.transformed.remove(d)
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package pw.hamzantal.bloodmoon.listeners
|
||||
|
||||
import hazae41.minecraft.kutils.bukkit.msg
|
||||
import org.bukkit.block.Sign
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.entity.EntityDamageEvent
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause.FALL
|
||||
import pw.hamzantal.bloodmoon.specialattacks.dunking
|
||||
|
||||
fun onFallDmg(e: EntityDamageEvent) {
|
||||
if (!dunking.containsKey(e.entity) || e.cause != FALL) return
|
||||
if (e.entity !is Player) return
|
||||
|
||||
val p = e.entity as Player
|
||||
val attacker = dunking[p]!!
|
||||
|
||||
dunking.remove(p)
|
||||
|
||||
p.world.createExplosion(p.location, 2F, false)
|
||||
attacker.isInvulnerable = false
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package pw.hamzantal.bloodmoon.listeners
|
||||
|
||||
import hazae41.minecraft.kutils.bukkit.schedule
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.entity.Zombie
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||
import pw.hamzantal.bloodmoon.BMData
|
||||
import pw.hamzantal.bloodmoon.BloodMoon
|
||||
import pw.hamzantal.bloodmoon.specialattacks.dunking
|
||||
import pw.hamzantal.bloodmoon.specialattacks.zombieAttacks
|
||||
|
||||
val cooldown = mutableListOf<Player>()
|
||||
|
||||
fun zombieHit(e: EntityDamageByEntityEvent) {
|
||||
if (!BMData.running || e.damager !is Zombie || e.entity !is Player
|
||||
|| BMData.transformed.any { (d, _) -> d.entity == e.damager }
|
||||
) return
|
||||
|
||||
|
||||
val p = e.entity as Player
|
||||
if (e.damager in dunking || p in dunking) {
|
||||
e.isCancelled = true
|
||||
return
|
||||
}
|
||||
|
||||
if (p in cooldown) return
|
||||
cooldown += p
|
||||
|
||||
zombieAttacks.random().spawnAttack(e.damager as Zombie, p, BloodMoon.pl)
|
||||
BloodMoon.pl.schedule(delay = 4) {
|
||||
cooldown -= p
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package pw.hamzantal.bloodmoon.listeners
|
||||
|
||||
import hazae41.minecraft.kutils.bukkit.schedule
|
||||
import org.bukkit.entity.Arrow
|
||||
import org.bukkit.entity.Skeleton
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent
|
||||
import pw.hamzantal.bloodmoon.BMData
|
||||
import pw.hamzantal.bloodmoon.BloodMoon
|
||||
|
||||
val recent = mutableListOf<Skeleton>()
|
||||
|
||||
fun onSkellyShoot(e: ProjectileLaunchEvent) {
|
||||
val sh = e.entity.shooter
|
||||
if (!BMData.running || BMData.transformed.any { (d, _) -> d.entity == sh }) return
|
||||
if (sh !is Skeleton || sh in recent) return
|
||||
|
||||
var count = 5
|
||||
var taskID = 0
|
||||
|
||||
recent += sh as Skeleton
|
||||
var pl = BloodMoon.pl
|
||||
taskID = pl.server.scheduler.scheduleSyncRepeatingTask(pl, {
|
||||
sh.launchProjectile(Arrow::class.java).apply arrow@{
|
||||
pl.schedule(delay = 2) {
|
||||
this@arrow.remove()
|
||||
}
|
||||
}
|
||||
if (--count == 0) {
|
||||
recent -= sh as Skeleton
|
||||
pl.server.scheduler.cancelTask(taskID)
|
||||
}
|
||||
}, 7, 7)
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package pw.hamzantal.bloodmoon.listeners
|
||||
|
||||
import org.bukkit.entity.Creeper
|
||||
import org.bukkit.entity.EntityType
|
||||
import org.bukkit.entity.Spider
|
||||
import org.bukkit.entity.Zombie
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent
|
||||
import org.bukkit.potion.PotionEffect
|
||||
import org.bukkit.potion.PotionEffectType
|
||||
import pw.hamzantal.bloodmoon.BMData
|
||||
import pw.hamzantal.bloodmoon.Config
|
||||
import kotlin.random.Random
|
||||
|
||||
val surrounding = listOf(
|
||||
0.0 to -1.0,
|
||||
0.0 to 1.0,
|
||||
1.0 to -1.0,
|
||||
1.0 to 0.0,
|
||||
1.0 to 1.0,
|
||||
-1.0 to -1.0,
|
||||
-1.0 to -0.0,
|
||||
-1.0 to 1.0
|
||||
)
|
||||
|
||||
fun onCreatureSpawn(e: CreatureSpawnEvent) {
|
||||
if (!BMData.running || e.spawnReason != CreatureSpawnEvent.SpawnReason.NATURAL) return
|
||||
|
||||
val loc = e.entity.location
|
||||
if (loc.world != Config.world || Random.nextDouble() > 0.9) return
|
||||
|
||||
when (val en = e.entity) {
|
||||
is Zombie -> if (Config.zombieSwarm) surrounding.forEach {
|
||||
val (x, z) = it
|
||||
Config.world.spawnEntity(loc.clone().add(x, 0.0, z), EntityType.ZOMBIE)
|
||||
}
|
||||
is Creeper -> if (Config.chargedCreepers) en.isPowered = true
|
||||
is Spider -> {
|
||||
if (!Config.strongSpiders) return
|
||||
en.addPotionEffect(PotionEffect(PotionEffectType.SPEED, BMData.ticksLeft(), 3, true, true))
|
||||
en.addPotionEffect(PotionEffect(PotionEffectType.INCREASE_DAMAGE, BMData.ticksLeft(), 1, true, true))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package pw.hamzantal.bloodmoon.specialattacks
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.entity.TippedArrow
|
||||
import org.bukkit.entity.Zombie
|
||||
import org.bukkit.potion.PotionEffect
|
||||
import org.bukkit.potion.PotionEffectType
|
||||
import org.bukkit.util.Vector
|
||||
import pw.hamzantal.bloodmoon.BloodMoon
|
||||
|
||||
class ArrowBarrage : SpecialAttack<Zombie> {
|
||||
override fun spawnAttack(attacker: Zombie, p: Player, pl: BloodMoon) {
|
||||
pl.server.scheduler.scheduleSyncDelayedTask(pl, {
|
||||
val loc = attacker.location
|
||||
val direction = loc.direction
|
||||
val baseSpawnLocation = loc.add(direction.clone().multiply(7)).apply { y -= 1 }
|
||||
val vector = direction.clone().multiply(Vector(-1.0, 0.1, -1.0))
|
||||
|
||||
p.world.spawnArrow(baseSpawnLocation, vector, 1f, 0f, TippedArrow::class.java).apply {
|
||||
addCustomEffect(PotionEffect(PotionEffectType.BLINDNESS, 60, 2), true)
|
||||
addCustomEffect(PotionEffect(PotionEffectType.SLOW, 80, 1), true)
|
||||
addCustomEffect(PotionEffect(PotionEffectType.HEAL, 5, 1), true)
|
||||
knockbackStrength = 2
|
||||
}
|
||||
}, 8)
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package pw.hamzantal.bloodmoon.specialattacks
|
||||
|
||||
import hazae41.minecraft.kutils.bukkit.schedule
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.entity.Zombie
|
||||
import org.bukkit.potion.PotionEffect
|
||||
import org.bukkit.potion.PotionEffectType
|
||||
import pw.hamzantal.bloodmoon.BloodMoon
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class FlipBack : SpecialAttack<Zombie> {
|
||||
|
||||
override fun spawnAttack(attacker: Zombie, p: Player, pl: BloodMoon) {
|
||||
pl.schedule(delay = 50, unit = TimeUnit.MILLISECONDS) {
|
||||
p.velocity = attacker.location.direction.multiply(-0.5).setY(0.2)
|
||||
p.addPotionEffect(PotionEffect(PotionEffectType.SLOW, 3, 2))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package pw.hamzantal.bloodmoon.specialattacks
|
||||
|
||||
import hazae41.minecraft.kutils.bukkit.schedule
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.entity.Zombie
|
||||
import org.bukkit.util.Vector
|
||||
import pw.hamzantal.bloodmoon.BloodMoon
|
||||
|
||||
val dunking = hashMapOf<Player, Entity>()
|
||||
|
||||
|
||||
class SlamDunk : SpecialAttack<Zombie> {
|
||||
|
||||
private val steps = listOf(
|
||||
Vector(0.1, 1.0, 0.1),
|
||||
Vector(0.1, 0.8, 0.1),
|
||||
Vector(0.1, 0.6, 0.1),
|
||||
Vector(0.1, 0.4, 0.1),
|
||||
Vector(0.1, 0.1, 0.1),
|
||||
Vector(0.1, 0.05, 0.1),
|
||||
Vector(0, -1, 0),
|
||||
Vector(0, -1, 0)
|
||||
)
|
||||
|
||||
override fun spawnAttack(attacker: Zombie, p: Player, pl: BloodMoon) {
|
||||
dunking += p to attacker
|
||||
|
||||
var i = 0
|
||||
var taskNumber = 0
|
||||
attacker.isInvulnerable = true
|
||||
|
||||
taskNumber = BloodMoon.pl.server.scheduler.scheduleSyncRepeatingTask(BloodMoon.pl, {
|
||||
p.velocity = steps[i]
|
||||
attacker.velocity = steps[i]
|
||||
|
||||
if (++i == steps.size) {
|
||||
BloodMoon.pl.server.scheduler.cancelTask(taskNumber)
|
||||
}
|
||||
}, 0, 4)
|
||||
|
||||
pl.schedule(delay = 4) {
|
||||
dunking -= p
|
||||
attacker.isInvulnerable = false
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package pw.hamzantal.bloodmoon.specialattacks
|
||||
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.entity.Monster
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.entity.Zombie
|
||||
import pw.hamzantal.bloodmoon.BloodMoon
|
||||
|
||||
interface SpecialAttack <T: Entity> {
|
||||
fun spawnAttack(attacker: T, p: Player, pl: BloodMoon)
|
||||
|
||||
infix fun typeNameHas(s: String) = javaClass.genericInterfaces.any { it.typeName.contains(s) }
|
||||
}
|
||||
|
||||
val zombieAttacks: List<SpecialAttack<Zombie>> = listOf(
|
||||
ArrowBarrage(),
|
||||
FlipBack(),
|
||||
SlamDunk()
|
||||
)
|
@ -0,0 +1,25 @@
|
||||
# Which world will the blood moon be enabled for?
|
||||
world: "world"
|
||||
|
||||
# WHat is the chance that the blood moon will occur on any specific night?
|
||||
chance: 0.2
|
||||
|
||||
# Which mobs will turn hostile (turn into a "zombie")
|
||||
transformed_mobs:
|
||||
- PIG
|
||||
- COW
|
||||
- CHICKEN
|
||||
|
||||
# All of these power ups happen 90% of the time
|
||||
# Should zombies spawn in swarms?
|
||||
zombieSwarm: true
|
||||
|
||||
# Should all creepers spawn charged?
|
||||
chargedCreepers: true
|
||||
|
||||
# Will spiders deal more damage and run faster?
|
||||
strongSpiders: true
|
||||
|
||||
#Starting and ending messages
|
||||
startMessage: "&c&lThe blood moon has now started"
|
||||
endMessage: "&cThe blood moon is now over"
|
@ -0,0 +1,9 @@
|
||||
name: BloodMoon
|
||||
main: pw.hamzantal.bloodmoon.BloodMoon
|
||||
version: 1.0.0
|
||||
depend:
|
||||
- LibsDisguises
|
||||
- ProtocolLib
|
||||
commands:
|
||||
bloodmoon:
|
||||
description: Default command for seeing bloodmoon status
|
Loading…
Reference in New Issue