Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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 @@ -6,6 +6,8 @@
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

import com.gmail.llmdlio.townyflight.events.PlayerFlightChangeEvent;
import com.palmergames.bukkit.util.BukkitTools;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
Expand Down Expand Up @@ -196,6 +198,7 @@ public void removeFlight(Player player, boolean silent, boolean forced, String c
}
player.setAllowFlight(false);
cachePlayerFlight(player, false);
BukkitTools.fireEvent(new PlayerFlightChangeEvent(player, false));
}

/**
Expand All @@ -208,6 +211,7 @@ public void addFlight(Player player, boolean silent) {
if (!silent) Message.of("flightOnMsg").to(player);
player.setAllowFlight(true);
cachePlayerFlight(player, true);
BukkitTools.fireEvent(new PlayerFlightChangeEvent(player, true));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.gmail.llmdlio.townyflight.events;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use event rather than the plural


import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class PlayerFlightChangeEvent extends Event {
private static final HandlerList handlers = new HandlerList();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HANDLER_LIST

private final Player player;
private final boolean flightAllowed;

public PlayerFlightChangeEvent(Player player, boolean flightAllowed) {
this.player = player;
this.flightAllowed = flightAllowed;
}

public Player getPlayer() {
return player;
}

public boolean isFlightAllowed() {
return flightAllowed;
}

public static HandlerList getHandlerList() {
return handlers;
}

@Override
public @NotNull HandlerList getHandlers() {
return handlers;
}
}