Skip to content

Commit

Permalink
V1.2.1 bugfixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
abc123me committed Dec 11, 2022
1 parent c089ee8 commit 2985850
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 23 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/jeremiahbl/bfcmod/BetterForgeChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
// The value here should match an entry in the META-INF/mods.toml file
@Mod(BetterForgeChat.MODID)
public class BetterForgeChat {
public static final String CHAT_ID_STR =
"&cBetter &9&lForge &eChat&r &d(c) Jeremiah Lowe 2022-2023&r\n";
public static final String MODID = "bfcmod";
public static final String VERSION = "V1.2";
public static final String VERSION = "V1.2.1";
public static final Logger LOGGER = LogUtils.getLogger();
public static BetterForgeChat instance;

Expand Down
28 changes: 11 additions & 17 deletions src/main/java/com/jeremiahbl/bfcmod/TextFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,17 @@ public static final TextComponent stringToFormattedText(String msg, boolean enab
curStr += "&";
} else nextIsStyle = true;
} else if(nextIsStyle) {
boolean makeNewComponent = false;
if(isStyle(c)) {
curStyle |= BitwiseStyling.getStyleBit(c);
makeNewComponent = c == 'r';
} else if(isColor(c)) {
makeNewComponent = true;
} else curStr += ("&" + c);
if(makeNewComponent) {
TextComponent tmp = BitwiseStyling.makeEncapsulatingTextComponent(curStr, enableStyles ? curStyle : 0);
tmp.withStyle(curColor);
newMsg.append(tmp);
if(enableColors)
curColor = getColor(c, curColor);
curStr = "";
if(makeNewComponent && c == 'r')
curStyle = 0;
}
TextComponent tmp = BitwiseStyling.makeEncapsulatingTextComponent(curStr, enableStyles ? curStyle : 0);
tmp.withStyle(curColor);
newMsg.append(tmp);
if(enableColors)
curColor = getColor(c, curColor);
curStr = "";

if(c == 'r') {
curColor = ChatFormatting.WHITE;
curStyle = 0;
} else curStyle |= BitwiseStyling.getStyleBit(c);
nextIsStyle = false;
} else curStr += c;
}
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/com/jeremiahbl/bfcmod/commands/BfcCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import net.minecraftforge.server.permission.nodes.PermissionNode;

public class BfcCommands {
private static final Iterable<String> bfcModSubCommands = Arrays.asList(new String[] { "info", "colors" });
private static final Iterable<String> bfcModSubCommands = Arrays.asList(new String[] {
"info", "colors", "test"
});

protected static boolean checkPermission(CommandSourceStack c, PermissionNode<Boolean> node) {
try {
Expand Down Expand Up @@ -57,17 +59,30 @@ public static int modCommand(CommandContext<CommandSourceStack> ctx) {
else return failNoPermission(ctx);
} else if(arg.contentEquals("info")) {
if(checkContextPermission(ctx, PermissionsHandler.bfcModCommandInfoSubCommand)) {
boolean hasMetaProv = BetterForgeChat.instance.metadataProvider != null;
boolean hasNickProv = BetterForgeChat.instance.nicknameProvider != null;
String metaProvName = hasMetaProv ? BetterForgeChat.instance.metadataProvider.getProviderName() : "";
String nickProvName = hasNickProv ? BetterForgeChat.instance.metadataProvider.getProviderName() : "";
if(hasMetaProv) metaProvName = "(via " + metaProvName + ")";
if(hasNickProv) nickProvName = "(via " + nickProvName + ")";
ctx.getSource().sendSuccess(TextFormatter.stringToFormattedText(
"Forge+LitePerms Chat Mod (c) Jeremiah Lowe 2022-2023\n"
+ BetterForgeChat.MODID + " " + BetterForgeChat.VERSION), false);
BetterForgeChat.CHAT_ID_STR + "&e" + BetterForgeChat.MODID + " " + BetterForgeChat.VERSION + "&r\n"
+ (hasMetaProv ? "&a&lWITH" : "&c&lWITHOUT") + "&r&e metadata integration" + metaProvName + "&r\n"
+ (hasNickProv ? "&a&lWITH" : "&c&lWITHOUT") + "&r&e nickname integration" + nickProvName + "&r\n"), false);
return 1;
} else return failNoPermission(ctx);
} else if(arg.contentEquals("test")) {
ctx.getSource().sendSuccess(TextFormatter.stringToFormattedText(
BetterForgeChat.CHAT_ID_STR
+ "&eColors & Styling internal debug test&r\n"
+ "Normal &lBold&r &nUnderline&r &oItalic&r &mStrikthrough&r &kObfuscated&r &rReset\n"
+ "Normal &lBold &nUnderline &oItalic &mStrikthrough &kObfuscated &rReset"), false);
return 1;
} else return 0;
}
public static int colorCommand(CommandContext<CommandSourceStack> ctx) {
ctx.getSource().sendSuccess(TextFormatter.stringToFormattedText(
"Forge+LitePerms Chat Mod (c) Jeremiah Lowe 2022-2023\n"
+ TextFormatter.colorString()), false);
BetterForgeChat.CHAT_ID_STR + TextFormatter.colorString()), false);
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mojang.authlib.GameProfile;

public interface IMetadataProvider {
@NonNull public String getProviderName();
@NonNull public default String getPlayerPrefix(@NonNull GameProfile player) { return getPlayerPrefixAndSuffix(player)[0]; }
@NonNull public default String getPlayerSuffix(@NonNull GameProfile player) { return getPlayerPrefixAndSuffix(player)[1]; }
@NonNull public String[] getPlayerPrefixAndSuffix(@NonNull GameProfile player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mojang.authlib.GameProfile;

public interface INicknameProvider {
@NonNull public String getProviderName();
public String getPlayerNickname(@NonNull GameProfile player);
@NonNull public default String getPlayerChatName(@NonNull GameProfile player) {
String nick = getPlayerNickname(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ public class IntegratedNicknameProvider implements INicknameProvider {
@Override public String getPlayerNickname(@NonNull GameProfile player) {
return PlayerData.getNickname(player.getId());
}
@Override public @NonNull String getProviderName() {
return "BetterForgeChat";
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jeremiahbl.bfcmod.utils.moddeps;

import org.checkerframework.checker.nullness.qual.NonNull;

import com.jeremiahbl.bfcmod.utils.INicknameProvider;
import com.mojang.authlib.GameProfile;

Expand All @@ -16,4 +18,8 @@ public FTBNicknameProvider() {
return data.nick;
return null;
}
@Override public @NonNull String getProviderName() {
return "FTB Essentials";
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jeremiahbl.bfcmod.utils.moddeps;

import org.checkerframework.checker.nullness.qual.NonNull;

import com.jeremiahbl.bfcmod.utils.IMetadataProvider;
import com.mojang.authlib.GameProfile;

Expand Down Expand Up @@ -30,4 +32,7 @@ public LuckPermsProvider(LuckPerms perms) {
return null;
}
}
@Override public @NonNull String getProviderName() {
return "LuckPerms";
}
}

0 comments on commit 2985850

Please sign in to comment.