Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
apply(plugin = "com.github.johnrengelman.shadow")

group = "me.dasshark"
version = "1.2"
version = "1.3"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Main : JavaPlugin() {

fun registerRecipe() {
if (!config.getBoolean("crafting.enabled")) return
val item: ItemStack = getInvisFrame()!!
val item: ItemStack = getInvisFrame(true)!!
// create a NamespacedKey for your recipe
val key = NamespacedKey(this, "invisible_item_frame")

Expand Down Expand Up @@ -77,10 +77,11 @@ class Main : JavaPlugin() {
Bukkit.removeRecipe(key)
}

fun getInvisFrame(): ItemStack? {
fun getInvisFrame(useAmount: Boolean): ItemStack? {
val amount = if (useAmount) config.getInt("crafting.amount") else 1
if (config.getBoolean("invisible-itemframe.enchanted")) {
try {
return ItemBuilder(Material.ITEM_FRAME, config.getInt("crafting.amount")).setName(ChatColor.translateAlternateColorCodes('&', config.getString("invisible-itemframe.name")!!)).setInvisible().addEnchant(Enchantment.ARROW_DAMAGE, 1).addItemFlag(ItemFlag.HIDE_ENCHANTS).itemStack
return ItemBuilder(Material.ITEM_FRAME, amount).setName(ChatColor.translateAlternateColorCodes('&', config.getString("invisible-itemframe.name")!!)).setInvisible().addEnchant(Enchantment.ARROW_DAMAGE, 1).addItemFlag(ItemFlag.HIDE_ENCHANTS).itemStack
} catch (e: NullPointerException) {
Bukkit.getLogger().warning("The item name or amount is not set in the config.yml!")
Bukkit.getLogger().severe("Please check your config.yml and correct the error or delete the entire file.")
Expand All @@ -89,7 +90,7 @@ class Main : JavaPlugin() {
}
} else {
try {
return ItemBuilder(Material.ITEM_FRAME, config.getInt("crafting.amount")).setName(ChatColor.translateAlternateColorCodes('&', config.getString("invisible-itemframe.name")!!)).setInvisible().itemStack
return ItemBuilder(Material.ITEM_FRAME, amount).setName(ChatColor.translateAlternateColorCodes('&', config.getString("invisible-itemframe.name")!!)).setInvisible().itemStack
} catch (e: NullPointerException) {
Bukkit.getLogger().warning("The item name or amount is not set in the config.yml!")
Bukkit.getLogger().severe("Please check your config.yml and correct the error or delete the entire file.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MainCommand : CommandExecutor, TabCompleter {
sender.sendMessage("${Main.prefix}§cYou need to be a player to execute this command")
return false
}
sender.inventory.addItem(Main.instance.getInvisFrame()!!)
sender.inventory.addItem(Main.instance.getInvisFrame(false)!!)
sender.sendMessage("${Main.prefix}§aYou have received an invisible item frame")
return true
} else if (args[0] == "reload") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class IFBreakListener : Listener {
if (event.entity.persistentDataContainer.has(Main.invisibleKey, PersistentDataType.BYTE)) {
event.isCancelled = true
event.entity.remove()
event.entity.world.dropItemNaturally(event.entity.location, Main.instance.getInvisFrame()!!)
event.entity.world.dropItemNaturally(event.entity.location, Main.instance.getInvisFrame(false)!!)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: AdvancedInvisibleItemframes
main: me.dasshark.advancedInvisibleItemframes.Main
version: 1.2
version: 1.3
api-version: 1.19
description: A plugin that adds invisible itemframes
author: DasShark
Expand Down