From 828cf8380c4c0a74980850cb7261dc8c6a0c7389 Mon Sep 17 00:00:00 2001 From: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com> Date: Thu, 4 Apr 2024 09:09:52 -0500 Subject: [PATCH 1/5] started working on save command --- .../commands/subcommands/SaveCommand.java | 39 ++++++++++++++++ .../core/services/AutoSavingService.java | 44 ++++++++++++++++--- src/main/resources/languages/en/messages.yml | 8 ++++ 3 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java new file mode 100644 index 0000000000..7477ccc73f --- /dev/null +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java @@ -0,0 +1,39 @@ +package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; + +import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun4.core.services.AutoSavingService; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +public class SaveCommand extends SubCommand { + private final AutoSavingService service; + + @ParametersAreNonnullByDefault + SaveCommand(Slimefun plugin, SlimefunCommand cmd, AutoSavingService service) { + super(plugin, cmd, "save", false); + this.service = service; + } + + @Override + public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { + if (!(sender instanceof Player)) { + Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true); + return; + } + + if (sender.hasPermission("slimefun.command.save")) { + boolean savedPlayers = this.service.saveAllPlayers(false); + Slimefun.getLocalization().sendMessage(sender, "commands.save.players." + savedPlayers, true); + boolean savedBlocks = this.service.saveAllBlocks(false); + Slimefun.getLocalization().sendMessage(sender, "commands.save.blocks." + savedBlocks, true); + } else { + Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); + } + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java index 060ce0d772..e26e703f0e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java @@ -29,6 +29,8 @@ public class AutoSavingService { private int interval; + private boolean savingPlayers; + private boolean savingBlocks; /** * This method starts the {@link AutoSavingService} with the given interval. @@ -41,19 +43,25 @@ public class AutoSavingService { public void start(@Nonnull Slimefun plugin, int interval) { this.interval = interval; - plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, this::saveAllPlayers, 2000L, interval * 60L * 20L); - plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, this::saveAllBlocks, 2000L, interval * 60L * 20L); + plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> saveAllPlayers(true), 2000L, interval * 60L * 20L); + plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> saveAllBlocks(true), 2000L, interval * 60L * 20L); } /** * This method saves every {@link PlayerProfile} in memory and removes profiles * that were marked for deletion. */ - private void saveAllPlayers() { + public boolean saveAllPlayers(boolean auto) { + if (this.savingPlayers) { + return false; + } + + this.savingPlayers = true; + long startTime = System.currentTimeMillis(); Iterator iterator = PlayerProfile.iterator(); int players = 0; - Debug.log(TestCase.PLAYER_PROFILE_DATA, "Saving all players data"); + Debug.log(TestCase.PLAYER_PROFILE_DATA, "Saving all player data"); while (iterator.hasNext()) { PlayerProfile profile = iterator.next(); @@ -81,14 +89,28 @@ private void saveAllPlayers() { } if (players > 0) { - Slimefun.logger().log(Level.INFO, "Auto-saved all player data for {0} player(s)!", players); + if (auto) { + Slimefun.logger().log(Level.INFO, "Auto-saved all player data for {0} player(s)!", players); + } else { + Slimefun.logger().log(Level.INFO, "Saved all player data for {0} player(s)!", players); + } + Slimefun.logger().log(Level.INFO, "Took {0}ms!", System.currentTimeMillis() - startTime); } + + this.savingPlayers = false; + return true; } /** * This method saves the data of every {@link Block} marked dirty by {@link BlockStorage}. */ - private void saveAllBlocks() { + public boolean saveAllBlocks(boolean auto) { + if (this.savingBlocks) { + return false; + } + + this.savingBlocks = true; + long startTime = System.currentTimeMillis(); Set worlds = new HashSet<>(); for (World world : Bukkit.getWorlds()) { @@ -104,7 +126,11 @@ private void saveAllBlocks() { } if (!worlds.isEmpty()) { - Slimefun.logger().log(Level.INFO, "Auto-saving block data... (Next auto-save: {0}m)", interval); + if (auto) { + Slimefun.logger().log(Level.INFO, "Auto-saving block data... (Next auto-save: {0}m)", interval); + } else { + Slimefun.logger().log(Level.INFO, "Saving block data..."); + } for (BlockStorage storage : worlds) { storage.save(); @@ -112,6 +138,10 @@ private void saveAllBlocks() { } BlockStorage.saveChunks(); + Slimefun.logger().log(Level.INFO, "Saved all block data, took {0}ms!", System.currentTimeMillis() - startTime); + + this.savingBlocks = false; + return true; } } diff --git a/src/main/resources/languages/en/messages.yml b/src/main/resources/languages/en/messages.yml index 81d5115c30..78cdd7de9b 100644 --- a/src/main/resources/languages/en/messages.yml +++ b/src/main/resources/languages/en/messages.yml @@ -39,6 +39,14 @@ commands: running: '&7Running debug mode with test: &6%test%' disabled: '&7Disabled debug mode.' + save: + players: + true: 'Successfully saved player-data!' + false: 'Player-data is already saving!' + blocks: + true: 'Successfully saved blockstorage!' + false: 'Blockstorage is already saving!' + placeholderapi: profile-loading: 'Loading...' From 5ae0265121323b21beaac73c2a888ccc483963ef Mon Sep 17 00:00:00 2001 From: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com> Date: Thu, 4 Apr 2024 09:11:54 -0500 Subject: [PATCH 2/5] actually register command --- .../slimefun4/core/commands/subcommands/SaveCommand.java | 4 ++-- .../core/commands/subcommands/SlimefunSubCommands.java | 1 + .../thebusybiscuit/slimefun4/implementation/Slimefun.java | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java index 7477ccc73f..0c198b49db 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java @@ -15,9 +15,9 @@ public class SaveCommand extends SubCommand { private final AutoSavingService service; @ParametersAreNonnullByDefault - SaveCommand(Slimefun plugin, SlimefunCommand cmd, AutoSavingService service) { + SaveCommand(Slimefun plugin, SlimefunCommand cmd) { super(plugin, cmd, "save", false); - this.service = service; + this.service = Slimefun.getAutoSavingService(); } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java index 17d70bce3e..a746242830 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java @@ -42,6 +42,7 @@ public static Collection getAllCommands(@Nonnull SlimefunCommand cmd commands.add(new BackpackCommand(plugin, cmd)); commands.add(new ChargeCommand(plugin, cmd)); commands.add(new DebugCommand(plugin, cmd)); + commands.add(new SaveCommand(plugin, cmd)) return commands; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java index ae065bc062..5fdd2cc8a0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java @@ -828,6 +828,11 @@ private static void validateInstance() { return instance.blockDataService; } + public static @Nonnull AutoSavingService getAutoSavingService() { + validateInstance(); + return instance.autoSavingService; + } + /** * This method returns out world settings service. * That service is responsible for managing item settings per From 8ca17b4767ca5cdf5cb0882d4091032b19eb61f7 Mon Sep 17 00:00:00 2001 From: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com> Date: Thu, 4 Apr 2024 12:30:48 -0500 Subject: [PATCH 3/5] wip (lots of this will probably be changed again) --- .../commands/subcommands/SaveCommand.java | 24 +++---- ...oSavingService.java => SavingService.java} | 65 ++++++++++--------- .../slimefun4/implementation/Slimefun.java | 10 +-- .../Slimefun/api/BlockStorage.java | 20 ++++-- src/main/resources/languages/en/messages.yml | 4 +- 5 files changed, 66 insertions(+), 57 deletions(-) rename src/main/java/io/github/thebusybiscuit/slimefun4/core/services/{AutoSavingService.java => SavingService.java} (66%) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java index 0c198b49db..781c11e1d9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java @@ -2,38 +2,32 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.services.AutoSavingService; +import io.github.thebusybiscuit.slimefun4.core.services.SavingService; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; public class SaveCommand extends SubCommand { - private final AutoSavingService service; + private final SavingService service; @ParametersAreNonnullByDefault SaveCommand(Slimefun plugin, SlimefunCommand cmd) { super(plugin, cmd, "save", false); - this.service = Slimefun.getAutoSavingService(); + this.service = Slimefun.getSavingService(); } @Override public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { - if (!(sender instanceof Player)) { - Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true); + if (!sender.hasPermission("slimefun.command.save")) { + Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); return; } - if (sender.hasPermission("slimefun.command.save")) { - boolean savedPlayers = this.service.saveAllPlayers(false); - Slimefun.getLocalization().sendMessage(sender, "commands.save.players." + savedPlayers, true); - boolean savedBlocks = this.service.saveAllBlocks(false); - Slimefun.getLocalization().sendMessage(sender, "commands.save.blocks." + savedBlocks, true); - } else { - Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); - } + boolean savedPlayers = this.service.saveAllPlayers(false); + Slimefun.getLocalization().sendMessage(sender, "commands.save.players." + savedPlayers, true); + boolean savedBlocks = this.service.saveAllBlocks(false); + Slimefun.getLocalization().sendMessage(sender, "commands.save.blocks." + savedBlocks, true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/SavingService.java similarity index 66% rename from src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java rename to src/main/java/io/github/thebusybiscuit/slimefun4/core/services/SavingService.java index e26e703f0e..aa1ccb7a89 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/SavingService.java @@ -1,8 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.services; -import java.util.HashSet; import java.util.Iterator; -import java.util.Set; import java.util.logging.Level; import javax.annotation.Nonnull; @@ -20,28 +18,37 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage; /** - * This Service is responsible for automatically saving {@link Player} and {@link Block} + * This Service is responsible for saving {@link Player} and {@link Block} * data. * * @author TheBusyBiscuit - * + * @author JustAHuman */ -public class AutoSavingService { +public class SavingService { private int interval; + private long lastPlayerSave; + private long lastBlockSave; + private boolean startedAutoSave; private boolean savingPlayers; private boolean savingBlocks; /** - * This method starts the {@link AutoSavingService} with the given interval. + * This method starts a {@link SavingService} task with the given interval. * * @param plugin * The current instance of Slimefun * @param interval * The interval in which to run this task */ - public void start(@Nonnull Slimefun plugin, int interval) { + public void startAutoSave(@Nonnull Slimefun plugin, int interval) { + if (this.startedAutoSave) { + // TODO: handle this + return; + } + this.interval = interval; + this.startedAutoSave = true; plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> saveAllPlayers(true), 2000L, interval * 60L * 20L); plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> saveAllBlocks(true), 2000L, interval * 60L * 20L); @@ -89,12 +96,15 @@ public boolean saveAllPlayers(boolean auto) { } if (players > 0) { + long endTime = System.currentTimeMillis(); if (auto) { - Slimefun.logger().log(Level.INFO, "Auto-saved all player data for {0} player(s)!", players); + this.lastPlayerSave = endTime; + Slimefun.logger().log(Level.INFO, "Auto-saved all player data for {0} player(s)! (Next auto-save: {1}m)", new Object[] { players, this.interval }); } else { - Slimefun.logger().log(Level.INFO, "Saved all player data for {0} player(s)!", players); + long nextAutoSave = (this.interval * 60L) - ((endTime - this.lastPlayerSave) / 1000L); + Slimefun.logger().log(Level.INFO, "Saved all player data for {0} player(s)! (Next auto-save: {1}m {2}s)", new Object[] { players, nextAutoSave / 60, nextAutoSave % 60 }); } - Slimefun.logger().log(Level.INFO, "Took {0}ms!", System.currentTimeMillis() - startTime); + Slimefun.logger().log(Level.INFO, "Took {0}ms!", endTime - startTime); } this.savingPlayers = false; @@ -111,35 +121,28 @@ public boolean saveAllBlocks(boolean auto) { this.savingBlocks = true; long startTime = System.currentTimeMillis(); - Set worlds = new HashSet<>(); + int savedChanges = 0; for (World world : Bukkit.getWorlds()) { BlockStorage storage = BlockStorage.getStorage(world); - - if (storage != null) { - storage.computeChanges(); - - if (storage.getChanges() > 0) { - worlds.add(storage); - } + if (storage == null) { + continue; } - } - if (!worlds.isEmpty()) { - if (auto) { - Slimefun.logger().log(Level.INFO, "Auto-saving block data... (Next auto-save: {0}m)", interval); - } else { - Slimefun.logger().log(Level.INFO, "Saving block data..."); - } - - for (BlockStorage storage : worlds) { - storage.save(); - } + savedChanges += storage.saveChanges(); } - BlockStorage.saveChunks(); - Slimefun.logger().log(Level.INFO, "Saved all block data, took {0}ms!", System.currentTimeMillis() - startTime); + long endTime = System.currentTimeMillis(); + if (auto) { + Slimefun.logger().log(Level.INFO, "Auto-saved all block data from {0} changes! (Next auto-save: {1}m)", new Object[] { savedChanges, this.interval }); + } else { + long nextAutoSave = (this.interval * 60L) - ((endTime - this.lastBlockSave) / 1000L); + Slimefun.logger().log(Level.INFO, "Saved all block data from {0} changes! (Next auto-save: {1}m {2}s)", new Object[] { savedChanges, nextAutoSave / 60, nextAutoSave % 60 }); + } + Slimefun.logger().log(Level.INFO, "Took {0}ms!", new Object[] { endTime - startTime }); + + this.lastBlockSave = endTime; this.savingBlocks = false; return true; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java index 5fdd2cc8a0..d46b40b68f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java @@ -43,7 +43,7 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager; import io.github.thebusybiscuit.slimefun4.core.services.AnalyticsService; -import io.github.thebusybiscuit.slimefun4.core.services.AutoSavingService; +import io.github.thebusybiscuit.slimefun4.core.services.SavingService; import io.github.thebusybiscuit.slimefun4.core.services.BackupService; import io.github.thebusybiscuit.slimefun4.core.services.BlockDataService; import io.github.thebusybiscuit.slimefun4.core.services.CustomItemDataService; @@ -177,7 +177,7 @@ public class Slimefun extends JavaPlugin implements SlimefunAddon { private final GitHubService gitHubService = new GitHubService("Slimefun/Slimefun4"); private final UpdaterService updaterService = new UpdaterService(this, getDescription().getVersion(), getFile()); private final MetricsService metricsService = new MetricsService(this); - private final AutoSavingService autoSavingService = new AutoSavingService(); + private final SavingService savingService = new SavingService(); private final BackupService backupService = new BackupService(); private final PermissionsService permissionsService = new PermissionsService(this); private final PerWorldSettingsService worldSettingsService = new PerWorldSettingsService(this); @@ -379,7 +379,7 @@ private void onPluginStart() { } // Starting our tasks - autoSavingService.start(this, config.getInt("options.auto-save-delay-in-minutes")); + savingService.startAutoSave(this, config.getInt("options.auto-save-delay-in-minutes")); hologramsService.start(); ticker.start(this); @@ -828,9 +828,9 @@ private static void validateInstance() { return instance.blockDataService; } - public static @Nonnull AutoSavingService getAutoSavingService() { + public static @Nonnull SavingService getSavingService() { validateInstance(); - return instance.autoSavingService; + return instance.savingService; } /** diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java index c2df4fd2c9..deb93d1f8d 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java @@ -304,15 +304,16 @@ public int getChanges() { return changes; } - public void save() { + public int saveChanges() { computeChanges(); - + if (changes == 0) { - return; + return 0; } Slimefun.logger().log(Level.INFO, "Saving block data for world \"{0}\" ({1} change(s) queued)", new Object[] { world.getName(), changes }); Map cache = new HashMap<>(blocksCache); + int savedChanges = 0; for (Map.Entry entry : cache.entrySet()) { blocksCache.remove(entry.getKey()); @@ -324,6 +325,7 @@ public void save() { if (file.exists()) { try { Files.delete(file.toPath()); + savedChanges++; } catch (IOException e) { Slimefun.logger().log(Level.WARNING, e, () -> "Could not delete file \"" + file.getName() + '"'); } @@ -334,6 +336,7 @@ public void save() { try { Files.move(tmpFile.toPath(), cfg.getFile().toPath(), StandardCopyOption.ATOMIC_MOVE); + savedChanges++; } catch (IOException x) { Slimefun.logger().log(Level.SEVERE, x, () -> "An Error occurred while copying a temporary File for Slimefun " + Slimefun.getVersion()); } @@ -342,15 +345,24 @@ public void save() { Map unsavedInventories = new HashMap<>(inventories); for (Map.Entry entry : unsavedInventories.entrySet()) { + savedChanges += entry.getValue().getUnsavedChanges(); entry.getValue().save(entry.getKey()); } Map unsavedUniversalInventories = new HashMap<>(Slimefun.getRegistry().getUniversalInventories()); for (Map.Entry entry : unsavedUniversalInventories.entrySet()) { + savedChanges += entry.getValue().getUnsavedChanges(); entry.getValue().save(); } - changes = 0; + Slimefun.logger().log(Level.INFO, "Saved block data for world \"{0}\" ({1} change(s) saved)", new Object[] { world.getName(), savedChanges }); + + this.changes = 0; + return savedChanges; + } + + public void save() { + saveChanges(); } public void saveAndRemove() { diff --git a/src/main/resources/languages/en/messages.yml b/src/main/resources/languages/en/messages.yml index 78cdd7de9b..879046f989 100644 --- a/src/main/resources/languages/en/messages.yml +++ b/src/main/resources/languages/en/messages.yml @@ -44,8 +44,8 @@ commands: true: 'Successfully saved player-data!' false: 'Player-data is already saving!' blocks: - true: 'Successfully saved blockstorage!' - false: 'Blockstorage is already saving!' + true: 'Successfully saved block-data!' + false: 'Block-data is already saving!' placeholderapi: profile-loading: 'Loading...' From c9ebf8bad894a3401845b24c01da021127e676ab Mon Sep 17 00:00:00 2001 From: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com> Date: Thu, 4 Apr 2024 12:37:39 -0500 Subject: [PATCH 4/5] just use the methods --- .../slimefun4/core/commands/subcommands/SaveCommand.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java index 781c11e1d9..a258ce0e8d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SaveCommand.java @@ -10,12 +10,9 @@ import javax.annotation.ParametersAreNonnullByDefault; public class SaveCommand extends SubCommand { - private final SavingService service; - @ParametersAreNonnullByDefault SaveCommand(Slimefun plugin, SlimefunCommand cmd) { super(plugin, cmd, "save", false); - this.service = Slimefun.getSavingService(); } @Override @@ -25,9 +22,9 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { return; } - boolean savedPlayers = this.service.saveAllPlayers(false); + boolean savedPlayers = Slimefun.getSavingService().saveAllPlayers(false); Slimefun.getLocalization().sendMessage(sender, "commands.save.players." + savedPlayers, true); - boolean savedBlocks = this.service.saveAllBlocks(false); + boolean savedBlocks = Slimefun.getSavingService().saveAllBlocks(false); Slimefun.getLocalization().sendMessage(sender, "commands.save.blocks." + savedBlocks, true); } } From 1776fcb5446379a318319112aa9355c624a55850 Mon Sep 17 00:00:00 2001 From: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com> Date: Tue, 9 Apr 2024 07:39:31 -0500 Subject: [PATCH 5/5] Fix build --- .../core/commands/subcommands/SlimefunSubCommands.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java index a746242830..8983a7ebad 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java @@ -42,7 +42,7 @@ public static Collection getAllCommands(@Nonnull SlimefunCommand cmd commands.add(new BackpackCommand(plugin, cmd)); commands.add(new ChargeCommand(plugin, cmd)); commands.add(new DebugCommand(plugin, cmd)); - commands.add(new SaveCommand(plugin, cmd)) + commands.add(new SaveCommand(plugin, cmd)); return commands; }