diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-11-17 18:05:02 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-11-17 18:05:02 +0800 |
commit | 5df6618fd38eee6b1bb9d16c2cc21eec6e7ad459 (patch) | |
tree | 84e8a2787fe88a9ae971c7b0bdb7f6e79d321283 | |
parent | 5e68ecb56a9ec04c55809c1471bd836b99a062ef (diff) | |
download | SoopyV2-5df6618fd38eee6b1bb9d16c2cc21eec6e7ad459.tar.gz SoopyV2-5df6618fd38eee6b1bb9d16c2cc21eec6e7ad459.tar.bz2 SoopyV2-5df6618fd38eee6b1bb9d16c2cc21eec6e7ad459.zip |
Refactoring
-rw-r--r-- | featureClass/featureManager.js | 2 | ||||
-rw-r--r-- | features/cosmetics/cosmetic.js | 6 | ||||
-rw-r--r-- | features/cosmetics/cosmetic/dragon/dragonWings.js | 11 | ||||
-rw-r--r-- | features/cosmetics/index.js | 76 | ||||
-rw-r--r-- | features/dungeonSolvers/index.js | 2 | ||||
-rw-r--r-- | features/globalSettings/index.js | 2 | ||||
-rw-r--r-- | features/slayers/index.js | 2 |
7 files changed, 43 insertions, 58 deletions
diff --git a/featureClass/featureManager.js b/featureClass/featureManager.js index 0d9101b..af539c4 100644 --- a/featureClass/featureManager.js +++ b/featureClass/featureManager.js @@ -245,7 +245,7 @@ class FeatureManager { registerStep(isFps, interval, func, context){ let event = this.registerCustom("step", func, context) - event.trigger[isFps?"setFps":"setDelay"](interval) //TODO: make this group events similar to registerEvent() + event.trigger[isFps?"setFps":"setDelay"](interval) return event } diff --git a/features/cosmetics/cosmetic.js b/features/cosmetics/cosmetic.js index 4b52fa8..1627f2f 100644 --- a/features/cosmetics/cosmetic.js +++ b/features/cosmetics/cosmetic.js @@ -1,11 +1,15 @@ class Cosmetic{ - constructor(player, parent){ + constructor(player, parent, id){ /** * @type {PlayerMP | Player} */ this.player = player this.parent = parent + + this.id = id + + this.settings = this.parent.getPlayerCosmeticSettings(this.player, id) } onRender(){ diff --git a/features/cosmetics/cosmetic/dragon/dragonWings.js b/features/cosmetics/cosmetic/dragon/dragonWings.js index a5b76d8..28d51bb 100644 --- a/features/cosmetics/cosmetic/dragon/dragonWings.js +++ b/features/cosmetics/cosmetic/dragon/dragonWings.js @@ -8,7 +8,7 @@ const EssentialCosmeticSlot = Java.type("gg.essential.cosmetics.CosmeticSlot") const FACING = Java.type("net.minecraft.block.BlockDirectional").field_176387_N let dragon = new ModelDragon(0) //too lazy to make my own model so i just yoink it from modelDragon lmfao -let textures = { +let textures = {//TODO: dynamicly load textures from server classic: new Image(javax.imageio.ImageIO.read(new java.io.File("./config/ChatTriggers/modules/SoopyV2/features/cosmetics/textures/dragon/classic.png"))), purple: new Image(javax.imageio.ImageIO.read(new java.io.File("./config/ChatTriggers/modules/SoopyV2/features/cosmetics/textures/dragon/purple.png"))) } @@ -18,15 +18,14 @@ const GL11 = Java.type("org.lwjgl.opengl.GL11"); class DragonWings extends Cosmetic { constructor(player, parent) { - super(player, parent); - - this.settings = this.parent.getPlayerCosmeticSettings(this.player, "dragon_wings") + super(player, parent, "dragon_wings"); this.animOffset = Math.random()*20*Math.PI this.lastRender = Date.now() this.lastFlapSound = this.animOffset } + onRender(ticks){ if(this.player.getPlayer().func_98034_c(Player.getPlayer())){ @@ -291,7 +290,7 @@ class DragonWings extends Cosmetic { if(wingCosmetic !== null){ this.player.getPlayer().getEssentialCosmeticModels().get(Essential.instance.getConnectionManager().getCosmeticsManager().getCosmetic(wingCosmetic)).getModel().getModel().boneList.forEach(b=>{ b.isHidden = true - this.parent.hiddenCosmetics.push(b) + this.parent.hiddenEssentialCosmetics.push(b) }) }else{ let fullBodyCosmetic = this.player.getPlayer().getEssentialCosmetics().get(EssentialCosmeticSlot.FULL_BODY) @@ -300,7 +299,7 @@ class DragonWings extends Cosmetic { if(b.boxName === "wing_left_1" || b.boxName === "wing_right_1"){ b.isHidden = true - this.parent.hiddenCosmetics.push(b) + this.parent.hiddenEssentialCosmetics.push(b) } }) } diff --git a/features/cosmetics/index.js b/features/cosmetics/index.js index 4fb1242..11f3abd 100644 --- a/features/cosmetics/index.js +++ b/features/cosmetics/index.js @@ -3,8 +3,6 @@ import Feature from "../../featureClass/class"; import DragonWings from "./cosmetic/dragon/dragonWings" import Toggle from "../settings/settingThings/toggle" -const Essential = Java.type("gg.essential.Essential") -const EssentialCosmeticSlot = Java.type("gg.essential.cosmetics.CosmeticSlot") class Cosmetics extends Feature { constructor() { @@ -18,7 +16,11 @@ class Cosmetics extends Feature { this.cosmeticsData = {} - this.hiddenCosmetics = [] + this.hiddenEssentialCosmetics = [] + + this.cosmeticsList = { + "dragon_wings": DragonWings + } this.playerHasACosmeticA = false @@ -52,13 +54,7 @@ class Cosmetics extends Feature { setUserCosmeticsInformation(uuid, cosmetics){ if(!this.enabled) return - this.loadedCosmetics = this.loadedCosmetics.filter(cosmetic=>{ - if(cosmetic.player.getUUID().toString().replace(/-/g,"") === uuid){ - this.uuidToCosmetic[cosmetic.player.getUUID().toString().replace(/-/g,"")] = undefined - return false - } - return true - }) + this.filterUnloadedCosmetics() if(!cosmetics){ delete this.cosmeticsData[uuid] @@ -72,19 +68,21 @@ class Cosmetics extends Feature { this.scanForNewCosmetics() } scanForNewCosmetics(){ - - if(!this.uuidToCosmetic[Player.getUUID().toString().replace(/-/g,"")] && this.shouldPlayerHaveCosmetic(Player, "dragon_wings")){ - let cosmetic = new DragonWings(Player, this) - this.loadedCosmetics.push(cosmetic) - this.uuidToCosmetic[Player.getUUID().toString().replace(/-/g,"")] = cosmetic - } - World.getAllPlayers().forEach(p=>{ - if(p.getUUID().toString().replace(/-/g,"") === Player.getUUID().toString().replace(/-/g,"") || this.uuidToCosmetic[p.getUUID().toString().replace(/-/g,"")]) return - if(this.shouldPlayerHaveCosmetic(p, "dragon_wings")){ - let cosmetic = new DragonWings(p, this) + this.loadCosmeticsForPlayer(p) + }) + } + + loadCosmeticsForPlayer(player){ + Object.keys(this.cosmeticsList).forEach(cosmeticName=>{ + if(!this.uuidToCosmetic[cosmeticName]) this.uuidToCosmetic[cosmeticName] = {} + + if(this.uuidToCosmetic[cosmeticName][player.getUUID().toString().replace(/-/g,"")]) return + + if(this.shouldPlayerHaveCosmetic(player, cosmeticName)){ + let cosmetic = new (this.cosmeticsList[cosmeticName])(player, this) this.loadedCosmetics.push(cosmetic) - this.uuidToCosmetic[p.getUUID().toString().replace(/-/g,"")] = cosmetic + this.uuidToCosmetic[cosmeticName][player.getUUID().toString().replace(/-/g,"")] = cosmetic } }) } @@ -93,37 +91,19 @@ class Cosmetics extends Feature { this.loadedCosmetics = [] this.uuidToCosmetic = {} - if(this.shouldPlayerHaveCosmetic(Player, "dragon_wings") && !this.uuidToCosmetic[Player.getUUID().toString().replace(/-/g,"")]){ - let cosmetic = new DragonWings(Player, this) - this.loadedCosmetics.push(cosmetic) - this.uuidToCosmetic[Player.getUUID().toString().replace(/-/g,"")] = cosmetic - } - - World.getAllPlayers().forEach(p=>{ - if(p.getUUID().toString().replace(/-/g,"") === Player.getUUID().toString().replace(/-/g,"")) return - if(this.shouldPlayerHaveCosmetic(p, "dragon_wings") && !this.uuidToCosmetic[p.getUUID().toString().replace(/-/g,"")]){ - let cosmetic = new DragonWings(p, this) - this.loadedCosmetics.push(cosmetic) - this.uuidToCosmetic[p.getUUID().toString().replace(/-/g,"")] = cosmetic - } - }) + this.scanForNewCosmetics() } playerJoined(player){ if(player.getUUID().toString().replace(/-/g,"") === Player.getUUID().toString().replace(/-/g,"")) return - if(this.shouldPlayerHaveCosmetic(player, "dragon_wings") && !this.uuidToCosmetic[player.getUUID().toString().replace(/-/g,"")]){ - let cosmetic = new DragonWings(player, this) - this.playerHasACosmeticA = true - this.loadedCosmetics.push(cosmetic) - this.uuidToCosmetic[player.getUUID().toString().replace(/-/g,"")] = cosmetic - } + this.loadCosmeticsForPlayer(player) } playerLeft(playerName){ this.loadedCosmetics.filter(cosmetic=>{ if(cosmetic.player.getName() === playerName){ - this.uuidToCosmetic[cosmetic.player.getUUID().toString().replace(/-/g,"")] = undefined + this.uuidToCosmetic[cosmetic.id][cosmetic.player.getUUID().toString().replace(/-/g,"")] = undefined return false } return true @@ -141,11 +121,11 @@ class Cosmetics extends Feature { return this.cosmeticsData[player.getUUID().toString().replace(/-/g,"")]?.[cosmetic] } - filterUnloadedCosmetics(tick){ + filterUnloadedCosmetics(tick=false){ this.loadedCosmetics = this.loadedCosmetics.filter(cosmetic => { if(tick) cosmetic.onTick() if(cosmetic.player.getPlayer().field_70128_L){ //filter out players that are no longer loaded - this.uuidToCosmetic[cosmetic.player.getUUID().toString().replace(/-/g,"")] = undefined + this.uuidToCosmetic[cosmetic.id][cosmetic.player.getUUID().toString().replace(/-/g,"")] = undefined return false } return true @@ -159,10 +139,10 @@ class Cosmetics extends Feature { } restoreEssentialCosmetics(){ - this.hiddenCosmetics.forEach(cosmetic=>{ + this.hiddenEssentialCosmetics.forEach(cosmetic=>{ cosmetic.isHidden = false }) - this.hiddenCosmetics = [] + this.hiddenEssentialCosmetics = [] } renderWorld(ticks){ @@ -176,7 +156,9 @@ class Cosmetics extends Feature { this.uuidToCosmetic = undefined this.playerHasACosmeticA = undefined this.cosmeticsData = undefined - this.hiddenCosmetics = undefined + this.hiddenEssentialCosmetics = undefined + this.hiddenEssentialCosmetics = undefined + this.cosmeticsList = undefined } onDisable(){ diff --git a/features/dungeonSolvers/index.js b/features/dungeonSolvers/index.js index 954c4b8..0d9a825 100644 --- a/features/dungeonSolvers/index.js +++ b/features/dungeonSolvers/index.js @@ -84,7 +84,7 @@ class DungeonSolvers extends Feature { } step(){ //2fps - if(this.lividFindEnabled.getValue() && (this.FeatureManager.features["dataLoader"].class.dungeonFloor === "F5")){ //TODO: fix on M5 + if(this.lividFindEnabled.getValue() && (this.FeatureManager.features["dataLoader"].class.dungeonFloor === "F5")){ //TODO: fix on M5 (detect correct livid based on roof color) World.getAllEntities().forEach(entity => { let entityName = entity.getName() if (/(?:Vendetta|Crossed|Hockey|Doctor|Frog|Smile|Scream|Purple|Arcade) Livid/g.test(entityName)) { diff --git a/features/globalSettings/index.js b/features/globalSettings/index.js index c044a4e..f7ae0b0 100644 --- a/features/globalSettings/index.js +++ b/features/globalSettings/index.js @@ -45,7 +45,7 @@ class Hud extends Feature { this.registerChat("&aYour new API key is &r&b${key}&r", this.newKey) // new Thread(()=>{ - // Thread.sleep(1000) //TODO: DO ON WORLDLOAD + // Thread.sleep(1000) //TODO: DO ON 2nd WORLDLOAD // ChatLib.command("soopyv2 first_load_thing", true)//TODO: ONLY RUN ON FIRST INSTALL // }).start() } diff --git a/features/slayers/index.js b/features/slayers/index.js index 8617a60..7232a0c 100644 --- a/features/slayers/index.js +++ b/features/slayers/index.js @@ -121,7 +121,7 @@ class Slayers extends Feature { if(this.FeatureManager.features["dataLoader"].class.isInSkyblock){ if(!this.entityAttackEventLoaded){ this.entityAttackEventLoaded = true - this.entityAttackEventE = this.registerForge(net.minecraftforge.event.entity.living.LivingAttackEvent, this.entityAttackEvent) //TODO: Use CT event when ct 2.0 because they fixed + this.entityAttackEventE = this.registerForge(net.minecraftforge.event.entity.living.LivingAttackEvent, this.entityAttackEvent) //TODO: Use CT event when ct 2.0 because they made the ct event actually work } }else{ if(this.entityAttackEventLoaded){ |