Merge branch 'v6' into refactor/v6/update-mm

This commit is contained in:
NotMyFault 2021-12-18 00:48:39 +01:00
commit b07bd6f39c
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
8 changed files with 98 additions and 102 deletions

2
.github/stale.yml vendored
View File

@ -1,4 +1,4 @@
daysUntilStale: 60 daysUntilStale: 30
daysUntilClose: 7 daysUntilClose: 7
only: issues only: issues
exemptLabels: exemptLabels:

View File

@ -1,41 +1,41 @@
name: "build" name: build
on: [ "pull_request", "push" ] on: [ pull_request, push ]
jobs: jobs:
build: build:
runs-on: "ubuntu-20.04" runs-on: ubuntu-latest
steps: steps:
- name: "Checkout Repository" - name: Checkout Repository
uses: "actions/checkout@v2.4.0" uses: actions/checkout@v2.3.5
- name: "Validate Gradle Wrapper" - name: Validate Gradle Wrapper"
uses: "gradle/wrapper-validation-action@v1.0.4" uses: gradle/wrapper-validation-action@v1.0.4
- name: "Setup Java" - name: Setup Java
uses: "actions/setup-java@v2.4.0" uses: actions/setup-java@v2.4.0
with: with:
distribution: "temurin" distribution: temurin
java-version: "17" java-version: 17
- name: "Clean Build" - name: Clean Build
run: "./gradlew clean build" run: ./gradlew clean build
- name: "Determine release status" - name: Determine release status
if: "${{ runner.os == 'Linux' }}" if: ${{ runner.os == 'Linux' }}
run: | run: |
if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then
echo "STATUS=snapshot" >> $GITHUB_ENV echo "STATUS=snapshot" >> $GITHUB_ENV
else else
echo "STATUS=release" >> $GITHUB_ENV echo "STATUS=release" >> $GITHUB_ENV
fi fi
- name: "Publish Release" - name: Publish Release
if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}}" if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}}
run: "./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository" run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
env: env:
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: "${{ secrets.SIGNING_KEY }}" ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: "${{ secrets.SIGNING_PASSWORD }}" ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
- name: "Publish Snapshot" - name: Publish Snapshot
if: "${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6' }}" if: ${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6' }}
run: "./gradlew publishToSonatype" run: ./gradlew publishToSonatype
env: env:
ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SONATYPE_USERNAME }}" ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SONATYPE_PASSWORD }}" ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}

View File

@ -1,4 +1,4 @@
name: "draft release" name: draft release
on: on:
push: push:
@ -7,8 +7,8 @@ on:
jobs: jobs:
update_release_draft: update_release_draft:
runs-on: "ubuntu-latest" runs-on: ubuntu-latest
steps: steps:
- uses: "release-drafter/release-drafter@v5.15.0" - uses: release-drafter/release-drafter@v5.15.0
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -371,14 +371,14 @@ public class EntityEventListener implements Listener {
if (shooter instanceof Player) { if (shooter instanceof Player) {
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter); PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_PROJECTILE_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
entity.remove(); entity.remove();
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
} }
if (plot.isAdded(pp.getUUID()) || Permissions if (plot.isAdded(pp.getUUID()) || Permissions
.hasPermission(pp, Permission.PERMISSION_PROJECTILE_OTHER)) { .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
return; return;
} }
entity.remove(); entity.remove();

View File

@ -39,11 +39,13 @@ import com.plotsquared.core.command.MainCommand;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -53,7 +55,6 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -321,9 +322,6 @@ public class PaperListener implements Listener {
return; return;
} }
Projectile entity = event.getProjectile(); Projectile entity = event.getProjectile();
if (!(entity instanceof ThrownPotion)) {
return;
}
ProjectileSource shooter = entity.getShooter(); ProjectileSource shooter = entity.getShooter();
if (!(shooter instanceof Player)) { if (!(shooter instanceof Player)) {
return; return;
@ -332,12 +330,37 @@ public class PaperListener implements Listener {
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) { if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
return; return;
} }
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter); PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter);
Plot plot = location.getOwnedPlot(); Plot plot = location.getOwnedPlot();
if (plot != null && !plot.isAdded(pp.getUUID())) {
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(); entity.remove();
event.setCancelled(true); 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);
}
}
} }
@EventHandler @EventHandler

