aboutsummaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
Diffstat (limited to 'features')
-rw-r--r--features/waypoints/index.js82
-rw-r--r--features/waypoints/minewaypoints_socket.js50
2 files changed, 132 insertions, 0 deletions
diff --git a/features/waypoints/index.js b/features/waypoints/index.js
index d5957e7..229a6a2 100644
--- a/features/waypoints/index.js
+++ b/features/waypoints/index.js
@@ -6,8 +6,19 @@ import { Waypoint } from "../../utils/renderJavaUtils";
import { drawCoolWaypoint } from "../../utils/renderUtils";
import SettingBase from "../settings/settingThings/settingBase";
import ToggleSetting from "../settings/settingThings/toggle";
+import minewaypoints_socket from "./minewaypoints_socket";
+let areas = {
+ "MinesofDivan": "Mines of Divan",
+ "LostPrecursorCity": "Lost Precursor City",
+ "JungleTemple": "Jungle Temple",
+ "GoblinQueensDen": "Goblin Queen's Den",
+ "Khazaddm": "Khazad-dûm",
+ "KingYolkar": "§6King Yolkar",
+ "BossCorleone": "§cBoss Corleone"
+}
+
class Waypoints extends Feature {
constructor() {
super()
@@ -24,6 +35,7 @@ class Waypoints extends Feature {
this.showInfoInChat = new ToggleSetting("Show info in chat", "Should chat msg be sent when theres waypoint added/cleared/removed", true, "waypoints_send_message", this);
this.loadWaypointsFromSendCoords = new ToggleSetting("Load waypoints from /patcher sendcoords messages", "Will dissapear after 1min", true, "load_waypoints_from_sendcoords", this)
+ this.mineWaypointsSetting = new ToggleSetting("CH waypoints", "Will sync between users", true, "minwaypoints", this)
this.userWaypoints = JSON.parse(FileLib.read("soopyAddonsData", "soopyv2userwaypoints.json") || "{}")
this.userWaypointsHash = {}
@@ -140,6 +152,76 @@ class Waypoints extends Feature {
this.tickWaypoints()
}
})
+
+
+ this.lastSend = 0
+ this.locations = {}
+ minewaypoints_socket.setLocationHandler = (area, loc) => {
+ if (!area) return
+ if (area == "undefined") return
+ this.locations[area] = loc;
+ // console.log(JSON.stringify(loc, undefined, 2))
+ }
+
+ this.registerEvent("tick", () => {
+ try {
+ if (Scoreboard.getLines().length < 2) return;
+ let server = ChatLib.removeFormatting(Scoreboard.getLineByIndex(Scoreboard.getLines().length - 1)).split(" ")
+
+ if (server.length === 2) {
+ server = server[1].replace(/[^0-9A-z]/g, "")
+ } else {
+ return;
+ }
+
+ minewaypoints_socket.setServer(server, World.getWorld().func_82737_E())
+
+ if (Date.now() - this.lastSend > 1000) {
+ Scoreboard.getLines().forEach(line => {
+ line = ChatLib.removeFormatting(line.getName()).replace(/[^0-9A-z]/g, "")
+ if (Object.keys(areas).includes(line)) {
+ minewaypoints_socket.setLocation(line, { x: Math.floor(Player.getX()), y: Math.floor(Player.getY()), z: Math.floor(Player.getZ()) })
+ }
+ })
+ this.lastSend = Date.now()
+ }
+ } catch (e) {
+ console.log("SOOPYV2MINEWAYPOINTS ERROR")
+ console.log(JSON.stringify(e, undefined, 2))
+ }
+ })
+
+ this.registerStep(false, 5, () => {
+
+ World.getAllEntities().forEach(e => {
+ if (Math.max(Math.abs(Player.getX() - e.getX()), Math.abs(Player.getY() - e.getY()), Math.abs(Player.getZ() - e.getZ())) > 20) return;
+
+ if (!this.locations["KingYolkar"]) {
+ if (ChatLib.removeFormatting(e.getName()) === "King Yolkar") {
+ minewaypoints_socket.setLocation("KingYolkar", { x: e.getX(), y: e.getY() + 3.5, z: e.getZ() })
+ }
+ }
+ if (ChatLib.removeFormatting(e.getName()).includes("Boss Corleone")) {
+ minewaypoints_socket.setLocation("BossCorleone", { x: e.getX(), y: e.getY() + 3.5, z: e.getZ() })
+ }
+ })
+ // console.log(JSON.stringify(locations, undefined, 2))
+ })
+
+ this.registerEvent("renderWorld", () => {
+ if (!this.mineWaypointsSetting.getValue()) return
+ Object.values(this.locations).forEach(item => {
+ if (!item) return;
+ item.forEach(loc => {
+ // console.log(JSON.stringify(loc, undefined, 2))
+ if (loc.loc.x) {
+ drawCoolWaypoint(loc.loc.x, loc.loc.y, loc.loc.z, 0, 255, 0, { name: areas[loc.area] })
+ } else {
+ drawCoolWaypoint(loc.loc.minX / 2 + loc.loc.maxX / 2, loc.loc.minY / 2 + loc.loc.maxY / 2, loc.loc.minZ / 2 + loc.loc.maxZ / 2, 0, 255, 0, { name: areas[loc.area] })
+ }
+ })
+ })
+ }).registeredWhen(() => this.mineWaypointsSetting.getValue())
}
tickWaypoints() {
diff --git a/features/waypoints/minewaypoints_socket.js b/features/waypoints/minewaypoints_socket.js
new file mode 100644
index 0000000..3a6dcd7
--- /dev/null
+++ b/features/waypoints/minewaypoints_socket.js
@@ -0,0 +1,50 @@
+import socketData from "../../../soopyApis/socketData";
+import WebsiteCommunicator from "../../../soopyApis/websiteCommunicator";
+
+class MineWayPointsServer extends WebsiteCommunicator {
+ constructor() {
+ super(socketData.serverNameToId.minewaypoints);
+
+ this.setLocationHandler = undefined
+ this.hypixelServer = undefined
+ this.lastSend = Date.now()
+ }
+
+ onConnect() {
+ this.hypixelServer = undefined
+ }
+
+ onData(data) {
+ switch (data.type) {
+ case "setLocation":
+ if (this.setLocationHandler) {
+ this.setLocationHandler(data.area, data.location);
+ }
+ break;
+ }
+ }
+
+ setLocation(area, loc) {
+ this.sendData({
+ type: "setLocation",
+ area: area,
+ location: loc
+ });
+ }
+
+ setServer(server, worldTime) {
+ if (this.hypixelServer === server && Date.now() - this.lastSend < 10000) return;
+
+ this.lastSend = Date.now()
+ this.hypixelServer = server
+
+ this.sendData({
+ type: "setServer",
+ server: server,
+ time: worldTime
+ });
+ }
+}
+
+global.soopyV2mineWayPointsServer = new MineWayPointsServer()
+export default global.soopyV2mineWayPointsServer; \ No newline at end of file