Skip to content

Commit

Permalink
chore: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingrim4 committed Sep 9, 2023
1 parent 5fa0a06 commit 6999695
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 37 deletions.
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,40 @@
# Orebfuscator - Anti X-Ray
[![Release Status](https://github.com/Imprex-Development/Orebfuscator/workflows/Releases/badge.svg)](https://github.com/Imprex-Development/Orebfuscator/releases/latest) [![Build Status](https://github.com/Imprex-Development/Orebfuscator/workflows/Build/badge.svg)](https://github.com/Imprex-Development/Orebfuscator/actions?query=workflow%3ABuild)

Orebfuscator is plugin for Spigot based Minecraft Servers that modifies packets in order to hide blocks of interest from X-Ray Clients and Texture Packs. Thus it doesn't modify your world and is safe to use.
Orebfuscator empowers server owners to protect their server from X-Ray Clients and Texture Packs, all while offering a high degree of configurability. This is achieved through modifying network packets without altering your game world, guaranteeing a secure and reliable experience for users. With Orebfuscator, you can tailor the settings to suit your server's needs, ensuring precise control over the visibility of specific blocks. This means that not only does Orebfuscator safeguard your world's integrity, but it also empowers you to fine-tune your Anti-X-Ray measures for the best gameplay experience.

### Features
* Plug & Play
* Highly configurable config
* Support for Spigot based servers 1.9.4+ (only tested on spigot)
* Obfuscate non-visible blocks
* Hide block entities like Chests and Furnaces
* Make blocks in a players proximity visible based on their distance an
* Seamless Integration: Plug & Play functionality for effortless use.
* Extensive Configuration: Highly customizable settings to tailor the experience to your liking.
* Server Compatibility: Designed for Spigot-based servers 1.9.4 and newer (primarily tested on Spigot).
* Block Obfuscation: Conceal non-visible blocks from players' view.
* Block-Entity Support: Hide block entities such as Chests and Furnaces.
* Dynamic Block Visibility: Adjust block visibility based on player proximity and distance.

### Requirements
- Java 11 or higher
- Spigot and (proably) any other fork of Spigot (1.9.4 or higher)
- [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997) 5.0.0 or higher
* Java 11 or higher
* Spigot or compatible forks (1.9.4 or newer)
* [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997) 5.0.0 or later

### Installation
1. Download [ProtocolLib](https://github.com/dmulloy2/ProtocolLib/releases)
2. Download [Orebfuscator](https://github.com/Imprex-Development/Orebfuscator/releases)
3. Put both in your *plugins* directory
4. Start your server and [configure](https://github.com/Imprex-Development/Orebfuscator/wiki/Config) orebfuscator to your liking
3. Place both plugins in your _plugins_ directory
4. Start your server and [configure Orebfuscator](https://github.com/Imprex-Development/Orebfuscator/wiki/Config) to your liking

Still having trouble getting Orebfuscator to run check out our [common issues](https://github.com/Imprex-Development/Orebfuscator/wiki/Common-Issues).

### Maven
```maven

To include the API in your Maven project, add the following configuration to your `pom.xml`:

```xml
<repositories>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
...
<!-- Additional repositories can be added here if needed -->
</repositories>

<dependencies>
Expand All @@ -42,6 +45,7 @@ Still having trouble getting Orebfuscator to run check out our [common issues](h
<artifactId>orebfuscator-api</artifactId>
<version>5.2.4</version>
</dependency>
<!-- Add other dependencies as required -->
</dependencies>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class WrappedClientboundLevelChunkPacketData {
private static final FieldAccessor BUFFER = Accessors.getFieldAccessor(CLIENTBOUND_LEVEL_CHUNK_PACKET_DATA, byte[].class, true);
private static final FieldAccessor BLOCK_ENTITIES = Accessors.getFieldAccessor(CLIENTBOUND_LEVEL_CHUNK_PACKET_DATA, List.class, true);

private static final Class<?> BLOCK_ENTITY_INFO = MinecraftReflection.getMinecraftClass("network.protocol.game.ClientboundLevelChunkPacketData$a");
private static final Class<?> BLOCK_ENTITY_INFO = MinecraftReflection.getMinecraftClass("network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo");
private static final FieldAccessor[] INT_FIELDS = Accessors.getFieldAccessorArray(BLOCK_ENTITY_INFO, int.class, true);
private static final FieldAccessor PACKED_XZ = INT_FIELDS[0];
private static final FieldAccessor Y = INT_FIELDS[1];
Expand Down
4 changes: 2 additions & 2 deletions orebfuscator-nms/orebfuscator-nms-v1_20_R1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<build>
<plugins>
<plugin>
<!--<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>${plugin.specialsource.version}</version>
Expand Down Expand Up @@ -60,7 +60,7 @@
</configuration>
</execution>
</executions>
</plugin>
</plugin>-->
</plugins>
</build>
</project>
15 changes: 14 additions & 1 deletion orebfuscator-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@

<artifactId>orebfuscator-plugin</artifactId>
<packaging>jar</packaging>


<repositories>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>

<build>
<resources>
<resource>
Expand Down Expand Up @@ -69,6 +76,12 @@
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${dependency.bukkit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dev.folia</groupId>
<artifactId>folia-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void onDisable() {
this.proximityThread.close();
}

getServer().getAsyncScheduler().cancelTasks(this);
this.getServer().getScheduler().cancelTasks(this);

NmsInstance.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private boolean isUpdateAvailable() {
}

private void checkForUpdates() {
Bukkit.getScheduler().runTaskAsynchronously(this.orebfuscator, () -> {
Bukkit.getAsyncScheduler().runNow(this.orebfuscator, (task) -> {
if (this.isUpdateAvailable()) {
ConsoleUtil.printBox(Level.WARNING,
"UPDATE AVAILABLE", "", this.getHtmlUrl());
Expand All @@ -124,15 +124,15 @@ private void checkForUpdates() {
}

public void checkForUpdates(Player player) {
Bukkit.getScheduler().runTaskAsynchronously(this.orebfuscator, () -> {
Bukkit.getAsyncScheduler().runNow(this.orebfuscator, (task) -> {
if (this.isUpdateAvailable()) {
BaseComponent[] components = new ComponentBuilder("[§bOrebfuscator§f]§7 A new release is available ")
.append("§f§l[CLICK HERE]")
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, this.getHtmlUrl()))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§7Click here to see the latest release").create())).create();
Bukkit.getScheduler().runTask(this.orebfuscator, () -> {
player.getScheduler().run(this.orebfuscator, (task2) -> {
player.spigot().sendMessage(components);
});
}, null);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ public ObfuscationCache(Orebfuscator orebfuscator) {
}

if (this.cacheConfig.enabled() && this.cacheConfig.deleteRegionFilesAfterAccess() > 0) {
Bukkit.getScheduler().runTaskTimerAsynchronously(orebfuscator, new CacheFileCleanupTask(orebfuscator), 0,
3_600_000L);
var temp = new CacheFileCleanupTask(orebfuscator);
Bukkit.getAsyncScheduler().runAtFixedRate(orebfuscator, task -> temp.run(), 0,
3_600_000L, TimeUnit.MILLISECONDS);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.imprex.orebfuscator.obfuscation;

import org.bukkit.Bukkit;

import com.comphenix.protocol.AsynchronousManager;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.async.AsyncListenerHandler;
Expand All @@ -17,7 +19,8 @@ public ObfuscationListenerAsync(Orebfuscator orebfuscator) {

this.asynchronousManager = ProtocolLibrary.getProtocolManager().getAsynchronousManager();
this.asyncListenerHandler = this.asynchronousManager.registerAsyncHandler(this);
this.asyncListenerHandler.start();
Bukkit.getAsyncScheduler().runNow(orebfuscator, (task) -> this.asyncListenerHandler.getListenerLoop().run());
// this.asyncListenerHandler.start();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

class ObfuscationTaskDispatcher implements Runnable {

private final Orebfuscator orebfuscator;
private final ObfuscationProcessor processor;

private final Queue<ObfuscationRequest> requests = new ConcurrentLinkedQueue<>();
Expand All @@ -21,6 +22,7 @@ class ObfuscationTaskDispatcher implements Runnable {
private final ObfuscationTaskWorker[] worker;

public ObfuscationTaskDispatcher(Orebfuscator orebfuscator, ObfuscationProcessor processor) {
this.orebfuscator = orebfuscator;
this.processor = processor;

AdvancedConfig config = orebfuscator.getOrebfuscatorConfig().advanced();
Expand All @@ -31,18 +33,25 @@ public ObfuscationTaskDispatcher(Orebfuscator orebfuscator, ObfuscationProcessor
this.worker[i] = new ObfuscationTaskWorker(this, this.processor);
}

Bukkit.getScheduler().runTaskTimer(orebfuscator, this, 0, 1);
// Bukkit.getScheduler().runTaskTimer(orebfuscator, this, 0, 1);
}

public void submitRequest(ObfuscationRequest request) {
this.requests.offer(request);
Bukkit.getRegionScheduler().run(this.orebfuscator,
request.getChunkStruct().world,
request.getChunkStruct().chunkX,
request.getChunkStruct().chunkZ,
(unused) -> {
this.tasks.offer(ObfuscationTask.fromRequest(request));
});
// this.requests.offer(request);
}

public ObfuscationTask retrieveTask() throws InterruptedException {
ObfuscationTask task;

while ((task = this.tasks.poll()) == null) {
LockSupport.park(this);
LockSupport.parkNanos(this, 50000000L/*50ms*/);
if (Thread.interrupted()) {
throw new InterruptedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.List;
import java.util.Set;

import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
Expand Down Expand Up @@ -149,10 +148,10 @@ private void process(Player player) {
}
}

Bukkit.getScheduler().runTask(this.orebfuscator, () -> {
player.getScheduler().run(this.orebfuscator, (task) -> {
if (player.isOnline() && player.getWorld().equals(world)) {
NmsInstance.sendBlockUpdates(player, updateBlocks);
}
});
}, null);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package net.imprex.orebfuscator.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;

import org.apache.commons.lang.StringUtils;

public final class ConsoleUtil {

private static final int BOX_PADDING = 3;
Expand Down Expand Up @@ -61,7 +60,7 @@ public static Iterable<String> createBox(String...lines) {
int totalWidth = width + BOX_PADDING * 2;

// create top/bottom lines
String bottomTopLine = StringUtils.repeat("═", totalWidth);
String bottomTopLine = repeat('═', totalWidth);
String topLine = String.format("╔%s╗", bottomTopLine);
String bottomLine = String.format("╚%s╝", bottomTopLine);

Expand All @@ -75,10 +74,10 @@ public static Iterable<String> createBox(String...lines) {
// center line
String leftPadding, rightPadding;
if (space % 2 == 0) {
leftPadding = rightPadding = StringUtils.repeat(" ", space / 2);
leftPadding = rightPadding = repeat(' ', space / 2);
} else {
leftPadding = StringUtils.repeat(" ", space / 2 + 1);
rightPadding = StringUtils.repeat(" ", space / 2);
leftPadding = repeat(' ', space / 2 + 1);
rightPadding = repeat(' ', space / 2);
}

box.add(String.format("║%s%s%s║", leftPadding, line, rightPadding));
Expand All @@ -87,4 +86,10 @@ public static Iterable<String> createBox(String...lines) {
box.add(bottomLine);
return box;
}

private static String repeat(char character, int length) {
char[] string = new char[length];
Arrays.fill(string, character);
return new String(string);
}
}
1 change: 1 addition & 0 deletions orebfuscator-plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ author: Ingrim4
authors: [NgLoader, lishid, SydMontague, ProgrammerDan, Aleksey-Terzi]

depend: [ProtocolLib]
folia-supported: true

commands:
orebfuscator:
Expand Down

0 comments on commit 6999695

Please sign in to comment.