mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Merge v6/v7
This commit is contained in:
commit
6b680fb2c0
24
.github/workflows/build.yml
vendored
24
.github/workflows/build.yml
vendored
@ -40,3 +40,27 @@ jobs:
|
|||||||
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 }}
|
||||||
|
- name: Publish core javadoc
|
||||||
|
if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}}
|
||||||
|
uses: cpina/github-action-push-to-another-repository@main
|
||||||
|
env:
|
||||||
|
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
||||||
|
with:
|
||||||
|
source-directory: 'Core/build/docs/javadoc'
|
||||||
|
destination-github-username: 'IntellectualSites'
|
||||||
|
destination-repository-name: 'plotsquared-javadocs'
|
||||||
|
user-email: ${{ secrets.USER_EMAIL }}
|
||||||
|
target-branch: main
|
||||||
|
target-directory: core
|
||||||
|
- name: Publish bukkit javadoc
|
||||||
|
if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}}
|
||||||
|
uses: cpina/github-action-push-to-another-repository@main
|
||||||
|
env:
|
||||||
|
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
||||||
|
with:
|
||||||
|
source-directory: 'Bukkit/build/docs/javadoc'
|
||||||
|
destination-github-username: 'IntellectualSites'
|
||||||
|
destination-repository-name: 'plotsquared-javadocs'
|
||||||
|
user-email: ${{ secrets.USER_EMAIL }}
|
||||||
|
target-branch: main
|
||||||
|
target-directory: bukkit
|
||||||
|
@ -99,7 +99,7 @@ tasks {
|
|||||||
val opt = options as StandardJavadocDocletOptions
|
val opt = options as StandardJavadocDocletOptions
|
||||||
opt.links("https://jd.papermc.io/paper/1.18/")
|
opt.links("https://jd.papermc.io/paper/1.18/")
|
||||||
opt.links("https://docs.enginehub.org/javadoc/com.sk89q.worldedit/worldedit-bukkit/" + libs.worldeditBukkit.get().versionConstraint.toString())
|
opt.links("https://docs.enginehub.org/javadoc/com.sk89q.worldedit/worldedit-bukkit/" + libs.worldeditBukkit.get().versionConstraint.toString())
|
||||||
opt.links("https://javadoc.io/doc/com.plotsquared/PlotSquared-Core/latest/")
|
opt.links("https://intellectualsites.github.io/plotsquared-javadocs/core/")
|
||||||
opt.links("https://jd.adventure.kyori.net/api/4.9.3/")
|
opt.links("https://jd.adventure.kyori.net/api/4.9.3/")
|
||||||
opt.links("https://google.github.io/guice/api-docs/" + libs.guice.get().versionConstraint.toString() + "/javadoc/")
|
opt.links("https://google.github.io/guice/api-docs/" + libs.guice.get().versionConstraint.toString() + "/javadoc/")
|
||||||
opt.links("https://checkerframework.org/api/")
|
opt.links("https://checkerframework.org/api/")
|
||||||
|
@ -108,11 +108,20 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class BlockEventListener implements Listener {
|
public class BlockEventListener implements Listener {
|
||||||
|
|
||||||
|
private static final Set<Material> PISTONS = Set.of(
|
||||||
|
Material.PISTON,
|
||||||
|
Material.STICKY_PISTON
|
||||||
|
);
|
||||||
|
private static final Set<Material> PHYSICS_BLOCKS = Set.of(
|
||||||
|
Material.TURTLE_EGG,
|
||||||
|
Material.TURTLE_SPAWN_EGG
|
||||||
|
);
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
|
|
||||||
@ -218,50 +227,33 @@ public class BlockEventListener implements Listener {
|
|||||||
plot.debug("Prevented block physics and resent block change because disable-physics = true");
|
plot.debug("Prevented block physics and resent block change because disable-physics = true");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (event.getChangedType()) {
|
if (event.getChangedType() == Material.COMPARATOR) {
|
||||||
case COMPARATOR: {
|
|
||||||
if (!plot.getFlag(RedstoneFlag.class)) {
|
if (!plot.getFlag(RedstoneFlag.class)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
plot.debug("Prevented comparator update because redstone = false");
|
plot.debug("Prevented comparator update because redstone = false");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case ANVIL:
|
if (PHYSICS_BLOCKS.contains(event.getChangedType())) {
|
||||||
case DRAGON_EGG:
|
|
||||||
case GRAVEL:
|
|
||||||
case SAND:
|
|
||||||
case TURTLE_EGG:
|
|
||||||
case TURTLE_HELMET:
|
|
||||||
case TURTLE_SPAWN_EGG: {
|
|
||||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
plot.debug("Prevented block physics because disable-physics = true");
|
plot.debug("Prevented block physics because disable-physics = true");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) {
|
if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) {
|
||||||
switch (block.getType()) {
|
if (PISTONS.contains(block.getType())) {
|
||||||
case PISTON, STICKY_PISTON -> {
|
|
||||||
org.bukkit.block.data.Directional piston = (org.bukkit.block.data.Directional) block.getBlockData();
|
org.bukkit.block.data.Directional piston = (org.bukkit.block.data.Directional) block.getBlockData();
|
||||||
switch (piston.getFacing()) {
|
final BlockFace facing = piston.getFacing();
|
||||||
case EAST -> location = location.add(1, 0, 0);
|
location = location.add(facing.getModX(), facing.getModY(), facing.getModZ());
|
||||||
case SOUTH -> location = location.add(-1, 0, 0);
|
|
||||||
case WEST -> location = location.add(0, 0, 1);
|
|
||||||
case NORTH -> location = location.add(0, 0, -1);
|
|
||||||
}
|
|
||||||
Plot newPlot = area.getOwnedPlotAbs(location);
|
Plot newPlot = area.getOwnedPlotAbs(location);
|
||||||
if (!plot.equals(newPlot)) {
|
if (!plot.equals(newPlot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
plot.debug("Prevented piston update because of invalid edge piston detection");
|
plot.debug("Prevented piston update because of invalid edge piston detection");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void blockCreate(BlockPlaceEvent event) {
|
public void blockCreate(BlockPlaceEvent event) {
|
||||||
@ -572,17 +564,14 @@ public class BlockEventListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (event.getNewState().getType()) {
|
if (org.bukkit.Tag.SNOW.isTagged(event.getNewState().getType())) {
|
||||||
case SNOW:
|
|
||||||
case SNOW_BLOCK:
|
|
||||||
if (!plot.getFlag(SnowFormFlag.class)) {
|
if (!plot.getFlag(SnowFormFlag.class)) {
|
||||||
plot.debug("Snow could not form because snow-form = false");
|
plot.debug("Snow could not form because snow-form = false");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case ICE:
|
}
|
||||||
case FROSTED_ICE:
|
if (org.bukkit.Tag.ICE.isTagged(event.getNewState().getType())) {
|
||||||
case PACKED_ICE:
|
|
||||||
if (!plot.getFlag(IceFormFlag.class)) {
|
if (!plot.getFlag(IceFormFlag.class)) {
|
||||||
plot.debug("Ice could not form because ice-form = false");
|
plot.debug("Ice could not form because ice-form = false");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -607,18 +596,12 @@ public class BlockEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Class<? extends BooleanFlag<?>> flag;
|
Class<? extends BooleanFlag<?>> flag;
|
||||||
switch (event.getNewState().getType()) {
|
if (org.bukkit.Tag.SNOW.isTagged(event.getNewState().getType())) {
|
||||||
case SNOW:
|
|
||||||
case SNOW_BLOCK:
|
|
||||||
flag = SnowFormFlag.class;
|
flag = SnowFormFlag.class;
|
||||||
break;
|
} else if (org.bukkit.Tag.ICE.isTagged(event.getNewState().getType())) {
|
||||||
case ICE:
|
|
||||||
case FROSTED_ICE:
|
|
||||||
case PACKED_ICE:
|
|
||||||
flag = IceFormFlag.class;
|
flag = IceFormFlag.class;
|
||||||
break;
|
} else {
|
||||||
default:
|
return;
|
||||||
return; // other blocks are ignored by this event
|
|
||||||
}
|
}
|
||||||
boolean allowed = plot.getFlag(flag);
|
boolean allowed = plot.getFlag(flag);
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
@ -722,50 +705,33 @@ public class BlockEventListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (block.getType()) {
|
Material blockType = block.getType();
|
||||||
case ICE:
|
if (org.bukkit.Tag.ICE.isTagged(blockType)) {
|
||||||
if (!plot.getFlag(IceMeltFlag.class)) {
|
if (!plot.getFlag(IceMeltFlag.class)) {
|
||||||
plot.debug("Ice could not melt because ice-melt = false");
|
plot.debug("Ice could not melt because ice-melt = false");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
return;
|
||||||
case SNOW:
|
}
|
||||||
|
if (org.bukkit.Tag.SNOW.isTagged(blockType)) {
|
||||||
if (!plot.getFlag(SnowMeltFlag.class)) {
|
if (!plot.getFlag(SnowMeltFlag.class)) {
|
||||||
plot.debug("Snow could not melt because snow-melt = false");
|
plot.debug("Snow could not melt because snow-melt = false");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
return;
|
||||||
case FARMLAND:
|
}
|
||||||
|
if (blockType == Material.FARMLAND) {
|
||||||
if (!plot.getFlag(SoilDryFlag.class)) {
|
if (!plot.getFlag(SoilDryFlag.class)) {
|
||||||
plot.debug("Soil could not dry because soil-dry = false");
|
plot.debug("Soil could not dry because soil-dry = false");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
return;
|
||||||
case TUBE_CORAL_BLOCK:
|
}
|
||||||
case BRAIN_CORAL_BLOCK:
|
if (org.bukkit.Tag.CORAL_BLOCKS.isTagged(blockType) || org.bukkit.Tag.CORALS.isTagged(blockType)) {
|
||||||
case BUBBLE_CORAL_BLOCK:
|
|
||||||
case FIRE_CORAL_BLOCK:
|
|
||||||
case HORN_CORAL_BLOCK:
|
|
||||||
case TUBE_CORAL:
|
|
||||||
case BRAIN_CORAL:
|
|
||||||
case BUBBLE_CORAL:
|
|
||||||
case FIRE_CORAL:
|
|
||||||
case HORN_CORAL:
|
|
||||||
case TUBE_CORAL_FAN:
|
|
||||||
case BRAIN_CORAL_FAN:
|
|
||||||
case BUBBLE_CORAL_FAN:
|
|
||||||
case FIRE_CORAL_FAN:
|
|
||||||
case HORN_CORAL_FAN:
|
|
||||||
case BRAIN_CORAL_WALL_FAN:
|
|
||||||
case BUBBLE_CORAL_WALL_FAN:
|
|
||||||
case FIRE_CORAL_WALL_FAN:
|
|
||||||
case HORN_CORAL_WALL_FAN:
|
|
||||||
case TUBE_CORAL_WALL_FAN:
|
|
||||||
if (!plot.getFlag(CoralDryFlag.class)) {
|
if (!plot.getFlag(CoralDryFlag.class)) {
|
||||||
plot.debug("Coral could not dry because coral-dry = false");
|
plot.debug("Coral could not dry because coral-dry = false");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ 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.CopperOxideFlag;
|
import com.plotsquared.core.plot.flag.implementations.CopperOxideFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.MiscInteractFlag;
|
import com.plotsquared.core.plot.flag.implementations.MiscInteractFlag;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
@ -39,11 +40,31 @@ import org.bukkit.event.block.BlockReceiveGameEvent;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class BlockEventListener117 implements Listener {
|
public class BlockEventListener117 implements Listener {
|
||||||
|
|
||||||
|
private static final Set<Material> COPPER_OXIDIZING = Set.of(
|
||||||
|
Material.COPPER_BLOCK,
|
||||||
|
Material.EXPOSED_COPPER,
|
||||||
|
Material.WEATHERED_COPPER,
|
||||||
|
Material.OXIDIZED_COPPER,
|
||||||
|
Material.CUT_COPPER,
|
||||||
|
Material.EXPOSED_CUT_COPPER,
|
||||||
|
Material.WEATHERED_CUT_COPPER,
|
||||||
|
Material.OXIDIZED_CUT_COPPER,
|
||||||
|
Material.CUT_COPPER_STAIRS,
|
||||||
|
Material.EXPOSED_CUT_COPPER_STAIRS,
|
||||||
|
Material.WEATHERED_CUT_COPPER_STAIRS,
|
||||||
|
Material.OXIDIZED_CUT_COPPER_STAIRS,
|
||||||
|
Material.CUT_COPPER_SLAB,
|
||||||
|
Material.EXPOSED_CUT_COPPER_SLAB,
|
||||||
|
Material.WEATHERED_CUT_COPPER_SLAB,
|
||||||
|
Material.OXIDIZED_CUT_COPPER_SLAB
|
||||||
|
);
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BlockEventListener117() {
|
public BlockEventListener117() {
|
||||||
}
|
}
|
||||||
@ -148,23 +169,7 @@ public class BlockEventListener117 implements Listener {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (event.getNewState().getType()) {
|
if (COPPER_OXIDIZING.contains(event.getNewState().getType())) {
|
||||||
case COPPER_BLOCK:
|
|
||||||
case EXPOSED_COPPER:
|
|
||||||
case WEATHERED_COPPER:
|
|
||||||
case OXIDIZED_COPPER:
|
|
||||||
case CUT_COPPER:
|
|
||||||
case EXPOSED_CUT_COPPER:
|
|
||||||
case WEATHERED_CUT_COPPER:
|
|
||||||
case OXIDIZED_CUT_COPPER:
|
|
||||||
case CUT_COPPER_STAIRS:
|
|
||||||
case EXPOSED_CUT_COPPER_STAIRS:
|
|
||||||
case WEATHERED_CUT_COPPER_STAIRS:
|
|
||||||
case OXIDIZED_CUT_COPPER_STAIRS:
|
|
||||||
case CUT_COPPER_SLAB:
|
|
||||||
case EXPOSED_CUT_COPPER_SLAB:
|
|
||||||
case WEATHERED_CUT_COPPER_SLAB:
|
|
||||||
case OXIDIZED_CUT_COPPER_SLAB:
|
|
||||||
if (!plot.getFlag(CopperOxideFlag.class)) {
|
if (!plot.getFlag(CopperOxideFlag.class)) {
|
||||||
plot.debug("Copper could not oxide because copper-oxide = false");
|
plot.debug("Copper could not oxide because copper-oxide = false");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -124,16 +124,16 @@ public class EntitySpawnListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = location.getOwnedPlotAbs();
|
Plot plot = location.getOwnedPlotAbs();
|
||||||
if (plot == null) {
|
|
||||||
EntityType type = entity.getType();
|
EntityType type = entity.getType();
|
||||||
|
if (plot == null) {
|
||||||
if (!area.isMobSpawning()) {
|
if (!area.isMobSpawning()) {
|
||||||
switch (type) {
|
if (type == EntityType.PLAYER) {
|
||||||
case DROPPED_ITEM:
|
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case PLAYER:
|
if (type == EntityType.DROPPED_ITEM) {
|
||||||
|
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type.isAlive()) {
|
if (type.isAlive()) {
|
||||||
@ -148,12 +148,13 @@ public class EntitySpawnListener implements Listener {
|
|||||||
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
switch (entity.getType()) {
|
if (type == EntityType.ENDER_CRYSTAL) {
|
||||||
case ENDER_CRYSTAL:
|
|
||||||
if (BukkitEntityUtil.checkEntity(entity, plot)) {
|
if (BukkitEntityUtil.checkEntity(entity, plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
case SHULKER:
|
return;
|
||||||
|
}
|
||||||
|
if (type == EntityType.SHULKER) {
|
||||||
if (!entity.hasMetadata("shulkerPlot")) {
|
if (!entity.hasMetadata("shulkerPlot")) {
|
||||||
entity.setMetadata("shulkerPlot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot.getId()));
|
entity.setMetadata("shulkerPlot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot.getId()));
|
||||||
}
|
}
|
||||||
|
@ -232,14 +232,14 @@ public class PaperListener implements Listener {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
EntityType type = event.getType();
|
EntityType type = event.getType();
|
||||||
if (!area.isMobSpawning()) {
|
if (!area.isMobSpawning()) {
|
||||||
switch (type) {
|
if (type == EntityType.PLAYER) {
|
||||||
case DROPPED_ITEM:
|
return;
|
||||||
|
}
|
||||||
|
if (type == EntityType.DROPPED_ITEM) {
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
|
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
|
||||||
event.setShouldAbortSpawn(true);
|
event.setShouldAbortSpawn(true);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
case PLAYER:
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type.isAlive()) {
|
if (type.isAlive()) {
|
||||||
|
@ -82,7 +82,6 @@ import net.kyori.adventure.text.minimessage.tag.Tag;
|
|||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.FluidCollisionMode;
|
import org.bukkit.FluidCollisionMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -160,6 +159,20 @@ import java.util.UUID;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class PlayerEventListener extends PlotListener implements Listener {
|
public class PlayerEventListener extends PlotListener implements Listener {
|
||||||
|
|
||||||
|
private static final Set<Material> MINECARTS = Set.of(
|
||||||
|
Material.MINECART,
|
||||||
|
Material.TNT_MINECART,
|
||||||
|
Material.CHEST_MINECART,
|
||||||
|
Material.COMMAND_BLOCK_MINECART,
|
||||||
|
Material.FURNACE_MINECART,
|
||||||
|
Material.HOPPER_MINECART
|
||||||
|
);
|
||||||
|
private static final Set<Material> BOOKS = Set.of(
|
||||||
|
Material.BOOK,
|
||||||
|
Material.KNOWLEDGE_BOOK,
|
||||||
|
Material.WRITABLE_BOOK,
|
||||||
|
Material.WRITTEN_BOOK
|
||||||
|
);
|
||||||
private final EventDispatcher eventDispatcher;
|
private final EventDispatcher eventDispatcher;
|
||||||
private final WorldEdit worldEdit;
|
private final WorldEdit worldEdit;
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
@ -829,10 +842,10 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
if ((slot > 8) || !event.getEventName().equals("InventoryCreativeEvent")) {
|
if ((slot > 8) || !event.getEventName().equals("InventoryCreativeEvent")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack current = inv.getItemInHand();
|
ItemStack oldItem = inv.getItemInHand();
|
||||||
|
ItemMeta oldMeta = oldItem.getItemMeta();
|
||||||
ItemStack newItem = event.getCursor();
|
ItemStack newItem = event.getCursor();
|
||||||
ItemMeta newMeta = newItem.getItemMeta();
|
ItemMeta newMeta = newItem.getItemMeta();
|
||||||
ItemMeta oldMeta = newItem.getItemMeta();
|
|
||||||
|
|
||||||
if (event.getClick() == ClickType.CREATIVE) {
|
if (event.getClick() == ClickType.CREATIVE) {
|
||||||
final Plot plot = pp.getCurrentPlot();
|
final Plot plot = pp.getCurrentPlot();
|
||||||
@ -872,33 +885,25 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
oldLore = lore.toString();
|
oldLore = lore.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!"[(+NBT)]".equals(newLore) || (current.equals(newItem) && newLore.equals(oldLore))) {
|
Material itemType = newItem.getType();
|
||||||
switch (newItem.getType()) {
|
if (!"[(+NBT)]".equals(newLore) || (oldItem.equals(newItem) && newLore.equals(oldLore))) {
|
||||||
case LEGACY_BANNER:
|
if (newMeta == null || (itemType != Material.LEGACY_BANNER && itemType != Material.PLAYER_HEAD)) {
|
||||||
case PLAYER_HEAD:
|
|
||||||
if (newMeta != null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Block block = player.getTargetBlock(null, 7);
|
Block block = player.getTargetBlock(null, 7);
|
||||||
org.bukkit.block.BlockState state = block.getState();
|
org.bukkit.block.BlockState state = block.getState();
|
||||||
Material stateType = state.getType();
|
Material stateType = state.getType();
|
||||||
Material itemType = newItem.getType();
|
|
||||||
if (stateType != itemType) {
|
if (stateType != itemType) {
|
||||||
switch (stateType) {
|
if (stateType == Material.LEGACY_WALL_BANNER || stateType == Material.LEGACY_STANDING_BANNER) {
|
||||||
case LEGACY_STANDING_BANNER:
|
if (itemType != Material.LEGACY_BANNER) {
|
||||||
case LEGACY_WALL_BANNER:
|
return;
|
||||||
if (itemType == Material.LEGACY_BANNER) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case LEGACY_SKULL:
|
} else if (stateType == Material.LEGACY_SKULL) {
|
||||||
if (itemType == Material.LEGACY_SKULL_ITEM) {
|
if (itemType != Material.LEGACY_SKULL_ITEM) {
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -947,7 +952,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
if ((current.getType() == newItem.getType()) && (current.getDurability() == newItem
|
if ((oldItem.getType() == newItem.getType()) && (oldItem.getDurability() == newItem
|
||||||
.getDurability())) {
|
.getDurability())) {
|
||||||
event.setCursor(
|
event.setCursor(
|
||||||
new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
|
new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
|
||||||
@ -1143,15 +1148,21 @@ public class PlayerEventListener extends PlotListener implements Listener {
|
|||||||
//Allow all players to eat while also allowing the block place event ot be fired
|
//Allow all players to eat while also allowing the block place event ot be fired
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (type) {
|
if (type == Material.ARMOR_STAND) {
|
||||||
case ACACIA_BOAT, BIRCH_BOAT, CHEST_MINECART, COMMAND_BLOCK_MINECART, DARK_OAK_BOAT, FURNACE_MINECART, HOPPER_MINECART, JUNGLE_BOAT, MINECART, OAK_BOAT, SPRUCE_BOAT, TNT_MINECART ->
|
|
||||||
eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
|
||||||
case FIREWORK_ROCKET, FIREWORK_STAR -> eventType = PlayerBlockEventType.SPAWN_MOB;
|
|
||||||
case BOOK, KNOWLEDGE_BOOK, WRITABLE_BOOK, WRITTEN_BOOK -> eventType = PlayerBlockEventType.READ;
|
|
||||||
case ARMOR_STAND -> {
|
|
||||||
location = BukkitUtil.adapt(block.getRelative(event.getBlockFace()).getLocation());
|
location = BukkitUtil.adapt(block.getRelative(event.getBlockFace()).getLocation());
|
||||||
eventType = PlayerBlockEventType.PLACE_MISC;
|
eventType = PlayerBlockEventType.PLACE_MISC;
|
||||||
}
|
}
|
||||||
|
if (org.bukkit.Tag.ITEMS_BOATS.isTagged(type) || MINECARTS.contains(type)) {
|
||||||
|
eventType = PlayerBlockEventType.PLACE_VEHICLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (type == Material.FIREWORK_ROCKET || type == Material.FIREWORK_STAR) {
|
||||||
|
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (BOOKS.contains(type)) {
|
||||||
|
eventType = PlayerBlockEventType.READ;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
public short PATH_WIDTH_UPPER;
|
public short PATH_WIDTH_UPPER;
|
||||||
public HashMap<Integer, BaseBlock[]> G_SCH;
|
public HashMap<Integer, BaseBlock[]> G_SCH;
|
||||||
public HashMap<Integer, BiomeType> G_SCH_B;
|
public HashMap<Integer, BiomeType> G_SCH_B;
|
||||||
|
/**
|
||||||
|
* The Y level at which schematic generation will start, lowest of either road or plot schematic generation.
|
||||||
|
*/
|
||||||
public int SCHEM_Y;
|
public int SCHEM_Y;
|
||||||
private Location SIGN_LOCATION;
|
private Location SIGN_LOCATION;
|
||||||
private File root = null;
|
private File root = null;
|
||||||
@ -266,33 +269,57 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
int oddshift = (this.ROAD_WIDTH & 1);
|
int oddshift = (this.ROAD_WIDTH & 1);
|
||||||
|
|
||||||
SCHEM_Y = schematicStartHeight();
|
SCHEM_Y = schematicStartHeight();
|
||||||
|
|
||||||
|
// plotY and roadY are important to allow plot and/or road schematic "overflow" into each other without causing AIOOB
|
||||||
|
// exceptions when attempting either to set blocks to, or get block from G_SCH
|
||||||
|
// Default plot schematic start height, normalized to the minimum height schematics are pasted from.
|
||||||
int plotY = PLOT_HEIGHT - SCHEM_Y;
|
int plotY = PLOT_HEIGHT - SCHEM_Y;
|
||||||
int minRoadWall = Settings.Schematics.USE_WALL_IN_ROAD_SCHEM_HEIGHT ? Math.min(ROAD_HEIGHT, WALL_HEIGHT) : ROAD_HEIGHT;
|
int minRoadWall = Settings.Schematics.USE_WALL_IN_ROAD_SCHEM_HEIGHT ? Math.min(ROAD_HEIGHT, WALL_HEIGHT) : ROAD_HEIGHT;
|
||||||
|
// Default road schematic start height, normalized to the minimum height schematics are pasted from.
|
||||||
int roadY = minRoadWall - SCHEM_Y;
|
int roadY = minRoadWall - SCHEM_Y;
|
||||||
|
|
||||||
int worldHeight = getMaxGenHeight() - getMinGenHeight() + 1;
|
int worldGenHeight = getMaxGenHeight() - getMinGenHeight() + 1;
|
||||||
|
|
||||||
|
int maxSchematicHeight = 0;
|
||||||
|
|
||||||
// SCHEM_Y should be normalised to the plot "start" height
|
// SCHEM_Y should be normalised to the plot "start" height
|
||||||
if (schematic3 != null) {
|
if (schematic3 != null) {
|
||||||
if (schematic3.getClipboard().getDimensions().getY() == worldHeight) {
|
if ((maxSchematicHeight = schematic3.getClipboard().getDimensions().getY()) == worldGenHeight) {
|
||||||
SCHEM_Y = plotY = 0;
|
SCHEM_Y = getMinGenHeight();
|
||||||
|
plotY = 0;
|
||||||
} else if (!Settings.Schematics.PASTE_ON_TOP) {
|
} else if (!Settings.Schematics.PASTE_ON_TOP) {
|
||||||
SCHEM_Y = plotY = getMinBuildHeight() - getMinGenHeight();
|
SCHEM_Y = getMinBuildHeight();
|
||||||
|
plotY = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schematic1 != null) {
|
if (schematic1 != null) {
|
||||||
if (schematic1.getClipboard().getDimensions().getY() == worldHeight) {
|
if ((maxSchematicHeight = Math.max(
|
||||||
SCHEM_Y = roadY = getMinGenHeight();
|
schematic1.getClipboard().getDimensions().getY(),
|
||||||
if (schematic3 != null && schematic3.getClipboard().getDimensions().getY() != worldHeight
|
maxSchematicHeight
|
||||||
&& !Settings.Schematics.PASTE_ON_TOP) {
|
)) == worldGenHeight) {
|
||||||
plotY = PLOT_HEIGHT;
|
SCHEM_Y = getMinGenHeight();
|
||||||
|
roadY = 0; // Road is the lowest schematic
|
||||||
|
if (schematic3 != null && schematic3.getClipboard().getDimensions().getY() != worldGenHeight) {
|
||||||
|
// Road is the lowest schematic. Normalize plotY to it.
|
||||||
|
if (Settings.Schematics.PASTE_ON_TOP) {
|
||||||
|
plotY = PLOT_HEIGHT - getMinGenHeight();
|
||||||
|
} else {
|
||||||
|
plotY = getMinBuildHeight() - getMinGenHeight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (!Settings.Schematics.PASTE_ROAD_ON_TOP) {
|
} else if (!Settings.Schematics.PASTE_ROAD_ON_TOP) {
|
||||||
SCHEM_Y = roadY = getMinBuildHeight();
|
if (SCHEM_Y == getMinGenHeight()) { // Only possible if plot schematic is enabled
|
||||||
if (schematic3 != null && schematic3.getClipboard().getDimensions().getY() != worldHeight
|
// Plot is still the lowest schematic, normalize roadY to it
|
||||||
&& !Settings.Schematics.PASTE_ON_TOP) {
|
roadY = getMinBuildHeight() - getMinGenHeight();
|
||||||
plotY = PLOT_HEIGHT;
|
} else if (schematic3 != null) {
|
||||||
|
SCHEM_Y = getMinBuildHeight();
|
||||||
|
roadY = 0;// Road is the lowest schematic
|
||||||
|
if (Settings.Schematics.PASTE_ON_TOP) {
|
||||||
|
// Road is the lowest schematic. Normalize plotY to it.
|
||||||
|
plotY = PLOT_HEIGHT - getMinBuildHeight();
|
||||||
|
}
|
||||||
|
// If plot schematic is not paste-on-top, it will be from min build height thus plotY = 0 as well already.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -330,7 +357,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
y + min.getBlockY(),
|
y + min.getBlockY(),
|
||||||
z + min.getBlockZ()
|
z + min.getBlockZ()
|
||||||
));
|
));
|
||||||
if (!id.getBlockType().getMaterial().isAir()) {
|
|
||||||
schem3PopulationNeeded |= id.hasNbtData();
|
schem3PopulationNeeded |= id.hasNbtData();
|
||||||
addOverlayBlock(
|
addOverlayBlock(
|
||||||
(short) (x + shift + oddshift + centerShiftX),
|
(short) (x + shift + oddshift + centerShiftX),
|
||||||
@ -338,10 +364,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
(short) (z + shift + oddshift + centerShiftZ),
|
(short) (z + shift + oddshift + centerShiftZ),
|
||||||
id,
|
id,
|
||||||
false,
|
false,
|
||||||
h3
|
maxSchematicHeight
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (blockArrayClipboard3.hasBiomes()) {
|
if (blockArrayClipboard3.hasBiomes()) {
|
||||||
BiomeType biome = blockArrayClipboard3.getBiome(BlockVector2.at(
|
BiomeType biome = blockArrayClipboard3.getBiome(BlockVector2.at(
|
||||||
x + min.getBlockX(),
|
x + min.getBlockX(),
|
||||||
@ -390,19 +415,24 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
y + min.getBlockY(),
|
y + min.getBlockY(),
|
||||||
z + min.getBlockZ()
|
z + min.getBlockZ()
|
||||||
));
|
));
|
||||||
if (!id.getBlockType().getMaterial().isAir()) {
|
|
||||||
schem1PopulationNeeded |= id.hasNbtData();
|
schem1PopulationNeeded |= id.hasNbtData();
|
||||||
addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z + shift + oddshift), id, false, h1);
|
addOverlayBlock(
|
||||||
|
(short) (x - shift),
|
||||||
|
(short) (y + roadY),
|
||||||
|
(short) (z + shift + oddshift),
|
||||||
|
id,
|
||||||
|
false,
|
||||||
|
maxSchematicHeight
|
||||||
|
);
|
||||||
addOverlayBlock(
|
addOverlayBlock(
|
||||||
(short) (z + shift + oddshift),
|
(short) (z + shift + oddshift),
|
||||||
(short) (y + roadY),
|
(short) (y + roadY),
|
||||||
(short) (shift - x + (oddshift - 1)),
|
(short) (shift - x + (oddshift - 1)),
|
||||||
id,
|
id,
|
||||||
true,
|
true,
|
||||||
h1
|
maxSchematicHeight
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (blockArrayClipboard1.hasBiomes()) {
|
if (blockArrayClipboard1.hasBiomes()) {
|
||||||
BiomeType biome = blockArrayClipboard1.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
BiomeType biome = blockArrayClipboard1.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
||||||
addOverlayBiome((short) (x - shift), (short) (z + shift + oddshift), biome);
|
addOverlayBiome((short) (x - shift), (short) (z + shift + oddshift), biome);
|
||||||
@ -429,10 +459,15 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
y + min.getBlockY(),
|
y + min.getBlockY(),
|
||||||
z + min.getBlockZ()
|
z + min.getBlockZ()
|
||||||
));
|
));
|
||||||
if (!id.getBlockType().getMaterial().isAir()) {
|
|
||||||
schem2PopulationNeeded |= id.hasNbtData();
|
schem2PopulationNeeded |= id.hasNbtData();
|
||||||
addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z - shift), id, false, h2);
|
addOverlayBlock(
|
||||||
}
|
(short) (x - shift),
|
||||||
|
(short) (y + roadY),
|
||||||
|
(short) (z - shift),
|
||||||
|
id,
|
||||||
|
false,
|
||||||
|
maxSchematicHeight
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (blockArrayClipboard2.hasBiomes()) {
|
if (blockArrayClipboard2.hasBiomes()) {
|
||||||
BiomeType biome = blockArrayClipboard2.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
BiomeType biome = blockArrayClipboard2.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
||||||
@ -442,6 +477,10 @@ 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 = "TODO")
|
||||||
public void addOverlayBlock(short x, short y, short z, BaseBlock id, boolean rotate, int height) {
|
public void addOverlayBlock(short x, short y, short z, BaseBlock id, boolean rotate, int height) {
|
||||||
if (z < 0) {
|
if (z < 0) {
|
||||||
z += this.SIZE;
|
z += this.SIZE;
|
||||||
@ -468,6 +507,10 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
existing[y] = id;
|
existing[y] = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This method should not be available for public API usage and will be made private.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "TODO")
|
||||||
public void addOverlayBiome(short x, short z, BiomeType id) {
|
public void addOverlayBiome(short x, short z, BiomeType id) {
|
||||||
if (z < 0) {
|
if (z < 0) {
|
||||||
z += this.SIZE;
|
z += this.SIZE;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
[versions]
|
[versions]
|
||||||
# Platform expectations
|
# Platform expectations
|
||||||
paper = "1.18.2-R0.1-SNAPSHOT"
|
paper = "1.19-R0.1-SNAPSHOT"
|
||||||
checker-qual = "3.22.0"
|
|
||||||
guice = "5.1.0"
|
guice = "5.1.0"
|
||||||
spotbugs = "4.7.0"
|
spotbugs = "4.7.0"
|
||||||
|
|
||||||
@ -15,7 +14,7 @@ mvdwapi = "3.1.1"
|
|||||||
# Third party
|
# Third party
|
||||||
prtree = "2.0.0"
|
prtree = "2.0.0"
|
||||||
aopalliance = "1.0"
|
aopalliance = "1.0"
|
||||||
cloud-services = "1.6.2"
|
cloud-services = "1.7.0"
|
||||||
arkitektonika = "2.1.1"
|
arkitektonika = "2.1.1"
|
||||||
squirrelid = "0.3.1"
|
squirrelid = "0.3.1"
|
||||||
http4j = "1.3"
|
http4j = "1.3"
|
||||||
@ -29,7 +28,6 @@ nexus = "1.1.0"
|
|||||||
[libraries]
|
[libraries]
|
||||||
# Platform expectations
|
# Platform expectations
|
||||||
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
|
paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
|
||||||
checkerqual = { group = "org.checkerframework", name = "checker-qual", version.ref = "checker-qual" }
|
|
||||||
|
|
||||||
# Platform expectations
|
# Platform expectations
|
||||||
guice = { group = "com.google.inject", name = "guice", version.ref = "guice" }
|
guice = { group = "com.google.inject", name = "guice", version.ref = "guice" }
|
||||||
|
Loading…
Reference in New Issue
Block a user