Skip to content

Releases: hoangxuanlam2007/BaloShulker

BaloShulker v1.4

20 Aug 10:17
Compare
Choose a tag to compare

BaloShulker Plugin - Version 1.4 Release Notes

Overview

Version 1.4 of the BaloShulker plugin introduces several enhancements, bug fixes, and code optimizations to improve player interactions with shulker boxes and overall plugin functionality. This release aims to provide a more user-friendly and stable experience.

✔️ No more dupes!

An issue was resolved when players opened a shulker box from their hand. During the opening GUI process, if a player dropped the shulker box being opened or moved it to another slot, then retrieved the item and closed it, the shulker box content wasn't properly saved. This allowed users to duplicate unlimited items inside the shulker box.

This issue has been addressed in the current release v1.4, ensuring that shulker boxes correctly save their contents even when manipulated during the opening process.

Changes

Player Interaction Enhancements

  • Improved interaction logic prevents accidental shulker box openings right after dropping them.
  • Added timestamp tracking to avoid immediate shulker box interactions after dropping.

TPS Check for Interaction

  • Implemented a check for server TPS before allowing shulker box interactions.
  • Players are informed when the server TPS is too low for instant interactions.

Help Command Enhancement

  • Improved the /bs help command to display the available subcommands more clearly.
  • Added the info subcommand to display plugin version information.

Miscellaneous Improvements

  • Added consistent plugin version and name retrieval throughout the code.
  • Removed unused imports for cleaner code.

Bug Fixes

  • Fixed deprecation warnings using the @Suppress("DEPRECATION") annotation.
  • Fixed a duplication issue that occurred when a player opened a shulker box from their hand. During the process of opening the GUI, if the player dropped the shulker box being opened or moved it to another slot, then retrieved the item and closed it, the shulker box failed to save its contents. This issue allowed users to duplicate an unlimited number of items inside the shulker box.

Instructions

Opening Shulker Boxes

  • Right-click a shulker box item in your main hand to open it.
  • A shulker box cannot be opened immediately after dropping it (within 1 second) to prevent accidental interactions.
  • You cannot open shulker box when the server TPS is not in range of 18.0 ≤ ... ≤ 20.0 to prevent accidental item disappearance.

Permissions

  • The following permissions are available:
    • baloshulker.use: Allows users to interact with shulker boxes.
    • baloshulker.info: Allows users to view plugin version information.
    • baloshulker.reload: Allows users to reload the plugin configuration.

Commands

  • /bs help: Displays the help message with available commands.
  • /bs info: Shows the plugin version information.
  • /bs reload: Reloads the plugin configuration (requires appropriate permissions).

Upgrading from Previous Versions

  1. Remove the previous version of the BaloShulker plugin from your server's plugins directory.
  2. Place the new version 1.4 .jar file in the plugins directory.
  3. Start or restart your server.
  4. Check the plugin console for successful enablement of version 1.4.
  5. Ensure your permissions configuration is up to date, if necessary.

Additional Information

For further assistance, bug reports, or inquiries, please contact the author:

We hope you enjoy the improved shulker box experience with the BaloShulker plugin version 1.4!


Author: @hoangxuanlam2007
Full Changelog: v1.3...v1.4

BaloShulker v1.3

07 Aug 08:19
Compare
Choose a tag to compare

Enhanced Commands and Customizable Messages

Introducing New Commands:

  • /bs: Display command usage
  • /bs reload: Reload the plugin (Server admins can configure custom messages while the server is running by safely reloading the plugin and loading messages.yml)
  • /bs help: Show command help

Default Permission (Ops):

  • baloshulker.reload: Permission for reloading the plugin

Customizable Messages:

  • Every message can now be customized within the messages.yml configuration file.

Importing Library Components:

import org.bukkit.configuration.file.YamlConfiguration
import org.bukkit.entity.Player
import org.bukkit.event.Listener
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.BlockStateMeta
import org.bukkit.plugin.java.JavaPlugin
import java.io.*
import java.nio.charset.StandardCharsets
import org.bukkit.configuration.file.FileConfiguration

Loading and Creating messages.yml:

val dataFolder = dataFolder // Assuming dataFolder is the plugin's data folder
  if (!dataFolder.exists()) {
     dataFolder.mkdirs() // Create the necessary directories
  }

Setting Default Messages:

