Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Commit a83337c

Browse files
committed
Initial commit
1 parent 64286f9 commit a83337c

File tree

17 files changed

+673
-122
lines changed

17 files changed

+673
-122
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# **Toolbreak Warning 1.16.5**
2+
## [Click here for 1.12.2 Version](https://github.com/RappyLabyAddons/Toolbreak-Warning)
3+
> With this plugin you can prevent breaking your expensive tools, especially when you're mining with high efficiency enchantments and/or haste.
4+
> Adds the command /tbw (Addon Settings as a command)
5+
6+
### You can customize these Settings:
7+
- If the addon is enabled or not
8+
- If durability numbers should be formatted (Formatted = 1.562 | Not Formatted = 1562)
9+
- If you should be warned at durability 0
10+
- If the debug mode is enabled or not (not recommended -> for developing purposes)
11+
- The message that pops up, when your tool's durability is low
12+
- At what percentage of durability the warning should be displayed (customizable for each tooltype)
13+
14+
### Installation
15+
1. Press `Win` + `R`
16+
2. Paste this into the window that popped up: `%appdata%/.minecraft/LabyMod/addons-1.16` and press enter
17+
3. It should open your Labymod addon directory; Paste the [Toolbreak_Warning.jar](https://github.com/RappyLabyAddons/Toolbreak-Warning-1.16.5/releases/download/1.0.0/Toolbreak_Warning.jar) in there.
18+
4. Launch your Labymod client.
19+
20+
If you have any problems with the addon/have update ideas, feel free to
21+
- Open an Issue [here](https://github.com/RappyLabyAddons/Toolbreak-Warning-1.16.5/issues/new/choose)
22+
or
23+
- Open a ticket on my [Discord Server](https://rappytv.com/server) in [this](https://discord.com/channels/815912035124248587/840285653946204181) channel
24+
25+
---
26+
27+
### Social Networks
28+
29+
[<img align="left" alt="RappyTV | Website" width="22px" src="https://raw.githubusercontent.com/iconic/open-iconic/master/svg/globe.svg" />][website]
30+
[<img align="left" alt="RappyTV | YouTube" width="22px" src="https://cdn.jsdelivr.net/npm/simple-icons@v3/icons/youtube.svg" />][youtube]
31+
[<img align="left" alt="RappyTV | Instagram" width="22px" src="https://cdn.jsdelivr.net/npm/simple-icons@v3/icons/instagram.svg" />][instagram]
32+
[<img align="left" alt="RappyTV | Discord" width="22px" src="https://cdn.jsdelivr.net/npm/simple-icons@v3/icons/discord.svg" />][dcServer]
33+
[<img align="left" alt="RappyTV | TikTok" width="22px" src="https://cdn.jsdelivr.net/npm/simple-icons@v3/icons/tiktok.svg" />][tiktok]
34+
35+
[website]: https://rappytv.com/
36+
[youtube]: https://youtube.com/c/RappyTVTutorials
37+
[instagram]: https://instagram.com/rappyytv
38+
[dcbotplaylist]: https://youtube.com/playlist?list=PL-NddfqjbJVZ2-CGquW0I42J9IGUkXq12
39+
[dcServer]: https://rappytv.com/server
40+
[dcBot]: https://rappytv.com/bot
41+
[tiktok]: https://tiktok.com/@rappytv

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ apply plugin: 'eclipse'
2424
apply plugin: 'maven-publish'
2525
apply plugin: 'org.spongepowered.mixin'
2626

27-
version = '1.0.0'
28-
group = 'com.example' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
29-
archivesBaseName = 'Example Addon'
27+
version = '1'
28+
group = 'com.rappytv' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
29+
archivesBaseName = 'tbw'
3030

3131
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
3232

src/main/java/com/example/addon/ExampleAddon.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/main/java/com/example/addon/ExampleAddonTransformer.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/main/java/com/example/addon/mixin/ExampleMixin.java

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
package com.rappytv.tbw;
2+
3+
import com.rappytv.tbw.events.ChatEvent;
4+
import com.rappytv.tbw.events.OnTickEvent;
5+
import com.rappytv.tbw.modules.DurabilityModule;
6+
import net.labymod.api.LabyModAddon;
7+
import net.labymod.settings.elements.*;
8+
import net.labymod.utils.Material;
9+
import net.minecraft.util.ResourceLocation;
10+
11+
import java.util.List;
12+
13+
public class ToolBreakWarning extends LabyModAddon {
14+
15+
public static String prefix = "\u00A79\u00A7lTBW \u00A78\u00bb \u00A7r";
16+
public static boolean enabled = true;
17+
public static boolean format = true;
18+
public static boolean debug = false;
19+
public static String warnMsg = "\u00A7cDo you really want to continue using this tool? Its durability is {durability}%!";
20+
public static String lastHitMsg = "\u00A7cYou should stop using this tool now, this is your last hit!";
21+
public static boolean lastHitWarn = true;
22+
public static int warnPercentageSword = 5;
23+
public static int warnPercentagePickaxe = 5;
24+
public static int warnPercentageAxe = 5;
25+
public static int warnPercentageShovel = 5;
26+
public static ToolBreakWarning instance;
27+
28+
@Override
29+
public void onEnable() {
30+
// Sets the instance
31+
instance = this;
32+
33+
getApi().getEventService().registerListener(new ChatEvent());
34+
getApi().getEventService().registerListener(new OnTickEvent());
35+
getApi().registerModule(new DurabilityModule());
36+
}
37+
38+
@Override
39+
public void loadConfig() {
40+
enabled = !getConfig().has("enabled") || getConfig().get("enabled").getAsBoolean();
41+
format = getConfig().has("format") ? getConfig().get("format").getAsBoolean() : format;
42+
debug = getConfig().has("debug") ? getConfig().get("debug").getAsBoolean() : debug;
43+
warnMsg = getConfig().has("warnmsg") ? getConfig().get("warnmsg").getAsString() : warnMsg;
44+
45+
lastHitWarn = getConfig().has("lastHitWarn") ? getConfig().get("lastHitWarn").getAsBoolean() : lastHitWarn;
46+
warnPercentageSword = getConfig().has("sword") ? getConfig().get("sword").getAsInt() : warnPercentageSword;
47+
warnPercentagePickaxe = getConfig().has("pick") ? getConfig().get("pick").getAsInt() : warnPercentagePickaxe;
48+
warnPercentageAxe = getConfig().has("axe") ? getConfig().get("axe").getAsInt() : warnPercentageAxe;
49+
warnPercentageShovel = getConfig().has("shovel") ? getConfig().get("shovel").getAsInt() : warnPercentageShovel;
50+
}
51+
52+
@Override
53+
protected void fillSettings(List<SettingsElement> list) {
54+
BooleanElement formatBool = new BooleanElement("Format Numbers", new ControlElement.IconData(new ResourceLocation("tbw/textures/format.png")), accepted -> {
55+
format = accepted;
56+
57+
getConfig().addProperty("format", format);
58+
saveConfig();
59+
}, format);
60+
61+
BooleanElement warnOnLastHit = new BooleanElement("Warn on last hit", new ControlElement.IconData(new ResourceLocation("tbw/textures/0p.png")), accepted -> {
62+
lastHitWarn = accepted;
63+
64+
getConfig().addProperty("lastHitWarn", lastHitWarn);
65+
saveConfig();
66+
}, lastHitWarn);
67+
68+
BooleanElement debugBool = new BooleanElement("Debug Mode (Development Feature)", new ControlElement.IconData(new ResourceLocation("tbw/textures/matrix.png")), accepted -> {
69+
debug = accepted;
70+
71+
getConfig().addProperty("debug", debug);
72+
saveConfig();
73+
}, debug);
74+
75+
StringElement warnmsg = new StringElement("Warn Message", new ControlElement.IconData(Material.REDSTONE_TORCH), warnMsg, accepted -> {
76+
warnMsg = accepted;
77+
78+
getConfig().addProperty("msg", warnMsg);
79+
saveConfig();
80+
});
81+
82+
SliderElement swordSlider = new SliderElement("Sword Warn Percentage",
83+
new ControlElement.IconData(Material.IRON_SWORD), warnPercentageSword);
84+
SliderElement pickSlider = new SliderElement("Pickaxe Warn Percentage",
85+
new ControlElement.IconData(Material.IRON_PICKAXE), warnPercentagePickaxe);
86+
SliderElement axeSlider = new SliderElement("Axe Warn Percentage",
87+
new ControlElement.IconData(Material.IRON_AXE), warnPercentageAxe);
88+
SliderElement spadeSlider = new SliderElement("Shovel Warn Percentage",
89+
new ControlElement.IconData(Material.IRON_SHOVEL), warnPercentageShovel);
90+
91+
92+
BooleanElement enabledBool = new BooleanElement("Enabled", new ControlElement.IconData(Material.LEVER), accepted -> {
93+
enabled = accepted;
94+
95+
formatBool.setBlocked(!enabled);
96+
formatBool.setHoverable(enabled);
97+
warnOnLastHit.setBlocked(!enabled);
98+
warnOnLastHit.setHoverable(enabled);
99+
debugBool.setBlocked(!enabled);
100+
debugBool.setHoverable(enabled);
101+
warnmsg.setBlocked(!enabled);
102+
warnmsg.setHoverable(enabled);
103+
swordSlider.setBlocked(!enabled);
104+
swordSlider.setHoverable(enabled);
105+
pickSlider.setBlocked(!enabled);
106+
pickSlider.setHoverable(enabled);
107+
axeSlider.setBlocked(!enabled);
108+
axeSlider.setHoverable(enabled);
109+
spadeSlider.setBlocked(!enabled);
110+
spadeSlider.setHoverable(enabled);
111+
112+
getConfig().addProperty("enabled", enabled);
113+
saveConfig();
114+
}, enabled);
115+
116+
formatBool.setDescriptionText("Unformatted Number: 1561\nFormatted Number: 1.561");
117+
118+
debugBool.setDescriptionText("Sends a message in the chat every tick you're holding a tool.");
119+
120+
warnOnLastHit.setDescriptionText("Warns you when your tool is at 0 durability");
121+
122+
{
123+
// Setting the slider's min & max values
124+
swordSlider.setRange(1, 25);
125+
126+
// Setting slider steps
127+
swordSlider.setSteps(1);
128+
129+
// Adding change listener
130+
swordSlider.addCallback(accepted -> {
131+
warnPercentageSword = accepted;
132+
133+
getConfig().addProperty("sword", warnPercentageSword);
134+
saveConfig();
135+
});
136+
}
137+
138+
{
139+
// Setting the slider's min & max values
140+
pickSlider.setRange(1, 25);
141+
142+
// Setting slider steps
143+
pickSlider.setSteps(1);
144+
145+
// Adding change listener
146+
pickSlider.addCallback(accepted -> {
147+
warnPercentagePickaxe = accepted;
148+
149+
getConfig().addProperty("pick", warnPercentagePickaxe);
150+
saveConfig();
151+
});
152+
}
153+
154+
{
155+
// Setting the slider's min & max values
156+
axeSlider.setRange(1, 25);
157+
158+
// Setting slider steps
159+
axeSlider.setSteps(1);
160+
161+
// Adding change listener
162+
axeSlider.addCallback(accepted -> {
163+
warnPercentageAxe = accepted;
164+
165+
getConfig().addProperty("axe", warnPercentageAxe);
166+
saveConfig();
167+
});
168+
}
169+
170+
{
171+
// Setting the slider's min & max values
172+
spadeSlider.setRange(1, 25);
173+
174+
// Setting slider steps
175+
spadeSlider.setSteps(1);
176+
177+
// Adding change listener
178+
spadeSlider.addCallback(accepted -> {
179+
warnPercentageShovel = accepted;
180+
181+
getConfig().addProperty("shovel", warnPercentageShovel);
182+
saveConfig();
183+
});
184+
}
185+
186+
// Adding setting
187+
list.add(new HeaderElement("General"));
188+
list.add(enabledBool);
189+
list.add(formatBool);
190+
list.add(warnOnLastHit);
191+
list.add(debugBool);
192+
list.add(new HeaderElement("\u00A7cWarn Settings"));
193+
list.add(warnmsg);
194+
list.add(swordSlider);
195+
list.add(pickSlider);
196+
list.add(axeSlider);
197+
list.add(spadeSlider);
198+
}
199+
200+
public static ToolBreakWarning getMain() {
201+
return instance;
202+
}
203+
}

0 commit comments

Comments
 (0)