Skip to content

Commit c07db09

Browse files
committed
feat: Add UGCSanitize to FirstPersonTransparency
1 parent e6b0838 commit c07db09

11 files changed

+202
-73
lines changed

readme.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Many of these packages represent not just useful code, but useful patterns, or w
5555
### All packages
5656
<!--package-list-generated-start-->
5757

58-
There are 267 packages in Nevermore.
58+
There are 268 packages in Nevermore.
5959

6060
| Package | Description | Install | docs | source | changelog | npm |
6161
| ------- | ----------- | ------- | ---- | ------ | --------- | --- |
@@ -134,7 +134,7 @@ There are 267 packages in Nevermore.
134134
| [EquippedTracker](https://quenty.github.io/NevermoreEngine/api/EquippedTracker) | Tracks the equipped player of a tool | `npm i @quenty/equippedtracker` | [docs](https://quenty.github.io/NevermoreEngine/api/EquippedTracker) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/equippedtracker) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/equippedtracker/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/equippedtracker) |
135135
| [ExperienceCalculator](https://quenty.github.io/NevermoreEngine/api/ExperienceUtils) | Calculate experience on an exponential curve and perform relevant calculations Uses formulas from stackoverflow.com/questions/6954874/php-game-formula-to-calculate-a-level-based-on-exp | `npm i @quenty/experiencecalculator` | [docs](https://quenty.github.io/NevermoreEngine/api/ExperienceUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/experiencecalculator) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/experiencecalculator/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/experiencecalculator) |
136136
| [FakeSkybox](https://quenty.github.io/NevermoreEngine/api/FakeSkybox) | Allow transitions between skyboxes | `npm i @quenty/fakeskybox` | [docs](https://quenty.github.io/NevermoreEngine/api/FakeSkybox) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/fakeskybox) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/fakeskybox/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/fakeskybox) |
137-
| [FirstPersonCharacterTransparency](https://quenty.github.io/NevermoreEngine/api/DisableHatParticles) | Allows transparency to manually be controlled for a character in first-person mode | `npm i @quenty/firstpersoncharactertransparency` | [docs](https://quenty.github.io/NevermoreEngine/api/DisableHatParticles) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/firstpersoncharactertransparency) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/firstpersoncharactertransparency/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/firstpersoncharactertransparency) |
137+
| [FirstPersonCharacterTransparency](https://quenty.github.io/NevermoreEngine/api/ShowBody) | Allows transparency to manually be controlled for a character in first-person mode | `npm i @quenty/firstpersoncharactertransparency` | [docs](https://quenty.github.io/NevermoreEngine/api/ShowBody) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/firstpersoncharactertransparency) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/firstpersoncharactertransparency/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/firstpersoncharactertransparency) |
138138
| [Flipbook](https://quenty.github.io/NevermoreEngine/api/Flipbook) | Handles playing back animated spritesheets | `npm i @quenty/flipbook` | [docs](https://quenty.github.io/NevermoreEngine/api/Flipbook) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/flipbook) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/flipbook/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/flipbook) |
139139
| [FriendUtils](https://quenty.github.io/NevermoreEngine/api/FriendUtils) | Utlity functions to help find friends of a user. Also contains utility to make testing in studio easier. | `npm i @quenty/friendutils` | [docs](https://quenty.github.io/NevermoreEngine/api/FriendUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/friendutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/friendutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/friendutils) |
140140
| [FunctionUtils](https://quenty.github.io/NevermoreEngine/api/FunctionUtils) | Utility functions involving functions | `npm i @quenty/functionutils` | [docs](https://quenty.github.io/NevermoreEngine/api/FunctionUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/functionutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/functionutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/functionutils) |
@@ -314,6 +314,7 @@ There are 267 packages in Nevermore.
314314
| [TransitionModel](https://quenty.github.io/NevermoreEngine/api/TransitionModelUtils) | Helps with Gui visiblity showing and hiding | `npm i @quenty/transitionmodel` | [docs](https://quenty.github.io/NevermoreEngine/api/TransitionModelUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/transitionmodel) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/transitionmodel/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/transitionmodel) |
315315
| [TransparencyService](https://quenty.github.io/NevermoreEngine/api/TransparencyService) | Service that orchistrates transparency setting from multiple colliding sources and handle the transparency appropriately. This means that 2 systems can work with transparency without knowing about each other. | `npm i @quenty/transparencyservice` | [docs](https://quenty.github.io/NevermoreEngine/api/TransparencyService) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/transparencyservice) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/transparencyservice/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/transparencyservice) |
316316
| [Tuple](https://quenty.github.io/NevermoreEngine/api/TupleUtils) | Tuple utility package | `npm i @quenty/tuple` | [docs](https://quenty.github.io/NevermoreEngine/api/TupleUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/tuple) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/tuple/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/tuple) |
317+
| [UGCSanitize](https://quenty.github.io/NevermoreEngine/api/UGCSanitizeUtils) | Sanitizes UGC hats and other items | `npm i @quenty/ugcsanitize` | [docs](https://quenty.github.io/NevermoreEngine/api/UGCSanitizeUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/ugcsanitize) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/ugcsanitize/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/ugcsanitize) |
317318
| [UIObjectUtils](https://quenty.github.io/NevermoreEngine/api/PlayerGuiUtils) | UI object utils library for Roblox | `npm i @quenty/uiobjectutils` | [docs](https://quenty.github.io/NevermoreEngine/api/PlayerGuiUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/uiobjectutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/uiobjectutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/uiobjectutils) |
318319
| [UltrawideContainerUtils](https://quenty.github.io/NevermoreEngine/api/UltrawideContainerUtils) | Creates a 1920x1080 scaling container to handle ultrawide monitors and screens in a reasonable way. This helps keep UI centered and available for ultrawide screens. | `npm i @quenty/ultrawidecontainerutils` | [docs](https://quenty.github.io/NevermoreEngine/api/UltrawideContainerUtils) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/ultrawidecontainerutils) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/ultrawidecontainerutils/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/ultrawidecontainerutils) |
319320
| [UndoStack](https://quenty.github.io/NevermoreEngine/api/UndoStack) | Generalized undo stack for Roblox | `npm i @quenty/undostack` | [docs](https://quenty.github.io/NevermoreEngine/api/UndoStack) | [source](https://github.com/Quenty/NevermoreEngine/tree/main/src/undostack) | [changelog](https://github.com/Quenty/NevermoreEngine/tree/main/src/undostack/CHANGELOG.md) | [npm](https://www.npmjs.com/package/@quenty/undostack) |

src/firstpersoncharactertransparency/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
Allows transparency to manually be controlled for a character in first-person mode
1515

16-
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/DisableHatParticles">View docs →</a></div>
16+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/ShowBody">View docs →</a></div>
1717

1818
## Installation
1919
```

src/firstpersoncharactertransparency/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"@quenty/r15utils": "file:../r15utils",
3636
"@quenty/rx": "file:../rx",
3737
"@quenty/statestack": "file:../statestack",
38-
"@quenty/transparencyservice": "file:../transparencyservice"
38+
"@quenty/transparencyservice": "file:../transparencyservice",
39+
"@quenty/ugcsanitize": "file:../ugcsanitize"
3940
},
4041
"publishConfig": {
4142
"access": "public"

src/firstpersoncharactertransparency/src/Client/DisableHatParticles.lua

-69
This file was deleted.

src/ugcsanitize/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## UGCSanitize
2+
3+
<div align="center">
4+
<a href="http://quenty.github.io/NevermoreEngine/">
5+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
6+
</a>
7+
<a href="https://discord.gg/mhtGUS8">
8+
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
9+
</a>
10+
<a href="https://github.com/Quenty/NevermoreEngine/actions">
11+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
12+
</a>
13+
</div>
14+
15+
Sanitizes UGC hats and other items
16+
17+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/UGCSanitizeUtils">View docs →</a></div>
18+
19+
## Installation
20+
21+
```
22+
npm install @quenty/ugcsanitize --save
23+
```

src/ugcsanitize/default.project.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "ugcsanitize",
3+
"globIgnorePaths": [ "**/.package-lock.json" ],
4+
"tree": {
5+
"$path": "src"
6+
}
7+
}

src/ugcsanitize/package.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "@quenty/ugcsanitize",
3+
"version": "1.0.0",
4+
"description": "Sanitizes UGC hats and other items",
5+
"keywords": [
6+
"Roblox",
7+
"Nevermore",
8+
"Lua",
9+
"ugcsanitize"
10+
],
11+
"bugs": {
12+
"url": "https://github.com/Quenty/NevermoreEngine/issues"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/Quenty/NevermoreEngine.git",
17+
"directory": "src/ugcsanitize/"
18+
},
19+
"funding": {
20+
"type": "patreon",
21+
"url": "https://www.patreon.com/quenty"
22+
},
23+
"license": "MIT",
24+
"contributors": [
25+
"Quenty"
26+
],
27+
"dependencies": {
28+
"@quenty/baseobject": "file:../baseobject",
29+
"@quenty/instanceutils": "file:../instanceutils",
30+
"@quenty/loader": "file:../loader",
31+
"@quenty/maid": "file:../maid",
32+
"@quenty/string": "file:../string"
33+
},
34+
"publishConfig": {
35+
"access": "public"
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
--[=[
2+
@class DisableHatParticles
3+
]=]
4+
5+
local require = require(script.Parent.loader).load(script)
6+
7+
local BaseObject = require("BaseObject")
8+
local RxInstanceUtils = require("RxInstanceUtils")
9+
local String = require("String")
10+
11+
local DisableHatParticles = setmetatable({}, BaseObject)
12+
DisableHatParticles.ClassName = "DisableHatParticles"
13+
DisableHatParticles.__index = DisableHatParticles
14+
15+
function DisableHatParticles.new(character)
16+
local self = setmetatable(BaseObject.new(character), DisableHatParticles)
17+
18+
self._maid:GiveTask(RxInstanceUtils.observeChildrenOfClassBrio(self._obj, "Accessory"):Subscribe(function(brio)
19+
if brio:IsDead() then
20+
return
21+
end
22+
23+
local maid, accessory = brio:ToMaidAndValue()
24+
self:_handleAccessory(maid, accessory)
25+
end))
26+
27+
return self
28+
end
29+
30+
function DisableHatParticles:_handleAccessory(maid, accessory)
31+
maid:GiveTask(accessory.DescendantAdded:Connect(function(descendant)
32+
self:_handleAccessoryDescendant(maid, descendant)
33+
end))
34+
maid:GiveTask(accessory.DescendantRemoving:Connect(function(descendant)
35+
maid[descendant] = nil
36+
end))
37+
38+
for _, descendant in pairs(accessory:GetDescendants()) do
39+
self:_handleAccessoryDescendant(maid, descendant)
40+
end
41+
end
42+
43+
function DisableHatParticles:_handleAccessoryDescendant(maid, descendant)
44+
if descendant:IsA("Fire")
45+
or descendant:IsA("Sparkles")
46+
or descendant:IsA("Smoke")
47+
or descendant:IsA("ParticleEmitter") then
48+
if descendant.Enabled then
49+
maid[descendant] = function()
50+
descendant.Enabled = true
51+
end
52+
53+
descendant.Enabled = false
54+
end
55+
end
56+
57+
-- TODO: This code is unsafe? Use a sound group?
58+
if self:_isASoundScript(descendant) then
59+
maid[descendant] = function()
60+
descendant.Enabled = true
61+
end
62+
63+
descendant.Enabled = false
64+
end
65+
66+
if self:_isSound(descendant) then
67+
local originalVolume = descendant.Volume
68+
maid[descendant] = function()
69+
descendant.Volume = originalVolume
70+
end
71+
72+
descendant.Volume = 0
73+
end
74+
end
75+
76+
function DisableHatParticles:_isASoundScript(descendant)
77+
if not descendant:IsA("LocalScript") then
78+
return false
79+
end
80+
81+
if String.endsWith(descendant.Name, "Sounds") then
82+
return true
83+
end
84+
85+
if String.endsWith(descendant.Name, "Sound") then
86+
return true
87+
end
88+
89+
if String.startsWith(descendant.Name, "Sound") then
90+
return true
91+
end
92+
93+
return false
94+
end
95+
96+
function DisableHatParticles:_isSound(descendant)
97+
-- Sound group check is paranoid but likely to be valid as to identify hat-sounds
98+
return descendant:IsA("Sound") and descendant.SoundGroup == nil
99+
end
100+
101+
return DisableHatParticles
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--[=[
2+
@class UGCSanitizeUtils
3+
]=]
4+
5+
local require = require(script.Parent.loader).load(script)
6+
7+
local UGCSanitizeUtils = {}
8+
9+
return UGCSanitizeUtils
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "node_modules",
3+
"globIgnorePaths": [ "**/.package-lock.json" ],
4+
"tree": {
5+
"$path": { "optional": "../node_modules" }
6+
}
7+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "UGCSanitizeTest",
3+
"globIgnorePaths": [ "**/.package-lock.json" ],
4+
"tree": {
5+
"$className": "DataModel",
6+
"ServerScriptService": {
7+
"ugcsanitize": {
8+
"$path": ".."
9+
}
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)