aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--features/globalSettings/index.js61
-rw-r--r--features/guild/index.js4
-rw-r--r--features/guild/metadata.json2
-rw-r--r--utils/utils.js2
4 files changed, 61 insertions, 8 deletions
diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js
index dbb21fb..a0cdc48 100644
--- a/features/globalSettings/index.js
+++ b/features/globalSettings/index.js
@@ -15,7 +15,7 @@ import { firstLetterCapital } from "../../utils/stringUtils";
import { fetch } from "../../utils/networkUtils";
import socketConnection from "../../socketConnection";
import renderLibs from "../../../guimanager/renderLibs";
-import { f } from "../../../mappings/mappings";
+import { f, m } from "../../../mappings/mappings";
import { addLore, getSBUUID, toMessageWithLinks } from "../../utils/utils";
import { delay } from "../../utils/delayUtils";
const Files = Java.type("java.nio.file.Files")
@@ -54,6 +54,7 @@ class GlobalSettings extends Feature {
this.hideFallingBlocks = new ToggleSetting("Hide falling blocks", "NOTE: This setting is a bit laggy", false, "hide_falling_sand", this)
this.twitchCommands = new ToggleSetting("Ingame twitch bot commands", "Allows u to use twitch bot commands ingame (eg -sa)", true, "twitch_commands_ingame", this)
+ this.handChat = new ToggleSetting("Replace [hand] with ur currently held item", "Only shows for soopy users", true, "hand_chat", this)
this.itemWorth = new ToggleSetting("(Approximate) Item worth in lore", "Accounts for stuff like enchants/recombs ect", false, "item_worth", this)
this.showHecatomb = new ToggleSetting("Show hecatomb enchant info in lore", "", true, "show_hecatomb", this)
this.showChampion = new ToggleSetting("Show champion enchant info in lore", "", true, "show_champion", this)
@@ -256,17 +257,69 @@ class GlobalSettings extends Feature {
})
this.registerEvent("messageSent", (message, event) => {
- if (!this.twitchCommands.getValue()) return
-
- if (message.startsWith("-") && message[1].toLowerCase().match(/[a-z]/)) {
+ if (this.twitchCommands.getValue() && message.startsWith("-") && message[1].toLowerCase().match(/[a-z]/)) {
cancel(event)
ChatLib.addToSentMessageHistory(message)
fetch("http://soopy.dev/api/soopyv2/botcommand?m=" + encodeURIComponent(message.replace("-", "")) + "&u=" + Player.getName()).text(text => {
ChatLib.chat(this.FeatureManager.messagePrefix + "&7" + message)
toMessageWithLinks(this.FeatureManager.messagePrefix + text, "7").chat()
})
+ return;
+ }
+
+ // if (/\[ITEM:[0-9]+\]/g.test(message)) {
+
+
+ // }
+ if (message.toLowerCase().includes("[hand]")) {
+ cancel(event)
+ ChatLib.addToSentMessageHistory(message)
+
+ fetch("http://soopy.dev/api/soopyv2/itemup", {
+ postData: {
+ name: Player.getHeldItem().getName(),
+ lore: Player.getHeldItem().getLore().join("\n")
+ }
+ }).text(text => {
+ if (text.length > 20) {
+ ChatLib.chat(this.FeatureManager.messagePrefix + "There was an error uploading the item data!")
+ return
+ }
+
+ ChatLib.say(message.replace(/\[hand\]/gi, "[ITEM:" + text + "]"))
+ })
+ return;
}
})
+
+ this.registerChat("${*}[ITEM:${*}", (event) => {
+ cancel(event)
+ let message = new Message(event)
+
+ let [_] = message.getUnformattedText().match(/\[ITEM:([0-9]+)\]/g)
+ let id = _.replace("[ITEM:", "").replace(/\]$/g, "")
+
+ fetch("http://soopy.dev/api/soopyv2/itemdown/" + id).json(([name, lore]) => {
+ console.log(JSON.stringify(lore, undefined, 2))
+ for (let i = 0; i < message.getMessageParts().length; i++) {
+ let component = message.getMessageParts()[i]
+
+ if (component.getText().match(/\[ITEM:([0-9]+)\]/g)) {
+ let [_] = component.getText().match(/\[ITEM:([0-9]+)\]/g)
+ let id = _.replace("[ITEM:", "").replace(/\]$/g, "")
+
+ message.setTextComponent(i, new TextComponent(component.getText().replace("[ITEM:" + id + "]", name + "&r")).setHover("show_text", lore))
+ }
+ }
+ message.setRecursive(true)
+ message.chat()
+ }).error(() => {
+ ChatLib.chat(this.FeatureManager.messagePrefix + "There was an error downloading the item data!")
+ message.setRecursive(true)
+ message.chat()
+ })
+
+ })
}
worldLoad() {
diff --git a/features/guild/index.js b/features/guild/index.js
index 8be193b..73d298b 100644
--- a/features/guild/index.js
+++ b/features/guild/index.js
@@ -45,8 +45,8 @@ class Guild extends Feature {
message = `&2B${this.shortenPrefix.getValue() ? "" : "ridge"} > &7⤷&f ${msg.trim()}`
}
} else {
- if (msg.match(/^@\w+, [\w\W]+[,.]+/)) {
- let [_, name2, reply] = msg.match(/^@(\w+?), ([\w\W]+?)[,.]+/)
+ if (msg.match(/^@\w+, [\w\W]+[,.]+$/)) {
+ let [_, name2, reply] = msg.match(/^@(\w+?), ([\w\W]+?)[,.]+$/)
message = `&2B${this.shortenPrefix.getValue() ? "" : "ridge"} > &b${name2} &7⤷&f ${reply.trim()}`
} else {
message = `&2G${this.shortenPrefix.getValue() ? "" : "uild"} > ${rank}${ign}${grank || ""}&f: ${msg}`
diff --git a/features/guild/metadata.json b/features/guild/metadata.json
index a75b3e4..babd19d 100644
--- a/features/guild/metadata.json
+++ b/features/guild/metadata.json
@@ -3,6 +3,6 @@
"description": "Features nice for guilds, eg bridge formatting",
"isHidden": false,
"isTogglable": true,
- "defaultEnabled": true,
+ "defaultEnabled": false,
"sortA": 1
} \ No newline at end of file
diff --git a/utils/utils.js b/utils/utils.js
index 0e916ae..1f6cd6e 100644
--- a/utils/utils.js
+++ b/utils/utils.js
@@ -130,7 +130,7 @@ let utils = {
return c
}, ["&" + color]).map(a => {
if (a.match(/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/igm)) {
- return new TextComponent("&" + color + "&n" + a + "&" + color + ' ').setHover("show_text", "Click to open " + a.trim()).setClick("open_url", a.trim())
+ return new TextComponent("&" + color + "&n" + a + "&" + color + ' ').setHover("show_text", "Click to open " + a.trim().replace(/^(?:[&§][0-9a-fmn])+|(?:[&§][0-9a-fmn])+$/g, "")).setClick("open_url", a.trim())
} else {
return new TextComponent(a + ' ')
}