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

Commit

Permalink
Release 1.2.0
Browse files Browse the repository at this point in the history
Now works without forge
Added new number format option
Now has a prefix when responding to commands
Slash command /ptbreak -> /tbw
  • Loading branch information
RappyTV committed Jun 15, 2022
1 parent 4b91e1b commit 255cf41
Show file tree
Hide file tree
Showing 12 changed files with 342 additions and 227 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# **Toolbreak Warning**
## Only works with forge
## Now works without Forge
> With this plugin you can prevent breaking your expensive tools, especially when you're mining with high efficiency enchantments and/or haste.
> Adds the command /tbw (Addon Settings as a command)
### You can customize these Settings:
- If the addon is enabled or not
- If durability numbers should be formatted (Formatted = 1.562 | Not Formatted = 1562)
- If the debug mode is enabled or not (not recommended)
- The message that pops up, when your tool's durability is low
- At what percentage of durability the warning should come (customizable for each tooltype)

### Installation
1. Press `Win` + `R`
2. Paste this into the window that popped up: `%appdata%/.minecraft/LabyMod/addons-1.12` and press enter
3. It should open your Labymod addon directory; Paste the [Toolbreak_Warning.jar](https://github.com/RappyTV/Toolbreak-Warning/releases/download/1.1.0/Toolbreak_Warning.jar) in there.
3. It should open your Labymod addon directory; Paste the [Toolbreak_Warning.jar](https://github.com/RappyTV/Toolbreak-Warning/releases/download/1.2.0/Toolbreak_Warning.jar) in there.
4. Launch your Labymod client.

If you have any problems with the addon/have update ideas, feel free to
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.0"
group = "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "modid"
version = "1.2"
group = "com.rappytv.tbw" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "tbw"

sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
Expand All @@ -30,7 +30,7 @@ minecraft {
// Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20171003"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}

dependencies {
Expand Down
Binary file added libs/forge.jar
Binary file not shown.
87 changes: 0 additions & 87 deletions src/main/java/com/rappytv/prevtb/events/ChatEvent.java

This file was deleted.

103 changes: 0 additions & 103 deletions src/main/java/com/rappytv/prevtb/util/Util.java

This file was deleted.

113 changes: 113 additions & 0 deletions src/main/java/com/rappytv/tbw/events/ChatEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.rappytv.tbw.events;

import com.rappytv.tbw.main.Main;
import com.rappytv.tbw.util.Util;
import net.labymod.api.events.MessageSendEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

public class ChatEvent implements MessageSendEvent {

@Override
public boolean onSend(String s) {
String[] args = s.split(" ");
if(args[0].equalsIgnoreCase("/tbw")) {
if(args.length < 2) {
Util.msg("\u00A7cPlease provide a valid argument! Args: enable, disable, format, debug", true);
return true;
}
if(args[1].equalsIgnoreCase("enable")) {
Main.enabled = true;

Main.getMain().getConfig().addProperty("enabled", Main.enabled);
Main.getMain().saveConfig();
Util.msg("\u00A7eAddon successfully \u00A7aenabled\u00A7e!", true);
return true;
} else if(args[1].equalsIgnoreCase("disable")) {
Main.enabled = false;

Main.getMain().getConfig().addProperty("enabled", Main.enabled);
Main.getMain().saveConfig();
Util.msg("\u00A7eAddon successfully \u00A7cdisabled\u00A7e!", true);
return true;
} else if(args[1].equalsIgnoreCase("format")) {
if(args.length >= 3) {
if(args[2].equalsIgnoreCase("on")) {
Main.format = true;

Main.getMain().getConfig().addProperty("format", Main.format);
Main.getMain().saveConfig();
Util.msg("\u00A72Number formatting \u00A7esuccessfully \u00A7aenabled\u00A7e!", true);
return true;
} else if(args[2].equalsIgnoreCase("off")) {
Main.format = false;

Main.getMain().getConfig().addProperty("format", Main.format);
Main.getMain().saveConfig();
Util.msg("\u00A7eNumber formatting successfully \u00A7cdisabled\u00A7e!", true);
return true;
} else {
Util.msg("\u00A7cPlease provide a valid argument! Args: on, off", true);
}
} else {
Util.msg("\u00A7cPlease provide a valid argument! Args: on, off", true);
}
return true;
} else if(args[1].equalsIgnoreCase("debug")) {
if(args.length >= 3) {
if(args[2].equalsIgnoreCase("on")) {
Main.enabled = true;
Main.debug = true;

Main.getMain().getConfig().addProperty("debug", Main.debug);
Main.getMain().saveConfig();
Util.msg("\u00A72Debug mode \u00A7esuccessfully \u00A7aenabled\u00A7e!", true);
} else if(args[2].equalsIgnoreCase("once")) {
EntityPlayer p = Minecraft.getMinecraft().player;
ItemStack itemStack = p.getHeldItemMainhand();
Util.msg("\u00A72Debug mode \u00A7esuccessfully \u00A7aenabled \u00A7eonce!", true);

if(Util.isSword(itemStack)) {
int itemWarnInt = (Main.warnPercentageSword * itemStack.getMaxDamage()) / 100;
int itemUsedInt = itemStack.getMaxDamage() - itemStack.getItemDamage();

Util.msg("\u00A7c\u00A7l------ Event triggered ------\n\u00A7eEvent: \u00A74Sword in main hand\n\u00A7eTool used: \u00A74" + (Main.format ? Util.formatNumber(itemUsedInt) : itemUsedInt) + "\n\u00A7eTool warn: \u00A74" + (Main.format ? Util.formatNumber(itemWarnInt) : itemWarnInt) + "\n\u00A7c\u00A7l---------------------------", false);
} else if(Util.isPickaxe(itemStack)) {
int itemWarnInt = (Main.warnPercentagePickaxe * itemStack.getMaxDamage()) / 100;
int itemUsedInt = itemStack.getMaxDamage() - itemStack.getItemDamage();

Util.msg("\u00A7c\u00A7l------ Event triggered ------\n\u00A7eEvent: \u00A74Pickaxe in main hand\n\u00A7eTool used: \u00A74" + (Main.format ? Util.formatNumber(itemUsedInt) : itemUsedInt) + "\n\u00A7eTool warn: \u00A74" + (Main.format ? Util.formatNumber(itemWarnInt) : itemWarnInt) + "\n\u00A7c\u00A7l---------------------------", false);
} else if(Util.isAxe(itemStack)) {
int itemWarnInt = (Main.warnPercentageAxe * itemStack.getMaxDamage()) / 100;
int itemUsedInt = itemStack.getMaxDamage() - itemStack.getItemDamage();

Util.msg("\u00A7c\u00A7l------ Event triggered ------\n\u00A7eEvent: \u00A74Axe in main hand\n\u00A7eTool used: \u00A74" + (Main.format ? Util.formatNumber(itemUsedInt) : itemUsedInt) + "\n\u00A7eTool warn: \u00A74" + (Main.format ? Util.formatNumber(itemWarnInt) : itemWarnInt) + "\n\u00A7c\u00A7l---------------------------", false);
} else if(Util.isShovel(itemStack)) {
int itemWarnInt = (Main.warnPercentageShovel * itemStack.getMaxDamage()) / 100;
int itemUsedInt = itemStack.getMaxDamage() - itemStack.getItemDamage();

Util.msg("\u00A7c\u00A7l------ Event triggered ------\n\u00A7eEvent: \u00A74Shovel in main hand\n\u00A7eTool used: \u00A74" + (Main.format ? Util.formatNumber(itemUsedInt) : itemUsedInt) + "\n\u00A7eTool warn: \u00A74" + (Main.format ? Util.formatNumber(itemWarnInt) : itemWarnInt) + "\n\u00A7c\u00A7l---------------------------", false);
} else {
Util.msg("\u00A7c\u00A7l------ No Event triggered ------\n\u00A7eEvent: \u00A74-\n\u00A7eTool used: \u00A74-\n\u00A7eTool warn: \u00A74-\n\u00A7c\u00A7l------------------------------", false);
}
} else if(args[2].equalsIgnoreCase("off")) {
Main.debug = false;

Main.getMain().getConfig().addProperty("debug", Main.debug);
Main.getMain().saveConfig();
Util.msg("\u00A72Debug mode \u00A7esuccessfully \u00A7cdisabled\u00A7e!", true);
} else {
Util.msg("\u00A7cPlease provide a valid argument! Args: on, off", true);
}
} else {
Util.msg("\u00A7cPlease provide a valid argument! Args: on, once, off", true);
}
return true;
} else {
Util.msg("\u00A7cPlease provide a valid argument! Args: enable, disable, format, debug", true);
return true;
}
} else return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.rappytv.prevtb.events;
package com.rappytv.tbw.events;

import com.rappytv.prevtb.main.Main;
import com.rappytv.prevtb.util.Util;
import com.rappytv.tbw.main.Main;
import com.rappytv.tbw.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
Expand All @@ -11,7 +11,7 @@
public class OnTickEvent {

@SubscribeEvent
public void onTick(TickEvent e) {
public void onTick(TickEvent.ClientTickEvent e) {
if(!Main.enabled) return;
if(Minecraft.getMinecraft().player == null) return;
EntityPlayer p = Minecraft.getMinecraft().player;
Expand All @@ -21,6 +21,9 @@ public void onTick(TickEvent e) {
if(!i.isItemStackDamageable()) return;
if(p.isCreative()) return;

if(Util.isSword(i)) {
Util.swordUsed(i);
}
if(Util.isPickaxe(i)) {
Util.pickaxeUsed(i);
}
Expand Down
Loading

0 comments on commit 255cf41

Please sign in to comment.