View File

@ -127,7 +127,6 @@ import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
@ -1239,13 +1238,6 @@ public class PlayerEventListener extends PlotListener implements Listener {
); );
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
List<BlockTypeWrapper> 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)) { if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
return; return;
} }
@ -1311,14 +1303,6 @@ public class PlayerEventListener extends PlotListener implements Listener {
); );
event.setCancelled(true); event.setCancelled(true);
} else if (!plot.isAdded(plotPlayer.getUUID())) { } else if (!plot.isAdded(plotPlayer.getUUID())) {
List<BlockTypeWrapper> 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)) { if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
return; 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 @EventHandler
public void onItemDrop(PlayerDropItemEvent event) { public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -28,6 +28,7 @@ package com.plotsquared.bukkit.listener;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.plotsquared.bukkit.util.BukkitEntityUtil; import com.plotsquared.bukkit.util.BukkitEntityUtil;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer; 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.PlotHandler;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.Template;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -96,9 +98,6 @@ public class ProjectileEventListener implements Listener {
@EventHandler @EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) { public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile entity = event.getEntity(); Projectile entity = event.getEntity();
if (!(entity instanceof ThrownPotion)) {
return;
}
ProjectileSource shooter = entity.getShooter(); ProjectileSource shooter = entity.getShooter();
if (!(shooter instanceof Player)) { if (!(shooter instanceof Player)) {
return; return;
@ -109,10 +108,35 @@ public class ProjectileEventListener implements Listener {
} }
PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter); PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter);
Plot plot = location.getOwnedPlot(); Plot plot = location.getOwnedPlot();
if (plot != null && !plot.isAdded(pp.getUUID())) {
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(); entity.remove();
event.setCancelled(true); 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);
}
}
} }
@EventHandler @EventHandler
@ -131,14 +155,14 @@ public class ProjectileEventListener implements Listener {
if (shooter instanceof Player) { if (shooter instanceof Player) {
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter); PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
if (plot == null) { if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_PROJECTILE_UNOWNED)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
entity.remove(); entity.remove();
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
} }
if (plot.isAdded(pp.getUUID()) || Permissions if (plot.isAdded(pp.getUUID()) || Permissions
.hasPermission(pp, Permission.PERMISSION_PROJECTILE_OTHER)) { .hasPermission(pp, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
return; return;
} }
entity.remove(); entity.remove();

View File

@ -37,7 +37,9 @@ public enum Permission {
PERMISSION_STAR("*"), PERMISSION_STAR("*"),
PERMISSION_ADMIN("plots.admin"), PERMISSION_ADMIN("plots.admin"),
PERMISSION_ADMIN_AREA_SUDO("plots.admin.area.sudo"), PERMISSION_ADMIN_AREA_SUDO("plots.admin.area.sudo"),
@Deprecated(forRemoval = true, since = "6.3.0")
PERMISSION_PROJECTILE_UNOWNED("plots.projectile.unowned"), PERMISSION_PROJECTILE_UNOWNED("plots.projectile.unowned"),
@Deprecated(forRemoval = true, since = "6.3.0")
PERMISSION_PROJECTILE_OTHER("plots.projectile.other"), PERMISSION_PROJECTILE_OTHER("plots.projectile.other"),
PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS("plots.admin.interact.blockedcommands"), PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS("plots.admin.interact.blockedcommands"),
PERMISSION_WORLDEDIT_BYPASS("plots.worldedit.bypass"), PERMISSION_WORLDEDIT_BYPASS("plots.worldedit.bypass"),