mirror of https://github.com/GeyserMC/Geyser.git
Compare commits
7 Commits
48d28634a8
...
c6fbe6905a
Author | SHA1 | Date |
---|---|---|
Eclipse | c6fbe6905a | |
RK_01 | 42a9ba617b | |
chris | a57e7b54dc | |
Eclipse | 5f070ddba4 | |
Eclipse | 0304b0e49b | |
Eclipse | 7affa7798e | |
Eclipse | bc6ded53fb |
|
@ -58,7 +58,7 @@ public class GeyserSpigotLegacyNativeWorldManager extends GeyserSpigotNativeWorl
|
|||
int newBlockId = oldBlockId;
|
||||
// protocolList should *not* be null; we checked for that before initializing this class
|
||||
for (int i = protocolList.size() - 1; i >= 0; i--) {
|
||||
MappingData mappingData = protocolList.get(i).getProtocol().getMappingData();
|
||||
MappingData mappingData = protocolList.get(i).protocol().getMappingData();
|
||||
if (mappingData != null) {
|
||||
newBlockId = mappingData.getNewBlockStateId(newBlockId);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.geysermc.geyser.platform.viaproxy;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.viaproxy.cli.options.Options;
|
||||
import net.raphimc.viaproxy.ViaProxy;
|
||||
import org.geysermc.geyser.configuration.GeyserJacksonConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -43,7 +43,7 @@ public class GeyserViaProxyConfiguration extends GeyserJacksonConfiguration {
|
|||
@Override
|
||||
public int getPingPassthroughInterval() {
|
||||
int interval = super.getPingPassthroughInterval();
|
||||
if (interval < 15 && Options.PROTOCOL_VERSION != null && Options.PROTOCOL_VERSION.olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
if (interval < 15 && ViaProxy.getConfig().getTargetVersion() != null && ViaProxy.getConfig().getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_6_4)) {
|
||||
// <= 1.6.4 servers sometimes block incoming connections from an IP address if too many connections are made
|
||||
interval = 15;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ package org.geysermc.geyser.platform.viaproxy;
|
|||
|
||||
import lombok.Getter;
|
||||
import net.raphimc.viaproxy.ViaProxy;
|
||||
import net.raphimc.viaproxy.cli.options.Options;
|
||||
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
|
||||
import org.geysermc.geyser.dump.BootstrapDumpInfo;
|
||||
import org.geysermc.geyser.text.AsteriskSerializer;
|
||||
|
@ -49,8 +48,8 @@ public class GeyserViaProxyDumpInfo extends BootstrapDumpInfo {
|
|||
|
||||
public GeyserViaProxyDumpInfo() {
|
||||
this.platformVersion = ViaProxy.VERSION;
|
||||
this.onlineMode = Options.ONLINE_MODE;
|
||||
if (Options.BIND_ADDRESS instanceof InetSocketAddress inetSocketAddress) {
|
||||
this.onlineMode = ViaProxy.getConfig().isProxyOnlineMode();
|
||||
if (ViaProxy.getConfig().getBindAddress() instanceof InetSocketAddress inetSocketAddress) {
|
||||
this.serverIP = inetSocketAddress.getHostString();
|
||||
this.serverPort = inetSocketAddress.getPort();
|
||||
} else {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
package org.geysermc.geyser.platform.viaproxy;
|
||||
|
||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||
import org.geysermc.geyser.GeyserMain;
|
||||
|
||||
public class GeyserViaProxyMain extends GeyserMain {
|
||||
|
@ -39,7 +38,7 @@ public class GeyserViaProxyMain extends GeyserMain {
|
|||
}
|
||||
|
||||
public String getPluginFolder() {
|
||||
return PluginManager.PLUGINS_DIR.getName();
|
||||
return "plugins";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ package org.geysermc.geyser.platform.viaproxy;
|
|||
import net.lenni0451.lambdaevents.EventHandler;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.viaproxy.ViaProxy;
|
||||
import net.raphimc.viaproxy.cli.options.Options;
|
||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
|
||||
import net.raphimc.viaproxy.plugins.events.ConsoleCommandEvent;
|
||||
|
@ -137,7 +136,7 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserBootst
|
|||
|
||||
GeyserImpl.start();
|
||||
|
||||
if (Options.PROTOCOL_VERSION != null && Options.PROTOCOL_VERSION.newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
if (ViaProxy.getConfig().getTargetVersion() != null && ViaProxy.getConfig().getTargetVersion().newerThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
// Only initialize the ping passthrough if the protocol version is above beta 1.7.3, as that's when the status protocol was added
|
||||
this.pingPassthrough = GeyserLegacyPingPassthrough.init(this.geyser);
|
||||
}
|
||||
|
@ -186,19 +185,19 @@ public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserBootst
|
|||
@NotNull
|
||||
@Override
|
||||
public String getServerBindAddress() {
|
||||
if (Options.BIND_ADDRESS instanceof InetSocketAddress socketAddress) {
|
||||
if (ViaProxy.getConfig().getBindAddress() instanceof InetSocketAddress socketAddress) {
|
||||
return socketAddress.getHostString();
|
||||
} else {
|
||||
throw new IllegalStateException("Unsupported bind address type: " + Options.BIND_ADDRESS.getClass().getName());
|
||||
throw new IllegalStateException("Unsupported bind address type: " + ViaProxy.getConfig().getBindAddress().getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getServerPort() {
|
||||
if (Options.BIND_ADDRESS instanceof InetSocketAddress socketAddress) {
|
||||
if (ViaProxy.getConfig().getBindAddress() instanceof InetSocketAddress socketAddress) {
|
||||
return socketAddress.getPort();
|
||||
} else {
|
||||
throw new IllegalStateException("Unsupported bind address type: " + Options.BIND_ADDRESS.getClass().getName());
|
||||
throw new IllegalStateException("Unsupported bind address type: " + ViaProxy.getConfig().getBindAddress().getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@ name: "${name}-ViaProxy"
|
|||
version: "${version}"
|
||||
author: "${author}"
|
||||
main: "org.geysermc.geyser.platform.viaproxy.GeyserViaProxyPlugin"
|
||||
min-version: "3.2.0"
|
||||
min-version: "3.2.1"
|
||||
|
|
|
@ -82,11 +82,15 @@ public class GeyserAdvancement {
|
|||
this.rootId = this.advancement.getId();
|
||||
} else {
|
||||
// Go through our cache, and descend until we find the root ID
|
||||
GeyserAdvancement advancement = advancementsCache.getStoredAdvancements().get(this.advancement.getParentId());
|
||||
if (advancement.getParentId() == null) {
|
||||
this.rootId = advancement.getId();
|
||||
GeyserAdvancement parent = advancementsCache.getStoredAdvancements().get(this.advancement.getParentId());
|
||||
if (parent == null) {
|
||||
// Parent doesn't exist, is invalid, or couldn't be found for another reason
|
||||
// So assuming there is no parent and this is the root
|
||||
this.rootId = this.advancement.getId();
|
||||
} else if (parent.getParentId() == null) {
|
||||
this.rootId = parent.getId();
|
||||
} else {
|
||||
this.rootId = advancement.getRootId(advancementsCache);
|
||||
this.rootId = parent.getRootId(advancementsCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,7 +162,15 @@ public class AdvancementsCache {
|
|||
// Cache language for easier access
|
||||
String language = session.locale();
|
||||
|
||||
String earned = isEarned(advancement) ? "yes" : "no";
|
||||
boolean advancementHasProgress = advancement.getRequirements().size() > 1;
|
||||
|
||||
int advancementProgress = getProgress(advancement);
|
||||
int advancementRequirements = advancement.getRequirements().size();
|
||||
|
||||
boolean advancementEarned = advancementRequirements > 0
|
||||
&& advancementProgress >= advancementRequirements;
|
||||
|
||||
String earned = advancementEarned ? "yes" : "no";
|
||||
|
||||
String description = getColorFromAdvancementFrameType(advancement) + MessageTranslator.convertMessage(advancement.getDisplayData().getDescription(), language);
|
||||
String earnedString = GeyserLocale.getPlayerLocaleString("geyser.advancements.earned", language, MinecraftLocale.getLocaleString("gui." + earned, language));
|
||||
|
@ -175,10 +183,20 @@ public class AdvancementsCache {
|
|||
(Description) Mine stone with your new pickaxe
|
||||
|
||||
Earned: Yes
|
||||
Progress: 1/4 // When advancement has multiple requirements
|
||||
Parent Advancement: Minecraft // If relevant
|
||||
*/
|
||||
|
||||
String content = description + "\n\n§f" + earnedString + "\n";
|
||||
|
||||
if (advancementHasProgress) {
|
||||
// Only display progress with multiple requirements
|
||||
String progress = MinecraftLocale.getLocaleString("advancements.progress", language)
|
||||
.replaceFirst("%s", String.valueOf(advancementProgress))
|
||||
.replaceFirst("%s", String.valueOf(advancementRequirements));
|
||||
content += GeyserLocale.getPlayerLocaleString("geyser.advancements.progress", language, progress) + "\n";
|
||||
}
|
||||
|
||||
if (!currentAdvancementCategoryId.equals(advancement.getParentId())) {
|
||||
// Only display the parent if it is not the category
|
||||
content += GeyserLocale.getPlayerLocaleString("geyser.advancements.parentid", language, MessageTranslator.convertMessage(storedAdvancements.get(advancement.getParentId()).getDisplayData().getTitle(), language));
|
||||
|
@ -200,34 +218,44 @@ public class AdvancementsCache {
|
|||
* @return true if the advancement has been earned.
|
||||
*/
|
||||
public boolean isEarned(GeyserAdvancement advancement) {
|
||||
boolean earned = false;
|
||||
if (advancement.getRequirements().size() == 0) {
|
||||
if (advancement.getRequirements().isEmpty()) {
|
||||
// Minecraft handles this case, so we better as well
|
||||
return false;
|
||||
}
|
||||
Map<String, Long> progress = storedAdvancementProgress.get(advancement.getId());
|
||||
if (progress != null) {
|
||||
// Progress should never be above requirements count, but you never know
|
||||
return getProgress(advancement) >= advancement.getRequirements().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the progress on an advancement.
|
||||
*
|
||||
* @param advancement the advancement to determine
|
||||
* @return the progress on the advancement.
|
||||
*/
|
||||
public int getProgress(GeyserAdvancement advancement) {
|
||||
if (advancement.getRequirements().isEmpty()) {
|
||||
// Minecraft handles this case
|
||||
return 0;
|
||||
}
|
||||
int progress = 0;
|
||||
Map<String, Long> progressMap = storedAdvancementProgress.get(advancement.getId());
|
||||
if (progressMap != null) {
|
||||
// Each advancement's requirement must be fulfilled
|
||||
// For example, [[zombie, blaze, skeleton]] means that one of those three categories must be achieved
|
||||
// But [[zombie], [blaze], [skeleton]] means that all three requirements must be completed
|
||||
for (List<String> requirements : advancement.getRequirements()) {
|
||||
boolean requirementsDone = false;
|
||||
for (String requirement : requirements) {
|
||||
Long obtained = progress.get(requirement);
|
||||
Long obtained = progressMap.get(requirement);
|
||||
// -1 means that this particular component required for completing the advancement
|
||||
// has yet to be fulfilled
|
||||
if (obtained != null && !obtained.equals(-1L)) {
|
||||
requirementsDone = true;
|
||||
break;
|
||||
progress++;
|
||||
}
|
||||
}
|
||||
if (!requirementsDone) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
earned = true;
|
||||
}
|
||||
return earned;
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
public String getColorFromAdvancementFrameType(GeyserAdvancement advancement) {
|
||||
|
|
|
@ -29,7 +29,7 @@ adapters = "1.11-SNAPSHOT"
|
|||
commodore = "2.2"
|
||||
bungeecord = "a7c6ede"
|
||||
velocity = "3.1.1"
|
||||
viaproxy = "3.2.0-SNAPSHOT"
|
||||
viaproxy = "3.2.1"
|
||||
fabric-minecraft = "1.20.4"
|
||||
fabric-loader = "0.15.2"
|
||||
fabric-api = "0.91.2+1.20.4"
|
||||
|
|
Loading…
Reference in New Issue