Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.modnmetl</groupId>
<artifactId>virtualrealty</artifactId>
<version>2.8.4</version>
<version>2.8.5</version>
<packaging>jar</packaging>
<description>A plot creation and management plugin for Minecraft</description>
<properties>
Expand Down Expand Up @@ -134,6 +134,7 @@
<id>bluecolored</id>
<url>https://repo.bluecolored.de/releases</url>
</repository>

</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
Expand Down Expand Up @@ -221,11 +222,11 @@
<version>6.3.0</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>maven.modrinth</groupId>-->
<!-- <artifactId>pl3xmap</artifactId>-->
<!-- <version>1.21-500</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>maven.modrinth</groupId>
<artifactId>pl3xmap</artifactId>
<version>1.20.4-492</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
14 changes: 14 additions & 0 deletions src/main/java/com/modnmetl/virtualrealty/VirtualRealty.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.modnmetl.virtualrealty.manager.DynmapManager;
import com.modnmetl.virtualrealty.manager.MetricsManager;
import com.modnmetl.virtualrealty.manager.PlotManager;
import com.modnmetl.virtualrealty.manager.Pl3xMapManager;
import com.modnmetl.virtualrealty.model.other.ServerVersion;
import com.modnmetl.virtualrealty.model.plot.Plot;
import com.modnmetl.virtualrealty.model.plot.PlotSize;
Expand All @@ -64,6 +65,7 @@ public final class VirtualRealty extends JavaPlugin {
// CORE
public List<JarFile> jarFiles = new ArrayList<>();
public DynmapManager dynmapManager;
public Pl3xMapManager pl3xMapManager;
public Locale locale;
@Getter
private static VirtualRealty instance;
Expand Down Expand Up @@ -135,6 +137,7 @@ public void onEnable() {
}
loadPlotsData();
loadDynMapHook();
loadPl3xMapHook();
registerCommands();
loadCommandsConfiguration();
updateCommandsConfig();
Expand Down Expand Up @@ -296,6 +299,13 @@ public void loadDynMapHook() {
}
}

public void loadPl3xMapHook() {
if (getPluginConfiguration().pl3xmapMarkers) {
pl3xMapManager = new Pl3xMapManager(this);
pl3xMapManager.registerPl3xMap();
}
}

