Skip to content

Commit

Permalink
Fix fly bug on WorldChange
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelillo15 committed Nov 10, 2023
1 parent 08600cc commit 59a82ec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public void registerListeners() {
registerListener(injector.getInstance(OnAttack.class));
registerListener(injector.getInstance(OnDamage.class));
registerListener(injector.getInstance(CommandManagerHandler.class));
registerListener(injector.getInstance(OnWorldChange.class));
injector.getInstance(EventManager.class).registerListener(injector.getInstance(OnAddonDisable.class));

if (Config.Freeze.enabled()) registerListener(injector.getInstance(FreezeListener.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package es.angelillo15.mast.bukkit.listener.staffmode;

import com.google.inject.Inject;
import com.nookure.mast.api.event.BukkitListener;
import es.angelillo15.mast.api.IStaffPlayer;
import es.angelillo15.mast.api.managers.StaffManager;
import es.angelillo15.mast.bukkit.MAStaff;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerChangedWorldEvent;

public class OnWorldChange implements BukkitListener<PlayerChangedWorldEvent> {
@Inject
private StaffManager staffManager;
@Override
@EventHandler
public void handle(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
IStaffPlayer staffPlayer = staffManager.getStaffPlayer(player);

if (staffPlayer == null) return;
if (!staffPlayer.isStaffMode()) return;

Bukkit.getScheduler().runTaskLater(MAStaff.getPlugin(), () -> {
player.setAllowFlight(true);
}, 20L);
}
}

0 comments on commit 59a82ec

Please sign in to comment.