geforkt von Mirrors/AxiomPaperPlugin
Dieser Commit ist enthalten in:
Ursprung
610ba248ea
Commit
028448be8d
@ -4,6 +4,7 @@ import com.moulberry.axiom.integration.PaperFailMoveListener;
|
|||||||
import com.moulberry.axiom.packet.*;
|
import com.moulberry.axiom.packet.*;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
import io.papermc.paper.event.player.PlayerFailMoveEvent;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
@ -90,6 +91,7 @@ public class AxiomPaper extends JavaPlugin implements Listener {
|
|||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
PlayerFailMoveEvent.class.getName(); //Try load class
|
||||||
Bukkit.getPluginManager().registerEvents(new PaperFailMoveListener(), this);
|
Bukkit.getPluginManager().registerEvents(new PaperFailMoveListener(), this);
|
||||||
} catch (NoClassDefFoundError e) {
|
} catch (NoClassDefFoundError e) {
|
||||||
getLogger().log(java.util.logging.Level.WARNING, "Axiom players may move too quickly according to the server. Use a current Paper version or increase the 'moved-too-quickly-multiplier' in spigot.yml.");
|
getLogger().log(java.util.logging.Level.WARNING, "Axiom players may move too quickly according to the server. Use a current Paper version or increase the 'moved-too-quickly-multiplier' in spigot.yml.");
|
||||||
|
@ -126,6 +126,28 @@ public class Reflection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public interface Constructor<T> {
|
||||||
|
T newInstance(Object... arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... params) {
|
||||||
|
try {
|
||||||
|
java.lang.reflect.Constructor<T> constructor = clazz.getDeclaredConstructor(params);
|
||||||
|
constructor.setAccessible(true);
|
||||||
|
|
||||||
|
return arguments -> {
|
||||||
|
try {
|
||||||
|
return constructor.newInstance(arguments);
|
||||||
|
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||||
|
throw new IllegalArgumentException("Cannot invoke constructor " + constructor, e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
throw new IllegalStateException("Cannot find matching constructor");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final String ORG_BUKKIT_CRAFTBUKKIT = Bukkit.getServer().getClass().getPackage().getName();
|
private static final String ORG_BUKKIT_CRAFTBUKKIT = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
public static final int VERSION; // Format: 2 digit minor version, 2 digit CraftBukkit revision: eg. 2001 for v1_20_R1
|
public static final int VERSION; // Format: 2 digit minor version, 2 digit CraftBukkit revision: eg. 2001 for v1_20_R1
|
||||||
static {
|
static {
|
||||||
|
@ -13,6 +13,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||||||
import net.minecraft.world.level.chunk.LevelChunk;
|
import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
|
|
||||||
|
import java.util.BitSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Version19R2 implements VersionWrapper {
|
public class Version19R2 implements VersionWrapper {
|
||||||
@ -25,6 +26,11 @@ public class Version19R2 implements VersionWrapper {
|
|||||||
return getLightBlock.invoke(old, chunk, pos) != getLightBlock.invoke(state, chunk, pos) || lightEmission.get(old) != lightEmission.get(state) || useShapeForLightOcclusion.get(old) || useShapeForLightOcclusion.get(state);
|
return getLightBlock.invoke(old, chunk, pos) != getLightBlock.invoke(state, chunk, pos) || lightEmission.get(old) != lightEmission.get(state) || useShapeForLightOcclusion.get(old) || useShapeForLightOcclusion.get(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Class<?> LevelLightEngine = Reflection.getClass("net.minecraft.world.level.lighting.LightEngine");
|
||||||
|
private static final Reflection.Constructor<ClientboundLevelChunkWithLightPacket> newClientboundLevelChunkWithLightPacket = Reflection.getConstructor(
|
||||||
|
ClientboundLevelChunkWithLightPacket.class,
|
||||||
|
LevelChunk.class, LevelLightEngine, BitSet.class, BitSet.class, boolean.class
|
||||||
|
);
|
||||||
@Override
|
@Override
|
||||||
public void publishBiomeChange(ServerLevel level, Set<Chunk> chunks) {
|
public void publishBiomeChange(ServerLevel level, Set<Chunk> chunks) {
|
||||||
ThreadedLevelLightEngine lightEngine = AxiomPaper.getLightEngine(AxiomPaper.getChunkSource(level));
|
ThreadedLevelLightEngine lightEngine = AxiomPaper.getLightEngine(AxiomPaper.getChunkSource(level));
|
||||||
@ -32,7 +38,7 @@ public class Version19R2 implements VersionWrapper {
|
|||||||
for (Chunk chunk : chunks) {
|
for (Chunk chunk : chunks) {
|
||||||
ChunkPos chunkPos = new ChunkPos(chunk.getX(), chunk.getZ());
|
ChunkPos chunkPos = new ChunkPos(chunk.getX(), chunk.getZ());
|
||||||
LevelChunk nativeChunk = AxiomPaper.getChunk(level, chunk.getX(), chunk.getZ());
|
LevelChunk nativeChunk = AxiomPaper.getChunk(level, chunk.getX(), chunk.getZ());
|
||||||
ClientboundLevelChunkWithLightPacket packet = new ClientboundLevelChunkWithLightPacket(nativeChunk, lightEngine, null, null, true);
|
ClientboundLevelChunkWithLightPacket packet = newClientboundLevelChunkWithLightPacket.newInstance(nativeChunk, lightEngine, null, null, true);
|
||||||
for (ServerPlayer player : AxiomPaper.getPlayersSeeingChunk(level, chunkPos)) {
|
for (ServerPlayer player : AxiomPaper.getPlayersSeeingChunk(level, chunkPos)) {
|
||||||
AxiomPaper.sendPacket(player, packet);
|
AxiomPaper.sendPacket(player, packet);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren