From 3ca993175e40a1d69f7c90f4b20f620f2ba92779 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 19 Mar 2017 20:20:25 +0100 Subject: [PATCH 01/18] Fixed missing chunks file --- .../Slimefun/SlimefunStartup.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java index 3fb80e686..fffd3a241 100644 --- a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java +++ b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java @@ -495,18 +495,20 @@ public class SlimefunStartup extends JavaPlugin { output.closeEntry(); } - ZipEntry entry = new ZipEntry("stored-chunks/chunks.sfc"); - output.putNextEntry(entry); - FileInputStream input = new FileInputStream(new File("data-storage/Slimefun/stored-chunks/chunks.sfc")); + if (new File("data-storage/Slimefun/stored-chunks/chunks.sfc").exists()) { + ZipEntry entry = new ZipEntry("stored-chunks/chunks.sfc"); + output.putNextEntry(entry); + FileInputStream input = new FileInputStream(new File("data-storage/Slimefun/stored-chunks/chunks.sfc")); - int length; - while ((length = input.read(buffer)) > 0) { - output.write(buffer, 0, length); + int length; + while ((length = input.read(buffer)) > 0) { + output.write(buffer, 0, length); + } + + input.close(); + output.closeEntry(); } - input.close(); - output.closeEntry(); - output.close(); System.out.println("[Slimfun] Backed up Blocks to " + file.getName()); } catch(IOException e) { From b6589d49f1782ad60802b61989a583df7d42d2c3 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 20 Mar 2017 15:24:29 +0100 Subject: [PATCH 02/18] Updated /sf versions --- src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java b/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java index d21f715f2..146721d5a 100644 --- a/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java +++ b/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java @@ -18,9 +18,11 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.plugin.Plugin; +import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Variable; import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.CommandHelp; import me.mrCookieSlime.CSCoreLibPlugin.general.Player.Players; +import me.mrCookieSlime.CSCoreLibPlugin.general.Reflection.ReflectionUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.World.TitleBuilder; import me.mrCookieSlime.CSCoreLibPlugin.general.World.TitleBuilder.TitleType; import me.mrCookieSlime.Slimefun.SlimefunGuide; @@ -152,6 +154,9 @@ public class SlimefunCommand implements CommandExecutor, Listener { } else if (args[0].equalsIgnoreCase("versions")) { if (sender.hasPermission("slimefun.command.versions")|| sender instanceof ConsoleCommandSender) { + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&a" + Bukkit.getName() + " &2" + ReflectionUtils.getVersion())); + sender.sendMessage(""); + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aCS-CoreLib &2v" + CSCoreLib.getLib().getDescription().getVersion())); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSlimefun &2v" + plugin.getDescription().getVersion())); sender.sendMessage(""); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&oInstalled Addons:")); From be5c407f9f1045187679704e9e8624a2498f3bf2 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 20 Mar 2017 15:25:46 +0100 Subject: [PATCH 03/18] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index b5fc58480..93f6acceb 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -10,5 +10,5 @@ Attach as many Screenshots or Videos if possible. Anything that helps us understand the Issue better, is gonna get your Issue fixed even faster. ## Environment -State what Version of Minecraft, CS-CoreLib and Slimefun you're using -"latest" is not enough, we need the EXACT VERSIONS. +We need the EXACT VERSIONS of the Software you are using. +Please run /sf versions on your Server and show us that command's output. From e5f2c3518ef49173072a30892722caea89053c0f Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 23 Mar 2017 14:34:16 +0100 Subject: [PATCH 04/18] Update CONTRIBUTING.md --- .github/CONTRIBUTING.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 71e716de3..a078e3da8 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -3,17 +3,24 @@ Slimefun is a community project, everyone is welcome to open Issues, make Pull Requests or make Pull Requests for an opened Issue. Without your help, this project is going to die. +## General Guidelines + +Rules for all types of posts: + +1. Follow our Templates for Issues and Pull Request, they are designed to tell you what exact Information we need and how you should present it to us. +2. Be nice and give constructive critism. Insulting, Harassment, Racism, Sexism or any form of bullying or discrimination is not tolerated. +3. Try to engage in conversations by pointing out scenarios to replicate Issues, providing fix approaches or other kind of help. +4. Advertisement is inappropriate and will be removed, especially advertisement for Minecraft Servers is completely unaccepted. + ## GitHub Issues Rules for posting an Issue on GitHub: 1. This Issue Section is ONLY for Slimefun-related Issues, Issues about other Plugins or Slimefun Addons should not be posted here. 2. Check other Issues before posting to make sure you are not posting a duplicate. -3. Do not put any Tags inside your title like [IMPORTANT], [URGENT] or [SUGGESTION]. -Try to be professional by making your title as short as possible, we will assign it the required labels if necessary. -4. Do not post your Issue more than once, this is considered spam and does not benefit our community in any way. -Do not repost your Issue if it was closed either. -5. Give us all available information right away, it may be a bit of time-wasting for us to keep asking for more Info. +3. Do not put any Tags inside your title like [IMPORTANT], [URGENT] or [SUGGESTION]. Try to be professional by making your title as short as possible, we will assign it the required labels if necessary. +4. Do not post your Issue more than once, this is considered spam and does not benefit our community in any way. Do not repost your Issue if it was closed either. +5. Give us all available information right away, it may be a bit of time-wasting for us to keep asking for more Info. And this includes any Information to reproduce your Issue step-by-step. 6. Check whether there are newer versions available than the ones you are using, it might be that your Issue has been fixed already. Your Issue will be CLOSED WITHOUT WARNING if we think you violated these Rules. @@ -22,9 +29,6 @@ Your Issue will be CLOSED WITHOUT WARNING if we think you violated these Rules. Guidelines for making a Pull Request on GitHub: -1. Try to be reasonable with your additions. -No, a Bacon flavoured unicorn that flies on a rainbow while dancing Gangnam Style is NOT a reasonable addition to this Project. -2. Try to make your values configurable in the config.yml / Items.yml or any additional file. -This may not be necessary at every instance but it does give the end-users a way to customize their experience. -3. If your Pull Request is made in response to an Issue opened on GitHub, -comment on that Issue and reference your Pull Request to show that you are proposing a fix for it. +1. Try to be reasonable with your additions. No, a Bacon flavoured unicorn that flies on a rainbow while dancing Gangnam Style is NOT a reasonable addition to this Project. +2. Try to make your values configurable in the config.yml / Items.yml or any additional file. This may not be necessary at every instance but it does give the end-users a way to customize their experience. +3. If your Pull Request is made in response to an Issue opened on GitHub, comment on that Issue and reference your Pull Request to show that you are proposing a fix for it. From f760dec5898dd97643fb01179520509f1f03f38e Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 23 Mar 2017 14:35:38 +0100 Subject: [PATCH 05/18] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 93f6acceb..059836237 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -11,4 +11,6 @@ Anything that helps us understand the Issue better, is gonna get your Issue fixe ## Environment We need the EXACT VERSIONS of the Software you are using. -Please run /sf versions on your Server and show us that command's output. +This includes your Minecraft Version, your CS-CoreLib version and your Slimefun Version. +If you cannot figure out what versions you are running, then please run /sf versions and +show us the output of that command. From fc00c5356ceb31a3f408d8692b44113d705f469f Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 24 Mar 2017 14:04:38 +0100 Subject: [PATCH 06/18] Fixed CSCoreLibLoader --- .../CSCoreLibSetup/CSCoreLibLoader.java | 301 +++++++++--------- .../Slimefun/SlimefunStartup.java | 8 +- 2 files changed, 156 insertions(+), 153 deletions(-) rename src/me/mrCookieSlime/{ => Slimefun}/CSCoreLibSetup/CSCoreLibLoader.java (73%) diff --git a/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java b/src/me/mrCookieSlime/Slimefun/CSCoreLibSetup/CSCoreLibLoader.java similarity index 73% rename from src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java rename to src/me/mrCookieSlime/Slimefun/CSCoreLibSetup/CSCoreLibLoader.java index 765db59cf..62053b2f8 100644 --- a/src/me/mrCookieSlime/CSCoreLibSetup/CSCoreLibLoader.java +++ b/src/me/mrCookieSlime/Slimefun/CSCoreLibSetup/CSCoreLibLoader.java @@ -1,149 +1,152 @@ -package me.mrCookieSlime.CSCoreLibSetup; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; - -import org.bukkit.plugin.Plugin; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -public class CSCoreLibLoader { - - Plugin plugin; - URL url; - URL download; - File file; - - public CSCoreLibLoader(Plugin plugin) { - this.plugin = plugin; - try { - this.url = new URL("https://api.curseforge.com/servermods/files?projectIds=88802"); - } catch (MalformedURLException e) { - } - } - - public boolean load() { - if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) return true; - else { - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - System.err.println(plugin.getName() + " could not be properly installed!"); - System.err.println("It appears that you have not installed CS-CoreLib"); - System.err.println("And because of that, CS-CoreLib is now going to be"); - System.err.println("downloaded and installed."); - System.err.println("But for the time being " + plugin.getName() + " will remain disabled"); - System.err.println("After the installation process has finished,"); - System.out.println("you will be asked to restart your Server."); - System.err.println("- mrCookieSlime"); - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - - @Override - public void run() { - if (connect()) install(); - } - }, 10L); - return false; - } - } - - private boolean connect() { - try { - final URLConnection connection = this.url.openConnection(); - connection.setConnectTimeout(5000); - connection.addRequestProperty("User-Agent", "CS-CoreLib Loader (by mrCookieSlime)"); - connection.setDoOutput(true); - - final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine()); - download = traceURL(((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")).replace("https:", "http:")); - file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar"); - - return true; - } catch (IOException e) { - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - System.err.println("Could not connect to BukkitDev, is it down?"); - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - return false; - } - } - - private URL traceURL(String location) throws IOException { - HttpURLConnection connection = null; - - while (true) { - URL url = new URL(location); - connection = (HttpURLConnection) url.openConnection(); - - connection.setInstanceFollowRedirects(false); - connection.setConnectTimeout(5000); - connection.addRequestProperty("User-Agent", "Auto Updater (by mrCookieSlime)"); - - switch (connection.getResponseCode()) { - case HttpURLConnection.HTTP_MOVED_PERM: - case HttpURLConnection.HTTP_MOVED_TEMP: - String loc = connection.getHeaderField("Location"); - location = new URL(new URL(location), loc).toExternalForm(); - continue; - } - break; - } - - return connection.getURL(); - } - - private void install() { - BufferedInputStream input = null; - FileOutputStream output = null; - try { - input = new BufferedInputStream(download.openStream()); - output = new FileOutputStream(file); - - final byte[] data = new byte[1024]; - int read; - while ((read = input.read(data, 0, 1024)) != -1) { - output.write(data, 0, read); - } - } catch (Exception ex) { - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - System.err.println("Could not download CS-CoreLib"); - System.err.println(" "); - System.err.println("#################### - FATAL ERROR - ####################"); - System.err.println(" "); - } finally { - try { - if (input != null) input.close(); - if (output != null) output.close(); - System.err.println(" "); - System.err.println("#################### - WARNING - ####################"); - System.err.println(" "); - System.err.println("Please restart your Server to finish the Installation"); - System.err.println("of " + plugin.getName() + " and CS-CoreLib"); - System.err.println(" "); - System.err.println("#################### - WARNING - ####################"); - System.err.println(" "); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - -} +package me.mrCookieSlime.Slimefun.CSCoreLibSetup; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; + +import org.bukkit.plugin.Plugin; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +public class CSCoreLibLoader { + + Plugin plugin; + URL url; + URL download; + File file; + + public CSCoreLibLoader(Plugin plugin) { + this.plugin = plugin; + try { + this.url = new URL("https://api.curseforge.com/servermods/files?projectIds=88802"); + } catch (MalformedURLException e) { + } + } + + public boolean load() { + if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) return true; + else { + System.err.println(" "); + System.err.println("#################### - INFO - ####################"); + System.err.println(" "); + System.err.println(plugin.getName() + " could not be loaded."); + System.err.println("It appears that you have not installed CS-CoreLib"); + System.err.println("Your Server will now try to download and install"); + System.err.println("CS-CoreLib for you."); + System.err.println("You will be asked to restart your Server when it's finished."); + System.err.println("If this somehow fails, please download and install CS-CoreLib manually:"); + System.err.println("https://dev.bukkit.org/projects/cs-corelib"); + System.err.println(" "); + System.err.println("#################### - INFO - ####################"); + System.err.println(" "); + plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { + + @Override + public void run() { + if (connect()) install(); + } + }, 10L); + return false; + } + } + + private boolean connect() { + try { + final URLConnection connection = this.url.openConnection(); + connection.setConnectTimeout(5000); + connection.addRequestProperty("User-Agent", "CS-CoreLib Loader (by mrCookieSlime)"); + connection.setDoOutput(true); + + final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine()); + download = traceURL(((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")).replace("https:", "http:")); + file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar"); + + return true; + } catch (IOException e) { + System.err.println(" "); + System.err.println("#################### - WARNING - ####################"); + System.err.println(" "); + System.err.println("Could not connect to BukkitDev."); + System.err.println("Please download & install CS-CoreLib manually:"); + System.err.println("https://dev.bukkit.org/projects/cs-corelib"); + System.err.println(" "); + System.err.println("#################### - WARNING - ####################"); + System.err.println(" "); + return false; + } + } + + private URL traceURL(String location) throws IOException { + HttpURLConnection connection = null; + + while (true) { + URL url = new URL(location); + connection = (HttpURLConnection) url.openConnection(); + + connection.setInstanceFollowRedirects(false); + connection.setConnectTimeout(5000); + connection.addRequestProperty("User-Agent", "Auto Updater (by mrCookieSlime)"); + + switch (connection.getResponseCode()) { + case HttpURLConnection.HTTP_MOVED_PERM: + case HttpURLConnection.HTTP_MOVED_TEMP: + String loc = connection.getHeaderField("Location"); + location = new URL(new URL(location), loc).toExternalForm(); + continue; + } + break; + } + + return new URL(connection.getURL().toString().replaceAll(" ", "%20")); + } + + private void install() { + BufferedInputStream input = null; + FileOutputStream output = null; + try { + input = new BufferedInputStream(download.openStream()); + output = new FileOutputStream(file); + + final byte[] data = new byte[1024]; + int read; + while ((read = input.read(data, 0, 1024)) != -1) { + output.write(data, 0, read); + } + } catch (Exception ex) { + System.err.println(" "); + System.err.println("#################### - WARNING - ####################"); + System.err.println(" "); + System.err.println("Failed to download CS-CoreLib"); + System.err.println("Please download & install CS-CoreLib manually:"); + System.err.println("https://dev.bukkit.org/projects/cs-corelib"); + System.err.println(" "); + System.err.println("#################### - WARNING - ####################"); + System.err.println(" "); + } finally { + try { + if (input != null) input.close(); + if (output != null) output.close(); + System.err.println(" "); + System.err.println("#################### - INFO - ####################"); + System.err.println(" "); + System.err.println("Please restart your Server to finish the Installation"); + System.err.println("of " + plugin.getName() + " and CS-CoreLib"); + System.err.println(" "); + System.err.println("#################### - INFO - ####################"); + System.err.println(" "); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + +} diff --git a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java index fffd3a241..fc9887095 100644 --- a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java +++ b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java @@ -15,9 +15,6 @@ import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.AutoEnchanter; -import net.coreprotect.CoreProtect; -import net.coreprotect.CoreProtectAPI; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.Block; @@ -39,8 +36,8 @@ import me.mrCookieSlime.CSCoreLibPlugin.PluginUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.CSCoreLibPlugin.general.Clock; import me.mrCookieSlime.CSCoreLibPlugin.general.Reflection.ReflectionUtils; -import me.mrCookieSlime.CSCoreLibSetup.CSCoreLibLoader; import me.mrCookieSlime.Slimefun.AncientAltar.Pedestals; +import me.mrCookieSlime.Slimefun.CSCoreLibSetup.CSCoreLibLoader; import me.mrCookieSlime.Slimefun.Commands.SlimefunCommand; import me.mrCookieSlime.Slimefun.Commands.SlimefunTabCompleter; import me.mrCookieSlime.Slimefun.GEO.OreGenSystem; @@ -55,6 +52,7 @@ import me.mrCookieSlime.Slimefun.Objects.Research; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunArmorPiece; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.AutoEnchanter; import me.mrCookieSlime.Slimefun.Setup.Files; import me.mrCookieSlime.Slimefun.Setup.Messages; import me.mrCookieSlime.Slimefun.Setup.MiscSetup; @@ -89,6 +87,8 @@ import me.mrCookieSlime.Slimefun.listeners.ItemListener; import me.mrCookieSlime.Slimefun.listeners.TalismanListener; import me.mrCookieSlime.Slimefun.listeners.TeleporterListener; import me.mrCookieSlime.Slimefun.listeners.ToolListener; +import net.coreprotect.CoreProtect; +import net.coreprotect.CoreProtectAPI; public class SlimefunStartup extends JavaPlugin { From 9f5b629c43ac177e5412d819afbd908c412e3faf Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 24 Mar 2017 14:08:48 +0100 Subject: [PATCH 07/18] Updated Version --- src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.yml b/src/plugin.yml index c24fc8aa0..283682775 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,5 +1,5 @@ name: Slimefun -version: 4.1.3 +version: 4.1.4 authors: [mrCookieSlime, John000708, st392, DeathlyPanda, BlackBeltPanda] description: Slimefun basically turns your entire Server into a FTB modpack without installing a single mod website: http://TheBusyBiscuit.github.io/ From 092fe4ea47b653dc65b7dabc075d0035356cce4d Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 25 Mar 2017 20:14:23 +0100 Subject: [PATCH 08/18] Update CONTRIBUTING.md --- .github/CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a078e3da8..e9299c33e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -22,6 +22,8 @@ Rules for posting an Issue on GitHub: 4. Do not post your Issue more than once, this is considered spam and does not benefit our community in any way. Do not repost your Issue if it was closed either. 5. Give us all available information right away, it may be a bit of time-wasting for us to keep asking for more Info. And this includes any Information to reproduce your Issue step-by-step. 6. Check whether there are newer versions available than the ones you are using, it might be that your Issue has been fixed already. +7. All text logs must be posted via a link to http://pastebin.com or similiar websites. +8. Please read the [FAQ Section](#Frequently-Asked-Questions) before posting. Your Issue will be CLOSED WITHOUT WARNING if we think you violated these Rules. @@ -32,3 +34,8 @@ Guidelines for making a Pull Request on GitHub: 1. Try to be reasonable with your additions. No, a Bacon flavoured unicorn that flies on a rainbow while dancing Gangnam Style is NOT a reasonable addition to this Project. 2. Try to make your values configurable in the config.yml / Items.yml or any additional file. This may not be necessary at every instance but it does give the end-users a way to customize their experience. 3. If your Pull Request is made in response to an Issue opened on GitHub, comment on that Issue and reference your Pull Request to show that you are proposing a fix for it. + +## Frequently Asked Questions + +> Slimefun does not work!? +> Install CS-CoreLib... From 6321c91376b1371fae7214f547e58e687cd63841 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 25 Mar 2017 20:15:04 +0100 Subject: [PATCH 09/18] Update CONTRIBUTING.md --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index e9299c33e..d304c0233 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -37,5 +37,5 @@ Guidelines for making a Pull Request on GitHub: ## Frequently Asked Questions -> Slimefun does not work!? +> Slimefun does not work!?
> Install CS-CoreLib... From 7e6e7fa5699e14cf8406b1cfcc9e1564feb0b934 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 25 Mar 2017 20:15:35 +0100 Subject: [PATCH 10/18] Update --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d304c0233..441a79c19 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -37,5 +37,5 @@ Guidelines for making a Pull Request on GitHub: ## Frequently Asked Questions -> Slimefun does not work!?
+### Slimefun does not work!? > Install CS-CoreLib... From c33d3bd4a2155bc4de491cc5c81ba1c0d92157ec Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 25 Mar 2017 21:25:58 +0100 Subject: [PATCH 11/18] Update CONTRIBUTING.md --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 441a79c19..b5f887ab6 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -23,7 +23,7 @@ Rules for posting an Issue on GitHub: 5. Give us all available information right away, it may be a bit of time-wasting for us to keep asking for more Info. And this includes any Information to reproduce your Issue step-by-step. 6. Check whether there are newer versions available than the ones you are using, it might be that your Issue has been fixed already. 7. All text logs must be posted via a link to http://pastebin.com or similiar websites. -8. Please read the [FAQ Section](#Frequently-Asked-Questions) before posting. +8. Please read the [FAQ Section](#frequently-asked-questions) before posting. Your Issue will be CLOSED WITHOUT WARNING if we think you violated these Rules. From b901f885fa4b9c528f063f25a2b8a395c0cadc87 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 26 Mar 2017 09:31:27 +0200 Subject: [PATCH 12/18] Fixed Block Inventories --- .../Slimefun/api/inventory/BlockMenu.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java b/src/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java index 7bb5168fd..7fe4a0aed 100644 --- a/src/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java +++ b/src/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java @@ -11,7 +11,6 @@ import org.bukkit.inventory.ItemStack; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; -import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; public class BlockMenu extends ChestMenu { @@ -105,26 +104,6 @@ public class BlockMenu extends ChestMenu { return this.preset.canOpen(b, p); } - @Override - public ChestMenu addItem(int slot, ItemStack item, MenuClickHandler handler) { - addMenuClickHandler(slot, handler); - return super.addItem(slot, item); - } - - @Override - public ChestMenu addMenuClickHandler(int slot, final MenuClickHandler handler) { - MenuClickHandler ch = new MenuClickHandler() { - - @Override - public boolean onClick(Player p, int slot, ItemStack stack, ClickAction action) { - changes++; - return handler.onClick(p, slot, stack, action); - } - }; - - return super.addMenuClickHandler(slot, ch); - } - @Override public void replaceExistingItem(int slot, ItemStack item) { this.replaceExistingItem(slot, item, true); @@ -141,6 +120,11 @@ public class BlockMenu extends ChestMenu { changes++; } + @Override + public ChestMenu addMenuOpeningHandler(MenuOpeningHandler handler) { + return super.addMenuOpeningHandler(new SaveHandler(this, handler)); + } + public void close() { Iterator iterator = toInventory().getViewers().iterator(); while (iterator.hasNext()) { @@ -148,4 +132,22 @@ public class BlockMenu extends ChestMenu { human.closeInventory(); } } + + public class SaveHandler implements MenuOpeningHandler { + + BlockMenu menu; + MenuOpeningHandler handler; + + public SaveHandler(BlockMenu menu, MenuOpeningHandler handler) { + this.handler = handler; + this.menu = menu; + } + + @Override + public void onOpen(Player p) { + handler.onOpen(p); + menu.changes++; + } + + } } From c88ddcc592cf29fced603cd77ff2ae0c29c9c781 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 26 Mar 2017 09:32:42 +0200 Subject: [PATCH 13/18] Updated Version --- src/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.yml b/src/plugin.yml index 283682775..1654cfc0d 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,5 +1,5 @@ name: Slimefun -version: 4.1.4 +version: 4.1.5 authors: [mrCookieSlime, John000708, st392, DeathlyPanda, BlackBeltPanda] description: Slimefun basically turns your entire Server into a FTB modpack without installing a single mod website: http://TheBusyBiscuit.github.io/ From e3e3e67720cd640f32730cd03f3267933be0cfd9 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 27 Mar 2017 16:14:52 +0200 Subject: [PATCH 14/18] Safe Handler --- src/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java b/src/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java index 7fe4a0aed..24209730b 100644 --- a/src/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java +++ b/src/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java @@ -122,7 +122,12 @@ public class BlockMenu extends ChestMenu { @Override public ChestMenu addMenuOpeningHandler(MenuOpeningHandler handler) { - return super.addMenuOpeningHandler(new SaveHandler(this, handler)); + if (handler instanceof SaveHandler) { + return super.addMenuOpeningHandler(new SaveHandler(this, ((SaveHandler) handler).handler)); + } + else { + return super.addMenuOpeningHandler(new SaveHandler(this, handler)); + } } public void close() { From eb9e313c09daf254bd365bad466ba82b029d1b4c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 27 Mar 2017 18:48:45 +0200 Subject: [PATCH 15/18] Create CONTRIBUTING.md --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..6de7b8c69 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +This is a test file. From c5f69d81ac6b76a626c320a0d767f0bd7fc24be7 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Mon, 27 Mar 2017 18:48:59 +0200 Subject: [PATCH 16/18] Delete CONTRIBUTING.md --- CONTRIBUTING.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 6de7b8c69..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -This is a test file. From af6ec415b091ef1c1d5caca8d17756327baa7912 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 31 Mar 2017 14:47:43 +0200 Subject: [PATCH 17/18] Maybe made the Block Storage stuff safer, idk --- .../Slimefun/SlimefunStartup.java | 129 +----- .../Slimefun/api/SlimefunBackup.java | 119 +++++ .../Slimefun/api/TickerTask.java | 415 +++++++++--------- 3 files changed, 343 insertions(+), 320 deletions(-) create mode 100644 src/me/mrCookieSlime/Slimefun/api/SlimefunBackup.java diff --git a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java index fc9887095..9dafc6126 100644 --- a/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java +++ b/src/me/mrCookieSlime/Slimefun/SlimefunStartup.java @@ -1,23 +1,9 @@ package me.mrCookieSlime.Slimefun; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -34,7 +20,6 @@ import org.bukkit.scheduler.BukkitRunnable; import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib; import me.mrCookieSlime.CSCoreLibPlugin.PluginUtils; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import me.mrCookieSlime.CSCoreLibPlugin.general.Clock; import me.mrCookieSlime.CSCoreLibPlugin.general.Reflection.ReflectionUtils; import me.mrCookieSlime.Slimefun.AncientAltar.Pedestals; import me.mrCookieSlime.Slimefun.CSCoreLibSetup.CSCoreLibLoader; @@ -64,6 +49,7 @@ import me.mrCookieSlime.Slimefun.URID.URID; import me.mrCookieSlime.Slimefun.WorldEdit.WESlimefunManager; import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.Slimefun; +import me.mrCookieSlime.Slimefun.api.SlimefunBackup; import me.mrCookieSlime.Slimefun.api.TickerTask; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; import me.mrCookieSlime.Slimefun.api.energy.EnergyNet; @@ -375,7 +361,7 @@ public class SlimefunStartup extends JavaPlugin { connector.pullFile(); } } - }, 60L, 20 * 60 * 20L); + }, 80L, 60 * 60 * 20L); // Hooray! System.out.println("[Slimefun] Finished!"); @@ -408,112 +394,23 @@ public class SlimefunStartup extends JavaPlugin { @Override public void onDisable() { Bukkit.getScheduler().cancelTasks(this); - + + // Finishes all started movements/removals of block data + ticker.HALTED = true; + ticker.run(); + try { - for (Map.Entry entry: ticker.move.entrySet()) { - BlockStorage._integrated_moveBlockInfo(entry.getKey(), entry.getValue()); - } - ticker.move.clear(); - for (World world: Bukkit.getWorlds()) { BlockStorage storage = BlockStorage.getStorage(world); - if (storage != null) storage.save(true); - else System.err.println("[Slimefun] Could not save Slimefun Blocks for World \"" + world.getName() + "\""); - } - - File folder = new File("data-storage/Slimefun/block-backups"); - List backups = Arrays.asList(folder.listFiles()); - if (backups.size() > 20) { - Collections.sort(backups, new Comparator() { - - @Override - public int compare(File f1, File f2) { - try { - return (int) (new SimpleDateFormat("yyyy-MM-dd-HH-mm").parse(f1.getName().replace(".zip", "")).getTime() - new SimpleDateFormat("yyyy-MM-dd-HH-mm").parse(f2.getName().replace(".zip", "")).getTime()); - } catch (ParseException e) { - return 0; - } - } - }); - - for (int i = backups.size() - 20; i > 0; i--) { - backups.get(i).delete(); + if (storage != null) { + storage.save(true); + } + else { + System.err.println("[Slimefun] Could not save Slimefun Blocks for World \"" + world.getName() + "\""); } } - File file = new File("data-storage/Slimefun/block-backups/" + Clock.format(new Date()) + ".zip"); - byte[] buffer = new byte[1024]; - - if (file.exists()) file.delete(); - - try { - file.createNewFile(); - - ZipOutputStream output = new ZipOutputStream(new FileOutputStream(file)); - - for (File f1: new File("data-storage/Slimefun/stored-blocks/").listFiles()) { - for (File f: f1.listFiles()) { - ZipEntry entry = new ZipEntry("stored-blocks/" + f1.getName() + "/" + f.getName()); - output.putNextEntry(entry); - FileInputStream input = new FileInputStream(f); - - int length; - while ((length = input.read(buffer)) > 0) { - output.write(buffer, 0, length); - } - - input.close(); - output.closeEntry(); - } - } - - for (File f: new File("data-storage/Slimefun/universal-inventories/").listFiles()) { - ZipEntry entry = new ZipEntry("universal-inventories/" + f.getName()); - output.putNextEntry(entry); - FileInputStream input = new FileInputStream(f); - - int length; - while ((length = input.read(buffer)) > 0) { - output.write(buffer, 0, length); - } - - input.close(); - output.closeEntry(); - } - - for (File f: new File("data-storage/Slimefun/stored-inventories/").listFiles()) { - ZipEntry entry = new ZipEntry("stored-inventories/" + f.getName()); - output.putNextEntry(entry); - FileInputStream input = new FileInputStream(f); - - int length; - while ((length = input.read(buffer)) > 0) { - output.write(buffer, 0, length); - } - - input.close(); - output.closeEntry(); - } - - if (new File("data-storage/Slimefun/stored-chunks/chunks.sfc").exists()) { - ZipEntry entry = new ZipEntry("stored-chunks/chunks.sfc"); - output.putNextEntry(entry); - FileInputStream input = new FileInputStream(new File("data-storage/Slimefun/stored-chunks/chunks.sfc")); - - int length; - while ((length = input.read(buffer)) > 0) { - output.write(buffer, 0, length); - } - - input.close(); - output.closeEntry(); - } - - output.close(); - System.out.println("[Slimfun] Backed up Blocks to " + file.getName()); - } catch(IOException e) { - e.printStackTrace(); - } + SlimefunBackup.start(); } catch(Exception x) { } diff --git a/src/me/mrCookieSlime/Slimefun/api/SlimefunBackup.java b/src/me/mrCookieSlime/Slimefun/api/SlimefunBackup.java new file mode 100644 index 000000000..76c3fbcb5 --- /dev/null +++ b/src/me/mrCookieSlime/Slimefun/api/SlimefunBackup.java @@ -0,0 +1,119 @@ +package me.mrCookieSlime.Slimefun.api; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import me.mrCookieSlime.CSCoreLibPlugin.general.Clock; + +public class SlimefunBackup { + + public static void start() { + File folder = new File("data-storage/Slimefun/block-backups"); + List backups = Arrays.asList(folder.listFiles()); + if (backups.size() > 20) { + Collections.sort(backups, new Comparator() { + + @Override + public int compare(File f1, File f2) { + try { + return (int) (new SimpleDateFormat("yyyy-MM-dd-HH-mm").parse(f1.getName().replace(".zip", "")).getTime() - new SimpleDateFormat("yyyy-MM-dd-HH-mm").parse(f2.getName().replace(".zip", "")).getTime()); + } catch (ParseException e) { + return 0; + } + } + }); + + for (int i = backups.size() - 20; i > 0; i--) { + backups.get(i).delete(); + } + } + + File file = new File("data-storage/Slimefun/block-backups/" + Clock.format(new Date()) + ".zip"); + byte[] buffer = new byte[1024]; + + if (file.exists()) { + file.delete(); + } + + try { + file.createNewFile(); + + ZipOutputStream output = new ZipOutputStream(new FileOutputStream(file)); + + for (File f1: new File("data-storage/Slimefun/stored-blocks/").listFiles()) { + for (File f: f1.listFiles()) { + ZipEntry entry = new ZipEntry("stored-blocks/" + f1.getName() + "/" + f.getName()); + output.putNextEntry(entry); + FileInputStream input = new FileInputStream(f); + + int length; + while ((length = input.read(buffer)) > 0) { + output.write(buffer, 0, length); + } + + input.close(); + output.closeEntry(); + } + } + + for (File f: new File("data-storage/Slimefun/universal-inventories/").listFiles()) { + ZipEntry entry = new ZipEntry("universal-inventories/" + f.getName()); + output.putNextEntry(entry); + FileInputStream input = new FileInputStream(f); + + int length; + while ((length = input.read(buffer)) > 0) { + output.write(buffer, 0, length); + } + + input.close(); + output.closeEntry(); + } + + for (File f: new File("data-storage/Slimefun/stored-inventories/").listFiles()) { + ZipEntry entry = new ZipEntry("stored-inventories/" + f.getName()); + output.putNextEntry(entry); + FileInputStream input = new FileInputStream(f); + + int length; + while ((length = input.read(buffer)) > 0) { + output.write(buffer, 0, length); + } + + input.close(); + output.closeEntry(); + } + + if (new File("data-storage/Slimefun/stored-chunks/chunks.sfc").exists()) { + ZipEntry entry = new ZipEntry("stored-chunks/chunks.sfc"); + output.putNextEntry(entry); + FileInputStream input = new FileInputStream(new File("data-storage/Slimefun/stored-chunks/chunks.sfc")); + + int length; + while ((length = input.read(buffer)) > 0) { + output.write(buffer, 0, length); + } + + input.close(); + output.closeEntry(); + } + + output.close(); + System.out.println("[Slimfun] Backed up Blocks to " + file.getName()); + } catch(IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/me/mrCookieSlime/Slimefun/api/TickerTask.java b/src/me/mrCookieSlime/Slimefun/api/TickerTask.java index d9677a317..23eb982ca 100644 --- a/src/me/mrCookieSlime/Slimefun/api/TickerTask.java +++ b/src/me/mrCookieSlime/Slimefun/api/TickerTask.java @@ -23,6 +23,8 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.handlers.BlockTicker; public class TickerTask implements Runnable { + public boolean HALTED = false; + public Map move = new HashMap(); public Map delete = new HashMap(); @@ -42,6 +44,7 @@ public class TickerTask implements Runnable { @Override public void run() { + long timestamp = System.currentTimeMillis(); skipped = 0; @@ -65,57 +68,59 @@ public class TickerTask implements Runnable { delete.remove(entry.getKey()); } - for (final String c: BlockStorage.getTickingChunks()) { - long timestamp2 = System.currentTimeMillis(); - chunks++; - - blocks: - for (final Block b: BlockStorage.getTickingBlocks(c)) { - if (b.getChunk().isLoaded()) { - final Location l = b.getLocation(); - final SlimefunItem item = BlockStorage.check(l); - if (item != null) { - machines++; - try { - item.getTicker().update(); - if (item.getTicker().isSynchronized()) { - Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { - - @Override - public void run() { - try { - long timestamp3 = System.currentTimeMillis(); - item.getTicker().tick(b, item, BlockStorage.getBlockInfo(l)); - - map_machinetime.put(item.getName(), (map_machinetime.containsKey(item.getName()) ? map_machinetime.get(item.getName()): 0) + (System.currentTimeMillis() - timestamp3)); - map_chunk.put(c, (map_chunk.containsKey(c) ? map_chunk.get(c): 0) + 1); - map_machine.put(item.getName(), (map_machine.containsKey(item.getName()) ? map_machine.get(item.getName()): 0) + 1); - block_timings.put(l, System.currentTimeMillis() - timestamp3); - } catch(Exception x) { - int errors = 0; - if (bugged.containsKey(l)) errors = bugged.get(l); - errors++; - - if (errors == 1) { - File file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + ".err"); - if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(2).err"); + if (!HALTED) { + for (final String c: BlockStorage.getTickingChunks()) { + long timestamp2 = System.currentTimeMillis(); + chunks++; + + blocks: + for (final Block b: BlockStorage.getTickingBlocks(c)) { + if (b.getChunk().isLoaded()) { + final Location l = b.getLocation(); + final SlimefunItem item = BlockStorage.check(l); + if (item != null) { + machines++; + try { + item.getTicker().update(); + if (item.getTicker().isSynchronized()) { + Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { + + @Override + public void run() { + try { + long timestamp3 = System.currentTimeMillis(); + item.getTicker().tick(b, item, BlockStorage.getBlockInfo(l)); + + map_machinetime.put(item.getName(), (map_machinetime.containsKey(item.getName()) ? map_machinetime.get(item.getName()): 0) + (System.currentTimeMillis() - timestamp3)); + map_chunk.put(c, (map_chunk.containsKey(c) ? map_chunk.get(c): 0) + 1); + map_machine.put(item.getName(), (map_machine.containsKey(item.getName()) ? map_machine.get(item.getName()): 0) + 1); + block_timings.put(l, System.currentTimeMillis() - timestamp3); + } catch(Exception x) { + int errors = 0; + if (bugged.containsKey(l)) errors = bugged.get(l); + errors++; + + if (errors == 1) { + File file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + ".err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(3).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(2).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(4).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(3).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(5).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(4).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(6).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(5).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(7).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(6).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(8).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(7).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(9).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(8).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(10).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(9).err"); + if (file.exists()) { + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(10).err"); + } } } } @@ -124,113 +129,113 @@ public class TickerTask implements Runnable { } } } - } - try { - PrintStream stream = new PrintStream(file); - stream.println(); - stream.println("Server Software: " + Bukkit.getName()); - stream.println(" Build: " + Bukkit.getVersion()); - stream.println(" Minecraft: " + Bukkit.getBukkitVersion()); - stream.println(); - stream.println("Installed Plugins (" + Bukkit.getPluginManager().getPlugins().length + ")"); - for (Plugin p: Bukkit.getPluginManager().getPlugins()) { - if (Bukkit.getPluginManager().isPluginEnabled(p)) { - stream.println(" + " + p.getName() + " " + p.getDescription().getVersion()); - } - else { - stream.println(" - " + p.getName() + " " + p.getDescription().getVersion()); + try { + PrintStream stream = new PrintStream(file); + stream.println(); + stream.println("Server Software: " + Bukkit.getName()); + stream.println(" Build: " + Bukkit.getVersion()); + stream.println(" Minecraft: " + Bukkit.getBukkitVersion()); + stream.println(); + stream.println("Installed Plugins (" + Bukkit.getPluginManager().getPlugins().length + ")"); + for (Plugin p: Bukkit.getPluginManager().getPlugins()) { + if (Bukkit.getPluginManager().isPluginEnabled(p)) { + stream.println(" + " + p.getName() + " " + p.getDescription().getVersion()); + } + else { + stream.println(" - " + p.getName() + " " + p.getDescription().getVersion()); + } } + stream.println(); + stream.println("Ticked Block:"); + stream.println(" World: " + l.getWorld().getName()); + stream.println(" X: " + l.getBlockX()); + stream.println(" Y: " + l.getBlockY()); + stream.println(" Z: " + l.getBlockZ()); + stream.println(); + stream.println("Slimefun Data:"); + stream.println(" ID: " + item.getName()); + stream.println(" Inventory: " + BlockStorage.getStorage(l.getWorld()).hasInventory(l)); + stream.println(" Data: " + BlockStorage.getBlockInfoAsJson(l)); + stream.println(); + stream.println("Stacktrace:"); + stream.println(); + x.printStackTrace(stream); + + stream.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); } - stream.println(); - stream.println("Ticked Block:"); - stream.println(" World: " + l.getWorld().getName()); - stream.println(" X: " + l.getBlockX()); - stream.println(" Y: " + l.getBlockY()); - stream.println(" Z: " + l.getBlockZ()); - stream.println(); - stream.println("Slimefun Data:"); - stream.println(" ID: " + item.getName()); - stream.println(" Inventory: " + BlockStorage.getStorage(l.getWorld()).hasInventory(l)); - stream.println(" Data: " + BlockStorage.getBlockInfoAsJson(l)); - stream.println(); - stream.println("Stacktrace:"); - stream.println(); - x.printStackTrace(stream); - stream.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); + System.err.println("[Slimefun] Exception caught while ticking a Block:" + x.getClass().getName()); + System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ()); + System.err.println("[Slimefun] Saved as: "); + System.err.println("[Slimefun] /plugins/Slimefun/error-reports/" + file.getName()); + System.err.println("[Slimefun] Please consider sending this File to the developer(s) of Slimefun, sending this Error won't get you any help though."); + System.err.println("[Slimefun] "); + + bugged_blocks.put(l, errors); } - - System.err.println("[Slimefun] Exception caught while ticking a Block:" + x.getClass().getName()); - System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ()); - System.err.println("[Slimefun] Saved as: "); - System.err.println("[Slimefun] /plugins/Slimefun/error-reports/" + file.getName()); - System.err.println("[Slimefun] Please consider sending this File to the developer(s) of Slimefun, sending this Error won't get you any help though."); - System.err.println("[Slimefun] "); - - bugged_blocks.put(l, errors); - } - else if (errors == 4) { - System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + "(" + item.getName() + ")"); - System.err.println("[Slimefun] has thrown 4 Exceptions in the last 4 Ticks, the Block has been terminated."); - System.err.println("[Slimefun] Check your /plugins/Slimefun/error-reports/ folder for details."); - System.err.println("[Slimefun] "); - - BlockStorage._integrated_removeBlockInfo(l, true); - - Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { + else if (errors == 4) { + System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + "(" + item.getName() + ")"); + System.err.println("[Slimefun] has thrown 4 Exceptions in the last 4 Ticks, the Block has been terminated."); + System.err.println("[Slimefun] Check your /plugins/Slimefun/error-reports/ folder for details."); + System.err.println("[Slimefun] "); + + BlockStorage._integrated_removeBlockInfo(l, true); + + Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { - @Override - public void run() { - l.getBlock().setType(Material.AIR); - } - - }); - } - else { - bugged_blocks.put(l, errors); + @Override + public void run() { + l.getBlock().setType(Material.AIR); + } + + }); + } + else { + bugged_blocks.put(l, errors); + } } } - } - }); - } - else { - long timestamp3 = System.currentTimeMillis(); - item.getTicker().tick(b, item, BlockStorage.getBlockInfo(l)); + }); + } + else { + long timestamp3 = System.currentTimeMillis(); + item.getTicker().tick(b, item, BlockStorage.getBlockInfo(l)); + + map_machinetime.put(item.getName(), (map_machinetime.containsKey(item.getName()) ? map_machinetime.get(item.getName()): 0) + (System.currentTimeMillis() - timestamp3)); + map_chunk.put(c, (map_chunk.containsKey(c) ? map_chunk.get(c): 0) + 1); + map_machine.put(item.getName(), (map_machine.containsKey(item.getName()) ? map_machine.get(item.getName()): 0) + 1); + block_timings.put(l, System.currentTimeMillis() - timestamp3); + } + tickers.add(item.getTicker()); + } catch(Exception x) { - map_machinetime.put(item.getName(), (map_machinetime.containsKey(item.getName()) ? map_machinetime.get(item.getName()): 0) + (System.currentTimeMillis() - timestamp3)); - map_chunk.put(c, (map_chunk.containsKey(c) ? map_chunk.get(c): 0) + 1); - map_machine.put(item.getName(), (map_machine.containsKey(item.getName()) ? map_machine.get(item.getName()): 0) + 1); - block_timings.put(l, System.currentTimeMillis() - timestamp3); - } - tickers.add(item.getTicker()); - } catch(Exception x) { - - int errors = 0; - if (bugged.containsKey(l)) errors = bugged.get(l); - errors++; - - if (errors == 1) { - File file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + ".err"); - if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(2).err"); + int errors = 0; + if (bugged.containsKey(l)) errors = bugged.get(l); + errors++; + + if (errors == 1) { + File file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + ".err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(3).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(2).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(4).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(3).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(5).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(4).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(6).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(5).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(7).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(6).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(8).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(7).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(9).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(8).err"); if (file.exists()) { - file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(10).err"); + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(9).err"); + if (file.exists()) { + file = new File("plugins/Slimefun/error-reports/" + Clock.getFormattedTime() + "(10).err"); + } } } } @@ -239,86 +244,86 @@ public class TickerTask implements Runnable { } } } - } - try { - PrintStream stream = new PrintStream(file); - stream.println(); - stream.println("Server Software: " + Bukkit.getName()); - stream.println(" Build: " + Bukkit.getVersion()); - stream.println(" Minecraft: " + Bukkit.getBukkitVersion()); - stream.println(); - stream.println("Installed Plugins (" + Bukkit.getPluginManager().getPlugins().length + ")"); - for (Plugin p: Bukkit.getPluginManager().getPlugins()) { - if (Bukkit.getPluginManager().isPluginEnabled(p)) { - stream.println(" + " + p.getName() + " " + p.getDescription().getVersion()); - } - else { - stream.println(" - " + p.getName() + " " + p.getDescription().getVersion()); + try { + PrintStream stream = new PrintStream(file); + stream.println(); + stream.println("Server Software: " + Bukkit.getName()); + stream.println(" Build: " + Bukkit.getVersion()); + stream.println(" Minecraft: " + Bukkit.getBukkitVersion()); + stream.println(); + stream.println("Installed Plugins (" + Bukkit.getPluginManager().getPlugins().length + ")"); + for (Plugin p: Bukkit.getPluginManager().getPlugins()) { + if (Bukkit.getPluginManager().isPluginEnabled(p)) { + stream.println(" + " + p.getName() + " " + p.getDescription().getVersion()); + } + else { + stream.println(" - " + p.getName() + " " + p.getDescription().getVersion()); + } } + stream.println(); + stream.println("Ticked Block:"); + stream.println(" World: " + l.getWorld().getName()); + stream.println(" X: " + l.getBlockX()); + stream.println(" Y: " + l.getBlockY()); + stream.println(" Z: " + l.getBlockZ()); + stream.println(); + stream.println("Slimefun Data:"); + stream.println(" ID: " + item.getName()); + stream.println(" Inventory: " + BlockStorage.getStorage(l.getWorld()).hasInventory(l)); + stream.println(" Data: " + BlockStorage.getBlockInfoAsJson(l)); + stream.println(); + stream.println("Stacktrace:"); + stream.println(); + x.printStackTrace(stream); + + stream.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); } - stream.println(); - stream.println("Ticked Block:"); - stream.println(" World: " + l.getWorld().getName()); - stream.println(" X: " + l.getBlockX()); - stream.println(" Y: " + l.getBlockY()); - stream.println(" Z: " + l.getBlockZ()); - stream.println(); - stream.println("Slimefun Data:"); - stream.println(" ID: " + item.getName()); - stream.println(" Inventory: " + BlockStorage.getStorage(l.getWorld()).hasInventory(l)); - stream.println(" Data: " + BlockStorage.getBlockInfoAsJson(l)); - stream.println(); - stream.println("Stacktrace:"); - stream.println(); - x.printStackTrace(stream); - stream.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); + System.err.println("[Slimefun] Exception caught while ticking a Block:" + x.getClass().getName()); + System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ()); + System.err.println("[Slimefun] Saved as: "); + System.err.println("[Slimefun] /plugins/Slimefun/error-reports/" + file.getName()); + System.err.println("[Slimefun] Please consider sending this File to the developer(s) of Slimefun, sending this Error won't get you any help though."); + System.err.println("[Slimefun] "); + + bugged_blocks.put(l, errors); } - - System.err.println("[Slimefun] Exception caught while ticking a Block:" + x.getClass().getName()); - System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ()); - System.err.println("[Slimefun] Saved as: "); - System.err.println("[Slimefun] /plugins/Slimefun/error-reports/" + file.getName()); - System.err.println("[Slimefun] Please consider sending this File to the developer(s) of Slimefun, sending this Error won't get you any help though."); - System.err.println("[Slimefun] "); - - bugged_blocks.put(l, errors); - } - else if (errors == 4) { - System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + "(" + item.getName() + ")"); - System.err.println("[Slimefun] has thrown 4 Exceptions in the last 4 Ticks, the Block has been terminated."); - System.err.println("[Slimefun] Check your /plugins/Slimefun/error-reports/ folder for details."); - System.err.println("[Slimefun] "); - - BlockStorage._integrated_removeBlockInfo(l, true); - - Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { + else if (errors == 4) { + System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + "(" + item.getName() + ")"); + System.err.println("[Slimefun] has thrown 4 Exceptions in the last 4 Ticks, the Block has been terminated."); + System.err.println("[Slimefun] Check your /plugins/Slimefun/error-reports/ folder for details."); + System.err.println("[Slimefun] "); + + BlockStorage._integrated_removeBlockInfo(l, true); + + Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { - @Override - public void run() { - l.getBlock().setType(Material.AIR); - } - - }); - } - else { - bugged_blocks.put(l, errors); + @Override + public void run() { + l.getBlock().setType(Material.AIR); + } + + }); + } + else { + bugged_blocks.put(l, errors); + } } } + else skipped++; + } + else { + skipped += BlockStorage.getTickingBlocks(c).size(); + skipped_chunks.add(c); + chunks--; + break blocks; } - else skipped++; - } - else { - skipped += BlockStorage.getTickingBlocks(c).size(); - skipped_chunks.add(c); - chunks--; - break blocks; } + + map_chunktime.put(c, System.currentTimeMillis() - timestamp2); } - - map_chunktime.put(c, System.currentTimeMillis() - timestamp2); } for (Map.Entry entry: move.entrySet()) { @@ -336,6 +341,8 @@ public class TickerTask implements Runnable { public void info(CommandSender sender) { sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&2== &aSlimefun Diagnostic Tool &2==")); + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6Halted: &e&l" + String.valueOf(HALTED).toUpperCase())); + sender.sendMessage(""); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6Impact: &e" + time + "ms / 50-750ms")); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6Ticked Chunks: &e" + chunks)); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6Ticked Machines: &e" + machines)); From 4650b9294706937fa4c6a2c710fb57628d35e059 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 2 Apr 2017 11:09:52 +0200 Subject: [PATCH 18/18] Added Addons amount to /sf versions --- .../Slimefun/Commands/SlimefunCommand.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java b/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java index 146721d5a..4b75cb48d 100644 --- a/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java +++ b/src/me/mrCookieSlime/Slimefun/Commands/SlimefunCommand.java @@ -159,19 +159,29 @@ public class SlimefunCommand implements CommandExecutor, Listener { sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aCS-CoreLib &2v" + CSCoreLib.getLib().getDescription().getVersion())); sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSlimefun &2v" + plugin.getDescription().getVersion())); sender.sendMessage(""); - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7&oInstalled Addons:")); + + List addons = new ArrayList(); + for (Plugin plugin: Bukkit.getPluginManager().getPlugins()) { if (plugin.getDescription().getDepend().contains("Slimefun") || plugin.getDescription().getSoftDepend().contains("Slimefun")) { if (Bukkit.getPluginManager().isPluginEnabled(plugin)) { - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', " &a" + plugin.getName() + " &2v" + plugin.getDescription().getVersion())); + addons.add(ChatColor.translateAlternateColorCodes('&', " &a" + plugin.getName() + " &2v" + plugin.getDescription().getVersion())); } else { - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', " &c" + plugin.getName() + " &4v" + plugin.getDescription().getVersion())); + addons.add(ChatColor.translateAlternateColorCodes('&', " &c" + plugin.getName() + " &4v" + plugin.getDescription().getVersion())); } } } + + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7Installed Addons &8(" + addons.size() + ")")); + + for (String addon: addons) { + sender.sendMessage(addon); + } + } + else { + Messages.local.sendTranslation(sender, "messages.no-permission", true); } - else Messages.local.sendTranslation(sender, "messages.no-permission", true); } else if (args[0].equalsIgnoreCase("give")) { if (args.length == 3) {