Skip to content

Commit a409e9a

Browse files
committed
refactor: small changes, wiki links & resource pack links
1 parent 43d32c7 commit a409e9a

File tree

9 files changed

+76
-25
lines changed

9 files changed

+76
-25
lines changed

NotEnoughUpdates-REPO

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
func main() {
1515
app := fiber.New(fiber.Config{
16-
Prefork: false, // Fork processes for max CPU utilization
16+
Prefork: true, // Fork processes for max CPU utilization
1717
ServerHeader: "", // Remove server header for slight perf gain
1818
DisableKeepalive: false, // Keep connections alive
1919
DisableDefaultDate: true, // Disable date header

src/NotEnoughUpdates/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ func GetItem(name string) (models.NEUItem, error) {
1717
}
1818

1919
itemsPath := "NotEnoughUpdates-REPO/items"
20+
/*
2021
if _, err := os.Stat(itemsPath); os.IsNotExist(err) {
2122
return models.NEUItem{}, fmt.Errorf("items directory does not exist: %w", err)
2223
}
24+
*/
2325

2426
itemPath := fmt.Sprintf("%s/%s.json", itemsPath, name)
2527
data, err := os.ReadFile(itemPath)

src/constants/accessories.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func GetAllAccessories() []Accessory {
271271
Name: item.Name,
272272
}
273273
output = append(output, specialAccessoryItem)
274-
fmt.Printf("[ACCESSORIES] Added special accessory %s with rarity %s\n", specialAccessoryItem.SkyBlockID, specialAccessoryItem.Rarity)
274+
// fmt.Printf("[ACCESSORIES] Added special accessory %s with rarity %s\n", specialAccessoryItem.SkyBlockID, specialAccessoryItem.Rarity)
275275
}
276276
}
277277
}

