Merge branch 'v6' into feature/v6/json

This commit is contained in:
Alexander Söderberg 2020-07-14 16:52:40 +02:00 committed by GitHub
commit 55eefd09da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 207 additions and 183 deletions

View File

@ -3,14 +3,12 @@ name: Java CI
on: on:
push: push:
branches: branches:
- 'v4'
- 'v5' - 'v5'
- 'legacy/1.8-1.12' - 'v6'
pull_request: pull_request:
branches: branches:
- 'v4'
- 'v5' - 'v5'
- 'legacy/1.8-1.12' - 'v6'
jobs: jobs:
test: test:

View File

@ -21,7 +21,7 @@
<dependency> <dependency>
<groupId>com.plotsquared</groupId> <groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId> <artifactId>PlotSquared-Core</artifactId>
<version>5.12.3</version> <version>5.12.5</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -831,7 +831,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
case "HOGLIN": case "HOGLIN":
case "PIGLIN": case "PIGLIN":
case "ZOGLIN": case "ZOGLIN":
break;
default: { default: {
if (Settings.Enabled_Components.KILL_ROAD_MOBS) { if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
Location location = entity.getLocation(); Location location = entity.getLocation();

View File

@ -230,7 +230,6 @@ public class PlayerEvents extends PlotListener implements Listener {
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE = public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE =
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake"); new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
private boolean pistonBlocks = true;
private float lastRadius; private float lastRadius;
// To prevent recursion // To prevent recursion
private boolean tmpTeleport = true; private boolean tmpTeleport = true;
@ -822,7 +821,9 @@ public class PlayerEvents extends PlotListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
BukkitPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) {
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
}
// Set last location // Set last location
Location location = BukkitUtil.getLocation(to); Location location = BukkitUtil.getLocation(to);
pp.setMeta(PlotPlayer.META_LOCATION, location); pp.setMeta(PlotPlayer.META_LOCATION, location);
@ -882,7 +883,9 @@ public class PlayerEvents extends PlotListener implements Listener {
Player player = event.getPlayer(); Player player = event.getPlayer();
BukkitPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
// Cancel teleport // Cancel teleport
TaskManager.TELEPORT_QUEUE.remove(pp.getName()); if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) {
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
}
// Set last location // Set last location
Location location = BukkitUtil.getLocation(to); Location location = BukkitUtil.getLocation(to);
pp.setMeta(PlotPlayer.META_LOCATION, location); pp.setMeta(PlotPlayer.META_LOCATION, location);
@ -1510,7 +1513,63 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
for (Block block1 : event.getBlocks()) { for (Block block1 : event.getBlocks()) {
if (BukkitUtil.getLocation(block1.getLocation().add(relative)).isPlotArea()) { Location bloc = BukkitUtil.getLocation(block1.getLocation());
if (bloc.isPlotArea() || bloc.add(relative.getBlockX(),
relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
event.setCancelled(true);
return;
}
}
if (location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
.isPlotArea()) {
// Prevent pistons from extending if they are: bordering a plot
// area, facing inside plot area, and not pushing any blocks
event.setCancelled(true);
}
return;
}
Plot plot = area.getOwnedPlot(location);
if (plot == null) {
event.setCancelled(true);
return;
}
for (Block block1 : event.getBlocks()) {
Location bloc = BukkitUtil.getLocation(block1.getLocation());
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
event.setCancelled(true);
return;
}
if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(
bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
event.setCancelled(true);
return;
}
}
if (!plot.equals(area.getOwnedPlot(location.add(
relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
// This branch is only necessary to prevent pistons from extending
// if they are: on a plot edge, facing outside the plot, and not
// pushing any blocks
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
Block block = event.getBlock();
Location location = BukkitUtil.getLocation(block.getLocation());
BlockFace face = event.getDirection();
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
PlotArea area = location.getPlotArea();
if (area == null) {
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
return;
}
for (Block block1 : event.getBlocks()) {
Location bloc = BukkitUtil.getLocation(block1.getLocation());
if (bloc.isPlotArea() || bloc.add(relative.getBlockX(),
relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -1537,87 +1596,39 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
Block block = event.getBlock();
Location location = BukkitUtil.getLocation(block.getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
return;
}
if (this.pistonBlocks) {
try {
for (Block pulled : event.getBlocks()) {
location = BukkitUtil.getLocation(pulled.getLocation());
if (location.isPlotArea()) {
event.setCancelled(true);
return;
}
}
} catch (Throwable ignored) {
this.pistonBlocks = false;
}
}
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
BlockFace dir = event.getDirection();
location = BukkitUtil.getLocation(block.getLocation()
.add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
if (location.isPlotArea()) {
event.setCancelled(true);
return;
}
}
return;
}
Plot plot = area.getOwnedPlot(location);
BlockFace dir = event.getDirection();
// Location head = location.add(-dir.getModX(), -dir.getModY(), -dir.getModZ());
//
// if (!Objects.equals(plot, area.getOwnedPlot(head))) {
// // FIXME: cancelling the event doesn't work here. See issue #1484
// event.setCancelled(true);
// return;
// }
if (this.pistonBlocks) {
try {
for (Block pulled : event.getBlocks()) {
Location from = BukkitUtil.getLocation(
pulled.getLocation().add(dir.getModX(), dir.getModY(), dir.getModZ()));
Location to = BukkitUtil.getLocation(pulled.getLocation());
if (!area.contains(to.getX(), to.getZ())) {
event.setCancelled(true);
return;
}
Plot fromPlot = area.getOwnedPlot(from);
Plot toPlot = area.getOwnedPlot(to);
if (!Objects.equals(fromPlot, toPlot)) {
event.setCancelled(true);
return;
}
}
} catch (Throwable ignored) {
this.pistonBlocks = false;
}
}
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
location = BukkitUtil.getLocation(
block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
if (!area.contains(location)) {
event.setCancelled(true);
return;
}
Plot newPlot = area.getOwnedPlot(location);
if (!Objects.equals(plot, newPlot)) {
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent event) { public void onBlockDispense(BlockDispenseEvent event) {
Material type = event.getItem().getType(); Material type = event.getItem().getType();
switch (type) { switch (type) {
case SHULKER_BOX:
case WHITE_SHULKER_BOX:
case ORANGE_SHULKER_BOX:
case MAGENTA_SHULKER_BOX:
case LIGHT_BLUE_SHULKER_BOX:
case YELLOW_SHULKER_BOX:
case LIME_SHULKER_BOX:
case PINK_SHULKER_BOX:
case GRAY_SHULKER_BOX:
case LIGHT_GRAY_SHULKER_BOX:
case CYAN_SHULKER_BOX:
case PURPLE_SHULKER_BOX:
case BLUE_SHULKER_BOX:
case BROWN_SHULKER_BOX:
case GREEN_SHULKER_BOX:
case RED_SHULKER_BOX:
case BLACK_SHULKER_BOX:
case CARVED_PUMPKIN:
case WITHER_SKELETON_SKULL:
case FLINT_AND_STEEL:
case BONE_MEAL:
case SHEARS:
case GLASS_BOTTLE:
case GLOWSTONE:
case COD_BUCKET:
case PUFFERFISH_BUCKET:
case SALMON_BUCKET:
case TROPICAL_FISH_BUCKET:
case BUCKET:
case WATER_BUCKET: case WATER_BUCKET:
case LAVA_BUCKET: { case LAVA_BUCKET: {
if (event.getBlock().getType() == Material.DROPPER) { if (event.getBlock().getType() == Material.DROPPER) {
@ -1864,8 +1875,8 @@ public class PlayerEvents extends PlotListener implements Listener {
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer()); BukkitPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
if (plot == null) { if (plot == null) {
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions
&& !Permissions.hasPermission(pp, "plots.admin.interact.road")) { .hasPermission(pp, "plots.admin.interact.road")) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road"); MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road");
e.setCancelled(true); e.setCancelled(true);
} }
@ -1878,8 +1889,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return; return;
} }
} }
if (!plot.hasOwner() && !area.isRoadFlags() && !area if (!plot.hasOwner()) {
.getRoadFlag(MiscInteractFlag.class)) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
"plots.admin.interact.unowned"); "plots.admin.interact.unowned");
@ -2601,8 +2611,8 @@ public class PlayerEvents extends PlotListener implements Listener {
Captions.PERMISSION_ADMIN_INTERACT_UNOWNED); Captions.PERMISSION_ADMIN_INTERACT_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} }
} else if ((plot != null && !plot.isAdded(pp.getUUID())) || area } else if ((plot != null && !plot.isAdded(pp.getUUID())) || (plot == null && area
.isRoadFlags()) { .isRoadFlags())) {
final Entity entity = event.getRightClicked(); final Entity entity = event.getRightClicked();
final com.sk89q.worldedit.world.entity.EntityType entityType = final com.sk89q.worldedit.world.entity.EntityType entityType =
BukkitAdapter.adapt(entity.getType()); BukkitAdapter.adapt(entity.getType());
@ -3145,7 +3155,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
Plot plot = location.getOwnedPlot(); Plot plot = location.getOwnedPlot();
if (plot == null) { if (plot == null) {
if (area.isRoadFlags() && area.getRoadFlag(ItemDropFlag.class)) { if (area.isRoadFlags() && !area.getRoadFlag(ItemDropFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
return; return;

View File

@ -26,17 +26,16 @@
package com.plotsquared.bukkit.placeholder; package com.plotsquared.bukkit.placeholder;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.GlobalFlagContainer; import com.plotsquared.core.plot.flag.GlobalFlagContainer;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.util.MainUtil;
import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
public class Placeholders extends PlaceholderExpansion { public class Placeholders extends PlaceholderExpansion {
@ -117,23 +116,16 @@ public class Placeholders extends PlaceholderExpansion {
return plot.getAlias(); return plot.getAlias();
} }
case "currentplot_owner": { case "currentplot_owner": {
final Set<UUID> o = plot.getOwners(); final UUID plotOwner = plot.getOwnerAbs();
if (o == null || o.isEmpty()) { if (plotOwner == null) {
return "";
}
final UUID uid = (UUID) o.toArray()[0];
if (uid == null) {
return ""; return "";
} }
String name = PlotSquared.get().getImpromptuUUIDPipeline() try {
.getSingle(uid, Settings.UUID.BLOCKING_TIMEOUT); return MainUtil.getName(plotOwner, false);
} catch (final Exception ignored) {}
if (name != null) { final String name = Bukkit.getOfflinePlayer(plotOwner).getName();
return name;
}
name = Bukkit.getOfflinePlayer(uid).getName();
return name != null ? name : "unknown"; return name != null ? name : "unknown";
} }
case "currentplot_members": { case "currentplot_members": {

View File

@ -26,6 +26,8 @@
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.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;
@ -35,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -65,8 +68,27 @@ public class SquirrelIdUUIDService implements UUIDService {
final List<UUIDMapping> results = new ArrayList<>(uuids.size()); final List<UUIDMapping> results = new ArrayList<>(uuids.size());
this.rateLimiter.acquire(uuids.size()); this.rateLimiter.acquire(uuids.size());
try { try {
for (final Profile profile : this.profileService.findAllById(uuids)) { try {
results.add(new UUIDMapping(profile.getUniqueId(), profile.getName())); for (final Profile profile : this.profileService.findAllById(uuids)) {
results.add(new UUIDMapping(profile.getUniqueId(), profile.getName()));
}
} catch (final IllegalArgumentException illegalArgumentException) {
//
// This means that the UUID was invalid for whatever reason, we'll try to
// go through them one by one
//
if (uuids.size() >= 2) {
PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID in batch. Will try each UUID individually.");
for (final UUID uuid : uuids) {
final List<UUIDMapping> result = this.getNames(Collections.singletonList(uuid));
if (result.isEmpty()) {
continue;
}
results.add(result.get(0));
}
} else if (uuids.size() == 1) {
PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID: " + uuids.get(0));
}
} }
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -155,11 +155,9 @@ public class PlotSquared {
public WorldEdit worldedit; public WorldEdit worldedit;
public File configFile; public File configFile;
public File worldsFile; public File worldsFile;
public File commandsFile;
public File translationFile; public File translationFile;
public YamlConfiguration worlds; public YamlConfiguration worlds;
public YamlConfiguration storage; public YamlConfiguration storage;
public YamlConfiguration commands;
// Temporary hold the plots/clusters before the worlds load // Temporary hold the plots/clusters before the worlds load
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;
@ -269,6 +267,7 @@ public class PlotSquared {
if (Settings.Enabled_Components.CHUNK_PROCESSOR) { if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
this.IMP.registerChunkProcessor(); this.IMP.registerChunkProcessor();
} }
startExpiryTasks();
// Create Event utility class // Create Event utility class
eventDispatcher = new EventDispatcher(); eventDispatcher = new EventDispatcher();
// create Hybrid utility class // create Hybrid utility class
@ -1786,22 +1785,6 @@ public class PlotSquared {
} catch (IOException ignored) { } catch (IOException ignored) {
PlotSquared.log("Failed to save storage.yml"); PlotSquared.log("Failed to save storage.yml");
} }
try {
this.commandsFile = new File(folder, "commands.yml");
if (!this.commandsFile.exists() && !this.commandsFile.createNewFile()) {
PlotSquared.log(
"Could not the storage settings file, please create \"commands.yml\" manually.");
}
this.commands = YamlConfiguration.loadConfiguration(this.commandsFile);
} catch (IOException ignored) {
PlotSquared.log("Failed to save commands.yml");
}
try {
this.commands.save(this.commandsFile);
} catch (IOException e) {
PlotSquared.log("Configuration file saving failed");
e.printStackTrace();
}
return true; return true;
} }

View File

@ -43,7 +43,6 @@ import lombok.SneakyThrows;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
@ -193,36 +192,16 @@ public abstract class Command {
this.permission = declaration.permission(); this.permission = declaration.permission();
this.required = declaration.requiredType(); this.required = declaration.requiredType();
this.category = declaration.category(); this.category = declaration.category();
List<String> aliasOptions = new ArrayList<>(); List<String> aliasOptions = new ArrayList<>();
aliasOptions.add(this.id); aliasOptions.add(this.id);
aliasOptions.addAll(Arrays.asList(declaration.aliases())); aliasOptions.addAll(Arrays.asList(declaration.aliases()));
HashMap<String, Object> options = new HashMap<>();
options.put("aliases", aliasOptions);
options.put("description", declaration.description());
options.put("usage", declaration.usage());
options.put("confirmation", declaration.confirmation());
boolean set = false;
YamlConfiguration commands =
PlotSquared.get() == null ? new YamlConfiguration() : PlotSquared.get().commands;
for (Map.Entry<String, Object> entry : options.entrySet()) {
String key = this.getFullId() + "." + entry.getKey();
if (!commands.contains(key)) {
commands.set(key, entry.getValue());
set = true;
}
}
if (set && PlotSquared.get() != null) {
try {
commands.save(PlotSquared.get().commandsFile);
} catch (IOException e) {
e.printStackTrace();
} this.aliases = aliasOptions;
} this.description = declaration.description();
this.aliases = commands.getStringList(this.getFullId() + ".aliases"); this.usage = declaration.usage();
this.description = commands.getString(this.getFullId() + ".description"); this.confirmation = declaration.confirmation();
this.usage = commands.getString(this.getFullId() + ".usage");
this.confirmation = commands.getBoolean(this.getFullId() + ".confirmation");
if (this.parent != null) { if (this.parent != null) {
this.parent.register(this); this.parent.register(this);
} }

View File

@ -84,7 +84,7 @@ public class HomeCommand extends Command {
@NotNull private PlotQuery query(@NotNull final PlotPlayer<?> player) { @NotNull private PlotQuery query(@NotNull final PlotPlayer<?> player) {
// everything plots need to have in common here // everything plots need to have in common here
return PlotQuery.newQuery().ownedBy(player).whereBasePlot(); return PlotQuery.newQuery().ownedBy(player);
} }
@Override public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args, @Override public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
@ -107,6 +107,7 @@ public class HomeCommand extends Command {
PlotQuery query = query(player); PlotQuery query = query(player);
int page = 1; // page = index + 1 int page = 1; // page = index + 1
String identifier; String identifier;
boolean basePlotOnly = true;
switch (args.length) { switch (args.length) {
case 1: case 1:
identifier = args[0]; identifier = args[0];
@ -124,6 +125,7 @@ public class HomeCommand extends Command {
Plot fromId = MainUtil.getPlotFromString(player, identifier, false); Plot fromId = MainUtil.getPlotFromString(player, identifier, false);
if (fromId != null && fromId.isOwner(player.getUUID())) { if (fromId != null && fromId.isOwner(player.getUUID())) {
// it was a valid plot id // it was a valid plot id
basePlotOnly = false;
query.withPlot(fromId); query.withPlot(fromId);
break; break;
} }
@ -165,12 +167,16 @@ public class HomeCommand extends Command {
break; break;
} }
// as the query already filters by owner, this is fine // as the query already filters by owner, this is fine
basePlotOnly = false;
query.withPlot(plot); query.withPlot(plot);
break; break;
case 0: case 0:
query.withSortingStrategy(SortingStrategy.SORT_BY_CREATION); query.withSortingStrategy(SortingStrategy.SORT_BY_CREATION);
break; break;
} }
if (basePlotOnly) {
query.whereBasePlot();
}
home(player, query, page, confirm, whenDone); home(player, query, page, confirm, whenDone);
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }

View File

@ -388,6 +388,9 @@ public class Settings extends Config {
@Comment( @Comment(
"Whether schematic based generation should paste schematic on top of plots, or from Y=1") "Whether schematic based generation should paste schematic on top of plots, or from Y=1")
public static boolean PASTE_ON_TOP = true; public static boolean PASTE_ON_TOP = true;
@Comment(
"Whether schematic based road generation should paste schematic on top of roads, or from Y=1")
public static boolean PASTE_ROAD_ON_TOP = true;
} }

View File

@ -47,7 +47,8 @@ public class HybridGen extends IndependentPlotGenerator {
private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX, private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX,
short relativeZ, int x, int z, boolean isRoad) { short relativeZ, int x, int z, boolean isRoad) {
int minY; // Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT); int minY; // Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT);
if (isRoad || Settings.Schematics.PASTE_ON_TOP) { if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad
&& Settings.Schematics.PASTE_ON_TOP)) {
minY = world.SCHEM_Y; minY = world.SCHEM_Y;
} else { } else {
minY = 1; minY = 1;

View File

@ -112,15 +112,17 @@ public class HybridPlotManager extends ClassicPlotManager {
return true; return true;
} }
LocalBlockQueue queue = hybridPlotWorld.getQueue(false); LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
createSchemAbs(queue, pos1, pos2); createSchemAbs(queue, pos1, pos2, true);
queue.enqueue(); queue.enqueue();
return true; return true;
} }
private void createSchemAbs(LocalBlockQueue queue, Location pos1, Location pos2) { private void createSchemAbs(LocalBlockQueue queue, Location pos1, Location pos2,
boolean isRoad) {
int size = hybridPlotWorld.SIZE; int size = hybridPlotWorld.SIZE;
int minY; int minY;
if (Settings.Schematics.PASTE_ON_TOP) { if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad
&& Settings.Schematics.PASTE_ON_TOP)) {
minY = hybridPlotWorld.SCHEM_Y; minY = hybridPlotWorld.SCHEM_Y;
} else { } else {
minY = 1; minY = 1;
@ -172,7 +174,7 @@ public class HybridPlotManager extends ClassicPlotManager {
return true; return true;
} }
LocalBlockQueue queue = hybridPlotWorld.getQueue(false); LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
createSchemAbs(queue, pos1, pos2); createSchemAbs(queue, pos1, pos2, true);
queue.enqueue(); queue.enqueue();
return true; return true;
} }
@ -186,9 +188,9 @@ public class HybridPlotManager extends ClassicPlotManager {
pos1.setY(0); pos1.setY(0);
pos2.setY(Math.min(getWorldHeight(), 255)); pos2.setY(Math.min(getWorldHeight(), 255));
LocalBlockQueue queue = hybridPlotWorld.getQueue(false); LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
createSchemAbs(queue, pos1, pos2); createSchemAbs(queue, pos1, pos2, true);
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
createSchemAbs(queue, pos1, pos2); createSchemAbs(queue, pos1, pos2, true);
} }
return queue.enqueue(); return queue.enqueue();
} }
@ -267,7 +269,7 @@ public class HybridPlotManager extends ClassicPlotManager {
if (!hybridPlotWorld.PLOT_SCHEMATIC) { if (!hybridPlotWorld.PLOT_SCHEMATIC) {
return; return;
} }
createSchemAbs(queue, bottom, top); createSchemAbs(queue, bottom, top, false);
} }
/** /**

View File

@ -83,6 +83,11 @@ public abstract class HybridUtils {
public static PlotArea area; public static PlotArea area;
public static boolean UPDATE = false; public static boolean UPDATE = false;
public static boolean regeneratePlotWalls(final PlotArea area) {
PlotManager plotManager = area.getPlotManager();
return plotManager.regenerateAllPlotWalls();
}
public void analyzeRegion(final String world, final CuboidRegion region, public void analyzeRegion(final String world, final CuboidRegion region,
final RunnableVal<PlotAnalysis> whenDone) { final RunnableVal<PlotAnalysis> whenDone) {
// int diff, int variety, int vertices, int rotation, int height_sd // int diff, int variety, int vertices, int rotation, int height_sd
@ -501,7 +506,7 @@ public abstract class HybridUtils {
PlotManager plotManager = plotworld.getPlotManager(); PlotManager plotManager = plotworld.getPlotManager();
int sx = bot.getX() - plotworld.ROAD_WIDTH + 1; int sx = bot.getX() - plotworld.ROAD_WIDTH + 1;
int sz = bot.getZ() + 1; int sz = bot.getZ() + 1;
int sy = plotworld.ROAD_HEIGHT; int sy = Settings.Schematics.PASTE_ROAD_ON_TOP ? plotworld.ROAD_HEIGHT : 1;
int ex = bot.getX(); int ex = bot.getX();
int ez = top.getZ(); int ez = top.getZ();
int ey = get_ey(plotManager, queue, sx, ex, sz, ez, sy); int ey = get_ey(plotManager, queue, sx, ex, sz, ez, sy);
@ -621,10 +626,7 @@ public abstract class HybridUtils {
} }
if (condition) { if (condition) {
BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ)); BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ));
int minY = plotWorld.SCHEM_Y; int minY = Settings.Schematics.PASTE_ROAD_ON_TOP ? plotWorld.SCHEM_Y : 1;
if (!Settings.Schematics.PASTE_ON_TOP) {
minY = 1;
}
int maxY = Math.max(extend, blocks.length); int maxY = Math.max(extend, blocks.length);
for (int y = 0; y < maxY; y++) { for (int y = 0; y < maxY; y++) {
if (y > blocks.length - 1) { if (y > blocks.length - 1) {
@ -659,9 +661,4 @@ public abstract class HybridUtils {
} }
return false; return false;
} }
public static boolean regeneratePlotWalls(final PlotArea area) {
PlotManager plotManager = area.getPlotManager();
return plotManager.regenerateAllPlotWalls();
}
} }

View File

@ -34,6 +34,7 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.khelekore.prtree.MBR; import org.khelekore.prtree.MBR;
import org.khelekore.prtree.SimpleMBR; import org.khelekore.prtree.SimpleMBR;
@ -103,6 +104,16 @@ public class Location implements Cloneable, Comparable<Location> {
} }
} }
/**
* Return a copy of the location. This will pass {@link #equals(Object)}
* but will have a different identity.
*
* @return Copy of the location
*/
@NotNull public Location copy() {
return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch);
}
public PlotArea getPlotArea() { public PlotArea getPlotArea() {
return PlotSquared.get().getPlotAreaAbs(this); return PlotSquared.get().getPlotAreaAbs(this);
} }
@ -179,6 +190,7 @@ public class Location implements Cloneable, Comparable<Location> {
this.x += x; this.x += x;
this.y += y; this.y += y;
this.z += z; this.z += z;
this.blockVector3 = BlockVector3.at(this.x, this.y, this.z);
return this; return this;
} }
@ -220,6 +232,7 @@ public class Location implements Cloneable, Comparable<Location> {
this.x -= x; this.x -= x;
this.y -= y; this.y -= y;
this.z -= z; this.z -= z;
this.blockVector3 = BlockVector3.at(this.x, this.y, this.z);
return this; return this;
} }

View File

@ -387,7 +387,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
@NotNull public Location getLocation() { @NotNull public Location getLocation() {
Location location = getMeta("location"); Location location = getMeta("location");
if (location != null) { if (location != null) {
return location; return location.copy(); // Always return a copy of the location
} }
return getLocationFull(); return getLocationFull();
} }

View File

@ -3010,11 +3010,9 @@ public class Plot {
final String name = player.getName(); final String name = player.getName();
TaskManager.TELEPORT_QUEUE.add(name); TaskManager.TELEPORT_QUEUE.add(name);
TaskManager.runTaskLater(() -> { TaskManager.runTaskLater(() -> {
if (!TaskManager.TELEPORT_QUEUE.contains(name)) { if (!TaskManager.TELEPORT_QUEUE.remove(name)) {
MainUtil.sendMessage(player, Captions.TELEPORT_FAILED);
return; return;
} }
TaskManager.TELEPORT_QUEUE.remove(name);
if (player.isOnline()) { if (player.isOnline()) {
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT); MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT);
player.teleport(location, cause); player.teleport(location, cause);

View File

@ -372,10 +372,21 @@ public class MainUtil {
/** /**
* Get the name from a UUID. * Get the name from a UUID.
* *
* @param owner * @param owner Owner UUID
* @return The player's name, None, Everyone or Unknown * @return The player's name, None, Everyone or Unknown
*/ */
@NotNull public static String getName(UUID owner) { @NotNull public static String getName(@Nullable UUID owner) {
return getName(owner, true);
}
/**
* Get the name from a UUID.
*
* @param owner Owner UUID
* @param blocking Whether or not the operation can be blocking
* @return The player's name, None, Everyone or Unknown
*/
@NotNull public static String getName(@Nullable final UUID owner, final boolean blocking) {
if (owner == null) { if (owner == null) {
return Captions.NONE.getTranslated(); return Captions.NONE.getTranslated();
} }
@ -385,7 +396,17 @@ public class MainUtil {
if (owner.equals(DBFunc.SERVER)) { if (owner.equals(DBFunc.SERVER)) {
return Captions.SERVER.getTranslated(); return Captions.SERVER.getTranslated();
} }
String name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT); final String name;
if (blocking) {
name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT);
} else {
final UUIDMapping uuidMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner);
if (uuidMapping != null) {
name = uuidMapping.getUsername();
} else {
name = null;
}
}
if (name == null) { if (name == null) {
return Captions.UNKNOWN.getTranslated(); return Captions.UNKNOWN.getTranslated();
} }

View File

@ -30,7 +30,7 @@ ext {
git = Grgit.open(dir: new File(rootDir.toString() + "/.git")) git = Grgit.open(dir: new File(rootDir.toString() + "/.git"))
} }
def ver = "5.12.3" def ver = "5.12.5"
def versuffix = "" def versuffix = ""
ext { ext {
if (project.hasProperty("versionsuffix")) { if (project.hasProperty("versionsuffix")) {