-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b132147
commit ce1b92a
Showing
10 changed files
with
450 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<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_11_R1</artifactId> | ||
<version>v1_11_R1</version> | ||
<packaging>jar</packaging> | ||
<name>Orebfuscator4 v1_11_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.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot</artifactId> | ||
<version>1.11-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> | ||
</dependencies> | ||
|
||
</project> |
65 changes: 65 additions & 0 deletions
65
v1_11_R1/src/main/java/com/lishid/orebfuscator/nms/v1_11_R1/BlockInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @author Aleksey Terzi | ||
* | ||
*/ | ||
|
||
package com.lishid.orebfuscator.nms.v1_11_R1; | ||
|
||
import net.minecraft.server.v1_11_R1.Block; | ||
import net.minecraft.server.v1_11_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 getTypeId() { | ||
return Block.getId(this.blockData.getBlock()); | ||
} | ||
|
||
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; | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
v1_11_R1/src/main/java/com/lishid/orebfuscator/nms/v1_11_R1/ChunkCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* @author lishid | ||
* @author Aleksey Terzi | ||
* | ||
*/ | ||
|
||
package com.lishid.orebfuscator.nms.v1_11_R1; | ||
|
||
import java.io.DataInputStream; | ||
import java.io.DataOutputStream; | ||
import java.io.File; | ||
import java.util.HashMap; | ||
|
||
import net.minecraft.server.v1_11_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(x & 0x1F, z & 0x1F); | ||
} | ||
|
||
public DataOutputStream getOutputStream(File folder, int x, int z) { | ||
RegionFile regionFile = getRegionFile(folder, x, z); | ||
return regionFile.b(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) | ||
regionFile.c(); | ||
} | ||
catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
cachedRegionFiles.clear(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
v1_11_R1/src/main/java/com/lishid/orebfuscator/nms/v1_11_R1/ChunkManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @author Aleksey Terzi | ||
* | ||
*/ | ||
|
||
package com.lishid.orebfuscator.nms.v1_11_R1; | ||
|
||
import java.util.HashSet; | ||
|
||
import net.minecraft.server.v1_11_R1.EntityPlayer; | ||
import net.minecraft.server.v1_11_R1.PacketPlayOutMapChunk; | ||
import net.minecraft.server.v1_11_R1.PacketPlayOutUnloadChunk; | ||
import net.minecraft.server.v1_11_R1.PlayerChunk; | ||
import net.minecraft.server.v1_11_R1.PlayerChunkMap; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
import com.lishid.orebfuscator.nms.IChunkManager; | ||
|
||
public class ChunkManager implements IChunkManager { | ||
private PlayerChunkMap chunkMap; | ||
|
||
public ChunkManager(PlayerChunkMap chunkMap) { | ||
this.chunkMap = chunkMap; | ||
} | ||
|
||
public boolean resendChunk(int chunkX, int chunkZ, HashSet<Player> affectedPlayers) { | ||
if(!this.chunkMap.isChunkInUse(chunkX, chunkZ)) return true; | ||
|
||
PlayerChunk playerChunk = this.chunkMap.getChunk(chunkX, chunkZ); | ||
|
||
if(playerChunk == null || playerChunk.chunk == null || !playerChunk.chunk.isReady()) return false; | ||
|
||
for(EntityPlayer player : playerChunk.c) { | ||
player.playerConnection.sendPacket(new PacketPlayOutUnloadChunk(chunkX, chunkZ)); | ||
player.playerConnection.sendPacket(new PacketPlayOutMapChunk(playerChunk.chunk, 0xffff)); | ||
|
||
affectedPlayers.add(player.getBukkitEntity()); | ||
} | ||
|
||
return true; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
v1_11_R1/src/main/java/com/lishid/orebfuscator/nms/v1_11_R1/NBT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* @author lishid | ||
* @author Aleksey Terzi | ||
* | ||
*/ | ||
|
||
package com.lishid.orebfuscator.nms.v1_11_R1; | ||
|
||
import java.io.DataInput; | ||
import java.io.DataInputStream; | ||
import java.io.DataOutput; | ||
import java.io.IOException; | ||
|
||
import net.minecraft.server.v1_11_R1.NBTCompressedStreamTools; | ||
import net.minecraft.server.v1_11_R1.NBTTagCompound; | ||
|
||
import com.lishid.orebfuscator.nms.INBT; | ||
|
||
public class NBT implements INBT { | ||
NBTTagCompound nbt = new NBTTagCompound(); | ||
|
||
public void reset() { | ||
nbt = new NBTTagCompound(); | ||
} | ||
|
||
public void setInt(String tag, int value) { | ||
nbt.setInt(tag, value); | ||
} | ||
|
||
public void setLong(String tag, long value) { | ||
nbt.setLong(tag, value); | ||
} | ||
|
||
public void setBoolean(String tag, boolean value) { | ||
nbt.setBoolean(tag, value); | ||
} | ||
|
||
public void setByteArray(String tag, byte[] value) { | ||
nbt.setByteArray(tag, value); | ||
} | ||
|
||
public void setIntArray(String tag, int[] value) { | ||
nbt.setIntArray(tag, value); | ||
} | ||
|
||
public int getInt(String tag) { | ||
return nbt.getInt(tag); | ||
} | ||
|
||
public long getLong(String tag) { | ||
return nbt.getLong(tag); | ||
} | ||
|
||
public boolean getBoolean(String tag) { | ||
return nbt.getBoolean(tag); | ||
} | ||
|
||
public byte[] getByteArray(String tag) { | ||
return nbt.getByteArray(tag); | ||
} | ||
|
||
public int[] getIntArray(String tag) { | ||
return nbt.getIntArray(tag); | ||
} | ||
|
||
public void Read(DataInput stream) throws IOException { | ||
nbt = NBTCompressedStreamTools.a((DataInputStream) stream); | ||
} | ||
|
||
public void Write(DataOutput stream) throws IOException { | ||
NBTCompressedStreamTools.a(nbt, stream); | ||
} | ||
} |
Oops, something went wrong.