Compare commits

...

44 Commits

Author SHA1 Message Date
e06bf2cd6b Checkstyle 2023-03-04 23:33:44 +01:00
0484915233 Record-inize methods 2023-03-04 12:55:50 +01:00
276e619caa Merge branch 'v6' into v7 2023-03-04 11:19:48 +01:00
f11acacedd Update dependency com.intellectualsites.prtree:PRTree to v2.0.1 (#3975)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-02 22:36:18 +01:00
f636a5ec63 Merge branch 'v6' into v7 2023-03-02 20:48:43 +01:00
d1bac90745 Update developers field 2023-03-02 20:48:33 +01:00
785362c576 Merge branch 'v6' into v7 2023-03-02 12:34:18 +01:00
e98f628d34 Pin GH actions to SHA to avoid mutable refs (#3973) 2023-03-02 12:30:14 +01:00
b2ab61559c Update dependency com.diffplug.spotless to v6.16.0 (#3970)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-02 00:46:34 +01:00
dd6eb8e74f Update dependency cloud.commandframework:cloud-services to v1.8.2 (#3971)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-02 00:46:19 +01:00
97cdd03ea4 Update dependency gradle to v7.6.1 (#3967)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-27 21:24:04 +01:00
f5118e6802 Don't fire 'PlotUnlinkEvent' twice on plot clear (#3947) 2023-02-23 09:26:30 +01:00
94ca5cf679 Update dependency cloud.commandframework:cloud-services to v1.8.1 (#3965)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-22 23:47:31 +01:00
5a55a1f602 Update dependency io.github.gradle-nexus.publish-plugin to v1.2.0 (#3966)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-22 23:47:13 +01:00
1e7ba7d173 Merge branch 'v6' into v7 2023-02-12 19:06:11 +01:00
ed33635a15 Update dependency com.diffplug.spotless to v6.15.0 (#3959)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-11 09:35:35 +01:00
888682e5d0 Update dependency com.intellectualsites.bom:bom-1.18.x to v1.24 (#3960)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-11 09:35:21 +01:00
72bb5f00b0 Back to snapshot for development 2023-02-10 17:16:52 +01:00
773fd6f59f Release 6.11.0 2023-02-10 17:12:15 +01:00
aa784e98f8 Merge branch 'v6' into v7 2023-02-10 16:44:57 +01:00
5cce86d924 feat: Add event firing on remove road entity (#3955)
* feat: Add event firing on remove road entity

Signed-off-by: ByteExceptionM <git@byteexception.eu>

* chore: Add some more entity vars

Signed-off-by: ByteExceptionM <git@byteexception.eu>

* chore: Rename method

Signed-off-by: ByteExceptionM <git@byteexception.eu>

* chore: Code cleanup

Signed-off-by: ByteExceptionM <git@byteexception.eu>

* chore: Code reformat

Signed-off-by: ByteExceptionM <git@byteexception.eu>

* chore: Change iterator removal

Signed-off-by: ByteExceptionM <git@byteexception.eu>

* Comply with checkstyle

---------

Signed-off-by: ByteExceptionM <git@byteexception.eu>
Co-authored-by: Alexander Brandes <mc.cache@web.de>
2023-02-09 20:51:59 +01:00
84567bcb00 Update dependency com.diffplug.spotless to v6.14.1 (#3957)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-06 12:48:30 +01:00
d7c2ab1d16 Make farmland keep its moisture (#3952)
Handle MoistureChangeEvent for farm land
2023-01-31 11:22:13 +01:00
0d359ade0c Update dependency com.diffplug.spotless to v6.14.0 (#3950)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-28 19:21:35 +01:00
ffbec24290 Update dependency com.intellectualsites.bom:bom-1.18.x to v1.23 (#3948)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-01-24 22:35:15 +01:00
586474c8e6 Merge branch 'v6' into v7 2023-01-23 13:40:52 +01:00
70b6636f50 Revert "Cleanup deprecated methods"
This reverts commit 26692d6633.
2023-01-23 13:40:47 +01:00
ab357deb48 Put more legacy web interface deprecations in place 2023-01-23 13:40:35 +01:00
bd62d1a1c7 Merge branch 'v6' into v7 2023-01-23 13:28:12 +01:00
6130c3dfa5 Clarify 2D biome deprecation 2023-01-23 13:28:05 +01:00
26692d6633 Cleanup deprecated methods 2023-01-23 13:27:08 +01:00
bb0f200429 Merge branch 'v6' into v7 2023-01-23 13:18:28 +01:00
5787588500 Move BukkitPlotGenerator#generateChunkData() deprecation from v7 to v6 2023-01-23 13:18:20 +01:00
bed62edc02 Resolved conflicts 2023-01-23 13:03:26 +01:00
ee0f389c78 Merge branch 'v6' into v7 2023-01-23 13:01:48 +01:00
b40383b5a4 Back to snapshot for development 2023-01-23 12:33:51 +01:00
be8903128d Release 6.10.9 2023-01-23 12:28:33 +01:00
08800ec16d Cleanup deperecated WorldEdit met
Co-authored-by: Matthew Kaulfers <42121989+mkaulfers@users.noreply.github.com>
2023-01-22 11:26:07 +01:00
83e274ff9f Revert "PS-3908: Cleanup deprecated methods to improve code maturity. (#3944)"
This reverts commit 0dd8b1053c.
2023-01-22 11:21:01 +01:00
0dd8b1053c PS-3908: Cleanup deprecated methods to improve code maturity. (#3944)
https://github.com/IntellectualSites/PlotSquared/issues/3908
2023-01-22 00:02:15 +01:00
0558fcf5d5 Provide full verbosity for invalid components 2023-01-21 22:27:20 +01:00
5af8be4293 chore: Remove things marked as for removal (#3941)
* chore: Remove things marked as for removal

* Address feedback

Co-authored-by: Alexander Brandes <mc.cache@web.de>
2023-01-21 16:44:28 +01:00
cbacdd67eb Merge branch 'v6' into v7 2023-01-21 16:39:14 +01:00
c45bbe3ec5 fix: ensure plots are fully unlinked before the clear itself is run (#3933)
* fix: ensure plots are fully unlinked before the clear itself is run

* Update Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java

Co-authored-by: Alexander Brandes <mc.cache@web.de>
2023-01-19 09:01:06 +01:00
64 changed files with 547 additions and 868 deletions

View File

@ -2,7 +2,6 @@ name: Announce release on discord
on:
release:
types: [published]
jobs:
send_announcement:
runs-on: ubuntu-latest
@ -12,7 +11,7 @@ jobs:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_USERNAME: PlotSquared Release
DISCORD_AVATAR: https://raw.githubusercontent.com/IntellectualSites/Assets/main/plugins/PlotSquared/PlotSquared.png
uses: Ilshidur/action-discord@0.3.2
uses: Ilshidur/action-discord@0c4b27844ba47cb1c7bee539c8eead5284ce9fa9 # ratchet:Ilshidur/action-discord@0.3.2
with:
args: |
"<@&525015541815967744> <@&679322738552471574> <@&699293353862496266>"

View File

@ -1,19 +1,17 @@
name: Build PR
on: [ pull_request ]
on: [pull_request]
jobs:
build_pr:
if: github.repository_owner == 'IntellectualSites'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@55e685c48d84285a5b0418cd094606e199cca3b6 # v1
- name: Setup Java
uses: actions/setup-java@v3
with:

View File

@ -1,10 +1,8 @@
name: build
on:
push:
branches:
- v7
jobs:
build:
if: github.repository_owner == 'IntellectualSites'
@ -13,7 +11,7 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@55e685c48d84285a5b0418cd094606e199cca3b6 # v1
- name: Setup Java
uses: actions/setup-java@v3
with:
@ -44,9 +42,14 @@ jobs:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
- name: Publish core javadoc
<<<<<<< HEAD
# if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}}
if: ${{ runner.os == 'Linux' && env.STATUS == 'snapshot' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}}
uses: cpina/github-action-push-to-another-repository@main
=======
if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}}
uses: cpina/github-action-push-to-another-repository@0a14457bb28b04dfa1652e0ffdfda866d2845c73 # main
>>>>>>> v6
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with:
@ -59,7 +62,7 @@ jobs:
- name: Publish bukkit javadoc
# if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}}
if: ${{ runner.os == 'Linux' && env.STATUS == 'snapshot' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}}
uses: cpina/github-action-push-to-another-repository@main
uses: cpina/github-action-push-to-another-repository@0a14457bb28b04dfa1652e0ffdfda866d2845c73 # main
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with:

View File

@ -1,5 +1,4 @@
name: "CodeQL"
on:
push:
branches: [ v7 ]
@ -15,23 +14,18 @@ jobs:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'java' ]
language: ['java']
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@32dc499307d133bb5085bae78498c0ac2cf762d5 # v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@32dc499307d133bb5085bae78498c0ac2cf762d5 # v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@32dc499307d133bb5085bae78498c0ac2cf762d5 # v2

View File

@ -1,14 +1,12 @@
name: draft release
on:
push:
branches:
- v6
pull_request:
types: [ opened, reopened, synchronize ]
types: [opened, reopened, synchronize]
pull_request_target:
types: [ opened, reopened, synchronize ]
types: [opened, reopened, synchronize]
jobs:
update_release_draft:
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}

View File

@ -72,6 +72,8 @@ import com.plotsquared.core.configuration.Storage;
import com.plotsquared.core.configuration.caption.ChatFormatter;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.RemoveRoadEntityEvent;
import com.plotsquared.core.events.Result;
import com.plotsquared.core.generator.GeneratorWrapper;
import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.generator.SingleWorldGenerator;
@ -110,6 +112,7 @@ import com.plotsquared.core.uuid.CacheUUIDService;
import com.plotsquared.core.uuid.UUIDPipeline;
import com.plotsquared.core.uuid.offline.OfflineModeUUIDService;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import io.papermc.lib.PaperLib;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
@ -818,8 +821,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
this.removeRoadEntity(entity, iterator);
}
continue;
}
@ -832,8 +834,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
this.removeRoadEntity(entity, iterator);
}
}
continue;
@ -843,7 +844,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
case "DROPPED_ITEM":
if (Settings.Enabled_Components.KILL_ROAD_ITEMS
&& plotArea.getOwnedPlotAbs(BukkitUtil.adapt(entity.getLocation())) == null) {
entity.remove();
this.removeRoadEntity(entity, iterator);
}
// dropped item
continue;
@ -874,8 +875,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
this.removeRoadEntity(entity, iterator);
}
}
}
@ -980,8 +980,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
this.removeRoadEntity(entity, iterator);
}
}
} else {
@ -992,8 +991,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
this.removeRoadEntity(entity, iterator);
}
}
}
@ -1007,6 +1005,17 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
}), TaskTime.seconds(1L));
}
private void removeRoadEntity(Entity entity, Iterator<Entity> entityIterator) {
RemoveRoadEntityEvent event = eventDispatcher.callRemoveRoadEntity(BukkitAdapter.adapt(entity));
if (event.getEventResult() == Result.DENY) {
return;
}
entityIterator.remove();
entity.remove();
}
@Override
public @Nullable
final ChunkGenerator getDefaultWorldGenerator(

View File

@ -24,7 +24,6 @@ import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.location.UncheckedWorldLocation;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
import org.bukkit.generator.BlockPopulator;
@ -47,17 +46,6 @@ final class BlockStatePopulator extends BlockPopulator {
this.plotGenerator = plotGenerator;
}
/**
* @deprecated Use {@link BlockStatePopulator#BlockStatePopulator(IndependentPlotGenerator)} as plotAreManager is unused
*/
@Deprecated(forRemoval = true, since = "6.9.0")
public BlockStatePopulator(
final @NonNull IndependentPlotGenerator plotGenerator,
final @NonNull PlotAreaManager plotAreaManager
) {
this.plotGenerator = plotGenerator;
}
@Override
public void populate(
@NonNull final WorldInfo worldInfo,

View File

@ -185,6 +185,12 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
world.setWaterAnimalSpawnLimit(limit);
}
/**
* The entire method is deprecated, but kept for compatibility with versions lower than or equal to 1.16.2.
* The method will be removed in future versions, because WorldEdit and FastAsyncWorldEdit only support the latest point
* release.
*/
@Deprecated(forRemoval = true, since = "6.11.0")
@Override
public void generateNoise(
@NotNull final WorldInfo worldInfo,

View File

@ -99,6 +99,7 @@ import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.CauldronLevelChangeEvent;
import org.bukkit.event.block.EntityBlockFormEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.MoistureChangeEvent;
import org.bukkit.event.block.SpongeAbsorbEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.projectiles.BlockProjectileSource;
@ -740,6 +741,28 @@ public class BlockEventListener implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onMoistureChange(MoistureChangeEvent event) {
Block block = event.getBlock();
Location location = BukkitUtil.adapt(block.getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = area.getOwnedPlot(location);
if (plot == null) {
event.setCancelled(true);
return;
}
Material blockType = block.getType();
if (blockType == Material.FARMLAND) {
if (!plot.getFlag(SoilDryFlag.class)) {
plot.debug("Soil could not dry because soil-dry = false");
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChange(BlockFromToEvent event) {
Block fromBlock = event.getBlock();

View File

@ -1,93 +0,0 @@
/*
* 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.bukkit.listener;
import com.google.inject.Inject;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.bukkit.block.Banner;
import org.bukkit.block.Beacon;
import org.bukkit.block.BlockState;
import org.bukkit.block.CommandBlock;
import org.bukkit.block.Comparator;
import org.bukkit.block.Conduit;
import org.bukkit.block.Container;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.DaylightDetector;
import org.bukkit.block.EnchantingTable;
import org.bukkit.block.EndGateway;
import org.bukkit.block.EnderChest;
import org.bukkit.block.Jukebox;
import org.bukkit.block.Sign;
import org.bukkit.block.Skull;
import org.bukkit.block.Structure;
import org.bukkit.block.data.type.Bed;
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
public PaperListener113(@NonNull PlotAreaManager plotAreaManager) {
super(plotAreaManager);
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (!Settings.Paper_Components.TILE_ENTITY_CHECK || !Settings.Enabled_Components.CHUNK_PROCESSOR) {
return;
}
BlockState state = event.getBlock().getState(false);
if (!(state instanceof Banner || state instanceof Beacon || state instanceof Bed || state instanceof CommandBlock
|| state instanceof Comparator || state instanceof Conduit || state instanceof Container || state instanceof CreatureSpawner
|| state instanceof DaylightDetector || state instanceof EnchantingTable || state instanceof EnderChest || state instanceof EndGateway
|| state instanceof Jukebox || state instanceof Sign || state instanceof Skull || state instanceof Structure)) {
return;
}
final Location location = BukkitUtil.adapt(event.getBlock().getLocation());
final PlotArea plotArea = location.getPlotArea();
if (plotArea == null) {
return;
}
final int tileEntityCount = event.getBlock().getChunk().getTileEntities(false).length;
if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) {
final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer());
plotPlayer.sendMessage(
TranslatableCaption.of("errors.tile_entity_cap_reached"),
TagResolver.resolver("amount", Tag.inserting(Component.text(Settings.Chunk_Processor.MAX_TILES)))
);
event.setCancelled(true);
event.setBuild(false);
}
}
}

View File

@ -52,7 +52,7 @@ public class MVdWPlaceholders {
@Subscribe
public void onNewPlaceholder(final PlaceholderRegistry.@NonNull PlaceholderAddedEvent event) {
this.addPlaceholder(event.getPlaceholder());
this.addPlaceholder(event.placeholder());
}
private void addPlaceholder(final @NonNull Placeholder placeholder) {

View File

@ -71,31 +71,11 @@ public class BukkitPlayer extends PlotPlayer<Player> {
* @param eventDispatcher EventDispatcher instance
* @param player Bukkit player instance
* @param permissionHandler PermissionHandler instance
*
* @deprecated Please do not use this method. Instead use {@link BukkitUtil#adapt(Player)}, as it caches player objects.
* This method will be made private in a future release.
*/
@Deprecated(forRemoval = true, since = "TODO")
public BukkitPlayer(
final @NonNull PlotAreaManager plotAreaManager, final @NonNull EventDispatcher eventDispatcher,
final @NonNull Player player, final @NonNull PermissionHandler permissionHandler
) {
this(plotAreaManager, eventDispatcher, player, false, permissionHandler);
}
/**
* @param plotAreaManager PlotAreaManager instance
* @param eventDispatcher EventDispatcher instance
* @param player Bukkit player instance
* @param permissionHandler PermissionHandler instance
*
* @deprecated Please do not use this method. Instead use {@link BukkitUtil#adapt(Player)}, as it caches player objects.
* This method will be made private in a future release.
*/
@Deprecated(forRemoval = true, since = "TODO")
public BukkitPlayer(
final @NonNull PlotAreaManager plotAreaManager, final @NonNull
EventDispatcher eventDispatcher, final @NonNull Player player,
BukkitPlayer(
final @NonNull PlotAreaManager plotAreaManager,
final @NonNull EventDispatcher eventDispatcher,
final @NonNull Player player,
final boolean realPlayer,
final @NonNull PermissionHandler permissionHandler
) {

View File

@ -54,7 +54,6 @@ public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
@NonNull
@Override
@SuppressWarnings("deprecation")
public BukkitPlayer getPlayer(final @NonNull Player object) {
if (object.getUniqueId().version() == 2) { // not a real player
return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, object, false, this.permissionHandler);
@ -66,13 +65,12 @@ public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
}
@Override
@SuppressWarnings("deprecation")
public @NonNull BukkitPlayer createPlayer(final @NonNull UUID uuid) {
final Player player = Bukkit.getPlayer(uuid);
if (player == null || !player.isOnline()) {
throw new NoSuchPlayerException(uuid);
}
return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, player, this.permissionHandler);
return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, player, false, this.permissionHandler);
}
@Nullable

View File

@ -110,9 +110,9 @@ public class GenChunk extends ZeroedDelegateScopedQueueCoordinator {
*/
public void setChunk(@NonNull ChunkWrapper wrap) {
chunk = null;
world = wrap.world;
chunkX = wrap.x;
chunkZ = wrap.z;
world = wrap.world();
chunkX = wrap.x();
chunkZ = wrap.z();
}
@Override

View File

@ -37,7 +37,6 @@ import org.bukkit.block.Sign;
import org.bukkit.block.Skull;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -52,15 +51,6 @@ public class StateWrapper {
public org.bukkit.block.BlockState state = null;
public CompoundTag tag = null;
/**
* @deprecated in favour of using WE methods for obtaining NBT, specifically by obtaining a
* {@link com.sk89q.worldedit.world.block.BaseBlock} and then using {@link com.sk89q.worldedit.world.block.BaseBlock#getNbtData()}
*/
@Deprecated(forRemoval = true, since = "6.9.0")
public StateWrapper(org.bukkit.block.BlockState state) {
this.state = state;
}
public StateWrapper(CompoundTag tag) {
this.tag = tag;
}
@ -254,26 +244,6 @@ public class StateWrapper {
return false;
}
/**
* Get a CompoundTag of the contents of a block's inventory (chest, furnace, etc.).
*
* @deprecated in favour of using WorldEdit methods for obtaining NBT, specifically by obtaining a
* {@link com.sk89q.worldedit.world.block.BaseBlock} and then using {@link com.sk89q.worldedit.world.block.BaseBlock#getNbtData()}
*/
@Deprecated(forRemoval = true, since = "6.9.0")
public CompoundTag getTag() {
if (this.tag != null) {
return this.tag;
}
if (this.state instanceof InventoryHolder inv) {
ItemStack[] contents = inv.getInventory().getContents();
Map<String, Tag> values = new HashMap<>();
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(contents)));
return new CompoundTag(values);
}
return null;
}
public String getId() {
String tileid = this.tag.getString("id").toLowerCase();
if (tileid.startsWith("minecraft:")) {

View File

@ -124,7 +124,7 @@ public class BukkitSetupUtils extends SetupUtils {
public String setupWorld(PlotAreaBuilder builder) {
this.updateGenerators(false);
ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ?
new ConfigurationNode[0] : builder.settingsNodesWrapper().getSettingsNodes();
new ConfigurationNode[0] : builder.settingsNodesWrapper().settingsNodes();
String world = builder.worldName();
PlotAreaType type = builder.plotAreaType();
String worldPath = "worlds." + builder.worldName();

View File

@ -111,8 +111,8 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
try (final PreparedStatement statement = getConnection()
.prepareStatement("INSERT OR REPLACE INTO `usercache` (`uuid`, `username`) VALUES(?, ?)")) {
for (final UUIDMapping mapping : uuidWrappers) {
statement.setString(1, mapping.getUuid().toString());
statement.setString(2, mapping.getUsername());
statement.setString(1, mapping.uuid().toString());
statement.setString(2, mapping.username());
statement.executeUpdate();
}
} catch (SQLException e) {

View File

@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at contact@intellectualsites.com. All
reported by contacting the project team at contact<at>intellectualsites.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.

View File

@ -136,33 +136,29 @@ public class SimpleBackupManager implements BackupManager {
return this.backupLimit;
}
private static final class PlotCacheKey {
private final Plot plot;
private PlotCacheKey(Plot plot) {
this.plot = plot;
}
private record PlotCacheKey(
Plot plot
) {
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final PlotCacheKey that = (PlotCacheKey) o;
return Objects.equals(plot.getArea(), that.plot.getArea())
&& Objects.equals(plot.getId(), that.plot.getId())
&& Objects.equals(plot.getOwnerAbs(), that.plot.getOwnerAbs());
}
if (o == null || getClass() != o.getClass()) {
return false;
@Override
public int hashCode() {
return Objects.hash(plot.getArea(), plot.getId(), plot.getOwnerAbs());
}
final PlotCacheKey that = (PlotCacheKey) o;
return Objects.equals(plot.getArea(), that.plot.getArea())
&& Objects.equals(plot.getId(), that.plot.getId())
&& Objects.equals(plot.getOwnerAbs(), that.plot.getOwnerAbs());
}
@Override
public int hashCode() {
return Objects.hash(plot.getArea(), plot.getId(), plot.getOwnerAbs());
}
}
}

View File

@ -55,6 +55,7 @@ import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal3;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.EditSessionBuilder;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
@ -232,10 +233,9 @@ public class Area extends SubCommand {
try (final ClipboardWriter clipboardWriter = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream(
file))) {
final BlockArrayClipboard clipboard = new BlockArrayClipboard(selectedRegion);
final EditSession editSession = WorldEdit
.getInstance()
.getEditSessionFactory()
.getEditSession(selectedRegion.getWorld(), -1);
EditSessionBuilder editSessionBuilder = WorldEdit.getInstance().newEditSessionBuilder();
editSessionBuilder.world(selectedRegion.getWorld());
final EditSession editSession = editSessionBuilder.build();
final ForwardExtentCopy forwardExtentCopy =
new ForwardExtentCopy(editSession, selectedRegion, clipboard, selectedRegion.getMinimumPoint());
forwardExtentCopy.setCopyingBiomes(true);

View File

@ -35,6 +35,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.services.plots.AutoQuery;
import com.plotsquared.core.services.plots.AutoService;
import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher;
@ -326,7 +327,7 @@ public class Auto extends SubCommand {
}
List<Plot> plots = this.servicePipeline
.pump(new AutoService.AutoQuery(player, null, sizeX, sizeZ, plotarea))
.pump(new AutoQuery(player, null, sizeX, sizeZ, plotarea))
.through(AutoService.class)
.getResult();

View File

@ -108,7 +108,6 @@ public class Clear extends Command {
BackupManager.backup(player, plot, () -> {
final long start = System.currentTimeMillis();
boolean result = plot.getPlotModificationManager().clear(true, false, player, () -> {
plot.getPlotModificationManager().unlink();
TaskManager.runTask(() -> {
plot.removeRunning();
// If the state changes, then mark it as no longer done

View File

@ -85,24 +85,24 @@ public class Inbox extends SubCommand {
for (int x = page * 12; x < max; x++) {
PlotComment comment = comments[x];
Component commentColored;
if (player.getName().equals(comment.senderName)) {
if (player.getName().equals(comment.senderName())) {
commentColored = MINI_MESSAGE
.deserialize(
TranslatableCaption.of("list.comment_list_by_lister").getComponent(player),
TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment)))
TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment())))
);
} else {
commentColored = MINI_MESSAGE
.deserialize(
TranslatableCaption.of("list.comment_list_by_other").getComponent(player),
TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment)))
TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment())))
);
}
TagResolver resolver = TagResolver.builder()
.tag("number", Tag.inserting(Component.text(x)))
.tag("world", Tag.inserting(Component.text(comment.world)))
.tag("plot_id", Tag.inserting(Component.text(comment.id.getX() + ";" + comment.id.getY())))
.tag("commenter", Tag.inserting(Component.text(comment.senderName)))
.tag("world", Tag.inserting(Component.text(comment.world())))
.tag("plot_id", Tag.inserting(Component.text(comment.id().getX() + ";" + comment.id().getY())))
.tag("commenter", Tag.inserting(Component.text(comment.senderName())))
.tag("comment", Tag.inserting(commentColored))
.build();
builder.append(MINI_MESSAGE
@ -137,7 +137,7 @@ public class Inbox extends SubCommand {
int unread = 0;
for (PlotComment comment : value) {
total++;
if (comment.timestamp > CommentManager
if (comment.timestamp() > CommentManager
.getTimestamp(player, inbox.toString())) {
unread++;
}
@ -242,7 +242,7 @@ public class Inbox extends SubCommand {
if (success) {
player.sendMessage(
TranslatableCaption.of("comment.comment_removed_success"),
TagResolver.resolver("value", Tag.inserting(Component.text(comment.comment)))
TagResolver.resolver("value", Tag.inserting(Component.text(comment.comment())))
);
} else {
player.sendMessage(

View File

@ -474,20 +474,20 @@ public class ListCmd extends SubCommand {
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
for (final UUIDMapping uuidMapping : names) {
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid());
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.uuid());
TagResolver resolver = TagResolver.builder()
.tag("prefix", Tag.inserting(Component.text(prefix)))
.tag("player", Tag.inserting(Component.text(uuidMapping.getUsername())))
.tag("player", Tag.inserting(Component.text(uuidMapping.username())))
.build();
if (pp != null) {
builder.append(MINI_MESSAGE.deserialize(online, resolver));
} else if (uuidMapping.getUsername().equalsIgnoreCase("unknown")) {
} else if (uuidMapping.username().equalsIgnoreCase("unknown")) {
TagResolver unknownResolver = TagResolver.resolver(
"info.unknown",
Tag.inserting(TranslatableCaption.of("info.unknown").toComponent(player))
);
builder.append(MINI_MESSAGE.deserialize(unknown, unknownResolver));
} else if (uuidMapping.getUuid().equals(DBFunc.EVERYONE)) {
} else if (uuidMapping.uuid().equals(DBFunc.EVERYONE)) {
TagResolver everyoneResolver = TagResolver.resolver(
"info.everyone",
Tag.inserting(TranslatableCaption.of("info.everyone").toComponent(player))

View File

@ -127,7 +127,7 @@ public class Purge extends SubCommand {
);
return false;
}
owner = ownerMapping.getUuid();
owner = ownerMapping.uuid();
break;
case "shared":
case "s":
@ -139,7 +139,7 @@ public class Purge extends SubCommand {
);
return false;
}
added = addedMapping.getUuid();
added = addedMapping.uuid();
break;
case "clear":
case "c":

View File

@ -156,9 +156,9 @@ public class Template extends SubCommand {
ZipOutputStream zos = new ZipOutputStream(fos)) {
for (FileBytes file : files) {
ZipEntry ze = new ZipEntry(file.path);
ZipEntry ze = new ZipEntry(file.path());
zos.putNextEntry(ze);
zos.write(file.data);
zos.write(file.data());
}
zos.closeEntry();
}

View File

@ -35,34 +35,21 @@ import java.util.Map;
* the component GUI
*/
@SerializableAs("preset")
public class ComponentPreset implements ConfigurationSerializable {
private final ClassicPlotManagerComponent component;
private final String pattern;
private final double cost;
private final String permission;
private final String displayName;
private final List<String> description;
private final ItemType icon;
public ComponentPreset(
ClassicPlotManagerComponent component, String pattern, double cost,
String permission, String displayName, List<String> description, final ItemType icon
) {
this.component = component;
this.pattern = pattern;
this.cost = cost;
this.permission = permission;
this.displayName = displayName;
this.description = description;
this.icon = icon;
}
public record ComponentPreset(
ClassicPlotManagerComponent component,
String pattern,
double cost,
String permission,
String displayName,
List<String> description,
ItemType icon
) implements ConfigurationSerializable {
@SuppressWarnings("unchecked")
public static ComponentPreset deserialize(final @NonNull Map<String, Object> map) {
final ClassicPlotManagerComponent classicPlotManagerComponent = ClassicPlotManagerComponent
.fromString(map.getOrDefault("component", "").toString()).orElseThrow(() ->
new IllegalArgumentException("The preset needs a valid target component"));
new IllegalArgumentException("The preset in components.yml needs a valid target component, got: " + map.get("component")));
final String pattern = map.getOrDefault("pattern", "").toString();
final double cost = Double.parseDouble(map.getOrDefault("cost", "0.0").toString());
final String permission = map.getOrDefault("permission", "").toString();
@ -74,34 +61,6 @@ public class ComponentPreset implements ConfigurationSerializable {
);
}
public ClassicPlotManagerComponent getComponent() {
return this.component;
}
public String getPattern() {
return this.pattern;
}
public double getCost() {
return this.cost;
}
public String getPermission() {
return this.permission;
}
public String getDisplayName() {
return this.displayName;
}
public List<String> getDescription() {
return this.description;
}
public ItemType getIcon() {
return this.icon;
}
@Override
public Map<String, Object> serialize() {
final Map<String, Object> map = new HashMap<>();

View File

@ -165,8 +165,8 @@ public class ComponentPresetManager {
final List<ComponentPreset> allowedPresets = new ArrayList<>(this.presets.size());
for (final ComponentPreset componentPreset : this.presets) {
if (!componentPreset.getPermission().isEmpty() && !player.hasPermission(
componentPreset.getPermission()
if (!componentPreset.permission().isEmpty() && !player.hasPermission(
componentPreset.permission()
)) {
continue;
}
@ -200,30 +200,30 @@ public class ComponentPresetManager {
return false;
}
final Pattern pattern = PatternUtil.parse(null, componentPreset.getPattern(), false);
final Pattern pattern = PatternUtil.parse(null, componentPreset.pattern(), false);
if (pattern == null) {
getPlayer().sendMessage(TranslatableCaption.of("preset.preset_invalid"));
return false;
}
if (componentPreset.getCost() > 0.0D) {
if (componentPreset.cost() > 0.0D) {
if (!econHandler.isEnabled(plot.getArea())) {
getPlayer().sendMessage(
TranslatableCaption.of("preset.economy_disabled"),
TagResolver.resolver("preset", Tag.inserting(Component.text(componentPreset.getDisplayName())))
TagResolver.resolver("preset", Tag.inserting(Component.text(componentPreset.displayName())))
);
return false;
}
if (econHandler.getMoney(getPlayer()) < componentPreset.getCost()) {
if (econHandler.getMoney(getPlayer()) < componentPreset.cost()) {
getPlayer().sendMessage(TranslatableCaption.of("preset.preset_cannot_afford"));
return false;
} else {
econHandler.withdrawMoney(getPlayer(), componentPreset.getCost());
econHandler.withdrawMoney(getPlayer(), componentPreset.cost());
getPlayer().sendMessage(
TranslatableCaption.of("economy.removed_balance"),
TagResolver.resolver(
"money",
Tag.inserting(Component.text(econHandler.format(componentPreset.getCost())))
Tag.inserting(Component.text(econHandler.format(componentPreset.cost())))
)
);
}
@ -235,7 +235,7 @@ public class ComponentPresetManager {
queue.setCompleteTask(plot::removeRunning);
for (Plot current : plot.getConnectedPlots()) {
current.getPlotModificationManager().setComponent(
componentPreset.getComponent().name(),
componentPreset.component().name(),
pattern,
player,
queue
@ -252,32 +252,32 @@ public class ComponentPresetManager {
for (int i = 0; i < allowedPresets.size(); i++) {
final ComponentPreset preset = allowedPresets.get(i);
final List<String> lore = new ArrayList<>();
if (preset.getCost() > 0) {
if (preset.cost() > 0) {
if (!this.econHandler.isEnabled(plot.getArea())) {
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize(
TranslatableCaption.of("preset.preset_lore_economy_disabled").getComponent(player))));
} else {
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize(
TranslatableCaption.of("preset.preset_lore_cost").getComponent(player),
TagResolver.resolver("cost", Tag.inserting(Component.text(String.format("%.2f", preset.getCost()))))
TagResolver.resolver("cost", Tag.inserting(Component.text(String.format("%.2f", preset.cost()))))
)));
}
}
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize(
TranslatableCaption.of("preset.preset_lore_component").getComponent(player),
TagResolver.builder()
.tag("component", Tag.inserting(Component.text(preset.getComponent().name().toLowerCase())))
.tag("component", Tag.inserting(Component.text(preset.component().name().toLowerCase())))
.tag("prefix", Tag.inserting(TranslatableCaption.of("core.prefix").toComponent(player)))
.build()
)));
lore.removeIf(String::isEmpty);
lore.addAll(preset.getDescription());
lore.addAll(preset.description());
plotInventory.setItem(
i,
new PlotItemStack(
preset.getIcon().getId().replace("minecraft:", ""),
preset.icon().getId().replace("minecraft:", ""),
1,
preset.getDisplayName(),
preset.displayName(),
lore.toArray(new String[0])
)
);

View File

@ -2400,13 +2400,13 @@ public class SQLManager implements AbstractDB {
if (plot != null) {
statement.setString(1, plot.getArea().toString());
statement.setInt(2, plot.getId().hashCode());
statement.setString(3, comment.comment);
statement.setString(4, comment.inbox);
statement.setString(5, comment.senderName);
statement.setString(3, comment.comment());
statement.setString(4, comment.inbox());
statement.setString(5, comment.senderName());
} else {
statement.setString(1, comment.comment);
statement.setString(2, comment.inbox);
statement.setString(3, comment.senderName);
statement.setString(1, comment.comment());
statement.setString(2, comment.inbox());
statement.setString(3, comment.senderName());
}
}
@ -2518,10 +2518,10 @@ public class SQLManager implements AbstractDB {
public void set(PreparedStatement statement) throws SQLException {
statement.setString(1, plot.getArea().toString());
statement.setInt(2, plot.getId().hashCode());
statement.setString(3, comment.comment);
statement.setString(4, comment.inbox);
statement.setInt(5, (int) (comment.timestamp / 1000));
statement.setString(6, comment.senderName);
statement.setString(3, comment.comment());
statement.setString(4, comment.inbox());
statement.setInt(5, (int) (comment.timestamp() / 1000));
statement.setString(6, comment.senderName());
}
@Override
@ -3414,15 +3414,10 @@ public class SQLManager implements AbstractDB {
}
}
private static class LegacySettings {
public final int id;
public final PlotSettings settings;
public LegacySettings(int id, PlotSettings settings) {
this.id = id;
this.settings = settings;
}
private record LegacySettings(
int id,
PlotSettings settings
) {
}

View File

@ -0,0 +1,63 @@
/*
* 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.events;
import com.sk89q.worldedit.entity.Entity;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* @since TODO
*/
public abstract class EntityEvent {
private final Entity entity;
private String name;
/**
* @since 6.11.0
*/
public EntityEvent(Entity entity) {
this.entity = entity;
}
/**
* Obtain the entity involved in the event
*
* @return Entity
* @since 6.11.0
*/
public Entity getEntity() {
return this.entity;
}
/**
* Obtain the event's class name
*
* @return the event class name
* @since 6.11.0
*/
@NonNull public String getEventName() {
if (this.name == null) {
this.name = this.getClass().getSimpleName();
}
return this.name;
}
}

View File

@ -105,38 +105,6 @@ public class PlayerAutoPlotEvent extends PlotEvent implements CancellablePlotEve
return this.plotArea;
}
/**
* @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeX()}
*/
@Deprecated(forRemoval = true, since = "6.1.0")
public int getSize_x() {
return getSizeX();
}
/**
* @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeX(int)}
*/
@Deprecated(forRemoval = true, since = "6.1.0")
public void setSize_x(int sizeX) {
setSizeX(sizeX);
}
/**
* @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeZ()}
*/
@Deprecated(forRemoval = true, since = "6.1.0")
public int getSize_z() {
return getSizeZ();
}
/**
* @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeZ(int)}
*/
@Deprecated(forRemoval = true, since = "6.1.0")
public void setSize_z(int sizeZ) {
setSizeZ(sizeZ);
}
/**
* Get the x size of the auto-area
*

View File

@ -0,0 +1,50 @@
/*
* 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.events;
import com.sk89q.worldedit.entity.Entity;
/**
* @since 6.11.0
*/
public class RemoveRoadEntityEvent extends EntityEvent implements CancellablePlotEvent {
private Result eventResult;
/**
* RemoveRoadEntityEvent: Called when an entity on road is removed.
*
* @param entity The entity to remove
* @since 6.11.0
*/
public RemoveRoadEntityEvent(Entity entity) {
super(entity);
}
@Override
public Result getEventResult() {
return this.eventResult;
}
@Override
public void setEventResult(Result eventResult) {
this.eventResult = eventResult;
}
}

View File

@ -68,8 +68,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
private static final AffineTransform transform = new AffineTransform().rotateY(90);
public boolean ROAD_SCHEMATIC_ENABLED;
public boolean PLOT_SCHEMATIC = false;
@Deprecated(forRemoval = true, since = "6.9.0")
public int PLOT_SCHEMATIC_HEIGHT = -1;
public short PATH_WIDTH_LOWER;
public short PATH_WIDTH_UPPER;
public HashMap<Integer, BaseBlock[]> G_SCH;
@ -104,22 +102,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
PlotSquared.platform().injector().injectMembers(this);
}
@Deprecated(forRemoval = true, since = "6.9.0")
public static byte wrap(byte data, int start) {
if ((data >= start) && (data < (start + 4))) {
data = (byte) ((((data - start) + 2) & 3) + start);
}
return data;
}
@Deprecated(forRemoval = true, since = "6.9.0")
public static byte wrap2(byte data, int start) {
if ((data >= start) && (data < (start + 2))) {
data = (byte) ((((data - start) + 1) & 1) + start);
}
return data;
}
public static BaseBlock rotate(BaseBlock id) {
CompoundTag tag = id.getNbtData();
@ -486,11 +468,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
}
}
/**
* @deprecated This method should not be available for public API usage and will be made private.
*/
@Deprecated(forRemoval = true, since = "6.10.2")
public void addOverlayBlock(short x, short y, short z, BaseBlock id, boolean rotate, int height) {
private void addOverlayBlock(short x, short y, short z, BaseBlock id, boolean rotate, int height) {
if (z < 0) {
z += this.SIZE;
} else if (z >= this.SIZE) {
@ -521,11 +499,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
existing[y] = id;
}
/**
* @deprecated This method should not be available for public API usage and will be made private.
*/
@Deprecated(forRemoval = true, since = "6.10.2")
public void addOverlayBiome(short x, short z, BiomeType id) {
private void addOverlayBiome(short x, short z, BiomeType id) {
if (z < 0) {
z += this.SIZE;
} else if (z >= this.SIZE) {

View File

@ -341,14 +341,14 @@ public class PlotListener {
}
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
if (feed.getInterval() != 0 && feed.getValue() != 0) {
if (feed.interval() != 0 && feed.value() != 0) {
feedRunnable
.put(player.getUUID(), new Interval(feed.getInterval(), feed.getValue(), 20));
.put(player.getUUID(), new Interval(feed.interval(), feed.value(), 20));
}
TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
if (heal.getInterval() != 0 && heal.getValue() != 0) {
if (heal.interval() != 0 && heal.value() != 0) {
healRunnable
.put(player.getUUID(), new Interval(heal.getInterval(), heal.getValue(), 20));
.put(player.getUUID(), new Interval(heal.interval(), heal.value(), 20));
}
return true;
}

View File

@ -21,17 +21,11 @@ package com.plotsquared.core.location;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.StringMan;
public class ChunkWrapper {
public final int x;
public final int z;
public final String world;
public ChunkWrapper(String world, int x, int z) {
this.world = world;
this.x = x;
this.z = z;
}
public record ChunkWrapper(
String world,
int x,
int z
) {
@Override
public int hashCode() {

View File

@ -215,66 +215,48 @@ public final class BlockBucket implements ConfigurationSerializable {
return result;
}
private static final class Range {
private final int min;
private final int max;
private final boolean automatic;
public Range(int min, int max, boolean automatic) {
this.min = min;
this.max = max;
this.automatic = automatic;
}
private record Range(
int min,
int max,
boolean automatic
) {
public int getWeight() {
return max - min;
}
return max - min;
}
public boolean isInRange(final int num) {
return num <= max && num >= min;
}
public boolean isInRange(final int num) {
return num <= max && num >= min;
}
public int getMin() {
return this.min;
}
public int getMax() {
return this.max;
}
public boolean equals(final Object o) {
if (o == this) {
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof final Range other)) {
return false;
}
if (this.min() != other.min()) {
return false;
}
if (this.max() != other.max()) {
return false;
}
if (this.automatic() != other.automatic()) {
return false;
}
return true;
}
if (!(o instanceof final Range other)) {
return false;
}
if (this.getMin() != other.getMin()) {
return false;
}
if (this.getMax() != other.getMax()) {
return false;
}
if (this.isAutomatic() != other.isAutomatic()) {
return false;
}
return true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
result = result * PRIME + this.getMin();
result = result * PRIME + this.getMax();
result = result * PRIME + (this.isAutomatic() ? 79 : 97);
return result;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
result = result * PRIME + this.min();
result = result * PRIME + this.max();
result = result * PRIME + (this.automatic() ? 79 : 97);
return result;
}
public boolean isAutomatic() {
return this.automatic;
}
}
}

View File

@ -106,17 +106,6 @@ public final class PlotId {
return PlotId.of(hash >> 16, hash & 0xFFFF);
}
/**
* Get a copy of the plot ID
*
* @return Plot ID copy
* @deprecated PlotId is immutable, copy is not required.
*/
@Deprecated(forRemoval = true, since = "6.10.2")
public @NonNull PlotId copy() {
return this;
}
/**
* Get the ID X component
*

View File

@ -222,17 +222,6 @@ public final class PlotModificationManager {
if (isDelete) {
this.removeSign();
}
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
.callUnlink(
this.plot.getArea(),
this.plot,
true,
!isDelete,
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR
);
if (event.getEventResult() != Result.DENY && this.unlinkPlot(event.isCreateRoad(), event.isCreateSign())) {
PlotSquared.get().getEventDispatcher().callPostUnlink(plot, event.getReason());
}
final PlotManager manager = this.plot.getArea().getPlotManager();
Runnable run = new Runnable() {
@Override
@ -283,7 +272,21 @@ public final class PlotModificationManager {
manager.clearPlot(current, this, actor, null);
}
};
run.run();
PlotUnlinkEvent event = PlotSquared.get().getEventDispatcher()
.callUnlink(
this.plot.getArea(),
this.plot,
true,
!isDelete,
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR
);
if (event.getEventResult() != Result.DENY) {
if (this.unlinkPlot(event.isCreateRoad(), event.isCreateSign(), run)) {
PlotSquared.get().getEventDispatcher().callPostUnlink(plot, event.getReason());
}
} else {
run.run();
}
return true;
}
@ -323,7 +326,23 @@ public final class PlotModificationManager {
* @return success/!cancelled
*/
public boolean unlinkPlot(final boolean createRoad, final boolean createSign) {
return unlinkPlot(createRoad, createSign, null);
}
/**
* Unlink the plot and all connected plots.
*
* @param createRoad whether to recreate road
* @param createSign whether to recreate signs
* @param whenDone Task to run when unlink is complete
* @return success/!cancelled
* @since 6.10.9
*/
public boolean unlinkPlot(final boolean createRoad, final boolean createSign, final Runnable whenDone) {
if (!this.plot.isMerged()) {
if (whenDone != null) {
whenDone.run();
}
return false;
}
final Set<Plot> plots = this.plot.getConnectedPlots();
@ -368,14 +387,17 @@ public final class PlotModificationManager {
current.getPlotModificationManager().setSign(PlayerManager.resolveName(current.getOwnerAbs()).getComponent(
LocaleHolder.console()));
}
if (whenDone != null) {
TaskManager.runTask(whenDone);
}
}));
} else if (whenDone != null) {
queue.setCompleteTask(whenDone);
}
if (createRoad) {
manager.finishPlotUnlink(ids, queue);
}
if (queue != null) {
queue.enqueue();
}
queue.enqueue();
return true;
}

View File

@ -113,13 +113,12 @@ public class PlotSettings {
this.position = position;
}
@SuppressWarnings({"UnstableApiUsage"})
public List<PlotComment> getComments(String inbox) {
if (this.comments == null) {
return Collections.emptyList();
}
return this.comments.stream().filter(comment -> comment.inbox.equals(inbox))
return this.comments.stream().filter(comment -> comment.inbox().equals(inbox))
.collect(ImmutableList.toImmutableList());
}

View File

@ -58,7 +58,7 @@ public class CommentManager {
if (value != null) {
int num = 0;
for (PlotComment comment : value) {
if (comment.timestamp > getTimestamp(player, inbox.toString())) {
if (comment.timestamp() > getTimestamp(player, inbox.toString())) {
num++;
}
}

View File

@ -20,25 +20,13 @@ package com.plotsquared.core.plot.comment;
import com.plotsquared.core.plot.PlotId;
public class PlotComment {
public final String comment;
public final String inbox;
public final String senderName;
public final PlotId id;
public final String world;
public final long timestamp;
public PlotComment(
String world, PlotId id, String comment, String senderName, String inbox,
long timestamp
) {
this.world = world;
this.id = id;
this.comment = comment;
this.senderName = senderName;
this.inbox = inbox;
this.timestamp = timestamp;
}
public record PlotComment(
String world,
PlotId id,
String comment,
String senderName,
String inbox,
long timestamp
) {
}

View File

@ -19,7 +19,6 @@
package com.plotsquared.core.plot.expiration;
import com.google.inject.Inject;
import com.plotsquared.core.PlotPlatform;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
@ -63,11 +62,6 @@ import java.util.concurrent.ConcurrentLinkedDeque;
public class ExpireManager {
/**
* @deprecated Use {@link PlotPlatform#expireManager()} instead
*/
@Deprecated(forRemoval = true, since = "6.10.2")
public static ExpireManager IMP;
private final ConcurrentHashMap<UUID, Long> dates_cache;
private final ConcurrentHashMap<UUID, Long> account_age_cache;
private final EventDispatcher eventDispatcher;

View File

@ -60,7 +60,7 @@ public class FeedFlag extends TimedFlag<Integer, FeedFlag> {
@Override
protected Integer mergeValue(Integer other) {
return this.getValue().getValue() + other;
return this.getValue().value() + other;
}
@Override

View File

@ -60,7 +60,7 @@ public class HealFlag extends TimedFlag<Integer, HealFlag> {
@Override
protected Integer mergeValue(Integer other) {
return this.getValue().getValue() + other;
return this.getValue().value() + other;
}
@Override

View File

@ -76,29 +76,16 @@ public abstract class TimedFlag<T, F extends PlotFlag<TimedFlag.Timed<T>, F>>
return getValue().toString();
}
public static final class Timed<T> {
private final int interval;
private final T value;
public Timed(int interval, T value) {
this.interval = interval;
this.value = value;
}
public int getInterval() {
return interval;
}
public T getValue() {
return value;
}
public record Timed<T>(
int interval,
T value
) {
@Override
public String toString() {
return String.format("%d %s", interval, value);
public String toString() {
return String.format("%d %s", interval, value);
}
}
}
}

View File

@ -203,7 +203,7 @@ public abstract class QueueCoordinator {
* @return success or not
* @deprecated Biomes now take XYZ, see {@link #setBiome(int, int, int, BiomeType)}
* <br>
* Scheduled for removal once we drop the support for versions not supporting 3D biomes.
* Scheduled for removal once we drop the support for versions not supporting 3D biomes, 1.18 and earlier.
*/
@Deprecated(forRemoval = true, since = "6.0.0")
public abstract boolean setBiome(int x, int z, @NonNull BiomeType biome);

View File

@ -0,0 +1,105 @@
/*
* 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.services.plots;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public record AutoQuery(
PlotPlayer<?> player,
PlotId startId,
int sizeX,
int sizeZ,
PlotArea plotArea
) {
/**
* Crate a new auto query
*
* @param player Player to claim for
* @param startId Plot ID to start searching from
* @param sizeX Number of plots along the X axis
* @param sizeZ Number of plots along the Z axis
* @param plotArea Plot area to search in
*/
public AutoQuery(
final @NonNull PlotPlayer<?> player, final @Nullable PlotId startId,
final int sizeX, final int sizeZ, final @NonNull PlotArea plotArea
) {
this.player = player;
this.startId = startId;
this.sizeX = sizeX;
this.sizeZ = sizeZ;
this.plotArea = plotArea;
}
/**
* Get the player that the plots are meant for
*
* @return Player
*/
@Override
public @NonNull PlotPlayer<?> player() {
return this.player;
}
/**
* Get the plot ID to start searching from
*
* @return Start ID
*/
@Override
public @Nullable PlotId startId() {
return this.startId;
}
/**
* Get the number of plots along the X axis
*
* @return Number of plots along the X axis
*/
@Override
public int sizeX() {
return this.sizeX;
}
/**
* Get the number of plots along the Z axis
*
* @return Number of plots along the Z axis
*/
@Override
public int sizeZ() {
return this.sizeZ;
}
/**
* Get the plot area to search in
*
* @return Plot area
*/
@Override
public @NonNull PlotArea plotArea() {
return this.plotArea;
}
}

View File

@ -21,9 +21,7 @@ package com.plotsquared.core.services.plots;
import cloud.commandframework.services.types.Service;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -34,88 +32,12 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>> {
public interface AutoService extends Service<AutoQuery, List<Plot>> {
Cache<PlotId, Plot> plotCandidateCache = CacheBuilder.newBuilder()
.expireAfterWrite(20, TimeUnit.SECONDS).build();
Object plotLock = new Object();
final class AutoQuery {
private final PlotPlayer<?> player;
private final PlotId startId;
private final int sizeX;
private final int sizeZ;
private final PlotArea plotArea;
/**
* Crate a new auto query
*
* @param player Player to claim for
* @param startId Plot ID to start searching from
* @param sizeX Number of plots along the X axis
* @param sizeZ Number of plots along the Z axis
* @param plotArea Plot area to search in
*/
public AutoQuery(
final @NonNull PlotPlayer<?> player, final @Nullable PlotId startId,
final int sizeX, final int sizeZ, final @NonNull PlotArea plotArea
) {
this.player = player;
this.startId = startId;
this.sizeX = sizeX;
this.sizeZ = sizeZ;
this.plotArea = plotArea;
}
/**
* Get the player that the plots are meant for
*
* @return Player
*/
public @NonNull PlotPlayer<?> getPlayer() {
return this.player;
}
/**
* Get the plot ID to start searching from
*
* @return Start ID
*/
public @Nullable PlotId getStartId() {
return this.startId;
}
/**
* Get the number of plots along the X axis
*
* @return Number of plots along the X axis
*/
public int getSizeX() {
return this.sizeX;
}
/**
* Get the number of plots along the Z axis
*
* @return Number of plots along the Z axis
*/
public int getSizeZ() {
return this.sizeZ;
}
/**
* Get the plot area to search in
*
* @return Plot area
*/
public @NonNull PlotArea getPlotArea() {
return this.plotArea;
}
}
final class DefaultAutoService implements AutoService {
@Override
@ -125,17 +47,16 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>>
}
final class SinglePlotService implements AutoService, Predicate<AutoQuery> {
@Nullable
@Override
public List<Plot> handle(@NonNull AutoQuery autoQuery) {
Plot plot;
PlotId nextId = autoQuery.getStartId();
PlotId nextId = autoQuery.startId();
do {
synchronized (plotLock) {
plot = autoQuery.getPlotArea().getNextFreePlot(autoQuery.getPlayer(), nextId);
plot = autoQuery.plotArea().getNextFreePlot(autoQuery.player(), nextId);
if (plot != null && plotCandidateCache.getIfPresent(plot.getId()) == null) {
plotCandidateCache.put(plot.getId(), plot);
return Collections.singletonList(plot);
@ -151,12 +72,11 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>>
@Override
public boolean test(final @NonNull AutoQuery autoQuery) {
return autoQuery.sizeX == 1 && autoQuery.sizeZ == 1;
return autoQuery.sizeX() == 1 && autoQuery.sizeZ() == 1;
}
}
final class MultiPlotService implements AutoService, Predicate<AutoQuery> {
@Override
@ -166,14 +86,14 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>>
while (true) {
synchronized (plotLock) {
final PlotId start =
autoQuery.getPlotArea().getMeta("lastPlot", PlotId.of(0, 0)).getNextId();
autoQuery.plotArea().getMeta("lastPlot", PlotId.of(0, 0)).getNextId();
final PlotId end = PlotId.of(
start.getX() + autoQuery.getSizeX() - 1,
start.getY() + autoQuery.getSizeZ() - 1
start.getX() + autoQuery.sizeX() - 1,
start.getY() + autoQuery.sizeZ() - 1
);
final List<Plot> plots =
autoQuery.getPlotArea().canClaim(autoQuery.getPlayer(), start, end);
autoQuery.getPlotArea().setMeta("lastPlot", start); // set entry point for next try
autoQuery.plotArea().canClaim(autoQuery.player(), start, end);
autoQuery.plotArea().setMeta("lastPlot", start); // set entry point for next try
if (plots != null && !plots.isEmpty()) {
for (final Plot plot : plots) {
if (plotCandidateCache.getIfPresent(plot.getId()) != null) {
@ -189,7 +109,7 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>>
@Override
public boolean test(final @NonNull AutoQuery autoQuery) {
return autoQuery.getPlotArea().getType() != PlotAreaType.PARTIAL;
return autoQuery.plotArea().getType() != PlotAreaType.PARTIAL;
}
}

View File

@ -48,10 +48,10 @@ public class SettingsNodeStep implements SetupStep {
) {
this.configurationNode = configurationNode;
this.id = id;
if (wrapper.getSettingsNodes().length > id + 1) {
this.next = new SettingsNodeStep(wrapper.getSettingsNodes()[id + 1], id + 1, wrapper);
if (wrapper.settingsNodes().length > id + 1) {
this.next = new SettingsNodeStep(wrapper.settingsNodes()[id + 1], id + 1, wrapper);
} else {
this.next = wrapper.getAfterwards();
this.next = wrapper.afterwards();
}
}

View File

@ -23,15 +23,10 @@ import com.plotsquared.core.configuration.ConfigurationNode;
/**
* This class wraps an array of {@link ConfigurationNode}s.
*/
public class SettingsNodesWrapper {
private final ConfigurationNode[] settingsNodes;
private final SetupStep afterwards;
public SettingsNodesWrapper(final ConfigurationNode[] settingsNodes, final SetupStep afterwards) {
this.settingsNodes = settingsNodes;
this.afterwards = afterwards;
}
public record SettingsNodesWrapper(
ConfigurationNode[] settingsNodes,
SetupStep afterwards
) {
/**
* Returns the first step of this wrapper or the step or the
@ -43,12 +38,4 @@ public class SettingsNodesWrapper {
return this.settingsNodes.length == 0 ? this.afterwards : new SettingsNodeStep(this.settingsNodes[0], 0, this);
}
public ConfigurationNode[] getSettingsNodes() {
return this.settingsNodes;
}
public SetupStep getAfterwards() {
return this.afterwards;
}
}

View File

@ -45,6 +45,7 @@ import com.plotsquared.core.events.PlotFlagRemoveEvent;
import com.plotsquared.core.events.PlotMergeEvent;
import com.plotsquared.core.events.PlotRateEvent;
import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.events.RemoveRoadEntityEvent;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.events.post.PostPlayerAutoPlotEvent;
import com.plotsquared.core.events.post.PostPlotChangeOwnerEvent;
@ -71,6 +72,7 @@ import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -298,6 +300,12 @@ public class EventDispatcher {
return event;
}
public RemoveRoadEntityEvent callRemoveRoadEntity(Entity entity) {
RemoveRoadEntityEvent event = new RemoveRoadEntityEvent(entity);
eventBus.post(event);
return event;
}
public void doJoinTask(final PlotPlayer<?> player) {
if (player == null) {
return; //possible future warning message to figure out where we are retrieving null

View File

@ -18,14 +18,9 @@
*/
package com.plotsquared.core.util;
public class FileBytes {
public final String path;
public final byte[] data;
public FileBytes(String path, byte[] data) {
this.path = path;
this.data = data;
}
public record FileBytes(
String path,
byte[] data
) {
}

View File

@ -1,150 +0,0 @@
/*
* 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.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.permissions.PermissionHolder;
import com.plotsquared.core.player.PlotPlayer;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* The Permissions class handles checking user permissions.<br>
* - This will respect * nodes and plots.admin and can be used to check permission ranges (e.g. plots.plot.5)<br>
* - Checking the PlotPlayer class directly will not take the above into account<br>
*
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public class Permissions {
/**
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes. Use {@link PlotPlayer#hasPermission(String, boolean)}
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(PlotPlayer<?> player, Permission permission, boolean notify) {
return hasPermission(player, permission.toString(), notify);
}
/**
* Check if the owner of the profile has a given (global) permission
*
* @param caller permission holder
* @param permission Permission
* @return {@code true} if the owner has the given permission, else {@code false}
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes. Use {@link PermissionHolder#hasPermission(Permission)}
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull Permission permission) {
return caller.hasPermission(permission.toString());
}
/**
* Check if the owner of the profile has a given (global) permission. There is no guarantee that per-world permissions will
* be checked because unmaintained crap plugins like PEX exist.
*
* @param caller permission holder
* @param permission Permission
* @return {@code true} if the owner has the given permission, else {@code false}
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes. Use {@link PermissionHolder#hasPermission(String)}
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull String permission) {
return caller.hasPermission(permission);
}
/**
* Check if the owner of the profile has a given (global) keyed permission. Checks both {@code permission.key}
* and {@code permission.*}
*
* @param caller permission holder
* @param permission Permission
* @param key Permission "key"
* @return {@code true} if the owner has the given permission, else {@code false}
* @since 6.0.10
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes. Use {@link PermissionHolder#hasKeyedPermission(String, String)}
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasKeyedPermission(
final @NonNull PermissionHolder caller, final @NonNull String permission,
final @NonNull String key
) {
return caller.hasKeyedPermission(permission, key);
}
/**
* Checks if a PlotPlayer has a permission, and optionally send the no permission message if applicable.
*
* @param player permission holder
* @param permission permission
* @param notify if to notify the permission holder
* @return if permission is had
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes. Use {@link PlotPlayer#hasPermission(String, boolean)}
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(PlotPlayer<?> player, String permission, boolean notify) {
if (!hasPermission(player, permission)) {
if (notify) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
TagResolver.resolver("node", Tag.inserting(Component.text(permission)))
);
}
return false;
}
return true;
}
/**
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes. Use {@link PlotPlayer#hasPermissionRange(Permission, int)}
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public static int hasPermissionRange(PlotPlayer<?> player, Permission Permission, int range) {
return hasPermissionRange(player, Permission.toString(), range);
}
/**
* Check the highest permission a PlotPlayer has within a specified range.<br>
* - Excessively high values will lag<br>
* - The default range that is checked is {@link Settings.Limit#MAX_PLOTS}<br>
*
* @param player Player to check for
* @param stub The permission stub to check e.g. for `plots.plot.#` the stub is `plots.plot`
* @param range The range to check
* @return The highest permission they have within that range
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes. Use {@link PlotPlayer#hasPermissionRange(String, int)}
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public static int hasPermissionRange(PlotPlayer<?> player, String stub, int range) {
return player.hasPermissionRange(stub, range);
}
}

View File

@ -98,7 +98,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
consumer.accept(null, throwable);
} else {
for (final UUIDMapping uuid : uuids) {
result.add(uuid.getUuid());
result.add(uuid.uuid());
}
consumer.accept(result, null);
}
@ -136,7 +136,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
try {
for (final UUIDMapping mapping : PlotSquared.get().getImpromptuUUIDPipeline()
.getNames(players).get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS)) {
users.add(Component.text(mapping.getUsername()));
users.add(Component.text(mapping.username()));
}
} catch (final Exception e) {
e.printStackTrace();
@ -200,7 +200,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
final UUIDMapping uuidMapping =
PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner);
if (uuidMapping != null) {
name = uuidMapping.getUsername();
name = uuidMapping.username();
} else {
name = null;
}

View File

@ -491,6 +491,10 @@ public abstract class SchematicHandler {
return null;
}
/**
* The legacy web interface is deprecated for removal in favor of Arkitektonika.
*/
@Deprecated(forRemoval = true, since = "6.11.0")
public List<String> getSaves(UUID uuid) {
String rawJSON;
try {

View File

@ -238,8 +238,8 @@ public final class TabCompletions {
PlotSquared.get().getImpromptuUUIDPipeline().getAllImmediately();
players = new ArrayList<>(mappings.size());
for (final UUIDMapping mapping : mappings) {
if (uuidFilter.test(mapping.getUuid())) {
players.add(mapping.getUsername());
if (uuidFilter.test(mapping.uuid())) {
players.add(mapping.username());
}
}
cachedCompletionValues.put(cacheIdentifier, players);

View File

@ -231,6 +231,10 @@ public abstract class WorldUtil {
*/
public abstract void refreshChunk(int x, int z, String world);
/**
* The legacy web interface is deprecated for removal in favor of Arkitektonika.
*/
@Deprecated(forRemoval = true, since = "6.11.0")
public void upload(
final @NonNull Plot plot,
final @Nullable UUID uuid,

View File

@ -298,19 +298,11 @@ public final class PlaceholderRegistry {
}
/**
* Event called when a new {@link Placeholder} has been added
*/
public static class PlaceholderAddedEvent {
private final Placeholder placeholder;
public PlaceholderAddedEvent(Placeholder placeholder) {
this.placeholder = placeholder;
}
public Placeholder getPlaceholder() {
return this.placeholder;
}
* Event called when a new {@link Placeholder} has been added
*/
public record PlaceholderAddedEvent(
Placeholder placeholder
) {
}

View File

@ -67,8 +67,8 @@ public class CacheUUIDService implements UUIDService, Consumer<List<UUIDMapping>
@Override
public void accept(final @NonNull List<@NonNull UUIDMapping> uuidMappings) {
for (final UUIDMapping mapping : uuidMappings) {
this.uuidCache.put(mapping.getUuid(), mapping);
this.usernameCache.put(mapping.getUsername(), mapping);
this.uuidCache.put(mapping.uuid(), mapping);
this.usernameCache.put(mapping.username(), mapping);
}
}

View File

@ -20,29 +20,15 @@ package com.plotsquared.core.uuid;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Objects;
import java.util.UUID;
/**
* A pair consisting of a UUID and a username
*/
public class UUIDMapping {
private final UUID uuid;
private final String username;
public UUIDMapping(final @NonNull UUID uuid, final @NonNull String username) {
this.uuid = uuid;
this.username = username;
}
public @NonNull String getUsername() {
return this.username;
}
public @NonNull UUID getUuid() {
return this.uuid;
}
public record UUIDMapping(
@NonNull UUID uuid,
@NonNull String username
) {
@Override
public boolean equals(final Object o) {
@ -56,9 +42,4 @@ public class UUIDMapping {
return uuid.equals(that.uuid) && username.equals(that.username);
}
@Override
public int hashCode() {
return Objects.hash(uuid, username);
}
}

View File

@ -157,7 +157,7 @@ public class UUIDPipeline {
TimeUnit.MILLISECONDS
);
if (mappings.size() == 1) {
return mappings.get(0).getUuid();
return mappings.get(0).uuid();
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
@ -182,7 +182,7 @@ public class UUIDPipeline {
try {
final List<UUIDMapping> mappings = this.getNames(Collections.singletonList(uuid)).get(timeout, TimeUnit.MILLISECONDS);
if (mappings.size() == 1) {
return mappings.get(0).getUsername();
return mappings.get(0).username();
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
@ -209,7 +209,7 @@ public class UUIDPipeline {
uuid.accept(null, throwable);
} else {
if (!uuids.isEmpty()) {
uuid.accept(uuids.get(0).getUuid(), null);
uuid.accept(uuids.get(0).uuid(), null);
} else {
uuid.accept(null, null);
}
@ -231,7 +231,7 @@ public class UUIDPipeline {
username.accept(null, throwable);
} else {
if (!uuids.isEmpty()) {
username.accept(uuids.get(0).getUsername(), null);
username.accept(uuids.get(0).username(), null);
} else {
username.accept(null, null);
}
@ -296,7 +296,7 @@ public class UUIDPipeline {
if (service.canBeSynchronous()) {
final List<UUIDMapping> completedRequests = service.getNames(remainingRequests);
for (final UUIDMapping mapping : completedRequests) {
remainingRequests.remove(mapping.getUuid());
remainingRequests.remove(mapping.uuid());
}
mappings.addAll(completedRequests);
} else {
@ -311,7 +311,7 @@ public class UUIDPipeline {
for (final UUIDService service : serviceList) {
final List<UUIDMapping> completedRequests = service.getNames(remainingRequests);
for (final UUIDMapping mapping : completedRequests) {
remainingRequests.remove(mapping.getUuid());
remainingRequests.remove(mapping.uuid());
}
mappings.addAll(completedRequests);
if (remainingRequests.isEmpty()) {
@ -365,7 +365,7 @@ public class UUIDPipeline {
if (service.canBeSynchronous()) {
final List<UUIDMapping> completedRequests = service.getUUIDs(remainingRequests);
for (final UUIDMapping mapping : completedRequests) {
remainingRequests.remove(mapping.getUsername());
remainingRequests.remove(mapping.username());
}
mappings.addAll(completedRequests);
} else {
@ -380,7 +380,7 @@ public class UUIDPipeline {
for (final UUIDService service : serviceList) {
final List<UUIDMapping> completedRequests = service.getUUIDs(remainingRequests);
for (final UUIDMapping mapping : completedRequests) {
remainingRequests.remove(mapping.getUsername());
remainingRequests.remove(mapping.username());
}
mappings.addAll(completedRequests);
if (remainingRequests.isEmpty()) {

View File

@ -74,7 +74,7 @@ subprojects {
}
dependencies {
implementation(platform("com.intellectualsites.bom:bom-newest:1.22"))
implementation(platform("com.intellectualsites.bom:bom-newest:1.24"))
}
dependencies {
@ -155,7 +155,7 @@ subprojects {
id.set("NotMyFault")
name.set("Alexander Brandes")
organization.set("IntellectualSites")
email.set("contact@notmyfault.dev")
email.set("contact(at)notmyfault.dev")
}
developer {
id.set("SirYwell")

View File

@ -11,17 +11,17 @@ essentialsx = "2.19.7"
mvdwapi = "3.1.1"
# Third party
prtree = "2.0.0"
prtree = "2.0.1"
aopalliance = "1.0"
cloud-services = "1.8.0"
cloud-services = "1.8.2"
arkitektonika = "2.1.1"
squirrelid = "0.3.1"
# Gradle plugins
shadow = "7.1.2"
grgit = "4.1.1"
spotless = "6.13.0"
nexus = "1.1.0"
spotless = "6.16.0"
nexus = "1.2.0"
[libraries]
# Platform expectations

View File

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