feat: reworked project structure, 1.20 to 1.21.1 mappings and more

This commit is contained in:
ineanto 2024-09-22 16:39:13 +02:00
parent b7be5ad54e
commit fd9676f6f5
Signed by: ineanto
GPG key ID: E511F9CAA2F9CE84
115 changed files with 1399 additions and 248 deletions

View file

@ -5,14 +5,16 @@
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="/usr/share/java/gradle" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/api" />
<option value="$PROJECT_DIR$/common" />
<option value="$PROJECT_DIR$/mappings" /> <option value="$PROJECT_DIR$/mappings" />
<option value="$PROJECT_DIR$/mappings/v1_20" /> <option value="$PROJECT_DIR$/mappings/v1_20" />
<option value="$PROJECT_DIR$/v1_20" /> <option value="$PROJECT_DIR$/mappings/v1_20_2" />
<option value="$PROJECT_DIR$/mappings/v1_20_4" />
<option value="$PROJECT_DIR$/mappings/v1_20_6" />
<option value="$PROJECT_DIR$/mappings/v1_21" />
</set> </set>
</option> </option>
</GradleProjectSettings> </GradleProjectSettings>

View file

@ -4,7 +4,7 @@
<component name="PWA"> <component name="PWA">
<option name="wasEnabledAtLeastOnce" value="true" /> <option name="wasEnabledAtLeastOnce" value="true" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="azul-17.0.10" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="graalvm-21.0.4" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View file

@ -1,16 +1,16 @@
1.2.0: Update n°13 (XX/XX/24) 1.2.0: Update n°12 (XX/XX/24)
[FEATURES] [FEATURES]
- Players are now able to save disguises as presets. - Players are now able to save disguises as presets.
- Modernized the messages and added various sound effects upon interacting with Nicko.
[FIXES] [FIXES]
- Fixed an oversight preventing the configuration from properly being migrated. - Fixed an oversight preventing the configuration from properly being migrated.
[LANGUAGE] [LANGUAGE]
- Moved the prefix to the language file. - Moved the prefix to the language file.
- Updated the language files to modernize the messages.
[OTHER] [OTHER]
- Dropped the release candidate status as Nicko is now considered stable. - Removed the ProtocolLib dependency, has Nicko being rewritten to use NMS until ProtocolLib has reworked its API.
1.1.7-RC1: Hotfix n°5 (04/05/24) 1.1.7-RC1: Hotfix n°5 (04/05/24)
[OTHER] [OTHER]

View file

