mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Some slf4j progress
This commit is contained in:
parent
efab6e92f7
commit
4b997d42df
@ -37,6 +37,7 @@ dependencies {
|
|||||||
implementation("net.alpenblock:BungeePerms:4.0-dev-106")
|
implementation("net.alpenblock:BungeePerms:4.0-dev-106")
|
||||||
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
|
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
|
||||||
compile('com.sk89q:squirrelid:1.0.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
|
sourceCompatibility = 1.8
|
||||||
@ -95,6 +96,7 @@ shadowJar {
|
|||||||
include(dependency("org.bstats:bstats-bukkit:1.7"))
|
include(dependency("org.bstats:bstats-bukkit:1.7"))
|
||||||
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
|
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
|
||||||
include(dependency("com.sk89q:squirrelid:1.0.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('net.kyori.text', 'com.plotsquared.formatting.text')
|
||||||
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
|
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
|
||||||
|
@ -18,6 +18,7 @@ dependencies {
|
|||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
|
||||||
implementation("org.jetbrains:annotations:19.0.0")
|
implementation("org.jetbrains:annotations:19.0.0")
|
||||||
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
|
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
|
||||||
|
implementation("org.slf4j:slf4j-api:2.0.0-alpha1")
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
|
@ -165,7 +165,7 @@ public class PlotSquared {
|
|||||||
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
||||||
private YamlConfiguration config;
|
private YamlConfiguration config;
|
||||||
// Implementation logger
|
// Implementation logger
|
||||||
@Setter @Getter private ILogger logger;
|
@Deprecated @Setter @Getter private ILogger logger;
|
||||||
// Platform / Version / Update URL
|
// Platform / Version / Update URL
|
||||||
private PlotVersion version;
|
private PlotVersion version;
|
||||||
// Files and configuration
|
// Files and configuration
|
||||||
@ -398,8 +398,9 @@ public class PlotSquared {
|
|||||||
*
|
*
|
||||||
* @param message Message to log
|
* @param message Message to log
|
||||||
* @see IPlotMain#log(String)
|
* @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 ?
|
if (message == null || (message instanceof Caption ?
|
||||||
((Caption) message).getTranslated().isEmpty() :
|
((Caption) message).getTranslated().isEmpty() :
|
||||||
message.toString().isEmpty())) {
|
message.toString().isEmpty())) {
|
||||||
@ -417,8 +418,9 @@ public class PlotSquared {
|
|||||||
*
|
*
|
||||||
* @param message Message to log
|
* @param message Message to log
|
||||||
* @see IPlotMain#log(String)
|
* @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 (Settings.DEBUG) {
|
||||||
if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) {
|
if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) {
|
||||||
System.out.printf("[P2][Debug] %s\n", StringMan.getString(message));
|
System.out.printf("[P2][Debug] %s\n", StringMan.getString(message));
|
||||||
|
@ -25,10 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration;
|
package com.plotsquared.core.configuration;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Settings.Enabled_Components;
|
import com.plotsquared.core.configuration.Settings.Enabled_Components;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
@ -46,6 +47,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(Config.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value for a node<br>
|
* Get the value for a node<br>
|
||||||
* Probably throws some error if you try to get a non existent key
|
* 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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,15 +98,13 @@ public class Config {
|
|||||||
}
|
}
|
||||||
field.set(instance, value);
|
field.set(instance, value);
|
||||||
return;
|
return;
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
PlotSquared.debug(
|
logger.atDebug().addArgument(key).addArgument(value).addArgument(root.getSimpleName())
|
||||||
"Invalid configuration value: " + key + ": " + value + " in " + root
|
.setCause(e).log("Invalid configuration value '{}: {}' in {}");
|
||||||
.getSimpleName());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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) {
|
public static boolean load(File file, Class<? extends Config> root) {
|
||||||
@ -289,9 +290,8 @@ public class Config {
|
|||||||
setAccessible(field);
|
setAccessible(field);
|
||||||
return field;
|
return field;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
PlotSquared.debug(
|
logger.atDebug().addArgument(StringMan.join(split, ".")).setCause(e)
|
||||||
"Invalid config field: " + StringMan.join(split, ".") + " for " + toNodeName(
|
.addArgument(toNodeName(instance.getClass().getSimpleName())).log("Invalid config field: {} for {}");
|
||||||
instance.getClass().getSimpleName()));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.listener;
|
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.configuration.Settings;
|
||||||
import com.plotsquared.core.util.WEManager;
|
import com.plotsquared.core.util.WEManager;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
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.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -52,6 +52,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ProcessedWEExtent.class);
|
||||||
|
|
||||||
private final Set<CuboidRegion> mask;
|
private final Set<CuboidRegion> mask;
|
||||||
private final String world;
|
private final String world;
|
||||||
private final int max;
|
private final int max;
|
||||||
@ -101,8 +103,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
tileEntityCount[0]++;
|
tileEntityCount[0]++;
|
||||||
PlotSquared.debug(Captions.PREFIX + "&cDetected unsafe WorldEdit: " + location.getX() + ","
|
logger.debug("Detected unsafe WorldEdit: {},{},{}", location.getX(), location.getY(), location.getZ());
|
||||||
+ location.getZ());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (WEManager.maskContains(this.mask, 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++;
|
this.Ecount++;
|
||||||
if (this.Ecount > Settings.Chunk_Processor.MAX_ENTITIES) {
|
if (this.Ecount > Settings.Chunk_Processor.MAX_ENTITIES) {
|
||||||
this.Eblocked = true;
|
this.Eblocked = true;
|
||||||
PlotSquared.debug(
|
logger.debug("Detected unsafe WorldEdit: {},{},{}", location.getX(), location.getY(), location.getZ());
|
||||||
Captions.PREFIX + "&cDetected unsafe WorldEdit: " + location.getBlockX() + ","
|
|
||||||
+ location.getBlockZ());
|
|
||||||
}
|
}
|
||||||
if (WEManager.maskContains(this.mask, location.getBlockX(), location.getBlockY(),
|
if (WEManager.maskContains(this.mask, location.getBlockX(), location.getBlockY(),
|
||||||
location.getBlockZ())) {
|
location.getBlockZ())) {
|
||||||
|
@ -54,6 +54,8 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
|
|||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -73,6 +75,8 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer {
|
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_LAST_PLOT = "lastplot";
|
||||||
public static final String META_LOCATION = "location";
|
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()) {
|
if (Settings.Enabled_Components.BAN_DELETER && isBanned()) {
|
||||||
for (Plot owned : getPlots()) {
|
for (Plot owned : getPlots()) {
|
||||||
owned.deletePlot(null);
|
owned.deletePlot(null);
|
||||||
PlotSquared.debug(String
|
logger.debug("Plot {} was deleted + cleared due to {} getting banned",
|
||||||
.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned",
|
owned.getId(), getName());
|
||||||
plot.getId(), getName()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ExpireManager.IMP != null) {
|
if (ExpireManager.IMP != null) {
|
||||||
|
@ -73,6 +73,8 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.PathIterator;
|
import java.awt.geom.PathIterator;
|
||||||
@ -117,6 +119,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
*/
|
*/
|
||||||
public class Plot {
|
public class Plot {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(Plot.class);
|
||||||
|
|
||||||
public static final int MAX_HEIGHT = 256;
|
public static final int MAX_HEIGHT = 256;
|
||||||
|
|
||||||
private static Set<Plot> connected_cache;
|
private static Set<Plot> connected_cache;
|
||||||
@ -1731,9 +1735,8 @@ public class Plot {
|
|||||||
|
|
||||||
public boolean claim(@NotNull final PlotPlayer player, boolean teleport, String schematic) {
|
public boolean claim(@NotNull final PlotPlayer player, boolean teleport, String schematic) {
|
||||||
if (!canClaim(player)) {
|
if (!canClaim(player)) {
|
||||||
PlotSquared.debug(Captions.PREFIX.getTranslated() + String
|
logger.atDebug().addArgument(player.getName()).addArgument(this.getId().toCommaSeparatedString())
|
||||||
.format("Player %s attempted to claim plot %s, but was not allowed",
|
.log("Player {} attempted to claim plot {}, but was not allowed");
|
||||||
player.getName(), this.getId().toCommaSeparatedString()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return claim(player, teleport, schematic, true);
|
return claim(player, teleport, schematic, true);
|
||||||
@ -1744,9 +1747,8 @@ public class Plot {
|
|||||||
|
|
||||||
if (updateDB) {
|
if (updateDB) {
|
||||||
if (!create(player.getUUID(), true)) {
|
if (!create(player.getUUID(), true)) {
|
||||||
PlotSquared.debug(Captions.PREFIX.getTranslated() + String.format(
|
logger.debug("Player {} attempted to claim plot {}, but the database failed to update",
|
||||||
"Player %s attempted to claim plot %s, but the database failed to update",
|
player.getName(), this.getId().toCommaSeparatedString());
|
||||||
player.getName(), this.getId().toCommaSeparatedString()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1833,9 +1835,8 @@ public class Plot {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String
|
logger.atInfo().addArgument(this.getId().toCommaSeparatedString())
|
||||||
.format("Failed to add plot %s to plot area %s", this.getId().toCommaSeparatedString(),
|
.addArgument(this.area.toString()).log("Failed to add plot {} to plot area {}");
|
||||||
this.area.toString()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1933,12 +1934,12 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public boolean moveData(Plot plot, Runnable whenDone) {
|
public boolean moveData(Plot plot, Runnable whenDone) {
|
||||||
if (!this.hasOwner()) {
|
if (!this.hasOwner()) {
|
||||||
PlotSquared.debug(plot + " is unowned (single)");
|
logger.atDebug().addArgument(plot).log("{} is unowned (single)");
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
PlotSquared.debug(plot + " is unowned (multi)");
|
logger.atDebug().addArgument(plot).log("{} is unowned (multi)");
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2646,7 +2647,7 @@ public class Plot {
|
|||||||
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH));
|
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH));
|
||||||
if (!tmp.getMerged(Direction.SOUTH)) {
|
if (!tmp.getMerged(Direction.SOUTH)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
|
||||||
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
||||||
tmp.getSettings().setMerged(Direction.SOUTH, true);
|
tmp.getSettings().setMerged(Direction.SOUTH, true);
|
||||||
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
||||||
@ -2663,7 +2664,7 @@ public class Plot {
|
|||||||
assert tmp != null;
|
assert tmp != null;
|
||||||
if (!tmp.getMerged(Direction.WEST)) {
|
if (!tmp.getMerged(Direction.WEST)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
|
||||||
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
||||||
tmp.getSettings().setMerged(Direction.WEST, true);
|
tmp.getSettings().setMerged(Direction.WEST, true);
|
||||||
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
||||||
@ -2680,7 +2681,7 @@ public class Plot {
|
|||||||
assert tmp != null;
|
assert tmp != null;
|
||||||
if (!tmp.getMerged(Direction.NORTH)) {
|
if (!tmp.getMerged(Direction.NORTH)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
|
||||||
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
||||||
tmp.getSettings().setMerged(Direction.NORTH, true);
|
tmp.getSettings().setMerged(Direction.NORTH, true);
|
||||||
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
||||||
@ -2696,7 +2697,7 @@ public class Plot {
|
|||||||
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.WEST));
|
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.WEST));
|
||||||
if (!tmp.getMerged(Direction.EAST)) {
|
if (!tmp.getMerged(Direction.EAST)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
logger.atDebug().addArgument(this).log("Fixing invalid merge: {}");
|
||||||
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
||||||
tmp.getSettings().setMerged(Direction.EAST, true);
|
tmp.getSettings().setMerged(Direction.EAST, true);
|
||||||
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
||||||
@ -2713,8 +2714,8 @@ public class Plot {
|
|||||||
if (!current.hasOwner() || current.settings == null) {
|
if (!current.hasOwner() || current.settings == null) {
|
||||||
// Invalid plot
|
// Invalid plot
|
||||||
// merged onto unclaimed plot
|
// merged onto unclaimed plot
|
||||||
PlotSquared.debug(
|
logger.atDebug().addArgument(current).addArgument(current.getOwnerAbs())
|
||||||
"Ignoring invalid merged plot: " + current + " | " + current.getOwnerAbs());
|
.log("Ignoring invalid merged plot: {} | {}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tmpSet.add(current);
|
tmpSet.add(current);
|
||||||
|
@ -66,6 +66,8 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -85,6 +87,8 @@ import java.util.function.Consumer;
|
|||||||
*/
|
*/
|
||||||
public abstract class PlotArea {
|
public abstract class PlotArea {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PlotArea.class);
|
||||||
|
|
||||||
protected final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
|
protected final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
|
||||||
@Getter @NotNull private final String worldName;
|
@Getter @NotNull private final String worldName;
|
||||||
@Getter private final String id;
|
@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.spawnEggs = config.getBoolean("event.spawn.egg");
|
||||||
this.spawnCustom = config.getBoolean("event.spawn.custom");
|
this.spawnCustom = config.getBoolean("event.spawn.custom");
|
||||||
this.spawnBreeding = config.getBoolean("event.spawn.breeding");
|
this.spawnBreeding = config.getBoolean("event.spawn.breeding");
|
||||||
@ -1060,10 +1063,13 @@ public abstract class PlotArea {
|
|||||||
try {
|
try {
|
||||||
flags.add(flagInstance.parse(split[1]));
|
flags.add(flagInstance.parse(split[1]));
|
||||||
} catch (final FlagParseException e) {
|
} catch (final FlagParseException e) {
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + String.format(
|
logger.atWarn()
|
||||||
"§cFailed to parse default flag with key §6'%s'§c and value: §6'%s'§c."
|
.addArgument(e.getFlag().getName())
|
||||||
+ " Reason: %s. This flag will not be added as a default flag.",
|
.addArgument(e.getValue())
|
||||||
e.getFlag().getName(), e.getValue(), e.getErrorMessage()));
|
.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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
|||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
@ -43,6 +45,9 @@ import java.util.List;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class PlotAnalysis {
|
public class PlotAnalysis {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PlotAnalysis.class);
|
||||||
|
|
||||||
public static boolean running = false;
|
public static boolean running = false;
|
||||||
public int changes;
|
public int changes;
|
||||||
public int faces;
|
public int faces;
|
||||||
@ -91,22 +96,20 @@ public class PlotAnalysis {
|
|||||||
*/
|
*/
|
||||||
public static void calcOptimalModifiers(final Runnable whenDone, final double threshold) {
|
public static void calcOptimalModifiers(final Runnable whenDone, final double threshold) {
|
||||||
if (running) {
|
if (running) {
|
||||||
PlotSquared.debug("Calibration task already in progress!");
|
logger.debug("Calibration task already in progress!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (threshold <= 0 || threshold >= 1) {
|
if (threshold <= 0 || threshold >= 1) {
|
||||||
PlotSquared.debug(
|
logger.debug("Invalid threshold provided! (Cannot be 0 or 100 as then there's no point in calibrating)");
|
||||||
"Invalid threshold provided! (Cannot be 0 or 100 as then there's no point calibrating)");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
running = true;
|
running = true;
|
||||||
PlotSquared.debug(" - Fetching all plots");
|
logger.debug("- Fetching all plots");
|
||||||
final ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
|
final ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
Iterator<Plot> iterator = plots.iterator();
|
Iterator<Plot> iterator = plots.iterator();
|
||||||
PlotSquared.debug(
|
logger.debug("- Reducing {} plots to those with sufficient data", plots.size());
|
||||||
" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Plot plot = iterator.next();
|
Plot plot = iterator.next();
|
||||||
if (plot.getSettings().getRatings() == null || plot.getSettings().getRatings()
|
if (plot.getSettings().getRatings() == null || plot.getSettings().getRatings()
|
||||||
@ -116,11 +119,10 @@ public class PlotAnalysis {
|
|||||||
plot.addRunning();
|
plot.addRunning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.debug(" - | Reduced to " + plots.size() + " plots");
|
logger.debug("- | Reduced to {} plots", plots.size());
|
||||||
|
|
||||||
if (plots.size() < 3) {
|
if (plots.size() < 3) {
|
||||||
PlotSquared.debug(
|
logger.debug("Calibration cancelled due to insufficient comparison data, please try again later");
|
||||||
"Calibration cancelled due to insufficient comparison data, please try again later");
|
|
||||||
running = false;
|
running = false;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
@ -128,7 +130,7 @@ public class PlotAnalysis {
|
|||||||
return;
|
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[] changes = new int[plots.size()];
|
||||||
int[] faces = new int[plots.size()];
|
int[] faces = new int[plots.size()];
|
||||||
@ -154,7 +156,7 @@ public class PlotAnalysis {
|
|||||||
ratings[i] = (int) (
|
ratings[i] = (int) (
|
||||||
(plot.getAverageRating() + plot.getSettings().getRatings().size())
|
(plot.getAverageRating() + plot.getSettings().getRatings().size())
|
||||||
* 100);
|
* 100);
|
||||||
PlotSquared.debug(" | " + plot + " (rating) " + ratings[i]);
|
logger.debug(" | {} (rating) {}", plot, ratings[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -166,7 +168,7 @@ public class PlotAnalysis {
|
|||||||
if (queuePlot == null) {
|
if (queuePlot == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PlotSquared.debug(" | " + queuePlot);
|
logger.debug(" | {}", queuePlot);
|
||||||
final Object lock = new Object();
|
final Object lock = new Object();
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTask(new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
@ -196,20 +198,18 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.debug(
|
logger.debug(" - Waiting on plot rating thread: {}%", mi.intValue() * 100 / plots.size());
|
||||||
" - $1Waiting on plot rating thread: " + mi.intValue() * 100 / plots.size()
|
|
||||||
+ "%");
|
|
||||||
try {
|
try {
|
||||||
ratingAnalysis.join();
|
ratingAnalysis.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared
|
logger.debug(" - Processing and grouping single plot analysis for bulk processing");
|
||||||
.debug(" - $1Processing and grouping single plot analysis for bulk processing");
|
|
||||||
for (int i = 0; i < plots.size(); i++) {
|
for (int i = 0; i < plots.size(); i++) {
|
||||||
Plot plot = plots.get(i);
|
Plot plot = plots.get(i);
|
||||||
PlotSquared.debug(" | " + plot);
|
logger.debug(" | {}", plot);
|
||||||
PlotAnalysis analysis = plot.getComplexity(null);
|
PlotAnalysis analysis = plot.getComplexity(null);
|
||||||
|
|
||||||
changes[i] = analysis.changes;
|
changes[i] = analysis.changes;
|
||||||
@ -225,18 +225,16 @@ public class PlotAnalysis {
|
|||||||
variety_sd[i] = analysis.variety_sd;
|
variety_sd[i] = analysis.variety_sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.debug(" - $1Calculating rankings");
|
logger.debug(" - Calculating rankings");
|
||||||
|
|
||||||
int[] rankRatings = rank(ratings);
|
int[] rankRatings = rank(ratings);
|
||||||
int n = rankRatings.length;
|
int n = rankRatings.length;
|
||||||
|
|
||||||
int optimalIndex = (int) Math.round((1 - threshold) * (n - 1));
|
int optimalIndex = (int) Math.round((1 - threshold) * (n - 1));
|
||||||
|
|
||||||
PlotSquared.debug(" - $1Calculating rank correlation: ");
|
logger.debug(" - Calculating rank correlation: ");
|
||||||
PlotSquared.debug(
|
logger.debug(" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking");
|
||||||
" - 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");
|
||||||
PlotSquared.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();
|
Settings.Auto_Clear settings = new Settings.Auto_Clear();
|
||||||
|
|
||||||
@ -248,7 +246,7 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.CHANGES = factorChanges == 1 ?
|
settings.CALIBRATION.CHANGES = factorChanges == 1 ?
|
||||||
0 :
|
0 :
|
||||||
(int) (factorChanges * 1000 / MathMan.getMean(changes));
|
(int) (factorChanges * 1000 / MathMan.getMean(changes));
|
||||||
PlotSquared.debug(" - | changes " + factorChanges);
|
logger.debug(" - | changes {}", factorChanges);
|
||||||
|
|
||||||
int[] rankFaces = rank(faces);
|
int[] rankFaces = rank(faces);
|
||||||
int[] sdFaces = getSD(rankFaces, rankRatings);
|
int[] sdFaces = getSD(rankFaces, rankRatings);
|
||||||
@ -257,7 +255,7 @@ public class PlotAnalysis {
|
|||||||
double factorFaces = getCC(n, sumFaces);
|
double factorFaces = getCC(n, sumFaces);
|
||||||
settings.CALIBRATION.FACES =
|
settings.CALIBRATION.FACES =
|
||||||
factorFaces == 1 ? 0 : (int) (factorFaces * 1000 / MathMan.getMean(faces));
|
factorFaces == 1 ? 0 : (int) (factorFaces * 1000 / MathMan.getMean(faces));
|
||||||
PlotSquared.debug(" - | faces " + factorFaces);
|
logger.debug(" - | faces {}", factorFaces);
|
||||||
|
|
||||||
int[] rankData = rank(data);
|
int[] rankData = rank(data);
|
||||||
int[] sdData = getSD(rankData, rankRatings);
|
int[] sdData = getSD(rankData, rankRatings);
|
||||||
@ -266,7 +264,7 @@ public class PlotAnalysis {
|
|||||||
double factor_data = getCC(n, sum_data);
|
double factor_data = getCC(n, sum_data);
|
||||||
settings.CALIBRATION.DATA =
|
settings.CALIBRATION.DATA =
|
||||||
factor_data == 1 ? 0 : (int) (factor_data * 1000 / MathMan.getMean(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[] rank_air = rank(air);
|
||||||
int[] sd_air = getSD(rank_air, rankRatings);
|
int[] sd_air = getSD(rank_air, rankRatings);
|
||||||
@ -275,7 +273,7 @@ public class PlotAnalysis {
|
|||||||
double factor_air = getCC(n, sum_air);
|
double factor_air = getCC(n, sum_air);
|
||||||
settings.CALIBRATION.AIR =
|
settings.CALIBRATION.AIR =
|
||||||
factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(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[] rank_variety = rank(variety);
|
||||||
int[] sd_variety = getSD(rank_variety, rankRatings);
|
int[] sd_variety = getSD(rank_variety, rankRatings);
|
||||||
@ -285,7 +283,7 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.VARIETY = factor_variety == 1 ?
|
settings.CALIBRATION.VARIETY = factor_variety == 1 ?
|
||||||
0 :
|
0 :
|
||||||
(int) (factor_variety * 1000 / MathMan.getMean(variety));
|
(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[] rank_changes_sd = rank(changes_sd);
|
||||||
int[] sd_changes_sd = getSD(rank_changes_sd, rankRatings);
|
int[] sd_changes_sd = getSD(rank_changes_sd, rankRatings);
|
||||||
@ -295,7 +293,7 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.CHANGES_SD = factor_changes_sd == 1 ?
|
settings.CALIBRATION.CHANGES_SD = factor_changes_sd == 1 ?
|
||||||
0 :
|
0 :
|
||||||
(int) (factor_changes_sd * 1000 / MathMan.getMean(changes_sd));
|
(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[] rank_faces_sd = rank(faces_sd);
|
||||||
int[] sd_faces_sd = getSD(rank_faces_sd, rankRatings);
|
int[] sd_faces_sd = getSD(rank_faces_sd, rankRatings);
|
||||||
@ -305,7 +303,7 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.FACES_SD = factor_faces_sd == 1 ?
|
settings.CALIBRATION.FACES_SD = factor_faces_sd == 1 ?
|
||||||
0 :
|
0 :
|
||||||
(int) (factor_faces_sd * 1000 / MathMan.getMean(faces_sd));
|
(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[] rank_data_sd = rank(data_sd);
|
||||||
int[] sd_data_sd = getSD(rank_data_sd, rankRatings);
|
int[] sd_data_sd = getSD(rank_data_sd, rankRatings);
|
||||||
@ -315,7 +313,7 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.DATA_SD = factor_data_sd == 1 ?
|
settings.CALIBRATION.DATA_SD = factor_data_sd == 1 ?
|
||||||
0 :
|
0 :
|
||||||
(int) (factor_data_sd * 1000 / MathMan.getMean(data_sd));
|
(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[] rank_air_sd = rank(air_sd);
|
||||||
int[] sd_air_sd = getSD(rank_air_sd, rankRatings);
|
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);
|
double factor_air_sd = getCC(n, sum_air_sd);
|
||||||
settings.CALIBRATION.AIR_SD =
|
settings.CALIBRATION.AIR_SD =
|
||||||
factor_air_sd == 1 ? 0 : (int) (factor_air_sd * 1000 / MathMan.getMean(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[] rank_variety_sd = rank(variety_sd);
|
||||||
int[] sd_variety_sd = getSD(rank_variety_sd, rankRatings);
|
int[] sd_variety_sd = getSD(rank_variety_sd, rankRatings);
|
||||||
@ -334,11 +332,11 @@ public class PlotAnalysis {
|
|||||||
settings.CALIBRATION.VARIETY_SD = factor_variety_sd == 1 ?
|
settings.CALIBRATION.VARIETY_SD = factor_variety_sd == 1 ?
|
||||||
0 :
|
0 :
|
||||||
(int) (factor_variety_sd * 1000 / MathMan.getMean(variety_sd));
|
(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];
|
int[] complexity = new int[n];
|
||||||
|
|
||||||
PlotSquared.debug(" $1Calculating threshold");
|
logger.debug(" Calculating threshold");
|
||||||
int max = 0;
|
int max = 0;
|
||||||
int min = 0;
|
int min = 0;
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
@ -367,9 +365,7 @@ public class PlotAnalysis {
|
|||||||
logln("Correlation: ");
|
logln("Correlation: ");
|
||||||
logln(getCC(n, sum(square(getSD(rankComplexity, rankRatings)))));
|
logln(getCC(n, sum(square(getSD(rankComplexity, rankRatings)))));
|
||||||
if (optimalComplexity == Integer.MAX_VALUE) {
|
if (optimalComplexity == Integer.MAX_VALUE) {
|
||||||
PlotSquared.debug(
|
logger.debug("Insufficient data to determine correlation! {} | {}", optimalIndex, n);
|
||||||
"Insufficient data to determine correlation! " + optimalIndex + " | "
|
|
||||||
+ n);
|
|
||||||
running = false;
|
running = false;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
@ -387,10 +383,10 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save calibration
|
// Save calibration
|
||||||
PlotSquared.debug(" $1Saving calibration");
|
logger.debug(" Saving calibration");
|
||||||
Settings.AUTO_CLEAR.put("auto-calibrated", settings);
|
Settings.AUTO_CLEAR.put("auto-calibrated", settings);
|
||||||
Settings.save(PlotSquared.get().worldsFile);
|
Settings.save(PlotSquared.get().worldsFile);
|
||||||
PlotSquared.debug("$1Done!");
|
logger.debug("Done!");
|
||||||
running = false;
|
running = false;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
@ -401,7 +397,7 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void logln(Object obj) {
|
public static void logln(Object obj) {
|
||||||
PlotSquared.debug(log(obj));
|
logger.debug(log(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String log(Object obj) {
|
public static String log(Object obj) {
|
||||||
|
@ -27,11 +27,12 @@ package com.plotsquared.core.plot.flag;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -44,6 +45,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(of = "flagMap") public class FlagContainer {
|
@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<String, String> unknownFlags = new HashMap<>();
|
||||||
private final Map<Class<?>, PlotFlag<?, ?>> flagMap = new HashMap<>();
|
private final Map<Class<?>, PlotFlag<?, ?>> flagMap = new HashMap<>();
|
||||||
private final PlotFlagUpdateHandler plotFlagUpdateHandler;
|
private final PlotFlagUpdateHandler plotFlagUpdateHandler;
|
||||||
@ -145,11 +148,9 @@ import java.util.Map;
|
|||||||
this.updateSubscribers
|
this.updateSubscribers
|
||||||
.forEach(subscriber -> subscriber.handle(flag, plotFlagUpdateType));
|
.forEach(subscriber -> subscriber.handle(flag, plotFlagUpdateType));
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
PlotSquared.log(String.format(
|
logger.info("Flag {} (class '{}') could not be added to the container because the "
|
||||||
"Flag '%s' (class: '%s') could not be added to the container"
|
+ "flag name exceeded the allowed limit of 64 characters. Please tell the developer "
|
||||||
+ " because the flag name exceeded the allowed limit of 64 characters."
|
+ "of the flag to fix this.", flag.getName(), flag.getClass().getName());
|
||||||
+ " Please tell the developer of that flag to fix this.", flag.getName(),
|
|
||||||
flag.getClass().getName()));
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,13 +27,14 @@ package com.plotsquared.core.plot.flag.types;
|
|||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -44,6 +45,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class BlockTypeWrapper {
|
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<BlockType, BlockTypeWrapper> blockTypes = new HashMap<>();
|
||||||
private static final Map<String, BlockTypeWrapper> blockCategories = new HashMap<>();
|
private static final Map<String, BlockTypeWrapper> blockCategories = new HashMap<>();
|
||||||
@Nullable @Getter private final BlockType blockType;
|
@Nullable @Getter private final BlockType blockType;
|
||||||
@ -129,7 +132,7 @@ public class BlockTypeWrapper {
|
|||||||
&& this.blockCategoryId != null) { // only if name is available
|
&& this.blockCategoryId != null) { // only if name is available
|
||||||
this.blockCategory = BlockCategory.REGISTRY.get(this.blockCategoryId);
|
this.blockCategory = BlockCategory.REGISTRY.get(this.blockCategoryId);
|
||||||
if (this.blockCategory == null && !BlockCategory.REGISTRY.values().isEmpty()) {
|
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);
|
this.blockCategory = new NullBlockCategory(this.blockCategoryId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,18 +29,20 @@ import com.plotsquared.core.PlotSquared;
|
|||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.util.ChatManager;
|
import com.plotsquared.core.util.ChatManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class PlotMessage {
|
public class PlotMessage {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PlotMessage.class);
|
||||||
|
|
||||||
private Object builder;
|
private Object builder;
|
||||||
|
|
||||||
public PlotMessage() {
|
public PlotMessage() {
|
||||||
try {
|
try {
|
||||||
reset(ChatManager.manager);
|
reset(ChatManager.manager);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
PlotSquared.debug(
|
logger.error("{} doesn't support fancy chat for {}", PlotSquared.imp().getPluginName(), PlotSquared.get().IMP.getServerVersion());
|
||||||
PlotSquared.imp().getPluginName() + " doesn't support fancy chat for " + PlotSquared
|
|
||||||
.get().IMP.getServerVersion());
|
|
||||||
ChatManager.manager = new PlainChatManager();
|
ChatManager.manager = new PlainChatManager();
|
||||||
reset(ChatManager.manager);
|
reset(ChatManager.manager);
|
||||||
}
|
}
|
||||||
|
@ -25,17 +25,20 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.queue;
|
package com.plotsquared.core.queue;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQueue {
|
public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQueue {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(LocationOffsetDelegateLocalBlockQueue.class);
|
||||||
|
|
||||||
private final boolean[][] canPlace;
|
private final boolean[][] canPlace;
|
||||||
private final int blockX;
|
private final int blockX;
|
||||||
private final int blockZ;
|
private final int blockZ;
|
||||||
@ -61,10 +64,9 @@ public class LocationOffsetDelegateLocalBlockQueue extends DelegateLocalBlockQue
|
|||||||
return super.setBlock(x, y, z, id);
|
return super.setBlock(x, y, z, id);
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.debug(String.format(
|
logger.debug("Failed set block at {},{},{} (to = {}) with offset {};{}. Translated to: {}, {}",
|
||||||
"Failed to set block at: %d;%d;%d (to = %s) with offset %d;%d."
|
x, y, z, id, blockX, blockZ, x - blockX,
|
||||||
+ " Translated to: %d;%d", x, y, z, id, blockX, blockZ, x - blockX,
|
z - blockZ);
|
||||||
z - blockZ));
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -28,10 +28,15 @@ package com.plotsquared.core.util;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.command.DebugExec;
|
import com.plotsquared.core.command.DebugExec;
|
||||||
import com.plotsquared.core.command.MainCommand;
|
import com.plotsquared.core.command.MainCommand;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
public abstract class Expression<T> {
|
public abstract class Expression<T> {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(Expression.class);
|
||||||
|
|
||||||
public static <U> Expression<U> constant(final U value) {
|
public static <U> Expression<U> constant(final U value) {
|
||||||
return new Expression<U>() {
|
return new Expression<U>() {
|
||||||
@Override public U evaluate(U arg) {
|
@Override public U evaluate(U arg) {
|
||||||
@ -66,7 +71,7 @@ public abstract class Expression<T> {
|
|||||||
try {
|
try {
|
||||||
return (Double) exec.getEngine().eval(expression.replace("{arg}", "" + arg));
|
return (Double) exec.getEngine().eval(expression.replace("{arg}", "" + arg));
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
PlotSquared.debug("Invalid Expression: " + expression);
|
logger.debug("Invalid expression: {}", expression);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0d;
|
return 0d;
|
||||||
|
@ -25,6 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util.logger;
|
package com.plotsquared.core.util.logger;
|
||||||
|
|
||||||
public interface ILogger {
|
@Deprecated public interface ILogger {
|
||||||
void log(String message);
|
@Deprecated void log(String message);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user