Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-205 Add on FightUntagEvent allow player flight again, coz its disable every time #205

Merged
merged 4 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void onEnable() {
new FightTagController(this.fightManager, this.pluginConfig),
new LogoutController(this.fightManager, this.logoutService, notificationAnnouncer, this.pluginConfig),
new FightUnTagController(this.fightManager, this.pluginConfig, this.logoutService),
new FightActionBlockerController(this.fightManager, notificationAnnouncer, this.pluginConfig),
new FightActionBlockerController(this.fightManager, notificationAnnouncer, this.pluginConfig, server),
new FightPearlController(this.pluginConfig.pearl, notificationAnnouncer, this.fightManager, this.fightPearlService),
new UpdaterNotificationController(updaterService, this.pluginConfig, this.audienceProvider, miniMessage),
new RegionController(notificationAnnouncer, this.regionProvider, this.fightManager, this.pluginConfig),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.WhitelistBlacklistMode;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.FightUntagEvent;
import com.eternalcode.combat.notification.NotificationAnnouncer;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -24,11 +27,13 @@ public class FightActionBlockerController implements Listener {
private final FightManager fightManager;
private final NotificationAnnouncer announcer;
private final PluginConfig config;
private final Server server;

public FightActionBlockerController(FightManager fightManager, NotificationAnnouncer announcer, PluginConfig config) {
public FightActionBlockerController(FightManager fightManager, NotificationAnnouncer announcer, PluginConfig config, Server server) {
this.fightManager = fightManager;
this.announcer = announcer;
this.config = config;
this.server = server;
}

@EventHandler
Expand Down Expand Up @@ -123,6 +128,24 @@ void onFly(PlayerToggleFlightEvent event) {
}
}

@EventHandler
void onUnTag(FightUntagEvent event) {
if (!this.config.settings.disableFlying) {
return;
}

UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);

if (player == null) {
return;
}
GameMode playerGameMode = player.getGameMode();
if (playerGameMode == GameMode.CREATIVE || playerGameMode == GameMode.SPECTATOR) {
player.setAllowFlight(true);
}
}

@EventHandler
void onDamage(EntityDamageEvent event) {
if (!this.config.settings.disableElytraOnDamage) {
Expand Down
Loading