private fun setDefaultMessage(key: String, defaultValue: String) {
    if (!customMessages.contains(key)) {
        customMessages.set(key, ChatColor.translateAlternateColorCodes('&', defaultValue))
        try {
            customMessages.save(File(dataFolder, "messages.yml"))
        } catch (e: IOException) {
            e.printStackTrace()
        }
    }
}

Getting Messages with Color Codes ( This automatically translate color code using & instead of §):

private fun getMessage(key: String): String {
    val message = customMessages.getString(key, "") ?: ""
    return ChatColor.translateAlternateColorCodes('&', message)
}

Managing messages.yml:

Declare our messages.yml:

val customMessagesFile = File(dataFolder, "messages.yml")

Then we do some logic:

if (!customMessagesFile.exists()) {
    // if the file doesn't exist then create one
    try {
        customMessagesFile.createNewFile()
    } catch (e: IOException) {
        e.printStackTrace()
    }
    
    // Add comment here at the top of `messages.yml`
    try {
        // Get UTF-8 encoding standard
        val writer = BufferedWriter(OutputStreamWriter(FileOutputStream(customMessagesFile), StandardCharsets.UTF_8))
        writer.write(" CUSTOM COMMENT GOES HERE ")
    } catch (e: IOException) {
        e.printStackTrace()
    }

    // declare a variable for yaml config
    customMessages = YamlConfiguration.loadConfiguration(customMessagesFile)

    // Set default messages
    setDefaultMessage("command_usage", "§cUse §7<§f/bs help§7> §cfor help.")
    setDefaultMessage("command_unknown", "§cUnknown command. Use §7<§f/bs help§7> §cfor help.")
    // ... (other default messages)
    try {
        customMessages.save(customMessagesFile)
    } catch (e: IOException) {
        e.printStackTrace()
    }
} else {
    // If the file existed, load it
    customMessages = YamlConfiguration.loadConfiguration(customMessagesFile)
}

Create a Reloading function

private fun reloadPlugin() {
    // Disable the plugin
    Bukkit.getPluginManager().disablePlugin(this)

    // Enable the plugin
    Bukkit.getPluginManager().enablePlugin(this)
}

Custom permission inside plugin.yml:

permissions:
  baloshulker.reload:
    default: op
commands:
  reload:
    description: Reload BaloShulker Plugin
    permission: baloshulker.reload

Additional commmands:

"reload" -> {
    if (sender.hasPermission("baloshulker.reload")) {
        reloadPlugin()

        // Get the plugin's description
        val pluginVersion = description.version
        val pluginName = description.name

        sender.sendMessage(format("§aBaloShulker plugin reloaded successfully!"))
        sender.sendMessage(format("§aYou are using $pluginName v$pluginVersion!"))
    } else {
        sender.sendMessage(format(getMessage("player_don't_have_reloadperm")))
    }
}
"help" -> {
    // Display help message for /bs help command
    showHelp(sender)
}

Custom messages usage:

For every messages we need to use sendMessage() function along with format(getMessage(string)) so that you can create your own default custom messages and export it to messages.yml. Make sure the message is send to the sender using sender, we dont want our console or every other player to see it.

⚠️ Warning:

This version has a duplication issue* that creates a duplicate GUI containing every item from within a shulker box. This problem arises due to a lingering ghost GUI caused by memory leaks. There is a slight chance that a player might have used /bs open while simultaneously placing a shulker box, causing the GUI to appear even when the shulker box is placed underground. This bypasses the isShulkerBox(itemInMainHand) and isShulkerBox(itemInOffHand) checks. I recommend using version 1.4 or later, as these issues have been patched in those releases.


Full Changelog: v1.2...v1.3

Author: @hoangxuanlam2007

BaloShulker v1.2

07 Aug 07:29
Compare
Choose a tag to compare

Enhanced GUI Titles: Custom Titles for Different Colored Shulker Boxes

In contrast to the approach used in version 1.1, the next update v1.2 implements a more efficient solution by utilizing a HashMap to validate the ItemStack method.

  1. First, we declare the openedShulkers variable:

    private val openedShulkers = HashMap<Player, ItemStack>()
  2. Next, a mapping is created to accommodate custom titles for each colored shulker box:

    private val shulkerBoxTitles = mapOf(
        Material.SHULKER_BOX to "&dBalo Shulker", // Default title for the regular shulker box
        Material.WHITE_SHULKER_BOX to "&fBalo Shulker trắng"
        // Add other shulker box titles here
    )

