aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorCow <cow@volloeko.de>2020-08-07 00:30:32 +0200
committerCow <cow@volloeko.de>2020-08-07 00:30:32 +0200
commitb064b892f4e4543db8e42b36f48c9b29bc0f5d8e (patch)
tree25f216990aad3d2369c741fff601beabe6edf906 /src/main/java
parentba4dc3a0cbb58152c1fbdfe58224cb65685acc55 (diff)
downloadCowlection-b064b892f4e4543db8e42b36f48c9b29bc0f5d8e.tar.gz
Cowlection-b064b892f4e4543db8e42b36f48c9b29bc0f5d8e.tar.bz2
Cowlection-b064b892f4e4543db8e42b36f48c9b29bc0f5d8e.zip
Dungeon party finder: Added warning message if entering a floor other than the queued one
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java10
-rw-r--r--src/main/java/de/cowtipper/cowlection/listener/skyblock/DungeonsListener.java91
2 files changed, 101 insertions, 0 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java b/src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java
index b687ef2..c1bc33a 100644
--- a/src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java
+++ b/src/main/java/de/cowtipper/cowlection/handler/DungeonCache.java
@@ -22,6 +22,7 @@ public class DungeonCache {
private int elapsedMinutes;
private int classMilestone;
private long lastScoreboardCheck;
+ private String queuedFloor;
public DungeonCache(Cowlection main) {
this.main = main;
@@ -108,6 +109,10 @@ public class DungeonCache {
}
// setter/adder
+ public void setQueuedFloor(String floorNr) {
+ this.queuedFloor = floorNr;
+ }
+
public void addDeath(String playerName) {
int previousPlayerDeaths = deathCounter.getOrDefault(playerName, 0);
deathCounter.put(playerName, previousPlayerDeaths + 1);
@@ -128,6 +133,10 @@ public class DungeonCache {
}
// getter
+ public String getQueuedFloor() {
+ return queuedFloor;
+ }
+
public int getMaxSkillScore() {
return 100 - getSkillScorePenalty();
}
@@ -167,5 +176,6 @@ public class DungeonCache {
destroyedCrypts.clear();
elapsedMinutes = 0;
classMilestone = 0;
+ queuedFloor = null;
}
}
diff --git a/src/main/java/de/cowtipper/cowlection/listener/skyblock/DungeonsListener.java b/src/main/java/de/cowtipper/cowlection/listener/skyblock/DungeonsListener.java
index 0c81a5c..b6bb2d0 100644
--- a/src/main/java/de/cowtipper/cowlection/listener/skyblock/DungeonsListener.java
+++ b/src/main/java/de/cowtipper/cowlection/listener/skyblock/DungeonsListener.java
@@ -6,6 +6,7 @@ import de.cowtipper.cowlection.config.MooConfig;
import de.cowtipper.cowlection.handler.DungeonCache;
import de.cowtipper.cowlection.util.TickDelay;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.SoundCategory;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.renderer.GlStateManager;
@@ -33,6 +34,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side;
import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Keyboard;
+import org.lwjgl.input.Mouse;
import java.awt.*;
import java.util.List;
@@ -48,6 +50,10 @@ public class DungeonsListener {
*/
private final Pattern DUNGEON_PARTY_FINDER_PLAYER = Pattern.compile("^ (?:\\w+): ([A-Za-z]+) \\((\\d+)\\)$");
/**
+ * example: (Adventuring|Playing|Plundering|Looting|...) The Catacombs with 5/5 players on Floor II!
+ */
+ private final Pattern DUNGEON_ENTERED_DUNGEON = Pattern.compile("^[A-Za-z ]+ The Catacombs( Entrance)? with [0-9]+/[0-9]+ players(?: on Floor ([IVX]+))?!$");
+ /**
* Example tooltip lines:
* <ul>
* <li>§7Crit Damage: §c+23% §8(Heavy -3%) §8(+28.75%)</li>
@@ -395,6 +401,24 @@ public class DungeonsListener {
if (text.startsWith("[NPC] Mort: ")) {
// Mort said something, probably entered dungeons
main.getDungeonCache().onDungeonEnterOrLeave(true);
+ return;
+ }
+ Matcher dungeonEnteredMatcher = DUNGEON_ENTERED_DUNGEON.matcher(text);
+ if (dungeonEnteredMatcher.matches()) {
+ String floor = dungeonEnteredMatcher.group(1) != null ? "Entrance" : dungeonEnteredMatcher.group(2);
+ if (floor == null) {
+ // this shouldn't ever happen: neither a floor nor the entrance was entered
+ return;
+ }
+ String queuedFloor = main.getDungeonCache().getQueuedFloor();
+ if (queuedFloor != null && !queuedFloor.equals(floor)) {
+ // queued and entered dungeon floors are different!
+ new TickDelay(() -> {
+ String attentionSeeker = "" + EnumChatFormatting.LIGHT_PURPLE + EnumChatFormatting.OBFUSCATED + "#";
+ main.getChatHelper().sendMessage(EnumChatFormatting.RED, attentionSeeker + EnumChatFormatting.RED + " You entered dungeon floor " + EnumChatFormatting.DARK_RED + floor + EnumChatFormatting.RED + " but originally queued for floor " + EnumChatFormatting.DARK_RED + queuedFloor + " " + attentionSeeker);
+ Minecraft.getMinecraft().thePlayer.playSound("mob.cow.hurt", Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.MASTER), 1);
+ }, 100);
+ }
}
return;
}
@@ -431,6 +455,73 @@ public class DungeonsListener {
}
@SubscribeEvent
+ public void onMouseInteractionInGui(GuiScreenEvent.MouseInputEvent.Pre e) {
+ if (Mouse.getEventButton() < 0) {
+ // no button press, just mouse-hover
+ return;
+ }
+ if (e.gui instanceof GuiChest) {
+ GuiChest guiChest = (GuiChest) e.gui;
+
+ IInventory inventory = guiChest.inventorySlots.getSlot(0).inventory;
+ if (inventory.getName().equals("Party Finder")) {
+ // get dungeon floor nr when joining a dungeon party via party finder
+ Slot hoveredSlot = guiChest.getSlotUnderMouse();
+ if (hoveredSlot != null && hoveredSlot.getHasStack()) {
+ // clicked on an item
+ List<String> itemToolTip = hoveredSlot.getStack().getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ if (itemToolTip.size() < 5) {
+ // not a valid dungeon party tooltip
+ return;
+ }
+ for (String toolTipLine : itemToolTip) {
+ String line = EnumChatFormatting.getTextWithoutFormattingCodes(toolTipLine);
+ if (line.startsWith("Floor: ")) {
+ // extract floor number
+ int lastSpace = line.lastIndexOf(' ');
+ if (lastSpace > 5) {
+ String floorNr = line.substring(lastSpace + 1);
+ main.getDungeonCache().setQueuedFloor(floorNr);
+ }
+ break;
+ }
+ }
+ }
+ } else if (inventory.getName().equals("Group Builder")) {
+ // get dungeon floor nr when creating a dungeon party for party finder
+ Slot hoveredSlot = guiChest.getSlotUnderMouse();
+ if (hoveredSlot != null && hoveredSlot.getHasStack() && hoveredSlot.getStack().hasDisplayName()) {
+ // clicked on an item
+ String clickedItemName = EnumChatFormatting.getTextWithoutFormattingCodes(hoveredSlot.getStack().getDisplayName());
+ if (clickedItemName.equals("Confirm Group")) {
+ // created dungeon party group
+ ItemStack selectedFloorItem = inventory.getStackInSlot(13);
+ if (selectedFloorItem != null && selectedFloorItem.hasDisplayName() && EnumChatFormatting.getTextWithoutFormattingCodes(selectedFloorItem.getDisplayName()).equals("Select Floor")) {
+ List<String> itemToolTip = selectedFloorItem.getTooltip(Minecraft.getMinecraft().thePlayer, false);
+ if (itemToolTip.size() < 5) {
+ // not a valid dungeon floor tooltip
+ return;
+ }
+ for (String toolTipLine : itemToolTip) {
+ String line = EnumChatFormatting.getTextWithoutFormattingCodes(toolTipLine);
+ if (line.startsWith("Currently Selected: ")) {
+ // extract floor number
+ int lastSpace = line.lastIndexOf(' ');
+ if (lastSpace > 18) {
+ String floorNr = line.substring(lastSpace + 1);
+ main.getDungeonCache().setQueuedFloor(floorNr);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent e) {
if (e.phase != TickEvent.Phase.END && e.side != Side.CLIENT && e.type != TickEvent.Type.PLAYER) {
return;