improve rtp

This commit is contained in:
Chayapak 2023-04-16 16:47:58 +07:00
parent 604b14270a
commit 094ca5018b

View file

@ -1,9 +1,9 @@
package land.chipmunk.chayapak.chomens_bot.commands;
import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.MutablePlayerListEntry;
import land.chipmunk.chayapak.chomens_bot.command.Command;
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
import land.chipmunk.chayapak.chomens_bot.util.NumberUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
@ -39,23 +39,22 @@ public class RandomTeleportCommand implements Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot();
final String stringDisplayName = ComponentUtilities.stringify(context.displayName());
final MutablePlayerListEntry sender = context.sender();
final int positionX = NumberUtilities.between(1_000, 10_000);
final int positionZ = NumberUtilities.between(1_000, 10_000);
final int positionX = NumberUtilities.between(1_000, 1_000_000);
final int positionZ = NumberUtilities.between(1_000, 1_000_000);
final String stringPosition = positionX + " 100 " + positionZ; // very 100 y
context.sendOutput(
Component.empty()
.append(Component.text("Teleporting "))
.append(context.displayName().color(NamedTextColor.AQUA))
.append(sender.displayName().color(NamedTextColor.AQUA))
.append(Component.text(" to ").color(NamedTextColor.WHITE))
.append(Component.text(stringPosition).color(NamedTextColor.GREEN))
.append(Component.text("...").color(NamedTextColor.WHITE))
);
// TODO: Use UUID instead of display name because it is a bad idea!!11
bot.core().run("essentials:teleport " + stringDisplayName + " " + stringPosition);
bot.core().run("essentials:teleport " + sender.profile().getIdAsString() + " " + stringPosition);
return Component.text("success");
}