mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fix DebugClaimTest (#2667)
* Fix DebugClaimTest * Remove code causing 3 database updates per plot + errors when using MySQL
This commit is contained in:
parent
30f37e1e8b
commit
d0b6badf09
@ -3,7 +3,6 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
|||||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
@ -21,6 +20,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@CommandDeclaration(command = "debugclaimtest", description =
|
@CommandDeclaration(command = "debugclaimtest", description =
|
||||||
"If you accidentally delete your database, this command will attempt to restore all plots based on the data from plot signs. "
|
"If you accidentally delete your database, this command will attempt to restore all plots based on the data from plot signs. "
|
||||||
@ -54,63 +54,49 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
"&3Sign Block&8->&3Plot&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
|
"&3Sign Block&8->&3Plot&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
|
||||||
PlotManager manager = area.getPlotManager();
|
PlotManager manager = area.getPlotManager();
|
||||||
ArrayList<Plot> plots = new ArrayList<>();
|
CompletableFuture.runAsync(() -> {
|
||||||
for (PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(min, max);
|
||||||
Plot plot = area.getPlotAbs(id);
|
MainUtil.sendMessage(player, "&3Sign Block&8->&3Plot&8: " + ids.size() + " plot ids to check!");
|
||||||
if (plot.hasOwner()) {
|
for (PlotId id : ids) {
|
||||||
MainUtil.sendMessage(player, " - &cDB Already contains: " + plot.getId());
|
Plot plot = area.getPlotAbs(id);
|
||||||
continue;
|
if (plot.hasOwner()) {
|
||||||
}
|
MainUtil.sendMessage(player, " - &cDB Already contains: " + plot.getId());
|
||||||
Location location = manager.getSignLoc(plot);
|
continue;
|
||||||
BlockVector2 chunk = BlockVector2.at(location.getX() >> 4, location.getZ() >> 4);
|
}
|
||||||
ChunkManager.manager.loadChunk(area.worldname, chunk, false).thenRun(() -> {
|
Location location = manager.getSignLoc(plot);
|
||||||
String[] lines = WorldUtil.IMP.getSign(location);
|
BlockVector2 chunk = BlockVector2.at(location.getX() >> 4, location.getZ() >> 4);
|
||||||
if (lines != null) {
|
ChunkManager.manager.loadChunk(area.worldname, chunk, false).thenRun(() -> {
|
||||||
String line = lines[2];
|
String[] lines = WorldUtil.IMP.getSign(location);
|
||||||
if (line != null && line.length() > 2) {
|
if (lines != null) {
|
||||||
line = line.substring(2);
|
String line = lines[2];
|
||||||
BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
if (line != null && line.length() > 2) {
|
||||||
UUID uuid = map.get(new StringWrapper(line));
|
line = line.substring(2);
|
||||||
if (uuid == null) {
|
BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
||||||
for (Map.Entry<StringWrapper, UUID> stringWrapperUUIDEntry : map
|
UUID uuid = map.get(new StringWrapper(line));
|
||||||
.entrySet()) {
|
if (uuid == null) {
|
||||||
if (stringWrapperUUIDEntry.getKey().value.toLowerCase()
|
for (Map.Entry<StringWrapper, UUID> stringWrapperUUIDEntry : map.entrySet()) {
|
||||||
.startsWith(line.toLowerCase())) {
|
if (stringWrapperUUIDEntry.getKey().value.toLowerCase()
|
||||||
uuid = stringWrapperUUIDEntry.getValue();
|
.startsWith(line.toLowerCase())) {
|
||||||
break;
|
uuid = stringWrapperUUIDEntry.getValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (uuid == null) {
|
||||||
if (uuid == null) {
|
uuid = UUIDHandler.getUUID(line, null);
|
||||||
uuid = UUIDHandler.getUUID(line, null);
|
}
|
||||||
}
|
if (uuid != null) {
|
||||||
if (uuid != null) {
|
MainUtil.sendMessage(player, " - &aFound plot: " + plot.getId() + " : " + line);
|
||||||
MainUtil.sendMessage(player,
|
plot.setOwner(uuid);
|
||||||
" - &aFound plot: " + plot.getId() + " : " + line);
|
MainUtil.sendMessage(player, " - &8Updated plot: " + plot.getId());
|
||||||
plot.setOwner(uuid);
|
} else {
|
||||||
plots.add(plot);
|
MainUtil.sendMessage(player, " - &cInvalid PlayerName: " + plot.getId() + " : " + line);
|
||||||
} else {
|
}
|
||||||
MainUtil.sendMessage(player,
|
|
||||||
" - &cInvalid PlayerName: " + plot.getId() + " : " + line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}).join();
|
||||||
}).thenRun(() -> {
|
}
|
||||||
if (!plots.isEmpty()) {
|
}).thenRun(() -> MainUtil.sendMessage(player, "&3Sign Block&8->&3Plot&8: Finished scan."));
|
||||||
MainUtil.sendMessage(player,
|
|
||||||
"&3Sign Block&8->&3Plot&8: &7Updating '" + plots.size() + "' plots!");
|
|
||||||
DBFunc.createPlotsAndData(plots,
|
|
||||||
() -> MainUtil.sendMessage(player, "&6Database update finished!"));
|
|
||||||
for (Plot plot1 : plots) {
|
|
||||||
plot.create();
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3Plot&8: &7Complete!");
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(player, "No plots were found for the given search.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user