From 4dd93518781c01bdfe89cccc0854aef1bb911ae1 Mon Sep 17 00:00:00 2001 From: Shynixn Date: Thu, 25 Jan 2024 21:41:49 +0100 Subject: [PATCH] #486 Moved events to simplified structure. --- .../api/business/enumeration/PlaceHolder.kt | 27 ---- .../api/business/service/EventService.kt | 8 -- blockball-bukkit-api/build.gradle.kts | 5 - .../BlockBallDependencyInjectionBinder.kt | 1 - .../compatibility/BallDeathEventEntity.kt | 5 - .../entity/compatibility/BallEventEntity.kt | 6 - .../compatibility/BallKickEventEntity.kt | 9 -- .../compatibility/BallPassEventEntity.kt | 9 -- .../compatibility/BallRayTraceEventEntity.kt | 27 ---- .../compatibility/BallSpawnEventEntity.kt | 5 - .../compatibility/BallTeleportEventEntity.kt | 5 - .../compatibility/BallTouchEventEntity.kt | 16 --- .../compatibility/BlockBallEventEntity.kt | 4 - .../compatibility/GameEndEventEntity.kt | 6 - .../entity/compatibility/GameEventEntity.kt | 5 - .../compatibility/GameGoalEventEntity.kt | 10 -- .../compatibility/GameJoinEventEntity.kt | 5 - .../compatibility/GameLeaveEventEntity.kt | 5 - .../shynixn/blockball}/event/BallEvent.kt | 2 +- .../blockball/event/BallLeftClickEvent.kt | 6 +- .../blockball}/event/BallRayTraceEvent.kt | 2 +- .../blockball/event/BallRemoveEvent.kt | 4 +- .../blockball/event/BallRightClickEvent.kt | 6 +- .../blockball}/event/BallSpawnEvent.kt | 2 +- .../blockball}/event/BallTeleportEvent.kt | 2 +- .../blockball/event/BallTouchPlayerEvent.kt | 4 +- .../blockball}/event/BlockBallEvent.kt | 2 +- .../shynixn/blockball}/event/GameEndEvent.kt | 2 +- .../shynixn/blockball}/event/GameEvent.kt | 2 +- .../shynixn/blockball}/event/GameGoalEvent.kt | 2 +- .../shynixn/blockball}/event/GameJoinEvent.kt | 2 +- .../blockball}/event/GameLeaveEvent.kt | 2 +- .../blockball/impl/AllPlayerTracker.kt | 15 +- .../blockball/impl/BallCrossPlatformProxy.kt | 30 ++-- .../blockball/impl/BallHitboxEntity.kt | 50 +++---- .../blockball/impl/listener/BallListener.kt | 10 +- .../blockball/impl/listener/GameListener.kt | 6 +- .../impl/listener/MinigameListener.kt | 2 +- .../impl/service/BallEntityServiceImpl.kt | 10 +- .../impl/service/EventServiceImpl.kt | 129 ------------------ .../impl/service/GameActionServiceImpl.kt | 18 +-- .../impl/service/GameSoccerServiceImpl.kt | 15 +- 42 files changed, 95 insertions(+), 388 deletions(-) delete mode 100644 blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/EventService.kt delete mode 100644 blockball-bukkit-api/build.gradle.kts delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallDeathEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallKickEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallPassEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallRayTraceEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallSpawnEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallTeleportEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallTouchEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BlockBallEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameEndEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameGoalEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameJoinEventEntity.kt delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameLeaveEventEntity.kt rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/BallEvent.kt (79%) rename blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallKickEvent.kt => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallLeftClickEvent.kt (68%) rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/BallRayTraceEvent.kt (95%) rename blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallDeathEvent.kt => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRemoveEvent.kt (56%) rename blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallPassEvent.kt => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRightClickEvent.kt (67%) rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/BallSpawnEvent.kt (69%) rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/BallTeleportEvent.kt (82%) rename blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallTouchEvent.kt => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallTouchPlayerEvent.kt (82%) rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/BlockBallEvent.kt (94%) rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/GameEndEvent.kt (86%) rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/GameEvent.kt (80%) rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/GameGoalEvent.kt (89%) rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/GameJoinEvent.kt (83%) rename {blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit => blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball}/event/GameLeaveEvent.kt (83%) delete mode 100644 blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/EventServiceImpl.kt diff --git a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/PlaceHolder.kt b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/PlaceHolder.kt index 5e6215447..e7bee2865 100644 --- a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/PlaceHolder.kt +++ b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/enumeration/PlaceHolder.kt @@ -1,32 +1,5 @@ package com.github.shynixn.blockball.api.business.enumeration -/** - * Placeholder being used in BlockBall. - *

- * Version 1.2 - *

- * MIT License - *

- * Copyright (c) 2018 by Shynixn - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ enum class PlaceHolder( /** * Placeholder value. diff --git a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/EventService.kt b/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/EventService.kt deleted file mode 100644 index 86689fcfd..000000000 --- a/blockball-api/src/main/java/com/github/shynixn/blockball/api/business/service/EventService.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.shynixn.blockball.api.business.service - -interface EventService { - /** - * Sends a custom event. - */ - fun sendEvent(event: Any) -} \ No newline at end of file diff --git a/blockball-bukkit-api/build.gradle.kts b/blockball-bukkit-api/build.gradle.kts deleted file mode 100644 index a972f7f5a..000000000 --- a/blockball-bukkit-api/build.gradle.kts +++ /dev/null @@ -1,5 +0,0 @@ -dependencies { - implementation(project(":blockball-api")) - - compileOnly("org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT") -} diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionBinder.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionBinder.kt index ca2c9371a..911c1cb4e 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionBinder.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/BlockBallDependencyInjectionBinder.kt @@ -51,7 +51,6 @@ class BlockBallDependencyInjectionBinder( // Services bind(PacketService::class.java).toInstance(packetService) bind(EntityService::class.java).toInstance(EntityServiceImpl()) - bind(EventService::class.java).to(EventServiceImpl::class.java).`in`(Scopes.SINGLETON) bind(TemplateService::class.java).to(TemplateServiceImpl::class.java).`in`(Scopes.SINGLETON) bind(VirtualArenaService::class.java).to(VirtualArenaServiceImpl::class.java).`in`(Scopes.SINGLETON) bind(ScoreboardService::class.java).to(ScoreboardServiceImpl::class.java).`in`(Scopes.SINGLETON) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallDeathEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallDeathEventEntity.kt deleted file mode 100644 index 77e17d2ed..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallDeathEventEntity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.proxy.BallProxy - -class BallDeathEventEntity(ball: BallProxy) : BallEventEntity(ball) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallEventEntity.kt deleted file mode 100644 index 45f281a25..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallEventEntity.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.proxy.BallProxy - -open class BallEventEntity(val ballProxy: BallProxy) : BlockBallEventEntity() { -} diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallKickEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallKickEventEntity.kt deleted file mode 100644 index a6d6fb089..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallKickEventEntity.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.proxy.BallProxy - -class BallKickEventEntity( - ball: BallProxy, - player: Any, - velocity: Any -) : BallTouchEventEntity(ball, player, velocity) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallPassEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallPassEventEntity.kt deleted file mode 100644 index f7fd116d7..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallPassEventEntity.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.proxy.BallProxy - -class BallPassEventEntity( - ball: BallProxy, - player: Any, - velocity: Any -) : BallTouchEventEntity(ball, player, velocity) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallRayTraceEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallRayTraceEventEntity.kt deleted file mode 100644 index fa0e48c64..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallRayTraceEventEntity.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.enumeration.BlockDirection -import com.github.shynixn.blockball.api.business.proxy.BallProxy - -class BallRayTraceEventEntity( - /** - * Ball. - */ - ball: BallProxy, - /** - * Modifies if the raytrace has ended in a block hit. - */ - var hitBlock: Boolean = false, - - /** - * Gets the resulting position if the object actually - * performs the raytrace. Current Position is the position of the ball. - */ - var targetLocation: Any, - - /** - * Block Direction which was hit. If hitBlock is false, it may contain any - * direction. If changed and the hitBlock is true the outgoing Vector is differently calculated later. - */ - var blockDirection: BlockDirection -) : BallEventEntity(ball) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallSpawnEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallSpawnEventEntity.kt deleted file mode 100644 index 8307cca95..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallSpawnEventEntity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.proxy.BallProxy - -class BallSpawnEventEntity(ball: BallProxy) : BallEventEntity(ball) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallTeleportEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallTeleportEventEntity.kt deleted file mode 100644 index e9f48a21e..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallTeleportEventEntity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.proxy.BallProxy - -class BallTeleportEventEntity(ball: BallProxy, var targetLocation: Any) : BallEventEntity(ball) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallTouchEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallTouchEventEntity.kt deleted file mode 100644 index 55b1bdc5a..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BallTouchEventEntity.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.proxy.BallProxy - -open class BallTouchEventEntity( - ball: BallProxy, - /** - * Player. - */ - val player: Any, - - /** - * Velocity of the ball after being kicked. - */ - var velocity: Any -) : BallEventEntity(ball) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BlockBallEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BlockBallEventEntity.kt deleted file mode 100644 index 27860c582..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/BlockBallEventEntity.kt +++ /dev/null @@ -1,4 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -open class BlockBallEventEntity(var isCancelled: Boolean = false) { -} diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameEndEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameEndEventEntity.kt deleted file mode 100644 index e6dfa2d67..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameEndEventEntity.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.enumeration.Team -import com.github.shynixn.blockball.api.persistence.entity.Game - -class GameEndEventEntity(game: Game, var winningTeam: Team?) : GameEventEntity(game) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameEventEntity.kt deleted file mode 100644 index e87a3a2a7..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameEventEntity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.persistence.entity.Game - -open class GameEventEntity(var game : Game) : BlockBallEventEntity() diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameGoalEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameGoalEventEntity.kt deleted file mode 100644 index 57ba05853..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameGoalEventEntity.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.business.enumeration.Team -import com.github.shynixn.blockball.api.persistence.entity.Game - -class GameGoalEventEntity( - game: Game, - var player: Any?, - var team: Team -) : GameEventEntity(game) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameJoinEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameJoinEventEntity.kt deleted file mode 100644 index cd2824dfb..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameJoinEventEntity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.persistence.entity.Game - -class GameJoinEventEntity(game: Game, var player : Any) : GameEventEntity(game) diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameLeaveEventEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameLeaveEventEntity.kt deleted file mode 100644 index 96cff481a..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/entity/compatibility/GameLeaveEventEntity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.shynixn.blockball.entity.compatibility - -import com.github.shynixn.blockball.api.persistence.entity.Game - -class GameLeaveEventEntity(game: Game, var player : Any) : GameEventEntity(game) diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallEvent.kt similarity index 79% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallEvent.kt index 59f6cb437..09d9d73e4 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.proxy.BallProxy diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallKickEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallLeftClickEvent.kt similarity index 68% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallKickEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallLeftClickEvent.kt index 9b4e2fd4f..a110adedf 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallKickEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallLeftClickEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.proxy.BallProxy import org.bukkit.entity.Player @@ -7,8 +7,8 @@ import org.bukkit.util.Vector /** * Event which gets called when the ball is kicked. */ -class BallKickEvent( +class BallLeftClickEvent( ball: BallProxy, player: Player, velocity: Vector -) : BallTouchEvent(ball, player, velocity) +) : BallTouchPlayerEvent(ball, player, velocity) diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallRayTraceEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRayTraceEvent.kt similarity index 95% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallRayTraceEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRayTraceEvent.kt index e4183854c..f1c244b59 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallRayTraceEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRayTraceEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.enumeration.BlockDirection import com.github.shynixn.blockball.api.business.proxy.BallProxy diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallDeathEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRemoveEvent.kt similarity index 56% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallDeathEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRemoveEvent.kt index 4e1a6bcba..a90257771 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallDeathEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRemoveEvent.kt @@ -1,8 +1,8 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.proxy.BallProxy /** * Event which gets sent when the ball is requested to get removed. */ -class BallDeathEvent(ball: BallProxy) : BallEvent(ball) +class BallRemoveEvent(ball: BallProxy) : BallEvent(ball) diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallPassEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRightClickEvent.kt similarity index 67% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallPassEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRightClickEvent.kt index 65734faa9..19347dae7 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallPassEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallRightClickEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.proxy.BallProxy import org.bukkit.entity.Player @@ -7,8 +7,8 @@ import org.bukkit.util.Vector /** * Event which gets called when the ball is passed. */ -class BallPassEvent( +class BallRightClickEvent( ball: BallProxy, player: Player, velocity: Vector -) : BallTouchEvent(ball, player, velocity) +) : BallTouchPlayerEvent(ball, player, velocity) diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallSpawnEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallSpawnEvent.kt similarity index 69% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallSpawnEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallSpawnEvent.kt index 4f9a3133f..11044802f 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallSpawnEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallSpawnEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.proxy.BallProxy diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallTeleportEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallTeleportEvent.kt similarity index 82% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallTeleportEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallTeleportEvent.kt index 4b826f6a9..8f2d98496 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallTeleportEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallTeleportEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.proxy.BallProxy import org.bukkit.Location diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallTouchEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallTouchPlayerEvent.kt similarity index 82% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallTouchEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallTouchPlayerEvent.kt index bd258708b..fb7dd8c72 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BallTouchEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BallTouchPlayerEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.proxy.BallProxy import org.bukkit.entity.Player @@ -8,7 +8,7 @@ import org.bukkit.util.Vector /** * Event which gets called when the ball is touched. */ -open class BallTouchEvent( +open class BallTouchPlayerEvent( ball: BallProxy, /** * Interacting player. diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BlockBallEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BlockBallEvent.kt similarity index 94% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BlockBallEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BlockBallEvent.kt index 52d12a7df..f8ff3acf7 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/BlockBallEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/BlockBallEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import org.bukkit.event.Cancellable import org.bukkit.event.Event diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameEndEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameEndEvent.kt similarity index 86% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameEndEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameEndEvent.kt index ae8c06dde..576dda14e 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameEndEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameEndEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.enumeration.Team import com.github.shynixn.blockball.api.persistence.entity.Game diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameEvent.kt similarity index 80% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameEvent.kt index cde262232..bf2e947b7 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.persistence.entity.Game diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameGoalEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameGoalEvent.kt similarity index 89% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameGoalEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameGoalEvent.kt index 85eded429..093d9d496 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameGoalEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameGoalEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.business.enumeration.Team import com.github.shynixn.blockball.api.persistence.entity.Game diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameJoinEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameJoinEvent.kt similarity index 83% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameJoinEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameJoinEvent.kt index eee3e75a1..d6fbc1f11 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameJoinEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameJoinEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.persistence.entity.Game import org.bukkit.entity.Player diff --git a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameLeaveEvent.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameLeaveEvent.kt similarity index 83% rename from blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameLeaveEvent.kt rename to blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameLeaveEvent.kt index b01c9e255..e998a1b96 100644 --- a/blockball-bukkit-api/src/main/java/com/github/shynixn/blockball/api/bukkit/event/GameLeaveEvent.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/event/GameLeaveEvent.kt @@ -1,4 +1,4 @@ -package com.github.shynixn.blockball.api.bukkit.event +package com.github.shynixn.blockball.event import com.github.shynixn.blockball.api.persistence.entity.Game import org.bukkit.entity.Player diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/AllPlayerTracker.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/AllPlayerTracker.kt index 35773335c..70ee86315 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/AllPlayerTracker.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/AllPlayerTracker.kt @@ -2,21 +2,22 @@ package com.github.shynixn.blockball.impl import com.github.shynixn.blockball.api.business.service.ProxyService import com.github.shynixn.blockball.api.persistence.entity.Position +import org.bukkit.entity.Player class AllPlayerTracker( private val locationFunction: () -> Position, - private val newPlayerFunction: (Any) -> Unit, - private val oldPlayerFunction: (Any) -> Unit, - private val filterPlayerFunction: (Any) -> Boolean = { true } + private val newPlayerFunction: (Player) -> Unit, + private val oldPlayerFunction: (Player) -> Unit, + private val filterPlayerFunction: (Player) -> Boolean = { true } ) { - private val cache = HashSet() + private val cache = HashSet() lateinit var proxyService: ProxyService /** - * Checks the players inthe world and returns the interesing ones. + * Checks the players in the world and returns the interesting ones. */ - fun checkAndGet(): List { - val players = proxyService.getPlayersInWorld(locationFunction.invoke()).toMutableList() + fun checkAndGet(): List { + val players = proxyService.getPlayersInWorld(locationFunction.invoke()).toMutableList() for (player in players.toTypedArray()) { if (!filterPlayerFunction.invoke(player)) { diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/BallCrossPlatformProxy.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/BallCrossPlatformProxy.kt index 0d88bd4e0..74d39b304 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/BallCrossPlatformProxy.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/BallCrossPlatformProxy.kt @@ -3,11 +3,13 @@ package com.github.shynixn.blockball.impl import com.github.shynixn.blockball.api.business.proxy.BallProxy -import com.github.shynixn.blockball.api.business.service.EventService import com.github.shynixn.blockball.api.business.service.ProxyService import com.github.shynixn.blockball.api.persistence.entity.BallMeta -import com.github.shynixn.blockball.entity.compatibility.BallDeathEventEntity -import com.github.shynixn.blockball.entity.compatibility.BallTeleportEventEntity +import com.github.shynixn.blockball.event.BallRemoveEvent +import com.github.shynixn.blockball.event.BallTeleportEvent +import org.bukkit.Bukkit +import org.bukkit.Location +import org.bukkit.entity.Player import org.bukkit.plugin.Plugin import java.util.logging.Level @@ -40,11 +42,6 @@ class BallCrossPlatformProxy( return allPlayerTracker.proxyService } - /** - * Event dependency. - */ - lateinit var eventService: EventService - /** * Is the entity dead? */ @@ -78,8 +75,9 @@ class BallCrossPlatformProxy( * Teleports the ball to the given [location]. */ override fun teleport(location: L) { - val ballTeleportEvent = BallTeleportEventEntity(this, location as Any) - eventService.sendEvent(ballTeleportEvent) + require(location is Location) + val ballTeleportEvent = BallTeleportEvent(this, location) + Bukkit.getPluginManager().callEvent(ballTeleportEvent) if (ballTeleportEvent.isCancelled) { return @@ -112,12 +110,12 @@ class BallCrossPlatformProxy( /** * Shoot the ball by the given player. - * The calculated velocity can be manipulated by the BallKickEvent. + * The calculated velocity can be manipulated by the BallLeftClickEvent. * * @param player */ override fun

kickByPlayer(player: P) { - require(player is Any) + require(player is Player) if (!meta.enabledKick) { return @@ -128,12 +126,12 @@ class BallCrossPlatformProxy( /** * Pass the ball by the given player. - * The calculated velocity can be manipulated by the BallKickEvent + * The calculated velocity can be manipulated by the BallLeftClickEvent * * @param player */ override fun

passByPlayer(player: P) { - require(player is Any) + require(player is Player) if (!meta.enabledPass) { return @@ -150,8 +148,8 @@ class BallCrossPlatformProxy( return } - val ballDeathEvent = BallDeathEventEntity(this) - eventService.sendEvent(ballDeathEvent) + val ballDeathEvent = BallRemoveEvent(this) + Bukkit.getPluginManager().callEvent(ballDeathEvent) if (ballDeathEvent.isCancelled) { return diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt index 5447d4b33..521f2cf7d 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/BallHitboxEntity.kt @@ -6,15 +6,16 @@ import com.github.shynixn.blockball.api.business.service.* import com.github.shynixn.blockball.api.persistence.entity.BallMeta import com.github.shynixn.blockball.api.persistence.entity.Position import com.github.shynixn.blockball.entity.PositionEntity -import com.github.shynixn.blockball.entity.compatibility.BallKickEventEntity -import com.github.shynixn.blockball.entity.compatibility.BallPassEventEntity -import com.github.shynixn.blockball.entity.compatibility.BallRayTraceEventEntity -import com.github.shynixn.blockball.entity.compatibility.BallTouchEventEntity +import com.github.shynixn.blockball.event.BallLeftClickEvent +import com.github.shynixn.blockball.event.BallRightClickEvent +import com.github.shynixn.blockball.event.BallRayTraceEvent +import com.github.shynixn.blockball.event.BallTouchPlayerEvent import com.github.shynixn.blockball.impl.extension.toLocation import com.github.shynixn.blockball.impl.extension.toVector import com.github.shynixn.mcutils.packet.api.EntityType import com.github.shynixn.mcutils.packet.api.PacketService import com.github.shynixn.mcutils.packet.api.packet.* +import org.bukkit.Bukkit import org.bukkit.entity.Player import kotlin.math.abs import kotlin.math.atan2 @@ -82,11 +83,6 @@ class BallHitboxEntity(val entityId: Int) { */ lateinit var concurrencyService: ConcurrencyService - /** - * Event service dependency. - */ - lateinit var eventService: EventService - /** * Ball Proxy. */ @@ -128,8 +124,7 @@ class BallHitboxEntity(val entityId: Int) { /** * Destroys the ball for the given player. */ - fun destroy(player: Any) { - require(player is Player) + fun destroy(player: Player) { packetService.sendPacketOutEntityDestroy(player, PacketOutEntityDestroy().also { it.entityIds = listOf(entityId) }) @@ -138,7 +133,7 @@ class BallHitboxEntity(val entityId: Int) { /** * Kicks the hitbox for the given player interaction. */ - fun kickPlayer(player: Any, baseMultiplier: Double, isPass: Boolean) { + fun kickPlayer(player: Player, baseMultiplier: Double, isPass: Boolean) { if (skipCounter > 0) { return } @@ -159,7 +154,7 @@ class BallHitboxEntity(val entityId: Int) { * Ticks the hitbox. * @param players watching this hitbox. */ - fun

tick(players: List

) { + fun tick(players: List) { if (skipCounter > 0) { skipCounter-- } @@ -170,7 +165,6 @@ class BallHitboxEntity(val entityId: Int) { // Visible position makes the slime hitbox better align with the ball. val visiblePosition = position.clone().add(0.0, -0.5, 0.0).add(0.0, meta.hitBoxRelocation, 0.0) for (player in players) { - require(player is Player) packetService.sendPacketOutEntityTeleport(player, PacketOutEntityTeleport().also { it.entityId = entityId it.target = visiblePosition.toLocation() @@ -181,7 +175,7 @@ class BallHitboxEntity(val entityId: Int) { return } - checkMovementInteractions(players as List) + checkMovementInteractions(players) if (motion.x == 0.0 && motion.y == 0.0 && motion.z == 0.0) { return @@ -189,12 +183,12 @@ class BallHitboxEntity(val entityId: Int) { val rayTraceResult = rayTracingService.rayTraceMotion(position, motion) - val rayTraceEvent = BallRayTraceEventEntity( + val rayTraceEvent = BallRayTraceEvent( ball, rayTraceResult.hitBlock, proxyService.toLocation(rayTraceResult.targetPosition), rayTraceResult.blockdirection ) - eventService.sendEvent(rayTraceEvent) + Bukkit.getPluginManager().callEvent(rayTraceEvent) if (rayTraceEvent.isCancelled) { return @@ -220,7 +214,7 @@ class BallHitboxEntity(val entityId: Int) { /** * Executes the kick. */ - private fun executeKickPass(player: Any, prevEyeLoc: Any, baseMultiplier: Double, isPass: Boolean) { + private fun executeKickPass(player: Player, prevEyeLoc: Any, baseMultiplier: Double, isPass: Boolean) { var kickVector = proxyService.getLocationDirection(prevEyeLoc) val eyeLocation = proxyService.getPlayerEyeLocation(player) val spinV = calculateSpinVelocity(proxyService.getLocationDirection(eyeLocation), kickVector) @@ -235,12 +229,12 @@ class BallHitboxEntity(val entityId: Int) { kickVector.y = verticalMod val event = if (isPass) { - val event = BallPassEventEntity(ball, player, proxyService.toVector(kickVector)) - eventService.sendEvent(event) + val event = BallRightClickEvent(ball, player, proxyService.toVector(kickVector)) + Bukkit.getPluginManager().callEvent(event) Pair(event, proxyService.toPosition(event.velocity)) } else { - val event = BallKickEventEntity(ball, player, proxyService.toVector(kickVector)) - eventService.sendEvent(event) + val event = BallLeftClickEvent(ball, player, proxyService.toVector(kickVector)) + Bukkit.getPluginManager().callEvent(event) Pair(event, proxyService.toPosition(event.velocity)) } @@ -258,7 +252,7 @@ class BallHitboxEntity(val entityId: Int) { /** * Checks movement interactions with the ball. */ - private fun checkMovementInteractions(players: List) { + private fun checkMovementInteractions(players: List) { if (!meta.enabledInteract || skipCounter > 0) { return } @@ -278,20 +272,20 @@ class BallHitboxEntity(val entityId: Int) { .normalize().multiply(meta.movementModifier.horizontalTouchModifier) vector.y = 0.1 * meta.movementModifier.verticalTouchModifier - val ballTouchEvent = BallTouchEventEntity(ball, player, proxyService.toVector(vector)) - eventService.sendEvent(ballTouchEvent) + val ballTouchPlayerEvent = BallTouchPlayerEvent(ball, player, proxyService.toVector(vector)) + Bukkit.getPluginManager().callEvent(ballTouchPlayerEvent) - if (ballTouchEvent.isCancelled) { + if (ballTouchPlayerEvent.isCancelled) { continue } // Correct the yaw of the ball after bouncing. this.position.yaw = - getYawFromVector(origin, proxyService.toPosition(ballTouchEvent.velocity).normalize()) * -1 + getYawFromVector(origin, proxyService.toPosition(ballTouchPlayerEvent.velocity).normalize()) * -1 this.angularVelocity = 0.0 // Move the ball a little bit up otherwise wallcollision of ground immidately cancel movement. this.position.y += 0.25 - this.motion = proxyService.toPosition(ballTouchEvent.velocity) + this.motion = proxyService.toPosition(ballTouchPlayerEvent.velocity) this.skipCounter = meta.interactionCoolDown } } diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/BallListener.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/BallListener.kt index a63e1c50b..edd2f0bf1 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/BallListener.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/BallListener.kt @@ -2,12 +2,12 @@ package com.github.shynixn.blockball.impl.listener -import com.github.shynixn.blockball.api.bukkit.event.* import com.github.shynixn.blockball.api.business.enumeration.BallActionType import com.github.shynixn.blockball.api.business.proxy.BallProxy import com.github.shynixn.blockball.api.business.service.BallEntityService import com.github.shynixn.blockball.api.business.service.ParticleService import com.github.shynixn.blockball.api.business.service.SoundService +import com.github.shynixn.blockball.event.* import com.google.inject.Inject import org.bukkit.Location import org.bukkit.event.EventHandler @@ -35,7 +35,7 @@ class BallListener @Inject constructor( * @param event event */ @EventHandler - fun ballDeathEvent(event: BallDeathEvent) { + fun ballDeathEvent(event: BallRemoveEvent) { this.ballEntityService.removeTrackedBall(event.ball) } @@ -45,7 +45,7 @@ class BallListener @Inject constructor( * @param event event */ @EventHandler - fun ballKickEvent(event: BallKickEvent) { + fun ballKickEvent(event: BallLeftClickEvent) { this.playEffects(event.ball, BallActionType.ONKICK) } @@ -53,7 +53,7 @@ class BallListener @Inject constructor( * Gets called when a player right clicks a ball. */ @EventHandler - fun ballPassEvent(event: BallPassEvent) { + fun ballPassEvent(event: BallRightClickEvent) { this.playEffects(event.ball, BallActionType.ONPASS) } @@ -63,7 +63,7 @@ class BallListener @Inject constructor( * @param event event */ @EventHandler - fun ballInteractEvent(event: BallTouchEvent) { + fun ballInteractEvent(event: BallTouchPlayerEvent) { this.playEffects(event.ball, BallActionType.ONINTERACTION) } diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/GameListener.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/GameListener.kt index 2432ba449..909846fc9 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/GameListener.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/GameListener.kt @@ -1,11 +1,11 @@ package com.github.shynixn.blockball.impl.listener -import com.github.shynixn.blockball.api.bukkit.event.BallRayTraceEvent -import com.github.shynixn.blockball.api.bukkit.event.BallTouchEvent import com.github.shynixn.blockball.api.business.enumeration.Permission import com.github.shynixn.blockball.api.business.enumeration.Team import com.github.shynixn.blockball.api.business.service.* import com.github.shynixn.blockball.api.persistence.entity.HubGame +import com.github.shynixn.blockball.event.BallRayTraceEvent +import com.github.shynixn.blockball.event.BallTouchPlayerEvent import com.github.shynixn.blockball.impl.extension.hasPermission import com.github.shynixn.blockball.impl.extension.toLocation import com.github.shynixn.blockball.impl.extension.toPosition @@ -261,7 +261,7 @@ class GameListener @Inject constructor( * Caches the last interacting entity with the ball. */ @EventHandler - fun onBallInteractEvent(event: BallTouchEvent) { + fun onBallInteractEvent(event: BallTouchPlayerEvent) { val game = gameService.getAllGames().find { p -> p.ball != null && p.ball!! == event.ball } if (game != null) { diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/MinigameListener.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/MinigameListener.kt index ce1d79645..af46d49b4 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/MinigameListener.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/listener/MinigameListener.kt @@ -1,6 +1,5 @@ package com.github.shynixn.blockball.impl.listener -import com.github.shynixn.blockball.api.bukkit.event.GameGoalEvent import com.github.shynixn.blockball.api.business.enumeration.GameType import com.github.shynixn.blockball.api.business.enumeration.MatchTimeCloseType import com.github.shynixn.blockball.api.business.enumeration.Permission @@ -8,6 +7,7 @@ import com.github.shynixn.blockball.api.business.service.ConfigurationService import com.github.shynixn.blockball.api.business.service.GameMiniGameActionService import com.github.shynixn.blockball.api.business.service.GameService import com.github.shynixn.blockball.api.persistence.entity.MiniGame +import com.github.shynixn.blockball.event.GameGoalEvent import com.github.shynixn.blockball.impl.extension.hasPermission import com.google.inject.Inject import org.bukkit.event.EventHandler diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/BallEntityServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/BallEntityServiceImpl.kt index a75aa0d4a..b719b182d 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/BallEntityServiceImpl.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/BallEntityServiceImpl.kt @@ -3,13 +3,14 @@ package com.github.shynixn.blockball.impl.service import com.github.shynixn.blockball.api.business.proxy.BallProxy import com.github.shynixn.blockball.api.business.service.* import com.github.shynixn.blockball.api.persistence.entity.BallMeta -import com.github.shynixn.blockball.entity.compatibility.BallSpawnEventEntity +import com.github.shynixn.blockball.event.BallSpawnEvent import com.github.shynixn.blockball.impl.BallCrossPlatformProxy import com.github.shynixn.blockball.impl.BallDesignEntity import com.github.shynixn.blockball.impl.BallHitboxEntity import com.github.shynixn.mcutils.common.item.ItemService import com.github.shynixn.mcutils.packet.api.PacketService import com.google.inject.Inject +import org.bukkit.Bukkit import org.bukkit.plugin.Plugin class BallEntityServiceImpl @Inject constructor( @@ -18,7 +19,6 @@ class BallEntityServiceImpl @Inject constructor( private val concurrencyService: ConcurrencyService, private val itemService: ItemService, private val rayTracingService: RayTracingService, - private val eventService: EventService, private val plugin: Plugin ) : BallEntityService { @@ -47,7 +47,6 @@ class BallEntityServiceImpl @Inject constructor( ballHitBoxEntity.rayTracingService = rayTracingService ballHitBoxEntity.concurrencyService = concurrencyService ballHitBoxEntity.packetService = packetService - ballHitBoxEntity.eventService = eventService ballHitBoxEntity.proxyService = proxyService val ballDesignEntity = BallDesignEntity(proxyService.createNewEntityId()) @@ -58,11 +57,10 @@ class BallEntityServiceImpl @Inject constructor( val ball = BallCrossPlatformProxy(meta, ballDesignEntity, ballHitBoxEntity, plugin) ballDesignEntity.ball = ball ballHitBoxEntity.ball = ball - ball.eventService = eventService ball.proxyService = proxyService - val event = BallSpawnEventEntity(ball) - eventService.sendEvent(event) + val event = BallSpawnEvent(ball) + Bukkit.getPluginManager().callEvent(event) if (event.isCancelled) { return null diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/EventServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/EventServiceImpl.kt deleted file mode 100644 index 42c724f0b..000000000 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/EventServiceImpl.kt +++ /dev/null @@ -1,129 +0,0 @@ -package com.github.shynixn.blockball.impl.service - -import com.github.shynixn.blockball.api.bukkit.event.BallSpawnEvent -import com.github.shynixn.blockball.api.business.service.EventService -import com.github.shynixn.blockball.entity.compatibility.* -import org.bukkit.Bukkit -import org.bukkit.Location -import org.bukkit.entity.Player -import org.bukkit.util.Vector - -class EventServiceImpl : EventService { - /** - * Sends a custom event. - */ - override fun sendEvent(event: Any) { - require(event is BlockBallEventEntity) - - when (event) { - is BallDeathEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.BallDeathEvent(event.ballProxy) - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - } - is BallKickEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.BallKickEvent( - event.ballProxy, - event.player as Player, - event.velocity as Vector - ) - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - event.velocity = bukkitEvent.velocity - } - is BallPassEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.BallPassEvent( - event.ballProxy, - event.player as Player, - event.velocity as Vector - ) - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - event.velocity = bukkitEvent.velocity - } - is BallRayTraceEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.BallRayTraceEvent( - event.ballProxy, event.hitBlock, - event.targetLocation as Location, event.blockDirection - ) - - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - event.blockDirection = bukkitEvent.blockDirection - event.hitBlock = bukkitEvent.hitBlock - event.targetLocation = bukkitEvent.targetLocation - } - is BallSpawnEventEntity -> { - val bukkitEvent = BallSpawnEvent(event.ballProxy) - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - } - is BallTeleportEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.BallTeleportEvent( - event.ballProxy, - event.targetLocation as Location - ) - - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - event.targetLocation = bukkitEvent.targetLocation - } - is BallTouchEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.BallTouchEvent( - event.ballProxy, - event.player as Player, - event.velocity as Vector - ) - - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - event.velocity = bukkitEvent.velocity - } - is GameEndEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.GameEndEvent( - event.winningTeam, - event.game - ) - - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - event.winningTeam = bukkitEvent.winningTeam - } - is GameGoalEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.GameGoalEvent( - event.player as Player, - event.team, - event.game - ) - - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - event.team = bukkitEvent.team - event.player = bukkitEvent.player - } - is GameJoinEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.GameJoinEvent( - event.player as Player, - event.game - ) - - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - event.player = bukkitEvent.player - } - is GameLeaveEventEntity -> { - val bukkitEvent = com.github.shynixn.blockball.api.bukkit.event.GameLeaveEvent( - event.player as Player, - event.game - ) - - Bukkit.getServer().pluginManager.callEvent(bukkitEvent) - event.isCancelled = bukkitEvent.isCancelled - event.player = bukkitEvent.player - } - else -> { - throw IllegalArgumentException("This event type $event does not exist!") - } - } - } -} diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/GameActionServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/GameActionServiceImpl.kt index be0f62941..09f619904 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/GameActionServiceImpl.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/GameActionServiceImpl.kt @@ -7,13 +7,15 @@ import com.github.shynixn.blockball.api.business.enumeration.* import com.github.shynixn.blockball.api.business.proxy.PluginProxy import com.github.shynixn.blockball.api.business.service.* import com.github.shynixn.blockball.api.persistence.entity.* -import com.github.shynixn.blockball.entity.compatibility.GameJoinEventEntity -import com.github.shynixn.blockball.entity.compatibility.GameLeaveEventEntity +import com.github.shynixn.blockball.event.GameJoinEvent +import com.github.shynixn.blockball.event.GameLeaveEvent import com.github.shynixn.blockball.impl.PacketHologram import com.github.shynixn.blockball.impl.extension.getCompatibilityServerVersion import com.github.shynixn.mcutils.common.Version import com.github.shynixn.mcutils.packet.api.PacketService import com.google.inject.Inject +import org.bukkit.Bukkit +import org.bukkit.entity.Player import org.bukkit.plugin.Plugin import java.util.logging.Level @@ -57,7 +59,6 @@ class GameActionServiceImpl @Inject constructor( private val dependencyBossBarApiService: DependencyBossBarApiService, private val gameSoccerService: GameSoccerService, private val placeholderService: PlaceholderService, - private val eventService: EventService, private val proxyService: ProxyService, private val packetService: PacketService, private val plugin: Plugin, @@ -85,8 +86,9 @@ class GameActionServiceImpl @Inject constructor( this.leaveGame(g, player) } - val event = GameJoinEventEntity(game, player) - eventService.sendEvent(event) + require(player is Player) + val event = GameJoinEvent(player, game) + Bukkit.getPluginManager().callEvent(event) if (event.isCancelled) { return false @@ -107,9 +109,9 @@ class GameActionServiceImpl @Inject constructor( * Does nothing if the player is not in the game. */ override fun

leaveGame(game: Game, player: P) { - require(player is Any) - val event = GameLeaveEventEntity(game, player) - eventService.sendEvent(event) + require(player is Player) + val event = GameLeaveEvent(player, game) + Bukkit.getPluginManager().callEvent(event) if (event.isCancelled) { return diff --git a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/GameSoccerServiceImpl.kt b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/GameSoccerServiceImpl.kt index 6b8a26e98..a7a95db03 100644 --- a/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/GameSoccerServiceImpl.kt +++ b/blockball-bukkit-plugin/src/main/java/com/github/shynixn/blockball/impl/service/GameSoccerServiceImpl.kt @@ -6,9 +6,11 @@ import com.github.shynixn.blockball.api.business.service.* import com.github.shynixn.blockball.api.persistence.entity.CommandMeta import com.github.shynixn.blockball.api.persistence.entity.Game import com.github.shynixn.blockball.api.persistence.entity.TeamMeta -import com.github.shynixn.blockball.entity.compatibility.GameEndEventEntity -import com.github.shynixn.blockball.entity.compatibility.GameGoalEventEntity +import com.github.shynixn.blockball.event.GameEndEvent +import com.github.shynixn.blockball.event.GameGoalEvent import com.google.inject.Inject +import org.bukkit.Bukkit +import org.bukkit.entity.Player class GameSoccerServiceImpl @Inject constructor( private val concurrencyService: ConcurrencyService, @@ -17,7 +19,6 @@ class GameSoccerServiceImpl @Inject constructor( private val ballEntityService: BallEntityService, private val placeholderService: PlaceholderService, private val proxyService: ProxyService, - private val eventService: EventService ) : GameSoccerService { /** * Handles the game actions per tick. [ticks] parameter shows the amount of ticks @@ -173,8 +174,8 @@ class GameSoccerServiceImpl @Inject constructor( game.lastInteractedEntity = interactionEntity } - val gameGoalEntityEvent = GameGoalEventEntity(game, interactionEntity, team) - eventService.sendEvent(gameGoalEntityEvent) + val gameGoalEntityEvent = GameGoalEvent(interactionEntity as Player?, team, game) + Bukkit.getPluginManager().callEvent(gameGoalEntityEvent) if (gameGoalEntityEvent.isCancelled) { return @@ -293,8 +294,8 @@ class GameSoccerServiceImpl @Inject constructor( * Gets called when the given [game] gets win by the given [team]. */ override fun onWin(game: Game, team: Team, teamMeta: TeamMeta) { - val event = GameEndEventEntity(game, team) - eventService.sendEvent(event) + val event =GameEndEvent(team, game) + Bukkit.getPluginManager().callEvent(event) if (event.isCancelled) { return