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
1 change: 1 addition & 0 deletions bukkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
implementation project(":bukkit:simpleclans")
implementation project(":bukkit:playerpoints")
implementation project(":bukkit:multiverse")
implementation project(":bukkit:multiverse5")
implementation project(":bukkit:factionsuuid")
implementation project(":bukkit:factionsuuid05")
implementation project(":bukkit:factions")
Expand Down
39 changes: 39 additions & 0 deletions bukkit/multiverse5/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2016 Florian Stober
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

repositories {
maven {
url "https://repo.onarandombox.com/content/groups/public/"
}
}

// Multiverse-Core 5 is compiled for Java 17, so javac 8 cannot read it. Compile this module with
// a Java 17 toolchain but emit Java 8 bytecode, so the rest of the project - which is Java 8
// throughout - can still depend on it directly, and the produced classes load on any server.
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

tasks.withType(JavaCompile).configureEach {
options.release.set(8)
}

dependencies {
compileOnly "org.mvplugins.multiverse.core:multiverse-core:5.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2020 Florian Stober
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package de.codecrafter47.data.bukkit.multiverse;

import org.bukkit.entity.Player;
import org.mvplugins.multiverse.core.MultiverseCoreApi;
import org.mvplugins.multiverse.core.world.MultiverseWorld;
import org.mvplugins.multiverse.external.vavr.control.Option;

import java.util.function.Function;

/**
* World alias lookup for Multiverse-Core 5.x.
*
* <p>Multiverse 5 renamed its packages from {@code com.onarandombox.MultiverseCore} to
* {@code org.mvplugins.multiverse.core}, so {@code MultiverseWorldAliasProvider} - which targets
* the 4.x API - fails with {@code NoClassDefFoundError} on a Multiverse 5 server.
*
* <p>Uses {@code getAliasOrName()} rather than {@code getAlias()} so a world without an alias
* yields its name instead of an empty string.
*/
public class MultiverseWorldAliasProvider5 implements Function<Player, String> {

@Override
public String apply(Player player) {
Option<MultiverseWorld> world = MultiverseCoreApi.get().getWorldManager().getWorld(player.getWorld());
return world.isDefined() ? world.get().getAliasOrName() : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import de.codecrafter47.data.bukkit.factions.*;
import de.codecrafter47.data.bukkit.factionsuuid.*;
import de.codecrafter47.data.bukkit.multiverse.MultiverseWorldAliasProvider;
import de.codecrafter47.data.bukkit.multiverse.MultiverseWorldAliasProvider5;
import de.codecrafter47.data.bukkit.playerpoints.PlayerPointsProvider;
import de.codecrafter47.data.bukkit.simpleclans.*;
import de.codecrafter47.data.bukkit.supervanish.SuperVanishIsVanishedProvider;
Expand Down Expand Up @@ -171,7 +172,11 @@ protected void init() {
}

if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) {
addProvider(BukkitData.Multiverse_WorldAlias, new MultiverseWorldAliasProvider());
if (classExists("org.mvplugins.multiverse.core.MultiverseCoreApi")) {
addProvider(BukkitData.Multiverse_WorldAlias, new MultiverseWorldAliasProvider5());
} else {
addProvider(BukkitData.Multiverse_WorldAlias, new MultiverseWorldAliasProvider());
}
}

if (Bukkit.getPluginManager().getPlugin("ASkyBlock") != null) {
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ include 'bukkit:supervanish'
include 'bukkit:simpleclans'
include 'bukkit:playerpoints'
include 'bukkit:multiverse'
include 'bukkit:multiverse5'
include 'bukkit:factionsuuid'
include 'bukkit:factionsuuid05'
include 'bukkit:factions'
Expand Down