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