Port back fixes from dev/optimize

This commit is contained in:
TomTom 2024-01-29 20:16:45 +01:00
parent aadf5ebeb4
commit a657ed55f6
21 changed files with 111 additions and 36 deletions

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -41,8 +41,9 @@ object MinionUtils {
var lava = false
var water = false
val locBlock = location.block
FACES.fastFor {
val relative = location.block.getRelative(it)
val relative = locBlock.getRelative(it)
val type = relative.type
if (!lava) {
lava = type == Material.LAVA
@ -57,7 +58,6 @@ object MinionUtils {
}
}
return false
}

View File

@ -3,11 +3,11 @@ plugins {
id 'com.github.johnrengelman.shadow' version "8.1.1"
id 'maven-publish'
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.9.0'
id 'org.jetbrains.kotlin.jvm' version '1.9.1.9.22'
}
group = 'com.artillexstudios.axminions'
version = '1.0.0'
version = '1.0.1'
repositories {
mavenCentral()
@ -20,7 +20,6 @@ repositories {
dependencies {
implementation project(path: ":api")
implementation project(path: ":common")
implementation project(path: ":nms:v1_19_R3", configuration: "reobf")
implementation project(path: ":nms:v1_20_R1", configuration: "reobf")
implementation project(path: ":nms:v1_20_R2", configuration: "reobf")
implementation project(path: ":nms:v1_20_R3", configuration: "reobf")
@ -46,6 +45,10 @@ allprojects {
mavenCentral()
mavenLocal()
maven {
url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
}
@ -107,7 +110,6 @@ allprojects {
compileOnly 'com.github.brcdev-minecraft:shopgui-api:3.0.0'
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.9.0'
compileOnly 'com.h2database:h2:2.2.220'
compileOnly 'dev.rosewood:rosestacker:1.5.9'
compileOnly 'com.bgsoftware:WildStackerAPI:2023.2'
compileOnly 'net.essentialsx:EssentialsX:2.19.0'
compileOnly 'com.github.Gypopo:EconomyShopGUI-API:1.6.0'
@ -124,9 +126,7 @@ allprojects {
implementation("com.artillexstudios.axapi:axapi:1.4.22")
implementation("net.byteflux:libby-bukkit:1.3.0")
implementation("com.zaxxer:HikariCP:5.1.0")
compileOnly files('../libs/CMI-API9.5.0.8.jar')
compileOnly files('../libs/IridiumSkyblock-3.2.12.jar')
compileOnly files('../libs/KingdomsX-1.16.12.jar')
compileOnly 'org.black_ixx:playerpoints:3.2.6'
}
shadowJar {

View File

@ -9,4 +9,8 @@ processResources {
dependencies {
implementation project(':api')
compileOnly files('../libs/CMI-API9.5.0.8.jar')
compileOnly files('../libs/IridiumSkyblock-4.0.9.jar')
compileOnly files('../libs/KingdomsX-1.16.12.jar')
compileOnly files('../libs/KGenerators-7.3-b161.jar')
}

View File

@ -127,23 +127,27 @@ class AxMinionsPlugin : AxPlugin() {
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate({
dataQueue.submit {
Minions.get().fastFor { pos ->
pos.minions.fastFor { minion ->
dataHandler.saveMinion(minion)
Minions.get {
it.fastFor { pos ->
pos.minions.fastFor { minion ->
dataHandler.saveMinion(minion)
}
}
}
}
},0, Config.AUTO_SAVE_MINUTES(), TimeUnit.MINUTES)
}, 0, Config.AUTO_SAVE_MINUTES(), TimeUnit.MINUTES)
}
override fun disable() {
Minions.get().fastFor { pos ->
pos.minions.fastFor { minion ->
val minionImp = minion as Minion
Minions.get {
it.fastFor { pos ->
pos.minions.fastFor { minion ->
val minionImp = minion as Minion
minionImp.openInventories.fastFor { inventory ->
inventory.viewers.fastFor { player ->
player.closeInventory()
minionImp.openInventories.fastFor { inventory ->
inventory.viewers.fastFor { player ->
player.closeInventory()
}
}
}
}

View File

@ -34,6 +34,7 @@ class Integrations : Integrations {
private var pricesIntegration: PricesIntegration? = null
private var economyIntegration: EconomyIntegration? = null
private val protectionIntegrations = com.artillexstudios.axminions.integrations.protection.ProtectionIntegrations()
internal var kGeneratorsIntegration = false
override fun getStackerIntegration(): StackerIntegration {
return stackerIntegration
@ -94,7 +95,7 @@ class Integrations : Integrations {
}
"economyshopgui" -> {
if (isPluginLoaded("EconomoyShopGUI")) {
if (isPluginLoaded("EconomyShopGUI")) {
register(EconomyShopGUIIntegration())
}
}
@ -157,6 +158,12 @@ class Integrations : Integrations {
Bukkit.getConsoleSender()
.sendMessage(StringUtils.formatToString("<#33FF33>[AxMinions] Hooked into KingdomsX!"))
}
if (Bukkit.getPluginManager().getPlugin("KGenerators") != null) {
kGeneratorsIntegration = true
Bukkit.getConsoleSender()
.sendMessage(StringUtils.formatToString("<#33FF33>[AxMinions] Hooked into KGenerators!"))
}
}
override fun register(integration: Integration) {

View File

@ -1,24 +1,24 @@
package com.artillexstudios.axminions.integrations.economy
import com.artillexstudios.axminions.api.integrations.types.EconomyIntegration
import org.black_ixx.playerpoints.PlayerPoints
import org.bukkit.OfflinePlayer
import org.bukkit.entity.Player
class PlayerPointsIntegration : EconomyIntegration {
override fun getBalance(player: OfflinePlayer): Double {
TODO("Not yet implemented")
return PlayerPoints.getInstance().api.look(player.uniqueId).toDouble()
}
override fun giveBalance(player: OfflinePlayer, amount: Double) {
TODO("Not yet implemented")
PlayerPoints.getInstance().api.give(player.uniqueId, amount.toInt())
}
override fun takeBalance(player: OfflinePlayer, amount: Double) {
TODO("Not yet implemented")
PlayerPoints.getInstance().api.take(player.uniqueId, amount.toInt())
}
override fun register() {
TODO("Not yet implemented")
}
}

View File

@ -1,6 +1,7 @@
package com.artillexstudios.axminions.integrations.protection
import com.artillexstudios.axminions.api.integrations.types.ProtectionIntegration
import com.iridium.iridiumskyblock.IridiumSkyblock
import com.iridium.iridiumskyblock.api.IridiumSkyblockAPI
import org.bukkit.Location
import org.bukkit.entity.Player
@ -10,7 +11,7 @@ class IridiumSkyBlockIntegration : ProtectionIntegration {
override fun canBuildAt(player: Player, location: Location): Boolean {
val island = IridiumSkyblockAPI.getInstance().getIslandViaLocation(location)
return island.map { IridiumSkyblockAPI.getInstance().getUser(player) in it.members }.orElse(true)
return island.map { IridiumSkyblockAPI.getInstance().getUser(player) in IridiumSkyblock.getInstance().teamManager.getMembersOnIsland(it) }.orElse(true) || IridiumSkyblockAPI.getInstance().getUser(player).isBypassing
}
override fun register() {

View File

@ -7,9 +7,11 @@ object MinionTicker {
private var tick = 0L
private inline fun tickAll() {
Minions.get().fastFor { pos ->
pos.minions.fastFor {
it.tick()
Minions.get { minions ->
minions.fastFor { pos ->
pos.minions.fastFor {
it.tick()
}
}
}

View File

@ -9,8 +9,8 @@ import kotlin.concurrent.write
import org.bukkit.Chunk
object Minions {
private val lock = ReentrantReadWriteLock()
private val minions = arrayListOf<ChunkPos>()
internal val lock = ReentrantReadWriteLock()
internal val minions = arrayListOf<ChunkPos>()
fun addTicking(chunk: Chunk) {
val chunkX = chunk.x
@ -120,9 +120,9 @@ object Minions {
}
}
internal fun get(): ArrayList<ChunkPos> {
internal inline fun get(minions: (ArrayList<ChunkPos>) -> Unit) {
lock.read {
return minions
minions(this.minions)
}
}

View File

@ -14,6 +14,7 @@ import java.util.Locale
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import kotlin.math.roundToInt
import me.kryniowesegryderiusz.kgenerators.Main
import org.bukkit.Material
import org.bukkit.block.BlockFace
import org.bukkit.enchantments.Enchantment
@ -61,6 +62,16 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
when (getConfig().getString("mode").lowercase(Locale.ENGLISH)) {
"sphere" -> {
LocationUtils.getAllBlocksInRadius(minion.getLocation(), minion.getRange(), false).fastFor { location ->
if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) {
val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false
if (possible) {
gen?.scheduleGeneratorRegeneration()
return@fastFor
}
}
val isStoneGenerator = MinionUtils.isStoneGenerator(location)
if (isStoneGenerator) {
@ -83,6 +94,16 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
asyncExecutor!!.execute {
LocationUtils.getAllBlocksInRadius(minion.getLocation(), minion.getRange(), false)
.fastFor { location ->
if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) {
val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false
if (possible) {
gen?.scheduleGeneratorRegeneration()
return@fastFor
}
}
val isStoneGenerator = MinionUtils.isStoneGenerator(location)
if (isStoneGenerator) {
@ -100,6 +121,16 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
} else {
LocationUtils.getAllBlocksInRadius(minion.getLocation(), minion.getRange(), false)
.fastFor { location ->
if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) {
val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false
if (possible) {
gen?.scheduleGeneratorRegeneration()
return@fastFor
}
}
val isStoneGenerator = MinionUtils.isStoneGenerator(location)
if (isStoneGenerator) {
@ -117,6 +148,16 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
"line" -> {
faces.fastFor {
LocationUtils.getAllBlocksFacing(minion.getLocation(), minion.getRange(), it).fastFor { location ->
if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) {
val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false
if (possible) {
gen?.scheduleGeneratorRegeneration()
return@fastFor
}
}
val isStoneGenerator = MinionUtils.isStoneGenerator(location)
if (isStoneGenerator) {
@ -134,6 +175,16 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
"face" -> {
LocationUtils.getAllBlocksFacing(minion.getLocation(), minion.getRange(), minion.getDirection().facing)
.fastFor { location ->
if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) {
val gen = Main.getPlacedGenerators().getLoaded(location)
val possible = gen?.isBlockPossibleToMine(location) ?: false
if (possible) {
gen?.scheduleGeneratorRegeneration()
return@fastFor
}
}
val isStoneGenerator = MinionUtils.isStoneGenerator(location)
if (isStoneGenerator) {

View File

@ -18,4 +18,5 @@ softdepend:
- Lands
- SuperiorSkyBlock2
- WorldGuard
- PlotSquared
- PlotSquared
- KGenerators

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
plugins {
id("io.papermc.paperweight.userdev") version "1.5.4" apply false
id("io.papermc.paperweight.userdev") version "1.5.10" apply false
}
group = "com.artillexstudios.axminions"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,6 @@ rootProject.name = 'AxMinions'
include 'api'
include 'common'
include 'nms'
include 'nms:v1_19_R3'
include 'nms:v1_20_R1'
include 'nms:v1_20_R2'
include 'nms:v1_20_R3'