Skip to content

Conversation

@YouSeeMeRunning2
Copy link

  • 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)

dependencies {
paperweight.paperDevBundle("1.21.5-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT")
Copy link
Member

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?

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

Comment on lines 166 to 167
.filter(chest -> chest.getPlacer().equals(placer))
.filter(chest -> chest.getData().getName().equals(chestType))
Copy link
Member

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

Comment on lines 166 to 167
.filter(chest -> chest.getPlacer().equals(placer))
.filter(chest -> chest.getData().getName().equals(chestType))
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chestType -> chestDataName

Comment on lines 64 to 81
# 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

Copy link
Member

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) {
Copy link
Member

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

/**
* Result class to hold both limit existence and value information
*/
public static class ChestLimitResult {
Copy link
Member

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) {
Copy link
Member

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;
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants