build: Add action to build and automatically release files #170

Merged
Jikoo merged 5 commits from chore/actions into master 2020-11-26 11:05:46 -05:00
4 changed files with 106 additions and 14 deletions

93
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,93 @@
name: OpenInv CI
on:
push:
create:
types: [tag]
pull_request_target:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set Up Java
uses: actions/setup-java@v1
with:
java-version: 1.8
# Use cache to speed up build
- name: Cache Maven Repo
uses: actions/cache@v2
id: cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
# If the cache was not present, run BuildTools to install the relevant versions to Maven.
# This will take approximately forever.
- name: Install Spigot Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir ~/buildtools
cd ~/buildtools
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar --rev 1.8.8
java -jar BuildTools.jar --rev 1.15.2
java -jar BuildTools.jar --rev 1.16.3
java -jar BuildTools.jar --rev 1.16.4
- name: Build With Maven
run: mvn -e clean package -am -P all
# Upload artifacts
- name: Upload Distributable Jar
id: upload-final
uses: actions/upload-artifact@v2
with:
name: dist
path: ./target/OpenInv.jar
- name: Upload API Jar
id: upload-api
uses: actions/upload-artifact@v2
with:
name: api
path: ./api/target/openinvapi*.jar
release:
name: Create Github Release
needs: [ build ]
if: github.event_name == 'create' && github.event.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: true
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ./OpenInv.jar
asset_name: OpenInv.jar
asset_content_type: application/java-archive

View File

@@ -32,7 +32,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15.1-R0.1-SNAPSHOT</version>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@@ -33,6 +33,7 @@ import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEnderChest {
@@ -115,7 +116,7 @@ public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEn
}
@Override
public Location getLocation() {
public @Nullable Location getLocation() {
return null;
}
@@ -204,7 +205,7 @@ public class SpecialEnderChest extends InventoryEnderChest implements ISpecialEn
}
@Override
public boolean isNotEmpty() {
public boolean isEmpty() {
for (ItemStack itemstack : this.items) {
if (!itemstack.isEmpty()) {

View File

@@ -326,7 +326,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
}
if (!this.a(itemstack, itemstack1)) {
remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount();
remains -= Math.min(itemstack1.getMaxStackSize(), this.getMaxStackSize()) - itemstack1.getCount();
}
if (remains <= 0) {
@@ -461,14 +461,12 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
k = this.getMaxStackSize() - itemstack1.getCount();
}
if (k == 0) {
return j;
} else {
if (k != 0) {
j -= k;
itemstack1.add(k);
itemstack1.d(5);
return j;
}
return j;
}
@Override
@@ -656,12 +654,12 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
}
@Override
public boolean isNotEmpty() {
Iterator iterator = this.items.iterator();
public boolean isEmpty() {
Iterator<ItemStack> iterator = this.items.iterator();
ItemStack itemstack;
while (iterator.hasNext()) {
itemstack = (ItemStack)iterator.next();
itemstack = iterator.next();
if (!itemstack.isEmpty()) {
return false;
}
@@ -670,7 +668,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
iterator = this.armor.iterator();
while (iterator.hasNext()) {
itemstack = (ItemStack)iterator.next();
itemstack = iterator.next();
if (!itemstack.isEmpty()) {
return false;
}
@@ -679,7 +677,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
iterator = this.extraSlots.iterator();
while (iterator.hasNext()) {
itemstack = (ItemStack)iterator.next();
itemstack = iterator.next();
if (!itemstack.isEmpty()) {
return false;
}
@@ -711,7 +709,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
ItemStack itemstack = this.armor.get(0);
int index = i;
if (itemstack.getItem() instanceof ItemArmor) {
itemstack.damage((int) f, this.player, (entityhuman) -> entityhuman.c(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, index)));
itemstack.damage((int) f, this.player, (entityhuman) -> entityhuman.broadcastItemBreak(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, index)));
}
}
}