-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
10 changed files
with
112 additions
and
6 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
21 changes: 21 additions & 0 deletions
21
...mmon/src/main/kotlin/com/willfp/libreforge/integrations/fancynpcs/FancyNPCsIntegration.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.willfp.libreforge.integrations.fancynpcs | ||
|
||
import com.willfp.eco.core.EcoPlugin | ||
import com.willfp.libreforge.filters.Filters | ||
import com.willfp.libreforge.integrations.LoadableIntegration | ||
import com.willfp.libreforge.integrations.fancynpcs.impl.FilterNPC | ||
import com.willfp.libreforge.integrations.fancynpcs.impl.TriggerLeftClickNPC | ||
import com.willfp.libreforge.integrations.fancynpcs.impl.TriggerRightClickNPC | ||
import com.willfp.libreforge.triggers.Triggers | ||
|
||
object FancyNPCsIntegration : LoadableIntegration { | ||
override fun load(plugin: EcoPlugin) { | ||
Triggers.register(TriggerLeftClickNPC) | ||
Triggers.register(TriggerRightClickNPC) | ||
Filters.register(FilterNPC) | ||
} | ||
|
||
override fun getPluginName(): String { | ||
return "FancyNpcs" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
core/common/src/main/kotlin/com/willfp/libreforge/integrations/fancynpcs/impl/FilterNPC.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.willfp.libreforge.integrations.fancynpcs.impl | ||
|
||
import com.willfp.eco.core.config.interfaces.Config | ||
import com.willfp.libreforge.NoCompileData | ||
import com.willfp.libreforge.filters.Filter | ||
import com.willfp.libreforge.triggers.TriggerData | ||
import de.oliver.fancynpcs.api.events.NpcInteractEvent | ||
|
||
object FilterNPC : Filter<NoCompileData, Collection<String>>("npc") { | ||
override fun getValue(config: Config, data: TriggerData?, key: String): Collection<String> { | ||
return config.getStrings(key) | ||
} | ||
|
||
override fun isMet(data: TriggerData, value: Collection<String>, compileData: NoCompileData): Boolean { | ||
val event = data.event as? NpcInteractEvent ?: return true | ||
|
||
return value.contains(event.npc.data.id) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
.../src/main/kotlin/com/willfp/libreforge/integrations/fancynpcs/impl/TriggerLeftClickNPC.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.willfp.libreforge.integrations.fancynpcs.impl | ||
|
||
import com.willfp.libreforge.toDispatcher | ||
import com.willfp.libreforge.triggers.Trigger | ||
import com.willfp.libreforge.triggers.TriggerData | ||
import com.willfp.libreforge.triggers.TriggerParameter | ||
import de.oliver.fancynpcs.api.actions.ActionTrigger | ||
import de.oliver.fancynpcs.api.events.NpcInteractEvent | ||
import org.bukkit.event.EventHandler | ||
|
||
object TriggerLeftClickNPC : Trigger("left_click_npc") { | ||
override val parameters = setOf( | ||
TriggerParameter.PLAYER, | ||
TriggerParameter.EVENT | ||
) | ||
|
||
@EventHandler(ignoreCancelled = true) | ||
fun handle(event: NpcInteractEvent) { | ||
if (event.interactionType == ActionTrigger.LEFT_CLICK) { | ||
val player = event.player ?: return | ||
|
||
this.dispatch( | ||
player.toDispatcher(), | ||
TriggerData( | ||
player = player, | ||
event = event | ||
) | ||
) | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...src/main/kotlin/com/willfp/libreforge/integrations/fancynpcs/impl/TriggerRightClickNPC.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.willfp.libreforge.integrations.fancynpcs.impl | ||
|
||
import com.willfp.libreforge.toDispatcher | ||
import com.willfp.libreforge.triggers.Trigger | ||
import com.willfp.libreforge.triggers.TriggerData | ||
import com.willfp.libreforge.triggers.TriggerParameter | ||
import de.oliver.fancynpcs.api.actions.ActionTrigger | ||
import de.oliver.fancynpcs.api.events.NpcInteractEvent | ||
import org.bukkit.event.EventHandler | ||
|
||
object TriggerRightClickNPC : Trigger("right_click_npc") { | ||
override val parameters = setOf( | ||
TriggerParameter.PLAYER, | ||
TriggerParameter.EVENT | ||
) | ||
|
||
@EventHandler(ignoreCancelled = true) | ||
fun handle(event: NpcInteractEvent) { | ||
if (event.interactionType == ActionTrigger.RIGHT_CLICK) { | ||
val player = event.player ?: return | ||
|
||
this.dispatch( | ||
player.toDispatcher(), | ||
TriggerData( | ||
player = player, | ||
event = event | ||
) | ||
) | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ softdepend: | |
- ModelEngine | ||
- AxEnvoy | ||
- Votifier | ||
- FancyNpcs | ||
|
||
commands: | ||
lrcdb: | ||
|
Binary file not shown.