mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 18:47:20 +01:00
Add /mv coordinates
This commit is contained in:
parent
1e9f19b01f
commit
90522a014e
@ -0,0 +1,61 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import co.aikar.commands.annotation.Subcommand;
|
||||
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager;
|
||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||
import com.onarandombox.MultiverseCore.utils.MVCorei18n;
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class CoordinatesCommand extends MultiverseCommand {
|
||||
|
||||
private final MVWorldManager worldManager;
|
||||
private final LocationManipulation locationManipulation;
|
||||
|
||||
@Inject
|
||||
public CoordinatesCommand(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager, @NotNull LocationManipulation locationManipulation) {
|
||||
super(commandManager);
|
||||
|
||||
this.worldManager = worldManager;
|
||||
this.locationManipulation = locationManipulation;
|
||||
}
|
||||
|
||||
@Subcommand("coordinates|coord|coords|co")
|
||||
@CommandPermission("multiverse.core.coord")
|
||||
@Description("{@@mv-core.coordinates.description}")
|
||||
public void onCoordinatesCommand(BukkitCommandIssuer issuer) {
|
||||
if (!issuer.isPlayer()) { // Players only
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_ERRORPLAYERSONLY);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = issuer.getPlayer();
|
||||
|
||||
if (!this.worldManager.isMVWorld(player.getWorld().getName())) { // MV Worlds only
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_ERROR_MULTIVERSEWORLDONLY);
|
||||
return;
|
||||
}
|
||||
World world = player.getWorld();
|
||||
MVWorld mvworld = this.worldManager.getMVWorld(world.getName());
|
||||
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_TITLE);
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_WORLD, "{world}", world.getName());
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_ALIAS, "{alias}", mvworld.getColoredWorldString());
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_WORLDSCALE, "{scale}", String.valueOf(mvworld.getScaling()));
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_COORDINATES, "{coordinates}", locationManipulation.strCoords(player.getLocation()));
|
||||
issuer.sendInfo(MVCorei18n.COORDINATES_INFO_DIRECTION, "{direction}", locationManipulation.getDirection(player.getLocation()));
|
||||
}
|
||||
}
|
@ -19,6 +19,16 @@ public enum MVCorei18n implements MessageKeyProvider {
|
||||
CLONE_FAILED,
|
||||
CLONE_SUCCESS,
|
||||
|
||||
// Coordinates command
|
||||
COORDINATES_ERRORPLAYERSONLY,
|
||||
COORDINATES_ERROR_MULTIVERSEWORLDONLY,
|
||||
COORDINATES_INFO_TITLE,
|
||||
COORDINATES_INFO_WORLD,
|
||||
COORDINATES_INFO_ALIAS,
|
||||
COORDINATES_INFO_WORLDSCALE,
|
||||
COORDINATES_INFO_COORDINATES,
|
||||
COORDINATES_INFO_DIRECTION,
|
||||
|
||||
// create command
|
||||
CREATE_PROPERTIES,
|
||||
CREATE_PROPERTIES_ENVIRONMENT,
|
||||
|
@ -19,6 +19,17 @@ mv-core.clone.success=Cloned world '{world}'!
|
||||
# /mv confirm
|
||||
mv-core.confirm.description=Confirms dangerous commands before executing them.
|
||||
|
||||
# /mv coordinates
|
||||
mv-core.coordinates.description=Simply sends your coordinates
|
||||
mv-core.coordinates.error.players-only=&cThis command can only be used by players
|
||||
mv-core.coordinates.error.multiverseWorldOnly=&cThis can only be used in multiverse worlds
|
||||
mv-core.coordinates.info.title=&b--- Location Information ---
|
||||
mv-core.coordinates.info.world=&bWorld: &f{world}
|
||||
mv-core.coordinates.info.alias=&bAlias: &f{alias}
|
||||
mv-core.coordinates.info.worldScale=&bWorld Scale: &f{scale}
|
||||
mv-core.coordinates.info.coordinates=&bCoordinates: &f{coordinates}
|
||||
mv-core.coordinates.info.direction=&bDirection: &f{direction}
|
||||
|
||||
# /mv create
|
||||
mv-core.create.description=Creates a new world and loads it.
|
||||
mv-core.create.name.description=New world name.
|
||||
|
Loading…
Reference in New Issue
Block a user