Compare commits

..

1 Commits

Author SHA1 Message Date
2cfbc35405 feat: Don't enable presets with prices if economy is disabled 2022-02-09 12:53:01 +01:00
22 changed files with 154 additions and 204 deletions

View File

@ -12,7 +12,7 @@ jobs:
- name: Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@v1.0.4
- name: Setup Java
uses: actions/setup-java@v3.0.0
uses: actions/setup-java@v2.5.0
with:
distribution: temurin
java-version: 17

View File

@ -1,37 +0,0 @@
name: "CodeQL"
on:
push:
branches: [ v6 ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ v6 ]
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'java' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

20
.github/workflows/rebase.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: Rebase Pull Request
on:
issue_comment:
types: [created]
jobs:
rebase:
name: Rebase
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') && github.event.comment.author_association == 'MEMBER'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2.4.0
with:
token: ${{ secrets.REBASE_TOKEN }}
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.5
env:
GITHUB_TOKEN: ${{ secrets.REBASE_TOKEN }}

View File

@ -74,7 +74,6 @@ import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Fireball;
@ -93,7 +92,6 @@ import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockMultiPlaceEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
@ -279,7 +277,7 @@ public class BlockEventListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(player);
Plot plot = area.getPlot(location);
if (plot != null) {
if ((location.getY() >= area.getMaxBuildHeight() || location.getY() < area
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
.getMinBuildHeight()) && !Permissions
.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true);
@ -364,7 +362,7 @@ public class BlockEventListener implements Listener {
event.setCancelled(true);
return;
}
} else if ((location.getY() >= area.getMaxBuildHeight() || location.getY() < area
} else if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
.getMinBuildHeight()) && !Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true);
@ -1210,51 +1208,4 @@ public class BlockEventListener implements Listener {
}
}
/*
* BlockMultiPlaceEvent is called unrelated to the BlockPlaceEvent itself and therefore doesn't respect the cancellation.
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
// Check if the generic block place event would be cancelled
blockCreate(event);
if (event.isCancelled()) {
return;
}
BukkitPlayer pp = BukkitUtil.adapt(event.getPlayer());
Location placedLocation = BukkitUtil.adapt(event.getBlockReplacedState().getLocation());
PlotArea area = placedLocation.getPlotArea();
if (area == null) {
return;
}
Plot plot = placedLocation.getPlot();
for (final BlockState state : event.getReplacedBlockStates()) {
Location currentLocation = BukkitUtil.adapt(state.getLocation());
if (!Permissions.hasPermission(
pp,
Permission.PERMISSION_ADMIN_BUILD_ROAD
) && !(Objects.equals(currentLocation.getPlot(), plot))) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
);
event.setCancelled(true);
break;
}
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
continue;
}
if (currentLocation.getY() >= area.getMaxBuildHeight() || currentLocation.getY() < area.getMinBuildHeight()) {
pp.sendMessage(
TranslatableCaption.of("height.height_limit"),
Template.of("minHeight", String.valueOf(area.getMinBuildHeight())),
Template.of("maxHeight", String.valueOf(area.getMaxBuildHeight()))
);
event.setCancelled(true);
break;
}
}
}
}

View File

@ -36,7 +36,6 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import io.papermc.lib.PaperLib;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -192,32 +191,8 @@ public class EntitySpawnListener implements Listener {
@EventHandler
public void onTeleport(EntityTeleportEvent event) {
Entity entity = event.getEntity();
Entity fromLocation = event.getEntity();
Block toLocation = event.getTo().getBlock();
final Location fromLocLocation = BukkitUtil.adapt(fromLocation.getLocation());
final PlotArea fromArea = fromLocLocation.getPlotArea();
Location toLocLocation = BukkitUtil.adapt(toLocation.getLocation());
PlotArea toArea = toLocLocation.getPlotArea();
if (toArea == null) {
if (fromLocation.getType() == EntityType.SHULKER && fromArea != null) {
event.setCancelled(true);
}
return;
}
Plot toPlot = toArea.getOwnedPlot(toLocLocation);
if (fromLocation.getType() == EntityType.SHULKER && fromArea != null) {
final Plot fromPlot = fromArea.getOwnedPlot(fromLocLocation);
if (fromPlot != null || toPlot != null) {
if ((fromPlot == null || !fromPlot.equals(toPlot)) && (toPlot == null || !toPlot.equals(fromPlot))) {
event.setCancelled(true);
return;
}
}
}
if (entity instanceof Vehicle || entity instanceof ArmorStand) {
Entity ent = event.getEntity();
if (ent instanceof Vehicle || ent instanceof ArmorStand) {
testNether(event.getEntity());
}
}

View File

@ -83,31 +83,34 @@ public class BukkitWorld implements World<org.bukkit.World> {
return this.world.getName();
}
@Override
public boolean equals(final Object o) {
if (this == o) {
if (o == this) {
return true;
}
if (o == null || getClass() != o.getClass()) {
if (!(o instanceof final BukkitWorld other)) {
return false;
}
final BukkitWorld that = (BukkitWorld) o;
return world.equals(that.world);
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(this.world, other.world)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return world.hashCode();
}
/**
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
*/
@Deprecated(forRemoval = true, since = "TODO")
protected boolean canEqual(final Object other) {
return other instanceof BukkitWorld;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $world = this.world;
result = result * PRIME + ($world == null ? 43 : $world.hashCode());
return result;
}
public String toString() {
return "BukkitWorld(world=" + this.world + ")";
}

