Skip to content

Commit 6727dcb

Browse files
committed
added fix with pricing in itemName, and advertisement for ltmods server
1 parent c9bda7f commit 6727dcb

5 files changed

Lines changed: 26 additions & 8 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ yarn_mappings=1.21.4+build.8
88
loader_version=0.16.10
99

1010
# Mod Properties
11-
mod_version=1.5.3-Alpha+1.21.4
11+
mod_version=1.5.4-Alpha+1.21.4
1212
maven_group=pl.lordtricker
1313
archives_base_name=ltrynek
1414

src/client/java/pl/lordtricker/ltrynek/client/config/ConfigLoader.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public static ServersConfig loadConfig() {
4040
if (config == null) {
4141
config = createDefaultConfig();
4242
}
43+
// Ensure default for new fields
44+
if (config.adsEnabled == null) {
45+
config.adsEnabled = true;
46+
// Persist the new default into the main config file
47+
saveAllConfigs(config);
48+
}
4349
} catch (IOException e) {
4450
e.printStackTrace();
4551
config = createDefaultConfig();
@@ -114,6 +120,7 @@ public static void saveAllConfigs(ServersConfig config) {
114120
ServersConfig mainConfig = new ServersConfig();
115121
mainConfig.defaultProfile = config.defaultProfile;
116122
mainConfig.soundsEnabled = config.soundsEnabled;
123+
mainConfig.adsEnabled = (config.adsEnabled == null) ? Boolean.TRUE : config.adsEnabled;
117124
mainConfig.servers = mainServers;
118125

119126
Path mainConfigFile = MOD_CONFIG_DIR.resolve(MAIN_CONFIG_FILE_NAME);
@@ -140,6 +147,7 @@ public static void saveAllConfigs(ServersConfig config) {
140147
private static ServersConfig createDefaultConfig() {
141148
ServersConfig cfg = new ServersConfig();
142149
cfg.defaultProfile = "default";
150+
cfg.adsEnabled = true;
143151

144152
ServerEntry server1 = new ServerEntry();
145153
server1.domains = List.of("minestar.pl");

src/client/java/pl/lordtricker/ltrynek/client/config/ServersConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ public class ServersConfig {
77
public String defaultProfile = "default";
88
public List<ServerEntry> servers = new ArrayList<>();
99
public boolean soundsEnabled = false;
10-
}
10+
// Toggle for advertising server injection (default enabled via loader)
11+
public Boolean adsEnabled;
12+
}

src/client/java/pl/lordtricker/ltrynek/client/mixin/HandledScreenMixin.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,15 @@ private boolean processSlot(DrawContext context, Slot slot) {
8080
ItemStack stack = slot.getStack();
8181
if (stack.isEmpty()) return false;
8282

83+
String displayName = stack.getName().getString();
84+
String noColorName = ColorStripUtils.stripAllColorsAndFormats(displayName);
85+
8386
List<Text> tooltip = stack.getTooltip(Item.TooltipContext.DEFAULT, null, TooltipType.BASIC);
8487
List<String> loreLines = new ArrayList<>();
85-
for (Text textLine : tooltip) {
88+
for (int i = 0; i < tooltip.size(); i++) {
89+
// Skip the first line which is the item name; we only want lore
90+
if (i == 0) continue;
91+
Text textLine = tooltip.get(i);
8692
String plain = textLine.getString();
8793
String noColor = ColorStripUtils.stripAllColorsAndFormats(plain);
8894
loreLines.add(noColor);
@@ -158,8 +164,6 @@ private boolean processSlot(DrawContext context, Slot slot) {
158164

159165
Identifier id = Registries.ITEM.getId(stack.getItem());
160166
String materialId = id.toString();
161-
String displayName = stack.getName().getString();
162-
String noColorName = ColorStripUtils.stripAllColorsAndFormats(displayName);
163167

164168
int stackSize = stack.getCount();
165169
boolean isStack = stackSize > 1;

src/client/resources/ltrynek.client.mixins.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
"compatibilityLevel": "JAVA_21",
55
"mixins": [
66
"HandledScreenMixin",
7-
"ScreenHandlerAccessor"
7+
"ScreenHandlerAccessor",
8+
"ServerListMixin",
9+
"ServerListAccessor"
810
],
911
"client": [
1012
"HandledScreenMixin",
11-
"ScreenHandlerAccessor"
13+
"ScreenHandlerAccessor",
14+
"ServerListMixin",
15+
"ServerListAccessor"
1216
],
1317
"injectors": {
1418
"defaultRequire": 1
1519
}
16-
}
20+
}

0 commit comments

Comments
 (0)