Skip to content

Commit

Permalink
Updating to ACC 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkKronicle committed Nov 19, 2021
1 parent 3a209e8 commit b5b7d2c
Showing 21 changed files with 167 additions and 113 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@ dependencies {
include 'org.javadelight:delight-nashorn-sandbox:0.2.5'
include group: 'org.webjars.bower', name: 'js-beautify', version: '1.9.0'
include group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'

implementation 'com.electronwill.night-config:toml:3.6.5'
}

processResources {
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -17,5 +17,5 @@ org.gradle.jvmargs=-Xmx1G --add-exports jdk.compiler/com.sun.tools.javac.api=ALL
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
advancedchat_version=1.3.0-beta1
advancedchat_version=1.3.0-beta3
owo_version=2.0.0
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
package io.github.darkkronicle.advancedchatfilters;

import io.github.darkkronicle.advancedchatcore.interfaces.IMessageFilter;
import io.github.darkkronicle.advancedchatcore.util.ColorUtil;
import io.github.darkkronicle.advancedchatcore.util.Color;
import io.github.darkkronicle.advancedchatcore.util.FluidText;
import io.github.darkkronicle.advancedchatfilters.config.Filter;
import io.github.darkkronicle.advancedchatfilters.config.FiltersConfigStorage;
@@ -47,7 +47,7 @@ public static FiltersHandler getInstance() {
public Optional<FluidText> filter(FluidText text) {
FluidText unfiltered = text;

ColorUtil.SimpleColor backgroundColor = null;
Color backgroundColor = null;
// Filter text
for (ParentFilter filter : filters) {
ParentFilter.FilterResult result = filter.filter(text, unfiltered);
@@ -58,7 +58,7 @@ public Optional<FluidText> filter(FluidText text) {
text = result.getText().get();
}
}
text.setBackgroundColor(backgroundColor);
text.setBackground(backgroundColor);

if (text.getString().length() != 0) {
return Optional.of(text);
@@ -93,7 +93,7 @@ public static ParentFilter createFilter(Filter filter) {
new ReplaceFilter(
filter.getReplaceTo().config.getStringValue().replaceAll("&", "§"),
filter.getReplace(),
filter.getTextColor().config.getSimpleColor()));
filter.getTextColor().config.get()));
} else {
filt.addFilter(
new ReplaceFilter(
@@ -103,7 +103,7 @@ public static ParentFilter createFilter(Filter filter) {
}
}
if (filter.getReplaceBackgroundColor().config.getBooleanValue()) {
filt.addFilter(new ColorFilter(filter.getBackgroundColor().config.getSimpleColor()));
filt.addFilter(new ColorFilter(filter.getBackgroundColor().config.get()));
}
if (filter.getProcessors().activeAmount() > 0) {
if (filter.getProcessors().activeAmount() == 1) {
Original file line number Diff line number Diff line change
@@ -18,12 +18,12 @@
import fi.dy.masa.malilib.config.options.ConfigString;
import fi.dy.masa.malilib.util.StringUtils;
import io.github.darkkronicle.advancedchatcore.AdvancedChatCore;
import io.github.darkkronicle.advancedchatcore.config.ConfigStorage;
import io.github.darkkronicle.advancedchatcore.config.options.ConfigSimpleColor;
import io.github.darkkronicle.advancedchatcore.config.SaveableConfig;
import io.github.darkkronicle.advancedchatcore.config.options.ConfigColor;
import io.github.darkkronicle.advancedchatcore.interfaces.ConfigRegistryOption;
import io.github.darkkronicle.advancedchatcore.interfaces.IJsonSave;
import io.github.darkkronicle.advancedchatcore.interfaces.IMatchProcessor;
import io.github.darkkronicle.advancedchatcore.util.ColorUtil;
import io.github.darkkronicle.advancedchatcore.util.Colors;
import io.github.darkkronicle.advancedchatcore.util.FindType;
import io.github.darkkronicle.advancedchatfilters.interfaces.IMatchReplace;
import io.github.darkkronicle.advancedchatfilters.registry.MatchProcessorRegistry;
@@ -59,26 +59,26 @@ private static String translate(String key) {
* Name is only cosmetic. Shows up when editing filters. Way to distinguish filters for the
* player.
*/
private ConfigStorage.SaveableConfig<ConfigString> name =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigString> name =
SaveableConfig.fromConfig(
"name", new ConfigString(translate("name"), "Default", translate("info.name")));

/** Whether or not it should be used to filter chat messages currently. */
private ConfigStorage.SaveableConfig<ConfigBoolean> active =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigBoolean> active =
SaveableConfig.fromConfig(
"active",
new ConfigBoolean(translate("active"), false, translate("info.active")));

/** Whether or not it should be used to filter chat messages currently. */
private ConfigStorage.SaveableConfig<ConfigBoolean> stripColors =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigBoolean> stripColors =
SaveableConfig.fromConfig(
"stripColors",
new ConfigBoolean(
translate("stripcolors"), true, translate("info.stripcolors")));

/** The Expression to find a match. The way it is interpreted is defined by findType. */
private ConfigStorage.SaveableConfig<ConfigString> findString =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigString> findString =
SaveableConfig.fromConfig(
"findString",
new ConfigString(
translate("findstring"), "Hello", translate("info.findstring")));
@@ -87,8 +87,8 @@ private static String translate(String key) {
* How findString is used. LITERAL checks just for a match character to character. UPPERLOWER is
* like literal, but ignore case. REGEX interprets findString as a regular expression.
*/
private ConfigStorage.SaveableConfig<ConfigOptionList> findType =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigOptionList> findType =
SaveableConfig.fromConfig(
"findType",
new ConfigOptionList(
translate("findtype"), FindType.LITERAL, translate("info.findtype")));
@@ -101,8 +101,8 @@ public FindType getFind() {
* How the found string is modified. ONLYMATCH replaces only what was matched. FULLLINE replaces
* the full message.
*/
private ConfigStorage.SaveableConfig<ConfigOptionList> replaceType =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigOptionList> replaceType =
SaveableConfig.fromConfig(
"replaceType",
new ConfigOptionList(
translate("replacetype"),
@@ -118,45 +118,47 @@ public IMatchReplace getReplace() {
* What the found string replaces to. (ex. If replaceType is FULLLINE this will replace the
* message with this)
*/
private ConfigStorage.SaveableConfig<ConfigString> replaceTo =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigString> replaceTo =
SaveableConfig.fromConfig(
"replaceTo",
new ConfigString(
translate("replaceto"), "Welcome", translate("info.replaceto")));

private ConfigStorage.SaveableConfig<ConfigBoolean> replaceTextColor =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigBoolean> replaceTextColor =
SaveableConfig.fromConfig(
"replaceTextColor",
new ConfigBoolean(
translate("replacetextcolor"),
false,
translate("info.replacetextcolor")));

private ConfigStorage.SaveableConfig<ConfigSimpleColor> textColor =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigColor> textColor =
SaveableConfig.fromConfig(
"textColor",
new ConfigSimpleColor(
translate("textcolor"), ColorUtil.WHITE, translate("info.textcolor")));
new ConfigColor(
translate("textcolor"),
Colors.getInstance().getColorOrWhite("white"),
translate("info.textcolor")));

private ConfigStorage.SaveableConfig<ConfigBoolean> replaceBackgroundColor =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigBoolean> replaceBackgroundColor =
SaveableConfig.fromConfig(
"replaceBackgroundColor",
new ConfigBoolean(
translate("replacebackgroundcolor"),
false,
translate("info.replacebackgroundcolor")));

private ConfigStorage.SaveableConfig<ConfigSimpleColor> backgroundColor =
ConfigStorage.SaveableConfig.fromConfig(
private SaveableConfig<ConfigColor> backgroundColor =
SaveableConfig.fromConfig(
"backgroundColor",
new ConfigSimpleColor(
new ConfigColor(
translate("backgroundcolor"),
ColorUtil.WHITE,
Colors.getInstance().getColorOrWhite("white"),
translate("info.backgroundcolor")));

private MatchProcessorRegistry processors = MatchProcessorRegistry.getInstance().clone();

private final ImmutableList<ConfigStorage.SaveableConfig<?>> options =
private final ImmutableList<SaveableConfig<?>> options =
ImmutableList.of(
name,
active,
@@ -203,7 +205,7 @@ public Filter load(JsonObject obj) {
f.setOrder(0);
}
}
for (ConfigStorage.SaveableConfig<?> conf : f.getOptions()) {
for (SaveableConfig<?> conf : f.getOptions()) {
IConfigBase option = conf.config;
if (obj.has(conf.key)) {
option.setValueFromJsonElement(obj.get(conf.key));
@@ -224,7 +226,7 @@ public Filter load(JsonObject obj) {
@Override
public JsonObject save(Filter filter) {
JsonObject obj = new JsonObject();
for (ConfigStorage.SaveableConfig<?> option : filter.getOptions()) {
for (SaveableConfig<?> option : filter.getOptions()) {
obj.add(option.key, option.config.getAsJsonElement());
}

@@ -329,7 +331,7 @@ public static NotifySound fromNotifySoundString(String notifysound) {

public static Filter getRandomFilter() {
Filter filter = new Filter();
for (ConfigStorage.SaveableConfig<?> c : filter.getOptions()) {
for (SaveableConfig<?> c : filter.getOptions()) {
if (c.config.getType() == ConfigType.STRING) {
((ConfigString) c.config).setValueFromString(AdvancedChatCore.getRandomString());
}
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import fi.dy.masa.malilib.util.FileUtils;
import fi.dy.masa.malilib.util.JsonUtils;
import io.github.darkkronicle.advancedchatcore.config.ConfigStorage;
import io.github.darkkronicle.advancedchatcore.config.SaveableConfig;
import io.github.darkkronicle.advancedchatfilters.AdvancedChatFilters;
import io.github.darkkronicle.advancedchatfilters.FiltersHandler;
import io.github.darkkronicle.advancedchatfilters.scripting.ScriptManager;
@@ -36,8 +37,8 @@ public class FiltersConfigStorage implements IConfigHandler {
public static final List<String> IMPORTED_FILTERS = new ArrayList<>();
private static final String IMPORTED_KEY = "importedfilters";

public static final ConfigStorage.SaveableConfig<ConfigBoolean> ADVANCED_ON =
ConfigStorage.SaveableConfig.fromConfig(
public static final SaveableConfig<ConfigBoolean> ADVANCED_ON =
SaveableConfig.fromConfig(
"advanced_filters_on",
new ConfigBoolean("advanced_filters_on", false, "advanced_filters_on"));

Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
import fi.dy.masa.malilib.gui.button.ButtonGeneric;
import fi.dy.masa.malilib.gui.button.IButtonActionListener;
import fi.dy.masa.malilib.util.StringUtils;
import io.github.darkkronicle.advancedchatcore.util.ColorUtil;
import io.github.darkkronicle.advancedchatcore.util.Colors;
import io.github.darkkronicle.advancedchatcore.util.FluidText;
import io.github.darkkronicle.advancedchatcore.util.RawText;
import io.github.darkkronicle.advancedchatcore.util.StyleFormatter;
@@ -73,7 +73,12 @@ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partia
int y = 100;
for (OrderedText warn : warning) {
drawCenteredTextWithShadow(
matrixStack, client.textRenderer, warn, width / 2, y, ColorUtil.WHITE.color());
matrixStack,
client.textRenderer,
warn,
width / 2,
y,
Colors.getInstance().getColorOrWhite("white").color());
y += client.textRenderer.fontHeight + 2;
}
}
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
import io.github.darkkronicle.advancedchatcore.config.gui.widgets.WidgetColor;
import io.github.darkkronicle.advancedchatcore.config.gui.widgets.WidgetLabelHoverable;
import io.github.darkkronicle.advancedchatcore.config.gui.widgets.WidgetToggle;
import io.github.darkkronicle.advancedchatcore.util.ColorUtil;
import io.github.darkkronicle.advancedchatcore.util.Colors;
import io.github.darkkronicle.advancedchatfilters.FiltersHandler;
import io.github.darkkronicle.advancedchatfilters.config.Filter;
import io.github.darkkronicle.advancedchatfilters.registry.MatchReplaceRegistry;
@@ -106,12 +106,12 @@ public void save() {
filter.getName().config.setValueFromString(name.getText());
filter.getFindString().config.setValueFromString(findString.getText());
filter.getReplaceTo().config.setValueFromString(replaceString.getText());
filter.getTextColor().config.setIntegerValue(textColor.getAndRefreshColor().color());
filter.getTextColor().config.setIntegerValue(textColor.getAndRefreshColor4f().color());
filter.getReplaceTextColor().config.setBooleanValue(setTextColor.isCurrentlyOn());
filter.getReplaceType().config.setOptionListValue(replaceTypeWidget.getSelectedEntry());
filter.getBackgroundColor()
.config
.setIntegerValue(backgroundColor.getAndRefreshColor().color());
.setIntegerValue(backgroundColor.getAndRefreshColor4f().color());
filter.getReplaceBackgroundColor()
.config
.setBooleanValue(setBackgroundColor.isCurrentlyOn());
@@ -177,7 +177,7 @@ private void createButtons(int x, int y) {
y,
getWidth() / 2 - 1,
18,
filter.getTextColor().config.getSimpleColor(),
filter.getTextColor().config.get(),
textRenderer);
this.addTextField(textColor, null);
setTextColor =
@@ -207,7 +207,7 @@ private void createButtons(int x, int y) {
y,
getWidth() / 2 - 1,
18,
filter.getBackgroundColor().config.getSimpleColor(),
filter.getBackgroundColor().config.get(),
textRenderer);
setBackgroundColor =
new WidgetToggle(
@@ -254,7 +254,12 @@ private int addLabel(int x, int y, IConfigBase config) {
int width = StringUtils.getStringWidth(config.getConfigGuiDisplayName());
WidgetLabelHoverable label =
new WidgetLabelHoverable(
x, y, width, 8, ColorUtil.WHITE.color(), config.getConfigGuiDisplayName());
x,
y,
width,
8,
Colors.getInstance().getColorOrWhite("white").color(),
config.getConfigGuiDisplayName());
label.setHoverLines(StringUtils.translate(config.getComment()));
this.addWidget(label);
return 8;
@@ -264,7 +269,13 @@ private int addLabel(int x, int y, String nameTranslation, String hoverTranslati
String display = StringUtils.translate(nameTranslation);
int width = StringUtils.getStringWidth(display);
WidgetLabelHoverable label =
new WidgetLabelHoverable(x, y, width, 8, ColorUtil.WHITE.color(), display);
new WidgetLabelHoverable(
x,
y,
width,
8,
Colors.getInstance().getColorOrWhite("white").color(),
display);
label.setHoverLines(StringUtils.translate(hoverTranslation));
this.addWidget(label);
return 8;
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
import fi.dy.masa.malilib.util.KeyCodes;
import fi.dy.masa.malilib.util.StringUtils;
import io.github.darkkronicle.advancedchatcore.config.gui.widgets.WidgetIntBox;
import io.github.darkkronicle.advancedchatcore.util.ColorUtil;
import io.github.darkkronicle.advancedchatcore.util.Colors;
import io.github.darkkronicle.advancedchatfilters.FiltersHandler;
import io.github.darkkronicle.advancedchatfilters.config.FiltersConfigStorage;
import io.github.darkkronicle.advancedchatfilters.scripting.ScriptFilter;
@@ -131,16 +131,29 @@ public void render(int mouseX, int mouseY, boolean selected, MatrixStack matrixS
this.y,
this.width,
this.height,
ColorUtil.WHITE.withAlpha(150).color());
Colors.getInstance().getColorOrWhite("listhover").color());
} else if (this.isOdd) {
RenderUtils.drawRect(
this.x, this.y, this.width, this.height, ColorUtil.WHITE.withAlpha(70).color());
this.x,
this.y,
this.width,
this.height,
Colors.getInstance().getColorOrWhite("list1").color());
} else {
RenderUtils.drawRect(
this.x, this.y, this.width, this.height, ColorUtil.WHITE.withAlpha(50).color());
this.x,
this.y,
this.width,
this.height,
Colors.getInstance().getColorOrWhite("list2").color());
}
String name = this.filter.getDisplayName();
this.drawString(this.x + 4, this.y + 7, ColorUtil.WHITE.color(), name, matrixStack);
this.drawString(
this.x + 4,
this.y + 7,
Colors.getInstance().getColorOrWhite("white").color(),
name,
matrixStack);

RenderUtils.color(1f, 1f, 1f, 1f);
RenderSystem.disableBlend();
Loading

0 comments on commit b5b7d2c

Please sign in to comment.