View File

@ -102,7 +102,7 @@ public enum CommandCategory implements Caption {
*
* @param player The player to check against
* @return {@code true} if at least one command of this category can be executed by the player, {@code false} otherwise
* @since 6.5.0
* @since TODO
*/
boolean canAccess(PlotPlayer<?> player) {
return !MainCommand.getInstance().getCommands(this, player).isEmpty();

View File

@ -181,10 +181,6 @@ public class ComponentPresetManager {
}
allowedPresets.add(componentPreset);
}
if (allowedPresets.isEmpty()) {
player.sendMessage(TranslatableCaption.of("preset.empty"));
return null;
}
final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D);
final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size,
TranslatableCaption.of("preset.title").getComponent(player)) {

View File

@ -174,9 +174,21 @@ public class PlotListener {
String greeting = plot.getFlag(GreetingFlag.class);
if (!greeting.isEmpty()) {
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
player.sendMessage(
TranslatableCaption.of("flags.greeting_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("greeting", greeting)
);
} else {
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendActionBar);
player.sendActionBar(
TranslatableCaption.of("flags.greeting_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("greeting", greeting)
);
}
}
@ -401,9 +413,21 @@ public class PlotListener {
String farewell = plot.getFlag(FarewellFlag.class);
if (!farewell.isEmpty()) {
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
player.sendMessage(
TranslatableCaption.of("flags.farewell_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("farewell", farewell)
);
} else {
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendActionBar);
player.sendActionBar(
TranslatableCaption.of("flags.farewell_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("farewell", farewell)
);
}
}

View File

@ -121,7 +121,7 @@ public class PlotInventory {
* @param item the item to place
* @return {@code true} if the item could be placed, otherwise {@code false}
* @see InventoryUtil#setItemChecked(PlotInventory, int, PlotItemStack)
* @since 6.5.0
* @since TODO
*/
public boolean setItemChecked(int index, PlotItemStack item) {
if (!this.inventoryUtil.setItemChecked(this, index, item)) {

View File

@ -54,7 +54,7 @@ public class PlotItemStack {
* @param amount Amount of items in the stack
* @param name The display name of the item stack
* @param lore The item stack lore
* @since 6.5.0
* @since TODO
*/
public PlotItemStack(
final ItemType type, final int amount, final String name,

View File

@ -105,29 +105,31 @@ public abstract class PlotWorld {
return this.world;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
if (o == this) {
return true;
}
if (o == null || getClass() != o.getClass()) {
if (!(o instanceof final PlotWorld other)) {
return false;
}
final PlotWorld plotWorld = (PlotWorld) o;
return world.equals(plotWorld.world);
if (!other.canEqual(this)) {
return false;
}
final Object this$world = this.getWorld();
final Object other$world = other.getWorld();
return Objects.equals(this$world, other$world);
}
@Override
public int hashCode() {
return world.hashCode();
}
/**
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
*/
@Deprecated(forRemoval = true, since = "TODO")
protected boolean canEqual(final Object other) {
return other instanceof PlotWorld;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $world = this.getWorld();
result = result * PRIME + ($world == null ? 43 : $world.hashCode());
return result;
}
}

View File

@ -371,31 +371,33 @@ public class FlagContainer {
}
}
@Override
public boolean equals(final Object o) {
if (this == o) {
if (o == this) {
return true;
}
if (o == null || getClass() != o.getClass()) {
if (!(o instanceof final FlagContainer other)) {
return false;
}
final FlagContainer that = (FlagContainer) o;
return flagMap.equals(that.flagMap);
if (!other.canEqual(this)) {
return false;
}
final Object this$flagMap = this.getFlagMap();
final Object other$flagMap = other.getFlagMap();
return Objects.equals(this$flagMap, other$flagMap);
}
@Override
public int hashCode() {
return flagMap.hashCode();
}
/**
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
*/
@Deprecated(forRemoval = true, since = "TODO")
protected boolean canEqual(final Object other) {
return other instanceof FlagContainer;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $flagMap = this.getFlagMap();
result = result * PRIME + ($flagMap == null ? 43 : $flagMap.hashCode());
return result;
}
/**
* Update event types used in {@link PlotFlagUpdateHandler}.
*/

View File

@ -31,7 +31,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
/**
* A plot flag is any property that can be assigned
@ -201,30 +200,34 @@ public abstract class PlotFlag<T, F extends PlotFlag<T, F>> {
return Collections.emptyList();
}
@Override
public boolean equals(final Object o) {
if (this == o) {
if (o == this) {
return true;
}
if (o == null || getClass() != o.getClass()) {
if (!(o instanceof final PlotFlag<?, ?> other)) {
return false;
}
final PlotFlag<?, ?> plotFlag = (PlotFlag<?, ?>) o;
return value.equals(plotFlag.value);
if (!other.canEqual(this)) {
return false;
}
final Object this$value = this.getValue();
final Object other$value = other.getValue();
if (this$value == null ? other$value != null : !this$value.equals(other$value)) {
return false;
}
return true;
}
@Override
public int hashCode() {
return value.hashCode();
}
/**
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
*/
@Deprecated(forRemoval = true, since = "TODO")
protected boolean canEqual(final Object other) {
return other instanceof PlotFlag;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $value = this.getValue();
result = result * PRIME + ($value == null ? 43 : $value.hashCode());
return result;
}
}

View File

@ -45,7 +45,7 @@ public abstract class InventoryUtil {
* @param index The index where to place the item
* @param item The item to place into the inventory
* @return {@code true} if the item could be placed, {@code false} otherwise (e.g. item not available in current version)
* @since 6.5.0
* @since TODO
*/
public abstract boolean setItemChecked(
final PlotInventory plotInventory, final int index,

View File

@ -51,29 +51,38 @@ public class UUIDMapping {
return this.uuid;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
if (o == this) {
return true;
}
if (o == null || getClass() != o.getClass()) {
if (!(o instanceof final UUIDMapping other)) {
return false;
}
final UUIDMapping that = (UUIDMapping) o;
return uuid.equals(that.uuid) && username.equals(that.username);
if (!other.canEqual(this)) {
return false;
}
final Object this$uuid = this.getUuid();
final Object other$uuid = other.getUuid();
if (!Objects.equals(this$uuid, other$uuid)) {
return false;
}
final Object this$username = this.getUsername();
final Object other$username = other.getUsername();
return Objects.equals(this$username, other$username);
}
@Override
public int hashCode() {
return Objects.hash(uuid, username);
}
/**
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
*/
@Deprecated(forRemoval = true, since = "TODO")
protected boolean canEqual(final Object other) {
return other instanceof UUIDMapping;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $uuid = this.getUuid();
result = result * PRIME + $uuid.hashCode();
final Object $username = this.getUsername();
result = result * PRIME + $username.hashCode();
return result;
}
}

View File

@ -464,7 +464,6 @@
"preset.preset_lore_economy_disabled": "<gray>Cost: </gray><red>Economy is disabled</red>",
"preset.preset_lore_component": "<gray>Component: </gray><gold><component></gold>",
"preset.title": "Plot Components",
"preset.empty": "<prefix><red>No plot component presets available.</red>",
"preset.economy_disabled": "<prefix><red>The component preset '<preset>' has a price set but economy is disabled.</red>",
"generic.generic_other": "<gray>other</gray>",
"generic.generic_merged": "<gray>merged</gray>",
@ -623,6 +622,8 @@
"flags.flag_error_title": "Flag value must be in the format </red><grey>\"A title\" \"The subtitle\"</grey><red>.",
"flags.area_flags": "<prefix><gray>Area flags: </gray><dark_aqua><flags></dark_aqua>",
"flags.road_flags": "<prefix><gray>Road flags: </gray><dark_aqua><flags></dark_aqua>",
"flags.greeting_flag_format": "<prefix><gold>[<world>;<plot_id>]:</gold> <greeting>",
"flags.farewell_flag_format": "<prefix><gold>[<world>;<plot_id>]:</gold> <farewell>",
"commands.description.add": "<gray>Allow a user to build in a plot while the plot owner is online.</gray>",
"commands.description.alias": "<gray>Set the plot alias.</gray>",
"commands.description.area": "<gray>Create a new plot area.</gray>",

View File

@ -18,7 +18,7 @@ plugins {
idea
}
version = "6.5.2-SNAPSHOT"
version = "6.4.1-SNAPSHOT"
allprojects {
group = "com.plotsquared"

View File

@ -21,14 +21,14 @@ worldedit = "7.2.9"
fawe = "2.0.1"
vault = "1.7.1"
placeholderapi = "2.11.1"
luckperms = "5.4"
luckperms = "5.3"
essentialsx = "2.19.2"
mvdwapi = "3.1.1"
# Third party
prtree = "2.0.0"
aopalliance = "1.0"
cloud-services = "1.6.2"
cloud-services = "1.6.1"
arkitektonika = "2.1.1"
paster = "1.1.4"
bstats = "3.0.0"

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -5,4 +5,5 @@ include("Core", "Bukkit")
project(":Core").name = "PlotSquared-Core"
project(":Bukkit").name = "PlotSquared-Bukkit"
enableFeaturePreview("VERSION_CATALOGS")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")