-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
344 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,65 @@ | ||
<p align="center"> | ||
<img src="src/main/resources/assets/tabby/img/Tabby.gif" alt="Tabby" width="10%" height="10%"> | ||
|
||
--- | ||
|
||
# Tabby | ||
A Minecraft Fabric mod that extends the "player list" that is shown when holding tab | ||
Tabby is a highly customisable Fabric mod for Minecraft that adds extra utility to the tab list. | ||
|
||
Tabby adds many utilities to the tab list such as: | ||
- Configurable settings to change the amount of players shown and the amount of rows | ||
- A highly configurable file to define groups of name colours and formats, full RGB and Minecraft formatting, read [here](#groups-config) for setup help | ||
- Option to remove or change the headers and footers on tab, no more obnoxious advertising | ||
|
||
Join my Discord at https://discord.gg/ey6ZvnwAJp for support and discussion. | ||
|
||
<img src="src/main/resources/assets/tabby/img/Tabby.png" alt="Tabby" width="75%" height="75%"> | ||
|
||
## Installation | ||
Download the mod from [here](https://github.com/Fruitloopins/Tabby/releases/latest) | ||
|
||
Additionally, this mod requires: | ||
- [Cloth Config API](https://modrinth.com/mod/cloth-config) | ||
- [Fabric API](https://modrinth.com/mod/fabric-api) | ||
- and optionally (highly recommended) [Mod Menu](https://modrinth.com/mod/modmenu) to view the config | ||
|
||
You will most likely have some, or all of these dependencies installed if you already use Fabric mods. | ||
|
||
If you have never used or installed Fabric before, learn how to install it [here](https://fabricmc.net/wiki/install) | ||
|
||
### Navigating to .minecraft | ||
Read [here](https://minecraft.fandom.com/wiki/.minecraft#Locating_.minecraft) for a guide for your OS on how to do navigate to the .minecraft directory. | ||
|
||
## Groups Config | ||
> Launch Minecraft with Tabby installed before following this guide to create the relevant files | ||
If you would like to customise the formatting of specific usernames in tab, you must navigate to your ".minecraft" folder, read [here](#navigating-to-minecraft) for help with that. There is regrettably no in-game editor for this functionality as of now. | ||
|
||
Once you have reached the .minecraft directory, navigate to `.minecraft/config/Tabby`. You will find that there is already a file here named "groups.json", the groups defined by default in this file are staff of the server I develop for, EarthMC. | ||
|
||
You are free to edit this file as you like, however, it is important that you follow the structure I have laid out. Below is an example of the "bare minimum": | ||
```json | ||
[ | ||
{ | ||
"group": "Friends", | ||
"colour": "GOLD", | ||
"bold": false, | ||
"italic": false, | ||
"underline": false, | ||
"strikethrough": false, | ||
"obfuscated": false, | ||
"usernames": [ | ||
"Fruitloopins", | ||
"Uberstrase" | ||
] | ||
} | ||
] | ||
``` | ||
|
||
If you don't understand what you are doing when editing this file you should just replace the default values I have already put there rather than attempting to start from scratch. If you have made an irreparable mistake you can delete the file or folder and restart your client to re-initialise the file. | ||
|
||
- "group" can be any string you like | ||
- "colour" can be any of the colours listed [here](https://www.digminecraft.com/lists/color_list_pc.php) i.e. BLACK, DARK_AQUA, RED etc. or you can choose a hexadecimal number, i.e. 4A412A | ||
- All boolean values (bold-obfuscated) must be present even if you are not setting them to true | ||
|
||
This mod requires Cloth Config API, Fabric API and Mod Menu to view the config. Join my Discord at https://discord.gg/ey6ZvnwAJp for support and discussion. | ||
![2023-04-23_06 47 15](https://user-images.githubusercontent.com/49851457/233806357-9169f9f4-f63a-483e-ad25-df73d26ee531.png) | ||
You can define as many groups as you like. If you make changes while in-game, you can press F9 to reload them on the fly. This is due to the JSON being cached to prevent lag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.fwloopins.tabby.config; | ||
|
||
import com.fwloopins.tabby.Tabby; | ||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonParser; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
public class DataManager { | ||
private static JsonArray cachedJson = null; | ||
|
||
public static void initFiles() { | ||
Path dir = FabricLoader.getInstance().getConfigDir().resolve("Tabby"); | ||
|
||
try { | ||
if (!Files.exists(dir.resolve("groups.json"))) { | ||
InputStream json = DataManager.class.getClassLoader().getResourceAsStream("assets/tabby/groups.json"); | ||
|
||
if (!Files.exists(dir)) | ||
Files.createDirectory(dir); | ||
|
||
Files.copy(json, dir.resolve("groups.json")); | ||
} | ||
} catch (IOException e) { | ||
Tabby.LOGGER.error("Failed to copy groups.json to " + dir, e); | ||
} | ||
} | ||
|
||
public static void cacheJson() { | ||
try { | ||
BufferedReader reader = Files.newBufferedReader(FabricLoader.getInstance().getConfigDir().resolve("Tabby/groups.json"), StandardCharsets.UTF_8); | ||
JsonElement element = JsonParser.parseReader(reader); | ||
|
||
cachedJson = element.getAsJsonArray(); | ||
} catch (IOException e) { | ||
Tabby.LOGGER.error("Failed to read groups.json", e); | ||
} | ||
} | ||
|
||
public static JsonArray getCachedJson() { | ||
return cachedJson; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.fwloopins.tabby.misc; | ||
|
||
import com.fwloopins.tabby.config.DataManager; | ||
import com.fwloopins.tabby.config.TabbyConfig; | ||
import me.shedaniel.autoconfig.AutoConfig; | ||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; | ||
import net.minecraft.client.option.KeyBinding; | ||
import net.minecraft.client.util.InputUtil; | ||
|
||
public class Reload { | ||
static TabbyConfig config = AutoConfig.getConfigHolder(TabbyConfig.class).getConfig(); | ||
|
||
public static void reload() { | ||
KeyBinding reloadBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding( | ||
"key.reload", | ||
InputUtil.Type.KEYSYM, | ||
config.misc.reloadKey, | ||
"category.tabby" | ||
)); | ||
|
||
ClientTickEvents.END_CLIENT_TICK.register(client -> { | ||
while (reloadBinding.wasPressed()) { | ||
DataManager.cacheJson(); | ||
} | ||
}); | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
src/main/java/com/fwloopins/tabby/mixin/HighlightMixin.java
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
src/main/java/com/fwloopins/tabby/mixin/TabHighlightMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.fwloopins.tabby.mixin; | ||
|
||
import com.fwloopins.tabby.config.DataManager; | ||
import com.fwloopins.tabby.config.TabbyConfig; | ||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import me.shedaniel.autoconfig.AutoConfig; | ||
import net.minecraft.client.gui.hud.PlayerListHud; | ||
import net.minecraft.text.MutableText; | ||
import net.minecraft.text.Style; | ||
import net.minecraft.util.Formatting; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@Mixin(PlayerListHud.class) | ||
public class TabHighlightMixin { | ||
@Unique | ||
TabbyConfig config = AutoConfig.getConfigHolder(TabbyConfig.class).getConfig(); | ||
final List<String> colours = new ArrayList<>(Arrays.asList("DARK_RED", "RED", "GOLD", "YELLOW", "DARK_GREEN", "GREEN", "AQUA", "DARK_AQUA", "DARK_BLUE", "BLUE", "LIGHT_PURPLE", "DARK_PURPLE", "WHITE", "GRAY", "DARK_GRAY", "BLACK")); | ||
|
||
@Inject(method = "applyGameModeFormatting", at = @At("RETURN"), cancellable = true) | ||
private void modifyNameColour(CallbackInfoReturnable<MutableText> cir) { | ||
if (!config.misc.customColours) | ||
return; | ||
|
||
MutableText text = cir.getReturnValue(); | ||
String name = text.getString(); | ||
JsonArray jsonArray = DataManager.getCachedJson().getAsJsonArray(); | ||
|
||
for (JsonElement group : jsonArray) { | ||
JsonArray usernamesArray = group.getAsJsonObject().getAsJsonArray("usernames"); | ||
|
||
for (JsonElement username : usernamesArray) { | ||
if (username.getAsString().equals(name)) { | ||
JsonObject jsonObject = group.getAsJsonObject(); | ||
|
||
String colour = jsonObject.get("colour").getAsString(); | ||
|
||
boolean bold = jsonObject.get("bold").getAsBoolean(); | ||
boolean italic = jsonObject.get("italic").getAsBoolean(); | ||
boolean underline = jsonObject.get("underline").getAsBoolean(); | ||
boolean strikethrough = jsonObject.get("strikethrough").getAsBoolean(); | ||
boolean obfuscated = jsonObject.get("obfuscated").getAsBoolean(); | ||
|
||
if (colours.contains(colour)) { | ||
cir.setReturnValue(text.setStyle(Style.EMPTY.withColor(Formatting.byName(colour)).withBold(bold).withItalic(italic).withUnderline(underline).withStrikethrough(strikethrough).withObfuscated(obfuscated))); | ||
} else { | ||
int rgb = Integer.parseInt(colour, 16); | ||
cir.setReturnValue(text.setStyle(Style.EMPTY.withColor(rgb).withBold(bold).withItalic(italic).withUnderline(underline).withStrikethrough(strikethrough).withObfuscated(obfuscated))); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.