@ -1,11 +0,0 @@
plugins {
id("java")
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

View file

@ -1,4 +0,0 @@
package xyz.ineanto.nicko.api;
public class NickoAPI {
}

View file

@ -1,6 +1,43 @@
plugins { plugins {
id("java") id("java")
id("io.github.goooler.shadow") version "8.1.7" id("com.gradleup.shadow") version "8.3.2"
id("xyz.jpenilla.run-paper") version "2.3.0"
}
allprojects {
group = "xyz.ineanto.nicko"
version = "1.2.0"
apply(plugin = "java")
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
mavenLocal()
maven { url = uri("https://jitpack.io") }
maven {
name = "xenondevs"
url = uri("https://repo.xenondevs.xyz/releases")
}
maven {
name = "papermc"
url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven {
name = "codemc"
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
}
maven {
name = "placeholderapi"
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}
}
} }
java { java {
@ -11,7 +48,98 @@ java {
} }
} }
allprojects { dependencies {
group = "xyz.ineanto.nicko" compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
version = "1.2.0" compileOnly("com.github.dmulloy2:ProtocolLib:master-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.11.5")
implementation("net.kyori:adventure-api:4.17.0")
implementation("xyz.xenondevs.invui:invui:1.35")
implementation("net.wesjd:anvilgui:1.10.1-SNAPSHOT")
implementation("com.github.jsixface:yamlconfig:1.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.2")
implementation("com.fasterxml.jackson.core:jackson-core:2.15.2")
implementation("com.mysql:mysql-connector-j:8.2.0")
implementation("org.mariadb.jdbc:mariadb-java-client:3.3.1")
implementation("redis.clients:jedis:5.1.2")
implementation("com.google.code.gson:gson:2.10.1")
implementation("org.bstats:bstats-bukkit:3.0.2")
implementation(project(":mappings"))
subprojects.forEach {
if (!it.name.startsWith("v")) return@forEach
implementation(project(":mappings:${it.name}"))
}
}
tasks {
processResources {
from("src/main/resources")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
filesMatching("*.yml") {
expand("version" to version)
}
}
shadowJar {
// NAMING
archiveBaseName.set("nicko")
archiveVersion.set(version.toString())
archiveAppendix.set("")
archiveClassifier.set("")
// RELOCATIONS
relocate("xyz.xenondevs", "xyz.ineanto.nicko.libs.invui")
relocate("me.clip", "xyz.ineanto.nicko.libs.placeholderapi")
relocate("net.wesjd", "xyz.ineanto.nicko.libs.anvilgui")
relocate("com.github.jsixface", "xyz.ineanto.nicko.libs.yaml")
relocate("com.fasterxml.jackson.dataformat", "xyz.ineanto.nicko.libs.jackson.yaml")
relocate("com.fasterxml.jackson.core", "xyz.ineanto.nicko.libs.jackson.core")
relocate("com.mysql", "xyz.ineanto.nicko.libs.mysql")
relocate("org.mariadb.jdbc", "xyz.ineanto.nicko.libs.mariadb")
relocate("redis.clients", "xyz.ineanto.nicko.libs.redis")
relocate("com.google.gson", "xyz.ineanto.nicko.libs.gson")
relocate("org.apache.commons.pool2", "xyz.ineanto.nicko.libs.pool2")
relocate("org.bstats", "xyz.ineanto.nicko.libs.bstats")
// EXCLUSIONS
exclude("colors.bin")
exclude("waffle/**")
exclude("com/sun/**")
exclude("com/google/protobuf/**")
exclude("com/google/errorprone/**")
exclude("org/apache/commons/logging/**")
exclude("org/jetbrains/**")
exclude("org/intellij/**")
exclude("org/checkerframework/**")
exclude("org/json/**")
exclude("org/slf4j/**")
exclude("org/yaml/**")
exclude("google/protobuf/**")
exclude("net/kyori/**")
// MINIFY
minimize {
exclude(dependency("xyz.xenondevs.invui:.*"))
exclude(dependency("net.wesjd:.*"))
exclude(dependency("org.bstats:.*"))
}
}
runServer {
dependsOn(shadowJar)
downloadPlugins {
url("https://download.luckperms.net/1554/bukkit/loader/LuckPerms-Bukkit-5.4.139.jar")
// 1.20 - 1.20.4 testing
//url("https://github.com/dmulloy2/ProtocolLib/releases/download/5.2.0/ProtocolLib.jar")
// 1.20.5 - latest testing
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
}
minecraftVersion("1.21.1")
}
} }

View file

