cleaned up stuff
This commit is contained in:
parent
190e630df4
commit
7624f7ad10
@ -7,9 +7,14 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public abstract class Addon implements EventListener {
|
||||
|
||||
public enum Category {
|
||||
CHAT,
|
||||
UI
|
||||
}
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final Category category;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
public Addon(String name, String description, Category category) {
|
||||
@ -19,12 +24,7 @@ public abstract class Addon implements EventListener {
|
||||
this.enabled = true;
|
||||
|
||||
EventManager.registerListener(this);
|
||||
onEnable();
|
||||
}
|
||||
|
||||
public enum Category {
|
||||
CHAT,
|
||||
UI
|
||||
this.onEnable();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,9 +34,9 @@ public abstract class Addon implements EventListener {
|
||||
this.enabled = !this.enabled;
|
||||
|
||||
if (this.enabled) {
|
||||
onDisable();
|
||||
this.onDisable();
|
||||
} else {
|
||||
onEnable();
|
||||
this.onEnable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
package cc.fascinated.wildaddons.addon;
|
||||
|
||||
import cc.fascinated.wildaddons.addon.impl.chat.AutoWelcomerAddon;
|
||||
import cc.fascinated.wildaddons.addon.impl.chat.MessageFilterAddon;
|
||||
import cc.fascinated.wildaddons.addon.impl.ui.OverlayAddon;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import cc.fascinated.wildaddons.addon.impl.chat.AutoWelcomerAddon;
|
||||
import cc.fascinated.wildaddons.addon.impl.chat.ChatGameHelperAddon;
|
||||
import cc.fascinated.wildaddons.addon.impl.chat.MessageFilterAddon;
|
||||
import cc.fascinated.wildaddons.addon.impl.ui.OverlayAddon;
|
||||
|
||||
public class AddonManager {
|
||||
|
||||
/**
|
||||
@ -14,10 +15,26 @@ public class AddonManager {
|
||||
*/
|
||||
public static final Set<Addon> ADDONS = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Checks if the addon is enabled
|
||||
*
|
||||
* @param clazz the class of the addon
|
||||
* @return true if the addon is enabled, false otherwise
|
||||
*/
|
||||
public static boolean isEnabled(Class<?> clazz) {
|
||||
for (Addon addon : ADDONS) {
|
||||
if (addon.getClass().equals(clazz)) {
|
||||
return addon.isEnabled();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public AddonManager() {
|
||||
registerAddon(new AutoWelcomerAddon());
|
||||
registerAddon(new OverlayAddon());
|
||||
registerAddon(new MessageFilterAddon());
|
||||
this.registerAddon(new AutoWelcomerAddon());
|
||||
this.registerAddon(new OverlayAddon());
|
||||
this.registerAddon(new MessageFilterAddon());
|
||||
this.registerAddon(new ChatGameHelperAddon());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -28,13 +45,4 @@ public class AddonManager {
|
||||
public void registerAddon(Addon addon) {
|
||||
ADDONS.add(addon);
|
||||
}
|
||||
|
||||
public static boolean isEnabled(Class<?> clazz) {
|
||||
for (Addon addon : ADDONS) {
|
||||
if (addon.getClass() == clazz) {
|
||||
return addon.isEnabled();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package cc.fascinated.wildaddons.addon.impl.chat;
|
||||
|
||||
import cc.fascinated.wildaddons.Main;
|
||||
import cc.fascinated.wildaddons.addon.Addon;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
public class ChatGameHelperAddon extends Addon {
|
||||
|
||||
public ChatGameHelperAddon() {
|
||||
super("Chat Game Helper", "Calculates the answers for Chat Games", Category.CHAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(String message, String messageStripped, CallbackInfo ci) {
|
||||
if (!messageStripped.startsWith("✎ MATHS » First player to calculate")) { // Check if the message is a maths chat game
|
||||
return;
|
||||
}
|
||||
ci.cancel();
|
||||
|
||||
String[] parts = message.split(" ");
|
||||
try {
|
||||
int first = Integer.parseInt(parts[7]);
|
||||
String mathExpression = parts[8];
|
||||
int second = Integer.parseInt(parts[9]);
|
||||
int answer = 0;
|
||||
|
||||
if (mathExpression.equals("*")) {
|
||||
answer = first * second;
|
||||
}
|
||||
if (mathExpression.equals("+")) {
|
||||
answer = first + second;
|
||||
}
|
||||
if (mathExpression.equals("-")) {
|
||||
answer = first - second;
|
||||
}
|
||||
if (mathExpression.equals("/")) {
|
||||
answer = first / second;
|
||||
}
|
||||
|
||||
Main.getMinecraftClient().inGameHud.getChatHud().addToMessageHistory(message + " §[Answer: " + answer + "]");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cc.fascinated.wildaddons.addon.impl.chat;
|
||||
|
||||
import cc.fascinated.wildaddons.Main;
|
||||
import cc.fascinated.wildaddons.addon.Addon;
|
||||
import cc.fascinated.wildaddons.statistic.Statistic;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@ -17,21 +18,30 @@ public class MessageFilterAddon extends Addon {
|
||||
//"has just won a",
|
||||
"+ KeyFinder",
|
||||
"ALERT",
|
||||
"WILDPASS",
|
||||
"VALUE",
|
||||
"----------------------------------------------------"
|
||||
"WILDPASS"
|
||||
);
|
||||
|
||||
private String lastMessage = null;
|
||||
|
||||
public MessageFilterAddon() {
|
||||
super("Chat Filter", "Removes all the junk messages from chat.", Category.CHAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(String message, String messageStripped, CallbackInfo ci) {
|
||||
if (message.equals("")) {
|
||||
Main.getMinecraftClient().inGameHud.getChatHud().addToMessageHistory("");
|
||||
if (lastMessage != null && lastMessage.equals(message)) { // Fixes double new lines for certain messages
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
lastMessage = message;
|
||||
|
||||
if (messageStripped.equals("----------------------------------------------------")) {
|
||||
ci.cancel();
|
||||
Main.getMinecraftClient().inGameHud.getChatHud().addToMessageHistory("");
|
||||
return;
|
||||
}
|
||||
|
||||
for (String check : toRemove) {
|
||||
if (messageStripped.startsWith(check)) {
|
||||
ci.cancel();
|
||||
|
@ -4,21 +4,17 @@ import cc.fascinated.wildaddons.Main;
|
||||
import cc.fascinated.wildaddons.addon.Addon;
|
||||
import cc.fascinated.wildaddons.listener.ActivePotionsListener;
|
||||
import cc.fascinated.wildaddons.listener.ArmorListener;
|
||||
import cc.fascinated.wildaddons.listener.PlayerListener;
|
||||
import cc.fascinated.wildaddons.listener.ResearchTasksListener;
|
||||
import cc.fascinated.wildaddons.statistic.Statistic;
|
||||
import cc.fascinated.wildaddons.tpsmonitor.TpsMonitor;
|
||||
import cc.fascinated.wildaddons.utils.GameUtils;
|
||||
import cc.fascinated.wildaddons.utils.NumberUtils;
|
||||
import cc.fascinated.wildaddons.utils.PlayerUtils;
|
||||
import lombok.Getter;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class OverlayAddon extends Addon {
|
||||
|
||||
@ -28,8 +24,8 @@ public class OverlayAddon extends Addon {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
HudRenderCallback.EVENT.register((matrixStack, somefloatidkwhatitdoes) -> {
|
||||
if (!this.isEnabled() || Main.getMinecraftClient().options.debugEnabled) { // Check if module is enabled or, if f3 debug menu is open
|
||||
HudRenderCallback.EVENT.register((matrixStack, yes) -> {
|
||||
if (!this.isEnabled() || Main.getMinecraftClient().options.debugEnabled) { // Check if module is enabled or if f3 debug menu is open
|
||||
return;
|
||||
}
|
||||
int lastY = 5;
|
||||
|
@ -21,7 +21,7 @@ public class ArmorListener implements EventListener {
|
||||
/**
|
||||
* The current multipliers from armor
|
||||
*/
|
||||
@Getter private static Map<String, Double> armorMultipliers = new HashMap<>();
|
||||
@Getter private static final Map<String, Double> armorMultipliers = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onTick(int ticksPassed) {
|
||||
|
@ -1,11 +1,8 @@
|
||||
package cc.fascinated.wildaddons.listener;
|
||||
|
||||
import cc.fascinated.wildaddons.Main;
|
||||
import cc.fascinated.wildaddons.event.EventListener;
|
||||
import cc.fascinated.wildaddons.utils.PlayerUtils;
|
||||
import cc.fascinated.wildaddons.utils.TextUtils;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
|
@ -5,14 +5,19 @@ import cc.fascinated.wildaddons.event.EventManager;
|
||||
import cc.fascinated.wildaddons.utils.PlayerUtils;
|
||||
import cc.fascinated.wildaddons.utils.TextUtils;
|
||||
import net.minecraft.client.gui.hud.ChatHud;
|
||||
import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
||||
import net.minecraft.network.message.MessageSignatureData;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(ChatHud.class)
|
||||
public class ChatHudMixin {
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
package cc.fascinated.wildaddons.mixin;
|
||||
|
||||
import cc.fascinated.wildaddons.addon.impl.ui.OverlayAddon;
|
||||
import cc.fascinated.wildaddons.event.EventListener;
|
||||
import cc.fascinated.wildaddons.event.EventManager;
|
||||
import cc.fascinated.wildaddons.utils.TextUtils;
|
||||
import net.minecraft.client.gui.hud.PlayerListHud;
|
||||
import net.minecraft.text.Text;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
@ -8,6 +8,7 @@ import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket;
|
||||
|
||||
public class TpsMonitor implements EventListener {
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
private static final EvictingQueue<Float> serverTPS = EvictingQueue.create(3);
|
||||
private static long systemTime = 0;
|
||||
private static long worldTicks = 0;
|
||||
|
Reference in New Issue
Block a user