aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hype/bbsentials/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/hype/bbsentials/client')
-rw-r--r--src/main/java/de/hype/bbsentials/client/BBsentials.java1
-rw-r--r--src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java10
-rw-r--r--src/main/java/de/hype/bbsentials/client/Config.java1
-rw-r--r--src/main/java/de/hype/bbsentials/client/ModMenueScreen.java7
-rw-r--r--src/main/java/de/hype/bbsentials/client/SplashStatusUpdateListener.java67
5 files changed, 82 insertions, 4 deletions
diff --git a/src/main/java/de/hype/bbsentials/client/BBsentials.java b/src/main/java/de/hype/bbsentials/client/BBsentials.java
index 5c14c2e..b74e633 100644
--- a/src/main/java/de/hype/bbsentials/client/BBsentials.java
+++ b/src/main/java/de/hype/bbsentials/client/BBsentials.java
@@ -35,6 +35,7 @@ public class BBsentials implements ClientModInitializer {
public static boolean splashLobby;
private static Thread bbthread;
private boolean initialised = false;
+ public static SplashStatusUpdateListener splashStatusUpdateListener;
public static Config getConfig() {
return config;
diff --git a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java b/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java
index 2d0039c..555c42d 100644
--- a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java
+++ b/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java
@@ -228,7 +228,7 @@ public class BBsentialsConfigScreemFactory {
.build());
} //Mining Events
if (config.hasBBRoles("dev")){
- ConfigCategory dev = builder.getOrCreateCategory(Text.of("Developing"));
+ ConfigCategory dev = builder.getOrCreateCategory(Text.of("§3Developing"));
dev.addEntry(entryBuilder.startBooleanToggle(Text.of("Dev Mode"), config.devMode)
.setDefaultValue(false)
.setTooltip(Text.of("Dev Mode"))
@@ -240,6 +240,14 @@ public class BBsentialsConfigScreemFactory {
.setSaveConsumer(newValue -> config.detailedDevMode = newValue)
.build());
}
+ if (config.hasBBRoles("splasher")){
+ ConfigCategory dev = builder.getOrCreateCategory(Text.of("§dSplashes"));
+ dev.addEntry(entryBuilder.startBooleanToggle(Text.of("Dev Mode"), config.devMode)
+ .setDefaultValue(true)
+ .setTooltip(Text.of("Auto Update Statuses"))
+ .setSaveConsumer(newValue -> config.autoSplashStatusUpdates = newValue)
+ .build());
+ }
return builder.build();
}
diff --git a/src/main/java/de/hype/bbsentials/client/Config.java b/src/main/java/de/hype/bbsentials/client/Config.java
index 2c9e471..31e794c 100644
--- a/src/main/java/de/hype/bbsentials/client/Config.java
+++ b/src/main/java/de/hype/bbsentials/client/Config.java
@@ -39,6 +39,7 @@ public class Config implements Serializable {
public boolean allowBBinviteMe = true;
public boolean doDesktopNotifications = false;
public boolean acceptReparty;
+ public boolean autoSplashStatusUpdates;
public String nickname;
public String NotifForPartyMessagesType;
diff --git a/src/main/java/de/hype/bbsentials/client/ModMenueScreen.java b/src/main/java/de/hype/bbsentials/client/ModMenueScreen.java
index 8376517..30bc74a 100644
--- a/src/main/java/de/hype/bbsentials/client/ModMenueScreen.java
+++ b/src/main/java/de/hype/bbsentials/client/ModMenueScreen.java
@@ -10,8 +10,9 @@ import net.minecraft.text.Text;
public class ModMenueScreen implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
- if (FabricLoader.getInstance().isModLoaded("cloth-config2"))
- return BBsentialsConfigScreemFactory::create;
- return parent -> new NoticeScreen(() -> MinecraftClient.getInstance().setScreen(parent), Text.of("BBsentials"), Text.of("BBsentials requires Cloth Config to be able to show the config."));
+ if (!FabricLoader.getInstance().isModLoaded("cloth-config2")) {
+ return parent -> new NoticeScreen(() -> MinecraftClient.getInstance().setScreen(parent), Text.of("BBsentials"), Text.of("BBsentials requires Cloth Config to be able to show the config."));
+ }
+ return BBsentialsConfigScreemFactory::create;
}
}
diff --git a/src/main/java/de/hype/bbsentials/client/SplashStatusUpdateListener.java b/src/main/java/de/hype/bbsentials/client/SplashStatusUpdateListener.java
new file mode 100644
index 0000000..6b5180a
--- /dev/null
+++ b/src/main/java/de/hype/bbsentials/client/SplashStatusUpdateListener.java
@@ -0,0 +1,67 @@
+package de.hype.bbsentials.client;
+
+import de.hype.bbsentials.communication.BBsentialConnection;
+import de.hype.bbsentials.packets.packets.SplashNotifyPacket;
+import de.hype.bbsentials.packets.packets.SplashUpdatePacket;
+
+import java.util.concurrent.TimeUnit;
+
+import static de.hype.bbsentials.client.BBsentials.executionService;
+import static de.hype.bbsentials.client.BBsentials.splashLobby;
+
+public class SplashStatusUpdateListener implements Runnable {
+ BBsentialConnection connection;
+ SplashNotifyPacket packet;
+ private String status = SplashUpdatePacket.STATUS_WAITING;
+ public String newStatus = SplashUpdatePacket.STATUS_WAITING;
+ public boolean splashed = false;
+ public boolean full = false;
+
+ public SplashStatusUpdateListener(BBsentialConnection connection, SplashNotifyPacket packet) {
+ this.connection = connection;
+ this.packet = packet;
+ }
+
+ @Override
+ public void run() {
+ BBsentials.splashLobby = true;
+ while (BBsentials.splashLobby) {
+ int maxPlayerCount = BBUtils.getMaximumPlayerCount() - 5;
+ while (splashLobby && !(status.equals(SplashUpdatePacket.STATUS_DONE) || status.equals(SplashUpdatePacket.STATUS_CANCELED))) {
+ if (!full&&(BBUtils.getPlayerCount() >= maxPlayerCount)) {
+ newStatus = SplashUpdatePacket.STATUS_FULL;
+ full=true;
+ }
+ if (!status.equals(newStatus)) {
+ status = newStatus;
+ connection.sendPacket(new SplashUpdatePacket(packet.splashId, status));
+ }
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ }
+ if (splashed) {
+ newStatus = SplashUpdatePacket.STATUS_DONE;
+ }
+ else {
+ newStatus = SplashUpdatePacket.STATUS_CANCELED;
+ }
+ if (!status.equals(newStatus)) {
+ status = newStatus;
+ connection.sendPacket(new SplashUpdatePacket(packet.splashId, status));
+ }
+ }
+
+ public void setStatus(String newStatus) {
+ this.newStatus = newStatus;
+ if (newStatus.equals(SplashUpdatePacket.STATUS_SPLASHING)) {
+ executionService.schedule(() -> {
+ splashed=true;
+ setStatus(SplashUpdatePacket.STATUS_DONE);
+ splashLobby = false;
+ }, 1, TimeUnit.MINUTES);
+ }
+ }
+}