Compare commits

..

2 commits

2 changed files with 32 additions and 8 deletions

View file

@ -96,7 +96,14 @@ public class SelfCarePlugin extends Bot.Listener {
// chat only // chat only
if (selfCares.op && permissionLevel < 2) bot.chat.send("/minecraft:op @s[type=player]"); if (selfCares.op && permissionLevel < 2) bot.chat.send("/minecraft:op @s[type=player]");
else if (selfCares.gamemode && gamemode != GameMode.CREATIVE && !bot.options.creayun) bot.chat.send("/minecraft:gamemode creative @s[type=player]"); else if (selfCares.gamemode && gamemode != GameMode.CREATIVE && !bot.options.creayun) bot.chat.send("/minecraft:gamemode creative @s[type=player]");
else if (selfCares.cspy && !cspy && kaboom) bot.chat.send("/commandspy:commandspy on");
// core
else if (selfCares.cspy && !cspy && kaboom) {
if (bot.options.useChat) bot.chat.sendCommandInstantly("/commandspy:commandspy on");
else bot.core.run("commandspy:commandspy " + bot.username + " on");
}
// back to chat only
else if (selfCares.prefix.enabled && !prefix && kaboom && !bot.options.creayun) bot.chat.send("/extras:prefix " + bot.config.selfCare.prefix.prefix); else if (selfCares.prefix.enabled && !prefix && kaboom && !bot.options.creayun) bot.chat.send("/extras:prefix " + bot.config.selfCare.prefix.prefix);
else if (selfCares.username && !username && kaboom) bot.chat.send("/extras:username " + bot.username); else if (selfCares.username && !username && kaboom) bot.chat.send("/extras:username " + bot.username);

View file

@ -9,6 +9,7 @@ import java.util.Map;
public class ColorUtilities { public class ColorUtilities {
private static final Map<Integer, String> ansiToIrcMap = new HashMap<>(); private static final Map<Integer, String> ansiToIrcMap = new HashMap<>();
private static final Map<Integer, String> ansiStyleToIrcMap = new HashMap<>();
public static TextColor getColorByString (String _color) { public static TextColor getColorByString (String _color) {
final String color = _color.toLowerCase(); final String color = _color.toLowerCase();
@ -93,15 +94,24 @@ public class ColorUtilities {
// Author: ChatGPT // Author: ChatGPT
static { static {
ansiToIrcMap.put(30, "01"); // Black -> IRC Black ansiToIrcMap.put(0, "0"); // Reset -> IRC White (is this correct?)
ansiToIrcMap.put(31, "04"); // Red -> IRC Red
ansiToIrcMap.put(32, "09"); // Green -> IRC Green ansiToIrcMap.put(30, "1"); // Black -> IRC Black
ansiToIrcMap.put(33, "08"); // Yellow -> IRC Yellow ansiToIrcMap.put(31, "4"); // Red -> IRC Red
ansiToIrcMap.put(34, "02"); // Blue -> IRC Blue ansiToIrcMap.put(32, "9"); // Green -> IRC Green
ansiToIrcMap.put(33, "8"); // Yellow -> IRC Yellow
ansiToIrcMap.put(34, "2"); // Blue -> IRC Blue
ansiToIrcMap.put(35, "13"); // Magenta -> IRC Magenta (Purple) ansiToIrcMap.put(35, "13"); // Magenta -> IRC Magenta (Purple)
ansiToIrcMap.put(36, "11"); // Cyan -> IRC Cyan ansiToIrcMap.put(36, "11"); // Cyan -> IRC Cyan
ansiToIrcMap.put(37, "00"); // White -> IRC White ansiToIrcMap.put(37, "0"); // White -> IRC White
ansiToIrcMap.put(39, "00"); // White -> IRC White ansiToIrcMap.put(39, "0"); // White -> IRC White
ansiToIrcMap.put(92, "9"); // Green -> IRC Green
ansiToIrcMap.put(96, "2"); // Blue -> IRC Blue
ansiToIrcMap.put(91, "4"); // Red -> IRC Red
ansiToIrcMap.put(95, "13"); // Magenta -> IRC Magenta (Purple)
ansiToIrcMap.put(93, "8"); // Yellow -> IRC Yellow
ansiToIrcMap.put(97, "0"); // White -> IRC White
final Map<Integer, String> clone = new HashMap<>(ansiToIrcMap); final Map<Integer, String> clone = new HashMap<>(ansiToIrcMap);
@ -110,6 +120,11 @@ public class ColorUtilities {
} }
ansiToIrcMap.put(49, "01"); ansiToIrcMap.put(49, "01");
// Styles
ansiStyleToIrcMap.put(1, "\u0002"); // Bold
ansiStyleToIrcMap.put(3, "\u001d"); // Italic
ansiStyleToIrcMap.put(4, "\u001f"); // Underlined
} }
public static String convertAnsiToIrc(String input) { public static String convertAnsiToIrc(String input) {
@ -129,6 +144,8 @@ public class ColorUtilities {
int ansiColorCode = Integer.parseInt(code); int ansiColorCode = Integer.parseInt(code);
if (ansiToIrcMap.containsKey(ansiColorCode)) { if (ansiToIrcMap.containsKey(ansiColorCode)) {
result.append("\u0003").append(ansiToIrcMap.get(ansiColorCode)); result.append("\u0003").append(ansiToIrcMap.get(ansiColorCode));
} else if (ansiStyleToIrcMap.containsKey(ansiColorCode)) {
result.append(ansiStyleToIrcMap.get(ansiColorCode));
} }
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
} }