Merge remote-tracking branch 'origin/unstable' into unstable

This commit is contained in:
KingRainbow44 2023-05-12 19:05:18 -04:00
commit 63488f826a
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
3 changed files with 6 additions and 18 deletions

View File

@ -12,8 +12,7 @@ function invalid(value: number): boolean {
*/ */
function basicGive(item: number, amount = 1): string { function basicGive(item: number, amount = 1): string {
// Validate the numbers. // Validate the numbers.
if (invalid(item) || invalid(amount)) if (invalid(item) || invalid(amount)) return "Invalid arguments.";
return "Invalid arguments.";
return `/give ${item} x${amount}`; return `/give ${item} x${amount}`;
} }

View File

@ -38,9 +38,7 @@ class TextState extends React.Component<IProps, IState> {
} }
render() { render() {
return this.state.state ? return this.state.state ? this.props.text2 : this.props.text1;
this.props.text2 :
this.props.text1;
} }
} }

View File

@ -86,15 +86,12 @@ class ItemCard extends React.Component<IProps, IState> {
*/ */
private async addToInventory(): Promise<void> { private async addToInventory(): Promise<void> {
const item = this.props.item?.id ?? 102; const item = this.props.item?.id ?? 102;
const amount = typeof this.state.count == "string" ? const amount = typeof this.state.count == "string" ? parseInt(this.state.count) : this.state.count;
parseInt(this.state.count) :
this.state.count;
if (connected) { if (connected) {
await giveItem(item, amount); await giveItem(item, amount);
} else { } else {
await copyToClipboard( await copyToClipboard(give.basic(item, amount));
give.basic(item, amount));
} }
} }
@ -165,14 +162,8 @@ class ItemCard extends React.Component<IProps, IState> {
</div> </div>
</div> </div>
<button className={"ItemCard_Submit"} <button className={"ItemCard_Submit"} onClick={this.addToInventory.bind(this)}>
onClick={this.addToInventory.bind(this)} <TextState event={"connected"} text1={"Copy Command"} text2={"Add to Inventory"} />
>
<TextState
event={"connected"}
text1={"Copy Command"}
text2={"Add to Inventory"}
/>
</button> </button>
</div> </div>
</div> </div>