diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java index f0ef20fba..9320fa39e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/entity/ReplicatingEntityWrapper.java @@ -25,7 +25,6 @@ */ package com.plotsquared.bukkit.entity; -import com.plotsquared.core.PlotSquared; import org.bukkit.Art; import org.bukkit.DyeColor; import org.bukkit.Location; @@ -55,11 +54,15 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.List; public final class ReplicatingEntityWrapper extends EntityWrapper { + private static final Logger logger = LoggerFactory.getLogger(ReplicatingEntityWrapper.class); + private final short depth; private final int hash; private final EntityBaseStats base = new EntityBaseStats(); @@ -331,7 +334,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { return; // END LIVING // default: - PlotSquared.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); + logger.debug("Could not identify entity: {}", entity.getType()); } } @@ -387,7 +390,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { try { entity.getInventory().setContents(this.inventory); } catch (IllegalArgumentException e) { - PlotSquared.debug("&c[WARN] Failed to restore inventory.\n Reason: " + e.getMessage()); + logger.error("Failed to restore inventory", e); } } @@ -730,7 +733,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { restoreLiving((LivingEntity) entity); return entity; default: - PlotSquared.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType()); + logger.debug("Could not identify entity: {}", entity.getType()); return entity; // END LIVING } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java index 1cfc897d4..feab438f6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ChunkListener.java @@ -51,6 +51,8 @@ import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.lang.reflect.Method; import java.util.HashSet; @@ -60,6 +62,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass; @SuppressWarnings("unused") public class ChunkListener implements Listener { + private static final Logger logger = LoggerFactory.getLogger(ChunkListener.class); + private RefMethod methodGetHandleChunk; private RefField mustSave; private Chunk lastChunk; @@ -73,9 +77,6 @@ public class ChunkListener implements Listener { this.mustSave = classChunk.getField("mustSave"); this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); } catch (Throwable ignored) { - PlotSquared.debug(PlotSquared.get().IMP.getPluginName() - + "/Server not compatible for chunk processor trim/gc"); - Settings.Chunk_Processor.AUTO_TRIM = false; } } @@ -251,7 +252,6 @@ public class ChunkListener implements Listener { if (!chunk.isLoaded()) { Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); - PlotSquared.debug("Successfully processed and unloaded chunk!"); chunk.unload(true); return; } @@ -259,7 +259,6 @@ public class ChunkListener implements Listener { if (tiles.length == 0) { Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); - PlotSquared.debug("Successfully processed and unloaded chunk!"); chunk.unload(true); return; } @@ -269,7 +268,6 @@ public class ChunkListener implements Listener { if (i >= tiles.length - Settings.Chunk_Processor.MAX_TILES) { Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex)); TaskManager.tasks.remove(currentIndex); - PlotSquared.debug("Successfully processed and unloaded chunk!"); chunk.unload(true); return; } @@ -297,15 +295,11 @@ public class ChunkListener implements Listener { } } - PlotSquared.debug( - "PlotSquared detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + ( - chunk.getX() << 4)); + logger.debug("PlotSquared detected chunk and processed it: {},{}", chunk.getX() << 4, chunk.getZ() << 4); } if (tiles.length > Settings.Chunk_Processor.MAX_TILES) { if (unload) { - PlotSquared.debug( - "PlotSquared detected unsafe chunk: " + (chunk.getX() << 4) + "," + ( - chunk.getX() << 4)); + logger.debug("PlotSquared detected chunk: {},{}", chunk.getX() << 4, chunk.getZ() << 4); cleanChunk(chunk); return true; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index 643f80611..2c0cc77bc 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -987,7 +987,8 @@ public class PlayerEvents extends PlotListener implements Listener { player.sendMessage(spyMessage); } } - PlotSquared.debug(full); + // TODO: Re-implement + // PlotSquared.debug(full); } @EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) { @@ -2435,7 +2436,6 @@ public class PlayerEvents extends PlotListener implements Listener { } Player p = event.getPlayer(); if (p == null) { - PlotSquared.debug("PlotSquared does not support HangingPlaceEvent for non-players."); event.setCancelled(true); return; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitLocalQueue.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitLocalQueue.java index c8d6d929f..b5197ce23 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitLocalQueue.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitLocalQueue.java @@ -27,11 +27,9 @@ package com.plotsquared.bukkit.queue; import com.plotsquared.bukkit.schematic.StateWrapper; import com.plotsquared.bukkit.util.BukkitBlockUtil; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.queue.BasicLocalBlockQueue; import com.plotsquared.core.util.BlockUtil; import com.plotsquared.core.util.MainUtil; -import com.plotsquared.core.util.task.TaskManager; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.WorldEdit; @@ -85,8 +83,6 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue { World worldObj = Bukkit.getWorld(getWorld()); if (worldObj != null) { worldObj.refreshChunk(x, z); - } else { - PlotSquared.debug("Error Refreshing Chunk"); } } @@ -109,8 +105,6 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue { world.regenerate(region, editSession); } } - } else { - PlotSquared.debug("Error Regenerating Chunk"); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java index 158f90928..f54cedccf 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java @@ -26,7 +26,6 @@ package com.plotsquared.bukkit.util; import com.plotsquared.bukkit.BukkitMain; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.generator.AugmentedUtils; import com.plotsquared.core.location.Location; import com.plotsquared.core.location.PlotLoc; @@ -55,6 +54,8 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayDeque; import java.util.ArrayList; @@ -75,6 +76,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE; public class BukkitRegionManager extends RegionManager { + private static final Logger logger = LoggerFactory.getLogger(BukkitRegionManager.class); + public static boolean isIn(CuboidRegion region, int x, int z) { return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX() && z >= region.getMinimumPoint().getZ() && z <= region.getMaximumPoint().getZ(); @@ -90,7 +93,7 @@ public class BukkitRegionManager extends RegionManager { } else { final Semaphore semaphore = new Semaphore(1); try { - PlotSquared.debug("Attempting to make an asynchronous call to getLoadedChunks." + logger.debug("Attempting to make an asynchronous call to getLoadedChunks." + " Will halt the calling thread until completed."); semaphore.acquire(); Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () -> { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index a9dcd4a66..373dac19a 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -468,7 +468,6 @@ public class BukkitUtil extends WorldUtil { block.setType(Material.valueOf("OAK_WALL_SIGN"), false); } if (!(block.getBlockData() instanceof WallSign)) { - PlotSquared.debug(block.getBlockData().getAsString()); throw new RuntimeException("Something went wrong generating a sign"); } final Directional sign = (Directional) block.getBlockData(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java index 08381ee22..3563b125b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/ContentMap.java @@ -27,7 +27,6 @@ package com.plotsquared.bukkit.util; import com.plotsquared.bukkit.entity.EntityWrapper; import com.plotsquared.bukkit.entity.ReplicatingEntityWrapper; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.location.Location; import com.plotsquared.core.location.PlotLoc; import com.sk89q.worldedit.bukkit.BukkitWorld; @@ -38,6 +37,8 @@ import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.HashMap; import java.util.HashSet; @@ -46,6 +47,8 @@ import java.util.Set; public class ContentMap { + private static final Logger logger = LoggerFactory.getLogger(ContentMap.class); + final Set entities; final Map allBlocks; @@ -123,8 +126,7 @@ public class ContentMap { try { entity.spawn(world, xOffset, zOffset); } catch (Exception e) { - PlotSquared.debug("Failed to restore entity (e): " + e.toString()); - e.printStackTrace(); + logger.error("Failed to restore entity", e); } } this.entities.clear(); diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index d6ccfd81d..f8f38e963 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -383,35 +383,6 @@ public class PlotSquared { throw new IllegalStateException("Plot main implementation is missing"); } - /** - * Log a message to the IPlotMain logger. - * - * @param message Message to log - * @see IPlotMain#log(String) - * @deprecated Use slf4j - */ - @Deprecated public static void log(Object message) { - if (message == null || (message instanceof Caption ? - ((Caption) message).getTranslated().isEmpty() : - message.toString().isEmpty())) { - return; - } - logger.info(StringMan.getString(message)); - } - - /** - * Log a message to the IPlotMain logger. - * - * @param message Message to log - * @see IPlotMain#log(String) - * @deprecated Use sl4j - */ - @Deprecated public static void debug(@Nullable Object message) { - if (Settings.DEBUG) { - logger.debug(StringMan.getString(message)); - } - } - private void startExpiryTasks() { if (Settings.Enabled_Components.PLOT_EXPIRY) { ExpireManager.IMP = new ExpireManager(); @@ -540,8 +511,8 @@ public class PlotSquared { chunkInts.forEach(l -> chunks.add(BlockVector2.at(l[0], l[1]))); int height = (int) list.get(2); logger.info("Incomplete road regeneration found. Restarting in world {} with height {}", plotArea.getWorldName(), height); - PlotSquared.debug(" Regions: " + regions.size()); - PlotSquared.debug(" Chunks: " + chunks.size()); + logger.debug(" Regions: {}", regions.size()); + logger.debug(" Chunks: {}", chunks.size()); HybridUtils.UPDATE = true; HybridUtils.manager.scheduleRoadUpdate(plotArea, regions, height, chunks); } catch (IOException | ClassNotFoundException e) { @@ -1108,7 +1079,7 @@ public class PlotSquared { } if (type == PlotAreaType.NORMAL) { if (plotAreaManager.getPlotAreas(world, null).length != 0) { - debug("World possibly already loaded: " + world); + logger.debug("Would possibly already loaded: {}", world); return; } IndependentPlotGenerator plotGenerator; diff --git a/Core/src/main/java/com/plotsquared/core/api/PlotAPI.java b/Core/src/main/java/com/plotsquared/core/api/PlotAPI.java index 3991643a3..9dc992c29 100644 --- a/Core/src/main/java/com/plotsquared/core/api/PlotAPI.java +++ b/Core/src/main/java/com/plotsquared/core/api/PlotAPI.java @@ -167,7 +167,8 @@ import java.util.UUID; * @see MainUtil#sendConsoleMessage(Captions, String...) */ public void sendConsoleMessage(String message) { - PlotSquared.log(message); + // TODO: Re-implement + // PlotSquared.log(message); } /** diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java index 488b2dc84..02990a107 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -44,6 +44,8 @@ import com.plotsquared.core.util.Expression; import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.TaskManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @CommandDeclaration(command = "claim", aliases = "c", @@ -54,6 +56,8 @@ import com.plotsquared.core.util.task.TaskManager; usage = "/plot claim") public class Claim extends SubCommand { + private static final Logger logger = LoggerFactory.getLogger(Claim.class); + @Override public boolean onCommand(final PlotPlayer player, String[] args) { String schematic = null; if (args.length >= 1) { @@ -133,7 +137,7 @@ public class Claim extends SubCommand { DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal() { @Override public void run(Object value) { if (!plot.claim(player, true, finalSchematic, false)) { - PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String + logger.info(Captions.PREFIX.getTranslated() + String .format("Failed to claim plot %s", plot.getId().toCommaSeparatedString())); sendMessage(player, Captions.PLOT_NOT_CLAIMED); plot.setOwnerAbs(null); @@ -148,7 +152,7 @@ public class Claim extends SubCommand { } } }), () -> { - PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String + logger.info(Captions.PREFIX.getTranslated() + String .format("Failed to add plot %s to the database", plot.getId().toCommaSeparatedString())); sendMessage(player, Captions.PLOT_NOT_CLAIMED); diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java index 53d6b00a5..91b9fbf91 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -452,7 +452,6 @@ public class DebugExec extends SubCommand { } init(); this.scope.put("PlotPlayer", player); - PlotSquared.debug("> " + script); try { if (async) { final String toExec = script; diff --git a/Core/src/main/java/com/plotsquared/core/command/Purge.java b/Core/src/main/java/com/plotsquared/core/command/Purge.java index 4e63ad8a1..8c155fff5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Purge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Purge.java @@ -175,7 +175,6 @@ public class Purge extends SubCommand { boolean finalClear = clear; Runnable run = () -> { logger.debug("Calculating plots to purge, please wait..."); - PlotSquared.debug("Calculating plots to purge, please wait..."); HashSet ids = new HashSet<>(); Iterator iterator = toDelete.iterator(); AtomicBoolean cleared = new AtomicBoolean(true); diff --git a/Core/src/main/java/com/plotsquared/core/command/Trim.java b/Core/src/main/java/com/plotsquared/core/command/Trim.java index 0702c7c08..d90277602 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Trim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Trim.java @@ -111,7 +111,6 @@ public class Trim extends SubCommand { BlockVector2 loc = BlockVector2.at(x, z); empty.add(loc); } catch (NumberFormatException ignored) { - PlotSquared.debug("INVALID MCA: " + name); } } }); diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Caption.java b/Core/src/main/java/com/plotsquared/core/configuration/Caption.java index bb9cf098f..081bc774a 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Caption.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Caption.java @@ -25,7 +25,6 @@ */ package com.plotsquared.core.configuration; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.util.StringMan; @@ -44,7 +43,8 @@ public interface Caption { default boolean send(PlotPlayer caller, Object... args) { String msg = CaptionUtility.format(caller, this, args); if (caller == null) { - PlotSquared.log(msg); + // TODO: Replace with adventure + System.out.println(msg); } else { caller.sendMessage(msg); } diff --git a/Core/src/main/java/com/plotsquared/core/configuration/file/YamlConfiguration.java b/Core/src/main/java/com/plotsquared/core/configuration/file/YamlConfiguration.java index f57cc56f8..ee1dec7d5 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/file/YamlConfiguration.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/file/YamlConfiguration.java @@ -29,6 +29,8 @@ import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Configuration; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.InvalidConfigurationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; @@ -45,6 +47,9 @@ import java.util.Map; * Note that this implementation is not synchronized. */ public class YamlConfiguration extends FileConfiguration { + + private static final Logger logger = LoggerFactory.getLogger(YamlConfiguration.class); + private static final String COMMENT_PREFIX = "# "; private static final String BLANK_CONFIG = "{}\n"; private final DumperOptions yamlOptions = new DumperOptions(); @@ -76,11 +81,11 @@ public class YamlConfiguration extends FileConfiguration { dest = new File(file.getAbsolutePath() + "_broken_" + i++); } Files.copy(file.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); - PlotSquared.debug("&dCould not read: &7" + file); - PlotSquared.debug("&dRenamed to: &7" + dest.getName()); - PlotSquared.debug("&c============ Full stacktrace ============"); + logger.debug("Could not read: {}", file); + logger.debug("Renamed to: {}", file); + logger.debug("============ Full stacktrace ============"); ex.printStackTrace(); - PlotSquared.debug("&c========================================="); + logger.debug("========================================="); } catch (IOException e) { e.printStackTrace(); } diff --git a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java index bab4ea1a5..a58eec7f9 100644 --- a/Core/src/main/java/com/plotsquared/core/database/SQLManager.java +++ b/Core/src/main/java/com/plotsquared/core/database/SQLManager.java @@ -626,9 +626,7 @@ public class SQLManager implements AbstractDB { } }))))); } catch (SQLException e) { - e.printStackTrace(); - PlotSquared - .debug("&7[WARN] Failed to set all flags and member tiers for plots"); + logger.error("Failed to set all flags and member tiers for plots", e); try { SQLManager.this.connection.commit(); } catch (SQLException e1) { @@ -2496,8 +2494,7 @@ public class SQLManager implements AbstractDB { } } } catch (SQLException e) { - PlotSquared - .debug("&7[WARN] Failed to fetch rating for plot " + plot.getId().toString()); + logger.error("Failed to fetch rating for plot {}", plot.getId().toString()); e.printStackTrace(); } return map; diff --git a/Core/src/main/java/com/plotsquared/core/database/SQLite.java b/Core/src/main/java/com/plotsquared/core/database/SQLite.java index 501033184..eb12a4672 100644 --- a/Core/src/main/java/com/plotsquared/core/database/SQLite.java +++ b/Core/src/main/java/com/plotsquared/core/database/SQLite.java @@ -26,6 +26,8 @@ package com.plotsquared.core.database; import com.plotsquared.core.PlotSquared; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -40,6 +42,8 @@ import java.sql.Statement; */ public class SQLite extends Database { + private static final Logger logger = LoggerFactory.getLogger(SQLite.class); + private final String dbLocation; private Connection connection; @@ -64,7 +68,7 @@ public class SQLite extends Database { try { file.createNewFile(); } catch (IOException ignored) { - PlotSquared.debug("&cUnable to create database!"); + logger.error("Unable to create database"); } } Class.forName("org.sqlite.JDBC"); diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java index f4e92ced6..4e1b2157d 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java @@ -26,7 +26,6 @@ package com.plotsquared.core.generator; import com.plotsquared.core.PlotSquared; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.location.Location; @@ -283,10 +282,10 @@ public class HybridPlotWorld extends ClassicPlotWorld { } } - PlotSquared.debug(Captions.PREFIX + "&3 - plot schematic: &7" + schematic3File.getPath()); + logger.debug(" - plot schematic: {}", schematic3File.getPath()); } if (schematic1 == null || schematic2 == null || this.ROAD_WIDTH == 0) { - PlotSquared.debug(Captions.PREFIX + "&3 - schematic: &7false"); + logger.debug(" - schematic: false"); return; } this.ROAD_SCHEMATIC_ENABLED = true; diff --git a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java index 9dbd2c611..531d2de92 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotManager.java @@ -25,7 +25,6 @@ */ package com.plotsquared.core.generator; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Location; import com.plotsquared.core.plot.Plot; @@ -34,8 +33,9 @@ import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.RegionManager; import com.sk89q.worldedit.regions.CuboidRegion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.util.Arrays; import java.util.Iterator; import java.util.Set; @@ -44,6 +44,8 @@ import java.util.Set; */ public abstract class SquarePlotManager extends GridPlotManager { + private static final Logger logger = LoggerFactory.getLogger(SquarePlotManager.class); + private final SquarePlotWorld squarePlotWorld; public SquarePlotManager(SquarePlotWorld squarePlotWorld) { @@ -226,11 +228,9 @@ public abstract class SquarePlotManager extends GridPlotManager { // northwest return plot.getMerged(Direction.NORTHWEST) ? id : null; } - PlotSquared.debug("invalid location: " + Arrays.toString(merged)); } catch (Exception ignored) { - PlotSquared.debug( - "Invalid plot / road width in settings.yml for world: " + squarePlotWorld - .getWorldName()); + logger.debug( "Invalid plot / road width in settings.yml for world: {}", squarePlotWorld + .getWorldName()); } return null; } diff --git a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java index 026b13ddc..a7270105e 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/SquarePlotWorld.java @@ -25,13 +25,16 @@ */ package com.plotsquared.core.generator; -import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.plot.PlotId; import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class SquarePlotWorld extends GridPlotWorld { + private static final Logger logger = LoggerFactory.getLogger(SquarePlotWorld.class); + public int PLOT_WIDTH = 42; public int ROAD_WIDTH = 7; public int ROAD_OFFSET_X = 0; @@ -44,7 +47,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld { @Override public void loadConfiguration(ConfigurationSection config) { if (!config.contains("plot.height")) { - PlotSquared.debug(" - &cConfiguration is null? (" + config.getCurrentPath() + ')'); + logger.debug(" - Configuration is null? ({})", config.getCurrentPath()); } this.PLOT_WIDTH = config.getInt("plot.size"); this.ROAD_WIDTH = config.getInt("road.width"); diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java b/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java index 88f9c100c..d52536e22 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotInventory.java @@ -29,9 +29,13 @@ import com.plotsquared.core.PlotSquared; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.util.InventoryUtil; import lombok.NonNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class PlotInventory { + private static final Logger logger = LoggerFactory.getLogger(PlotInventory.class); + private static final String META_KEY = "inventory"; public final PlotPlayer player; public final int size; @@ -79,8 +83,8 @@ public class PlotInventory { return; } if (hasPlotInventoryOpen(player)) { - PlotSquared.debug(String.format("Failed to open plot inventory for %s " - + "because the player already has an open plot inventory", player.getName())); + logger.debug("Failed to open plot inventory for {} because" + + " the player already has an open plot inventory", player.getName()); } else { this.open = true; setPlotInventoryOpen(player, this); diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java index 532134536..96499df87 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java @@ -47,6 +47,8 @@ import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.TaskManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayDeque; import java.util.ArrayList; @@ -62,6 +64,8 @@ import java.util.concurrent.ConcurrentLinkedDeque; public class ExpireManager { + private final Logger logger = LoggerFactory.getLogger(ExpireManager.class); + public static ExpireManager IMP; private final ConcurrentHashMap dates_cache; private final ConcurrentHashMap account_age_cache; @@ -79,7 +83,7 @@ public class ExpireManager { } public void addTask(ExpiryTask task) { - PlotSquared.debug("Adding new expiry task!"); + logger.debug("Adding new expiry task!"); this.tasks.add(task); } @@ -425,15 +429,13 @@ public class ExpireManager { PlotAnalysis changed = plot.getComplexity(null); int changes = changed == null ? 0 : changed.changes_sd; int modified = changed == null ? 0 : changed.changes; - PlotSquared.debug( - "$2[&5Expire&dManager$2] &cDeleted expired plot: " + plot + " User:" + plot.getOwner() - + " Delta:" + changes + "/" + modified + " Connected: " + StringMan - .getString(plots)); - PlotSquared.debug("$4 - Area: " + plot.getArea()); + logger.debug("Deleted expired plot: {} | User: {} | Delta: {}/{} | Connected: {}", + plot, plot.getOwner(), changes, modified, StringMan.getString(plots)); + logger.debug(" - Area: {}", plot.getArea()); if (plot.hasOwner()) { - PlotSquared.debug("$4 - Owner: " + plot.getOwner()); + logger.debug(" - Owner: {}", plot.getOwner()); } else { - PlotSquared.debug("$4 - Owner: Unowned"); + logger.debug(" - Owner: Unowned"); } } diff --git a/Core/src/main/java/com/plotsquared/core/util/MainUtil.java b/Core/src/main/java/com/plotsquared/core/util/MainUtil.java index dbe3599d6..11b17cc02 100644 --- a/Core/src/main/java/com/plotsquared/core/util/MainUtil.java +++ b/Core/src/main/java/com/plotsquared/core/util/MainUtil.java @@ -156,7 +156,7 @@ public class MainUtil { public static void upload(UUID uuid, String file, String extension, final RunnableVal writeTask, final RunnableVal whenDone) { if (writeTask == null) { - PlotSquared.debug("&cWrite task cannot be null"); + logger.debug("Write task cannot be null"); TaskManager.runTask(whenDone); return; } @@ -218,7 +218,6 @@ public class MainUtil { content = scanner.next().trim(); } if (!content.startsWith("<")) { - PlotSquared.debug(content); } int responseCode = ((HttpURLConnection) con).getResponseCode(); if (responseCode == 200) { @@ -899,7 +898,7 @@ public class MainUtil { if (file.isDirectory()) { deleteDirectory(file); } else { - PlotSquared.debug("Deleting file: " + file + " | " + file.delete()); + logger.debug("Deleting file: {} | {}", file, file.delete()); } } } diff --git a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java index 547741e6f..c4fee2dbe 100644 --- a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java +++ b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java @@ -61,6 +61,8 @@ import com.sk89q.worldedit.world.block.BaseBlock; import org.jetbrains.annotations.NotNull; import org.json.JSONArray; import org.json.JSONException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; @@ -93,6 +95,8 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; public abstract class SchematicHandler { + + private static final Logger logger = LoggerFactory.getLogger(SchematicHandler.class); public static SchematicHandler manager; private boolean exportAll = false; @@ -187,7 +191,6 @@ public abstract class SchematicHandler { whenDone.value = false; } if (schematic == null) { - PlotSquared.debug("Schematic == null :|"); TaskManager.runTask(whenDone); return; } @@ -203,12 +206,7 @@ public abstract class SchematicHandler { + 1) < WIDTH) || ( (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT > 256)) { - PlotSquared.debug("Schematic is too large"); - PlotSquared.debug( - "(" + WIDTH + ',' + LENGTH + ',' + HEIGHT + ") is bigger than (" + ( - region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) + ',' - + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) - + ",256)"); + logger.debug("Schematic is too large"); TaskManager.runTask(whenDone); return; } @@ -405,8 +403,6 @@ public abstract class SchematicHandler { return new Schematic(clip); } catch (IOException e) { e.printStackTrace(); - PlotSquared.debug(is.toString() + " | " + is.getClass().getCanonicalName() - + " is not in GZIP format : " + e.getMessage()); } } return null; @@ -432,14 +428,12 @@ public abstract class SchematicHandler { return schematics; } catch (JSONException | IOException e) { e.printStackTrace(); - PlotSquared.debug("ERROR PARSING: " + rawJSON); } return null; } public void upload(final CompoundTag tag, UUID uuid, String file, RunnableVal whenDone) { if (tag == null) { - PlotSquared.debug("&cCannot save empty tag"); TaskManager.runTask(whenDone); return; } @@ -464,7 +458,6 @@ public abstract class SchematicHandler { */ public boolean save(CompoundTag tag, String path) { if (tag == null) { - PlotSquared.debug("&cCannot save empty tag"); return false; } try { diff --git a/Core/src/main/java/com/plotsquared/core/util/net/IncendoPaster.java b/Core/src/main/java/com/plotsquared/core/util/net/IncendoPaster.java index 46ae63f7d..1189bc5cb 100644 --- a/Core/src/main/java/com/plotsquared/core/util/net/IncendoPaster.java +++ b/Core/src/main/java/com/plotsquared/core/util/net/IncendoPaster.java @@ -26,7 +26,8 @@ package com.plotsquared.core.util.net; import com.google.common.base.Charsets; -import com.plotsquared.core.PlotSquared; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -47,6 +48,8 @@ import java.util.Locale; @SuppressWarnings({"unused", "WeakerAccess"}) public final class IncendoPaster { + private static Logger logger = LoggerFactory.getLogger(IncendoPaster.class); + /** * Upload service URL */ @@ -158,7 +161,7 @@ public final class IncendoPaster { if (!httpURLConnection.getResponseMessage().contains("OK")) { if (httpURLConnection.getResponseCode() == 413) { final long size = content.length; - PlotSquared.debug(String.format("Paste Too Big > Size: %dMB", size / 1_000_000)); + logger.debug("Paste too big > size: {}MB", size / 1_000_000); } throw new IllegalStateException(String .format("Server returned status: %d %s", httpURLConnection.getResponseCode(),