-
-
Notifications
You must be signed in to change notification settings - Fork 32
Add permission based chest placement limits #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
YouSeeMeRunning2
commented
Sep 20, 2025
- Added wildchests.limit.. permission system
- Added default-chest-limits config section (0=unlimited, 1+=limited, -1=disabled)
- Added enable-chest-limits config option (default: false)
- Added limit enforcement in BlockListener with lang messages
- Added ChestLimitUtils for permission and config limit checking
- Added getChestCount() method to ChestsManager API
- Fixed v1_21_5 NMS compatibility issues (might of been an issue in my project only)
- Added wildchests.limit.<type>.<amount> permission system - Added default-chest-limits config section (0=unlimited, 1+=limited, -1=disabled) - Added enable-chest-limits config option (default: false) - Added limit enforcement in BlockListener with lang messages - Added ChestLimitUtils for permission and config limit checking - Added getChestCount() method to ChestsManager API - Fixed v1_21_5 NMS compatibility issues (might of been an issue in my project only)
NMS/v1_21_5/build.gradle
Outdated
|
|
||
| dependencies { | ||
| paperweight.paperDevBundle("1.21.5-R0.1-SNAPSHOT") | ||
| paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you downgrade the version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file are only because you downgraded the version
settings.gradle
Outdated
| include 'NMS:v1_21_3' | ||
| include 'NMS:v1_21_4' | ||
| include 'NMS:v1_21_5' | ||
| // include 'NMS:v1_21_5' // Temporarily disabled due to API incompatibilities |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
| .filter(chest -> chest.getPlacer().equals(placer)) | ||
| .filter(chest -> chest.getData().getName().equals(chestType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine both filters to a single predicate
| .filter(chest -> chest.getPlacer().equals(placer)) | ||
| .filter(chest -> chest.getData().getName().equals(chestType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of comparing the names of the chestType, get the chest data of the provided chestType and check if they are equal with ==
| } | ||
|
|
||
| @Override | ||
| public int getChestCount(UUID placer, String chestType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chestType -> chestDataName
src/main/resources/config.yml
Outdated
| # Enable permission-based chest placement limits. | ||
| # When enabled, players can only place a limited number of each chest type based on permissions. | ||
| # Permission format: wildchests.limit.<type>.<amount> | ||
| # For example: wildchests.limit.linked_chest.5 allows placing up to 5 linked chests | ||
| enable-chest-limits: false | ||
|
|
||
| # Default limits for each chest type when no specific permission is given. | ||
| # Set to 0 for unlimited, or any positive number for the default limit. | ||
| # Set to -1 to disable this chest type entirely. | ||
| # These only apply when enable-chest-limits is true. | ||
| default-chest-limits: | ||
| linked_chest: 0 | ||
| large_chest: 0 | ||
| sell_chest: 0 | ||
| auto_crafter: 0 | ||
| storage_unit: 0 | ||
| chunk_collector: 0 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to:
chest-limits:
enabled: false
default:
- ...
|
|
||
| private ChestLimitUtils() {} | ||
|
|
||
| public static int getPlayerChestLimit(Player player, String chestType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling hasPlayerChestLimit and then getPlayerChestLimit are really expensive calls (in terms of performance). Optimize this
- Chest placement limits functionality
| /** | ||
| * Result class to hold both limit existence and value information | ||
| */ | ||
| public static class ChestLimitResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to Result and move this down, below the method to check for limit
| } | ||
| } | ||
|
|
||
| public static ChestLimitResult getPlayerChestLimitResult(Player player, String chestDataName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to checkChestLimit
|
|
||
| Integer defaultLimit = WildChestsPlugin.getPlugin().getSettings().defaultChestLimits.get(chestDataName); | ||
| if (defaultLimit != null && defaultLimit != -1) { | ||
| int actualLimit = defaultLimit == 0 ? Integer.MAX_VALUE : defaultLimit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should support limit 0 - this means players won't be able to place that chest
Instead, check if the limit is non-negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert changes