forked from xjboss/KCauldronX
Some portion of optimizations:
* Clear outgoing packet queue after player disconnect * Disable sleep between chunk saving * Put 2x4096 bytes instead 2048x4 bytes for region file aligment * Using map to search player by name instead iterating over all players * Some tweaks for decorations (item frames, maps)
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
package org.bukkit.craftbukkit.map;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
@ -8,6 +11,8 @@ import org.bukkit.map.MapCursorCollection;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import net.minecraft.world.storage.MapData;
|
||||
|
||||
public class CraftMapRenderer extends MapRenderer {
|
||||
|
||||
private final net.minecraft.world.storage.MapData worldMap;
|
||||
@ -32,14 +37,14 @@ public class CraftMapRenderer extends MapRenderer {
|
||||
cursors.removeCursor(cursors.getCursor(0));
|
||||
}
|
||||
|
||||
for (Object key : worldMap.playersVisibleOnMap.keySet()) {
|
||||
for (Map.Entry<UUID, MapData.MapCoord> key : worldMap.playersVisibleOnMap.entrySet()) {
|
||||
// If this cursor is for a player check visibility with vanish system
|
||||
Player other = Bukkit.getPlayerExact((String) key);
|
||||
Player other = Bukkit.getPlayer(key.getKey());
|
||||
if (other != null && !player.canSee(other)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
net.minecraft.world.storage.MapData.MapCoord decoration = (net.minecraft.world.storage.MapData.MapCoord) worldMap.playersVisibleOnMap.get(key);
|
||||
MapData.MapCoord decoration = key.getValue();
|
||||
cursors.addCursor(decoration.centerX, decoration.centerZ, (byte) (decoration.iconRotation & 15), decoration.iconSize);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package org.spigotmc;
|
||||
|
||||
import gnu.trove.strategy.HashingStrategy;
|
||||
|
||||
class CaseInsensitiveHashingStrategy implements HashingStrategy<String> {
|
||||
private static final long serialVersionUID = -9212222772914758878L;
|
||||
static final CaseInsensitiveHashingStrategy INSTANCE = new CaseInsensitiveHashingStrategy();
|
||||
|
||||
@Override
|
||||
public int computeHashCode(String object) {
|
||||
return object.toLowerCase().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(String o1, String o2) {
|
||||
return o1.equalsIgnoreCase(o2);
|
||||
}
|
||||
}
|
15
src/main/java/org/spigotmc/CaseInsensitiveMap.java
Normal file
15
src/main/java/org/spigotmc/CaseInsensitiveMap.java
Normal file
@ -0,0 +1,15 @@
|
||||
package org.spigotmc;
|
||||
|
||||
import gnu.trove.map.hash.TCustomHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CaseInsensitiveMap<V> extends TCustomHashMap<String, V> {
|
||||
|
||||
public CaseInsensitiveMap() {
|
||||
super(CaseInsensitiveHashingStrategy.INSTANCE);
|
||||
}
|
||||
|
||||
public CaseInsensitiveMap(Map<? extends String, ? extends V> map) {
|
||||
super(CaseInsensitiveHashingStrategy.INSTANCE, map);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user