-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Tweak to fix Flight being turned off when changing world via a …
…non portal teleport. Temporarily disables TreeTwerking while I work out how to solve an issue with it.
- Loading branch information
1 parent
ddff5bd
commit 914181f
Showing
5 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...rotein/treebotweakssp/Tweaks/MaintainFlightBetweenWorlds/MaintainFlightBetweenWorlds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package me.shakeforprotein.treebotweakssp.Tweaks.MaintainFlightBetweenWorlds; | ||
|
||
import me.shakeforprotein.treebotweakssp.TreeboTweaksSP; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerChangedWorldEvent; | ||
|
||
import java.util.HashMap; | ||
|
||
public class MaintainFlightBetweenWorlds implements Listener { | ||
|
||
|
||
private TreeboTweaksSP pl; | ||
private HashMap<Player, Boolean> flyingPlayers = new HashMap<>(); | ||
|
||
public MaintainFlightBetweenWorlds(TreeboTweaksSP main){ | ||
this.pl = main; | ||
|
||
Bukkit.getScheduler().runTaskTimer(pl, ()->{ | ||
flyingPlayers.clear(); | ||
for(Player player : Bukkit.getOnlinePlayers()){ | ||
if(player.isFlying() && player.getAllowFlight()){ | ||
flyingPlayers.put(player, true); | ||
} else { | ||
flyingPlayers.put(player, false); | ||
} | ||
} | ||
}, 60L, 5L); | ||
} | ||
|
||
@EventHandler | ||
public void maintainFlight(PlayerChangedWorldEvent e){ | ||
if(flyingPlayers.containsKey(e.getPlayer()) && e.getPlayer().hasPermission("essentials.fly")){ | ||
Bukkit.getScheduler().runTaskLater(pl, ()->{ | ||
e.getPlayer().setAllowFlight(true); | ||
e.getPlayer().setFlying(true); | ||
}, 2L); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters