Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #60

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
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
20 changes: 14 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
name: SonarCloud
name: Build
on:
push:
branches:
- develop
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
distribution: 'adopt'
java-version: '21'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
Expand All @@ -36,3 +35,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_Upgrades
- run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
- run: mkdir staging && cp target/*.jar staging
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: Package
path: staging


34 changes: 24 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>16</java.version>
<java.version>21</java.version>
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.9</powermock.version>

<spigot.version>1.16.5-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.20.0-SNAPSHOT</bentobox.version>
<level.version>2.9.0</level.version>
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>3.0.0-SNAPSHOT</bentobox.version>
<level.version>2.17.0</level.version>
<limits.version>1.19.1-SNAPSHOT</limits.version>
<vault.version>1.7</vault.version>

Expand Down Expand Up @@ -216,17 +216,20 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<version>3.8.1</version>
<configuration>
<release>${java.version}</release>
<!-- <source>${java.version}</source> <target>${java.version}</target> -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<!--suppress MavenModelInspection -->
<configuration>
<argLine>
${argLine}
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.math=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
Expand All @@ -244,13 +247,17 @@
--add-opens java.base/java.nio.charset=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.logging/java.util.logging=ALL-UNNAMED
--add-opens java.base/java.lang.ref=ALL-UNNAMED
--add-opens java.base/java.util.jar=ALL-UNNAMED
--add-opens java.base/java.util.zip=ALL-UNNAMED
--add-opens=java.base/java.security=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -262,30 +269,37 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<version>0.8.10</version>
<configuration>
<append>true</append>
<excludes>
<!-- This is required to prevent Jacoco from adding
synthetic fields to a JavaBean class (causes errors in testing) -->
<exclude>**/*Names*</exclude>
<!-- Prevents the Material is too large to mock error -->
<exclude>org/bukkit/Material*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
54 changes: 23 additions & 31 deletions src/main/java/world/bentobox/upgrades/UpgradesAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@

public class UpgradesAddon extends Addon {

private Settings settings;

private boolean hooked;

private UpgradesManager upgradesManager;

private Set<Upgrade> upgrade = new HashSet<>();

private Database<UpgradesData> database = new Database<>(this, UpgradesData.class);

private Map<String, UpgradesData> upgradesCache = new HashMap<>();

private Level levelAddon;

private Limits limitsAddon;

private VaultHook vault;

public final static Flag UPGRADES_RANK_RIGHT = new Flag.Builder("UPGRADES_RANK_RIGHT", Material.GOLD_INGOT)
.type(Flag.Type.PROTECTION).mode(Flag.Mode.BASIC)
.clickHandler(new CycleClick("UPGRADES_RANK_RIGHT", RanksManager.MEMBER_RANK, RanksManager.OWNER_RANK))
.defaultRank(RanksManager.MEMBER_RANK).build();

@Override
public void onLoad() {
super.onLoad();
Expand Down Expand Up @@ -67,11 +90,6 @@ public void onEnable() {
this.upgradesManager = new UpgradesManager(this);
this.upgradesManager.addGameModes(hookedGameModes);

this.upgrade = new HashSet<>();

this.database = new Database<>(this, UpgradesData.class);
this.upgradesCache = new HashMap<>();

Optional<Addon> level = this.getAddonByName("Level");

if (!level.isPresent()) {
Expand Down Expand Up @@ -204,30 +222,4 @@ public void registerUpgrade(Upgrade upgrade) {
this.upgrade.add(upgrade);
}

private Settings settings;

private boolean hooked;

private UpgradesManager upgradesManager;

private Set<Upgrade> upgrade;

private Database<UpgradesData> database;

private Map<String, UpgradesData> upgradesCache;

private Level levelAddon;

private Limits limitsAddon;

private VaultHook vault;

public final static Flag UPGRADES_RANK_RIGHT =
new Flag.Builder("UPGRADES_RANK_RIGHT", Material.GOLD_INGOT)
.type(Flag.Type.PROTECTION)
.mode(Flag.Mode.BASIC)
.clickHandler(new CycleClick("UPGRADES_RANK_RIGHT", RanksManager.MEMBER_RANK, RanksManager.OWNER_RANK))
.defaultRank(RanksManager.MEMBER_RANK)
.build();

}
Loading
Loading