This new approach offers enhanced precision, as it directly targets each shulker box in the Minecraft vanilla game, rather than relying on item names that end with _SHULKER_BOX. This flexibility enables us to provide a higher level of customization, export configurations, and more.

As part of this release, we've created this markdown to keep you informed about the exciting improvements introduced in version 1.2.

⚠️ Warning:

This version has a duplication issue* that creates a duplicate GUI containing every item from within a shulker box. This problem arises due to a lingering ghost GUI caused by memory leaks. There is a slight chance that a player might have used /bs open while simultaneously placing a shulker box, causing the GUI to appear even when the shulker box is placed underground. This bypasses the isShulkerBox(itemInMainHand) and isShulkerBox(itemInOffHand) checks. I recommend using version 1.4 or later, as these issues have been patched in those releases.


Full Changelog: v1.1...v1.2

Author: @hoangxuanlam2007

BaloShulker v1.1

06 Aug 13:37
Compare
Choose a tag to compare

Enhanced GUI Title: Color Codes Added

In this update, we've introduced an exciting new feature – Add a color-coded title to your shulker boxes' GUIs. Now, your GUIs can have a vibrant and visually appealing appearance, making your user experience even more engaging.

Importing components:

import org.bukkit.Material
import org.bukkit.block.ShulkerBox
import org.bukkit.command.Command
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.block.Action
import org.bukkit.event.inventory.InventoryCloseEvent
import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.inventory.EquipmentSlot
import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.BlockStateMeta
import org.bukkit.plugin.java.JavaPlugin
import org.bukkit.ChatColor

Check for shulker:

To implement this feature, simply utilize the isShulkerBox(item: ItemStack) method. By using the item.type.name.endsWith("_SHULKER_BOX") approach, we've ensured that the title functionality works seamlessly across all varieties of shulker boxes, regardless of their color.

private fun isShulkerBox(item: ItemStack): Boolean {
    return item.type == Material.SHULKER_BOX || item.type.name.endsWith("_SHULKER_BOX")
}

Change the title:

private fun openShulkerBox(player: Player, shulkerBoxItem: ItemStack) {
    val shulkerBoxMeta = shulkerBoxItem.itemMeta as? BlockStateMeta

    if (shulkerBoxMeta != null && shulkerBoxMeta.blockState is ShulkerBox) {
        val shulkerBox = shulkerBoxMeta.blockState as ShulkerBox

        // Set the new title with aqua color using the & symbol
        shulkerBox.customName = ChatColor.translateAlternateColorCodes('&', "&l&bBalo Shulker")

        player.openInventory(shulkerBox.inventory)
        openedShulkers[player] = shulkerBoxItem
    }
}

⚠️ Warning:

This version has a duplication issue* that creates a duplicate GUI containing every item from within a shulker box. This problem arises due to a lingering ghost GUI caused by memory leaks. There is a slight chance that a player might have used /bs open while simultaneously placing a shulker box, causing the GUI to appear even when the shulker box is placed underground. This bypasses the isShulkerBox(itemInMainHand) and isShulkerBox(itemInOffHand) checks. I recommend using version 1.4 or later, as these issues have been patched in those releases.


Full Changelog: v1.0...v1.1

Author: @hoangxuanlam2007

BaloShulker v1.0

06 Aug 12:06
Compare
Choose a tag to compare

Release first BaloShulker Version!

BaloShulker v1.0

  • Use /bs open to open a shulker box while holding it.
  • RIGHT_CLICK while holding a shulker box does the same.

⚠️ Warning:

This version has a duplication issue* that creates a duplicate GUI containing every item from within a shulker box. This problem arises due to a lingering ghost GUI caused by memory leaks. There is a slight chance that a player might have used /bs open while simultaneously placing a shulker box, causing the GUI to appear even when the shulker box is placed underground. This bypasses the isShulkerBox(itemInMainHand) and isShulkerBox(itemInOffHand) checks. I recommend using version 1.4 or later, as these issues have been patched in those releases.


Full Changelog: https://github.com/hoangxuanlam2007/BaloShulker/commits/v1.0

Author: @hoangxuanlam2007