Compare commits

...

14 Commits

Author SHA1 Message Date
e06bf2cd6b Checkstyle 2023-03-04 23:33:44 +01:00
0484915233 Record-inize methods 2023-03-04 12:55:50 +01:00
276e619caa Merge branch 'v6' into v7 2023-03-04 11:19:48 +01:00
f11acacedd Update dependency com.intellectualsites.prtree:PRTree to v2.0.1 (#3975)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-02 22:36:18 +01:00
f636a5ec63 Merge branch 'v6' into v7 2023-03-02 20:48:43 +01:00
d1bac90745 Update developers field 2023-03-02 20:48:33 +01:00
785362c576 Merge branch 'v6' into v7 2023-03-02 12:34:18 +01:00
e98f628d34 Pin GH actions to SHA to avoid mutable refs (#3973) 2023-03-02 12:30:14 +01:00
b2ab61559c Update dependency com.diffplug.spotless to v6.16.0 (#3970)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-02 00:46:34 +01:00
dd6eb8e74f Update dependency cloud.commandframework:cloud-services to v1.8.2 (#3971)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-03-02 00:46:19 +01:00
97cdd03ea4 Update dependency gradle to v7.6.1 (#3967)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-27 21:24:04 +01:00
f5118e6802 Don't fire 'PlotUnlinkEvent' twice on plot clear (#3947) 2023-02-23 09:26:30 +01:00
94ca5cf679 Update dependency cloud.commandframework:cloud-services to v1.8.1 (#3965)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-22 23:47:31 +01:00
5a55a1f602 Update dependency io.github.gradle-nexus.publish-plugin to v1.2.0 (#3966)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-02-22 23:47:13 +01:00
43 changed files with 318 additions and 446 deletions

View File

@ -2,7 +2,6 @@ name: Announce release on discord
on: on:
release: release:
types: [published] types: [published]
jobs: jobs:
send_announcement: send_announcement:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -12,7 +11,7 @@ jobs:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_USERNAME: PlotSquared Release DISCORD_USERNAME: PlotSquared Release
DISCORD_AVATAR: https://raw.githubusercontent.com/IntellectualSites/Assets/main/plugins/PlotSquared/PlotSquared.png DISCORD_AVATAR: https://raw.githubusercontent.com/IntellectualSites/Assets/main/plugins/PlotSquared/PlotSquared.png
uses: Ilshidur/action-discord@0.3.2 uses: Ilshidur/action-discord@0c4b27844ba47cb1c7bee539c8eead5284ce9fa9 # ratchet:Ilshidur/action-discord@0.3.2
with: with:
args: | args: |
"<@&525015541815967744> <@&679322738552471574> <@&699293353862496266>" "<@&525015541815967744> <@&679322738552471574> <@&699293353862496266>"

View File

@ -1,19 +1,17 @@
name: Build PR name: Build PR
on: [pull_request]
on: [ pull_request ]
jobs: jobs:
build_pr: build_pr:
if: github.repository_owner == 'IntellectualSites' if: github.repository_owner == 'IntellectualSites'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ] os: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Validate Gradle Wrapper - name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1 uses: gradle/wrapper-validation-action@55e685c48d84285a5b0418cd094606e199cca3b6 # v1
- name: Setup Java - name: Setup Java
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:

View File

@ -1,10 +1,8 @@
name: build name: build
on: on:
push: push:
branches: branches:
- v7 - v7
jobs: jobs:
build: build:
if: github.repository_owner == 'IntellectualSites' if: github.repository_owner == 'IntellectualSites'
@ -13,7 +11,7 @@ jobs:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Validate Gradle Wrapper - name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1 uses: gradle/wrapper-validation-action@55e685c48d84285a5b0418cd094606e199cca3b6 # v1
- name: Setup Java - name: Setup Java
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
@ -44,9 +42,14 @@ jobs:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
- name: Publish core javadoc - name: Publish core javadoc
<<<<<<< HEAD
# if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}} # if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}}
if: ${{ runner.os == 'Linux' && env.STATUS == 'snapshot' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}} if: ${{ runner.os == 'Linux' && env.STATUS == 'snapshot' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}}
uses: cpina/github-action-push-to-another-repository@main uses: cpina/github-action-push-to-another-repository@main
=======
if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v6'}}
uses: cpina/github-action-push-to-another-repository@0a14457bb28b04dfa1652e0ffdfda866d2845c73 # main
>>>>>>> v6
env: env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with: with:
@ -59,7 +62,7 @@ jobs:
- name: Publish bukkit javadoc - name: Publish bukkit javadoc
# if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}} # if: ${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}}
if: ${{ runner.os == 'Linux' && env.STATUS == 'snapshot' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}} if: ${{ runner.os == 'Linux' && env.STATUS == 'snapshot' && github.event_name == 'push' && github.ref == 'refs/heads/v7'}}
uses: cpina/github-action-push-to-another-repository@main uses: cpina/github-action-push-to-another-repository@0a14457bb28b04dfa1652e0ffdfda866d2845c73 # main
env: env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
with: with:

View File

@ -1,5 +1,4 @@
name: "CodeQL" name: "CodeQL"
on: on:
push: push:
branches: [ v7 ] branches: [ v7 ]
@ -15,23 +14,18 @@ jobs:
actions: read actions: read
contents: read contents: read
security-events: write security-events: write
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
language: [ 'java' ] language: ['java']
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v2 uses: github/codeql-action/init@32dc499307d133bb5085bae78498c0ac2cf762d5 # v2
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v2 uses: github/codeql-action/autobuild@32dc499307d133bb5085bae78498c0ac2cf762d5 # v2
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@32dc499307d133bb5085bae78498c0ac2cf762d5 # v2

View File

@ -1,14 +1,12 @@
name: draft release name: draft release
on: on:
push: push:
branches: branches:
- v6 - v6
pull_request: pull_request:
types: [ opened, reopened, synchronize ] types: [opened, reopened, synchronize]
pull_request_target: pull_request_target:
types: [ opened, reopened, synchronize ] types: [opened, reopened, synchronize]
jobs: jobs:
update_release_draft: update_release_draft:
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}

View File

@ -52,7 +52,7 @@ public class MVdWPlaceholders {
@Subscribe @Subscribe
public void onNewPlaceholder(final PlaceholderRegistry.@NonNull PlaceholderAddedEvent event) { public void onNewPlaceholder(final PlaceholderRegistry.@NonNull PlaceholderAddedEvent event) {
this.addPlaceholder(event.getPlaceholder()); this.addPlaceholder(event.placeholder());
} }
private void addPlaceholder(final @NonNull Placeholder placeholder) { private void addPlaceholder(final @NonNull Placeholder placeholder) {

View File

@ -110,9 +110,9 @@ public class GenChunk extends ZeroedDelegateScopedQueueCoordinator {
*/ */
public void setChunk(@NonNull ChunkWrapper wrap) { public void setChunk(@NonNull ChunkWrapper wrap) {
chunk = null; chunk = null;
world = wrap.world; world = wrap.world();
chunkX = wrap.x; chunkX = wrap.x();
chunkZ = wrap.z; chunkZ = wrap.z();
} }
@Override @Override

View File

@ -124,7 +124,7 @@ public class BukkitSetupUtils extends SetupUtils {
public String setupWorld(PlotAreaBuilder builder) { public String setupWorld(PlotAreaBuilder builder) {
this.updateGenerators(false); this.updateGenerators(false);
ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ? ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ?
new ConfigurationNode[0] : builder.settingsNodesWrapper().getSettingsNodes(); new ConfigurationNode[0] : builder.settingsNodesWrapper().settingsNodes();
String world = builder.worldName(); String world = builder.worldName();
PlotAreaType type = builder.plotAreaType(); PlotAreaType type = builder.plotAreaType();
String worldPath = "worlds." + builder.worldName(); String worldPath = "worlds." + builder.worldName();

View File

@ -111,8 +111,8 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
try (final PreparedStatement statement = getConnection() try (final PreparedStatement statement = getConnection()
.prepareStatement("INSERT OR REPLACE INTO `usercache` (`uuid`, `username`) VALUES(?, ?)")) { .prepareStatement("INSERT OR REPLACE INTO `usercache` (`uuid`, `username`) VALUES(?, ?)")) {
for (final UUIDMapping mapping : uuidWrappers) { for (final UUIDMapping mapping : uuidWrappers) {
statement.setString(1, mapping.getUuid().toString()); statement.setString(1, mapping.uuid().toString());
statement.setString(2, mapping.getUsername()); statement.setString(2, mapping.username());
statement.executeUpdate(); statement.executeUpdate();
} }
} catch (SQLException e) { } catch (SQLException e) {

View File

@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement ## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at contact@intellectualsites.com. All reported by contacting the project team at contact<at>intellectualsites.com. All
complaints will be reviewed and investigated and will result in a response that complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident. obligated to maintain confidentiality with regard to the reporter of an incident.

View File

@ -136,33 +136,29 @@ public class SimpleBackupManager implements BackupManager {
return this.backupLimit; return this.backupLimit;
} }
private static final class PlotCacheKey { private record PlotCacheKey(
Plot plot
private final Plot plot; ) {
private PlotCacheKey(Plot plot) {
this.plot = plot;
}
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) { if (this == o) {
return true; return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final PlotCacheKey that = (PlotCacheKey) o;
return Objects.equals(plot.getArea(), that.plot.getArea())
&& Objects.equals(plot.getId(), that.plot.getId())
&& Objects.equals(plot.getOwnerAbs(), that.plot.getOwnerAbs());
} }
if (o == null || getClass() != o.getClass()) {
return false; @Override
public int hashCode() {
return Objects.hash(plot.getArea(), plot.getId(), plot.getOwnerAbs());
} }
final PlotCacheKey that = (PlotCacheKey) o;
return Objects.equals(plot.getArea(), that.plot.getArea())
&& Objects.equals(plot.getId(), that.plot.getId())
&& Objects.equals(plot.getOwnerAbs(), that.plot.getOwnerAbs());
}
@Override
public int hashCode() {
return Objects.hash(plot.getArea(), plot.getId(), plot.getOwnerAbs());
} }
}
} }

View File

@ -35,6 +35,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.services.plots.AutoQuery;
import com.plotsquared.core.services.plots.AutoService; import com.plotsquared.core.services.plots.AutoService;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
@ -326,7 +327,7 @@ public class Auto extends SubCommand {
} }
List<Plot> plots = this.servicePipeline List<Plot> plots = this.servicePipeline
.pump(new AutoService.AutoQuery(player, null, sizeX, sizeZ, plotarea)) .pump(new AutoQuery(player, null, sizeX, sizeZ, plotarea))
.through(AutoService.class) .through(AutoService.class)
.getResult(); .getResult();

View File

@ -108,7 +108,6 @@ public class Clear extends Command {
BackupManager.backup(player, plot, () -> { BackupManager.backup(player, plot, () -> {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
boolean result = plot.getPlotModificationManager().clear(true, false, player, () -> { boolean result = plot.getPlotModificationManager().clear(true, false, player, () -> {
plot.getPlotModificationManager().unlink();
TaskManager.runTask(() -> { TaskManager.runTask(() -> {
plot.removeRunning(); plot.removeRunning();
// If the state changes, then mark it as no longer done // If the state changes, then mark it as no longer done

View File

@ -85,24 +85,24 @@ public class Inbox extends SubCommand {
for (int x = page * 12; x < max; x++) { for (int x = page * 12; x < max; x++) {
PlotComment comment = comments[x]; PlotComment comment = comments[x];
Component commentColored; Component commentColored;
if (player.getName().equals(comment.senderName)) { if (player.getName().equals(comment.senderName())) {
commentColored = MINI_MESSAGE commentColored = MINI_MESSAGE
.deserialize( .deserialize(
TranslatableCaption.of("list.comment_list_by_lister").getComponent(player), TranslatableCaption.of("list.comment_list_by_lister").getComponent(player),
TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment))) TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment())))
); );
} else { } else {
commentColored = MINI_MESSAGE commentColored = MINI_MESSAGE
.deserialize( .deserialize(
TranslatableCaption.of("list.comment_list_by_other").getComponent(player), TranslatableCaption.of("list.comment_list_by_other").getComponent(player),
TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment))) TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment())))
); );
} }
TagResolver resolver = TagResolver.builder() TagResolver resolver = TagResolver.builder()
.tag("number", Tag.inserting(Component.text(x))) .tag("number", Tag.inserting(Component.text(x)))
.tag("world", Tag.inserting(Component.text(comment.world))) .tag("world", Tag.inserting(Component.text(comment.world())))
.tag("plot_id", Tag.inserting(Component.text(comment.id.getX() + ";" + comment.id.getY()))) .tag("plot_id", Tag.inserting(Component.text(comment.id().getX() + ";" + comment.id().getY())))
.tag("commenter", Tag.inserting(Component.text(comment.senderName))) .tag("commenter", Tag.inserting(Component.text(comment.senderName())))
.tag("comment", Tag.inserting(commentColored)) .tag("comment", Tag.inserting(commentColored))
.build(); .build();
builder.append(MINI_MESSAGE builder.append(MINI_MESSAGE
@ -137,7 +137,7 @@ public class Inbox extends SubCommand {
int unread = 0; int unread = 0;
for (PlotComment comment : value) { for (PlotComment comment : value) {
total++; total++;
if (comment.timestamp > CommentManager if (comment.timestamp() > CommentManager
.getTimestamp(player, inbox.toString())) { .getTimestamp(player, inbox.toString())) {
unread++; unread++;
} }
@ -242,7 +242,7 @@ public class Inbox extends SubCommand {
if (success) { if (success) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("comment.comment_removed_success"), TranslatableCaption.of("comment.comment_removed_success"),
TagResolver.resolver("value", Tag.inserting(Component.text(comment.comment))) TagResolver.resolver("value", Tag.inserting(Component.text(comment.comment())))
); );
} else { } else {
player.sendMessage( player.sendMessage(

View File

@ -474,20 +474,20 @@ public class ListCmd extends SubCommand {
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners()) final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS); .get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
for (final UUIDMapping uuidMapping : names) { for (final UUIDMapping uuidMapping : names) {
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid()); PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.uuid());
TagResolver resolver = TagResolver.builder() TagResolver resolver = TagResolver.builder()
.tag("prefix", Tag.inserting(Component.text(prefix))) .tag("prefix", Tag.inserting(Component.text(prefix)))
.tag("player", Tag.inserting(Component.text(uuidMapping.getUsername()))) .tag("player", Tag.inserting(Component.text(uuidMapping.username())))
.build(); .build();
if (pp != null) { if (pp != null) {
builder.append(MINI_MESSAGE.deserialize(online, resolver)); builder.append(MINI_MESSAGE.deserialize(online, resolver));
} else if (uuidMapping.getUsername().equalsIgnoreCase("unknown")) { } else if (uuidMapping.username().equalsIgnoreCase("unknown")) {
TagResolver unknownResolver = TagResolver.resolver( TagResolver unknownResolver = TagResolver.resolver(
"info.unknown", "info.unknown",
Tag.inserting(TranslatableCaption.of("info.unknown").toComponent(player)) Tag.inserting(TranslatableCaption.of("info.unknown").toComponent(player))
); );
builder.append(MINI_MESSAGE.deserialize(unknown, unknownResolver)); builder.append(MINI_MESSAGE.deserialize(unknown, unknownResolver));
} else if (uuidMapping.getUuid().equals(DBFunc.EVERYONE)) { } else if (uuidMapping.uuid().equals(DBFunc.EVERYONE)) {
TagResolver everyoneResolver = TagResolver.resolver( TagResolver everyoneResolver = TagResolver.resolver(
"info.everyone", "info.everyone",
Tag.inserting(TranslatableCaption.of("info.everyone").toComponent(player)) Tag.inserting(TranslatableCaption.of("info.everyone").toComponent(player))

View File

@ -127,7 +127,7 @@ public class Purge extends SubCommand {
); );
return false; return false;
} }
owner = ownerMapping.getUuid(); owner = ownerMapping.uuid();
break; break;
case "shared": case "shared":
case "s": case "s":
@ -139,7 +139,7 @@ public class Purge extends SubCommand {
); );
return false; return false;
} }
added = addedMapping.getUuid(); added = addedMapping.uuid();
break; break;
case "clear": case "clear":
case "c": case "c":

View File

@ -156,9 +156,9 @@ public class Template extends SubCommand {
ZipOutputStream zos = new ZipOutputStream(fos)) { ZipOutputStream zos = new ZipOutputStream(fos)) {
for (FileBytes file : files) { for (FileBytes file : files) {
ZipEntry ze = new ZipEntry(file.path); ZipEntry ze = new ZipEntry(file.path());
zos.putNextEntry(ze); zos.putNextEntry(ze);
zos.write(file.data); zos.write(file.data());
} }
zos.closeEntry(); zos.closeEntry();
} }

View File

@ -35,28 +35,15 @@ import java.util.Map;
* the component GUI * the component GUI
*/ */
@SerializableAs("preset") @SerializableAs("preset")
public class ComponentPreset implements ConfigurationSerializable { public record ComponentPreset(
ClassicPlotManagerComponent component,
private final ClassicPlotManagerComponent component; String pattern,
private final String pattern; double cost,
private final double cost; String permission,
private final String permission; String displayName,
private final String displayName; List<String> description,
private final List<String> description; ItemType icon
private final ItemType icon; ) implements ConfigurationSerializable {
public ComponentPreset(
ClassicPlotManagerComponent component, String pattern, double cost,
String permission, String displayName, List<String> description, final ItemType icon
) {
this.component = component;
this.pattern = pattern;
this.cost = cost;
this.permission = permission;
this.displayName = displayName;
this.description = description;
this.icon = icon;
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static ComponentPreset deserialize(final @NonNull Map<String, Object> map) { public static ComponentPreset deserialize(final @NonNull Map<String, Object> map) {
@ -74,34 +61,6 @@ public class ComponentPreset implements ConfigurationSerializable {
); );
} }
public ClassicPlotManagerComponent getComponent() {
return this.component;
}
public String getPattern() {
return this.pattern;
}
public double getCost() {
return this.cost;
}
public String getPermission() {
return this.permission;
}
public String getDisplayName() {
return this.displayName;
}
public List<String> getDescription() {
return this.description;
}
public ItemType getIcon() {
return this.icon;
}
@Override @Override
public Map<String, Object> serialize() { public Map<String, Object> serialize() {
final Map<String, Object> map = new HashMap<>(); final Map<String, Object> map = new HashMap<>();

View File

@ -165,8 +165,8 @@ public class ComponentPresetManager {
final List<ComponentPreset> allowedPresets = new ArrayList<>(this.presets.size()); final List<ComponentPreset> allowedPresets = new ArrayList<>(this.presets.size());
for (final ComponentPreset componentPreset : this.presets) { for (final ComponentPreset componentPreset : this.presets) {
if (!componentPreset.getPermission().isEmpty() && !player.hasPermission( if (!componentPreset.permission().isEmpty() && !player.hasPermission(
componentPreset.getPermission() componentPreset.permission()
)) { )) {
continue; continue;
} }
@ -200,30 +200,30 @@ public class ComponentPresetManager {
return false; return false;
} }
final Pattern pattern = PatternUtil.parse(null, componentPreset.getPattern(), false); final Pattern pattern = PatternUtil.parse(null, componentPreset.pattern(), false);
if (pattern == null) { if (pattern == null) {
getPlayer().sendMessage(TranslatableCaption.of("preset.preset_invalid")); getPlayer().sendMessage(TranslatableCaption.of("preset.preset_invalid"));
return false; return false;
} }
if (componentPreset.getCost() > 0.0D) { if (componentPreset.cost() > 0.0D) {
if (!econHandler.isEnabled(plot.getArea())) { if (!econHandler.isEnabled(plot.getArea())) {
getPlayer().sendMessage( getPlayer().sendMessage(
TranslatableCaption.of("preset.economy_disabled"), TranslatableCaption.of("preset.economy_disabled"),
TagResolver.resolver("preset", Tag.inserting(Component.text(componentPreset.getDisplayName()))) TagResolver.resolver("preset", Tag.inserting(Component.text(componentPreset.displayName())))
); );
return false; return false;
} }
if (econHandler.getMoney(getPlayer()) < componentPreset.getCost()) { if (econHandler.getMoney(getPlayer()) < componentPreset.cost()) {
getPlayer().sendMessage(TranslatableCaption.of("preset.preset_cannot_afford")); getPlayer().sendMessage(TranslatableCaption.of("preset.preset_cannot_afford"));
return false; return false;
} else { } else {
econHandler.withdrawMoney(getPlayer(), componentPreset.getCost()); econHandler.withdrawMoney(getPlayer(), componentPreset.cost());
getPlayer().sendMessage( getPlayer().sendMessage(
TranslatableCaption.of("economy.removed_balance"), TranslatableCaption.of("economy.removed_balance"),
TagResolver.resolver( TagResolver.resolver(
"money", "money",
Tag.inserting(Component.text(econHandler.format(componentPreset.getCost()))) Tag.inserting(Component.text(econHandler.format(componentPreset.cost())))
) )
); );
} }
@ -235,7 +235,7 @@ public class ComponentPresetManager {
queue.setCompleteTask(plot::removeRunning); queue.setCompleteTask(plot::removeRunning);
for (Plot current : plot.getConnectedPlots()) { for (Plot current : plot.getConnectedPlots()) {
current.getPlotModificationManager().setComponent( current.getPlotModificationManager().setComponent(
componentPreset.getComponent().name(), componentPreset.component().name(),
pattern, pattern,
player, player,
queue queue
@ -252,32 +252,32 @@ public class ComponentPresetManager {
for (int i = 0; i < allowedPresets.size(); i++) { for (int i = 0; i < allowedPresets.size(); i++) {
final ComponentPreset preset = allowedPresets.get(i); final ComponentPreset preset = allowedPresets.get(i);
final List<String> lore = new ArrayList<>(); final List<String> lore = new ArrayList<>();
if (preset.getCost() > 0) { if (preset.cost() > 0) {
if (!this.econHandler.isEnabled(plot.getArea())) { if (!this.econHandler.isEnabled(plot.getArea())) {
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize( lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize(
TranslatableCaption.of("preset.preset_lore_economy_disabled").getComponent(player)))); TranslatableCaption.of("preset.preset_lore_economy_disabled").getComponent(player))));
} else { } else {
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize( lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize(
TranslatableCaption.of("preset.preset_lore_cost").getComponent(player), TranslatableCaption.of("preset.preset_lore_cost").getComponent(player),
TagResolver.resolver("cost", Tag.inserting(Component.text(String.format("%.2f", preset.getCost())))) TagResolver.resolver("cost", Tag.inserting(Component.text(String.format("%.2f", preset.cost()))))
))); )));
} }
} }
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize( lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize(
TranslatableCaption.of("preset.preset_lore_component").getComponent(player), TranslatableCaption.of("preset.preset_lore_component").getComponent(player),
TagResolver.builder() TagResolver.builder()
.tag("component", Tag.inserting(Component.text(preset.getComponent().name().toLowerCase()))) .tag("component", Tag.inserting(Component.text(preset.component().name().toLowerCase())))
.tag("prefix", Tag.inserting(TranslatableCaption.of("core.prefix").toComponent(player))) .tag("prefix", Tag.inserting(TranslatableCaption.of("core.prefix").toComponent(player)))
.build() .build()
))); )));
lore.removeIf(String::isEmpty); lore.removeIf(String::isEmpty);
lore.addAll(preset.getDescription()); lore.addAll(preset.description());
plotInventory.setItem( plotInventory.setItem(
i, i,
new PlotItemStack( new PlotItemStack(
preset.getIcon().getId().replace("minecraft:", ""), preset.icon().getId().replace("minecraft:", ""),
1, 1,
preset.getDisplayName(), preset.displayName(),
lore.toArray(new String[0]) lore.toArray(new String[0])
) )
); );

View File

@ -2400,13 +2400,13 @@ public class SQLManager implements AbstractDB {
if (plot != null) { if (plot != null) {
statement.setString(1, plot.getArea().toString()); statement.setString(1, plot.getArea().toString());
statement.setInt(2, plot.getId().hashCode()); statement.setInt(2, plot.getId().hashCode());
statement.setString(3, comment.comment); statement.setString(3, comment.comment());
statement.setString(4, comment.inbox); statement.setString(4, comment.inbox());
statement.setString(5, comment.senderName); statement.setString(5, comment.senderName());
} else { } else {
statement.setString(1, comment.comment); statement.setString(1, comment.comment());
statement.setString(2, comment.inbox); statement.setString(2, comment.inbox());
statement.setString(3, comment.senderName); statement.setString(3, comment.senderName());
} }
} }
@ -2518,10 +2518,10 @@ public class SQLManager implements AbstractDB {
public void set(PreparedStatement statement) throws SQLException { public void set(PreparedStatement statement) throws SQLException {
statement.setString(1, plot.getArea().toString()); statement.setString(1, plot.getArea().toString());
statement.setInt(2, plot.getId().hashCode()); statement.setInt(2, plot.getId().hashCode());
statement.setString(3, comment.comment); statement.setString(3, comment.comment());
statement.setString(4, comment.inbox); statement.setString(4, comment.inbox());
statement.setInt(5, (int) (comment.timestamp / 1000)); statement.setInt(5, (int) (comment.timestamp() / 1000));
statement.setString(6, comment.senderName); statement.setString(6, comment.senderName());
} }
@Override @Override
@ -3414,15 +3414,10 @@ public class SQLManager implements AbstractDB {
} }
} }
private static class LegacySettings { private record LegacySettings(
int id,
public final int id; PlotSettings settings
public final PlotSettings settings; ) {
public LegacySettings(int id, PlotSettings settings) {
this.id = id;
this.settings = settings;
}
} }

View File

@ -341,14 +341,14 @@ public class PlotListener {
} }
TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class); TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class);
if (feed.getInterval() != 0 && feed.getValue() != 0) { if (feed.interval() != 0 && feed.value() != 0) {
feedRunnable feedRunnable
.put(player.getUUID(), new Interval(feed.getInterval(), feed.getValue(), 20)); .put(player.getUUID(), new Interval(feed.interval(), feed.value(), 20));
} }
TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class); TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class);
if (heal.getInterval() != 0 && heal.getValue() != 0) { if (heal.interval() != 0 && heal.value() != 0) {
healRunnable healRunnable
.put(player.getUUID(), new Interval(heal.getInterval(), heal.getValue(), 20)); .put(player.getUUID(), new Interval(heal.interval(), heal.value(), 20));
} }
return true; return true;
} }

View File

@ -21,17 +21,11 @@ package com.plotsquared.core.location;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
public class ChunkWrapper { public record ChunkWrapper(
String world,
public final int x; int x,
public final int z; int z
public final String world; ) {
public ChunkWrapper(String world, int x, int z) {
this.world = world;
this.x = x;
this.z = z;
}
@Override @Override
public int hashCode() { public int hashCode() {

View File

@ -215,66 +215,48 @@ public final class BlockBucket implements ConfigurationSerializable {
return result; return result;
} }
private static final class Range { private record Range(
int min,
private final int min; int max,
private final int max; boolean automatic
private final boolean automatic; ) {
public Range(int min, int max, boolean automatic) {
this.min = min;
this.max = max;
this.automatic = automatic;
}
public int getWeight() { public int getWeight() {
return max - min; return max - min;
} }
public boolean isInRange(final int num) { public boolean isInRange(final int num) {
return num <= max && num >= min; return num <= max && num >= min;
} }
public int getMin() { public boolean equals(final Object o) {
return this.min; if (o == this) {
} return true;
}
public int getMax() { if (!(o instanceof final Range other)) {
return this.max; return false;
} }
if (this.min() != other.min()) {
public boolean equals(final Object o) { return false;
if (o == this) { }
if (this.max() != other.max()) {
return false;
}
if (this.automatic() != other.automatic()) {
return false;
}
return true; return true;
} }
if (!(o instanceof final Range other)) {
return false;
}
if (this.getMin() != other.getMin()) {
return false;
}
if (this.getMax() != other.getMax()) {
return false;
}
if (this.isAutomatic() != other.isAutomatic()) {
return false;
}
return true;
}
public int hashCode() { public int hashCode() {
final int PRIME = 59; final int PRIME = 59;
int result = 1; int result = 1;
result = result * PRIME + this.getMin(); result = result * PRIME + this.min();
result = result * PRIME + this.getMax(); result = result * PRIME + this.max();
result = result * PRIME + (this.isAutomatic() ? 79 : 97); result = result * PRIME + (this.automatic() ? 79 : 97);
return result; return result;
} }
public boolean isAutomatic() {
return this.automatic;
} }
}
} }

View File

@ -113,13 +113,12 @@ public class PlotSettings {
this.position = position; this.position = position;
} }
@SuppressWarnings({"UnstableApiUsage"})
public List<PlotComment> getComments(String inbox) { public List<PlotComment> getComments(String inbox) {
if (this.comments == null) { if (this.comments == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
return this.comments.stream().filter(comment -> comment.inbox.equals(inbox)) return this.comments.stream().filter(comment -> comment.inbox().equals(inbox))
.collect(ImmutableList.toImmutableList()); .collect(ImmutableList.toImmutableList());
} }

View File

@ -58,7 +58,7 @@ public class CommentManager {
if (value != null) { if (value != null) {
int num = 0; int num = 0;
for (PlotComment comment : value) { for (PlotComment comment : value) {
if (comment.timestamp > getTimestamp(player, inbox.toString())) { if (comment.timestamp() > getTimestamp(player, inbox.toString())) {
num++; num++;
} }
} }

View File

@ -20,25 +20,13 @@ package com.plotsquared.core.plot.comment;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
public class PlotComment { public record PlotComment(
String world,
public final String comment; PlotId id,
public final String inbox; String comment,
public final String senderName; String senderName,
public final PlotId id; String inbox,
public final String world; long timestamp
public final long timestamp; ) {
public PlotComment(
String world, PlotId id, String comment, String senderName, String inbox,
long timestamp
) {
this.world = world;
this.id = id;
this.comment = comment;
this.senderName = senderName;
this.inbox = inbox;
this.timestamp = timestamp;
}
} }

View File

@ -60,7 +60,7 @@ public class FeedFlag extends TimedFlag<Integer, FeedFlag> {
@Override @Override
protected Integer mergeValue(Integer other) { protected Integer mergeValue(Integer other) {
return this.getValue().getValue() + other; return this.getValue().value() + other;
} }
@Override @Override

View File

@ -60,7 +60,7 @@ public class HealFlag extends TimedFlag<Integer, HealFlag> {
@Override @Override
protected Integer mergeValue(Integer other) { protected Integer mergeValue(Integer other) {
return this.getValue().getValue() + other; return this.getValue().value() + other;
} }
@Override @Override

View File

@ -76,29 +76,16 @@ public abstract class TimedFlag<T, F extends PlotFlag<TimedFlag.Timed<T>, F>>
return getValue().toString(); return getValue().toString();
} }
public static final class Timed<T> { public record Timed<T>(
int interval,
private final int interval; T value
private final T value; ) {
public Timed(int interval, T value) {
this.interval = interval;
this.value = value;
}
public int getInterval() {
return interval;
}
public T getValue() {
return value;
}
@Override @Override
public String toString() { public String toString() {
return String.format("%d %s", interval, value); return String.format("%d %s", interval, value);
}
} }
}
} }

View File

@ -0,0 +1,105 @@
/*
* PlotSquared, a land and world management plugin for Minecraft.
* Copyright (C) IntellectualSites <https://intellectualsites.com>
* Copyright (C) IntellectualSites team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.services.plots;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public record AutoQuery(
PlotPlayer<?> player,
PlotId startId,
int sizeX,
int sizeZ,
PlotArea plotArea
) {
/**
* Crate a new auto query
*
* @param player Player to claim for
* @param startId Plot ID to start searching from
* @param sizeX Number of plots along the X axis
* @param sizeZ Number of plots along the Z axis
* @param plotArea Plot area to search in
*/
public AutoQuery(
final @NonNull PlotPlayer<?> player, final @Nullable PlotId startId,
final int sizeX, final int sizeZ, final @NonNull PlotArea plotArea
) {
this.player = player;
this.startId = startId;
this.sizeX = sizeX;
this.sizeZ = sizeZ;
this.plotArea = plotArea;
}
/**
* Get the player that the plots are meant for
*
* @return Player
*/
@Override
public @NonNull PlotPlayer<?> player() {
return this.player;
}
/**
* Get the plot ID to start searching from
*
* @return Start ID
*/
@Override
public @Nullable PlotId startId() {
return this.startId;
}
/**
* Get the number of plots along the X axis
*
* @return Number of plots along the X axis
*/
@Override
public int sizeX() {
return this.sizeX;
}
/**
* Get the number of plots along the Z axis
*
* @return Number of plots along the Z axis
*/
@Override
public int sizeZ() {
return this.sizeZ;
}
/**
* Get the plot area to search in
*
* @return Plot area
*/
@Override
public @NonNull PlotArea plotArea() {
return this.plotArea;
}
}

View File

@ -21,9 +21,7 @@ package com.plotsquared.core.services.plots;
import cloud.commandframework.services.types.Service; import cloud.commandframework.services.types.Service;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaType; import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
@ -34,88 +32,12 @@ import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Predicate; import java.util.function.Predicate;
public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>> { public interface AutoService extends Service<AutoQuery, List<Plot>> {
Cache<PlotId, Plot> plotCandidateCache = CacheBuilder.newBuilder() Cache<PlotId, Plot> plotCandidateCache = CacheBuilder.newBuilder()
.expireAfterWrite(20, TimeUnit.SECONDS).build(); .expireAfterWrite(20, TimeUnit.SECONDS).build();
Object plotLock = new Object(); Object plotLock = new Object();
final class AutoQuery {
private final PlotPlayer<?> player;
private final PlotId startId;
private final int sizeX;
private final int sizeZ;
private final PlotArea plotArea;
/**
* Crate a new auto query
*
* @param player Player to claim for
* @param startId Plot ID to start searching from
* @param sizeX Number of plots along the X axis
* @param sizeZ Number of plots along the Z axis
* @param plotArea Plot area to search in
*/
public AutoQuery(
final @NonNull PlotPlayer<?> player, final @Nullable PlotId startId,
final int sizeX, final int sizeZ, final @NonNull PlotArea plotArea
) {
this.player = player;
this.startId = startId;
this.sizeX = sizeX;
this.sizeZ = sizeZ;
this.plotArea = plotArea;
}
/**
* Get the player that the plots are meant for
*
* @return Player
*/
public @NonNull PlotPlayer<?> getPlayer() {
return this.player;
}
/**
* Get the plot ID to start searching from
*
* @return Start ID
*/
public @Nullable PlotId getStartId() {
return this.startId;
}
/**
* Get the number of plots along the X axis
*
* @return Number of plots along the X axis
*/
public int getSizeX() {
return this.sizeX;
}
/**
* Get the number of plots along the Z axis
*
* @return Number of plots along the Z axis
*/
public int getSizeZ() {
return this.sizeZ;
}
/**
* Get the plot area to search in
*
* @return Plot area
*/
public @NonNull PlotArea getPlotArea() {
return this.plotArea;
}
}
final class DefaultAutoService implements AutoService { final class DefaultAutoService implements AutoService {
@Override @Override
@ -125,17 +47,16 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>>
} }
final class SinglePlotService implements AutoService, Predicate<AutoQuery> { final class SinglePlotService implements AutoService, Predicate<AutoQuery> {
@Nullable @Nullable
@Override @Override
public List<Plot> handle(@NonNull AutoQuery autoQuery) { public List<Plot> handle(@NonNull AutoQuery autoQuery) {
Plot plot; Plot plot;
PlotId nextId = autoQuery.getStartId(); PlotId nextId = autoQuery.startId();
do { do {
synchronized (plotLock) { synchronized (plotLock) {
plot = autoQuery.getPlotArea().getNextFreePlot(autoQuery.getPlayer(), nextId); plot = autoQuery.plotArea().getNextFreePlot(autoQuery.player(), nextId);
if (plot != null && plotCandidateCache.getIfPresent(plot.getId()) == null) { if (plot != null && plotCandidateCache.getIfPresent(plot.getId()) == null) {
plotCandidateCache.put(plot.getId(), plot); plotCandidateCache.put(plot.getId(), plot);
return Collections.singletonList(plot); return Collections.singletonList(plot);
@ -151,12 +72,11 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>>
@Override @Override
public boolean test(final @NonNull AutoQuery autoQuery) { public boolean test(final @NonNull AutoQuery autoQuery) {
return autoQuery.sizeX == 1 && autoQuery.sizeZ == 1; return autoQuery.sizeX() == 1 && autoQuery.sizeZ() == 1;
} }
} }
final class MultiPlotService implements AutoService, Predicate<AutoQuery> { final class MultiPlotService implements AutoService, Predicate<AutoQuery> {
@Override @Override
@ -166,14 +86,14 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>>
while (true) { while (true) {
synchronized (plotLock) { synchronized (plotLock) {
final PlotId start = final PlotId start =
autoQuery.getPlotArea().getMeta("lastPlot", PlotId.of(0, 0)).getNextId(); autoQuery.plotArea().getMeta("lastPlot", PlotId.of(0, 0)).getNextId();
final PlotId end = PlotId.of( final PlotId end = PlotId.of(
start.getX() + autoQuery.getSizeX() - 1, start.getX() + autoQuery.sizeX() - 1,
start.getY() + autoQuery.getSizeZ() - 1 start.getY() + autoQuery.sizeZ() - 1
); );
final List<Plot> plots = final List<Plot> plots =
autoQuery.getPlotArea().canClaim(autoQuery.getPlayer(), start, end); autoQuery.plotArea().canClaim(autoQuery.player(), start, end);
autoQuery.getPlotArea().setMeta("lastPlot", start); // set entry point for next try autoQuery.plotArea().setMeta("lastPlot", start); // set entry point for next try
if (plots != null && !plots.isEmpty()) { if (plots != null && !plots.isEmpty()) {
for (final Plot plot : plots) { for (final Plot plot : plots) {
if (plotCandidateCache.getIfPresent(plot.getId()) != null) { if (plotCandidateCache.getIfPresent(plot.getId()) != null) {
@ -189,7 +109,7 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>>
@Override @Override
public boolean test(final @NonNull AutoQuery autoQuery) { public boolean test(final @NonNull AutoQuery autoQuery) {
return autoQuery.getPlotArea().getType() != PlotAreaType.PARTIAL; return autoQuery.plotArea().getType() != PlotAreaType.PARTIAL;
} }
} }

View File

@ -48,10 +48,10 @@ public class SettingsNodeStep implements SetupStep {
) { ) {
this.configurationNode = configurationNode; this.configurationNode = configurationNode;
this.id = id; this.id = id;
if (wrapper.getSettingsNodes().length > id + 1) { if (wrapper.settingsNodes().length > id + 1) {
this.next = new SettingsNodeStep(wrapper.getSettingsNodes()[id + 1], id + 1, wrapper); this.next = new SettingsNodeStep(wrapper.settingsNodes()[id + 1], id + 1, wrapper);
} else { } else {
this.next = wrapper.getAfterwards(); this.next = wrapper.afterwards();
} }
} }

View File

@ -23,15 +23,10 @@ import com.plotsquared.core.configuration.ConfigurationNode;
/** /**
* This class wraps an array of {@link ConfigurationNode}s. * This class wraps an array of {@link ConfigurationNode}s.
*/ */
public class SettingsNodesWrapper { public record SettingsNodesWrapper(
ConfigurationNode[] settingsNodes,
private final ConfigurationNode[] settingsNodes; SetupStep afterwards
private final SetupStep afterwards; ) {
public SettingsNodesWrapper(final ConfigurationNode[] settingsNodes, final SetupStep afterwards) {
this.settingsNodes = settingsNodes;
this.afterwards = afterwards;
}
/** /**
* Returns the first step of this wrapper or the step or the * Returns the first step of this wrapper or the step or the
@ -43,12 +38,4 @@ public class SettingsNodesWrapper {
return this.settingsNodes.length == 0 ? this.afterwards : new SettingsNodeStep(this.settingsNodes[0], 0, this); return this.settingsNodes.length == 0 ? this.afterwards : new SettingsNodeStep(this.settingsNodes[0], 0, this);
} }
public ConfigurationNode[] getSettingsNodes() {
return this.settingsNodes;
}
public SetupStep getAfterwards() {
return this.afterwards;
}
} }

View File

@ -18,14 +18,9 @@
*/ */
package com.plotsquared.core.util; package com.plotsquared.core.util;
public class FileBytes { public record FileBytes(
String path,
public final String path; byte[] data
public final byte[] data; ) {
public FileBytes(String path, byte[] data) {
this.path = path;
this.data = data;
}
} }

View File

@ -98,7 +98,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
consumer.accept(null, throwable); consumer.accept(null, throwable);
} else { } else {
for (final UUIDMapping uuid : uuids) { for (final UUIDMapping uuid : uuids) {
result.add(uuid.getUuid()); result.add(uuid.uuid());
} }
consumer.accept(result, null); consumer.accept(result, null);
} }
@ -136,7 +136,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
try { try {
for (final UUIDMapping mapping : PlotSquared.get().getImpromptuUUIDPipeline() for (final UUIDMapping mapping : PlotSquared.get().getImpromptuUUIDPipeline()
.getNames(players).get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS)) { .getNames(players).get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS)) {
users.add(Component.text(mapping.getUsername())); users.add(Component.text(mapping.username()));
} }
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -200,7 +200,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
final UUIDMapping uuidMapping = final UUIDMapping uuidMapping =
PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner); PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner);
if (uuidMapping != null) { if (uuidMapping != null) {
name = uuidMapping.getUsername(); name = uuidMapping.username();
} else { } else {
name = null; name = null;
} }

View File

@ -238,8 +238,8 @@ public final class TabCompletions {
PlotSquared.get().getImpromptuUUIDPipeline().getAllImmediately(); PlotSquared.get().getImpromptuUUIDPipeline().getAllImmediately();
players = new ArrayList<>(mappings.size()); players = new ArrayList<>(mappings.size());
for (final UUIDMapping mapping : mappings) { for (final UUIDMapping mapping : mappings) {
if (uuidFilter.test(mapping.getUuid())) { if (uuidFilter.test(mapping.uuid())) {
players.add(mapping.getUsername()); players.add(mapping.username());
} }
} }
cachedCompletionValues.put(cacheIdentifier, players); cachedCompletionValues.put(cacheIdentifier, players);

View File

@ -298,19 +298,11 @@ public final class PlaceholderRegistry {
} }
/** /**
* Event called when a new {@link Placeholder} has been added * Event called when a new {@link Placeholder} has been added
*/ */
public static class PlaceholderAddedEvent { public record PlaceholderAddedEvent(
Placeholder placeholder
private final Placeholder placeholder; ) {
public PlaceholderAddedEvent(Placeholder placeholder) {
this.placeholder = placeholder;
}
public Placeholder getPlaceholder() {
return this.placeholder;
}
} }

View File

@ -67,8 +67,8 @@ public class CacheUUIDService implements UUIDService, Consumer<List<UUIDMapping>
@Override @Override
public void accept(final @NonNull List<@NonNull UUIDMapping> uuidMappings) { public void accept(final @NonNull List<@NonNull UUIDMapping> uuidMappings) {
for (final UUIDMapping mapping : uuidMappings) { for (final UUIDMapping mapping : uuidMappings) {
this.uuidCache.put(mapping.getUuid(), mapping); this.uuidCache.put(mapping.uuid(), mapping);
this.usernameCache.put(mapping.getUsername(), mapping); this.usernameCache.put(mapping.username(), mapping);
} }
} }

View File

@ -20,29 +20,15 @@ package com.plotsquared.core.uuid;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
/** /**
* A pair consisting of a UUID and a username * A pair consisting of a UUID and a username
*/ */
public class UUIDMapping { public record UUIDMapping(
@NonNull UUID uuid,
private final UUID uuid; @NonNull String username
private final String username; ) {
public UUIDMapping(final @NonNull UUID uuid, final @NonNull String username) {
this.uuid = uuid;
this.username = username;
}
public @NonNull String getUsername() {
return this.username;
}
public @NonNull UUID getUuid() {
return this.uuid;
}
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
@ -56,9 +42,4 @@ public class UUIDMapping {
return uuid.equals(that.uuid) && username.equals(that.username); return uuid.equals(that.uuid) && username.equals(that.username);
} }
@Override
public int hashCode() {
return Objects.hash(uuid, username);
}
} }

View File

@ -157,7 +157,7 @@ public class UUIDPipeline {
TimeUnit.MILLISECONDS TimeUnit.MILLISECONDS
); );
if (mappings.size() == 1) { if (mappings.size() == 1) {
return mappings.get(0).getUuid(); return mappings.get(0).uuid();
} }
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
e.printStackTrace(); e.printStackTrace();
@ -182,7 +182,7 @@ public class UUIDPipeline {
try { try {
final List<UUIDMapping> mappings = this.getNames(Collections.singletonList(uuid)).get(timeout, TimeUnit.MILLISECONDS); final List<UUIDMapping> mappings = this.getNames(Collections.singletonList(uuid)).get(timeout, TimeUnit.MILLISECONDS);
if (mappings.size() == 1) { if (mappings.size() == 1) {
return mappings.get(0).getUsername(); return mappings.get(0).username();
} }
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
e.printStackTrace(); e.printStackTrace();
@ -209,7 +209,7 @@ public class UUIDPipeline {
uuid.accept(null, throwable); uuid.accept(null, throwable);
} else { } else {
if (!uuids.isEmpty()) { if (!uuids.isEmpty()) {
uuid.accept(uuids.get(0).getUuid(), null); uuid.accept(uuids.get(0).uuid(), null);
} else { } else {
uuid.accept(null, null); uuid.accept(null, null);
} }
@ -231,7 +231,7 @@ public class UUIDPipeline {
username.accept(null, throwable); username.accept(null, throwable);
} else { } else {
if (!uuids.isEmpty()) { if (!uuids.isEmpty()) {
username.accept(uuids.get(0).getUsername(), null); username.accept(uuids.get(0).username(), null);
} else { } else {
username.accept(null, null); username.accept(null, null);
} }
@ -296,7 +296,7 @@ public class UUIDPipeline {
if (service.canBeSynchronous()) { if (service.canBeSynchronous()) {
final List<UUIDMapping> completedRequests = service.getNames(remainingRequests); final List<UUIDMapping> completedRequests = service.getNames(remainingRequests);
for (final UUIDMapping mapping : completedRequests) { for (final UUIDMapping mapping : completedRequests) {
remainingRequests.remove(mapping.getUuid()); remainingRequests.remove(mapping.uuid());
} }
mappings.addAll(completedRequests); mappings.addAll(completedRequests);
} else { } else {
@ -311,7 +311,7 @@ public class UUIDPipeline {
for (final UUIDService service : serviceList) { for (final UUIDService service : serviceList) {
final List<UUIDMapping> completedRequests = service.getNames(remainingRequests); final List<UUIDMapping> completedRequests = service.getNames(remainingRequests);
for (final UUIDMapping mapping : completedRequests) { for (final UUIDMapping mapping : completedRequests) {
remainingRequests.remove(mapping.getUuid()); remainingRequests.remove(mapping.uuid());
} }
mappings.addAll(completedRequests); mappings.addAll(completedRequests);
if (remainingRequests.isEmpty()) { if (remainingRequests.isEmpty()) {
@ -365,7 +365,7 @@ public class UUIDPipeline {
if (service.canBeSynchronous()) { if (service.canBeSynchronous()) {
final List<UUIDMapping> completedRequests = service.getUUIDs(remainingRequests); final List<UUIDMapping> completedRequests = service.getUUIDs(remainingRequests);
for (final UUIDMapping mapping : completedRequests) { for (final UUIDMapping mapping : completedRequests) {
remainingRequests.remove(mapping.getUsername()); remainingRequests.remove(mapping.username());
} }
mappings.addAll(completedRequests); mappings.addAll(completedRequests);
} else { } else {
@ -380,7 +380,7 @@ public class UUIDPipeline {
for (final UUIDService service : serviceList) { for (final UUIDService service : serviceList) {
final List<UUIDMapping> completedRequests = service.getUUIDs(remainingRequests); final List<UUIDMapping> completedRequests = service.getUUIDs(remainingRequests);
for (final UUIDMapping mapping : completedRequests) { for (final UUIDMapping mapping : completedRequests) {
remainingRequests.remove(mapping.getUsername()); remainingRequests.remove(mapping.username());
} }
mappings.addAll(completedRequests); mappings.addAll(completedRequests);
if (remainingRequests.isEmpty()) { if (remainingRequests.isEmpty()) {

View File

@ -155,7 +155,7 @@ subprojects {
id.set("NotMyFault") id.set("NotMyFault")
name.set("Alexander Brandes") name.set("Alexander Brandes")
organization.set("IntellectualSites") organization.set("IntellectualSites")
email.set("contact@notmyfault.dev") email.set("contact(at)notmyfault.dev")
} }
developer { developer {
id.set("SirYwell") id.set("SirYwell")

View File

@ -11,17 +11,17 @@ essentialsx = "2.19.7"
mvdwapi = "3.1.1" mvdwapi = "3.1.1"
# Third party # Third party
prtree = "2.0.0" prtree = "2.0.1"
aopalliance = "1.0" aopalliance = "1.0"
cloud-services = "1.8.0" cloud-services = "1.8.2"
arkitektonika = "2.1.1" arkitektonika = "2.1.1"
squirrelid = "0.3.1" squirrelid = "0.3.1"
# Gradle plugins # Gradle plugins
shadow = "7.1.2" shadow = "7.1.2"
grgit = "4.1.1" grgit = "4.1.1"
spotless = "6.15.0" spotless = "6.16.0"
nexus = "1.1.0" nexus = "1.2.0"
[libraries] [libraries]
# Platform expectations # Platform expectations

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
networkTimeout=10000 networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists