mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-15 12:02:48 +01:00
Merge pull request #3159 from Multiverse/dtm/mv5/sonarqube-fixes
Checkstyle/Sonarqube fixes.
This commit is contained in:
commit
d3274cced7
@ -380,7 +380,7 @@
|
||||
<property name="throwsIndent" value="8"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
<property name="lineWrappingIndentation" value="8"/>
|
||||
<property name="forceStrictCondition" value="true"/>
|
||||
<property name="forceStrictCondition" value="false"/>
|
||||
</module>
|
||||
<module name="NoCodeInFile"/>
|
||||
<module name="OuterTypeFilename"/>
|
||||
|
@ -11,18 +11,21 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.MultiverseCore;
|
||||
@ -34,6 +37,10 @@ import org.mvplugins.multiverse.core.teleportation.LocationManipulation;
|
||||
*/
|
||||
@Service
|
||||
public final class AnchorManager {
|
||||
|
||||
private static final String ANCHORS_FILE = "anchors.yml";
|
||||
private static final String ANCHORS_CONFIG_SECTION = "anchors";
|
||||
|
||||
private Map<String, Location> anchors;
|
||||
private FileConfiguration anchorConfig;
|
||||
|
||||
@ -42,33 +49,31 @@ public final class AnchorManager {
|
||||
private final MVCoreConfig config;
|
||||
|
||||
@Inject
|
||||
public AnchorManager(
|
||||
AnchorManager(
|
||||
MultiverseCore plugin,
|
||||
LocationManipulation locationManipulation,
|
||||
MVCoreConfig config
|
||||
) {
|
||||
MVCoreConfig config) {
|
||||
this.plugin = plugin;
|
||||
this.locationManipulation = locationManipulation;
|
||||
this.config = config;
|
||||
|
||||
this.anchors = new HashMap<String, Location>();
|
||||
anchors = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all anchors.
|
||||
*/
|
||||
public void loadAnchors() {
|
||||
this.anchors = new HashMap<String, Location>();
|
||||
this.anchorConfig = YamlConfiguration.loadConfiguration(new File(this.plugin.getDataFolder(), "anchors.yml"));
|
||||
this.ensureConfigIsPrepared();
|
||||
ConfigurationSection anchorsSection = this.anchorConfig.getConfigurationSection("anchors");
|
||||
anchors = new HashMap<>();
|
||||
anchorConfig = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), ANCHORS_FILE));
|
||||
var anchorsSection = getAnchorsConfigSection();
|
||||
Set<String> anchorKeys = anchorsSection.getKeys(false);
|
||||
for (String key : anchorKeys) {
|
||||
//world:x,y,z:pitch:yaw
|
||||
Location anchorLocation = this.locationManipulation.stringToLocation(anchorsSection.getString(key, ""));
|
||||
Location anchorLocation = locationManipulation.stringToLocation(anchorsSection.getString(key, ""));
|
||||
if (anchorLocation != null) {
|
||||
Logging.config("Loading anchor: '%s'...", key);
|
||||
this.anchors.put(key, anchorLocation);
|
||||
anchors.put(key, anchorLocation);
|
||||
} else {
|
||||
Logging.warning("The location for anchor '%s' is INVALID.", key);
|
||||
}
|
||||
@ -76,19 +81,22 @@ public final class AnchorManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureConfigIsPrepared() {
|
||||
if (this.anchorConfig.getConfigurationSection("anchors") == null) {
|
||||
this.anchorConfig.createSection("anchors");
|
||||
private ConfigurationSection getAnchorsConfigSection() {
|
||||
var anchorsConfigSection = anchorConfig.getConfigurationSection(ANCHORS_CONFIG_SECTION);
|
||||
if (anchorsConfigSection == null) {
|
||||
anchorsConfigSection = anchorConfig.createSection(ANCHORS_CONFIG_SECTION);
|
||||
}
|
||||
return anchorsConfigSection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all anchors.
|
||||
*
|
||||
* @return True if all anchors were successfully saved.
|
||||
*/
|
||||
public boolean saveAnchors() {
|
||||
try {
|
||||
this.anchorConfig.save(new File(this.plugin.getDataFolder(), "anchors.yml"));
|
||||
anchorConfig.save(new File(plugin.getDataFolder(), ANCHORS_FILE));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Logging.severe("Failed to save anchors.yml. Please check your file permissions.");
|
||||
@ -98,29 +106,32 @@ public final class AnchorManager {
|
||||
|
||||
/**
|
||||
* Gets the {@link Location} associated with an anchor.
|
||||
*
|
||||
* @param anchor The name of the anchor.
|
||||
* @return The {@link Location}.
|
||||
*/
|
||||
public Location getAnchorLocation(String anchor) {
|
||||
if (this.anchors.containsKey(anchor)) {
|
||||
return this.anchors.get(anchor);
|
||||
if (anchors.containsKey(anchor)) {
|
||||
return anchors.get(anchor);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an anchor.
|
||||
*
|
||||
* @param anchor The name of the anchor.
|
||||
* @param location The location of the anchor as string.
|
||||
* @return True if the anchor was successfully saved.
|
||||
*/
|
||||
public boolean saveAnchorLocation(String anchor, String location) {
|
||||
Location parsed = this.locationManipulation.stringToLocation(location);
|
||||
return parsed != null && this.saveAnchorLocation(anchor, parsed);
|
||||
Location parsed = locationManipulation.stringToLocation(location);
|
||||
return saveAnchorLocation(anchor, parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an anchor.
|
||||
*
|
||||
* @param anchor The name of the anchor.
|
||||
* @param l The {@link Location} of the anchor.
|
||||
* @return True if the anchor was successfully saved.
|
||||
@ -129,60 +140,74 @@ public final class AnchorManager {
|
||||
if (l == null) {
|
||||
return false;
|
||||
}
|
||||
this.anchorConfig.set("anchors." + anchor, this.locationManipulation.locationToString(l));
|
||||
this.anchors.put(anchor, l);
|
||||
return this.saveAnchors();
|
||||
getAnchorsConfigSection().set(anchor, locationManipulation.locationToString(l));
|
||||
anchors.put(anchor, l);
|
||||
return saveAnchors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all anchors.
|
||||
*
|
||||
* @return An unmodifiable {@link Set} containing all anchors.
|
||||
*/
|
||||
public Set<String> getAllAnchors() {
|
||||
return Collections.unmodifiableSet(this.anchors.keySet());
|
||||
return Collections.unmodifiableSet(anchors.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all anchors that the specified {@link Player} can access.
|
||||
* @param p The {@link Player}.
|
||||
*
|
||||
* @param player The {@link Player}.
|
||||
* @return An unmodifiable {@link Set} containing all anchors the specified {@link Player} can access.
|
||||
*/
|
||||
public Set<String> getAnchors(Player p) {
|
||||
if (p == null) {
|
||||
return this.anchors.keySet();
|
||||
public Set<String> getAnchors(Player player) {
|
||||
if (player == null) {
|
||||
return anchors.keySet();
|
||||
} else {
|
||||
return getAnchorsForPlayer(player);
|
||||
}
|
||||
Set<String> myAnchors = new HashSet<String>();
|
||||
for (String anchor : this.anchors.keySet()) {
|
||||
Location ancLoc = this.anchors.get(anchor);
|
||||
if (ancLoc == null) {
|
||||
continue;
|
||||
}
|
||||
String worldPerm = "multiverse.access." + ancLoc.getWorld().getName();
|
||||
// Add to the list if we're not enforcing access
|
||||
// OR
|
||||
// We are enforcing access and the user has the permission.
|
||||
if (!config.getEnforceAccess() ||
|
||||
(config.getEnforceAccess() && p.hasPermission(worldPerm))) {
|
||||
myAnchors.add(anchor);
|
||||
} else {
|
||||
Logging.finer(String.format("Not adding anchor %s to the list, user %s doesn't have the %s " +
|
||||
"permission and 'enforceaccess' is enabled!",
|
||||
anchor, p.getName(), worldPerm));
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> getAnchorsForPlayer(@NotNull Player player) {
|
||||
return anchors.entrySet().stream()
|
||||
.filter(entry -> shouldIncludeAnchorForPlayer(entry.getKey(), entry.getValue(), player))
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private boolean shouldIncludeAnchorForPlayer(String anchor, Location location, Player player) {
|
||||
var world = getLocationWorld(location);
|
||||
return world != null && playerCanAccess(player, world, anchor);
|
||||
}
|
||||
|
||||
private @Nullable World getLocationWorld(@Nullable Location location) {
|
||||
if (location == null) {
|
||||
return null;
|
||||
}
|
||||
return Collections.unmodifiableSet(myAnchors);
|
||||
return location.getWorld();
|
||||
}
|
||||
|
||||
private boolean playerCanAccess(Player player, World world, String anchor) {
|
||||
String worldPerm = "multiverse.access." + world.getName();
|
||||
if (config.getEnforceAccess() && !player.hasPermission(worldPerm)) {
|
||||
Logging.finer(String.format("Not adding anchor %s to the list, user %s doesn't have the %s permission "
|
||||
+ "and 'enforceaccess' is enabled!", anchor, player.getName(), worldPerm));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the specified anchor.
|
||||
*
|
||||
* @param s The name of the anchor.
|
||||
* @return True if the anchor was successfully deleted.
|
||||
*/
|
||||
public boolean deleteAnchor(String s) {
|
||||
if (this.anchors.containsKey(s)) {
|
||||
this.anchors.remove(s);
|
||||
this.anchorConfig.set("anchors." + s, null);
|
||||
return this.saveAnchors();
|
||||
if (anchors.containsKey(s)) {
|
||||
anchors.remove(s);
|
||||
getAnchorsConfigSection().set(s, null);
|
||||
return saveAnchors();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import org.jvnet.hk2.annotations.Service;
|
||||
import org.mvplugins.multiverse.core.anchor.AnchorManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
|
@ -36,7 +36,7 @@ final class AnchorListCommand extends CoreCommand {
|
||||
private final AnchorManager anchorManager;
|
||||
private final LocationManipulation locationManipulation;
|
||||
|
||||
private final CommandValueFlag<Integer> PAGE_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<Integer> pageFlag = flag(CommandValueFlag
|
||||
.builder("--page", Integer.class)
|
||||
.addAlias("-p")
|
||||
.context(value -> {
|
||||
@ -48,7 +48,7 @@ final class AnchorListCommand extends CoreCommand {
|
||||
})
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<ContentFilter> FILTER_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<ContentFilter> filterFlag = flag(CommandValueFlag
|
||||
.builder("--filter", ContentFilter.class)
|
||||
.addAlias("-f")
|
||||
.context(value -> {
|
||||
@ -88,8 +88,8 @@ final class AnchorListCommand extends CoreCommand {
|
||||
.withSendHandler(PagedSendHandler.create()
|
||||
.withHeader("&3==== [ Multiverse Anchors ] ====")
|
||||
.doPagination(true)
|
||||
.withTargetPage(parsedFlags.flagValue(PAGE_FLAG, 1))
|
||||
.withFilter(parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get())))
|
||||
.withTargetPage(parsedFlags.flagValue(pageFlag, 1))
|
||||
.withFilter(parsedFlags.flagValue(filterFlag, DefaultContentFilter.get())))
|
||||
.send(issuer);
|
||||
}
|
||||
|
||||
|
@ -54,10 +54,9 @@ final class AnchorSetCommand extends CoreCommand {
|
||||
String anchorName) {
|
||||
Location anchorLocation = player.getLocation();
|
||||
if (anchorManager.saveAnchorLocation(anchorName, anchorLocation)) {
|
||||
issuer.sendMessage("&aAnchor &f" + anchorName + "&a set to &f"
|
||||
+ locationManipulation.locationToString(anchorLocation));
|
||||
sendAnchorSetSuccessMessage(issuer, anchorName, locationManipulation.locationToString(anchorLocation));
|
||||
} else {
|
||||
issuer.sendMessage("&cFailed to set anchor &f" + anchorName + ".");
|
||||
sendAnchorSetFailedMessage(issuer, anchorName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,9 +77,17 @@ final class AnchorSetCommand extends CoreCommand {
|
||||
@Description("")
|
||||
String locationString) {
|
||||
if (anchorManager.saveAnchorLocation(anchorName, locationString)) {
|
||||
issuer.sendMessage("&aAnchor &f" + anchorName + "&a set to &f" + locationString);
|
||||
sendAnchorSetSuccessMessage(issuer, anchorName, locationString);
|
||||
} else {
|
||||
issuer.sendMessage("&cFailed to set anchor &f" + anchorName + ".");
|
||||
sendAnchorSetFailedMessage(issuer, anchorName);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendAnchorSetSuccessMessage(MVCommandIssuer issuer, String anchorName, String locationString) {
|
||||
issuer.sendMessage("&aAnchor &f" + anchorName + "&a set to &f" + locationString);
|
||||
}
|
||||
|
||||
private void sendAnchorSetFailedMessage(MVCommandIssuer issuer, String anchorName) {
|
||||
issuer.sendMessage("&cFailed to set anchor &f" + anchorName + ".");
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,10 @@ import org.jvnet.hk2.annotations.Service;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.destination.DestinationInstance;
|
||||
import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.Message;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker;
|
||||
import org.mvplugins.multiverse.core.teleportation.LocationManipulation;
|
||||
|
||||
import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace;
|
||||
@ -56,8 +57,8 @@ final class CheckCommand extends CoreCommand {
|
||||
issuer.sendInfo(this.corePermissionsChecker.checkTeleportPermissions(player, player, destination)
|
||||
? MVCorei18n.CHECK_HASPERMISSION
|
||||
: MVCorei18n.CHECK_NOPERMISSION,
|
||||
replace("{player}").with(player.getName()),
|
||||
replace("{destination}").with(destination));
|
||||
Replace.PLAYER.with(player.getName()),
|
||||
Replace.DESTINATION.with(destination));
|
||||
issuer.sendInfo(MVCorei18n.CHECK_LOCATION,
|
||||
replace("{location}").with(destination.getLocation(player)
|
||||
.map(locationManipulation::locationToString)
|
||||
|
@ -17,25 +17,28 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
import org.mvplugins.multiverse.core.world.options.CloneWorldOptions;
|
||||
|
||||
import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
final class CloneCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
private final CommandFlag RESET_WORLD_CONFIG_FLAG = flag(CommandFlag.builder("--reset-world-config")
|
||||
private final CommandFlag resetWorldConfigFlag = flag(CommandFlag.builder("--reset-world-config")
|
||||
.addAlias("-wc")
|
||||
.build());
|
||||
|
||||
private final CommandFlag RESET_GAMERULES_FLAG = flag(CommandFlag.builder("--reset-gamerules")
|
||||
private final CommandFlag resetGamerulesFlag = flag(CommandFlag.builder("--reset-gamerules")
|
||||
.addAlias("-gm")
|
||||
.build());
|
||||
|
||||
private final CommandFlag RESET_WORLD_BORDER_FLAG = flag(CommandFlag.builder("--reset-world-border")
|
||||
private final CommandFlag resetWorldBorderFlag = flag(CommandFlag.builder("--reset-world-border")
|
||||
.addAlias("-wb")
|
||||
.build());
|
||||
|
||||
@ -68,15 +71,17 @@ final class CloneCommand extends CoreCommand {
|
||||
String[] flags) {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
issuer.sendInfo(MVCorei18n.CLONE_CLONING, "{world}", world.getName(), "{newworld}", newWorldName);
|
||||
issuer.sendInfo(MVCorei18n.CLONE_CLONING,
|
||||
Replace.WORLD.with(world.getName()),
|
||||
replace("{newworld}").with(newWorldName));
|
||||
CloneWorldOptions cloneWorldOptions = CloneWorldOptions.fromTo(world, newWorldName)
|
||||
.keepWorldConfig(!parsedFlags.hasFlag(RESET_WORLD_CONFIG_FLAG))
|
||||
.keepGameRule(!parsedFlags.hasFlag(RESET_GAMERULES_FLAG))
|
||||
.keepWorldBorder(!parsedFlags.hasFlag(RESET_WORLD_BORDER_FLAG));
|
||||
.keepWorldConfig(!parsedFlags.hasFlag(resetWorldConfigFlag))
|
||||
.keepGameRule(!parsedFlags.hasFlag(resetGamerulesFlag))
|
||||
.keepWorldBorder(!parsedFlags.hasFlag(resetWorldBorderFlag));
|
||||
worldManager.cloneWorld(cloneWorldOptions)
|
||||
.onSuccess(newWorld -> {
|
||||
Logging.fine("World clone success: " + newWorld);
|
||||
issuer.sendInfo(MVCorei18n.CLONE_SUCCESS, "{world}", newWorld.getName());
|
||||
issuer.sendInfo(MVCorei18n.CLONE_SUCCESS, Replace.WORLD.with(newWorld.getName()));
|
||||
}).onFailure(failure -> {
|
||||
Logging.fine("World clone failure: " + failure);
|
||||
issuer.sendError(failure.getFailureMessage());
|
||||
|
@ -1,11 +1,9 @@
|
||||
package org.mvplugins.multiverse.core.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Default;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import jakarta.inject.Inject;
|
||||
@ -14,7 +12,6 @@ import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.mvplugins.multiverse.core.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
@ -11,11 +10,15 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.teleportation.LocationManipulation;
|
||||
import org.mvplugins.multiverse.core.world.MultiverseWorld;
|
||||
|
||||
import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
final class CoordinatesCommand extends CoreCommand {
|
||||
@ -29,12 +32,13 @@ final class CoordinatesCommand extends CoreCommand {
|
||||
super(commandManager);
|
||||
this.locationManipulation = locationManipulation;
|
||||
}
|
||||
|
||||
@CommandAlias("mvcoord|mvco")
|
||||
@Subcommand("coordinates|coords|coord|co")
|
||||
@CommandPermission("multiverse.core.coord")
|
||||
@Description("{@@mv-core.coordinates.description}")
|
||||
void onCoordinatesCommand(
|
||||
BukkitCommandIssuer issuer,
|
||||
MVCommandIssuer issuer,
|
||||
|
||||
@Flags("resolve=issuerOnly")
|
||||
Player player,
|
||||
@ -42,10 +46,13 @@ final class CoordinatesCommand extends CoreCommand {
|
||||
@Flags("resolve=issuerOnly")
|
||||
MultiverseWorld world) {
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_TITLE);
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_WORLD, "{world}", world.getName());
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_ALIAS, "{alias}", world.getAlias());
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_WORLDSCALE, "{scale}", String.valueOf(world.getScale()));
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_COORDINATES, "{coordinates}", locationManipulation.strCoords(player.getLocation()));
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_DIRECTION, "{direction}", locationManipulation.getDirection(player.getLocation()));
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_WORLD, Replace.WORLD.with(world.getName()));
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_ALIAS, replace("{alias}").with(world.getAlias()));
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_WORLDSCALE,
|
||||
replace("{scale}").with(String.valueOf(world.getScale())));
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_COORDINATES,
|
||||
replace("{coordinates}").with(locationManipulation.strCoords(player.getLocation())));
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_DIRECTION,
|
||||
replace("{direction}").with(locationManipulation.getDirection(player.getLocation())));
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,13 @@ package org.mvplugins.multiverse.core.commands;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
|
||||
/**
|
||||
* Represents a command that is part of the Multiverse-Core plugin.
|
||||
*/
|
||||
@Contract
|
||||
public abstract class CoreCommand extends MultiverseCommand {
|
||||
protected CoreCommand(@NotNull MVCommandManager commandManager) {
|
||||
|
@ -21,15 +21,18 @@ import org.bukkit.block.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
import org.mvplugins.multiverse.core.world.options.CreateWorldOptions;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
import org.mvplugins.multiverse.core.world.generators.GeneratorProvider;
|
||||
import org.mvplugins.multiverse.core.world.options.CreateWorldOptions;
|
||||
|
||||
import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
@ -38,34 +41,36 @@ final class CreateCommand extends CoreCommand {
|
||||
private final WorldManager worldManager;
|
||||
private GeneratorProvider generatorProvider;
|
||||
|
||||
private final CommandValueFlag<String> SEED_FLAG = flag(CommandValueFlag.builder("--seed", String.class)
|
||||
private final Random random = new Random();
|
||||
|
||||
private final CommandValueFlag<String> seedFlag = flag(CommandValueFlag.builder("--seed", String.class)
|
||||
.addAlias("-s")
|
||||
.completion(input -> Collections.singleton(String.valueOf(new Random().nextLong())))
|
||||
.completion(input -> Collections.singleton(String.valueOf(random.nextLong())))
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<String> GENERATOR_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<String> generatorFlag = flag(CommandValueFlag
|
||||
.builder("--generator", String.class)
|
||||
.addAlias("-g")
|
||||
.completion(input -> generatorProvider.suggestGeneratorString(input))
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<WorldType> WORLD_TYPE_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<WorldType> worldTypeFlag = flag(CommandValueFlag
|
||||
.enumBuilder("--world-type", WorldType.class)
|
||||
.addAlias("-t")
|
||||
.build());
|
||||
|
||||
private final CommandFlag NO_ADJUST_SPAWN_FLAG = flag(CommandFlag.builder("--no-adjust-spawn")
|
||||
private final CommandFlag noAdjustSpawnFlag = flag(CommandFlag.builder("--no-adjust-spawn")
|
||||
.addAlias("-n")
|
||||
.build());
|
||||
|
||||
private final CommandFlag NO_STRUCTURES_FLAG = flag(CommandFlag.builder("--no-structures")
|
||||
private final CommandFlag noStructuresFlag = flag(CommandFlag.builder("--no-structures")
|
||||
.addAlias("-a")
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<Biome> BIOME_FLAG = flag(CommandValueFlag.builder("--biome", Biome.class)
|
||||
private final CommandValueFlag<Biome> biomeFlag = flag(CommandValueFlag.builder("--biome", Biome.class)
|
||||
.addAlias("-b")
|
||||
.completion(input -> Lists.newArrayList(Registry.BIOME).stream()
|
||||
.filter(biome -> biome !=Biome.CUSTOM)
|
||||
.filter(biome -> biome != Biome.CUSTOM)
|
||||
.map(biome -> biome.getKey().getKey())
|
||||
.toList())
|
||||
.context(biomeStr -> Registry.BIOME.get(NamespacedKey.minecraft(biomeStr)))
|
||||
@ -85,7 +90,8 @@ final class CreateCommand extends CoreCommand {
|
||||
@Subcommand("create")
|
||||
@CommandPermission("multiverse.core.create")
|
||||
@CommandCompletion("@empty @environments @flags:groupName=mvcreatecommand")
|
||||
@Syntax("<name> <environment> [--seed <seed> --generator <generator[:id]> --world-type <worldtype> --adjust-spawn --no-structures --biome <biome>]")
|
||||
@Syntax("<name> <environment> [--seed <seed> --generator <generator[:id]> --world-type <worldtype> --adjust-spawn "
|
||||
+ "--no-structures --biome <biome>]")
|
||||
@Description("{@@mv-core.create.description}")
|
||||
void onCreateCommand(
|
||||
MVCommandIssuer issuer,
|
||||
@ -99,45 +105,46 @@ final class CreateCommand extends CoreCommand {
|
||||
World.Environment environment,
|
||||
|
||||
@Optional
|
||||
@Syntax("[--seed <seed> --generator <generator[:id]> --world-type <worldtype> --adjust-spawn --no-structures --biome <biome>]")
|
||||
@Syntax("[--seed <seed> --generator <generator[:id]> --world-type <worldtype> --adjust-spawn "
|
||||
+ "--no-structures --biome <biome>]")
|
||||
@Description("{@@mv-core.create.flags.description}")
|
||||
String[] flags) {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES,
|
||||
"{worldName}", worldName);
|
||||
replace("{worldName}").with(worldName));
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ENVIRONMENT,
|
||||
"{environment}", environment.name());
|
||||
replace("{environment}").with(environment.name()));
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_SEED,
|
||||
"{seed}", parsedFlags.flagValue(SEED_FLAG, "RANDOM"));
|
||||
replace("{seed}").with(parsedFlags.flagValue(seedFlag, "RANDOM")));
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_WORLDTYPE,
|
||||
"{worldType}", parsedFlags.flagValue(WORLD_TYPE_FLAG, WorldType.NORMAL).name());
|
||||
replace("{worldType}").with(parsedFlags.flagValue(worldTypeFlag, WorldType.NORMAL).name()));
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_ADJUSTSPAWN,
|
||||
"{adjustSpawn}", String.valueOf(!parsedFlags.hasFlag(NO_ADJUST_SPAWN_FLAG)));
|
||||
if (parsedFlags.hasFlag(BIOME_FLAG)) {
|
||||
replace("{adjustSpawn}").with(String.valueOf(!parsedFlags.hasFlag(noAdjustSpawnFlag))));
|
||||
if (parsedFlags.hasFlag(biomeFlag)) {
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_BIOME,
|
||||
"{biome}", parsedFlags.flagValue(BIOME_FLAG, Biome.CUSTOM).name());
|
||||
replace("{biome}").with(parsedFlags.flagValue(biomeFlag, Biome.CUSTOM).name()));
|
||||
}
|
||||
if (parsedFlags.hasFlag(GENERATOR_FLAG)) {
|
||||
if (parsedFlags.hasFlag(generatorFlag)) {
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_GENERATOR,
|
||||
"{generator}", parsedFlags.flagValue(GENERATOR_FLAG));
|
||||
replace("{generator}").with(parsedFlags.flagValue(generatorFlag)));
|
||||
}
|
||||
issuer.sendInfo(MVCorei18n.CREATE_PROPERTIES_STRUCTURES,
|
||||
"{structures}", String.valueOf(!parsedFlags.hasFlag(NO_STRUCTURES_FLAG)));
|
||||
replace("{structures}").with(String.valueOf(!parsedFlags.hasFlag(noStructuresFlag))));
|
||||
|
||||
issuer.sendInfo(MVCorei18n.CREATE_LOADING);
|
||||
|
||||
worldManager.createWorld(CreateWorldOptions.worldName(worldName)
|
||||
.biome(parsedFlags.flagValue(BIOME_FLAG, Biome.CUSTOM))
|
||||
.biome(parsedFlags.flagValue(biomeFlag, Biome.CUSTOM))
|
||||
.environment(environment)
|
||||
.seed(parsedFlags.flagValue(SEED_FLAG))
|
||||
.worldType(parsedFlags.flagValue(WORLD_TYPE_FLAG, WorldType.NORMAL))
|
||||
.useSpawnAdjust(!parsedFlags.hasFlag(NO_ADJUST_SPAWN_FLAG))
|
||||
.generator(parsedFlags.flagValue(GENERATOR_FLAG, ""))
|
||||
.generateStructures(!parsedFlags.hasFlag(NO_STRUCTURES_FLAG)))
|
||||
.seed(parsedFlags.flagValue(seedFlag))
|
||||
.worldType(parsedFlags.flagValue(worldTypeFlag, WorldType.NORMAL))
|
||||
.useSpawnAdjust(!parsedFlags.hasFlag(noAdjustSpawnFlag))
|
||||
.generator(parsedFlags.flagValue(generatorFlag, ""))
|
||||
.generateStructures(!parsedFlags.hasFlag(noStructuresFlag)))
|
||||
.onSuccess(newWorld -> {
|
||||
Logging.fine("World create success: " + newWorld);
|
||||
issuer.sendInfo(MVCorei18n.CREATE_SUCCESS, "{world}", newWorld.getName());
|
||||
issuer.sendInfo(MVCorei18n.CREATE_SUCCESS, Replace.WORLD.with(newWorld.getName()));
|
||||
}).onFailure(failure -> {
|
||||
Logging.fine("World create failure: " + failure);
|
||||
issuer.sendError(failure.getFailureMessage());
|
||||
|
@ -21,16 +21,15 @@ import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
|
||||
import org.mvplugins.multiverse.core.commandtools.queue.CommandQueuePayload;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.utils.WorldTickDeferrer;
|
||||
import org.mvplugins.multiverse.core.locale.message.Message;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.utils.WorldTickDeferrer;
|
||||
import org.mvplugins.multiverse.core.utils.result.Async;
|
||||
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
import org.mvplugins.multiverse.core.world.MultiverseWorld;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
import org.mvplugins.multiverse.core.world.helpers.PlayerWorldTeleporter;
|
||||
|
||||
import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
final class DeleteCommand extends CoreCommand {
|
||||
@ -39,7 +38,7 @@ final class DeleteCommand extends CoreCommand {
|
||||
private final PlayerWorldTeleporter playerWorldTeleporter;
|
||||
private final WorldTickDeferrer worldTickDeferrer;
|
||||
|
||||
private final CommandFlag REMOVE_PLAYERS_FLAG = flag(CommandFlag.builder("--remove-players")
|
||||
private final CommandFlag removePlayersFlag = flag(CommandFlag.builder("--remove-players")
|
||||
.addAlias("-r")
|
||||
.build());
|
||||
|
||||
@ -79,13 +78,15 @@ final class DeleteCommand extends CoreCommand {
|
||||
.issuer(issuer)
|
||||
.action(() -> runDeleteCommand(issuer, world, parsedFlags))
|
||||
.prompt(Message.of(MVCorei18n.DELETE_PROMPT, "",
|
||||
replace("{world}").with(world.getName()))));
|
||||
Replace.WORLD.with(world.getName()))));
|
||||
}
|
||||
|
||||
private void runDeleteCommand(MVCommandIssuer issuer, MultiverseWorld world, ParsedCommandFlags parsedFlags) {
|
||||
issuer.sendInfo(MVCorei18n.DELETE_DELETING, "{world}", world.getName());
|
||||
issuer.sendInfo(MVCorei18n.DELETE_DELETING, Replace.WORLD.with(world.getName()));
|
||||
|
||||
var future = parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG) && world.isLoaded() && world instanceof LoadedMultiverseWorld loadedWorld
|
||||
var future = parsedFlags.hasFlag(removePlayersFlag)
|
||||
&& world.isLoaded()
|
||||
&& world instanceof LoadedMultiverseWorld loadedWorld
|
||||
? playerWorldTeleporter.removeFromWorld(loadedWorld)
|
||||
: Async.completedFuture(Collections.emptyList());
|
||||
|
||||
@ -96,7 +97,7 @@ final class DeleteCommand extends CoreCommand {
|
||||
worldManager.deleteWorld(world)
|
||||
.onSuccess(deletedWorldName -> {
|
||||
Logging.fine("World delete success: " + deletedWorldName);
|
||||
issuer.sendInfo(MVCorei18n.DELETE_SUCCESS, "{world}", deletedWorldName);
|
||||
issuer.sendInfo(MVCorei18n.DELETE_SUCCESS, Replace.WORLD.with(deletedWorldName));
|
||||
}).onFailure(failure -> {
|
||||
Logging.fine("World delete failure: " + failure);
|
||||
issuer.sendError(failure.getFailureMessage());
|
||||
|
@ -45,18 +45,18 @@ final class DumpsCommand extends CoreCommand {
|
||||
private final WorldManager worldManager;
|
||||
private final FileUtils fileUtils;
|
||||
|
||||
private final CommandValueFlag<LogsTypeOption> LOGS_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<LogsTypeOption> logsFlag = flag(CommandValueFlag
|
||||
.enumBuilder("--logs", LogsTypeOption.class)
|
||||
.addAlias("-l")
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<ServiceTypeOption> UPLOAD_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<ServiceTypeOption> uploadFlag = flag(CommandValueFlag
|
||||
.enumBuilder("--upload", ServiceTypeOption.class)
|
||||
.addAlias("-u")
|
||||
.build());
|
||||
|
||||
// Does not upload logs or plugin list (except if --logs mclogs is there)
|
||||
private final CommandFlag PARANOID_FLAG = flag(CommandFlag.builder("--paranoid")
|
||||
private final CommandFlag paranoidFlag = flag(CommandFlag.builder("--paranoid")
|
||||
.addAlias("-p")
|
||||
.build());
|
||||
|
||||
@ -95,9 +95,9 @@ final class DumpsCommand extends CoreCommand {
|
||||
final ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
// Grab all our flags
|
||||
final boolean paranoid = parsedFlags.hasFlag(PARANOID_FLAG);
|
||||
final LogsTypeOption logsType = parsedFlags.flagValue(LOGS_FLAG, LogsTypeOption.MCLOGS);
|
||||
final ServiceTypeOption servicesType = parsedFlags.flagValue(UPLOAD_FLAG, ServiceTypeOption.PASTESDEV);
|
||||
final boolean paranoid = parsedFlags.hasFlag(paranoidFlag);
|
||||
final LogsTypeOption logsType = parsedFlags.flagValue(logsFlag, LogsTypeOption.MCLOGS);
|
||||
final ServiceTypeOption servicesType = parsedFlags.flagValue(uploadFlag, ServiceTypeOption.PASTESDEV);
|
||||
|
||||
// Initialise and add info to the debug event
|
||||
MVDumpsDebugInfoEvent versionEvent = new MVDumpsDebugInfoEvent();
|
||||
|
@ -35,14 +35,17 @@ import org.mvplugins.multiverse.core.display.filters.RegexContentFilter;
|
||||
import org.mvplugins.multiverse.core.display.handlers.PagedSendHandler;
|
||||
import org.mvplugins.multiverse.core.display.parsers.MapContentProvider;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
|
||||
import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
@Subcommand("gamerule|rule|gamerules|rules")
|
||||
final class GameruleCommand extends CoreCommand {
|
||||
|
||||
private final CommandValueFlag<Integer> PAGE_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<Integer> pageFlag = flag(CommandValueFlag
|
||||
.builder("--page", Integer.class)
|
||||
.addAlias("-p")
|
||||
.context(value -> {
|
||||
@ -54,7 +57,7 @@ final class GameruleCommand extends CoreCommand {
|
||||
})
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<ContentFilter> FILTER_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<ContentFilter> filterFlag = flag(CommandValueFlag
|
||||
.builder("--filter", ContentFilter.class)
|
||||
.addAlias("-f")
|
||||
.context(value -> {
|
||||
@ -98,10 +101,10 @@ final class GameruleCommand extends CoreCommand {
|
||||
World bukkitWorld = world.getBukkitWorld().getOrNull();
|
||||
if (bukkitWorld == null || !bukkitWorld.setGameRule(gamerule, value)) {
|
||||
issuer.sendError(MVCorei18n.GAMERULE_SET_FAILED,
|
||||
"{gamerule}", gamerule.getName(),
|
||||
"{value}", value.toString(),
|
||||
"{world}", world.getName(),
|
||||
"{type}", gamerule.getType().getName());
|
||||
Replace.GAMERULE.with(gamerule.getName()),
|
||||
Replace.VALUE.with(value.toString()),
|
||||
Replace.WORLD.with(world.getName()),
|
||||
replace("{type}").with(gamerule.getType().getName()));
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
@ -109,14 +112,14 @@ final class GameruleCommand extends CoreCommand {
|
||||
if (success) {
|
||||
if (worlds.length == 1) {
|
||||
issuer.sendInfo(MVCorei18n.GAMERULE_SET_SUCCESS_SINGLE,
|
||||
"{gamerule}", gamerule.getName(),
|
||||
"{value}", value.toString(),
|
||||
"{world}", worlds[0].getName());
|
||||
Replace.GAMERULE.with(gamerule.getName()),
|
||||
Replace.VALUE.with(value.toString()),
|
||||
Replace.WORLD.with(worlds[0].getName()));
|
||||
} else if (worlds.length > 1) {
|
||||
issuer.sendInfo(MVCorei18n.GAMERULE_SET_SUCCESS_MULTIPLE,
|
||||
"{gamerule}", gamerule.getName(),
|
||||
"{value}", value.toString(),
|
||||
"{count}", String.valueOf(worlds.length));
|
||||
Replace.GAMERULE.with(gamerule.getName()),
|
||||
Replace.VALUE.with(value.toString()),
|
||||
Replace.COUNT.with(String.valueOf(worlds.length)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -138,25 +141,26 @@ final class GameruleCommand extends CoreCommand {
|
||||
@Description("{@@mv-core.gamerule.reset.world.description}")
|
||||
LoadedMultiverseWorld[] worlds) {
|
||||
AtomicBoolean success = new AtomicBoolean(true);
|
||||
Arrays.stream(worlds).forEach(world -> world.getBukkitWorld().peek(bukkitWorld -> {
|
||||
bukkitWorld.setGameRule(gamerule, bukkitWorld.getGameRuleDefault(gamerule));
|
||||
}).onEmpty(() -> {
|
||||
success.set(false);
|
||||
issuer.sendError(MVCorei18n.GAMERULE_RESET_FAILED,
|
||||
"{gamerule}", gamerule.getName(),
|
||||
"{world}", world.getName());
|
||||
}));
|
||||
Arrays.stream(worlds)
|
||||
.forEach(world -> world.getBukkitWorld()
|
||||
.peek(bukkitWorld -> bukkitWorld.setGameRule(gamerule, bukkitWorld.getGameRuleDefault(gamerule)))
|
||||
.onEmpty(() -> {
|
||||
success.set(false);
|
||||
issuer.sendError(MVCorei18n.GAMERULE_RESET_FAILED,
|
||||
Replace.GAMERULE.with(gamerule.getName()),
|
||||
Replace.WORLD.with(world.getName()));
|
||||
}));
|
||||
|
||||
// Tell user if it was successful
|
||||
if (success.get()) {
|
||||
if (worlds.length == 1) {
|
||||
issuer.sendInfo(MVCorei18n.GAMERULE_RESET_SUCCESS_SINGLE,
|
||||
"{gamerule}", gamerule.getName(),
|
||||
"{world}", worlds[0].getName());
|
||||
Replace.GAMERULE.with(gamerule.getName()),
|
||||
Replace.WORLD.with(worlds[0].getName()));
|
||||
} else if (worlds.length > 1) {
|
||||
issuer.sendInfo(MVCorei18n.GAMERULE_RESET_SUCCESS_MULTIPLE,
|
||||
"{gamerule}", gamerule.getName(),
|
||||
"{count}", String.valueOf(worlds.length));
|
||||
Replace.GAMERULE.with(gamerule.getName()),
|
||||
Replace.COUNT.with(String.valueOf(worlds.length)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -187,8 +191,8 @@ final class GameruleCommand extends CoreCommand {
|
||||
.withSendHandler(PagedSendHandler.create()
|
||||
.withHeader(this.getListTitle(issuer, world.getBukkitWorld().getOrNull()))
|
||||
.doPagination(true)
|
||||
.withTargetPage(parsedFlags.flagValue(PAGE_FLAG, 1))
|
||||
.withFilter(parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get())))
|
||||
.withTargetPage(parsedFlags.flagValue(pageFlag, 1))
|
||||
.withFilter(parsedFlags.flagValue(filterFlag, DefaultContentFilter.get())))
|
||||
.send(issuer);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ final class GeneratorsCommand extends CoreCommand {
|
||||
|
||||
private final GeneratorProvider generatorProvider;
|
||||
|
||||
private final CommandValueFlag<Integer> PAGE_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<Integer> pageFlag = flag(CommandValueFlag
|
||||
.builder("--page", Integer.class)
|
||||
.addAlias("-p")
|
||||
.context(value -> {
|
||||
@ -50,7 +50,7 @@ final class GeneratorsCommand extends CoreCommand {
|
||||
})
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<ContentFilter> FILTER_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<ContentFilter> filterFlag = flag(CommandValueFlag
|
||||
.builder("--filter", ContentFilter.class)
|
||||
.addAlias("-f")
|
||||
.context(value -> {
|
||||
@ -97,8 +97,8 @@ final class GeneratorsCommand extends CoreCommand {
|
||||
.withSendHandler(PagedSendHandler.create()
|
||||
.withHeader("%s====[ Multiverse Generator List ]====", ChatColor.AQUA)
|
||||
.doPagination(true)
|
||||
.withTargetPage(parsedFlags.flagValue(PAGE_FLAG, 1))
|
||||
.withFilter(parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get())))
|
||||
.withTargetPage(parsedFlags.flagValue(pageFlag, 1))
|
||||
.withFilter(parsedFlags.flagValue(filterFlag, DefaultContentFilter.get())))
|
||||
.send(issuer);
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,10 @@ import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
import org.mvplugins.multiverse.core.world.options.ImportWorldOptions;
|
||||
import org.mvplugins.multiverse.core.world.generators.GeneratorProvider;
|
||||
import org.mvplugins.multiverse.core.world.options.ImportWorldOptions;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
@ -35,20 +36,20 @@ final class ImportCommand extends CoreCommand {
|
||||
private final WorldManager worldManager;
|
||||
|
||||
private GeneratorProvider generatorProvider;
|
||||
private final CommandValueFlag<String> GENERATOR_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<String> generatorFlag = flag(CommandValueFlag
|
||||
.builder("--generator", String.class)
|
||||
.addAlias("-g")
|
||||
.completion(input -> generatorProvider.suggestGeneratorString(input))
|
||||
.build());
|
||||
|
||||
private final CommandFlag NO_ADJUST_SPAWN_FLAG = flag(CommandFlag.builder("--no-adjust-spawn")
|
||||
private final CommandFlag noAdjustSpawnFlag = flag(CommandFlag.builder("--no-adjust-spawn")
|
||||
.addAlias("-n")
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<Biome> BIOME_FLAG = flag(CommandValueFlag.builder("--biome", Biome.class)
|
||||
private final CommandValueFlag<Biome> biomeFlag = flag(CommandValueFlag.builder("--biome", Biome.class)
|
||||
.addAlias("-b")
|
||||
.completion(input -> Lists.newArrayList(Registry.BIOME).stream()
|
||||
.filter(biome -> biome !=Biome.CUSTOM)
|
||||
.filter(biome -> biome != Biome.CUSTOM)
|
||||
.map(biome -> biome.getKey().getKey())
|
||||
.toList())
|
||||
.context(biomeStr -> Registry.BIOME.get(NamespacedKey.minecraft(biomeStr)))
|
||||
@ -88,15 +89,15 @@ final class ImportCommand extends CoreCommand {
|
||||
String[] flags) {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
issuer.sendInfo(MVCorei18n.IMPORT_IMPORTING, "{world}", worldName);
|
||||
issuer.sendInfo(MVCorei18n.IMPORT_IMPORTING, Replace.WORLD.with(worldName));
|
||||
worldManager.importWorld(ImportWorldOptions.worldName(worldName)
|
||||
.biome(parsedFlags.flagValue(BIOME_FLAG, Biome.CUSTOM))
|
||||
.biome(parsedFlags.flagValue(biomeFlag, Biome.CUSTOM))
|
||||
.environment(environment)
|
||||
.generator(parsedFlags.flagValue(GENERATOR_FLAG, String.class))
|
||||
.useSpawnAdjust(!parsedFlags.hasFlag(NO_ADJUST_SPAWN_FLAG)))
|
||||
.generator(parsedFlags.flagValue(generatorFlag, String.class))
|
||||
.useSpawnAdjust(!parsedFlags.hasFlag(noAdjustSpawnFlag)))
|
||||
.onSuccess(newWorld -> {
|
||||
Logging.fine("World import success: " + newWorld);
|
||||
issuer.sendInfo(MVCorei18n.IMPORT_SUCCESS, "{world}", newWorld.getName());
|
||||
issuer.sendInfo(MVCorei18n.IMPORT_SUCCESS, Replace.WORLD.with(newWorld.getName()));
|
||||
})
|
||||
.onFailure(failure -> {
|
||||
Logging.fine("World import failure: " + failure);
|
||||
|
@ -36,7 +36,7 @@ import org.mvplugins.multiverse.core.world.MultiverseWorld;
|
||||
@CommandAlias("mv")
|
||||
final class InfoCommand extends CoreCommand {
|
||||
|
||||
private final CommandValueFlag<Integer> PAGE_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<Integer> pageFlag = flag(CommandValueFlag
|
||||
.builder("--page", Integer.class)
|
||||
.addAlias("-p")
|
||||
.context(value -> {
|
||||
@ -48,7 +48,7 @@ final class InfoCommand extends CoreCommand {
|
||||
})
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<ContentFilter> FILTER_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<ContentFilter> filterFlag = flag(CommandValueFlag
|
||||
.builder("--filter", ContentFilter.class)
|
||||
.addAlias("-f")
|
||||
.context(value -> {
|
||||
@ -101,8 +101,8 @@ final class InfoCommand extends CoreCommand {
|
||||
.withSendHandler(PagedSendHandler.create()
|
||||
.withHeader(getTitle(world))
|
||||
.doPagination(true)
|
||||
.withTargetPage(parsedFlags.flagValue(PAGE_FLAG, 1))
|
||||
.withFilter(parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get())))
|
||||
.withTargetPage(parsedFlags.flagValue(pageFlag, 1))
|
||||
.withFilter(parsedFlags.flagValue(filterFlag, DefaultContentFilter.get())))
|
||||
.send(issuer);
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ final class InfoCommand extends CoreCommand {
|
||||
outMap.put("Difficulty", world.getDifficulty().toString());
|
||||
outMap.put("Spawn Location", locationManipulation.strCoords(world.getSpawnLocation()));
|
||||
outMap.put("Seed", String.valueOf(world.getSeed()));
|
||||
getEntryFeeInfo(outMap, world); // Entry fee/reward
|
||||
getEntryFeeInfo(outMap, world);
|
||||
outMap.put("Respawn World", world.getRespawnWorldName());
|
||||
outMap.put("World Type", world.getWorldType().get().toString());
|
||||
outMap.put("Biome", world.getBiome() == null ? "@vanilla" : world.getBiome().getKey().getKey());
|
||||
@ -131,8 +131,8 @@ final class InfoCommand extends CoreCommand {
|
||||
outMap.put("Hunger Depletes", String.valueOf(world.getHunger()));
|
||||
outMap.put("Keep Spawn In Memory", String.valueOf(world.getKeepSpawnInMemory()));
|
||||
outMap.put("PVP Enabled", String.valueOf(world.getPvp()));
|
||||
getAnimalSpawningInfo(outMap, world); // Animals that can spawn
|
||||
getMonsterSpawningInfo(outMap, world); // Monsters that can spawn
|
||||
getAnimalSpawningInfo(outMap, world);
|
||||
getMonsterSpawningInfo(outMap, world);
|
||||
|
||||
return outMap;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ final class ListCommand extends CoreCommand {
|
||||
private final WorldManager worldManager;
|
||||
private final WorldEntryCheckerProvider worldEntryCheckerProvider;
|
||||
|
||||
private final CommandValueFlag<Integer> PAGE_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<Integer> pageFlag = flag(CommandValueFlag
|
||||
.builder("--page", Integer.class)
|
||||
.addAlias("-p")
|
||||
.context(value -> {
|
||||
@ -51,7 +51,7 @@ final class ListCommand extends CoreCommand {
|
||||
})
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<ContentFilter> FILTER_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<ContentFilter> filterFlag = flag(CommandValueFlag
|
||||
.builder("--filter", ContentFilter.class)
|
||||
.addAlias("-f")
|
||||
.context(value -> {
|
||||
@ -63,7 +63,7 @@ final class ListCommand extends CoreCommand {
|
||||
})
|
||||
.build());
|
||||
|
||||
private final CommandFlag RAW_FLAG = flag(CommandFlag.builder("--raw")
|
||||
private final CommandFlag rawFlag = flag(CommandFlag.builder("--raw")
|
||||
.addAlias("-r")
|
||||
.build());
|
||||
|
||||
@ -91,11 +91,11 @@ final class ListCommand extends CoreCommand {
|
||||
String[] flags) {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
ContentDisplay.create()
|
||||
.addContent(ListContentProvider.forContent(getListContents(issuer, parsedFlags.hasFlag(RAW_FLAG))))
|
||||
.addContent(ListContentProvider.forContent(getListContents(issuer, parsedFlags.hasFlag(rawFlag))))
|
||||
.withSendHandler(PagedSendHandler.create()
|
||||
.withHeader("%s====[ Multiverse World List ]====", ChatColor.GOLD)
|
||||
.withTargetPage(parsedFlags.flagValue(PAGE_FLAG, 1))
|
||||
.withFilter(parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get())))
|
||||
.withTargetPage(parsedFlags.flagValue(pageFlag, 1))
|
||||
.withFilter(parsedFlags.flagValue(filterFlag, DefaultContentFilter.get())))
|
||||
.send(issuer);
|
||||
}
|
||||
|
||||
@ -106,7 +106,8 @@ final class ListCommand extends CoreCommand {
|
||||
worldManager.getLoadedWorlds().stream()
|
||||
.filter(world -> worldEntryChecker.canAccessWorld(world).isSuccess())
|
||||
.filter(world -> canSeeWorld(issuer, world))
|
||||
.map(world -> hiddenText(world) + getWorldName(world, useRawNames) + " - " + parseColouredEnvironment(world.getEnvironment()))
|
||||
.map(world -> hiddenText(world) + getWorldName(world, useRawNames) + " - "
|
||||
+ parseColouredEnvironment(world.getEnvironment()))
|
||||
.sorted()
|
||||
.forEach(worldList::add);
|
||||
|
||||
@ -120,7 +121,8 @@ final class ListCommand extends CoreCommand {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a world's name or alias
|
||||
* Gets a world's name or alias.
|
||||
*
|
||||
* @param world The world to retrieve the name of
|
||||
* @param useRawNames True to return the name, false to return the alias
|
||||
* @return The name
|
||||
@ -135,7 +137,8 @@ final class ListCommand extends CoreCommand {
|
||||
|
||||
private boolean canSeeWorld(MVCommandIssuer issuer, MultiverseWorld world) {
|
||||
return !world.isHidden()
|
||||
|| issuer.hasPermission("multiverse.core.modify"); // TODO: Refactor stray permission check
|
||||
// TODO: Refactor stray permission check
|
||||
|| issuer.hasPermission("multiverse.core.modify");
|
||||
}
|
||||
|
||||
private String hiddenText(MultiverseWorld world) {
|
||||
|
@ -16,6 +16,7 @@ import org.jvnet.hk2.annotations.Service;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
@Service
|
||||
@ -44,11 +45,11 @@ final class LoadCommand extends CoreCommand {
|
||||
@Syntax("<world>")
|
||||
@Description("{@@mv-core.load.world.description}")
|
||||
String worldName) {
|
||||
issuer.sendInfo(MVCorei18n.LOAD_LOADING, "{world}", worldName);
|
||||
issuer.sendInfo(MVCorei18n.LOAD_LOADING, Replace.WORLD.with(worldName));
|
||||
worldManager.loadWorld(worldName)
|
||||
.onSuccess(newWorld -> {
|
||||
Logging.fine("World load success: " + newWorld);
|
||||
issuer.sendInfo(MVCorei18n.LOAD_SUCCESS, "{world}", newWorld.getName());
|
||||
issuer.sendInfo(MVCorei18n.LOAD_SUCCESS, Replace.WORLD.with(newWorld.getName()));
|
||||
}).onFailure(failure -> {
|
||||
Logging.fine("World load failure: " + failure);
|
||||
issuer.sendError(failure.getFailureMessage());
|
||||
|
@ -40,7 +40,7 @@ final class ModifyCommand extends CoreCommand {
|
||||
@CommandCompletion("@mvworlds:scope=both @propsmodifyaction @mvworldpropsname @mvworldpropsvalue")
|
||||
@Syntax("[world] <set|add|remove|reset> <property> <value>")
|
||||
@Description("")
|
||||
void onModifyCommand(
|
||||
void onModifyCommand(// SUPPRESS CHECKSTYLE: ParameterNumber
|
||||
MVCommandIssuer issuer,
|
||||
|
||||
@Flags("resolve=issuerAware")
|
||||
@ -60,36 +60,23 @@ final class ModifyCommand extends CoreCommand {
|
||||
@Single
|
||||
@Syntax("[value]")
|
||||
@Description("")
|
||||
@Nullable String propertyValue
|
||||
) {
|
||||
@Nullable String propertyValue) {
|
||||
if (action.isRequireValue() && propertyValue == null) {
|
||||
issuer.sendMessage("You must specify a value to " + action.name().toLowerCase() + " '" + propertyName + "'.");
|
||||
issuer.sendMessage("You must specify a value to " + action.name().toLowerCase()
|
||||
+ " '" + propertyName + "'.");
|
||||
return;
|
||||
}
|
||||
|
||||
StringPropertyHandle worldPropertyHandle = world.getStringPropertyHandle();
|
||||
worldPropertyHandle.modifyPropertyString(propertyName, propertyValue, action).onSuccess(ignore -> {
|
||||
issuer.sendMessage("Property %s%s set to %s%s for world %s%s%s.".formatted(
|
||||
propertyName,
|
||||
ChatColor.BLUE,
|
||||
worldPropertyHandle.getProperty(propertyName).getOrNull(),
|
||||
ChatColor.BLUE,
|
||||
ChatColor.GRAY,
|
||||
world.getName(),
|
||||
ChatColor.BLUE
|
||||
));
|
||||
propertyName, ChatColor.BLUE, worldPropertyHandle.getProperty(propertyName).getOrNull(),
|
||||
ChatColor.BLUE, ChatColor.GRAY, world.getName(), ChatColor.BLUE));
|
||||
worldManager.saveWorldsConfig();
|
||||
}).onFailure(exception -> {
|
||||
issuer.sendMessage("Failed to %s%s property %s%s to %s%s for world %s%s.".formatted(
|
||||
action.name().toLowerCase(),
|
||||
ChatColor.BLUE,
|
||||
propertyName,
|
||||
ChatColor.BLUE,
|
||||
propertyValue,
|
||||
ChatColor.BLUE,
|
||||
world.getName(),
|
||||
ChatColor.BLUE
|
||||
));
|
||||
action.name().toLowerCase(), ChatColor.BLUE, propertyName, ChatColor.BLUE,
|
||||
propertyValue, ChatColor.BLUE, world.getName(), ChatColor.BLUE));
|
||||
issuer.sendMessage(exception.getMessage());
|
||||
});
|
||||
}
|
||||
|
@ -24,16 +24,15 @@ import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
|
||||
import org.mvplugins.multiverse.core.commandtools.queue.CommandQueuePayload;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.utils.WorldTickDeferrer;
|
||||
import org.mvplugins.multiverse.core.locale.message.Message;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.utils.WorldTickDeferrer;
|
||||
import org.mvplugins.multiverse.core.utils.result.Async;
|
||||
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
import org.mvplugins.multiverse.core.world.helpers.PlayerWorldTeleporter;
|
||||
import org.mvplugins.multiverse.core.world.options.RegenWorldOptions;
|
||||
|
||||
import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
final class RegenCommand extends CoreCommand {
|
||||
@ -42,25 +41,27 @@ final class RegenCommand extends CoreCommand {
|
||||
private final PlayerWorldTeleporter playerWorldTeleporter;
|
||||
private final WorldTickDeferrer worldTickDeferrer;
|
||||
|
||||
private final CommandValueFlag<String> SEED_FLAG = flag(CommandValueFlag.builder("--seed", String.class)
|
||||
private final Random random = new Random();
|
||||
|
||||
private final CommandValueFlag<String> seedFlag = flag(CommandValueFlag.builder("--seed", String.class)
|
||||
.addAlias("-s")
|
||||
.completion(input -> Collections.singleton(String.valueOf(new Random().nextLong())))
|
||||
.completion(input -> Collections.singleton(String.valueOf(random.nextLong())))
|
||||
.optional()
|
||||
.build());
|
||||
|
||||
private final CommandFlag RESET_WORLD_CONFIG_FLAG = flag(CommandFlag.builder("--reset-world-config")
|
||||
private final CommandFlag resetWorldConfigFlag = flag(CommandFlag.builder("--reset-world-config")
|
||||
.addAlias("-wc")
|
||||
.build());
|
||||
|
||||
private final CommandFlag RESET_GAMERULES_FLAG = flag(CommandFlag.builder("--reset-gamerules")
|
||||
private final CommandFlag resetGamerulesFlag = flag(CommandFlag.builder("--reset-gamerules")
|
||||
.addAlias("-gm")
|
||||
.build());
|
||||
|
||||
private final CommandFlag RESET_WORLD_BORDER_FLAG = flag(CommandFlag.builder("--reset-world-border")
|
||||
private final CommandFlag resetWorldBorderFlag = flag(CommandFlag.builder("--reset-world-border")
|
||||
.addAlias("-wb")
|
||||
.build());
|
||||
|
||||
private final CommandFlag REMOVE_PLAYERS_FLAG = flag(CommandFlag.builder("--remove-players")
|
||||
private final CommandFlag removePlayersFlag = flag(CommandFlag.builder("--remove-players")
|
||||
.addAlias("-r")
|
||||
.build());
|
||||
|
||||
@ -99,14 +100,14 @@ final class RegenCommand extends CoreCommand {
|
||||
.issuer(issuer)
|
||||
.action(() -> runRegenCommand(issuer, world, parsedFlags))
|
||||
.prompt(Message.of(MVCorei18n.REGEN_PROMPT, "",
|
||||
replace("{world}").with(world.getName()))));
|
||||
Replace.WORLD.with(world.getName()))));
|
||||
}
|
||||
|
||||
private void runRegenCommand(MVCommandIssuer issuer, LoadedMultiverseWorld world, ParsedCommandFlags parsedFlags) {
|
||||
issuer.sendInfo(MVCorei18n.REGEN_REGENERATING, "{world}", world.getName());
|
||||
issuer.sendInfo(MVCorei18n.REGEN_REGENERATING, Replace.WORLD.with(world.getName()));
|
||||
List<Player> worldPlayers = world.getPlayers().getOrElse(Collections.emptyList());
|
||||
|
||||
var future = parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG)
|
||||
var future = parsedFlags.hasFlag(removePlayersFlag)
|
||||
? playerWorldTeleporter.removeFromWorld(world)
|
||||
: Async.completedFuture(Collections.emptyList());
|
||||
|
||||
@ -122,16 +123,16 @@ final class RegenCommand extends CoreCommand {
|
||||
List<Player> worldPlayers) {
|
||||
//todo: Change biome on regen
|
||||
RegenWorldOptions regenWorldOptions = RegenWorldOptions.world(world)
|
||||
.randomSeed(parsedFlags.hasFlag(SEED_FLAG))
|
||||
.seed(parsedFlags.flagValue(SEED_FLAG))
|
||||
.keepWorldConfig(!parsedFlags.hasFlag(RESET_WORLD_CONFIG_FLAG))
|
||||
.keepGameRule(!parsedFlags.hasFlag(RESET_GAMERULES_FLAG))
|
||||
.keepWorldBorder(!parsedFlags.hasFlag(RESET_WORLD_BORDER_FLAG));
|
||||
.randomSeed(parsedFlags.hasFlag(seedFlag))
|
||||
.seed(parsedFlags.flagValue(seedFlag))
|
||||
.keepWorldConfig(!parsedFlags.hasFlag(resetWorldConfigFlag))
|
||||
.keepGameRule(!parsedFlags.hasFlag(resetGamerulesFlag))
|
||||
.keepWorldBorder(!parsedFlags.hasFlag(resetWorldBorderFlag));
|
||||
|
||||
worldManager.regenWorld(regenWorldOptions).onSuccess(newWorld -> {
|
||||
Logging.fine("World regen success: " + newWorld);
|
||||
issuer.sendInfo(MVCorei18n.REGEN_SUCCESS, "{world}", newWorld.getName());
|
||||
if (parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG)) {
|
||||
issuer.sendInfo(MVCorei18n.REGEN_SUCCESS, Replace.WORLD.with(newWorld.getName()));
|
||||
if (parsedFlags.hasFlag(removePlayersFlag)) {
|
||||
playerWorldTeleporter.teleportPlayersToWorld(worldPlayers, newWorld);
|
||||
}
|
||||
}).onFailure(failure -> {
|
||||
|
@ -21,6 +21,7 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.utils.result.Async;
|
||||
import org.mvplugins.multiverse.core.world.MultiverseWorld;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
@ -33,7 +34,7 @@ final class RemoveCommand extends CoreCommand {
|
||||
private final WorldManager worldManager;
|
||||
private final PlayerWorldTeleporter playerWorldTeleporter;
|
||||
|
||||
private final CommandFlag REMOVE_PLAYERS_FLAG = flag(CommandFlag.builder("--remove-players")
|
||||
private final CommandFlag removePlayersFlag = flag(CommandFlag.builder("--remove-players")
|
||||
.addAlias("-r")
|
||||
.build());
|
||||
|
||||
@ -68,7 +69,7 @@ final class RemoveCommand extends CoreCommand {
|
||||
String[] flags) {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
var future = parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG)
|
||||
var future = parsedFlags.hasFlag(removePlayersFlag)
|
||||
? worldManager.getLoadedWorld(world)
|
||||
.map(playerWorldTeleporter::removeFromWorld)
|
||||
.getOrElse(Async.completedFuture(Collections.emptyList()))
|
||||
@ -81,7 +82,7 @@ final class RemoveCommand extends CoreCommand {
|
||||
worldManager.removeWorld(world)
|
||||
.onSuccess(removedWorldName -> {
|
||||
Logging.fine("World remove success: " + removedWorldName);
|
||||
issuer.sendInfo(MVCorei18n.REMOVE_SUCCESS, "{world}", removedWorldName);
|
||||
issuer.sendInfo(MVCorei18n.REMOVE_SUCCESS, Replace.WORLD.with(removedWorldName));
|
||||
}).onFailure(failure -> {
|
||||
Logging.fine("World remove failure: " + failure);
|
||||
issuer.sendError(failure.getFailureMessage());
|
||||
|
@ -12,12 +12,13 @@ import jakarta.inject.Inject;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
final public class SetSpawnCommand extends CoreCommand {
|
||||
final class SetSpawnCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
@ -50,13 +51,15 @@ final public class SetSpawnCommand extends CoreCommand {
|
||||
worldManager.getLoadedWorld(finalLocation.getWorld())
|
||||
.peek(mvWorld -> mvWorld.setSpawnLocation(finalLocation)
|
||||
.onSuccess(ignore -> issuer.sendMessage(
|
||||
"Successfully set spawn in " + mvWorld.getName() + " to " + prettyLocation(mvWorld.getSpawnLocation())))
|
||||
"Successfully set spawn in " + mvWorld.getName() + " to "
|
||||
+ prettyLocation(mvWorld.getSpawnLocation())))
|
||||
.onFailure(e -> issuer.sendMessage(e.getLocalizedMessage())))
|
||||
.onEmpty(() -> issuer.sendMessage("That world is not loaded or does not exist!"))
|
||||
).onEmpty(() -> issuer.sendMessage("You must specify a location in the format: worldname:x,y,z"));
|
||||
.onEmpty(() -> issuer.sendMessage("That world is not loaded or does not exist!")))
|
||||
.onEmpty(() -> issuer.sendMessage("You must specify a location in the format: worldname:x,y,z"));
|
||||
}
|
||||
|
||||
private String prettyLocation(Location location) {
|
||||
return location.getX() + ", " + location.getY() + ", " + location.getZ() + ". pitch:" + location.getPitch() + ", yaw:" + location.getYaw();
|
||||
return location.getX() + ", " + location.getY() + ", " + location.getZ() + ". pitch:" + location.getPitch()
|
||||
+ ", yaw:" + location.getYaw();
|
||||
}
|
||||
}
|
||||
|
@ -1,32 +1,39 @@
|
||||
package org.mvplugins.multiverse.core.commands;
|
||||
|
||||
import co.aikar.commands.annotation.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Flags;
|
||||
import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import co.aikar.commands.annotation.Syntax;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.Message;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker;
|
||||
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
|
||||
import org.mvplugins.multiverse.core.teleportation.TeleportFailureReason;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.Message;
|
||||
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
final class SpawnCommand extends CoreCommand {
|
||||
@ -35,7 +42,7 @@ final class SpawnCommand extends CoreCommand {
|
||||
private final AsyncSafetyTeleporter safetyTeleporter;
|
||||
private final CorePermissionsChecker permissionsChecker;
|
||||
|
||||
private final CommandFlag UNSAFE_FLAG = flag(CommandFlag.builder("--unsafe")
|
||||
private final CommandFlag unsafeFlag = flag(CommandFlag.builder("--unsafe")
|
||||
.addAlias("-u")
|
||||
.build());
|
||||
|
||||
@ -53,7 +60,8 @@ final class SpawnCommand extends CoreCommand {
|
||||
@CommandAlias("mvspawn")
|
||||
@Subcommand("spawn")
|
||||
@CommandPermission("@mvspawn")
|
||||
@CommandCompletion("@playersarray:checkPermissions=@mvspawnother|@flags:groupName=mvspawncommand,resolveUntil=arg1 @flags:groupName=mvspawncommand")
|
||||
@CommandCompletion("@playersarray:checkPermissions=@mvspawnother|@flags:groupName=mvspawncommand,resolveUntil=arg1"
|
||||
+ " @flags:groupName=mvspawncommand")
|
||||
@Syntax("[player]")
|
||||
@Description("{@@mv-core.spawn.description}")
|
||||
void onSpawnTpCommand(
|
||||
@ -70,12 +78,14 @@ final class SpawnCommand extends CoreCommand {
|
||||
String[] flags) {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
Map<World, List<Player>> playersByWorld = Arrays.stream(players).collect(Collectors.groupingBy(Entity::getWorld));
|
||||
Map<World, List<Player>> playersByWorld = Arrays.stream(players)
|
||||
.collect(Collectors.groupingBy(Entity::getWorld));
|
||||
playersByWorld.forEach((world, playerList) ->
|
||||
teleportPlayersToSpawn(issuer, world, playerList, !parsedFlags.hasFlag(UNSAFE_FLAG)));
|
||||
teleportPlayersToSpawn(issuer, world, playerList, !parsedFlags.hasFlag(unsafeFlag)));
|
||||
}
|
||||
|
||||
private void teleportPlayersToSpawn(MVCommandIssuer issuer, World world, List<Player> players, boolean checkSafety) {
|
||||
private void teleportPlayersToSpawn(MVCommandIssuer issuer, World world,
|
||||
List<Player> players, boolean checkSafety) {
|
||||
LoadedMultiverseWorld mvWorld = worldManager.getLoadedWorld(world).getOrNull();
|
||||
if (mvWorld == null) {
|
||||
issuer.sendMessage("The world '" + world.getName() + "' is not a multiverse world!");
|
||||
@ -98,49 +108,54 @@ final class SpawnCommand extends CoreCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSingleTeleport(MVCommandIssuer issuer, LoadedMultiverseWorld mvWorld, Player player, boolean checkSafety) {
|
||||
private void handleSingleTeleport(MVCommandIssuer issuer, LoadedMultiverseWorld mvWorld,
|
||||
Player player, boolean checkSafety) {
|
||||
safetyTeleporter.to(mvWorld.getSpawnLocation())
|
||||
.by(issuer)
|
||||
.checkSafety(checkSafety)
|
||||
.teleport(player)
|
||||
.onSuccess(() -> issuer.sendInfo(MVCorei18n.SPAWN_SUCCESS,
|
||||
replace("{player}").with(player.equals(issuer.getPlayer()) ?
|
||||
Message.of(MVCorei18n.GENERIC_YOU)
|
||||
Replace.PLAYER.with(player.equals(issuer.getPlayer())
|
||||
? Message.of(MVCorei18n.GENERIC_YOU)
|
||||
: Message.of(player.getName())),
|
||||
replace("{world}").with(mvWorld.getName())))
|
||||
Replace.WORLD.with(mvWorld.getName())))
|
||||
.onFailure(failure -> issuer.sendError(MVCorei18n.SPAWN_FAILED,
|
||||
replace("{player}").with(player.equals(issuer.getPlayer()) ?
|
||||
Message.of(MVCorei18n.GENERIC_YOU)
|
||||
Replace.PLAYER.with(player.equals(issuer.getPlayer())
|
||||
? Message.of(MVCorei18n.GENERIC_YOU)
|
||||
: Message.of(player.getName())),
|
||||
replace("{world}").with(mvWorld.getName()),
|
||||
replace("{reason}").with(failure.getFailureMessage())));
|
||||
Replace.WORLD.with(mvWorld.getName()),
|
||||
Replace.REASON.with(failure.getFailureMessage())));
|
||||
}
|
||||
|
||||
private void handleMultiTeleport(MVCommandIssuer issuer, LoadedMultiverseWorld mvWorld, List<Player> players, boolean checkSafety) {
|
||||
private void handleMultiTeleport(MVCommandIssuer issuer, LoadedMultiverseWorld mvWorld,
|
||||
List<Player> players, boolean checkSafety) {
|
||||
safetyTeleporter.to(mvWorld.getSpawnLocation())
|
||||
.by(issuer)
|
||||
.checkSafety(checkSafety)
|
||||
.teleport(players)
|
||||
.thenAccept(attempts -> {
|
||||
int successCount = 0;
|
||||
Map<TeleportFailureReason, Integer> failures = new HashMap<>();
|
||||
Map<TeleportFailureReason, Integer> failures = new EnumMap<>(TeleportFailureReason.class);
|
||||
for (var attempt : attempts) {
|
||||
if (attempt.isSuccess()) {
|
||||
successCount++;
|
||||
} else {
|
||||
failures.compute(attempt.getFailureReason(), (reason, count) -> count == null ? 1 : count + 1);
|
||||
failures.compute(attempt.getFailureReason(),
|
||||
(reason, count) -> count == null ? 1 : count + 1);
|
||||
}
|
||||
}
|
||||
if (successCount > 0) {
|
||||
issuer.sendInfo(MVCorei18n.SPAWN_SUCCESS,
|
||||
replace("{player}").with(successCount + " players"),
|
||||
replace("{world}").with(mvWorld.getName()));
|
||||
// TODO should use {count} instead of {player} most likely
|
||||
Replace.PLAYER.with(successCount + " players"),
|
||||
Replace.WORLD.with(mvWorld.getName()));
|
||||
} else {
|
||||
for (var entry : failures.entrySet()) {
|
||||
issuer.sendError(MVCorei18n.SPAWN_FAILED,
|
||||
replace("{player}").with(entry.getValue() + " players"),
|
||||
replace("{world}").with(mvWorld.getName()),
|
||||
replace("{reason}").with(entry.getKey().getMessageKey()));
|
||||
// TODO should use {count} instead of {player} most likely
|
||||
Replace.PLAYER.with(entry.getValue() + " players"),
|
||||
Replace.WORLD.with(mvWorld.getName()),
|
||||
Replace.REASON.with(entry.getKey().getMessageKey()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.mvplugins.multiverse.core.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -25,13 +25,12 @@ import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
|
||||
import org.mvplugins.multiverse.core.config.MVCoreConfig;
|
||||
import org.mvplugins.multiverse.core.destination.DestinationInstance;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.Message;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker;
|
||||
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
|
||||
import org.mvplugins.multiverse.core.teleportation.TeleportFailureReason;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.Message;
|
||||
|
||||
import static org.mvplugins.multiverse.core.locale.message.MessageReplacement.replace;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
@ -41,7 +40,7 @@ final class TeleportCommand extends CoreCommand {
|
||||
private final CorePermissionsChecker permissionsChecker;
|
||||
private final AsyncSafetyTeleporter safetyTeleporter;
|
||||
|
||||
private final CommandFlag UNSAFE_FLAG = flag(CommandFlag.builder("--unsafe")
|
||||
private final CommandFlag unsafeFlag = flag(CommandFlag.builder("--unsafe")
|
||||
.addAlias("-u")
|
||||
.build());
|
||||
|
||||
@ -61,10 +60,9 @@ final class TeleportCommand extends CoreCommand {
|
||||
@Subcommand("teleport|tp")
|
||||
@CommandPermission("@mvteleport")
|
||||
@CommandCompletion(
|
||||
"@destinations:playerOnly|@playersarray:checkPermissions=@mvteleportother " +
|
||||
"@destinations:othersOnly|@flags:groupName=mvteleportcommand,resolveUntil=arg2 " +
|
||||
"@flags:groupName=mvteleportcommand"
|
||||
)
|
||||
"@destinations:playerOnly|@playersarray:checkPermissions=@mvteleportother "
|
||||
+ "@destinations:othersOnly|@flags:groupName=mvteleportcommand,resolveUntil=arg2 "
|
||||
+ "@flags:groupName=mvteleportcommand")
|
||||
@Syntax("[player] <destination> [--unsafe]")
|
||||
@Description("{@@mv-core.teleport.description}")
|
||||
void onTeleportCommand(
|
||||
@ -87,17 +85,19 @@ final class TeleportCommand extends CoreCommand {
|
||||
|
||||
if (players.length == 1) {
|
||||
teleportSinglePlayer(issuer, players[0], destination, parsedFlags);
|
||||
}
|
||||
else if (players.length > config.getConcurrentTeleportLimit()) {
|
||||
} else if (players.length > config.getConcurrentTeleportLimit()) {
|
||||
issuer.sendError(MVCorei18n.TELEPORT_TOOMANYPLAYERS,
|
||||
replace("{count}").with(config.getConcurrentTeleportLimit()));
|
||||
Replace.COUNT.with(config.getConcurrentTeleportLimit()));
|
||||
} else {
|
||||
teleportMultiplePlayers(issuer, players, destination, parsedFlags);
|
||||
}
|
||||
}
|
||||
|
||||
private void teleportSinglePlayer(MVCommandIssuer issuer, Player player, DestinationInstance<?, ?> destination, ParsedCommandFlags parsedFlags) {
|
||||
private void teleportSinglePlayer(MVCommandIssuer issuer, Player player,
|
||||
DestinationInstance<?, ?> destination,
|
||||
ParsedCommandFlags parsedFlags) {
|
||||
if (!permissionsChecker.checkTeleportPermissions(issuer.getIssuer(), player, destination)) {
|
||||
// TODO localize
|
||||
issuer.sendMessage(player == issuer.getPlayer()
|
||||
? "You do not have permission to teleport yourself!"
|
||||
: "You do not have permission to teleport other players!");
|
||||
@ -106,59 +106,69 @@ final class TeleportCommand extends CoreCommand {
|
||||
|
||||
safetyTeleporter.to(destination)
|
||||
.by(issuer)
|
||||
.checkSafety(!parsedFlags.hasFlag(UNSAFE_FLAG) && destination.checkTeleportSafety())
|
||||
.checkSafety(!parsedFlags.hasFlag(unsafeFlag) && destination.checkTeleportSafety())
|
||||
.teleport(player)
|
||||
.onSuccess(() -> issuer.sendInfo(MVCorei18n.TELEPORT_SUCCESS,
|
||||
replace("{player}").with(getYouOrName(issuer, player)),
|
||||
replace("{destination}").with(destination.toString())))
|
||||
Replace.PLAYER.with(getYouOrName(issuer, player)),
|
||||
Replace.DESTINATION.with(destination.toString())))
|
||||
.onFailure(failure -> issuer.sendError(MVCorei18n.TELEPORT_FAILED,
|
||||
replace("{player}").with(getYouOrName(issuer, player)),
|
||||
replace("{destination}").with(destination.toString()),
|
||||
replace("{reason}").with(failure.getFailureMessage())));
|
||||
Replace.PLAYER.with(getYouOrName(issuer, player)),
|
||||
Replace.DESTINATION.with(destination.toString()),
|
||||
Replace.REASON.with(failure.getFailureMessage())));
|
||||
}
|
||||
|
||||
private Message getYouOrName(MVCommandIssuer issuer, Player player) {
|
||||
return player == issuer.getPlayer() ? Message.of(MVCorei18n.GENERIC_YOU) : Message.of(player.getName());
|
||||
}
|
||||
|
||||
private void teleportMultiplePlayers(MVCommandIssuer issuer, Player[] players, DestinationInstance<?, ?> destination, ParsedCommandFlags parsedFlags) {
|
||||
private void teleportMultiplePlayers(MVCommandIssuer issuer, Player[] players,
|
||||
DestinationInstance<?, ?> destination,
|
||||
ParsedCommandFlags parsedFlags) {
|
||||
var selfPlayer = Arrays.stream(players).filter(p -> p == issuer.getPlayer()).findFirst();
|
||||
var otherPlayer = Arrays.stream(players).filter(p -> p != issuer.getPlayer()).findFirst();
|
||||
if (selfPlayer.isPresent() && !permissionsChecker.checkTeleportPermissions(issuer.getIssuer(), selfPlayer.get(), destination)) {
|
||||
if (selfPlayer.isPresent()
|
||||
&& !permissionsChecker.checkTeleportPermissions(issuer.getIssuer(), selfPlayer.get(), destination)) {
|
||||
// TODO localize
|
||||
issuer.sendMessage("You do not have permission to teleport yourself!");
|
||||
return;
|
||||
}
|
||||
if (otherPlayer.isPresent() && !permissionsChecker.checkTeleportPermissions(issuer.getIssuer(), otherPlayer.get(), destination)) {
|
||||
if (otherPlayer.isPresent()
|
||||
&& !permissionsChecker.checkTeleportPermissions(issuer.getIssuer(), otherPlayer.get(), destination)) {
|
||||
// TODO localize
|
||||
issuer.sendMessage("You do not have permission to teleport other players!");
|
||||
return;
|
||||
}
|
||||
safetyTeleporter.to(destination)
|
||||
.by(issuer)
|
||||
.checkSafety(!parsedFlags.hasFlag(UNSAFE_FLAG) && destination.checkTeleportSafety())
|
||||
.checkSafety(!parsedFlags.hasFlag(unsafeFlag) && destination.checkTeleportSafety())
|
||||
.teleport(List.of(players))
|
||||
.thenAccept(attempts -> {
|
||||
int successCount = 0;
|
||||
Map<TeleportFailureReason, Integer> failures = new HashMap<>();
|
||||
Map<TeleportFailureReason, Integer> failures = new EnumMap<>(TeleportFailureReason.class);
|
||||
for (var attempt : attempts) {
|
||||
if (attempt.isSuccess()) {
|
||||
successCount++;
|
||||
} else {
|
||||
failures.compute(attempt.getFailureReason(), (reason, count) -> count == null ? 1 : count + 1);
|
||||
failures.compute(attempt.getFailureReason(),
|
||||
(reason, count) -> count == null ? 1 : count + 1);
|
||||
}
|
||||
}
|
||||
if (successCount > 0) {
|
||||
Logging.finer("Teleported %s players to %s", successCount, destination);
|
||||
issuer.sendInfo(MVCorei18n.TELEPORT_SUCCESS,
|
||||
replace("{player}").with(successCount + " players"),
|
||||
replace("{destination}").with(destination.toString()));
|
||||
// TODO should use {count} instead of {player} most likely
|
||||
Replace.PLAYER.with(successCount + " players"),
|
||||
Replace.DESTINATION.with(destination.toString()));
|
||||
}
|
||||
if (!failures.isEmpty()) {
|
||||
for (var entry : failures.entrySet()) {
|
||||
Logging.finer("Failed to teleport %s players to %s: %s", entry.getValue(), destination, entry.getKey());
|
||||
Logging.finer("Failed to teleport %s players to %s: %s",
|
||||
entry.getValue(), destination, entry.getKey());
|
||||
issuer.sendError(MVCorei18n.TELEPORT_FAILED,
|
||||
replace("{player}").with(entry.getValue() + " players"),
|
||||
replace("{destination}").with(destination.toString()),
|
||||
replace("{reason}").with(Message.of(entry.getKey(), "")));
|
||||
// TODO should use {count} instead of {player} most likely
|
||||
Replace.PLAYER.with(entry.getValue() + " players"),
|
||||
Replace.DESTINATION.with(destination.toString()),
|
||||
Replace.REASON.with(Message.of(entry.getKey(), "")));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -19,6 +19,7 @@ import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.CommandFlag;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.ParsedCommandFlags;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.utils.result.Async;
|
||||
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
@ -32,11 +33,11 @@ final class UnloadCommand extends CoreCommand {
|
||||
private final WorldManager worldManager;
|
||||
private final PlayerWorldTeleporter playerWorldTeleporter;
|
||||
|
||||
private final CommandFlag REMOVE_PLAYERS_FLAG = flag(CommandFlag.builder("--remove-players")
|
||||
private final CommandFlag removePlayersFlag = flag(CommandFlag.builder("--remove-players")
|
||||
.addAlias("-r")
|
||||
.build());
|
||||
|
||||
private final CommandFlag NO_SAVE_FLAG = flag(CommandFlag.builder("--no-save")
|
||||
private final CommandFlag noSaveFlag = flag(CommandFlag.builder("--no-save")
|
||||
.addAlias("-n")
|
||||
.build());
|
||||
|
||||
@ -69,9 +70,9 @@ final class UnloadCommand extends CoreCommand {
|
||||
String[] flags) {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
issuer.sendInfo(MVCorei18n.UNLOAD_UNLOADING, "{world}", world.getAlias());
|
||||
issuer.sendInfo(MVCorei18n.UNLOAD_UNLOADING, Replace.WORLD.with(world.getAlias()));
|
||||
|
||||
var future = parsedFlags.hasFlag(REMOVE_PLAYERS_FLAG)
|
||||
var future = parsedFlags.hasFlag(removePlayersFlag)
|
||||
? playerWorldTeleporter.removeFromWorld(world)
|
||||
: Async.completedFuture(Collections.emptyList());
|
||||
|
||||
@ -80,11 +81,11 @@ final class UnloadCommand extends CoreCommand {
|
||||
|
||||
private void doWorldUnloading(MVCommandIssuer issuer, LoadedMultiverseWorld world, ParsedCommandFlags parsedFlags) {
|
||||
UnloadWorldOptions unloadWorldOptions = UnloadWorldOptions.world(world)
|
||||
.saveBukkitWorld(!parsedFlags.hasFlag(NO_SAVE_FLAG));
|
||||
.saveBukkitWorld(!parsedFlags.hasFlag(noSaveFlag));
|
||||
worldManager.unloadWorld(unloadWorldOptions)
|
||||
.onSuccess(loadedWorld -> {
|
||||
Logging.fine("World unload success: " + loadedWorld);
|
||||
issuer.sendInfo(MVCorei18n.UNLOAD_SUCCESS, "{world}", loadedWorld.getName());
|
||||
issuer.sendInfo(MVCorei18n.UNLOAD_SUCCESS, Replace.WORLD.with(loadedWorld.getName()));
|
||||
}).onFailure(failure -> {
|
||||
Logging.fine("World unload failure: " + failure);
|
||||
issuer.sendError(failure.getFailureMessage());
|
||||
|
@ -13,7 +13,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
|
@ -9,6 +9,7 @@ import co.aikar.commands.annotation.Subcommand;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.MultiverseCore;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.locale.MVCorei18n;
|
||||
@ -31,7 +32,9 @@ final class VersionCommand extends CoreCommand {
|
||||
@Description("{@@mv-core.version.description}")
|
||||
void versionCommand(BukkitCommandIssuer issuer) {
|
||||
issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_MV, "{version}", plugin.getDescription().getVersion());
|
||||
issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_AUTHORS, "{authors}", String.join(", ", plugin.getDescription().getAuthors()));
|
||||
issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_SECRETCODE); // An in joke I don't get...
|
||||
issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_AUTHORS,
|
||||
"{authors}", String.join(", ", plugin.getDescription().getAuthors()));
|
||||
// An in joke I don't get...
|
||||
issuer.sendMessage(MessageType.INFO, MVCorei18n.VERSION_SECRETCODE);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
package org.mvplugins.multiverse.core.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandCompletion;
|
||||
@ -14,6 +21,7 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandIssuer;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.flags.CommandValueFlag;
|
||||
@ -27,17 +35,11 @@ import org.mvplugins.multiverse.core.display.parsers.MapContentProvider;
|
||||
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
final public class WhoCommand extends CoreCommand {
|
||||
final class WhoCommand extends CoreCommand {
|
||||
|
||||
private final CommandValueFlag<Integer> PAGE_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<Integer> pageFlag = flag(CommandValueFlag
|
||||
.builder("--page", Integer.class)
|
||||
.addAlias("-p")
|
||||
.context(value -> {
|
||||
@ -49,7 +51,7 @@ final public class WhoCommand extends CoreCommand {
|
||||
})
|
||||
.build());
|
||||
|
||||
private final CommandValueFlag<ContentFilter> FILTER_FLAG = flag(CommandValueFlag
|
||||
private final CommandValueFlag<ContentFilter> filterFlag = flag(CommandValueFlag
|
||||
.builder("--filter", ContentFilter.class)
|
||||
.addAlias("-f")
|
||||
.context(value -> {
|
||||
@ -84,12 +86,11 @@ final public class WhoCommand extends CoreCommand {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
// Send the display
|
||||
getListDisplay(
|
||||
worldManager.getLoadedWorlds(),
|
||||
parsedFlags.flagValue(PAGE_FLAG, 1),
|
||||
parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get()),
|
||||
true
|
||||
).send(issuer);
|
||||
getListDisplay(worldManager.getLoadedWorlds(),
|
||||
parsedFlags.flagValue(pageFlag, 1),
|
||||
parsedFlags.flagValue(filterFlag, DefaultContentFilter.get()),
|
||||
true)
|
||||
.send(issuer);
|
||||
|
||||
}
|
||||
|
||||
@ -112,41 +113,38 @@ final public class WhoCommand extends CoreCommand {
|
||||
ParsedCommandFlags parsedFlags = parseFlags(flags);
|
||||
|
||||
// Send the display
|
||||
getListDisplay(
|
||||
inputtedWorld,
|
||||
parsedFlags.flagValue(PAGE_FLAG, 1),
|
||||
parsedFlags.flagValue(FILTER_FLAG, DefaultContentFilter.get()),
|
||||
false
|
||||
).send(issuer);
|
||||
getListDisplay(inputtedWorld,
|
||||
parsedFlags.flagValue(pageFlag, 1),
|
||||
parsedFlags.flagValue(filterFlag, DefaultContentFilter.get()),
|
||||
false)
|
||||
.send(issuer);
|
||||
}
|
||||
|
||||
private String phrasePlayerList(List<Player> players) {
|
||||
return players.stream().map(Player::getName).collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
private ContentDisplay getListDisplay(LoadedMultiverseWorld world, int page, ContentFilter filter, boolean ignoreEmptyWorlds) {
|
||||
private ContentDisplay getListDisplay(LoadedMultiverseWorld world, int page,
|
||||
ContentFilter filter, boolean ignoreEmptyWorlds) {
|
||||
Collection<LoadedMultiverseWorld> listingWorlds = new ArrayList<>();
|
||||
listingWorlds.add(world);
|
||||
return getListDisplay(listingWorlds, page, filter, ignoreEmptyWorlds);
|
||||
}
|
||||
|
||||
private ContentDisplay getListDisplay(Collection<LoadedMultiverseWorld> worlds, int page, ContentFilter filter, boolean ignoreEmptyWorlds) {
|
||||
HashMap<String, String> outMap = new HashMap<>();
|
||||
private ContentDisplay getListDisplay(Collection<LoadedMultiverseWorld> worlds, int page,
|
||||
ContentFilter filter, boolean ignoreEmptyWorlds) {
|
||||
Map<String, String> outMap = new HashMap<>();
|
||||
|
||||
// Add all the worlds to our hashmap
|
||||
for (LoadedMultiverseWorld world : worlds) {
|
||||
@Nullable List<Player> players = world.getPlayers().getOrNull();
|
||||
|
||||
// If the world has 0 players in it, say that it is empty
|
||||
if ((players == null || players.isEmpty()) && !ignoreEmptyWorlds) {
|
||||
if (players != null && !players.isEmpty()) {
|
||||
outMap.put(world.getAlias(), phrasePlayerList(players));
|
||||
} else if (!ignoreEmptyWorlds) {
|
||||
// If the world has 0 players in it, say that it is empty
|
||||
outMap.put(world.getAlias(), ChatColor.RED + "Empty");
|
||||
continue;
|
||||
}
|
||||
if (players == null || players.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
outMap.put(world.getAlias(), phrasePlayerList(players));
|
||||
}
|
||||
|
||||
return ContentDisplay.create()
|
||||
|
@ -11,7 +11,7 @@ import org.mvplugins.multiverse.core.locale.message.Message;
|
||||
*/
|
||||
public class MultiverseException extends Exception {
|
||||
|
||||
private final @Nullable Message message;
|
||||
private final transient @Nullable Message message;
|
||||
|
||||
/**
|
||||
* Creates a new exception with the given message.
|
||||
@ -22,7 +22,8 @@ public class MultiverseException extends Exception {
|
||||
* @param message The message for the exception
|
||||
*/
|
||||
public MultiverseException(@Nullable String message) {
|
||||
this(message != null ? Message.of(message) : null);
|
||||
super(message);
|
||||
this.message = message != null ? Message.of(message) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,41 +21,6 @@ public final class MessageReplacement {
|
||||
return new MessageReplacement.Key(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* A replacement key that maps to a value it can be replaced with.
|
||||
*
|
||||
*/
|
||||
public static final class Key {
|
||||
|
||||
private final @NotNull String key;
|
||||
|
||||
private Key(@NotNull String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a replacement for this key.
|
||||
*
|
||||
* @param replacement The replacement message
|
||||
* @return A new message replacement
|
||||
*/
|
||||
@Contract(value = "_ -> new", pure = true)
|
||||
public MessageReplacement with(@NotNull Message replacement) {
|
||||
return new MessageReplacement(key, replacement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a replacement for this key.
|
||||
*
|
||||
* @param replacement The replacement value, if null it will be replaced with a string equal to "null"
|
||||
* @return A new message replacement
|
||||
*/
|
||||
@Contract(value = "_ -> new", pure = true)
|
||||
public MessageReplacement with(@Nullable Object replacement) {
|
||||
return new MessageReplacement(key, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
private final @NotNull String key;
|
||||
private final @NotNull Either<String, Message> replacement;
|
||||
|
||||
@ -86,4 +51,82 @@ public final class MessageReplacement {
|
||||
public @NotNull Either<String, Message> getReplacement() {
|
||||
return replacement;
|
||||
}
|
||||
|
||||
/**
|
||||
* A replacement key that maps to a value it can be replaced with.
|
||||
*
|
||||
*/
|
||||
public static final class Key {
|
||||
|
||||
private final @NotNull String key2;
|
||||
|
||||
private Key(@NotNull String key) {
|
||||
this.key2 = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a replacement for this key.
|
||||
*
|
||||
* @param replacement The replacement message
|
||||
* @return A new message replacement
|
||||
*/
|
||||
@Contract(value = "_ -> new", pure = true)
|
||||
public MessageReplacement with(@NotNull Message replacement) {
|
||||
return new MessageReplacement(key2, replacement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a replacement for this key.
|
||||
*
|
||||
* @param replacement The replacement value, if null it will be replaced with a string equal to "null"
|
||||
* @return A new message replacement
|
||||
*/
|
||||
@Contract(value = "_ -> new", pure = true)
|
||||
public MessageReplacement with(@Nullable Object replacement) {
|
||||
return new MessageReplacement(key2, replacement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Predefined replacement keys for common replacements.
|
||||
*/
|
||||
public enum Replace {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: JavadocVariable
|
||||
COUNT(replace("{count}")),
|
||||
DESTINATION(replace("{destination}")),
|
||||
GAMERULE(replace("{gamerule}")),
|
||||
PLAYER(replace("{player}")),
|
||||
REASON(replace("{reason}")),
|
||||
VALUE(replace("{value}")),
|
||||
WORLD(replace("{world}")),;
|
||||
// END CHECKSTYLE-SUPPRESSION: JavadocVariable
|
||||
|
||||
private final Key replaceKey;
|
||||
|
||||
Replace(Key replaceKey) {
|
||||
this.replaceKey = replaceKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a replacement for this key.
|
||||
*
|
||||
* @param replacement The replacement message
|
||||
* @return A new message replacement
|
||||
*/
|
||||
@Contract(value = "_ -> new", pure = true)
|
||||
public MessageReplacement with(@NotNull Message replacement) {
|
||||
return replaceKey.with(replacement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a replacement for this key.
|
||||
*
|
||||
* @param replacement The replacement value, if null it will be replaced with a string equal to "null"
|
||||
* @return A new message replacement
|
||||
*/
|
||||
@Contract(value = "_ -> new", pure = true)
|
||||
public MessageReplacement with(@Nullable Object replacement) {
|
||||
return replaceKey.with(replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.event.MVWorldDeleteEvent;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.permissions.CorePermissions;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement;
|
||||
import org.mvplugins.multiverse.core.teleportation.BlockSafety;
|
||||
@ -650,21 +651,13 @@ public final class WorldManager {
|
||||
|
||||
private <T, F extends FailureReason> Attempt<T, F> worldActionResult(
|
||||
@NotNull F failureReason, @NotNull String worldName) {
|
||||
return Attempt.failure(failureReason, replaceWorldName(worldName));
|
||||
return Attempt.failure(failureReason, Replace.WORLD.with(worldName));
|
||||
}
|
||||
|
||||
private <T, F extends FailureReason> Attempt<T, F> worldActionResult(
|
||||
@NotNull F failureReason, @NotNull String worldName, @NotNull Throwable error) {
|
||||
// TODO: Localize error message if its a MultiverseException
|
||||
return Attempt.failure(failureReason, replaceWorldName(worldName), replaceError(error.getMessage()));
|
||||
}
|
||||
|
||||
private MessageReplacement replaceWorldName(@NotNull String worldName) {
|
||||
return replace("{world}").with(worldName);
|
||||
}
|
||||
|
||||
private MessageReplacement replaceError(@NotNull String errorMessage) {
|
||||
return replace("{error}").with(errorMessage);
|
||||
return Attempt.failure(failureReason, Replace.WORLD.with(worldName), replace("{error}").with(error.getMessage()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import org.mvplugins.multiverse.core.config.MVCoreConfig;
|
||||
import org.mvplugins.multiverse.core.economy.MVEconomist;
|
||||
import org.mvplugins.multiverse.core.locale.message.MessageReplacement.Replace;
|
||||
import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker;
|
||||
import org.mvplugins.multiverse.core.utils.result.Result;
|
||||
import org.mvplugins.multiverse.core.utils.result.ResultChain;
|
||||
@ -123,7 +124,7 @@ public final class WorldEntryChecker {
|
||||
return Result.success(BlacklistResult.Success.UNKNOWN_FROM_WORLD);
|
||||
}
|
||||
return toWorld.getWorldBlacklist().contains(fromWorld.getName())
|
||||
? Result.failure(BlacklistResult.Failure.BLACKLISTED, replace("{world}").with(fromWorld.getAlias()))
|
||||
? Result.failure(BlacklistResult.Failure.BLACKLISTED, Replace.WORLD.with(fromWorld.getAlias()))
|
||||
: Result.success(BlacklistResult.Success.NOT_BLACKLISTED);
|
||||
}
|
||||
|
||||
@ -135,7 +136,6 @@ public final class WorldEntryChecker {
|
||||
*/
|
||||
public Result<EntryFeeResult.Success, EntryFeeResult.Failure> canPayEntryFee(MultiverseWorld world) {
|
||||
double price = world.getPrice();
|
||||
Material currency = world.getCurrency();
|
||||
if (!world.isEntryFeeEnabled() || price == 0D) {
|
||||
return Result.success(EntryFeeResult.Success.FREE_ENTRY);
|
||||
}
|
||||
@ -148,6 +148,7 @@ public final class WorldEntryChecker {
|
||||
if (!(sender instanceof Player player)) {
|
||||
return Result.failure(EntryFeeResult.Failure.CANNOT_PAY_ENTRY_FEE);
|
||||
}
|
||||
Material currency = world.getCurrency();
|
||||
return economist.isPlayerWealthyEnough(player, price, currency)
|
||||
? Result.success(EntryFeeResult.Success.ENOUGH_MONEY)
|
||||
: Result.failure(EntryFeeResult.Failure.NOT_ENOUGH_MONEY,
|
||||
|
@ -99,13 +99,13 @@ public class SpawnLocation extends Location implements ConfigurationSerializable
|
||||
*/
|
||||
@Override
|
||||
public @NotNull Map<String, Object> serialize() {
|
||||
return new HashMap<>() {{
|
||||
put("x", getX());
|
||||
put("y", getY());
|
||||
put("z", getZ());
|
||||
put("pitch", getPitch());
|
||||
put("yaw", getYaw());
|
||||
}};
|
||||
var map = new HashMap<String, Object>();
|
||||
map.put("x", getX());
|
||||
map.put("y", getY());
|
||||
map.put("z", getZ());
|
||||
map.put("pitch", getPitch());
|
||||
map.put("yaw", getYaw());
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ import java.util.Random;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
|
||||
/**
|
||||
@ -22,6 +23,8 @@ public final class RegenWorldOptions implements KeepWorldSettingsOptions {
|
||||
return new RegenWorldOptions(world);
|
||||
}
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
private final LoadedMultiverseWorld world;
|
||||
private Biome biome;
|
||||
private boolean keepGameRule = true;
|
||||
@ -44,8 +47,8 @@ public final class RegenWorldOptions implements KeepWorldSettingsOptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the single biome used for this world. This may be null, in which case the biome from the generator will be used.
|
||||
* If no generator is specified, the "natural" biome behaviour for this environment will be used.
|
||||
* Sets the single biome used for this world. This may be null, in which case the biome from the generator will be
|
||||
* used. If no generator is specified, the "natural" biome behaviour for this environment will be used.
|
||||
*
|
||||
* @param biome The biome used for this world
|
||||
* @return This {@link RegenWorldOptions} instance.
|
||||
@ -56,8 +59,8 @@ public final class RegenWorldOptions implements KeepWorldSettingsOptions {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the single biome used for this world. This may be null, in which case the biome from the generator will be used.
|
||||
* If no generator is specified, the "natural" biome behaviour for this environment will be used.
|
||||
* Gets the single biome used for this world. This may be null, in which case the biome from the generator will be
|
||||
* used. If no generator is specified, the "natural" biome behaviour for this environment will be used.
|
||||
*
|
||||
* @return The biome used for this world
|
||||
*/
|
||||
@ -194,7 +197,7 @@ public final class RegenWorldOptions implements KeepWorldSettingsOptions {
|
||||
*/
|
||||
public long seed() {
|
||||
if (randomSeed) {
|
||||
return new Random().nextLong();
|
||||
return random.nextLong();
|
||||
} else if (seed == Long.MIN_VALUE) {
|
||||
return world.getSeed();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user