use of net.minecraft.world.server.ChunkManager in project dynmap by webbukkit.
the class ForgeMapChunkCache method readChunk.
public CompoundNBT readChunk(int x, int z) {
try {
ChunkManager acl = cps.chunkManager;
ChunkPos coord = new ChunkPos(x, z);
CompoundNBT rslt = acl.readChunk(coord);
if (rslt != null) {
rslt = rslt.getCompound("Level");
// Don't load uncooked chunks
String stat = rslt.getString("Status");
ChunkStatus cs = ChunkStatus.byName(stat);
if ((stat == null) || // Needs to be at least lighted
(!cs.isAtLeast(ChunkStatus.LIGHT))) {
rslt = null;
}
}
// Log.info(String.format("loadChunk(%d,%d)=%s", x, z, (rslt != null) ? rslt.toString() : "null"));
return rslt;
} catch (Exception exc) {
Log.severe(String.format("Error reading chunk: %s,%d,%d", dw.getName(), x, z), exc);
return null;
}
}
use of net.minecraft.world.server.ChunkManager in project dynmap by webbukkit.
the class ForgeMapChunkCache method readChunk.
public CompoundNBT readChunk(int x, int z) {
try {
ChunkManager acl = cps.chunkManager;
ChunkPos coord = new ChunkPos(x, z);
CompoundNBT rslt = acl.readChunk(coord);
if (rslt != null) {
rslt = rslt.getCompound("Level");
// Don't load uncooked chunks
String stat = rslt.getString("Status");
ChunkStatus cs = ChunkStatus.byName(stat);
if ((stat == null) || // Needs to be at least lighted
(!cs.isAtLeast(ChunkStatus.LIGHT))) {
rslt = null;
}
}
// Log.info(String.format("loadChunk(%d,%d)=%s", x, z, (rslt != null) ? rslt.toString() : "null"));
return rslt;
} catch (Exception exc) {
Log.severe(String.format("Error reading chunk: %s,%d,%d", dw.getName(), x, z), exc);
return null;
}
}
use of net.minecraft.world.server.ChunkManager in project Magma-1.16.x by magmafoundation.
the class CraftPlayer method hidePlayer0.
private void hidePlayer0(@Nullable Plugin plugin, Player player) {
Validate.notNull(player, "hidden player cannot be null");
if (getHandle().connection == null)
return;
if (equals(player))
return;
Set<WeakReference<Plugin>> hidingPlugins = hiddenPlayers.get(player.getUniqueId());
if (hidingPlugins != null) {
// Some plugins are already hiding the player. Just mark that this
// plugin wants the player hidden too and end.
hidingPlugins.add(getPluginWeakReference(plugin));
return;
}
hidingPlugins = new HashSet<>();
hidingPlugins.add(getPluginWeakReference(plugin));
hiddenPlayers.put(player.getUniqueId(), hidingPlugins);
// Remove this player from the hidden player's EntityTrackerEntry
ChunkManager tracker = ((ServerWorld) entity.level).getChunkSource().chunkMap;
ServerPlayerEntity other = ((CraftPlayer) player).getHandle();
ChunkManager.EntityTracker entry = tracker.entityMap.get(other.getId());
if (entry != null) {
entry.removePlayer(getHandle());
}
// Remove the hidden player from this player user list, if they're on it
if (other.sentListPacket) {
getHandle().connection.send(new SPlayerListItemPacket(SPlayerListItemPacket.Action.REMOVE_PLAYER, other));
}
}
use of net.minecraft.world.server.ChunkManager in project Magma-1.16.x by magmafoundation.
the class CraftPlayer method showPlayer0.
private void showPlayer0(@Nullable Plugin plugin, Player player) {
Validate.notNull(player, "shown player cannot be null");
if (getHandle().connection == null)
return;
if (equals(player))
return;
Set<WeakReference<Plugin>> hidingPlugins = hiddenPlayers.get(player.getUniqueId());
if (hidingPlugins == null) {
// Player isn't hidden
return;
}
hidingPlugins.remove(getPluginWeakReference(plugin));
if (!hidingPlugins.isEmpty()) {
// Some other plugins still want the player hidden
return;
}
hiddenPlayers.remove(player.getUniqueId());
ChunkManager tracker = ((ServerWorld) entity.level).getChunkSource().chunkMap;
ServerPlayerEntity other = ((CraftPlayer) player).getHandle();
getHandle().connection.send(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, other));
ChunkManager.EntityTracker entry = tracker.entityMap.get(other.getId());
if (entry != null && !entry.seenBy.contains(getHandle())) {
entry.updatePlayer(getHandle());
}
}
use of net.minecraft.world.server.ChunkManager in project LoliServer by Loli-Server.
the class CraftPlayer method showPlayer0.
private void showPlayer0(@Nullable Plugin plugin, Player player) {
Validate.notNull(player, "shown player cannot be null");
if (getHandle().connection == null)
return;
if (equals(player))
return;
Set<WeakReference<Plugin>> hidingPlugins = hiddenPlayers.get(player.getUniqueId());
if (hidingPlugins == null) {
// Player isn't hidden
return;
}
hidingPlugins.remove(getPluginWeakReference(plugin));
if (!hidingPlugins.isEmpty()) {
// Some other plugins still want the player hidden
return;
}
hiddenPlayers.remove(player.getUniqueId());
ChunkManager tracker = ((ServerWorld) entity.level).getChunkSource().chunkMap;
ServerPlayerEntity other = ((CraftPlayer) player).getHandle();
getHandle().connection.send(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, other));
tracker.updateTrackingState(tracker, getHandle(), other.getId());
}
Aggregations