Skip to content

Commit

Permalink
refactor: add @CommandTarget for /tppos
Browse files Browse the repository at this point in the history
  • Loading branch information
sakurawald committed Oct 30, 2024
1 parent 0d0f175 commit 6c0879e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.github.sakurawald.core.command.annotation.CommandNode;
import io.github.sakurawald.core.command.annotation.CommandRequirement;
import io.github.sakurawald.core.command.annotation.CommandSource;
import io.github.sakurawald.core.command.annotation.CommandTarget;
import io.github.sakurawald.core.command.argument.wrapper.impl.Dimension;
import io.github.sakurawald.core.command.argument.wrapper.impl.OfflinePlayerName;
import io.github.sakurawald.core.service.random_teleport.RandomTeleporter;
Expand All @@ -23,8 +24,7 @@ public class TpposInitializer extends ModuleInitializer {
@CommandNode("tppos")
@CommandRequirement(level = 4)
@Document("The unified teleport command.")
private static int tppos(@CommandSource ServerPlayerEntity player
, @Document("the target player") Optional<ServerPlayerEntity> targetPlayer
private static int tppos(@CommandSource @CommandTarget ServerPlayerEntity player
, @Document("the target dimension") Optional<Dimension> dimension
, @Document("the target x for fixed-tp") Optional<Double> x
, @Document("the target y for fixed-tp") Optional<Double> y
Expand All @@ -40,11 +40,6 @@ private static int tppos(@CommandSource ServerPlayerEntity player
, @Document("max y for rtp") Optional<Integer> maxY
, @Document("max try times for rtp") Optional<Integer> maxTryTimes
) {
// specify another player
if (targetPlayer.isPresent()) {
player = targetPlayer.get();
}

/* specify the dimension */
ServerWorld world = dimension.isPresent() ? dimension.get().getValue() : player.getServerWorld();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void tick() {

/* discard nametag if the vehicle is sneaking */
if (this.getVehicle().isSneaking()) {
LogUtil.debug("discard nametag entity {}: its vehicle is sneaking", this);
this.discardNametag();
}

Expand Down

0 comments on commit 6c0879e

Please sign in to comment.