-
Notifications
You must be signed in to change notification settings - Fork 5
Merge Zivush1/VirtualRealty #74
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -64,11 +64,18 @@ public class PlotProtectionListener extends VirtualListener { | |||||||||||||||||||||||||||||||||
| public static final LinkedList<Material> SWITCHES = new LinkedList<>(); | ||||||||||||||||||||||||||||||||||
| public static final LinkedList<Material> STORAGES = new LinkedList<>(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public boolean isDoor(Material type) { | ||||||||||||||||||||||||||||||||||
| if (type.name().endsWith("DOOR")) | ||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| public boolean isDoor(Material type) { | ||||||||||||||||||||||||||||||||||
| // Only treat actual doors as "doors" for permission purposes | ||||||||||||||||||||||||||||||||||
| // Dripleaf is now handled separately to allow tilting without door permissions | ||||||||||||||||||||||||||||||||||
| if (type.name().endsWith("DOOR")) | ||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| private boolean isDripleaf(Material type) { | ||||||||||||||||||||||||||||||||||
| String name = type.name(); | ||||||||||||||||||||||||||||||||||
| return name.contains("DRIPLEAF"); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public boolean isInteractable(Material type) { | ||||||||||||||||||||||||||||||||||
| if (INTERACT.contains(type)) { | ||||||||||||||||||||||||||||||||||
|
|
@@ -192,9 +199,10 @@ public void onBlockInteract(PlayerInteractEvent e) { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if (e.getHand() == EquipmentSlot.OFF_HAND) | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| if (!e.getClickedBlock().getType().isInteractable() | ||||||||||||||||||||||||||||||||||
| && !(e.getClickedBlock().getType().name().endsWith("PRESSURE_PLATE"))) | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| if (!e.getClickedBlock().getType().isInteractable() | ||||||||||||||||||||||||||||||||||
| && !(e.getClickedBlock().getType().name().endsWith("PRESSURE_PLATE")) | ||||||||||||||||||||||||||||||||||
| && !isDripleaf(e.getClickedBlock().getType())) | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Plot plot = PlotManager.getInstance().getPlot(e.getClickedBlock().getLocation()); | ||||||||||||||||||||||||||||||||||
| if (plot == null) | ||||||||||||||||||||||||||||||||||
|
|
@@ -234,7 +242,15 @@ public void onBlockInteract(PlayerInteractEvent e) { | |||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| // Allow dripleaf interactions (tilting) without permission checks for members | ||||||||||||||||||||||||||||||||||
| if (isDripleaf(e.getClickedBlock().getType())) { | ||||||||||||||||||||||||||||||||||
| return; // Allow all dripleaf interactions for members | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| // Allow dripleaf interactions (tilting) without permission checks for non-members too | ||||||||||||||||||||||||||||||||||
| if (isDripleaf(e.getClickedBlock().getType())) { | ||||||||||||||||||||||||||||||||||
| return; // Allow all dripleaf interactions for non-members | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| if (isModernSwitch || isLegacySwitch || e.getClickedBlock().getType().name().endsWith("PRESSURE_PLATE")) { | ||||||||||||||||||||||||||||||||||
| if (!plot.hasPermission(RegionPermission.SWITCH)) { | ||||||||||||||||||||||||||||||||||
| e.setCancelled(true); | ||||||||||||||||||||||||||||||||||
|
|
@@ -484,6 +500,9 @@ public void onBlockBreak(BlockBreakEvent e) { | |||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| if (hasPermission(player, PLOT_BUILD)) | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // For dripleaf blocks, always require BREAK permission for actual breaking | ||||||||||||||||||||||||||||||||||
| // State changes (tilting) are handled in the EntityChangeBlockEvent handler | ||||||||||||||||||||||||||||||||||
| if (plot.hasMembershipAccess(player.getUniqueId())) { | ||||||||||||||||||||||||||||||||||
| PlotMember plotMember = plot.getMember(player.getUniqueId()); | ||||||||||||||||||||||||||||||||||
| if (plot.isOwnershipExpired()) { | ||||||||||||||||||||||||||||||||||
|
|
@@ -505,6 +524,23 @@ public void onBlockBreak(BlockBreakEvent e) { | |||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| @EventHandler(priority = EventPriority.LOW) | ||||||||||||||||||||||||||||||||||
| public void onDripleafStateChange(EntityChangeBlockEvent e) { | ||||||||||||||||||||||||||||||||||
| if (e.isCancelled()) | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Only handle dripleaf tilting (state changes, not breaking) | ||||||||||||||||||||||||||||||||||
| if (!isDripleaf(e.getBlock().getType())) | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // If the dripleaf is being broken (set to AIR), let the BlockBreakEvent handle it | ||||||||||||||||||||||||||||||||||
| if (e.getTo() == Material.AIR) | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // This is a state change (tilting), allow it without requiring BREAK permission | ||||||||||||||||||||||||||||||||||
| // No permission check needed for dripleaf tilting | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+527
to
+542
|
||||||||||||||||||||||||||||||||||
| @EventHandler(priority = EventPriority.LOW) | |
| public void onDripleafStateChange(EntityChangeBlockEvent e) { | |
| if (e.isCancelled()) | |
| return; | |
| // Only handle dripleaf tilting (state changes, not breaking) | |
| if (!isDripleaf(e.getBlock().getType())) | |
| return; | |
| // If the dripleaf is being broken (set to AIR), let the BlockBreakEvent handle it | |
| if (e.getTo() == Material.AIR) | |
| return; | |
| // This is a state change (tilting), allow it without requiring BREAK permission | |
| // No permission check needed for dripleaf tilting | |
| } |
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.
Debug mode is enabled by default. This should typically be false in production code to avoid excessive logging.