Skip to content

Commit e4beb2b

Browse files
committed
Small update, just clubs stuff and replace stuff etc
1 parent 2a2ba6c commit e4beb2b

File tree

18 files changed

+653
-66
lines changed

18 files changed

+653
-66
lines changed

src/main/java/llc/redstone/hysentials/GuiIngameHysentials.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ else if (renderExperiance)
215215
if (Minecraft.getMinecraft().currentScreen == null) {
216216
Minecraft.getMinecraft().mouseHelper.grabMouseCursor();
217217
}
218-
cooldown = System.currentTimeMillis() + 1000;
218+
// cooldown = System.currentTimeMillis() + 1000;
219219
}
220220

221221
post(ALL);

src/main/java/llc/redstone/hysentials/Hysentials.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
import java.net.URL;
8282
import java.nio.charset.Charset;
8383
import java.nio.charset.StandardCharsets;
84+
import java.nio.file.Files;
85+
import java.nio.file.Paths;
8486
import java.util.ArrayList;
8587
import java.util.List;
8688

@@ -263,7 +265,7 @@ public static void updateAndAdd() {
263265
if (icon.custom) {
264266
if (icon.localPath == null || icon.name.isEmpty() || ImageIcon.imageIcons.containsKey(icon.name)) continue;
265267
if (!new File(icon.localPath).exists()) continue;
266-
ImageIcon icon1 = new ImageIcon(icon.name, null, false);
268+
ImageIcon icon1 = new ImageIcon(icon.name, icon.localPath, false);
267269
icon1.width = icon.width;
268270
icon1.height = icon.height;
269271
}

src/main/java/llc/redstone/hysentials/config/HysentialsConfig.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,19 @@ public class HysentialsConfig extends Config {
7777
new CosmeticConfig()
7878
);
7979
@PageAnnotation(
80-
name = "Icons",
80+
name = "Icons and Replace",
8181
category = "Hysentials Mods",
8282
subcategory = "Hysentials Mods",
83-
description = "Icon related settings."
83+
description = "Icon and replace related settings.",
84+
group = true
8485
)
85-
public transient IconsConfig iconsConfig = new IconsConfig();
86+
public transient List<Config> hysentialMods3 = Arrays.asList(
87+
new IconsConfig(),
88+
new ReplaceConfig()
89+
);
90+
91+
public transient IconsConfig iconsConfig = (IconsConfig) hysentialMods3.get(0);
92+
public transient ReplaceConfig replaceConfig = (ReplaceConfig) hysentialMods3.get(1);
8693
public transient ChatConfig chatConfig = (ChatConfig) hysentialMods.get(0);
8794
public transient FormattingConfig formattingConfig = (FormattingConfig) hysentialMods.get(1);
8895
public transient HousingConfig housingConfig = (HousingConfig) hysentialMods.get(2);

src/main/java/llc/redstone/hysentials/config/hysentialMods/FormattingConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,8 @@ public static RankStuff getRank(String type) {
277277
public static boolean fancyRendering() {
278278
return (futuristicRanks || hexColors) && Hysentials.INSTANCE.getConfig().formattingConfig.enabled;
279279
}
280+
281+
public static boolean hexRendering() {
282+
return hexColors && Hysentials.INSTANCE.getConfig().formattingConfig.enabled;
283+
}
280284
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package llc.redstone.hysentials.config.hysentialMods;
2+
3+
import cc.polyfrost.oneconfig.config.Config;
4+
import cc.polyfrost.oneconfig.config.annotations.CustomOption;
5+
import cc.polyfrost.oneconfig.config.annotations.Info;
6+
import cc.polyfrost.oneconfig.config.annotations.Switch;
7+
import cc.polyfrost.oneconfig.config.core.ConfigUtils;
8+
import cc.polyfrost.oneconfig.config.data.InfoType;
9+
import cc.polyfrost.oneconfig.config.data.Mod;
10+
import cc.polyfrost.oneconfig.config.data.ModType;
11+
import cc.polyfrost.oneconfig.config.elements.BasicOption;
12+
import cc.polyfrost.oneconfig.config.elements.OptionPage;
13+
import llc.redstone.hysentials.config.hysentialMods.icons.IconStuff;
14+
import llc.redstone.hysentials.config.hysentialMods.icons.IconsAnnotation;
15+
import llc.redstone.hysentials.config.hysentialMods.icons.IconsOption;
16+
import llc.redstone.hysentials.config.hysentialMods.replace.ReplaceAnnotation;
17+
import llc.redstone.hysentials.config.hysentialMods.replace.ReplaceOption;
18+
import llc.redstone.hysentials.config.hysentialMods.replace.ReplaceStuff;
19+
import llc.redstone.hysentials.handlers.imageicons.ImageIcon;
20+
import llc.redstone.hysentials.util.BlockWAPIUtils;
21+
22+
import java.io.File;
23+
import java.lang.reflect.Field;
24+
import java.util.*;
25+
import java.util.stream.Collectors;
26+
27+
public class ReplaceConfig extends Config {
28+
@Switch(
29+
name = "Enable Regex Replacement",
30+
description = "Enable regex replacement",
31+
category = "Global",
32+
subcategory = "Global",
33+
size = 0
34+
)
35+
public boolean enableRegex = false;
36+
37+
@ReplaceAnnotation(
38+
name = "Global Replace",
39+
description = "Replace things globally",
40+
category = "Global",
41+
subcategory = "Global"
42+
)
43+
public List<ReplaceStuff> globalReplacements = new ArrayList<>(Collections.singletonList(
44+
new ReplaceStuff("Global")
45+
));
46+
47+
@ReplaceAnnotation(
48+
name = "Club Replace",
49+
description = "Replace things in clubs",
50+
category = "Clubs",
51+
subcategory = ""
52+
)
53+
public List<ReplaceStuff> clubReplacements = new ArrayList<>();
54+
55+
//, "/assets/hysentials/mods/cosmetics.png", 244, 80
56+
public ReplaceConfig() {
57+
super(new Mod("Replace", ModType.UTIL_QOL), "hysentials-replace.json", true, false);
58+
initialize();
59+
}
60+
61+
public void initialize() {
62+
boolean migrate = false;
63+
File profileFile = ConfigUtils.getProfileFile(configFile);
64+
if (profileFile.exists()) load();
65+
if (!profileFile.exists()) {
66+
if (mod.migrator != null) migrate = true;
67+
else save();
68+
}
69+
mod.config = this;
70+
generateOptionList(this, mod.defaultPage, mod, migrate);
71+
if (migrate) save();
72+
}
73+
74+
@Override
75+
protected BasicOption getCustomOption(Field field, CustomOption annotation, OptionPage page, Mod mod, boolean migrate) {
76+
BasicOption option = null;
77+
switch (annotation.id()) {
78+
case "replace":
79+
ReplaceAnnotation myOption = ConfigUtils.findAnnotation(field, ReplaceAnnotation.class);
80+
option = ReplaceOption.create(field, this);
81+
ConfigUtils.getSubCategory(page, myOption.category(), myOption.subcategory()).options.add(option);
82+
break;
83+
}
84+
return option;
85+
}
86+
87+
public HashMap<String, String> getAllActiveReplacements() {
88+
HashMap<String, String> replacements = new HashMap<>();
89+
for (ReplaceStuff replaceStuff : globalReplacements) {
90+
replacements.putAll(replaceStuff.replacements);
91+
}
92+
if (BlockWAPIUtils.currentHousingsClub != null) {
93+
clubReplacements.stream().filter(replaceStuff -> replaceStuff.clubName.equals(BlockWAPIUtils.currentHousingsClub.getName())).findFirst().ifPresent(clubReplace -> {
94+
replacements.putAll(clubReplace.replacements);
95+
});
96+
}
97+
return replacements;
98+
}
99+
100+
public boolean isRegexEnabled() {
101+
boolean regex = enableRegex;
102+
if (BlockWAPIUtils.currentHousingsClub != null) {
103+
regex = BlockWAPIUtils.currentHousingsClub.getRegex();
104+
}
105+
return regex;
106+
}
107+
}

src/main/java/llc/redstone/hysentials/config/hysentialMods/page/PageOption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void draw(long vg, int x, int y, InputHandler inputHandler) {
8484
element.draw(vg, x + 1024 / 2f - 260 /2f, y, inputHandler);
8585
} else if (config.size() == 2) {
8686
//draw 2 in the center
87-
element.draw(vg, x + 1024 / 2f - 260 * 4/3f, y, inputHandler);
87+
element.draw(vg, x + 1024 / 2f - 260, y, inputHandler);
8888
x += 260;
8989
} else if (config.size() == 3) {
9090
//draw 3 in the center
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package llc.redstone.hysentials.config.hysentialMods.replace;
2+
3+
import cc.polyfrost.oneconfig.config.annotations.CustomOption;
4+
5+
import javax.annotation.Nullable;
6+
import java.lang.annotation.ElementType;
7+
import java.lang.annotation.Retention;
8+
import java.lang.annotation.RetentionPolicy;
9+
import java.lang.annotation.Target;
10+
11+
@Retention(RetentionPolicy.RUNTIME)
12+
@Target(ElementType.FIELD)
13+
@CustomOption(id = "replace")
14+
public @interface ReplaceAnnotation {
15+
String name();
16+
String description() default "";
17+
String category();
18+
@Nullable String subcategory();
19+
}

0 commit comments

Comments
 (0)