wadrix
📎 1 file 4,870 chars
📄
pasted-code-1768774409418.txt
txt 15 lines
▶
This plugin is a Java plugin for Paper/Purpur 1.21.11 designed to integrate directly with SuperiorSkyblock2 while fully supporting the OneBlock addon. Each island has exactly one special LuckyBlock that exists permanently for the lifetime of the island and is represented in the world as a NOTE_BLOCK. The LuckyBlock is not placed arbitrarily; instead, its location is derived dynamically from the island’s OneBlock origin, always spawning at a relative offset of X + 2, Y + 2, Z + 2. The block cannot be moved, mined normally, silk-touched, pushed, or destroyed by explosions, and all interactions with it are handled exclusively through custom logic rather than vanilla block-breaking mechanics.

The LuckyBlock operates on a state-based lifecycle consisting of an active state, a cooldown state, and a respawn state. When active, the block exists physically in the world and can be interacted with. Left-clicking the block applies a single “hit” regardless of tool or mining speed, playing a configurable sound and particle effect while decrementing a configurable hit counter. The number of hits required to break the block is configurable and is also influenced by an island-wide leveling system; for example, an island may initially require 30 hits to break the block, with upgrades or levels reducing this requirement down to a configurable minimum such as 10 or 5. When the final hit is applied, the block does not drop itself but instead triggers a reward roll, visual effects, and transitions into cooldown.

During cooldown, the block is temporarily removed or replaced with a non-interactable placeholder, and it cannot be hit. Any left-click during this period results in a red subtitle message informing the player that the LuckyBlock is respawning and displaying the remaining time. The cooldown duration is configurable and defaults to five minutes, but this cooldown cannot be reduced through upgrades, ensuring consistent pacing and balance. When the cooldown ends, the block respawns automatically at the same relative position, accompanied by a subtitle notification to all island members and optional sounds or particles.

Above the LuckyBlock, a FancyHolograms hologram is spawned and managed dynamically by the plugin. While the block is active, the hologram displays information such as the island’s LuckyBlock level or tier, the remaining number of hits required to break it, and its current status. While the block is in cooldown, the hologram switches to a countdown display showing the exact time until respawn. Hologram updates are event-driven rather than tick-based to avoid unnecessary performance overhead, and holograms are safely removed and recreated as needed.

The plugin includes a fully configurable island-based leveling system tied to the LuckyBlock. Levels are stored per island, not per player, to prevent alt abuse and ensure fair progression for island teams. Gaining levels can be tied to the number of LuckyBlock breaks, total hits contributed, or rewards obtained. As an island’s LuckyBlock level increases, it can reduce the required hits to break the block, unlock higher reward tiers, apply multipliers to money rewards, increase chances for rare drops, or unlock cosmetic or passive bonuses. All level thresholds, effects, and messages are configurable via YAML.

Rewards are tier-based and fully configurable. When the LuckyBlock is broken, the plugin determines the island’s current level, selects an appropriate reward tier, and rolls rewards based on weighted chances. Rewards can include Vault-based money, items, custom items with metadata, commands, island experience, or temporary effects. Right-clicking the LuckyBlock opens a configurable INVENTORY GUI menu that allows players to view possible rewards, inspect their island’s LuckyBlock progression, and purchase or unlock upgrades using in-game currency. When the block is in cooldown, the menu remains accessible in a read-only or limited mode.

The plugin is built to handle island lifecycle events safely and intelligently. When an island is deleted or reset through SuperiorSkyblock2, all associated LuckyBlock data, holograms, cooldown timers, and stored state are cleanly removed to prevent memory leaks or orphaned tasks. If an island is recreated, the LuckyBlock is regenerated automatically at the correct relative position with fresh or optionally reset progression, depending on configuration. All persistent data is stored using island UUIDs rather than raw coordinates, ensuring compatibility with island movement, resets, and future expansions.

Overall, the plugin is designed to be modular, exploit-resistant, and performance-conscious, providing a long-term progression mechanic that integrates naturally into OneBlock gameplay while remaining fully configurable for server-specific balance, messaging, visuals, and rewards.
Kodari AI
KodariJan 18 at 10:13 pm 100 (v2)

The generation was stopped before any content could be produced.

wadrix

This plugin is a Java plugin for Paper/Purpur 1.21.11 designed to integrate directly with SuperiorSkyblock2 while fully supporting the OneBlock addon. Each island has exactly one special LuckyBlock that exists permanently for the lifetime of the island and is represented in the world as a NOTE_BLOCK. The LuckyBlock is not placed arbitrarily; instead, its location is derived dynamically from the island’s OneBlock origin, always spawning at a relative offset of X + 2, Y + 2, Z + 2. The block cannot be moved, mined normally, silk-touched, pushed, or destroyed by explosions, and all interactions with it are handled exclusively through custom logic rather than vanilla block-breaking mechanics.

Kodari AI
KodariJan 18 at 10:14 pm 6,122 (v2)

I’ll create a SuperiorSkyblock2 LuckyBlock integration plugin with OneBlock addon support.

SuperiorLuckyBlock
A Paper/Purpur 1.21.1 plugin that integrates with SuperiorSkyblock2 and OneBlock addon. Each island features a permanent, indestructible LuckyBlock represented as a NOTE_BLOCK positioned at the OneBlock origin offset by (2, 2, 2). The block is fully protected from mining, explosions, pistons, and silk touch, with all interactions managed through custom logic rather than vanilla mechanics.

