1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Logger Conversion Pt.5

This commit is contained in:
TheBusyBiscuit 2019-08-31 17:52:20 +02:00
parent 2f5177b785
commit edeef7c14d
16 changed files with 150 additions and 100 deletions

View File

@ -1,6 +1,7 @@
package me.mrCookieSlime.Slimefun.GEO;
import java.util.Collection;
import java.util.logging.Level;
import org.bukkit.Chunk;
import org.bukkit.block.Biome;
@ -8,6 +9,7 @@ import org.bukkit.block.Biome;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun;
public final class OreGenSystem {
@ -19,7 +21,7 @@ public final class OreGenSystem {
public static void registerResource(OreGenResource resource) {
SlimefunPlugin.getUtilities().resources.put(resource.getName(), resource);
System.out.println("[Slimefun - GEO] Registering Ore Gen: " + resource.getName());
Slimefun.getLogger().log(Level.INFO, "Registering Ore Gen: " + resource.getName());
Config cfg = new Config("plugins/Slimefun/generators/" + resource.getName() + ".cfg");
for (Biome biome: Biome.values()) {

View File

@ -38,40 +38,38 @@ public class MultiBlock {
}
public boolean isMultiBlock(SlimefunItem machine) {
if (machine == null) return false;
else if (!(machine instanceof SlimefunMachine)) return false;
else if (machine instanceof SlimefunMachine) {
MultiBlock mb = ((SlimefunMachine) machine).toMultiBlock();
if (trigger == mb.getTriggerBlock()) {
for (int i = 0; i < mb.getBuild().length; i++) {
if (mb.getBuild()[i] != null) {
if (MaterialHelper.isLog( mb.getBuild()[i])) {
if (!MaterialHelper.isLog(blocks[i])) return false;
}
else if (mb.getBuild()[i] != blocks[i]) return false;
}
}
return true;
}
else return false;
if (machine instanceof SlimefunMachine) {
return isMultiBlock(((SlimefunMachine) machine).toMultiBlock());
}
else return false;
}
public boolean isMultiBlock(MultiBlock mb) {
if (mb == null) return false;
else if (trigger == mb.getTriggerBlock()) {
if (trigger == mb.getTriggerBlock()) {
for (int i = 0; i < mb.getBuild().length; i++) {
if (mb.getBuild()[i] != null) {
if (MaterialHelper.isLog(mb.getBuild()[i])) {
if (!MaterialHelper.isLog(blocks[i])) return false;
}
else if (mb.getBuild()[i] != blocks[i]) return false;
}
if (!compareBlocks(blocks[i], mb.getBuild()[i])) return false;
}
return true;
}
else return false;
return false;
}
private boolean compareBlocks(Material a, Material b) {
if (b != null) {
if (MaterialHelper.isLog(b)) {
return MaterialHelper.isLog(a);
}
if (b != a) {
return false;
}
}
return true;
}
}

View File

@ -7,6 +7,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -303,7 +304,9 @@ public class Research {
this.enabled = SlimefunPlugin.getResearchCfg().getBoolean(this.getID() + ".enabled");
list.add(this);
if (SlimefunPlugin.getCfg().getBoolean("options.print-out-loading")) System.out.println("[Slimefun] Loaded Research \"" + this.getName() + "\"");
if (SlimefunPlugin.getSettings().printOutLoading) {
Slimefun.getLogger().log(Level.INFO, "Loaded Research \"" + this.getName() + "\"");
}
}
/**

View File

@ -259,7 +259,9 @@ public class SlimefunItem {
handlers.put(handler.toCodename(), handlerset);
}
if (SlimefunPlugin.getCfg().getBoolean("options.print-out-loading")) System.out.println("[Slimefun] Loaded Item \"" + this.id + "\"");
if (SlimefunPlugin.getSettings().printOutLoading) {
Slimefun.getLogger().log(Level.INFO, "Loaded Item \"" + this.id + "\"");
}
}
else {
if (this instanceof VanillaItem) this.state = State.VANILLA;

View File

@ -1,6 +1,9 @@
package me.mrCookieSlime.Slimefun.Setup;
import java.io.File;
import java.util.logging.Level;
import me.mrCookieSlime.Slimefun.api.Slimefun;
public final class Files {
@ -12,17 +15,17 @@ public final class Files {
public void cleanup() {
if (!researches.exists()) {
System.err.println("###############################################");
System.err.println("############## = - INFO - = #################");
System.err.println("###############################################");
System.err.println(" ");
System.err.println("Slimefun Warning:");
System.err.println(" ");
System.err.println("Slimefun has detected that your Files are either");
System.err.println("outdated or do not exist. We generated new Files");
System.err.println("instead otherwise Slimefun would not work. If you");
System.err.println("have used Slimefun before, your Settings are now");
System.err.println("gone. But therefore Slimefun works!");
Slimefun.getLogger().log(Level.WARNING, "###############################################");
Slimefun.getLogger().log(Level.WARNING, "############## = - INFO - = #################");
Slimefun.getLogger().log(Level.WARNING, "###############################################");
Slimefun.getLogger().log(Level.WARNING, " ");
Slimefun.getLogger().log(Level.WARNING, "Slimefun Warning:");
Slimefun.getLogger().log(Level.WARNING, " ");
Slimefun.getLogger().log(Level.WARNING, "Slimefun has detected that your Files are either");
Slimefun.getLogger().log(Level.WARNING, "outdated or do not exist. We generated new Files");
Slimefun.getLogger().log(Level.WARNING, "instead otherwise Slimefun would not work. If you");
Slimefun.getLogger().log(Level.WARNING, "have used Slimefun before, your Settings are now");
Slimefun.getLogger().log(Level.WARNING, "gone. But therefore Slimefun works!");
delete(new File("plugins/Slimefun"));
delete(new File("data-storage/Slimefun"));
}

View File

@ -3,6 +3,7 @@ package me.mrCookieSlime.Slimefun.Setup;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.stream.Stream;
import org.bukkit.Bukkit;
@ -53,11 +54,11 @@ public final class MiscSetup {
while (iterator.hasNext()) {
SlimefunItem item = iterator.next();
if (item == null) {
System.err.println("[Slimefun] Removed bugged Item ('NULL?')");
Slimefun.getLogger().log(Level.WARNING, "Removed bugged Item ('NULL?')");
iterator.remove();
}
else if (item.getItem() == null) {
System.err.println("[Slimefun] Removed bugged Item ('" + item.getID() + "')");
Slimefun.getLogger().log(Level.WARNING, "Removed bugged Item ('" + item.getID() + "')");
iterator.remove();
}
}

View File

@ -122,27 +122,27 @@ public final class SlimefunPlugin extends JavaPlugin {
// Looks like you are using an unsupported Minecraft Version
if (!compatibleVersion) {
System.err.println("### Slimefun failed to load!");
System.err.println("###");
System.err.println("### You are using the wrong Version of Minecraft!!!");
System.err.println("###");
System.err.println("### You are using Minecraft " + ReflectionUtils.getVersion());
System.err.println("### but Slimefun v" + getDescription().getVersion() + " requires you to be using");
System.err.println("### Minecraft " + versions.toString());
System.err.println("###");
System.err.println("### Please use an older Version of Slimefun and disable auto-updating");
System.err.println("### or consider updating your Server Software.");
getLogger().log(Level.SEVERE, "### Slimefun was not installed correctly!");
getLogger().log(Level.SEVERE, "###");
getLogger().log(Level.SEVERE, "### You are using the wrong Version of Minecraft!");
getLogger().log(Level.SEVERE, "###");
getLogger().log(Level.SEVERE, "### You are using Minecraft " + ReflectionUtils.getVersion());
getLogger().log(Level.SEVERE, "### but Slimefun v" + getDescription().getVersion() + " requires you to be using");
getLogger().log(Level.SEVERE, "### Minecraft " + versions.toString());
getLogger().log(Level.SEVERE, "###");
getLogger().log(Level.SEVERE, "### Please use an older Version of Slimefun and disable auto-updating");
getLogger().log(Level.SEVERE, "### or consider updating your Server Software.");
getServer().getPluginManager().disablePlugin(this);
return;
}
}
instance = this;
System.out.println("[Slimefun] Loading Files...");
getLogger().log(Level.INFO, "Loading Files...");
Files files = new Files();
files.cleanup();
System.out.println("[Slimefun] Loading Config...");
getLogger().log(Level.INFO, "Loading Config...");
PluginUtils utils = new PluginUtils(this);
utils.setupConfig();
@ -181,7 +181,7 @@ public final class SlimefunPlugin extends JavaPlugin {
for (String s : storage) createDir("data-storage/Slimefun/" + s);
for (String s : general) createDir("plugins/Slimefun/" + s);
System.out.println("[Slimefun] Loading Items...");
getLogger().log(Level.INFO, "Loading Items...");
MiscSetup.setupItemSettings();
try {
@ -189,18 +189,19 @@ public final class SlimefunPlugin extends JavaPlugin {
} catch (Exception x) {
getLogger().log(Level.SEVERE, "An Error occured while initializing SlimefunItems for Slimefun " + Slimefun.getVersion());
}
MiscSetup.loadDescriptions();
settings = new Settings(config);
settings.researchesEnabled = getResearchCfg().getBoolean("enable-researching");
settings.smelteryFireBreakChance = (Integer) Slimefun.getItemValue("SMELTERY", "chance.fireBreak");
System.out.println("[Slimefun] Loading Researches...");
getLogger().log(Level.INFO, "Loading Researches...");
ResearchSetup.setupResearches();
MiscSetup.setupMisc();
System.out.println("[Slimefun] Loading World Generators...");
getLogger().log(Level.INFO, "Loading World Generators...");
// Generating Oil as an OreGenResource (its a cool API)
OreGenSystem.registerResource(new OilResource());
@ -310,7 +311,7 @@ public final class SlimefunPlugin extends JavaPlugin {
getServer().getScheduler().runTaskTimerAsynchronously(this, () -> utilities.connectors.forEach(GitHubConnector::pullFile), 80L, 60 * 60 * 20L);
// Hooray!
System.out.println("[Slimefun] Finished!");
getLogger().log(Level.INFO, "Finished!");
hooks = new SlimefunHooks(this);
OreWasher.items = new ItemStack[] {SlimefunItems.IRON_DUST, SlimefunItems.GOLD_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.COPPER_DUST, SlimefunItems.ZINC_DUST, SlimefunItems.TIN_DUST, SlimefunItems.LEAD_DUST, SlimefunItems.SILVER_DUST, SlimefunItems.MAGNESIUM_DUST};

View File

@ -81,8 +81,9 @@ public class BlockStorage {
public BlockStorage(final World w) {
if (SlimefunPlugin.getUtilities().worlds.containsKey(w.getName())) return;
this.world = w;
System.out.println("[Slimefun] Loading Blocks for World \"" + w.getName() + "\"");
System.out.println("[Slimefun] This may take a long time...");
Slimefun.getLogger().log(Level.INFO, "Loading Blocks for World \"" + w.getName() + "\"");
Slimefun.getLogger().log(Level.INFO, "This may take a long time...");
File f = new File(path_blocks + w.getName());
if (f.exists()) {
@ -95,13 +96,14 @@ public class BlockStorage {
try {
for (File file: f.listFiles()) {
if (file.getName().equals("null.sfb")) {
System.err.println("[Slimefun] Corrupted file detected!");
System.err.println("[Slimefun] Slimefun will simply skip this File, but you");
System.err.println("[Slimefun] should probably look into it!");
Slimefun.getLogger().log(Level.WARNING, "Corrupted file detected!");
Slimefun.getLogger().log(Level.WARNING, "Slimefun will simply skip this File, but you");
Slimefun.getLogger().log(Level.WARNING, "should maybe look into it!");
Slimefun.getLogger().log(Level.WARNING, file.getPath());
}
else if (file.getName().endsWith(".sfb")) {
if (timestamp + SlimefunPlugin.getSettings().blocksInfoLoadingDelay < System.currentTimeMillis()) {
System.out.println("[Slimefun] Loading Blocks... " + Math.round((((done * 100.0F) / total) * 100.0F) / 100.0F) + "% done (\"" + w.getName() + "\")");
Slimefun.getLogger().log(Level.INFO, "Loading Blocks... " + Math.round((((done * 100.0F) / total) * 100.0F) / 100.0F) + "% done (\"" + w.getName() + "\")");
timestamp = System.currentTimeMillis();
}
@ -118,9 +120,9 @@ public class BlockStorage {
// It should not be possible to have two blocks on the same location. Ignore the
// new entry if a block is already present and print an error to the console.
System.out.println("[Slimefun] Ignoring duplicate block @ " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ());
System.out.println("[Slimefun] Old block data: " + serializeBlockInfo(storage.get(l)));
System.out.println("[Slimefun] New block data (" + key + "): " + json);
Slimefun.getLogger().log(Level.INFO, "Ignoring duplicate block @ " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ());
Slimefun.getLogger().log(Level.INFO, "Old block data: " + serializeBlockInfo(storage.get(l)));
Slimefun.getLogger().log(Level.INFO, "New block data (" + key + "): " + json);
continue;
}
storage.put(l, blockInfo);
@ -129,7 +131,10 @@ public class BlockStorage {
Set<Location> locations = SlimefunPlugin.getUtilities().tickingChunks.getOrDefault(chunkString, new HashSet<>());
locations.add(l);
SlimefunPlugin.getUtilities().tickingChunks.put(chunkString, locations);
if (!SlimefunPlugin.getUtilities().loadedTickers.contains(chunkString)) SlimefunPlugin.getUtilities().loadedTickers.add(chunkString);
if (!SlimefunPlugin.getUtilities().loadedTickers.contains(chunkString)) {
SlimefunPlugin.getUtilities().loadedTickers.add(chunkString);
}
}
} catch (Exception x) {
Slimefun.getLogger().log(Level.WARNING, "Failed to load " + file.getName() + "(" + key + ") for Slimefun " + Slimefun.getVersion(), x);
@ -140,8 +145,8 @@ public class BlockStorage {
}
} finally {
long time = (System.currentTimeMillis() - start);
System.out.println("[Slimefun] Loading Blocks... 100% (FINISHED - " + time + "ms)");
System.out.println("[Slimefun] Loaded a total of " + totalBlocks + " Blocks for World \"" + world.getName() + "\"");
Slimefun.getLogger().log(Level.INFO, "Loading Blocks... 100% (FINISHED - " + time + "ms)");
Slimefun.getLogger().log(Level.INFO, "Loaded a total of " + totalBlocks + " Blocks for World \"" + world.getName() + "\"");
if (totalBlocks > 0) System.out.println("[Slimefun] Avg: " + DoubleHandler.fixDouble((double) time / (double) totalBlocks, 3) + "ms/Block");
}
}
@ -165,6 +170,7 @@ public class BlockStorage {
if (file.getName().startsWith(w.getName()) && file.getName().endsWith(".sfi")) {
Location l = deserializeLocation(file.getName().replace(".sfi", ""));
Config cfg = new Config(file);
try {
BlockMenuPreset preset = BlockMenuPreset.getPreset(cfg.getString("preset"));
if (preset == null) {
@ -222,7 +228,7 @@ public class BlockStorage {
if (computeChanges) computeChanges();
if (changes == 0) return;
System.out.println("[Slimefun] Saving Blocks for World \"" + world.getName() + "\" (" + changes + " Change(s) queued)");
Slimefun.getLogger().log(Level.INFO, "Saving Blocks for World \"" + world.getName() + "\" (" + changes + " Change(s) queued)");
Map<String, Config> cache = new HashMap<>(cache_blocks);

View File

@ -82,6 +82,7 @@ public class ErrorReport {
stream.println();
throwable.printStackTrace(stream);
Slimefun.getLogger().log(Level.WARNING, "");
Slimefun.getLogger().log(Level.WARNING, "An Error occured! It has been saved as: ");
Slimefun.getLogger().log(Level.WARNING, "/plugins/Slimefun/error-reports/" + file.getName());
Slimefun.getLogger().log(Level.WARNING, "Please consider sending this File to the developer(s) of Slimefun, this message does not have to be included.");

View File

@ -108,16 +108,13 @@ public class TickerTask implements Runnable {
// Generate a new Error-Report
new ErrorReport(x, this, l, item);
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());
buggedBlocks.put(l, errors);
}
else if (errors == 4) {
System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + "(" + item.getID() + ")");
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] ");
Slimefun.getLogger().log(Level.SEVERE, "X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + "(" + item.getID() + ")");
Slimefun.getLogger().log(Level.SEVERE, "has thrown 4 Exceptions in the last 4 Ticks, the Block has been terminated.");
Slimefun.getLogger().log(Level.SEVERE, "Check your /plugins/Slimefun/error-reports/ folder for details.");
Slimefun.getLogger().log(Level.SEVERE, " ");
BlockStorage._integrated_removeBlockInfo(l, true);
@ -149,17 +146,13 @@ public class TickerTask implements Runnable {
if (errors == 1) {
// Generate a new Error-Report
new ErrorReport(x, this, l, item);
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());
buggedBlocks.put(l, errors);
}
else if (errors == 4) {
System.err.println("[Slimefun] X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + "(" + item.getID() + ")");
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] ");
Slimefun.getLogger().log(Level.SEVERE, "X: " + l.getBlockX() + " Y: " + l.getBlockY() + " Z: " + l.getBlockZ() + "(" + item.getID() + ")");
Slimefun.getLogger().log(Level.SEVERE, "has thrown 4 Exceptions in the last 4 Ticks, the Block has been terminated.");
Slimefun.getLogger().log(Level.SEVERE, "Check your /plugins/Slimefun/error-reports/ folder for details.");
Slimefun.getLogger().log(Level.SEVERE, " ");
BlockStorage._integrated_removeBlockInfo(l, true);

View File

@ -2,12 +2,14 @@ package me.mrCookieSlime.Slimefun.autosave;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.World;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun;
public class BlockAutoSaver implements Runnable {
@ -27,7 +29,7 @@ public class BlockAutoSaver implements Runnable {
}
if (!worlds.isEmpty()) {
System.out.println("[Slimefun] Auto-Saving Block Data... (Next Auto-Save: " + SlimefunPlugin.getCfg().getInt("options.auto-save-delay-in-minutes") + "m)");
Slimefun.getLogger().log(Level.INFO, "Auto-Saving Block Data... (Next Auto-Save: " + SlimefunPlugin.getCfg().getInt("options.auto-save-delay-in-minutes") + "m)");
for (BlockStorage storage: worlds) {
storage.save(false);

View File

@ -1,8 +1,10 @@
package me.mrCookieSlime.Slimefun.autosave;
import java.util.Iterator;
import java.util.logging.Level;
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
import me.mrCookieSlime.Slimefun.api.Slimefun;
public class PlayerAutoSaver implements Runnable {
@ -23,7 +25,7 @@ public class PlayerAutoSaver implements Runnable {
}
if (players > 0) {
System.out.println("[Slimefun] Auto-Saved Player Data for " + players + " Player(s)!");
Slimefun.getLogger().log(Level.INFO, "Auto-Saved Player Data for " + players + " Player(s)!");
}
}

View File

@ -1,11 +1,16 @@
package me.mrCookieSlime.Slimefun.hooks;
import java.util.logging.Level;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.api.Slimefun;
import net.coreprotect.CoreProtect;
import net.coreprotect.CoreProtectAPI;
public final class SlimefunHooks {
private SlimefunPlugin plugin;
private boolean exoticGarden = false;
private boolean emeraldEnchants = false;
private boolean coreProtect = false;
@ -16,39 +21,55 @@ public final class SlimefunHooks {
private CoreProtectAPI coreProtectAPI;
public SlimefunHooks(SlimefunPlugin plugin) {
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
this.plugin = plugin;
if (isPluginInstalled("PlaceholderAPI")) {
placeHolderAPI = true;
new PlaceholderAPIHook().register();
}
/*
* These Items are not marked as soft-dependencies and
* therefore need to be loaded after the Server has finished
* loading all plugins
*/
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (plugin.getServer().getPluginManager().isPluginEnabled("ClearLag")) {
if (isPluginInstalled("ClearLag")) {
clearLag = true;
new ClearLagHook(plugin);
}
exoticGarden = plugin.getServer().getPluginManager().isPluginEnabled("ExoticGarden"); // Had to do it this way, otherwise it seems disabled.
emeraldEnchants = plugin.getServer().getPluginManager().isPluginEnabled("EmeraldEnchants");
exoticGarden = isPluginInstalled("ExoticGarden");
emeraldEnchants = isPluginInstalled("EmeraldEnchants");
if (plugin.getServer().getPluginManager().isPluginEnabled("CoreProtect")) {
if (isPluginInstalled("CoreProtect")) {
coreProtectAPI = ((CoreProtect) plugin.getServer().getPluginManager().getPlugin("CoreProtect")).getAPI();
}
// WorldEdit Hook to clear Slimefun Data upon //set 0 //cut or any other equivalent
if (plugin.getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
if (isPluginInstalled("WorldEdit")) {
try {
Class.forName("com.sk89q.worldedit.extent.Extent");
worldEdit = true;
new WorldEditHook();
System.out.println("[Slimefun] Successfully hooked into WorldEdit!");
} catch (Exception x) {
System.err.println("[Slimefun] Failed to hook into WorldEdit!");
System.err.println("[Slimefun] Maybe consider updating WorldEdit or Slimefun?");
Slimefun.getLogger().log(Level.WARNING, "Failed to hook into WorldEdit!");
Slimefun.getLogger().log(Level.WARNING, "Maybe consider updating WorldEdit or Slimefun?");
}
}
});
}
private boolean isPluginInstalled(String hook) {
if (plugin.getServer().getPluginManager().isPluginEnabled(hook)) {
Slimefun.getLogger().log(Level.INFO, "Hooked into Plugin: " + hook);
return true;
}
else {
return false;
}
}
public boolean isExoticGardenInstalled() {
return exoticGarden;
}

View File

@ -33,7 +33,9 @@ public abstract class GitHubConnector {
public abstract void onFailure();
public void pullFile() {
if (SlimefunPlugin.getCfg().getBoolean("options.print-out-github-data-retrieving")) System.out.println("[Slimefun - GitHub] Retrieving '" + this.getFileName() + ".json' from GitHub...");
if (SlimefunPlugin.getCfg().getBoolean("options.print-out-github-data-retrieving")) {
Slimefun.getLogger().log(Level.INFO, "Retrieving '" + this.getFileName() + ".json' from GitHub...");
}
try {
URL website = new URL("https://api.github.com/repos/" + this.getRepository() + this.getURLSuffix());
@ -50,7 +52,9 @@ public abstract class GitHubConnector {
}
}
} catch (IOException e) {
if (SlimefunPlugin.getCfg().getBoolean("options.print-out-github-data-retrieving")) System.err.println("[Slimefun - GitHub] ERROR - Could not connect to GitHub in time.");
if (SlimefunPlugin.getCfg().getBoolean("options.print-out-github-data-retrieving")) {
Slimefun.getLogger().log(Level.WARNING, "Could not connect to GitHub in time.");
}
if (hasData()) {
this.parseData();

View File

@ -1,5 +1,7 @@
package me.mrCookieSlime.Slimefun.listeners;
import java.util.logging.Level;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldLoadEvent;
@ -7,6 +9,7 @@ import org.bukkit.event.world.WorldUnloadEvent;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun;
public class WorldListener implements Listener {
@ -26,8 +29,12 @@ public class WorldListener implements Listener {
@EventHandler
public void onWorldUnload(WorldUnloadEvent e) {
BlockStorage storage = BlockStorage.getStorage(e.getWorld());
if (storage != null) storage.save(true);
else System.err.println("[Slimefun] Could not save Slimefun Blocks for World \"" + e.getWorld().getName() + "\"");
if (storage != null) {
storage.save(true);
}
else {
Slimefun.getLogger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"" + e.getWorld().getName() + "\"");
}
}
}

View File

@ -6,6 +6,8 @@ import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
public final class Settings {
public boolean printOutLoading;
public boolean researchesEnabled;
public boolean researchesFreeInCreative;
public List<String> researchesTitles;
@ -24,6 +26,8 @@ public final class Settings {
public int smelteryFireBreakChance;
public Settings(Config cfg) {
printOutLoading = cfg.getBoolean("options.print-out-loading");
researchesFreeInCreative = cfg.getBoolean("options.allow-free-creative-research");
researchesTitles = cfg.getStringList("research-ranks");