Search in sources :

Example 11 with FakeEntity

use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.

the class GuildEntityHelper method despawnGuildHeart.

public static void despawnGuildHeart(Guild guild) {
    try {
        FakeEntity guildHeartEntity = ENTITY_MAP.remove(guild);
        if (guildHeartEntity == null) {
            return;
        }
        FunnyGuilds.getInstance().getNmsAccessor().getEntityAccessor().despawnFakeEntityFor(guildHeartEntity, Bukkit.getOnlinePlayers().toArray(new Player[0]));
    } catch (Exception exception) {
        FunnyGuilds.getPluginLogger().error("Could not despawn guild heart", exception);
    }
}
Also used : FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) Player(org.bukkit.entity.Player)

Example 12 with FakeEntity

use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.

the class WarInfoRequest method execute.

@Override
public void execute() throws Exception {
    for (Map.Entry<Guild, FakeEntity> entry : GuildEntityHelper.getGuildEntities().entrySet()) {
        if (entry.getValue().getId() != entityId) {
            continue;
        }
        Guild guild = entry.getKey();
        Option<Player> playerOption = this.user.getPlayer();
        if (playerOption.isEmpty()) {
            return;
        }
        Player player = playerOption.get();
        if (SecuritySystem.onHitCrystal(player, guild)) {
            return;
        }
        FunnyGuilds plugin = FunnyGuilds.getInstance();
        PluginConfiguration config = plugin.getPluginConfiguration();
        MessageConfiguration messages = plugin.getMessageConfiguration();
        if (config.informationMessageCooldowns.cooldown(player, TimeUnit.SECONDS, config.infoPlayerCooldown)) {
            return;
        }
        try {
            infoExecutor.execute(player, new String[] { entry.getKey().getTag() });
            return;
        } catch (ValidationException validatorException) {
            validatorException.getValidationMessage().peek(message -> ChatUtils.sendMessage(player, message));
        }
    }
}
Also used : FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) MessageConfiguration(net.dzikoysk.funnyguilds.config.MessageConfiguration) GuildEntityHelper(net.dzikoysk.funnyguilds.nms.GuildEntityHelper) FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) Player(org.bukkit.entity.Player) Option(panda.std.Option) TimeUnit(java.util.concurrent.TimeUnit) DefaultConcurrencyRequest(net.dzikoysk.funnyguilds.concurrency.util.DefaultConcurrencyRequest) FunnyGuilds(net.dzikoysk.funnyguilds.FunnyGuilds) SecuritySystem(net.dzikoysk.funnyguilds.feature.security.SecuritySystem) Guild(net.dzikoysk.funnyguilds.guild.Guild) Map(java.util.Map) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) InfoCommand(net.dzikoysk.funnyguilds.feature.command.user.InfoCommand) ValidationException(net.dzikoysk.funnycommands.resources.ValidationException) User(net.dzikoysk.funnyguilds.user.User) ChatUtils(net.dzikoysk.funnyguilds.shared.bukkit.ChatUtils) Player(org.bukkit.entity.Player) MessageConfiguration(net.dzikoysk.funnyguilds.config.MessageConfiguration) ValidationException(net.dzikoysk.funnycommands.resources.ValidationException) FunnyGuilds(net.dzikoysk.funnyguilds.FunnyGuilds) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) Guild(net.dzikoysk.funnyguilds.guild.Guild) Map(java.util.Map)

Example 13 with FakeEntity

use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.

the class V1_8R3EntityAccessor method createFakeEntity.

