diff --git a/.github/stale.yml b/.github/stale.yml index 7d95c1f66..c6ad3e8fe 100644 --- a/.github/stale.yml +++ b/.github/stale.yml @@ -1,4 +1,4 @@ -daysUntilStale: 60 +daysUntilStale: 30 daysUntilClose: 7 only: issues exemptLabels: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4c1c5726..275c96b38 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,41 +1,41 @@ -name: "build" +name: build -on: [ "pull_request", "push" ] +on: [ pull_request, push ] jobs: build: - runs-on: "ubuntu-20.04" + runs-on: ubuntu-latest steps: - - name: "Checkout Repository" - uses: "actions/checkout@v2.4.0" - - name: "Validate Gradle Wrapper" - uses: "gradle/wrapper-validation-action@v1.0.4" - - name: "Setup Java" - uses: "actions/setup-java@v2.4.0" + - name: Checkout Repository + uses: actions/checkout@v2.3.5 + - name: Validate Gradle Wrapper" + uses: gradle/wrapper-validation-action@v1.0.4 + - name: Setup Java + uses: actions/setup-java@v2.4.0 with: - distribution: "temurin" - java-version: "17" - - name: "Clean Build" - run: "./gradlew clean build" - - name: "Determine release status" - if: "${{ runner.os == 'Linux' }}" + distribution: temurin + java-version: 17 + - name: Clean Build + run: ./gradlew clean build + - name: Determine release status + if: ${{ runner.os == 'Linux' }} run: | if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then echo "STATUS=snapshot" >> $GITHUB_ENV else echo "STATUS=release" >> $GITHUB_ENV fi - - name: "Publish Release" - if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}}" - run: "./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository" + - name: Publish Release + if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}} + run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository env: - ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" - ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" - ORG_GRADLE_PROJECT_signingKey: "${{ secrets.SIGNING_KEY }}" - ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.SIGNING_PASSWORD }}" - - name: "Publish Snapshot" - if: "${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6' }}" - run: "./gradlew publishToSonatype" + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} + - name: Publish Snapshot + if: ${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6' }} + run: ./gradlew publishToSonatype env: - ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" - ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index d3ba4de8b..65e3d4b31 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -1,4 +1,4 @@ -name: "draft release" +name: draft release on: push: @@ -7,8 +7,8 @@ on: jobs: update_release_draft: - runs-on: "ubuntu-latest" + runs-on: ubuntu-latest steps: - - uses: "release-drafter/release-drafter@v5.15.0" + - uses: release-drafter/release-drafter@v5.15.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java index 826aef2a2..d97b23d02 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java @@ -371,14 +371,14 @@ public class EntityEventListener implements Listener { if (shooter instanceof Player) { PlotPlayer pp = BukkitUtil.adapt((Player) shooter); if (plot == null) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_PROJECTILE_UNOWNED)) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { entity.remove(); event.setCancelled(true); } return; } if (plot.isAdded(pp.getUUID()) || Permissions - .hasPermission(pp, Permission.PERMISSION_PROJECTILE_OTHER)) { + .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { return; } entity.remove(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index 3a3c56d6e..fb0bfce9e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -39,11 +39,13 @@ import com.plotsquared.core.command.MainCommand; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.location.Location; +import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.world.PlotAreaManager; +import com.plotsquared.core.util.Permissions; import net.kyori.adventure.text.minimessage.placeholder.Placeholder; import org.bukkit.Chunk; import org.bukkit.block.Block; @@ -53,7 +55,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.entity.Slime; -import org.bukkit.entity.ThrownPotion; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -321,9 +322,6 @@ public class PaperListener implements Listener { return; } Projectile entity = event.getProjectile(); - if (!(entity instanceof ThrownPotion)) { - return; - } ProjectileSource shooter = entity.getShooter(); if (!(shooter instanceof Player)) { return; @@ -332,11 +330,36 @@ public class PaperListener implements Listener { if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) { return; } - PlotPlayer pp = BukkitUtil.adapt((Player) shooter); + PlotPlayer pp = BukkitUtil.adapt((Player) shooter); Plot plot = location.getOwnedPlot(); - if (plot != null && !plot.isAdded(pp.getUUID())) { - entity.remove(); - event.setCancelled(true); + + if (plot == null) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) { + pp.sendMessage( + TranslatableCaption.miniMessage("permission.no_permission_event"), + Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) + ); + entity.remove(); + event.setCancelled(true); + } + } else if (!plot.hasOwner()) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { + pp.sendMessage( + TranslatableCaption.miniMessage("permission.no_permission_event"), + Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) + ); + entity.remove(); + event.setCancelled(true); + } + } else if (!plot.isAdded(pp.getUUID())) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { + pp.sendMessage( + TranslatableCaption.miniMessage("permission.no_permission_event"), + Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) + ); + entity.remove(); + event.setCancelled(true); + } } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index c8c2db05c..b7bece73f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -127,7 +127,6 @@ import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerEggThrowEvent; import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; @@ -1239,13 +1238,6 @@ public class PlayerEventListener extends PlotListener implements Listener { ); event.setCancelled(true); } else if (!plot.isAdded(pp.getUUID())) { - List use = plot.getFlag(UseFlag.class); - final BlockType blockType = BukkitAdapter.asBlockType(block.getType()); - for (final BlockTypeWrapper blockTypeWrapper : use) { - if (blockTypeWrapper.accepts(blockType)) { - return; - } - } if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { return; } @@ -1311,14 +1303,6 @@ public class PlayerEventListener extends PlotListener implements Listener { ); event.setCancelled(true); } else if (!plot.isAdded(plotPlayer.getUUID())) { - List use = plot.getFlag(UseFlag.class); - Block block = event.getBlockClicked(); - final BlockType blockType = BukkitAdapter.asBlockType(block.getType()); - for (final BlockTypeWrapper blockTypeWrapper : use) { - if (blockTypeWrapper.accepts(blockType)) { - return; - } - } if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { return; } @@ -1610,43 +1594,6 @@ public class PlayerEventListener extends PlotListener implements Listener { } } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onPlayerEggThrow(PlayerEggThrowEvent event) { - Location location = BukkitUtil.adapt(event.getEgg().getLocation()); - PlotArea area = location.getPlotArea(); - if (area == null) { - return; - } - Player player = event.getPlayer(); - BukkitPlayer plotPlayer = BukkitUtil.adapt(player); - Plot plot = area.getPlot(location); - if (plot == null) { - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) { - plotPlayer.sendMessage( - TranslatableCaption.miniMessage("permission.no_permission_event"), - Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) - ); - event.setHatching(false); - } - } else if (!plot.hasOwner()) { - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { - plotPlayer.sendMessage( - TranslatableCaption.miniMessage("permission.no_permission_event"), - Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) - ); - event.setHatching(false); - } - } else if (!plot.isAdded(plotPlayer.getUUID())) { - if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { - plotPlayer.sendMessage( - TranslatableCaption.miniMessage("permission.no_permission_event"), - Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) - ); - event.setHatching(false); - } - } - } - @EventHandler public void onItemDrop(PlayerDropItemEvent event) { Player player = event.getPlayer(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java index 9a28ab448..895a40b32 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ProjectileEventListener.java @@ -28,6 +28,7 @@ package com.plotsquared.bukkit.listener; import com.google.inject.Inject; import com.plotsquared.bukkit.util.BukkitEntityUtil; import com.plotsquared.bukkit.util.BukkitUtil; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.location.Location; import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.player.PlotPlayer; @@ -36,6 +37,7 @@ import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotHandler; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.Permissions; +import net.kyori.adventure.text.minimessage.Template; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -96,9 +98,6 @@ public class ProjectileEventListener implements Listener { @EventHandler public void onProjectileLaunch(ProjectileLaunchEvent event) { Projectile entity = event.getEntity(); - if (!(entity instanceof ThrownPotion)) { - return; - } ProjectileSource shooter = entity.getShooter(); if (!(shooter instanceof Player)) { return; @@ -109,9 +108,34 @@ public class ProjectileEventListener implements Listener { } PlotPlayer pp = BukkitUtil.adapt((Player) shooter); Plot plot = location.getOwnedPlot(); - if (plot != null && !plot.isAdded(pp.getUUID())) { - entity.remove(); - event.setCancelled(true); + + if (plot == null) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) { + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) + ); + entity.remove(); + event.setCancelled(true); + } + } else if (!plot.hasOwner()) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) + ); + entity.remove(); + event.setCancelled(true); + } + } else if (!plot.isAdded(pp.getUUID())) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) + ); + entity.remove(); + event.setCancelled(true); + } } } @@ -131,14 +155,14 @@ public class ProjectileEventListener implements Listener { if (shooter instanceof Player) { PlotPlayer pp = BukkitUtil.adapt((Player) shooter); if (plot == null) { - if (!Permissions.hasPermission(pp, Permission.PERMISSION_PROJECTILE_UNOWNED)) { + if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) { entity.remove(); event.setCancelled(true); } return; } if (plot.isAdded(pp.getUUID()) || Permissions - .hasPermission(pp, Permission.PERMISSION_PROJECTILE_OTHER)) { + .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) { return; } entity.remove(); diff --git a/Core/src/main/java/com/plotsquared/core/permissions/Permission.java b/Core/src/main/java/com/plotsquared/core/permissions/Permission.java index ca07ac4ea..bec34ac8a 100644 --- a/Core/src/main/java/com/plotsquared/core/permissions/Permission.java +++ b/Core/src/main/java/com/plotsquared/core/permissions/Permission.java @@ -37,7 +37,9 @@ public enum Permission { PERMISSION_STAR("*"), PERMISSION_ADMIN("plots.admin"), PERMISSION_ADMIN_AREA_SUDO("plots.admin.area.sudo"), + @Deprecated(forRemoval = true, since = "6.3.0") PERMISSION_PROJECTILE_UNOWNED("plots.projectile.unowned"), + @Deprecated(forRemoval = true, since = "6.3.0") PERMISSION_PROJECTILE_OTHER("plots.projectile.other"), PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS("plots.admin.interact.blockedcommands"), PERMISSION_WORLDEDIT_BYPASS("plots.worldedit.bypass"),