Compare commits

..

22 Commits

Author SHA1 Message Date
ac285cae99 Clear caches in more cases 2022-12-21 21:27:23 +01:00
612402d9cb Avoid extensive hashing of plots 2022-12-21 16:11:58 +01:00
c9d210bd64 Simplify isOwner check 2022-12-21 16:08:09 +01:00
25defaac07 Replace global connected plots cache with local cache 2022-12-21 15:20:15 +01:00
0661d0d5a1 Add JFR events 2022-12-20 18:53:33 +01:00
2a40a6b35e Update dependency com.intellectualsites.bom:bom-1.18.x to v1.21 (#3890)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-12-13 22:45:51 +01:00
ea1f35b45a Update dependency cloud.commandframework:cloud-services to v1.8.0 (#3891)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-12-13 22:44:29 +01:00
15e63378a7 Update worldedit to v7.2.13 (#3889)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-12-11 08:39:32 +01:00
f3bc504a6f refactor: adjust specific Nullable annotations used (#3869) 2022-12-02 12:39:38 +00:00
3a8fae47a0 Update dependency com.intellectualsites.bom:bom-1.18.x to v1.20 (#3882)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-11-28 15:23:44 +01:00
70cb1cd100 Back to snapshot for development 2022-11-28 11:18:56 +01:00
2067cc1670 Release 6.10.5 2022-11-28 11:18:06 +01:00
e6338976dd Update dependency gradle to v7.6 (#3880)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-11-25 19:20:37 +01:00
90ebd5d5ed feat: add a permission to override-allow a merge if the other plot's owner is offline (#3844) 2022-11-25 10:48:33 +00:00
c973ee8649 Revert "feat: check merge limits when completing auto-merge (#3868)" - Fixes a bug in 6.10.4 (#3876)
Revert "feat: check merge limits when completing auto-merge (#3868)"

This reverts commit 25ce7a83f1.
2022-11-20 10:58:04 +01:00
c1543f034c feat: improve handling of null issues in plot analysis (#3867) 2022-11-17 17:23:44 +00:00
6baf339ecb Update dependency com.intellectualsites.bom:bom-1.18.x to v1.19 (#3874)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-11-16 18:35:03 +01:00
11906ef1c9 Back to snapshot for development 2022-11-16 11:30:23 +01:00
ee8902154a Release 6.10.4 2022-11-16 11:26:03 +01:00
b5bc1988e5 feature: implement road flags as widely as seems reasonable (#3870)
* feature: implement road flags as widely as seems reasonable
 - Closes #3047
 - Any further road flag implementations would be very specific from what I can gather, and thus the gist of #3047 is now implemented

* Add javadoc since tag

Co-authored-by: Alexander Brandes <mc.cache@web.de>

* Create util class for method

Co-authored-by: Alexander Brandes <mc.cache@web.de>
2022-11-15 19:07:38 +01:00
2147012beb chore: deprecate paper 1.13 listener as P2 effectively doesn't support 1.13 (#3872) 2022-11-14 22:58:05 +01:00
52bb561689 fix: attempt to recover from IllegalStateException when restoring block tags (#3838)
- Fixes #3801
2022-11-14 16:47:24 +01:00
31 changed files with 300 additions and 183 deletions

View File

@ -33,7 +33,6 @@ import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
@ -51,7 +50,7 @@ final class LegacyBlockStatePopulator extends BlockPopulator {
}
@Override
public void populate(@NotNull final World world, @NotNull final Random random, @NotNull final Chunk source) {
public void populate(@NonNull final World world, @NonNull final Random random, @NonNull final Chunk source) {
int chunkMinX = source.getX() << 4;
int chunkMinZ = source.getZ() << 4;
PlotArea area = Location.at(world.getName(), chunkMinX, 0, chunkMinZ).getPlotArea();

View File

@ -56,6 +56,7 @@ import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime;
import com.sk89q.worldedit.WorldEdit;
@ -166,7 +167,7 @@ public class BlockEventListener implements Listener {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadFlags() && !area.getRoadFlag(RedstoneFlag.class)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, RedstoneFlag.class, false)) {
event.setNewCurrent(0);
}
return;
@ -1084,7 +1085,10 @@ public class BlockEventListener implements Listener {
return;
}
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !Permissions.hasPermission(
pp,
Permission.PERMISSION_ADMIN_BUILD_ROAD
)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
@ -1092,7 +1096,10 @@ public class BlockEventListener implements Listener {
event.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, BlockIgnitionFlag.class, true) && !Permissions.hasPermission(
pp,
Permission.PERMISSION_ADMIN_BUILD_UNOWNED
)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))

View File

@ -26,6 +26,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.CopperOxideFlag;
import com.plotsquared.core.plot.flag.implementations.MiscInteractFlag;
import com.plotsquared.core.util.PlotFlagUtil;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
@ -91,7 +92,8 @@ public class BlockEventListener117 implements Listener {
}
Plot plot = location.getOwnedPlot();
if (plot == null || !plot.getFlag(MiscInteractFlag.class)) {
if (plot == null && !PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, MiscInteractFlag.class, true) || plot != null && !plot.getFlag(
MiscInteractFlag.class)) {
if (plotPlayer != null) {
if (plot != null) {
if (!plot.isAdded(plotPlayer.getUUID())) {

View File

@ -38,6 +38,7 @@ import com.plotsquared.core.plot.flag.implementations.InvincibleFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType;
import org.bukkit.Material;
@ -261,7 +262,7 @@ public class EntityEventListener implements Listener {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadFlags() && area.getRoadFlag(InvincibleFlag.class)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, InvincibleFlag.class, true)) {
event.setCancelled(true);
}
return;

View File

@ -44,6 +44,7 @@ import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
import com.plotsquared.core.plot.flag.types.BooleanFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import net.kyori.adventure.text.minimessage.Template;
import org.bukkit.Chunk;
import org.bukkit.block.Block;
@ -326,14 +327,18 @@ public class PaperListener implements Listener {
return;
}
Location location = BukkitUtil.adapt(entity.getLocation());
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter);
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !Permissions.hasPermission(
pp,
Permission.PERMISSION_ADMIN_PROJECTILE_ROAD
)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD))

View File

@ -48,6 +48,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockPlaceEvent;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* @deprecated P2 effectively no longer supports 1.13
*/
@Deprecated(forRemoval = true, since = "6.10.4")
public class PaperListener113 extends PaperListener {
@Inject

View File

@ -68,6 +68,7 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.entity.EntityCategories;
import com.plotsquared.core.util.task.TaskManager;
@ -596,7 +597,7 @@ public class PlayerEventListener implements Listener {
this.tmpTeleport = true;
return;
}
int border = area.getBorder(true);
int border = area.getBorder();
int x1;
if (x2 > border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
@ -687,7 +688,7 @@ public class PlayerEventListener implements Listener {
this.tmpTeleport = true;
return;
}
int border = area.getBorder(true);
int border = area.getBorder();
int z1;
if (z2 > border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
@ -889,8 +890,7 @@ public class PlayerEventListener implements Listener {
}
} else {
PlotArea area = pp.getPlotAreaAbs();
if (area != null && area.isRoadFlags() && area
.getRoadFlag(PreventCreativeCopyFlag.class)) {
if (area != null && PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, PreventCreativeCopyFlag.class, true)) {
final ItemStack newStack =
new ItemStack(newItem.getType(), newItem.getAmount());
event.setCursor(newStack);
@ -998,8 +998,10 @@ public class PlayerEventListener implements Listener {
Plot plot = location.getPlotAbs();
BukkitPlayer pp = BukkitUtil.adapt(e.getPlayer());
if (plot == null) {
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions
.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, MiscInteractFlag.class, true) && !Permissions.hasPermission(
pp,
Permission.PERMISSION_ADMIN_INTERACT_ROAD
)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
@ -1009,9 +1011,7 @@ public class PlayerEventListener implements Listener {
} else {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("done.building_restricted")
);
pp.sendMessage(TranslatableCaption.of("done.building_restricted"));
e.setCancelled(true);
return;
}
@ -1594,7 +1594,10 @@ public class PlayerEventListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(p);
Plot plot = area.getPlot(location);
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD)) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, VehicleBreakFlag.class, true) && !Permissions.hasPermission(
pp,
Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD
)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD))
@ -1642,7 +1645,7 @@ public class PlayerEventListener implements Listener {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadFlags() && !area.getRoadFlag(ItemDropFlag.class)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ItemDropFlag.class, false)) {
event.setCancelled(true);
}
return;
@ -1668,7 +1671,7 @@ public class PlayerEventListener implements Listener {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadFlags() && area.getRoadFlag(DropProtectionFlag.class)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, DropProtectionFlag.class, true)) {
event.setCancelled(true);
}
return;
@ -1690,17 +1693,15 @@ public class PlayerEventListener implements Listener {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadFlags() && area.getRoadFlag(KeepInventoryFlag.class)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, KeepInventoryFlag.class, true)) {
event.setCancelled(true);
}
return;
}
if (plot.getFlag(KeepInventoryFlag.class)) {
if (plot.getFlag(KeepInventoryFlag.class)) {
plot.debug(event.getEntity().getName() + " kept their inventory because of keep-inventory = true");
event.getDrops().clear();
event.setKeepInventory(true);
}
plot.debug(event.getEntity().getName() + " kept their inventory because of keep-inventory = true");
event.getDrops().clear();
event.setKeepInventory(true);
}
}
@ -1725,16 +1726,14 @@ public class PlayerEventListener implements Listener {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadFlags() && area.getRoadFlag(DenyPortalTravelFlag.class)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, DenyPortalTravelFlag.class, true)) {
event.setCancelled(true);
}
return;
}
if (plot.getFlag(DenyPortalTravelFlag.class)) {
if (plot.getFlag(DenyPortalTravelFlag.class)) {
plot.debug(event.getPlayer().getName() + " did not travel thru a portal because of deny-portal-travel = true");
event.setCancelled(true);
}
plot.debug(event.getPlayer().getName() + " did not travel thru a portal because of deny-portal-travel = true");
event.setCancelled(true);
}
}
@ -1772,7 +1771,7 @@ public class PlayerEventListener implements Listener {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadFlags() && area.getRoadFlag(DenyPortalsFlag.class)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, DenyPortalsFlag.class, true)) {
event.setCancelled(true);
return;
}
@ -1801,16 +1800,14 @@ public class PlayerEventListener implements Listener {
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadFlags() && area.getRoadFlag(LecternReadBookFlag.class)) {
if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, LecternReadBookFlag.class, true)) {
event.setCancelled(true);
}
return;
}
if (plot.getFlag(LecternReadBookFlag.class)) {
if (plot.getFlag(LecternReadBookFlag.class)) {
plot.debug(event.getPlayer().getName() + " could not take the book because of lectern-read-book = true");
event.setCancelled(true);
}
plot.debug(event.getPlayer().getName() + " could not take the book because of lectern-read-book = true");
event.setCancelled(true);
}
}

