Some slf4j progress

This commit is contained in:
Alexander Söderberg 2020-06-26 11:03:42 +02:00
parent efab6e92f7
commit 4b997d42df
No known key found for this signature in database
GPG Key ID: C0207FF7EA146678
15 changed files with 129 additions and 106 deletions

View File

@ -37,6 +37,7 @@ dependencies {
implementation("net.alpenblock:BungeePerms:4.0-dev-106")
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false }
compile("org.slf4j:slf4j-jdk14:2.0.0-alpha1")
}
sourceCompatibility = 1.8
@ -95,6 +96,7 @@ shadowJar {
include(dependency("org.bstats:bstats-bukkit:1.7"))
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
include(dependency("org.slf4j:slf4j-jdk14:2.0.0-alpha1"))
}
relocate('net.kyori.text', 'com.plotsquared.formatting.text')
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")

View File

@ -18,6 +18,7 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
implementation("org.jetbrains:annotations:19.0.0")
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
implementation("org.slf4j:slf4j-api:2.0.0-alpha1")
}
sourceCompatibility = 1.8

View File

@ -165,7 +165,7 @@ public class PlotSquared {
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
private YamlConfiguration config;
// Implementation logger
@Setter @Getter private ILogger logger;
@Deprecated @Setter @Getter private ILogger logger;
// Platform / Version / Update URL
private PlotVersion version;
// Files and configuration
@ -398,8 +398,9 @@ public class PlotSquared {
*
* @param message Message to log
* @see IPlotMain#log(String)
* @deprecated Use slf4j
*/
public static void log(Object message) {
@Deprecated public static void log(Object message) {
if (message == null || (message instanceof Caption ?
((Caption) message).getTranslated().isEmpty() :
message.toString().isEmpty())) {
@ -417,8 +418,9 @@ public class PlotSquared {
*
* @param message Message to log
* @see IPlotMain#log(String)
* @deprecated Use sl4j
*/
public static void debug(@Nullable Object message) {
@Deprecated public static void debug(@Nullable Object message) {
if (Settings.DEBUG) {
if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) {
System.out.printf("[P2][Debug] %s\n", StringMan.getString(message));

View File

@ -25,10 +25,11 @@
*/
package com.plotsquared.core.configuration;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings.Enabled_Components;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.util.StringMan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.PrintWriter;
@ -46,6 +47,8 @@ import java.util.Map;
public class Config {
private static final Logger logger = LoggerFactory.getLogger(Config.class);
/**
* Get the value for a node<br>
* Probably throws some error if you try to get a non existent key
@ -68,7 +71,7 @@ public class Config {
}
}
}
PlotSquared.debug("Failed to get config option: " + key);
logger.debug("Failed to get config option: {}", key);
return null;
}
@ -95,15 +98,13 @@ public class Config {
}
field.set(instance, value);
return;
} catch (Throwable e) {
PlotSquared.debug(
"Invalid configuration value: " + key + ": " + value + " in " + root
.getSimpleName());
e.printStackTrace();
} catch (final Throwable e) {
logger.atDebug().addArgument(key).addArgument(value).addArgument(root.getSimpleName())
.setCause(e).log("Invalid configuration value '{}: {}' in {}");
}
}
}
PlotSquared.debug("Failed to set config option: " + key + ": " + value + " | " + instance);
logger.debug("Failed to set config option '{}: {}' | {}", key, value, instance);
}
public static boolean load(File file, Class<? extends Config> root) {
@ -289,9 +290,8 @@ public class Config {
setAccessible(field);
return field;
} catch (Throwable e) {
PlotSquared.debug(
"Invalid config field: " + StringMan.join(split, ".") + " for " + toNodeName(
instance.getClass().getSimpleName()));
logger.atDebug().addArgument(StringMan.join(split, ".")).setCause(e)
.addArgument(toNodeName(instance.getClass().getSimpleName())).log("Invalid config field: {} for {}");
return null;
}
}

View File

@ -25,8 +25,6 @@
*/
package com.plotsquared.core.listener;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.util.WEManager;
import com.plotsquared.core.util.WorldUtil;
@ -44,6 +42,8 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
import java.util.HashMap;
@ -52,6 +52,8 @@ import java.util.Set;
public class ProcessedWEExtent extends AbstractDelegateExtent {
private static final Logger logger = LoggerFactory.getLogger(ProcessedWEExtent.class);
private final Set<CuboidRegion> mask;
private final String world;
private final int max;
@ -101,8 +103,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
return false;
} else {
tileEntityCount[0]++;
PlotSquared.debug(Captions.PREFIX + "&cDetected unsafe WorldEdit: " + location.getX() + ","
+ location.getZ());
logger.debug("Detected unsafe WorldEdit: {},{},{}", location.getX(), location.getY(), location.getZ());
}
}
if (WEManager.maskContains(this.mask, location.getX(), location.getY(), location.getZ())) {
@ -133,9 +134,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
this.Ecount++;
if (this.Ecount > Settings.Chunk_Processor.MAX_ENTITIES) {
this.Eblocked = true;
PlotSquared.debug(
Captions.PREFIX + "&cDetected unsafe WorldEdit: " + location.getBlockX() + ","
+ location.getBlockZ());
logger.debug("Detected unsafe WorldEdit: {},{},{}", location.getX(), location.getY(), location.getZ());
}
if (WEManager.maskContains(this.mask, location.getBlockX(), location.getBlockY(),
location.getBlockZ())) {

View File

@ -54,6 +54,8 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.item.ItemType;
import lombok.NonNull;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.util.Collection;
@ -73,6 +75,8 @@ import java.util.stream.Collectors;
*/
public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer {
private static final Logger logger = LoggerFactory.getLogger(PlotPlayer.class);
public static final String META_LAST_PLOT = "lastplot";
public static final String META_LOCATION = "location";
@ -580,9 +584,8 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
if (Settings.Enabled_Components.BAN_DELETER && isBanned()) {
for (Plot owned : getPlots()) {
owned.deletePlot(null);
PlotSquared.debug(String
.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned",
plot.getId(), getName()));
logger.debug("Plot {} was deleted + cleared due to {} getting banned",
owned.getId(), getName());
}
}
if (ExpireManager.IMP != null) {

View File

@ -73,6 +73,8 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.geom.Area;
import java.awt.geom.PathIterator;
@ -117,6 +119,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
*/
public class Plot {
private static final Logger logger = LoggerFactory.getLogger(Plot.class);
public static final int MAX_HEIGHT = 256;
private static Set<Plot> connected_cache;
@ -1731,9 +1735,8 @@ public class Plot {
public boolean claim(@NotNull final PlotPlayer player, boolean teleport, String schematic) {
if (!canClaim(player)) {
PlotSquared.debug(Captions.PREFIX.getTranslated() + String
.format("Player %s attempted to claim plot %s, but was not allowed",
player.getName(), this.getId().toCommaSeparatedString()));
logger.atDebug().addArgument(player.getName()).addArgument(this.getId().toCommaSeparatedString())
.log("Player {} attempted to claim plot {}, but was not allowed");
return false;
}
return claim(player, teleport, schematic, true);
@ -1744,9 +1747,8 @@ public class Plot {
if (updateDB) {
if (!create(player.getUUID(), true)) {
PlotSquared.debug(Captions.PREFIX.getTranslated() + String.format(
"Player %s attempted to claim plot %s, but the database failed to update",
player.getName(), this.getId().toCommaSeparatedString()));
logger.debug("Player {} attempted to claim plot {}, but the database failed to update",
player.getName(), this.getId().toCommaSeparatedString());
return false;
}
} else {
@ -1833,9 +1835,8 @@ public class Plot {
});
return true;
}
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String
.format("Failed to add plot %s to plot area %s", this.getId().toCommaSeparatedString(),
this.area.toString()));
logger.atInfo().addArgument(this.getId().toCommaSeparatedString())
.addArgument(this.area.toString()).log("Failed to add plot {} to plot area {}");
return false;
}
@ -1933,12 +1934,12 @@ public class Plot {
*/
public boolean moveData(Plot plot, Runnable whenDone) {
if (!this.hasOwner()) {
PlotSquared.debug(plot + " is unowned (single)");
logger.atDebug().addArgument(plot).log("{} is unowned (single)");
TaskManager.runTask(whenDone);
return false;
}
if (plot.hasOwner()) {
PlotSquared.debug(plot + " is unowned (multi)");
logger.atDebug().addArgument(plot).log("{} is unowned (multi)");
TaskManager.runTask(whenDone);
return false;
}
@ -2646,7 +2647,7 @@ public class Plot {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH));
if (!tmp.getMerged(Direction.SOUTH)) {
// invalid merge
PlotSquared.debug("Fixing invalid merge: " + this);
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.SOUTH, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
@ -2663,7 +2664,7 @@ public class Plot {
assert tmp != null;
if (!tmp.getMerged(Direction.WEST)) {
// invalid merge
PlotSquared.debug("Fixing invalid merge: " + this);
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.WEST, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
@ -2680,7 +2681,7 @@ public class Plot {
assert tmp != null;
if (!tmp.getMerged(Direction.NORTH)) {
// invalid merge
PlotSquared.debug("Fixing invalid merge: " + this);
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.NORTH, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
@ -2696,7 +2697,7 @@ public class Plot {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.WEST));
if (!tmp.getMerged(Direction.EAST)) {
// invalid merge
PlotSquared.debug("Fixing invalid merge: " + this);
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.EAST, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
@ -2713,8 +2714,8 @@ public class Plot {
if (!current.hasOwner() || current.settings == null) {
// Invalid plot
// merged onto unclaimed plot
PlotSquared.debug(
"Ignoring invalid merged plot: " + current + " | " + current.getOwnerAbs());
logger.atDebug().addArgument(current).addArgument(current.getOwnerAbs())
.log("Ignoring invalid merged plot: {} | {}");
continue;
}
tmpSet.add(current);

View File

@ -66,6 +66,8 @@ import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
@ -85,6 +87,8 @@ import java.util.function.Consumer;
*/
public abstract class PlotArea {
private static final Logger logger = LoggerFactory.getLogger(PlotArea.class);
protected final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
@Getter @NotNull private final String worldName;
@Getter private final String id;
@ -366,7 +370,6 @@ public abstract class PlotArea {
}
}
PlotSquared.log(Captions.PREFIX + "&3 - default flags: &7" + flagBuilder.toString());
this.spawnEggs = config.getBoolean("event.spawn.egg");
this.spawnCustom = config.getBoolean("event.spawn.custom");
this.spawnBreeding = config.getBoolean("event.spawn.breeding");
@ -1060,10 +1063,13 @@ public abstract class PlotArea {
try {
flags.add(flagInstance.parse(split[1]));
} catch (final FlagParseException e) {
PlotSquared.log(Captions.PREFIX.getTranslated() + String.format(
"§cFailed to parse default flag with key §6'%s'§c and value: §6'%s'§c."
+ " Reason: %s. This flag will not be added as a default flag.",
e.getFlag().getName(), e.getValue(), e.getErrorMessage()));
logger.atWarn()
.addArgument(e.getFlag().getName())
.addArgument(e.getValue())
.addArgument(e.getErrorMessage())
.setCause(e)
.log("Failed to parse default flag with key '{}' and value '{}'. "
+ "Reason: {}. This flag will not be added as a default flag.");
}
}
}

View File

@ -33,6 +33,8 @@ import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Array;
import java.util.ArrayDeque;
@ -43,6 +45,9 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class PlotAnalysis {
private static final Logger logger = LoggerFactory.getLogger(PlotAnalysis.class);
public static boolean running = false;
public int changes;
public int faces;
@ -91,22 +96,20 @@ public class PlotAnalysis {
*/
public static void calcOptimalModifiers(final Runnable whenDone, final double threshold) {
if (running) {
PlotSquared.debug("Calibration task already in progress!");
logger.debug("Calibration task already in progress!");
return;
}
if (threshold <= 0 || threshold >= 1) {
PlotSquared.debug(
"Invalid threshold provided! (Cannot be 0 or 100 as then there's no point calibrating)");
logger.debug("Invalid threshold provided! (Cannot be 0 or 100 as then there's no point in calibrating)");
return;
}
running = true;
PlotSquared.debug(" - Fetching all plots");
logger.debug("- Fetching all plots");
final ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
Iterator<Plot> iterator = plots.iterator();
PlotSquared.debug(
" - $1Reducing " + plots.size() + " plots to those with sufficient data");
logger.debug("- Reducing {} plots to those with sufficient data", plots.size());
while (iterator.hasNext()) {
Plot plot = iterator.next();
if (plot.getSettings().getRatings() == null || plot.getSettings().getRatings()
@ -116,11 +119,10 @@ public class PlotAnalysis {
plot.addRunning();
}
}
PlotSquared.debug(" - | Reduced to " + plots.size() + " plots");
logger.debug("- | Reduced to {} plots", plots.size());
if (plots.size() < 3) {
PlotSquared.debug(
"Calibration cancelled due to insufficient comparison data, please try again later");
logger.debug("Calibration cancelled due to insufficient comparison data, please try again later");
running = false;
for (Plot plot : plots) {
plot.removeRunning();
@ -128,7 +130,7 @@ public class PlotAnalysis {
return;
}
PlotSquared.debug(" - $1Analyzing plot contents (this may take a while)");
logger.debug("- Analyzing plot contents (this may take a while)");
int[] changes = new int[plots.size()];
int[] faces = new int[plots.size()];
@ -154,7 +156,7 @@ public class PlotAnalysis {
ratings[i] = (int) (
(plot.getAverageRating() + plot.getSettings().getRatings().size())
* 100);
PlotSquared.debug(" | " + plot + " (rating) " + ratings[i]);
logger.debug(" | {} (rating) {}", plot, ratings[i]);
}
}
});
@ -166,7 +168,7 @@ public class PlotAnalysis {
if (queuePlot == null) {
break;
}
PlotSquared.debug(" | " + queuePlot);
logger.debug(" | {}", queuePlot);
final Object lock = new Object();
TaskManager.runTask(new Runnable() {
@Override public void run() {
@ -196,20 +198,18 @@ public class PlotAnalysis {
}
}
PlotSquared.debug(
" - $1Waiting on plot rating thread: " + mi.intValue() * 100 / plots.size()
+ "%");
logger.debug(" - Waiting on plot rating thread: {}%", mi.intValue() * 100 / plots.size());
try {
ratingAnalysis.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
PlotSquared
.debug(" - $1Processing and grouping single plot analysis for bulk processing");
logger.debug(" - Processing and grouping single plot analysis for bulk processing");
for (int i = 0; i < plots.size(); i++) {
Plot plot = plots.get(i);
PlotSquared.debug(" | " + plot);
logger.debug(" | {}", plot);
PlotAnalysis analysis = plot.getComplexity(null);
changes[i] = analysis.changes;
@ -225,18 +225,16 @@ public class PlotAnalysis {
variety_sd[i] = analysis.variety_sd;
}
PlotSquared.debug(" - $1Calculating rankings");
logger.debug(" - Calculating rankings");
int[] rankRatings = rank(ratings);
int n = rankRatings.length;
int optimalIndex = (int) Math.round((1 - threshold) * (n - 1));
PlotSquared.debug(" - $1Calculating rank correlation: ");
PlotSquared.debug(
" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking");
PlotSquared.debug(
" - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing");
logger.debug(" - Calculating rank correlation: ");
logger.debug(" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking");
logger.debug(" - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing");
Settings.Auto_Clear settings = new Settings.Auto_Clear();
@ -248,7 +246,7 @@ public class PlotAnalysis {
settings.CALIBRATION.CHANGES = factorChanges == 1 ?
0 :
(int) (factorChanges * 1000 / MathMan.getMean(changes));
PlotSquared.debug(" - | changes " + factorChanges);
logger.debug(" - | changes {}", factorChanges);
int[] rankFaces = rank(faces);
int[] sdFaces = getSD(rankFaces, rankRatings);
@ -257,7 +255,7 @@ public class PlotAnalysis {
double factorFaces = getCC(n, sumFaces);
settings.CALIBRATION.FACES =
factorFaces == 1 ? 0 : (int) (factorFaces * 1000 / MathMan.getMean(faces));
PlotSquared.debug(" - | faces " + factorFaces);
logger.debug(" - | faces {}", factorFaces);
int[] rankData = rank(data);
int[] sdData = getSD(rankData, rankRatings);
@ -266,7 +264,7 @@ public class PlotAnalysis {
double factor_data = getCC(n, sum_data);
settings.CALIBRATION.DATA =
factor_data == 1 ? 0 : (int) (factor_data * 1000 / MathMan.getMean(data));
PlotSquared.debug(" - | data " + factor_data);
logger.debug(" - | data {}", factor_data);
int[] rank_air = rank(air);
int[] sd_air = getSD(rank_air, rankRatings);
@ -275,7 +273,7 @@ public class PlotAnalysis {
double factor_air = getCC(n, sum_air);
settings.CALIBRATION.AIR =
factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(air));
PlotSquared.debug(" - | air " + factor_air);
logger.debug("- | air {}", factor_air);
int[] rank_variety = rank(variety);
int[] sd_variety = getSD(rank_variety, rankRatings);
@ -285,7 +283,7 @@ public class PlotAnalysis {
settings.CALIBRATION.VARIETY = factor_variety == 1 ?
0 :
(int) (factor_variety * 1000 / MathMan.getMean(variety));
PlotSquared.debug(" - | variety " + factor_variety);
logger.debug("- | variety {}", factor_variety);
int[] rank_changes_sd = rank(changes_sd);
int[] sd_changes_sd = getSD(rank_changes_sd, rankRatings);
@ -295,7 +293,7 @@ public class PlotAnalysis {
settings.CALIBRATION.CHANGES_SD = factor_changes_sd == 1 ?
0 :
(int) (factor_changes_sd * 1000 / MathMan.getMean(changes_sd));
PlotSquared.debug(" - | changes_sd " + factor_changes_sd);
logger.debug(" - | changed_sd {}", factor_changes_sd);
int[] rank_faces_sd = rank(faces_sd);
int[] sd_faces_sd = getSD(rank_faces_sd, rankRatings);
@ -305,7 +303,7 @@ public class PlotAnalysis {
settings.CALIBRATION.FACES_SD = factor_faces_sd == 1 ?
0 :
(int) (factor_faces_sd * 1000 / MathMan.getMean(faces_sd));
PlotSquared.debug(" - | faces_sd " + factor_faces_sd);
logger.debug(" - | faced_sd {}", factor_faces_sd);
int[] rank_data_sd = rank(data_sd);
int[] sd_data_sd = getSD(rank_data_sd, rankRatings);
@ -315,7 +313,7 @@ public class PlotAnalysis {
settings.CALIBRATION.DATA_SD = factor_data_sd == 1 ?
0 :
(int) (factor_data_sd * 1000 / MathMan.getMean(data_sd));
PlotSquared.debug(" - | data_sd " + factor_data_sd);
logger.debug(" - | data_sd {}", factor_data_sd);
int[] rank_air_sd = rank(air_sd);
int[] sd_air_sd = getSD(rank_air_sd, rankRatings);
@ -324,7 +322,7 @@ public class PlotAnalysis {
double factor_air_sd = getCC(n, sum_air_sd);
settings.CALIBRATION.AIR_SD =
factor_air_sd == 1 ? 0 : (int) (factor_air_sd * 1000 / MathMan.getMean(air_sd));
PlotSquared.debug(" - | air_sd " + factor_air_sd);
logger.debug(" - | air_sd {}", factor_air_sd);
int[] rank_variety_sd = rank(variety_sd);
int[] sd_variety_sd = getSD(rank_variety_sd, rankRatings);
@ -334,11 +332,11 @@ public class PlotAnalysis {
settings.CALIBRATION.VARIETY_SD = factor_variety_sd == 1 ?
0 :
(int) (factor_variety_sd * 1000 / MathMan.getMean(variety_sd));
PlotSquared.debug(" - | variety_sd " + factor_variety_sd);
logger.debug(" - | variety_sd {}", factor_variety_sd);
int[] complexity = new int[n];
PlotSquared.debug(" $1Calculating threshold");
logger.debug(" Calculating threshold");
int max = 0;
int min = 0;
for (int i = 0; i < n; i++) {
@ -367,9 +365,7 @@ public class PlotAnalysis {
logln("Correlation: ");
logln(getCC(n, sum(square(getSD(rankComplexity, rankRatings)))));
if (optimalComplexity == Integer.MAX_VALUE) {
PlotSquared.debug(
"Insufficient data to determine correlation! " + optimalIndex + " | "
+ n);
logger.debug("Insufficient data to determine correlation! {} | {}", optimalIndex, n);
running = false;
for (Plot plot : plots) {
plot.removeRunning();
@ -387,10 +383,10 @@ public class PlotAnalysis {
}
// Save calibration
PlotSquared.debug(" $1Saving calibration");
logger.debug(" Saving calibration");
Settings.AUTO_CLEAR.put("auto-calibrated", settings);
Settings.save(PlotSquared.get().worldsFile);
PlotSquared.debug("$1Done!");
logger.debug("Done!");
running = false;
for (Plot plot : plots) {
plot.removeRunning();
@ -401,7 +397,7 @@ public class PlotAnalysis {
}
public static void logln(Object obj) {
PlotSquared.debug(log(obj));
logger.debug(log(obj));
}
public static String log(Object obj) {

View File

@ -27,11 +27,12 @@ package com.plotsquared.core.plot.flag;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.plotsquared.core.PlotSquared;
import lombok.EqualsAndHashCode;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
@ -44,6 +45,8 @@ import java.util.Map;
*/
@EqualsAndHashCode(of = "flagMap") public class FlagContainer {
private static final Logger logger = LoggerFactory.getLogger(FlagContainer.class);
private final Map<String, String> unknownFlags = new HashMap<>();
private final Map<Class<?>, PlotFlag<?, ?>> flagMap = new HashMap<>();
private final PlotFlagUpdateHandler plotFlagUpdateHandler;
@ -145,11 +148,9 @@ import java.util.Map;
this.updateSubscribers
.forEach(subscriber -> subscriber.handle(flag, plotFlagUpdateType));
} catch (IllegalStateException e) {
PlotSquared.log(String.format(
"Flag '%s' (class: '%s') could not be added to the container"
+ " because the flag name exceeded the allowed limit of 64 characters."
+ " Please tell the developer of that flag to fix this.", flag.getName(),
flag.getClass().getName()));
logger.info("Flag {} (class '{}') could not be added to the container because the "
+ "flag name exceeded the allowed limit of 64 characters. Please tell the developer "
+ "of the flag to fix this.", flag.getName(), flag.getClass().getName());
e.printStackTrace();
}
}

View File

@ -27,13 +27,14 @@ package com.plotsquared.core.plot.flag.types;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.plotsquared.core.PlotSquared;
import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
@ -44,6 +45,8 @@ import java.util.Map;
*/
public class BlockTypeWrapper {
private static final Logger logger = LoggerFactory.getLogger(BlockTypeWrapper.class);
private static final Map<BlockType, BlockTypeWrapper> blockTypes = new HashMap<>();
private static final Map<String, BlockTypeWrapper> blockCategories = new HashMap<>();
@Nullable @Getter private final BlockType blockType;
@ -129,7 +132,7 @@ public class BlockTypeWrapper {
&& this.blockCategoryId != null) { // only if name is available
this.blockCategory = BlockCategory.REGISTRY.get(this.blockCategoryId);
if (this.blockCategory == null && !BlockCategory.REGISTRY.values().isEmpty()) {
PlotSquared.debug("- Block category #" + this.blockCategoryId + " does not exist");
logger.debug("- Block category #{} does not exist", this.blockCategoryId);
this.blockCategory = new NullBlockCategory(this.blockCategoryId);
}
}

View File

@ -29,18 +29,20 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.ChatManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PlotMessage {
private static final Logger logger = LoggerFactory.getLogger(PlotMessage.class);
private Object builder;
public PlotMessage() {
try {
reset(ChatManager.manager);
} catch (Throwable e) {
PlotSquared.debug(
PlotSquared.imp().getPluginName() + " doesn't support fancy chat for " + PlotSquared
.get().IMP.getServerVersion());
logger.error("{} doesn't support fancy chat for {}", PlotSquared.imp().getPluginName(), PlotSquared.get().IMP.getServerVersion());
ChatManager.manager = new PlainChatManager();
reset(ChatManager.manager);
}

View File

@ -25,17 +25,20 @@
*/
package com.plotsquared.core.queue;
import com.plotsquared.core.PlotSquared;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQueue {
private static final Logger logger = LoggerFactory.getLogger(LocationOffsetDelegateLocalBlockQueue.class);
private final boolean[][] canPlace;
private final int blockX;
private final int blockZ;
@ -61,10 +64,9 @@ public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQue
return super.setBlock(x, y, z, id);
}
} catch (final Exception e) {
PlotSquared.debug(String.format(
"Failed to set block at: %d;%d;%d (to = %s) with offset %d;%d."
+ " Translated to: %d;%d", x, y, z, id, blockX, blockZ, x - blockX,
z - blockZ));
logger.debug("Failed set block at {},{},{} (to = {}) with offset {};{}. Translated to: {}, {}",
x, y, z, id, blockX, blockZ, x - blockX,
z - blockZ);
throw e;
}
return false;

View File

@ -28,10 +28,15 @@ package com.plotsquared.core.util;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.command.DebugExec;
import com.plotsquared.core.command.MainCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.script.ScriptException;
public abstract class Expression<T> {
private static final Logger logger = LoggerFactory.getLogger(Expression.class);
public static <U> Expression<U> constant(final U value) {
return new Expression<U>() {
@Override public U evaluate(U arg) {
@ -66,7 +71,7 @@ public abstract class Expression<T> {
try {
return (Double) exec.getEngine().eval(expression.replace("{arg}", "" + arg));
} catch (ScriptException e) {
PlotSquared.debug("Invalid Expression: " + expression);
logger.debug("Invalid expression: {}", expression);
e.printStackTrace();
}
return 0d;

View File

@ -25,6 +25,6 @@
*/
package com.plotsquared.core.util.logger;
public interface ILogger {
void log(String message);
@Deprecated public interface ILogger {
@Deprecated void log(String message);
}