public void loadMetrics() {
metricsManager = new MetricsManager(this, 14066);
metricsManager.registerMetrics();
Expand Down Expand Up @@ -454,6 +464,10 @@ public static DynmapManager getDynmapManager() {
return getInstance().dynmapManager;
}

public static Pl3xMapManager getPl3xMapManager() {
return getInstance().pl3xMapManager;
}

public static Database getDatabase() {
return Database.getInstance();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class PluginConfiguration extends OkaeriConfig {
public String initServerVersion = ServerVersion.MODERN.toString();

@Comment("Debug mode (Displays more detailed info about plugin executions)")
public boolean debugMode = false;
public boolean debugMode = true;
Copy link

Copilot AI Oct 5, 2025

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.

Suggested change
public boolean debugMode = true;
public boolean debugMode = false;

Copilot uses AI. Check for mistakes.

@Comment("Local loader mode (for devs)")
public boolean loaderDebugMode = false;
Expand Down Expand Up @@ -102,6 +102,16 @@ public GameMode getDefaultPlotGamemode() {
@CustomKey("dynmap-markers")
public MarkerColor dynmapMarkersColor = new MarkerColor();

@Comment("Enables pl3xmap plots highlighting")
@CustomKey("enable-pl3xmap-markers")
public boolean pl3xmapMarkers = true;

@Comment("Choose which type of plots should be highlighted on Pl3xMap page | Choose from: { ALL, AVAILABLE, OWNED }")
public HighlightType pl3xmapType = HighlightType.ALL;

@CustomKey("pl3xmap-markers")
public Pl3xMapMarkerColor pl3xmapMarkersColor = new Pl3xMapMarkerColor();

@Names(strategy = NameStrategy.IDENTITY)
public static class MarkerColor extends OkaeriConfig {

Expand Down Expand Up @@ -134,6 +144,30 @@ public int getHexColor() {

}

@Names(strategy = NameStrategy.IDENTITY)
public static class Pl3xMapMarkerColor extends OkaeriConfig {

public Pl3xMapAvailable available = new Pl3xMapAvailable();
public Pl3xMapOwned owned = new Pl3xMapOwned();

@Names(strategy = NameStrategy.IDENTITY)
public static class Pl3xMapAvailable extends OkaeriConfig {

public String color = "#80eb34";
public double opacity = 0.3;

}

@Names(strategy = NameStrategy.IDENTITY)
public static class Pl3xMapOwned extends OkaeriConfig {

public String color = "#ffbf00";
public double opacity = 0.45;

}

}

@Comment("Enables plots enter/leave sounds")
@CustomKey("plot-sounds")
public boolean plotSound = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void run() {
OfflinePlayer offlinePlayer = PanelUtil.SELECTED_MEMBER.get(player.getUniqueId());
PlotMember plotMember = plot.getMember(offlinePlayer.getUniqueId());
ManagementPermission managementPermission = ManagementPermission.getPermission(e.getSlot() - 12);
if (plot.getPlotOwner().getUniqueId() != player.getUniqueId()) {
if (!plot.getPlotOwner().getUniqueId().equals(player.getUniqueId())) {
ChatMessage.of(VirtualRealty.getMessages().noAccess).sendWithPrefix(player);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()) {
Expand All @@ -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
Copy link

Copilot AI Oct 5, 2025

Choose a reason for hiding this comment

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

The method onDripleafStateChange doesn't perform any meaningful action - it only has early returns and comments. This suggests the method is incomplete or the logic should be consolidated with the existing onEndermanChangeBlock method that already handles dripleaf state changes.

Suggested change
@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
}

Copilot uses AI. Check for mistakes.

@EventHandler(priority = EventPriority.LOW)
public void onPistonRetract(BlockPistonRetractEvent e) {
if (e.isCancelled())
Expand Down Expand Up @@ -957,13 +993,24 @@ public void onFireBurn(BlockBurnEvent e) {

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEndermanChangeBlock(EntityChangeBlockEvent e) {
Plot plot = PlotManager.getInstance().getPlot(e.getBlock().getLocation());
if (plot == null) {
return;
}

// Protect against Enderman block changes
if (e.getEntityType() == EntityType.ENDERMAN) {
Plot plot = PlotManager.getInstance().getPlot(e.getBlock().getLocation());
if (plot == null) {
return;
} else {
e.setCancelled(true);
return;
}

// Protect dripleaves from breaking while allowing tilting/interaction
if (isDripleaf(e.getBlock().getType())) {
// Check if this is a dripleaf breaking (changing to air or different block)
if (e.getTo() == Material.AIR || !isDripleaf(e.getTo())) {
e.setCancelled(true);
}
// Allow dripleaf state changes (tilting) by not cancelling other dripleaf-to-dripleaf changes
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public WorldProtectionListener(VirtualRealty plugin) {
super(plugin);
}

public boolean isDoor(Material type) {
if (type.name().endsWith("DOOR"))
return true;
return false;
}

@EventHandler(priority = EventPriority.LOWEST)
public void onBlockInteract(PlayerInteractEvent e) {
if (e.isCancelled())
Expand All @@ -45,7 +51,8 @@ public void onBlockInteract(PlayerInteractEvent e) {
if (player.isSneaking() && e.isBlockInHand())
return;
if (!(PlotProtectionListener.INTERACT.contains(e.getClickedBlock().getType())
|| PlotProtectionListener.SWITCHES.contains(e.getClickedBlock().getType())))
|| PlotProtectionListener.SWITCHES.contains(e.getClickedBlock().getType())
|| isDoor(e.getClickedBlock().getType())))
return;

if (e.getHand() == EquipmentSlot.OFF_HAND)
Expand Down Expand Up @@ -76,6 +83,15 @@ public void onBlockInteract(PlayerInteractEvent e) {
e.setCancelled(true);
player.sendMessage(VirtualRealty.PREFIX + VirtualRealty.getMessages().cantInteract);
}
return;
}
if (isDoor(e.getClickedBlock().getType())) {
Class.forName("com.modnmetl.virtualrealty.premiumloader.PremiumLoader", false,
VirtualRealty.getLoader());
if (!WorldUtil.hasPermission(RegionPermission.DOORS)) {
e.setCancelled(true);
player.sendMessage(VirtualRealty.PREFIX + VirtualRealty.getMessages().cantInteract);
}
}
} catch (Exception ignored) {
}
Expand Down
Loading