mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-15 23:05:12 +01:00
Dedicated compat module for Spigot/CB 1.8.3 (1_8_R2).
This commit is contained in:
parent
806b31ec4f
commit
888f1cbaa8
@ -39,7 +39,7 @@ public class MCAccessCBDev implements MCAccess{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMCVersion() {
|
public String getMCVersion() {
|
||||||
// 1_8_R2
|
// 1.8.3 (1_8_R2)
|
||||||
return "1.8.3";
|
return "1.8.3";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
NCPCompatSpigotCB1_8_R2/pom.xml
Normal file
30
NCPCompatSpigotCB1_8_R2/pom.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
<artifactId>ncpcompatspigotcb1_8_r2</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>NCPCompatSpigotCB1_8_R2</name>
|
||||||
|
<version>1.1-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
<artifactId>nocheatplus-parent</artifactId>
|
||||||
|
<version>1.1-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
<artifactId>ncpcore</artifactId>
|
||||||
|
<version>1.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>craftbukkit</artifactId>
|
||||||
|
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<description>Compatibility for Minecraft 1.8.3 with CraftBukkit/Spigot (1_8_R2).</description>
|
||||||
|
</project>
|
@ -0,0 +1,134 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_r2;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R2.AxisAlignedBB;
|
||||||
|
import net.minecraft.server.v1_8_R2.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_8_R2.EntityBoat;
|
||||||
|
import net.minecraft.server.v1_8_R2.EnumDirection;
|
||||||
|
import net.minecraft.server.v1_8_R2.IBlockAccess;
|
||||||
|
import net.minecraft.server.v1_8_R2.IBlockData;
|
||||||
|
import net.minecraft.server.v1_8_R2.TileEntity;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||||
|
|
||||||
|
public class BlockCacheCBSpigot1_8_R2 extends BlockCache implements IBlockAccess{
|
||||||
|
|
||||||
|
protected net.minecraft.server.v1_8_R2.WorldServer world;
|
||||||
|
protected World bukkitWorld; // WHACKS
|
||||||
|
|
||||||
|
public BlockCacheCBSpigot1_8_R2(World world) {
|
||||||
|
setAccess(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAccess(World world) {
|
||||||
|
if (world != null) {
|
||||||
|
this.maxBlockY = world.getMaxHeight() - 1;
|
||||||
|
this.world = ((CraftWorld) world).getHandle();
|
||||||
|
this.bukkitWorld = world;
|
||||||
|
} else {
|
||||||
|
this.world = null;
|
||||||
|
this.bukkitWorld = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public int fetchTypeId(final int x, final int y, final int z) {
|
||||||
|
return bukkitWorld.getBlockTypeIdAt(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public int fetchData(final int x, final int y, final int z) {
|
||||||
|
return bukkitWorld.getBlockAt(x, y, z).getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double[] fetchBounds(final int x, final int y, final int z){
|
||||||
|
final int id = getTypeId(x, y, z);
|
||||||
|
final net.minecraft.server.v1_8_R2.Block block = net.minecraft.server.v1_8_R2.Block.getById(id);
|
||||||
|
if (block == null) {
|
||||||
|
// TODO: Convention for null bounds -> full ?
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
block.updateShape(this, new BlockPosition(x, y, z));
|
||||||
|
|
||||||
|
// minX, minY, minZ, maxX, maxY, maxZ
|
||||||
|
return new double[]{block.B(), block.D(), block.F(), block.C(), block.E(), block.G()};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean standsOnEntity(final Entity entity, final double minX, final double minY, final double minZ, final double maxX, final double maxY, final double maxZ){
|
||||||
|
try{
|
||||||
|
// TODO: Find some simplification!
|
||||||
|
|
||||||
|
final net.minecraft.server.v1_8_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
|
||||||
|
final AxisAlignedBB box = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
final List list = world.getEntities(mcEntity, box);
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
final Iterator iterator = list.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
final net.minecraft.server.v1_8_R2.Entity other = (net.minecraft.server.v1_8_R2.Entity) iterator.next();
|
||||||
|
if (!(other instanceof EntityBoat)){ // && !(other instanceof EntityMinecart)) continue;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (minY >= other.locY && minY - other.locY <= 0.7){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Still check this for some reason.
|
||||||
|
final AxisAlignedBB otherBox = other.getBoundingBox();
|
||||||
|
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable t){
|
||||||
|
// Ignore exceptions (Context: DisguiseCraft).
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.neatmonster.nocheatplus.utilities.BlockCache#cleanup()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cleanup() {
|
||||||
|
super.cleanup();
|
||||||
|
world = null;
|
||||||
|
bukkitWorld = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBlockPower(BlockPosition pos, EnumDirection dir) {
|
||||||
|
return world.getBlockPower(pos, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity getTileEntity(BlockPosition pos) {
|
||||||
|
return world.getTileEntity(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockData getType(BlockPosition pos) {
|
||||||
|
return world.getType(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty(BlockPosition pos) {
|
||||||
|
return world.isEmpty(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,193 @@
|
|||||||
|
package fr.neatmonster.nocheatplus.compat.spigotcb1_8_r2;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R2.AxisAlignedBB;
|
||||||
|
import net.minecraft.server.v1_8_R2.Block;
|
||||||
|
import net.minecraft.server.v1_8_R2.DamageSource;
|
||||||
|
import net.minecraft.server.v1_8_R2.EntityComplexPart;
|
||||||
|
import net.minecraft.server.v1_8_R2.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_8_R2.MobEffectList;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R2.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
|
||||||
|
import fr.neatmonster.nocheatplus.compat.MCAccess;
|
||||||
|
import fr.neatmonster.nocheatplus.utilities.BlockCache;
|
||||||
|
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
|
||||||
|
|
||||||
|
public class MCAccessCBSpigot1_8_R2 implements MCAccess{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to let it fail.
|
||||||
|
*/
|
||||||
|
public MCAccessCBSpigot1_8_R2() {
|
||||||
|
getCommandMap();
|
||||||
|
ReflectionUtil.checkMembers("net.minecraft.server.v1_8_R2.", new String[] {"Entity" , "dead"});
|
||||||
|
// block bounds, original: minX, maxX, minY, maxY, minZ, maxZ
|
||||||
|
ReflectionUtil.checkMethodReturnTypesNoArgs(net.minecraft.server.v1_8_R2.Block.class,
|
||||||
|
new String[]{"B", "C", "D", "E", "F", "G"}, double.class);
|
||||||
|
// TODO: Nail it down further.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMCVersion() {
|
||||||
|
// 1.8.3 (1_8_R2)
|
||||||
|
return "1.8.3";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServerVersionTag() {
|
||||||
|
return "Spigot-CB-1.8_R2";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandMap getCommandMap() {
|
||||||
|
return ((CraftServer) Bukkit.getServer()).getCommandMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockCache getBlockCache(final World world) {
|
||||||
|
return new BlockCacheCBSpigot1_8_R2(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getHeight(final Entity entity) {
|
||||||
|
final net.minecraft.server.v1_8_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
|
||||||
|
AxisAlignedBB boundingBox = mcEntity.getBoundingBox();
|
||||||
|
final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.getHeadHeight(), boundingBox.e - boundingBox.b));
|
||||||
|
if (entity instanceof LivingEntity) {
|
||||||
|
return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
|
||||||
|
} else return entityHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlmostBoolean isBlockSolid(final int id) {
|
||||||
|
final Block block = Block.getById(id);
|
||||||
|
if (block == null || block.getMaterial() == null) {
|
||||||
|
return AlmostBoolean.MAYBE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return AlmostBoolean.match(block.getMaterial().isSolid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlmostBoolean isBlockLiquid(final int id) {
|
||||||
|
final Block block = Block.getById(id);
|
||||||
|
if (block == null || block.getMaterial() == null) {
|
||||||
|
return AlmostBoolean.MAYBE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return AlmostBoolean.match(block.getMaterial().isLiquid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth(final Entity entity) {
|
||||||
|
return ((CraftEntity) entity).getHandle().width;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlmostBoolean isIllegalBounds(final Player player) {
|
||||||
|
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
if (entityPlayer.dead) {
|
||||||
|
return AlmostBoolean.NO;
|
||||||
|
}
|
||||||
|
// TODO: Does this need a method call for the "real" box? Might be no problem during moving events, though.
|
||||||
|
final AxisAlignedBB box = entityPlayer.getBoundingBox();
|
||||||
|
if (!entityPlayer.isSleeping()) {
|
||||||
|
// This can not really test stance but height of bounding box.
|
||||||
|
final double dY = Math.abs(box.e - box.b);
|
||||||
|
if (dY > 1.8) {
|
||||||
|
return AlmostBoolean.YES; // dY > 1.65D ||
|
||||||
|
}
|
||||||
|
if (dY < 0.1D && entityPlayer.length >= 0.1) {
|
||||||
|
return AlmostBoolean.YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AlmostBoolean.MAYBE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getJumpAmplifier(final Player player) {
|
||||||
|
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
if (mcPlayer.hasEffect(MobEffectList.JUMP)) {
|
||||||
|
return mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Double.NEGATIVE_INFINITY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getFasterMovementAmplifier(final Player player) {
|
||||||
|
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
if (mcPlayer.hasEffect(MobEffectList.FASTER_MOVEMENT)) {
|
||||||
|
return mcPlayer.getEffect(MobEffectList.FASTER_MOVEMENT).getAmplifier();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Double.NEGATIVE_INFINITY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInvulnerableTicks(final Player player) {
|
||||||
|
return ((CraftPlayer) player).getHandle().invulnerableTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInvulnerableTicks(final Player player, final int ticks) {
|
||||||
|
((CraftPlayer) player).getHandle().invulnerableTicks = ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dealFallDamage(final Player player, final double damage) {
|
||||||
|
((CraftPlayer) player).getHandle().damageEntity(DamageSource.FALL, (float) damage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isComplexPart(final Entity entity) {
|
||||||
|
return ((CraftEntity) entity).getHandle() instanceof EntityComplexPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldBeZombie(final Player player) {
|
||||||
|
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
return !mcPlayer.dead && mcPlayer.getHealth() <= 0.0f ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDead(final Player player, final int deathTicks) {
|
||||||
|
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
mcPlayer.deathTicks = deathTicks;
|
||||||
|
mcPlayer.dead = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasGravity(final Material mat) {
|
||||||
|
return mat.hasGravity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AlmostBoolean dealFallDamageFiresAnEvent() {
|
||||||
|
return AlmostBoolean.YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public void correctDirection(final Player player) {
|
||||||
|
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
|
||||||
|
// // Main direction.
|
||||||
|
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
|
||||||
|
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
|
||||||
|
// // Consider setting the lastYaw here too.
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
@ -95,6 +95,11 @@
|
|||||||
<artifactId>ncpcompatspigotcb1_8_r1</artifactId>
|
<artifactId>ncpcompatspigotcb1_8_r1</artifactId>
|
||||||
<version>1.1-SNAPSHOT</version>
|
<version>1.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>fr.neatmonster</groupId>
|
||||||
|
<artifactId>ncpcompatspigotcb1_8_r2</artifactId>
|
||||||
|
<version>1.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.neatmonster</groupId>
|
<groupId>fr.neatmonster</groupId>
|
||||||
<artifactId>ncpcompatcbdev</artifactId>
|
<artifactId>ncpcompatcbdev</artifactId>
|
||||||
|
@ -89,9 +89,10 @@ public class MCAccessFactory {
|
|||||||
|
|
||||||
final String[] classNames = new String[] {
|
final String[] classNames = new String[] {
|
||||||
// Current DEV / LATEST: CB (Spigot)
|
// Current DEV / LATEST: CB (Spigot)
|
||||||
"fr.neatmonster.nocheatplus.compat.cbdev.MCAccessCBDev", // 1.8.3
|
// "fr.neatmonster.nocheatplus.compat.cbdev.MCAccessCBDev", // TODO: 1.8.4, 1.8.5
|
||||||
// Dedicated: CB (Spigot)
|
// Dedicated: CB (Spigot)
|
||||||
"fr.neatmonster.nocheatplus.compat.spigotcb1_8_r1.MCAccessSpigotCB1_8_R1", // 1.8
|
"fr.neatmonster.nocheatplus.compat.spigotcb1_8_r2.MCAccessSpigotCB1_8_R2", // 1.8.3 (1_8_R2)
|
||||||
|
"fr.neatmonster.nocheatplus.compat.spigotcb1_8_r1.MCAccessSpigotCB1_8_R1", // 1.8 (1_8_R1)
|
||||||
// Dedicated CB (original)
|
// Dedicated CB (original)
|
||||||
"fr.neatmonster.nocheatplus.compat.cb3100.MCAccessCB3100", // 1.7.10
|
"fr.neatmonster.nocheatplus.compat.cb3100.MCAccessCB3100", // 1.7.10
|
||||||
"fr.neatmonster.nocheatplus.compat.cb3043.MCAccessCB3043", // 1.7.8|1.7.9
|
"fr.neatmonster.nocheatplus.compat.cb3043.MCAccessCB3043", // 1.7.8|1.7.9
|
||||||
|
@ -94,6 +94,7 @@
|
|||||||
<include>fr.neatmonster:ncpcompatcb3043</include>
|
<include>fr.neatmonster:ncpcompatcb3043</include>
|
||||||
<include>fr.neatmonster:ncpcompatcb3100</include>
|
<include>fr.neatmonster:ncpcompatcb3100</include>
|
||||||
<include>fr.neatmonster:ncpcompatspigotcb1_8_r1</include>
|
<include>fr.neatmonster:ncpcompatspigotcb1_8_r1</include>
|
||||||
|
<include>fr.neatmonster:ncpcompatspigotcb1_8_r2</include>
|
||||||
<include>fr.neatmonster:ncpcompatcbdev</include>
|
<include>fr.neatmonster:ncpcompatcbdev</include>
|
||||||
<include>fr.neatmonster:ncpcompatprotocollib</include>
|
<include>fr.neatmonster:ncpcompatprotocollib</include>
|
||||||
<include>fr.neatmonster:ncpcompatglowstone</include>
|
<include>fr.neatmonster:ncpcompatglowstone</include>
|
||||||
|
1
pom.xml
1
pom.xml
@ -32,6 +32,7 @@
|
|||||||
<module>NCPCompatCB3043</module>
|
<module>NCPCompatCB3043</module>
|
||||||
<module>NCPCompatCB3100</module>
|
<module>NCPCompatCB3100</module>
|
||||||
<module>NCPCompatSpigotCB1_8_R1</module>
|
<module>NCPCompatSpigotCB1_8_R1</module>
|
||||||
|
<module>NCPCompatSpigotCB1_8_R2</module>
|
||||||
<module>NCPCompatCBDev</module>
|
<module>NCPCompatCBDev</module>
|
||||||
<module>NCPCompatProtocolLib</module>
|
<module>NCPCompatProtocolLib</module>
|
||||||
<module>NCPCompatGlowstone</module>
|
<module>NCPCompatGlowstone</module>
|
||||||
|
Loading…
Reference in New Issue
Block a user