mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2025-01-05 18:37:44 +01:00
Add MinionPrePlaceEvent
This commit is contained in:
parent
f90a28e8b0
commit
12773889cd
10
.idea/codeStyles/Project.xml
Normal file
10
.idea/codeStyles/Project.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
@ -4,7 +4,15 @@
|
||||
<option name="show" value="ASK" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
<component name="EntryPointsManager">
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="JavadocGenerationManager">
|
||||
<option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/../javadocs" />
|
||||
</component>
|
||||
@ -15,7 +23,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,34 @@
|
||||
package com.artillexstudios.axminions.api.events
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.Cancellable
|
||||
import org.bukkit.event.Event
|
||||
import org.bukkit.event.HandlerList
|
||||
|
||||
class MinionPrePlaceEvent(private val player: Player) : Cancellable, Event() {
|
||||
companion object {
|
||||
private val handlerList = HandlerList()
|
||||
|
||||
@JvmStatic
|
||||
fun getHandlerList(): HandlerList = handlerList
|
||||
}
|
||||
|
||||
private var isCancelled = false
|
||||
|
||||
|
||||
override fun getHandlers(): HandlerList {
|
||||
return MinionPrePlaceEvent.handlerList
|
||||
}
|
||||
|
||||
override fun isCancelled(): Boolean {
|
||||
return isCancelled
|
||||
}
|
||||
|
||||
fun getPlacer(): Player {
|
||||
return player
|
||||
}
|
||||
|
||||
override fun setCancelled(cancelled: Boolean) {
|
||||
isCancelled = cancelled
|
||||
}
|
||||
}
|
@ -20,6 +20,8 @@ import org.bukkit.event.player.PlayerInteractEvent
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.persistence.PersistentDataType
|
||||
import org.bukkit.event.block.BlockPlaceEvent
|
||||
import com.artillexstudios.axminions.api.events.MinionPrePlaceEvent
|
||||
import org.bukkit.Bukkit
|
||||
|
||||
class MinionPlaceListener : Listener {
|
||||
|
||||
@ -55,6 +57,12 @@ class MinionPlaceListener : Listener {
|
||||
}
|
||||
|
||||
if (meta.persistentDataContainer.has(Keys.PLACED, PersistentDataType.BYTE)) return
|
||||
|
||||
val prePlaceEvent = MinionPrePlaceEvent(event.player)
|
||||
Bukkit.getPluginManager().callEvent(prePlaceEvent)
|
||||
|
||||
if(prePlaceEvent.isCancelled) return
|
||||
|
||||
meta.persistentDataContainer.set(Keys.PLACED, PersistentDataType.BYTE, 0)
|
||||
item.itemMeta = meta
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user