Search in sources :

Example 26 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Dragonet-Legacy by DragonetMC.

the class ClientChunkManager method sendChunks.

/**
     * Send all queued chunks to the client and mark them as sent
     */
public synchronized void sendChunks() {
    if (!(this.getSession().getPlayer() instanceof GlowPlayer)) {
        return;
    }
    ChunkLocation chunkLocation;
    while ((chunkLocation = this.chunksQueue.poll()) != null) {
        this.sendChunk(chunkLocation.getX(), chunkLocation.getZ());
        this.chunksLoaded.add(chunkLocation);
    }
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) ChunkLocation(org.dragonet.ChunkLocation)

Example 27 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Glowstone by GlowstoneMC.

the class GlowBlock method setTypeIdAndData.

@Override
public boolean setTypeIdAndData(int type, byte data, boolean applyPhysics) {
    Material oldTypeId = getType();
    byte oldData = getData();
    ((GlowChunk) world.getChunkAt(this)).setType(x & 0xf, z & 0xf, y, type);
    ((GlowChunk) world.getChunkAt(this)).setMetaData(x & 0xf, z & 0xf, y, data);
    if (oldTypeId == Material.DOUBLE_PLANT && getRelative(BlockFace.UP).getType() == Material.DOUBLE_PLANT) {
        world.getChunkAtAsync(this, chunk -> ((GlowChunk) chunk).setType(x & 0xf, z & 0xf, y + 1, 0));
        BlockChangeMessage bcmsg = new BlockChangeMessage(x, y + 1, z, 0, 0);
        for (GlowPlayer p : getWorld().getRawPlayers()) {
            p.sendBlockChange(bcmsg);
        }
    }
    if (applyPhysics) {
        applyPhysics(oldTypeId, type, oldData, data);
    }
    BlockChangeMessage bcmsg = new BlockChangeMessage(x, y, z, type, data);
    for (GlowPlayer p : getWorld().getRawPlayers()) {
        p.sendBlockChange(bcmsg);
    }
    return true;
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) Material(org.bukkit.Material) BlockChangeMessage(net.glowstone.net.message.play.game.BlockChangeMessage) GlowChunk(net.glowstone.chunk.GlowChunk)

Example 28 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Glowstone by GlowstoneMC.

the class PlayerProfile method getProfile.

/**
     * Get the profile for a username.
     *
     * @param name The username to lookup.
     * @return The profile.
     */
public static PlayerProfile getProfile(String name) {
    if (name == null || name.length() > MAX_USERNAME_LENGTH || name.isEmpty()) {
        return null;
    }
    Player player = Bukkit.getServer().getPlayer(name);
    if (player != null) {
        return ((GlowPlayer) player).getProfile();
    }
    UUID uuid = ProfileCache.getUUID(name);
    if (uuid != null) {
        return ProfileCache.getProfile(uuid);
    }
    GlowServer.logger.warning("Unable to get UUID for username: " + name);
    return null;
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer) Player(org.bukkit.entity.Player) GlowPlayer(net.glowstone.entity.GlowPlayer)

Example 29 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Glowstone by GlowstoneMC.

the class GlowServer method shutdown.

/**
     * Stops this server.
     */
@Override
public void shutdown() {
    // Just in case this gets called twice
    if (isShuttingDown) {
        return;
    }
    isShuttingDown = true;
    logger.info("The server is shutting down...");
    // Disable plugins
    pluginManager.clearPlugins();
    // Kick all players (this saves their data too)
    for (GlowPlayer player : new ArrayList<>(getRawOnlinePlayers())) {
        player.kickPlayer(getShutdownMessage(), false);
    }
    // It may take a second or two for Netty to totally clean up
    if (networkServer != null) {
        networkServer.shutdown();
    }
    if (queryServer != null) {
        queryServer.shutdown();
    }
    if (rconServer != null) {
        rconServer.shutdown();
    }
    // Save worlds
    for (World world : getWorlds()) {
        logger.info("Saving world: " + world.getName());
        unloadWorld(world, true);
    }
    // Stop scheduler and console
    scheduler.stop();
    consoleManager.stop();
    // Wait for a while and terminate any rogue threads
    new ShutdownMonitorThread().start();
}
Also used : GlowPlayer(net.glowstone.entity.GlowPlayer)

Example 30 with GlowPlayer

use of net.glowstone.entity.GlowPlayer in project Glowstone by GlowstoneMC.

the class GlowItem method pulse.

@Override
public void pulse() {
    super.pulse();
    // decrement pickupDelay if it's less than the NBT maximum
    if (pickupDelay > 0) {
        if (pickupDelay < Short.MAX_VALUE) {
            --pickupDelay;
        }
        if (pickupDelay < 20 && biasPlayer != null) {
            // check for the bias player
            for (Entity entity : getNearbyEntities(1, 0.5, 1)) {
                if (entity.isDead()) {
                    continue;
                }
                if (entity == biasPlayer && getPickedUp((GlowPlayer) entity)) {
                    break;
                }
            }
        }
    } else {
        // check for nearby players
        for (Entity entity : getNearbyEntities(1, 0.5, 1)) {
            if (entity.isDead()) {
                continue;
            }
            if (entity instanceof GlowPlayer && getPickedUp((GlowPlayer) entity)) {
                break;
            }
            if (entity instanceof GlowItem) {
                if (entity != this && ((GlowItem) entity).getItemStack().isSimilar(getItemStack())) {
                    ItemStack clone = getItemStack().clone();
                    clone.setAmount(((GlowItem) entity).getItemStack().getAmount() + clone.getAmount());
                    entity.remove();
                    setItemStack(clone);
                }
            }
        }
    }
    // disappear if we've lived too long
    if (getTicksLived() >= LIFETIME) {
        remove();
    }
}
Also used : Entity(org.bukkit.entity.Entity) GlowEntity(net.glowstone.entity.GlowEntity) GlowPlayer(net.glowstone.entity.GlowPlayer) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

GlowPlayer (net.glowstone.entity.GlowPlayer)39 ItemStack (org.bukkit.inventory.ItemStack)10 GlowBlock (net.glowstone.block.GlowBlock)5 Player (org.bukkit.entity.Player)5 Message (com.flowpowered.network.Message)4 Location (org.bukkit.Location)4 GlowWorld (net.glowstone.GlowWorld)3 ItemType (net.glowstone.block.itemtype.ItemType)3 UserListItemMessage (net.glowstone.net.message.play.game.UserListItemMessage)3 BlockPlacementMessage (net.glowstone.net.message.play.player.BlockPlacementMessage)3 Material (org.bukkit.Material)3 Block (org.bukkit.block.Block)3 BlockFace (org.bukkit.block.BlockFace)3 Vector (org.bukkit.util.Vector)3 ChunkLocation (org.dragonet.ChunkLocation)3 PEPacket (org.dragonet.net.packet.minecraft.PEPacket)3 AsyncableMessage (com.flowpowered.network.AsyncableMessage)2 Message (com.flowpowered.networking.Message)2 ArrayList (java.util.ArrayList)2 BlockType (net.glowstone.block.blocktype.BlockType)2