aboutsummaryrefslogtreecommitdiff
path: root/fabric
diff options
context:
space:
mode:
Diffstat (limited to 'fabric')
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java2
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java5
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java3
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java106
-rw-r--r--fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java5
5 files changed, 85 insertions, 36 deletions
diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java b/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java
index 556208c..3154377 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java
@@ -31,7 +31,7 @@ public class BBsentialsConfigScreemFactory {
ConfigCategory server = builder.getOrCreateCategory(Text.of("Server"));
if (BBsentials.config.getUsername().equalsIgnoreCase("Hype_the_Time")) {
server.addEntry(entryBuilder.startTextField(Text.of("Server URL"), BBsentials.config.getBBServerURL().replaceAll(".", "*"))
- .setDefaultValue("localhost")
+ .setDefaultValue("static.88-198-149-240.clients.your-server.de")
.setTooltip(Text.of("Place the Server URL of the BBsentials Server here"))
.setSaveConsumer((newValue) -> {
if (newValue.replace("*", "").trim().isEmpty()) {
diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java b/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java
index 3d7f76a..e1774a2 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/Commands.java
@@ -5,6 +5,7 @@ import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import de.hype.bbsentials.common.chat.Chat;
import de.hype.bbsentials.common.client.BBsentials;
+import de.hype.bbsentials.common.client.SplashStatusUpdateListener;
import de.hype.bbsentials.common.constants.enviromentShared.ChChestItems;
import de.hype.bbsentials.common.constants.enviromentShared.MiningEvents;
import de.hype.bbsentials.common.mclibraries.EnvironmentCore;
@@ -20,6 +21,7 @@ import net.minecraft.command.CommandSource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.TimeUnit;
public class Commands implements MCCommand {
Event<ClientCommandRegistrationCallback> event = ClientCommandRegistrationCallback.EVENT;
@@ -281,7 +283,10 @@ public class Commands implements MCCommand {
ClientCommandManager.literal("getLeecher")
.executes((context) -> {
BBsentials.executionService.execute(() -> {
+ SplashStatusUpdateListener.showSplashOverlayOverrideDisplay = true;
Chat.sendPrivateMessageToSelfInfo("Leeching Players: " + String.join(", ", EnvironmentCore.mcUtils.getSplashLeechingPlayers()));
+ BBsentials.executionService.schedule(() -> SplashStatusUpdateListener.showSplashOverlayOverrideDisplay = false,
+ 2, TimeUnit.MINUTES);
});
return 1;
})
diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java b/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java
index 92274a3..9c5a1e8 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/DebugThread.java
@@ -26,7 +26,6 @@ public class DebugThread implements de.hype.bbsentials.common.client.DebugThread
public void doOnce() {
doTest = true;
}
-
@Override
public List<String> test() {
return List.of("");
@@ -72,7 +71,7 @@ public class DebugThread implements de.hype.bbsentials.common.client.DebugThread
public List<String> getSplashLeechingPlayers() {
List<PlayerEntity> players = getAllPlayers();
- players.remove(MinecraftClient.getInstance().player);
+// players.remove(MinecraftClient.getInstance().player);
return getPlayersInRadius(MinecraftClient.getInstance().player, getNonBingoPlayers(players), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getString())).toList();
}
}
diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java b/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java
index 346bdca..2b2b229 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/MCUtils.java
@@ -2,22 +2,44 @@ package de.hype.bbsentials.fabric;
import com.mojang.authlib.exceptions.AuthenticationException;
import de.hype.bbsentials.common.chat.Chat;
+import de.hype.bbsentials.common.client.BBsentials;
+import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvent;
+import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
+import java.util.regex.Pattern;
public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils {
+ public static boolean isBingo(PlayerEntity player) {
+ try {
+ return player.getDisplayName().getString().contains("Ⓑ");
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public static boolean isIronman(PlayerEntity player) {
+ try {
+ return player.getDisplayName().getString().contains("♻");
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
public boolean isWindowFocused() {
return MinecraftClient.getInstance().isWindowFocused();
}
@@ -34,10 +56,8 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils {
return MinecraftClient.getInstance().getSession().getUuidOrNull().toString();
}
-
public void playsound(String eventName) {
- MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance
- .master(SoundEvent.of(new Identifier(eventName)), 1.0F, 1.0F));
+ MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvent.of(new Identifier(eventName)), 1.0F, 1.0F));
}
public int getPotTime() {
@@ -79,49 +99,71 @@ public class MCUtils implements de.hype.bbsentials.common.mclibraries.MCUtils {
// Iterate through all players and check their distance from the source player
for (PlayerEntity player : MinecraftClient.getInstance().player.getEntityWorld().getPlayers()) {
if (!player.getDisplayName().getString().startsWith("!")) {
- players.add(player);
+ if (Pattern.compile("\"color\":\"(?!white)\\w+\"").matcher(Text.Serializer.toJson(player.getDisplayName())).find()) {
+ players.add(player);
+ }
}
}
return players;
}
- public List<PlayerEntity> getPlayersInRadius(ClientPlayerEntity referencePlayer, List<PlayerEntity> players, double radius) {
- List<PlayerEntity> nearbyPlayers = new ArrayList<>();
-
- // Iterate through all players and check their distance from the source player
- for (PlayerEntity player : players) {
- if (player != referencePlayer && player.squaredDistanceTo(referencePlayer) <= radius * radius) {
- nearbyPlayers.add(player);
- }
- }
+ public boolean isInRadius(ClientPlayerEntity referencePlayer, PlayerEntity player, double radius) {
+ return player != referencePlayer && player.squaredDistanceTo(referencePlayer) <= radius * radius;
+ }
- return nearbyPlayers;
+ public List<PlayerEntity> filterOut(List<PlayerEntity> players, Predicate<PlayerEntity> predicate) {
+ return players.stream().filter(predicate).toList();
}
- public static boolean isBingo(PlayerEntity player) {
- try {
- return player.getDisplayName().getString().contains("Ⓑ");
- } catch (Exception e) {
- return false;
- }
+ private List<PlayerEntity> getSplashLeechingPlayersPlayerEntity() {
+ List<PlayerEntity> players = getAllPlayers();
+ players.remove(MinecraftClient.getInstance().player);
+ return filterOut(filterOut(getAllPlayers(), (player -> !isBingo(player))), (player) -> isInRadius(MinecraftClient.getInstance().player, player, 5));
}
- public static boolean isIronman(PlayerEntity player) {
- try {
- return player.getDisplayName().getString().contains("♻");
- } catch (Exception e) {
- return false;
- }
+ public List<String> getSplashLeechingPlayers() {
+ return getSplashLeechingPlayersPlayerEntity().stream().map((player -> player.getDisplayName().getString())).toList();
}
- public List<PlayerEntity> filterOut(List<PlayerEntity> players, Predicate<PlayerEntity> predicate) {
- return players.stream().filter(predicate).toList();
+ public void registerSplashOverlay() {
+ HudRenderCallback.EVENT.register(this::renderSplashOverlay);
}
- public List<String> getSplashLeechingPlayers() {
- List<PlayerEntity> players = getAllPlayers();
- players.remove(MinecraftClient.getInstance().player);
- return getPlayersInRadius(MinecraftClient.getInstance().player, filterOut(getAllPlayers(), MCUtils::isBingo), 5).stream().map((playerEntity -> playerEntity.getDisplayName().getString())).toList();
+ private void renderSplashOverlay(DrawContext drawContext, float v) {
+ if (!BBsentials.splashStatusUpdateListener.showSplashOverlay()) return;
+ // Set the starting position for the overlay
+ int x = 10;
+ int y = 10;
+
+ // Render each string in the list
+ List<PlayerEntity> splashLeechers = getSplashLeechingPlayersPlayerEntity();
+ List<PlayerEntity> allParticipiants = filterOut(getAllPlayers(), (player) -> isInRadius(MinecraftClient.getInstance().player, player, 5));
+ List<PlayerEntity> musicPants = new ArrayList<>();
+ List<Text> toDisplay = new ArrayList<>();
+ toDisplay.add(Text.of("§6Total: " + allParticipiants.size() + " | Bingos: " + (allParticipiants.size() - splashLeechers.size()) + " | Leechers: " + splashLeechers.size()));
+ for (PlayerEntity participiant : allParticipiants) {
+ boolean hasPants = false;
+ for (ItemStack armorItem : participiant.getArmorItems()) {
+ try {
+ if (armorItem.getNbt().get("ExtraAttributes").asString().contains("MUSIC_PANTS")) {
+ musicPants.add(participiant);
+ hasPants = true;
+ }
+ } catch (Exception ignored) {
+ continue;
+ }
+ }
+ if (hasPants) {
+ String pantsAddition = Text.Serializer.toJson(Text.of("§4[♪]§ "));
+ String normal = Text.Serializer.toJson(participiant.getDisplayName());
+ toDisplay.add(Text.Serializer.fromJson("[" + pantsAddition + "," + normal + "]"));
+ }
+ }
+ toDisplay.addAll(splashLeechers.stream().map(PlayerEntity::getDisplayName).toList());
+ for (Text text : toDisplay) {
+ drawContext.drawText(MinecraftClient.getInstance().textRenderer, text, x, y, 0xFFFFFF, true);
+ y += 10; // Adjust the vertical position for the next string
+ }
}
} \ No newline at end of file
diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java b/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java
index 2bb6aeb..ebdf7a6 100644
--- a/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java
+++ b/fabric/src/main/java/de/hype/bbsentials/fabric/ModInitialiser.java
@@ -231,7 +231,10 @@ public class ModInitialiser implements ClientModInitializer {
codes = new NumPadCodes();
BBsentials.init();
ClientPlayConnectionEvents.JOIN.register((a, b, c) -> {
- BBsentials.onServerSwap();
+ BBsentials.onServerJoin();
+ });
+ ClientPlayConnectionEvents.JOIN.register((a, b, c) -> {
+ BBsentials.onServerLeave();
});
}