Skip to content

Commit

Permalink
- Fix for players who are in Creative or Spectator mode losing their
Browse files Browse the repository at this point in the history
flight on join.
  - Closes #23.
- Fix for config not updating latest run version.
  - Closes #23.
  • Loading branch information
LlmDl committed Jan 30, 2020
1 parent 5314edc commit 801f972
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.llmdlio</groupId>
<artifactId>TownyFlight</artifactId>
<version>1.5.5</version>
<version>1.5.6</version>
<name>TownyFlight</name>
<description>A flight plugin for Towny servers.</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ private void addComment(String path, String... comment) {
}

private void addDefault(String path, Object defaultValue) {
if (path.equals("Version"))
config.set(path, plugin.getDescription().getVersion());
if (!hasPath(path))
config.set(path, defaultValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public PlayerEnterTownListener(TownyFlight instance) {
* Used only if the config has auto-flight enabled.
*/
@EventHandler(priority = EventPriority.LOWEST)
private void playerEnterTownEvent (PlayerEnterTownEvent event) {
private void playerEnterTownEvent (PlayerEnterTownEvent event) {
final Player player = event.getPlayer();
if (player.hasPermission("townyflight.bypass")) // Added in 1.2.5 to stop players with the bypass node from losing flight when entering a town.
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ public PlayerJoinListener(TownyFlight instance) {
@EventHandler(priority = EventPriority.MONITOR)
private void playerJoinEvent (PlayerJoinEvent event) throws NotRegisteredException {
final Player player = event.getPlayer();

Bukkit.getScheduler().runTaskLater(this.plugin, new Runnable() {
@Override
public void run() {
if (!TownyFlight.canFly(player, true))
boolean canFly = TownyFlight.canFly(player, true);
boolean isFlying = player.isFlying();
if (isFlying && canFly)
return;

if (TownyFlight.autoEnableFlight) {
if (isFlying && !canFly) {
TownyFlight.toggleFlight(player, false, true, "");
return;
}

if (!isFlying && canFly && TownyFlight.autoEnableFlight)
TownyFlight.toggleFlight(player, false, false, "");
} else {
player.setFallDistance(-100000);
}
}
}, 1);
}
Expand Down

0 comments on commit 801f972

Please sign in to comment.