mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 02:15:34 -04:00
fix duplicated version mappings loading
This commit is contained in:
parent
fad06a58a1
commit
da589cd6b4
@ -25,6 +25,7 @@ public class Version {
|
||||
final HashMap<ConnectionStates, HashBiMap<Packets.Serverbound, Integer>> serverboundPacketMapping;
|
||||
final HashMap<ConnectionStates, HashBiMap<Packets.Clientbound, Integer>> clientboundPacketMapping;
|
||||
VersionMapping mapping;
|
||||
boolean isGettingLoaded;
|
||||
|
||||
public Version(String versionName, int protocolVersion, HashMap<ConnectionStates, HashBiMap<Packets.Serverbound, Integer>> serverboundPacketMapping, HashMap<ConnectionStates, HashBiMap<Packets.Clientbound, Integer>> clientboundPacketMapping) {
|
||||
this.versionName = versionName;
|
||||
@ -76,6 +77,15 @@ public class Version {
|
||||
this.mapping = mapping;
|
||||
}
|
||||
|
||||
|
||||
public boolean isGettingLoaded() {
|
||||
return isGettingLoaded;
|
||||
}
|
||||
|
||||
public void setGettingLoaded(boolean gettingLoaded) {
|
||||
isGettingLoaded = gettingLoaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (super.equals(obj)) {
|
||||
|
@ -134,6 +134,10 @@ public class Versions {
|
||||
if (protocolId < ProtocolDefinition.FLATTING_VERSION_ID) {
|
||||
version = versionMap.get(ProtocolDefinition.PRE_FLATTENING_VERSION_ID);
|
||||
}
|
||||
if (version.isGettingLoaded()) {
|
||||
return;
|
||||
}
|
||||
version.setGettingLoaded(true);
|
||||
Log.verbose(String.format("Loading mappings for version %s...", version));
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
@ -161,7 +165,7 @@ public class Versions {
|
||||
}
|
||||
|
||||
Log.verbose(String.format("Loaded mappings for version %s in %dms (%s)", version, (System.currentTimeMillis() - startTime), version.getVersionName()));
|
||||
|
||||
version.setGettingLoaded(false);
|
||||
}
|
||||
|
||||
public static void unloadUnnecessaryVersions(int necessary) {
|
||||
|
@ -275,7 +275,7 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
Log.info(String.format("Refreshing server status (serverName=\"%s\", address=\"%s\"", server.getName(), server.getAddress()));
|
||||
Log.info(String.format("Refreshing server status (serverName=\"%s\", address=\"%s\")", server.getName(), server.getAddress()));
|
||||
if (server.getLastPing() == null) {
|
||||
// server was not pinged, don't even try, only costs memory and cpu
|
||||
return;
|
||||
|
@ -207,11 +207,14 @@ public class Connection {
|
||||
}
|
||||
|
||||
public void setVersion(Version version) {
|
||||
if (this.version == version) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.version = version;
|
||||
this.customMapping.setVersion(version);
|
||||
try {
|
||||
Versions.loadVersionMappings(version.getProtocolVersion());
|
||||
customMapping.setVersion(version);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.fatal(String.format("Could not load mapping for %s. This version seems to be unsupported!", version));
|
||||
|
@ -65,7 +65,7 @@ public class PacketHandler {
|
||||
if (version == null) {
|
||||
Log.fatal(String.format("Server is running on unknown version or a invalid version was forced (version=%d, brand=\"%s\")", versionId, pkg.getResponse().getServerBrand()));
|
||||
} else {
|
||||
connection.setVersion(version);
|
||||
connection.setVersion(version);
|
||||
}
|
||||
Log.info(String.format("Status response received: %s/%s online. MotD: '%s'", pkg.getResponse().getPlayerOnline(), pkg.getResponse().getMaxPlayers(), pkg.getResponse().getMotd().getColoredMessage()));
|
||||
connection.handleCallbacks(pkg.getResponse());
|
||||
|
Loading…
x
Reference in New Issue
Block a user