@ -1,108 +0,0 @@
plugins {
id("java")
id("xyz.jpenilla.run-paper") version "2.3.0"
id("io.github.goooler.shadow") version "8.1.7"
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
compileOnly("com.github.dmulloy2:ProtocolLib:master-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.11.5")
compileOnly("net.kyori:adventure-api:4.17.0")
rootProject.subprojects.forEach {
if (!it.name.startsWith("v")) return@forEach
compileOnly(project(":mappings:${it.name}"))
}
implementation("xyz.xenondevs.invui:invui:1.35")
implementation("net.wesjd:anvilgui:1.10.1-SNAPSHOT")
implementation("com.github.jsixface:yamlconfig:1.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.2")
implementation("com.fasterxml.jackson.core:jackson-core:2.15.2")
implementation("com.mysql:mysql-connector-j:8.2.0")
implementation("org.mariadb.jdbc:mariadb-java-client:3.3.1")
implementation("redis.clients:jedis:5.1.2")
implementation("com.google.code.gson:gson:2.10.1")
implementation("org.bstats:bstats-bukkit:3.0.2")
}
tasks {
processResources {
from("src/main/resources")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
filesMatching("*.yml") {
expand("version" to version)
}
}
shadowJar {
// NAMING
archiveBaseName.set("nicko")
archiveVersion.set(version.toString())
archiveAppendix.set("")
archiveClassifier.set("")
// RELOCATIONS
relocate("xyz.xenondevs", "xyz.ineanto.nicko.libs.invui")
relocate("me.clip", "xyz.ineanto.nicko.libs.placeholderapi")
relocate("net.wesjd", "xyz.ineanto.nicko.libs.anvilgui")
relocate("com.github.jsixface", "xyz.ineanto.nicko.libs.yaml")
relocate("com.fasterxml.jackson.dataformat", "xyz.ineanto.nicko.libs.jackson.yaml")
relocate("com.fasterxml.jackson.core", "xyz.ineanto.nicko.libs.jackson.core")
relocate("com.mysql", "xyz.ineanto.nicko.libs.mysql")
relocate("org.mariadb.jdbc", "xyz.ineanto.nicko.libs.mariadb")
relocate("redis.clients", "xyz.ineanto.nicko.libs.redis")
relocate("com.google.gson", "xyz.ineanto.nicko.libs.gson")
relocate("org.apache.commons.pool2", "xyz.ineanto.nicko.libs.pool2")
relocate("org.bstats", "xyz.ineanto.nicko.libs.bstats")
// EXCLUSIONS
exclude("colors.bin")
exclude("waffle/**")
exclude("com/sun/**")
exclude("com/google/protobuf/**")
exclude("com/google/errorprone/**")
exclude("org/apache/commons/logging/**")
exclude("org/jetbrains/**")
exclude("org/intellij/**")
exclude("org/checkerframework/**")
exclude("org/json/**")
exclude("org/slf4j/**")
exclude("org/yaml/**")
exclude("google/protobuf/**")
exclude("net/kyori/**")
// MINIFY
minimize {
exclude(dependency("xyz.xenondevs.invui:.*"))
exclude(dependency("net.wesjd:.*"))
exclude(dependency("org.bstats:.*"))
}
}
runServer {
dependsOn(shadowJar)
downloadPlugins {
url("https://download.luckperms.net/1554/bukkit/loader/LuckPerms-Bukkit-5.4.139.jar")
// 1.20 - 1.20.4 testing
//url("https://github.com/dmulloy2/ProtocolLib/releases/download/5.2.0/ProtocolLib.jar")
// 1.20.5 - latest testing
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
}
minecraftVersion("1.21.1")
}
}

View file

@ -1,18 +0,0 @@
package xyz.ineanto.nicko.mapping;
import org.bukkit.entity.Player;
import xyz.ineanto.nicko.Nicko;
import xyz.ineanto.nicko.storage.PlayerDataStore;
import xyz.ineanto.nicko.storage.name.PlayerNameStore;
import java.util.Set;
public abstract class Mapping {
private final Nicko instance = Nicko.getInstance();
private final PlayerDataStore dataStore = instance.getDataStore();
private final PlayerNameStore nameStore = instance.getNameStore();
public abstract void respawn(Player player);
public abstract Set<String> supportedVersions();
}

View file

@ -1,20 +0,0 @@
package xyz.ineanto.nicko.mapping;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import xyz.ineanto.nicko.mapping.v1_20.Mapping1_20;
import java.util.List;
import java.util.Optional;
public class MappingManager {
private final List<Mapping> mappings = List.of(
new Mapping1_20()
);
public Optional<Mapping> getMappingFor(Server server) {
return mappings.stream()
.filter(mapping -> mapping.supportedVersions().contains(Bukkit.getMinecraftVersion()))
.findFirst();
}
}

Binary file not shown.

View file

@ -1,6 +1,7 @@
#Mon Dec 11 00:36:17 CET 2023
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

