Skip to content
Merged
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
23 changes: 0 additions & 23 deletions .github/workflows/build-and-release.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build Plugin

on:
workflow_dispatch:
push:
branches: [main]
pull_request:

permissions:
contents: write
actions: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Build Plugin
run: mvn clean package

- name: Get short commit hash
id: vars
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Upload build
uses: actions/upload-artifact@v4
with:
name: TuffX_${{ steps.vars.outputs.hash }}
path: target/TuffX.jar

- name: Create Release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.vars.outputs.hash }}
name: Release ${{ steps.vars.outputs.hash }}
files: target/TuffX.jar
prerelease: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/.DS_Store
**/target/
/.idea/
5 changes: 0 additions & 5 deletions .idea/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/compiler.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/encodings.xml

This file was deleted.

30 changes: 0 additions & 30 deletions .idea/jarRepositories.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
# TuffXPlugin
# TuffX

![preview](https://raw.githubusercontent.com/TuffNetwork/TuffX-Plugin/refs/heads/main/img/showcase.png)
:-:
TuffX allowing players to see and beat a trial chamber.

> [!WARNING]
> This is not a "crack" for Minecraft, it simply allows for better TuffClient integration on servers.

## Quick Start
Install the latest jar from [releases](https://github.com/TuffNetwork/TuffX-Plugin/releases/latest/) into your server's `plugins` folder. Then, restart your server, and join via TuffClient. You should now be able to use extra features such as below y0 and ViaBlocks!

## Compiling
```sh
$ git clone https://github.com/TuffNetwork/TuffX-Plugin
$ cd TuffX-Plugin
$ mvn clean install
```

The built plugin jar will be in the `target` folder.
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</dependency>
</dependencies>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
</properties>
</project>
Binary file added img/showcase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 37 additions & 39 deletions src/main/java/net/potato/tuff/ChunkPacketListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,46 @@
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;
import net.potato.tuff.TuffX;

public class ChunkPacketListener {

private static boolean initialized = false;

public static void initialize(TuffX plugin) {
if (initialized) {
return;
}

ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
if (protocolManager == null) {
plugin.getLogger().severe("Could not initialize ChunkPacketListener because ProtocolManager is null!");
return;
}

protocolManager.addPacketListener(
new PacketAdapter(plugin, PacketType.Play.Server.MAP_CHUNK) {
@Override
public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer();

if (!((TuffX) this.plugin).isPlayerReady(player)) {
return;
}

World world = player.getWorld();
int chunkX = event.getPacket().getIntegers().read(0);
int chunkZ = event.getPacket().getIntegers().read(1);

plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
if (player.isOnline() && world.isChunkLoaded(chunkX, chunkZ)) {
Chunk chunk = world.getChunkAt(chunkX, chunkZ);
((TuffX) this.plugin).processAndSendChunk(player, chunk);
}
});
}
}
);
private static boolean initialized = false;

public static void initialize(TuffX plugin) {
if (initialized) {
return;
}

plugin.getLogger().info("ProtocolLib listener for chunks registered successfully.");
initialized = true;
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
if (protocolManager == null) {
plugin.getLogger().severe("Could not initialize ChunkPacketListener because ProtocolManager is null!");
return;
}

protocolManager.addPacketListener(
new PacketAdapter(plugin, PacketType.Play.Server.MAP_CHUNK) {
@Override
public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer();

if (!((TuffX) this.plugin).isPlayerReady(player)) {
return;
}

World world = player.getWorld();
int chunkX = event.getPacket().getIntegers().read(0);
int chunkZ = event.getPacket().getIntegers().read(1);

plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
if (player.isOnline() && world.isChunkLoaded(chunkX, chunkZ)) {
Chunk chunk = world.getChunkAt(chunkX, chunkZ);
((TuffX) this.plugin).processAndSendChunk(player, chunk);
}
});
}
});

plugin.getLogger().info("ProtocolLib listener for chunks registered successfully.");
initialized = true;
}
}
Loading