src/models/items.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ type DecodedInventory struct {
9696
type ProcessedItem struct {
9797
Item
9898
Texture string `json:"texture_path,omitempty"`
99+
TexturePack string `json:"texture_pack,omitempty"`
99100
DisplayName string `json:"display_name,omitempty"`
100101
Lore []string `json:"lore,omitempty"`
101102
Rarity string `json:"rarity,omitempty"`
@@ -106,6 +107,12 @@ type ProcessedItem struct {
106107
Id string `json:"id,omitempty"`
107108
IsInactive *bool `json:"isInactive,omitempty"`
108109
Shiny bool `json:"shiny,omitempty"`
110+
Wiki *WikipediaLinks `json:"wiki,omitempty"`
111+
}
112+
113+
type WikipediaLinks struct {
114+
Official string `json:"official,omitempty"`
115+
Fandom string `json:"fandom,omitempty"`
109116
}
110117

111118
type SkillToolsResult struct {
@@ -126,14 +133,16 @@ type EquipmentResult struct {
126133
}
127134

128135
type StrippedItem struct {
129-
DisplayName string `json:"display_name,omitempty"`
130-
Lore []string `json:"lore,omitempty"`
131-
Rarity string `json:"rarity,omitempty"`
132-
Recombobulated bool `json:"recombobulated,omitempty"`
133-
ContainsItems []StrippedItem `json:"containsItems,omitempty"`
134-
Source string `json:"source,omitempty"`
135-
Texture string `json:"texture_path,omitempty"`
136-
IsInactive *bool `json:"isInactive,omitempty"`
137-
Count *int `json:"Count,omitempty"`
138-
Shiny bool `json:"shiny,omitempty"`
136+
DisplayName string `json:"display_name,omitempty"`
137+
Lore []string `json:"lore,omitempty"`
138+
Rarity string `json:"rarity,omitempty"`
139+
Recombobulated bool `json:"recombobulated,omitempty"`
140+
ContainsItems []StrippedItem `json:"containsItems,omitempty"`
141+
Source string `json:"source,omitempty"`
142+
Texture string `json:"texture_path,omitempty"`
143+
IsInactive *bool `json:"isInactive,omitempty"`
144+
Count *int `json:"Count,omitempty"`
145+
Shiny bool `json:"shiny,omitempty"`
146+
Wiki *WikipediaLinks `json:"wiki,omitempty"`
147+
TexturePack string `json:"texture_pack,omitempty"`
139148
}

src/routes.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ import (
88
"skycrypt/src/api"
99
redis "skycrypt/src/db"
1010
"skycrypt/src/routes"
11-
"time"
1211

1312
"github.com/gofiber/fiber/v2"
14-
"github.com/gofiber/fiber/v2/middleware/cache"
1513
"github.com/gofiber/fiber/v2/middleware/compress"
16-
"github.com/gofiber/fiber/v2/middleware/etag"
1714
"github.com/joho/godotenv"
1815
)
1916

@@ -78,11 +75,14 @@ func SetupRoutes(app *fiber.App) {
7875

7976
if os.Getenv("DEV") != "true" {
8077
fmt.Println("[ENVIROMENT] Running in production mode")
81-
app.Use(etag.New())
82-
app.Use("/api", cache.New(cache.Config{
83-
Expiration: 5 * time.Minute,
84-
CacheControl: true,
85-
}))
78+
79+
/*
80+
app.Use(etag.New())
81+
app.Use("/api", cache.New(cache.Config{
82+
Expiration: 5 * time.Minute,
83+
CacheControl: true,
84+
})
85+
*/
8686
}
8787

8888
api := app.Group("/api")

src/routes/networth.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package routes
22

33
import (
4+
"fmt"
5+
"skycrypt/src/api"
6+
"skycrypt/src/stats"
7+
"time"
8+
9+
skyhelpernetworthgo "github.com/DuckySoLucky/SkyHelper-Networth-Go"
410
"github.com/gofiber/fiber/v2"
511
)
612

713
func NetworthHandler(c *fiber.Ctx) error {
8-
/*timeNow := time.Now()
14+
timeNow := time.Now()
915

1016
uuid := c.Params("uuid")
1117
profileId := c.Params("profileId")
@@ -67,8 +73,6 @@ func NetworthHandler(c *fiber.Ctx) error {
6773
"normal": networth,
6874
"nonCosmetic": nonCosmeticNetworth,
6975
},
70-
})*/
71-
return c.JSON(fiber.Map{
72-
"networth": nil,
7376
})
77+
7478
}

src/stats/items/processing.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package stats
22

33
import (
44
"fmt"
5+
notenoughupdates "skycrypt/src/NotEnoughUpdates"
56
"skycrypt/src/constants"
67
"skycrypt/src/lib"
78
"skycrypt/src/models"
89
"skycrypt/src/utility"
910
"slices"
11+
"strings"
1012
)
1113

1214
func ProcessItems(items *[]models.Item, source string) []models.ProcessedItem {
@@ -129,6 +131,10 @@ func ProcessItem(item *models.Item, source string) models.ProcessedItem {
129131
}
130132

131133
processedItem.Texture = lib.ApplyTexture(TextureItem)
134+
if strings.HasPrefix(processedItem.Texture, "http://localhost:8080/assets/resourcepacks/FurfSky/") {
135+
processedItem.TexturePack = "FURFSKY_REBORN"
136+
}
137+
132138
if processedItem.Texture == "" {
133139
fmt.Printf("[CUSTOM_RESOURCES] Found no textures for item: %s\n", item.Tag.ExtraAttributes.ID)
134140
}
@@ -138,6 +144,28 @@ func ProcessItem(item *models.Item, source string) models.ProcessedItem {
138144
processedItem.ContainsItems = ProcessItems(&item.ContainsItems, source)
139145
}
140146

147+
if item.Tag.ExtraAttributes.ID != "" {
148+
NEUItem, err := notenoughupdates.GetItem(item.Tag.ExtraAttributes.ID)
149+
if err == nil && len(NEUItem.Wiki) > 0 {
150+
processedItem.Wiki = &models.WikipediaLinks{}
151+
if len(NEUItem.Wiki) == 1 {
152+
if strings.HasPrefix(NEUItem.Wiki[0], "https://wiki.hypixel.net/") {
153+
processedItem.Wiki.Official = NEUItem.Wiki[0]
154+
} else {
155+
processedItem.Wiki.Fandom = NEUItem.Wiki[0]
156+
}
157+
} else {
158+
if strings.HasPrefix(NEUItem.Wiki[0], "https://wiki.hypixel.net/") {
159+
processedItem.Wiki.Official = NEUItem.Wiki[0]
160+
processedItem.Wiki.Fandom = NEUItem.Wiki[1]
161+
} else {
162+
processedItem.Wiki.Fandom = NEUItem.Wiki[0]
163+
processedItem.Wiki.Official = NEUItem.Wiki[1]
164+
}
165+
}
166+
}
167+
}
168+
141169
// TODO: add cake bag & legacy backpack support
142170

143171
return processedItem

src/stats/items/stripping.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ func StripItem(item *models.ProcessedItem, search ...bool) *models.StrippedItem
4444
output.Count = item.Count
4545
}
4646

47+
if item.Wiki != nil {
48+
output.Wiki = item.Wiki
49+
}
50+
51+
if item.TexturePack != "" {
52+
output.TexturePack = item.TexturePack
53+
}
54+
4755
return output
4856
}
4957

0 commit comments

Comments
 (0)