# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>

pkgname=craftbukkit-plugin-essentialx
_pkgver=2.19.2
_buildver=release
_buildcommit=0
pkgrel=2
pkgdesc="EssentialsX is the essential plugin suite for Minecraft servers, with over 130 commands for servers of all size and scale."
options=!check
arch='noarch'
url="https://essentialsx.net/"
license="GPL-3.0"
depends="craftbukkit>=1.8.8 craftbukkit<=1.18.1"

if _buildver=release; then
	pkgver=$_pkgver
	_url=https://github.com/EssentialsX/Essentials/releases/download/$pkgver
	_filename="$pkgver.jar"
else
	pkgver=$_pkgver.$_buildver
	_url=https://ci.ender.zone/job/EssentialsX/lastSuccessfulBuild/artifact/jars
	_filename="$_pkgver-dev+$_buildver-$_buildcommit.jar"
fi

source="
	$_url/EssentialsX-$_filename
	$_url/EssentialsXChat-$_filename
	$_url/EssentialsXSpawn-$_filename
	$_url/EssentialsXAntiBuild-$_filename
	$_url/EssentialsXDiscord-$_filename
	$_url/EssentialsXGeoIP-$_filename
	$_url/EssentialsXProtect-$_filename
	$_url/EssentialsXXMPP-$_filename
"

subpackages="$pkgname-core $pkgname-chat $pkgname-spawn $pkgname-antibuild $pkgname-discord $pkgname-geo $pkgname-protect $pkgname-xmpp"


package() {
	mkdir -p "$pkgdir"
}

core() {
	pkgdesc="Core functionality: teleports, private messages, homes, warps and more"
	install -Dm644 "$srcdir"/EssentialsX-*.jar "$subpkgdir/var/lib/craftbukkit/plugins/Essentials.jar"
	chown craftbukkit:craftbukkit "$subpkgdir"/var/lib/craftbukkit/plugins/Essentials.jar
}

chat() {
	pkgdesc="Chat formatting, local chat"
	depends="$pkgname-core"
	install -Dm644 "$srcdir"/EssentialsXChat-*.jar "$subpkgdir/var/lib/craftbukkit/plugins/EssentialsChat.jar"
	chown craftbukkit:craftbukkit "$subpkgdir"/var/lib/craftbukkit/plugins/EssentialsChat.jar
}

spawn() {
	pkgdesc="Spawnpoint control, per-player spawns"
	depends="$pkgname-core"
	install -Dm644 "$srcdir"/EssentialsXSpawn-*.jar "$subpkgdir/var/lib/craftbukkit/plugins/EssentialsSpawn.jar"
	chown craftbukkit:craftbukkit "$subpkgdir"/var/lib/craftbukkit/plugins/EssentialsSpawn.jar
}

antibuild() {
	pkgdesc="Simple permissions-based building control"
	depends="$pkgname-core"
	install -Dm644 "$srcdir"/EssentialsXAntiBuild-*.jar "$subpkgdir/var/lib/craftbukkit/plugins/EssentialsAntiBuild.jar"
	chown craftbukkit:craftbukkit "$subpkgdir"/var/lib/craftbukkit/plugins/EssentialsAntiBuild.jar
}

discord() {
	pkgdesc="Lightweight chat, messaging and command integration with Discord"
	depends="$pkgname-core"
	install -Dm644 "$srcdir"/EssentialsXDiscord-*.jar "$subpkgdir/var/lib/craftbukkit/plugins/EssentialsDiscord.jar"
	chown craftbukkit:craftbukkit "$subpkgdir"/var/lib/craftbukkit/plugins/EssentialsDiscord.jar
}

geo() {
	pkgdesc="Geographical player lookup (formerly EssentialsX GeoIP)"
	depends="$pkgname-core"
	install -Dm644 "$srcdir"/EssentialsXGeoIP-*.jar "$subpkgdir/var/lib/craftbukkit/plugins/EssentialsGeo.jar"
	chown craftbukkit:craftbukkit "$subpkgdir"/var/lib/craftbukkit/plugins/EssentialsGeo.jar
}

protect() {
	pkgdesc="Configurable world protection and control"
	depends="$pkgname-core"
	install -Dm644 "$srcdir"/EssentialsXProtect-*.jar "$subpkgdir/var/lib/craftbukkit/plugins/EssentialsProtect.jar"
	chown craftbukkit:craftbukkit "$subpkgdir"/var/lib/craftbukkit/plugins/EssentialsProtect.jar
}

xmpp() {
	pkgdesc="Lightweight chat, messaging and server log integration with Jabber/XMPP services"
	depends="$pkgname-core"
	install -Dm644 "$srcdir"/EssentialsXXMPP-*.jar "$subpkgdir/var/lib/craftbukkit/plugins/EssentialsXMPP.jar"
	chown craftbukkit:craftbukkit "$subpkgdir"/var/lib/craftbukkit/plugins/EssentialsXMPP.jar
}

sha512sums="
c91c0905c11482d93b1565f8b9dce7b6f939567b4cb2756b112ee408bdcca1fece04742f9b7b0876d5b2e84cebdbc555d35cf783e9e86ab12fafb9dc02bc6008  EssentialsX-2.19.2.jar
e2df6f242db38689579501b34763ad7d4b5e8ddd87b7b57956c6b5cc667f1b34af6b1289d668a64761da63f8ae8507eb9687ca490cc715a3eff6338770963240  EssentialsXChat-2.19.2.jar
24e41168428f20bd6506282b9920718c43f7e5227bf35e174522e49859e294048a1d979ae42044bdbdba45c8a1109f4db6ffd0e24d5f3e909d0f9a3ac31e21d3  EssentialsXSpawn-2.19.2.jar
326ec004241b526965cb67ae0f0245dfa960da2fdb4b59d867eb08e5196fceb468f9314cb838c8a0bc513cc55f43cf58023d11b18ed98e472be7089838538f97  EssentialsXAntiBuild-2.19.2.jar
211c575adde17c3f2f901144e5c31beb2918df7e6e15f8ebe16805d3b53214a4756b87ec84466790ebf1dacb41e1aea97b6a9ba8ed39e85092293a821044d579  EssentialsXDiscord-2.19.2.jar
7845e7666f983d3e793528a7085ced7c9f1bf881740bcc68b6a54fea74e31c3c0c2a52e26fc20330ba7d4a190dad0a1b27195fed0e1417a48494c5fa2ac60d92  EssentialsXGeoIP-2.19.2.jar
e74ed72a15b5e6cd3c5f61d032a26c151865e3197638c9059237dc2d1144b0cb15668545532fc532ac8ec247bdf9b9ee6843b8f4af7506aef86d155dd5672c5f  EssentialsXProtect-2.19.2.jar
8d35009499557700f49c27ca3132e866f511a200791dbcfd2f595396977058cc2fc9349d0b4eaa0eb67b27331e91e6209df6ed57a766c06fd3b3325718462478  EssentialsXXMPP-2.19.2.jar
"
