-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
10 changed files
with
115 additions
and
69 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
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
61 changes: 61 additions & 0 deletions
61
src/main/java/com/eternalcode/combat/fight/controller/FightMessageController.java
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,61 @@ | ||
package com.eternalcode.combat.fight.controller; | ||
|
||
import com.eternalcode.combat.config.implementation.PluginConfig; | ||
import com.eternalcode.combat.fight.FightManager; | ||
import com.eternalcode.combat.fight.bossbar.FightBossBarService; | ||
import com.eternalcode.combat.fight.event.FightTagEvent; | ||
import com.eternalcode.combat.notification.NotificationAnnouncer; | ||
import org.bukkit.Server; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
|
||
public class FightMessageController implements Listener { | ||
|
||
private final FightManager fightManager; | ||
private final NotificationAnnouncer announcer; | ||
private final FightBossBarService bossBarService; | ||
private final PluginConfig config; | ||
private final Server server; | ||
|
||
public FightMessageController(FightManager fightManager, NotificationAnnouncer announcer, FightBossBarService bossBarService, PluginConfig config, Server server) { | ||
this.fightManager = fightManager; | ||
this.announcer = announcer; | ||
this.bossBarService = bossBarService; | ||
this.config = config; | ||
this.server = server; | ||
} | ||
|
||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) | ||
void onTag(FightTagEvent event) { | ||
Player player = this.server.getPlayer(event.getPlayer()); | ||
|
||
if (player == null) { | ||
throw new IllegalStateException("Player cannot be null!"); | ||
} | ||
|
||
if (this.fightManager.isInCombat(player.getUniqueId())) { | ||
return; | ||
} | ||
|
||
this.announcer.sendMessage(player, this.config.messages.playerTagged); | ||
} | ||
|
||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) | ||
void onUnTag(FightTagEvent event) { | ||
Player player = this.server.getPlayer(event.getPlayer()); | ||
|
||
if (player == null) { | ||
throw new IllegalStateException("Player cannot be null!"); | ||
} | ||
|
||
if (!this.fightManager.isInCombat(player.getUniqueId())) { | ||
return; | ||
} | ||
|
||
this.announcer.sendMessage(player, this.config.messages.playerUntagged); | ||
this.bossBarService.hide(event.getPlayer()); | ||
} | ||
|
||
} |
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