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);
}
}
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));
}
}
}
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);
}
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);
}
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);
}
Aggregations