View File

@ -31,6 +31,7 @@ import com.plotsquared.core.plot.PlotHandler;
import com.plotsquared.core.plot.flag.implementations.ProjectilesFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotFlagUtil;
import net.kyori.adventure.text.minimessage.Template;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -97,14 +98,18 @@ public class ProjectileEventListener implements Listener {
return;
}
Location location = BukkitUtil.adapt(entity.getLocation());
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter);
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !Permissions.hasPermission(
pp,
Permission.PERMISSION_ADMIN_PROJECTILE_ROAD
)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD))
@ -154,6 +159,8 @@ public class ProjectileEventListener implements Listener {
if (plot.isAdded(((Player) shooter).getUniqueId()) || plot.getFlag(ProjectilesFlag.class)) {
return;
}
} else if (PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true)) {
return;
}
entity.remove();
@ -163,7 +170,10 @@ public class ProjectileEventListener implements Listener {
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
if (!PlotFlagUtil.isAreaRoadFlagsAndFlagEquals(area, ProjectilesFlag.class, true) && !Permissions.hasPermission(
pp,
Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED
)) {
entity.remove();
event.setCancelled(true);
}
@ -194,7 +204,6 @@ public class ProjectileEventListener implements Listener {
if (sPlot == null || !PlotHandler.sameOwners(plot, sPlot)) {
entity.remove();
event.setCancelled(true);
return;
}
}
}

