Skip to content

Commit

Permalink
Bug fixes and 1.18.2 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Mar 24, 2022
1 parent b34551a commit 36055e0
Show file tree
Hide file tree
Showing 9 changed files with 631 additions and 11 deletions.
12 changes: 12 additions & 0 deletions modules/Movecraft/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
</repositories>

<dependencies>
<dependency>
<groupId>net.countercraft</groupId>
<artifactId>movecraft-v1_18_R2</artifactId>
<version>v1_18_R2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.countercraft</groupId>
<artifactId>movecraft-v1_18_R1</artifactId>
Expand Down Expand Up @@ -295,6 +301,12 @@
<include>**</include>
</includes>
</filter>
<filter>
<artifact>net.countercraft:movecraft-v1_18_R2</artifact>
<includes>
<include>**</include>
</includes>
</filter>
</filters>
<artifactSet>
<includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void onLoad() {
String packageName = this.getServer().getClass().getPackage().getName();
String version = packageName.substring(packageName.lastIndexOf('.') + 1);
String[] parts = version.split("_");
int versionNumber = Integer.valueOf(parts[1]);
int versionNumber = Integer.parseInt(parts[1]);
//Check if the server is 1.12 and lower or 1.13 and higher
Settings.IsPre1_9 = versionNumber < 9;
Settings.IsLegacy = versionNumber <= 12;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class Settings {
public static HashSet<Material> DisableShadowBlocks = new HashSet<>();
public static boolean CheckForUpdates;
public static boolean GearshiftsWithPilotToolEnabled;
public static boolean IsV1_17;
public static boolean IsV1_18;
public static boolean IsV1_17 = false;
public static boolean IsV1_18 = false;
public static boolean IsV1_17_1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,29 +200,34 @@ public CraftType(File f) {
explodeOnCrash = floatFromObject(data.getOrDefault("explodeOnCrash", 0F));
collisionExplosion = floatFromObject(data.getOrDefault("collisionExplosion", 0F));
int minHeight = 0;
Method getMinHeight = null;

if (Settings.IsV1_17) {
Class<?> clazz;
try {
clazz = Class.forName("org.bukkit.generator.WorldInfo");
} catch (ClassNotFoundException e) {
clazz = World.class;
}
try {
final Class<?> clazz = Settings.IsV1_18 ? Class.forName("org.bukkit.generator.WorldInfo") : World.class ;
final Method getMinHeight;
getMinHeight = clazz.getDeclaredMethod("getMinHeight");
minHeight = (int) getMinHeight.invoke(Bukkit.getWorlds().get(0));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
minHeightLimit = max(minHeight, integerFromObject(data.getOrDefault("minHeightLimit", 0)));
perWorldMinHeightLimit = new HashMap<>();
Map<String, Integer> minHeightMap = stringToIntMapFromObject(data.getOrDefault("perWorldMinHeightLimit", new HashMap<>()));
Method finalGetMinHeight = getMinHeight;
minHeightMap.forEach((world, height) -> {
int worldMinHeight = 0;
if (Settings.IsV1_17) {
final Method getMinHeight;
final World foundWorld = Bukkit.getWorld(world);
if (world != null) {
try {
getMinHeight = World.class.getDeclaredMethod("getMinHeight");
worldMinHeight = (int) getMinHeight.invoke(foundWorld);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
worldMinHeight = (int) finalGetMinHeight.invoke(foundWorld);
} catch (IllegalAccessException | InvocationTargetException e) {

}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/v1_17_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<version>1.17.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
Expand Down
98 changes: 98 additions & 0 deletions modules/v1_18_R2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?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">
<parent>
<artifactId>movecraft-parent</artifactId>
<groupId>net.countercraft</groupId>
<version>parent</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<name>Movecraft-v1_18_R2</name>
<artifactId>movecraft-v1_18_R2</artifactId>
<version>v1_18_R2</version>
<packaging>jar</packaging>

<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>net.countercraft</groupId>
<artifactId>movecraft-api</artifactId>
<version>API</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<includes>
<include>net/countercraft/movecraft/compat/v1_18_R2/**</include>
</includes>
<source>13</source>
<target>13</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<includes>
<include>net/countercraft/movecraft/compat/v1_18_R2/**</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 36055e0

Please sign in to comment.