Skip to content

Commit 7c37629

Browse files
committed
2 parents 341de24 + 495d951 commit 7c37629

File tree

66 files changed

+3053
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3053
-154
lines changed

.github/workflows/ci.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Build Gradle and Publish Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- 'master'
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
build-gradle:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: 0
25+
26+
- uses: actions/setup-java@v3
27+
with:
28+
distribution: 'temurin'
29+
java-version: '17'
30+
31+
- name: Setup Gradle
32+
uses: gradle/gradle-build-action@v2
33+
34+
- name: Run build with Gradle wrapper
35+
run: ./gradlew build
36+
37+
- name: Upload all artifacts
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: jars
41+
path: |
42+
bukkit/loader/build/libs/LuckPerms-Bukkit-*.jar
43+
bukkit-legacy/loader/build/libs/LuckPerms-Bukkit-Legacy-*.jar
44+
bungee/loader/build/libs/LuckPerms-Bungee-*.jar
45+
sponge/loader/build/libs/LuckPerms-Sponge-*.jar
46+
nukkit/loader/build/libs/LuckPerms-Nukkit-*.jar
47+
velocity/build/libs/LuckPerms-Velocity-*.jar
48+
fabric/build/libs/LuckPerms-Fabric-*.jar
49+
forge/loader/build/libs/LuckPerms-Forge-*.jar
50+
standalone/loader/build/libs/LuckPerms-Standalone-*.jar
51+
52+
- name: Upload standalone artifact
53+
uses: actions/upload-artifact@v3
54+
with:
55+
name: standalone-binary
56+
path: standalone/loader/build/libs/LuckPerms-Standalone-*.jar
57+
58+
59+
build-docker:
60+
needs: build-gradle
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: read
64+
packages: write
65+
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v3
69+
70+
- name: Retrieve saved standalone jar artifact
71+
uses: actions/download-artifact@v3
72+
with:
73+
name: standalone-binary
74+
path: standalone/docker/
75+
76+
- name: Display structure of downloaded files
77+
run: ls -R
78+
working-directory: standalone/docker/
79+
80+
- name: Set up QEMU
81+
uses: docker/setup-qemu-action@v1
82+
83+
- name: Set up Docker Buildx
84+
uses: docker/setup-buildx-action@v1
85+
86+
- name: Log in to the Container registry
87+
uses: docker/login-action@v1
88+
with:
89+
registry: ${{ env.REGISTRY }}
90+
username: ${{ github.actor }}
91+
password: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Extract metadata for Docker
94+
id: meta
95+
uses: docker/metadata-action@v3
96+
with:
97+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
98+
flavor: |
99+
latest=${{ github.ref == 'refs/heads/master' }}
100+
101+
- name: Build and push Docker image
102+
uses: docker/build-push-action@v2
103+
with:
104+
context: standalone/docker/
105+
platforms: linux/amd64,linux/arm64
106+
push: ${{ github.event_name != 'pull_request' }}
107+
tags: ${{ steps.meta.outputs.tags }}
108+
labels: ${{ steps.meta.outputs.labels }}

api/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
group = 'net.luckperms'
22
project.version = '5.4'
33

