Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.21.1 and 1.21.3 support #104

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ but does not necessarily have to.

## World Interaction

Load chunks asynchronously using PaperLib whenever possible.
Load chunks asynchronously whenever possible.

## Dependency Injection

Expand Down
3 changes: 1 addition & 2 deletions THIRD-PARTY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Lists of 29 third-party dependencies.
Lists of 28 third-party dependencies.
- (Public Domain) [AOP alliance (aopalliance:aopalliance:1.0)](http://aopalliance.sourceforge.net)
- (MIT) [DelegatingMap (co.aikar:DelegatingMap:1.0.0-20180331.052245-5)]()
- (MIT) [Table (co.aikar:Table:1.0.0-20180331.054128-7)]()
Expand All @@ -16,7 +16,6 @@ Lists of 29 third-party dependencies.
- (ISC License) [ORMLite JDBC (com.j256.ormlite:ormlite-jdbc:5.1)](http://ormlite.sourceforge.net/)
- (Apache License, Version 2.0) [config (com.typesafe:config:1.3.1)](https://github.com/typesafehub/config)
- (The Apache Software License, Version 2.0) [Commons Lang (commons-lang:commons-lang:2.6)](http://commons.apache.org/lang/)
- (MIT) [PaperLib (io.papermc:paperlib:1.0.2)](https://github.com/PaperMC/PaperLib)
- (The Apache Software License, Version 2.0) [javax.inject (javax.inject:javax.inject:1)](http://code.google.com/p/atinject/)
- (MIT) [MiniMessage (me.minidigger:MiniMessage:1.0.1)](https://github.com/MiniDigger/MiniMessage)
- (Apache License, Version 2.0) [ExpiringMap (net.jodah:expiringmap:0.5.8)](http://github.com/jhalterman/expiringmap/)
Expand Down
8 changes: 3 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ cloud-build-logic = "0.0.3"
ktlint = "0.50.0"
checkstyle = "10.12.5"
kotlin = "1.9.20"
shadow = "8.1.1"
shadow = "8.3.5"
paperweight = "1.7.1"
run-paper = "2.3.0"
pluginyml = "0.6.0"

# Platforms
minecraft = "1.17.1-R0.1-SNAPSHOT"
minecraft = "1.18.2-R0.1-SNAPSHOT"

# Libraries
cloud = "1.8.4"
guice = "5.1.0"
paperlib = "1.0.8"
taskchain = "3.7.2"
bstats = "3.0.2"
configurate = "4.1.2"
Expand All @@ -38,7 +37,6 @@ cloudMinecraftExtras = { group = "cloud.commandframework", name = "cloud-minecra
cloudAnnotations = { group = "cloud.commandframework", name = "cloud-annotations", version.ref = "cloud" }
guice = { group = "com.google.inject", name = "guice", version.ref = "guice" }
assistedInject = { group = "com.google.inject.extensions", name = "guice-assistedinject", version.ref = "guice" }
paperlib = { group = "io.papermc", name = "paperlib", version.ref = "paperlib"}
taskchain = { group = "co.aikar", name = "taskchain-bukkit", version.ref = "taskchain" }
bstats = { group = "org.bstats", name = "bstats-bukkit", version.ref = "bstats" }
configurateHocon = { group = "org.spongepowered", name = "configurate-hocon", version.ref = "configurate"}
Expand All @@ -54,6 +52,6 @@ paperweight-userdev = { id = "io.papermc.paperweight.userdev", version.ref = "pa
cloud-buildLogic-spotless = { id = "org.incendo.cloud-build-logic.spotless", version.ref = "cloud-build-logic" }
cloud-buildLogic-rootProject-publishing = { id = "org.incendo.cloud-build-logic.publishing.root-project", version.ref = "cloud-build-logic" }
cloud-buildLogic-rootProject-spotless = { id = "org.incendo.cloud-build-logic.spotless.root-project", version.ref = "cloud-build-logic" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
run-paper = { id = "xyz.jpenilla.run-paper", version.ref = "run-paper" }
pluginyml = { id = "net.minecrell.plugin-yml.bukkit", version.ref = "pluginyml" }
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,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# 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"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
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
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
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
# shellcheck disable=SC2039,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
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# 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
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# 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, 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 -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
24 changes: 10 additions & 14 deletions hyperverse-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dependencies {
// TODO: Remove, because yuck.
implementation("co.aikar:acf-paper:0.5.1-SNAPSHOT")
implementation(libs.taskchain)
implementation(libs.paperlib)
implementation(libs.guice) {
exclude("com.google.guava", "guava")
}
Expand All @@ -37,16 +36,8 @@ dependencies {
implementation(libs.configurateHocon)
implementation(libs.cloudPaper)
implementation(libs.cloudMinecraftExtras)
implementation(libs.cloudMinecraftExtras)

// TODO: Remove and use native versions.
implementation("net.kyori:adventure-platform-bukkit:4.3.2")
implementation("net.kyori:adventure-text-minimessage:4.14.0")

implementation(projects.hyperverseNmsUnsupported)
runtimeOnly(project(":hyperverse-nms-1-17")) {
targetConfiguration = "reobf"
}
runtimeOnly(project(":hyperverse-nms-1-18")) {
targetConfiguration = "reobf"
}
Expand All @@ -62,6 +53,12 @@ dependencies {
runtimeOnly(project(":hyperverse-nms-1-21")) {
targetConfiguration = "reobf"
}
runtimeOnly(project(":hyperverse-nms-1-21-1")) {
targetConfiguration = "reobf"
}
runtimeOnly(project(":hyperverse-nms-1-21-3")) {
targetConfiguration = "reobf"
}
}

bukkit {
Expand All @@ -70,7 +67,7 @@ bukkit {
authors = listOf("Citymonstret", "andrewandy")
main = "org.incendo.hyperverse.Hyperverse"
softDepend = listOf("Essentials", "Multiverse", "MyWorlds")
apiVersion = "1.14"
apiVersion = "1.18"
permissions {
mapOf(
"worlds" to "Allows players to use the Hyperverse command",
Expand Down Expand Up @@ -117,12 +114,13 @@ tasks {
shadowJar {
minimize {
exclude(project(":hyperverse-nms-unsupported"))
exclude(project(":hyperverse-nms-1-17"))
exclude(project(":hyperverse-nms-1-18"))
exclude(project(":hyperverse-nms-1-19"))
exclude(project(":hyperverse-nms-1-20"))
exclude(project(":hyperverse-nms-1-20-6"))
exclude(project(":hyperverse-nms-1-21"))
exclude(project(":hyperverse-nms-1-21-1"))
exclude(project(":hyperverse-nms-1-21-3"))
}
mergeServiceFiles()

Expand All @@ -132,14 +130,12 @@ tasks {
}
}

relocate("io.papermc.lib", "org.incendo.hyperverse.libs.paperlib")
relocate("org.bstats", "org.incendo.hyperverse.libs.bstats")
relocate("co.aikar.commands", "org.incendo.hyperverse.libs.aikar.commands")
relocate("co.aikar.locales", "org.incendo.hyperverse.libs.aikar.locales")
relocate("co.aikar.taskchain", "org.incendo.hyperverse.libs.taskchain")
relocate("co.aikar.util", "org.incendo.hyperverse.libs.aikar.util")
relocate("net.jodah.expiringmap", "org.incendo.hyperverse.libs.expiringmap")
relocate("net.kyori", "org.incendo.hyperverse.libs.kyori")
relocate("cloud.commandframework", "org.incendo.hyperverse.libs.cloud")
relocate("org.spongepowered.configurate", "org.incendo.hyperverse.libs.configurate")
relocate("io.leangen.geantyref", "org.incendo.hyperverse.libs.geantyref")
Expand All @@ -160,6 +156,6 @@ tasks {

runServer {
java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))
minecraftVersion("1.21")
minecraftVersion("1.21.3")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.google.inject.Stage;
import io.leangen.geantyref.GenericTypeReflector;
import io.leangen.geantyref.TypeToken;
import io.papermc.lib.PaperLib;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -98,7 +97,9 @@ public final class Hyperverse extends JavaPlugin implements HyperverseAPI, Liste
Version.parseMinecraft("1.19.4"),
Version.parseMinecraft("1.20.4"),
Version.parseMinecraft("1.20.6"),
Version.parseMinecraft("1.21")
Version.parseMinecraft("1.21"),
Version.parseMinecraft("1.21.1"),
Version.parseMinecraft("1.21.3")
);

private WorldManager worldManager;
Expand Down Expand Up @@ -136,7 +137,7 @@ public void onEnable() {
}
Version currentMcVersion = VersionUtil.parseMinecraftVersion(Bukkit.getBukkitVersion());
if (!this.supportedVersions.contains(currentMcVersion)) {
throw new UnsupportedOperationException("Current mc version: " + currentMcVersion + "is not supported");
throw new UnsupportedOperationException("Current mc version: " + currentMcVersion + " is not supported");
}
PlatformProvider platformProvider = new ReflectionPlatformProvider(currentMcVersion);
try {
Expand Down Expand Up @@ -235,10 +236,6 @@ public void onEnable() {

// Initialize bStats metrics tracking
new Metrics(this, BSTATS_ID);

// Add paper suggestion
PaperLib.suggestPaper(this);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

package org.incendo.hyperverse.listeners;

import com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent;
import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
import com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import io.papermc.lib.PaperLib;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
Expand Down Expand Up @@ -71,6 +73,7 @@
import org.incendo.hyperverse.database.PersistentLocation;
import org.incendo.hyperverse.events.PlayerSeekSpawnEvent;
import org.incendo.hyperverse.events.PlayerSetSpawnEvent;
import org.incendo.hyperverse.flags.implementation.AdvancementFlag;
import org.incendo.hyperverse.flags.implementation.CreatureSpawnFlag;
import org.incendo.hyperverse.flags.implementation.EndFlag;
import org.incendo.hyperverse.flags.implementation.GamemodeFlag;
Expand Down Expand Up @@ -127,10 +130,6 @@ public EventListener(
this.scheduler = scheduler;
this.plugin = plugin;
this.nms = nms;
// Register pre-spawn listeners
if (PaperLib.isPaper()) {
pluginManager.registerEvents(new PaperListener(this.worldManager), plugin);
}
}

/**
Expand Down Expand Up @@ -201,7 +200,7 @@ public void onTeleport(final @NonNull PlayerTeleportEvent event) {
}
}
this.nms.writePlayerData(event.getPlayer(), oldWorldDirectory.resolve(
String.format("%s.nbt", event.getPlayer().getUniqueId().toString())));
String.format("%s.nbt", event.getPlayer().getUniqueId())));
}
}
}
Expand Down Expand Up @@ -245,7 +244,7 @@ public void onWorldChange(final @NonNull PlayerChangedWorldEvent event) {
}
}
final Path playerData = newWorldDirectory
.resolve(String.format("%s.nbt", player.getUniqueId().toString()));
.resolve(String.format("%s.nbt", player.getUniqueId()));
if (Files.exists(playerData)) {
final GameMode originalGameMode = player.getGameMode();
this.nms.readPlayerData(event.getPlayer(), playerData,
Expand Down Expand Up @@ -472,14 +471,12 @@ public void onEntityPortalEnter(final @NonNull EntityPortalEnterEvent event) {
if (location != null) {
this.teleportationTimeout
.put(event.getEntity().getUniqueId(), System.currentTimeMillis());
PaperLib.teleportAsync(event.getEntity(), location,
PlayerTeleportEvent.TeleportCause.COMMAND
);
event.getEntity().teleportAsync(location, PlayerTeleportEvent.TeleportCause.COMMAND);
} else {
this.plugin.getLogger().warning(String
.format(
"Failed to find/create a portal surrounding %s",
destination.toString()
destination
));
}
}
Expand All @@ -497,9 +494,7 @@ public void onEntityPortalEnter(final @NonNull EntityPortalEnterEvent event) {
final Location destination =
hyperWorld.getTeleportationManager().endDestination(event.getEntity());
if (destination != null) {
PaperLib.teleportAsync(event.getEntity(), destination,
PlayerTeleportEvent.TeleportCause.COMMAND
);
event.getEntity().teleportAsync(destination, PlayerTeleportEvent.TeleportCause.COMMAND);
}
}
}
Expand Down Expand Up @@ -585,4 +580,43 @@ public void onSleep(final @NonNull PlayerBedEnterEvent event) {
), true, false);
}

@EventHandler
public void onEntityPreSpawn(final @NonNull PreCreatureSpawnEvent event) {
final HyperWorld hyperWorld = this.worldManager.getWorld(event.getSpawnLocation().getWorld());
if (hyperWorld == null) {
return;
}
if (hyperWorld.getFlag(CreatureSpawnFlag.class)) {
return;
}
if (event.getReason() != CreatureSpawnEvent.SpawnReason.NATURAL) {
return;
}
event.setCancelled(true);
event.setShouldAbortSpawn(true);
}

@EventHandler
public void onMobPreSpawn(final @NonNull PlayerNaturallySpawnCreaturesEvent event) {
final HyperWorld hyperWorld = this.worldManager.getWorld(event.getPlayer().getWorld());
if (hyperWorld == null) {
return;
}
if (hyperWorld.getFlag(MobSpawnFlag.class)) {
return;
}
event.setCancelled(true);
}

@EventHandler
public void onAdvancementGrant(final @NonNull PlayerAdvancementCriterionGrantEvent event) {
final HyperWorld hyperWorld = this.worldManager.getWorld(event.getPlayer().getWorld());
if (hyperWorld == null) {
return;
}
if (hyperWorld.getFlag(AdvancementFlag.class)) {
return;
}
event.setCancelled(true);
}
}
Loading