mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2025-02-10 00:11:30 +01:00
New features, fixes
This commit is contained in:
parent
60d1abcf32
commit
5481b8ac4a
@ -13,6 +13,7 @@
|
||||
<option value="$PROJECT_DIR$/nms" />
|
||||
<option value="$PROJECT_DIR$/nms/v1_20_R1" />
|
||||
<option value="$PROJECT_DIR$/nms/v1_20_R2" />
|
||||
<option value="$PROJECT_DIR$/nms/v1_20_R3" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.9.0" />
|
||||
<option name="version" value="1.9.22" />
|
||||
</component>
|
||||
</project>
|
@ -40,6 +40,10 @@ class Config(file: File, stream: InputStream) {
|
||||
@JvmStatic
|
||||
fun GUI_SIZE() = AxMinionsAPI.INSTANCE.getConfig().get<Int>("gui.size")
|
||||
@JvmStatic
|
||||
fun PULL_FROM_CHEST() = AxMinionsAPI.INSTANCE.getConfig().get("pull-tools-from-chest", false)
|
||||
@JvmStatic
|
||||
fun PLACE_PERMISSION() = AxMinionsAPI.INSTANCE.getConfig().get("place-permissions", false)
|
||||
@JvmStatic
|
||||
fun DEBUG(): Boolean {
|
||||
if (debug === null) {
|
||||
debug = AxMinionsAPI.INSTANCE.getConfig().get("debug", false)
|
||||
|
@ -35,6 +35,8 @@ class Messages(file: File, stream: InputStream) {
|
||||
@JvmStatic
|
||||
fun PLACE_MINION_AT_LOCATION() = AxMinionsAPI.INSTANCE.getMessages().get<String>("place.minion-at-location")
|
||||
@JvmStatic
|
||||
fun PLACE_MISSING_PERMISSION() = AxMinionsAPI.INSTANCE.getMessages().get<String>("place.missing-permission")
|
||||
@JvmStatic
|
||||
fun STATISTICS() = AxMinionsAPI.INSTANCE.getMessages().get<String>("statistics")
|
||||
@JvmStatic
|
||||
fun LEVEL_COLOR(level: Int = 1) = AxMinionsAPI.INSTANCE.getMessages().get("levels.$level", "<#33FF33>")
|
||||
|
@ -4,7 +4,7 @@ import com.artillexstudios.axminions.api.minions.Minion
|
||||
import com.artillexstudios.axminions.api.utils.fastFor
|
||||
import org.bukkit.World
|
||||
|
||||
data class ChunkPos(val world: World, var x: Int, var z: Int) {
|
||||
data class ChunkPos(val world: World, val x: Int, val z: Int) {
|
||||
val minions = arrayListOf<Minion>()
|
||||
val worldUUID = world.uid
|
||||
|
||||
|
@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'com.artillexstudios.axminions'
|
||||
version = '1.0.1'
|
||||
version = '1.0.2'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -126,6 +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")
|
||||
implementation("org.bstats:bstats-bukkit:3.0.2")
|
||||
compileOnly 'org.black_ixx:playerpoints:3.2.6'
|
||||
}
|
||||
|
||||
@ -134,6 +135,7 @@ allprojects {
|
||||
relocate("org.h2", "com.artillexstudios.axminions.libs.h2")
|
||||
relocate("org.jetbrains.kotlin", "com.artillexstudios.axminions.libs.kotlin")
|
||||
relocate("com.zaxxer", "com.artillexstudios.axminions.libs.hikaricp")
|
||||
relocate("org.bstats", "com.artillexstudios.axminions.libs.bstats")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package com.artillexstudios.axminions
|
||||
|
||||
import com.artillexstudios.axapi.AxPlugin
|
||||
import com.artillexstudios.axapi.data.ThreadedQueue
|
||||
import com.artillexstudios.axapi.scheduler.Scheduler
|
||||
import com.artillexstudios.axminions.api.AxMinionsAPI
|
||||
import com.artillexstudios.axminions.api.AxMinionsAPIImpl
|
||||
import com.artillexstudios.axminions.api.config.Config
|
||||
@ -31,10 +32,9 @@ import com.artillexstudios.axminions.minions.miniontype.MinerMinionType
|
||||
import com.artillexstudios.axminions.minions.miniontype.SellerMinionType
|
||||
import com.artillexstudios.axminions.minions.miniontype.SlayerMinionType
|
||||
import java.io.File
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import net.byteflux.libby.BukkitLibraryManager
|
||||
import net.byteflux.libby.Library
|
||||
import org.bstats.bukkit.Metrics
|
||||
import org.bukkit.Bukkit
|
||||
import revxrsal.commands.bukkit.BukkitCommandHandler
|
||||
|
||||
@ -65,6 +65,8 @@ class AxMinionsPlugin : AxPlugin() {
|
||||
}
|
||||
|
||||
override fun enable() {
|
||||
Metrics(this, 19043)
|
||||
|
||||
AxMinionsPlugin.config = Config(File(dataFolder, "config.yml"), getResource("config.yml")!!)
|
||||
messages = Messages(File(dataFolder, "messages.yml"), getResource("messages.yml")!!)
|
||||
integrations = Integrations()
|
||||
@ -125,7 +127,7 @@ class AxMinionsPlugin : AxPlugin() {
|
||||
|
||||
MinionTicker.startTicking()
|
||||
|
||||
Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate({
|
||||
Scheduler.get().runTimer({
|
||||
dataQueue.submit {
|
||||
Minions.get {
|
||||
it.fastFor { pos ->
|
||||
@ -135,7 +137,7 @@ class AxMinionsPlugin : AxPlugin() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, Config.AUTO_SAVE_MINUTES(), TimeUnit.MINUTES)
|
||||
}, 0, Config.AUTO_SAVE_MINUTES() * 20 * 60)
|
||||
}
|
||||
|
||||
override fun disable() {
|
||||
|
@ -356,8 +356,6 @@ class H2DataHandler : DataHandler {
|
||||
}
|
||||
|
||||
override fun disable() {
|
||||
dataSource.connection.use { connection ->
|
||||
connection.prepareStatement("SHUTDOWN DEFRAG;").executeUpdate()
|
||||
}
|
||||
dataSource.connection.prepareStatement("SHUTDOWN DEFRAG;").executeUpdate()
|
||||
}
|
||||
}
|
@ -135,6 +135,7 @@ class MinionInventoryListener : Listener {
|
||||
|
||||
AxMinionsPlugin.integrations.getEconomyIntegration()?.let {
|
||||
if (it.getBalance(player) < money) {
|
||||
player.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.UPGRADE_FAIL()))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,11 @@ class MinionPlaceListener : Listener {
|
||||
if (!AxMinionsPlugin.integrations.getProtectionIntegration().canBuildAt(event.player, event.clickedBlock!!.location)) return
|
||||
val level = meta.persistentDataContainer.get(Keys.LEVEL, PersistentDataType.INTEGER) ?: 0
|
||||
val stats = meta.persistentDataContainer.get(Keys.STATISTICS, PersistentDataType.LONG) ?: 0
|
||||
if (Config.PLACE_PERMISSION() && !event.player.hasPermission("axminions.place.${minionType.getName()}")) {
|
||||
event.player.sendMessage(StringUtils.formatToString(Messages.PREFIX() + Messages.PLACE_MISSING_PERMISSION()))
|
||||
return
|
||||
}
|
||||
|
||||
if (meta.persistentDataContainer.has(Keys.PLACED, PersistentDataType.BYTE)) return
|
||||
meta.persistentDataContainer.set(Keys.PLACED, PersistentDataType.BYTE, 0)
|
||||
item.itemMeta = meta
|
||||
|
@ -25,9 +25,7 @@ import com.artillexstudios.axminions.api.utils.fastFor
|
||||
import com.artillexstudios.axminions.api.warnings.Warning
|
||||
import com.artillexstudios.axminions.api.warnings.Warnings
|
||||
import com.artillexstudios.axminions.listeners.LinkingListener
|
||||
import java.util.HashMap
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Location
|
||||
@ -498,7 +496,7 @@ class Minion(
|
||||
}
|
||||
|
||||
override fun addToContainerOrDrop(itemStack: ItemStack) {
|
||||
if (linkedInventory == null) {
|
||||
if (linkedInventory == null) {
|
||||
AxMinionsPlugin.integrations.getStackerIntegration().dropItemAt(itemStack, itemStack.amount, location)
|
||||
return
|
||||
}
|
||||
@ -595,7 +593,36 @@ class Minion(
|
||||
|
||||
if ((tool?.type?.maxDurability ?: return) <= meta.damage + amount) {
|
||||
if (Config.CAN_BREAK_TOOLS()) {
|
||||
if (Config.PULL_FROM_CHEST()) {
|
||||
val allowedTools = arrayListOf<Material>()
|
||||
getType().getConfig().getStringList("tool.material").fastFor {
|
||||
allowedTools.add(Material.matchMaterial(it) ?: return@fastFor)
|
||||
}
|
||||
|
||||
linkedInventory?.contents?.fastFor {
|
||||
if (it == null || it.type !in allowedTools) return@fastFor
|
||||
|
||||
setTool(it)
|
||||
linkedInventory?.remove(it)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
setTool(ItemStack(Material.AIR))
|
||||
} else if (Config.PULL_FROM_CHEST()) {
|
||||
val allowedTools = arrayListOf<Material>()
|
||||
getType().getConfig().getStringList("tool.material").fastFor {
|
||||
allowedTools.add(Material.matchMaterial(it) ?: return@fastFor)
|
||||
}
|
||||
|
||||
linkedInventory?.contents?.fastFor {
|
||||
if (it == null || it.type !in allowedTools) return@fastFor
|
||||
|
||||
linkedInventory?.addItem(getTool())
|
||||
setTool(it)
|
||||
linkedInventory?.remove(it)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
meta.damage += amount
|
||||
|
@ -70,7 +70,6 @@ object Minions {
|
||||
lock.write {
|
||||
var pos: ChunkPos? = null
|
||||
run breaking@{
|
||||
|
||||
minions.forEach {
|
||||
if (world.uid == it.worldUUID && it.x == chunkX && it.z == chunkZ) {
|
||||
pos = it
|
||||
|
@ -60,9 +60,7 @@ class FarmerMinionType : MinionType("farmer", AxMinionsPlugin.INSTANCE.getResour
|
||||
Material.CACTUS, Material.SUGAR_CANE, Material.BAMBOO -> {
|
||||
MinionUtils.getPlant(block).fastFor {
|
||||
val blockDrops = it.getDrops(minion.getTool())
|
||||
blockDrops.forEach { itemStack ->
|
||||
size += itemStack.amount
|
||||
}
|
||||
size++
|
||||
drops.addAll(blockDrops)
|
||||
it.type = Material.AIR
|
||||
}
|
||||
@ -70,9 +68,7 @@ class FarmerMinionType : MinionType("farmer", AxMinionsPlugin.INSTANCE.getResour
|
||||
|
||||
Material.MELON, Material.PUMPKIN -> {
|
||||
val blockDrops = block.getDrops(minion.getTool())
|
||||
blockDrops.forEach { itemStack ->
|
||||
size += itemStack.amount
|
||||
}
|
||||
size++
|
||||
drops.addAll(blockDrops)
|
||||
block.type = Material.AIR
|
||||
}
|
||||
@ -81,9 +77,7 @@ class FarmerMinionType : MinionType("farmer", AxMinionsPlugin.INSTANCE.getResour
|
||||
val ageable = block.blockData as Ageable
|
||||
if (ageable.age != ageable.maximumAge) return@fastFor
|
||||
val blockDrops = block.getDrops(minion.getTool())
|
||||
blockDrops.forEach { itemStack ->
|
||||
size += itemStack.amount
|
||||
}
|
||||
size++
|
||||
drops.addAll(blockDrops)
|
||||
ageable.age = 0
|
||||
block.blockData = ageable
|
||||
@ -93,9 +87,7 @@ class FarmerMinionType : MinionType("farmer", AxMinionsPlugin.INSTANCE.getResour
|
||||
val ageable = block.blockData as Ageable
|
||||
if (ageable.age != ageable.maximumAge) return@fastFor
|
||||
val blockDrops = block.getDrops(minion.getTool())
|
||||
blockDrops.forEach { itemStack ->
|
||||
size += itemStack.amount
|
||||
}
|
||||
size++
|
||||
drops.addAll(blockDrops)
|
||||
ageable.age = 1
|
||||
block.blockData = ageable
|
||||
|
@ -6,6 +6,10 @@ auto-save-minutes: 3
|
||||
# How far the storage chest can be from the minion
|
||||
max-linking-distance: 30
|
||||
|
||||
# If players need to have 'axminions.place.<minion>' permission
|
||||
# to be able to place this minion
|
||||
place-permissions: false
|
||||
|
||||
# The default amount of minions a player can have.
|
||||
# This setting can be overwritten by setting the 'axminions.limit.<amount>' permission!
|
||||
default-minion-limit: 5
|
||||
@ -32,6 +36,9 @@ can-break-tools: true
|
||||
# If the minion should be able to take durability from it's held item
|
||||
use-durability: true
|
||||
|
||||
# If the minion should pull new tools from the chest it's connected to
|
||||
pull-tools-from-chest: false
|
||||
|
||||
database:
|
||||
# Can be H2 (SqLite support is planned)
|
||||
type: "H2"
|
||||
@ -83,4 +90,4 @@ gui:
|
||||
debug: false
|
||||
|
||||
# Do not change!
|
||||
config-version: 1
|
||||
config-version: 2
|
@ -6,6 +6,7 @@ place:
|
||||
success: "<green>Successfully placed a new <type> minion! <gray>(<placed>/<max>)"
|
||||
limit-reached: "<red>Could not place minion! You have reached the limit! <gray>(<placed>/<max>)"
|
||||
minion-at-location: "<red>Could not place minion! There already is a minion at that location!"
|
||||
missing-permission: "<red>You do not have the required permissions to place this minion!"
|
||||
|
||||
pickup:
|
||||
success: "<green>Successfully picked up a minion! <gray>(<placed>/<max>)"
|
||||
@ -61,4 +62,4 @@ tools:
|
||||
wrong-tool: "<red>You can't place this item as the tool if this minion!"
|
||||
|
||||
# Do not change!
|
||||
config-version: 1
|
||||
config-version: 2
|
Loading…
Reference in New Issue
Block a user