From 7d45f94ce3944746ce415d731d0a0ce856b45a4a Mon Sep 17 00:00:00 2001 From: Alexander B Date: Tue, 5 Jan 2021 19:41:02 +0100 Subject: [PATCH] Added save --- eu/railduction/ruakij/spawnerDrops/Main.java | 5 +++++ .../ruakij/spawnerDrops/listener/OnBlockPlace.java | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/eu/railduction/ruakij/spawnerDrops/Main.java b/eu/railduction/ruakij/spawnerDrops/Main.java index 9391385..1133af1 100644 --- a/eu/railduction/ruakij/spawnerDrops/Main.java +++ b/eu/railduction/ruakij/spawnerDrops/Main.java @@ -6,6 +6,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -13,11 +14,15 @@ import java.io.File; public class Main extends JavaPlugin { + public static Plugin plugin; + public static FileConfiguration config; public static FileConfiguration data; public void onEnable() { + plugin = this; + PluginManager pluginManager = Bukkit.getPluginManager(); pluginManager.registerEvents(new OnBlockPlace(), this); pluginManager.registerEvents(new OnBlockBreak(), this); diff --git a/eu/railduction/ruakij/spawnerDrops/listener/OnBlockPlace.java b/eu/railduction/ruakij/spawnerDrops/listener/OnBlockPlace.java index c06d835..94c3e1f 100644 --- a/eu/railduction/ruakij/spawnerDrops/listener/OnBlockPlace.java +++ b/eu/railduction/ruakij/spawnerDrops/listener/OnBlockPlace.java @@ -7,6 +7,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; +import java.io.IOException; + public class OnBlockPlace implements Listener { public void onBlockPlaceEvent(BlockPlaceEvent e){ @@ -30,6 +32,12 @@ public class OnBlockPlace implements Listener { else{ // Write place-data Main.data.set(Main.serialiseLocation(loc), isAdmin); + try { + Main.data.save("data.yml"); + } catch (IOException ex) { + Main.plugin.getLogger().severe("Cannot save data to data.yml! Data will lost after restart!"); + ex.printStackTrace(); + } // Send msg String msg = Main.config.getString("place.player.msg.success");