Add gitlab auto build

master
ALI Hamza 2020-03-29 14:25:35 +07:00
parent e8a52f074a
commit a39a2d0f68
No known key found for this signature in database
GPG Key ID: BCA8A46C87798C4C
6 changed files with 76 additions and 25 deletions

@ -0,0 +1,19 @@
image: java:8-jdk
before_script:
- chmod 777 ./*
stages:
- build
build:
stage: build
script:
- ./gradlew clean shadowJar
artifacts:
name: latest
paths:
- ./build/libs/*.jar
expire_in: 50 yrs
only:
- master

@ -20,21 +20,12 @@ object BMData {
fun begin() {
stop()
println(Config.enabledMobs)
Config.world.entities.forEach { en ->
if (!Config.enabledMobs.contains(en.type.toString().toUpperCase())) {
if (!Config.enabledMobs.contains(en.type.toString().toUpperCase()) || en !is LivingEntity) {
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 (en.customName != null) return@forEach
animalSpawn(en)
}
if (Config.chargedCreepers) Config.world.entities.filter { it is Creeper }.forEach {
(it as Creeper).isPowered = true
@ -50,7 +41,6 @@ object BMData {
}
fun stop() {
println("stopping...")
running = false
transformed.forEach { (d, e) ->
d.entity.remove()
@ -64,4 +54,17 @@ object BMData {
creepers.forEach { it.isPowered = false }
creepers.clear()
}
fun animalSpawn(en: LivingEntity) {
en.remove()
val blood = en.world.spawnEntity(en.location, EntityType.ZOMBIE).apply {
(this as Zombie).isBaby = true
customName = Config.bloodAnimalName.replace("%t%", en.name).c
isCustomNameVisible = true
}
val disguise = MobDisguise(DisguiseType.valueOf(en.type.name))
disguise.entity = blood
disguise.startDisguise()
transformed[disguise] = en
}
}

@ -26,16 +26,41 @@ class BloodMoon : JavaPlugin(), Listener {
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}) ")
else Bukkit.getOnlinePlayers().filter { it.hasPermission("bloodmoon.admin") }.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.")
}
command("bloodmoon") { sender, args ->
if (args.isEmpty())
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.")
if (!sender.hasPermission("bloodmoon.admin")) {
sender.msg("&cNo permission!")
return@command
}
when (args.component1().toLowerCase()) {
"stop" -> {
sender.msg("&c[!] &7Blood moon has stopped.")
BMData.stop()
}
"start" -> {
Config.world.time = 13050
sender.msg("&c[!] &7Blood moon has started manually.")
BMData.begin()
}
}
}
}
override fun onDisable() {

@ -17,6 +17,7 @@ object Config : ConfigFile(BloodMoon.pl.dataFolder["config.yml"]) {
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 bloodAnimalName by string ("bloodAnimalNames", "&c&lBlood %t%")
}
val String.c get() = ChatColor.translateAlternateColorCodes('&', this)

@ -1,5 +1,7 @@
package pw.hamzantal.bloodmoon.listeners
import me.libraryaddict.disguise.disguisetypes.DisguiseType
import me.libraryaddict.disguise.disguisetypes.MobDisguise
import org.bukkit.entity.Creeper
import org.bukkit.entity.EntityType
import org.bukkit.entity.Spider
@ -15,11 +17,7 @@ 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
1.0 to 0.0
)
fun onCreatureSpawn(e: CreatureSpawnEvent) {
@ -39,5 +37,9 @@ fun onCreatureSpawn(e: CreatureSpawnEvent) {
en.addPotionEffect(PotionEffect(PotionEffectType.SPEED, BMData.ticksLeft(), 3, true, true))
en.addPotionEffect(PotionEffect(PotionEffectType.INCREASE_DAMAGE, BMData.ticksLeft(), 1, true, true))
}
else -> {
if (!Config.enabledMobs.contains(en.type.toString().toUpperCase())) return
BMData.animalSpawn(en)
}
}
}

@ -22,4 +22,5 @@ strongSpiders: true
#Starting and ending messages
startMessage: "&c&lThe blood moon has now started"
endMessage: "&cThe blood moon is now over"
endMessage: "&cThe blood moon is now over"
bloodAnimalNames: "&c&lBlood %t%"