@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
    Preconditions.checkNotNull(entityType, "entity type can't be null!");
    Preconditions.checkNotNull(location, "location can't be null!");
    Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
    CraftWorld world = ((CraftWorld) location.getWorld());
    if (world == null) {
        throw new IllegalStateException("location's world is null!");
    }
    Entity entity = world.createEntity(location, entityType.getEntityClass());
    Packet<?> spawnEntityPacket;
    if (entity instanceof EntityLiving) {
        spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
    } else {
        spawnEntityPacket = new PacketPlayOutSpawnEntity(entity, ObjectType.getIdFor(entityType));
    }
    return new FakeEntity(entity.getId(), spawnEntityPacket);
}
Also used : FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) PacketPlayOutSpawnEntity(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity) Entity(net.minecraft.server.v1_8_R3.Entity) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) PacketPlayOutSpawnEntity(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Example 14 with FakeEntity

use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.

the class V1_14R1EntityAccessor method createFakeEntity.

@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
    Preconditions.checkNotNull(entityType, "entity type can't be null!");
    Preconditions.checkNotNull(location, "location can't be null!");
    Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
    CraftWorld world = ((CraftWorld) location.getWorld());
    if (world == null) {
        throw new IllegalStateException("location's world is null!");
    }
    Entity entity = world.createEntity(location, entityType.getEntityClass());
    Packet<?> spawnEntityPacket;
    if (entity instanceof EntityLiving) {
        spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
    } else {
        spawnEntityPacket = new PacketPlayOutSpawnEntity(entity, ObjectType.getIdFor(entityType));
    }
    return new FakeEntity(entity.getId(), spawnEntityPacket);
}
Also used : FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) PacketPlayOutSpawnEntity(net.minecraft.server.v1_14_R1.PacketPlayOutSpawnEntity) FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) Entity(net.minecraft.server.v1_14_R1.Entity) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_14_R1.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_14_R1.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.server.v1_14_R1.EntityLiving) PacketPlayOutSpawnEntity(net.minecraft.server.v1_14_R1.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_14_R1.CraftWorld)

Example 15 with FakeEntity

use of net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity in project FunnyGuilds by FunnyGuilds.

the class V1_15R1EntityAccessor method createFakeEntity.

@Override
public FakeEntity createFakeEntity(EntityType entityType, Location location) {
    Preconditions.checkNotNull(entityType, "entity type can't be null!");
    Preconditions.checkNotNull(location, "location can't be null!");
    Preconditions.checkArgument(entityType.isSpawnable(), "entity type is not spawnable!");
    CraftWorld world = ((CraftWorld) location.getWorld());
    if (world == null) {
        throw new IllegalStateException("location's world is null!");
    }
    Entity entity = world.createEntity(location, entityType.getEntityClass());
    Packet<?> spawnEntityPacket;
    if (entity instanceof EntityLiving) {
        spawnEntityPacket = new PacketPlayOutSpawnEntityLiving((EntityLiving) entity);
    } else {
        spawnEntityPacket = new PacketPlayOutSpawnEntity(entity, ObjectType.getIdFor(entityType));
    }
    return new FakeEntity(entity.getId(), spawnEntityPacket);
}
Also used : FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) FakeEntity(net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity) PacketPlayOutSpawnEntity(net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntity) Entity(net.minecraft.server.v1_15_R1.Entity) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntityLiving) EntityLiving(net.minecraft.server.v1_15_R1.EntityLiving) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntityLiving) PacketPlayOutSpawnEntity(net.minecraft.server.v1_15_R1.PacketPlayOutSpawnEntity) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld)

Aggregations

FakeEntity (net.dzikoysk.funnyguilds.nms.api.entity.FakeEntity)16 Player (org.bukkit.entity.Player)3 Map (java.util.Map)2 FunnyGuilds (net.dzikoysk.funnyguilds.FunnyGuilds)2 Guild (net.dzikoysk.funnyguilds.guild.Guild)2 PacketPlayOutSpawnEntity (net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity)2 PacketPlayOutSpawnEntityLiving (net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving)2 EntityLiving (net.minecraft.world.entity.EntityLiving)2 TimeUnit (java.util.concurrent.TimeUnit)1 ValidationException (net.dzikoysk.funnycommands.resources.ValidationException)1 DefaultConcurrencyRequest (net.dzikoysk.funnyguilds.concurrency.util.DefaultConcurrencyRequest)1 MessageConfiguration (net.dzikoysk.funnyguilds.config.MessageConfiguration)1 PluginConfiguration (net.dzikoysk.funnyguilds.config.PluginConfiguration)1 GuildHeartAttackEvent (net.dzikoysk.funnyguilds.event.guild.GuildHeartAttackEvent)1 InfoCommand (net.dzikoysk.funnyguilds.feature.command.user.InfoCommand)1 SecuritySystem (net.dzikoysk.funnyguilds.feature.security.SecuritySystem)1 GuildEntityHelper (net.dzikoysk.funnyguilds.nms.GuildEntityHelper)1 ChatUtils (net.dzikoysk.funnyguilds.shared.bukkit.ChatUtils)1 User (net.dzikoysk.funnyguilds.user.User)1 Entity (net.minecraft.server.v1_10_R1.Entity)1