Skip to content

Commit

Permalink
Merge branch 'master' into experimental-obfuscation-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingrim4 committed Oct 7, 2024
2 parents 78343ae + 7de1d8e commit df22120
Show file tree
Hide file tree
Showing 58 changed files with 1,259 additions and 582 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buildtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ checkVersion "1.20.1" "17"
checkVersion "1.20.2" "17"
checkVersion "1.20.4" "17"
checkVersion "1.20.6" "21"
checkVersion "1.21" "21"
checkVersion "1.21.1" "21"
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

public interface AdvancedConfig {

int maxMillisecondsPerTick();

int obfuscationWorkerThreads();
int obfuscationThreads();

boolean hasObfuscationTimeout();

int obfuscationTimeout();
long obfuscationTimeout();

int maxMillisecondsPerTick();

int proximityHiderThreads();
int proximityThreads();

int proximityDefaultBucketSize();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ public interface CacheConfig {

boolean enabled();

int maximumSize();

long expireAfterAccess();

boolean enableDiskCache();

Path baseDirectory();

Path regionFile(ChunkPosition chunkPosition);

int maximumOpenRegionFiles();

long deleteRegionFilesAfterAccess();

boolean enableDiskCache();

int maximumSize();

long expireAfterAccess();

int maximumTaskQueueSize();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public interface Config {

byte[] systemHash();

String report();

GeneralConfig general();

AdvancedConfig advanced();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private static int javaMajorVersion() {

/**
* taken from:
* https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/PlatformDependent0.java#L1011
* https://github.com/netty/netty/blob/7ad2b91515b3affaeadb4b2975cd6d2a8342c403/common/src/main/java/io/netty/util/internal/PlatformDependent0.java#L1037
*/
private static int majorVersion(final String javaSpecVersion) {
final String[] components = javaSpecVersion.split("\\.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static Builder builder() {
private final int weight;

/**
* Flat int array where each entry has a value of one
* Flat int array where each entry has a probability of one
*
* @implNote use flat int array instead of treemap cause O(N*log(N)) is too
* slow since this is the second hottest code path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().isSyncChunkWrites();
return new RegionFile(path, path.getParent(), RegionFileCompression.b, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileCompression.c, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().isSyncChunkWrites();
return new RegionFile(path, path.getParent(), RegionFileCompression.b, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileCompression.c, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().isSyncChunkWrites();
return new RegionFile(path, path.getParent(), RegionFileCompression.b, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileCompression.c, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(null, path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(null, path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
10 changes: 5 additions & 5 deletions orebfuscator-nms/orebfuscator-nms-v1_21_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.21.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
Expand Down Expand Up @@ -54,9 +54,9 @@
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<srgIn>org.spigotmc:minecraft-server:1.21.1-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedDependencies>org.spigotmc:spigot:1.21.1-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
Expand All @@ -69,8 +69,8 @@
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
<srgIn>org.spigotmc:minecraft-server:1.21.1-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.21.1-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class RegionFileCache extends AbstractRegionFileCache<RegionFile> {
@Override
protected RegionFile createRegionFile(Path path) throws IOException {
boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites();
return new RegionFile(null, path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites);
return new RegionFile(null, path, path.getParent(), RegionFileVersion.VERSION_NONE, isSyncChunkWrites);
}

@Override
Expand Down
16 changes: 16 additions & 0 deletions orebfuscator-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<configuration>
<minimizeJar>true</minimizeJar>
<filters>
<filter>
<artifact>*:lz4-java</artifact>
<includes>
<include>**</include>
</includes>
</filter>
<filter>
<artifact>*:*</artifact>
<excludeDefaults>false</excludeDefaults>
Expand All @@ -43,6 +49,10 @@
<pattern>org.joml</pattern>
<shadedPattern>net.imprex.shaded.org.joml</shadedPattern>
</relocation>
<relocation>
<pattern>net.jpountz</pattern>
<shadedPattern>net.imprex.shaded.net.jpountz</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
Expand Down Expand Up @@ -85,6 +95,12 @@
<version>${dependency.bstats.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
<version>${dependency.lz4.version}</version>
<scope>compile</scope>
</dependency>

<!-- Orebfuscator -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class Orebfuscator extends JavaPlugin implements Listener {

private final Thread mainThread = Thread.currentThread();

private OrebfuscatorStatistics statistics;
private OrebfuscatorConfig config;
private OrebfuscatorPlayerMap playerMap;
private UpdateSystem updateSystem;
Expand Down Expand Up @@ -54,6 +55,8 @@ public void onEnable() {
throw new RuntimeException("ProtocolLib can't be found or is disabled! Orebfuscator can't be enabled.");
}

this.statistics = new OrebfuscatorStatistics();

// Load configurations
this.config = new OrebfuscatorConfig(this);

Expand Down Expand Up @@ -138,6 +141,10 @@ public boolean isGameThread() {
return Thread.currentThread() == this.mainThread;
}

public OrebfuscatorStatistics getStatistics() {
return statistics;
}

public OrebfuscatorConfig getOrebfuscatorConfig() {
return this.config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

if (args.length == 0) {
sender.sendMessage("You are using " + this.orebfuscator.toString());
sender.sendMessage(this.orebfuscator.getStatistics().toString());
} else if (args[0].equalsIgnoreCase("dump")) {
TemporalAccessor now = OffsetDateTime.now(ZoneOffset.UTC);

Expand All @@ -77,6 +78,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
versions.addProperty("orebfuscator", orebfuscator.toString());
root.add("versions", versions);

root.add("statistics", orebfuscator.getStatistics().toJson());

JsonObject plugins = new JsonObject();
for (Plugin bukkitPlugin : Bukkit.getPluginManager().getPlugins()) {
PluginDescriptionFile description = bukkitPlugin.getDescription();
Expand Down Expand Up @@ -110,7 +113,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
Base64.Encoder encoder = Base64.getUrlEncoder();

String latestLog = OFCLogger.getLatestVerboseLog();
root.addProperty("verbose_log", encoder.encodeToString(latestLog.getBytes(StandardCharsets.UTF_8)));
root.addProperty("verboseLog", encoder.encodeToString(latestLog.getBytes(StandardCharsets.UTF_8)));

try {
Path configPath = orebfuscator.getDataFolder().toPath().resolve("config.yml");
Expand All @@ -120,6 +123,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
e.printStackTrace();
}

String configReport = orebfuscator.getOrebfuscatorConfig().report();
configReport = configReport != null ? configReport : "";
root.addProperty("configReport", encoder.encodeToString(configReport.getBytes(StandardCharsets.UTF_8)));

Path path = orebfuscator.getDataFolder().toPath().resolve("dump-" + fileFormat.format(now) + ".json");
try (JsonWriter writer = new JsonWriter(Files.newBufferedWriter(path))) {
writer.setIndent(" ");
Expand Down
Loading

0 comments on commit df22120

Please sign in to comment.