We do a little trolling

This commit is contained in:
kuroppoi 2021-06-09 22:11:44 +02:00
parent 0aa063d285
commit c9df56cf32
2 changed files with 58 additions and 0 deletions

View file

@ -22,6 +22,7 @@ import brainwine.gameserver.command.commands.KickCommand;
import brainwine.gameserver.command.commands.PlayerIdCommand;
import brainwine.gameserver.command.commands.PositionCommand;
import brainwine.gameserver.command.commands.RegisterCommand;
import brainwine.gameserver.command.commands.RickrollCommand;
import brainwine.gameserver.command.commands.SayCommand;
import brainwine.gameserver.command.commands.SeedCommand;
import brainwine.gameserver.command.commands.StopCommand;
@ -67,6 +68,7 @@ public class CommandManager {
registerCommand(new ExportCommand());
registerCommand(new ImportCommand());
registerCommand(new PositionCommand());
registerCommand(new RickrollCommand());
}
public static void executeCommand(CommandExecutor executor, String commandLine) {

View file

@ -0,0 +1,56 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import brainwine.gameserver.GameServer;
import brainwine.gameserver.command.Command;
import brainwine.gameserver.command.CommandExecutor;
import brainwine.gameserver.entity.player.Player;
import brainwine.gameserver.server.messages.EventMessage;
public class RickrollCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length < 1) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
return;
}
Player player = GameServer.getInstance().getPlayerManager().getPlayer(args[0]);
if(player == null) {
executor.notify("This player does not exist.", ALERT);
return;
} else if(!player.isOnline()) {
executor.notify("This player is offline.", ALERT);
return;
} else if(!player.isV3()) {
executor.notify("Cannot open URLs on iOS clients.", ALERT);
return;
}
player.sendMessage(new EventMessage("openUrl", "https://www.youtube.com/watch?v=dQw4w9WgXcQ"));
executor.notify(String.format("Successfully rickrolled %s!", player.getName()), ALERT);
}
@Override
public String getName() {
return "rickroll";
}
@Override
public String getDescription() {
return "Makes a player hate you forever.";
}
@Override
public String getUsage(CommandExecutor executor) {
return "/rickroll <player>";
}
@Override
public boolean canExecute(CommandExecutor executor) {
return executor.isAdmin();
}
}