aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunities.java26
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/EntityCustomNameUpdateEvent.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/SkyhanniPlayersWhenTheySeeUngiftedPlayers.kt84
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java25
9 files changed, 186 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 451fde279..9c95c0d08 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni
import at.hannibal2.skyhanni.api.CollectionAPI
+import at.hannibal2.skyhanni.api.DataWatcherAPI
import at.hannibal2.skyhanni.config.ConfigFileType
import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.config.Features
@@ -101,6 +102,7 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonMilestonesDisplay
import at.hannibal2.skyhanni.features.dungeon.DungeonRankTabListColor
import at.hannibal2.skyhanni.features.dungeon.DungeonTeammateOutlines
import at.hannibal2.skyhanni.features.dungeon.HighlightDungeonDeathmite
+import at.hannibal2.skyhanni.features.event.SkyhanniPlayersWhenTheySeeUngiftedPlayers
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder
@@ -401,6 +403,7 @@ class SkyHanniMod {
loadModule(BazaarApi())
loadModule(GardenAPI)
loadModule(GardenPlotAPI)
+ loadModule(DataWatcherAPI())
loadModule(CollectionAPI())
loadModule(FarmingContestAPI)
loadModule(FriendAPI)
@@ -432,6 +435,7 @@ class SkyHanniMod {
loadModule(DungeonCleanEnd())
loadModule(DungeonBossMessages())
loadModule(DungeonBossHideDamageSplash())
+ loadModule(SkyhanniPlayersWhenTheySeeUngiftedPlayers)
loadModule(TrophyFishManager)
loadModule(TrophyFishFillet())
loadModule(TrophyFishMessages())
diff --git a/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt
new file mode 100644
index 000000000..1493e7a8c
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/api/DataWatcherAPI.kt
@@ -0,0 +1,19 @@
+package at.hannibal2.skyhanni.api
+
+import at.hannibal2.skyhanni.events.DataWatcherUpdatedEvent
+import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class DataWatcherAPI {
+
+ val DATA_VALUE_CUSTOM_NAME = 2
+
+ @SubscribeEvent
+ fun onDataWatcherUpdate(event: DataWatcherUpdatedEvent) {
+ for (updatedEntry in event.updatedEntries) {
+ if (updatedEntry.dataValueId == DATA_VALUE_CUSTOM_NAME) {
+ EntityCustomNameUpdateEvent(event.entity.customNameTag, event.entity).postAndCatch()
+ }
+ }
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 91570137e..1e063cbd2 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -27,8 +27,10 @@ import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
public class Storage {
@@ -77,6 +79,10 @@ public class Storage {
@Expose
public List<String> guildMembers = new ArrayList<>();
+
+ @Expose
+ public Set<String> playersThatHaveBeenGifted = new HashSet<>();
+
}
public static class ProfileSpecific {
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunities.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunities.java
new file mode 100644
index 000000000..751017942
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunities.java
@@ -0,0 +1,26 @@
+package at.hannibal2.skyhanni.config.features.event.winter;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+
+public class GiftingOpportunities {
+ @Expose
+ @ConfigOption(name = "Highlight unique gift opportunities", desc = "Highlight players who you haven't given gifts to yet")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean highlightSpecialNeedsPlayers = true;
+
+ @Expose
+ @ConfigOption(name = "Display only while holding a gift", desc = "Only highlight ungifted players while holding a gift.")
+ @ConfigEditorBoolean
+ public boolean highlighWithGiftOnly = true;
+
+
+ @Expose
+ @ConfigOption(name = "Use armor stands", desc = "Make use of armor stands to stop highlighting players. A bit inaccurate, but can help with people you gifted before this feature was used.")
+ @ConfigEditorBoolean
+ public boolean useArmorStandDetection = false;
+
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java
index 8af9472b1..2548558dc 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java
@@ -20,6 +20,11 @@ public class WinterConfig {
@FeatureToggle
public boolean islandCloseTime = true;
+ @Accordion
+ @Expose
+ @ConfigOption(name = "Unique Gifting Opportunities", desc = "Highlight players who you haven't given gifts to yet")
+ public GiftingOpportunities giftingOpportunities = new GiftingOpportunities();
+
@Expose
public Position islandCloseTimePosition = new Position(10, 10, false, true);
diff --git a/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt
new file mode 100644
index 000000000..05389c2d7
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/DataWatcherUpdatedEvent.kt
@@ -0,0 +1,9 @@
+package at.hannibal2.skyhanni.events
+
+import net.minecraft.entity.DataWatcher
+import net.minecraft.entity.Entity
+
+data class DataWatcherUpdatedEvent(
+ val entity: Entity,
+ val updatedEntries: List<DataWatcher.WatchableObject>,
+) : LorenzEvent()
diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityCustomNameUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityCustomNameUpdateEvent.kt
new file mode 100644
index 000000000..4b4b075e3
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/EntityCustomNameUpdateEvent.kt
@@ -0,0 +1,8 @@
+package at.hannibal2.skyhanni.events
+
+import net.minecraft.entity.Entity
+
+data class EntityCustomNameUpdateEvent(
+ val newName: String?,
+ val entity: Entity,
+) : LorenzEvent()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/SkyhanniPlayersWhenTheySeeUngiftedPlayers.kt b/src/main/java/at/hannibal2/skyhanni/features/event/SkyhanniPlayersWhenTheySeeUngiftedPlayers.kt
new file mode 100644
index 000000000..e720e3e30
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/SkyhanniPlayersWhenTheySeeUngiftedPlayers.kt
@@ -0,0 +1,84 @@
+package at.hannibal2.skyhanni.features.event
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.RenderMobColoredEvent
+import at.hannibal2.skyhanni.events.withAlpha
+import at.hannibal2.skyhanni.utils.EntityUtils.isNPC
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.LorenzColor
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.getLorenzVec
+import net.minecraft.client.Minecraft
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.entity.player.EntityPlayer
+import net.minecraftforge.event.entity.EntityJoinWorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object SkyhanniPlayersWhenTheySeeUngiftedPlayers {
+ val playerList: MutableSet<String>?
+ get() = ProfileStorageData.playerSpecific?.playersThatHaveBeenGifted
+
+ val pattern = "§6\\+1 Unique Gift given! To ([^§]+)§r§6!".toPattern()
+ fun hasGiftedPlayer(player: EntityPlayer): Boolean =
+ playerList?.contains(player.name) == true
+
+ fun addGiftedPlayer(playerName: String): Unit {
+ playerList?.add(playerName)
+ }
+
+ val config get() = SkyHanniMod.feature.event.winter.giftingOpportunities
+
+ fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyBlock && config.highlightSpecialNeedsPlayers &&
+ (Minecraft.getMinecraft().thePlayer?.heldItem?.getInternalName()?.endsWith("_GIFT") == true
+ || (!config.highlighWithGiftOnly))
+ }
+
+ val hasNotGiftedNametag = "§a§lꤥ"
+ val hasGiftedNametag = "§c§lꤥ"
+
+ fun analyzeArmorStand(entity: EntityArmorStand) {
+ if (!config.useArmorStandDetection) return
+ val world = Minecraft.getMinecraft().theWorld ?: return
+ if (entity.name != hasGiftedNametag) return
+ val matchedPlayer =
+ world.playerEntities.singleOrNull {
+ !it.isNPC() && it.getLorenzVec().distance(entity.getLorenzVec()) < 2
+ } ?: return
+ addGiftedPlayer(matchedPlayer.name)
+
+ }
+
+ @SubscribeEvent
+ fun onEntityChangeName(event: EntityCustomNameUpdateEvent) {
+ val entity = event.entity as? EntityArmorStand ?: return
+ analyzeArmorStand(entity)
+ }
+
+ @SubscribeEvent
+ fun onEntityJoinWorldEvent(event: EntityJoinWorldEvent) {
+ val entity = event.entity as? EntityArmorStand ?: return
+ analyzeArmorStand(entity)
+ }
+
+ @SubscribeEvent
+ fun onRenderMobColored(event: RenderMobColoredEvent) {
+ if (!isEnabled()) return
+ val entity = event.entity
+ if (entity is EntityPlayer && !entity.isNPC() && !hasGiftedPlayer(entity))
+ event.color = LorenzColor.DARK_GREEN.toColor().withAlpha(127)
+ }
+
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ pattern.matchMatcher(event.message) {
+ addGiftedPlayer(group(1))
+ }
+ }
+
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java
new file mode 100644
index 000000000..bcc30f42d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java
@@ -0,0 +1,25 @@
+package at.hannibal2.skyhanni.mixins.transformers;
+
+import at.hannibal2.skyhanni.events.DataWatcherUpdatedEvent;
+import net.minecraft.entity.DataWatcher;
+import net.minecraft.entity.Entity;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import java.util.List;
+
+@Mixin(DataWatcher.class)
+public class UpdateDataWatcherEventPatch {
+ @Shadow
+ @Final
+ private Entity owner;
+
+ @Inject(method = "updateWatchedObjectsFromList", at = @At("TAIL"))
+ public void onWhatever(List<DataWatcher.WatchableObject> list, CallbackInfo ci) {
+ new DataWatcherUpdatedEvent(owner, list).postAndCatch();
+ }
+}