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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public interface RegionTagMapper {

int insert(@NotNull String tagId, @NotNull String worldGuardRegionId);

/** Inserts the tag if the region doesn't already have it; a no-op (0 rows) when it does. */
int insertIfAbsent(@NotNull String tagId, @NotNull String worldGuardRegionId);

@NotNull List<String> selectRegionIdsByTagId(@NotNull String tagId);

@NotNull List<String> selectTagIdsByRegionId(@NotNull String worldGuardRegionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ INSERT INTO LeaseholdContract (landlordId, tenantId, price, durationSeconds, sta
#{tenantId},
#{price},
#{durationSeconds},
NOW(),
NOW() + INTERVAL #{durationSeconds} SECOND,
CASE WHEN #{tenantId} IS NULL THEN NULL ELSE NOW() END,
CASE WHEN #{tenantId} IS NULL THEN NULL ELSE NOW() + INTERVAL #{durationSeconds} SECOND END,
CASE WHEN #{maxRenewals} >= 0 THEN 0 ELSE NULL END,
CASE WHEN #{maxRenewals} >= 0 THEN #{maxRenewals} ELSE NULL END
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ INSERT INTO RegionTag (tagId, worldGuardRegionId)
int insert(@Param("tagId") @NotNull String tagId,
@Param("worldGuardRegionId") @NotNull String worldGuardRegionId);

@Override
@Insert("""
INSERT IGNORE INTO RegionTag (tagId, worldGuardRegionId)
VALUES (#{tagId}, #{worldGuardRegionId})
""")
int insertIfAbsent(@Param("tagId") @NotNull String tagId,
@Param("worldGuardRegionId") @NotNull String worldGuardRegionId);

@Override
@Select("""
SELECT worldGuardRegionId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ record Error(@NotNull String message) implements QuickCreateSubregionResult {}
@NotNull WorldGuardRegion parentRegion,
@NotNull String childName,
@NotNull Region selection,
double price, long durationSeconds,
double price, long durationSeconds, int maxRenewals,
@NotNull UUID landlordId);

// --- Sign Place ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
import io.github.md5sha256.realty.database.maria.MariaDatabase;
import io.github.md5sha256.realty.listener.PropertyTaxListener;
import io.github.md5sha256.realty.listener.SignInteractionListener;
import io.github.md5sha256.realty.listener.SubregionWandListener;
import io.github.md5sha256.realty.command.SubregionDialog;
import io.github.md5sha256.realty.wand.SubregionWand;
import io.github.md5sha256.realty.wand.SubregionWandManager;
import io.github.md5sha256.realty.localisation.MessageContainer;
import io.github.md5sha256.realty.localisation.MessageKeys;
import io.github.md5sha256.realty.settings.ConfigRegionTag;
Expand Down Expand Up @@ -575,6 +579,16 @@ private void registerCommands(
) {
String version = getPluginMeta().getVersion();
var helpCommand = new HelpCommand(messageContainer);

SubregionWand subregionWand = new SubregionWand(this, this.settings);
SubregionWandManager subregionWandManager = new SubregionWandManager();
SubregionDialog subregionDialog = new SubregionDialog(paperApi, executorState,
this.database, subregionWandManager, this.settings, this.realtyTags,
messageContainer);
getServer().getPluginManager().registerEvents(
new SubregionWandListener(this, subregionWand, subregionWandManager,
messageContainer), this);

List<CustomCommandBean> commands = List.of(
new VersionCommand(version),
new AddCommand(messageContainer),
Expand Down Expand Up @@ -614,7 +628,8 @@ private void registerCommands(
new RemoveCommand(messageContainer),
new SignCommand(paperApi, executorState, messageContainer),
new TeleportCommand(getLogger(), paperApi, this.settings, messageContainer, safeLocationFinder),
new SubregionCommandGroup(paperApi, this.settings, messageContainer),
new SubregionCommandGroup(subregionWand, subregionWandManager, subregionDialog,
messageContainer),
new CleanupCommandGroup(this.database,
executorState,
this.realtyTags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ public RealtyPaperApiImpl(@NotNull RealtyBackend realtyApi,
@NotNull WorldGuardRegion parentRegion,
@NotNull String childName,
@NotNull Region selection,
double price, long durationSeconds,
double price, long durationSeconds, int maxRenewals,
@NotNull UUID landlordId) {
String parentId = parentRegion.region().getId();
UUID worldId = parentRegion.world().getUID();
Expand All @@ -867,7 +867,7 @@ public RealtyPaperApiImpl(@NotNull RealtyBackend realtyApi,
return (QuickCreateSubregionResult) new QuickCreateSubregionResult.NoFreeholdContract(parentId);
}
boolean created = realtyApi.createLeasehold(
childName, worldId, price, durationSeconds, -1, landlordId);
childName, worldId, price, durationSeconds, maxRenewals, landlordId);
if (!created) {
return (QuickCreateSubregionResult) new QuickCreateSubregionResult.RegionExists(childName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.github.md5sha256.realty.command;

/** Lease-duration units offered in the subregion create dialog. */
enum DurationUnit {
MINUTES(60L, "Minutes"),
HOURS(3600L, "Hours"),
DAYS(86400L, "Days"),
WEEKS(604800L, "Weeks");

final long seconds;
final String label;

DurationUnit(long seconds, String label) {
this.seconds = seconds;
this.label = label;
}
}
Loading