Mirror von
https://github.com/Moulberry/AxiomPaperPlugin.git
synchronisiert 2024-11-08 17:40:04 +01:00
Add two more config options
Dieser Commit ist enthalten in:
Ursprung
fa3f904f22
Commit
5c8e845b62
@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.moulberry.axiom"
|
group = "com.moulberry.axiom"
|
||||||
version = "1.5.1"
|
version = "1.5.2"
|
||||||
description = "Serverside component for Axiom on Paper"
|
description = "Serverside component for Axiom on Paper"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -93,39 +93,43 @@ public class RequestChunkDataPacketListener implements PluginMessageListener {
|
|||||||
int playerSectionZ = player.getBlockZ() >> 4;
|
int playerSectionZ = player.getBlockZ() >> 4;
|
||||||
|
|
||||||
Long2ObjectMap<PalettedContainer<BlockState>> sections = new Long2ObjectOpenHashMap<>();
|
Long2ObjectMap<PalettedContainer<BlockState>> sections = new Long2ObjectOpenHashMap<>();
|
||||||
count = friendlyByteBuf.readVarInt();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
long pos = friendlyByteBuf.readLong();
|
|
||||||
|
|
||||||
int sx = BlockPos.getX(pos);
|
int maxChunkLoadDistance = this.plugin.configuration.getInt("max-chunk-load-distance");
|
||||||
int sy = BlockPos.getY(pos);
|
if (maxChunkLoadDistance > 0) {
|
||||||
int sz = BlockPos.getZ(pos);
|
count = friendlyByteBuf.readVarInt();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
long pos = friendlyByteBuf.readLong();
|
||||||
|
|
||||||
int distance = Math.abs(playerSectionX - sx) + Math.abs(playerSectionZ - sz);
|
int sx = BlockPos.getX(pos);
|
||||||
if (distance > 128) continue;
|
int sy = BlockPos.getY(pos);
|
||||||
|
int sz = BlockPos.getZ(pos);
|
||||||
|
|
||||||
LevelChunk chunk = level.getChunk(sx, sz);
|
int distance = Math.abs(playerSectionX - sx) + Math.abs(playerSectionZ - sz);
|
||||||
int sectionIndex = chunk.getSectionIndexFromSectionY(sy);
|
if (distance > maxChunkLoadDistance) continue;
|
||||||
if (sectionIndex < 0 || sectionIndex >= chunk.getSectionsCount()) continue;
|
|
||||||
LevelChunkSection section = chunk.getSection(sectionIndex);
|
|
||||||
|
|
||||||
if (section.hasOnlyAir()) {
|
LevelChunk chunk = level.getChunk(sx, sz);
|
||||||
sections.put(pos, null);
|
int sectionIndex = chunk.getSectionIndexFromSectionY(sy);
|
||||||
} else {
|
if (sectionIndex < 0 || sectionIndex >= chunk.getSectionsCount()) continue;
|
||||||
PalettedContainer<BlockState> container = section.getStates();
|
LevelChunkSection section = chunk.getSection(sectionIndex);
|
||||||
sections.put(pos, container);
|
|
||||||
|
|
||||||
if (sendBlockEntitiesInChunks && section.maybeHas(BlockState::hasBlockEntity)) {
|
if (section.hasOnlyAir()) {
|
||||||
for (int x = 0; x < 16; x++) {
|
sections.put(pos, null);
|
||||||
for (int y = 0; y < 16; y++) {
|
} else {
|
||||||
for (int z = 0; z < 16; z++) {
|
PalettedContainer<BlockState> container = section.getStates();
|
||||||
BlockState blockState = container.get(x, y, z);
|
sections.put(pos, container);
|
||||||
if (blockState.hasBlockEntity()) {
|
|
||||||
mutableBlockPos.set(sx*16 + x, sy*16 + y, sz*16 + z);
|
if (sendBlockEntitiesInChunks && section.maybeHas(BlockState::hasBlockEntity)) {
|
||||||
BlockEntity blockEntity = chunk.getBlockEntity(mutableBlockPos, LevelChunk.EntityCreationType.CHECK);
|
for (int x = 0; x < 16; x++) {
|
||||||
if (blockEntity != null) {
|
for (int y = 0; y < 16; y++) {
|
||||||
CompoundTag tag = blockEntity.saveWithoutMetadata();
|
for (int z = 0; z < 16; z++) {
|
||||||
blockEntityMap.put(mutableBlockPos.asLong(), CompressedBlockEntity.compress(tag, baos));
|
BlockState blockState = container.get(x, y, z);
|
||||||
|
if (blockState.hasBlockEntity()) {
|
||||||
|
mutableBlockPos.set(sx*16 + x, sy*16 + y, sz*16 + z);
|
||||||
|
BlockEntity blockEntity = chunk.getBlockEntity(mutableBlockPos, LevelChunk.EntityCreationType.CHECK);
|
||||||
|
if (blockEntity != null) {
|
||||||
|
CompoundTag tag = blockEntity.saveWithoutMetadata();
|
||||||
|
blockEntityMap.put(mutableBlockPos.asLong(), CompressedBlockEntity.compress(tag, baos));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +139,6 @@ public class RequestChunkDataPacketListener implements PluginMessageListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Send response packet
|
// Send response packet
|
||||||
|
|
||||||
boolean firstPart = true;
|
boolean firstPart = true;
|
||||||
|
@ -38,7 +38,6 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class SetBlockPacketListener implements PluginMessageListener {
|
public class SetBlockPacketListener implements PluginMessageListener {
|
||||||
|
|
||||||
|
@ -38,6 +38,12 @@ public class TeleportPacketListener implements PluginMessageListener {
|
|||||||
World world = Bukkit.getWorld(namespacedKey);
|
World world = Bukkit.getWorld(namespacedKey);
|
||||||
if (world == null) return;
|
if (world == null) return;
|
||||||
|
|
||||||
|
// Prevent teleport based on config value
|
||||||
|
boolean allowTeleportBetweenWorlds = this.plugin.configuration.getBoolean("allow-teleport-between-worlds");
|
||||||
|
if (!allowTeleportBetweenWorlds && world != player.getWorld()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Call event
|
// Call event
|
||||||
AxiomTeleportEvent teleportEvent = new AxiomTeleportEvent(player, new Location(world, x, y, z, yRot, xRot));
|
AxiomTeleportEvent teleportEvent = new AxiomTeleportEvent(player, new Location(world, x, y, z, yRot, xRot));
|
||||||
Bukkit.getPluginManager().callEvent(teleportEvent);
|
Bukkit.getPluginManager().callEvent(teleportEvent);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren