Mirror von
https://github.com/Moulberry/AxiomPaperPlugin.git
synchronisiert 2024-11-17 05:40:06 +01:00
Construct CraftBlockState correctly
Dieser Commit ist enthalten in:
Ursprung
2cfe9b63b2
Commit
2b91b781ed
@ -4,7 +4,6 @@ import com.google.common.collect.Maps;
|
|||||||
import com.moulberry.axiom.AxiomPaper;
|
import com.moulberry.axiom.AxiomPaper;
|
||||||
import com.moulberry.axiom.integration.Integration;
|
import com.moulberry.axiom.integration.Integration;
|
||||||
import com.moulberry.axiom.integration.coreprotect.CoreProtectIntegration;
|
import com.moulberry.axiom.integration.coreprotect.CoreProtectIntegration;
|
||||||
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@ -28,24 +27,22 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
|
|||||||
import net.minecraft.world.level.levelgen.Heightmap;
|
import net.minecraft.world.level.levelgen.Heightmap;
|
||||||
import net.minecraft.world.level.lighting.LightEngine;
|
import net.minecraft.world.level.lighting.LightEngine;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_20_R2.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.block.CapturedBlockState;
|
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.block.CraftBlock;
|
import org.bukkit.craftbukkit.v1_20_R2.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.block.CraftBlockStates;
|
import org.bukkit.craftbukkit.v1_20_R2.block.CraftBlockState;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory;
|
import org.bukkit.craftbukkit.v1_20_R2.event.CraftEventFactory;
|
||||||
import org.bukkit.craftbukkit.v1_20_R2.util.CraftMagicNumbers;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import xyz.jpenilla.reflectionremapper.ReflectionRemapper;
|
import xyz.jpenilla.reflectionremapper.ReflectionRemapper;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -86,6 +83,12 @@ public class SetBlockPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class AxiomPlacingCraftBlockState extends CraftBlockState {
|
||||||
|
public AxiomPlacingCraftBlockState(@Nullable World world, BlockPos blockPosition, BlockState blockData) {
|
||||||
|
super(world, blockPosition, blockData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void process(Player bukkitPlayer, byte[] message) {
|
private void process(Player bukkitPlayer, byte[] message) {
|
||||||
if (!this.plugin.canUseAxiom(bukkitPlayer, "axiom.build.place")) {
|
if (!this.plugin.canUseAxiom(bukkitPlayer, "axiom.build.place")) {
|
||||||
return;
|
return;
|
||||||
@ -139,8 +142,9 @@ public class SetBlockPacketListener implements PluginMessageListener {
|
|||||||
|
|
||||||
// Call BlockMultiPlace / BlockPlace event
|
// Call BlockMultiPlace / BlockPlace event
|
||||||
List<org.bukkit.block.BlockState> blockStates = new ArrayList<>();
|
List<org.bukkit.block.BlockState> blockStates = new ArrayList<>();
|
||||||
|
World world = player.serverLevel().getWorld();
|
||||||
for (Map.Entry<BlockPos, BlockState> entry : blocks.entrySet()) {
|
for (Map.Entry<BlockPos, BlockState> entry : blocks.entrySet()) {
|
||||||
blockStates.add(CraftBlockStates.getBlockState(entry.getKey(), entry.getValue(), null));
|
blockStates.add(new AxiomPlacingCraftBlockState(world, entry.getKey(), entry.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Cancellable event = null;
|
Cancellable event = null;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren