Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
onebeastchris committed Jun 3, 2024
1 parent f2290a6 commit 9fa4c8f
Show file tree
Hide file tree
Showing 15 changed files with 325 additions and 145 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build
on:
push:
branches:
- "master"
jobs:
build:
name: Build
runs-on: ubuntu-latest
container:
image: gradle:8-jdk17
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: 'gradle'
- name: Gradle Build
run: gradle shadowJar
- name: Auto Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: false
title: "Build"
files: |
build/libs/TransferTool-*.jar
95 changes: 53 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,53 @@
# Geyser Extension Template
A Geyser Extension template for creating Geyser Extensions.

## What are Geyser extensions?
Geyser Extensions are the equivalent of “plugins”, but specifically for the Geyser platform. This brings the advantage of them being platform-agnostic, meaning that you won’t have to worry about supporting all platforms individually. Additionally, they will be, by design, only applied for Bedrock players joining via Geyser.

## What can extensions do?
- Register [custom items](https://wiki.geysermc.org/geyser/custom-items/), [custom blocks](https://wiki.geysermc.org/geyser/custom-blocks/#geyser-extensions) and more in code!
- Listen and toggle various Bedrock features (i.e. commands)
- Send forms to Bedrock players using [Cumulus](https://github.com/GeyserMC/Cumulus)
- Listen and interact with [Events](https://wiki.geysermc.org/geyser/events/)

## GeyserAPI / Geyer Extension docs:
- [Geyser extensions guide](https://wiki.geysermc.org/geyser/extensions/)
- [Geyser API introduction](https://wiki.geysermc.org/geyser/api/)
- [Introduction to Events](https://wiki.geysermc.org/geyser/events/)

## Using this Template
1. Create a new repository using this template
2. Replace the data in `extension.yml` with data relevant to your extension
3. Update the main extension class
4. Run `./gradlew build` to build the extension
5. Copy the built jar from `build/libs` to your Geyser's extensions folder

## Documentation
Our [wiki](https://wiki.geysermc.org/) has helpful articles

## Coming Soon
- Custom entities
- Resource packs represented in code

## Existing Extensions
See our list [here](https://github.com/GeyserMC/GeyserExtensionList).

## Suggestions?
Reach out on our [Discord](https://discord.gg/geysermc)!

## Important Notes
- `extension.yml` is required for Geyser to load the extension. It must be in the resources folder.
- Geyser Extensions: https://github.com/GeyserMC/Geyser/blob/master/api/src/main/java/org/geysermc/geyser/api/extension/Extension.java
- Geyser API docs: https://github.com/GeyserMC/Geyser/blob/master/api/src/main/java/org/geysermc/geyser/api/

# TransferTool

A Geyser extension that allows you to map Java -> Geyser servers to transfer players to.

# Introduction
Since 1.20.5/6, there is a native Java transfer packet. For once, this is a feature that Bedrock already did have!
However, there is one notable difference: Geyser receives the Java client ip/port to transfer players to. If Geyser
just passes that to the Bedrock client, the client likely would not find a Bedrock server there*.
In most cases, this would not happen. Hence, this Geyser extension allows you to customize which Geyser - or Bedrock server -
to transfer players to upon Geyser receives a Java transfer packet.


*unless Geyser is also running on the same Java port, but that's not usually the case.

# Configuration
There are currently two configuration options:
- "forwardOriginalTarget" (boolean; possible values true/false): <br>
Forwards the ip/port combination received from the Java server directly to the Bedrock client.
This would only be useful in the case where the Java server already accounts for the receiver to be a Geyser player,
and is already sending a Geyser server ip/port to connect to.

- "transferMappings" (Map, String -> String) <br>
Maps a Java ip/port combination to a Bedrock ip/port combination. To represent a ip/address combination,
use the following format: `example.com:12892`, or `198.51.100.0:13132`. Alternatively, you can leave out the port,
this would fall back to the default Java/Bedrock ports (25565 for Java, and 19132 for Bedrock).

Example config:
```
# TranferTool Configuration
# Whether to pass the IP/Port sent by the Java server to the Bedrock client.
# This option will only work properly if the Java server already accounts for Geyser clients
# when sending transfer requests.
forward-original-target=false
# A map of Java ip/port combinations to Geyser ip/port combinations.
# If you do not specify a port with a ":<port>" addition,
# it will use the default ports for Bedrock/Java respectively.
transfer-mappings {
"127.0.0.1:25565"="127.0.0.1:19132"
"javaip.com"="bedrockip.com"
}
```

To add more transfer mappings, create a new line - just like in the example.
Note for ipv6 addresses, you'll need to wrap the ipv6 with square brackets (see [here](https://en.wikipedia.org/wiki/IPv6_address#Literal_IPv6_addresses_in_network_resource_identifiers))

# Installation
To install this Geyser extension, download the TransferTool.jar from the Releases tab, and add it to Geyser's extension folder.
One restart later, and this extension is ready to be used! To reload the config, you can use Geyser's reload command (`/geyser reload`).

# Getting Help
Help is provided via discord: https://discord.gg/WdmrRHRJhS. Alternatively, if you are getting errors or
are running into complications, feel free to open an issue here! Feature requests can also be made that way.
31 changes: 0 additions & 31 deletions build.gradle

This file was deleted.

42 changes: 42 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
java
id("io.github.goooler.shadow") version "8.1.7"
}

repositories {
mavenCentral()
maven("https://repo.opencollab.dev/main/")
}

dependencies {
// Geyser API - needed for all extensions
compileOnly("org.geysermc.geyser:api:2.3.1-SNAPSHOT")

// Include other dependencies here - e.g. for configuration.
implementation("org.spongepowered:configurate-hocon:4.1.2")
}

java {
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

tasks {
build {
dependsOn(shadowJar)
}

jar {
archiveClassifier.set("unshaded")
}

shadowJar {
archiveClassifier.set("")
relocate("org.spongepowered.configurate", "net.onebeastchris.relocate.configurate")
relocate("io.leangen.geantyref", "net.onebeastchris.relocate.geantyref")
relocate("com.typesafe.config", "net.onebeastchris.relocate.typesafe")
}
}


Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
25 changes: 18 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand All @@ -205,6 +210,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
2 changes: 0 additions & 2 deletions settings.gradle

This file was deleted.

1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "TransferTool"
Loading

0 comments on commit 9fa4c8f

Please sign in to comment.