Skip to content

Commit

Permalink
Merge pull request #4 from PimvanderLoos/feat/1.19.4
Browse files Browse the repository at this point in the history
Add support for 1.19.4
  • Loading branch information
PimvanderLoos committed Mar 20, 2023
2 parents 8d3d537 + 92d63a9 commit 765e46e
Show file tree
Hide file tree
Showing 15 changed files with 549 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog.txt
@@ -1,4 +1,5 @@
Alpha 0.1.8.44
- Add 1.19.4 support.
- Add support for PlotSquared 7. Thanks, Bloody_Mind, for the suggestion!
- Added the "/BigDoors PrepareDatabaseForV2" command. This will export your database to the format used by v2. Note that both the export and v2 are still experimental!
- Fix rare issue with retrieving permissions for offline players that could result in a server crash. Thanks, VikEnd, for the bug report!
Expand Down
7 changes: 7 additions & 0 deletions core/pom.xml
Expand Up @@ -151,6 +151,13 @@
<scope>compile</scope>
</dependency>

<dependency>
<groupId>nl.pim16aap2.BigDoors</groupId>
<artifactId>v1_19_R3</artifactId>
<version>0.1.8.44-ALPHA</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>${dependency.xseries.groupid}</groupId>
<artifactId>XSeries</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/nl/pim16aap2/bigDoors/BigDoors.java
Expand Up @@ -18,6 +18,7 @@
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactory_V1_19_R1;
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactory_V1_19_R1_1;
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactory_V1_19_R2;
import nl.pim16aap2.bigDoors.NMS.FallingBlockFactory_V1_19_R3;
import nl.pim16aap2.bigDoors.codegeneration.FallbackGeneratorManager;
import nl.pim16aap2.bigDoors.compatibility.FakePlayerCreator;
import nl.pim16aap2.bigDoors.compatibility.ProtectionCompatManager;
Expand Down Expand Up @@ -835,6 +836,9 @@ private boolean compatibleMCVer()
case "v1_19_R2":
fabf = new FallingBlockFactory_V1_19_R2();
break;
case "v1_19_R3":
fabf = new FallingBlockFactory_V1_19_R3();
break;
default:
if (config.allowCodeGeneration())
fabf = FallbackGeneratorManager.getFallingBlockFactory();
Expand Down Expand Up @@ -1083,6 +1087,7 @@ public enum MCVersion
v1_18_R2,
v1_19_R1,
v1_19_R2,
v1_19_R3,
v1_20_R1,
v1_21_R1,
v1_22_R1,
Expand Down
Expand Up @@ -151,7 +151,7 @@ private DynamicType.Builder<?> addCTor(DynamicType.Builder<?> builder)
FieldAccessor.of(fieldNoClip).setsValue(true)).andThen(
invoke(methodSetNoGravity).with(true)).andThen(
invoke(methodSetMotVec).withMethodCall(construct(cTorVec3D).with(0d, 0d, 0d))).andThen(
invoke(methodSetStartPos).withMethodCall(construct(cTorBlockPosition)
invoke(methodSetStartPos).withMethodCall(invoke(methodNewBlockPosition)
.withMethodCall(invoke(methodLocX))
.withMethodCall(invoke(methodLocY))
.withMethodCall(invoke(methodLocZ)))).andThen(
Expand Down
Expand Up @@ -111,7 +111,7 @@ private DynamicType.Builder<?> addNMSBlockFactoryMethod(DynamicType.Builder<?> b
final MethodCall getNMSWorld = (MethodCall)
invoke(methodGetNMSWorld).onArgument(0).withAssigner(Assigner.DEFAULT, Assigner.Typing.DYNAMIC);

final MethodCall createBlockPosition = construct(cTorBlockPosition).withArgument(1, 2, 3);
final MethodCall createBlockPosition = invoke(methodNewBlockPosition).withArgument(1, 2, 3);

final MethodCall getType = invoke(methodGetTypeFromBlockPosition)
.onMethodCall(getNMSWorld).withMethodCall(createBlockPosition);
Expand Down
Expand Up @@ -375,7 +375,7 @@ private DynamicType.Builder<?> addPutBlockMethod(DynamicType.Builder<?> builder)

invoke(methodSetTypeAndData)
.onMethodCall(worldCast)
.withMethodCall(construct(cTorBlockPosition)
.withMethodCall(invoke(methodNewBlockPosition)
.withMethodCall(invoke(methodLocationGetX).onField(FIELD_LOCATION))
.withMethodCall(invoke(methodLocationGetY).onField(FIELD_LOCATION))
.withMethodCall(invoke(methodLocationGetZ).onField(FIELD_LOCATION)))
Expand Down
Expand Up @@ -22,6 +22,8 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import static nl.pim16aap2.bigDoors.reflection.ReflectionBuilder.*;

Expand Down Expand Up @@ -68,12 +70,12 @@ final class ReflectionRepository

public static final Constructor<?> cTorPublicNMSFallingBlockEntity;
public static final Constructor<?> cTorPrivateNMSFallingBlockEntity;
public static final Constructor<?> cTorBlockPosition;
public static final Constructor<?> cTorVec3D;
public static final Constructor<?> ctorCraftEntity;
public static final Constructor<?> ctorBlockBase;
public static final Constructor<?> ctorLocation;

public static final Method methodNewBlockPosition;
public static final Method methodGetBlockData;
public static final Method methodSetBlockData;
public static final Method methodGetBlockMaterial;
Expand Down Expand Up @@ -213,8 +215,6 @@ final class ReflectionRepository
cTorPublicNMSFallingBlockEntity =
findConstructor().inClass(classEntityFallingBlock)
.withParameters(classEntityTypes, classNMSWorld).get();
cTorBlockPosition = findConstructor().inClass(classBlockPosition)
.withParameters(double.class, double.class, double.class).get();
cTorVec3D = findConstructor().inClass(classVec3D)
.withParameters(double.class, double.class, double.class).get();
ctorCraftEntity = findConstructor().inClass(classCraftEntity)
Expand All @@ -226,6 +226,9 @@ final class ReflectionRepository
.get();


methodNewBlockPosition = findMethod().inClass(classBlockPosition).withReturnType(classBlockPosition)
.withParameters(double.class, double.class, double.class)
.withModifiers(Modifier.STATIC, Modifier.PUBLIC).get();
methodGetBlockData = findMethod().inClass(Block.class).withName("getBlockData").withoutParameters().get();
methodSetBlockData = findMethod().inClass(Block.class).withName("setBlockData")
.withParameters(BlockData.class).get();
Expand All @@ -241,8 +244,7 @@ final class ReflectionRepository
.withoutParameters().withModifiers(Modifier.PUBLIC).get();
methodGetEntityHandle = findMethod().inClass(classCraftEntity).withName("getHandle")
.withoutParameters().withModifiers(Modifier.PUBLIC).get();
methodTick = findMethod().inClass(classEntityFallingBlock).withReturnType(void.class)
.withModifiers(Modifier.PUBLIC).withoutParameters().get();
methodTick = findTickMethod();
methodHurtEntities = findMethod().inClass(classEntityFallingBlock).withReturnType(boolean.class)
.withParameters(parameterBuilder()
.withRequiredParameters(float.class, float.class)
Expand Down Expand Up @@ -391,6 +393,25 @@ final class ReflectionRepository
.exactCount(3).get());
}

private static Method findTickMethod()
{
final Set<String> baseMethods =
findMethod().inClass(classNMSEntity).findMultiple().withReturnType(void.class)
.withModifiers(Modifier.PUBLIC).withoutParameters().atLeast(1).get()
.stream().map(Method::getName).collect(Collectors.toSet());
final List<Method> fbMethods =
findMethod().inClass(classEntityFallingBlock).findMultiple().withReturnType(void.class)
.withModifiers(Modifier.PUBLIC).withoutParameters().atLeast(1).get();

final List<Method> filtered =
fbMethods.stream().filter(method -> baseMethods.contains(method.getName())).collect(Collectors.toList());

if (filtered.size() != 1)
throw new IllegalStateException("Found " + filtered.size() +
" methods that could be the tick method: " + filtered);
return filtered.get(0);
}

private ReflectionRepository()
{
}
Expand Down
Expand Up @@ -121,6 +121,10 @@ public class ConfigLoader
populateResourcePacks(
RESOURCEPACKS, "https://www.dropbox.com/s/8vpwzjkd9jnp1xu/BigDoorsResourcePack-Format12.zip?dl=1",
MCVersion.v1_19_R2);

populateResourcePacks(
RESOURCEPACKS, "https://www.dropbox.com/s/3b6ohu02ueq5no0/BigDoorsResourcePack-Format13.zip?dl=1",
MCVersion.v1_19_R3);
}

public ConfigLoader(BigDoors plugin)
Expand Down Expand Up @@ -197,6 +201,8 @@ public void makeConfig()
+ RESOURCEPACKS.get(MCVersion.v1_19_R1) + "'",
"The resource pack for 1.19.3 is: '"
+ RESOURCEPACKS.get(MCVersion.v1_19_R2) + "'",
"The resource pack for 1.19.4 is: '"
+ RESOURCEPACKS.get(MCVersion.v1_19_R3) + "'",
};
String[] multiplierComment = { "These multipliers affect the opening/closing speed of their respective door types.",
"Note that the maximum speed is limited, so beyond a certain point rasising these values won't have any effect.",
Expand Down
1 change: 1 addition & 0 deletions nms/pom.xml
Expand Up @@ -30,6 +30,7 @@
<module>v1_19_R1</module>
<module>v1_19_R1_1</module>
<module>v1_19_R2</module>
<module>v1_19_R3</module>
</modules>

<dependencies>
Expand Down
36 changes: 36 additions & 0 deletions nms/v1_19_R3/pom.xml
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<packaging>jar</packaging>
<artifactId>v1_19_R3</artifactId>

<parent>
<groupId>nl.pim16aap2.BigDoors</groupId>
<artifactId>nms</artifactId>
<version>0.1.8.44-ALPHA</version>
</parent>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>nl.pim16aap2.BigDoors</groupId>
<artifactId>nms-api</artifactId>
<version>0.1.8.44-ALPHA</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,110 @@
package nl.pim16aap2.bigDoors.NMS;

import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_19_R3.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_19_R3.util.CraftMagicNumbers;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

public class CustomCraftFallingBlock_V1_19_R3 extends CraftEntity implements FallingBlock, CustomCraftFallingBlock
{
CustomCraftFallingBlock_V1_19_R3(final Server server, final CustomEntityFallingBlock_V1_19_R3 entity)
{
super((org.bukkit.craftbukkit.v1_19_R3.CraftServer) server, entity);
setVelocity(new Vector(0, 0, 0));
setDropItem(false);
}

@Override
public CustomEntityFallingBlock_V1_19_R3 getHandle()
{
return (CustomEntityFallingBlock_V1_19_R3) entity;
}

@Override
public boolean isOnGround()
{
return false;
}

@Override
public String toString()
{
return "CraftFallingBlock";
}

@Override
public @NotNull EntityType getType()
{
return EntityType.FALLING_BLOCK;
}

@Override
public void setVisibleByDefault(boolean flag)
{
}

@Override
public boolean isVisibleByDefault()
{
return true;
}

@Override
@Deprecated
public @NotNull Material getMaterial()
{
return CraftMagicNumbers.getMaterial(getHandle().k()).getItemType();
}

@Override
public @NotNull BlockData getBlockData()
{
return CraftBlockData.fromData(this.getHandle().k());
}

@Override
public boolean getDropItem()
{
return false;
}

@Override
public void setDropItem(final boolean drop)
{
}

@Override
public boolean canHurtEntities()
{
return false;
}

@Override
public void setHurtEntities(final boolean hurtEntities)
{
}

@Override
public void setTicksLived(final int value)
{
super.setTicksLived(value);
getHandle().b = value;
}

@Override
public void setHeadPose(EulerAngle pose)
{
}

@Override
public void setBodyPose(EulerAngle eulerAngle)
{
}
}

0 comments on commit 765e46e

Please sign in to comment.