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

Actually implement check command #3145

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,35 @@
import co.aikar.commands.annotation.Subcommand;
import co.aikar.commands.annotation.Syntax;
import jakarta.inject.Inject;
import org.bukkit.command.CommandSender;

Check warning on line 10 in src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Unused import - org.bukkit.command.CommandSender. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java:10:8: warning: Unused import - org.bukkit.command.CommandSender. (com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck)
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jvnet.hk2.annotations.Service;

import org.mvplugins.multiverse.core.api.LocationManipulation;
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.destination.DestinationsProvider;
import org.mvplugins.multiverse.core.permissions.CorePermissionsChecker;
import org.mvplugins.multiverse.core.utils.MVCorei18n;
import org.mvplugins.multiverse.core.utils.message.Message;

import static org.mvplugins.multiverse.core.utils.message.MessageReplacement.replace;

@Service
@CommandAlias("mv")
class CheckCommand extends CoreCommand {

private final DestinationsProvider destinationsProvider;
private final CorePermissionsChecker corePermissionsChecker;
private final LocationManipulation locationManipulation;

@Inject
CheckCommand(@NotNull MVCommandManager commandManager, @NotNull DestinationsProvider destinationsProvider) {
CheckCommand(@NotNull MVCommandManager commandManager,
@NotNull CorePermissionsChecker corePermissionsChecker,

Check warning on line 34 in src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.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/CheckCommand.java:34:18: warning: '@' has incorrect indentation level 17, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
@NotNull LocationManipulation locationManipulation) {

Check warning on line 35 in src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.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/CheckCommand.java:35:18: warning: '@' has incorrect indentation level 17, expected level should be 12. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
super(commandManager);
this.destinationsProvider = destinationsProvider;
this.corePermissionsChecker = corePermissionsChecker;
this.locationManipulation = locationManipulation;
}

@CommandAlias("mvcheck")
Expand All @@ -45,10 +54,17 @@
@Syntax("<destination>")
@Description("{@@mv-core.check.destination.description}")
DestinationInstance<?, ?> destination) {
issuer.sendInfo(MVCorei18n.CHECK_CHECKING,
"{player}", player.getName(),
"{destination}", destination.toString());
// TODO: More detailed output on permissions required.
// this.destinationsProvider.checkTeleportPermissions(issuer, player, destination);
issuer.sendInfo(this.corePermissionsChecker.checkTeleportPermissions(player, player, destination)
? MVCorei18n.CHECK_HASPERMISSION

Check warning on line 58 in src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 '?' has incorrect indentation level 24, expected level should be 16. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java:58:25: warning: '?' has incorrect indentation level 24, expected level should be 16. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
: MVCorei18n.CHECK_NOPERMISSION,

Check warning on line 59 in src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 ':' has incorrect indentation level 24, expected level should be 16. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commands/CheckCommand.java:59:25: warning: ':' has incorrect indentation level 24, expected level should be 16. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
replace("{player}").with(player.getName()),
replace("{destination}").with(destination));
issuer.sendInfo(MVCorei18n.CHECK_LOCATION,
replace("{location}").with(destination.getLocation(player)
.map(locationManipulation::locationToString)
.map(Message::of)
.getOrElse(() -> Message.of(MVCorei18n.GENERIC_NULL, "Null!"))));

// TODO: Show permission required for this particular destination
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
CONFIG_NODE_NOTFOUND,

// check command
CHECK_CHECKING,
CHECK_HASPERMISSION,
CHECK_NOPERMISSION,
CHECK_LOCATION,

// clone command
CLONE_CLONING,
Expand Down Expand Up @@ -175,7 +177,10 @@

// generic
GENERIC_SUCCESS,
GENERIC_FAILURE;
GENERIC_FAILURE,
GENERIC_ERROR,
GENERIC_NULL,
;

Check warning on line 183 in src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 ';' is preceded with whitespace. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.java:183:5: warning: ';' is preceded with whitespace. (AllowedWhitespaceBeforeWithoutLinebreak)

Check warning on line 183 in src/main/java/org/mvplugins/multiverse/core/utils/MVCorei18n.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/utils/MVCorei18n.java:183:5: warning: ';' should be on the previous line. (SeparatorWrapEol)

// END CHECKSTYLE-SUPPRESSION: Javadoc

Expand Down
8 changes: 6 additions & 2 deletions src/main/resources/multiverse-core_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
mv-core.config.node.notfound=Node not found in config: {node}

# /mv check
mv-core.check.description=Checks if a player can teleport to a destination.
mv-core.check.description=Checks if a player can teleport themselves to a destination.

Check warning on line 6 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.check.description' is not in the right order with previous property 'mv-core.config.node.notfound'. Raw Output: /github/workspace/./src/main/resources/multiverse-core_en.properties:6:0: warning: Property key 'mv-core.check.description' is not in the right order with previous property 'mv-core.config.node.notfound'. (com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck)
mv-core.check.player.description=Player to check destination on.
mv-core.check.destination.description=A destination location, e.g. a world name.
mv-core.check.checking=Checking {player} to {destination} ..
mv-core.check.haspermission=&a{player} can teleport to {destination}
mv-core.check.nopermission=&c{player} cannot teleport to {destination}
mv-core.check.location=The destination's location is: &f{location}

Check warning on line 11 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.check.location' is not in the right order with previous property 'mv-core.check.nopermission'. Raw Output: /github/workspace/./src/main/resources/multiverse-core_en.properties:11:0: warning: Property key 'mv-core.check.location' is not in the right order with previous property 'mv-core.check.nopermission'. (com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck)

# /mv clone
mv-core.clone.description=Clones a world.
Expand Down Expand Up @@ -216,3 +218,5 @@
# generic
mv-core.generic.success=Success!
mv-core.generic.failure=Failed!
mv-core.generic.error=Error!

Check warning on line 221 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.generic.error' is not in the right order with previous property 'mv-core.generic.failure'. Raw Output: /github/workspace/./src/main/resources/multiverse-core_en.properties:221:0: warning: Property key 'mv-core.generic.error' is not in the right order with previous property 'mv-core.generic.failure'. (com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck)
mv-core.generic.null=Null!
Loading