From 62ec83607540fe35505dafc04f079a6442f879ab Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 1 Feb 2024 13:05:54 +0100 Subject: [PATCH 01/53] Add empty tool config activity --- .../java/com/rappytv/toolwarn/ui/ToolConfigActivity.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java new file mode 100644 index 0000000..7012fce --- /dev/null +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java @@ -0,0 +1,9 @@ +package com.rappytv.toolwarn.ui; + +import net.labymod.api.client.gui.screen.activity.AutoActivity; +import net.labymod.api.client.gui.screen.activity.types.SimpleActivity; + +@AutoActivity +public class ToolConfigActivity extends SimpleActivity { + +} From b51f5ce207f6656a0716cdcb891a0ae42aa71722 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 1 Feb 2024 13:07:23 +0100 Subject: [PATCH 02/53] Add setting which opens ToolConfigActivity --- .../com/rappytv/toolwarn/config/TbwConfiguration.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 02e6e4a..c009cf7 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -1,7 +1,10 @@ package com.rappytv.toolwarn.config; import com.rappytv.toolwarn.config.subconfig.TbwSoundSubConfig; +import com.rappytv.toolwarn.ui.ToolConfigActivity; import net.labymod.api.addon.AddonConfig; +import net.labymod.api.client.gui.screen.activity.Activity; +import net.labymod.api.client.gui.screen.widget.widgets.activity.settings.ActivitySettingWidget.ActivitySetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; import net.labymod.api.configuration.loader.annotation.ConfigName; @@ -11,6 +14,7 @@ import net.labymod.api.configuration.loader.annotation.VersionCompatibility; import net.labymod.api.configuration.loader.property.ConfigProperty; import net.labymod.api.configuration.settings.annotation.SettingSection; +import net.labymod.api.util.MethodOrder; @ConfigName("settings") @SpriteTexture(value = "settings") @@ -32,6 +36,11 @@ public class TbwConfiguration extends AddonConfig { private final TbwSoundSubConfig sounds = new TbwSoundSubConfig(); @SettingSection("tools") + @MethodOrder(after = "sounds") + @ActivitySetting + public Activity activity() { + return new ToolConfigActivity(); + } @SliderSetting(steps = 1, min = 1, max = 25) @SpriteSlot(size = 32, y = 2) private final ConfigProperty swordPercentage = new ConfigProperty<>(5); From 86cb507694ee40570815ab61afca06eed627dfc2 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 1 Feb 2024 13:42:09 +0100 Subject: [PATCH 03/53] Add empty lss files --- .../main/resources/assets/toolwarn/themes/vanilla/lss/config.lss | 0 .../main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss create mode 100644 core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss new file mode 100644 index 0000000..e69de29 diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss new file mode 100644 index 0000000..e69de29 From b58a8b08ddd9014f6df64cfc159c428f43c5173d Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 1 Feb 2024 13:43:16 +0100 Subject: [PATCH 04/53] Add tool widget --- .../com/rappytv/toolwarn/ui/ToolWidget.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java new file mode 100644 index 0000000..c22f327 --- /dev/null +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java @@ -0,0 +1,45 @@ +package com.rappytv.toolwarn.ui; + +import com.rappytv.toolwarn.util.ToolType; +import net.labymod.api.client.gui.icon.Icon; +import net.labymod.api.client.gui.lss.property.annotation.AutoWidget; +import net.labymod.api.client.gui.screen.Parent; +import net.labymod.api.client.gui.screen.activity.Link; +import net.labymod.api.client.gui.screen.widget.SimpleWidget; +import net.labymod.api.client.gui.screen.widget.widgets.ComponentWidget; +import net.labymod.api.client.gui.screen.widget.widgets.renderer.IconWidget; +import net.labymod.api.client.resources.ResourceLocation; + +@Link("tool.lss") +@AutoWidget +public class ToolWidget extends SimpleWidget { + + private final ToolType toolType; + private final int warnAt; + private final boolean openChat; + private final boolean lastHitWarn; + + public ToolWidget(ToolType toolType, int warnAt, boolean openChat, boolean lastHitWarn) { + this.toolType = toolType; + this.warnAt = warnAt; + this.openChat = openChat; + this.lastHitWarn = lastHitWarn; + } + + @Override + public void initialize(Parent parent) { + super.initialize(parent); + IconWidget iconWidget = new IconWidget(Icon.texture(ResourceLocation.create("minecraft", ""))) + .addId("tool-icon"); + + ComponentWidget nameWidget = ComponentWidget.text(this.toolType.name()) + .addId("name-component"); + + ComponentWidget meta = ComponentWidget.i18n("", warnAt, openChat, lastHitWarn) + .addId("meta-component"); + + this.addChild(iconWidget); + this.addChild(nameWidget); + this.addChild(meta); + } +} From b60cdb53a5c2628039cc003dbf837cb2f429e7c6 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 1 Feb 2024 13:43:31 +0100 Subject: [PATCH 05/53] Link config activity to lss file --- .../main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java index 7012fce..e8c23d8 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java @@ -1,8 +1,10 @@ package com.rappytv.toolwarn.ui; import net.labymod.api.client.gui.screen.activity.AutoActivity; +import net.labymod.api.client.gui.screen.activity.Link; import net.labymod.api.client.gui.screen.activity.types.SimpleActivity; +@Link("config.lss") @AutoActivity public class ToolConfigActivity extends SimpleActivity { From 34aceeafaf2b227afb97cc9246f1a7ffddd79f74 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 1 Feb 2024 13:45:03 +0100 Subject: [PATCH 06/53] Add warn sound to ToolWidget --- core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java index c22f327..b8f7a44 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java @@ -1,6 +1,7 @@ package com.rappytv.toolwarn.ui; import com.rappytv.toolwarn.util.ToolType; +import com.rappytv.toolwarn.util.WarnSound; import net.labymod.api.client.gui.icon.Icon; import net.labymod.api.client.gui.lss.property.annotation.AutoWidget; import net.labymod.api.client.gui.screen.Parent; @@ -15,12 +16,14 @@ public class ToolWidget extends SimpleWidget { private final ToolType toolType; + private final WarnSound warnSound; private final int warnAt; private final boolean openChat; private final boolean lastHitWarn; - public ToolWidget(ToolType toolType, int warnAt, boolean openChat, boolean lastHitWarn) { + public ToolWidget(ToolType toolType, WarnSound warnSound, int warnAt, boolean openChat, boolean lastHitWarn) { this.toolType = toolType; + this.warnSound = warnSound; this.warnAt = warnAt; this.openChat = openChat; this.lastHitWarn = lastHitWarn; @@ -35,7 +38,7 @@ public void initialize(Parent parent) { ComponentWidget nameWidget = ComponentWidget.text(this.toolType.name()) .addId("name-component"); - ComponentWidget meta = ComponentWidget.i18n("", warnAt, openChat, lastHitWarn) + ComponentWidget meta = ComponentWidget.i18n("", warnAt, warnSound, openChat, lastHitWarn) .addId("meta-component"); this.addChild(iconWidget); From 18371775405b14d8a7536b85d0599ff2d6fed8e0 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 1 Feb 2024 13:48:39 +0100 Subject: [PATCH 07/53] Add new translation --- .../java/com/rappytv/toolwarn/config/TbwConfiguration.java | 2 +- core/src/main/resources/assets/toolwarn/i18n/de_de.json | 3 +++ core/src/main/resources/assets/toolwarn/i18n/en_us.json | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index c009cf7..50b1492 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -38,7 +38,7 @@ public class TbwConfiguration extends AddonConfig { @SettingSection("tools") @MethodOrder(after = "sounds") @ActivitySetting - public Activity activity() { + public Activity toolConfig() { return new ToolConfigActivity(); } @SliderSetting(steps = 1, min = 1, max = 25) diff --git a/core/src/main/resources/assets/toolwarn/i18n/de_de.json b/core/src/main/resources/assets/toolwarn/i18n/de_de.json index c51ed1e..0bdba16 100644 --- a/core/src/main/resources/assets/toolwarn/i18n/de_de.json +++ b/core/src/main/resources/assets/toolwarn/i18n/de_de.json @@ -48,6 +48,9 @@ } } }, + "toolConfig": { + "name": "Werkzeuge verwalten" + }, "swordPercentage": { "name": "Schwert-Warnung (%)" }, diff --git a/core/src/main/resources/assets/toolwarn/i18n/en_us.json b/core/src/main/resources/assets/toolwarn/i18n/en_us.json index dc4efaf..2cff646 100644 --- a/core/src/main/resources/assets/toolwarn/i18n/en_us.json +++ b/core/src/main/resources/assets/toolwarn/i18n/en_us.json @@ -48,6 +48,9 @@ } } }, + "toolConfig": { + "name": "Manage tools" + }, "swordPercentage": { "name": "Sword warn percentage" }, From 15d1c18a550126041df4c0bb122498d696979a70 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 1 Feb 2024 14:14:42 +0100 Subject: [PATCH 08/53] Some other changes - and a lot of errors --- .../java/com/rappytv/toolwarn/TbwAddon.java | 6 + .../toolwarn/config/TbwConfiguration.java | 13 + .../toolwarn/ui/ToolConfigActivity.java | 343 ++++++++++++++++++ .../com/rappytv/toolwarn/ui/ToolWidget.java | 8 +- .../com/rappytv/toolwarn/util/WarnTool.java | 18 + 5 files changed, 383 insertions(+), 5 deletions(-) create mode 100644 core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java diff --git a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java index 0a77a26..a1a4691 100644 --- a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java +++ b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java @@ -19,6 +19,7 @@ public class TbwAddon extends LabyAddon { public static Component prefix; private static ITbwSounds sounds; + private static TbwAddon instance; @Override protected void preConfigurationLoad() { @@ -32,10 +33,15 @@ protected void enable() { .append(Component.text("» ", NamedTextColor.DARK_GRAY)); sounds = ((DefaultReferenceStorage) this.referenceStorageAccessor()).iTbwSounds(); registerSettingCategory(); + instance = this; registerListener(new GameTickListener(this)); } + public static TbwAddon get() { + return instance; + } + public static ITbwSounds getSounds() { return sounds; } diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 50b1492..0f77b19 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -2,12 +2,16 @@ import com.rappytv.toolwarn.config.subconfig.TbwSoundSubConfig; import com.rappytv.toolwarn.ui.ToolConfigActivity; +import com.rappytv.toolwarn.ui.ToolWidget; +import com.rappytv.toolwarn.util.ToolType; +import com.rappytv.toolwarn.util.WarnTool; import net.labymod.api.addon.AddonConfig; import net.labymod.api.client.gui.screen.activity.Activity; import net.labymod.api.client.gui.screen.widget.widgets.activity.settings.ActivitySettingWidget.ActivitySetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; import net.labymod.api.configuration.loader.annotation.ConfigName; +import net.labymod.api.configuration.loader.annotation.Exclude; import net.labymod.api.configuration.loader.annotation.IntroducedIn; import net.labymod.api.configuration.loader.annotation.SpriteSlot; import net.labymod.api.configuration.loader.annotation.SpriteTexture; @@ -15,11 +19,20 @@ import net.labymod.api.configuration.loader.property.ConfigProperty; import net.labymod.api.configuration.settings.annotation.SettingSection; import net.labymod.api.util.MethodOrder; +import java.util.HashMap; +import java.util.Map; @ConfigName("settings") @SpriteTexture(value = "settings") public class TbwConfiguration extends AddonConfig { + @Exclude + private final Map tools = new HashMap<>(); + + public Map getTools() { + return tools; + } + @SwitchSetting @SpriteSlot(size = 32) private final ConfigProperty enabled = new ConfigProperty<>(true); diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java index e8c23d8..bca392f 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java @@ -1,11 +1,354 @@ package com.rappytv.toolwarn.ui; +import com.rappytv.toolwarn.TbwAddon; +import net.labymod.api.Laby; +import net.labymod.api.client.component.serializer.legacy.LegacyComponentSerializer; +import net.labymod.api.client.gui.mouse.MutableMouse; +import net.labymod.api.client.gui.screen.LabyScreen; +import net.labymod.api.client.gui.screen.Parent; import net.labymod.api.client.gui.screen.activity.AutoActivity; import net.labymod.api.client.gui.screen.activity.Link; import net.labymod.api.client.gui.screen.activity.types.SimpleActivity; +import net.labymod.api.client.gui.screen.key.InputType; +import net.labymod.api.client.gui.screen.key.Key; +import net.labymod.api.client.gui.screen.key.MouseButton; +import net.labymod.api.client.gui.screen.widget.Widget; +import net.labymod.api.client.gui.screen.widget.widgets.ComponentWidget; +import net.labymod.api.client.gui.screen.widget.widgets.DivWidget; +import net.labymod.api.client.gui.screen.widget.widgets.input.ButtonWidget; +import net.labymod.api.client.gui.screen.widget.widgets.input.CheckBoxWidget; +import net.labymod.api.client.gui.screen.widget.widgets.input.CheckBoxWidget.State; +import net.labymod.api.client.gui.screen.widget.widgets.input.TextFieldWidget; +import net.labymod.api.client.gui.screen.widget.widgets.layout.FlexibleContentWidget; +import net.labymod.api.client.gui.screen.widget.widgets.layout.ScrollWidget; +import net.labymod.api.client.gui.screen.widget.widgets.layout.list.HorizontalListWidget; +import net.labymod.api.client.gui.screen.widget.widgets.layout.list.VerticalListWidget; +import net.labymod.api.client.gui.screen.widget.widgets.renderer.IconWidget; +import net.labymod.api.client.render.font.TextColorStripper; +import org.jetbrains.annotations.Nullable; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; @Link("config.lss") @AutoActivity public class ToolConfigActivity extends SimpleActivity { + private static final Pattern NAME_PATTERN = Pattern.compile("[\\w]{0,16}"); + private static final TextColorStripper TEXT_COLOR_STRIPPER = Laby.references() + .textColorStripper(); + private final TbwAddon addon; + private final VerticalListWidget toolList; + private final Map toolWidgets; + + private ToolWidget selectedTool; + + private ButtonWidget removeButton; + private ButtonWidget editButton; + + private FlexibleContentWidget inputWidget; + private String lastUserName; + private String lastCustomName; + + private Action action; + + public ToolConfigActivity() { + this.addon = TbwAddon.get(); + + this.toolWidgets = new HashMap<>(); + this.addon.configuration().getTools().forEach((toolType, customTag) -> { + this.toolWidgets.put(toolType, new ToolWidget(toolType, customTag)); + }); + + this.toolList = new VerticalListWidget<>(); + this.toolList.addId("name-tag-list"); + this.toolList.setSelectCallback(nameTagWidget -> { + NameTagWidget selectedNameTag = this.toolList.session().getSelectedEntry(); + if (selectedNameTag == null + || selectedNameTag.getCustomTag() != nameTagWidget.getCustomTag()) { + this.editButton.setEnabled(true); + this.removeButton.setEnabled(true); + } + }); + + this.toolList.setDoubleClickCallback(nameTagWidget -> this.setAction(Action.EDIT)); + } + + @Override + public void initialize(Parent parent) { + super.initialize(parent); + + FlexibleContentWidget container = new FlexibleContentWidget(); + container.addId("name-tag-container"); + for (NameTagWidget nameTagWidget : this.toolWidgets.values()) { + this.toolList.addChild(nameTagWidget); + } + + container.addFlexibleContent(new ScrollWidget(this.toolList)); + + this.selectedTool = this.toolList.session().getSelectedEntry(); + HorizontalListWidget menu = new HorizontalListWidget(); + menu.addId("overview-button-menu"); + + menu.addEntry(ButtonWidget.i18n("labymod.ui.button.add", () -> this.setAction(Action.ADD))); + + this.editButton = ButtonWidget.i18n("labymod.ui.button.edit", + () -> this.setAction(Action.EDIT)); + this.editButton.setEnabled(this.selectedTool != null); + menu.addEntry(this.editButton); + + this.removeButton = ButtonWidget.i18n("labymod.ui.button.remove", + () -> this.setAction(Action.REMOVE)); + this.removeButton.setEnabled(this.selectedTool != null); + menu.addEntry(this.removeButton); + + container.addContent(menu); + this.document().addChild(container); + if (this.action == null) { + return; + } + + DivWidget manageContainer = new DivWidget(); + manageContainer.addId("manage-container"); + + Widget overlayWidget; + switch (this.action) { + default: + case ADD: + NameTagWidget newCustomNameTag = new NameTagWidget("", CustomNameTag.createDefault()); + overlayWidget = this.initializeManageContainer(newCustomNameTag); + break; + case EDIT: + overlayWidget = this.initializeManageContainer(this.selectedTool); + break; + case REMOVE: + overlayWidget = this.initializeRemoveContainer(this.selectedTool); + break; + } + + manageContainer.addChild(overlayWidget); + this.document().addChild(manageContainer); + } + + private FlexibleContentWidget initializeRemoveContainer(NameTagWidget nameTagWidget) { + this.inputWidget = new FlexibleContentWidget(); + this.inputWidget.addId("remove-container"); + + ComponentWidget confirmationWidget = ComponentWidget.i18n( + "customnametags.gui.manage.remove.title"); + confirmationWidget.addId("remove-confirmation"); + this.inputWidget.addContent(confirmationWidget); + + NameTagWidget previewWidget = new NameTagWidget(nameTagWidget.getUserName(), + nameTagWidget.getCustomTag()); + previewWidget.addId("remove-preview"); + this.inputWidget.addContent(previewWidget); + + HorizontalListWidget menu = new HorizontalListWidget(); + menu.addId("remove-button-menu"); + + menu.addEntry(ButtonWidget.i18n("labymod.ui.button.remove", () -> { + this.addon.configuration().getCustomTags().remove(nameTagWidget.getUserName()); + this.toolWidgets.remove(nameTagWidget.getUserName()); + this.toolList.session().setSelectedEntry(null); + this.setAction(null); + this.updateRequired = true; + })); + + menu.addEntry(ButtonWidget.i18n("labymod.ui.button.cancel", () -> this.setAction(null))); + this.inputWidget.addContent(menu); + + return this.inputWidget; + } + + private DivWidget initializeManageContainer(NameTagWidget nameTagWidget) { + TextFieldWidget customTextField = new TextFieldWidget(); + ButtonWidget doneButton = ButtonWidget.i18n("labymod.ui.button.done"); + + DivWidget inputContainer = new DivWidget(); + inputContainer.addId("input-container"); + + ComponentWidget customNameWidget = ComponentWidget.component( + nameTagWidget.getCustomTag().displayName()); + customNameWidget.addId("custom-preview"); + inputContainer.addChild(customNameWidget); + + this.inputWidget = new FlexibleContentWidget(); + this.inputWidget.addId("input-list"); + + ComponentWidget labelName = ComponentWidget.i18n("customnametags.gui.manage.name"); + labelName.addId("label-name"); + this.inputWidget.addContent(labelName); + + HorizontalListWidget nameList = new HorizontalListWidget(); + nameList.addId("input-name-list"); + + IconWidget iconWidget = new IconWidget( + nameTagWidget.getIconWidget(nameTagWidget.getUserName())); + iconWidget.addId("input-avatar"); + nameList.addEntry(iconWidget); + + TextFieldWidget nameTextField = new TextFieldWidget(); + nameTextField.maximalLength(16); + nameTextField.setText(nameTagWidget.getUserName()); + nameTextField.validator(newValue -> NAME_PATTERN.matcher(newValue).matches()); + nameTextField.updateListener(newValue -> { + doneButton.setEnabled( + !newValue.trim().isEmpty() && !this.getStrippedText(customTextField.getText()).isEmpty() + ); + if (newValue.equals(this.lastUserName)) { + return; + } + + this.lastUserName = newValue; + iconWidget.icon().set(nameTagWidget.getIconWidget(newValue)); + }); + + nameList.addEntry(nameTextField); + this.inputWidget.addContent(nameList); + + ComponentWidget labelCustomName = ComponentWidget.i18n("customnametags.gui.manage.custom.name"); + labelCustomName.addId("label-name"); + this.inputWidget.addContent(labelCustomName); + + HorizontalListWidget customNameList = new HorizontalListWidget(); + customNameList.addId("input-name-list"); + + DivWidget placeHolder = new DivWidget(); + placeHolder.addId("input-avatar"); + customNameList.addEntry(placeHolder); + + customTextField.maximalLength(64); + customTextField.setText(nameTagWidget.getCustomTag().getCustomName()); + customTextField.updateListener(newValue -> { + doneButton.setEnabled( + !this.getStrippedText(newValue).isEmpty() && !nameTextField.getText().trim().isEmpty() + ); + if (newValue.equals(this.lastCustomName)) { + return; + } + + this.lastCustomName = newValue; + customNameWidget.setComponent( + LegacyComponentSerializer.legacyAmpersand().deserialize(newValue)); + }); + + customNameList.addEntry(customTextField); + this.inputWidget.addContent(customNameList); + + HorizontalListWidget checkBoxList = new HorizontalListWidget(); + checkBoxList.addId("checkbox-list"); + + DivWidget enabledDiv = new DivWidget(); + enabledDiv.addId("checkbox-div"); + + ComponentWidget enabledText = ComponentWidget.i18n("customnametags.gui.manage.enabled.name"); + enabledText.addId("checkbox-name"); + enabledDiv.addChild(enabledText); + + CheckBoxWidget enabledWidget = new CheckBoxWidget(); + enabledWidget.addId("checkbox-item"); + enabledWidget.setState( + nameTagWidget.getCustomTag().isEnabled() ? State.CHECKED : State.UNCHECKED); + enabledDiv.addChild(enabledWidget); + checkBoxList.addEntry(enabledDiv); + + DivWidget replaceDiv = new DivWidget(); + replaceDiv.addId("checkbox-div"); + + ComponentWidget replaceText = ComponentWidget.i18n("customnametags.gui.manage.replace.name"); + replaceText.addId("checkbox-name"); + replaceDiv.addChild(replaceText); + + CheckBoxWidget replaceWidget = new CheckBoxWidget(); + replaceWidget.addId("checkbox-item"); + replaceWidget.setState( + nameTagWidget.getCustomTag().isReplaceScoreboard() ? State.CHECKED : State.UNCHECKED); + replaceDiv.addChild(replaceWidget); + checkBoxList.addEntry(replaceDiv); + this.inputWidget.addContent(checkBoxList); + + HorizontalListWidget buttonList = new HorizontalListWidget(); + buttonList.addId("edit-button-menu"); + + doneButton.setEnabled( + !nameTextField.getText().trim().isEmpty() && !this.getStrippedText( + customTextField.getText()).isEmpty() + ); + doneButton.setPressable(() -> { + if (nameTagWidget.getUserName().length() == 0) { + this.toolWidgets.put(nameTextField.getText(), nameTagWidget); + this.toolList.session().setSelectedEntry(nameTagWidget); + } + + this.addon.configuration().getCustomTags().remove(nameTagWidget.getUserName()); + CustomNameTag customNameTag = nameTagWidget.getCustomTag(); + customNameTag.setCustomName(customTextField.getText()); + customNameTag.setEnabled(enabledWidget.state() == State.CHECKED); + customNameTag.setReplaceScoreboard(replaceWidget.state() == State.CHECKED); + this.addon.configuration().getCustomTags().put(nameTextField.getText(), customNameTag); + this.addon.configuration().removeInvalidNameTags(); + + nameTagWidget.setUserName(nameTextField.getText()); + nameTagWidget.setCustomTag(customNameTag); + this.setAction(null); + + this.updateRequired = true; + }); + + buttonList.addEntry(doneButton); + + buttonList.addEntry(ButtonWidget.i18n("labymod.ui.button.cancel", () -> this.setAction(null))); + inputContainer.addChild(this.inputWidget); + this.inputWidget.addContent(buttonList); + return inputContainer; + } + + private String getStrippedText(String text) { + text = text.trim(); + if (text.isEmpty()) { + return text; + } + + return TEXT_COLOR_STRIPPER.stripColorCodes(text, '&'); + } + + @Override + public boolean mouseClicked(MutableMouse mouse, MouseButton mouseButton) { + try { + if (this.action != null) { + return this.inputWidget.mouseClicked(mouse, mouseButton); + } + + return super.mouseClicked(mouse, mouseButton); + } finally { + this.selectedTool = this.toolList.session().getSelectedEntry(); + this.removeButton.setEnabled(this.selectedTool != null); + this.editButton.setEnabled(this.selectedTool != null); + } + } + + @Override + public boolean keyPressed(Key key, InputType type) { + if (key.getId() == 256 && this.action != null) { + this.setAction(null); + return true; + } + + return super.keyPressed(key, type); + } + + private void setAction(Action action) { + this.action = action; + this.reload(); + } + + @Override + public @Nullable T renew() { + return null; + } + + private enum Action { + ADD, EDIT, REMOVE + } } diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java index b8f7a44..2805be1 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java @@ -2,6 +2,7 @@ import com.rappytv.toolwarn.util.ToolType; import com.rappytv.toolwarn.util.WarnSound; +import com.rappytv.toolwarn.util.WarnTool; import net.labymod.api.client.gui.icon.Icon; import net.labymod.api.client.gui.lss.property.annotation.AutoWidget; import net.labymod.api.client.gui.screen.Parent; @@ -21,12 +22,9 @@ public class ToolWidget extends SimpleWidget { private final boolean openChat; private final boolean lastHitWarn; - public ToolWidget(ToolType toolType, WarnSound warnSound, int warnAt, boolean openChat, boolean lastHitWarn) { + public ToolWidget(ToolType toolType, WarnTool warnTool) { this.toolType = toolType; - this.warnSound = warnSound; - this.warnAt = warnAt; - this.openChat = openChat; - this.lastHitWarn = lastHitWarn; + } @Override diff --git a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java new file mode 100644 index 0000000..d77e4fb --- /dev/null +++ b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java @@ -0,0 +1,18 @@ +package com.rappytv.toolwarn.util; + +public class WarnTool { + + private final ToolType type; + private final WarnSound sound; + private final int warnAt; + private final boolean openChat; + private final boolean lastHitWarn; + + public WarnTool(ToolType type, WarnSound sound, int warnAt, boolean openChat, boolean lastHitWarn) { + this.type = type; + this.sound = sound; + this.warnAt = warnAt; + this.openChat = openChat; + this.lastHitWarn = lastHitWarn; + } +} From 75b7841733545d91698768dd95037de2c7137e1a Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 3 Feb 2024 00:35:36 +0100 Subject: [PATCH 09/53] Progress - 03.02.2024 00:35 --- .../toolwarn/config/TbwConfiguration.java | 13 +- .../toolwarn/listener/GameTickListener.java | 8 +- .../toolwarn/ui/ToolConfigActivity.java | 403 +++++++++--------- .../com/rappytv/toolwarn/ui/ToolWidget.java | 34 +- .../com/rappytv/toolwarn/util/ToolType.java | 43 -- .../com/rappytv/toolwarn/util/WarnTool.java | 122 +++++- .../resources/assets/toolwarn/i18n/en_us.json | 5 + .../toolwarn/themes/vanilla/lss/config.lss | 53 +++ .../toolwarn/themes/vanilla/lss/manage.lss | 126 ++++++ .../toolwarn/themes/vanilla/lss/tool.lss | 45 ++ 10 files changed, 572 insertions(+), 280 deletions(-) delete mode 100644 core/src/main/java/com/rappytv/toolwarn/util/ToolType.java create mode 100644 core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 0f77b19..8c35569 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -2,8 +2,6 @@ import com.rappytv.toolwarn.config.subconfig.TbwSoundSubConfig; import com.rappytv.toolwarn.ui.ToolConfigActivity; -import com.rappytv.toolwarn.ui.ToolWidget; -import com.rappytv.toolwarn.util.ToolType; import com.rappytv.toolwarn.util.WarnTool; import net.labymod.api.addon.AddonConfig; import net.labymod.api.client.gui.screen.activity.Activity; @@ -19,19 +17,22 @@ import net.labymod.api.configuration.loader.property.ConfigProperty; import net.labymod.api.configuration.settings.annotation.SettingSection; import net.labymod.api.util.MethodOrder; -import java.util.HashMap; -import java.util.Map; +import java.util.ArrayList; +import java.util.List; @ConfigName("settings") @SpriteTexture(value = "settings") public class TbwConfiguration extends AddonConfig { @Exclude - private final Map tools = new HashMap<>(); + private final List tools = new ArrayList<>(); - public Map getTools() { + public List getTools() { return tools; } + public void removeInvalidTools() { + + } @SwitchSetting @SpriteSlot(size = 32) diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java index 0e429f2..97cf97f 100644 --- a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java +++ b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java @@ -2,9 +2,9 @@ import com.rappytv.toolwarn.TbwAddon; import com.rappytv.toolwarn.config.TbwConfiguration; -import com.rappytv.toolwarn.util.ToolType; import com.rappytv.toolwarn.util.Util; import com.rappytv.toolwarn.util.WarnSound; +import com.rappytv.toolwarn.util.WarnTool.Type; import net.labymod.api.Laby; import net.labymod.api.client.component.Component; import net.labymod.api.client.component.format.NamedTextColor; @@ -38,11 +38,11 @@ public void onTick(GameTickEvent event) { if(itemStack.getMaximumDamage() == 0) return; if(player.gameMode() != GameMode.SURVIVAL && player.gameMode() != GameMode.ADVENTURE) return; - toolUsed(itemStack, ToolType.getByItem(itemStack)); + toolUsed(itemStack, Type.getByItem(itemStack)); } - public void toolUsed(ItemStack itemStack, ToolType toolType) { - if(toolType == ToolType.None) return; + public void toolUsed(ItemStack itemStack, Type toolType) { + if(toolType == Type.None) return; if(Laby.labyAPI().minecraft().minecraftWindow().isScreenOpened()) return; int itemWarnInt = (toolType.getWarnPercentage(config) * itemStack.getMaximumDamage()) / 100; diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java index bca392f..878af62 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java @@ -1,13 +1,18 @@ package com.rappytv.toolwarn.ui; import com.rappytv.toolwarn.TbwAddon; +import com.rappytv.toolwarn.util.WarnTool; +import com.rappytv.toolwarn.util.WarnTool.Type; import net.labymod.api.Laby; import net.labymod.api.client.component.serializer.legacy.LegacyComponentSerializer; +import net.labymod.api.client.gui.hud.hudwidget.item.ItemHudWidget; import net.labymod.api.client.gui.mouse.MutableMouse; import net.labymod.api.client.gui.screen.LabyScreen; import net.labymod.api.client.gui.screen.Parent; +import net.labymod.api.client.gui.screen.activity.Activity; import net.labymod.api.client.gui.screen.activity.AutoActivity; import net.labymod.api.client.gui.screen.activity.Link; +import net.labymod.api.client.gui.screen.activity.Links; import net.labymod.api.client.gui.screen.activity.types.SimpleActivity; import net.labymod.api.client.gui.screen.key.InputType; import net.labymod.api.client.gui.screen.key.Key; @@ -19,27 +24,26 @@ import net.labymod.api.client.gui.screen.widget.widgets.input.CheckBoxWidget; import net.labymod.api.client.gui.screen.widget.widgets.input.CheckBoxWidget.State; import net.labymod.api.client.gui.screen.widget.widgets.input.TextFieldWidget; +import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.FlexibleContentWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.ScrollWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.list.HorizontalListWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.list.VerticalListWidget; import net.labymod.api.client.gui.screen.widget.widgets.renderer.IconWidget; -import net.labymod.api.client.render.font.TextColorStripper; +import net.labymod.api.client.world.item.ItemStack; +import net.labymod.api.client.world.item.ItemStackFactory; import org.jetbrains.annotations.Nullable; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; +import java.util.ArrayList; +import java.util.List; -@Link("config.lss") +//@SuppressWarnings("deprecation") +@Links({@Link("manage.lss"), @Link("config.lss")}) @AutoActivity -public class ToolConfigActivity extends SimpleActivity { - private static final Pattern NAME_PATTERN = Pattern.compile("[\\w]{0,16}"); - private static final TextColorStripper TEXT_COLOR_STRIPPER = Laby.references() - .textColorStripper(); +public class ToolConfigActivity extends Activity { private final TbwAddon addon; private final VerticalListWidget toolList; - private final Map toolWidgets; + private final List toolWidgets; private ToolWidget selectedTool; @@ -55,17 +59,16 @@ public class ToolConfigActivity extends SimpleActivity { public ToolConfigActivity() { this.addon = TbwAddon.get(); - this.toolWidgets = new HashMap<>(); - this.addon.configuration().getTools().forEach((toolType, customTag) -> { - this.toolWidgets.put(toolType, new ToolWidget(toolType, customTag)); - }); + this.toolWidgets = new ArrayList<>(); + this.addon.configuration().getTools().forEach((tool) -> + this.toolWidgets.add(new ToolWidget(tool)) + ); - this.toolList = new VerticalListWidget<>(); - this.toolList.addId("name-tag-list"); + this.toolList = new VerticalListWidget<>() + .addId("tool-list"); this.toolList.setSelectCallback(nameTagWidget -> { - NameTagWidget selectedNameTag = this.toolList.session().getSelectedEntry(); - if (selectedNameTag == null - || selectedNameTag.getCustomTag() != nameTagWidget.getCustomTag()) { + ToolWidget selectedNameTag = this.toolList.session().getSelectedEntry(); + if (selectedNameTag == null || selectedNameTag.getTool() != nameTagWidget.getTool()) { this.editButton.setEnabled(true); this.removeButton.setEnabled(true); } @@ -78,239 +81,227 @@ public ToolConfigActivity() { public void initialize(Parent parent) { super.initialize(parent); - FlexibleContentWidget container = new FlexibleContentWidget(); - container.addId("name-tag-container"); - for (NameTagWidget nameTagWidget : this.toolWidgets.values()) { + FlexibleContentWidget container = new FlexibleContentWidget() + .addId("tool-container"); + for (ToolWidget nameTagWidget : this.toolWidgets) { this.toolList.addChild(nameTagWidget); } - - container.addFlexibleContent(new ScrollWidget(this.toolList)); - this.selectedTool = this.toolList.session().getSelectedEntry(); - HorizontalListWidget menu = new HorizontalListWidget(); - menu.addId("overview-button-menu"); - menu.addEntry(ButtonWidget.i18n("labymod.ui.button.add", () -> this.setAction(Action.ADD))); - - this.editButton = ButtonWidget.i18n("labymod.ui.button.edit", - () -> this.setAction(Action.EDIT)); + HorizontalListWidget buttons = new HorizontalListWidget() + .addId("overview-button-menu"); + this.editButton = ButtonWidget.i18n("labymod.ui.button.edit", () -> + this.setAction(Action.EDIT) + ); this.editButton.setEnabled(this.selectedTool != null); - menu.addEntry(this.editButton); - - this.removeButton = ButtonWidget.i18n("labymod.ui.button.remove", - () -> this.setAction(Action.REMOVE)); + this.removeButton = ButtonWidget.i18n("labymod.ui.button.remove", () -> + this.setAction(Action.REMOVE) + ); this.removeButton.setEnabled(this.selectedTool != null); - menu.addEntry(this.removeButton); - container.addContent(menu); + buttons.addEntry(ButtonWidget.i18n("labymod.ui.button.add", () -> + this.setAction(Action.ADD)) + ); + buttons.addEntry(this.editButton); + buttons.addEntry(this.removeButton); + + container.addFlexibleContent(new ScrollWidget(this.toolList)); + container.addContent(buttons); this.document().addChild(container); - if (this.action == null) { - return; - } - DivWidget manageContainer = new DivWidget(); - manageContainer.addId("manage-container"); - - Widget overlayWidget; - switch (this.action) { - default: - case ADD: - NameTagWidget newCustomNameTag = new NameTagWidget("", CustomNameTag.createDefault()); - overlayWidget = this.initializeManageContainer(newCustomNameTag); - break; - case EDIT: - overlayWidget = this.initializeManageContainer(this.selectedTool); - break; - case REMOVE: - overlayWidget = this.initializeRemoveContainer(this.selectedTool); - break; - } + if(this.action == null) return; + Widget overlayWidget = switch (this.action) { + default -> { + ToolWidget newCustomNameTag = new ToolWidget(new WarnTool()); + yield this.initializeManageContainer(newCustomNameTag); + } + case EDIT -> this.initializeManageContainer(this.selectedTool); + case REMOVE -> this.initializeRemoveContainer(this.selectedTool); + }; + + DivWidget manageContainer = new DivWidget() + .addId("manage.lss-container"); manageContainer.addChild(overlayWidget); this.document().addChild(manageContainer); } - private FlexibleContentWidget initializeRemoveContainer(NameTagWidget nameTagWidget) { - this.inputWidget = new FlexibleContentWidget(); - this.inputWidget.addId("remove-container"); + private FlexibleContentWidget initializeRemoveContainer(ToolWidget toolWidget) { + this.inputWidget = new FlexibleContentWidget() + .addId("remove-container"); - ComponentWidget confirmationWidget = ComponentWidget.i18n( - "customnametags.gui.manage.remove.title"); - confirmationWidget.addId("remove-confirmation"); - this.inputWidget.addContent(confirmationWidget); + ComponentWidget confirmationWidget = ComponentWidget.i18n("toolwarn.gui.remove") + .addId("remove-confirmation"); - NameTagWidget previewWidget = new NameTagWidget(nameTagWidget.getUserName(), - nameTagWidget.getCustomTag()); + ToolWidget previewWidget = new ToolWidget(toolWidget.getTool()); previewWidget.addId("remove-preview"); - this.inputWidget.addContent(previewWidget); HorizontalListWidget menu = new HorizontalListWidget(); menu.addId("remove-button-menu"); menu.addEntry(ButtonWidget.i18n("labymod.ui.button.remove", () -> { - this.addon.configuration().getCustomTags().remove(nameTagWidget.getUserName()); - this.toolWidgets.remove(nameTagWidget.getUserName()); + this.addon.configuration().getTools().remove(toolWidget.getTool()); + this.toolWidgets.remove(toolWidget); this.toolList.session().setSelectedEntry(null); this.setAction(null); - this.updateRequired = true; })); - menu.addEntry(ButtonWidget.i18n("labymod.ui.button.cancel", () -> this.setAction(null))); + + this.inputWidget.addContent(confirmationWidget); + this.inputWidget.addContent(previewWidget); this.inputWidget.addContent(menu); return this.inputWidget; } - private DivWidget initializeManageContainer(NameTagWidget nameTagWidget) { - TextFieldWidget customTextField = new TextFieldWidget(); + private DivWidget initializeManageContainer(ToolWidget toolWidget) { ButtonWidget doneButton = ButtonWidget.i18n("labymod.ui.button.done"); - DivWidget inputContainer = new DivWidget(); - inputContainer.addId("input-container"); + DivWidget inputContainer = new DivWidget() + .addId("input-container"); - ComponentWidget customNameWidget = ComponentWidget.component( - nameTagWidget.getCustomTag().displayName()); - customNameWidget.addId("custom-preview"); - inputContainer.addChild(customNameWidget); - - this.inputWidget = new FlexibleContentWidget(); - this.inputWidget.addId("input-list"); - - ComponentWidget labelName = ComponentWidget.i18n("customnametags.gui.manage.name"); - labelName.addId("label-name"); - this.inputWidget.addContent(labelName); - - HorizontalListWidget nameList = new HorizontalListWidget(); - nameList.addId("input-name-list"); - - IconWidget iconWidget = new IconWidget( - nameTagWidget.getIconWidget(nameTagWidget.getUserName())); - iconWidget.addId("input-avatar"); - nameList.addEntry(iconWidget); - - TextFieldWidget nameTextField = new TextFieldWidget(); - nameTextField.maximalLength(16); - nameTextField.setText(nameTagWidget.getUserName()); - nameTextField.validator(newValue -> NAME_PATTERN.matcher(newValue).matches()); - nameTextField.updateListener(newValue -> { - doneButton.setEnabled( - !newValue.trim().isEmpty() && !this.getStrippedText(customTextField.getText()).isEmpty() - ); - if (newValue.equals(this.lastUserName)) { - return; - } - - this.lastUserName = newValue; - iconWidget.icon().set(nameTagWidget.getIconWidget(newValue)); - }); + IconWidget toolIconWidget = new IconWidget(toolWidget.getTool().getType().getIcon()) + .addId("tool-icon"); - nameList.addEntry(nameTextField); - this.inputWidget.addContent(nameList); - - ComponentWidget labelCustomName = ComponentWidget.i18n("customnametags.gui.manage.custom.name"); - labelCustomName.addId("label-name"); - this.inputWidget.addContent(labelCustomName); - - HorizontalListWidget customNameList = new HorizontalListWidget(); - customNameList.addId("input-name-list"); - - DivWidget placeHolder = new DivWidget(); - placeHolder.addId("input-avatar"); - customNameList.addEntry(placeHolder); - - customTextField.maximalLength(64); - customTextField.setText(nameTagWidget.getCustomTag().getCustomName()); - customTextField.updateListener(newValue -> { - doneButton.setEnabled( - !this.getStrippedText(newValue).isEmpty() && !nameTextField.getText().trim().isEmpty() - ); - if (newValue.equals(this.lastCustomName)) { - return; - } - - this.lastCustomName = newValue; - customNameWidget.setComponent( - LegacyComponentSerializer.legacyAmpersand().deserialize(newValue)); + DropdownWidget typeDropdown = new DropdownWidget<>() + .addId("type-dropdown"); + for(WarnTool.Type type : WarnTool.Type.values()) { + if(type == Type.None) continue; + typeDropdown.add(type); + } + typeDropdown.setSelected(toolWidget.getTool().getType()); + typeDropdown.setChangeListener((type) -> { + // Update toolIcon to type.getIcon() }); - customNameList.addEntry(customTextField); - this.inputWidget.addContent(customNameList); - - HorizontalListWidget checkBoxList = new HorizontalListWidget(); - checkBoxList.addId("checkbox-list"); - - DivWidget enabledDiv = new DivWidget(); - enabledDiv.addId("checkbox-div"); - - ComponentWidget enabledText = ComponentWidget.i18n("customnametags.gui.manage.enabled.name"); - enabledText.addId("checkbox-name"); - enabledDiv.addChild(enabledText); - - CheckBoxWidget enabledWidget = new CheckBoxWidget(); - enabledWidget.addId("checkbox-item"); - enabledWidget.setState( - nameTagWidget.getCustomTag().isEnabled() ? State.CHECKED : State.UNCHECKED); - enabledDiv.addChild(enabledWidget); - checkBoxList.addEntry(enabledDiv); - - DivWidget replaceDiv = new DivWidget(); - replaceDiv.addId("checkbox-div"); - - ComponentWidget replaceText = ComponentWidget.i18n("customnametags.gui.manage.replace.name"); - replaceText.addId("checkbox-name"); - replaceDiv.addChild(replaceText); - - CheckBoxWidget replaceWidget = new CheckBoxWidget(); - replaceWidget.addId("checkbox-item"); - replaceWidget.setState( - nameTagWidget.getCustomTag().isReplaceScoreboard() ? State.CHECKED : State.UNCHECKED); - replaceDiv.addChild(replaceWidget); - checkBoxList.addEntry(replaceDiv); - this.inputWidget.addContent(checkBoxList); - - HorizontalListWidget buttonList = new HorizontalListWidget(); - buttonList.addId("edit-button-menu"); +// ComponentWidget customNameWidget = ComponentWidget.component(toolWidget.getCustomTag().displayName()); +// customNameWidget.addId("custom-preview"); +// inputContainer.addChild(customNameWidget); - doneButton.setEnabled( - !nameTextField.getText().trim().isEmpty() && !this.getStrippedText( - customTextField.getText()).isEmpty() - ); + this.inputWidget = new FlexibleContentWidget(); + this.inputWidget.addId("input-list"); +// +// ComponentWidget labelName = ComponentWidget.i18n("toolwarn.gui.name"); +// labelName.addId("label-name"); +// this.inputWidget.addContent(labelName); +// +// HorizontalListWidget nameList = new HorizontalListWidget(); +// nameList.addId("input-name-list"); +// +// IconWidget iconWidget = new IconWidget( +// toolWidget.getIconWidget(toolWidget.getUserName())); +// iconWidget.addId("input-avatar"); +// nameList.addEntry(iconWidget); +// +// TextFieldWidget nameTextField = new TextFieldWidget(); +// nameTextField.maximalLength(16); +// nameTextField.setText(toolWidget.getUserName()); +// nameTextField.validator(newValue -> NAME_PATTERN.matcher(newValue).matches()); +// nameTextField.updateListener(newValue -> { +// doneButton.setEnabled( +// !newValue.trim().isEmpty() && !this.getStrippedText(customTextField.getText()).isEmpty() +// ); +// if (newValue.equals(this.lastUserName)) { +// return; +// } +// +// this.lastUserName = newValue; +// iconWidget.icon().set(toolWidget.getIconWidget(newValue)); +// }); +// +// nameList.addEntry(nameTextField); +// this.inputWidget.addContent(nameList); +// +// ComponentWidget labelCustomName = ComponentWidget.i18n("customnametags.gui.manage.lss.custom.name"); +// labelCustomName.addId("label-name"); +// this.inputWidget.addContent(labelCustomName); +// +// HorizontalListWidget customNameList = new HorizontalListWidget(); +// customNameList.addId("input-name-list"); +// +// DivWidget placeHolder = new DivWidget(); +// placeHolder.addId("input-avatar"); +// customNameList.addEntry(placeHolder); +// +// TextFieldWidget customTextField = new TextFieldWidget(); +// customTextField.maximalLength(64); +// customTextField.setText(toolWidget.getCustomTag().getCustomName()); +// customTextField.updateListener(newValue -> { +// doneButton.setEnabled( +// !this.getStrippedText(newValue).isEmpty() && !nameTextField.getText().trim().isEmpty() +// ); +// if (newValue.equals(this.lastCustomName)) { +// return; +// } +// +// this.lastCustomName = newValue; +// customNameWidget.setComponent( +// LegacyComponentSerializer.legacyAmpersand().deserialize(newValue)); +// }); +// +// customNameList.addEntry(customTextField); +// this.inputWidget.addContent(customNameList); +// +// HorizontalListWidget checkBoxList = new HorizontalListWidget(); +// checkBoxList.addId("checkbox-list"); +// +// DivWidget enabledDiv = new DivWidget(); +// enabledDiv.addId("checkbox-div"); +// +// ComponentWidget enabledText = ComponentWidget.i18n("customnametags.gui.manage.lss.enabled.name"); +// enabledText.addId("checkbox-name"); +// enabledDiv.addChild(enabledText); +// +// CheckBoxWidget enabledWidget = new CheckBoxWidget(); +// enabledWidget.addId("checkbox-item"); +// enabledWidget.setState( +// toolWidget.getCustomTag().isEnabled() ? State.CHECKED : State.UNCHECKED); +// enabledDiv.addChild(enabledWidget); +// checkBoxList.addEntry(enabledDiv); +// +// DivWidget replaceDiv = new DivWidget(); +// replaceDiv.addId("checkbox-div"); +// +// ComponentWidget replaceText = ComponentWidget.i18n("customnametags.gui.manage.lss.replace.name"); +// replaceText.addId("checkbox-name"); +// replaceDiv.addChild(replaceText); +// +// CheckBoxWidget replaceWidget = new CheckBoxWidget(); +// replaceWidget.addId("checkbox-item"); +// replaceWidget.setState( +// toolWidget.getCustomTag().isReplaceScoreboard() ? State.CHECKED : State.UNCHECKED); +// replaceDiv.addChild(replaceWidget); +// checkBoxList.addEntry(replaceDiv); +// this.inputWidget.addContent(checkBoxList); + + HorizontalListWidget buttonList = new HorizontalListWidget() + .addId("edit-button-menu"); + + doneButton.setEnabled(true); doneButton.setPressable(() -> { - if (nameTagWidget.getUserName().length() == 0) { - this.toolWidgets.put(nameTextField.getText(), nameTagWidget); - this.toolList.session().setSelectedEntry(nameTagWidget); - } - - this.addon.configuration().getCustomTags().remove(nameTagWidget.getUserName()); - CustomNameTag customNameTag = nameTagWidget.getCustomTag(); - customNameTag.setCustomName(customTextField.getText()); - customNameTag.setEnabled(enabledWidget.state() == State.CHECKED); - customNameTag.setReplaceScoreboard(replaceWidget.state() == State.CHECKED); - this.addon.configuration().getCustomTags().put(nameTextField.getText(), customNameTag); - this.addon.configuration().removeInvalidNameTags(); - - nameTagWidget.setUserName(nameTextField.getText()); - nameTagWidget.setCustomTag(customNameTag); +// if (toolWidget.getUserName().length() == 0) { +// this.toolWidgets.put(nameTextField.getText(), toolWidget); +// this.toolList.session().setSelectedEntry(toolWidget); +// } + + WarnTool tool = toolWidget.getTool(); + tool.setType(typeDropdown.getSelected()); + this.addon.configuration().getTools().remove(toolWidget.getTool()); + this.addon.configuration().getTools().add(tool); + this.addon.configuration().removeInvalidTools(); + + toolWidget.setTool(tool); this.setAction(null); - - this.updateRequired = true; }); buttonList.addEntry(doneButton); - buttonList.addEntry(ButtonWidget.i18n("labymod.ui.button.cancel", () -> this.setAction(null))); - inputContainer.addChild(this.inputWidget); this.inputWidget.addContent(buttonList); - return inputContainer; - } - private String getStrippedText(String text) { - text = text.trim(); - if (text.isEmpty()) { - return text; - } - - return TEXT_COLOR_STRIPPER.stripColorCodes(text, '&'); + inputContainer.addChild(toolIconWidget); + inputContainer.addChild(typeDropdown); + inputContainer.addChild(this.inputWidget); + return inputContainer; } @Override diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java index 2805be1..52055d2 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java @@ -1,8 +1,7 @@ package com.rappytv.toolwarn.ui; -import com.rappytv.toolwarn.util.ToolType; -import com.rappytv.toolwarn.util.WarnSound; import com.rappytv.toolwarn.util.WarnTool; +import net.labymod.api.Laby; import net.labymod.api.client.gui.icon.Icon; import net.labymod.api.client.gui.lss.property.annotation.AutoWidget; import net.labymod.api.client.gui.screen.Parent; @@ -10,37 +9,42 @@ import net.labymod.api.client.gui.screen.widget.SimpleWidget; import net.labymod.api.client.gui.screen.widget.widgets.ComponentWidget; import net.labymod.api.client.gui.screen.widget.widgets.renderer.IconWidget; -import net.labymod.api.client.resources.ResourceLocation; @Link("tool.lss") @AutoWidget public class ToolWidget extends SimpleWidget { - private final ToolType toolType; - private final WarnSound warnSound; - private final int warnAt; - private final boolean openChat; - private final boolean lastHitWarn; - - public ToolWidget(ToolType toolType, WarnTool warnTool) { - this.toolType = toolType; + private WarnTool tool; + public ToolWidget(WarnTool tool) { + this.tool = tool; } @Override public void initialize(Parent parent) { super.initialize(parent); - IconWidget iconWidget = new IconWidget(Icon.texture(ResourceLocation.create("minecraft", ""))) + IconWidget iconWidget = new IconWidget(Icon.head(Laby.labyAPI().getUniqueId())) .addId("tool-icon"); - ComponentWidget nameWidget = ComponentWidget.text(this.toolType.name()) + ComponentWidget nameWidget = ComponentWidget.text(tool.getType().name()) .addId("name-component"); - ComponentWidget meta = ComponentWidget.i18n("", warnAt, warnSound, openChat, lastHitWarn) - .addId("meta-component"); + ComponentWidget meta = ComponentWidget.i18n( + "toolwarn.gui.meta", + tool.getWarnAt(), + tool.openChat() ? "§a✔§r" : "§c✘§r", + tool.lastHitWarn() ? "§a✔§r" : "§c✘§r" + ).addId("meta-component"); this.addChild(iconWidget); this.addChild(nameWidget); this.addChild(meta); } + + public WarnTool getTool() { + return tool; + } + public void setTool(WarnTool tool) { + this.tool = tool; + } } diff --git a/core/src/main/java/com/rappytv/toolwarn/util/ToolType.java b/core/src/main/java/com/rappytv/toolwarn/util/ToolType.java deleted file mode 100644 index d71b562..0000000 --- a/core/src/main/java/com/rappytv/toolwarn/util/ToolType.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.rappytv.toolwarn.util; - -import com.rappytv.toolwarn.config.TbwConfiguration; -import net.labymod.api.client.world.item.ItemStack; - -public enum ToolType { - None, Sword, Pickaxe, Axe, Shovel, Crossbow, Lighter, Shears, Trident; - - public static ToolType getByItem(ItemStack itemStack) { - String path = itemStack.getIdentifier().getPath(); - if(path.endsWith("_sword")) - return Sword; - else if(path.endsWith("_pickaxe")) - return Pickaxe; - else if(path.endsWith("_axe")) - return Axe; - else if(path.endsWith("_shovel")) - return Shovel; - else if(path.equalsIgnoreCase("crossbow")) - return Crossbow; - else if(path.equalsIgnoreCase("flint_and_steel")) - return Lighter; - else if(path.equalsIgnoreCase("shears")) - return Shears; - else if(path.equalsIgnoreCase("trident")) - return Trident; - return None; - } - - public int getWarnPercentage(TbwConfiguration configuration) { - return switch (this) { - case Sword -> configuration.swordPercentage().get(); - case Pickaxe -> configuration.pickAxePercentage().get(); - case Axe -> configuration.axePercentage().get(); - case Shovel -> configuration.shovelPercentage().get(); - case Crossbow -> configuration.crossbowPercentage().get(); - case Lighter -> configuration.lighterPercentage().get(); - case Shears -> configuration.shearsPercentage().get(); - case Trident -> configuration.tridentPercentage().get(); - default -> -1; - }; - } -} diff --git a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java index d77e4fb..9bdf33c 100644 --- a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java +++ b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java @@ -1,18 +1,128 @@ package com.rappytv.toolwarn.util; +import com.rappytv.toolwarn.config.TbwConfiguration; +import net.labymod.api.client.gui.icon.Icon; +import net.labymod.api.client.resources.ResourceLocation; +import net.labymod.api.client.world.item.ItemStack; + public class WarnTool { - private final ToolType type; - private final WarnSound sound; - private final int warnAt; - private final boolean openChat; - private final boolean lastHitWarn; + private Type type; + private WarnSound sound; + private WarnSound lastSound; + private int warnAt; + private boolean openChat; + private boolean lastHitWarn; + + public WarnTool() { + this(Type.Sword, WarnSound.NONE, WarnSound.NONE, 5, true, true); + } - public WarnTool(ToolType type, WarnSound sound, int warnAt, boolean openChat, boolean lastHitWarn) { + public WarnTool(Type type, WarnSound sound, WarnSound lastSound, int warnAt, boolean openChat, boolean lastHitWarn) { this.type = type; this.sound = sound; + this.lastSound = lastSound; this.warnAt = warnAt; this.openChat = openChat; this.lastHitWarn = lastHitWarn; } + + public Type getType() { + return type; + } + public WarnSound getSound() { + return sound; + } + public WarnSound getLastSound() { + return lastSound; + } + public int getWarnAt() { + return warnAt; + } + public boolean openChat() { + return openChat; + } + public boolean lastHitWarn() { + return lastHitWarn; + } + + public void setType(Type type) { + this.type = type; + } + public void setSound(WarnSound sound) { + this.sound = sound; + } + public void setLastSound(WarnSound lastSound) { + this.lastSound = lastSound; + } + public void setWarnAt(int warnAt) { + this.warnAt = warnAt; + } + public void setOpenChat(boolean openChat) { + this.openChat = openChat; + } + public void setLastHitWarn(boolean lastHitWarn) { + this.lastHitWarn = lastHitWarn; + } + + public enum Type { + None(-1, -1), + Sword(0, 0), + Pickaxe(0, 1), + Axe(0, 2), + Shovel(0, 3), + Crossbow(1, 0), + Lighter(1, 1), + Shears(1, 2), + Trident(1, 3); + + private final ResourceLocation sprite = ResourceLocation.create("toolwarn", "textures/tools.png"); + private final int x; + private final int y; + + Type(int x, int y) { + this.x = x; + this.y = y; + } + + public Icon getIcon() { + return Icon.sprite32(sprite, x, y); + } + + public static Type getByItem(ItemStack itemStack) { + String path = itemStack.getIdentifier().getPath(); + if (path.endsWith("_sword")) { + return Sword; + } else if (path.endsWith("_pickaxe")) { + return Pickaxe; + } else if (path.endsWith("_axe")) { + return Axe; + } else if (path.endsWith("_shovel")) { + return Shovel; + } else if (path.equalsIgnoreCase("crossbow")) { + return Crossbow; + } else if (path.equalsIgnoreCase("flint_and_steel")) { + return Lighter; + } else if (path.equalsIgnoreCase("shears")) { + return Shears; + } else if (path.equalsIgnoreCase("trident")) { + return Trident; + } + return None; + } + + public int getWarnPercentage(TbwConfiguration configuration) { + return switch (this) { + case Sword -> configuration.swordPercentage().get(); + case Pickaxe -> configuration.pickAxePercentage().get(); + case Axe -> configuration.axePercentage().get(); + case Shovel -> configuration.shovelPercentage().get(); + case Crossbow -> configuration.crossbowPercentage().get(); + case Lighter -> configuration.lighterPercentage().get(); + case Shears -> configuration.shearsPercentage().get(); + case Trident -> configuration.tridentPercentage().get(); + default -> -1; + }; + } + } } diff --git a/core/src/main/resources/assets/toolwarn/i18n/en_us.json b/core/src/main/resources/assets/toolwarn/i18n/en_us.json index 2cff646..7924858 100644 --- a/core/src/main/resources/assets/toolwarn/i18n/en_us.json +++ b/core/src/main/resources/assets/toolwarn/i18n/en_us.json @@ -79,6 +79,11 @@ "messages": { "lastHit": "You should stop using this tool now, this is your last hit!", "warning": "Do you really want to continue using this tool? Its durability is at %s%%!" + }, + "gui": { + "meta": "%s%% • Chat: %s • Last hit: %s", + "add": "Add a new tool configuration", + "remove": "Do you really want to remove this entry?" } } } \ No newline at end of file diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss index e69de29..af1905d 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss @@ -0,0 +1,53 @@ +.tool-container { + width: 100%; + height: 100%; + left: 0; + top: 0; + + Scroll { + width: 90%; + top: 0; + bottom: 0; + margin-top: 5; + margin-bottom: 5; + left: 50%; + alignment-x: center; + + .tool-list { + left: 0; + top: 0; + height: fit-content; + space-between-entries: 2; + selectable: true; + } + + Scrollbar { + left: 0; + top: 0; + width: 5; + height: 100%; + margin-left: 5; + } + } +} + +.overview-button-menu { + width: 90%; + height: 20; + left: 50%; + alignment-x: center; + bottom: 5; + layout: fill; + space-between-entries: 8; + margin-bottom: 5; +} + +.edit-button-menu { + width: 90%; + height: 20; + left: 50%; + alignment-x: center; + bottom: 0; + layout: fill; + space-between-entries: 8; +} \ No newline at end of file diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss new file mode 100644 index 0000000..840b805 --- /dev/null +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss @@ -0,0 +1,126 @@ +TextField { + top: 0; + left: 0; + height: 20; + width: 100%; + margin: 2 40 5 5; +} + +.manage-container { + top: 0; + left: 0; + width: 100%; + height: 100%; + clear-depth: true; + + .input-container { + width: 90%; + height: 165; + left: 50%; + top: 47%; + alignment-x: center; + alignment-y: center; + + background-color: rgba(20, 20, 20, 150); + padding: 10; + + .custom-preview { + top: 5; + left: 50%; + alignment-x: center; + font-size: 1.5; + padding: 2 3 2 3; + background-color: black; + min-width: 11; + max-width: 100%; + } + + .input-list { + left: 0; + top: 30; + width: 100%; + bottom: 0; + } + } +} + +.input-name-list { + left: 0; + height: 30; + width: 100%; +} + +.input-avatar { + margin-top: -4; + top: 0; + left: 2; + width: 16; + height: width; +} + +.label-name { + margin-left: 21; +} + +.remove-container { + width: 90%; + height: fit-content; + left: 50%; + top: 50%; + alignment-x: center; + alignment-y: center; + space-between-entries: 15; + + background-color: rgba(20, 20, 20, 150); + padding: 10; +} + +.remove-confirmation { + left: 50%; + alignment-x: center; +} + +.remove-preview { + left: 50%; + alignment-x: center; + height: 24; + width: 100%; +} + +.remove-button-menu { + left: 50%; + alignment-x: center; + height: 20; + layout: fill; + space-between-entries: 8; + width: 90%; +} + +.checkbox-list { + left: 0; + width: 90%; + height: 35; + left: 50%; + alignment-x: center; +} + +.checkbox-div { + top: 0; + height: 100%; + width: 50%; +} + +.checkbox-name { + top: 0; + left: 50%; + alignment-x: center; + font-size: 0.8; +} + +.checkbox-item { + top: 10; + width: 20; + height: 20; + left: 50%; + alignment-x: center; +} diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss index e69de29..c30304f 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss @@ -0,0 +1,45 @@ +Tool { + width: 100%; + height: 24; + padding: 1; + + .tool-icon { + left: 4; + top: 2; + width: 16; + height: width; + clickable: true; + + margin-top: 2; + } + + .name-component { + left: 22; + top: 2; + } + + .meta-component { + left: 22; + top: 13; + } + + &:selected { + padding: 0; + border: 1 gray; + background-color: black; + } + + &.disabled { + .avatar { + opacity: 0.5; + } + + .name { + opacity: 0.5; + } + + .custom-name { + opacity: 0.5; + } + } +} \ No newline at end of file From 90242a859c305d1fa842639bb1371ba8b6455c0f Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 3 Feb 2024 17:57:42 +0100 Subject: [PATCH 10/53] Delete own tool lss file --- .../toolwarn/themes/vanilla/lss/config.lss | 32 +++++++++++++ .../toolwarn/themes/vanilla/lss/tool.lss | 45 ------------------- 2 files changed, 32 insertions(+), 45 deletions(-) delete mode 100644 core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss index af1905d..a79ba02 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss @@ -50,4 +50,36 @@ bottom: 0; layout: fill; space-between-entries: 8; +} + +Tool { + width: 100%; + height: 24; + padding: 1; + + .tool-icon { + left: 4; + top: 2; + width: 16; + height: width; + clickable: true; + + margin-top: 2; + } + + .name-component { + left: 22; + top: 2; + } + + .meta-component { + left: 22; + top: 13; + } + + &:selected { + padding: 0; + border: 1 gray; + background-color: black; + } } \ No newline at end of file diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss deleted file mode 100644 index c30304f..0000000 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/tool.lss +++ /dev/null @@ -1,45 +0,0 @@ -Tool { - width: 100%; - height: 24; - padding: 1; - - .tool-icon { - left: 4; - top: 2; - width: 16; - height: width; - clickable: true; - - margin-top: 2; - } - - .name-component { - left: 22; - top: 2; - } - - .meta-component { - left: 22; - top: 13; - } - - &:selected { - padding: 0; - border: 1 gray; - background-color: black; - } - - &.disabled { - .avatar { - opacity: 0.5; - } - - .name { - opacity: 0.5; - } - - .custom-name { - opacity: 0.5; - } - } -} \ No newline at end of file From f2701d3cc17cc9e3ac8c281f757f600a9ef7a9a0 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 3 Feb 2024 17:58:46 +0100 Subject: [PATCH 11/53] Add own tool spritesheet, fix ToolWidget meta line --- .../com/rappytv/toolwarn/ui/ToolWidget.java | 17 +++++++---------- .../assets/toolwarn/textures/tools.png | Bin 0 -> 5763 bytes 2 files changed, 7 insertions(+), 10 deletions(-) create mode 100644 core/src/main/resources/assets/toolwarn/textures/tools.png diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java index 52055d2..8c4ba52 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java @@ -1,16 +1,13 @@ package com.rappytv.toolwarn.ui; import com.rappytv.toolwarn.util.WarnTool; -import net.labymod.api.Laby; -import net.labymod.api.client.gui.icon.Icon; import net.labymod.api.client.gui.lss.property.annotation.AutoWidget; import net.labymod.api.client.gui.screen.Parent; -import net.labymod.api.client.gui.screen.activity.Link; import net.labymod.api.client.gui.screen.widget.SimpleWidget; import net.labymod.api.client.gui.screen.widget.widgets.ComponentWidget; import net.labymod.api.client.gui.screen.widget.widgets.renderer.IconWidget; +import net.labymod.api.util.I18n; -@Link("tool.lss") @AutoWidget public class ToolWidget extends SimpleWidget { @@ -23,18 +20,18 @@ public ToolWidget(WarnTool tool) { @Override public void initialize(Parent parent) { super.initialize(parent); - IconWidget iconWidget = new IconWidget(Icon.head(Laby.labyAPI().getUniqueId())) + IconWidget iconWidget = new IconWidget(tool.getType().getIcon()) .addId("tool-icon"); ComponentWidget nameWidget = ComponentWidget.text(tool.getType().name()) .addId("name-component"); - ComponentWidget meta = ComponentWidget.i18n( + ComponentWidget meta = ComponentWidget.text(I18n.translate( "toolwarn.gui.meta", - tool.getWarnAt(), - tool.openChat() ? "§a✔§r" : "§c✘§r", - tool.lastHitWarn() ? "§a✔§r" : "§c✘§r" - ).addId("meta-component"); + tool.getWarnAt(), + tool.openChat() ? "§a✔§r" : "§c✘§r", + tool.lastHitWarn() ? "§a✔§r" : "§c✘§r" + )).addId("meta-component"); this.addChild(iconWidget); this.addChild(nameWidget); diff --git a/core/src/main/resources/assets/toolwarn/textures/tools.png b/core/src/main/resources/assets/toolwarn/textures/tools.png new file mode 100644 index 0000000000000000000000000000000000000000..a7f36dafe0a655fc607199cb5c43521dd6070275 GIT binary patch literal 5763 zcmeHLX;@R|w%!2+l_FNFwpbwz_Mk^MnRa#(AOsLaYy;S$AZlUnWCy~KU=j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CSH2QPH`g)A%RM#G4$DOxAs$b$2MIdq8`&IGxdz8xT|)5UsmkrM{4(xtiDw0>$4-RzK zZ|BeQ-xhnis&v;Jn}ZtZHND;KDepZT#e*Pe#YoYe+KM{fg{F4W_4I3cvj>{M(!AoA zYSqlX3&vAiCnv00ZrKP3l$?37CA&H*vajHfcIC^f7QG2_7fbpF(>I%Rz)yXhy_xTMi2*;84qv}xHnyNPDS z(&A)wO(KsKzksJR7cYEISpTah|1bw>>E)1OjGWi+2SR&Fnm0Rj zb)kA=N=iyy8Bpifv#BWCZrvs190e2&yZInnmfBHQ=QoqO?f&iZ=j|EwHj_3zw4fHh z7&$S0)WQflv9_c`@75a|+_HVI9pi&l9tXG1l=R*64}%iF+ToNudbshtu04enUBBK) z5^FT$&glA5y*q4mMQzYI7#Kd}C4^C)SC|C#?c!CnYSvr`n>-v|nZXk~vRE@OSxlLE zzpE1&+LU#;c!xKDEDkT#MUPhUcjvbB-Z*c2`q`J(^k!dA&-H7aXVf^JEov)EicPv< zwkO^E=h&YDGue5c_l=Z~qBhHcC-BSJ5mWCo-!Ak`&5zxkyhd;85?7%W{k*5D$#=s5S&ubIB{wn>iZYvW`WrHwYtu|CqVNHAW1q8e zITYb_XS+ouXd*E$u4RvY^VDMw(tFu!Z&%W?B!lWda!z_xct)RM<6d6pt1l{>TAmTE zI@+&sMo@HLbc5R#ua@eiEbS?qh*g@toaZTnvf1$bIHApVdR?n3bR?H+jR=!wK$b^9 z#jY?SPcj;v$ns3Lzt{CD*YlV9Q^rQnGYYlt{R!x8}*tkz!4`+6vQHw&d<{DkO-0wKpZ=(+& ziPe^A)$CXF;KrgEGg6w1e(mW#1_*$I!!S#s&9~FPS6e~t+dg`GpuCx}3<(9;i literal 0 HcmV?d00001 From 4adb3f680d062d585534eae500773747a11825f2 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 3 Feb 2024 19:16:22 +0100 Subject: [PATCH 12/53] Fix WarnTool SpriteTextures --- .../java/com/rappytv/toolwarn/util/WarnTool.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java index 9bdf33c..b83df57 100644 --- a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java +++ b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java @@ -68,13 +68,13 @@ public void setLastHitWarn(boolean lastHitWarn) { public enum Type { None(-1, -1), Sword(0, 0), - Pickaxe(0, 1), - Axe(0, 2), - Shovel(0, 3), - Crossbow(1, 0), + Pickaxe(1, 0), + Axe(2, 0), + Shovel(3, 0), + Crossbow(0, 1), Lighter(1, 1), - Shears(1, 2), - Trident(1, 3); + Shears(2, 1), + Trident(3, 1); private final ResourceLocation sprite = ResourceLocation.create("toolwarn", "textures/tools.png"); private final int x; From 3cfe4aeefe96d5e21935fe7633bd88b39eb21255 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 3 Feb 2024 23:40:36 +0100 Subject: [PATCH 13/53] Add gui translations --- .../main/resources/assets/toolwarn/i18n/en_us.json | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/assets/toolwarn/i18n/en_us.json b/core/src/main/resources/assets/toolwarn/i18n/en_us.json index 7924858..9ecfc21 100644 --- a/core/src/main/resources/assets/toolwarn/i18n/en_us.json +++ b/core/src/main/resources/assets/toolwarn/i18n/en_us.json @@ -81,9 +81,19 @@ "warning": "Do you really want to continue using this tool? Its durability is at %s%%!" }, "gui": { - "meta": "%s%% • Chat: %s • Last hit: %s", + "meta": "Warn at: %s%% • Chat: %s • Last hit: %s", "add": "Add a new tool configuration", - "remove": "Do you really want to remove this entry?" + "remove": "Do you really want to remove this entry?", + "checkbox": { + "openChat": "Open chat", + "lastHit": "Last hit warning" + }, + "dropdown": { + "sound": "Warn sound", + "lastSound": "Last hit warn sound" + }, + "slider": "Warning durability (in %)", + "type": "Tool type" } } } \ No newline at end of file From a139c22ee18a02a82c6ca46e22a63538e78a22dd Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 3 Feb 2024 23:41:37 +0100 Subject: [PATCH 14/53] Another Activity structure update --- .../toolwarn/ui/ToolConfigActivity.java | 105 +++++++++++++++--- 1 file changed, 87 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java index 878af62..656bbc6 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java @@ -1,11 +1,9 @@ package com.rappytv.toolwarn.ui; import com.rappytv.toolwarn.TbwAddon; +import com.rappytv.toolwarn.util.WarnSound; import com.rappytv.toolwarn.util.WarnTool; import com.rappytv.toolwarn.util.WarnTool.Type; -import net.labymod.api.Laby; -import net.labymod.api.client.component.serializer.legacy.LegacyComponentSerializer; -import net.labymod.api.client.gui.hud.hudwidget.item.ItemHudWidget; import net.labymod.api.client.gui.mouse.MutableMouse; import net.labymod.api.client.gui.screen.LabyScreen; import net.labymod.api.client.gui.screen.Parent; @@ -13,7 +11,6 @@ import net.labymod.api.client.gui.screen.activity.AutoActivity; import net.labymod.api.client.gui.screen.activity.Link; import net.labymod.api.client.gui.screen.activity.Links; -import net.labymod.api.client.gui.screen.activity.types.SimpleActivity; import net.labymod.api.client.gui.screen.key.InputType; import net.labymod.api.client.gui.screen.key.Key; import net.labymod.api.client.gui.screen.key.MouseButton; @@ -23,20 +20,18 @@ import net.labymod.api.client.gui.screen.widget.widgets.input.ButtonWidget; import net.labymod.api.client.gui.screen.widget.widgets.input.CheckBoxWidget; import net.labymod.api.client.gui.screen.widget.widgets.input.CheckBoxWidget.State; -import net.labymod.api.client.gui.screen.widget.widgets.input.TextFieldWidget; +import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget; import net.labymod.api.client.gui.screen.widget.widgets.input.dropdown.DropdownWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.FlexibleContentWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.ScrollWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.list.HorizontalListWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.list.VerticalListWidget; import net.labymod.api.client.gui.screen.widget.widgets.renderer.IconWidget; -import net.labymod.api.client.world.item.ItemStack; -import net.labymod.api.client.world.item.ItemStackFactory; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; -//@SuppressWarnings("deprecation") +@SuppressWarnings("deprecation") @Links({@Link("manage.lss"), @Link("config.lss")}) @AutoActivity public class ToolConfigActivity extends Activity { @@ -51,8 +46,6 @@ public class ToolConfigActivity extends Activity { private ButtonWidget editButton; private FlexibleContentWidget inputWidget; - private String lastUserName; - private String lastCustomName; private Action action; @@ -121,7 +114,7 @@ public void initialize(Parent parent) { }; DivWidget manageContainer = new DivWidget() - .addId("manage.lss-container"); + .addId("manage-container"); manageContainer.addChild(overlayWidget); this.document().addChild(manageContainer); } @@ -174,6 +167,66 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { // Update toolIcon to type.getIcon() }); + ComponentWidget sliderText = ComponentWidget.i18n("toolwarn.gui.slider") + .addId("slider-name"); + + SliderWidget warnSlider = new SliderWidget() + .addId("warn-slider"); + warnSlider.range(1, 25); + warnSlider.setValue(toolWidget.getTool().getWarnAt()); + + DivWidget soundDiv = new DivWidget() + .addId("dropdown-div"); + DivWidget lastSoundDiv = new DivWidget() + .addId("dropdown-div"); + + ComponentWidget soundText = ComponentWidget.i18n("toolwarn.gui.dropdown.sound") + .addId("dropdown-name"); + + DropdownWidget soundDropdown = new DropdownWidget<>() + .addId("dropdown-item"); + + ComponentWidget lastSoundText = ComponentWidget.i18n("toolwarn.gui.dropdown.lastSound") + .addId("dropdown-name"); + + DropdownWidget lastSoundDropdown = new DropdownWidget<>() + .addId("dropdown-item"); + + soundDiv.addChild(soundText); + soundDiv.addChild(soundDropdown); + lastSoundDiv.addChild(lastSoundText); + lastSoundDiv.addChild(lastSoundDropdown); + + for(WarnSound sound : WarnSound.values()) { + soundDropdown.add(sound); + lastSoundDropdown.add(sound); + } + soundDropdown.setSelected(toolWidget.getTool().getSound()); + lastSoundDropdown.setSelected(toolWidget.getTool().getLastSound()); + + DivWidget openChatDiv = new DivWidget() + .addId("checkbox-div"); + DivWidget lastHitDiv = new DivWidget() + .addId("checkbox-div"); + + ComponentWidget openChatText = ComponentWidget.i18n("toolwarn.gui.checkbox.openChat") + .addId("checkbox-name"); + + CheckBoxWidget openChatCheck = new CheckBoxWidget() + .addId("checkbox-item"); + openChatCheck.setState(toolWidget.getTool().openChat() ? State.CHECKED : State.UNCHECKED); + + ComponentWidget lastHitText = ComponentWidget.i18n("toolwarn.gui.checkbox.lastHit") + .addId("checkbox-name"); + + CheckBoxWidget lastHitCheck = new CheckBoxWidget() + .addId("checkbox-item"); + lastHitCheck.setState(toolWidget.getTool().lastHitWarn() ? State.CHECKED : State.UNCHECKED); + + openChatDiv.addChild(openChatText); + openChatDiv.addChild(openChatCheck); + lastHitDiv.addChild(lastHitText); + lastHitDiv.addChild(lastHitCheck); // ComponentWidget customNameWidget = ComponentWidget.component(toolWidget.getCustomTag().displayName()); // customNameWidget.addId("custom-preview"); // inputContainer.addChild(customNameWidget); @@ -274,32 +327,48 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { // checkBoxList.addEntry(replaceDiv); // this.inputWidget.addContent(checkBoxList); + HorizontalListWidget dropdownList = new HorizontalListWidget() + .addId("dropdown-list"); + dropdownList.addEntry(soundDiv); + dropdownList.addEntry(lastSoundDiv); + + HorizontalListWidget checkBoxList = new HorizontalListWidget() + .addId("checkbox-list"); + checkBoxList.addEntry(openChatDiv); + checkBoxList.addEntry(lastHitDiv); + + inputWidget.addContent(toolIconWidget); + inputWidget.addContent(typeDropdown); + inputWidget.addContent(sliderText); + inputWidget.addContent(warnSlider); + inputWidget.addContent(dropdownList); + inputWidget.addContent(checkBoxList); + HorizontalListWidget buttonList = new HorizontalListWidget() .addId("edit-button-menu"); doneButton.setEnabled(true); doneButton.setPressable(() -> { -// if (toolWidget.getUserName().length() == 0) { -// this.toolWidgets.put(nameTextField.getText(), toolWidget); -// this.toolList.session().setSelectedEntry(toolWidget); -// } - WarnTool tool = toolWidget.getTool(); tool.setType(typeDropdown.getSelected()); +// tool.setWarnAt(warnSlider); + tool.setSound(soundDropdown.getSelected()); + tool.setLastSound(lastSoundDropdown.getSelected()); + tool.setOpenChat(openChatCheck.state() == State.CHECKED); + tool.setLastHitWarn(lastHitCheck.state() == State.CHECKED); this.addon.configuration().getTools().remove(toolWidget.getTool()); this.addon.configuration().getTools().add(tool); this.addon.configuration().removeInvalidTools(); toolWidget.setTool(tool); this.setAction(null); + reload(); }); buttonList.addEntry(doneButton); buttonList.addEntry(ButtonWidget.i18n("labymod.ui.button.cancel", () -> this.setAction(null))); this.inputWidget.addContent(buttonList); - inputContainer.addChild(toolIconWidget); - inputContainer.addChild(typeDropdown); inputContainer.addChild(this.inputWidget); return inputContainer; } From 5998ef2d91eb37e9a77500d996706c176923bb3a Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 3 Feb 2024 23:42:06 +0100 Subject: [PATCH 15/53] pretty hacky only half working lss code (i'm gonna kms) --- .../toolwarn/themes/vanilla/lss/manage.lss | 70 ++++++++++++------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss index 840b805..dcee360 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss @@ -1,9 +1,8 @@ -TextField { - top: 0; - left: 0; - height: 20; - width: 100%; - margin: 2 40 5 5; +Dropdown { + top: 10; + height: 20; + left: 50%; + alignment-x: center; } .manage-container { @@ -21,7 +20,8 @@ TextField { alignment-x: center; alignment-y: center; - background-color: rgba(20, 20, 20, 150); + background-color: rgba(20, 20, 20, 180); + border-radius: 10; padding: 10; .custom-preview { @@ -44,24 +44,6 @@ TextField { } } -.input-name-list { - left: 0; - height: 30; - width: 100%; -} - -.input-avatar { - margin-top: -4; - top: 0; - left: 2; - width: 16; - height: width; -} - -.label-name { - margin-left: 21; -} - .remove-container { width: 90%; height: fit-content; @@ -124,3 +106,41 @@ TextField { left: 50%; alignment-x: center; } + +.dropdown-list { + left: 0; + width: 90%; + height: 45; + left: 50%; + alignment-x: center; +} + +.dropdown-div { + top: 0; + height: 100%; + width: 50%; +} + +.dropdown-name { + top: 0; + left: 50%; + alignment-x: center; + font-size: 0.8; +} + +.warn-slider { + height: 20; + width: 100; + alignment-x: center; +} + +.slider-name { + top: 0; + alignment-x: center; + font-size: 0.8; +} + +.tool-icon { + top: 0; + alignment-x: center; +} \ No newline at end of file From 3e6893221c56955d5f345ceaf3719cd678f57d4f Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 3 Feb 2024 23:53:39 +0100 Subject: [PATCH 16/53] Add change Interaction for slider value, remove out-commented code --- .../toolwarn/ui/ToolConfigActivity.java | 101 +----------------- 1 file changed, 3 insertions(+), 98 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java index 656bbc6..566dd68 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java @@ -39,6 +39,7 @@ public class ToolConfigActivity extends Activity { private final TbwAddon addon; private final VerticalListWidget toolList; private final List toolWidgets; + private int sliderValue; private ToolWidget selectedTool; @@ -170,7 +171,7 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { ComponentWidget sliderText = ComponentWidget.i18n("toolwarn.gui.slider") .addId("slider-name"); - SliderWidget warnSlider = new SliderWidget() + SliderWidget warnSlider = new SliderWidget(value -> sliderValue = (int) value) .addId("warn-slider"); warnSlider.range(1, 25); warnSlider.setValue(toolWidget.getTool().getWarnAt()); @@ -227,105 +228,9 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { openChatDiv.addChild(openChatCheck); lastHitDiv.addChild(lastHitText); lastHitDiv.addChild(lastHitCheck); -// ComponentWidget customNameWidget = ComponentWidget.component(toolWidget.getCustomTag().displayName()); -// customNameWidget.addId("custom-preview"); -// inputContainer.addChild(customNameWidget); this.inputWidget = new FlexibleContentWidget(); this.inputWidget.addId("input-list"); -// -// ComponentWidget labelName = ComponentWidget.i18n("toolwarn.gui.name"); -// labelName.addId("label-name"); -// this.inputWidget.addContent(labelName); -// -// HorizontalListWidget nameList = new HorizontalListWidget(); -// nameList.addId("input-name-list"); -// -// IconWidget iconWidget = new IconWidget( -// toolWidget.getIconWidget(toolWidget.getUserName())); -// iconWidget.addId("input-avatar"); -// nameList.addEntry(iconWidget); -// -// TextFieldWidget nameTextField = new TextFieldWidget(); -// nameTextField.maximalLength(16); -// nameTextField.setText(toolWidget.getUserName()); -// nameTextField.validator(newValue -> NAME_PATTERN.matcher(newValue).matches()); -// nameTextField.updateListener(newValue -> { -// doneButton.setEnabled( -// !newValue.trim().isEmpty() && !this.getStrippedText(customTextField.getText()).isEmpty() -// ); -// if (newValue.equals(this.lastUserName)) { -// return; -// } -// -// this.lastUserName = newValue; -// iconWidget.icon().set(toolWidget.getIconWidget(newValue)); -// }); -// -// nameList.addEntry(nameTextField); -// this.inputWidget.addContent(nameList); -// -// ComponentWidget labelCustomName = ComponentWidget.i18n("customnametags.gui.manage.lss.custom.name"); -// labelCustomName.addId("label-name"); -// this.inputWidget.addContent(labelCustomName); -// -// HorizontalListWidget customNameList = new HorizontalListWidget(); -// customNameList.addId("input-name-list"); -// -// DivWidget placeHolder = new DivWidget(); -// placeHolder.addId("input-avatar"); -// customNameList.addEntry(placeHolder); -// -// TextFieldWidget customTextField = new TextFieldWidget(); -// customTextField.maximalLength(64); -// customTextField.setText(toolWidget.getCustomTag().getCustomName()); -// customTextField.updateListener(newValue -> { -// doneButton.setEnabled( -// !this.getStrippedText(newValue).isEmpty() && !nameTextField.getText().trim().isEmpty() -// ); -// if (newValue.equals(this.lastCustomName)) { -// return; -// } -// -// this.lastCustomName = newValue; -// customNameWidget.setComponent( -// LegacyComponentSerializer.legacyAmpersand().deserialize(newValue)); -// }); -// -// customNameList.addEntry(customTextField); -// this.inputWidget.addContent(customNameList); -// -// HorizontalListWidget checkBoxList = new HorizontalListWidget(); -// checkBoxList.addId("checkbox-list"); -// -// DivWidget enabledDiv = new DivWidget(); -// enabledDiv.addId("checkbox-div"); -// -// ComponentWidget enabledText = ComponentWidget.i18n("customnametags.gui.manage.lss.enabled.name"); -// enabledText.addId("checkbox-name"); -// enabledDiv.addChild(enabledText); -// -// CheckBoxWidget enabledWidget = new CheckBoxWidget(); -// enabledWidget.addId("checkbox-item"); -// enabledWidget.setState( -// toolWidget.getCustomTag().isEnabled() ? State.CHECKED : State.UNCHECKED); -// enabledDiv.addChild(enabledWidget); -// checkBoxList.addEntry(enabledDiv); -// -// DivWidget replaceDiv = new DivWidget(); -// replaceDiv.addId("checkbox-div"); -// -// ComponentWidget replaceText = ComponentWidget.i18n("customnametags.gui.manage.lss.replace.name"); -// replaceText.addId("checkbox-name"); -// replaceDiv.addChild(replaceText); -// -// CheckBoxWidget replaceWidget = new CheckBoxWidget(); -// replaceWidget.addId("checkbox-item"); -// replaceWidget.setState( -// toolWidget.getCustomTag().isReplaceScoreboard() ? State.CHECKED : State.UNCHECKED); -// replaceDiv.addChild(replaceWidget); -// checkBoxList.addEntry(replaceDiv); -// this.inputWidget.addContent(checkBoxList); HorizontalListWidget dropdownList = new HorizontalListWidget() .addId("dropdown-list"); @@ -351,7 +256,7 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { doneButton.setPressable(() -> { WarnTool tool = toolWidget.getTool(); tool.setType(typeDropdown.getSelected()); -// tool.setWarnAt(warnSlider); + tool.setWarnAt(sliderValue); tool.setSound(soundDropdown.getSelected()); tool.setLastSound(lastSoundDropdown.getSelected()); tool.setOpenChat(openChatCheck.state() == State.CHECKED); From a490f6707d98c6b4dd7c183e6b3aea005d12ffb9 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 3 Feb 2024 23:58:48 +0100 Subject: [PATCH 17/53] Implement TbwConfiguration#removeInvalidTools --- .../main/java/com/rappytv/toolwarn/config/TbwConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 8c35569..4a554f3 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -31,7 +31,7 @@ public List getTools() { return tools; } public void removeInvalidTools() { - + this.tools.removeIf(entry -> entry.getWarnAt() < 1 || entry.getWarnAt() > 25); } @SwitchSetting From 9a3ce2af7ed3ebf421dc62beb9239259a032d7ce Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 00:05:01 +0100 Subject: [PATCH 18/53] Make remove confirmation round and background darker --- .../resources/assets/toolwarn/themes/vanilla/lss/manage.lss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss index dcee360..ce505f2 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss @@ -53,7 +53,8 @@ Dropdown { alignment-y: center; space-between-entries: 15; - background-color: rgba(20, 20, 20, 150); + background-color: rgba(20, 20, 20, 180); + border-radius: 10; padding: 10; } From 7ec3a6911029ae2cb2e653b4e2741c91b14ad1e6 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 00:05:15 +0100 Subject: [PATCH 19/53] Move tool icon more to the center --- .../resources/assets/toolwarn/themes/vanilla/lss/config.lss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss index a79ba02..2d98601 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss @@ -58,7 +58,7 @@ Tool { padding: 1; .tool-icon { - left: 4; + left: 11; top: 2; width: 16; height: width; From d61f31e38c44f024e27411527b4802d54a7d6080 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 00:07:53 +0100 Subject: [PATCH 20/53] Change WarnTool.Type enum to SCREAMING_SNAKE_CASE --- .../toolwarn/listener/GameTickListener.java | 2 +- .../com/rappytv/toolwarn/util/WarnTool.java | 54 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java index 97cf97f..b080d8b 100644 --- a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java +++ b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java @@ -42,7 +42,7 @@ public void onTick(GameTickEvent event) { } public void toolUsed(ItemStack itemStack, Type toolType) { - if(toolType == Type.None) return; + if(toolType == Type.NONE) return; if(Laby.labyAPI().minecraft().minecraftWindow().isScreenOpened()) return; int itemWarnInt = (toolType.getWarnPercentage(config) * itemStack.getMaximumDamage()) / 100; diff --git a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java index b83df57..17af2cf 100644 --- a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java +++ b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java @@ -15,7 +15,7 @@ public class WarnTool { private boolean lastHitWarn; public WarnTool() { - this(Type.Sword, WarnSound.NONE, WarnSound.NONE, 5, true, true); + this(Type.SWORD, WarnSound.NONE, WarnSound.NONE, 5, true, true); } public WarnTool(Type type, WarnSound sound, WarnSound lastSound, int warnAt, boolean openChat, boolean lastHitWarn) { @@ -66,15 +66,15 @@ public void setLastHitWarn(boolean lastHitWarn) { } public enum Type { - None(-1, -1), - Sword(0, 0), - Pickaxe(1, 0), - Axe(2, 0), - Shovel(3, 0), - Crossbow(0, 1), - Lighter(1, 1), - Shears(2, 1), - Trident(3, 1); + NONE(-1, -1), + SWORD(0, 0), + PICKAXE(1, 0), + AXE(2, 0), + SHOVEL(3, 0), + CROSSBOW(0, 1), + LIGHTER(1, 1), + SHEARS(2, 1), + TRIDENT(3, 1); private final ResourceLocation sprite = ResourceLocation.create("toolwarn", "textures/tools.png"); private final int x; @@ -92,35 +92,35 @@ public Icon getIcon() { public static Type getByItem(ItemStack itemStack) { String path = itemStack.getIdentifier().getPath(); if (path.endsWith("_sword")) { - return Sword; + return SWORD; } else if (path.endsWith("_pickaxe")) { - return Pickaxe; + return PICKAXE; } else if (path.endsWith("_axe")) { - return Axe; + return AXE; } else if (path.endsWith("_shovel")) { - return Shovel; + return SHOVEL; } else if (path.equalsIgnoreCase("crossbow")) { - return Crossbow; + return CROSSBOW; } else if (path.equalsIgnoreCase("flint_and_steel")) { - return Lighter; + return LIGHTER; } else if (path.equalsIgnoreCase("shears")) { - return Shears; + return SHEARS; } else if (path.equalsIgnoreCase("trident")) { - return Trident; + return TRIDENT; } - return None; + return NONE; } public int getWarnPercentage(TbwConfiguration configuration) { return switch (this) { - case Sword -> configuration.swordPercentage().get(); - case Pickaxe -> configuration.pickAxePercentage().get(); - case Axe -> configuration.axePercentage().get(); - case Shovel -> configuration.shovelPercentage().get(); - case Crossbow -> configuration.crossbowPercentage().get(); - case Lighter -> configuration.lighterPercentage().get(); - case Shears -> configuration.shearsPercentage().get(); - case Trident -> configuration.tridentPercentage().get(); + case SWORD -> configuration.swordPercentage().get(); + case PICKAXE -> configuration.pickAxePercentage().get(); + case AXE -> configuration.axePercentage().get(); + case SHOVEL -> configuration.shovelPercentage().get(); + case CROSSBOW -> configuration.crossbowPercentage().get(); + case LIGHTER -> configuration.lighterPercentage().get(); + case SHEARS -> configuration.shearsPercentage().get(); + case TRIDENT -> configuration.tridentPercentage().get(); default -> -1; }; } From e65b0c9345bc8e2ae555b8bfee507e93a0e79bf2 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 00:19:17 +0100 Subject: [PATCH 21/53] Add another condition to TbwConfiguration#removeInvalidTools --- .../java/com/rappytv/toolwarn/config/TbwConfiguration.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 4a554f3..a20d693 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -31,7 +31,11 @@ public List getTools() { return tools; } public void removeInvalidTools() { - this.tools.removeIf(entry -> entry.getWarnAt() < 1 || entry.getWarnAt() > 25); + this.tools.removeIf(entry -> + entry.getWarnAt() < 1 + || entry.getWarnAt() > 25 + || entry.getType() == null + ); } @SwitchSetting From 91a1f3955051d88751ac6189efde65c46cfac739 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 00:23:04 +0100 Subject: [PATCH 22/53] Add translations for sound and tool enum --- .../toolwarn/ui/ToolConfigActivity.java | 7 +++++-- .../resources/assets/toolwarn/i18n/en_us.json | 21 +++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java index 566dd68..71ba654 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java @@ -160,9 +160,10 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { DropdownWidget typeDropdown = new DropdownWidget<>() .addId("type-dropdown"); for(WarnTool.Type type : WarnTool.Type.values()) { - if(type == Type.None) continue; + if(type == Type.NONE) continue; typeDropdown.add(type); } + typeDropdown.setTranslationKeyPrefix("toolwarn.gui.dropdown.type"); typeDropdown.setSelected(toolWidget.getTool().getType()); typeDropdown.setChangeListener((type) -> { // Update toolIcon to type.getIcon() @@ -181,17 +182,19 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { DivWidget lastSoundDiv = new DivWidget() .addId("dropdown-div"); - ComponentWidget soundText = ComponentWidget.i18n("toolwarn.gui.dropdown.sound") + ComponentWidget soundText = ComponentWidget.i18n("toolwarn.gui.dropdown.warnSound") .addId("dropdown-name"); DropdownWidget soundDropdown = new DropdownWidget<>() .addId("dropdown-item"); + soundDropdown.setTranslationKeyPrefix("toolwarn.gui.dropdown.sound"); ComponentWidget lastSoundText = ComponentWidget.i18n("toolwarn.gui.dropdown.lastSound") .addId("dropdown-name"); DropdownWidget lastSoundDropdown = new DropdownWidget<>() .addId("dropdown-item"); + lastSoundDropdown.setTranslationKeyPrefix("toolwarn.gui.dropdown.sound"); soundDiv.addChild(soundText); soundDiv.addChild(soundDropdown); diff --git a/core/src/main/resources/assets/toolwarn/i18n/en_us.json b/core/src/main/resources/assets/toolwarn/i18n/en_us.json index 9ecfc21..816dfb9 100644 --- a/core/src/main/resources/assets/toolwarn/i18n/en_us.json +++ b/core/src/main/resources/assets/toolwarn/i18n/en_us.json @@ -89,8 +89,25 @@ "lastHit": "Last hit warning" }, "dropdown": { - "sound": "Warn sound", - "lastSound": "Last hit warn sound" + "warnSound": "Warn sound", + "lastSound": "Last hit warn sound", + "type": { + "sword": "Sword", + "pickaxe": "Pickaxe", + "axe": "Axe", + "shovel": "Shovel", + "crossbow": "Crossbow", + "lighter": "Flint and steel", + "shears": "Shears", + "trident": "Trident" + }, + "sound": { + "none": "None", + "anvilUse": "Anvil Use", + "levelUp": "Level Up", + "glassBreak": "Glass Break", + "pling": "Pling" + } }, "slider": "Warning durability (in %)", "type": "Tool type" From 393b59e8a2d43d4b5d54763a9d7c62a024998cc1 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 00:26:16 +0100 Subject: [PATCH 23/53] Fix conflicting tool-icon properties --- .../resources/assets/toolwarn/themes/vanilla/lss/config.lss | 2 +- .../resources/assets/toolwarn/themes/vanilla/lss/manage.lss | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss index 2d98601..443f5e2 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/config.lss @@ -58,7 +58,7 @@ Tool { padding: 1; .tool-icon { - left: 11; + left: 3; top: 2; width: 16; height: width; diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss index ce505f2..a20d920 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss @@ -139,9 +139,4 @@ Dropdown { top: 0; alignment-x: center; font-size: 0.8; -} - -.tool-icon { - top: 0; - alignment-x: center; } \ No newline at end of file From feeec2e0156c602183519cd4c5e42df544d9d18e Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 01:23:33 +0100 Subject: [PATCH 24/53] Complete manageContainer structure and lss style --- .../toolwarn/ui/ToolConfigActivity.java | 17 +++-- .../toolwarn/themes/vanilla/lss/manage.lss | 75 +++++++++++-------- 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java index 71ba654..420cc19 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java @@ -26,7 +26,6 @@ import net.labymod.api.client.gui.screen.widget.widgets.layout.ScrollWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.list.HorizontalListWidget; import net.labymod.api.client.gui.screen.widget.widgets.layout.list.VerticalListWidget; -import net.labymod.api.client.gui.screen.widget.widgets.renderer.IconWidget; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; @@ -154,8 +153,11 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { DivWidget inputContainer = new DivWidget() .addId("input-container"); - IconWidget toolIconWidget = new IconWidget(toolWidget.getTool().getType().getIcon()) - .addId("tool-icon"); + DivWidget typeDiv = new DivWidget() + .addId("type-div"); + + ComponentWidget typeText = ComponentWidget.i18n("toolwarn.gui.type") + .addId("type-name"); DropdownWidget typeDropdown = new DropdownWidget<>() .addId("type-dropdown"); @@ -165,9 +167,9 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { } typeDropdown.setTranslationKeyPrefix("toolwarn.gui.dropdown.type"); typeDropdown.setSelected(toolWidget.getTool().getType()); - typeDropdown.setChangeListener((type) -> { - // Update toolIcon to type.getIcon() - }); + + typeDiv.addChild(typeText); + typeDiv.addChild(typeDropdown); ComponentWidget sliderText = ComponentWidget.i18n("toolwarn.gui.slider") .addId("slider-name"); @@ -245,8 +247,7 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { checkBoxList.addEntry(openChatDiv); checkBoxList.addEntry(lastHitDiv); - inputWidget.addContent(toolIconWidget); - inputWidget.addContent(typeDropdown); + inputWidget.addContent(typeDiv); inputWidget.addContent(sliderText); inputWidget.addContent(warnSlider); inputWidget.addContent(dropdownList); diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss index a20d920..1d18ac5 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss @@ -1,10 +1,3 @@ -Dropdown { - top: 10; - height: 20; - left: 50%; - alignment-x: center; -} - .manage-container { top: 0; left: 0; @@ -37,7 +30,7 @@ Dropdown { .input-list { left: 0; - top: 30; + top: 0; width: 100%; bottom: 0; } @@ -79,64 +72,84 @@ Dropdown { width: 90%; } -.checkbox-list { - left: 0; - width: 90%; - height: 35; - left: 50%; - alignment-x: center; -} - -.checkbox-div { +.type-div { top: 0; - height: 100%; - width: 50%; + height: 20%; + width: 100%; } - -.checkbox-name { +.type-name { top: 0; left: 50%; alignment-x: center; font-size: 0.8; } - -.checkbox-item { +.type-dropdown { top: 10; - width: 20; height: 20; left: 50%; alignment-x: center; } +.slider-name { + top: 0; + alignment-x: center; + font-size: 0.8; +} +.warn-slider { + margin-top: 2; + height: 20; + width: 100; + alignment-x: center; +} + .dropdown-list { + margin-top: 10; left: 0; width: 90%; - height: 45; + height: 25%; left: 50%; alignment-x: center; } - .dropdown-div { top: 0; height: 100%; width: 50%; } - .dropdown-name { top: 0; left: 50%; alignment-x: center; font-size: 0.8; } - -.warn-slider { +.dropdown-item { + top: 10; height: 20; - width: 100; + left: 50%; alignment-x: center; } -.slider-name { +.checkbox-list { + left: 0; + width: 90%; + height: 35; + left: 50%; + alignment-x: center; +} +.checkbox-div { + top: 0; + height: 100%; + width: 50%; +} +.checkbox-name { top: 0; + left: 50%; alignment-x: center; font-size: 0.8; +} +.checkbox-item { + top: 10; + width: 20; + height: 20; + left: 50%; + alignment-x: center; } \ No newline at end of file From 73cfac6813a1aacd055897eb48c20bcaba4d2728 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 01:25:48 +0100 Subject: [PATCH 25/53] Use correct item type title --- core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java index 8c4ba52..0fa91df 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolWidget.java @@ -23,8 +23,9 @@ public void initialize(Parent parent) { IconWidget iconWidget = new IconWidget(tool.getType().getIcon()) .addId("tool-icon"); - ComponentWidget nameWidget = ComponentWidget.text(tool.getType().name()) - .addId("name-component"); + ComponentWidget nameWidget = ComponentWidget.i18n( + "toolwarn.gui.dropdown.type." + tool.getType().name().toLowerCase() + ).addId("name-component"); ComponentWidget meta = ComponentWidget.text(I18n.translate( "toolwarn.gui.meta", From 92f14e0f1ea054f63d40e8563c0b8cf344181cb6 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 01:44:09 +0100 Subject: [PATCH 26/53] Show item instantly when added --- .../java/com/rappytv/toolwarn/ui/ToolConfigActivity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java index 420cc19..5eec10d 100644 --- a/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java +++ b/core/src/main/java/com/rappytv/toolwarn/ui/ToolConfigActivity.java @@ -258,6 +258,11 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { doneButton.setEnabled(true); doneButton.setPressable(() -> { + if(!this.toolWidgets.contains(toolWidget)) { + this.toolWidgets.add(toolWidget); + this.toolList.session().setSelectedEntry(toolWidget); + } + WarnTool tool = toolWidget.getTool(); tool.setType(typeDropdown.getSelected()); tool.setWarnAt(sliderValue); @@ -271,7 +276,6 @@ private DivWidget initializeManageContainer(ToolWidget toolWidget) { toolWidget.setTool(tool); this.setAction(null); - reload(); }); buttonList.addEntry(doneButton); From 34620f69c9a1ac400de4afea580609b2f733877a Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 01:45:21 +0100 Subject: [PATCH 27/53] Copy files for fancy theme --- .../toolwarn/themes/fancy/lss/config.lss | 85 ++++++++++ .../toolwarn/themes/fancy/lss/manage.lss | 155 ++++++++++++++++++ 2 files changed, 240 insertions(+) create mode 100644 core/src/main/resources/assets/toolwarn/themes/fancy/lss/config.lss create mode 100644 core/src/main/resources/assets/toolwarn/themes/fancy/lss/manage.lss diff --git a/core/src/main/resources/assets/toolwarn/themes/fancy/lss/config.lss b/core/src/main/resources/assets/toolwarn/themes/fancy/lss/config.lss new file mode 100644 index 0000000..443f5e2 --- /dev/null +++ b/core/src/main/resources/assets/toolwarn/themes/fancy/lss/config.lss @@ -0,0 +1,85 @@ +.tool-container { + width: 100%; + height: 100%; + left: 0; + top: 0; + + Scroll { + width: 90%; + top: 0; + bottom: 0; + margin-top: 5; + margin-bottom: 5; + left: 50%; + alignment-x: center; + + .tool-list { + left: 0; + top: 0; + height: fit-content; + space-between-entries: 2; + selectable: true; + } + + Scrollbar { + left: 0; + top: 0; + width: 5; + height: 100%; + margin-left: 5; + } + } +} + +.overview-button-menu { + width: 90%; + height: 20; + left: 50%; + alignment-x: center; + bottom: 5; + layout: fill; + space-between-entries: 8; + margin-bottom: 5; +} + +.edit-button-menu { + width: 90%; + height: 20; + left: 50%; + alignment-x: center; + bottom: 0; + layout: fill; + space-between-entries: 8; +} + +Tool { + width: 100%; + height: 24; + padding: 1; + + .tool-icon { + left: 3; + top: 2; + width: 16; + height: width; + clickable: true; + + margin-top: 2; + } + + .name-component { + left: 22; + top: 2; + } + + .meta-component { + left: 22; + top: 13; + } + + &:selected { + padding: 0; + border: 1 gray; + background-color: black; + } +} \ No newline at end of file diff --git a/core/src/main/resources/assets/toolwarn/themes/fancy/lss/manage.lss b/core/src/main/resources/assets/toolwarn/themes/fancy/lss/manage.lss new file mode 100644 index 0000000..1d18ac5 --- /dev/null +++ b/core/src/main/resources/assets/toolwarn/themes/fancy/lss/manage.lss @@ -0,0 +1,155 @@ +.manage-container { + top: 0; + left: 0; + width: 100%; + height: 100%; + clear-depth: true; + + .input-container { + width: 90%; + height: 165; + left: 50%; + top: 47%; + alignment-x: center; + alignment-y: center; + + background-color: rgba(20, 20, 20, 180); + border-radius: 10; + padding: 10; + + .custom-preview { + top: 5; + left: 50%; + alignment-x: center; + font-size: 1.5; + padding: 2 3 2 3; + background-color: black; + min-width: 11; + max-width: 100%; + } + + .input-list { + left: 0; + top: 0; + width: 100%; + bottom: 0; + } + } +} + +.remove-container { + width: 90%; + height: fit-content; + left: 50%; + top: 50%; + alignment-x: center; + alignment-y: center; + space-between-entries: 15; + + background-color: rgba(20, 20, 20, 180); + border-radius: 10; + padding: 10; +} + +.remove-confirmation { + left: 50%; + alignment-x: center; +} + +.remove-preview { + left: 50%; + alignment-x: center; + height: 24; + width: 100%; +} + +.remove-button-menu { + left: 50%; + alignment-x: center; + height: 20; + layout: fill; + space-between-entries: 8; + width: 90%; +} + +.type-div { + top: 0; + height: 20%; + width: 100%; +} +.type-name { + top: 0; + left: 50%; + alignment-x: center; + font-size: 0.8; +} +.type-dropdown { + top: 10; + height: 20; + left: 50%; + alignment-x: center; +} + +.slider-name { + top: 0; + alignment-x: center; + font-size: 0.8; +} +.warn-slider { + margin-top: 2; + height: 20; + width: 100; + alignment-x: center; +} + +.dropdown-list { + margin-top: 10; + left: 0; + width: 90%; + height: 25%; + left: 50%; + alignment-x: center; +} +.dropdown-div { + top: 0; + height: 100%; + width: 50%; +} +.dropdown-name { + top: 0; + left: 50%; + alignment-x: center; + font-size: 0.8; +} +.dropdown-item { + top: 10; + height: 20; + left: 50%; + alignment-x: center; +} + +.checkbox-list { + left: 0; + width: 90%; + height: 35; + left: 50%; + alignment-x: center; +} +.checkbox-div { + top: 0; + height: 100%; + width: 50%; +} +.checkbox-name { + top: 0; + left: 50%; + alignment-x: center; + font-size: 0.8; +} +.checkbox-item { + top: 10; + width: 20; + height: 20; + left: 50%; + alignment-x: center; +} \ No newline at end of file From 072eab2932089634263d181e890bb037c6e916fd Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 01:48:30 +0100 Subject: [PATCH 28/53] Implement vanilla theme --- .../resources/assets/toolwarn/themes/vanilla/lss/manage.lss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss index 1d18ac5..3ba4c39 100644 --- a/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss +++ b/core/src/main/resources/assets/toolwarn/themes/vanilla/lss/manage.lss @@ -14,7 +14,6 @@ alignment-y: center; background-color: rgba(20, 20, 20, 180); - border-radius: 10; padding: 10; .custom-preview { @@ -47,7 +46,6 @@ space-between-entries: 15; background-color: rgba(20, 20, 20, 180); - border-radius: 10; padding: 10; } @@ -129,6 +127,7 @@ } .checkbox-list { + margin-top: 5; left: 0; width: 90%; height: 35; From ee7c0b41f41d320fb9f558e93020a91955972ec9 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 01:56:11 +0100 Subject: [PATCH 29/53] Remove redundant config options, deprecate GameTickListener --- .../toolwarn/config/TbwConfiguration.java | 80 ------------------- .../toolwarn/listener/GameTickListener.java | 35 ++++---- 2 files changed, 18 insertions(+), 97 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index a20d693..795cf19 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -1,19 +1,15 @@ package com.rappytv.toolwarn.config; -import com.rappytv.toolwarn.config.subconfig.TbwSoundSubConfig; import com.rappytv.toolwarn.ui.ToolConfigActivity; import com.rappytv.toolwarn.util.WarnTool; import net.labymod.api.addon.AddonConfig; import net.labymod.api.client.gui.screen.activity.Activity; import net.labymod.api.client.gui.screen.widget.widgets.activity.settings.ActivitySettingWidget.ActivitySetting; -import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; import net.labymod.api.configuration.loader.annotation.ConfigName; import net.labymod.api.configuration.loader.annotation.Exclude; -import net.labymod.api.configuration.loader.annotation.IntroducedIn; import net.labymod.api.configuration.loader.annotation.SpriteSlot; import net.labymod.api.configuration.loader.annotation.SpriteTexture; -import net.labymod.api.configuration.loader.annotation.VersionCompatibility; import net.labymod.api.configuration.loader.property.ConfigProperty; import net.labymod.api.configuration.settings.annotation.SettingSection; import net.labymod.api.util.MethodOrder; @@ -41,17 +37,6 @@ public void removeInvalidTools() { @SwitchSetting @SpriteSlot(size = 32) private final ConfigProperty enabled = new ConfigProperty<>(true); - @SettingSection("general") - @SwitchSetting - @SpriteSlot(size = 32, x = 1) - private final ConfigProperty openChat = new ConfigProperty<>(true); - @SwitchSetting - @SpriteSlot(size = 32, x = 3) - private final ConfigProperty lastHit = new ConfigProperty<>(true); - - @SettingSection("sounds") - @SpriteSlot(size = 32, y = 1) - private final TbwSoundSubConfig sounds = new TbwSoundSubConfig(); @SettingSection("tools") @MethodOrder(after = "sounds") @@ -59,74 +44,9 @@ public void removeInvalidTools() { public Activity toolConfig() { return new ToolConfigActivity(); } - @SliderSetting(steps = 1, min = 1, max = 25) - @SpriteSlot(size = 32, y = 2) - private final ConfigProperty swordPercentage = new ConfigProperty<>(5); - @SliderSetting(steps = 1, min = 1, max = 25) - @SpriteSlot(size = 32, y = 2, x = 1) - private final ConfigProperty pickaxePercentage = new ConfigProperty<>(5); - @SliderSetting(steps = 1, min = 1, max = 25) - @SpriteSlot(size = 32, y = 2, x = 2) - private final ConfigProperty axePercentage = new ConfigProperty<>(5); - @SliderSetting(steps = 1, min = 1, max = 25) - @SpriteSlot(size = 32, y = 2, x = 3) - private final ConfigProperty shovelPercentage = new ConfigProperty<>(5); - @SliderSetting(steps = 1, min = 1, max = 25) - @SpriteSlot(size = 32, y = 3) - @VersionCompatibility("1.14<*") - @IntroducedIn(namespace = "globaltags", value = "1.4.3") - private final ConfigProperty crossbowPercentage = new ConfigProperty<>(5); - @SliderSetting(steps = 1, min = 1, max = 25) - @SpriteSlot(size = 32, y = 3, x = 1) - @IntroducedIn(namespace = "globaltags", value = "1.4.3") - private final ConfigProperty lighterPercentage = new ConfigProperty<>(5); - @SliderSetting(steps = 1, min = 1, max = 25) - @SpriteSlot(size = 32, y = 3, x = 2) - @IntroducedIn(namespace = "globaltags", value = "1.4.3") - private final ConfigProperty shearsPercentage = new ConfigProperty<>(5); - @SliderSetting(steps = 1, min = 1, max = 25) - @SpriteSlot(size = 32, y = 3, x = 3) - @VersionCompatibility("1.13<*") - @IntroducedIn(namespace = "globaltags", value = "1.4.3") - private final ConfigProperty tridentPercentage = new ConfigProperty<>(5); @Override public ConfigProperty enabled() { return enabled; } - public ConfigProperty openChat() { - return openChat; - } - public ConfigProperty lastHit() { - return lastHit; - } - - public TbwSoundSubConfig sounds() { - return sounds; - } - - public ConfigProperty swordPercentage() { - return swordPercentage; - } - public ConfigProperty pickAxePercentage() { - return pickaxePercentage; - } - public ConfigProperty axePercentage() { - return axePercentage; - } - public ConfigProperty shovelPercentage() { - return shovelPercentage; - } - public ConfigProperty crossbowPercentage() { - return crossbowPercentage; - } - public ConfigProperty lighterPercentage() { - return lighterPercentage; - } - public ConfigProperty shearsPercentage() { - return shearsPercentage; - } - public ConfigProperty tridentPercentage() { - return tridentPercentage; - } } diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java index b080d8b..9d86003 100644 --- a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java +++ b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.List; +@Deprecated public class GameTickListener { private final TbwAddon addon; @@ -50,31 +51,31 @@ public void toolUsed(ItemStack itemStack, Type toolType) { if(itemUsedInt == itemWarnInt) { if(!warns.contains(itemStack)) { - if(this.config.openChat().get()) Laby.labyAPI().minecraft().openChat(""); +// if(this.config.openChat().get()) Laby.labyAPI().minecraft().openChat(""); Util.msg(Component.translatable("toolwarn.messages.warning", NamedTextColor.RED, Component.text(toolType.getWarnPercentage(config))), true); warns.add(itemStack); - if(config.sounds().enabled().get() && config.sounds().warnSound().get() != WarnSound.NONE) { - Laby.labyAPI().minecraft().sounds().playSound( - config.sounds().warnSound().get().getResourceLocation(), - 1f, - 1f - ); - } +// if(config.sounds().enabled().get() && config.sounds().warnSound().get() != WarnSound.NONE) { +// Laby.labyAPI().minecraft().sounds().playSound( +// config.sounds().warnSound().get().getResourceLocation(), +// 1f, +// 1f +// ); +// } } } else if(isLastHit(itemStack)) { if(!warns.contains(itemStack)) { - if(this.config.openChat().get()) Laby.labyAPI().minecraft().openChat(""); +// if(this.config.openChat().get()) Laby.labyAPI().minecraft().openChat(""); Util.msg(Component.translatable("toolwarn.messages.lastHit", NamedTextColor.RED), true); warns.add(itemStack); - if(config.sounds().enabled().get() && config.sounds().lastHitSound().get() != WarnSound.NONE) { - Laby.labyAPI().minecraft().sounds().playSound( - config.sounds().lastHitSound().get().getResourceLocation(), - 1f, - 1f - ); - } +// if(config.sounds().enabled().get() && config.sounds().lastHitSound().get() != WarnSound.NONE) { +// Laby.labyAPI().minecraft().sounds().playSound( +// config.sounds().lastHitSound().get().getResourceLocation(), +// 1f, +// 1f +// ); +// } } } else { warns.remove(itemStack); @@ -82,7 +83,7 @@ public void toolUsed(ItemStack itemStack, Type toolType) { } public boolean isLastHit(ItemStack i) { - if (!addon.configuration().lastHit().get()) return false; +// if (!addon.configuration().lastHit().get()) return false; return (i.getMaximumDamage() - i.getCurrentDamageValue()) <= 1; } } From 58607a5e07443c051cb3e9817bd916269acf7891 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 02:06:58 +0100 Subject: [PATCH 30/53] Add some empty events and listeners --- .../com/rappytv/toolwarn/event/BlockBreakEvent.java | 7 +++++++ .../com/rappytv/toolwarn/event/ToolUseEvent.java | 7 +++++++ .../toolwarn/listener/BlockBreakListener.java | 13 +++++++++++++ .../toolwarn/listener/ItemEquipListener.java | 11 +++++++++++ 4 files changed, 38 insertions(+) create mode 100644 core/src/main/java/com/rappytv/toolwarn/event/BlockBreakEvent.java create mode 100644 core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java create mode 100644 core/src/main/java/com/rappytv/toolwarn/listener/BlockBreakListener.java create mode 100644 core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java diff --git a/core/src/main/java/com/rappytv/toolwarn/event/BlockBreakEvent.java b/core/src/main/java/com/rappytv/toolwarn/event/BlockBreakEvent.java new file mode 100644 index 0000000..5f2ffe9 --- /dev/null +++ b/core/src/main/java/com/rappytv/toolwarn/event/BlockBreakEvent.java @@ -0,0 +1,7 @@ +package com.rappytv.toolwarn.event; + +import net.labymod.api.event.Event; + +public class BlockBreakEvent implements Event { + +} diff --git a/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java b/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java new file mode 100644 index 0000000..983d759 --- /dev/null +++ b/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java @@ -0,0 +1,7 @@ +package com.rappytv.toolwarn.event; + +import net.labymod.api.event.Event; + +public class ToolUseEvent implements Event { + +} diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/BlockBreakListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/BlockBreakListener.java new file mode 100644 index 0000000..36a39b3 --- /dev/null +++ b/core/src/main/java/com/rappytv/toolwarn/listener/BlockBreakListener.java @@ -0,0 +1,13 @@ +package com.rappytv.toolwarn.listener; + +import com.rappytv.toolwarn.event.BlockBreakEvent; +import net.labymod.api.event.Subscribe; + +public class BlockBreakListener { + + @Subscribe + public void onBlockBreak(BlockBreakEvent event) { + + } + +} diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java new file mode 100644 index 0000000..b241a38 --- /dev/null +++ b/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java @@ -0,0 +1,11 @@ +package com.rappytv.toolwarn.listener; + +import net.labymod.api.event.client.entity.player.ClientHotbarSlotChangeEvent; + +public class ItemEquipListener { + + public void onItemEquip(ClientHotbarSlotChangeEvent event) { + + } + +} From 1c43d728577475f05c35124e48dd1ae849eded86 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 02:07:15 +0100 Subject: [PATCH 31/53] Register empty listeners --- core/src/main/java/com/rappytv/toolwarn/TbwAddon.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java index a1a4691..85be1c7 100644 --- a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java +++ b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java @@ -2,7 +2,9 @@ import com.rappytv.toolwarn.config.TbwConfiguration; import com.rappytv.toolwarn.core.generated.DefaultReferenceStorage; +import com.rappytv.toolwarn.listener.BlockBreakListener; import com.rappytv.toolwarn.listener.GameTickListener; +import com.rappytv.toolwarn.listener.ItemEquipListener; import com.rappytv.toolwarn.util.ITbwSounds; import net.labymod.api.Laby; import net.labymod.api.addon.LabyAddon; @@ -24,6 +26,7 @@ public class TbwAddon extends LabyAddon { @Override protected void preConfigurationLoad() { Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.4.3"), "2024-01-26")); + // TODO: Create revision for v1.4.0 } @Override @@ -35,7 +38,9 @@ protected void enable() { registerSettingCategory(); instance = this; + registerListener(new BlockBreakListener()); registerListener(new GameTickListener(this)); + registerListener(new ItemEquipListener()); } public static TbwAddon get() { From 9caadadc2ec02656c1a4750c79d651392af53c51 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 14:19:33 +0100 Subject: [PATCH 32/53] Add german translations, improve config --- .../toolwarn/config/TbwConfiguration.java | 2 +- .../resources/assets/toolwarn/i18n/de_de.json | 93 +++++++------------ .../resources/assets/toolwarn/i18n/en_us.json | 63 ------------- 3 files changed, 32 insertions(+), 126 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 795cf19..2db5b9e 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -39,7 +39,7 @@ public void removeInvalidTools() { private final ConfigProperty enabled = new ConfigProperty<>(true); @SettingSection("tools") - @MethodOrder(after = "sounds") + @MethodOrder(after = "enabled") @ActivitySetting public Activity toolConfig() { return new ToolConfigActivity(); diff --git a/core/src/main/resources/assets/toolwarn/i18n/de_de.json b/core/src/main/resources/assets/toolwarn/i18n/de_de.json index 0bdba16..6400cfe 100644 --- a/core/src/main/resources/assets/toolwarn/i18n/de_de.json +++ b/core/src/main/resources/assets/toolwarn/i18n/de_de.json @@ -3,12 +3,6 @@ "settings": { "name": "Toolbreak Warnung", "header": { - "general": { - "name": "Allgemein" - }, - "sounds": { - "name": "Sounds" - }, "tools": { "name": "Werkzeuge" } @@ -16,69 +10,44 @@ "enabled": { "name": "Aktiviert" }, - "openChat": { - "name": "Chat öffnen beim warnen", - "description": "Wenn das Addon dich warnt, wird sich dein Chat öffnen, damit du daran gehindert wirst, die letzten Hits mit deinem Tool zu verbrauchen." - }, - "lastHit": { - "name": "Warnung beim letzten Schlag", - "description": "Warnt dich, wenn dein Tool bei Haltbarkeit 1 angekommen ist" - }, - "sounds": { - "name": "Sound Einstellungen", - "description": "Verwaltet die Sounds, die abgespielt werden.", - "warnSound": { - "name": "Warnungs Sound", - "entries": { - "none": "Keiner", - "anvilUse": "Amboss", - "levelUp": "Level Up", - "glassBreak": "Glas abbauen", - "pling": "Pling" - } - }, - "lastHitSound": { - "name": "Sound beim letzten Schlag", - "entries": { - "none": "Keiner", - "anvilUse": "Amboss", - "levelUp": "Level Up", - "glassBreak": "Glas abbauen", - "pling": "Pling" - } - } - }, "toolConfig": { "name": "Werkzeuge verwalten" - }, - "swordPercentage": { - "name": "Schwert-Warnung (%)" - }, - "pickaxePercentage": { - "name": "Spitzhacken-Warnung (%)" - }, - "axePercentage": { - "name": "Axt-Warnung (%)" - }, - "shovelPercentage": { - "name": "Schaufel-Warnung (%)" - }, - "crossbowPercentage": { - "name": "Armbrust-Warnung (%)" - }, - "lighterPercentage": { - "name": "Feuerzeug-Warnung (%)" - }, - "shearsPercentage": { - "name": "Scheren-Warnung (%)" - }, - "tridentPercentage": { - "name": "Dreizack-Warnung (%)" } }, "messages": { "lastHit": "Du solltest das Tool jetzt weglegen. Das ist dein letzter Schlag!", "warning": "Willst du das Tool wirklich weiter benutzen? Die Haltbarkeit liegt bei %s%%!" + }, + "gui": { + "meta": "Warnung bei: %s%% • Chat: %s • Letzter Schlag: %s", + "remove": "Willst du diesen Eintrag wirklich entfernen?", + "checkbox": { + "openChat": "Chat öffnen", + "lastHit": "Warnung bei letztem Schlag" + }, + "dropdown": { + "warnSound": "Warnungston", + "lastSound": "Warnungston bei letztem Schlag", + "type": { + "sword": "Schwert", + "pickaxe": "Spitzhacke", + "axe": "Axt", + "shovel": "Schaufel", + "crossbow": "Armbrust", + "lighter": "Feuerzeug", + "shears": "Schere", + "trident": "Dreizack" + }, + "sound": { + "none": "Keiner", + "anvilUse": "Amboss", + "levelUp": "Level Up", + "glassBreak": "Glas Abbauen", + "pling": "Pling" + } + }, + "slider": "Haltbarkeit (in %)", + "type": "Werkzeug Typ" } } } \ No newline at end of file diff --git a/core/src/main/resources/assets/toolwarn/i18n/en_us.json b/core/src/main/resources/assets/toolwarn/i18n/en_us.json index 816dfb9..3f81884 100644 --- a/core/src/main/resources/assets/toolwarn/i18n/en_us.json +++ b/core/src/main/resources/assets/toolwarn/i18n/en_us.json @@ -3,12 +3,6 @@ "settings": { "name": "Toolbreak Warning", "header": { - "general": { - "name": "General" - }, - "sounds": { - "name": "Sounds" - }, "tools": { "name": "Tools" } @@ -16,64 +10,8 @@ "enabled": { "name": "Activated" }, - "openChat": { - "name": "Open chat on warn", - "description": "When the addon warns you, your chat will open to prevent you from wasting the last durability of your tool." - }, - "lastHit": { - "name": "Warn on last hit", - "description": "Warns you when your tool is at 1 durability" - }, - "sounds": { - "name": "Sound Settings", - "description": "Manages the sounds that are played.", - "warnSound": { - "name": "Warn Sound", - "entries": { - "none": "None", - "anvilUse": "Anvil Use", - "levelUp": "Level Up", - "glassBreak": "Glass Break", - "pling": "Pling" - } - }, - "lastHitSound": { - "name": "Last hit warn sound", - "entries": { - "none": "None", - "anvilUse": "Anvil Use", - "levelUp": "Level Up", - "glassBreak": "Glass Break", - "pling": "Pling" - } - } - }, "toolConfig": { "name": "Manage tools" - }, - "swordPercentage": { - "name": "Sword warn percentage" - }, - "pickaxePercentage": { - "name": "Pickaxe warn percentage" - }, - "axePercentage": { - "name": "Axe warn percentage" - }, - "shovelPercentage": { - "name": "Shovel warn percentage" - }, - "crossbowPercentage": { - "name": "Crossbow warn percentage" - }, - "lighterPercentage": { - "name": "Flint and Steel warn percentage" - }, - "shearsPercentage": { - "name": "Shears warn percentage" - }, - "tridentPercentage": { - "name": "Trident warn percentage" } }, "messages": { @@ -82,7 +20,6 @@ }, "gui": { "meta": "Warn at: %s%% • Chat: %s • Last hit: %s", - "add": "Add a new tool configuration", "remove": "Do you really want to remove this entry?", "checkbox": { "openChat": "Open chat", From 625cc80cd3681db0741b05260c0359bffb42218f Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 14:20:35 +0100 Subject: [PATCH 33/53] Deprecate WarnTool.Type#getWarnPercentage --- .../java/com/rappytv/toolwarn/util/WarnTool.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java index 17af2cf..ace2768 100644 --- a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java +++ b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java @@ -111,18 +111,9 @@ public static Type getByItem(ItemStack itemStack) { return NONE; } + @Deprecated public int getWarnPercentage(TbwConfiguration configuration) { - return switch (this) { - case SWORD -> configuration.swordPercentage().get(); - case PICKAXE -> configuration.pickAxePercentage().get(); - case AXE -> configuration.axePercentage().get(); - case SHOVEL -> configuration.shovelPercentage().get(); - case CROSSBOW -> configuration.crossbowPercentage().get(); - case LIGHTER -> configuration.lighterPercentage().get(); - case SHEARS -> configuration.shearsPercentage().get(); - case TRIDENT -> configuration.tridentPercentage().get(); - default -> -1; - }; + return -1; } } } From 15aaca61abd9892f23344a0113a6b1516565eeaa Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 14:21:23 +0100 Subject: [PATCH 34/53] Remove some warnings --- .../java/com/rappytv/toolwarn/listener/GameTickListener.java | 1 - .../java/com/rappytv/toolwarn/listener/ItemEquipListener.java | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java index 9d86003..0b8e6aa 100644 --- a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java +++ b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java @@ -3,7 +3,6 @@ import com.rappytv.toolwarn.TbwAddon; import com.rappytv.toolwarn.config.TbwConfiguration; import com.rappytv.toolwarn.util.Util; -import com.rappytv.toolwarn.util.WarnSound; import com.rappytv.toolwarn.util.WarnTool.Type; import net.labymod.api.Laby; import net.labymod.api.client.component.Component; diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java index b241a38..df3b669 100644 --- a/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java +++ b/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java @@ -1,9 +1,11 @@ package com.rappytv.toolwarn.listener; +import net.labymod.api.event.Subscribe; import net.labymod.api.event.client.entity.player.ClientHotbarSlotChangeEvent; public class ItemEquipListener { + @Subscribe public void onItemEquip(ClientHotbarSlotChangeEvent event) { } From b850a9f0c9ca56ba8afc40d7bb320bc30d1b289c Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 14:23:52 +0100 Subject: [PATCH 35/53] Add missing NotNull annotations on ITbwSounds implementations --- .../java/com/rappytv/toolwarn/v1_12_2/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_16_5/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_17_1/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_18_2/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_19_2/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_19_3/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_19_4/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_20_1/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_20_2/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_20_4/TbwSoundImpl.java | 6 +++--- .../java/com/rappytv/toolwarn/v1_8_9/TbwSoundImpl.java | 6 +++--- 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/game-runner/src/v1_12_2/java/com/rappytv/toolwarn/v1_12_2/TbwSoundImpl.java b/game-runner/src/v1_12_2/java/com/rappytv/toolwarn/v1_12_2/TbwSoundImpl.java index 824ee4e..019bac1 100644 --- a/game-runner/src/v1_12_2/java/com/rappytv/toolwarn/v1_12_2/TbwSoundImpl.java +++ b/game-runner/src/v1_12_2/java/com/rappytv/toolwarn/v1_12_2/TbwSoundImpl.java @@ -16,11 +16,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -28,7 +28,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_16_5/java/com/rappytv/toolwarn/v1_16_5/TbwSoundImpl.java b/game-runner/src/v1_16_5/java/com/rappytv/toolwarn/v1_16_5/TbwSoundImpl.java index 5fdc009..14b2251 100644 --- a/game-runner/src/v1_16_5/java/com/rappytv/toolwarn/v1_16_5/TbwSoundImpl.java +++ b/game-runner/src/v1_16_5/java/com/rappytv/toolwarn/v1_16_5/TbwSoundImpl.java @@ -16,11 +16,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -28,7 +28,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_17_1/java/com/rappytv/toolwarn/v1_17_1/TbwSoundImpl.java b/game-runner/src/v1_17_1/java/com/rappytv/toolwarn/v1_17_1/TbwSoundImpl.java index ebb2032..4d0b846 100644 --- a/game-runner/src/v1_17_1/java/com/rappytv/toolwarn/v1_17_1/TbwSoundImpl.java +++ b/game-runner/src/v1_17_1/java/com/rappytv/toolwarn/v1_17_1/TbwSoundImpl.java @@ -17,11 +17,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -29,7 +29,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_18_2/java/com/rappytv/toolwarn/v1_18_2/TbwSoundImpl.java b/game-runner/src/v1_18_2/java/com/rappytv/toolwarn/v1_18_2/TbwSoundImpl.java index 6d25e6f..bb9774a 100644 --- a/game-runner/src/v1_18_2/java/com/rappytv/toolwarn/v1_18_2/TbwSoundImpl.java +++ b/game-runner/src/v1_18_2/java/com/rappytv/toolwarn/v1_18_2/TbwSoundImpl.java @@ -16,11 +16,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -28,7 +28,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_19_2/java/com/rappytv/toolwarn/v1_19_2/TbwSoundImpl.java b/game-runner/src/v1_19_2/java/com/rappytv/toolwarn/v1_19_2/TbwSoundImpl.java index 8bc0b0e..6dad5bd 100644 --- a/game-runner/src/v1_19_2/java/com/rappytv/toolwarn/v1_19_2/TbwSoundImpl.java +++ b/game-runner/src/v1_19_2/java/com/rappytv/toolwarn/v1_19_2/TbwSoundImpl.java @@ -16,11 +16,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -28,7 +28,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_19_3/java/com/rappytv/toolwarn/v1_19_3/TbwSoundImpl.java b/game-runner/src/v1_19_3/java/com/rappytv/toolwarn/v1_19_3/TbwSoundImpl.java index 48bea28..39c2916 100644 --- a/game-runner/src/v1_19_3/java/com/rappytv/toolwarn/v1_19_3/TbwSoundImpl.java +++ b/game-runner/src/v1_19_3/java/com/rappytv/toolwarn/v1_19_3/TbwSoundImpl.java @@ -16,11 +16,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -28,7 +28,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_19_4/java/com/rappytv/toolwarn/v1_19_4/TbwSoundImpl.java b/game-runner/src/v1_19_4/java/com/rappytv/toolwarn/v1_19_4/TbwSoundImpl.java index 0fbf221..f5200b1 100644 --- a/game-runner/src/v1_19_4/java/com/rappytv/toolwarn/v1_19_4/TbwSoundImpl.java +++ b/game-runner/src/v1_19_4/java/com/rappytv/toolwarn/v1_19_4/TbwSoundImpl.java @@ -16,11 +16,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -28,7 +28,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_20_1/java/com/rappytv/toolwarn/v1_20_1/TbwSoundImpl.java b/game-runner/src/v1_20_1/java/com/rappytv/toolwarn/v1_20_1/TbwSoundImpl.java index f8304e0..8bbf29a 100644 --- a/game-runner/src/v1_20_1/java/com/rappytv/toolwarn/v1_20_1/TbwSoundImpl.java +++ b/game-runner/src/v1_20_1/java/com/rappytv/toolwarn/v1_20_1/TbwSoundImpl.java @@ -16,11 +16,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -28,7 +28,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_20_2/java/com/rappytv/toolwarn/v1_20_2/TbwSoundImpl.java b/game-runner/src/v1_20_2/java/com/rappytv/toolwarn/v1_20_2/TbwSoundImpl.java index c4caf1d..ab814f5 100644 --- a/game-runner/src/v1_20_2/java/com/rappytv/toolwarn/v1_20_2/TbwSoundImpl.java +++ b/game-runner/src/v1_20_2/java/com/rappytv/toolwarn/v1_20_2/TbwSoundImpl.java @@ -16,11 +16,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -28,7 +28,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_20_4/java/com/rappytv/toolwarn/v1_20_4/TbwSoundImpl.java b/game-runner/src/v1_20_4/java/com/rappytv/toolwarn/v1_20_4/TbwSoundImpl.java index d1aa47c..9fcd23b 100644 --- a/game-runner/src/v1_20_4/java/com/rappytv/toolwarn/v1_20_4/TbwSoundImpl.java +++ b/game-runner/src/v1_20_4/java/com/rappytv/toolwarn/v1_20_4/TbwSoundImpl.java @@ -17,11 +17,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "block.anvil.use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -29,7 +29,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } diff --git a/game-runner/src/v1_8_9/java/com/rappytv/toolwarn/v1_8_9/TbwSoundImpl.java b/game-runner/src/v1_8_9/java/com/rappytv/toolwarn/v1_8_9/TbwSoundImpl.java index dc07f4b..5ba01bc 100644 --- a/game-runner/src/v1_8_9/java/com/rappytv/toolwarn/v1_8_9/TbwSoundImpl.java +++ b/game-runner/src/v1_8_9/java/com/rappytv/toolwarn/v1_8_9/TbwSoundImpl.java @@ -16,11 +16,11 @@ public class TbwSoundImpl implements ITbwSounds { private final ResourceLocation anvilUseSound = ResourceLocation.create("minecraft", "random.anvil_use"); @Override - public ResourceLocation getPlingSound() { + public @NotNull ResourceLocation getPlingSound() { return plingSound; } @Override - public ResourceLocation getLevelUpSound() { + public @NotNull ResourceLocation getLevelUpSound() { return levelUpSound; } @Override @@ -28,7 +28,7 @@ public ResourceLocation getLevelUpSound() { return glassBreakSound; } @Override - public ResourceLocation getAnvilUseSound() { + public @NotNull ResourceLocation getAnvilUseSound() { return anvilUseSound; } } From a205baa2633c204f7672a4a9ed6e2553dfa10dd6 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 15:11:17 +0100 Subject: [PATCH 36/53] Return NONE in WarnTool.Type#getByItem if itemStack is null --- core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java index ace2768..361c9e2 100644 --- a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java +++ b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java @@ -90,6 +90,7 @@ public Icon getIcon() { } public static Type getByItem(ItemStack itemStack) { + if(itemStack == null) return NONE; String path = itemStack.getIdentifier().getPath(); if (path.endsWith("_sword")) { return SWORD; From c34f6d5ef878835434687d75ad8131360f31f04e Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 15:11:44 +0100 Subject: [PATCH 37/53] Write ToolUseEvent prototype --- .../rappytv/toolwarn/event/ToolUseEvent.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java b/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java index 983d759..dc13d50 100644 --- a/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java +++ b/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java @@ -1,7 +1,24 @@ package com.rappytv.toolwarn.event; +import com.rappytv.toolwarn.util.WarnTool; +import com.rappytv.toolwarn.util.WarnTool.Type; +import net.labymod.api.client.world.item.ItemStack; import net.labymod.api.event.Event; public class ToolUseEvent implements Event { + private final ItemStack itemStack; + private final WarnTool.Type type; + + public ToolUseEvent(ItemStack itemStack) { + this.itemStack = itemStack; + this.type = WarnTool.Type.getByItem(itemStack); + } + + public ItemStack getItemStack() { + return itemStack; + } + public Type getType() { + return type; + } } From 1a026836aec0da24f9ec27dd0870f069985e008b Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 15:12:32 +0100 Subject: [PATCH 38/53] Add some event boilerplate code in ItemEquipListener --- .../com/rappytv/toolwarn/listener/ItemEquipListener.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java index df3b669..098193b 100644 --- a/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java +++ b/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java @@ -1,10 +1,17 @@ package com.rappytv.toolwarn.listener; +import com.rappytv.toolwarn.TbwAddon; import net.labymod.api.event.Subscribe; import net.labymod.api.event.client.entity.player.ClientHotbarSlotChangeEvent; public class ItemEquipListener { + private final TbwAddon addon; + + public ItemEquipListener(TbwAddon addon) { + this.addon = addon; + } + @Subscribe public void onItemEquip(ClientHotbarSlotChangeEvent event) { From 891286d8dca902a4651ae2e86eec59a24e66d67f Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 15:12:48 +0100 Subject: [PATCH 39/53] Debug ToolUseListener --- .../toolwarn/listener/ToolUseListener.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 core/src/main/java/com/rappytv/toolwarn/listener/ToolUseListener.java diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/ToolUseListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/ToolUseListener.java new file mode 100644 index 0000000..5e19de7 --- /dev/null +++ b/core/src/main/java/com/rappytv/toolwarn/listener/ToolUseListener.java @@ -0,0 +1,26 @@ +package com.rappytv.toolwarn.listener; + +import com.rappytv.toolwarn.TbwAddon; +import com.rappytv.toolwarn.config.TbwConfiguration; +import com.rappytv.toolwarn.event.ToolUseEvent; +import net.labymod.api.client.world.item.ItemStack; +import net.labymod.api.event.Subscribe; +import java.util.ArrayList; +import java.util.List; + +public class ToolUseListener { + + private final TbwAddon addon; + private final TbwConfiguration config; + private static final List warns = new ArrayList<>(); + + public ToolUseListener(TbwAddon addon) { + this.addon = addon; + this.config = addon.configuration(); + } + + @Subscribe + public void onToolUse(ToolUseEvent event) { + System.out.println("Tool use event"); + } +} From 3c8fb33d2e99b7a938b1244a8bc7b2dd5859a4fc Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 15:13:10 +0100 Subject: [PATCH 40/53] Only register ItemEquipListener and ToolUseListener --- core/src/main/java/com/rappytv/toolwarn/TbwAddon.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java index 85be1c7..e8f3c76 100644 --- a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java +++ b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java @@ -2,9 +2,8 @@ import com.rappytv.toolwarn.config.TbwConfiguration; import com.rappytv.toolwarn.core.generated.DefaultReferenceStorage; -import com.rappytv.toolwarn.listener.BlockBreakListener; -import com.rappytv.toolwarn.listener.GameTickListener; import com.rappytv.toolwarn.listener.ItemEquipListener; +import com.rappytv.toolwarn.listener.ToolUseListener; import com.rappytv.toolwarn.util.ITbwSounds; import net.labymod.api.Laby; import net.labymod.api.addon.LabyAddon; @@ -38,9 +37,8 @@ protected void enable() { registerSettingCategory(); instance = this; - registerListener(new BlockBreakListener()); - registerListener(new GameTickListener(this)); - registerListener(new ItemEquipListener()); + registerListener(new ItemEquipListener(this)); + registerListener(new ToolUseListener(this)); } public static TbwAddon get() { From 6cc6b8f635372343eb8452f3bba78c4f63abe140 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 4 Feb 2024 22:37:23 +0100 Subject: [PATCH 41/53] fuck mixins, use old method instead --- .../java/com/rappytv/toolwarn/TbwAddon.java | 6 +- .../toolwarn/event/BlockBreakEvent.java | 7 -- .../rappytv/toolwarn/event/ToolUseEvent.java | 24 ------ .../toolwarn/listener/BlockBreakListener.java | 13 --- .../toolwarn/listener/GameTickListener.java | 80 ++++++++++--------- .../toolwarn/listener/ItemEquipListener.java | 20 ----- .../toolwarn/listener/ToolUseListener.java | 26 ------ 7 files changed, 45 insertions(+), 131 deletions(-) delete mode 100644 core/src/main/java/com/rappytv/toolwarn/event/BlockBreakEvent.java delete mode 100644 core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java delete mode 100644 core/src/main/java/com/rappytv/toolwarn/listener/BlockBreakListener.java delete mode 100644 core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java delete mode 100644 core/src/main/java/com/rappytv/toolwarn/listener/ToolUseListener.java diff --git a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java index e8f3c76..4b8bc2b 100644 --- a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java +++ b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java @@ -2,8 +2,7 @@ import com.rappytv.toolwarn.config.TbwConfiguration; import com.rappytv.toolwarn.core.generated.DefaultReferenceStorage; -import com.rappytv.toolwarn.listener.ItemEquipListener; -import com.rappytv.toolwarn.listener.ToolUseListener; +import com.rappytv.toolwarn.listener.GameTickListener; import com.rappytv.toolwarn.util.ITbwSounds; import net.labymod.api.Laby; import net.labymod.api.addon.LabyAddon; @@ -37,8 +36,7 @@ protected void enable() { registerSettingCategory(); instance = this; - registerListener(new ItemEquipListener(this)); - registerListener(new ToolUseListener(this)); + registerListener(new GameTickListener(this)); } public static TbwAddon get() { diff --git a/core/src/main/java/com/rappytv/toolwarn/event/BlockBreakEvent.java b/core/src/main/java/com/rappytv/toolwarn/event/BlockBreakEvent.java deleted file mode 100644 index 5f2ffe9..0000000 --- a/core/src/main/java/com/rappytv/toolwarn/event/BlockBreakEvent.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.rappytv.toolwarn.event; - -import net.labymod.api.event.Event; - -public class BlockBreakEvent implements Event { - -} diff --git a/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java b/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java deleted file mode 100644 index dc13d50..0000000 --- a/core/src/main/java/com/rappytv/toolwarn/event/ToolUseEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.rappytv.toolwarn.event; - -import com.rappytv.toolwarn.util.WarnTool; -import com.rappytv.toolwarn.util.WarnTool.Type; -import net.labymod.api.client.world.item.ItemStack; -import net.labymod.api.event.Event; - -public class ToolUseEvent implements Event { - - private final ItemStack itemStack; - private final WarnTool.Type type; - - public ToolUseEvent(ItemStack itemStack) { - this.itemStack = itemStack; - this.type = WarnTool.Type.getByItem(itemStack); - } - - public ItemStack getItemStack() { - return itemStack; - } - public Type getType() { - return type; - } -} diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/BlockBreakListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/BlockBreakListener.java deleted file mode 100644 index 36a39b3..0000000 --- a/core/src/main/java/com/rappytv/toolwarn/listener/BlockBreakListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.rappytv.toolwarn.listener; - -import com.rappytv.toolwarn.event.BlockBreakEvent; -import net.labymod.api.event.Subscribe; - -public class BlockBreakListener { - - @Subscribe - public void onBlockBreak(BlockBreakEvent event) { - - } - -} diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java index 0b8e6aa..acf9480 100644 --- a/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java +++ b/core/src/main/java/com/rappytv/toolwarn/listener/GameTickListener.java @@ -3,6 +3,8 @@ import com.rappytv.toolwarn.TbwAddon; import com.rappytv.toolwarn.config.TbwConfiguration; import com.rappytv.toolwarn.util.Util; +import com.rappytv.toolwarn.util.WarnSound; +import com.rappytv.toolwarn.util.WarnTool; import com.rappytv.toolwarn.util.WarnTool.Type; import net.labymod.api.Laby; import net.labymod.api.client.component.Component; @@ -15,7 +17,6 @@ import java.util.ArrayList; import java.util.List; -@Deprecated public class GameTickListener { private final TbwAddon addon; @@ -38,51 +39,56 @@ public void onTick(GameTickEvent event) { if(itemStack.getMaximumDamage() == 0) return; if(player.gameMode() != GameMode.SURVIVAL && player.gameMode() != GameMode.ADVENTURE) return; - toolUsed(itemStack, Type.getByItem(itemStack)); + checkForWarn(itemStack, Type.getByItem(itemStack)); } - public void toolUsed(ItemStack itemStack, Type toolType) { - if(toolType == Type.NONE) return; + private void checkForWarn(ItemStack itemStack, WarnTool.Type type) { + if(type == Type.NONE) return; if(Laby.labyAPI().minecraft().minecraftWindow().isScreenOpened()) return; - int itemWarnInt = (toolType.getWarnPercentage(config) * itemStack.getMaximumDamage()) / 100; int itemUsedInt = itemStack.getMaximumDamage() - itemStack.getCurrentDamageValue(); - if(itemUsedInt == itemWarnInt) { - if(!warns.contains(itemStack)) { -// if(this.config.openChat().get()) Laby.labyAPI().minecraft().openChat(""); - Util.msg(Component.translatable("toolwarn.messages.warning", NamedTextColor.RED, Component.text(toolType.getWarnPercentage(config))), true); - warns.add(itemStack); + for(WarnTool tool : config.getTools()) { + if(tool.getType() != type) continue; + int itemWarnInt = (tool.getWarnAt() * itemStack.getMaximumDamage()) / 100; -// if(config.sounds().enabled().get() && config.sounds().warnSound().get() != WarnSound.NONE) { -// Laby.labyAPI().minecraft().sounds().playSound( -// config.sounds().warnSound().get().getResourceLocation(), -// 1f, -// 1f -// ); -// } - } - } else if(isLastHit(itemStack)) { - if(!warns.contains(itemStack)) { -// if(this.config.openChat().get()) Laby.labyAPI().minecraft().openChat(""); - Util.msg(Component.translatable("toolwarn.messages.lastHit", NamedTextColor.RED), true); - warns.add(itemStack); + if(itemUsedInt == itemWarnInt) { + if(!warns.contains(itemStack)) { + if(tool.openChat()) Laby.labyAPI().minecraft().openChat(""); + Util.msg(Component.translatable( + "toolwarn.messages.warning", + NamedTextColor.RED, + Component.text(tool.getWarnAt()) + ), true); + warns.add(itemStack); -// if(config.sounds().enabled().get() && config.sounds().lastHitSound().get() != WarnSound.NONE) { -// Laby.labyAPI().minecraft().sounds().playSound( -// config.sounds().lastHitSound().get().getResourceLocation(), -// 1f, -// 1f -// ); -// } + if(tool.getSound() != WarnSound.NONE) { + Laby.labyAPI().minecraft().sounds().playSound( + tool.getSound().getResourceLocation(), + 1f, + 1f + ); + } + } + } else if(tool.lastHitWarn() && itemUsedInt <= 1) { + if(!warns.contains(itemStack)) { + if(tool.openChat()) Laby.labyAPI().minecraft().openChat(""); + Util.msg( + Component.translatable("toolwarn.messages.lastHit", NamedTextColor.RED), + true + ); + warns.add(itemStack); + if(tool.getLastSound() != WarnSound.NONE) { + Laby.labyAPI().minecraft().sounds().playSound( + tool.getLastSound().getResourceLocation(), + 1f, + 1f + ); + } + } + } else { + warns.remove(itemStack); } - } else { - warns.remove(itemStack); } } - - public boolean isLastHit(ItemStack i) { -// if (!addon.configuration().lastHit().get()) return false; - return (i.getMaximumDamage() - i.getCurrentDamageValue()) <= 1; - } } diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java deleted file mode 100644 index 098193b..0000000 --- a/core/src/main/java/com/rappytv/toolwarn/listener/ItemEquipListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.rappytv.toolwarn.listener; - -import com.rappytv.toolwarn.TbwAddon; -import net.labymod.api.event.Subscribe; -import net.labymod.api.event.client.entity.player.ClientHotbarSlotChangeEvent; - -public class ItemEquipListener { - - private final TbwAddon addon; - - public ItemEquipListener(TbwAddon addon) { - this.addon = addon; - } - - @Subscribe - public void onItemEquip(ClientHotbarSlotChangeEvent event) { - - } - -} diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/ToolUseListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/ToolUseListener.java deleted file mode 100644 index 5e19de7..0000000 --- a/core/src/main/java/com/rappytv/toolwarn/listener/ToolUseListener.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.rappytv.toolwarn.listener; - -import com.rappytv.toolwarn.TbwAddon; -import com.rappytv.toolwarn.config.TbwConfiguration; -import com.rappytv.toolwarn.event.ToolUseEvent; -import net.labymod.api.client.world.item.ItemStack; -import net.labymod.api.event.Subscribe; -import java.util.ArrayList; -import java.util.List; - -public class ToolUseListener { - - private final TbwAddon addon; - private final TbwConfiguration config; - private static final List warns = new ArrayList<>(); - - public ToolUseListener(TbwAddon addon) { - this.addon = addon; - this.config = addon.configuration(); - } - - @Subscribe - public void onToolUse(ToolUseEvent event) { - System.out.println("Tool use event"); - } -} From 2297f6d320e644cc18b97ae42e337230173f1583 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 9 Mar 2024 19:38:50 +0100 Subject: [PATCH 42/53] Remove all unused slots --- .../themes/vanilla/textures/settings.png | Bin 11114 -> 5547 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/core/src/main/resources/assets/toolwarn/themes/vanilla/textures/settings.png b/core/src/main/resources/assets/toolwarn/themes/vanilla/textures/settings.png index 25ca292fe4ae1621bffc71096e1bf9ae67bfd655..653361faa534c4b1ee09c1452b59de2a11ea2eec 100644 GIT binary patch delta 2403 zcmb`IdsGu=8pbD=a#^kD30qo`hC?}VD+Y4EaJP!+7Nji}P=OFaf;1o?7(@sY>2a|l zAj_%A%>9a?9`sqZQcIiZg>9u-ucb*J@50* zI~#V>tsxA>Ama(lgG8n$iQ!3Nx)F$;1cHn6$)ps|;N-XjUgjQlI@iaAL?BV{gkO}F z6rvcebUK5>CNY?JB7qTyXV583Jd?s9~iA_)=CAz3N=SSJ8u% zQKR&utoKBx&_J$i-o7#_DbPoeXp9$s*+sbmIG5&&bPZpBO3!PZwEJG zOg-Xe2nX2AZ0(q`?k*)_ z2i&GsZh43Xz|J)v#Jr#%(#$#JYpe5o2`}``9w!Q8)L!Aee&*ui=J{mf0!P9}sv|L? zk4xcu^MOI~uyDOThuidaeEW*za(<8B%2Z?bDa~YWYP(Za5Ri7wxC>i)$tMIDPqT!3 zEiFLNYF|(%hFU>m?{f0;jN`PSSho=}Y=0MYSH#!bE6@hD!FooL61_Y$XvT^R1|AIQ(fdRCm%n&W7sdkn^h~-nv*Z7mZg$68LI=&Xz80yPLS(^fY7Nkpu7zu z$|~*5Z(#(oa$bygf1Z(<45n@ZSEqU>bs2tcK-Pp1upTh_ntI2|JA|<+OovRO+>Hgf z>al?yFx9B*HhcnkOgpq`I**$x`U6CMEUdw#bMwf-_5RobNtI5Y;ib+?ARx9mKLBw_ zJeYBW-jkKJt@o<-RmLDoLklf^xqQG# zA2gaWZYiOF?;Fwca7;S)UIEU%_fR2S*RP({9Mp&MRd=;vw{o6e#9opQ3zMNa$Xx+9 zd$$BNHtIHQ_##hvnuYok3E|%Wr@%~}Mo6P1jiG&w;brebOC1_ZriE$TFyTx9;fmBn zVAj7Z*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U#B}*p z5+GX75$eA`RiYuj_OLS8jl`y;&PDsibQ_Zje!b8B+`DG?gsif&ebq0{Q3ivhU=V_* za)M}lWy)_az`l9xn@*ka7_(eXPC>W(=&F&?rS9J-k5E9*l8pp`Hy39@P%^Vt$C&eI zoyFrY2DF?i%c{-ko@oD3i9(##jiMo_XNVzOV~~S~o@p}~ zfb5aR)^jKyC7xtjUSU^iwWoY00)Y4@qd-Q4uIoOUSc-WQZiklA^Qt8uLd==U(!KEt z5+818mKhLT-T$P7i#U!bdtZqwxHEGPd$^RW_w(^NN9Ej5?%7M(&gEm#f=ndc|7ICP_Hx;;mWLZ?~nlF{o&}S|%}uU}M90 zGsVIC3At3+K_RkwNCZSJKm2#E)WL)d)Oiuf!f00Sp1ml0TM1X=G7^z3et$qh(qSM= zHY{j=>89#T^?g0z5Xx%QrSkgs4I}_|&`|GF=7WVDRj7&r!qe{iH?RA(kDG*t3reSm zDO`ExOvhyekX9sH<9ld@69NC$GQI5-K5$NwH%U%Ppzlia0vYEuIPu?k9S0%m7@HNU zZhvQ=uXkN~$}`+$vdZxjk-xKZuMcI+WqeRI+h~fuevh~b*_4yu>fLX`-L;ElU<>IE$nJTJx&Jxc_J}mv(ESn$L6c^2hh-+JyM-hwMhYP4!mM*6G$#HTO=b z8|F`K=WEV@zVs)ENQwS~CPpMsagp2I9e*`A&CfaMV@m*%99fjGMIw*v-p4qWUREjd zyX}lt81R@sFwMQ0L;C}_Sv^R;g&!!KQC{S0Za-@JDy`Lk-@sx1Q}_^oL1(|Fr{wGU z&y5At&O}g-sUU_$Y+cVdpcdF)y5<^4y*C(Y)Ndj(R570UZ$ADR;c+y*m!-`uMgvO$ P{O6|TZH;oZdtv_vsXm$t From 09eec591adfa8244395fd5f9ff653e110446e6c2 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 9 Mar 2024 19:39:57 +0100 Subject: [PATCH 43/53] Add SpriteSlot to tool manager config --- .../java/com/rappytv/toolwarn/config/TbwConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 2db5b9e..1138b2a 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -34,11 +34,12 @@ public void removeInvalidTools() { ); } - @SwitchSetting @SpriteSlot(size = 32) + @SwitchSetting private final ConfigProperty enabled = new ConfigProperty<>(true); @SettingSection("tools") + @SpriteSlot(size = 32, x = 1) @MethodOrder(after = "enabled") @ActivitySetting public Activity toolConfig() { From a7fd7a43fe70ef858114efcb099319b4456650b9 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 9 Mar 2024 19:42:25 +0100 Subject: [PATCH 44/53] Support hoes, remove deprecated WarnTool#getWarnPercentage --- .../com/rappytv/toolwarn/util/WarnTool.java | 17 +++++++---------- .../resources/assets/toolwarn/i18n/de_de.json | 1 + .../resources/assets/toolwarn/i18n/en_us.json | 1 + .../assets/toolwarn/textures/tools.png | Bin 5763 -> 6377 bytes 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java index 361c9e2..ada5414 100644 --- a/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java +++ b/core/src/main/java/com/rappytv/toolwarn/util/WarnTool.java @@ -1,6 +1,5 @@ package com.rappytv.toolwarn.util; -import com.rappytv.toolwarn.config.TbwConfiguration; import net.labymod.api.client.gui.icon.Icon; import net.labymod.api.client.resources.ResourceLocation; import net.labymod.api.client.world.item.ItemStack; @@ -71,10 +70,11 @@ public enum Type { PICKAXE(1, 0), AXE(2, 0), SHOVEL(3, 0), - CROSSBOW(0, 1), - LIGHTER(1, 1), - SHEARS(2, 1), - TRIDENT(3, 1); + HOE(0, 1), + CROSSBOW(1, 1), + LIGHTER(2, 1), + SHEARS(3, 1), + TRIDENT(0, 2); private final ResourceLocation sprite = ResourceLocation.create("toolwarn", "textures/tools.png"); private final int x; @@ -100,6 +100,8 @@ public static Type getByItem(ItemStack itemStack) { return AXE; } else if (path.endsWith("_shovel")) { return SHOVEL; + } else if (path.endsWith("_hoe")) { + return HOE; } else if (path.equalsIgnoreCase("crossbow")) { return CROSSBOW; } else if (path.equalsIgnoreCase("flint_and_steel")) { @@ -111,10 +113,5 @@ public static Type getByItem(ItemStack itemStack) { } return NONE; } - - @Deprecated - public int getWarnPercentage(TbwConfiguration configuration) { - return -1; - } } } diff --git a/core/src/main/resources/assets/toolwarn/i18n/de_de.json b/core/src/main/resources/assets/toolwarn/i18n/de_de.json index 6400cfe..1a00470 100644 --- a/core/src/main/resources/assets/toolwarn/i18n/de_de.json +++ b/core/src/main/resources/assets/toolwarn/i18n/de_de.json @@ -33,6 +33,7 @@ "pickaxe": "Spitzhacke", "axe": "Axt", "shovel": "Schaufel", + "hoe": "Hacke", "crossbow": "Armbrust", "lighter": "Feuerzeug", "shears": "Schere", diff --git a/core/src/main/resources/assets/toolwarn/i18n/en_us.json b/core/src/main/resources/assets/toolwarn/i18n/en_us.json index 3f81884..d707cf3 100644 --- a/core/src/main/resources/assets/toolwarn/i18n/en_us.json +++ b/core/src/main/resources/assets/toolwarn/i18n/en_us.json @@ -33,6 +33,7 @@ "pickaxe": "Pickaxe", "axe": "Axe", "shovel": "Shovel", + "hoe": "Hoe", "crossbow": "Crossbow", "lighter": "Flint and steel", "shears": "Shears", diff --git a/core/src/main/resources/assets/toolwarn/textures/tools.png b/core/src/main/resources/assets/toolwarn/textures/tools.png index a7f36dafe0a655fc607199cb5c43521dd6070275..470ad8f99deefc193fd23855257ca758984b9fba 100644 GIT binary patch literal 6377 zcmd5>3pA8_*MA1NoRmr(RG5aO%b5GM7=@&WN}*F2&&;@v(agBz$mpgJi6|A)DJqv! ziOOZXZ-pOhDJqRiVqAuKpAnApuFmCqzx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 9 Mar 2024 20:12:32 +0100 Subject: [PATCH 45/53] Bump version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 091b14f..6396976 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,7 @@ labyMod { author = "RappyTV" description = "Stops you from using your currently used tool when its almost destroyed." minecraftVersion = "1.8<1.20.4" - version = System.getenv().getOrDefault("VERSION", "1.3.4") + version = System.getenv().getOrDefault("VERSION", "1.4.0") } minecraft { From 7231f533f70356c58b316efc0a4e20d9de624fe8 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sat, 9 Mar 2024 20:12:54 +0100 Subject: [PATCH 46/53] Register 1.4.0 revision --- core/src/main/java/com/rappytv/toolwarn/TbwAddon.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java index 4b8bc2b..cda443b 100644 --- a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java +++ b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java @@ -23,8 +23,8 @@ public class TbwAddon extends LabyAddon { @Override protected void preConfigurationLoad() { - Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.4.3"), "2024-01-26")); - // TODO: Create revision for v1.4.0 + Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.3.4"), "2024-01-26")); + Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.4.0"), "2024-03-09")); } @Override From b7921b1b769776650408a2496cf29952663082d7 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 10 Mar 2024 20:39:20 +0100 Subject: [PATCH 47/53] Rearrange config a bit, add commented IntroducedIn annotation LabyMod does not support methods annotated with IntroducedIn yet. It's gonna be uncommented as soon as they change that. --- .../toolwarn/config/TbwConfiguration.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 1138b2a..072608a 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -20,25 +20,15 @@ @SpriteTexture(value = "settings") public class TbwConfiguration extends AddonConfig { - @Exclude - private final List tools = new ArrayList<>(); - - public List getTools() { - return tools; - } - public void removeInvalidTools() { - this.tools.removeIf(entry -> - entry.getWarnAt() < 1 - || entry.getWarnAt() > 25 - || entry.getType() == null - ); - } - @SpriteSlot(size = 32) @SwitchSetting private final ConfigProperty enabled = new ConfigProperty<>(true); + @Exclude + private final List tools = new ArrayList<>(); + @SettingSection("tools") +// @IntroducedIn(namespace = "toolwarn", value = "1.4.0") @SpriteSlot(size = 32, x = 1) @MethodOrder(after = "enabled") @ActivitySetting @@ -50,4 +40,15 @@ public Activity toolConfig() { public ConfigProperty enabled() { return enabled; } + + public List getTools() { + return tools; + } + public void removeInvalidTools() { + this.tools.removeIf(entry -> + entry.getWarnAt() < 1 + || entry.getWarnAt() > 25 + || entry.getType() == null + ); + } } From cbc7ac7760784cbc5b88f48f23eb821da4a0ed31 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Sun, 10 Mar 2024 20:42:15 +0100 Subject: [PATCH 48/53] Implement half-finished config migrator As soon as the LabyMod API supports the access to the previous config I'm gonna finish this. --- .../java/com/rappytv/toolwarn/TbwAddon.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java index cda443b..e54726d 100644 --- a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java +++ b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java @@ -4,6 +4,9 @@ import com.rappytv.toolwarn.core.generated.DefaultReferenceStorage; import com.rappytv.toolwarn.listener.GameTickListener; import com.rappytv.toolwarn.util.ITbwSounds; +import com.rappytv.toolwarn.util.WarnSound; +import com.rappytv.toolwarn.util.WarnTool; +import com.rappytv.toolwarn.util.WarnTool.Type; import net.labymod.api.Laby; import net.labymod.api.addon.LabyAddon; import net.labymod.api.client.component.Component; @@ -36,6 +39,7 @@ protected void enable() { registerSettingCategory(); instance = this; + migrateConfig(); registerListener(new GameTickListener(this)); } @@ -51,4 +55,23 @@ public static ITbwSounds getSounds() { protected Class configurationClass() { return TbwConfiguration.class; } + + private void migrateConfig() { + if(configuration().getConfigVersion() == 1) { + WarnSound warnSound = WarnSound.NONE; + WarnSound lastHitSound = WarnSound.NONE; + boolean openChat = true; + boolean lastHitWarn = true; + + configuration().getTools().add(new WarnTool(Type.SWORD, warnSound, lastHitSound, 5, openChat, lastHitWarn)); + configuration().getTools().add(new WarnTool(Type.PICKAXE, warnSound, lastHitSound, 5, openChat, lastHitWarn)); + configuration().getTools().add(new WarnTool(Type.AXE, warnSound, lastHitSound, 5, openChat, lastHitWarn)); + configuration().getTools().add(new WarnTool(Type.SHOVEL, warnSound, lastHitSound, 5, openChat, lastHitWarn)); + configuration().getTools().add(new WarnTool(Type.CROSSBOW, warnSound, lastHitSound, 5, openChat, lastHitWarn)); + configuration().getTools().add(new WarnTool(Type.LIGHTER, warnSound, lastHitSound, 5, openChat, lastHitWarn)); + configuration().getTools().add(new WarnTool(Type.SHEARS, warnSound, lastHitSound, 5, openChat, lastHitWarn)); + configuration().getTools().add(new WarnTool(Type.TRIDENT, warnSound, lastHitSound, 5, openChat, lastHitWarn)); + configuration().usedConfigVersion().set(2); + } + } } From 532581768efe617d407e0fffd39c1198cf12fd55 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Tue, 12 Mar 2024 00:45:54 +0100 Subject: [PATCH 49/53] Set config version to 2 --- .../java/com/rappytv/toolwarn/config/TbwConfiguration.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 072608a..5d50599 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -51,4 +51,9 @@ public void removeInvalidTools() { || entry.getType() == null ); } + + @Override + public int getConfigVersion() { + return 2; + } } From 73684d6964a2684b30486a8285050062a9d9db3c Mon Sep 17 00:00:00 2001 From: RappyTV Date: Tue, 12 Mar 2024 00:46:16 +0100 Subject: [PATCH 50/53] Write a ConfigMigrator --- .../listener/ConfigMigrationListener.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 core/src/main/java/com/rappytv/toolwarn/listener/ConfigMigrationListener.java diff --git a/core/src/main/java/com/rappytv/toolwarn/listener/ConfigMigrationListener.java b/core/src/main/java/com/rappytv/toolwarn/listener/ConfigMigrationListener.java new file mode 100644 index 0000000..05e9c38 --- /dev/null +++ b/core/src/main/java/com/rappytv/toolwarn/listener/ConfigMigrationListener.java @@ -0,0 +1,79 @@ +package com.rappytv.toolwarn.listener; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.rappytv.toolwarn.config.TbwConfiguration; +import com.rappytv.toolwarn.util.WarnSound; +import com.rappytv.toolwarn.util.WarnTool; +import com.rappytv.toolwarn.util.WarnTool.Type; +import net.labymod.api.configuration.loader.Config; +import net.labymod.api.event.Subscribe; +import net.labymod.api.event.labymod.config.ConfigurationVersionUpdateEvent; + +@SuppressWarnings("FieldCanBeLocal") +public class ConfigMigrationListener { + + private final Gson gson = new Gson(); + private final int defaultPercentage = 5; + + @Subscribe + public void onConfigVersionUpdate(ConfigurationVersionUpdateEvent event) { + Class configClass = event.getConfigClass(); + int usedVersion = event.getUsedVersion(); + + if(configClass == TbwConfiguration.class) { + if(usedVersion == 1) migrateFromOne(event); + } + } + + private void migrateFromOne(ConfigurationVersionUpdateEvent event) { + JsonObject config = event.getJsonObject(); + if(!config.has("sounds")) return; + + JsonObject sounds = config.get("sounds").getAsJsonObject(); + + WarnSound warnSound = WarnSound.NONE; + WarnSound lastHitSound = WarnSound.NONE; + boolean openChat = true; + boolean lastHitWarn = true; + int sword = defaultPercentage; + int pickaxe = defaultPercentage; + int axe = defaultPercentage; + int shovel = defaultPercentage; + int crossbow = defaultPercentage; + int lighter = defaultPercentage; + int shears = defaultPercentage; + int trident = defaultPercentage; + + try { + warnSound = WarnSound.valueOf(sounds.get("warnSound").getAsString()); + lastHitSound = WarnSound.valueOf(sounds.get("lastHitSound").getAsString()); + openChat = config.get("openChat").getAsBoolean(); + lastHitWarn = config.get("lastHit").getAsBoolean(); + sword = config.get("swordPercentage").getAsInt(); + pickaxe = config.get("pickaxePercentage").getAsInt(); + axe = config.get("axePercentage").getAsInt(); + shovel = config.get("shovelPercentage").getAsInt(); + crossbow = config.get("crossbowPercentage").getAsInt(); + lighter = config.get("lighterPercentage").getAsInt(); + shears = config.get("shearsPercentage").getAsInt(); + trident = config.get("tridentPercentage").getAsInt(); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + + JsonArray tools = new JsonArray(); + tools.add(gson.toJsonTree(new WarnTool(Type.SWORD, warnSound, lastHitSound, sword, openChat, lastHitWarn))); + tools.add(gson.toJsonTree(new WarnTool(Type.PICKAXE, warnSound, lastHitSound, pickaxe, openChat, lastHitWarn))); + tools.add(gson.toJsonTree(new WarnTool(Type.AXE, warnSound, lastHitSound, axe, openChat, lastHitWarn))); + tools.add(gson.toJsonTree(new WarnTool(Type.SHOVEL, warnSound, lastHitSound, shovel, openChat, lastHitWarn))); + tools.add(gson.toJsonTree(new WarnTool(Type.CROSSBOW, warnSound, lastHitSound, crossbow, openChat, lastHitWarn))); + tools.add(gson.toJsonTree(new WarnTool(Type.LIGHTER, warnSound, lastHitSound, lighter, openChat, lastHitWarn))); + tools.add(gson.toJsonTree(new WarnTool(Type.SHEARS, warnSound, lastHitSound, shears, openChat, lastHitWarn))); + tools.add(gson.toJsonTree(new WarnTool(Type.TRIDENT, warnSound, lastHitSound, trident, openChat, lastHitWarn))); + + config.add("tools", tools); + event.setJsonObject(config); + } +} From fcf9acd4add00fb811611a48d7526a7c4b901b04 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Tue, 12 Mar 2024 00:46:36 +0100 Subject: [PATCH 51/53] Remove old config migrator, register new one --- .../java/com/rappytv/toolwarn/TbwAddon.java | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java index e54726d..fc2dbc0 100644 --- a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java +++ b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java @@ -2,11 +2,9 @@ import com.rappytv.toolwarn.config.TbwConfiguration; import com.rappytv.toolwarn.core.generated.DefaultReferenceStorage; +import com.rappytv.toolwarn.listener.ConfigMigrationListener; import com.rappytv.toolwarn.listener.GameTickListener; import com.rappytv.toolwarn.util.ITbwSounds; -import com.rappytv.toolwarn.util.WarnSound; -import com.rappytv.toolwarn.util.WarnTool; -import com.rappytv.toolwarn.util.WarnTool.Type; import net.labymod.api.Laby; import net.labymod.api.addon.LabyAddon; import net.labymod.api.client.component.Component; @@ -28,6 +26,7 @@ public class TbwAddon extends LabyAddon { protected void preConfigurationLoad() { Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.3.4"), "2024-01-26")); Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.4.0"), "2024-03-09")); + registerListener(new ConfigMigrationListener()); } @Override @@ -39,7 +38,6 @@ protected void enable() { registerSettingCategory(); instance = this; - migrateConfig(); registerListener(new GameTickListener(this)); } @@ -55,23 +53,4 @@ public static ITbwSounds getSounds() { protected Class configurationClass() { return TbwConfiguration.class; } - - private void migrateConfig() { - if(configuration().getConfigVersion() == 1) { - WarnSound warnSound = WarnSound.NONE; - WarnSound lastHitSound = WarnSound.NONE; - boolean openChat = true; - boolean lastHitWarn = true; - - configuration().getTools().add(new WarnTool(Type.SWORD, warnSound, lastHitSound, 5, openChat, lastHitWarn)); - configuration().getTools().add(new WarnTool(Type.PICKAXE, warnSound, lastHitSound, 5, openChat, lastHitWarn)); - configuration().getTools().add(new WarnTool(Type.AXE, warnSound, lastHitSound, 5, openChat, lastHitWarn)); - configuration().getTools().add(new WarnTool(Type.SHOVEL, warnSound, lastHitSound, 5, openChat, lastHitWarn)); - configuration().getTools().add(new WarnTool(Type.CROSSBOW, warnSound, lastHitSound, 5, openChat, lastHitWarn)); - configuration().getTools().add(new WarnTool(Type.LIGHTER, warnSound, lastHitSound, 5, openChat, lastHitWarn)); - configuration().getTools().add(new WarnTool(Type.SHEARS, warnSound, lastHitSound, 5, openChat, lastHitWarn)); - configuration().getTools().add(new WarnTool(Type.TRIDENT, warnSound, lastHitSound, 5, openChat, lastHitWarn)); - configuration().usedConfigVersion().set(2); - } - } } From 2d30a605af23f9436e17bea3c9020641745208d3 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 14 Mar 2024 19:30:17 +0100 Subject: [PATCH 52/53] The annotation finally works :D --- .../java/com/rappytv/toolwarn/config/TbwConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java index 5d50599..59ebefd 100644 --- a/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java +++ b/core/src/main/java/com/rappytv/toolwarn/config/TbwConfiguration.java @@ -8,6 +8,7 @@ import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; import net.labymod.api.configuration.loader.annotation.ConfigName; import net.labymod.api.configuration.loader.annotation.Exclude; +import net.labymod.api.configuration.loader.annotation.IntroducedIn; import net.labymod.api.configuration.loader.annotation.SpriteSlot; import net.labymod.api.configuration.loader.annotation.SpriteTexture; import net.labymod.api.configuration.loader.property.ConfigProperty; @@ -28,7 +29,7 @@ public class TbwConfiguration extends AddonConfig { private final List tools = new ArrayList<>(); @SettingSection("tools") -// @IntroducedIn(namespace = "toolwarn", value = "1.4.0") + @IntroducedIn(namespace = "toolwarn", value = "1.4.0") @SpriteSlot(size = 32, x = 1) @MethodOrder(after = "enabled") @ActivitySetting From c5c6689dbfae9e9c92c0a57efd8839b585d6c739 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 14 Mar 2024 19:32:14 +0100 Subject: [PATCH 53/53] Change v1.4.0 release date --- core/src/main/java/com/rappytv/toolwarn/TbwAddon.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java index fc2dbc0..7050b28 100644 --- a/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java +++ b/core/src/main/java/com/rappytv/toolwarn/TbwAddon.java @@ -25,7 +25,7 @@ public class TbwAddon extends LabyAddon { @Override protected void preConfigurationLoad() { Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.3.4"), "2024-01-26")); - Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.4.0"), "2024-03-09")); + Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.4.0"), "2024-03-14")); registerListener(new ConfigMigrationListener()); }