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:
@ -41,6 +41,8 @@ public class KCauldron {
|
||||
sGroup = manifest.getProperty("KCauldron-Group");
|
||||
sBranch = manifest.getProperty("KCauldron-Branch");
|
||||
sChannel = manifest.getProperty("KCauldron-Channel");
|
||||
sLegacy = Boolean.parseBoolean(manifest.getProperty("KCauldron-Legacy"));
|
||||
sOfficial = Boolean.parseBoolean(manifest.getProperty("KCauldron-Official"));
|
||||
break;
|
||||
}
|
||||
manifest.clear();
|
||||
@ -99,6 +101,18 @@ public class KCauldron {
|
||||
parseManifest();
|
||||
return sChannel;
|
||||
}
|
||||
|
||||
private static boolean sLegacy, sOfficial;
|
||||
|
||||
public static boolean isLegacy() {
|
||||
parseManifest();
|
||||
return sLegacy;
|
||||
}
|
||||
|
||||
public static boolean isOfficial() {
|
||||
parseManifest();
|
||||
return sOfficial;
|
||||
}
|
||||
|
||||
public static File sNewServerLocation;
|
||||
public static String sNewServerVersion;
|
||||
|
@ -6,6 +6,7 @@ import kcauldron.updater.KVersionRetriever.IVersionCheckCallback;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@ -19,13 +20,21 @@ public class DefaultUpdateCallback implements IVersionCheckCallback {
|
||||
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (mHasUpdate && hasPermission(player)) {
|
||||
sendUpdate(player);
|
||||
if (hasPermission(player)) {
|
||||
if (KCauldron.isLegacy()) {
|
||||
player.sendMessage(ChatColor.YELLOW + "We're running on legacy version on KCauldron, please update your version");
|
||||
}
|
||||
if (!KCauldron.isOfficial()) {
|
||||
player.sendMessage(ChatColor.YELLOW + "We're running on non-official version on KCauldron, please update your version");
|
||||
}
|
||||
if (mHasUpdate) {
|
||||
sendUpdate(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasPermission(CommandSender player) {
|
||||
return player.hasPermission(KCauldronCommand.UPDATE);
|
||||
return player.hasPermission(KCauldronCommand.UPDATE) || player.isOp();
|
||||
}
|
||||
|
||||
private void sendUpdate(CommandSender player) {
|
||||
|
@ -83,6 +83,7 @@ public class KVersionRetriever implements Runnable, UncaughtExceptionHandler {
|
||||
.get()
|
||||
.setUri("https://api.prok.pw/repo/version/" + mGroup + "/"
|
||||
+ mName)
|
||||
.addParameter("version", KCauldron.getCurrentVersion())
|
||||
.addParameter("hostname", sServer.getHostname())
|
||||
.addParameter("port", "" + sServer.getPort()).build();
|
||||
HttpResponse response = HttpClientBuilder.create()
|
||||
|
@ -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