[BUG] Fix servers being un-pingable. Closes #13
This commit is contained in:
@@ -16,7 +16,7 @@ public class ServerStatusMixin {
|
|||||||
|
|
||||||
@Inject(method = "getFavicon", at = @At("RETURN"), cancellable = true)
|
@Inject(method = "getFavicon", at = @At("RETURN"), cancellable = true)
|
||||||
private void injectIconEvent(CallbackInfoReturnable<String> cir) {
|
private void injectIconEvent(CallbackInfoReturnable<String> cir) {
|
||||||
ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue())));
|
ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(isEmpty(cir.getReturnValue()) ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue())));
|
||||||
CraterEventBus.INSTANCE.postEvent(event);
|
CraterEventBus.INSTANCE.postEvent(event);
|
||||||
|
|
||||||
if (event.getNewIcon().isPresent()) {
|
if (event.getNewIcon().isPresent()) {
|
||||||
@@ -24,4 +24,8 @@ public class ServerStatusMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isEmpty(String input) {
|
||||||
|
return input == null || input.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@ public class ServerStatusMixin {
|
|||||||
|
|
||||||
@Inject(method = "getFavicon", at = @At("RETURN"), cancellable = true)
|
@Inject(method = "getFavicon", at = @At("RETURN"), cancellable = true)
|
||||||
private void injectIconEvent(CallbackInfoReturnable<String> cir) {
|
private void injectIconEvent(CallbackInfoReturnable<String> cir) {
|
||||||
ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue())));
|
ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(isEmpty(cir.getReturnValue()) ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue())));
|
||||||
CraterEventBus.INSTANCE.postEvent(event);
|
CraterEventBus.INSTANCE.postEvent(event);
|
||||||
|
|
||||||
if (event.getNewIcon().isPresent()) {
|
if (event.getNewIcon().isPresent()) {
|
||||||
@@ -24,4 +24,8 @@ public class ServerStatusMixin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isEmpty(String input) {
|
||||||
|
return input == null || input.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
--- a/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
--- a/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
||||||
+++ b/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
+++ b/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
||||||
@@ -14,13 +14,13 @@
|
@@ -14,14 +14,18 @@
|
||||||
@Mixin(ServerStatus.class)
|
@Mixin(ServerStatus.class)
|
||||||
public class ServerStatusMixin {
|
public class ServerStatusMixin {
|
||||||
|
|
||||||
@@ -9,12 +9,17 @@
|
|||||||
- ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue().get())));
|
- ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue().get())));
|
||||||
+ @Inject(method = "getFavicon", at = @At("RETURN"), cancellable = true)
|
+ @Inject(method = "getFavicon", at = @At("RETURN"), cancellable = true)
|
||||||
+ private void injectIconEvent(CallbackInfoReturnable<String> cir) {
|
+ private void injectIconEvent(CallbackInfoReturnable<String> cir) {
|
||||||
+ ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue())));
|
+ ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(isEmpty(cir.getReturnValue()) ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue())));
|
||||||
CraterEventBus.INSTANCE.postEvent(event);
|
CraterEventBus.INSTANCE.postEvent(event);
|
||||||
|
|
||||||
if (event.getNewIcon().isPresent()) {
|
if (event.getNewIcon().isPresent()) {
|
||||||
- cir.setReturnValue(Optional.of(event.getNewIcon().get().toMojang()));
|
- cir.setReturnValue(Optional.of(event.getNewIcon().get().toMojang()));
|
||||||
+ cir.setReturnValue(event.getNewIcon().get().toMojang());
|
+ cir.setReturnValue(event.getNewIcon().get().toMojang());
|
||||||
}
|
}
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private boolean isEmpty(String input) {
|
||||||
|
+ return input == null || input.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
--- a/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
--- a/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
||||||
+++ b/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
+++ b/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
||||||
@@ -14,13 +14,13 @@
|
@@ -14,14 +14,18 @@
|
||||||
@Mixin(ServerStatus.class)
|
@Mixin(ServerStatus.class)
|
||||||
public class ServerStatusMixin {
|
public class ServerStatusMixin {
|
||||||
|
|
||||||
@@ -9,12 +9,17 @@
|
|||||||
- ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue().get())));
|
- ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue().get())));
|
||||||
+ @Inject(method = "getFavicon", at = @At("RETURN"), cancellable = true)
|
+ @Inject(method = "getFavicon", at = @At("RETURN"), cancellable = true)
|
||||||
+ private void injectIconEvent(CallbackInfoReturnable<String> cir) {
|
+ private void injectIconEvent(CallbackInfoReturnable<String> cir) {
|
||||||
+ ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue())));
|
+ ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(isEmpty(cir.getReturnValue()) ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue())));
|
||||||
CraterEventBus.INSTANCE.postEvent(event);
|
CraterEventBus.INSTANCE.postEvent(event);
|
||||||
|
|
||||||
if (event.getNewIcon().isPresent()) {
|
if (event.getNewIcon().isPresent()) {
|
||||||
- cir.setReturnValue(Optional.of(event.getNewIcon().get().toMojang()));
|
- cir.setReturnValue(Optional.of(event.getNewIcon().get().toMojang()));
|
||||||
+ cir.setReturnValue(event.getNewIcon().get().toMojang());
|
+ cir.setReturnValue(event.getNewIcon().get().toMojang());
|
||||||
}
|
}
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private boolean isEmpty(String input) {
|
||||||
|
+ return input == null || input.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user