41
gradlew vendored
View file

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (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/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@ -80,13 +80,11 @@ do
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # This is normally unused
# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@ -133,22 +131,29 @@ location of your Java installation."
fi fi
else else
JAVACMD=java JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
# shell script including quotes and variable substitutions, so put them in DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded. # Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \
@ -205,6 +214,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ 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. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

35
gradlew.bat vendored
View file

@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

10
mappings/DISCLAIMER.md Normal file
View file

@ -0,0 +1,10 @@
For full transparency, the following project structure
and code are __heavily__ inspired by SkinRestorer.
I made some slight tweaking here and there, but credit where credit is due.
```
SkinsRestorer Copyright (C) 2021-2024 SRTeam
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
```

View file

@ -0,0 +1,7 @@
plugins {
id("java")
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
}

View file

@ -0,0 +1,11 @@
package xyz.ineanto.nicko.mapping;
import org.bukkit.entity.Player;
import java.util.Set;
public abstract class Mapping {
public abstract void respawn(Player player);
public abstract Set<String> supportedVersions();
}

View file

@ -5,5 +5,5 @@ plugins {
dependencies { dependencies {
paperweight.paperDevBundle("1.20-R0.1-SNAPSHOT") paperweight.paperDevBundle("1.20-R0.1-SNAPSHOT")
implementation(project(":common")) compileOnly(project(":mappings"))
} }

View file

@ -17,13 +17,9 @@ import java.util.List;
import java.util.Set; import java.util.Set;
public class Mapping1_20 extends Mapping { public class Mapping1_20 extends Mapping {
@Override @Override
public void respawn(Player player) { public void respawn(Player player) {
final ServerPlayer entityPlayer = (ServerPlayer) player;
final ServerLevel world = entityPlayer.serverLevel();
final ServerPlayerGameMode gameMode = entityPlayer.gameMode;
// Really Mojang...? (also applies to Bukkit/Spigot maintainers) // Really Mojang...? (also applies to Bukkit/Spigot maintainers)
// I'll have to do this everytime I want to update Nicko for the foreseeable future. // I'll have to do this everytime I want to update Nicko for the foreseeable future.
// (until ProtocolLib has reworked its API to be more maintainable that said) // (until ProtocolLib has reworked its API to be more maintainable that said)
@ -36,12 +32,18 @@ public class Mapping1_20 extends Mapping {
// I can't be bothered with fighting your game anymore. // I can't be bothered with fighting your game anymore.
// We need an easy and reliable way to send packets across multiple server versions. // We need an easy and reliable way to send packets across multiple server versions.
// And I know that this is easier said than done, the game protocol needs // And I know that this is easier said than done, the game protocol needs
// to evolve and be updated, I get it. But I think you can at least try. // to evolve and be updated, I get it.
// But I think you can at least try.
// You made a step forward by providing the mappings for Java, this I can agree with. // You made a step forward by providing the mappings for Java, this I can agree with.
// (and still stripped them from Bedrock against community feedback, haha f*ck you.) // (and still stripped them from Bedrock against community feedback, haha f*ck you.)
// However, we still need a stable and reliable Packet API (and so much more!) one day. // However, we still need a stable and reliable Packet API (and so much more!) one day.
final ServerPlayer entityPlayer = (ServerPlayer) player;
final ServerLevel world = entityPlayer.serverLevel();
final ServerPlayerGameMode gameMode = entityPlayer.gameMode;
final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket( final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(
world.dimensionTypeId(), world.dimensionTypeId(),
world.dimension(), world.dimension(),
@ -70,7 +72,6 @@ public class Mapping1_20 extends Mapping {
playerList.sendLevelInfo(entityPlayer, world); playerList.sendLevelInfo(entityPlayer, world);
playerList.sendAllPlayerInfo(entityPlayer); playerList.sendAllPlayerInfo(entityPlayer);
// Resend their effects
for (MobEffectInstance effect : entityPlayer.getActiveEffects()) { for (MobEffectInstance effect : entityPlayer.getActiveEffects()) {
entityPlayer.connection.send(new ClientboundUpdateMobEffectPacket(entityPlayer.getId(), effect)); entityPlayer.connection.send(new ClientboundUpdateMobEffectPacket(entityPlayer.getId(), effect));
} }

View file

@ -0,0 +1,9 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.2"
}
dependencies {
paperweight.paperDevBundle("1.20.2-R0.1-SNAPSHOT")
compileOnly(project(":mappings"))
}

View file

@ -0,0 +1,54 @@
package xyz.ineanto.nicko.mapping.v1_20_2;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundRespawnPacket;
import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.effect.MobEffectInstance;
import org.bukkit.entity.Player;
import xyz.ineanto.nicko.mapping.Mapping;
import java.util.List;
import java.util.Set;
public class Mapping1_20_2 extends Mapping {
@Override
public void respawn(Player player) {
final ServerPlayer entityPlayer = (ServerPlayer) player;
final ServerLevel world = entityPlayer.serverLevel();
final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(
entityPlayer.createCommonSpawnInfo(world),
ClientboundRespawnPacket.KEEP_ALL_DATA
);
entityPlayer.connection.send(new ClientboundPlayerInfoRemovePacket(List.of(player.getUniqueId())));
entityPlayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityPlayer)));
entityPlayer.connection.send(respawn);
entityPlayer.onUpdateAbilities();
entityPlayer.connection.teleport(player.getLocation());
entityPlayer.resetSentInfo();
final PlayerList playerList = entityPlayer.server.getPlayerList();
playerList.sendPlayerPermissionLevel(entityPlayer);
playerList.sendLevelInfo(entityPlayer, world);
playerList.sendAllPlayerInfo(entityPlayer);
for (MobEffectInstance effect : entityPlayer.getActiveEffects()) {
entityPlayer.connection.send(new ClientboundUpdateMobEffectPacket(entityPlayer.getId(), effect));
}
}
@Override
public Set<String> supportedVersions() {
return Set.of("1.20.2", "1.20.3");
}
}

View file

@ -0,0 +1,9 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.2"
}
dependencies {
paperweight.paperDevBundle("1.20.4-R0.1-SNAPSHOT")
compileOnly(project(":mappings"))
}

View file

@ -0,0 +1,54 @@
package xyz.ineanto.nicko.mapping.v1_20_4;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundRespawnPacket;
import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.effect.MobEffectInstance;
import org.bukkit.entity.Player;
import xyz.ineanto.nicko.mapping.Mapping;
import java.util.List;
import java.util.Set;
public class Mapping1_20_4 extends Mapping {
@Override
public void respawn(Player player) {
final ServerPlayer entityPlayer = (ServerPlayer) player;
final ServerLevel world = entityPlayer.serverLevel();
final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(
entityPlayer.createCommonSpawnInfo(world),
ClientboundRespawnPacket.KEEP_ALL_DATA
);
entityPlayer.connection.send(new ClientboundPlayerInfoRemovePacket(List.of(player.getUniqueId())));
entityPlayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityPlayer)));
entityPlayer.connection.send(respawn);
entityPlayer.onUpdateAbilities();
entityPlayer.connection.teleport(player.getLocation());
entityPlayer.resetSentInfo();
final PlayerList playerList = entityPlayer.server.getPlayerList();
playerList.sendPlayerPermissionLevel(entityPlayer);
playerList.sendLevelInfo(entityPlayer, world);
playerList.sendAllPlayerInfo(entityPlayer);
for (MobEffectInstance effect : entityPlayer.getActiveEffects()) {
entityPlayer.connection.send(new ClientboundUpdateMobEffectPacket(entityPlayer.getId(), effect));
}
}
@Override
public Set<String> supportedVersions() {
return Set.of("1.20.4", "1.20.5");
}
}

View file

@ -0,0 +1,9 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.2"
}
dependencies {
paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT")
compileOnly(project(":mappings"))
}

View file

@ -0,0 +1,53 @@
package xyz.ineanto.nicko.mapping.v1_20_6;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundRespawnPacket;
import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.effect.MobEffectInstance;
import org.bukkit.entity.Player;
import xyz.ineanto.nicko.mapping.Mapping;
import java.util.List;
import java.util.Set;
public class Mapping1_20_6 extends Mapping {
@Override
public void respawn(Player player) {
final ServerPlayer entityPlayer = (ServerPlayer) player;
final ServerLevel world = entityPlayer.serverLevel();
final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(
entityPlayer.createCommonSpawnInfo(world),
ClientboundRespawnPacket.KEEP_ALL_DATA
);
entityPlayer.connection.send(new ClientboundPlayerInfoRemovePacket(List.of(player.getUniqueId())));
entityPlayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityPlayer)));
entityPlayer.connection.send(respawn);
entityPlayer.onUpdateAbilities();
entityPlayer.connection.teleport(player.getLocation());
entityPlayer.resetSentInfo();
final PlayerList playerList = entityPlayer.server.getPlayerList();
playerList.sendPlayerPermissionLevel(entityPlayer);
playerList.sendLevelInfo(entityPlayer, world);
playerList.sendAllPlayerInfo(entityPlayer);
for (MobEffectInstance effect : entityPlayer.getActiveEffects()) {
entityPlayer.connection.send(new ClientboundUpdateMobEffectPacket(entityPlayer.getId(), effect, true));
}
}
@Override
public Set<String> supportedVersions() {
return Set.of("1.20.6");
}
}

