mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Merge pull request #2868 from IntellectualSites/feature/v6/slf4j
This commit is contained in:
commit
7897d78f0d
@ -41,6 +41,8 @@ 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 }
|
||||||
|
// logging
|
||||||
|
implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1')
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
@ -99,12 +101,18 @@ 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.apache.logging.log4j:log4j-slf4j-impl'))
|
||||||
|
include(dependency('org.slf4j:slf4j-api'))
|
||||||
}
|
}
|
||||||
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")
|
||||||
relocate("org.bstats", "com.plotsquared.metrics")
|
relocate("org.bstats", "com.plotsquared.metrics")
|
||||||
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
|
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
|
||||||
relocate('org.khelekore.prtree', 'com.plotsquared.prtree')
|
relocate('org.khelekore.prtree', 'com.plotsquared.prtree')
|
||||||
|
relocate('org.apache.logging.slf4j', 'com.plotsquared.logging.apache')
|
||||||
|
relocate('org.slf4j', 'com.plotsquared.logging.slf4j')
|
||||||
|
|
||||||
|
|
||||||
archiveFileName = "${project.name}-${parent.version}.jar"
|
archiveFileName = "${project.name}-${parent.version}.jar"
|
||||||
destinationDirectory = file "../target"
|
destinationDirectory = file "../target"
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,12 @@
|
|||||||
<version>4.0-dev-106</version>
|
<version>4.0-dev-106</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-slf4j-impl</artifactId>
|
||||||
|
<version>2.8.1</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -103,7 +103,6 @@ import com.plotsquared.core.util.ReflectionUtils;
|
|||||||
import com.plotsquared.core.util.RegionManager;
|
import com.plotsquared.core.util.RegionManager;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
import com.plotsquared.core.util.StringMan;
|
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.uuid.CacheUUIDService;
|
import com.plotsquared.core.uuid.CacheUUIDService;
|
||||||
@ -135,6 +134,8 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
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.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -161,6 +162,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
|
|
||||||
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<Player> {
|
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<Player> {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitMain.class.getSimpleName());
|
||||||
|
|
||||||
private static final int BSTATS_ID = 1404;
|
private static final int BSTATS_ID = 1404;
|
||||||
@Getter private static WorldEdit worldEdit;
|
@Getter private static WorldEdit worldEdit;
|
||||||
|
|
||||||
@ -195,9 +198,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
|
||||||
PlotSquared.debug(
|
|
||||||
StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
|
||||||
return new int[] {1, 13, 0};
|
return new int[] {1, 13, 0};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,14 +229,12 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PremiumVerification.isPremium()) {
|
if (PremiumVerification.isPremium()) {
|
||||||
PlotSquared.log(
|
logger.info("[P2] PlotSquared version licensed to Spigot user {}", getUserID());
|
||||||
Captions.PREFIX + "&6PlotSquared version licensed to Spigot user " + getUserID());
|
logger.info("[P2] https://www.spigotmc.org/resources/{}", getResourceID());
|
||||||
PlotSquared
|
logger.info("[P2] Download ID: {}", getDownloadID());
|
||||||
.log(Captions.PREFIX + "&6https://www.spigotmc.org/resources/" + getResourceID());
|
logger.info("[P2] Thanks for supporting us :)");
|
||||||
PlotSquared.log(Captions.PREFIX + "&6Download ID: " + getDownloadID());
|
|
||||||
PlotSquared.log(Captions.PREFIX + "&6Thanks for supporting us :)");
|
|
||||||
} else {
|
} else {
|
||||||
PlotSquared.log(Captions.PREFIX + "&6Couldn't verify purchase :(");
|
logger.info("[P2] Couldn't verify purchase :(");
|
||||||
}
|
}
|
||||||
|
|
||||||
final UUIDPipeline impromptuPipeline = PlotSquared.get().getImpromptuUUIDPipeline();
|
final UUIDPipeline impromptuPipeline = PlotSquared.get().getImpromptuUUIDPipeline();
|
||||||
@ -256,7 +254,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
final OfflineModeUUIDService offlineModeUUIDService = new OfflineModeUUIDService();
|
final OfflineModeUUIDService offlineModeUUIDService = new OfflineModeUUIDService();
|
||||||
impromptuPipeline.registerService(offlineModeUUIDService);
|
impromptuPipeline.registerService(offlineModeUUIDService);
|
||||||
backgroundPipeline.registerService(offlineModeUUIDService);
|
backgroundPipeline.registerService(offlineModeUUIDService);
|
||||||
PlotSquared.log(Captions.PREFIX + "(UUID) Using the offline mode UUID service");
|
logger.info("[P2] (UUID) Using the offline mode UUID service");
|
||||||
}
|
}
|
||||||
|
|
||||||
final OfflinePlayerUUIDService offlinePlayerUUIDService = new OfflinePlayerUUIDService();
|
final OfflinePlayerUUIDService offlinePlayerUUIDService = new OfflinePlayerUUIDService();
|
||||||
@ -276,8 +274,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
final LuckPermsUUIDService luckPermsUUIDService;
|
final LuckPermsUUIDService luckPermsUUIDService;
|
||||||
if (Bukkit.getPluginManager().getPlugin("LuckPerms") != null) {
|
if (Bukkit.getPluginManager().getPlugin("LuckPerms") != null) {
|
||||||
luckPermsUUIDService = new LuckPermsUUIDService();
|
luckPermsUUIDService = new LuckPermsUUIDService();
|
||||||
PlotSquared
|
logger.info("[P2] (UUID) Using LuckPerms as a complementary UUID service");
|
||||||
.log(Captions.PREFIX + "(UUID) Using LuckPerms as a complementary UUID service");
|
|
||||||
} else {
|
} else {
|
||||||
luckPermsUUIDService = null;
|
luckPermsUUIDService = null;
|
||||||
}
|
}
|
||||||
@ -285,8 +282,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
final BungeePermsUUIDService bungeePermsUUIDService;
|
final BungeePermsUUIDService bungeePermsUUIDService;
|
||||||
if (Bukkit.getPluginManager().getPlugin("BungeePerms") != null) {
|
if (Bukkit.getPluginManager().getPlugin("BungeePerms") != null) {
|
||||||
bungeePermsUUIDService = new BungeePermsUUIDService();
|
bungeePermsUUIDService = new BungeePermsUUIDService();
|
||||||
PlotSquared
|
logger.info("[P2] (UUID) Using BungeePerms as a complementary UUID service");
|
||||||
.log(Captions.PREFIX + "(UUID) Using BungeePerms as a complementary UUID service");
|
|
||||||
} else {
|
} else {
|
||||||
bungeePermsUUIDService = null;
|
bungeePermsUUIDService = null;
|
||||||
}
|
}
|
||||||
@ -294,8 +290,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
final EssentialsUUIDService essentialsUUIDService;
|
final EssentialsUUIDService essentialsUUIDService;
|
||||||
if (Bukkit.getPluginManager().getPlugin("Essentials") != null) {
|
if (Bukkit.getPluginManager().getPlugin("Essentials") != null) {
|
||||||
essentialsUUIDService = new EssentialsUUIDService();
|
essentialsUUIDService = new EssentialsUUIDService();
|
||||||
PlotSquared
|
logger.info("[P2] (UUID) Using Essentials as a complementary UUID service");
|
||||||
.log(Captions.PREFIX + "(UUID) Using Essentials as a complementary UUID service");
|
|
||||||
} else {
|
} else {
|
||||||
essentialsUUIDService = null;
|
essentialsUUIDService = null;
|
||||||
}
|
}
|
||||||
@ -306,8 +301,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
final PaperUUIDService paperUUIDService = new PaperUUIDService();
|
final PaperUUIDService paperUUIDService = new PaperUUIDService();
|
||||||
impromptuPipeline.registerService(paperUUIDService);
|
impromptuPipeline.registerService(paperUUIDService);
|
||||||
backgroundPipeline.registerService(paperUUIDService);
|
backgroundPipeline.registerService(paperUUIDService);
|
||||||
PlotSquared
|
logger.info("[P2] (UUID) Using Paper as a complementary UUID service");
|
||||||
.log(Captions.PREFIX + "(UUID) Using Paper as a complementary UUID service");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impromptuPipeline.registerService(sqLiteUUIDService);
|
impromptuPipeline.registerService(sqLiteUUIDService);
|
||||||
@ -363,10 +357,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
if (Settings.Enabled_Components.EXTERNAL_PLACEHOLDERS) {
|
if (Settings.Enabled_Components.EXTERNAL_PLACEHOLDERS) {
|
||||||
ChatFormatter.formatters.add(new PlaceholderFormatter());
|
ChatFormatter.formatters.add(new PlaceholderFormatter());
|
||||||
}
|
}
|
||||||
PlotSquared.log(Captions.PREFIX + "&6PlotSquared hooked into PlaceholderAPI");
|
logger.info("[P2] PlotSquared hooked into PlaceholderAPI");
|
||||||
} else {
|
} else {
|
||||||
PlotSquared
|
logger.info("[P2] PlaceholderAPI is not in use. Hook deactivated");
|
||||||
.debug(Captions.PREFIX + "&6PlaceholderAPI is not in use. Hook deactivated.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.startMetrics();
|
this.startMetrics();
|
||||||
@ -382,9 +375,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
try {
|
try {
|
||||||
this.backupManager = new SimpleBackupManager();
|
this.backupManager = new SimpleBackupManager();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(Captions.PREFIX + "&6Failed to initialize backup manager");
|
logger.error("[P2] Failed to initialize backup manager", e);
|
||||||
e.printStackTrace();
|
logger.error("[P2] Backup features will be disabled");
|
||||||
PlotSquared.log(Captions.PREFIX + "&6Backup features will be disabled");
|
|
||||||
this.backupManager = new NullBackupManager();
|
this.backupManager = new NullBackupManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,9 +388,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
this.worldManager = new BukkitWorldManager();
|
this.worldManager = new BukkitWorldManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.log(
|
logger.info("[P2] Using platform world manager: {}", this.worldManager.getName());
|
||||||
Captions.PREFIX.getTranslated() + "Using platform world manager: " + this.worldManager
|
|
||||||
.getName());
|
|
||||||
|
|
||||||
// Clean up potential memory leak
|
// Clean up potential memory leak
|
||||||
Bukkit.getScheduler().runTaskTimer(this, () -> {
|
Bukkit.getScheduler().runTaskTimer(this, () -> {
|
||||||
@ -459,7 +449,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
final Chunk[] chunks = world.getLoadedChunks();
|
final Chunk[] chunks = world.getLoadedChunks();
|
||||||
if (chunks.length == 0) {
|
if (chunks.length == 0) {
|
||||||
if (!Bukkit.unloadWorld(world, true)) {
|
if (!Bukkit.unloadWorld(world, true)) {
|
||||||
PlotSquared.debug("Failed to unload " + world.getName());
|
logger.warn("[P2] Failed to unload {}", world.getName());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -509,8 +499,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "(UUID) " + uuidQueue.size()
|
|
||||||
+ " UUIDs will be cached.");
|
logger.info("[P2] (UUID) {} UUIDs will be cached", uuidQueue.size());
|
||||||
|
|
||||||
Executors.newSingleThreadScheduledExecutor().schedule(() -> {
|
Executors.newSingleThreadScheduledExecutor().schedule(() -> {
|
||||||
// Begin by reading all the SQLite cache at once
|
// Begin by reading all the SQLite cache at once
|
||||||
@ -518,9 +508,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
// Now fetch names for all known UUIDs
|
// Now fetch names for all known UUIDs
|
||||||
final int totalSize = uuidQueue.size();
|
final int totalSize = uuidQueue.size();
|
||||||
int read = 0;
|
int read = 0;
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated()
|
logger.info("[P2] (UUID) PlotSquared will fetch UUIDs in groups of {}", Settings.UUID.BACKGROUND_LIMIT);
|
||||||
+ "(UUID) PlotSquared will fetch UUIDs in groups of "
|
|
||||||
+ Settings.UUID.BACKGROUND_LIMIT);
|
|
||||||
final List<UUID> uuidList = new ArrayList<>(Settings.UUID.BACKGROUND_LIMIT);
|
final List<UUID> uuidList = new ArrayList<>(Settings.UUID.BACKGROUND_LIMIT);
|
||||||
|
|
||||||
// Used to indicate that the second retrieval has been attempted
|
// Used to indicate that the second retrieval has been attempted
|
||||||
@ -528,7 +516,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
|
|
||||||
while (!uuidQueue.isEmpty() || !uuidList.isEmpty()) {
|
while (!uuidQueue.isEmpty() || !uuidList.isEmpty()) {
|
||||||
if (!uuidList.isEmpty() && secondRun) {
|
if (!uuidList.isEmpty() && secondRun) {
|
||||||
PlotSquared.log("Giving up on last batch. Fetching new batch instead.");
|
logger.warn("[P2] (UUID) Giving up on last batch. Fetching new batch instead");
|
||||||
uuidList.clear();
|
uuidList.clear();
|
||||||
}
|
}
|
||||||
if (uuidList.isEmpty()) {
|
if (uuidList.isEmpty()) {
|
||||||
@ -552,15 +540,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
uuidList.clear();
|
uuidList.clear();
|
||||||
// Print progress
|
// Print progress
|
||||||
final double percentage = ((double) read / (double) totalSize) * 100.0D;
|
final double percentage = ((double) read / (double) totalSize) * 100.0D;
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + String
|
if (Settings.DEBUG) {
|
||||||
.format("(UUID) PlotSquared has cached %.1f%% of UUIDs", percentage));
|
logger.info("[P2] (UUID) PlotSquared has cached {} of UUIDs", String.format("%.1f%%", percentage));
|
||||||
|
}
|
||||||
} catch (final InterruptedException | ExecutionException e) {
|
} catch (final InterruptedException | ExecutionException e) {
|
||||||
PlotSquared.log("Failed to retrieve that batch. Will try again.");
|
logger.error("[P2] (UUID) Failed to retrieve last batch. Will try again", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared
|
logger.info("[P2] (UUID) PlotSquared has cached all UUIDs");
|
||||||
.log(Captions.PREFIX.getTranslated() + "(UUID) PlotSquared has cached all UUIDs");
|
|
||||||
}, 10, TimeUnit.SECONDS);
|
}, 10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,7 +609,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("deprecation") public void runEntityTask() {
|
@Override @SuppressWarnings("deprecation") public void runEntityTask() {
|
||||||
PlotSquared.log(Captions.PREFIX + "KillAllEntities started.");
|
logger.info("[P2] KillAllEntities started");
|
||||||
TaskManager.runTaskRepeat(() -> PlotSquared.get().forEachPlotArea(plotArea -> {
|
TaskManager.runTaskRepeat(() -> PlotSquared.get().forEachPlotArea(plotArea -> {
|
||||||
final World world = Bukkit.getWorld(plotArea.getWorldName());
|
final World world = Bukkit.getWorld(plotArea.getWorldName());
|
||||||
try {
|
try {
|
||||||
@ -927,7 +914,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
return econ;
|
return econ;
|
||||||
}
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
PlotSquared.debug("No economy detected!");
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -947,21 +933,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
return perm;
|
return perm;
|
||||||
}
|
}
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
PlotSquared.debug("No permissions detected!");
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public QueueProvider initBlockQueue() {
|
@Override public QueueProvider initBlockQueue() {
|
||||||
//TODO Figure out why this code is still here yet isn't being called anywhere.
|
|
||||||
// try {
|
|
||||||
// new SendChunk();
|
|
||||||
// MainUtil.canSendChunk = true;
|
|
||||||
// } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
|
||||||
// PlotSquared.debug(
|
|
||||||
// SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
|
|
||||||
// MainUtil.canSendChunk = false;
|
|
||||||
// }
|
|
||||||
return QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class);
|
return QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1073,8 +1049,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
|||||||
if (!PlotSquared.get().hasPlotArea(worldName)) {
|
if (!PlotSquared.get().hasPlotArea(worldName)) {
|
||||||
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
|
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log("Failed to reload world: " + world + " | " + e.getMessage());
|
logger.error("[P2] Failed to reload world: {} | {}", world, e.getMessage());
|
||||||
Bukkit.getServer().unloadWorld(world, false);
|
Bukkit.getServer().unloadWorld(world, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.entity;
|
package com.plotsquared.bukkit.entity;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -55,11 +55,15 @@ import org.bukkit.inventory.InventoryHolder;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class ReplicatingEntityWrapper extends EntityWrapper {
|
public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + ReplicatingEntityWrapper.class.getSimpleName());
|
||||||
|
|
||||||
private final short depth;
|
private final short depth;
|
||||||
private final int hash;
|
private final int hash;
|
||||||
private final EntityBaseStats base = new EntityBaseStats();
|
private final EntityBaseStats base = new EntityBaseStats();
|
||||||
@ -331,10 +335,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
this.dataByte = (byte) 0;
|
this.dataByte = (byte) 0;
|
||||||
}
|
}
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
|
||||||
// END LIVING //
|
// END LIVING //
|
||||||
default:
|
|
||||||
PlotSquared.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +391,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
try {
|
try {
|
||||||
entity.getInventory().setContents(this.inventory);
|
entity.getInventory().setContents(this.inventory);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
PlotSquared.debug("&c[WARN] Failed to restore inventory.\n Reason: " + e.getMessage());
|
logger.error("[P2] Failed to restore inventory", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,7 +737,9 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
restoreLiving((LivingEntity) entity);
|
restoreLiving((LivingEntity) entity);
|
||||||
return entity;
|
return entity;
|
||||||
default:
|
default:
|
||||||
PlotSquared.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] Could not identify entity: {}", entity.getType());
|
||||||
|
}
|
||||||
return entity;
|
return entity;
|
||||||
// END LIVING
|
// END LIVING
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
|
|||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -60,6 +62,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class ChunkListener implements Listener {
|
public class ChunkListener implements Listener {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + ChunkListener.class.getSimpleName());
|
||||||
|
|
||||||
private RefMethod methodGetHandleChunk;
|
private RefMethod methodGetHandleChunk;
|
||||||
private RefField mustSave;
|
private RefField mustSave;
|
||||||
private Chunk lastChunk;
|
private Chunk lastChunk;
|
||||||
@ -73,9 +77,6 @@ public class ChunkListener implements Listener {
|
|||||||
this.mustSave = classChunk.getField("mustSave");
|
this.mustSave = classChunk.getField("mustSave");
|
||||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
PlotSquared.debug(PlotSquared.get().IMP.getPluginName()
|
|
||||||
+ "/Server not compatible for chunk processor trim/gc");
|
|
||||||
|
|
||||||
Settings.Chunk_Processor.AUTO_TRIM = false;
|
Settings.Chunk_Processor.AUTO_TRIM = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,7 +252,6 @@ public class ChunkListener implements Listener {
|
|||||||
if (!chunk.isLoaded()) {
|
if (!chunk.isLoaded()) {
|
||||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
TaskManager.tasks.remove(currentIndex);
|
TaskManager.tasks.remove(currentIndex);
|
||||||
PlotSquared.debug("Successfully processed and unloaded chunk!");
|
|
||||||
chunk.unload(true);
|
chunk.unload(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -259,7 +259,6 @@ public class ChunkListener implements Listener {
|
|||||||
if (tiles.length == 0) {
|
if (tiles.length == 0) {
|
||||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
TaskManager.tasks.remove(currentIndex);
|
TaskManager.tasks.remove(currentIndex);
|
||||||
PlotSquared.debug("Successfully processed and unloaded chunk!");
|
|
||||||
chunk.unload(true);
|
chunk.unload(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -269,7 +268,6 @@ public class ChunkListener implements Listener {
|
|||||||
if (i >= tiles.length - Settings.Chunk_Processor.MAX_TILES) {
|
if (i >= tiles.length - Settings.Chunk_Processor.MAX_TILES) {
|
||||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
TaskManager.tasks.remove(currentIndex);
|
TaskManager.tasks.remove(currentIndex);
|
||||||
PlotSquared.debug("Successfully processed and unloaded chunk!");
|
|
||||||
chunk.unload(true);
|
chunk.unload(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -296,16 +294,9 @@ public class ChunkListener implements Listener {
|
|||||||
toRemove--;
|
toRemove--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.debug(
|
|
||||||
"PlotSquared detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (
|
|
||||||
chunk.getX() << 4));
|
|
||||||
}
|
}
|
||||||
if (tiles.length > Settings.Chunk_Processor.MAX_TILES) {
|
if (tiles.length > Settings.Chunk_Processor.MAX_TILES) {
|
||||||
if (unload) {
|
if (unload) {
|
||||||
PlotSquared.debug(
|
|
||||||
"PlotSquared detected unsafe chunk: " + (chunk.getX() << 4) + "," + (
|
|
||||||
chunk.getX() << 4));
|
|
||||||
cleanChunk(chunk);
|
cleanChunk(chunk);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1000,7 +1000,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
player.sendMessage(spyMessage);
|
player.sendMessage(spyMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.debug(full);
|
// TODO: Re-implement
|
||||||
|
// PlotSquared.debug(full);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) {
|
@EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) {
|
||||||
@ -2477,7 +2478,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
PlotSquared.debug("PlotSquared does not support HangingPlaceEvent for non-players.");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,9 @@ package com.plotsquared.bukkit.queue;
|
|||||||
|
|
||||||
import com.plotsquared.bukkit.schematic.StateWrapper;
|
import com.plotsquared.bukkit.schematic.StateWrapper;
|
||||||
import com.plotsquared.bukkit.util.BukkitBlockUtil;
|
import com.plotsquared.bukkit.util.BukkitBlockUtil;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.queue.BasicLocalBlockQueue;
|
import com.plotsquared.core.queue.BasicLocalBlockQueue;
|
||||||
import com.plotsquared.core.util.BlockUtil;
|
import com.plotsquared.core.util.BlockUtil;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -85,8 +83,6 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
|
|||||||
World worldObj = Bukkit.getWorld(getWorld());
|
World worldObj = Bukkit.getWorld(getWorld());
|
||||||
if (worldObj != null) {
|
if (worldObj != null) {
|
||||||
worldObj.refreshChunk(x, z);
|
worldObj.refreshChunk(x, z);
|
||||||
} else {
|
|
||||||
PlotSquared.debug("Error Refreshing Chunk");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,8 +105,6 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
|
|||||||
world.regenerate(region, editSession);
|
world.regenerate(region, editSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
PlotSquared.debug("Error Regenerating Chunk");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
import com.plotsquared.bukkit.BukkitMain;
|
import com.plotsquared.bukkit.BukkitMain;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.generator.AugmentedUtils;
|
import com.plotsquared.core.generator.AugmentedUtils;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.location.PlotLoc;
|
import com.plotsquared.core.location.PlotLoc;
|
||||||
@ -56,6 +55,8 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -76,6 +77,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
|
|
||||||
public class BukkitRegionManager extends RegionManager {
|
public class BukkitRegionManager extends RegionManager {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitRegionManager.class.getSimpleName());
|
||||||
|
|
||||||
public static boolean isIn(CuboidRegion region, int x, int z) {
|
public static boolean isIn(CuboidRegion region, int x, int z) {
|
||||||
return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX()
|
return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX()
|
||||||
&& z >= region.getMinimumPoint().getZ() && z <= region.getMaximumPoint().getZ();
|
&& z >= region.getMinimumPoint().getZ() && z <= region.getMaximumPoint().getZ();
|
||||||
@ -91,8 +94,6 @@ public class BukkitRegionManager extends RegionManager {
|
|||||||
} else {
|
} else {
|
||||||
final Semaphore semaphore = new Semaphore(1);
|
final Semaphore semaphore = new Semaphore(1);
|
||||||
try {
|
try {
|
||||||
PlotSquared.debug("Attempting to make an asynchronous call to getLoadedChunks."
|
|
||||||
+ " Will halt the calling thread until completed.");
|
|
||||||
semaphore.acquire();
|
semaphore.acquire();
|
||||||
Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () -> {
|
Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () -> {
|
||||||
for (Chunk chunk : Objects.requireNonNull(Bukkit.getWorld(world))
|
for (Chunk chunk : Objects.requireNonNull(Bukkit.getWorld(world))
|
||||||
|
@ -95,6 +95,8 @@ import org.bukkit.entity.Vehicle;
|
|||||||
import org.bukkit.entity.WaterMob;
|
import org.bukkit.entity.WaterMob;
|
||||||
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;
|
||||||
@ -110,6 +112,8 @@ import java.util.stream.Stream;
|
|||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
public class BukkitUtil extends WorldUtil {
|
public class BukkitUtil extends WorldUtil {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitUtil.class.getSimpleName());
|
||||||
|
|
||||||
private static String lastString = null;
|
private static String lastString = null;
|
||||||
private static World lastWorld = null;
|
private static World lastWorld = null;
|
||||||
|
|
||||||
@ -464,7 +468,6 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
block.setType(Material.valueOf("OAK_WALL_SIGN"), false);
|
block.setType(Material.valueOf("OAK_WALL_SIGN"), false);
|
||||||
}
|
}
|
||||||
if (!(block.getBlockData() instanceof WallSign)) {
|
if (!(block.getBlockData() instanceof WallSign)) {
|
||||||
PlotSquared.debug(block.getBlockData().getAsString());
|
|
||||||
throw new RuntimeException("Something went wrong generating a sign");
|
throw new RuntimeException("Something went wrong generating a sign");
|
||||||
}
|
}
|
||||||
final Directional sign = (Directional) block.getBlockData();
|
final Directional sign = (Directional) block.getBlockData();
|
||||||
@ -505,7 +508,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
@NonNull final BiomeType biomeType) {
|
@NonNull final BiomeType biomeType) {
|
||||||
final World world = getWorld(worldName);
|
final World world = getWorld(worldName);
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
PlotSquared.log("An error occurred setting the biome because the world was null.");
|
logger.warn("[P2] An error occured while setting the biome because the world was null", new RuntimeException());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Biome biome = BukkitAdapter.adapt(biomeType);
|
final Biome biome = BukkitAdapter.adapt(biomeType);
|
||||||
@ -619,7 +622,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
PlotSquared.log(Captions.PREFIX + "Unknown entity category requested: " + category);
|
logger.error("[P2] Unknown entity category requested: {}", category);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ package com.plotsquared.bukkit.util;
|
|||||||
|
|
||||||
import com.plotsquared.bukkit.entity.EntityWrapper;
|
import com.plotsquared.bukkit.entity.EntityWrapper;
|
||||||
import com.plotsquared.bukkit.entity.ReplicatingEntityWrapper;
|
import com.plotsquared.bukkit.entity.ReplicatingEntityWrapper;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.location.PlotLoc;
|
import com.plotsquared.core.location.PlotLoc;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
@ -38,6 +37,8 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -46,6 +47,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class ContentMap {
|
public class ContentMap {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + ContentMap.class.getSimpleName());
|
||||||
|
|
||||||
final Set<EntityWrapper> entities;
|
final Set<EntityWrapper> entities;
|
||||||
final Map<PlotLoc, BaseBlock[]> allBlocks;
|
final Map<PlotLoc, BaseBlock[]> allBlocks;
|
||||||
|
|
||||||
@ -123,8 +126,7 @@ public class ContentMap {
|
|||||||
try {
|
try {
|
||||||
entity.spawn(world, xOffset, zOffset);
|
entity.spawn(world, xOffset, zOffset);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
PlotSquared.debug("Failed to restore entity (e): " + e.toString());
|
logger.error("[P2] Failed to restore entity", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.entities.clear();
|
this.entities.clear();
|
||||||
|
@ -30,12 +30,13 @@ import com.google.gson.JsonParser;
|
|||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.PlotVersion;
|
import com.plotsquared.core.PlotVersion;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -44,6 +45,8 @@ import java.net.URL;
|
|||||||
|
|
||||||
public class UpdateUtility implements Listener {
|
public class UpdateUtility implements Listener {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + UpdateUtility.class.getSimpleName());
|
||||||
|
|
||||||
public static PlotVersion internalVersion;
|
public static PlotVersion internalVersion;
|
||||||
public static String spigotVersion;
|
public static String spigotVersion;
|
||||||
public static boolean hasUpdate;
|
public static boolean hasUpdate;
|
||||||
@ -68,26 +71,22 @@ public class UpdateUtility implements Listener {
|
|||||||
.getAsJsonObject();
|
.getAsJsonObject();
|
||||||
spigotVersion = result.get("current_version").getAsString();
|
spigotVersion = result.get("current_version").getAsString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
PlotSquared.log(Captions.PREFIX + "&cUnable to check for updates because: " + e);
|
logger.error("[P2] Unable to check for updates. Error: {}", e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internalVersion.isLaterVersion(spigotVersion)) {
|
if (internalVersion.isLaterVersion(spigotVersion)) {
|
||||||
PlotSquared
|
logger.info("[P2] There appears to be a PlotSquared update available!");
|
||||||
.log(Captions.PREFIX + "&6There appears to be a PlotSquared update available!");
|
logger.info("[P2] You are running version {}, the latest version is {}",
|
||||||
PlotSquared.log(
|
internalVersion.versionString(), spigotVersion);
|
||||||
Captions.PREFIX + "&6You are running version " + internalVersion.versionString()
|
logger.info("[P2] https://www.spigotmc.org/resources/77506/updates");
|
||||||
+ ", &6latest version is " + spigotVersion);
|
|
||||||
PlotSquared
|
|
||||||
.log(Captions.PREFIX + "&6https://www.spigotmc.org/resources/77506/updates");
|
|
||||||
hasUpdate = true;
|
hasUpdate = true;
|
||||||
if (Settings.UpdateChecker.NOTIFY_ONCE) {
|
if (Settings.UpdateChecker.NOTIFY_ONCE) {
|
||||||
cancelTask();
|
cancelTask();
|
||||||
}
|
}
|
||||||
} else if (notify) {
|
} else if (notify) {
|
||||||
notify = false;
|
notify = false;
|
||||||
PlotSquared.log(Captions.PREFIX
|
logger.info("[P2] Congratulations! You are running the latest PlotSquared version");
|
||||||
+ "Congratulations! You are running the latest PlotSquared version.");
|
|
||||||
}
|
}
|
||||||
}, 0L, Settings.UpdateChecker.POLL_RATE * 60 * 20);
|
}, 0L, Settings.UpdateChecker.POLL_RATE * 60 * 20);
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,15 @@
|
|||||||
package com.plotsquared.bukkit.uuid;
|
package com.plotsquared.bukkit.uuid;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.RateLimiter;
|
import com.google.common.util.concurrent.RateLimiter;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
|
||||||
import com.plotsquared.core.uuid.UUIDMapping;
|
import com.plotsquared.core.uuid.UUIDMapping;
|
||||||
import com.plotsquared.core.uuid.UUIDService;
|
import com.plotsquared.core.uuid.UUIDService;
|
||||||
import com.sk89q.squirrelid.Profile;
|
import com.sk89q.squirrelid.Profile;
|
||||||
import com.sk89q.squirrelid.resolver.HttpRepositoryService;
|
import com.sk89q.squirrelid.resolver.HttpRepositoryService;
|
||||||
import com.sk89q.squirrelid.resolver.ProfileService;
|
import com.sk89q.squirrelid.resolver.ProfileService;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -47,6 +48,8 @@ import java.util.UUID;
|
|||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
public class SquirrelIdUUIDService implements UUIDService {
|
public class SquirrelIdUUIDService implements UUIDService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + SquirrelIdUUIDService.class.getSimpleName());
|
||||||
|
|
||||||
private final ProfileService profileService;
|
private final ProfileService profileService;
|
||||||
private final RateLimiter rateLimiter;
|
private final RateLimiter rateLimiter;
|
||||||
|
|
||||||
@ -78,7 +81,9 @@ public class SquirrelIdUUIDService implements UUIDService {
|
|||||||
// go through them one by one
|
// go through them one by one
|
||||||
//
|
//
|
||||||
if (uuids.size() >= 2) {
|
if (uuids.size() >= 2) {
|
||||||
PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID in batch. Will try each UUID individually.");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] (UUID) Found invalid UUID in batch. Will try each UUID individually.");
|
||||||
|
}
|
||||||
for (final UUID uuid : uuids) {
|
for (final UUID uuid : uuids) {
|
||||||
final List<UUIDMapping> result = this.getNames(Collections.singletonList(uuid));
|
final List<UUIDMapping> result = this.getNames(Collections.singletonList(uuid));
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
@ -86,8 +91,8 @@ public class SquirrelIdUUIDService implements UUIDService {
|
|||||||
}
|
}
|
||||||
results.add(result.get(0));
|
results.add(result.get(0));
|
||||||
}
|
}
|
||||||
} else if (uuids.size() == 1) {
|
} else if (uuids.size() == 1 && Settings.DEBUG) {
|
||||||
PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID: " + uuids.get(0));
|
logger.info("[P2] (UUID) Found invalid UUID: {}", uuids.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
|
@ -18,6 +18,8 @@ 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")
|
||||||
|
// logging
|
||||||
|
implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
|
@ -98,6 +98,12 @@
|
|||||||
<version>1.7.0-SNAPSHOT</version>
|
<version>1.7.0-SNAPSHOT</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-slf4j-impl</artifactId>
|
||||||
|
<version>2.8.1</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -27,8 +27,6 @@ package com.plotsquared.core;
|
|||||||
|
|
||||||
import com.plotsquared.core.command.WE_Anywhere;
|
import com.plotsquared.core.command.WE_Anywhere;
|
||||||
import com.plotsquared.core.components.ComponentPresetManager;
|
import com.plotsquared.core.components.ComponentPresetManager;
|
||||||
import com.plotsquared.core.configuration.Caption;
|
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||||
@ -48,7 +46,6 @@ import com.plotsquared.core.generator.HybridUtils;
|
|||||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
import com.plotsquared.core.listener.WESubscriber;
|
import com.plotsquared.core.listener.WESubscriber;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.BlockBucket;
|
import com.plotsquared.core.plot.BlockBucket;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
@ -81,7 +78,6 @@ import com.plotsquared.core.util.SchematicHandler;
|
|||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.logger.ILogger;
|
|
||||||
import com.plotsquared.core.util.query.PlotQuery;
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.uuid.UUIDPipeline;
|
import com.plotsquared.core.uuid.UUIDPipeline;
|
||||||
@ -90,9 +86,10 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
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.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -138,6 +135,9 @@ import java.util.zip.ZipInputStream;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
public class PlotSquared {
|
public class PlotSquared {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotSquared.class.getSimpleName());
|
||||||
|
|
||||||
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
private static final Set<Plot> EMPTY_SET = Collections.unmodifiableSet(Collections.emptySet());
|
||||||
private static PlotSquared instance;
|
private static PlotSquared instance;
|
||||||
// Implementation
|
// Implementation
|
||||||
@ -162,8 +162,6 @@ public class PlotSquared {
|
|||||||
public HashMap<String, Set<PlotCluster>> clusters_tmp;
|
public HashMap<String, Set<PlotCluster>> clusters_tmp;
|
||||||
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
public HashMap<String, HashMap<PlotId, Plot>> plots_tmp;
|
||||||
private YamlConfiguration config;
|
private YamlConfiguration config;
|
||||||
// Implementation logger
|
|
||||||
@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
|
||||||
@ -186,7 +184,6 @@ public class PlotSquared {
|
|||||||
|
|
||||||
this.thread = Thread.currentThread();
|
this.thread = Thread.currentThread();
|
||||||
this.IMP = iPlotMain;
|
this.IMP = iPlotMain;
|
||||||
this.logger = iPlotMain;
|
|
||||||
Settings.PLATFORM = platform;
|
Settings.PLATFORM = platform;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -197,9 +194,9 @@ public class PlotSquared {
|
|||||||
try {
|
try {
|
||||||
new ReflectionUtils(this.IMP.getNMSPackage());
|
new ReflectionUtils(this.IMP.getNMSPackage());
|
||||||
try {
|
try {
|
||||||
URL url = PlotSquared.class.getProtectionDomain().getCodeSource().getLocation();
|
URL logurl = PlotSquared.class.getProtectionDomain().getCodeSource().getLocation();
|
||||||
this.jarFile = new File(
|
this.jarFile = new File(
|
||||||
new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file"))
|
new URL(logurl.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file"))
|
||||||
.toURI().getPath());
|
.toURI().getPath());
|
||||||
} catch (MalformedURLException | URISyntaxException | SecurityException e) {
|
} catch (MalformedURLException | URISyntaxException | SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -238,7 +235,7 @@ public class PlotSquared {
|
|||||||
if (!getConfigurationVersion().equalsIgnoreCase("v5")) {
|
if (!getConfigurationVersion().equalsIgnoreCase("v5")) {
|
||||||
// Perform upgrade
|
// Perform upgrade
|
||||||
if (DBFunc.dbManager.convertFlags()) {
|
if (DBFunc.dbManager.convertFlags()) {
|
||||||
log(Captions.PREFIX.getTranslated() + "Flags were converted successfully!");
|
logger.info("[P2] Flags were converted successfully");
|
||||||
// Update the config version
|
// Update the config version
|
||||||
setConfigurationVersion("v5");
|
setConfigurationVersion("v5");
|
||||||
}
|
}
|
||||||
@ -287,8 +284,7 @@ public class PlotSquared {
|
|||||||
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
||||||
try {
|
try {
|
||||||
if (this.IMP.initWorldEdit()) {
|
if (this.IMP.initWorldEdit()) {
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + IMP.getPluginName()
|
logger.info("[P2] {} hooked into WorldEdit", imp().getPluginName());
|
||||||
+ " hooked into WorldEdit.");
|
|
||||||
this.worldedit = WorldEdit.getInstance();
|
this.worldedit = WorldEdit.getInstance();
|
||||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
||||||
if (Settings.Enabled_Components.COMMANDS) {
|
if (Settings.Enabled_Components.COMMANDS) {
|
||||||
@ -297,8 +293,8 @@ public class PlotSquared {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
PlotSquared.debug(
|
logger.error("[P2] Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
|
||||||
"Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Economy
|
// Economy
|
||||||
@ -310,8 +306,7 @@ public class PlotSquared {
|
|||||||
try {
|
try {
|
||||||
new ComponentPresetManager();
|
new ComponentPresetManager();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(Captions.PREFIX + "Failed to initialize the preset system");
|
logger.error("[P2] Failed to initialize the preset system", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,14 +327,11 @@ public class PlotSquared {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) {
|
if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) {
|
||||||
debug("`" + world + "` was not properly loaded - " + IMP.getPluginName()
|
logger.warn("[P2] `{}` was not properly loaded - {} will now try to load it properly",
|
||||||
+ " will now try to load it properly: ");
|
world, imp().getPluginName());
|
||||||
debug(
|
logger.warn("[P2] - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
|
||||||
" - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
|
logger.warn("[P2] - Your world management plugin may be faulty (or non existent)");
|
||||||
debug(
|
logger.warn("[P2] This message may also be a false positive and could be ignored.");
|
||||||
" - Your world management plugin may be faulty (or non existent)");
|
|
||||||
debug(
|
|
||||||
" This message may also be a false positive and could be ignored.");
|
|
||||||
PlotSquared.this.IMP.setGenerator(world);
|
PlotSquared.this.IMP.setGenerator(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -370,9 +362,6 @@ public class PlotSquared {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.log(Captions.PREFIX + CaptionUtility
|
|
||||||
.format(ConsolePlayer.getConsole(), Captions.ENABLED.getTranslated(),
|
|
||||||
IMP.getPluginName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -391,41 +380,6 @@ public class PlotSquared {
|
|||||||
throw new IllegalStateException("Plot main implementation is missing");
|
throw new IllegalStateException("Plot main implementation is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Log a message to the IPlotMain logger.
|
|
||||||
*
|
|
||||||
* @param message Message to log
|
|
||||||
* @see IPlotMain#log(String)
|
|
||||||
*/
|
|
||||||
public static void log(Object message) {
|
|
||||||
if (message == null || (message instanceof Caption ?
|
|
||||||
((Caption) message).getTranslated().isEmpty() :
|
|
||||||
message.toString().isEmpty())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (PlotSquared.get() == null || PlotSquared.get().getLogger() == null) {
|
|
||||||
System.out.printf("[P2][Info] %s\n", StringMan.getString(message));
|
|
||||||
} else {
|
|
||||||
PlotSquared.get().getLogger().log(StringMan.getString(message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log a message to the IPlotMain logger.
|
|
||||||
*
|
|
||||||
* @param message Message to log
|
|
||||||
* @see IPlotMain#log(String)
|
|
||||||
*/
|
|
||||||
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));
|
|
||||||
} else {
|
|
||||||
PlotSquared.get().getLogger().log(StringMan.getString(message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startExpiryTasks() {
|
private void startExpiryTasks() {
|
||||||
if (Settings.Enabled_Components.PLOT_EXPIRY) {
|
if (Settings.Enabled_Components.PLOT_EXPIRY) {
|
||||||
ExpireManager.IMP = new ExpireManager();
|
ExpireManager.IMP = new ExpireManager();
|
||||||
@ -553,21 +507,16 @@ public class PlotSquared {
|
|||||||
regionInts.forEach(l -> regions.add(BlockVector2.at(l[0], l[1])));
|
regionInts.forEach(l -> regions.add(BlockVector2.at(l[0], l[1])));
|
||||||
chunkInts.forEach(l -> chunks.add(BlockVector2.at(l[0], l[1])));
|
chunkInts.forEach(l -> chunks.add(BlockVector2.at(l[0], l[1])));
|
||||||
int height = (int) list.get(2);
|
int height = (int) list.get(2);
|
||||||
PlotSquared.log(
|
logger.info("[P2] Incomplete road regeneration found. Restarting in world {} with height {}", plotArea.getWorldName(), height);
|
||||||
Captions.PREFIX + "Incomplete road regeneration found. Restarting in world "
|
logger.info("[P2] - Regions: {}", regions.size());
|
||||||
+ plotArea.getWorldName() + " with height " + height + ".");
|
logger.info("[P2] - Chunks: {}", chunks.size());
|
||||||
PlotSquared.debug(" Regions: " + regions.size());
|
|
||||||
PlotSquared.debug(" Chunks: " + chunks.size());
|
|
||||||
HybridUtils.UPDATE = true;
|
HybridUtils.UPDATE = true;
|
||||||
HybridUtils.manager.scheduleRoadUpdate(plotArea, regions, height, chunks);
|
HybridUtils.manager.scheduleRoadUpdate(plotArea, regions, height, chunks);
|
||||||
} catch (IOException | ClassNotFoundException e) {
|
} catch (IOException | ClassNotFoundException e) {
|
||||||
PlotSquared.log(Captions.PREFIX + "Error restarting road regeneration.");
|
logger.error("[P2] Error restarting road regeneration", e);
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
} finally {
|
||||||
if (!file.delete()) {
|
if (!file.delete()) {
|
||||||
PlotSquared.log(
|
logger.error("[P2] Error deleting persistent_regen_data_{}. Please delete this file manually", plotArea.getId());
|
||||||
Captions.PREFIX + "Error deleting persistent_regen_data_" + plotArea.getId()
|
|
||||||
+ ". Please manually delete this file.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1127,7 +1076,6 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
if (type == PlotAreaType.NORMAL) {
|
if (type == PlotAreaType.NORMAL) {
|
||||||
if (plotAreaManager.getPlotAreas(world, null).length != 0) {
|
if (plotAreaManager.getPlotAreas(world, null).length != 0) {
|
||||||
debug("World possibly already loaded: " + world);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IndependentPlotGenerator plotGenerator;
|
IndependentPlotGenerator plotGenerator;
|
||||||
@ -1155,12 +1103,10 @@ public class PlotSquared {
|
|||||||
// Conventional plot generator
|
// Conventional plot generator
|
||||||
PlotArea plotArea = plotGenerator.getNewPlotArea(world, null, null, null);
|
PlotArea plotArea = plotGenerator.getNewPlotArea(world, null, null, null);
|
||||||
PlotManager plotManager = plotArea.getPlotManager();
|
PlotManager plotManager = plotArea.getPlotManager();
|
||||||
PlotSquared.log(Captions.PREFIX + "&aDetected world load for '" + world + "'");
|
logger.info("[P2] Detected world load for '{}'", world);
|
||||||
PlotSquared
|
logger.info("[P2] - generator: {}>{}", baseGenerator, plotGenerator);
|
||||||
.log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + plotGenerator);
|
logger.info("[P2] - plot world: {}", plotArea.getClass().getCanonicalName());
|
||||||
PlotSquared.log(Captions.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
logger.info("[P2] - plot area manager: {}", plotManager.getClass().getCanonicalName());
|
||||||
PlotSquared.log(
|
|
||||||
Captions.PREFIX + "&3 - plotAreaManager: &7" + plotManager.getClass().getName());
|
|
||||||
if (!this.worlds.contains(path)) {
|
if (!this.worlds.contains(path)) {
|
||||||
this.worlds.createSection(path);
|
this.worlds.createSection(path);
|
||||||
worldSection = this.worlds.getConfigurationSection(path);
|
worldSection = this.worlds.getConfigurationSection(path);
|
||||||
@ -1182,10 +1128,9 @@ public class PlotSquared {
|
|||||||
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
|
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
|
||||||
if (areasSection == null) {
|
if (areasSection == null) {
|
||||||
if (plotAreaManager.getPlotAreas(world, null).length != 0) {
|
if (plotAreaManager.getPlotAreas(world, null).length != 0) {
|
||||||
debug("World possibly already loaded: " + world);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotSquared.log(Captions.PREFIX + "&aDetected world load for '" + world + "'");
|
logger.info("[P2] Detected world load for '{}'", world);
|
||||||
String gen_string = worldSection.getString("generator.plugin", IMP.getPluginName());
|
String gen_string = worldSection.getString("generator.plugin", IMP.getPluginName());
|
||||||
if (type == PlotAreaType.PARTIAL) {
|
if (type == PlotAreaType.PARTIAL) {
|
||||||
Set<PlotCluster> clusters =
|
Set<PlotCluster> clusters =
|
||||||
@ -1201,8 +1146,7 @@ public class PlotSquared {
|
|||||||
String fullId = name + "-" + pos1 + "-" + pos2;
|
String fullId = name + "-" + pos1 + "-" + pos2;
|
||||||
worldSection.createSection("areas." + fullId);
|
worldSection.createSection("areas." + fullId);
|
||||||
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
|
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
|
||||||
|
logger.info("[P2] - {}-{}-{}", name, pos1, pos2);
|
||||||
PlotSquared.log(Captions.PREFIX + "&3 - " + name + "-" + pos1 + "-" + pos2);
|
|
||||||
GeneratorWrapper<?> areaGen = this.IMP.getGenerator(world, gen_string);
|
GeneratorWrapper<?> areaGen = this.IMP.getGenerator(world, gen_string);
|
||||||
if (areaGen == null) {
|
if (areaGen == null) {
|
||||||
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
||||||
@ -1216,14 +1160,10 @@ public class PlotSquared {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
PlotSquared.log(
|
logger.info("[P2] | generator: {}>{}", baseGenerator, areaGen);
|
||||||
Captions.PREFIX + "&c | &9generator: &7" + baseGenerator + ">"
|
logger.info("[P2] | plot world: {}", pa);
|
||||||
+ areaGen);
|
logger.info("[P2] | manager: {}", pa);
|
||||||
PlotSquared.log(Captions.PREFIX + "&c | &9plotworld: &7" + pa);
|
logger.info("[P2] Note: Area created for cluster '{}' (invalid or old configuration?)", name);
|
||||||
PlotSquared.log(Captions.PREFIX + "&c | &9manager: &7" + pa);
|
|
||||||
PlotSquared.log(
|
|
||||||
Captions.PREFIX + "&cNote: &7Area created for cluster:" + name
|
|
||||||
+ " (invalid or old configuration?)");
|
|
||||||
areaGen.getPlotGenerator().initialize(pa);
|
areaGen.getPlotGenerator().initialize(pa);
|
||||||
areaGen.augment(pa);
|
areaGen.augment(pa);
|
||||||
toLoad.add(pa);
|
toLoad.add(pa);
|
||||||
@ -1245,10 +1185,9 @@ public class PlotSquared {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
PlotSquared
|
logger.info("[P2] - generator: {}>{}", baseGenerator, areaGen);
|
||||||
.log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + areaGen);
|
logger.info("[P2] - plot world: {}", pa);
|
||||||
PlotSquared.log(Captions.PREFIX + "&3 - plotworld: &7" + pa);
|
logger.info("[P2] - plot area manager: {}", pa.getPlotManager());
|
||||||
PlotSquared.log(Captions.PREFIX + "&3 - plotAreaManager: &7" + pa.getPlotManager());
|
|
||||||
areaGen.getPlotGenerator().initialize(pa);
|
areaGen.getPlotGenerator().initialize(pa);
|
||||||
areaGen.augment(pa);
|
areaGen.augment(pa);
|
||||||
addPlotArea(pa);
|
addPlotArea(pa);
|
||||||
@ -1260,7 +1199,7 @@ public class PlotSquared {
|
|||||||
+ PlotAreaType.AUGMENTED + "`");
|
+ PlotAreaType.AUGMENTED + "`");
|
||||||
}
|
}
|
||||||
for (String areaId : areasSection.getKeys(false)) {
|
for (String areaId : areasSection.getKeys(false)) {
|
||||||
PlotSquared.log(Captions.PREFIX + " - " + areaId);
|
logger.info("[P2] - {}", areaId);
|
||||||
String[] split = areaId.split("(?<=[^;-])-");
|
String[] split = areaId.split("(?<=[^;-])-");
|
||||||
if (split.length != 3) {
|
if (split.length != 3) {
|
||||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId
|
throw new IllegalArgumentException("Invalid Area identifier: " + areaId
|
||||||
@ -1322,11 +1261,10 @@ public class PlotSquared {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
PlotSquared.log(Captions.PREFIX + "&aDetected area load for '" + world + "'");
|
logger.info("[P2] Detected area load for '{}'", world);
|
||||||
PlotSquared
|
logger.info("[P2] | generator: {}>{}", baseGenerator, areaGen);
|
||||||
.log(Captions.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
logger.info("[P2] | plot world: {}", pa);
|
||||||
PlotSquared.log(Captions.PREFIX + "&c | &9plotworld: &7" + pa);
|
logger.info("[P2] | manager: {}", pa.getPlotManager());
|
||||||
PlotSquared.log(Captions.PREFIX + "&c | &9manager: &7" + pa.getPlotManager());
|
|
||||||
areaGen.getPlotGenerator().initialize(pa);
|
areaGen.getPlotGenerator().initialize(pa);
|
||||||
areaGen.augment(pa);
|
areaGen.augment(pa);
|
||||||
addPlotArea(pa);
|
addPlotArea(pa);
|
||||||
@ -1395,7 +1333,7 @@ public class PlotSquared {
|
|||||||
for (String element : split) {
|
for (String element : split) {
|
||||||
String[] pair = element.split("=");
|
String[] pair = element.split("=");
|
||||||
if (pair.length != 2) {
|
if (pair.length != 2) {
|
||||||
PlotSquared.log("&cNo value provided for: &7" + element);
|
logger.error("[P2] No value provided for '{}'", element);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String key = pair[0].toLowerCase();
|
String key = pair[0].toLowerCase();
|
||||||
@ -1443,12 +1381,12 @@ public class PlotSquared {
|
|||||||
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString());
|
ConfigurationUtil.BLOCK_BUCKET.parseString(value).toString());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PlotSquared.log("&cKey not found: &7" + element);
|
logger.error("[P2] Key not found: {}", element);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
logger.error("[P2] Invalid value '{}' for arg '{}'", value, element);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.log("&cInvalid value: &7" + value + " in arg " + element);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1526,8 +1464,8 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
logger.error("[P2] Could not save {}", file);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.log("&cCould not save " + file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1562,8 +1500,8 @@ public class PlotSquared {
|
|||||||
// Close the connection
|
// Close the connection
|
||||||
DBFunc.close();
|
DBFunc.close();
|
||||||
} catch (NullPointerException throwable) {
|
} catch (NullPointerException throwable) {
|
||||||
|
logger.error("[P2] Could not close database connection", throwable);
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
PlotSquared.log("&cCould not close database connection!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1575,10 +1513,9 @@ public class PlotSquared {
|
|||||||
HybridUtils.regions.isEmpty() && HybridUtils.chunks.isEmpty())) {
|
HybridUtils.regions.isEmpty() && HybridUtils.chunks.isEmpty())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotSquared.log(
|
logger.info("[P2] Road regeneration incomplete. Saving incomplete regions to disk");
|
||||||
Captions.PREFIX + "Road regeneration incomplete. Saving incomplete regions to disk.");
|
logger.info("[P2] - regions: {}", HybridUtils.regions.size());
|
||||||
PlotSquared.debug(" Regions: " + HybridUtils.regions.size());
|
logger.info("[P2] - chunks: {}", HybridUtils.chunks.size());
|
||||||
PlotSquared.debug(" Chunks: " + HybridUtils.chunks.size());
|
|
||||||
ArrayList<int[]> regions = new ArrayList<>();
|
ArrayList<int[]> regions = new ArrayList<>();
|
||||||
ArrayList<int[]> chunks = new ArrayList<>();
|
ArrayList<int[]> chunks = new ArrayList<>();
|
||||||
for (BlockVector2 r : HybridUtils.regions) {
|
for (BlockVector2 r : HybridUtils.regions) {
|
||||||
@ -1595,16 +1532,14 @@ public class PlotSquared {
|
|||||||
this.IMP.getDirectory() + File.separator + "persistent_regen_data_" + HybridUtils.area
|
this.IMP.getDirectory() + File.separator + "persistent_regen_data_" + HybridUtils.area
|
||||||
.getId() + "_" + HybridUtils.area.getWorldName());
|
.getId() + "_" + HybridUtils.area.getWorldName());
|
||||||
if (file.exists() && !file.delete()) {
|
if (file.exists() && !file.delete()) {
|
||||||
PlotSquared.log(Captions.PREFIX
|
logger.error("[P2] persistent_regene_data file already exists and could not be deleted");
|
||||||
+ "persistent_regen_data file already exists and could not be deleted.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try (ObjectOutputStream oos = new ObjectOutputStream(
|
try (ObjectOutputStream oos = new ObjectOutputStream(
|
||||||
Files.newOutputStream(file.toPath(), StandardOpenOption.CREATE_NEW))) {
|
Files.newOutputStream(file.toPath(), StandardOpenOption.CREATE_NEW))) {
|
||||||
oos.writeObject(list);
|
oos.writeObject(list);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
PlotSquared.log(Captions.PREFIX + "Error create persistent_regen_data file.");
|
logger.error("[P2] Error creating persistent_region_data file", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1624,7 +1559,7 @@ public class PlotSquared {
|
|||||||
File file = MainUtil.getFile(IMP.getDirectory(), Storage.SQLite.DB + ".db");
|
File file = MainUtil.getFile(IMP.getDirectory(), Storage.SQLite.DB + ".db");
|
||||||
database = new SQLite(file);
|
database = new SQLite(file);
|
||||||
} else {
|
} else {
|
||||||
PlotSquared.log(Captions.PREFIX + "&cNo storage type is set!");
|
logger.error("[P2] No storage type is set. Disabling PlotSquared");
|
||||||
this.IMP.shutdown(); //shutdown used instead of disable because no database is set
|
this.IMP.shutdown(); //shutdown used instead of disable because no database is set
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1642,19 +1577,12 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
this.clusters_tmp = DBFunc.getClusters();
|
this.clusters_tmp = DBFunc.getClusters();
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
PlotSquared.log(Captions.PREFIX
|
logger.error("[P2] Failed to open database connection ({}). Disabling PlotSquared", Storage.MySQL.USE ? "MySQL" : "SQLite");
|
||||||
+ "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
logger.error("[P2] ==== Here is an ugly stacktrace, if you are interested in those things ===");
|
||||||
if (Storage.MySQL.USE) {
|
|
||||||
PlotSquared.log("$4MYSQL");
|
|
||||||
} else if (Storage.SQLite.USE) {
|
|
||||||
PlotSquared.log("$4SQLITE");
|
|
||||||
}
|
|
||||||
PlotSquared.log(
|
|
||||||
"&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.log("&d==== End of stacktrace ====");
|
logger.error("[P2] &d==== End of stacktrace ====");
|
||||||
PlotSquared.log("&6Please go to the " + IMP.getPluginName()
|
logger.error("[P2] &6Please go to the {} 'storage.yml' and configure the database correctly",
|
||||||
+ " 'storage.yml' and configure the database correctly.");
|
imp().getPluginName());
|
||||||
this.IMP.shutdown(); //shutdown used instead of disable because of database error
|
this.IMP.shutdown(); //shutdown used instead of disable because of database error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1679,7 +1607,7 @@ public class PlotSquared {
|
|||||||
try {
|
try {
|
||||||
worlds.save(worldsFile);
|
worlds.save(worldsFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
PlotSquared.debug("Failed to save " + IMP.getPluginName() + " worlds.yml");
|
logger.error("[P2] Failed to save worlds.yml", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1712,14 +1640,12 @@ public class PlotSquared {
|
|||||||
public boolean setupConfigs() {
|
public boolean setupConfigs() {
|
||||||
File folder = new File(this.IMP.getDirectory(), "config");
|
File folder = new File(this.IMP.getDirectory(), "config");
|
||||||
if (!folder.exists() && !folder.mkdirs()) {
|
if (!folder.exists() && !folder.mkdirs()) {
|
||||||
PlotSquared.log(Captions.PREFIX
|
logger.error("[P2] Failed to create the /plugins/config folder. Please create it manually");
|
||||||
+ "&cFailed to create the /plugins/config folder. Please create it manually.");
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.worldsFile = new File(folder, "worlds.yml");
|
this.worldsFile = new File(folder, "worlds.yml");
|
||||||
if (!this.worldsFile.exists() && !this.worldsFile.createNewFile()) {
|
if (!this.worldsFile.exists() && !this.worldsFile.createNewFile()) {
|
||||||
PlotSquared.log(
|
logger.error("[P2] Could not create the worlds file. Please create 'worlds.yml' manually");
|
||||||
"Could not create the worlds file, please create \"worlds.yml\" manually.");
|
|
||||||
}
|
}
|
||||||
this.worlds = YamlConfiguration.loadConfiguration(this.worldsFile);
|
this.worlds = YamlConfiguration.loadConfiguration(this.worldsFile);
|
||||||
|
|
||||||
@ -1729,21 +1655,20 @@ public class PlotSquared {
|
|||||||
.equalsIgnoreCase(LegacyConverter.CONFIGURATION_VERSION) && !this.worlds
|
.equalsIgnoreCase(LegacyConverter.CONFIGURATION_VERSION) && !this.worlds
|
||||||
.getString("configuration_version").equalsIgnoreCase("v5"))) {
|
.getString("configuration_version").equalsIgnoreCase("v5"))) {
|
||||||
// Conversion needed
|
// Conversion needed
|
||||||
log(Captions.LEGACY_CONFIG_FOUND.getTranslated());
|
logger.info(Captions.LEGACY_CONFIG_FOUND.getTranslated());
|
||||||
try {
|
try {
|
||||||
com.google.common.io.Files
|
com.google.common.io.Files
|
||||||
.copy(this.worldsFile, new File(folder, "worlds.yml.old"));
|
.copy(this.worldsFile, new File(folder, "worlds.yml.old"));
|
||||||
log(Captions.LEGACY_CONFIG_BACKUP.getTranslated());
|
logger.info(Captions.LEGACY_CONFIG_BACKUP.getTranslated());
|
||||||
final ConfigurationSection worlds =
|
final ConfigurationSection worlds =
|
||||||
this.worlds.getConfigurationSection("worlds");
|
this.worlds.getConfigurationSection("worlds");
|
||||||
final LegacyConverter converter = new LegacyConverter(worlds);
|
final LegacyConverter converter = new LegacyConverter(worlds);
|
||||||
converter.convert();
|
converter.convert();
|
||||||
this.worlds.set("worlds", worlds);
|
this.worlds.set("worlds", worlds);
|
||||||
this.setConfigurationVersion(LegacyConverter.CONFIGURATION_VERSION);
|
this.setConfigurationVersion(LegacyConverter.CONFIGURATION_VERSION);
|
||||||
log(Captions.LEGACY_CONFIG_DONE.getTranslated());
|
logger.info(Captions.LEGACY_CONFIG_DONE.getTranslated());
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
log(Captions.LEGACY_CONFIG_CONVERSION_FAILED.getTranslated());
|
logger.error(Captions.LEGACY_CONFIG_CONVERSION_FAILED.getTranslated(), e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
// Disable plugin
|
// Disable plugin
|
||||||
this.IMP.shutdown();
|
this.IMP.shutdown();
|
||||||
@ -1753,18 +1678,17 @@ public class PlotSquared {
|
|||||||
this.worlds.set("configuration_version", LegacyConverter.CONFIGURATION_VERSION);
|
this.worlds.set("configuration_version", LegacyConverter.CONFIGURATION_VERSION);
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
PlotSquared.log("Failed to save settings.yml");
|
logger.error("[P2] Failed to save worlds.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.configFile = new File(folder, "settings.yml");
|
this.configFile = new File(folder, "settings.yml");
|
||||||
if (!this.configFile.exists() && !this.configFile.createNewFile()) {
|
if (!this.configFile.exists() && !this.configFile.createNewFile()) {
|
||||||
PlotSquared.log(
|
logger.error("[P2] Could not create the settings file. Please create 'settings.yml' manually");
|
||||||
"Could not create the settings file, please create \"settings.yml\" manually.");
|
|
||||||
}
|
}
|
||||||
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||||
setupConfig();
|
setupConfig();
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
PlotSquared.log("Failed to save settings.yml");
|
logger.error("[P2] Failed to save settings.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.styleFile = MainUtil.getFile(IMP.getDirectory(),
|
this.styleFile = MainUtil.getFile(IMP.getDirectory(),
|
||||||
@ -1774,27 +1698,28 @@ public class PlotSquared {
|
|||||||
this.styleFile.getParentFile().mkdirs();
|
this.styleFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
if (!this.styleFile.createNewFile()) {
|
if (!this.styleFile.createNewFile()) {
|
||||||
PlotSquared.log(
|
logger.error("[P2] Failed to create the style file. Please create 'translations/style.yml' manually");
|
||||||
"Could not create the style file, please create \"translations/style.yml\" manually");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.style = YamlConfiguration.loadConfiguration(this.styleFile);
|
this.style = YamlConfiguration.loadConfiguration(this.styleFile);
|
||||||
setupStyle();
|
setupStyle();
|
||||||
this.style.save(this.styleFile);
|
} catch (IOException ignored) {
|
||||||
} catch (IOException err) {
|
logger.error("[P2] Failed to save style.yml");
|
||||||
err.printStackTrace();
|
|
||||||
PlotSquared.log("Failed to save style.yml");
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.storageFile = new File(folder, "storage.yml");
|
this.storageFile = new File(folder, "storage.yml");
|
||||||
if (!this.storageFile.exists() && !this.storageFile.createNewFile()) {
|
if (!this.storageFile.exists() && !this.storageFile.createNewFile()) {
|
||||||
PlotSquared.log(
|
logger.error("[P2] Could not create the storage settings file. Please create 'storage.yml' manually");
|
||||||
"Could not the storage settings file, please create \"storage.yml\" manually.");
|
|
||||||
}
|
}
|
||||||
this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
|
this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
|
||||||
setupStorage();
|
setupStorage();
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
PlotSquared.log("Failed to save storage.yml");
|
logger.error("[P2] Failed to save storage.yml");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.style.save(this.styleFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.error("[P2] Configuration file saving failed", e);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1825,9 +1750,7 @@ public class PlotSquared {
|
|||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
Map<String, Object> components = Settings.getFields(Settings.Enabled_Components.class);
|
Map<String, Object> components = Settings.getFields(Settings.Enabled_Components.class);
|
||||||
for (Entry<String, Object> component : components.entrySet()) {
|
for (Entry<String, Object> component : components.entrySet()) {
|
||||||
PlotSquared.log(Captions.PREFIX + String
|
logger.info("[P2] Key: {} | Value: {}", component.getKey(), component.getValue());
|
||||||
.format("&cKey: &6%s&c, Value: &6%s", component.getKey(),
|
|
||||||
component.getValue()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,8 @@ import java.util.UUID;
|
|||||||
* @see MainUtil#sendConsoleMessage(Captions, String...)
|
* @see MainUtil#sendConsoleMessage(Captions, String...)
|
||||||
*/
|
*/
|
||||||
public void sendConsoleMessage(String message) {
|
public void sendConsoleMessage(String message) {
|
||||||
PlotSquared.log(message);
|
// TODO: Re-implement
|
||||||
|
// PlotSquared.log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,6 +44,8 @@ import com.plotsquared.core.util.Expression;
|
|||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
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;
|
||||||
|
|
||||||
@CommandDeclaration(command = "claim",
|
@CommandDeclaration(command = "claim",
|
||||||
aliases = "c",
|
aliases = "c",
|
||||||
@ -54,6 +56,8 @@ import com.plotsquared.core.util.task.TaskManager;
|
|||||||
usage = "/plot claim")
|
usage = "/plot claim")
|
||||||
public class Claim extends SubCommand {
|
public class Claim extends SubCommand {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + Claim.class.getSimpleName());
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
String schematic = null;
|
String schematic = null;
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
@ -133,7 +137,7 @@ public class Claim extends SubCommand {
|
|||||||
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
|
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override public void run(Object value) {
|
@Override public void run(Object value) {
|
||||||
if (!plot.claim(player, true, finalSchematic, false)) {
|
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()));
|
.format("Failed to claim plot %s", plot.getId().toCommaSeparatedString()));
|
||||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||||
plot.setOwnerAbs(null);
|
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",
|
.format("Failed to add plot %s to the database",
|
||||||
plot.getId().toCommaSeparatedString()));
|
plot.getId().toCommaSeparatedString()));
|
||||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||||
|
@ -36,6 +36,8 @@ import com.plotsquared.core.util.entity.EntityCategory;
|
|||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.plotsquared.core.uuid.UUIDMapping;
|
import com.plotsquared.core.uuid.UUIDMapping;
|
||||||
import com.sk89q.worldedit.world.entity.EntityType;
|
import com.sk89q.worldedit.world.entity.EntityType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -48,6 +50,8 @@ import java.util.Map;
|
|||||||
permission = "plots.admin")
|
permission = "plots.admin")
|
||||||
public class Debug extends SubCommand {
|
public class Debug extends SubCommand {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + Debug.class.getSimpleName());
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if ("player".equalsIgnoreCase(args[0])) {
|
if ("player".equalsIgnoreCase(args[0])) {
|
||||||
@ -79,6 +83,13 @@ public class Debug extends SubCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (args.length > 0 && "logging".equalsIgnoreCase(args[0])) {
|
||||||
|
logger.info("[P2] Info!");
|
||||||
|
logger.warn("[P2] Warning!");
|
||||||
|
logger.error("[P2] Error!", new RuntimeException());
|
||||||
|
logger.debug("[P2] Debug!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) {
|
if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) {
|
||||||
EntityCategories.init();
|
EntityCategories.init();
|
||||||
player.sendMessage(Captions.PREFIX.getTranslated() + "§cEntity Categories: ");
|
player.sendMessage(Captions.PREFIX.getTranslated() + "§cEntity Categories: ");
|
||||||
|
@ -59,6 +59,8 @@ import com.plotsquared.core.util.task.RunnableVal2;
|
|||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.script.Bindings;
|
import javax.script.Bindings;
|
||||||
import javax.script.ScriptContext;
|
import javax.script.ScriptContext;
|
||||||
@ -81,6 +83,9 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
aliases = {"exec", "$"},
|
aliases = {"exec", "$"},
|
||||||
category = CommandCategory.DEBUG)
|
category = CommandCategory.DEBUG)
|
||||||
public class DebugExec extends SubCommand {
|
public class DebugExec extends SubCommand {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + DebugExec.class.getSimpleName());
|
||||||
|
|
||||||
private ScriptEngine engine;
|
private ScriptEngine engine;
|
||||||
private Bindings scope;
|
private Bindings scope;
|
||||||
|
|
||||||
@ -447,7 +452,6 @@ public class DebugExec extends SubCommand {
|
|||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
this.scope.put("PlotPlayer", player);
|
this.scope.put("PlotPlayer", player);
|
||||||
PlotSquared.debug("> " + script);
|
|
||||||
try {
|
try {
|
||||||
if (async) {
|
if (async) {
|
||||||
final String toExec = script;
|
final String toExec = script;
|
||||||
@ -459,14 +463,12 @@ public class DebugExec extends SubCommand {
|
|||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
PlotSquared
|
logger.info("[P2] > {}ms -> {}", System.currentTimeMillis() - start, result);
|
||||||
.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Object result = this.engine.eval(script, this.scope);
|
Object result = this.engine.eval(script, this.scope);
|
||||||
PlotSquared
|
logger.info("[P2] > {}ms -> {}", System.currentTimeMillis() - start, result);
|
||||||
.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
|
@ -36,6 +36,8 @@ import com.plotsquared.core.plot.PlotArea;
|
|||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -53,6 +55,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
confirmation = true)
|
confirmation = true)
|
||||||
public class Purge extends SubCommand {
|
public class Purge extends SubCommand {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + Purge.class.getSimpleName());
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
@ -170,7 +174,9 @@ public class Purge extends SubCommand {
|
|||||||
"/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)";
|
"/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)";
|
||||||
boolean finalClear = clear;
|
boolean finalClear = clear;
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
PlotSquared.debug("Calculating plots to purge, please wait...");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] Calculating plots to purge, please wait...");
|
||||||
|
}
|
||||||
HashSet<Integer> ids = new HashSet<>();
|
HashSet<Integer> ids = new HashSet<>();
|
||||||
Iterator<Plot> iterator = toDelete.iterator();
|
Iterator<Plot> iterator = toDelete.iterator();
|
||||||
AtomicBoolean cleared = new AtomicBoolean(true);
|
AtomicBoolean cleared = new AtomicBoolean(true);
|
||||||
@ -183,22 +189,21 @@ public class Purge extends SubCommand {
|
|||||||
try {
|
try {
|
||||||
ids.add(plot.temp);
|
ids.add(plot.temp);
|
||||||
if (finalClear) {
|
if (finalClear) {
|
||||||
plot.clear(false, true, () -> PlotSquared
|
plot.clear(false, true, () -> {
|
||||||
.debug("Plot " + plot.getId() + " cleared by purge."));
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] Plot {} cleared by purge", plot.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
plot.removeSign();
|
plot.removeSign();
|
||||||
}
|
}
|
||||||
plot.getArea().removePlot(plot.getId());
|
plot.getArea().removePlot(plot.getId());
|
||||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
for (PlotPlayer<?> pp : plot.getPlayersInPlot()) {
|
||||||
PlotListener.plotEntry(pp, plot);
|
PlotListener.plotEntry(pp, plot);
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
PlotSquared.log(
|
logger.error("[P2] NullPointer during purge detected. This is likely"
|
||||||
"NullPointer during purge detected. This is likely because you are "
|
+ " because you are deleting a world that has been removed", e);
|
||||||
+ "deleting a world that has been removed.");
|
|
||||||
if (Settings.DEBUG) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cleared.set(true);
|
cleared.set(true);
|
||||||
|
@ -42,6 +42,8 @@ import com.plotsquared.core.util.task.RunnableVal2;
|
|||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -62,6 +64,7 @@ import java.util.Set;
|
|||||||
category = CommandCategory.ADMINISTRATION)
|
category = CommandCategory.ADMINISTRATION)
|
||||||
public class Trim extends SubCommand {
|
public class Trim extends SubCommand {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + Trim.class.getSimpleName());
|
||||||
public static ArrayList<Plot> expired = null;
|
public static ArrayList<Plot> expired = null;
|
||||||
private static volatile boolean TASK = false;
|
private static volatile boolean TASK = false;
|
||||||
|
|
||||||
@ -108,7 +111,6 @@ public class Trim extends SubCommand {
|
|||||||
BlockVector2 loc = BlockVector2.at(x, z);
|
BlockVector2 loc = BlockVector2.at(x, z);
|
||||||
empty.add(loc);
|
empty.add(loc);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
PlotSquared.debug("INVALID MCA: " + name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -179,14 +181,15 @@ public class Trim extends SubCommand {
|
|||||||
@Override public void run(Set<BlockVector2> viable, final Set<BlockVector2> nonViable) {
|
@Override public void run(Set<BlockVector2> viable, final Set<BlockVector2> nonViable) {
|
||||||
Runnable regenTask;
|
Runnable regenTask;
|
||||||
if (regen) {
|
if (regen) {
|
||||||
PlotSquared.log("Starting regen task:");
|
logger.info("[P2] Starting regen task");
|
||||||
PlotSquared.log(" - This is a VERY slow command");
|
logger.info("[P2] - This is a VERY slow command");
|
||||||
PlotSquared.log(" - It will say `Trim done!` when complete");
|
logger.info("[P2] - It will say 'Trim done!' when complete");
|
||||||
regenTask = new Runnable() {
|
regenTask = new Runnable() {
|
||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
if (nonViable.isEmpty()) {
|
if (nonViable.isEmpty()) {
|
||||||
Trim.TASK = false;
|
Trim.TASK = false;
|
||||||
player.sendMessage("Trim done!");
|
player.sendMessage("Trim done!");
|
||||||
|
logger.info("[P2] Trim done!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Iterator<BlockVector2> iterator = nonViable.iterator();
|
Iterator<BlockVector2> iterator = nonViable.iterator();
|
||||||
|
@ -44,6 +44,8 @@ import com.plotsquared.core.util.Permissions;
|
|||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -57,6 +59,8 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class ComponentPresetManager {
|
public class ComponentPresetManager {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + ComponentPresetManager.class.getSimpleName());
|
||||||
|
|
||||||
private final List<ComponentPreset> presets;
|
private final List<ComponentPreset> presets;
|
||||||
private final String guiName;
|
private final String guiName;
|
||||||
|
|
||||||
@ -70,7 +74,7 @@ public class ComponentPresetManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (!created) {
|
if (!created) {
|
||||||
PlotSquared.log(Captions.PREFIX + "Failed to create components.yml");
|
logger.error("[P2] Failed to create components.yml");
|
||||||
this.guiName = "&cInvalid!";
|
this.guiName = "&cInvalid!";
|
||||||
this.presets = new ArrayList<>();
|
this.presets = new ArrayList<>();
|
||||||
return;
|
return;
|
||||||
@ -86,8 +90,7 @@ public class ComponentPresetManager {
|
|||||||
try {
|
try {
|
||||||
yamlConfiguration.save(file);
|
yamlConfiguration.save(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
PlotSquared.log(Captions.PREFIX + "Failed to save default values to components.yml");
|
logger.error("[P2] Failed to save default values to components.yml", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.guiName = yamlConfiguration.getString("title", "&6Plot Components");
|
this.guiName = yamlConfiguration.getString("title", "&6Plot Components");
|
||||||
@ -105,8 +108,7 @@ public class ComponentPresetManager {
|
|||||||
try {
|
try {
|
||||||
yamlConfiguration.save(file);
|
yamlConfiguration.save(file);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
PlotSquared.log(Captions.PREFIX + "Failed to save default values to components.yml");
|
logger.error("[P2] Failed to save default values to components.yml", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
this.presets = defaultPreset;
|
this.presets = defaultPreset;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration;
|
package com.plotsquared.core.configuration;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
|
|
||||||
@ -44,7 +43,8 @@ public interface Caption {
|
|||||||
default boolean send(PlotPlayer caller, Object... args) {
|
default boolean send(PlotPlayer caller, Object... args) {
|
||||||
String msg = CaptionUtility.format(caller, this, args);
|
String msg = CaptionUtility.format(caller, this, args);
|
||||||
if (caller == null) {
|
if (caller == null) {
|
||||||
PlotSquared.log(msg);
|
// TODO: Replace with adventure
|
||||||
|
System.out.println(msg);
|
||||||
} else {
|
} else {
|
||||||
caller.sendMessage(msg);
|
caller.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
@ -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("P2/" + Config.class.getSimpleName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,6 @@ public class Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.debug("Failed to get config option: " + key);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,15 +97,13 @@ public class Config {
|
|||||||
}
|
}
|
||||||
field.set(instance, value);
|
field.set(instance, value);
|
||||||
return;
|
return;
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
PlotSquared.debug(
|
logger.error("[P2] Invalid configuration value '{}: {}' in {}", key, value, root.getSimpleName());
|
||||||
"Invalid configuration value: " + key + ": " + value + " in " + root
|
|
||||||
.getSimpleName());
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.debug("Failed to set config option: " + key + ": " + value + " | " + instance);
|
logger.error("[P2] 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) {
|
||||||
@ -288,10 +288,10 @@ public class Config {
|
|||||||
Field field = instance.getClass().getField(toFieldName(split[split.length - 1]));
|
Field field = instance.getClass().getField(toFieldName(split[split.length - 1]));
|
||||||
setAccessible(field);
|
setAccessible(field);
|
||||||
return field;
|
return field;
|
||||||
} catch (Throwable e) {
|
} catch (final Throwable e) {
|
||||||
PlotSquared.debug(
|
logger.error("[P2] Invalid config field: {} for {}",
|
||||||
"Invalid config field: " + StringMan.join(split, ".") + " for " + toNodeName(
|
StringMan.join(split, "."), toNodeName(instance.getClass().getSimpleName()));
|
||||||
instance.getClass().getSimpleName()));
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.configuration.file;
|
package com.plotsquared.core.configuration.file;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Configuration;
|
import com.plotsquared.core.configuration.Configuration;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.InvalidConfigurationException;
|
import com.plotsquared.core.configuration.InvalidConfigurationException;
|
||||||
|
import com.plotsquared.core.configuration.Settings;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.error.YAMLException;
|
import org.yaml.snakeyaml.error.YAMLException;
|
||||||
@ -45,6 +47,9 @@ import java.util.Map;
|
|||||||
* Note that this implementation is not synchronized.
|
* Note that this implementation is not synchronized.
|
||||||
*/
|
*/
|
||||||
public class YamlConfiguration extends FileConfiguration {
|
public class YamlConfiguration extends FileConfiguration {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + YamlConfiguration.class.getSimpleName());
|
||||||
|
|
||||||
private static final String COMMENT_PREFIX = "# ";
|
private static final String COMMENT_PREFIX = "# ";
|
||||||
private static final String BLANK_CONFIG = "{}\n";
|
private static final String BLANK_CONFIG = "{}\n";
|
||||||
private final DumperOptions yamlOptions = new DumperOptions();
|
private final DumperOptions yamlOptions = new DumperOptions();
|
||||||
@ -76,11 +81,13 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
dest = new File(file.getAbsolutePath() + "_broken_" + i++);
|
dest = new File(file.getAbsolutePath() + "_broken_" + i++);
|
||||||
}
|
}
|
||||||
Files.copy(file.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(file.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
PlotSquared.debug("&dCould not read: &7" + file);
|
if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&dRenamed to: &7" + dest.getName());
|
logger.error("[P2] Could not read: {}", file);
|
||||||
PlotSquared.debug("&c============ Full stacktrace ============");
|
logger.error("[P2] Renamed to: {}", file);
|
||||||
|
logger.error("[P2] ============ Full stacktrace ============");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
PlotSquared.debug("&c=========================================");
|
logger.error("[P2] =========================================");
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ package com.plotsquared.core.database;
|
|||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.Storage;
|
import com.plotsquared.core.configuration.Storage;
|
||||||
@ -48,6 +47,8 @@ import com.plotsquared.core.util.StringMan;
|
|||||||
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.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
@ -79,6 +80,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@SuppressWarnings("SqlDialectInspection")
|
@SuppressWarnings("SqlDialectInspection")
|
||||||
public class SQLManager implements AbstractDB {
|
public class SQLManager implements AbstractDB {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + SQLManager.class.getSimpleName());
|
||||||
|
|
||||||
// Public final
|
// Public final
|
||||||
public final String SET_OWNER;
|
public final String SET_OWNER;
|
||||||
public final String GET_ALL_PLOTS;
|
public final String GET_ALL_PLOTS;
|
||||||
@ -355,11 +358,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
task.run();
|
task.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
PlotSquared.debug("============ DATABASE ERROR ============");
|
logger.error("[P2] ============ DATABASE ERROR ============");
|
||||||
PlotSquared.debug("There was an error updating the database.");
|
logger.error("[P2] ============ DATABASE ERROR ============");
|
||||||
PlotSquared.debug(" - It will be corrected on shutdown");
|
logger.error("[P2] There was an error updating the database.");
|
||||||
|
logger.error("[P2] - It will be corrected on shutdown");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("========================================");
|
logger.error("[P2] ========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commit();
|
commit();
|
||||||
@ -409,12 +413,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
lastTask = task;
|
lastTask = task;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
PlotSquared.debug("============ DATABASE ERROR ============");
|
logger.error("[P2] ============ DATABASE ERROR ============");
|
||||||
PlotSquared.debug("There was an error updating the database.");
|
logger.error("[P2] There was an error updating the database.");
|
||||||
PlotSquared.debug(" - It will be corrected on shutdown");
|
logger.error("[P2] - It will be corrected on shutdown");
|
||||||
PlotSquared.debug("========================================");
|
logger.error("[P2] ========================================");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("========================================");
|
logger.error("[P2] ========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (statement != null && task != null) {
|
if (statement != null && task != null) {
|
||||||
@ -454,12 +458,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
lastTask = task;
|
lastTask = task;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
PlotSquared.debug("============ DATABASE ERROR ============");
|
logger.error("[P2] ============ DATABASE ERROR ============");
|
||||||
PlotSquared.debug("There was an error updating the database.");
|
logger.error("[P2] There was an error updating the database.");
|
||||||
PlotSquared.debug(" - It will be corrected on shutdown");
|
logger.error("[P2] - It will be corrected on shutdown");
|
||||||
PlotSquared.debug("========================================");
|
logger.error("[P2] ========================================");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("========================================");
|
logger.error("[P2] ========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (statement != null && task != null) {
|
if (statement != null && task != null) {
|
||||||
@ -500,12 +504,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
lastTask = task;
|
lastTask = task;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
PlotSquared.debug("============ DATABASE ERROR ============");
|
logger.error("[P2] ============ DATABASE ERROR ============");
|
||||||
PlotSquared.debug("There was an error updating the database.");
|
logger.error("[P2] There was an error updating the database.");
|
||||||
PlotSquared.debug(" - It will be corrected on shutdown");
|
logger.error("[P2] - It will be corrected on shutdown");
|
||||||
PlotSquared.debug("========================================");
|
logger.error("[P2] ========================================");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("========================================");
|
logger.error("[P2] ========================================");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (statement != null && task != null) {
|
if (statement != null && task != null) {
|
||||||
@ -529,12 +533,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
this.plotTasks.clear();
|
this.plotTasks.clear();
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
PlotSquared.debug("============ DATABASE ERROR ============");
|
logger.error("[P2] ============ DATABASE ERROR ============");
|
||||||
PlotSquared.debug("There was an error updating the database.");
|
logger.error("[P2] There was an error updating the database.");
|
||||||
PlotSquared.debug(" - It will be corrected on shutdown");
|
logger.error("[P2] - It will be corrected on shutdown");
|
||||||
PlotSquared.debug("========================================");
|
logger.error("[P2] ========================================");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("========================================");
|
logger.error("[P2] ========================================");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -622,9 +626,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
})))));
|
})))));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
logger.warn("[P2] Failed to set all flags and member tiers for plots", e);
|
||||||
PlotSquared
|
|
||||||
.debug("&7[WARN] Failed to set all flags and member tiers for plots");
|
|
||||||
try {
|
try {
|
||||||
SQLManager.this.connection.commit();
|
SQLManager.this.connection.commit();
|
||||||
} catch (SQLException e1) {
|
} catch (SQLException e1) {
|
||||||
@ -633,8 +635,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.warn("[P2] Warning! Failed to set all helper for plots", e);
|
||||||
PlotSquared.debug("&7[WARN] Failed to set all helpers for plots");
|
|
||||||
try {
|
try {
|
||||||
SQLManager.this.connection.commit();
|
SQLManager.this.connection.commit();
|
||||||
} catch (SQLException e1) {
|
} catch (SQLException e1) {
|
||||||
@ -703,21 +704,19 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
preparedStatement.executeBatch();
|
preparedStatement.executeBatch();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated()
|
logger.error("[P2] Failed to store flag values for plot with entry ID: {}", plot);
|
||||||
+ "Failed to store flag values for plot with entry ID: " + plot.getId());
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PlotSquared.debug(Captions.PREFIX.getTranslated()
|
if (Settings.DEBUG) {
|
||||||
+ "- Finished converting flags for plot with entry ID: " + plot.getId());
|
logger.info("[P2] - Finished converting flag values for plot with entry ID: {}",
|
||||||
|
plot.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values:");
|
logger.error("[P2] Failed to store flag values", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
PlotSquared.log(
|
logger.info("[P2] Finished converting flags ({} plots processed)", plots.size());
|
||||||
Captions.PREFIX.getTranslated() + "Finished converting flags (" + plots.size()
|
|
||||||
+ " plots processed)");
|
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,8 +824,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
last = subList.size();
|
last = subList.size();
|
||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
}
|
}
|
||||||
PlotSquared.debug(
|
|
||||||
"&aBatch 1: " + count + " | " + objList.get(0).getClass().getCanonicalName());
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
preparedStmt.clearParameters();
|
preparedStmt.clearParameters();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
@ -836,8 +833,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
return;
|
return;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
if (this.mySQL) {
|
if (this.mySQL) {
|
||||||
|
logger.error("[P2] 1: | {}", objList.get(0).getClass().getCanonicalName());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("&cERROR 1: | " + objList.get(0).getClass().getCanonicalName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -869,26 +866,23 @@ public class SQLManager implements AbstractDB {
|
|||||||
last = subList.size();
|
last = subList.size();
|
||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
}
|
}
|
||||||
PlotSquared.debug(
|
|
||||||
"&aBatch 2: " + count + " | " + objList.get(0).getClass().getCanonicalName());
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
preparedStmt.clearParameters();
|
preparedStmt.clearParameters();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("&cERROR 2: | " + objList.get(0).getClass().getCanonicalName());
|
logger.error("[P2] 2: | {}", objList.get(0).getClass().getCanonicalName());
|
||||||
PlotSquared.debug("&6[WARN] Could not bulk save!");
|
logger.error("[P2] Could not bulk save!");
|
||||||
try (PreparedStatement preparedStmt = this.connection
|
try (PreparedStatement preparedStmt = this.connection
|
||||||
.prepareStatement(mod.getCreateSQL())) {
|
.prepareStatement(mod.getCreateSQL())) {
|
||||||
for (T obj : objList) {
|
for (T obj : objList) {
|
||||||
mod.setSQL(preparedStmt, obj);
|
mod.setSQL(preparedStmt, obj);
|
||||||
preparedStmt.addBatch();
|
preparedStmt.addBatch();
|
||||||
}
|
}
|
||||||
PlotSquared.debug("&aBatch 3");
|
|
||||||
preparedStmt.executeBatch();
|
preparedStmt.executeBatch();
|
||||||
} catch (SQLException e3) {
|
} catch (SQLException e3) {
|
||||||
|
logger.error("[P2] Failed to save all", e);
|
||||||
e3.printStackTrace();
|
e3.printStackTrace();
|
||||||
PlotSquared.debug("&c[ERROR] Failed to save all!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
@ -939,9 +933,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
preparedStatement.executeBatch();
|
preparedStatement.executeBatch();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated()
|
logger.error("[P2] Failed to store settings for plot with entry ID: {}", legacySettings.id);
|
||||||
+ "Failed to store settings values for plot with entry ID: "
|
|
||||||
+ legacySettings.id);
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -953,18 +945,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
preparedStatement.executeBatch();
|
preparedStatement.executeBatch();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared
|
logger.error("[P2] Failed to store settings", e);
|
||||||
.log(Captions.PREFIX.getTranslated() + "Failed to store settings values");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store settings values:");
|
logger.error("[P2] Failed to store settings", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
PlotSquared.log(
|
logger.info("[P2] Finished converting settihgs ({} plots processed)", myList.size());
|
||||||
Captions.PREFIX.getTranslated() + "Finished converting settings (" + myList.size()
|
|
||||||
+ " plots processed)");
|
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1143,7 +1130,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean addConstraint = create == tables.length;
|
boolean addConstraint = create == tables.length;
|
||||||
PlotSquared.debug("Creating tables");
|
|
||||||
try (Statement stmt = this.connection.createStatement()) {
|
try (Statement stmt = this.connection.createStatement()) {
|
||||||
if (this.mySQL) {
|
if (this.mySQL) {
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` ("
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot` ("
|
||||||
@ -1383,9 +1369,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
@Override public void delete(final Plot plot) {
|
@Override public void delete(final Plot plot) {
|
||||||
PlotSquared.debug(
|
|
||||||
"Deleting plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
|
|
||||||
+ plot.getOwnerAbs() + " Index: " + plot.temp);
|
|
||||||
deleteSettings(plot);
|
deleteSettings(plot);
|
||||||
deleteDenied(plot);
|
deleteDenied(plot);
|
||||||
deleteHelpers(plot);
|
deleteHelpers(plot);
|
||||||
@ -1411,9 +1394,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
@Override public void createPlotSettings(final int id, Plot plot) {
|
@Override public void createPlotSettings(final int id, Plot plot) {
|
||||||
PlotSquared.debug(
|
|
||||||
"Creating plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
|
|
||||||
+ plot.getOwnerAbs() + " Index: " + id);
|
|
||||||
addPlotTask(plot, new UniqueStatement("createPlotSettings") {
|
addPlotTask(plot, new UniqueStatement("createPlotSettings") {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setInt(1, id);
|
statement.setInt(1, id);
|
||||||
@ -1571,7 +1551,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
"SELECT plot_plot_id, user_uuid, COUNT(*) FROM " + this.prefix + table
|
"SELECT plot_plot_id, user_uuid, COUNT(*) FROM " + this.prefix + table
|
||||||
+ " GROUP BY plot_plot_id, user_uuid HAVING COUNT(*) > 1");
|
+ " GROUP BY plot_plot_id, user_uuid HAVING COUNT(*) > 1");
|
||||||
if (result.next()) {
|
if (result.next()) {
|
||||||
PlotSquared.debug("BACKING UP: " + this.prefix + table);
|
|
||||||
result.close();
|
result.close();
|
||||||
statement.executeUpdate(
|
statement.executeUpdate(
|
||||||
"CREATE TABLE " + this.prefix + table + "_tmp AS SELECT * FROM "
|
"CREATE TABLE " + this.prefix + table + "_tmp AS SELECT * FROM "
|
||||||
@ -1581,7 +1560,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
"CREATE TABLE " + this.prefix + table + " AS SELECT * FROM "
|
"CREATE TABLE " + this.prefix + table + " AS SELECT * FROM "
|
||||||
+ this.prefix + table + "_tmp");
|
+ this.prefix + table + "_tmp");
|
||||||
statement.executeUpdate("DROP TABLE " + this.prefix + table + "_tmp");
|
statement.executeUpdate("DROP TABLE " + this.prefix + table + "_tmp");
|
||||||
PlotSquared.debug("RESTORING: " + this.prefix + table);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e2) {
|
} catch (SQLException e2) {
|
||||||
@ -1645,40 +1623,20 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
String flag_str =
|
String flag_str =
|
||||||
split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
|
split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
|
||||||
/*PlotFlag<?, ?> flag = GlobalFlagContainer.getInstance().getFlagFromString(split[0]);
|
|
||||||
if (flag == null) {
|
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "Flag not found and therefore ignored: " + split[0]);
|
|
||||||
continue;
|
|
||||||
}*/
|
|
||||||
flagMap.get(id).put(split[0], flag_str);
|
flagMap.get(id).put(split[0], flag_str);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} /*else {
|
|
||||||
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
|
|
||||||
if (StringMan
|
|
||||||
.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
|
||||||
PlotFlag<?, ?> flag = GlobalFlagContainer.getInstance().getFlagFromString(element);
|
|
||||||
if (flag == null) {
|
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "Flag not found and therefore ignored: " + element);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "INVALID FLAG: " + element);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to load old flag values:");
|
logger.error("[P2] Failed to load old flag values", e);
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "Loaded " + flagMap.size()
|
logger.info("[P2] Loaded {} plot flag collections...", flagMap.size());
|
||||||
+ " plot flag collections...");
|
logger.info("[P2] Attempting to store these flags in the new table...");
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated()
|
|
||||||
+ "Attempting to store these flags in the new table...");
|
|
||||||
//
|
|
||||||
try (final PreparedStatement preparedStatement = this.connection.prepareStatement(
|
try (final PreparedStatement preparedStatement = this.connection.prepareStatement(
|
||||||
"INSERT INTO `" + SQLManager.this.prefix
|
"INSERT INTO `" + SQLManager.this.prefix
|
||||||
+ "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?)")) {
|
+ "plot_flags`(`plot_id`, `flag`, `value`) VALUES(?, ?, ?)")) {
|
||||||
@ -1706,9 +1664,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
preparedStatement.executeBatch();
|
preparedStatement.executeBatch();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated()
|
logger.error("[P2] Failed to store flag values for plot with entry ID: {}", plotFlagEntry.getKey());
|
||||||
+ "Failed to store flag values for plot with entry ID: " + plotFlagEntry
|
|
||||||
.getKey());
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1716,19 +1672,17 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (System.currentTimeMillis() - timeStarted >= 1000L || plotsProcessed >= flagMap
|
if (System.currentTimeMillis() - timeStarted >= 1000L || plotsProcessed >= flagMap
|
||||||
.size()) {
|
.size()) {
|
||||||
timeStarted = System.currentTimeMillis();
|
timeStarted = System.currentTimeMillis();
|
||||||
PlotSquared.log(
|
logger.info("[P2] ... Flag conversion in progress. {}% done",
|
||||||
Captions.PREFIX.getTranslated() + "... Flag conversion in progress. "
|
String.format("%.1f", ((float) flagsProcessed / totalFlags) * 100));
|
||||||
+ String.format("%.1f", ((float) flagsProcessed / totalFlags) * 100)
|
|
||||||
+ "% Done");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.debug(Captions.PREFIX.getTranslated()
|
if (Settings.DEBUG) {
|
||||||
+ "- Finished converting flags for plot with entry ID: " + plotFlagEntry
|
logger.info("[P2] - Finished converting flags for plot with entry ID: {}",
|
||||||
.getKey());
|
plotFlagEntry.getKey());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "Failed to store flag values:");
|
logger.error("[P2] Failed to store flag values", e);
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1820,9 +1774,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(parsable)
|
time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(parsable)
|
||||||
.getTime();
|
.getTime();
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
PlotSquared.debug(
|
logger.error("[P2] Could not parse date for plot: #{}({};{}) ({})",
|
||||||
"Could not parse date for plot: #" + id + "(" + areaID + ";"
|
id, areaID, plot_id, parsable);
|
||||||
+ plot_id + ") (" + parsable + ")");
|
|
||||||
time = System.currentTimeMillis() + id;
|
time = System.currentTimeMillis() + id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1835,10 +1788,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (last != null) {
|
if (last != null) {
|
||||||
if (Settings.Enabled_Components.DATABASE_PURGER) {
|
if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(last.temp);
|
toDelete.add(last.temp);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug(
|
logger.info("[P2] Plot #{}({}) in `{}plot` is a duplicate."
|
||||||
"&cPLOT #" + id + "(" + last + ") in `" + this.prefix
|
+ " Delete this plot or set `database-purger: true` in the settings.yml", id, last, this.prefix);
|
||||||
+ "plot` is a duplicate. Delete this plot or set `database-purger: true` in the settings.yml.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1868,10 +1820,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getSettings().getRatings().put(user, r.getInt("rating"));
|
plot.getSettings().getRatings().put(user, r.getInt("rating"));
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&cENTRY #" + id + "(" + plot
|
logger.info("[P2] Entry #{}({}) in `plot_rating` does not exist."
|
||||||
+ ") in `plot_rating` does not exist. Create this plot or set `database-purger: true` in the "
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
+ "settings.yml.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteRows(toDelete, this.prefix + "plot_rating", "plot_plot_id");
|
deleteRows(toDelete, this.prefix + "plot_rating", "plot_plot_id");
|
||||||
@ -1897,10 +1848,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getTrusted().add(user);
|
plot.getTrusted().add(user);
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&cENTRY #" + id + "(" + plot
|
logger.info("[P2] Entry #{}({}) in `plot_helpers` does not exist."
|
||||||
+ ") in `plot_helpers` does not exist. Create this plot or set `database-purger: true` in the settings"
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
+ ".yml.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteRows(toDelete, this.prefix + "plot_helpers", "plot_plot_id");
|
deleteRows(toDelete, this.prefix + "plot_helpers", "plot_plot_id");
|
||||||
@ -1925,10 +1875,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getMembers().add(user);
|
plot.getMembers().add(user);
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&cENTRY #" + id + "(" + plot
|
logger.info("[P2] Entry #{}({}) in `plot_trusted` does not exist."
|
||||||
+ ") in `plot_trusted` does not exist. Create this plot or set `database-purger: true` in the settings"
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
+ ".yml.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteRows(toDelete, this.prefix + "plot_trusted", "plot_plot_id");
|
deleteRows(toDelete, this.prefix + "plot_trusted", "plot_plot_id");
|
||||||
@ -1953,9 +1902,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getDenied().add(user);
|
plot.getDenied().add(user);
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&cENTRY " + id
|
logger.info("[P2] Entry #{}({}) in `plot_denied` does not exist."
|
||||||
+ " in `plot_denied` does not exist. Create this plot or set `database-purger: true` in the settings.yml.");
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteRows(toDelete, this.prefix + "plot_denied", "plot_plot_id");
|
deleteRows(toDelete, this.prefix + "plot_denied", "plot_plot_id");
|
||||||
@ -1976,19 +1925,15 @@ public class SQLManager implements AbstractDB {
|
|||||||
final PlotFlag<?, ?> plotFlag =
|
final PlotFlag<?, ?> plotFlag =
|
||||||
GlobalFlagContainer.getInstance().getFlagFromString(flag);
|
GlobalFlagContainer.getInstance().getFlagFromString(flag);
|
||||||
if (plotFlag == null) {
|
if (plotFlag == null) {
|
||||||
PlotSquared.debug("Adding unknown flag to plot with ID " + id);
|
|
||||||
plot.getFlagContainer().addUnknownFlag(flag, value);
|
plot.getFlagContainer().addUnknownFlag(flag, value);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
plot.getFlagContainer().addFlag(plotFlag.parse(value));
|
plot.getFlagContainer().addFlag(plotFlag.parse(value));
|
||||||
} catch (final FlagParseException e) {
|
} catch (final FlagParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared
|
logger.error("[P2] Plot with ID {} has an invalid value:", id);
|
||||||
.debug("Plot with ID " + id + " has an invalid value:");
|
logger.error("[P2] Failed to parse flag '{}', value '{}': {}",
|
||||||
PlotSquared.debug(Captions.FLAG_PARSE_ERROR.getTranslated()
|
plotFlag.getName(), e.getValue(), e.getErrorMessage());
|
||||||
.replace("%flag_name%", plotFlag.getName())
|
|
||||||
.replace("%flag_value%", e.getValue())
|
|
||||||
.replace("%error%", e.getErrorMessage()));
|
|
||||||
if (!invalidFlags.containsKey(plot)) {
|
if (!invalidFlags.containsKey(plot)) {
|
||||||
invalidFlags.put(plot, new ArrayList<>());
|
invalidFlags.put(plot, new ArrayList<>());
|
||||||
}
|
}
|
||||||
@ -1997,9 +1942,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&cPlot " + id
|
logger.info("[P2] Entry #{}({}) in `plot_flags` does not exist."
|
||||||
+ " in `plot_flags` does not exist. Create this plot or set `database-purger: true` in the settings.yml.");
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BlockTypeListFlag.skipCategoryVerification =
|
BlockTypeListFlag.skipCategoryVerification =
|
||||||
@ -2008,9 +1953,11 @@ public class SQLManager implements AbstractDB {
|
|||||||
for (final Map.Entry<Plot, Collection<PlotFlag<?, ?>>> plotFlagEntry : invalidFlags
|
for (final Map.Entry<Plot, Collection<PlotFlag<?, ?>>> plotFlagEntry : invalidFlags
|
||||||
.entrySet()) {
|
.entrySet()) {
|
||||||
for (final PlotFlag<?, ?> flag : plotFlagEntry.getValue()) {
|
for (final PlotFlag<?, ?> flag : plotFlagEntry.getValue()) {
|
||||||
PlotSquared.debug("&cPlot \"" + plotFlagEntry.getKey() + "\""
|
if (Settings.DEBUG) {
|
||||||
+ " had an invalid flag (" + flag.getName()
|
logger.info(
|
||||||
+ "). A fix has been attempted.");
|
"Plot {} has an invalid flag ({}). A fix has been attempted",
|
||||||
|
plotFlagEntry.getKey(), flag.getName());
|
||||||
|
}
|
||||||
removeFlag(plotFlagEntry.getKey(), flag);
|
removeFlag(plotFlagEntry.getKey(), flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2051,10 +1998,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
plot.getSettings().setMerged(merged);
|
plot.getSettings().setMerged(merged);
|
||||||
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
} else if (Settings.Enabled_Components.DATABASE_PURGER) {
|
||||||
toDelete.add(id);
|
toDelete.add(id);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&cENTRY #" + id + "(" + plot
|
logger.info("[P2] Entry #{}({}) in `plot_settings` does not exist."
|
||||||
+ ") in `plot_settings` does not exist. Create this plot or set `database-purger: true` in the settings"
|
+ " Create this plot or set `database-purger: true` in settings.yml", id, plot);
|
||||||
+ ".yml.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deleteRows(toDelete, this.prefix + "plot_settings", "plot_plot_id");
|
deleteRows(toDelete, this.prefix + "plot_settings", "plot_plot_id");
|
||||||
@ -2070,16 +2016,16 @@ public class SQLManager implements AbstractDB {
|
|||||||
for (Entry<String, AtomicInteger> entry : noExist.entrySet()) {
|
for (Entry<String, AtomicInteger> entry : noExist.entrySet()) {
|
||||||
String worldName = entry.getKey();
|
String worldName = entry.getKey();
|
||||||
invalidPlot = true;
|
invalidPlot = true;
|
||||||
PlotSquared.debug("&c[WARNING] Found " + entry.getValue().intValue()
|
if (Settings.DEBUG) {
|
||||||
+ " plots in DB for non existent world; '" + worldName + "'.");
|
logger.info("[P2] Warning! Found {} plots in DB for non existent world: '{}'",
|
||||||
|
entry.getValue().intValue(), worldName);
|
||||||
}
|
}
|
||||||
if (invalidPlot) {
|
}
|
||||||
PlotSquared.debug(
|
if (invalidPlot && Settings.DEBUG) {
|
||||||
"&c[WARNING] - Please create the world/s or remove the plots using the purge command");
|
logger.info("[P2] Warning! Please create the world(s) or remove the plots using the purge command");
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
PlotSquared.debug("&7[WARN] Failed to load plots.");
|
logger.error("[P2] Failed to load plots", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return newPlots;
|
return newPlots;
|
||||||
}
|
}
|
||||||
@ -2120,9 +2066,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
preparedStatement.setInt(3, id2);
|
preparedStatement.setInt(3, id2);
|
||||||
preparedStatement.execute();
|
preparedStatement.execute();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log(
|
logger.error("[P2] Failed to persist wap of {} and {}", plot1, plot2);
|
||||||
Captions.PREFIX.getTranslated() + "Failed to persist swap of " + plot1 + " and "
|
|
||||||
+ plot2 + "!");
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
future.complete(false);
|
future.complete(false);
|
||||||
return;
|
return;
|
||||||
@ -2220,8 +2164,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int last = -1;
|
int last = -1;
|
||||||
for (int j = 0; j <= amount; j++) {
|
for (int j = 0; j <= amount; j++) {
|
||||||
int purging = Math.max(j * packet, size);
|
|
||||||
PlotSquared.debug("Purging " + purging + " / " + size);
|
|
||||||
List<Integer> subList =
|
List<Integer> subList =
|
||||||
uniqueIdsList.subList(j * packet, Math.min(size, (j + 1) * packet));
|
uniqueIdsList.subList(j * packet, Math.min(size, (j + 1) * packet));
|
||||||
if (subList.isEmpty()) {
|
if (subList.isEmpty()) {
|
||||||
@ -2267,12 +2209,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
commit();
|
commit();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
logger.error("[P2] Failed to purge plots", e);
|
||||||
PlotSquared.debug("&c[ERROR] FAILED TO PURGE PLOTS!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.debug("&6[INFO] SUCCESSFULLY PURGED " + uniqueIds.size() + " PLOTS!");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] Successfully purged {} plots", uniqueIds.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2295,8 +2238,8 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
purgeIds(ids);
|
purgeIds(ids);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
logger.error("[P2] Failed to purge area '{}'", area);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("&c[ERROR] FAILED TO PURGE AREA '" + area + "'!");
|
|
||||||
}
|
}
|
||||||
for (Iterator<PlotId> iterator = plots.iterator(); iterator.hasNext(); ) {
|
for (Iterator<PlotId> iterator = plots.iterator(); iterator.hasNext(); ) {
|
||||||
PlotId plotId = iterator.next();
|
PlotId plotId = iterator.next();
|
||||||
@ -2552,8 +2495,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
PlotSquared
|
logger.error("[P2] Failed to fetch rating for plot {}", plot.getId().toString());
|
||||||
.debug("&7[WARN] Failed to fetch rating for plot " + plot.getId().toString());
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
@ -2773,9 +2715,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
cluster = clusters.get(id);
|
cluster = clusters.get(id);
|
||||||
if (cluster != null) {
|
if (cluster != null) {
|
||||||
cluster.helpers.add(user);
|
cluster.helpers.add(user);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&cCluster #" + id + "(" + cluster
|
logger.warn("[P2] Cluster #{}({}) in cluster_helpers does not exist."
|
||||||
+ ") in cluster_helpers does not exist. Please create the cluster or remove this entry.");
|
+ " Please create the cluster or remove this entry", id, cluster);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Getting invited
|
// Getting invited
|
||||||
@ -2792,9 +2734,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
cluster = clusters.get(id);
|
cluster = clusters.get(id);
|
||||||
if (cluster != null) {
|
if (cluster != null) {
|
||||||
cluster.invited.add(user);
|
cluster.invited.add(user);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&cCluster #" + id + "(" + cluster
|
logger.warn("[P2] Cluster #{}({}) in cluster_helpers does not exist."
|
||||||
+ ") in cluster_invited does not exist. Please create the cluster or remove this entry.");
|
+ " Please create the cluster or remove this entry", id, cluster);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultSet =
|
resultSet =
|
||||||
@ -2827,9 +2769,9 @@ public class SQLManager implements AbstractDB {
|
|||||||
merged[3 - i] = (m & 1 << i) != 0;
|
merged[3 - i] = (m & 1 << i) != 0;
|
||||||
}
|
}
|
||||||
cluster.settings.setMerged(merged);
|
cluster.settings.setMerged(merged);
|
||||||
} else {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.debug("&cCluster #" + id + "(" + cluster
|
logger.warn("[P2] Cluster #{}({}) in cluster_helpers does not exist."
|
||||||
+ ") in cluster_settings does not exist. Please create the cluster or remove this entry.");
|
+ " Please create the cluster or remove this entry", id, cluster);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
@ -2838,16 +2780,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
||||||
String a = entry.getKey();
|
String a = entry.getKey();
|
||||||
invalidPlot = true;
|
invalidPlot = true;
|
||||||
PlotSquared.debug("&c[WARNING] Found " + noExist.get(a)
|
logger.warn("[P2] Warning! Found {} clusters in DB for non existent area; '{}'", noExist.get(a), a);
|
||||||
+ " clusters in DB for non existent area; '" + a + "'.");
|
|
||||||
}
|
}
|
||||||
if (invalidPlot) {
|
if (invalidPlot) {
|
||||||
PlotSquared.debug(
|
logger.warn("[P2] Warning! Please create the world(s) or remove the clusters using the purge command");
|
||||||
"&c[WARNING] - Please create the world/s or remove the clusters using the purge command");
|
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
PlotSquared.debug("&7[WARN] Failed to load clusters.");
|
logger.error("[P2] Failed to load clusters", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return newClusters;
|
return newClusters;
|
||||||
}
|
}
|
||||||
@ -3039,8 +2978,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (!isValid()) {
|
if (!isValid()) {
|
||||||
reconnect();
|
reconnect();
|
||||||
}
|
}
|
||||||
PlotSquared.debug(
|
logger.info("[P2] All DB transactions during this session are being validated (This may take a while if corrections need to be made)");
|
||||||
"$1All DB transactions during this session are being validated (This may take a while if corrections need to be made)");
|
|
||||||
commit();
|
commit();
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!sendBatch()) {
|
if (!sendBatch()) {
|
||||||
@ -3061,31 +2999,27 @@ public class SQLManager implements AbstractDB {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (plot.getArea() == null) {
|
if (plot.getArea() == null) {
|
||||||
PlotSquared.debug("CRITICAL ERROR IN VALIDATION TASK!");
|
logger.error("[P2] CRITICAL ERROR IN VALIDATION TASK!");
|
||||||
PlotSquared.debug("PLOT AREA CANNOT BE NULL! SKIPPING PLOT!");
|
logger.error("[P2] PLOT AREA CANNOT BE NULL! SKIPPING PLOT!");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (database == null) {
|
if (database == null) {
|
||||||
PlotSquared.debug("CRITICAL ERROR IN VALIDATION TASK!");
|
logger.error("[P2] CRITICAL ERROR IN VALIDATION TASK!");
|
||||||
PlotSquared.debug("DATABASE VARIABLE CANNOT BE NULL! NOW ENDING VALIDATION!!");
|
logger.error("[P2] DATABASE VARIABLE CANNOT BE NULL! NOW ENDING VALIDATION!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
HashMap<PlotId, Plot> worldPlots = database.get(plot.getArea().toString());
|
HashMap<PlotId, Plot> worldPlots = database.get(plot.getArea().toString());
|
||||||
if (worldPlots == null) {
|
if (worldPlots == null) {
|
||||||
PlotSquared.debug("&8 - &7Creating plot (1): " + plot);
|
|
||||||
toCreate.add(plot);
|
toCreate.add(plot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Plot dataPlot = worldPlots.remove(plot.getId());
|
Plot dataPlot = worldPlots.remove(plot.getId());
|
||||||
if (dataPlot == null) {
|
if (dataPlot == null) {
|
||||||
PlotSquared.debug("&8 - &7Creating plot (2): " + plot);
|
|
||||||
toCreate.add(plot);
|
toCreate.add(plot);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// owner
|
// owner
|
||||||
if (!plot.getOwnerAbs().equals(dataPlot.getOwnerAbs())) {
|
if (!plot.getOwnerAbs().equals(dataPlot.getOwnerAbs())) {
|
||||||
PlotSquared.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil
|
|
||||||
.getName(plot.getOwnerAbs()));
|
|
||||||
setOwner(plot, plot.getOwnerAbs());
|
setOwner(plot, plot.getOwnerAbs());
|
||||||
}
|
}
|
||||||
// trusted
|
// trusted
|
||||||
@ -3094,9 +3028,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getTrusted().clone();
|
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getTrusted().clone();
|
||||||
toRemove.removeAll(plot.getTrusted());
|
toRemove.removeAll(plot.getTrusted());
|
||||||
toAdd.removeAll(dataPlot.getTrusted());
|
toAdd.removeAll(dataPlot.getTrusted());
|
||||||
PlotSquared.debug(
|
|
||||||
"&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " trusted for: "
|
|
||||||
+ plot);
|
|
||||||
if (!toRemove.isEmpty()) {
|
if (!toRemove.isEmpty()) {
|
||||||
for (UUID uuid : toRemove) {
|
for (UUID uuid : toRemove) {
|
||||||
removeTrusted(plot, uuid);
|
removeTrusted(plot, uuid);
|
||||||
@ -3113,9 +3044,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getMembers().clone();
|
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getMembers().clone();
|
||||||
toRemove.removeAll(plot.getMembers());
|
toRemove.removeAll(plot.getMembers());
|
||||||
toAdd.removeAll(dataPlot.getMembers());
|
toAdd.removeAll(dataPlot.getMembers());
|
||||||
PlotSquared.debug(
|
|
||||||
"&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " members for: "
|
|
||||||
+ plot);
|
|
||||||
if (!toRemove.isEmpty()) {
|
if (!toRemove.isEmpty()) {
|
||||||
for (UUID uuid : toRemove) {
|
for (UUID uuid : toRemove) {
|
||||||
removeMember(plot, uuid);
|
removeMember(plot, uuid);
|
||||||
@ -3132,9 +3060,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getDenied().clone();
|
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getDenied().clone();
|
||||||
toRemove.removeAll(plot.getDenied());
|
toRemove.removeAll(plot.getDenied());
|
||||||
toAdd.removeAll(dataPlot.getDenied());
|
toAdd.removeAll(dataPlot.getDenied());
|
||||||
PlotSquared.debug(
|
|
||||||
"&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " denied for: "
|
|
||||||
+ plot);
|
|
||||||
if (!toRemove.isEmpty()) {
|
if (!toRemove.isEmpty()) {
|
||||||
for (UUID uuid : toRemove) {
|
for (UUID uuid : toRemove) {
|
||||||
removeDenied(plot, uuid);
|
removeDenied(plot, uuid);
|
||||||
@ -3149,7 +3074,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
boolean[] pm = plot.getMerged();
|
boolean[] pm = plot.getMerged();
|
||||||
boolean[] dm = dataPlot.getMerged();
|
boolean[] dm = dataPlot.getMerged();
|
||||||
if (pm[0] != dm[0] || pm[1] != dm[1]) {
|
if (pm[0] != dm[0] || pm[1] != dm[1]) {
|
||||||
PlotSquared.debug(" - Correcting merge for: " + plot);
|
|
||||||
setMerged(dataPlot, plot.getMerged());
|
setMerged(dataPlot, plot.getMerged());
|
||||||
}
|
}
|
||||||
Set<PlotFlag<?, ?>> pf = plot.getFlags();
|
Set<PlotFlag<?, ?>> pf = plot.getFlags();
|
||||||
@ -3157,7 +3081,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (!pf.isEmpty() && !df.isEmpty()) {
|
if (!pf.isEmpty() && !df.isEmpty()) {
|
||||||
if (pf.size() != df.size() || !StringMan
|
if (pf.size() != df.size() || !StringMan
|
||||||
.isEqual(StringMan.joinOrdered(pf, ","), StringMan.joinOrdered(df, ","))) {
|
.isEqual(StringMan.joinOrdered(pf, ","), StringMan.joinOrdered(df, ","))) {
|
||||||
PlotSquared.debug(" - Correcting flags for: " + plot);
|
|
||||||
// setFlags(plot, pf);
|
// setFlags(plot, pf);
|
||||||
// TODO: Re-implement
|
// TODO: Re-implement
|
||||||
}
|
}
|
||||||
@ -3168,8 +3091,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
HashMap<PlotId, Plot> map = entry.getValue();
|
HashMap<PlotId, Plot> map = entry.getValue();
|
||||||
if (!map.isEmpty()) {
|
if (!map.isEmpty()) {
|
||||||
for (Entry<PlotId, Plot> entry2 : map.entrySet()) {
|
for (Entry<PlotId, Plot> entry2 : map.entrySet()) {
|
||||||
PlotSquared.debug("$1Plot was deleted: " + entry2.getValue().toString()
|
// TODO implement this when sure safe"
|
||||||
+ "// TODO implement this when sure safe");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
package com.plotsquared.core.database;
|
package com.plotsquared.core.database;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -40,6 +42,8 @@ import java.sql.Statement;
|
|||||||
*/
|
*/
|
||||||
public class SQLite extends Database {
|
public class SQLite extends Database {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + SQLite.class.getSimpleName());
|
||||||
|
|
||||||
private final String dbLocation;
|
private final String dbLocation;
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
@ -64,7 +68,7 @@ public class SQLite extends Database {
|
|||||||
try {
|
try {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
PlotSquared.debug("&cUnable to create database!");
|
logger.error("[P2] Unable to create database");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
@ -52,6 +51,8 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -60,7 +61,8 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class HybridPlotWorld extends ClassicPlotWorld {
|
public class HybridPlotWorld extends ClassicPlotWorld {
|
||||||
|
|
||||||
private static AffineTransform transform = new AffineTransform().rotateY(90);
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + HybridPlotWorld.class.getSimpleName());
|
||||||
|
private static final AffineTransform transform = new AffineTransform().rotateY(90);
|
||||||
public boolean ROAD_SCHEMATIC_ENABLED;
|
public boolean ROAD_SCHEMATIC_ENABLED;
|
||||||
public boolean PLOT_SCHEMATIC = false;
|
public boolean PLOT_SCHEMATIC = false;
|
||||||
public int PLOT_SCHEMATIC_HEIGHT = -1;
|
public int PLOT_SCHEMATIC_HEIGHT = -1;
|
||||||
@ -160,13 +162,11 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
setupSchematics();
|
setupSchematics();
|
||||||
} catch (Exception event) {
|
} catch (Exception event) {
|
||||||
event.printStackTrace();
|
event.printStackTrace();
|
||||||
PlotSquared.debug("&c - road schematics are disabled for this world.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump world settings
|
// Dump world settings
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
PlotSquared.debug(String.format("- Dumping settings for ClassicPlotWorld with name %s",
|
logger.info("[P2] - Dumping settings for ClassicPlotWorld with name {}", this.getWorldName());
|
||||||
this.getWorldName()));
|
|
||||||
final Field[] fields = this.getClass().getFields();
|
final Field[] fields = this.getClass().getFields();
|
||||||
for (final Field field : fields) {
|
for (final Field field : fields) {
|
||||||
final String name = field.getName().toLowerCase(Locale.ENGLISH);
|
final String name = field.getName().toLowerCase(Locale.ENGLISH);
|
||||||
@ -182,7 +182,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
} catch (final IllegalAccessException e) {
|
} catch (final IllegalAccessException e) {
|
||||||
value = String.format("Failed to parse: %s", e.getMessage());
|
value = String.format("Failed to parse: %s", e.getMessage());
|
||||||
}
|
}
|
||||||
PlotSquared.debug(String.format("-- %s = %s", name, value));
|
logger.info("[P2] -- {} = {}", name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,10 +282,14 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.debug(Captions.PREFIX + "&3 - plot schematic: &7" + schematic3File.getPath());
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - plot schematic: {}", schematic3File.getPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (schematic1 == null || schematic2 == null || this.ROAD_WIDTH == 0) {
|
if (schematic1 == null || schematic2 == null || this.ROAD_WIDTH == 0) {
|
||||||
PlotSquared.debug(Captions.PREFIX + "&3 - schematic: &7false");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - schematic: false");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.ROAD_SCHEMATIC_ENABLED = true;
|
this.ROAD_SCHEMATIC_ENABLED = true;
|
||||||
@ -361,7 +365,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
int pair = MathMan.pair(x, z);
|
int pair = MathMan.pair(x, z);
|
||||||
BaseBlock[] existing = this.G_SCH.computeIfAbsent(pair, k -> new BaseBlock[height]);
|
BaseBlock[] existing = this.G_SCH.computeIfAbsent(pair, k -> new BaseBlock[height]);
|
||||||
if (y >= height) {
|
if (y >= height) {
|
||||||
PlotSquared.log("Error adding overlay block. `y > height` ");
|
logger.error("[P2] Error adding overlay block. `y > height`");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
existing[y] = id;
|
existing[y] = id;
|
||||||
|
@ -61,6 +61,8 @@ 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.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
@ -76,6 +78,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
public abstract class HybridUtils {
|
public abstract class HybridUtils {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + HybridUtils.class.getSimpleName());
|
||||||
|
|
||||||
public static HybridUtils manager;
|
public static HybridUtils manager;
|
||||||
public static Set<BlockVector2> regions;
|
public static Set<BlockVector2> regions;
|
||||||
public static int height;
|
public static int height;
|
||||||
@ -413,24 +417,25 @@ public abstract class HybridUtils {
|
|||||||
BlockVector2 chunk = iter.next();
|
BlockVector2 chunk = iter.next();
|
||||||
iter.remove();
|
iter.remove();
|
||||||
boolean regenedRoad = regenerateRoad(area, chunk, extend);
|
boolean regenedRoad = regenerateRoad(area, chunk, extend);
|
||||||
if (!regenedRoad) {
|
if (!regenedRoad && Settings.DEBUG) {
|
||||||
PlotSquared.debug("Failed to regenerate roads.");
|
logger.info("[P2] Failed to regenerate roads");
|
||||||
}
|
}
|
||||||
ChunkManager.manager.unloadChunk(area.getWorldName(), chunk, true);
|
ChunkManager.manager.unloadChunk(area.getWorldName(), chunk, true);
|
||||||
}
|
}
|
||||||
PlotSquared.debug("Cancelled road task");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] Cancelled road task");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
if (count.intValue() % 20 == 0) {
|
if (count.intValue() % 20 == 0) {
|
||||||
PlotSquared.debug("PROGRESS: " + 100 * (2048 - chunks.size()) / 2048 + "%");
|
logger.info("[P2] Progress: {}%", 100 * (2048 - chunks.size()) / 2048);
|
||||||
}
|
}
|
||||||
if (HybridUtils.regions.isEmpty() && chunks.isEmpty()) {
|
if (HybridUtils.regions.isEmpty() && chunks.isEmpty()) {
|
||||||
PlotSquared.debug("Regenerating plot walls");
|
|
||||||
regeneratePlotWalls(area);
|
regeneratePlotWalls(area);
|
||||||
|
|
||||||
HybridUtils.UPDATE = false;
|
HybridUtils.UPDATE = false;
|
||||||
PlotSquared.log("Finished road conversion");
|
logger.info("[P2] Finished road conversion");
|
||||||
// CANCEL TASK
|
// CANCEL TASK
|
||||||
} else {
|
} else {
|
||||||
final Runnable task = this;
|
final Runnable task = this;
|
||||||
@ -442,11 +447,11 @@ public abstract class HybridUtils {
|
|||||||
HybridUtils.regions.iterator();
|
HybridUtils.regions.iterator();
|
||||||
BlockVector2 loc = iterator.next();
|
BlockVector2 loc = iterator.next();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
PlotSquared.debug(
|
if (Settings.DEBUG) {
|
||||||
"Updating .mcr: " + loc.getX() + ", " + loc.getZ()
|
logger.info("[P2] Updating .mcr: {}, {} (approx 1024 chunks)",
|
||||||
+ " (approx 1024 chunks)");
|
loc.getX(), loc.getZ());
|
||||||
PlotSquared
|
logger.info("[P2] - Remaining: {}", HybridUtils.regions.size());
|
||||||
.debug(" - Remaining: " + HybridUtils.regions.size());
|
}
|
||||||
chunks.addAll(getChunks(loc));
|
chunks.addAll(getChunks(loc));
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
@ -462,8 +467,8 @@ public abstract class HybridUtils {
|
|||||||
iterator.remove();
|
iterator.remove();
|
||||||
boolean regenedRoads =
|
boolean regenedRoads =
|
||||||
regenerateRoad(area, chunk, extend);
|
regenerateRoad(area, chunk, extend);
|
||||||
if (!regenedRoads) {
|
if (!regenedRoads && Settings.DEBUG) {
|
||||||
PlotSquared.debug("Failed to regenerate road.");
|
logger.info("[P2] Failed to regenerate road");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -474,9 +479,8 @@ public abstract class HybridUtils {
|
|||||||
Iterator<BlockVector2> iterator = HybridUtils.regions.iterator();
|
Iterator<BlockVector2> iterator = HybridUtils.regions.iterator();
|
||||||
BlockVector2 loc = iterator.next();
|
BlockVector2 loc = iterator.next();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
PlotSquared.debug(
|
logger.error("[P2] Error! Could not update '{}/region/r.{}.{}.mca' (Corrupt chunk?)",
|
||||||
"[ERROR] Could not update '" + area.getWorldName() + "/region/r."
|
area.getWorldHash(), loc.getX(), loc.getZ());
|
||||||
+ loc.getX() + "." + loc.getZ() + ".mca' (Corrupt chunk?)");
|
|
||||||
int sx = loc.getX() << 5;
|
int sx = loc.getX() << 5;
|
||||||
int sz = loc.getZ() << 5;
|
int sz = loc.getZ() << 5;
|
||||||
for (int x = sx; x < sx + 32; x++) {
|
for (int x = sx; x < sx + 32; x++) {
|
||||||
@ -486,8 +490,6 @@ public abstract class HybridUtils {
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.debug(" - Potentially skipping 1024 chunks");
|
|
||||||
PlotSquared.debug(" - TODO: recommend chunkster if corrupt");
|
|
||||||
}
|
}
|
||||||
GlobalBlockQueue.IMP.addEmptyTask(() -> TaskManager.runTaskLater(task, 20));
|
GlobalBlockQueue.IMP.addEmptyTask(() -> TaskManager.runTaskLater(task, 20));
|
||||||
});
|
});
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.location.Direction;
|
import com.plotsquared.core.location.Direction;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.Plot;
|
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.MainUtil;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
import com.plotsquared.core.util.RegionManager;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
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.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -44,6 +44,8 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public abstract class SquarePlotManager extends GridPlotManager {
|
public abstract class SquarePlotManager extends GridPlotManager {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + SquarePlotManager.class.getSimpleName());
|
||||||
|
|
||||||
private final SquarePlotWorld squarePlotWorld;
|
private final SquarePlotWorld squarePlotWorld;
|
||||||
|
|
||||||
public SquarePlotManager(SquarePlotWorld squarePlotWorld) {
|
public SquarePlotManager(SquarePlotWorld squarePlotWorld) {
|
||||||
@ -226,10 +228,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
// northwest
|
// northwest
|
||||||
return plot.getMerged(Direction.NORTHWEST) ? id : null;
|
return plot.getMerged(Direction.NORTHWEST) ? id : null;
|
||||||
}
|
}
|
||||||
PlotSquared.debug("invalid location: " + Arrays.toString(merged));
|
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
PlotSquared.debug(
|
logger.error( "Invalid plot / road width in settings.yml for world: {}", squarePlotWorld
|
||||||
"Invalid plot / road width in settings.yml for world: " + squarePlotWorld
|
|
||||||
.getWorldName());
|
.getWorldName());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -25,13 +25,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public abstract class SquarePlotWorld extends GridPlotWorld {
|
public abstract class SquarePlotWorld extends GridPlotWorld {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + SquarePlotWorld.class.getSimpleName());
|
||||||
|
|
||||||
public int PLOT_WIDTH = 42;
|
public int PLOT_WIDTH = 42;
|
||||||
public int ROAD_WIDTH = 7;
|
public int ROAD_WIDTH = 7;
|
||||||
public int ROAD_OFFSET_X = 0;
|
public int ROAD_OFFSET_X = 0;
|
||||||
@ -44,7 +48,10 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
|
|||||||
|
|
||||||
@Override public void loadConfiguration(ConfigurationSection config) {
|
@Override public void loadConfiguration(ConfigurationSection config) {
|
||||||
if (!config.contains("plot.height")) {
|
if (!config.contains("plot.height")) {
|
||||||
PlotSquared.debug(" - &cConfiguration is null? (" + config.getCurrentPath() + ')');
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - Configuration is null? ({})", config.getCurrentPath());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
this.PLOT_WIDTH = config.getInt("plot.size");
|
this.PLOT_WIDTH = config.getInt("plot.size");
|
||||||
this.ROAD_WIDTH = config.getInt("road.width");
|
this.ROAD_WIDTH = config.getInt("road.width");
|
||||||
|
@ -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("P2/" + ProcessedWEExtent.class.getSimpleName());
|
||||||
|
|
||||||
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,6 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
tileEntityCount[0]++;
|
tileEntityCount[0]++;
|
||||||
PlotSquared.debug(Captions.PREFIX + "&cDetected unsafe WorldEdit: " + location.getX() + ","
|
|
||||||
+ 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 +133,6 @@ 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(
|
|
||||||
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())) {
|
||||||
|
@ -38,11 +38,14 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
|
|||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ConsolePlayer extends PlotPlayer<Actor> {
|
public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + ConsolePlayer.class.getSimpleName());
|
||||||
private static ConsolePlayer instance;
|
private static ConsolePlayer instance;
|
||||||
|
|
||||||
private ConsolePlayer() {
|
private ConsolePlayer() {
|
||||||
@ -108,7 +111,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void sendMessage(String message) {
|
@Override public void sendMessage(String message) {
|
||||||
PlotSquared.log(message);
|
logger.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void teleport(Location location, TeleportCause cause) {
|
@Override public void teleport(Location location, TeleportCause cause) {
|
||||||
|
@ -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("P2/" + PlotPlayer.class.getSimpleName());
|
||||||
|
|
||||||
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,9 @@ 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
|
if (Settings.DEBUG) {
|
||||||
.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned",
|
logger.info("[P2] Plot {} was deleted + cleared due to {} 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("P2/" + Plot.class.getSimpleName());
|
||||||
|
|
||||||
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,6 @@ 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
|
|
||||||
.format("Player %s attempted to claim plot %s, 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 +1745,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.error("[P2] 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 {
|
||||||
@ -1834,9 +1834,8 @@ public class Plot {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String
|
logger.info("[P2] Failed to add plot {} to plot area {}",
|
||||||
.format("Failed to add plot %s to plot area %s", this.getId().toCommaSeparatedString(),
|
this.getId().toCommaSeparatedString(), this.area.toString());
|
||||||
this.area.toString()));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1934,12 +1933,10 @@ 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)");
|
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
PlotSquared.debug(plot + " is unowned (multi)");
|
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2647,7 +2644,6 @@ 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);
|
|
||||||
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());
|
||||||
@ -2664,7 +2660,6 @@ 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);
|
|
||||||
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());
|
||||||
@ -2681,7 +2676,6 @@ 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);
|
|
||||||
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());
|
||||||
@ -2697,7 +2691,6 @@ 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);
|
|
||||||
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());
|
||||||
@ -2712,10 +2705,6 @@ public class Plot {
|
|||||||
Plot current;
|
Plot current;
|
||||||
while ((current = frontier.poll()) != null) {
|
while ((current = frontier.poll()) != null) {
|
||||||
if (!current.hasOwner() || current.settings == null) {
|
if (!current.hasOwner() || current.settings == null) {
|
||||||
// Invalid plot
|
|
||||||
// merged onto unclaimed plot
|
|
||||||
PlotSquared.debug(
|
|
||||||
"Ignoring invalid merged plot: " + current + " | " + current.getOwnerAbs());
|
|
||||||
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("P2/" + PlotArea.class.getSimpleName());
|
||||||
|
|
||||||
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;
|
||||||
@ -369,7 +373,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");
|
||||||
@ -405,7 +408,8 @@ public abstract class PlotArea {
|
|||||||
prefix = ", ";
|
prefix = ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.log(Captions.PREFIX + "&3 - road flags: &7" + roadFlagBuilder.toString());
|
|
||||||
|
logger.info("[P2] - road flags: {}", roadFlagBuilder.toString());
|
||||||
|
|
||||||
loadConfiguration(config);
|
loadConfiguration(config);
|
||||||
}
|
}
|
||||||
@ -1101,10 +1105,12 @@ 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.warn("[P2] Failed to parse default flag with key '{}' and value '{}'. "
|
||||||
"§cFailed to parse default flag with key §6'%s'§c and value: §6'%s'§c."
|
+ "Reason: {}. This flag will not be added as a default flag.",
|
||||||
+ " Reason: %s. This flag will not be added as a default flag.",
|
e.getFlag().getName(),
|
||||||
e.getFlag().getName(), e.getValue(), e.getErrorMessage()));
|
e.getValue(),
|
||||||
|
e.getErrorMessage());
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot;
|
package com.plotsquared.core.plot;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.util.InventoryUtil;
|
import com.plotsquared.core.util.InventoryUtil;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class PlotInventory {
|
public class PlotInventory {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotInventory.class.getSimpleName());
|
||||||
|
|
||||||
private static final String META_KEY = "inventory";
|
private static final String META_KEY = "inventory";
|
||||||
public final PlotPlayer<?> player;
|
public final PlotPlayer<?> player;
|
||||||
public final int size;
|
public final int size;
|
||||||
@ -78,10 +81,7 @@ public class PlotInventory {
|
|||||||
if (this.title == null) {
|
if (this.title == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasPlotInventoryOpen(player)) {
|
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()));
|
|
||||||
} else {
|
|
||||||
this.open = true;
|
this.open = true;
|
||||||
setPlotInventoryOpen(player, this);
|
setPlotInventoryOpen(player, this);
|
||||||
InventoryUtil.manager.open(this);
|
InventoryUtil.manager.open(this);
|
||||||
|
@ -43,10 +43,11 @@ import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.KeepFlag;
|
import com.plotsquared.core.plot.flag.implementations.KeepFlag;
|
||||||
import com.plotsquared.core.plot.message.PlotMessage;
|
import com.plotsquared.core.plot.message.PlotMessage;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.StringMan;
|
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -55,13 +56,14 @@ import java.util.Collections;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
|
|
||||||
public class ExpireManager {
|
public class ExpireManager {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger("P2/" + ExpireManager.class);
|
||||||
|
|
||||||
public static ExpireManager IMP;
|
public static ExpireManager IMP;
|
||||||
private final ConcurrentHashMap<UUID, Long> dates_cache;
|
private final ConcurrentHashMap<UUID, Long> dates_cache;
|
||||||
private final ConcurrentHashMap<UUID, Long> account_age_cache;
|
private final ConcurrentHashMap<UUID, Long> account_age_cache;
|
||||||
@ -79,7 +81,6 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addTask(ExpiryTask task) {
|
public void addTask(ExpiryTask task) {
|
||||||
PlotSquared.debug("Adding new expiry task!");
|
|
||||||
this.tasks.add(task);
|
this.tasks.add(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,21 +421,7 @@ public class ExpireManager {
|
|||||||
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
|
MainUtil.sendMessage(player, Captions.PLOT_REMOVED_USER, plot.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Set<Plot> plots = plot.getConnectedPlots();
|
|
||||||
plot.deletePlot(whenDone);
|
plot.deletePlot(whenDone);
|
||||||
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());
|
|
||||||
if (plot.hasOwner()) {
|
|
||||||
PlotSquared.debug("$4 - Owner: " + plot.getOwner());
|
|
||||||
} else {
|
|
||||||
PlotSquared.debug("$4 - Owner: Unowned");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getAge(UUID uuid) {
|
public long getAge(UUID uuid) {
|
||||||
|
@ -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("P2/" + PlotAnalysis.class.getSimpleName());
|
||||||
|
|
||||||
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,26 @@ 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!");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] Calibration task already in progress!");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (threshold <= 0 || threshold >= 1) {
|
if (threshold <= 0 || threshold >= 1) {
|
||||||
PlotSquared.debug(
|
if (Settings.DEBUG) {
|
||||||
"Invalid threshold provided! (Cannot be 0 or 100 as then there's no point calibrating)");
|
logger.info(
|
||||||
|
"Invalid threshold provided! (Cannot be 0 or 100 as then there's no point in calibrating)");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
running = true;
|
running = true;
|
||||||
PlotSquared.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(
|
if (Settings.DEBUG) {
|
||||||
" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
logger.info("[P2] - Reducing {} plots to those with sufficient data", plots.size());
|
||||||
|
}
|
||||||
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 +125,12 @@ public class PlotAnalysis {
|
|||||||
plot.addRunning();
|
plot.addRunning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.debug(" - | Reduced to " + plots.size() + " plots");
|
|
||||||
|
|
||||||
if (plots.size() < 3) {
|
if (plots.size() < 3) {
|
||||||
PlotSquared.debug(
|
if (Settings.DEBUG) {
|
||||||
|
logger.info(
|
||||||
"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 +138,9 @@ public class PlotAnalysis {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.debug(" - $1Analyzing plot contents (this may take a while)");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - 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 +166,9 @@ 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]);
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] | {} (rating) {}", plot, ratings[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -166,7 +180,9 @@ public class PlotAnalysis {
|
|||||||
if (queuePlot == null) {
|
if (queuePlot == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PlotSquared.debug(" | " + queuePlot);
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] | {}", 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 +212,25 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.debug(
|
if (Settings.DEBUG) {
|
||||||
" - $1Waiting on plot rating thread: " + mi.intValue() * 100 / plots.size()
|
logger.info("[P2] - Waiting 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
|
if (Settings.DEBUG) {
|
||||||
.debug(" - $1Processing and grouping single plot analysis for bulk processing");
|
logger.info(
|
||||||
|
" - Processing 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);
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] | {}", plot);
|
||||||
|
}
|
||||||
PlotAnalysis analysis = plot.getComplexity(null);
|
PlotAnalysis analysis = plot.getComplexity(null);
|
||||||
|
|
||||||
changes[i] = analysis.changes;
|
changes[i] = analysis.changes;
|
||||||
@ -225,18 +246,22 @@ public class PlotAnalysis {
|
|||||||
variety_sd[i] = analysis.variety_sd;
|
variety_sd[i] = analysis.variety_sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotSquared.debug(" - $1Calculating rankings");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - 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: ");
|
if (Settings.DEBUG) {
|
||||||
PlotSquared.debug(
|
logger.info("[P2] - Calculating rank correlation: ");
|
||||||
|
logger.info(
|
||||||
" - 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");
|
||||||
PlotSquared.debug(
|
logger.info(
|
||||||
" - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing");
|
" - 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 +273,10 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | changes {}", factorChanges);
|
||||||
|
}
|
||||||
|
|
||||||
int[] rankFaces = rank(faces);
|
int[] rankFaces = rank(faces);
|
||||||
int[] sdFaces = getSD(rankFaces, rankRatings);
|
int[] sdFaces = getSD(rankFaces, rankRatings);
|
||||||
@ -257,7 +285,10 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | faces {}", factorFaces);
|
||||||
|
}
|
||||||
|
|
||||||
int[] rankData = rank(data);
|
int[] rankData = rank(data);
|
||||||
int[] sdData = getSD(rankData, rankRatings);
|
int[] sdData = getSD(rankData, rankRatings);
|
||||||
@ -266,7 +297,10 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | 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 +309,10 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | 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 +322,10 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | 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 +335,10 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | 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 +348,10 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | 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 +361,10 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | 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 +373,10 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | 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 +386,17 @@ 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);
|
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - | variety_sd {}", factor_variety_sd);
|
||||||
|
}
|
||||||
|
|
||||||
int[] complexity = new int[n];
|
int[] complexity = new int[n];
|
||||||
|
|
||||||
PlotSquared.debug(" $1Calculating threshold");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] 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 +425,10 @@ 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(
|
if (Settings.DEBUG) {
|
||||||
"Insufficient data to determine correlation! " + optimalIndex + " | "
|
logger.info("[P2] Insufficient data to determine correlation! {} | {}",
|
||||||
+ n);
|
optimalIndex, n);
|
||||||
|
}
|
||||||
running = false;
|
running = false;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
@ -387,21 +446,27 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save calibration
|
// Save calibration
|
||||||
PlotSquared.debug(" $1Saving calibration");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] 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!");
|
|
||||||
running = false;
|
running = false;
|
||||||
for (Plot plot : plots) {
|
for (Plot plot : plots) {
|
||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
}
|
}
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] Done!");
|
||||||
|
}
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logln(Object obj) {
|
public static void logln(Object obj) {
|
||||||
PlotSquared.debug(log(obj));
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] " + 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("P2/" + FlagContainer.class.getSimpleName());
|
||||||
|
|
||||||
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("[P2] 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,15 @@ 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.plotsquared.core.configuration.Settings;
|
||||||
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 +46,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class BlockTypeWrapper {
|
public class BlockTypeWrapper {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + BlockTypeWrapper.class.getSimpleName());
|
||||||
|
|
||||||
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 +133,9 @@ 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");
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] - 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("P2/" + PlotMessage.class.getSimpleName());
|
||||||
|
|
||||||
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("[P2] {} 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("P2/" + LocationOffsetDelegateLocalBlockQueue.class.getSimpleName());
|
||||||
|
|
||||||
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,6 @@ 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(
|
|
||||||
"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));
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -25,13 +25,18 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
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 com.plotsquared.core.configuration.Settings;
|
||||||
|
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("P2/" + Expression.class.getSimpleName());
|
||||||
|
|
||||||
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,9 @@ 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);
|
if (Settings.DEBUG) {
|
||||||
|
logger.info("[P2] Invalid expression: {}", expression);
|
||||||
|
}
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0d;
|
return 0d;
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
@ -33,6 +32,8 @@ import com.plotsquared.core.player.ConsolePlayer;
|
|||||||
import com.plotsquared.core.plot.BlockBucket;
|
import com.plotsquared.core.plot.BlockBucket;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -45,6 +46,7 @@ import java.util.Map;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class LegacyConverter {
|
public final class LegacyConverter {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + LegacyConverter.class.getSimpleName());
|
||||||
public static final String CONFIGURATION_VERSION = "post_flattening";
|
public static final String CONFIGURATION_VERSION = "post_flattening";
|
||||||
private static final HashMap<String, ConfigurationType> TYPE_MAP = new HashMap<>();
|
private static final HashMap<String, ConfigurationType> TYPE_MAP = new HashMap<>();
|
||||||
|
|
||||||
@ -109,7 +111,7 @@ public final class LegacyConverter {
|
|||||||
@NonNull final String key, @NonNull final String block) {
|
@NonNull final String key, @NonNull final String block) {
|
||||||
final BlockBucket bucket = this.blockToBucket(block);
|
final BlockBucket bucket = this.blockToBucket(block);
|
||||||
this.setString(section, key, bucket);
|
this.setString(section, key, bucket);
|
||||||
PlotSquared.log(CaptionUtility
|
logger.info(CaptionUtility
|
||||||
.format(ConsolePlayer.getConsole(), Captions.LEGACY_CONFIG_REPLACED.getTranslated(),
|
.format(ConsolePlayer.getConsole(), Captions.LEGACY_CONFIG_REPLACED.getTranslated(),
|
||||||
block, bucket.toString()));
|
block, bucket.toString()));
|
||||||
}
|
}
|
||||||
@ -119,7 +121,7 @@ public final class LegacyConverter {
|
|||||||
final BlockState[] blocks = this.splitBlockList(blockList);
|
final BlockState[] blocks = this.splitBlockList(blockList);
|
||||||
final BlockBucket bucket = this.blockListToBucket(blocks);
|
final BlockBucket bucket = this.blockListToBucket(blocks);
|
||||||
this.setString(section, key, bucket);
|
this.setString(section, key, bucket);
|
||||||
PlotSquared.log(CaptionUtility
|
logger.info(CaptionUtility
|
||||||
.format(ConsolePlayer.getConsole(), Captions.LEGACY_CONFIG_REPLACED.getTranslated(),
|
.format(ConsolePlayer.getConsole(), Captions.LEGACY_CONFIG_REPLACED.getTranslated(),
|
||||||
plotBlockArrayString(blocks), bucket.toString()));
|
plotBlockArrayString(blocks), bucket.toString()));
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,8 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
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.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -97,6 +99,7 @@ import java.util.stream.IntStream;
|
|||||||
*/
|
*/
|
||||||
public class MainUtil {
|
public class MainUtil {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + MainUtil.class.getSimpleName());
|
||||||
private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0");
|
private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -153,7 +156,6 @@ public class MainUtil {
|
|||||||
public static void upload(UUID uuid, String file, String extension,
|
public static void upload(UUID uuid, String file, String extension,
|
||||||
final RunnableVal<OutputStream> writeTask, final RunnableVal<URL> whenDone) {
|
final RunnableVal<OutputStream> writeTask, final RunnableVal<URL> whenDone) {
|
||||||
if (writeTask == null) {
|
if (writeTask == null) {
|
||||||
PlotSquared.debug("&cWrite task cannot be null");
|
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -215,7 +217,6 @@ public class MainUtil {
|
|||||||
content = scanner.next().trim();
|
content = scanner.next().trim();
|
||||||
}
|
}
|
||||||
if (!content.startsWith("<")) {
|
if (!content.startsWith("<")) {
|
||||||
PlotSquared.debug(content);
|
|
||||||
}
|
}
|
||||||
int responseCode = ((HttpURLConnection) con).getResponseCode();
|
int responseCode = ((HttpURLConnection) con).getResponseCode();
|
||||||
if (responseCode == 200) {
|
if (responseCode == 200) {
|
||||||
@ -537,11 +538,11 @@ public class MainUtil {
|
|||||||
* @param message If a message should be sent to the player if a plot cannot be found
|
* @param message If a message should be sent to the player if a plot cannot be found
|
||||||
* @return The plot if only 1 result is found, or null
|
* @return The plot if only 1 result is found, or null
|
||||||
*/
|
*/
|
||||||
@Nullable public static Plot getPlotFromString(PlotPlayer player, String arg, boolean message) {
|
@Nullable public static Plot getPlotFromString(PlotPlayer<?> player, String arg, boolean message) {
|
||||||
if (arg == null) {
|
if (arg == null) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
if (message) {
|
if (message) {
|
||||||
PlotSquared.log(Captions.NOT_VALID_PLOT_WORLD);
|
logger.info("[P2] No plot area string was supplied");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -664,7 +665,7 @@ public class MainUtil {
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
String message = CaptionUtility
|
String message = CaptionUtility
|
||||||
.format(null, (prefix ? Captions.PREFIX.getTranslated() : "") + msg);
|
.format(null, (prefix ? Captions.PREFIX.getTranslated() : "") + msg);
|
||||||
PlotSquared.log(message);
|
logger.info(message);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(CaptionUtility.format(player,
|
player.sendMessage(CaptionUtility.format(player,
|
||||||
(prefix ? Captions.PREFIX.getTranslated() : "") + Captions.color(msg)));
|
(prefix ? Captions.PREFIX.getTranslated() : "") + Captions.color(msg)));
|
||||||
@ -699,7 +700,7 @@ public class MainUtil {
|
|||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
String m = CaptionUtility.format(player, caption, args);
|
String m = CaptionUtility.format(player, caption, args);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
PlotSquared.log(m);
|
logger.info(m);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(m);
|
player.sendMessage(m);
|
||||||
}
|
}
|
||||||
@ -916,8 +917,6 @@ public class MainUtil {
|
|||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
deleteDirectory(file);
|
deleteDirectory(file);
|
||||||
} else {
|
|
||||||
PlotSquared.debug("Deleting file: " + file + " | " + file.delete());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
|||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -45,6 +47,8 @@ import java.util.Set;
|
|||||||
|
|
||||||
public abstract class RegionManager {
|
public abstract class RegionManager {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + RegionManager.class.getSimpleName());
|
||||||
|
|
||||||
public static RegionManager manager = null;
|
public static RegionManager manager = null;
|
||||||
|
|
||||||
public static BlockVector2 getRegion(Location location) {
|
public static BlockVector2 getRegion(Location location) {
|
||||||
@ -142,7 +146,7 @@ public abstract class RegionManager {
|
|||||||
world + File.separator + "region" + File.separator + "r." + loc.getX() + "."
|
world + File.separator + "region" + File.separator + "r." + loc.getX() + "."
|
||||||
+ loc.getZ() + ".mca";
|
+ loc.getZ() + ".mca";
|
||||||
File file = new File(PlotSquared.get().IMP.getWorldContainer(), directory);
|
File file = new File(PlotSquared.get().IMP.getWorldContainer(), directory);
|
||||||
PlotSquared.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
|
logger.info("[P2] - Deleting file: {} (max 1024 chunks)", file.getName());
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,8 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -93,6 +95,8 @@ import java.util.zip.GZIPInputStream;
|
|||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public abstract class SchematicHandler {
|
public abstract class SchematicHandler {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + SchematicHandler.class.getSimpleName());
|
||||||
public static SchematicHandler manager;
|
public static SchematicHandler manager;
|
||||||
|
|
||||||
private boolean exportAll = false;
|
private boolean exportAll = false;
|
||||||
@ -146,18 +150,12 @@ public abstract class SchematicHandler {
|
|||||||
final Runnable THIS = this;
|
final Runnable THIS = this;
|
||||||
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||||
@Override public void run(final CompoundTag value) {
|
@Override public void run(final CompoundTag value) {
|
||||||
if (value == null) {
|
if (value != null) {
|
||||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.getId());
|
|
||||||
} else {
|
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
MainUtil.sendMessage(null, "&6ID: " + plot.getId());
|
|
||||||
boolean result = SchematicHandler.manager
|
boolean result = SchematicHandler.manager
|
||||||
.save(value, directory + File.separator + name + ".schem");
|
.save(value, directory + File.separator + name + ".schem");
|
||||||
if (!result) {
|
if (!result) {
|
||||||
MainUtil
|
logger.error("[P2] Failed to save {}", plot.getId());
|
||||||
.sendMessage(null, "&7 - Failed to save &c" + plot.getId());
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(null, "&7 - &a success: " + plot.getId());
|
|
||||||
}
|
}
|
||||||
TaskManager.runTask(THIS);
|
TaskManager.runTask(THIS);
|
||||||
});
|
});
|
||||||
@ -186,7 +184,6 @@ public abstract class SchematicHandler {
|
|||||||
whenDone.value = false;
|
whenDone.value = false;
|
||||||
}
|
}
|
||||||
if (schematic == null) {
|
if (schematic == null) {
|
||||||
PlotSquared.debug("Schematic == null :|");
|
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -202,12 +199,6 @@ public abstract class SchematicHandler {
|
|||||||
+ 1) < WIDTH) || (
|
+ 1) < WIDTH) || (
|
||||||
(region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset
|
(region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset
|
||||||
+ 1) < LENGTH) || (HEIGHT > 256)) {
|
+ 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)");
|
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -404,8 +395,6 @@ public abstract class SchematicHandler {
|
|||||||
return new Schematic(clip);
|
return new Schematic(clip);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug(is.toString() + " | " + is.getClass().getCanonicalName()
|
|
||||||
+ " is not in GZIP format : " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -431,14 +420,12 @@ public abstract class SchematicHandler {
|
|||||||
return schematics;
|
return schematics;
|
||||||
} catch (JSONException | IOException e) {
|
} catch (JSONException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PlotSquared.debug("ERROR PARSING: " + rawJSON);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void upload(final CompoundTag tag, UUID uuid, String file, RunnableVal<URL> whenDone) {
|
public void upload(final CompoundTag tag, UUID uuid, String file, RunnableVal<URL> whenDone) {
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
PlotSquared.debug("&cCannot save empty tag");
|
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -463,7 +450,6 @@ public abstract class SchematicHandler {
|
|||||||
*/
|
*/
|
||||||
public boolean save(CompoundTag tag, String path) {
|
public boolean save(CompoundTag tag, String path) {
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
PlotSquared.debug("&cCannot save empty tag");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
package com.plotsquared.core.util.net;
|
package com.plotsquared.core.util.net;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
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.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@ -47,6 +48,8 @@ import java.util.Locale;
|
|||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
public final class IncendoPaster {
|
public final class IncendoPaster {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger("P2/" + IncendoPaster.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload service URL
|
* Upload service URL
|
||||||
*/
|
*/
|
||||||
@ -158,7 +161,7 @@ public final class IncendoPaster {
|
|||||||
if (!httpURLConnection.getResponseMessage().contains("OK")) {
|
if (!httpURLConnection.getResponseMessage().contains("OK")) {
|
||||||
if (httpURLConnection.getResponseCode() == 413) {
|
if (httpURLConnection.getResponseCode() == 413) {
|
||||||
final long size = content.length;
|
final long size = content.length;
|
||||||
PlotSquared.debug(String.format("Paste Too Big > Size: %dMB", size / 1_000_000));
|
logger.error("[P2] Paste too big > size: {}MB", size / 1_000_000);
|
||||||
}
|
}
|
||||||
throw new IllegalStateException(String
|
throw new IllegalStateException(String
|
||||||
.format("Server returned status: %d %s", httpURLConnection.getResponseCode(),
|
.format("Server returned status: %d %s", httpURLConnection.getResponseCode(),
|
||||||
|
@ -33,6 +33,8 @@ import com.plotsquared.core.util.ThreadUtils;
|
|||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
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;
|
||||||
@ -62,6 +64,8 @@ import java.util.function.Function;
|
|||||||
*/
|
*/
|
||||||
public class UUIDPipeline {
|
public class UUIDPipeline {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + UUIDPipeline.class.getSimpleName());
|
||||||
|
|
||||||
private final Executor executor;
|
private final Executor executor;
|
||||||
private final List<UUIDService> serviceList;
|
private final List<UUIDService> serviceList;
|
||||||
private final List<Consumer<List<UUIDMapping>>> consumerList;
|
private final List<Consumer<List<UUIDMapping>>> consumerList;
|
||||||
@ -164,7 +168,7 @@ public class UUIDPipeline {
|
|||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (TimeoutException ignored) {
|
} catch (TimeoutException ignored) {
|
||||||
PlotSquared.log(Captions.PREFIX + " (UUID) Request for " + username + " timed out");
|
logger.warn("[P2] (UUID) Request for {} timed out", username);
|
||||||
// This is completely valid, we just don't care anymore
|
// This is completely valid, we just don't care anymore
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -187,7 +191,7 @@ public class UUIDPipeline {
|
|||||||
} catch (InterruptedException | ExecutionException e) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (TimeoutException ignored) {
|
} catch (TimeoutException ignored) {
|
||||||
PlotSquared.log(Captions.PREFIX + " (UUID) Request for " + uuid + " timed out");
|
logger.warn("[P2] (UUID) Request for {} timed out", uuid);
|
||||||
// This is completely valid, we just don't care anymore
|
// This is completely valid, we just don't care anymore
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -321,7 +325,7 @@ public class UUIDPipeline {
|
|||||||
this.consume(mappings);
|
this.consume(mappings);
|
||||||
return mappings;
|
return mappings;
|
||||||
} else if (Settings.DEBUG) {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.log("Failed to find all usernames");
|
logger.info("[P2] (UUID) Failed to find all usernames");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.UUID.UNKNOWN_AS_DEFAULT) {
|
if (Settings.UUID.UNKNOWN_AS_DEFAULT) {
|
||||||
@ -384,7 +388,7 @@ public class UUIDPipeline {
|
|||||||
this.consume(mappings);
|
this.consume(mappings);
|
||||||
return mappings;
|
return mappings;
|
||||||
} else if (Settings.DEBUG) {
|
} else if (Settings.DEBUG) {
|
||||||
PlotSquared.log("Failed to find all UUIDs");
|
logger.info("[P2] (UUID) Failed to find all UUIDs");
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ServiceError("End of pipeline");
|
throw new ServiceError("End of pipeline");
|
||||||
|
Loading…
Reference in New Issue
Block a user