Skip to content

Commit

Permalink
Update to v2.1.1 (#5)
Browse files Browse the repository at this point in the history
* some minor updates

* minor changes

* Update .gitignore

* add repos

* Delete gradle.properties

* update documentation
  • Loading branch information
Jaimss authored Aug 24, 2020
1 parent 3845da8 commit 7870f31
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 103 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
build/
.gradle

gradle.properties
35 changes: 19 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,8 @@ allprojects {
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.github.johnrengelman.shadow'

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
}
}

shadowJar {
archiveClassifier.set("")
// relocate('org.intellij.lang.annotations', 'dev.jaims.mcutils.libs.org.intellij.lang.annotations')
// relocate('org.jetbrains.annotations', 'dev.jaims.mcutils.libs.org.jetbrains.annotations')
// relocate('org.json', 'dev.jaims.mcutils.libs.org.json')
// relocate('kotlin', 'dev.jaims.mcutils.libs.kotlin')
// relocate('khttp', 'dev.jaims.mcutils.libs.khttp')
}

repositories {
Expand Down Expand Up @@ -58,7 +42,26 @@ subprojects {
group 'dev.jaims.mcutils'
version ver

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
maven {
def releasesRepoUrl = "https://repo.jaims.dev/repository/maven-releases/"
def snapshotsRepoUrl = "https://repo.jaims.dev/repository/maven-snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl

credentials {
username = project.property('sonatype.user')
password = project.property('sonatype.password')
}
}
}
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ package dev.jaims.mcutils.bukkit
import org.bukkit.plugin.Plugin

/**
* Executes the given [f] via the [plugin] asynchronous.
* Executes the given [block] via the [plugin] asynchronous.
*/
fun async(plugin: Plugin, delayTicks: Long = 0L, repeatingTicks: Long = 0L, f: () -> Unit) {
fun async(plugin: Plugin, delayTicks: Long = 0L, repeatingTicks: Long = 0L, block: () -> Unit) {
when (repeatingTicks > 0) {
true -> plugin.server.scheduler.runTaskTimerAsynchronously(plugin, f, delayTicks, repeatingTicks)
false -> plugin.server.scheduler.runTaskLaterAsynchronously(plugin, f, delayTicks)
true -> plugin.server.scheduler.runTaskTimerAsynchronously(plugin, block, delayTicks, repeatingTicks)
false -> plugin.server.scheduler.runTaskLaterAsynchronously(plugin, block, delayTicks)
}
}

/**
* Executes the given [f] via the [plugin] synchronized with the server tick.
* Executes the given [block] via the [plugin] synchronized with the server tick.
*/
fun sync(plugin: Plugin, delayTicks: Long = 0L, repeatingTicks: Long = 0L, f: () -> Unit) {
fun sync(plugin: Plugin, delayTicks: Long = 0L, repeatingTicks: Long = 0L, block: () -> Unit) {
when (repeatingTicks > 0) {
true -> plugin.server.scheduler.runTaskTimer(plugin, f, delayTicks, repeatingTicks)
false -> plugin.server.scheduler.runTaskLater(plugin, f, delayTicks)
true -> plugin.server.scheduler.runTaskTimer(plugin, block, delayTicks, repeatingTicks)
false -> plugin.server.scheduler.runTaskLater(plugin, block, delayTicks)
}
}
6 changes: 3 additions & 3 deletions bukkit/src/main/kotlin/dev/jaims/mcutils/bukkit/BukkitUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import org.bukkit.entity.Player
import java.util.regex.Pattern

/**
* A chat colorization util that supports hex.
* A chat colorization util that supports hex and PlaceholderAPI placeholders for a [player] if one is provided.
* Loosely based off of https://gist.github.com/iGabyTM/7415263c2209653ede82457c289de697
*
* @param player the player to use for color codes
* @sample dev.jaims.mcutils.tests.BukkitTests.chatColorizeTest()
*/
fun String.colorize(player: Player? = null): String {
val pattern = Pattern.compile(
Expand All @@ -28,7 +28,7 @@ fun String.colorize(player: Player? = null): String {
}
final = when (player == null) {
true -> final
false -> PlaceholderAPI.setPlaceholders(player, this)
false -> PlaceholderAPI.setPlaceholders(player, final)
}
return ChatColor.translateAlternateColorCodes('&', final)

Expand Down
19 changes: 7 additions & 12 deletions bukkit/src/main/kotlin/dev/jaims/mcutils/bukkit/ItemBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@ import org.bukkit.inventory.meta.Damageable
import java.util.function.Supplier

/**
* @param material The only required parameter. This will be the items material
* @param amount the amount of the item
* @param damage the damage on the item
* @param name the name of the item
* @param lore the lore of the item
* @param enchantments the enchantments on the item
* @param glow should the item have a glow or not
* @param unbreakable should the item be breakable
* @param itemflags the item flags on the item
* An item builder class. The only required parameter to initialize this is [material], then you can use the methods
* in the builder to build the item.
*/
@Suppress("unused")
class ItemBuilder(
Expand Down Expand Up @@ -95,9 +88,8 @@ class ItemBuilder(
fun addLore(newlore: String) = apply { lore.add(newlore) }

/**
* Add a map of enchantments to the item
* Add a map of [newenchantments] the enchantment map to add
*
* @param newenchantments the enchantment map to add
* @return an [ItemBuilder]
*/
fun addEnchantments(newenchantments: Map<Enchantment, Int>) =
Expand Down Expand Up @@ -145,4 +137,7 @@ class ItemBuilder(
*/
fun addItemFlag(newitemflag: ItemFlag) = apply { itemflags.add(newitemflag) }

}
}



Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package dev.jaims.mcutils.tests

import dev.jaims.mcutils.bukkit.colorize
import net.md_5.bungee.api.ChatColor
import org.junit.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="filter-section" id="filter-section"><button class="platform-tag platform-selector jvm-like" data-active="" data-filter=":bukkit/main">jvm</button></div>
<h1 class="cover"><a data-name="&lt;init&gt;"></a>&lt;init&gt;</h1>
</div>
<div class="divergent-group" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="brief-with-platform-tags"><div class="inner-brief-with-platform-tags"><h2 class=""><a data-name="parameters"></a>Parameters</h2><div data-togglable="Parameters"><div class="platform-hinted WithExtraAttributes" data-platform-hinted="data-platform-hinted" data-togglable="Parameters"><div class="content sourceset-depenent-content" data-active="" data-togglable=":bukkit/main"><div data-togglable="Parameters"><div class="table" data-togglable="Parameters"><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/&lt;init&gt;/#org.bukkit.Material#kotlin.Int#kotlin.Int#kotlin.String?#kotlin.collections.MutableList[kotlin.String]#kotlin.collections.MutableMap[org.bukkit.enchantments.Enchantment,kotlin.Int]#kotlin.Boolean#kotlin.Boolean#kotlin.collections.MutableList[org.bukkit.inventory.ItemFlag]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>amount</div><div class="title"><div data-togglable="Parameters">the amount of the item</div></div></div></div><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/&lt;init&gt;/#org.bukkit.Material#kotlin.Int#kotlin.Int#kotlin.String?#kotlin.collections.MutableList[kotlin.String]#kotlin.collections.MutableMap[org.bukkit.enchantments.Enchantment,kotlin.Int]#kotlin.Boolean#kotlin.Boolean#kotlin.collections.MutableList[org.bukkit.inventory.ItemFlag]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>damage</div><div class="title"><div data-togglable="Parameters">the damage on the item</div></div></div></div><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/&lt;init&gt;/#org.bukkit.Material#kotlin.Int#kotlin.Int#kotlin.String?#kotlin.collections.MutableList[kotlin.String]#kotlin.collections.MutableMap[org.bukkit.enchantments.Enchantment,kotlin.Int]#kotlin.Boolean#kotlin.Boolean#kotlin.collections.MutableList[org.bukkit.inventory.ItemFlag]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>enchantments</div><div class="title"><div data-togglable="Parameters">the enchantments on the item</div></div></div></div><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/&lt;init&gt;/#org.bukkit.Material#kotlin.Int#kotlin.Int#kotlin.String?#kotlin.collections.MutableList[kotlin.String]#kotlin.collections.MutableMap[org.bukkit.enchantments.Enchantment,kotlin.Int]#kotlin.Boolean#kotlin.Boolean#kotlin.collections.MutableList[org.bukkit.inventory.ItemFlag]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>glow</div><div class="title"><div data-togglable="Parameters">should the item have a glow or not</div></div></div></div><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/&lt;init&gt;/#org.bukkit.Material#kotlin.Int#kotlin.Int#kotlin.String?#kotlin.collections.MutableList[kotlin.String]#kotlin.collections.MutableMap[org.bukkit.enchantments.Enchantment,kotlin.Int]#kotlin.Boolean#kotlin.Boolean#kotlin.collections.MutableList[org.bukkit.inventory.ItemFlag]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>itemflags</div><div class="title"><div data-togglable="Parameters">the item flags on the item</div></div></div></div><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/&lt;init&gt;/#org.bukkit.Material#kotlin.Int#kotlin.Int#kotlin.String?#kotlin.collections.MutableList[kotlin.String]#kotlin.collections.MutableMap[org.bukkit.enchantments.Enchantment,kotlin.Int]#kotlin.Boolean#kotlin.Boolean#kotlin.collections.MutableList[org.bukkit.inventory.ItemFlag]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>lore</div><div class="title"><div data-togglable="Parameters">the lore of the item</div></div></div></div><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/&lt;init&gt;/#org.bukkit.Material#kotlin.Int#kotlin.Int#kotlin.String?#kotlin.collections.MutableList[kotlin.String]#kotlin.collections.MutableMap[org.bukkit.enchantments.Enchantment,kotlin.Int]#kotlin.Boolean#kotlin.Boolean#kotlin.collections.MutableList[org.bukkit.inventory.ItemFlag]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>material</div><div class="title"><div data-togglable="Parameters">The only required parameter. This will be the items material</div></div></div></div><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/&lt;init&gt;/#org.bukkit.Material#kotlin.Int#kotlin.Int#kotlin.String?#kotlin.collections.MutableList[kotlin.String]#kotlin.collections.MutableMap[org.bukkit.enchantments.Enchantment,kotlin.Int]#kotlin.Boolean#kotlin.Boolean#kotlin.collections.MutableList[org.bukkit.inventory.ItemFlag]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>name</div><div class="title"><div data-togglable="Parameters">the name of the item</div></div></div></div><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/&lt;init&gt;/#org.bukkit.Material#kotlin.Int#kotlin.Int#kotlin.String?#kotlin.collections.MutableList[kotlin.String]#kotlin.collections.MutableMap[org.bukkit.enchantments.Enchantment,kotlin.Int]#kotlin.Boolean#kotlin.Boolean#kotlin.collections.MutableList[org.bukkit.inventory.ItemFlag]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>unbreakable</div><div class="title"><div data-togglable="Parameters">should the item be breakable</div></div></div></div></div></div></div></div></div></div>
<div class="divergent-group" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="brief-with-platform-tags"><div class="inner-brief-with-platform-tags"></div>
<span class="pull-right"></span></div>

<div class="main-subrow">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="filter-section" id="filter-section"><button class="platform-tag platform-selector jvm-like" data-active="" data-filter=":bukkit/main">jvm</button></div>
<h1 class="cover"><a data-name="addenchantments"></a>addEnchantments</h1>
</div>
<div class="divergent-group" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="brief-with-platform-tags"><div class="inner-brief-with-platform-tags"><div class="block"><div class="block">Add a map of enchantments to the item</div></div><div class="block"><h4 class="block"><a data-name="return"></a>Return</h4><div class="block">an <a href="index.html">ItemBuilder</a></div></div><h2 class=""><a data-name="parameters"></a>Parameters</h2><div data-togglable="Parameters"><div class="platform-hinted WithExtraAttributes" data-platform-hinted="data-platform-hinted" data-togglable="Parameters"><div class="content sourceset-depenent-content" data-active="" data-togglable=":bukkit/main"><div data-togglable="Parameters"><div class="table" data-togglable="Parameters"><a data-name="dev.jaims.mcutils.bukkit/ItemBuilder/addEnchantments/#kotlin.collections.Map[org.bukkit.enchantments.Enchantment,kotlin.Int]/PointingToDeclaration/"></a><div class="table-row" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="platform-dependent-row keyValue"><div>newenchantments</div><div class="title"><div data-togglable="Parameters">the enchantment map to add</div></div></div></div></div></div></div></div></div></div>
<div class="divergent-group" data-filterable-current=":bukkit/main" data-filterable-set=":bukkit/main"><div class="brief-with-platform-tags"><div class="inner-brief-with-platform-tags"><div class="block"><div class="block">Add a map of <a href="">newenchantments</a> the enchantment map to add</div></div><div class="block"><h4 class="block"><a data-name="return"></a>Return</h4><div class="block">an <a href="index.html">ItemBuilder</a></div></div></div>
<span class="pull-right"></span></div>

<div class="main-subrow">
Expand Down
Loading

0 comments on commit 7870f31

Please sign in to comment.