Skip to content

Commit

Permalink
Merge branch 'main' into v0.0.26
Browse files Browse the repository at this point in the history
  • Loading branch information
cjburkey01 committed Jun 5, 2024
2 parents 3bcebc8 + 0b4462f commit 658955d
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 14 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![ClaimChunk Logo](imgs/icon64.png)
![ClaimChunk Title](imgs/logo_carrier.png)

[![Plugin Version](https://img.shields.io/static/v1?label=Version&message=0.0.25-FIX1&color=blueviolet&style=for-the-badge)](https://github.com/cjburkey01/ClaimChunk/releases)
[![Plugin Version](https://img.shields.io/static/v1?label=Version&message=0.0.25-FIX3&color=blueviolet&style=for-the-badge)](https://github.com/cjburkey01/ClaimChunk/releases)
[![Maven Central Version](https://img.shields.io/maven-central/v/com.cjburkey.claimchunk/claimchunk?label=Maven%20Central&color=blueviolet&style=for-the-badge)](https://central.sonatype.com/artifact/com.cjburkey.claimchunk/claimchunk)
[![Minecraft Version](https://img.shields.io/static/v1?label=Spigot&message=1.20.6&color=blueviolet&style=for-the-badge)](https://www.spigotmc.org/resources/claimchunk.44458/)
![Java Version](https://img.shields.io/static/v1?label=Java&message=17&color=blueviolet&style=for-the-badge)
Expand Down Expand Up @@ -85,20 +85,20 @@ Maven:
<dependency>
<groupId>com.cjburkey.claimchunk</groupId>
<artifactId>claimchunk</artifactId>
<version>0.0.25-FIX1</version>
<version>0.0.25-FIX3</version>
</dependency>
```

Gradle (Groovy):

```groovy
implementation 'com.cjburkey.claimchunk:claimchunk:0.0.25-FIX1'
implementation 'com.cjburkey.claimchunk:claimchunk:0.0.25-FIX3'
```

Gradle (Kotlin):

```kotlin
implementation("com.cjburkey.claimchunk:claimchunk:0.0.25-FIX1")
implementation("com.cjburkey.claimchunk:claimchunk:0.0.25-FIX3")
```

Building
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
object DepData {
const val JAVA_VERSION = 17

const val LIVE_VERSION = "0.0.25-FIX1"
const val LIVE_VERSION = "0.0.25-FIX3"
const val THIS_VERSION = "0.0.26-SNAPSHOT1"
const val PLUGIN_NAME = "ClaimChunk"
const val ARCHIVES_BASE_NAME = "claimchunk"
Expand Down
4 changes: 4 additions & 0 deletions changelogs/0.0.25-FIX1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ClaimChunk 0.0.25-FIX1

Fixes:
* Crash on first launch! Kinda a problem :)
8 changes: 8 additions & 0 deletions changelogs/0.0.25-FIX2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ClaimChunk 0.0.25-FIX1

Fixes:
* Re-add the `claimchunk_am_trusted` placeholder
* The placeholder works the same way, returning that the player is trusted if
said player has *any* permissions granted by the owner for the chunk they're
standing in (the chunk must be owned; the placeholder shows not trusted in
unclaimed chunks to match pre-0.0.24 behavior).
5 changes: 5 additions & 0 deletions changelogs/0.0.25-FIX3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ClaimChunk 0.0.25-FIX1

Fixes:
* My stupid update checker
* Allow header customization for chunk list command in messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public final class V2JsonMessages {
public String infoName = "Chunk name: &l%%NAME%%";

// List localization
public String claimsHeader = "%s&l--- [ %s ] ---";
public String claimsTitle = "Claims for %%NAME%% in %%WORLD%%";
public String claimsChunk = "%%X%%, %%Z%%";
public String claimsPagination = "Page %%PAGE%% of %%MAXPAGE%%";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cjburkey.claimchunk.placeholder;

import com.cjburkey.claimchunk.api.IClaimChunkPlugin;
import com.cjburkey.claimchunk.chunk.ChunkPos;

import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
Expand Down Expand Up @@ -64,6 +65,17 @@ public ClaimChunkPlaceholders(IClaimChunkPlugin claimChunk) {

/* Online player with chunk owner UUID placeholders */

// Whether this player has ANY permissions in the chunk they're inside
playerOwnerPlaceholders.put(
"am_trusted",
(ply, ignoredOwner) -> {
ChunkPos pos = new ChunkPos(ply.getLocation().getChunk());
Map<String, Boolean> permissions =
claimChunk.getPlayerHandler().getPermissions(pos, ply.getUniqueId());
return permissions == null
|| permissions.values().stream().anyMatch(Boolean::booleanValue);
});

// Get the username of the owner for this chunk
playerOwnerPlaceholders.put(
"current_owner",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public boolean onCall(@NotNull String cmdUsed, @NotNull CommandSender executor,
messageChat(
player,
String.format(
"%s&l--- [ %s ] ---",
claimChunk.getMessages().claimsHeader,
claimChunk.getConfigHandler().getInfoColor(),
claimChunk
.getMessages()
Expand Down
43 changes: 37 additions & 6 deletions src/main/java/com/cjburkey/claimchunk/update/SemVer.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,60 @@ private static IllegalArgumentException INVALID_SEMVER(String input, Throwable c

@Override
public int compareTo(SemVer o) {
// If the other major is larger than this one, this one is older
if (o.major > major) return -1;
// If this major is larger, this one is newer
if (o.major < major) return 1;

// Same as major handling
if (o.minor > minor) return -1;
if (o.minor < minor) return 1;

// Same as major/minor handling
if (o.patch > patch) return -1;
if (o.patch < patch) return 1;

if (marker != null && o.marker != null) {
return marker.compareTo(o.marker);
}
boolean thisIsFixMarker = marker != null && marker.toUpperCase().startsWith("FIX");
boolean otherIsFixMarker = o.marker != null && o.marker.toUpperCase().startsWith("FIX");

// Quick hack fix, if I release 0.0.25 and then 0.0.25-FIX1, I want FIX1 to represent a
// newer version because I've decided semver is a fuck and I can do what i want
if (marker == null && o.marker != null && !o.marker.startsWith("FIX")) {
// If the other version has a "FIX" marker but this version has no marker, the fix is newer.
if (marker == null && o.marker != null && otherIsFixMarker) {
return -1;
}
// If the other version doesn't have a marker but this one has a fix marker, this one is
// newer.
if (o.marker == null && marker != null && thisIsFixMarker) {
return 1;
}

if (marker != null) {
// If both versions have a marker, do string comparison (they should end with numbers to
// differentiate them, such as RC1, RC2, etc.)
if (o.marker != null) {
// If this version has a fix marker but the other one doesn't, this one is newer
if (thisIsFixMarker && !otherIsFixMarker) {
return 1;
}
// If this version doesn't have a fix marker but the other one does, the other
// version is newer.
if (otherIsFixMarker && !thisIsFixMarker) {
return -1;
}

return marker.compareTo(o.marker);
}

// If there is a marker on this one but not a marker on the other one, this one is OLDER
return -1;
}

// If the other version has a marker but this one does not (and it's not a FIX marker), this
// version is newer.
if (o.marker != null) {
return 1;
}

// Versions are equal
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.Arrays;
import java.util.Comparator;

// A not-too-flexible GitHub update checker designed by yours truly!
Expand Down Expand Up @@ -63,7 +62,6 @@ public static SemVer getLatestRelease()
throws URISyntaxException, InterruptedException, IOException {
GithubRelease[] tags = getRepoReleases();
if (tags.length == 0) return null;
if (tags.length > 1) Arrays.sort(tags, new GithubTagComparator());
return tags[tags.length - 1].semVer;
}

Expand Down
25 changes: 25 additions & 0 deletions src/test/java/com/cjburkey/claimchunk/TestSemVerMee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.cjburkey.claimchunk;

import com.cjburkey.claimchunk.update.SemVer;

import org.junit.jupiter.api.Test;

class TestSemVerMee {

@Test
void testVersions() {
SemVer v0022 = new SemVer(0, 0, 22, null);
SemVer v0024 = new SemVer(0, 0, 24, null);
SemVer v0024FIX1 = new SemVer(0, 0, 24, "FIX1");
SemVer v0024FIX2 = new SemVer(0, 0, 24, "FIX2");
SemVer v0024RC1 = new SemVer(0, 0, 24, "RC1");
SemVer v0024RC2 = new SemVer(0, 0, 24, "RC2");

assert v0024.isNewerThan(v0022);
assert v0024FIX1.isNewerThan(v0024);
assert v0024FIX1.isNewerThan(v0024RC1);
assert v0024FIX2.isNewerThan(v0024FIX1);
assert v0024RC2.isNewerThan(v0024RC1);
assert !v0024RC1.isNewerThan(v0024RC2);
}
}

0 comments on commit 658955d

Please sign in to comment.