Factions Fly Cache on Startup, Attempt At SaveSync Fix
This commit is contained in:
parent
932a5768b0
commit
3aa98121e5
@ -122,7 +122,7 @@ public class Conf {
|
|||||||
public static boolean useDisbandGUI = true;
|
public static boolean useDisbandGUI = true;
|
||||||
|
|
||||||
//SEALTH
|
//SEALTH
|
||||||
public static boolean useSealthSystem = true;
|
public static boolean useStealthSystem = true;
|
||||||
|
|
||||||
//STRIKES
|
//STRIKES
|
||||||
public static boolean useStrikeSystem = true;
|
public static boolean useStrikeSystem = true;
|
||||||
|
@ -82,7 +82,7 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
public boolean mc114 = false;
|
public boolean mc114 = false;
|
||||||
public boolean mc115 = false;
|
public boolean mc115 = false;
|
||||||
public boolean useNonPacketParticles = false;
|
public boolean useNonPacketParticles = false;
|
||||||
public boolean factionsFlight = false;
|
public static boolean factionsFlight = false;
|
||||||
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
|
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
|
||||||
SkriptAddon skriptAddon;
|
SkriptAddon skriptAddon;
|
||||||
private FactionsPlayerListener factionsPlayerListener;
|
private FactionsPlayerListener factionsPlayerListener;
|
||||||
@ -453,37 +453,32 @@ public class FactionsPlugin extends MPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
super.onDisable();
|
|
||||||
timerManager.saveTimerData();
|
|
||||||
try {
|
|
||||||
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
|
|
||||||
File file = new File(path);
|
|
||||||
if (!file.exists()) {
|
|
||||||
file.getParentFile().mkdirs();
|
|
||||||
file.createNewFile();
|
|
||||||
}
|
|
||||||
Files.write(Paths.get(file.getPath()), getGsonBuilder().create().toJson(reserveObjects).getBytes());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
// only save data if plugin actually completely loaded successfully
|
// only save data if plugin actually completely loaded successfully
|
||||||
if (this.loadSuccessful) Conf.saveSync();
|
if (this.loadSuccessful) {
|
||||||
|
Conf.load();
|
||||||
|
Conf.saveSync();
|
||||||
if (AutoLeaveTask != null) {
|
timerManager.saveTimerData();
|
||||||
this.getServer().getScheduler().cancelTask(AutoLeaveTask);
|
DiscordListener.saveGuilds();
|
||||||
AutoLeaveTask = null;
|
if (Discord.jda != null) Discord.jda.shutdownNow();
|
||||||
}
|
try {
|
||||||
DiscordListener.saveGuilds();
|
fLogManager.saveLogs();
|
||||||
if (Discord.jda != null) {
|
} catch (Exception e) {
|
||||||
Discord.jda.shutdownNow();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
fLogManager.saveLogs();
|
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
|
||||||
} catch (Exception e) {
|
File file = new File(path);
|
||||||
e.printStackTrace();
|
if (!file.exists()) {
|
||||||
|
file.getParentFile().mkdirs();
|
||||||
|
file.createNewFile();
|
||||||
|
}
|
||||||
|
Files.write(Paths.get(file.getPath()), getGsonBuilder().create().toJson(reserveObjects).getBytes());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.getServer().getScheduler().cancelTasks(this);
|
||||||
|
super.onDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startAutoLeaveTask(boolean restartIfRunning) {
|
public void startAutoLeaveTask(boolean restartIfRunning) {
|
||||||
|
@ -101,14 +101,14 @@ public class CmdDisband extends FCommand {
|
|||||||
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
|
String amountString = context.sender instanceof ConsoleCommandSender ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(follower);
|
||||||
if (follower.getFaction() == faction) {
|
if (follower.getFaction() == faction) {
|
||||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_YOURS, amountString);
|
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);
|
follower.setFFlying(false, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
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);
|
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||||
context.fPlayer.setFFlying(false, false);
|
context.fPlayer.setFFlying(false, false);
|
||||||
Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
|
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);
|
faction.disband(context.player, PlayerDisbandReason.COMMAND);
|
||||||
Cooldown.setCooldown(context.fPlayer.getPlayer(), "disbandCooldown", FactionsPlugin.getInstance().getConfig().getInt("fcooldowns.f-disband"));
|
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);
|
context.fPlayer.setFFlying(false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class CmdReload extends FCommand {
|
|||||||
|
|
||||||
|
|
||||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
|
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
|
||||||
FactionsPlugin.getInstance().factionsFlight = true;
|
FactionsPlugin.factionsFlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FactionsPlugin.getInstance().mc17) {
|
if (!FactionsPlugin.getInstance().mc17) {
|
||||||
|
@ -20,7 +20,7 @@ public class CmdStealth extends FCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void perform(CommandContext context) {
|
public void perform(CommandContext context) {
|
||||||
if (!Conf.useSealthSystem) {
|
if (!Conf.useStealthSystem) {
|
||||||
context.msg(TL.GENERIC_DISABLED, "Factions Stealth");
|
context.msg(TL.GENERIC_DISABLED, "Factions Stealth");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -572,7 +572,7 @@ public class FactionsPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void checkCanFly(FPlayer me) {
|
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;
|
return;
|
||||||
if (me.isFlying()) return;
|
if (me.isFlying()) return;
|
||||||
if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) {
|
if (me.getPlayer().hasPermission(Permission.FLY_FLY.node)) {
|
||||||
|
@ -15,7 +15,7 @@ public class UtilFly {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void run() {
|
public static void run() {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
if (!FactionsPlugin.factionsFlight)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
||||||
@ -28,7 +28,7 @@ public class UtilFly {
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
|
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
if (!FactionsPlugin.factionsFlight)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fp.getPlayer().setAllowFlight(fly);
|
fp.getPlayer().setAllowFlight(fly);
|
||||||
|
@ -178,7 +178,6 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
try {
|
|
||||||
if (saveTask != null) {
|
if (saveTask != null) {
|
||||||
this.getServer().getScheduler().cancelTask(saveTask);
|
this.getServer().getScheduler().cancelTask(saveTask);
|
||||||
saveTask = null;
|
saveTask = null;
|
||||||
@ -190,8 +189,6 @@ public abstract class MPlugin extends JavaPlugin {
|
|||||||
Board.getInstance().forceSave();
|
Board.getInstance().forceSave();
|
||||||
}
|
}
|
||||||
log("Disabled");
|
log("Disabled");
|
||||||
} catch (IllegalPluginAccessException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -961,7 +961,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFFlying(boolean fly, boolean damage) {
|
public void setFFlying(boolean fly, boolean damage) {
|
||||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
if (!FactionsPlugin.factionsFlight)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
|
Loading…
Reference in New Issue
Block a user