-
-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improve Inventory Cleaner item count constraints interface (#3796)
* Improved item limits * Fix detekt
- Loading branch information
1 parent
c537513
commit f13d200
Showing
4 changed files
with
192 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...t/ccbluex/liquidbounce/features/module/modules/player/invcleaner/ItemNumberConstraints.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package net.ccbluex.liquidbounce.features.module.modules.player.invcleaner | ||
|
||
/** | ||
* Defines an item constraint group. | ||
* | ||
* For example if we had two constraints: | ||
* - `BLOCKS` -> `128..` | ||
* - `TNT` -> `..64` | ||
* | ||
* Imagine a situation where the player has 125 TNT: | ||
* - If the TNT was processed first it would be thrown out since the TNT limit says that we have too much TNT. | ||
* - If the BLOCKS constraint was processed first, the TNT would be kept since the BLOCKS constraint is not yet | ||
* satisfied. | ||
*/ | ||
abstract class ItemNumberContraintGroup( | ||
/** | ||
* The range of desired item amounts (which might be raw item counts, food saturation, etc.): | ||
* - The lower limit defines the desired amount of items (=> any more items *might* be thrown out) | ||
* - The upper limit defines the maximum amount of items (=> any more items *will* be thrown out) | ||
*/ | ||
val acceptableRange: IntRange, | ||
/** | ||
* The priority of this constraint group. Lower values are processed first. | ||
* Affects the order in which items are processed. | ||
*/ | ||
val priority: Int, | ||
) { | ||
abstract override fun hashCode(): Int | ||
abstract override fun equals(other: Any?): Boolean | ||
} | ||
|
||
class ItemCategoryConstraintGroup( | ||
acceptableRange: IntRange, | ||
priority: Int, | ||
val category: ItemCategory, | ||
) : ItemNumberContraintGroup(acceptableRange, priority) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as ItemCategoryConstraintGroup | ||
|
||
if (category != other.category) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return category.hashCode() | ||
} | ||
} | ||
|
||
class ItemFunctionCategoryConstraintGroup( | ||
acceptableRange: IntRange, | ||
priority: Int, | ||
val function: ItemFunction, | ||
) : ItemNumberContraintGroup(acceptableRange, priority) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as ItemFunctionCategoryConstraintGroup | ||
|
||
if (function != other.function) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return function.hashCode() | ||
} | ||
} | ||
|
||
class ItemConstraintInfo( | ||
val group: ItemNumberContraintGroup, | ||
val amountAddedByItem: Int | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters