Fixes, update AxAPI to handle 1.20.2, smaller filesize, only-owner-gui config option

This commit is contained in:
TomTom 2023-11-05 12:55:56 +01:00
parent ac2a1a3cb3
commit 382c33cd4f
12 changed files with 35 additions and 24 deletions

View File

@ -22,6 +22,8 @@ class Config(file: File, stream: InputStream) {
@JvmStatic
fun ONLY_OWNER_BREAK() = AxMinionsAPI.INSTANCE.getConfig().get("only-owner-break", true)
@JvmStatic
fun ONLY_OWNER_GUI() = AxMinionsAPI.INSTANCE.getConfig().get("only-owner-gui", true)
@JvmStatic
fun DISPLAY_WARNINGS() = AxMinionsAPI.INSTANCE.getConfig().get("display-warnings", true)
@JvmStatic
fun CAN_BREAK_TOOLS() = AxMinionsAPI.INSTANCE.getConfig().get("can-break-tools", true)

View File

@ -94,28 +94,18 @@ class Minion(
entity.setHasArms(true)
entity.onClick { event ->
Scheduler.get().execute {
Scheduler.get().run {
if (event.isAttack) {
if (ownerUUID == event.player.uniqueId && Config.ONLY_OWNER_BREAK()) {
if (ownerUUID == event.player.uniqueId) {
breakMinion(event)
} else if (AxMinionsPlugin.integrations.getProtectionIntegration()
.canBuildAt(
event.player,
event.packetEntity.location
) || event.player.hasPermission("axminions.*")
) {
} else if ((AxMinionsPlugin.integrations.getProtectionIntegration().canBuildAt(event.player, event.packetEntity.location) && !Config.ONLY_OWNER_BREAK()) || event.player.hasPermission("axminions.*")) {
breakMinion(event)
}
} else {
if (ownerUUID == event.player.uniqueId || AxMinionsPlugin.integrations.getProtectionIntegration()
.canBuildAt(
event.player,
event.packetEntity.location
) || event.player.hasPermission("axminions.*")
) {
Scheduler.get().run {
openInventory(event.player)
}
if (ownerUUID == event.player.uniqueId) {
openInventory(event.player)
} else if ((AxMinionsPlugin.integrations.getProtectionIntegration().canBuildAt(event.player, event.packetEntity.location) && !Config.ONLY_OWNER_GUI()) || event.player.hasPermission("axminions.*")) {
openInventory(event.player)
}
}
}

View File

@ -26,7 +26,9 @@ class CollectorMinionType : MinionType("collector", AxMinionsPlugin.INSTANCE.get
}
override fun run(minion: Minion) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
if (minion.getLinkedInventory() != null && minion.getLinkedInventory()?.firstEmpty() != -1) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
}
if (minion.getLinkedChest() == null) {
Warnings.NO_CONTAINER.display(minion)

View File

@ -29,7 +29,9 @@ class FarmerMinionType : MinionType("farmer", AxMinionsPlugin.INSTANCE.getResour
}
override fun run(minion: Minion) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
if (minion.getLinkedInventory() != null && minion.getLinkedInventory()?.firstEmpty() != -1) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
}
if (minion.getLinkedChest() != null) {
val type = minion.getLinkedChest()!!.block.type

View File

@ -29,7 +29,9 @@ class FisherMinionType : MinionType("fisher", AxMinionsPlugin.INSTANCE.getResour
}
override fun run(minion: Minion) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
if (minion.getLinkedInventory() != null && minion.getLinkedInventory()?.firstEmpty() != -1) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
}
if (minion.getLinkedChest() != null) {
val type = minion.getLinkedChest()!!.block.type

View File

@ -29,7 +29,9 @@ class LumberMinionType : MinionType("lumber", AxMinionsPlugin.INSTANCE.getResour
}
override fun run(minion: Minion) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
if (minion.getLinkedInventory() != null && minion.getLinkedInventory()?.firstEmpty() != -1) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
}
if (minion.getLinkedChest() != null) {
val type = minion.getLinkedChest()!!.block.type

View File

@ -35,7 +35,9 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource
}
override fun run(minion: Minion) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
if (minion.getLinkedInventory() != null && minion.getLinkedInventory()?.firstEmpty() != -1) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
}
if (minion.getLinkedChest() != null) {
val type = minion.getLinkedChest()!!.block.type

View File

@ -24,7 +24,9 @@ class SellerMinionType : MinionType("seller", AxMinionsPlugin.INSTANCE.getResour
}
override fun run(minion: Minion) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
if (minion.getLinkedInventory() != null && minion.getLinkedInventory()?.firstEmpty() != -1) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
}
if (minion.getLinkedChest() == null) {
Warnings.NO_CONTAINER.display(minion)

View File

@ -29,7 +29,9 @@ class SlayerMinionType : MinionType("slayer", AxMinionsPlugin.INSTANCE.getResour
}
override fun run(minion: Minion) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
if (minion.getLinkedInventory() != null && minion.getLinkedInventory()?.firstEmpty() != -1) {
Warnings.remove(minion, Warnings.CONTAINER_FULL)
}
if (minion.getLinkedChest() != null) {
val type = minion.getLinkedChest()!!.block.type

View File

@ -15,6 +15,11 @@ default-minion-limit: 5
# You should enable this, if you aren't using a supported protection plugin!
only-owner-break: true
# If true, only the owner of this minion can open it's GUI
# If false, everyone, who can break blocks at said location can open the GUI of this minion
# You should enable this, if you aren't using a supported protection plugin!
only-owner-gui: true
# Should minions show holograms if they have an issue?
# (They won't complain about not having a girlfriend, though!)
# You can configure these messages in the messages.yml

Binary file not shown.

Binary file not shown.