mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Merge branch 'features/v5/internal-updates' into features/v5/async-load
This commit is contained in:
commit
7fdb7961ce
4 changed files with 40 additions and 10 deletions
|
@ -39,7 +39,7 @@ public class EntitySpawnListener implements Listener {
|
|||
private static boolean hasPlotArea = false;
|
||||
private static String areaName = null;
|
||||
|
||||
public static void testNether(Entity entity) {
|
||||
public static void testNether(final Entity entity) {
|
||||
@NotNull World world = entity.getWorld();
|
||||
if (world.getEnvironment() != World.Environment.NETHER
|
||||
&& world.getEnvironment() != World.Environment.THE_END) {
|
||||
|
@ -48,15 +48,16 @@ public class EntitySpawnListener implements Listener {
|
|||
test(entity);
|
||||
}
|
||||
|
||||
public static void testCreate(Entity entity) {
|
||||
public static void testCreate(final Entity entity) {
|
||||
@NotNull World world = entity.getWorld();
|
||||
if (areaName == world.getName()) {
|
||||
} else {
|
||||
areaName = world.getName();
|
||||
hasPlotArea = PlotSquared.get().hasPlotArea(areaName);
|
||||
}
|
||||
if (!hasPlotArea)
|
||||
if (!hasPlotArea) {
|
||||
return;
|
||||
}
|
||||
test(entity);
|
||||
}
|
||||
|
||||
|
@ -76,15 +77,21 @@ public class EntitySpawnListener implements Listener {
|
|||
if (!world.getName().equalsIgnoreCase(originWorld + "_the_end")) {
|
||||
try {
|
||||
ignoreTP = true;
|
||||
PaperLib.teleportAsync(entity,origin);
|
||||
PaperLib.teleportAsync(entity, origin);
|
||||
} finally {
|
||||
ignoreTP = false;
|
||||
}
|
||||
if (entity.getType() == EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
if (entity.getLocation().getWorld().equals(world)) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (entity.getType() == EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +143,7 @@ public class EntitySpawnListener implements Listener {
|
|||
|
||||
@EventHandler public void onChunkLoad(ChunkLoadEvent event) {
|
||||
@NotNull Chunk chunk = event.getChunk();
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
for (final Entity entity : chunk.getEntities()) {
|
||||
testCreate(entity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,8 +101,12 @@ public class Claim extends SubCommand {
|
|||
final String finalSchematic = schematic;
|
||||
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override public void run(Object value) {
|
||||
plot.claim(player, true, finalSchematic);
|
||||
if (area.isAutoMerge()) {
|
||||
if (!plot.claim(player, true, finalSchematic)) {
|
||||
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
|
||||
String.format("Failed to claim plot %s", plot.getId().toCommaSeparatedString()));
|
||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||
plot.owner = null;
|
||||
} else if (area.isAutoMerge()) {
|
||||
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
|
||||
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
||||
if (event.getEventResult() == Result.DENY) {
|
||||
|
@ -112,7 +116,12 @@ public class Claim extends SubCommand {
|
|||
}
|
||||
}
|
||||
}
|
||||
}), () -> sendMessage(player, Captions.PLOT_NOT_CLAIMED));
|
||||
}), () -> {
|
||||
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
|
||||
String.format("Failed to add plot %s to the database", plot.getId().toCommaSeparatedString()));
|
||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||
plot.owner = null;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -978,7 +978,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
}
|
||||
|
||||
public void createPlotSafe(final Plot plot, final Runnable success, final Runnable failure) {
|
||||
final long timestamp = plot.getTimestamp();
|
||||
addPlotTask(plot, new UniqueStatement("createPlotSafe_" + plot.hashCode()) {
|
||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||
statement.setInt(1, plot.getId().x);
|
||||
|
|
|
@ -1709,6 +1709,9 @@ public class Plot {
|
|||
|
||||
public boolean claim(final PlotPlayer player, boolean teleport, String schematic) {
|
||||
if (!canClaim(player)) {
|
||||
PlotSquared.debug(Captions.PREFIX.getTranslated() +
|
||||
String.format("Player %s attempted to claim plot %s, but was not allowed",
|
||||
player.getName(), this.getId().toCommaSeparatedString()));
|
||||
return false;
|
||||
}
|
||||
return claim(player, teleport, schematic, true);
|
||||
|
@ -1719,6 +1722,9 @@ public class Plot {
|
|||
|
||||
if (updateDB) {
|
||||
if (!create(player.getUUID(), true)) {
|
||||
PlotSquared.debug(Captions.PREFIX.getTranslated() +
|
||||
String.format("Player %s attempted to claim plot %s, but the database failed to update",
|
||||
player.getName(), this.getId().toCommaSeparatedString()));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -1804,6 +1810,9 @@ public class Plot {
|
|||
});
|
||||
return true;
|
||||
}
|
||||
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
|
||||
String.format("Failed to add plot %s to plot area %s", this.getId().toCommaSeparatedString(),
|
||||
this.area.toString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2346,7 +2355,13 @@ public class Plot {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return this.guessOwner() == null && !isMerged();
|
||||
final UUID owner = this.guessOwner();
|
||||
if (owner != null) {
|
||||
if (player == null || !player.getUUID().equals(owner)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return !isMerged();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue