Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add /mv spawn tp and /mv spawn set #3057

Merged
merged 9 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.mvplugins.multiverse.core.commands;

import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.MessageType;
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.Subcommand;
import co.aikar.commands.annotation.Syntax;
import jakarta.inject.Inject;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;

Check warning on line 16 in src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 'org.mvplugins.multiverse.core.commandtools.MVCommandManager' should be separated from previous imports. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java:16:1: warning: 'org.mvplugins.multiverse.core.commandtools.MVCommandManager' should be separated from previous imports. (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
import org.mvplugins.multiverse.core.world.WorldManager;

@Service
@CommandAlias("mv")
class SpawnCommand extends MultiverseCommand {

private final WorldManager worldManager;
private final AsyncSafetyTeleporter safetyTeleporter;

@Inject
SpawnCommand(@NotNull MVCommandManager commandManager,
WorldManager worldManager,

Check warning on line 32 in src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 'WorldManager' has incorrect indentation level 17, expected level should be 12. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java:32:18: warning: 'WorldManager' has incorrect indentation level 17, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
@NotNull AsyncSafetyTeleporter safetyTeleporter) {

Check warning on line 33 in src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 '@' has incorrect indentation level 17, expected level should be 12. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java:33:18: warning: '@' has incorrect indentation level 17, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
super(commandManager);
this.worldManager = worldManager;
this.safetyTeleporter = safetyTeleporter;
}

@Subcommand("spawn tp")
@CommandPermission("multiverse.core.spawn")
@CommandCompletion("@players")
@Syntax("[player]")
@Description("{@@mv-core.spawn.tp.description}")
void onSpawnTpCommand(
BukkitCommandIssuer issuer,

@Flags("resolve=issuerAware")
@Syntax("[player]")
@Description("{@@mv-core.spawn.tp.player.description}")
Player player
) {

Check warning on line 51 in src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 'method def rparen' has incorrect indentation level 11, expected level should be 4. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java:51:12: warning: 'method def rparen' has incorrect indentation level 11, expected level should be 4. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)

Check warning on line 51 in src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 ')' should be on the previous line. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java:51:12: warning: ')' should be on the previous line. (SeparatorWrapEol)
// The player is in the world, so it must be loaded
LoadedMultiverseWorld world = worldManager.getLoadedWorld(player.getWorld().getName()).getOrNull();
zax71 marked this conversation as resolved.
Show resolved Hide resolved

// Teleport the player
safetyTeleporter.teleportSafely(issuer.getIssuer(), player, world.getSpawnLocation());
benwoo1110 marked this conversation as resolved.
Show resolved Hide resolved

// Make the conformation message make sense
String teleporterName;
if (issuer.getIssuer().getName().equals("CONSOLE")) {
teleporterName = commandManager.formatMessage(issuer, MessageType.INFO, MVCorei18n.SPAWN_TP_CONSOLENAME);
} else if (issuer.getIssuer().getName().equals(player.getName())) {
teleporterName = commandManager.formatMessage(issuer, MessageType.INFO, MVCorei18n.SPAWN_TP_YOU);
} else {
teleporterName = issuer.getIssuer().getName();
}

// Send the conformation message
player.sendMessage(commandManager.formatMessage(
issuer,
MessageType.INFO,
MVCorei18n.SPAWN_TP_MESSAGE,
"{teleporter}",
teleporterName
));

Check warning on line 75 in src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 ')' should be on the previous line. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java:75:9: warning: ')' should be on the previous line. (SeparatorWrapEol)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ public enum MVCorei18n implements MessageKeyProvider {
ROOT_TITLE,
ROOT_HELP,

// spawn tp command
SPAWN_TP_DESCRIPTION,
SPAWN_TP_PLAYER_DESCRIPTION,
SPAWN_TP_MESSAGE,
SPAWN_TP_CONSOLENAME,
SPAWN_TP_YOU,

// teleport command
TELEPORT_SUCCESS,

Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/multiverse-core_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@
mv-core.root.title=&a{name} version {version}
mv-core.root.help=&aSee &f/mv help&a for commands available.

# /mv spawn tp
mv-core.spawn.tp.description=Teleports the specified player to the spawn of the world they are in
mv-core.spawn.tp.player.description=The player
mv-core.spawn.tp.message={teleporter} just sent you to spawn!

Check warning on line 130 in src/main/resources/multiverse-core_en.properties

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Property key 'mv-core.spawn.tp.message' is not in the right order with previous property 'mv-core.spawn.tp.player.description'. Raw Output: /github/workspace/./src/main/resources/multiverse-core_en.properties:130:0: warning: Property key 'mv-core.spawn.tp.message' is not in the right order with previous property 'mv-core.spawn.tp.player.description'. (com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck)
mv-core.spawn.tp.consolename=The console

Check warning on line 131 in src/main/resources/multiverse-core_en.properties

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Property key 'mv-core.spawn.tp.consolename' is not in the right order with previous property 'mv-core.spawn.tp.message'. Raw Output: /github/workspace/./src/main/resources/multiverse-core_en.properties:131:0: warning: Property key 'mv-core.spawn.tp.consolename' is not in the right order with previous property 'mv-core.spawn.tp.message'. (com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck)
mv-core.spawn.tp.you=You

# /mv tp
mv-core.teleport.description=Allows you to teleport to a location on your server!
mv-core.teleport.player.description=Target player to teleport.
Expand Down
Loading