add random tp
EASIEST COMMAND EVER TO MAKE !! actually its prob test but whatever lol
This commit is contained in:
parent
b515b1b8b1
commit
394f22bbfb
4 changed files with 72 additions and 8 deletions
|
@ -0,0 +1,62 @@
|
|||
package me.chayapak1.chomensbot_mabe.commands;
|
||||
|
||||
import me.chayapak1.chomensbot_mabe.Bot;
|
||||
import me.chayapak1.chomensbot_mabe.command.Command;
|
||||
import me.chayapak1.chomensbot_mabe.command.CommandContext;
|
||||
import me.chayapak1.chomensbot_mabe.util.ComponentUtilities;
|
||||
import me.chayapak1.chomensbot_mabe.util.NumberUtilities;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RandomTeleportCommand implements Command {
|
||||
public String name() { return "rtp"; }
|
||||
|
||||
public String description() {
|
||||
return "Randomly teleports you";
|
||||
}
|
||||
|
||||
public List<String> usage() {
|
||||
final List<String> usages = new ArrayList<>();
|
||||
usages.add("");
|
||||
|
||||
return usages;
|
||||
}
|
||||
|
||||
public List<String> alias() {
|
||||
final List<String> aliases = new ArrayList<>();
|
||||
aliases.add("randomteleport");
|
||||
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public int trustLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
|
||||
final String stringDisplayName = ComponentUtilities.stringify(context.displayName());
|
||||
|
||||
final int positionX = NumberUtilities.between(1_000, 10_000);
|
||||
final int positionZ = NumberUtilities.between(1_000, 10_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(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);
|
||||
|
||||
return Component.text("success");
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ public class CommandHandlerPlugin {
|
|||
registerCommand(new ThrowCommand());
|
||||
registerCommand(new ValidateCommand());
|
||||
registerCommand(new MusicCommand());
|
||||
registerCommand(new RandomTeleportCommand());
|
||||
}
|
||||
|
||||
public void registerCommand (Command command) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package me.chayapak1.chomensbot_mabe.util;
|
||||
|
||||
public class NumberUtilities {
|
||||
public static int between (int min, int max) {
|
||||
return (int) Math.floor(
|
||||
Math.random() * (max - min) + min
|
||||
);
|
||||
}
|
||||
}
|
|
@ -18,14 +18,6 @@ public class UUIDUtilities {
|
|||
return intArray;
|
||||
}
|
||||
|
||||
public static UUID byString (String string, int version) {
|
||||
UUID uuid = UUID.nameUUIDFromBytes(string.getBytes());
|
||||
uuid = new UUID(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits() & ~(0xfL << 12));
|
||||
uuid = new UUID(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits() | ((long) version << 12));
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public static IntArrayTag tag (UUID uuid) {
|
||||
return new IntArrayTag("", intArray(uuid));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue