Skip to content
Merged

V5.8 #3500

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
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
}

// PlaceholderAPI
externalPlugin 'me.clip:placeholderapi:2.11.6'
externalPlugin 'me.clip:placeholderapi:2.12.3'

// Command Framework
shadowed 'co.aikar:acf-paper:0.5.1-SNAPSHOT'
Expand All @@ -48,7 +48,7 @@ dependencies {
}

// Utils
shadowed 'io.vavr:vavr:0.10.7'
shadowed 'io.vavr:vavr:1.0.1'
shadowed 'org.glassfish.hk2:hk2-locator:3.1.1'
shadowed('org.glassfish.hk2:hk2-inhabitant-generator:3.1.1') {
exclude group: 'org.apache.maven', module: 'maven-core'
Expand All @@ -57,11 +57,11 @@ dependencies {
exclude group: 'junit', module: 'junit'
}
shadowed 'de.themoep.idconverter:mappings:1.2-SNAPSHOT'
shadowed('org.bstats:bstats-bukkit:3.1.0') {
shadowed('org.bstats:bstats-bukkit:3.2.1') {
exclude group: 'org.bukkit', module: 'bukkit'
}
shadowed 'net.minidev:json-smart:2.5.2'
shadowed 'org.jetbrains:annotations:26.0.2'
shadowed 'net.minidev:json-smart:2.6.0'
shadowed 'org.jetbrains:annotations:26.1.0'
shadowed 'io.papermc:paperlib:1.0.8'

// Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ public void onEnable() {
SpawnCategoryMapper.buildSpawnCategoryMap();

// Initialize the worlds
worldManagerProvider.get().initAllWorlds().andThenTry(() -> {
Try.run(() -> {
setUpLocales();
worldManagerProvider.get().initAllWorlds();
loadEconomist(); // Setup economy here so vault is loaded
loadAnchors();
registerDynamicListeners(CoreListener.class);
setUpLocales();
registerCommands(CoreCommand.class);
registerDestinations();
setupMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public boolean persist() {
@Override
public @Nullable String onRequest(OfflinePlayer offlinePlayer, @NotNull String params) {
// Split string in to an Array with underscores
List<String> paramsArray = Lists.newArrayList(REPatterns.UNDERSCORE.split(params));
List<String> paramsArray = Lists.newArrayList(
StringFormatter.parseQuotesInArgs(REPatterns.UNDERSCORE.split(params), "_"));

// No placeholder defined
if (paramsArray.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import co.aikar.commands.PaperCommandManager;
import co.aikar.commands.RootCommand;
import com.dumptruckman.minecraft.util.Logging;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.inject.Inject;
import jakarta.inject.Provider;
import org.bukkit.Bukkit;
Expand All @@ -24,6 +26,7 @@
import org.mvplugins.multiverse.core.command.queue.CommandQueueManager;
import org.mvplugins.multiverse.core.config.CoreConfig;
import org.mvplugins.multiverse.core.locale.PluginLocales;
import org.mvplugins.multiverse.core.locale.message.LocalizedMessage;
import org.mvplugins.multiverse.core.world.WorldManager;
import org.mvplugins.multiverse.core.world.helpers.WorldNameChecker;

Expand Down Expand Up @@ -68,6 +71,16 @@ public class MVCommandManager extends PaperCommandManager {
this.setDefaultExceptionHandler(new MVDefaultExceptionHandler());
}

@PostConstruct
private void postConstruct() {
LocalizedMessage.setDefaultLocalesManager(getLocales());
}

@PreDestroy
private void preDestroy() {
LocalizedMessage.setDefaultLocalesManager(null);
}

/**
* Registers a list of commands and handles {@link LegacyAliasCommand} based on config option.
* @param commands The commands to register
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void onCheckCommand(
replace("{location}").with(destination.getLocation(player)
.map(locationManipulation::locationToString)
.map(Message::of)
.getOrElse(() -> Message.of(MVCorei18n.GENERIC_NULL, "Null!"))));
.getOrElse(() -> Message.of(MVCorei18n.GENERIC_NULL))));

// TODO: Show permission required for this particular destination
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void onCloneCommand(
MultiverseWorld world,

@Syntax("<new-world-name>")
@Description("{@@mv-core.clone.newWorld.description}")
@Description("{@@mv-core.clone.newworld.description}")
String newWorldName,

@Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void onDeleteCommand(
commandQueueManager.addToQueue(CommandQueuePayload
.issuer(issuer)
.action(() -> runDeleteCommand(issuer, world, parsedFlags))
.prompt(Message.of(MVCorei18n.DELETE_PROMPT, "",
.prompt(Message.of(MVCorei18n.DELETE_PROMPT,
Replace.WORLD.with(world.getName()))));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void onRegenCommand(
commandQueueManager.addToQueue(CommandQueuePayload
.issuer(issuer)
.action(() -> runRegenCommand(issuer, world, parsedFlags))
.prompt(Message.of(MVCorei18n.REGEN_PROMPT, "",
.prompt(Message.of(MVCorei18n.REGEN_PROMPT,
Replace.WORLD.with(world.getName()))));
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/mvplugins/multiverse/core/config/CoreConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ public DimensionFormat getEndWorldNameFormat() {
return configHandle.get(configNodes.endWorldNameFormat);
}

@ApiStatus.AvailableSince("5.8")
public Try<Void> setWarnAliasConflicts(boolean warnAliasConflicts) {
return configHandle.set(configNodes.warnAliasConflicts, warnAliasConflicts);
}

@ApiStatus.AvailableSince("5.8")
public boolean getWarnAliasConflicts() {
return configHandle.get(configNodes.warnAliasConflicts);
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ private <N extends Node> N node(N node) {
.stringParser(DimensionFormatNodeStringParser.INSTANCE)
.build());

final ConfigNode<Boolean> warnAliasConflicts = node(ConfigNode.builder("world.warn-alias-conflicts", Boolean.class)
.comment("")
.comment("Sets whether Multiverse will warn about alias duplicates when adding worlds or modifying aliases.")
.comment("Although not enforced, it is highly recommended to not have multiple worlds with the same alias or")
.comment("alias matching another world's name as it can cause confusion during world listing and selection in commands.")
.defaultValue(true)
.name("warn-alias-conflicts")
.build());

private final ConfigHeaderNode teleportHeader = node(ConfigHeaderNode.builder("teleport")
.comment("")
.comment("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ protected Builder(@NotNull String path, @NotNull Class<T> type) {
* @deprecated Use {@link #onLoadAndChange(NodeChangeCallback)} instead.
*/
@Deprecated(since = "5.4", forRemoval = true)
@ApiStatus.ScheduledForRemoval(inVersion = "6.0")
public @NotNull B onSetValue(@NotNull BiConsumer<T, T> onSetValue) {
return onLoadAndChange(onSetValue::accept);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.mvplugins.multiverse.core.exceptions;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import org.mvplugins.multiverse.core.locale.message.LocalizableMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import co.aikar.commands.InvalidCommandArgument;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.mvplugins.multiverse.core.locale.message.LocalizableMessage;
import org.mvplugins.multiverse.core.locale.message.LocalizedMessage;
import org.mvplugins.multiverse.core.locale.message.Message;
Expand All @@ -18,16 +19,20 @@ public static MVInvalidCommandArgument causeBy(Throwable throwable) {

@ApiStatus.AvailableSince("5.7")
public static MVInvalidCommandArgument causeBy(Throwable throwable, boolean showSyntax) {
return (throwable instanceof LocalizableMessage localizableMessage)
? of(localizableMessage.getLocalizableMessage(), showSyntax)
: new MVInvalidCommandArgument(throwable.getLocalizedMessage(), showSyntax);
if (throwable instanceof LocalizableMessage localizableMessage) {
Message message = localizableMessage.getLocalizableMessage();
return message == null
? new MVInvalidCommandArgument(throwable.getLocalizedMessage(), showSyntax)
: of(message, showSyntax);
}
return new MVInvalidCommandArgument(throwable.getLocalizedMessage(), showSyntax);
}

public static MVInvalidCommandArgument of(Message message) {
public static MVInvalidCommandArgument of(@NotNull Message message) {
return of(message, true);
}

public static MVInvalidCommandArgument of(Message message, boolean showSyntax) {
public static MVInvalidCommandArgument of(@NotNull Message message, boolean showSyntax) {
return message instanceof LocalizedMessage
? new MVInvalidCommandArgument((LocalizedMessage) message, showSyntax)
: new MVInvalidCommandArgument(message, showSyntax);
Expand All @@ -42,6 +47,6 @@ private MVInvalidCommandArgument(Message message, boolean showSyntax) {
}

private MVInvalidCommandArgument(LocalizedMessage message, boolean showSyntax) {
super(message.getMessageKey(), showSyntax, message.getReplacements());
super(message.getMessageKey(), showSyntax, message.getRawReplacements());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public enum MVCorei18n implements MessageKeyProvider {

// /mv meta info
META_INFO_DESCRIPTION,
META_INFO_WORLD,
META_INFO_WORLD_DESCRIPTION,
META_INFO_HEADER,
META_INFO_NOCONTENT,

Expand Down Expand Up @@ -370,6 +370,11 @@ public enum MVCorei18n implements MessageKeyProvider {
TELEPORTFAILUREREASON_TELEPORT_FAILED_EXCEPTION,
TELEPORTFAILUREREASON_EVENT_CANCELLED,

// alias name conflict
ALIASNAMECONFLICT_DETECTED,
ALIASNAMECONFLICT_DUPLICATEALIAS,
ALIASNAMECONFLICT_DUPLICATEWORLDNAME,

// world manager result
CLONEWORLD_INVALIDWORLDNAME,
CLONEWORLD_WORLDEXISTFOLDER,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package org.mvplugins.multiverse.core.locale.message;

import java.util.Objects;

import co.aikar.commands.ACFUtil;
import co.aikar.commands.CommandIssuer;
import co.aikar.commands.Locales;
import co.aikar.locales.MessageKey;
import co.aikar.locales.MessageKeyProvider;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class LocalizedMessage extends Message implements MessageKeyProvider {

private static @Nullable Locales locales;

@ApiStatus.Internal
public static void setDefaultLocalesManager(@Nullable Locales locales) {
LocalizedMessage.locales = locales;
}

private final @NotNull MessageKeyProvider messageKeyProvider;

LocalizedMessage(
Expand All @@ -22,11 +28,33 @@ public final class LocalizedMessage extends Message implements MessageKeyProvide
this.messageKeyProvider = messageKeyProvider;
}

/**
* {@inheritDoc}
*/
@Override
public MessageKey getMessageKey() {
return messageKeyProvider.getMessageKey();
}

/**
* {@inheritDoc}
*/
@Override
public @NotNull String[] getReplacements() {
return locales == null ? super.getReplacements() : getReplacements(locales, null);
}

/**
* {@inheritDoc}
*/
@Override
public @NotNull String formatted() {
return locales == null ? super.formatted() : formatted(locales, null);
}

/**
* {@inheritDoc}
*/
@Override
public @NotNull String formatted(@NotNull Locales locales, @Nullable CommandIssuer commandIssuer) {
String[] parsedReplacements = getReplacements(locales, commandIssuer);
Expand Down
Loading
Loading