Search in sources :

Example 1 with CraftServer

use of org.bukkit.craftbukkit.v1_8_R2.CraftServer in project DragonsOnline by UniverseCraft.

the class PlayerNPC116R3 method spawn.

public void spawn() {
    registry.unregister(this);
    uuid = UUID.randomUUID();
    this.isDestroyed = false;
    DedicatedServer server = ((CraftServer) Bukkit.getServer()).getServer();
    WorldServer world = ((CraftWorld) location.getWorld()).getHandle();
    // displayName);
    GameProfile gameProfile = new GameProfile(uuid, "");
    gameProfile.getProperties().clear();
    gameProfile.getProperties().put("textures", new Property("textures", texture, signature));
    this.handle = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
    handle.persist = true;
    handle.collides = false;
    handle.setCustomNameVisible(false);
    handle.setInvulnerable(npc.isImmortal());
    handle.playerConnection = new PlayerConnection(((CraftServer) Bukkit.getServer()).getServer(), new NetworkManager(EnumProtocolDirection.SERVERBOUND), handle);
    ((CraftWorld) location.getWorld()).addEntity(handle, CreatureSpawnEvent.SpawnReason.CUSTOM);
    handle.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    registry.register(this);
    for (Entity e : getEntity().getNearbyEntities(SPAWN_RADIUS, SPAWN_RADIUS, SPAWN_RADIUS)) {
        if (e instanceof Player) {
            registry.updateSpawns((Player) e, true);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) PacketPlayOutEntity(net.minecraft.server.v1_16_R3.PacketPlayOutEntity) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) GameProfile(com.mojang.authlib.GameProfile) PlayerInteractManager(net.minecraft.server.v1_16_R3.PlayerInteractManager) EntityPlayer(net.minecraft.server.v1_16_R3.EntityPlayer) DedicatedServer(net.minecraft.server.v1_16_R3.DedicatedServer) WorldServer(net.minecraft.server.v1_16_R3.WorldServer) CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer) NetworkManager(net.minecraft.server.v1_16_R3.NetworkManager) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Property(com.mojang.authlib.properties.Property) PlayerConnection(net.minecraft.server.v1_16_R3.PlayerConnection)

Example 2 with CraftServer

use of org.bukkit.craftbukkit.v1_8_R2.CraftServer in project Warlords by ebicep.

the class Warlords method onDisable.

