switch all system.err to the logger

This commit is contained in:
danielb 2024-05-22 23:08:42 +00:00
parent 96eed281dc
commit 98276d0961
12 changed files with 23 additions and 18 deletions

View File

@ -1,5 +1,6 @@
package de.butzlabben.inventory;
import de.butzlabben.world.WorldSystem;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
@ -8,6 +9,7 @@ import org.bukkit.inventory.Inventory;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.logging.Level;
public abstract class OrcInventory {
@ -91,7 +93,7 @@ public abstract class OrcInventory {
if (entry.getKey() >= 0 && entry.getKey() < size) {
inv.setItem(entry.getKey(), entry.getValue().getItemStack(p));
} else {
System.err.println("There is a problem with a configured Item!");
WorldSystem.logger().log(Level.SEVERE, "There is a problem with a configured Item!");
}
}

View File

@ -50,7 +50,7 @@ public class InventoryPage extends OrcInventory {
public void addItem(OrcItem item) {
if (i > 36) {
System.err.println("More items than allowed in page view");
WorldSystem.logger().log(Level.SEVERE,"More items than allowed in page view");
return;
}
addItem(i, item);

View File

@ -19,6 +19,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.util.logging.Logger;
/**
* @author Butzlabben
@ -70,7 +71,7 @@ public class WorldSystem extends JavaPlugin {
try {
dconfig.createNewFile();
} catch (IOException e) {
System.err.println("Wasn't able to create DependenceConfig");
WorldSystem.logger().log(Level.SEVERE,"Wasn't able to create DependenceConfig");
e.printStackTrace();
}
new DependenceConfig();
@ -91,6 +92,8 @@ public class WorldSystem extends JavaPlugin {
return JavaPlugin.getPlugin(WorldSystem.class);
}
public static Logger logger() {return WorldSystem.getPlugin(WorldSystem.class).getLogger();}
@Override
public void onEnable() {
//////

View File

@ -280,7 +280,7 @@ public class WorldSettingsCommands {
} catch (IOException e) {
e.printStackTrace();
p.sendMessage(MessageConfig.getUnknownError());
System.err.println("Couldn't reset world of " + p.getName());
WorldSystem.logger().log(Level.SEVERE,"Couldn't reset world of " + p.getName());
}
}
}

View File

@ -38,7 +38,7 @@ public class GuiConfig {
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource(guiFileResource);
Files.copy(in, file.toPath());
} catch (IOException e) {
System.err.println("Wasn't able to create Config");
WorldSystem.logger().log(Level.SEVERE,"Wasn't able to create Config");
e.printStackTrace();
}
}

View File

@ -47,7 +47,7 @@ public class MessageConfig {
}
Files.copy(in, file.toPath());
} catch (IOException e) {
System.err.println("Wasn't able to create Message file");
WorldSystem.logger().log(Level.SEVERE,"Wasn't able to create Message file");
e.printStackTrace();
}
}

View File

@ -68,7 +68,7 @@ public class PluginConfig {
+ new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss").format(new Date()) + ".yml").toPath(),
StandardCopyOption.REPLACE_EXISTING);
Files.delete(file.toPath());
System.err.println("[WorldSystem] Config is broken, creating a new one!");
WorldSystem.logger().log(Level.SEVERE,"[WorldSystem] Config is broken, creating a new one!");
checkConfig(f);
} catch (IOException e) {
e.printStackTrace();
@ -79,7 +79,7 @@ public class PluginConfig {
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource("config.yml");
Files.copy(in, file.toPath());
} catch (IOException e) {
System.err.println("Wasn't able to create Config");
WorldSystem.logger().log(Level.SEVERE,"Wasn't able to create Config");
e.printStackTrace();
}
}

View File

@ -175,7 +175,7 @@ public class SettingsConfig {
InputStream in = JavaPlugin.getPlugin(WorldSystem.class).getResource("settings.yml");
Files.copy(in, file.toPath());
} catch (IOException e) {
System.err.println("Wasn't able to create Config");
WorldSystem.logger().log(Level.SEVERE,"Wasn't able to create Config");
e.printStackTrace();
}
}

View File

@ -90,7 +90,7 @@ public class WorldConfig {
file.createNewFile();
} catch (IOException e1) {
e1.printStackTrace();
System.err.println("Error while creating worldconfig for " + uuid.toString());
WorldSystem.logger().log(Level.SEVERE,"Error while creating worldconfig for " + uuid.toString());
}
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
cfg.set("Informations.ID", dc.getID());
@ -104,7 +104,7 @@ public class WorldConfig {
cfg.save(file);
} catch (IOException e) {
e.printStackTrace();
System.err.println("Error while saving worldconfig for " + uuid.toString());
WorldSystem.logger().log(Level.SEVERE,"Error while saving worldconfig for " + uuid.toString());
}
}

View File

@ -39,8 +39,8 @@ public class VersionUtil {
else if (v.contains("1.3")) version = 3;
}
if (version == 0) {
System.err.println("[WorldSystem] Unknown version: " + Bukkit.getVersion());
System.err.println("[WorldSystem] Choosing version 1.12.2");
WorldSystem.logger().log(Level.SEVERE,"[WorldSystem] Unknown version: " + Bukkit.getVersion());
WorldSystem.logger().log(Level.SEVERE,"[WorldSystem] Choosing version 1.12.2");
version = 12;
}
return version;

View File

@ -14,7 +14,7 @@ public abstract class DatabaseConnection implements DatabaseUtil {
synchronized (lock) {
try {
if (connection == null || connection.isClosed()) {
System.err.println("[WorldSystem | DB] Connection does not exist or was already closed");
WorldSystem.logger().log(Level.SEVERE,"[WorldSystem | DB] Connection does not exist or was already closed");
return;
}
connection.close();

View File

@ -119,7 +119,7 @@ public class SystemWorld {
try {
FileUtils.copyDirectory(exampleworld, newworld);
} catch (IOException e) {
System.err.println("Couldn't create world for " + uuid);
WorldSystem.logger().log(Level.SEVERE,"Couldn't create world for " + uuid);
e.printStackTrace();
}
else
@ -145,7 +145,7 @@ public class SystemWorld {
} catch (IOException e) {
if (p != null && p.isOnline())
p.sendMessage(PluginConfig.getPrefix() + "§cError: " + e.getMessage());
System.err.println("Couldn't load world of " + uuid);
WorldSystem.logger().log(Level.SEVERE,"Couldn't load world of " + uuid);
e.printStackTrace();
return false;
}
@ -311,7 +311,7 @@ public class SystemWorld {
// Check for duplicated worlds
File propablyExistingWorld = new File(Bukkit.getWorldContainer(), worldname);
if (propablyExistingWorld.exists()) {
System.err.println("World " + worldname + " existed twice!");
WorldSystem.logger().log(Level.SEVERE,"World " + worldname + " existed twice!");
try {
FileUtils.deleteDirectory(propablyExistingWorld);
} catch (IOException e) {
@ -324,7 +324,7 @@ public class SystemWorld {
try {
FileUtils.moveDirectoryToDirectory(world, Bukkit.getWorldContainer(), false);
} catch (IOException e) {
System.err.println("Couldn't load world of " + p.getName());
WorldSystem.logger().log(Level.SEVERE,"Couldn't load world of " + p.getName());
p.sendMessage(PluginConfig.getPrefix() + "§cError: " + e.getMessage());
e.printStackTrace();
}