use of me.xjcyan1de.cyanbot.listeners.event.EventHandler in project CyanBot by XjCyan1de.
the class CommandEvents method on.
@EventHandler
public void on(CommandEvent event) {
// если игрок не авторизировался
if (!event.hasAccessSender()) {
return;
}
final String[] args = event.getArgs();
switch(event.getCommand().toLowerCase()) {
case "say":
case "напиши":
case "скажи":
{
final String arguments = event.getArguments(0);
if (!arguments.isEmpty()) {
bot.sendMessage(arguments);
}
break;
}
case "flood":
case "флуди":
{
final String arguments = event.getArguments(0);
if (!arguments.isEmpty()) {
Schedule.timer(() -> {
bot.sendMessage(arguments);
}, 1000, 1000);
}
break;
}
case "walk":
case "иди":
{
if (args.length != 3)
return;
double x = Double.parseDouble(args[0]);
double y = Double.parseDouble(args[1]);
double z = Double.parseDouble(args[2]);
bot.getLoc().add(x, y, z);
break;
}
case "spin":
case "кружись":
{
final int[] yaw = { 0 };
Schedule.timer(() -> {
bot.getLoc().setYaw(yaw[0]);
yaw[0] += 30;
}, 50, 50);
break;
}
case "drop":
case "выкинь":
{
bot.sendPacket(new ClientPlayerActionPacket(PlayerAction.DROP_ITEM, new Position(bot.getLoc().getBlockX(), bot.getLoc().getBlockY(), bot.getLoc().getBlockZ()), BlockFace.UP));
break;
}
case "swap":
case "переложи":
{
bot.sendPacket(new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(bot.getLoc().getBlockX(), bot.getLoc().getBlockY(), bot.getLoc().getBlockZ()), BlockFace.UP));
break;
}
case "swapping":
case "перехватывай":
{
if (args.length != 1)
return;
int delay = Integer.parseInt(args[0]);
Schedule.timer(() -> {
bot.sendPacket(new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(bot.getLoc().getBlockX(), bot.getLoc().getBlockY(), bot.getLoc().getBlockZ()), BlockFace.UP));
}, delay, delay);
break;
}
case "rightclick":
case "пкм":
{
bot.sendPacket(new ClientPlayerUseItemPacket(Hand.MAIN_HAND));
break;
}
case "deus":
{
if (event.has(0, "vult")) {
bot.sendMessage("Ave Maria!");
}
break;
}
case "слава":
{
if (event.has(0, "украине")) {
bot.sendMessage("ГЕРОЯМ СЛАВА!");
}
break;
}
default:
return;
}
// если обработали команду, тогда дальше не пускаем
event.setCancelled(true);
}
use of me.xjcyan1de.cyanbot.listeners.event.EventHandler in project CyanBot by XjCyan1de.
the class PacketWorldEntityEvents method on.
@EventHandler
public void on(ServerEntityTeleportPacket packet) {
final Entity entity = world.getEntityMap().get(packet.getEntityId());
if (entity != null) {
entity.setX(packet.getX());
entity.setY(packet.getY());
entity.setZ(packet.getZ());
entity.setPitch(packet.getPitch());
entity.setYaw(packet.getYaw());
}
}
Aggregations