Skip to content

Commit

Permalink
Use safetyTeleporter and add i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
zax71 committed Feb 24, 2024
1 parent b1a5907 commit 39c533e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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;
Expand All @@ -14,6 +15,8 @@
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;

Expand All @@ -22,11 +25,15 @@
class SpawnCommand extends MultiverseCommand {

private final WorldManager worldManager;
private final AsyncSafetyTeleporter safetyTeleporter;

@Inject
SpawnCommand(@NotNull MVCommandManager commandManager, WorldManager worldManager) {
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")
Expand All @@ -45,19 +52,27 @@ void onSpawnCommand(
// The player is in the world, so it must be loaded
LoadedMultiverseWorld world = worldManager.getLoadedWorld(player.getWorld().getName()).getOrNull();

player.teleport(world.getSpawnLocation()); // TODO: use safety teleporter
// Teleport the player
safetyTeleporter.teleportSafely(issuer.getIssuer(), player, world.getSpawnLocation());

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

player.sendMessage(teleporterName + " just sent you to spawn!"); // TODO: i18n
// Send the conformation message
player.sendMessage(commandManager.formatMessage(
issuer,
MessageType.INFO,
MVCorei18n.SPAWN_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)

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 🐶 There is more than 1 empty line after this line. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java:75:11: warning: There is more than 1 empty line after this line. (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)


}

Check warning on line 78 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 more than 1 empty lines after. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/SpawnCommand.java:78:5: warning: '}' has more than 1 empty lines after. (com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck)
Expand Down
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 command
SPAWN_DESCRIPTION,
SPAWN_PLAYER_DESCRIPTION,
SPAWN_MESSAGE,
SPAWN_CONSOLENAME,
SPAWN_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.remove.success=&aWorld '{world}' removed!
mv-core.root.title=&a{name} version {version}
mv-core.root.help=&aSee &f/mv help&a for commands available.

# /mv spawn
mv-core.spawn.description=Teleports the specified player to the spawn of the world they are in
mv-core.spawn.player.description=The player
mv-core.spawn.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.message' is not in the right order with previous property 'mv-core.spawn.player.description'. Raw Output: /github/workspace/./src/main/resources/multiverse-core_en.properties:130:0: warning: Property key 'mv-core.spawn.message' is not in the right order with previous property 'mv-core.spawn.player.description'. (com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck)
mv-core.spawn.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.consolename' is not in the right order with previous property 'mv-core.spawn.message'. Raw Output: /github/workspace/./src/main/resources/multiverse-core_en.properties:131:0: warning: Property key 'mv-core.spawn.consolename' is not in the right order with previous property 'mv-core.spawn.message'. (com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck)
mv-core.spawn.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

0 comments on commit 39c533e

Please sign in to comment.