diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index e23be00b..1d2f8f14 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -23,10 +23,10 @@ jobs: distribution: temurin - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1.1.0 + uses: gradle/wrapper-validation-action@v2 - name: Build with Gradle - uses: gradle/gradle-build-action@v2.11.1 + uses: gradle/gradle-build-action@v3 with: arguments: build diff --git a/build.gradle b/build.gradle index 9c56673f..3c2a5873 100644 --- a/build.gradle +++ b/build.gradle @@ -2,14 +2,26 @@ plugins { id 'java' id 'com.github.johnrengelman.shadow' version '8.1.1' id 'org.sonarqube' version '4.4.1.3373' + id 'io.freefair.lombok' version '8.6' + id 'net.minecrell.plugin-yml.bukkit' version '0.6.0' } group = 'io.github.slimefunguguproject' +version = 'UNOFFICIAL' description = 'Bump' -java.sourceCompatibility = JavaVersion.VERSION_16 + +java { + sourceCompatibility = JavaVersion.VERSION_16 +} + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} repositories { + mavenLocal() mavenCentral() + maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') } @@ -24,33 +36,28 @@ repositories { } dependencies { - implementation 'net.guizhanss:GuizhanLib-api:1.7.0' + implementation 'net.guizhanss:GuizhanLib-api:1.7.6' implementation 'dev.sefiraat:SefiLib:0.2.6' implementation 'org.bstats:bstats-bukkit:3.0.2' - compileOnly 'org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT' - compileOnly 'io.github.Slimefun:Slimefun4:RC-32' + compileOnly 'org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT' + compileOnly 'io.github.Slimefun:Slimefun4:RC-37' compileOnly 'com.google.code.findbugs:jsr305:3.0.2' - compileOnly 'org.projectlombok:lombok:1.18.30' - - annotationProcessor 'org.projectlombok:lombok:1.18.30' } shadowJar { - // relocate 'net.guizhanss.guizhanlib', 'io.github.slimefunguguproject.bump.guizhanlib' - relocate 'dev.sefiraat.sefilib', 'io.github.slimefunguguproject.bump.sefilib' - relocate 'org.bstats', 'io.github.slimefunguguproject.bump.bstats' + relocate 'net.guizhanss.guizhanlib', 'io.github.slimefunguguproject.bump.libs.guizhanlib' + relocate 'dev.sefiraat.sefilib', 'io.github.slimefunguguproject.bump.libs.sefilib' + relocate 'org.bstats', 'io.github.slimefunguguproject.bump.libs.bstats' minimize() } -processResources { - expand project.properties - def props = [version: version] - inputs.properties props - filteringCharset 'UTF-8' - filesMatching('plugin.yml') { - expand props - } +bukkit { + main = 'io.github.slimefunguguproject.bump.implementation.Bump' + apiVersion = '1.16' + authors = ['bxx2004', 'LobbyTech-MC', 'zimzaza4', 'haiman233', 'ybw0014'] + depend = ['Slimefun'] + softDepend = ['GuizhanLibPlugin'] } sonar { @@ -60,7 +67,3 @@ sonar { property "sonar.host.url", "https://sonarcloud.io" } } - -tasks.withType(JavaCompile) { - options.encoding = 'UTF-8' -} diff --git a/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseAttribute.java b/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseAttribute.java index 4f0b2b3f..2f650fba 100644 --- a/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseAttribute.java +++ b/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseAttribute.java @@ -85,15 +85,15 @@ public int hashCode() { } /** - * Get the percentile of result value within range. + * Get the percentage of result value within range. *

* Return range from 0 to 100. * * @param value The result value. * - * @return The percentile of the result value. + * @return The percentage of the result value. */ - public double getPercentile(double value) { + public double getPercentage(double value) { if (value <= min) { return 0; } else if (value >= max) { @@ -104,13 +104,13 @@ public double getPercentile(double value) { } /** - * Get the weighted percentile of result value. + * Get the weighted percentage of result value. * * @param value The result value. * - * @return The weighted percentile of the result value. + * @return The weighted percentage of the result value. */ - public double getWeightedPercentile(double value) { - return getPercentile(value) * weight / 100.D; + public double getWeightedPercentage(double value) { + return getPercentage(value) * weight / 100.D; } } diff --git a/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseResult.java b/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseResult.java index 0c10366d..57f99ca3 100644 --- a/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseResult.java +++ b/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseResult.java @@ -30,7 +30,7 @@ import lombok.Getter; /** - * An {@link AppraiseResult} contains results of attributes and + * An {@link AppraiseResult} contains results of attributes and the weights. * * @author ybw0014 */ @@ -40,20 +40,17 @@ public final class AppraiseResult { /** * This is a reference to the {@link AppraiseType} that generates this {@link AppraiseResult}. */ - @Getter private final AppraiseType appraiseType; /** * This unmodifiable map stores the {@link AppraiseAttribute} and result. */ - @Getter private final Map result; /** - * This represents the calculated overall percentile. + * This represents the calculated overall percentage. */ - @Getter - private final double totalPercentile; + private final double totalPercentage; /** * Construct this {@link AppraiseResult} from {@link Builder} @@ -63,7 +60,7 @@ public final class AppraiseResult { private AppraiseResult(@Nonnull Builder builder) { this.appraiseType = builder.appraiseType; this.result = Map.copyOf(builder.result); - this.totalPercentile = builder.totalPercentile; + this.totalPercentage = builder.totalPercentage; } /** @@ -74,7 +71,7 @@ private AppraiseResult(@Nonnull Builder builder) { */ public byte getStars() { for (Map.Entry entry : Bump.getRegistry().getStarThresholds().entrySet()) { - if (totalPercentile >= entry.getKey()) { + if (totalPercentage >= entry.getKey()) { return entry.getValue(); } } @@ -140,7 +137,7 @@ public void apply(@Nullable ItemStack itemStack) { static class Builder { private final AppraiseType appraiseType; private final Map result = new HashMap<>(); - private double totalPercentile = 0; + private double totalPercentage = 0; Builder(@Nonnull AppraiseType type) { appraiseType = type; @@ -156,7 +153,7 @@ static class Builder { */ Builder add(AppraiseAttribute attribute, double result) { this.result.put(attribute, result); - totalPercentile += attribute.getWeightedPercentile(result); + totalPercentage += attribute.getWeightedPercentage(result); return this; } diff --git a/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseType.java b/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseType.java index afe90a80..ac15c2cb 100644 --- a/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseType.java +++ b/src/main/java/io/github/slimefunguguproject/bump/api/appraise/AppraiseType.java @@ -56,17 +56,20 @@ public class AppraiseType { private final NamespacedKey key; /** - * This is the display name of {@link AppraiseType}. + * The display name of {@link AppraiseType}. */ @Getter private String name; /** - * This is the description of {@link AppraiseType}. + * The description of {@link AppraiseType}. */ @Getter private List description = new ArrayList<>(); + /** + * The permission required to use this {@link AppraiseType}. + */ @Getter private String permission; @@ -77,9 +80,9 @@ public class AppraiseType { private Set attributes = new LinkedHashSet<>(); /** - * This indicates the used percentile of added {@link AppraiseAttribute}. + * This indicates the used percentage of added {@link AppraiseAttribute}. */ - private double usedPercentile; + private double usedPercentage; /** * This indicates whether check equipment material when appraising. @@ -267,14 +270,14 @@ public final AppraiseType addAttribute(Attribute attribute, double min, double m Preconditions.checkArgument(weight == -1 || (weight >= 0 && weight <= 100), "The weight should be -1 or between 0 and 100"); if (weight != -1) { - Preconditions.checkArgument(usedPercentile + weight <= 100, "The overall weight exceeds 100"); + Preconditions.checkArgument(usedPercentage + weight <= 100, "The overall weight exceeds 100"); } AppraiseAttribute attr = new AppraiseAttribute(attribute, min, max, weight); attributes.add(attr); if (weight != -1) { - usedPercentile += weight; + usedPercentage += weight; } return this; @@ -405,17 +408,17 @@ public final AppraiseType register(@Nonnull SlimefunAddon addon) { .filter(appraiseAttribute -> appraiseAttribute.getWeight() == -1) .collect(Collectors.toSet()); - // check percentile - if (usedPercentile < 100 && noWeightAttributes.isEmpty()) { - throw new IllegalArgumentException("Used percentile is less than 100"); + // check percentage + if (usedPercentage < 100 && noWeightAttributes.isEmpty()) { + throw new IllegalArgumentException("Used percentage is less than 100"); } // split remaining weight int num = noWeightAttributes.size(); - double percentile = (100 - usedPercentile) / num; + double percentage = (100 - usedPercentage) / num; for (AppraiseAttribute attr : noWeightAttributes) { - attr.setWeight(percentile); - usedPercentile += percentile; + attr.setWeight(percentage); + usedPercentage += percentage; } // registry diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml deleted file mode 100644 index 9b7b4d2f..00000000 --- a/src/main/resources/plugin.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Bump -main: io.github.slimefunguguproject.bump.implementation.Bump -website: https://github.com/SlimefunGuguProject/Bump -version: '${project.version}' -api-version: 1.16 -authors: - - bxx2004 - - Lobbytech-MC - - zimzaza4 - - haiman233 - - ybw0014 -depend: - - Slimefun -softdepend: - - GuizhanLibPlugin