Skip to content

Commit f1d47bd

Browse files
author
Francisco Solis
authored
Fixed Settings Gui & Workflow Updates (#16)
* Fix to the Settings Gui * New workflow for tests in pull requests * Now github actions will push the artifact to nexus * Added scheduled codeql workflow * Added url and description to pom.xml
1 parent b3bee56 commit f1d47bd

File tree

7 files changed

+160
-18
lines changed

7 files changed

+160
-18
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '22 12 * * 1'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'java' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37+
# Learn more:
38+
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v2
43+
44+
# Initializes the CodeQL tools for scanning.
45+
- name: Initialize CodeQL
46+
uses: github/codeql-action/init@v1
47+
with:
48+
languages: ${{ matrix.language }}
49+
# If you wish to specify custom queries, you can do so here or in a config file.
50+
# By default, queries listed here will override any specified in a config file.
51+
# Prefix the list here with "+" to use these queries and those in the config file.
52+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53+
54+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55+
# If this step fails, then you should remove it and run the build manually (see below)
56+
- name: Autobuild
57+
uses: github/codeql-action/autobuild@v1
58+
59+
# ℹ️ Command-line programs to run using the OS shell.
60+
# 📚 https://git.io/JvXDl
61+
62+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63+
# and modify them (or add more) to build your code if your project
64+
# uses a compiled language
65+
66+
#- run: |
67+
# make bootstrap
68+
# make release
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v1

.github/workflows/maven-build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Maven Build
2+
# Only execute this workflow when a PR is opened or when something is pushed to a the master branch
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
# Setup checkout
13+
- uses: actions/checkout@v2
14+
# Setup java and maven
15+
- name: Set up JDK 1.8
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 1.8
19+
# Only test the project and skip the javadoc generation
20+
- name: Test with Maven
21+
run: mvn clean test --file pom.xml -Dmaven.javadoc.skip=true

.github/workflows/maven.yml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,60 @@
11
name: Java CI
2-
on: [push]
2+
on:
3+
release:
4+
types: [published]
35
jobs:
46
build:
7+
# Setup the environment
58
runs-on: ubuntu-latest
9+
env:
10+
NEXUS_MAVEN_REPO: 'https://repo.theprogramsrc.xyz/'
11+
NEXUS_USERNAME: '${{ secrets.NEXUS_USERNAME }}'
12+
NEXUS_PASSWORD: '${{ secrets.NEXUS_PASSWORD }}'
13+
NEXUS_RELEASE_URL: 'https://repo.theprogramsrc.xyz/repository/maven-releases/'
14+
NEXUS_SNAPSHOT_URL: 'https://repo.theprogramsrc.xyz/repository/maven-snapshots/'
615
steps:
7-
- uses: actions/checkout@v2
16+
# Setup checkout
17+
- name: Setup checkout
18+
uses: actions/checkout@v2
19+
# Install java and maven
820
- name: Set up JDK 1.8
921
uses: actions/setup-java@v1
1022
with:
1123
java-version: 1.8
12-
- name: Build with Maven
13-
run: mvn -B package test --file pom.xml
24+
# We build and test again then deploy
25+
- name: Setup Maven Settings
26+
run: |
27+
touch ~/.m2/settings.xml
28+
echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
29+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
30+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
31+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
32+
33+
<servers>
34+
<server>
35+
<id>theprogramsrc-releases</id>
36+
<username>${{ secrets.NEXUS_USERNAME }}</username>
37+
<password>${{ secrets.NEXUS_PASSWORD }}</password>
38+
<url>${{ env.NEXUS_RELEASE_URL }}</url>
39+
</server>
40+
<server>
41+
<id>theprogramsrc-snapshots</id>
42+
<username>${{ secrets.NEXUS_USERNAME }}</username>
43+
<password>${{ secrets.NEXUS_PASSWORD }}</password>
44+
<url>${{ env.NEXUS_SNAPSHOT_URL }}</url>
45+
</server>
46+
</servers>
47+
48+
</settings>' > ~/.m2/settings.xml
49+
- name: Build, Test & Deoploy with Maven
50+
run: mvn -B clean package test deploy --file pom.xml
51+
# Now we store the artifact in the action
52+
- name: Store Artifact
1453
- run: mkdir -p ./artifacts
1554
- run: cp target/SuperCoreAPI.jar ./artifacts/
1655
- uses: actions/upload-artifact@v2
1756
with:
1857
name: SuperCoreAPI
1958
path: ./artifacts/SuperCoreAPI.jar
2059

60+

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ Temporary Items
6868
.apdisk
6969
.classpath
7070
.project
71-
.settings/
71+
.settings/
72+
.env
73+
.secrets.env

dependency-reduced-pom.xml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44
<groupId>xyz.theprogramsrc</groupId>
55
<artifactId>SuperCoreAPI</artifactId>
66
<name>SuperCoreAPI</name>
7-
<version>5.2.0-SNAPSHOT</version>
7+
<version>5.2.2-SNAPSHOT</version>
88
<build>
99
<sourceDirectory>src/main/java</sourceDirectory>
1010
<testSourceDirectory>src/test/java</testSourceDirectory>
1111
<defaultGoal>clean package test</defaultGoal>
12-
<resources>
13-
<resource>
14-
<filtering>true</filtering>
15-
<directory>src/main/resources</directory>
16-
</resource>
17-
</resources>
1812
<finalName>${project.artifactId}</finalName>
1913
<plugins>
2014
<plugin>
@@ -87,6 +81,17 @@
8781
<shadedPattern>xyz.theprogramsrc.supercoreapi.libs.zip4j</shadedPattern>
8882
</relocation>
8983
</relocations>
84+
<filters>
85+
<filter>
86+
<artifact>*:*</artifact>
87+
<excludes>
88+
<exclude>module-info.class</exclude>
89+
<exclude>META-INF/*.SF</exclude>
90+
<exclude>META-INF/*.DSA</exclude>
91+
<exclude>META-INF/*.RSA</exclude>
92+
</excludes>
93+
</filter>
94+
</filters>
9095
</configuration>
9196
</execution>
9297
</executions>

pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
<groupId>xyz.theprogramsrc</groupId>
88
<artifactId>SuperCoreAPI</artifactId>
9-
<version>5.2.1</version>
9+
<version>5.2.2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>
13+
<description>The best way to create a plugin.</description>
14+
<url>https://github.com/TheProgramSrc/SuperCoreAPI</url>
1315

1416
<properties>
1517
<java.version>1.8</java.version>
@@ -132,6 +134,7 @@
132134
</plugins>
133135
</build>
134136

137+
<!-- Deployment -->
135138
<distributionManagement>
136139
<repository>
137140
<id>theprogramsrc-releases</id>

src/main/java/xyz/theprogramsrc/supercoreapi/spigot/gui/precreated/settings/SettingsGui.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package xyz.theprogramsrc.supercoreapi.spigot.gui.precreated.settings;
22

3-
import java.util.stream.IntStream;
4-
53
import org.bukkit.entity.Player;
64

75
import xyz.theprogramsrc.supercoreapi.global.translations.Base;
@@ -61,19 +59,21 @@ public GuiTitle getTitle() {
6159

6260
@Override
6361
public void onBuild(GuiModel model) {
62+
model.clearButtons();
6463
if(this.current == -1){
6564
model.setButton(0, new GuiEntry(this.getPreloadedItems().getBackItem(), this::onBack));
66-
IntStream.range(0, this.containerSlots.length).forEach(i -> {
65+
for(int i = 0; i < this.containerSlots.length; i++){
6766
int slot = this.containerSlots[i];
6867
if(i < this.settingPanes.length){
68+
int newCurrent = i;
6969
model.setButton(slot, new GuiEntry(this.settingPanes[i].getDisplayItem(), a -> {
70-
this.current = i;
70+
this.current = newCurrent;
7171
this.open();
7272
}));
7373
}else{
7474
model.setButton(slot, new GuiEntry(this.getPreloadedItems().emptyItem()));
7575
}
76-
});
76+
}
7777
}else{
7878
SettingPane pane = this.settingPanes[current];
7979
int[] paneContainerSlots = pane.getContainerSlots();

0 commit comments

Comments
 (0)