@Override
public void onDisable() {
    if (BotManager.task != null) {
        BotManager.task.cancel();
    }
    try {
        // Pre-caution
        for (Player player : Bukkit.getOnlinePlayers()) {
            player.removePotionEffect(PotionEffectType.BLINDNESS);
            player.getActivePotionEffects().clear();
            player.removeMetadata("WARLORDS_PLAYER", this);
            PacketUtils.sendTitle(player, "", "", 0, 0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        CraftServer server = (CraftServer) Bukkit.getServer();
        server.getEntityMetadata().invalidateAll(this);
        server.getWorldMetadata().invalidateAll(this);
        server.getPlayerMetadata().invalidateAll(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        gameManager.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        if (holographicDisplaysEnabled) {
            HolographicDisplaysAPI.get(instance).getHolograms().forEach(Hologram::delete);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        NPCManager.gameStartNPC.destroy();
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        Bukkit.getWorld("MainLobby").getEntities().stream().filter(entity -> entity.getName().equals("capture-the-flag")).forEach(Entity::remove);
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        BotManager.deleteStatusMessage();
        BotManager.jda.shutdownNow();
    } catch (Exception e) {
        e.printStackTrace();
    }
    getServer().getConsoleSender().sendMessage(ChatColor.RED + "[Warlords] Plugin is disabled");
// TODO persist this.playerSettings to a database
}
Also used : LoginException(javax.security.auth.login.LoginException) com.ebicep.warlords.game(com.ebicep.warlords.game) PersistentCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.PersistentCooldown) BukkitTaskChainFactory(co.aikar.taskchain.BukkitTaskChainFactory) LoggerFactory(org.slf4j.LoggerFactory) com.ebicep.warlords.commands.debugcommands(com.ebicep.warlords.commands.debugcommands) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) Player(org.bukkit.entity.Player) SkullMeta(org.bukkit.inventory.meta.SkullMeta) org.bukkit(org.bukkit) StreamCommand(com.ebicep.warlords.party.StreamCommand) HolographicDisplaysAPI(me.filoghost.holographicdisplays.api.beta.HolographicDisplaysAPI) TaskChainFactory(co.aikar.taskchain.TaskChainFactory) RemoveEntities(com.ebicep.warlords.util.bukkit.RemoveEntities) LocationFactory(com.ebicep.warlords.util.bukkit.LocationFactory) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) QueueCommand(com.ebicep.warlords.queuesystem.QueueCommand) BotManager(com.ebicep.jda.BotManager) HealingPowerup(com.ebicep.warlords.abilties.internal.HealingPowerup) Overheal(com.ebicep.warlords.abilties.internal.Overheal) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Entity(org.bukkit.entity.Entity) TaskChain(co.aikar.taskchain.TaskChain) com.ebicep.warlords.commands.miscellaneouscommands(com.ebicep.warlords.commands.miscellaneouscommands) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) ListenerPriority(com.comphenix.protocol.events.ListenerPriority) FlagHolder(com.ebicep.warlords.game.option.marker.FlagHolder) PacketType(com.comphenix.protocol.PacketType) FireWorkEffectPlayer(com.ebicep.warlords.effects.FireWorkEffectPlayer) LivingEntity(org.bukkit.entity.LivingEntity) PartyListener(com.ebicep.warlords.party.PartyListener) Collectors(java.util.stream.Collectors) CraftServer(org.bukkit.craftbukkit.v1_8_R3.CraftServer) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) ItemStack(org.bukkit.inventory.ItemStack) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) MetadataValue(org.bukkit.metadata.MetadataValue) RegularCooldown(com.ebicep.warlords.player.cooldowns.cooldowns.RegularCooldown) NPCManager(com.ebicep.customentities.npc.NPCManager) LocationBuilder(com.ebicep.warlords.util.bukkit.LocationBuilder) LeaderboardCommand(com.ebicep.warlords.database.leaderboards.LeaderboardCommand) CooldownFilter(com.ebicep.warlords.player.cooldowns.CooldownFilter) ProtocolManager(com.comphenix.protocol.ProtocolManager) PotionEffectType(org.bukkit.potion.PotionEffectType) BotCommands(com.ebicep.jda.BotCommands) ConfigurationSerialization(org.bukkit.configuration.serialization.ConfigurationSerialization) Utils(com.ebicep.warlords.util.warlords.Utils) java.util(java.util) ApplicationConfiguration(com.ebicep.warlords.database.configuration.ApplicationConfiguration) ProtocolLibrary(com.comphenix.protocol.ProtocolLibrary) PacketUtils(com.ebicep.warlords.util.bukkit.PacketUtils) CooldownManager(com.ebicep.warlords.player.cooldowns.CooldownManager) FutureMessageManager(com.ebicep.warlords.database.FutureMessageManager) PacketPlayInSteerVehicle(net.minecraft.server.v1_8_R3.PacketPlayInSteerVehicle) GameMode(org.bukkit.GameMode) PollCommand(com.ebicep.warlords.poll.PollCommand) PacketAdapter(com.comphenix.protocol.events.PacketAdapter) Apothecary(com.ebicep.warlords.classes.rogue.specs.Apothecary) BotListener(com.ebicep.jda.BotListener) MenuEventListener(com.ebicep.warlords.menu.MenuEventListener) Utils.iterable(com.ebicep.warlords.util.warlords.Utils.iterable) Nonnull(javax.annotation.Nonnull) com.ebicep.warlords.abilties(com.ebicep.warlords.abilties) Nullable(javax.annotation.Nullable) PacketEvent(com.comphenix.protocol.events.PacketEvent) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Field(java.lang.reflect.Field) File(java.io.File) PartyCommand(com.ebicep.warlords.party.PartyCommand) com.ebicep.warlords.player(com.ebicep.warlords.player) PartyManager(com.ebicep.warlords.party.PartyManager) ChatChannels(com.ebicep.warlords.util.chat.ChatChannels) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) EnergyPowerup(com.ebicep.warlords.abilties.internal.EnergyPowerup) WarlordsEvents(com.ebicep.warlords.events.WarlordsEvents) Hologram(me.filoghost.holographicdisplays.api.beta.hologram.Hologram) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) FireWorkEffectPlayer(com.ebicep.warlords.effects.FireWorkEffectPlayer) CraftServer(org.bukkit.craftbukkit.v1_8_R3.CraftServer) LoginException(javax.security.auth.login.LoginException)

Example 3 with CraftServer

use of org.bukkit.craftbukkit.v1_8_R2.CraftServer in project CokesAddon by Cokes86.

the class v1_15_R1 method hide.

