Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion API/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>1.14.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand Down
10 changes: 9 additions & 1 deletion Plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.lishid</groupId>
<artifactId>orebfuscator</artifactId>
<version>4.4.3-SNAPSHOT</version>
<version>4.4.4</version>
<packaging>jar</packaging>

<name>Orebfuscator4</name>
Expand Down Expand Up @@ -105,6 +105,14 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.lishid</groupId>
<artifactId>orebfuscator-v1_14_R1</artifactId>
<version>v1_14_R1</version>
<type>jar</type>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ private static INmsManager createNmsManager() {

String serverVersion = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];

if(serverVersion.equals("v1_13_R2")) {
if(serverVersion.equals("v1_14_R1")) {
return new com.lishid.orebfuscator.nms.v1_14_R1.NmsManager();
}
else if(serverVersion.equals("v1_13_R2")) {
return new com.lishid.orebfuscator.nms.v1_13_R2.NmsManager();
}
else if(serverVersion.equals("v1_13_R1")) {
Expand Down
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<id>techcable-repo</id>
<url>https://repo.techcable.net/content/groups/public/</url>
</repository>
<!--<repository>
<id>spigot-plugins</id>
<url>https://repo.aikar.co/nexus/content/repositories/aikar/</url>
</repository>-->
</repositories>

<modules>
Expand All @@ -38,6 +42,7 @@
<module>v1_12_R1</module>
<module>v1_13_R1</module>
<module>v1_13_R2</module>
<module>v1_14_R1</module>
<module>Plugin</module>
</modules>

Expand All @@ -46,9 +51,9 @@
</build>

<scm>
<connection>scm:git:git://github.com/lishid/Orebfuscator.git</connection>
<developerConnection>scm:git:git@github.com:lishid/Orebfuscator.git</developerConnection>
<url>https://github.com/lishid/Orebfuscator</url>
<connection>scm:git:git://github.com/JayJay1989/Orebfuscator.git</connection>
<developerConnection>scm:git:git@github.com:JayJay1989/Orebfuscator.git</developerConnection>
<url>https://github.com/JayJay1989/Orebfuscator</url>
</scm>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,8 @@ private synchronized void closeCacheFilesInternal() {
try {
Method c = regionFile.getClass().getDeclaredMethod("c");
c.invoke(regionFile);
} catch (NoSuchMethodException nsme) {
try {
Method close = regionFile.getClass().getDeclaredMethod("close");
close.invoke(regionFile);
} catch (NoSuchMethodException nsme2) {

}
} catch (Exception nsme) {
regionFile.close();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,9 @@ public void updateBlockTileEntity(BlockCoord blockCoord, Player player) {
// 1.13.2 has made this quite a bit different in later builds.
TileEntity tileEntity = null;
try {
Method getTileEntityAt = world.getClass().getMethod("getTileEntityAt", int.class, int.class, int.class);
tileEntity = (TileEntity) getTileEntityAt.invoke(world, blockCoord.x, blockCoord.y, blockCoord.z);
} catch (NoSuchMethodException nsme) {
// hasty hf introduced issue due to getDeclaredMethod, it's not declared in WorldServer but in World
tileEntity = world.getHandle().getTileEntity(new BlockPosition(blockCoord.x, blockCoord.y, blockCoord.z));
} catch (Exception e) {
return;
} catch (Exception nsme) {
}

if (tileEntity == null) {
Expand Down Expand Up @@ -542,19 +539,8 @@ private static IBlockData getBlockData(World world, int x, int y, int z, boolean
// like in ChunkCache, NMS change without R increment.
ChunkProviderServer chunkProviderServer = null;
try {
Method getChunkProviderServer = worldServer.getClass().getDeclaredMethod("getChunkProviderServer");
chunkProviderServer = (ChunkProviderServer) getChunkProviderServer.invoke(worldServer);
} catch (NoSuchMethodException nmfe) {
try {
Method getChunkProvider = worldServer.getClass().getDeclaredMethod("getChunkProvider");
chunkProviderServer = (ChunkProviderServer) getChunkProvider.invoke(worldServer);
} catch (NoSuchMethodException nsme) {
return null; // oops
} catch (Exception e) {
return null;
}
} catch (Exception e) {
return null;
chunkProviderServer = worldServer.getChunkProvider();
} catch (Exception nmfe) {
}
if(!loadChunk && !chunkProviderServer.isLoaded(chunkX, chunkZ)) return null;

Expand Down
52 changes: 52 additions & 0 deletions v1_14_R1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<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>com.lishid</groupId>
<artifactId>orebfuscator-v1_14_R1</artifactId>
<version>v1_14_R1</version>
<packaging>jar</packaging>
<name>Orebfuscator4 v1_14_R1</name>

<parent>
<groupId>com.lishid.parent</groupId>
<artifactId>orebfuscator-parent</artifactId>
<version>parent</version>
</parent>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.14.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.lishid</groupId>
<artifactId>orebfuscator-api</artifactId>
<version>API</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* @author Aleksey Terzi
*
*/

package com.lishid.orebfuscator.nms.v1_14_R1;

import net.minecraft.server.v1_14_R1.Block;
import net.minecraft.server.v1_14_R1.IBlockData;

import com.lishid.orebfuscator.nms.IBlockInfo;

public class BlockInfo implements IBlockInfo {
private int x;
private int y;
private int z;
private IBlockData blockData;

public BlockInfo(int x, int y, int z, IBlockData blockData) {
this.x = x;
this.y = y;
this.z = z;
this.blockData = blockData;
}

public int getX() {
return this.x;
}

public int getY() {
return this.y;
}

public int getZ() {
return this.z;
}

public int getCombinedId() {
return Block.getCombinedId(this.blockData);
}

public IBlockData getBlockData() {
return this.blockData;
}

@Override
public boolean equals(Object other) {
if (other == null || !(other instanceof BlockInfo)) {
return false;
}
BlockInfo object = (BlockInfo) other;

return this.x == object.x && this.y == object.y && this.z == object.z;
}

@Override
public int hashCode() {
return this.x ^ this.y ^ this.z;
}

@Override
public String toString() {
return this.x + " " + this.y + " " + this.z;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* @author lishid
* @author Aleksey Terzi
*
*/

package com.lishid.orebfuscator.nms.v1_14_R1;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.lang.reflect.Method;
import java.util.HashMap;

import net.minecraft.server.v1_14_R1.ChunkCoordIntPair;
import net.minecraft.server.v1_14_R1.RegionFile;

import com.lishid.orebfuscator.nms.IChunkCache;

public class ChunkCache implements IChunkCache {
private static final HashMap<File, RegionFile> cachedRegionFiles = new HashMap<File, RegionFile>();

private int maxLoadedCacheFiles;

public ChunkCache(int maxLoadedCacheFiles) {
this.maxLoadedCacheFiles = maxLoadedCacheFiles;
}

public DataInputStream getInputStream(File folder, int x, int z) {
RegionFile regionFile = getRegionFile(folder, x, z);
return regionFile.a(new ChunkCoordIntPair(x & 0x1F, z & 0x1F));
}

public DataOutputStream getOutputStream(File folder, int x, int z) {
RegionFile regionFile = getRegionFile(folder, x, z);
return regionFile.c(new ChunkCoordIntPair(x & 0x1F, z & 0x1F));
}

public void closeCacheFiles() {
closeCacheFilesInternal();
}

private synchronized RegionFile getRegionFile(File folder, int x, int z) {
File path = new File(folder, "region");
File file = new File(path, "r." + (x >> 5) + "." + (z >> 5) + ".mcr");
try {
RegionFile regionFile = cachedRegionFiles.get(file);
if (regionFile != null) {
return regionFile;
}

if (!path.exists()) {
path.mkdirs();
}

if (cachedRegionFiles.size() >= this.maxLoadedCacheFiles) {
closeCacheFiles();
}

regionFile = new RegionFile(file);
cachedRegionFiles.put(file, regionFile);

return regionFile;
}
catch (Exception e) {
try {
file.delete();
}
catch (Exception e2) {
}
}
return null;
}

private synchronized void closeCacheFilesInternal() {
for (RegionFile regionFile : cachedRegionFiles.values()) {
try {
if (regionFile != null) {
// This lovely piece of work is due to an NMS change in Spigot 1.13.2 without an R increase.
try {
Method c = regionFile.getClass().getDeclaredMethod("c");
c.invoke(regionFile);
} catch (Exception nsme) {
regionFile.close();
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
cachedRegionFiles.clear();
}
}
Loading