View file

@ -0,0 +1,9 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.7.2"
}
dependencies {
paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT")
compileOnly(project(":mappings"))
}

View file

@ -0,0 +1,53 @@
package xyz.ineanto.nicko.mapping.v1_21;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundRespawnPacket;
import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.effect.MobEffectInstance;
import org.bukkit.entity.Player;
import xyz.ineanto.nicko.mapping.Mapping;
import java.util.List;
import java.util.Set;
public class Mapping1_21 extends Mapping {
@Override
public void respawn(Player player) {
final ServerPlayer entityPlayer = (ServerPlayer) player;
final ServerLevel world = entityPlayer.serverLevel();
final ClientboundRespawnPacket respawn = new ClientboundRespawnPacket(
entityPlayer.createCommonSpawnInfo(world),
ClientboundRespawnPacket.KEEP_ALL_DATA
);
entityPlayer.connection.send(new ClientboundPlayerInfoRemovePacket(List.of(player.getUniqueId())));
entityPlayer.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityPlayer)));
entityPlayer.connection.send(respawn);
entityPlayer.onUpdateAbilities();
entityPlayer.connection.teleport(player.getLocation());
entityPlayer.resetSentInfo();
final PlayerList playerList = entityPlayer.server.getPlayerList();
playerList.sendPlayerPermissionLevel(entityPlayer);
playerList.sendLevelInfo(entityPlayer, world);
playerList.sendAllPlayerInfo(entityPlayer);
for (MobEffectInstance effect : entityPlayer.getActiveEffects()) {
entityPlayer.connection.send(new ClientboundUpdateMobEffectPacket(entityPlayer.getId(), effect, true));
}
}
@Override
public Set<String> supportedVersions() {
return Set.of("1.21", "1.21.1");
}
}

