Skip to content

Commit 5c0258b

Browse files
committed
Add on FightUntagEvent allow player flight again, coz its disable every time
1 parent c7f93d9 commit 5c0258b

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void onEnable() {
151151
new FightTagController(this.fightManager, this.pluginConfig),
152152
new LogoutController(this.fightManager, this.logoutService, notificationAnnouncer, this.pluginConfig),
153153
new FightUnTagController(this.fightManager, this.pluginConfig, this.logoutService),
154-
new FightActionBlockerController(this.fightManager, notificationAnnouncer, this.pluginConfig),
154+
new FightActionBlockerController(this.fightManager, notificationAnnouncer, this.pluginConfig, server),
155155
new FightPearlController(this.pluginConfig.pearl, notificationAnnouncer, this.fightManager, this.fightPearlService),
156156
new UpdaterNotificationController(updaterService, this.pluginConfig, this.audienceProvider, miniMessage),
157157
new RegionController(notificationAnnouncer, this.regionProvider, this.fightManager, this.pluginConfig),

eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/controller/FightActionBlockerController.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import com.eternalcode.combat.config.implementation.PluginConfig;
44
import com.eternalcode.combat.WhitelistBlacklistMode;
55
import com.eternalcode.combat.fight.FightManager;
6+
import com.eternalcode.combat.fight.event.FightUntagEvent;
67
import com.eternalcode.combat.notification.NotificationAnnouncer;
78
import org.bukkit.Material;
9+
import org.bukkit.Server;
810
import org.bukkit.block.Block;
911
import org.bukkit.entity.Player;
1012
import org.bukkit.event.EventHandler;
@@ -24,11 +26,13 @@ public class FightActionBlockerController implements Listener {
2426
private final FightManager fightManager;
2527
private final NotificationAnnouncer announcer;
2628
private final PluginConfig config;
29+
private final Server server;
2730

28-
public FightActionBlockerController(FightManager fightManager, NotificationAnnouncer announcer, PluginConfig config) {
31+
public FightActionBlockerController(FightManager fightManager, NotificationAnnouncer announcer, PluginConfig config, Server server) {
2932
this.fightManager = fightManager;
3033
this.announcer = announcer;
3134
this.config = config;
35+
this.server = server;
3236
}
3337

3438
@EventHandler
@@ -123,6 +127,22 @@ void onFly(PlayerToggleFlightEvent event) {
123127
}
124128
}
125129

130+
@EventHandler
131+
void onUnTag(FightUntagEvent event) {
132+
if (!this.config.settings.shouldPreventFlying) {
133+
return;
134+
}
135+
136+
UUID uniqueId = event.getPlayer();
137+
Player player = this.server.getPlayer(uniqueId);
138+
139+
if (player == null) {
140+
return;
141+
}
142+
143+
player.setAllowFlight(true);
144+
}
145+
126146
@EventHandler
127147
void onDamage(EntityDamageEvent event) {
128148
if (!this.config.settings.shouldElytraDisableOnDamage) {

0 commit comments

Comments
 (0)