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
66 changes: 66 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Java CI with Gradle and Release

on:
push:
branches: ["master"]

jobs:
build_and_release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build with Gradle Wrapper
id: build
run: |
./gradlew build
echo "::set-output name=jar_file::$(find target/bukkit -name '*.jar' -print -quit)"

- name: Extract version from build.gradle.kts
id: extract_version
run: |
VERSION=$(grep '^version\s*=' build.gradle.kts | sed -E 's/version\s*=\s*"([^"]+)"/\1/')
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Determine next build number
id: build_number
run: |
git fetch --tags
TAG_PATTERN="v${VERSION}-build-"
LAST_TAG=$(git tag --list "${TAG_PATTERN}*" | sort -V | tail -n1)
if [[ $LAST_TAG =~ -build-([0-9]+)$ ]]; then
BUILD_NUMBER=$((BASH_REMATCH[1]+1))
else
BUILD_NUMBER=1
fi
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV

- name: Create and push tag
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
NEW_TAG="v${VERSION}-build-${BUILD_NUMBER}"
git tag "$NEW_TAG"
git push origin "$NEW_TAG"

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ env.VERSION }}-build-${{ env.BUILD_NUMBER }}"
name: "v${{ env.VERSION }}-build-${{ env.BUILD_NUMBER }}"
files: ${{ steps.build.outputs.jar_file }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
From current maintainer Lumine1909: I'm considering drop support of 1.20.5- servers, so I add bstats to collect user's version info. If there aren't enough users in those legacy versions, I'll do that in roughly next minor version. Then I will rewrite the plugin to improve its performance and readability, just like what I did [here](https://github.com/Lumine1909/CustomBiomeColors_Continue).

-----

# Panilla
Panilla (the name) is a combination of the word Packet and Vanilla (as in Vanilla Minecraft).

Expand Down Expand Up @@ -27,8 +31,7 @@ Currently Panilla supports:
- Bukkit
- CraftBukkit* 1.8.8
- CraftBukkit* 1.12.x-1.20.4
- Paper 1.20.6
- Paper 1.21-1.21.1
- Paper 1.20.5-26.1.2

**CraftBukkit includes any CraftBukkit derivatives (Spigot, Paper, Folia, etc)*

Expand All @@ -39,4 +42,4 @@ In order for you to compile Panilla, you will need to use [BuildTools, by Spigot
When you run BuildTools, it will add the dependencies required (CraftBukkit/Bukkit) to your local Maven repository.
From there, you can compile the project with `./gradlew build`. The output plugin jars file will located in the `target/` directory.

Java 17 is required to build Panilla.
Java 21 is required to build Panilla.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.ruinscraft.panilla.api;

public class DefaultProtocolConstants implements IProtocolConstants {

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ public interface IPanillaPlayer {
boolean hasPermission(String node);

boolean canBypassChecks(IPanilla panilla, PacketException e);

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public abstract class PConfig {

/* Defaults */
public String language = "en";
public boolean safeMode = false;
public boolean consoleLogging = true;
public boolean chatLogging = false;
public PStrictness strictness = PStrictness.AVERAGE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String getTranslation(String key, String... replacements) {
if (unformatted == null) {
return "unknown translation: " + key;
}
String formatted = String.format(translations.get(key), replacements);
String formatted = String.format(translations.get(key), (Object[]) replacements);
return formatted;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public interface IPacketInspector {

void checkPacketPlayInClickContainer(Object packetHandle) throws NbtNotPermittedException;
void checkPacketPlayInClickContainer(Object packetHandle, IPanillaPlayer player) throws NbtNotPermittedException;

void checkPacketPlayInSetCreativeSlot(Object packetHandle) throws NbtNotPermittedException;

Expand Down Expand Up @@ -45,7 +45,7 @@ public interface IPacketInspector {

default void checkPlayIn(IPanilla panilla, IPanillaPlayer player, Object packetHandle) throws PacketException {
try {
checkPacketPlayInClickContainer(packetHandle);
checkPacketPlayInClickContainer(packetHandle, player);
} catch (NbtNotPermittedException e) {
if (!player.canBypassChecks(panilla, e)) {
sendPacketPlayOutSetSlotAir(player, e.getItemSlot());
Expand Down Expand Up @@ -81,5 +81,4 @@ default void checkPlayOut(IPanilla panilla, Object packetHandle) throws PacketEx
throw e;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.ruinscraft.panilla.api.IPanilla;
import com.ruinscraft.panilla.api.IPanillaPlayer;
import com.ruinscraft.panilla.api.io.dplx.PacketDecompressorDplx;
import com.ruinscraft.panilla.api.io.dplx.PacketInspectorDplx;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panil

// signs with text
if (blockEntityTag.hasKey("Text1")
|| blockEntityTag.hasKey("Text2")
|| blockEntityTag.hasKey("Text3")
|| blockEntityTag.hasKey("Text4")) {
|| blockEntityTag.hasKey("Text2")
|| blockEntityTag.hasKey("Text3")
|| blockEntityTag.hasKey("Text4")) {
result = NbtCheckResult.FAIL;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ private static FailedNbt checkItems(INbtTagList items, String nmsItemClassName,
return failedNbt;
}

private static NbtCheckResult checkEffectsTag(INbtTagList effectsList) {
for (int i = 0; i < effectsList.size(); i++) {
INbtTagCompound effect = effectsList.getCompound(i);

if (effect.hasKeyOfType("amplifier", NbtDataType.BYTE)) {
short amplifier = effect.getByte("amplifier");
if (amplifier > 32) {
return NbtCheckResult.CRITICAL;
}
}

if (effect.hasKeyOfType("Amplifier", NbtDataType.BYTE)) {
short amplifier = effect.getByte("Amplifier");
if (amplifier > 32) {
return NbtCheckResult.CRITICAL;
}
}
}

return NbtCheckResult.PASS;
}

@Override
public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panilla) {
NbtCheckResult result = NbtCheckResult.PASS;
Expand Down Expand Up @@ -238,26 +260,4 @@ public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panil
return result;
}

private static NbtCheckResult checkEffectsTag(INbtTagList effectsList) {
for (int i = 0; i < effectsList.size(); i++) {
INbtTagCompound effect = effectsList.getCompound(i);

if (effect.hasKeyOfType("amplifier", NbtDataType.BYTE)) {
short amplifier = effect.getByte("amplifier");
if (amplifier > 32) {
return NbtCheckResult.CRITICAL;
}
}

if (effect.hasKeyOfType("Amplifier", NbtDataType.BYTE)) {
short amplifier = effect.getByte("Amplifier");
if (amplifier > 32) {
return NbtCheckResult.CRITICAL;
}
}
}

return NbtCheckResult.PASS;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panil
int flight = fireworks.getInt("Flight");

if (flight > panilla.getProtocolConstants().maxFireworksFlight()
|| flight < panilla.getProtocolConstants().minFireworksFlight()) {
|| flight < panilla.getProtocolConstants().minFireworksFlight()) {
result = NbtCheckResult.FAIL;
}

INbtTagList explosions = fireworks.getList("Explosions", NbtDataType.COMPOUND);

if (explosions != null
&& explosions.size() > panilla.getProtocolConstants().maxFireworksExplosions()) {
&& explosions.size() > panilla.getProtocolConstants().maxFireworksExplosions()) {
result = NbtCheckResult.FAIL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ public class NbtCheck_SkullOwner extends NbtCheck {

public static final Pattern URL_MATCHER = Pattern.compile("url");

public static UUID minecraftSerializableUuid(final int[] ints) {
return new UUID((long) ints[0] << 32 | ((long) ints[1] & 0xFFFFFFFFL), (long) ints[2] << 32 | ((long) ints[3] & 0xFFFFFFFFL));
}

public NbtCheck_SkullOwner() {
super("SkullOwner", PStrictness.LENIENT);
}

public static UUID minecraftSerializableUuid(final int[] ints) {
return new UUID((long) ints[0] << 32 | ((long) ints[1] & 0xFFFFFFFFL), (long) ints[2] << 32 | ((long) ints[3] & 0xFFFFFFFFL));
}

@Override
public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panilla) {
INbtTagCompound skullOwner = tag.getCompound("SkullOwner");
Expand Down Expand Up @@ -88,9 +88,9 @@ public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panil

// all lowercase, no parentheses or spaces
decoded = decoded.trim()
.replace(" ", "")
.replace("\"", "")
.toLowerCase();
.replace(" ", "")
.replace("\"", "")
.toLowerCase();

Matcher matcher = URL_MATCHER.matcher(decoded);

Expand All @@ -100,7 +100,7 @@ public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panil
String url = decoded.substring(matcher.end() + 1);

if (url.startsWith("http://textures.minecraft.net") ||
url.startsWith("https://textures.minecraft.net")) {
url.startsWith("https://textures.minecraft.net")) {
continue;
} else {
return NbtCheckResult.FAIL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class NbtCheck_Unbreakable extends NbtCheck {

public NbtCheck_Unbreakable() {
super("Unbreakable", PStrictness.LENIENT,"minecraft:unbreakable");
super("Unbreakable", PStrictness.LENIENT, "minecraft:unbreakable");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ else if (name.startsWith("{")) {
}

if (display.hasKeyOfType("Lore", NbtDataType.LIST)) {
INbtTagList lore = display.getList("Lore");
INbtTagList lore = display.getList("Lore", NbtDataType.STRING);

if (lore.size() > panilla.getProtocolConstants().NOT_PROTOCOL_maxLoreLines()) {
return NbtCheckResult.CRITICAL; // can cause crashes
}

if (lore.size() > 0 && lore.isCompound(0)) {
return NbtCheckResult.CRITICAL; // can cause crashes
}

for (int i = 0; i < lore.size(); i++) {
String line = lore.getString(i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class NbtCheck_pages extends NbtCheck {

// translations in the game which (intentionally) crash the user
public static final String[] MOJANG_CRASH_TRANSLATIONS = new String[]{
"translation.test.invalid",
"translation.test.invalid2"
"translation.test.invalid",
"translation.test.invalid2"
};

private static final int MINECRAFT_UNICODE_MAX = 65535;
Expand All @@ -39,6 +39,37 @@ public static short[] createCharMap(String string) {
return charMap;
}

private static int getCharCountForItem(INbtTagCompound item) {
int charCount = 0;

if (item.hasKey("tag")) {
INbtTagCompound tag = item.getCompound("tag");

if (tag.hasKey("pages")) {
INbtTagList pages = tag.getList("pages", NbtDataType.STRING);

for (int i = 0; i < pages.size(); i++) {
final String page = pages.getString(i);
final String pageNoSpaces = page.replace(" ", "");
charCount += pageNoSpaces.length();
}
}
}

return charCount;
}

// Gets the amount of characters of books within in a list of items
public static int getCharCountForItems(INbtTagList items) {
int charCount = 0;

for (int i = 0; i < items.size(); i++) {
charCount += getCharCountForItem(items.getCompound(i));
}

return charCount;
}

@Override
public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panilla) {
INbtTagList pages = tag.getList("pages", NbtDataType.STRING);
Expand Down Expand Up @@ -107,35 +138,4 @@ public NbtCheckResult check(INbtTagCompound tag, String itemName, IPanilla panil
return NbtCheckResult.PASS;
}

private static int getCharCountForItem(INbtTagCompound item) {
int charCount = 0;

if (item.hasKey("tag")) {
INbtTagCompound tag = item.getCompound("tag");

if (tag.hasKey("pages")) {
INbtTagList pages = tag.getList("pages", NbtDataType.STRING);

for (int i = 0; i < pages.size(); i++) {
final String page = pages.getString(i);
final String pageNoSpaces = page.replace(" ", "");
charCount += pageNoSpaces.length();
}
}
}

return charCount;
}

// Gets the amount of characters of books within in a list of items
public static int getCharCountForItems(INbtTagList items) {
int charCount = 0;

for (int i = 0; i < items.size(); i++) {
charCount += getCharCountForItem(items.getCompound(i));
}

return charCount;
}

}
Loading