View file

@ -1,34 +1,9 @@
rootProject.name = "nicko" rootProject.name = "nicko"
include(":mappings")
setOf( setOf(
"1_20" "1_20", "1_20_2", "1_20_4", "1_20_6",
"1_21"
).forEach { ).forEach {
include("mappings:v$it") include(":mappings:v$it")
} }
include("common", "api")
dependencyResolutionManagement {
repositories {
mavenCentral()
mavenLocal()
maven { url = uri("https://jitpack.io") }
maven {
name = "xenondevs"
url = uri("https://repo.xenondevs.xyz/releases")
}
maven {
name = "papermc"
url = uri("https://repo.papermc.io/repository/maven-public/")
}
maven {
name = "codemc"
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
}
maven {
name = "placeholderapi"
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}
}
}
include("v1_20")

View file

@ -14,6 +14,7 @@ import xyz.ineanto.nicko.event.PlayerJoinListener;
import xyz.ineanto.nicko.event.PlayerQuitListener; import xyz.ineanto.nicko.event.PlayerQuitListener;
import xyz.ineanto.nicko.language.CustomLanguage; import xyz.ineanto.nicko.language.CustomLanguage;
import xyz.ineanto.nicko.language.Language; import xyz.ineanto.nicko.language.Language;
import xyz.ineanto.nicko.mapping.MappingManager;
import xyz.ineanto.nicko.migration.ConfigurationMigrator; import xyz.ineanto.nicko.migration.ConfigurationMigrator;
import xyz.ineanto.nicko.migration.CustomLocaleMigrator; import xyz.ineanto.nicko.migration.CustomLocaleMigrator;
import xyz.ineanto.nicko.mojang.MojangAPI; import xyz.ineanto.nicko.mojang.MojangAPI;
@ -40,6 +41,7 @@ public class Nicko extends JavaPlugin {
private CustomLanguage customLanguage; private CustomLanguage customLanguage;
private PlayerNameStore nameStore; private PlayerNameStore nameStore;
private RandomNameFetcher nameFetcher; private RandomNameFetcher nameFetcher;
private MappingManager mappingManager;
private Metrics metrics; private Metrics metrics;
public Nicko() { public Nicko() {
@ -63,8 +65,9 @@ public class Nicko extends JavaPlugin {
configurationManager.saveDefaultConfig(); configurationManager.saveDefaultConfig();
dataStore = new PlayerDataStore(mojangAPI, getNickoConfig()); dataStore = new PlayerDataStore(mojangAPI, getNickoConfig());
mappingManager = new MappingManager();
if (!MinecraftVersion.TRAILS_AND_TAILS.atOrAbove()) { if (!MinecraftVersion.TRAILS_AND_TAILS.atOrAbove() || mappingManager.getMappingForServer().isEmpty()) {
getLogger().severe("This version (" + MinecraftVersion.getCurrentVersion().getVersion() + ") is not supported by Nicko!"); getLogger().severe("This version (" + MinecraftVersion.getCurrentVersion().getVersion() + ") is not supported by Nicko!");
getLogger().severe("As of version 1.0.7, Nicko only supports the latest two majors Minecraft versions. (Currently 1.20.X-1.21.X)"); getLogger().severe("As of version 1.0.7, Nicko only supports the latest two majors Minecraft versions. (Currently 1.20.X-1.21.X)");
dataStore.getStorage().setError(true); dataStore.getStorage().setError(true);
@ -116,7 +119,7 @@ public class Nicko extends JavaPlugin {
} }
} }
final PluginCommand command = getCommand("nicko"); final PluginCommand command = getCommand("xyz/ineanto/nicko");
if (command != null) { if (command != null) {
command.setExecutor(new NickoCommand()); command.setExecutor(new NickoCommand());
} }
@ -198,4 +201,8 @@ public class Nicko extends JavaPlugin {
public CustomLanguage getCustomLocale() { public CustomLanguage getCustomLocale() {
return customLanguage; return customLanguage;
} }
public MappingManager getMappingManager() {
return mappingManager;
}
} }

View file

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import xyz.ineanto.nicko.Nicko; import xyz.ineanto.nicko.Nicko;
import xyz.ineanto.nicko.language.LanguageKey; import xyz.ineanto.nicko.language.LanguageKey;
import xyz.ineanto.nicko.mapping.Mapping;
import xyz.ineanto.nicko.mojang.MojangAPI; import xyz.ineanto.nicko.mojang.MojangAPI;
import xyz.ineanto.nicko.mojang.MojangSkin; import xyz.ineanto.nicko.mojang.MojangSkin;
import xyz.ineanto.nicko.profile.NickoProfile; import xyz.ineanto.nicko.profile.NickoProfile;
@ -58,7 +59,7 @@ public class AppearanceManager {
if (!result.isError()) { if (!result.isError()) {
updateMetadata(); updateMetadata();
updateTabList(gameProfile, displayName); updateTabList(gameProfile, displayName);
respawnPlayer(); respawnPlayerViaMappings();
respawnEntityForOthers(); respawnEntityForOthers();
} }
return result; return result;
@ -140,7 +141,14 @@ public class AppearanceManager {
entityWatcher.setObject(17, (byte) 0x7f, true); entityWatcher.setObject(17, (byte) 0x7f, true);
} }
private void respawnPlayer() { private void respawnPlayerViaMappings() {
final Optional<Mapping> mapping = instance.getMappingManager().getMappingForServer();
if (mapping.isEmpty()) return;
mapping.get().respawn(player);
}
@Deprecated
private void respawnPlayerViaProtocolLib() {
final World world = player.getWorld(); final World world = player.getWorld();
final boolean wasFlying = player.isFlying(); final boolean wasFlying = player.isFlying();
final boolean wasAllowedToFly = player.getAllowFlight(); final boolean wasAllowedToFly = player.getAllowFlight();

View file

@ -5,8 +5,8 @@ import xyz.ineanto.nicko.gui.items.appearance.ChangeBothItem;
import xyz.ineanto.nicko.gui.items.appearance.ChangeNameItem; import xyz.ineanto.nicko.gui.items.appearance.ChangeNameItem;
import xyz.ineanto.nicko.gui.items.appearance.ChangeSkinItem; import xyz.ineanto.nicko.gui.items.appearance.ChangeSkinItem;
import xyz.ineanto.nicko.gui.items.home.*; import xyz.ineanto.nicko.gui.items.home.*;
import xyz.ineanto.nicko.language.PlayerLanguage;
import xyz.ineanto.nicko.language.LanguageKey; import xyz.ineanto.nicko.language.LanguageKey;
import xyz.ineanto.nicko.language.PlayerLanguage;
import xyz.xenondevs.invui.gui.Gui; import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.window.Window; import xyz.xenondevs.invui.window.Window;

View file

@ -0,0 +1,27 @@
package xyz.ineanto.nicko.mapping;
import org.bukkit.Bukkit;
import xyz.ineanto.nicko.mapping.v1_20.Mapping1_20;
import xyz.ineanto.nicko.mapping.v1_20_2.Mapping1_20_2;
import xyz.ineanto.nicko.mapping.v1_20_4.Mapping1_20_4;
import xyz.ineanto.nicko.mapping.v1_20_6.Mapping1_20_6;
import xyz.ineanto.nicko.mapping.v1_21.Mapping1_21;
import java.util.List;
import java.util.Optional;
public class MappingManager {
private final List<Mapping> mappings = List.of(
new Mapping1_20(),
new Mapping1_20_2(),
new Mapping1_20_4(),
new Mapping1_20_6(),
new Mapping1_21()
);
public Optional<Mapping> getMappingForServer() {
return mappings.stream()
.filter(mapping -> mapping.supportedVersions().contains(Bukkit.getMinecraftVersion()))
.findFirst();
}
}

View file

@ -19,7 +19,7 @@ public class NickoExpansion extends PlaceholderExpansion {
@Override @Override
public @NotNull String getIdentifier() { public @NotNull String getIdentifier() {
return "nicko"; return "xyz/ineanto/nicko";
} }
@Override @Override

View file

@ -16,7 +16,7 @@ public class MariaDBStorageProvider implements StorageProvider {
private Connection connection; private Connection connection;
private final String schemaName = "nicko"; private final String schemaName = "xyz/ineanto/nicko";
public MariaDBStorageProvider(Configuration configuration) { public MariaDBStorageProvider(Configuration configuration) {
this.configuration = configuration; this.configuration = configuration;

View file

@ -16,7 +16,7 @@ public class MySQLStorageProvider implements StorageProvider {
private Connection connection; private Connection connection;
private final String schemaName = "nicko"; private final String schemaName = "xyz/ineanto/nicko";
public MySQLStorageProvider(Configuration configuration) { public MySQLStorageProvider(Configuration configuration) {
this.configuration = configuration; this.configuration = configuration;

Some files were not shown because too many files have changed in this diff Show more