public void hide() {
    getParticipant().attributes().TARGETABLE.setValue(false);
    final CraftPlayer craftPlayer = (CraftPlayer) getPlayer();
    craftPlayer.getHandle().getDataWatcher().set(new DataWatcherObject<>(10, DataWatcherRegistry.b), 0);
    craftPlayer.getHandle().setInvisible(true);
    final PacketPlayOutEntityEquipment[] packets = { new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.MAINHAND, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.OFFHAND, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.HEAD, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.CHEST, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.LEGS, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.FEET, ItemStack.a) };
    for (CraftPlayer player : ((CraftServer) Bukkit.getServer()).getOnlinePlayers()) {
        if (player.equals(getPlayer()))
            continue;
        for (PacketPlayOutEntityEquipment packet : packets) {
            player.getHandle().playerConnection.sendPacket(packet);
        }
        injectPlayer(player);
    }
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) CraftServer(org.bukkit.craftbukkit.v1_15_R1.CraftServer)

Example 4 with CraftServer

use of org.bukkit.craftbukkit.v1_8_R2.CraftServer in project CokesAddon by Cokes86.

the class v1_12_R1 method hide.

public void hide() {
    getParticipant().attributes().TARGETABLE.setValue(false);
    final CraftPlayer craftPlayer = (CraftPlayer) getPlayer();
    craftPlayer.getHandle().getDataWatcher().set(new DataWatcherObject<>(10, DataWatcherRegistry.b), 0);
    craftPlayer.getHandle().setInvisible(true);
    final PacketPlayOutEntityEquipment[] packets = { new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.MAINHAND, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.OFFHAND, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.HEAD, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.CHEST, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.LEGS, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.FEET, ItemStack.a) };
    for (CraftPlayer player : ((CraftServer) Bukkit.getServer()).getOnlinePlayers()) {
        if (player.equals(getPlayer()))
            continue;
        for (PacketPlayOutEntityEquipment packet : packets) {
            player.getHandle().playerConnection.sendPacket(packet);
        }
        injectPlayer(player);
    }
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) CraftServer(org.bukkit.craftbukkit.v1_12_R1.CraftServer)

Example 5 with CraftServer

use of org.bukkit.craftbukkit.v1_8_R2.CraftServer in project CokesAddon by Cokes86.

the class v1_13_R1 method hide.

public void hide() {
    getParticipant().attributes().TARGETABLE.setValue(false);
    final CraftPlayer craftPlayer = (CraftPlayer) getPlayer();
    craftPlayer.getHandle().getDataWatcher().set(new DataWatcherObject<>(10, DataWatcherRegistry.b), 0);
    craftPlayer.getHandle().setInvisible(true);
    final PacketPlayOutEntityEquipment[] packets = { new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.MAINHAND, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.OFFHAND, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.HEAD, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.CHEST, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.LEGS, ItemStack.a), new PacketPlayOutEntityEquipment(getPlayer().getEntityId(), EnumItemSlot.FEET, ItemStack.a) };
    for (CraftPlayer player : ((CraftServer) Bukkit.getServer()).getOnlinePlayers()) {
        if (player.equals(getPlayer()))
            continue;
        for (PacketPlayOutEntityEquipment packet : packets) {
            player.getHandle().playerConnection.sendPacket(packet);
        }
        injectPlayer(player);
    }
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer) CraftServer(org.bukkit.craftbukkit.v1_13_R1.CraftServer)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)49 CraftServer (org.bukkit.craftbukkit.v1_16_R3.CraftServer)38 Player (org.bukkit.entity.Player)29 CraftServer (org.bukkit.craftbukkit.v1_18_R2.CraftServer)23 MinecraftServer (net.minecraft.server.MinecraftServer)22 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)21 CraftServer (org.bukkit.craftbukkit.v1_17_R1.CraftServer)21 ResourceLocation (net.minecraft.resources.ResourceLocation)20 NotNull (org.jetbrains.annotations.NotNull)18 ServerPlayer (net.minecraft.server.level.ServerPlayer)16 OfflinePlayer (org.bukkit.OfflinePlayer)16 CraftServer (org.bukkit.craftbukkit.v1_12_R1.CraftServer)16 Block (org.bukkit.block.Block)15 ServerLevel (net.minecraft.server.level.ServerLevel)14 Property (com.mojang.authlib.properties.Property)13 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)11 CraftBlock (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock)10 CraftServer (org.bukkit.craftbukkit.v1_18_R1.CraftServer)8 PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)7 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)7