From e2ccd14eb383844c1bfb5d0e56e7924bb47f5997 Mon Sep 17 00:00:00 2001 From: Video Date: Fri, 27 Aug 2021 16:54:55 -0600 Subject: [PATCH] Unsaves SavedFlags --- .../totalfreedommod/SavedFlags.java | 98 ------------------- .../totalfreedommod/TotalFreedomMod.java | 2 - .../bridge/CoreProtectBridge.java | 7 -- .../totalfreedommod/util/FUtil.java | 2 - .../totalfreedommod/world/Flatlands.java | 33 ------- 5 files changed, 142 deletions(-) delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java b/src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java deleted file mode 100644 index a86320fa..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java +++ /dev/null @@ -1,98 +0,0 @@ -package me.totalfreedom.totalfreedommod; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.HashMap; -import java.util.Map; -import me.totalfreedom.totalfreedommod.util.FLog; -import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME; - -public class SavedFlags extends FreedomService -{ - @Override - public void onStart() - { - } - - @Override - public void onStop() - { - } - - @SuppressWarnings("unchecked") - public Map getSavedFlags() - { - Map flags = null; - File input = new File(TotalFreedomMod.getPlugin().getDataFolder(), SAVED_FLAGS_FILENAME); - - if (input.exists()) - { - try - { - try (FileInputStream fis = new FileInputStream(input); ObjectInputStream ois = new ObjectInputStream(fis)) - { - flags = (HashMap)ois.readObject(); - } - } - catch (Exception ex) - { - FLog.severe(ex); - } - } - - return flags; - } - - public boolean getSavedFlag(String flag) throws Exception - { - Boolean flagValue = null; - - Map flags = getSavedFlags(); - - if (flags != null) - { - if (flags.containsKey(flag)) - { - flagValue = flags.get(flag); - } - } - - if (flagValue != null) - { - return flagValue; - } - else - { - throw new Exception(); - } - } - - public void setSavedFlag(String flag, boolean value) - { - Map flags = getSavedFlags(); - - if (flags == null) - { - flags = new HashMap<>(); - } - - flags.put(flag, value); - - try - { - final FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), SAVED_FLAGS_FILENAME)); - final ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(flags); - oos.close(); - fos.close(); - } - catch (Exception ex) - { - FLog.severe(ex); - } - } - -} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java index 9804f730..1bb8207b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/TotalFreedomMod.java @@ -75,7 +75,6 @@ public class TotalFreedomMod extends JavaPlugin public CommandLoader cl; // Services public ServerInterface si; - public SavedFlags sf; public WorldManager wm; public LogViewer lv; public AdminList al; @@ -299,7 +298,6 @@ public class TotalFreedomMod extends JavaPlugin { // Start services si = new ServerInterface(); - sf = new SavedFlags(); wm = new WorldManager(); lv = new LogViewer(); sql = new SQLite(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java b/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java index dc846cd1..1db19d19 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/bridge/CoreProtectBridge.java @@ -192,7 +192,6 @@ public class CoreProtectBridge extends FreedomService return (megabytes / 1024); } - // Wipes DB for the specified world public void clearDatabase(World world) { clearDatabase(world, false); @@ -260,12 +259,6 @@ public class CoreProtectBridge extends FreedomService { FLog.warning("Failed to delete the CoreProtect data for the " + world.getName()); } - - // This exits for flatlands wipes - if (shutdown) - { - server.shutdown(); - } } @EventHandler(priority = EventPriority.MONITOR) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index 81bae8cc..ea7a7344 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -36,8 +36,6 @@ import static org.bukkit.Bukkit.getServer; public class FUtil { - - public static final String SAVED_FLAGS_FILENAME = "savedflags.dat"; /* See https://github.com/TotalFreedom/License - None of the listed names may be removed. Leaving this list here for anyone running TFM on a cracked server: public static final List DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "Telesphoreo", "CoolJWB"); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java b/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java index 32033da5..790a6f33 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java @@ -1,9 +1,6 @@ package me.totalfreedom.totalfreedommod.world; -import java.io.File; import me.totalfreedom.totalfreedommod.config.ConfigEntry; -import me.totalfreedom.totalfreedommod.util.FLog; -import org.apache.commons.io.FileUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -32,8 +29,6 @@ public class Flatlands extends CustomWorld return null; } - wipeFlatlandsIfFlagged(); - final WorldCreator worldCreator = new WorldCreator(getName()); worldCreator.generateStructures(false); worldCreator.type(WorldType.NORMAL); @@ -63,32 +58,4 @@ public class Flatlands extends CustomWorld return world; } - - - public void wipeFlatlandsIfFlagged() - { - boolean doFlatlandsWipe = false; - try - { - doFlatlandsWipe = plugin.sf.getSavedFlag("do_wipe_flatlands"); - } - catch (Exception ignored) - { - } - - if (doFlatlandsWipe) - { - if (Bukkit.getServer().getWorld("flatlands") == null) - { - FLog.info("Wiping flatlands."); - plugin.sf.setSavedFlag("do_wipe_flatlands", false); - FileUtils.deleteQuietly(new File("./flatlands")); - } - else - { - FLog.severe("Can't wipe flatlands, it is already loaded."); - } - } - } - }