Fixed a few known issues with F Fly

This commit is contained in:
DroppingAnvil 2020-04-30 14:27:26 -05:00 committed by droppinganvil
parent 86cba0e24c
commit e37745eff9
7 changed files with 10 additions and 36 deletions

View File

@ -82,7 +82,6 @@ public class FactionsPlugin extends MPlugin {
public boolean mc114 = false;
public boolean mc115 = false;
public boolean useNonPacketParticles = false;
public static boolean factionsFlight = false;
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
SkriptAddon skriptAddon;
private FactionsPlayerListener factionsPlayerListener;
@ -254,8 +253,6 @@ public class FactionsPlugin extends MPlugin {
log("Minecraft Version 1.9 or higher found, using non packet based particle API");
}
if (getConfig().getBoolean("enable-faction-flight")) factionsFlight = true;
if (getServer().getPluginManager().getPlugin("Skript") != null) {
log("Skript was found! Registering FactionsPlugin Addon...");
skriptAddon = Skript.registerAddon(this);

View File

@ -101,27 +101,15 @@ public class CmdDisband extends FCommand {
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
if (follower.getFaction() == faction) {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
if (!follower.canFlyAtLocation() && FactionsPlugin.factionsFlight) {
follower.setFFlying(false, false);
}
} else {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
}
}
if (FactionsPlugin.factionsFlight) {
faction.disband(context.player, PlayerDisbandReason.COMMAND);
context.fPlayer.setFFlying(false, false);
Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
return;
}
} else {
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
}
faction.disband(context.player, PlayerDisbandReason.COMMAND);
Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
if (!context.fPlayer.canFlyAtLocation() && FactionsPlugin.factionsFlight) {
context.fPlayer.setFFlying(false, false);
}
}
}

View File

@ -28,6 +28,7 @@ public class CmdFly extends FCommand {
public static BukkitTask particleTask = null;
public static BukkitTask flyTask = null;
public static boolean autoenable = FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable");
public static final boolean fly = FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight");
public CmdFly() {
@ -46,7 +47,7 @@ public class CmdFly extends FCommand {
particleTask = Bukkit.getScheduler().runTaskTimerAsynchronously(FactionsPlugin.instance, () -> {
for (FPlayer fPlayer : flyMap.keySet()) {
Player player = fPlayer.getPlayer();
if (!player.isOnline() || !player.isFlying()) continue;
if (player == null || !player.isOnline() || !fPlayer.isFlying()) continue;
if (!FactionsPlugin.getInstance().mc17) {
if (player.getGameMode() == GameMode.SPECTATOR) continue;
}
@ -66,7 +67,7 @@ public class CmdFly extends FCommand {
for (FPlayer fPlayer : flyMap.keySet()) {
Player player = fPlayer.getPlayer();
if (player == null
|| !player.isFlying()
|| !fPlayer.isFlying()
|| player.getGameMode() == GameMode.CREATIVE
|| !FactionsPlugin.getInstance().mc17 && player.getGameMode() == GameMode.SPECTATOR) {
continue;
@ -113,12 +114,10 @@ public class CmdFly extends FCommand {
public static void disableFlight(final FPlayer fme) {
fme.setFlying(false);
flyMap.remove(fme);
}
private static void disableFlightSync(FPlayer fme) {
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fme.setFFlying(false, false));
flyMap.remove(fme);
}
private static void checkEnemiesSync(FPlayer fp) {
@ -164,7 +163,6 @@ public class CmdFly extends FCommand {
private void toggleFlight(final boolean toggle, final FPlayer fme, CommandContext context) {
if (toggle) {
fme.setFlying(false);
flyMap.remove(fme);
return;
}

View File

@ -30,10 +30,6 @@ public class CmdReload extends FCommand {
FactionsPlugin.getInstance().loadLang();
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
FactionsPlugin.factionsFlight = true;
}
if (!FactionsPlugin.getInstance().mc17) {
FactionsPlayerListener.loadCorners();
}

View File

@ -577,7 +577,7 @@ public class FactionsPlayerListener implements Listener {
}
@Deprecated
public void checkCanFly(FPlayer me) {
if (!FactionsPlugin.factionsFlight || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
if (!CmdFly.fly || !CmdFly.autoenable)
return;
if (me.isFlying()) return;
if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) {
@ -726,7 +726,6 @@ public class FactionsPlayerListener implements Listener {
}
if (FCmdRoot.instance.fFlyEnabled && CmdFly.autoenable && CmdFly.checkFly(me, me.getPlayer(), factionTo)) {
me.setFFlying(true, false);
CmdFly.flyMap.put(me, true);
if (CmdFly.particleTask == null)
CmdFly.startParticles();
}

View File

@ -15,8 +15,6 @@ public class UtilFly {
*/
@Deprecated
public static void run() {
if (!FactionsPlugin.factionsFlight)
return;
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
for (FPlayer fp : FPlayers.getInstance().getOnlinePlayers()) {
@ -28,8 +26,6 @@ public class UtilFly {
@Deprecated
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
if (!FactionsPlugin.factionsFlight)
return;
fp.getPlayer().setAllowFlight(fly);
fp.getPlayer().setFlying(fly);

View File

@ -963,19 +963,19 @@ public abstract class MemoryFPlayer implements FPlayer {
}
public void setFFlying(boolean fly, boolean damage) {
if (!FactionsPlugin.factionsFlight)
return;
Player player = getPlayer();
if (player == null) return;
assert player != null;
player.setAllowFlight(fly);
player.setFlying(fly);
if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly)
if (!fly) {
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
} else {
CmdFly.flyMap.put(this, true);
}
} else {
msg(TL.COMMAND_FLY_DAMAGE);
}
@ -983,7 +983,7 @@ public abstract class MemoryFPlayer implements FPlayer {
// If leaving fly mode, don't let them take fall damage for x seconds.
if (!fly) {
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
CmdFly.flyMap.remove(player.getName());
CmdFly.flyMap.remove(this);
// If the value is 0 or lower, make them take fall damage.
// Otherwise, start a timer and have this cancel after a few seconds.