I’ll proceed with creating the plugin structure based on standard SuperiorSkyblock2 API patterns.

Plan:

  • Create build.gradle.kts with Paper API and SuperiorSkyblock2 dependencies

  • Create main plugin class with SuperiorSkyblock2 integration

  • Implement LuckyBlock manager to track and create blocks at OneBlock offset

  • Add protection listeners for block break, explosions, pistons, and interactions

  • Create plugin.yml with proper configuration

Plugin created successfully!

Core features implemented:

  • Dynamic positioning: LuckyBlock spawns at OneBlock origin + (2, 2, 2) offset

  • Full protection: Prevents breaking, explosions, pistons, and silk touch

  • Island lifecycle: Auto-creates on island creation, removes on disband

  • Interaction system: Right-click to use with configurable cooldown

  • SuperiorSkyblock2 integration: Uses island membership checks and API

  • OneBlock addon support: Detects addon and uses OneBlock origin when available

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle.kts
manifest.kod
settings.gradle.kts
Code
9 379
src/main/kotlin/com/superiorluckyblock/listener/BlockProtectionListener.kt
package com.superiorluckyblock.listener

import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI
import com.superiorluckyblock.SuperiorLuckyBlockPlugin
import org.bukkit.GameMode
import org.bukkit.Material
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.event.block.BlockDamageEvent
import org.bukkit.event.block.BlockExplodeEvent
import org.bukkit.event.block.BlockPistonExtendEvent
import org.bukkit.event.block.BlockPistonRetractEvent
import org.bukkit.event.entity.EntityExplodeEvent
import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.event.block.Action

class BlockProtectionListener(private val plugin: SuperiorLuckyBlockPlugin) : Listener {
    
    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    fun onBlockBreak(event: BlockBreakEvent) {
        if (!plugin.config.getBoolean("lucky-block.protection.prevent-break", true)) return
        
        if (plugin.luckyBlockManager.isLuckyBlock(event.block)) {
            event.isCancelled = true
            event.player.sendMessage("§cYou cannot break the LuckyBlock! Right-click to use it.")
        }
    }
    
    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    fun onBlockDamage(event: BlockDamageEvent) {
        if (!plugin.config.getBoolean("lucky-block.protection.prevent-break", true)) return
        
        if (plugin.luckyBlockManager.isLuckyBlock(event.block)) {
            event.isCancelled = true
        }
    }
    
    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    fun onEntityExplode(event: EntityExplodeEvent) {
        if (!plugin.config.getBoolean("lucky-block.protection.prevent-explosion", true)) return
        
        event.blockList().removeIf { block ->
            plugin.luckyBlockManager.isLuckyBlock(block)
        }
    }
    
    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    fun onBlockExplode(event: BlockExplodeEvent) {
        if (!plugin.config.getBoolean("lucky-block.protection.prevent-explosion", true)) return
        
        event.blockList().removeIf { block ->
            plugin.luckyBlockManager.isLuckyBlock(block)
        }
    }
    
    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    fun onPistonExtend(event: BlockPistonExtendEvent) {
        if (!plugin.config.getBoolean("lucky-block.protection.prevent-piston", true)) return
        
        for (block in event.blocks) {
            if (plugin.luckyBlockManager.isLuckyBlock(block)) {
                event.isCancelled = true
                return
            }
        }
    }
    
    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    fun onPistonRetract(event: BlockPistonRetractEvent) {
        if (!plugin.config.getBoolean("lucky-block.protection.prevent-piston", true)) return
        
        for (block in event.blocks) {
            if (plugin.luckyBlockManager.isLuckyBlock(block)) {
                event.isCancelled = true
                return
            }
        }
    }
    
    @EventHandler(priority = EventPriority.HIGH)
    fun onPlayerInteract(event: PlayerInteractEvent) {
        if (event.action != Action.RIGHT_CLICK_BLOCK) return
        
        val block = event.clickedBlock ?: return
        
        if (!plugin.luckyBlockManager.isLuckyBlock(block)) return
        
        event.isCancelled = true
        
        val player = event.player
        val superiorPlayer = SuperiorSkyblockAPI.getPlayer(player)
        val island = plugin.luckyBlockManager.getIslandByLuckyBlock(block) ?: return
        
        if (!island.isMember(superiorPlayer)) {
            player.sendMessage("§cYou must be a member of this island to use the LuckyBlock!")
            return
        }
        
        if (!plugin.luckyBlockManager.canInteract(player.uniqueId, island)) {
            val remaining = plugin.luckyBlockManager.getRemainingCooldown(player.uniqueId)
            player.sendMessage("§cYou must wait $remaining seconds before using the LuckyBlock again!")
            return
        }
        
        plugin.luckyBlockManager.setLastInteraction(player.uniqueId)
        
        player.sendMessage("§aYou used the LuckyBlock!")
        block.world.createExplosion(block.location, 0f, false, false)
        
        plugin.server.scheduler.runTaskLater(plugin, Runnable {
            if (block.type != Material.NOTE_BLOCK) {
                block.type = Material.NOTE_BLOCK
            }
        }, 1L)
    }
}