View File

@ -44,6 +44,7 @@ public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + LimitedRegionWrapperQueue.class.getSimpleName());
private final LimitedRegion limitedRegion;
private boolean useOtherRestoreTagMethod = false;
/**
* @since 6.9.0
@ -65,10 +66,18 @@ public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
CompoundTag tag = id.getNbtData();
StateWrapper sw = new StateWrapper(tag);
try {
sw.restoreTag(limitedRegion.getBlockState(x, y, z).getBlock());
if (useOtherRestoreTagMethod && getWorld() != null) {
sw.restoreTag(getWorld().getName(), x, y, z);
} else {
sw.restoreTag(limitedRegion.getBlockState(x, y, z).getBlock());
}
} catch (IllegalArgumentException e) {
LOGGER.error("Error attempting to populate tile entity into the world at location {},{},{}", x, y, z, e);
return false;
} catch (IllegalStateException e) {
useOtherRestoreTagMethod = true;
LOGGER.warn("IllegalStateException attempting to populate tile entity into the world at location {},{},{}. " +
"Possibly on <=1.17.1, switching to secondary method.", x, y, z, e);
}
}
return result;

View File

@ -36,8 +36,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Set;
@ -46,10 +45,7 @@ public class FaweRegionManager extends BukkitRegionManager {
private final FaweDelegateRegionManager delegate = new FaweDelegateRegionManager();
@Inject
public FaweRegionManager(
@NonNull WorldUtil worldUtil, @NonNull GlobalBlockQueue blockQueue, @NonNull
ProgressSubscriberFactory subscriberFactory
) {
public FaweRegionManager(WorldUtil worldUtil, GlobalBlockQueue blockQueue, ProgressSubscriberFactory subscriberFactory) {
super(worldUtil, blockQueue, subscriberFactory);
}
@ -76,9 +72,9 @@ public class FaweRegionManager extends BukkitRegionManager {
@Override
public boolean handleClear(
@NotNull Plot plot,
@NonNull Plot plot,
@Nullable Runnable whenDone,
@NotNull PlotManager manager,
@NonNull PlotManager manager,
final @Nullable PlotPlayer<?> player
) {
if (!Settings.FAWE_Components.CLEAR || !(manager instanceof HybridPlotManager)) {

View File

@ -29,7 +29,7 @@ import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import com.sk89q.jnbt.CompoundTag;
import org.jetbrains.annotations.NotNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.InputStream;
import java.net.URL;
@ -40,7 +40,7 @@ public class FaweSchematicHandler extends SchematicHandler {
private final FaweDelegateSchematicHandler delegate = new FaweDelegateSchematicHandler();
@Inject
public FaweSchematicHandler(@NotNull WorldUtil worldUtil, @NotNull ProgressSubscriberFactory subscriberFactory) {
public FaweSchematicHandler(WorldUtil worldUtil, ProgressSubscriberFactory subscriberFactory) {
super(worldUtil, subscriberFactory);
}
@ -75,7 +75,7 @@ public class FaweSchematicHandler extends SchematicHandler {
}
@Override
public Schematic getSchematic(@NotNull InputStream is) {
public Schematic getSchematic(@NonNull InputStream is) {
return delegate.getSchematic(is);
}

View File

@ -142,14 +142,6 @@ public class Auto extends SubCommand {
}
}
}
int maxMerge = Permissions.hasPermissionRange(player, Permission.PERMISSION_MERGE, Settings.Limit.MAX_PLOTS);
if (sizeX * sizeZ > maxMerge) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_MERGE + "." + (sizeX * sizeZ))
);
return false;
}
return true;
}

View File

@ -177,7 +177,7 @@ public class Claim extends SubCommand {
}
}
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
int border = area.getBorder(false);
int border = area.getBorder();
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
player.sendMessage(TranslatableCaption.of("border.denied"));
return false;

View File

@ -35,6 +35,9 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.query.SortingStrategy;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import jdk.jfr.Category;
import jdk.jfr.Event;
import jdk.jfr.Label;
import net.kyori.adventure.text.minimessage.Template;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -59,13 +62,24 @@ public class HomeCommand extends Command {
this.plotAreaManager = plotAreaManager;
}
@Label("Home Query")
@Category("PlotSquared")
static class HomeQueryEvent extends Event {
@Label("Result Size")
public int size;
}
private void home(
final @NonNull PlotPlayer<?> player,
final @NonNull PlotQuery query, final int page,
final RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone
) {
final HomeQueryEvent event = new HomeQueryEvent();
event.begin();
List<Plot> plots = query.asList();
event.size = plots.size();
event.commit();
if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
return;

View File

@ -124,7 +124,7 @@ public class Merge extends SubCommand {
return false;
}
final int size = plot.getConnectedPlots().size();
int max = Permissions.hasPermissionRange(player, Permission.PERMISSION_MERGE, Settings.Limit.MAX_PLOTS);
int max = Permissions.hasPermissionRange(player, "plots.merge", Settings.Limit.MAX_PLOTS);
PlotMergeEvent event =
this.eventDispatcher.callMerge(plot, direction, max, player);
if (event.getEventResult() == Result.DENY) {
@ -282,7 +282,28 @@ public class Merge extends SubCommand {
run.run();
}
}
if (!force && !isOnline) {
if (force || !isOnline) {
if (force || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_MERGE_OTHER_OFFLINE)) {
if (plot.getPlotModificationManager().autoMerge(direction, maxSize - size, uuids.iterator().next(), player, terrain)) {
if (this.econHandler.isEnabled(plotArea) && price > 0d) {
if (!force && this.econHandler.getMoney(player) < price) {
player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_merge"),
Template.of("money", this.econHandler.format(price))
);
return false;
}
this.econHandler.withdrawMoney(player, price);
player.sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", this.econHandler.format(price))
);
}
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
eventDispatcher.callPostMerge(player, plot);
return true;
}
}
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
return false;
}

View File

@ -21,16 +21,15 @@ package com.plotsquared.core.configuration.caption;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.jetbrains.annotations.NotNull;
import java.util.EnumSet;
import java.util.Set;
final class ClickStripTransform implements ComponentTransform {
private final Set<ClickEvent.@NotNull Action> actionsToStrip;
private final Set<ClickEvent.@NonNull Action> actionsToStrip;
public ClickStripTransform(final Set<ClickEvent.@NotNull Action> actionsToStrip) {
public ClickStripTransform(final Set<ClickEvent.@NonNull Action> actionsToStrip) {
this.actionsToStrip = EnumSet.copyOf(actionsToStrip);
}

View File

@ -93,10 +93,10 @@ public class HybridPlotWorld extends ClassicPlotWorld {
@Inject
public HybridPlotWorld(
@Assisted("world") final String worldName,
@Nullable @Assisted("id") final String id,
@javax.annotation.Nullable @Assisted("id") final String id,
@Assisted final @NonNull IndependentPlotGenerator generator,
@Nullable @Assisted("min") final PlotId min,
@Nullable @Assisted("max") final PlotId max,
@javax.annotation.Nullable @Assisted("min") final PlotId min,
@javax.annotation.Nullable @Assisted("max") final PlotId max,
@WorldConfig final @NonNull YamlConfiguration worldConfiguration,
final @NonNull GlobalBlockQueue blockQueue
) {

View File

@ -234,44 +234,52 @@ public class HybridUtils {
Set<BlockType> types = new HashSet<>();
for (int yIndex = 0; yIndex < height; yIndex++) {
BlockState old = oldBlocks[yIndex][x][z]; // Nullable
try {
BlockState now = newBlocks[yIndex][x][z]; // Not null
if (!now.equals(old) && !(old == null && now.getBlockType().equals(BlockTypes.AIR))) {
changes[i]++;
}
if (now.getBlockType().getMaterial().isAir()) {
air[i]++;
} else {
// check vertices
// modifications_adjacent
if (x > 0 && z > 0 && yIndex > 0 && x < width - 1 && z < length - 1 && yIndex < (height - 1)) {
if (newBlocks[yIndex - 1][x][z].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex][x - 1][z].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex][x][z - 1].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex + 1][x][z].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex][x + 1][z].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex][x][z + 1].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
BlockState now = newBlocks[yIndex][x][z]; // Not null
if (now == null) {
throw new NullPointerException(String.format(
"\"now\" block null attempting to perform plot analysis. Indexes: x=%d of %d, yIndex=%d" +
" of %d, z=%d of %d",
x,
width,
yIndex,
height,
z,
length
));
}
if (!now.equals(old) && !(old == null && now.getBlockType().equals(BlockTypes.AIR))) {
changes[i]++;
}
if (now.getBlockType().getMaterial().isAir()) {
air[i]++;
} else {
// check vertices
// modifications_adjacent
if (x > 0 && z > 0 && yIndex > 0 && x < width - 1 && z < length - 1 && yIndex < (height - 1)) {
if (newBlocks[yIndex - 1][x][z].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex][x - 1][z].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex][x][z - 1].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex + 1][x][z].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex][x + 1][z].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
if (newBlocks[yIndex][x][z + 1].getBlockType().getMaterial().isAir()) {
faces[i]++;
}
}
if (!now.equals(now.getBlockType().getDefaultState())) {
data[i]++;
}
types.add(now.getBlockType());
if (!now.equals(now.getBlockType().getDefaultState())) {
data[i]++;
}
} catch (NullPointerException e) {
e.printStackTrace();
types.add(now.getBlockType());
}
}
variety[i] = types.size();

View File

@ -162,6 +162,7 @@ public enum Permission {
PERMISSION_LIST_AREA("plots.list.area"),
PERMISSION_ADMIN_COMMAND_LOAD("plots.admin.command.load"),
PERMISSION_ADMIN_COMMAND_MERGE("plots.admin.command.merge"),
PERMISSION_ADMIN_COMMAND_MERGE_OTHER_OFFLINE("plots.admin.command.merge.other.offline"),
PERMISSION_ADMIN_COMMAND_SET_OWNER("plots.admin.command.setowner"),
PERMISSION_COMMENT("plots.comment"),
PERMISSION_INBOX("plots.inbox"),

View File

@ -68,6 +68,9 @@ import com.plotsquared.core.util.task.TaskTime;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import jdk.jfr.Category;
import jdk.jfr.Event;
import jdk.jfr.Label;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
@ -122,9 +125,6 @@ public class Plot {
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private static final Cleaner CLEANER = Cleaner.create();
static Set<Plot> connected_cache;
static Set<CuboidRegion> regions_cache;
static {
FLAG_DECIMAL_FORMAT.setMaximumFractionDigits(340);
}
@ -207,6 +207,8 @@ public class Plot {
*/
private Plot origin;
private Set<Plot> connectedCache;
/**
* Constructor for a new plot.
* (Only changes after plot.create() will be properly set in the database)
@ -576,7 +578,14 @@ public class Plot {
return false;
}
final Set<Plot> connected = getConnectedPlots();
return connected.stream().anyMatch(current -> uuid.equals(current.getOwner()));
for (Plot current : connected) {
// can skip ServerPlotFlag check in getOwner()
// as flags are synchronized between plots
if (uuid.equals(current.getOwnerAbs())) {
return true;
}
}
return false;
}
/**
@ -1294,6 +1303,7 @@ public class Plot {
DBFunc.delete(current);
current.setOwnerAbs(null);
current.settings = null;
current.clearCache();
for (final PlotPlayer<?> pp : players) {
this.plotListener.plotEntry(pp, current);
}
@ -1864,6 +1874,7 @@ public class Plot {
this.area.removePlot(this.id);
this.id = plot.getId();
this.area.addPlotAbs(this);
clearCache();
DBFunc.movePlot(this, plot);
TaskManager.runTaskLater(whenDone, TaskTime.ticks(1L));
return true;
@ -2128,17 +2139,16 @@ public class Plot {
this.origin.origin = base;
other.origin = base;
this.origin = base;
connected_cache = null;
this.connectedCache = null;
}
} else {
if (this.origin != null) {
this.origin.origin = null;
this.origin = null;
}
connected_cache = null;
this.connectedCache = null;
}
DBFunc.setMerged(this, this.getSettings().getMerged());
regions_cache = null;
}
}
@ -2173,8 +2183,7 @@ public class Plot {
}
public void clearCache() {
connected_cache = null;
regions_cache = null;
this.connectedCache = null;
if (this.origin != null) {
this.origin.origin = null;
this.origin = null;
@ -2288,6 +2297,25 @@ public class Plot {
return this.area.getPlotAbs(this.id.getRelative(direction));
}
@Label("Connected Plots Search")
@Category("PlotSquared")
static class ConnectedPlotsEvent extends Event {
public ConnectedPlotsEvent(final int x, final int y) {
this.x = x;
this.y = y;
}
@Label("Plot Id X")
public int x;
@Label("Plot Id Y")
public int y;
@Label("Merged Plots Count")
public int mergedSize;
@Label("Connected Plots Cache Miss")
public boolean cacheMiss;
}
/**
* Gets a set of plots connected (and including) this plot<br>
* - This result is cached globally
@ -2295,16 +2323,21 @@ public class Plot {
* @return a Set of Plots connected to this Plot
*/
public Set<Plot> getConnectedPlots() {
ConnectedPlotsEvent event = new ConnectedPlotsEvent(this.id.getX(), this.id.getY());
event.begin();
if (this.settings == null) {
event.commit();
return Collections.singleton(this);
}
if (!this.isMerged()) {
event.commit();
return Collections.singleton(this);
}
if (connected_cache != null && connected_cache.contains(this)) {
return connected_cache;
if (this.connectedCache != null && this.connectedCache.contains(this)) {
event.mergedSize = this.connectedCache.size();
event.commit();
return this.connectedCache;
}
regions_cache = null;
HashSet<Plot> tmpSet = new HashSet<>();
tmpSet.add(this);
@ -2409,7 +2442,10 @@ public class Plot {
}
}
}
connected_cache = tmpSet;
this.connectedCache = tmpSet;
event.mergedSize = tmpSet.size();
event.cacheMiss = true;
event.commit();
return tmpSet;
}
@ -2421,19 +2457,15 @@ public class Plot {
* @return all regions within the plot
*/
public @NonNull Set<CuboidRegion> getRegions() {
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
return regions_cache;
}
if (!this.isMerged()) {
Location pos1 = this.getBottomAbs().withY(getArea().getMinBuildHeight());
Location pos2 = this.getTopAbs().withY(getArea().getMaxBuildHeight());
connected_cache = Sets.newHashSet(this);
this.connectedCache = Sets.newHashSet(this);
CuboidRegion rg = new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3());
regions_cache = Collections.singleton(rg);
return regions_cache;
return Collections.singleton(rg);
}
Set<Plot> plots = this.getConnectedPlots();
Set<CuboidRegion> regions = regions_cache = new HashSet<>();
Set<CuboidRegion> regions = new HashSet<>();
Set<PlotId> visited = new HashSet<>();
for (Plot current : plots) {
if (visited.contains(current.getId())) {
@ -2690,11 +2722,6 @@ public class Plot {
return false;
}
/**
* Get the maximum distance of the plot from x=0, z=0.
*
* @return max block distance from 0,0
*/
public int getDistanceFromOrigin() {
Location bot = getManager().getPlotBottomLocAbs(id);
Location top = getManager().getPlotTopLocAbs(id);
@ -2708,7 +2735,7 @@ public class Plot {
* Expands the world border to include this plot if it is beyond the current border.
*/
public void updateWorldBorder() {
int border = this.area.getBorder(false);
int border = this.area.getBorder();
if (border == Integer.MAX_VALUE) {
return;
}

View File

@ -143,7 +143,6 @@ public abstract class PlotArea {
private Map<String, PlotExpression> prices = new HashMap<>();
private List<String> schematics = new ArrayList<>();
private boolean worldBorder = false;
private int extraBorder;
private boolean useEconomy = false;
private int hash;
private CuboidRegion region;
@ -353,7 +352,6 @@ public abstract class PlotArea {
this.plotChat = config.getBoolean("chat.enabled");
this.forcingPlotChat = config.getBoolean("chat.forced");
this.worldBorder = config.getBoolean("world.border");
this.extraBorder = config.getInt("world.extra_border");
this.maxBuildHeight = config.getInt("world.max_height");
this.minBuildHeight = config.getInt("world.min_height");
this.minGenHeight = config.getInt("world.min_gen_height");
@ -471,7 +469,6 @@ public abstract class PlotArea {
options.put("event.spawn.custom", this.isSpawnCustom());
options.put("event.spawn.breeding", this.isSpawnBreeding());
options.put("world.border", this.hasWorldBorder());
options.put("world.extra_border", this.getExtaBorder());
options.put("home.default", "side");
String position = config.getString(
"home.nonmembers",
@ -911,9 +908,7 @@ public abstract class PlotArea {
* Get the plot border distance for a world<br>
*
* @return The border distance or Integer.MAX_VALUE if no border is set
* @deprecated Use {@link PlotArea#getBorder(boolean)}
*/
@Deprecated(forRemoval = true, since = "TODO")
public int getBorder() {
final Integer meta = (Integer) getMeta("worldBorder");
if (meta != null) {
@ -927,27 +922,6 @@ public abstract class PlotArea {
return Integer.MAX_VALUE;
}
/**
* Get the plot border distance for a world, specifying whether the returned value should include the world.extra-border
* value.
*
* @param includeExtra If the extra border given by world.extra-border should be included
* @return Border distance of Integer.MAX_VALUE if no border is set
* @since TODO
*/
public int getBorder(boolean includeExtra) {
final Integer meta = (Integer) getMeta("worldBorder");
if (meta != null) {
int border = meta + 1;
if (border == 0) {
return Integer.MAX_VALUE;
} else {
return includeExtra ? border + extraBorder : border;
}
}
return Integer.MAX_VALUE;
}
/**
* Setup the plot border for a world (usually done when the world is created).
*/
@ -1207,16 +1181,6 @@ public abstract class PlotArea {
return worldBorder;
}
/**
* Get the "extra border" size of the plot area.
*
* @return Plot area extra border size
* @since TODO
*/
public int getExtaBorder() {
return extraBorder;
}
/**
* Get whether plot signs are allowed or not.
*

View File

@ -263,6 +263,7 @@ public final class PlotModificationManager {
return;
}
Plot current = queue.poll();
current.clearCache();
if (plot.getArea().getTerrain() != PlotAreaTerrainType.NONE) {
try {
PlotSquared.platform().regionManager().regenerateRegion(
@ -327,6 +328,7 @@ public final class PlotModificationManager {
ArrayList<PlotId> ids = new ArrayList<>(plots.size());
for (Plot current : plots) {
current.setHome(null);
current.clearCache();
ids.add(current.getId());
}
this.plot.clearRatings();
@ -478,8 +480,7 @@ public final class PlotModificationManager {
this.plot.updateWorldBorder();
}
}
Plot.connected_cache = null;
Plot.regions_cache = null;
this.plot.clearCache();
this.plot.getTrusted().clear();
this.plot.getMembers().clear();
this.plot.getDenied().clear();
@ -630,6 +631,7 @@ public final class PlotModificationManager {
if (queue.size() > 0) {
queue.enqueue();
}
visited.forEach(Plot::clearCache);
return toReturn;
}

View File

@ -18,7 +18,8 @@
*/
package com.plotsquared.core.plot;
import javax.annotation.Nullable;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Objects;
public class PlotTitle {

View File

@ -0,0 +1,53 @@
/*
* PlotSquared, a land and world management plugin for Minecraft.
* Copyright (C) IntellectualSites <https://intellectualsites.com>
* Copyright (C) IntellectualSites team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.util;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.PlotFlag;
import java.util.Objects;
/**
* Util class for generic methods relating to plot flags.
*
* @since 6.10.4
*/
public final class PlotFlagUtil {
private PlotFlagUtil() {
//No-op
}
/**
* Check if the value of a {@link PlotFlag} matches the given value. If
* road flags are disabled for the given plot area, returns false.
*
* @param flagClass boolean flag to get value of
* @param value boolean value to check flag value against
* @param <T> The flag value type
* @return true if road flag value matches with road flags enabled
* @since 6.10.4
*/
public static <T> boolean isAreaRoadFlagsAndFlagEquals(
PlotArea area, final Class<? extends PlotFlag<T, ?>> flagClass, T value
) {
return area.isRoadFlags() && Objects.equals(area.getRoadFlag(flagClass), value);
}
}

View File

@ -23,9 +23,9 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.List;
class GlobalPlotProvider implements PlotProvider {
@ -37,7 +37,7 @@ class GlobalPlotProvider implements PlotProvider {
@Override
public Collection<Plot> getPlots() {
final Set<Plot> plots = new HashSet<>();
final List<Plot> plots = new ArrayList<>();
for (final PlotArea plotArea : this.plotAreaManager.getAllPlotAreas()) {
plots.addAll(plotArea.getPlots());
}

View File

@ -19,7 +19,7 @@ plugins {
}
group = "com.plotsquared"
version = "6.10.4-SNAPSHOT"
version = "6.10.6-SNAPSHOT"
subprojects {
group = rootProject.group
@ -65,7 +65,7 @@ subprojects {
}
dependencies {
implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.18"))
implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.21"))
}
dependencies {

View File

@ -4,7 +4,7 @@ guice = "5.1.0"
spotbugs = "4.7.3"
# Plugins
worldedit = "7.2.12"
worldedit = "7.2.13"
placeholderapi = "2.11.2"
luckperms = "5.4"
essentialsx = "2.19.7"
@ -13,7 +13,7 @@ mvdwapi = "3.1.1"
# Third party
prtree = "2.0.0"
aopalliance = "1.0"
cloud-services = "1.7.1"
cloud-services = "1.8.0"
arkitektonika = "2.1.1"
squirrelid = "0.3.1"
http4j = "1.3"

Binary file not shown.

View File

@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

12
gradlew vendored
View File

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@ -80,10 +80,10 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac

1
gradlew.bat vendored
View File

@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%