4+
jar {
5+
manifest {
6+
attributes('Automatic-Module-Name': 'net.luckperms.api')
7+
}
8+
}
9+
410
dependencies {
511
compileOnly 'org.checkerframework:checker-qual:3.21.2'
612
compileOnly 'org.jetbrains:annotations:23.0.0'

api/src/main/java/net/luckperms/api/cacheddata/CachedMetaData.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import net.luckperms.api.node.types.MetaNode;
3030
import net.luckperms.api.node.types.PrefixNode;
3131
import net.luckperms.api.node.types.SuffixNode;
32+
import net.luckperms.api.node.types.WeightNode;
3233

3334
import org.checkerframework.checker.nullness.qual.NonNull;
3435
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -177,6 +178,30 @@ public interface CachedMetaData extends CachedData {
177178
return querySuffix().result();
178179
}
179180

181+
/**
182+
* Query for a weight.
183+
*
184+
* <p>This method will always return a {@link Result}, and the
185+
* {@link Result#result() inner result} {@link Integer} will never be null.
186+
* A value of {@code 0} is equivalent to null.</p>
187+
*
188+
* @return a result containing the weight
189+
* @since 5.5
190+
*/
191+
@NonNull Result<Integer, WeightNode> queryWeight();
192+
193+
/**
194+
* Gets the weight.
195+
*
196+
* <p>If the there is no defined weight, {@code 0} is returned.</p>
197+
*
198+
* @return the weight
199+
* @since 5.5
200+
*/
201+
default int getWeight() {
202+
return queryWeight().result();
203+
}
204+
180205
/**
181206
* Gets a map of all accumulated {@link MetaNode meta}.
182207
*

api/src/main/java/net/luckperms/api/platform/Platform.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ enum Type {
7676
NUKKIT("Nukkit"),
7777
VELOCITY("Velocity"),
7878
FABRIC("Fabric"),
79-
FORGE("Forge");
79+
FORGE("Forge"),
80+
STANDALONE("Standalone");
8081

8182
private final String friendlyName;
8283

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ subprojects {
5252

5353
repositories {
5454
mavenCentral()
55-
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
55+
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
56+
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
5657
maven { url 'https://repo.lucko.me/' }
5758
maven { url 'https://libraries.minecraft.net/' }
5859
maven { url 'https://repo.clojars.org/' }

bukkit-legacy/loader/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
repositories {
6-
maven { url 'https://papermc.io/repo/repository/maven-public/' }
6+
maven { url 'https://repo.papermc.io/repository/maven-public/' }
77
}
88

99
dependencies {

bukkit/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
repositories {
6-
maven { url 'https://papermc.io/repo/repository/maven-public/' }
6+
maven { url 'https://repo.papermc.io/repository/maven-public/' }
77
}
88

99
dependencies {

bukkit/loader/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
repositories {
6-
maven { url 'https://papermc.io/repo/repository/maven-public/' }
6+
maven { url 'https://repo.papermc.io/repository/maven-public/' }
77
}
88

99
dependencies {

common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ protected void processOutput(JsonObject json) {
258258

259259
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
260260
try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(bytesOut), StandardCharsets.UTF_8)) {
261-
GsonProvider.prettyPrinting().toJson(json, writer);
261+
GsonProvider.normal().toJson(json, writer);
262262
} catch (IOException e) {
263263
this.plugin.getLogger().severe("Error compressing data", e);
264264
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* This file is part of LuckPerms, licensed under the MIT License.
3+
*
4+
* Copyright (c) lucko (Luck) <luck@lucko.me>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
26+
package me.lucko.luckperms.common.cacheddata.result;
27+
28+
import net.luckperms.api.cacheddata.Result;
29+
import net.luckperms.api.node.Node;
30+
import net.luckperms.api.node.types.WeightNode;
31+
32+
import org.checkerframework.checker.nullness.qual.NonNull;
33+
import org.checkerframework.checker.nullness.qual.Nullable;
34+
35+
/**
36+
* Represents the result of an integer meta lookup
37+
*
38+
* @param <N> the node type
39+
*/
40+
public final class IntegerResult<N extends Node> implements Result<Integer, N> {
41+
42+
/** The result */
43+
private final int result;
44+
/** The node that caused the result */
45+
private final N node;
46+
/** A reference to another result that this one overrides */
47+
private IntegerResult<N> overriddenResult;
48+
49+
public IntegerResult(int result, N node, IntegerResult<N> overriddenResult) {
50+
this.result = result;
51+
this.node = node;
52+
this.overriddenResult = overriddenResult;
53+
}
54+
55+
@Override
56+
@Deprecated // use intResult()
57+
public @NonNull Integer result() {
58+
return this.result;
59+
}
60+
61+
public int intResult() {
62+
return this.result;
63+
}
64+
65+
public StringResult<N> asStringResult() {
66+
if (isNull()) {
67+
return StringResult.nullResult();
68+
} else {
69+
StringResult<N> result = StringResult.of(Integer.toString(this.result), this.node);
70+
if (this.overriddenResult != null) {
71+
result.setOverriddenResult(this.overriddenResult.asStringResult());
72+
}
73+
return result;
74+
}
75+
}
76+
77+
@Override
78+
public @Nullable N node() {
79+
return this.node;
80+
}
81+
82+
public @Nullable IntegerResult<N> overriddenResult() {
83+
return this.overriddenResult;
84+
}
85+
86+
public void setOverriddenResult(IntegerResult<N> overriddenResult) {
87+
this.overriddenResult = overriddenResult;
88+
}
89+
90+
public boolean isNull() {
91+
return this == NULL_RESULT;
92+
}
93+
94+
public IntegerResult<N> copy() {
95+
return new IntegerResult<>(this.result, this.node, this.overriddenResult);
96+
}
97+
98+
@Override
99+
public String toString() {
100+
return "IntegerResult(" +
101+
"result=" + this.result + ", " +
102+
"node=" + this.node + ", " +
103+
"overriddenResult=" + this.overriddenResult + ')';
104+
}
105+
106+
private static final IntegerResult<?> NULL_RESULT = new IntegerResult<>(0, null, null);
107+
108+
@SuppressWarnings("unchecked")
109+
public static <N extends Node> IntegerResult<N> nullResult() {
110+
return (IntegerResult<N>) NULL_RESULT;
111+
}
112+
113+
public static <N extends Node> IntegerResult<N> of(int result) {
114+
return new IntegerResult<>(result, null, null);
115+
}
116+
117+
public static <N extends Node> IntegerResult<N> of(int result, N node) {
118+
return new IntegerResult<>(result, node, null);
119+
}
120+
121+
public static IntegerResult<WeightNode> of(WeightNode node) {
122+
return new IntegerResult<>(node.getWeight(), node, null);
123+
}
124+
125+
}

0 commit comments

Comments
 (0)