Factions Fly Cache on Startup, Attempt At SaveSync Fix

This commit is contained in:
Driftay 2020-04-12 06:26:27 -04:00
parent 932a5768b0
commit 3aa98121e5
9 changed files with 35 additions and 43 deletions

View File

@ -122,7 +122,7 @@ public class Conf {
public static boolean useDisbandGUI = true;
//SEALTH
public static boolean useSealthSystem = true;
public static boolean useStealthSystem = true;
//STRIKES
public static boolean useStrikeSystem = true;

View File

@ -82,7 +82,7 @@ public class FactionsPlugin extends MPlugin {
public boolean mc114 = false;
public boolean mc115 = false;
public boolean useNonPacketParticles = false;
public boolean factionsFlight = false;
public static boolean factionsFlight = false;
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
SkriptAddon skriptAddon;
private FactionsPlayerListener factionsPlayerListener;
@ -453,8 +453,18 @@ public class FactionsPlugin extends MPlugin {
@Override
public void onDisable() {
super.onDisable();
// only save data if plugin actually completely loaded successfully
if (this.loadSuccessful) {
Conf.load();
Conf.saveSync();
timerManager.saveTimerData();
DiscordListener.saveGuilds();
if (Discord.jda != null) Discord.jda.shutdownNow();
try {
fLogManager.saveLogs();
} catch (Exception e) {
e.printStackTrace();
}
try {
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
File file = new File(path);
@ -466,24 +476,9 @@ public class FactionsPlugin extends MPlugin {
} catch (IOException e) {
e.printStackTrace();
}
// only save data if plugin actually completely loaded successfully
if (this.loadSuccessful) Conf.saveSync();
if (AutoLeaveTask != null) {
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
AutoLeaveTask = null;
}
DiscordListener.saveGuilds();
if (Discord.jda != null) {
Discord.jda.shutdownNow();
}
try {
fLogManager.saveLogs();
} catch (Exception e) {
e.printStackTrace();
}
this.getServer().getScheduler().cancelTasks(this);
super.onDisable();
}
public void startAutoLeaveTask(boolean restartIfRunning) {

View File

@ -101,14 +101,14 @@ 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.getInstance().getConfig().getBoolean("enable-faction-flight")) {
if (!follower.canFlyAtLocation() && FactionsPlugin.factionsFlight) {
follower.setFFlying(false, false);
}
} else {
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
}
}
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
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"));
@ -119,7 +119,7 @@ public class CmdDisband extends FCommand {
}
faction.disband(context.player, PlayerDisbandReason.COMMAND);
Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
if (!context.fPlayer.canFlyAtLocation() && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
if (!context.fPlayer.canFlyAtLocation() && FactionsPlugin.factionsFlight) {
context.fPlayer.setFFlying(false, false);
}
}

View File

@ -31,7 +31,7 @@ public class CmdReload extends FCommand {
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
FactionsPlugin.getInstance().factionsFlight = true;
FactionsPlugin.factionsFlight = true;
}
if (!FactionsPlugin.getInstance().mc17) {

View File

@ -20,7 +20,7 @@ public class CmdStealth extends FCommand {
@Override
public void perform(CommandContext context) {
if (!Conf.useSealthSystem) {
if (!Conf.useStealthSystem) {
context.msg(TL.GENERIC_DISABLED, "Factions Stealth");
return;
}

View File

@ -572,7 +572,7 @@ public class FactionsPlayerListener implements Listener {
}
@Deprecated
public void checkCanFly(FPlayer me) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight") || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
if (!FactionsPlugin.factionsFlight || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
return;
if (me.isFlying()) return;
if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) {

View File

@ -15,7 +15,7 @@ public class UtilFly {
*/
@Deprecated
public static void run() {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
if (!FactionsPlugin.factionsFlight)
return;
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
@ -28,7 +28,7 @@ public class UtilFly {
@Deprecated
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
if (!FactionsPlugin.factionsFlight)
return;
fp.getPlayer().setAllowFlight(fly);

View File

@ -178,7 +178,6 @@ public abstract class MPlugin extends JavaPlugin {
}
public void onDisable() {
try {
if (saveTask != null) {
this.getServer().getScheduler().cancelTask(saveTask);
saveTask = null;
@ -190,8 +189,6 @@ public abstract class MPlugin extends JavaPlugin {
Board.getInstance().forceSave();
}
log("Disabled");
} catch (IllegalPluginAccessException e) {
}
}
// -------------------------------------------- //

View File

@ -961,7 +961,7 @@ public abstract class MemoryFPlayer implements FPlayer {
}
public void setFFlying(boolean fly, boolean damage) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
if (!FactionsPlugin.factionsFlight)
return;
Player player = getPlayer();