Skip to content

Commit

Permalink
Merge pull request #16 from RappyLabyAddons/feat/moreTools
Browse files Browse the repository at this point in the history
Support more tools, add new icon design
  • Loading branch information
RappyTV committed Jan 26, 2024
2 parents 8d5f259 + f8b2c02 commit 3a5d3ee
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.3")
version = System.getenv().getOrDefault("VERSION", "1.3.4")
}

minecraft {
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/com/rappytv/toolwarn/TbwAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@
import com.rappytv.toolwarn.core.generated.DefaultReferenceStorage;
import com.rappytv.toolwarn.listener.GameTickListener;
import com.rappytv.toolwarn.util.ITbwSounds;
import net.labymod.api.Laby;
import net.labymod.api.addon.LabyAddon;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.format.NamedTextColor;
import net.labymod.api.client.component.format.Style;
import net.labymod.api.client.component.format.TextDecoration;
import net.labymod.api.models.addon.annotation.AddonMain;
import net.labymod.api.revision.SimpleRevision;
import net.labymod.api.util.version.SemanticVersion;

@AddonMain
public class TbwAddon extends LabyAddon<TbwConfiguration> {

public static Component prefix;
private static ITbwSounds sounds;

@Override
protected void preConfigurationLoad() {
Laby.references().revisionRegistry().register(new SimpleRevision("toolwarn", new SemanticVersion("1.4.3"), "2024-01-26"));
}

@Override
protected void enable() {
prefix = Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
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.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;

Expand All @@ -26,22 +28,40 @@ public class TbwConfiguration extends AddonConfig {
private final ConfigProperty<Boolean> lastHit = new ConfigProperty<>(true);

@SettingSection("sounds")
@SpriteSlot(size = 32, y = 1, x = 1)
@SpriteSlot(size = 32, y = 1)
private final TbwSoundSubConfig sounds = new TbwSoundSubConfig();

@SettingSection("tools")
@SliderSetting(steps = 1, min = 1, max = 25)
@SpriteSlot(size = 32, y = 3)
@SpriteSlot(size = 32, y = 2)
private final ConfigProperty<Integer> swordPercentage = new ConfigProperty<>(5);
@SliderSetting(steps = 1, min = 1, max = 25)
@SpriteSlot(size = 32, x = 1, y = 3)
@SpriteSlot(size = 32, y = 2, x = 1)
private final ConfigProperty<Integer> pickaxePercentage = new ConfigProperty<>(5);
@SliderSetting(steps = 1, min = 1, max = 25)
@SpriteSlot(size = 32, x = 2, y = 3)
@SpriteSlot(size = 32, y = 2, x = 2)
private final ConfigProperty<Integer> axePercentage = new ConfigProperty<>(5);
@SliderSetting(steps = 1, min = 1, max = 25)
@SpriteSlot(size = 32, x = 3, y = 3)
@SpriteSlot(size = 32, y = 2, x = 3)
private final ConfigProperty<Integer> 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<Integer> 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<Integer> 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<Integer> 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<Integer> tridentPercentage = new ConfigProperty<>(5);

@Override
public ConfigProperty<Boolean> enabled() {
Expand Down Expand Up @@ -70,4 +90,16 @@ public ConfigProperty<Integer> axePercentage() {
public ConfigProperty<Integer> shovelPercentage() {
return shovelPercentage;
}
public ConfigProperty<Integer> crossbowPercentage() {
return crossbowPercentage;
}
public ConfigProperty<Integer> lighterPercentage() {
return lighterPercentage;
}
public ConfigProperty<Integer> shearsPercentage() {
return shearsPercentage;
}
public ConfigProperty<Integer> tridentPercentage() {
return tridentPercentage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class TbwSoundSubConfig extends Config {
@ParentSwitch
private final ConfigProperty<Boolean> enabled = new ConfigProperty<>(true);
@DropdownSetting
@SpriteSlot(size = 32, y = 1, x = 2)
@SpriteSlot(size = 32, y = 1, x = 1)
private final ConfigProperty<WarnSound> warnSound = new ConfigProperty<>(WarnSound.PLING);
@DropdownSetting
@SpriteSlot(size = 32, y = 1, x = 3)
@SpriteSlot(size = 32, y = 1, x = 2)
private final ConfigProperty<WarnSound> lastHitSound = new ConfigProperty<>(WarnSound.ANVIL_USE);

public ConfigProperty<Boolean> enabled() {
Expand Down
19 changes: 13 additions & 6 deletions core/src/main/java/com/rappytv/toolwarn/util/ToolType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import com.rappytv.toolwarn.config.TbwConfiguration;
import net.labymod.api.client.world.item.ItemStack;
import net.labymod.api.util.I18n;

public enum ToolType {
None, Sword, Pickaxe, Axe, Shovel;
None, Sword, Pickaxe, Axe, Shovel, Crossbow, Lighter, Shears, Trident;

public static ToolType getByItem(ItemStack itemStack) {
String path = itemStack.getIdentifier().getPath();
Expand All @@ -17,6 +16,14 @@ 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;
}

Expand All @@ -26,11 +33,11 @@ public int getWarnPercentage(TbwConfiguration configuration) {
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;
};
}

public String displayName() {
return I18n.translate("toolwarn.tooltype." + this.name().toLowerCase());
}
}
26 changes: 16 additions & 10 deletions core/src/main/resources/assets/toolwarn/i18n/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,30 @@
}
},
"swordPercentage": {
"name": "Schwertwarnung (%)"
"name": "Schwert-Warnung (%)"
},
"pickaxePercentage": {
"name": "Spitzhackenwarnung (%)"
"name": "Spitzhacken-Warnung (%)"
},
"axePercentage": {
"name": "Axtwarnung (%)"
"name": "Axt-Warnung (%)"
},
"shovelPercentage": {
"name": "Schaufelwarnung (%)"
"name": "Schaufel-Warnung (%)"
},
"crossbowPercentage": {
"name": "Armbrust-Warnung (%)"
},
"lighterPercentage": {
"name": "Feuerzeug-Warnung (%)"
},
"shearsPercentage": {
"name": "Scheren-Warnung (%)"
},
"tridentPercentage": {
"name": "Dreizack-Warnung (%)"
}
},
"tooltype": {
"sword": "Schwert",
"pickaxe": "Spitzhacke",
"axe": "Axt",
"shovel": "Schaufel"
},
"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%%!"
Expand Down
26 changes: 16 additions & 10 deletions core/src/main/resources/assets/toolwarn/i18n/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,30 @@
}
},
"swordPercentage": {
"name": "Sword Warn Percentage"
"name": "Sword warn percentage"
},
"pickaxePercentage": {
"name": "Pickaxe Warn Percentage"
"name": "Pickaxe warn percentage"
},
"axePercentage": {
"name": "Axe Warn Percentage"
"name": "Axe warn percentage"
},
"shovelPercentage": {
"name": "Shovel Warn Percentage"
"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"
}
},
"tooltype": {
"sword": "Sword",
"pickaxe": "Pickaxe",
"axe": "Axe",
"shovel": "Shovel"
},
"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%%!"
Expand Down
Binary file modified core/src/main/resources/assets/toolwarn/textures/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rootProject.name = "toolwarn"

pluginManagement {
val labyGradlePluginVersion = "0.3.38"
val labyGradlePluginVersion = "0.3.44"
plugins {
id("net.labymod.gradle") version (labyGradlePluginVersion)
}
Expand Down

0 comments on commit 3a5d3ee

Please sign in to comment.