Merge branch 'v6' into v7

This commit is contained in:
Alexander Brandes
2023-02-10 16:44:57 +01:00
7 changed files with 166 additions and 13 deletions

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

@ -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();