This repository has been archived by the owner on May 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
132 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
group=com.mineinabyss | ||
version=0.12 | ||
idofrontVersion=0.21.5 | ||
version=0.13 | ||
idofrontVersion=0.22.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[versions] | ||
gearyPaper = "0.29.0" | ||
gearyPaper = "0.29.12-dev.3" | ||
|
||
[libraries] | ||
geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "gearyPaper" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 29 additions & 13 deletions
42
...main/kotlin/com/mineinabyss/looty/features/nointeraction/DisableItemInteractionsSystem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
package com.mineinabyss.looty.features.nointeraction | ||
|
||
import com.mineinabyss.geary.autoscan.AutoScan | ||
import com.mineinabyss.geary.datatypes.family.family | ||
import com.mineinabyss.geary.systems.GearyListener | ||
import com.mineinabyss.geary.systems.accessors.Pointers | ||
import com.mineinabyss.geary.papermc.tracking.items.inventory.toGeary | ||
import org.bukkit.entity.Player | ||
import org.bukkit.event.Cancellable | ||
import org.bukkit.event.Event | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.EventPriority | ||
import org.bukkit.event.Listener | ||
import org.bukkit.event.player.PlayerInteractEntityEvent | ||
import org.bukkit.event.player.PlayerInteractEvent | ||
import org.bukkit.event.player.PlayerItemConsumeEvent | ||
import org.bukkit.inventory.EquipmentSlot | ||
|
||
@AutoScan | ||
class DisableItemInteractionsSystem : GearyListener() { | ||
private val Pointers.bukkit by get<Event>().map { (it as? Cancellable) }.on(event) | ||
// private val Pointers.interacted by family { has<Interacted>() }.on(event) | ||
private val Pointers.noVanilla by family { has<DisableItemInteractions>() }.on(target) | ||
class DisableItemInteractionsBukkitListener : Listener { | ||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) | ||
fun PlayerInteractEvent.onClick() { | ||
disableIfNeeded(player, hand) | ||
} | ||
|
||
override fun Pointers.handle() { | ||
bukkit?.isCancelled = true | ||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) | ||
fun PlayerInteractEntityEvent.onClick() { | ||
disableIfNeeded(player, hand) | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) | ||
fun PlayerItemConsumeEvent.onConsume() { | ||
disableIfNeeded(player, hand) | ||
} | ||
} | ||
|
||
fun Cancellable.disableIfNeeded(player: Player, hand: EquipmentSlot?) { | ||
val heldItem = player.inventory.toGeary()?.get(hand ?: return) ?: return | ||
if (heldItem.has<DisableItemInteractions>()) | ||
isCancelled = true | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.