prezeswis111-ops

napisz mi plugin do mc na wersje 1.21.4 n askelp za spedzony czas na serverze ma to miec INVENTORY GUI i w tedy np za 1 h bedznie dz 10 diaxów zrob tam łatwy conifg itp dodaj to pod koemne /sklepczas

Kodari AI
KodariMay 16 at 9:36 pm 10,349 (v2)

I’ll create a playtime shop plugin for Minecraft 1.21.4 with an inventory GUI where players can spend their accumulated time for rewards.

PlaytimeShop
A Minecraft plugin that rewards players for time spent on the server. Players use /sklepczas to open a GUI shop where they can purchase items using their accumulated playtime as currency. Features include configurable shop items with customizable costs, inventory-based interface, and automatic playtime tracking. Perfect for rewarding active players with in-game items.

Created a complete playtime shop plugin with:

Features:

  • ✅ /sklepczas command opens GUI shop

  • ✅ Players spend accumulated playtime (tracked automatically by Minecraft)

  • ✅ 6 configurable shop items (diamonds, iron, gold, emeralds, enchanted book, netherite)

  • ✅ Example: 1 hour = 10 diamonds (configurable)

  • ✅ Polish interface and messages

  • ✅ Inventory space checking

  • ✅ Easy config for adding/editing items

How it works:

  • Tracks playtime using Minecraft’s built-in statistics

  • Players use /sklepczas to see their time and open shop

  • Click items to purchase (deducts playtime automatically)

  • All items, costs, and messages configurable in config.yml

To add more items: Edit config.yml under shop-items, set slot (0-26), material, amount, cost in minutes, and display info.

Build with ./gradlew build - jar will be in build/libs/

prezeswis111-ops

w formacie sk

Kodari AI
KodariMay 16 at 9:39 pm 9,500 (v2)

Rozumiem! Chcesz to w formacie Skript (.sk). Przekonwertuję plugin na skrypt:

Gotowe! Plugin przepisany na format Skript (.sk):

📁 Struktura:

  • sklepczas.sk - główny plik skryptu

  • config.yml - instrukcja dodawania przedmiotów

🎮 Jak używać:

  1. Zainstaluj Skript na serwerze (jeśli jeszcze nie masz)

  2. Wrzuć plik sklepczas.sk do folderu /plugins/Skript/scripts/

  3. Użyj /sk reload sklepczas lub zrestartuj serwer

  4. Gotowe! Komenda /sklepczas działa

⚙️ Komendy:

  • /sklepczas - otwiera sklep (aliasy: /timeshop, /czasshop)

  • /sklepczas-reset <gracz> - resetuje wydany czas gracza (admin)

🛒 Przedmioty w sklepie:

  • 10x Diament - 1h (60 min)

  • 32x Żelazo - 30 min

  • 16x Złoto - 45 min

  • 5x Szmaragd - 1.5h (90 min)

  • Księga Ostrość V - 2h (120 min)

  • 1x Netherite - 3h (180 min)

📝 Jak dodać nowe przedmioty:

Wszystkie instrukcje są w config.yml - tam znajdziesz dokładny przykład jak dodać np. 64x TNT za 50 minut. Wystarczy skopiować blok kodu i zmienić wartości!

Kodari can make mistakes. Review important code before using.
Files
src
sklepczas.sk
Code
2 327
sklepczas.sk
# ========================================
#         SKLEP CZASU - Skript
# ========================================
# Gracze wydają czas gry na nagrody
# Komenda: /sklepczas
# ========================================

options:
    gui-title: &6&lSklep Czasu
    gui-size: 3 # Ilość rzędów (3 = 27 slotów)
    
    # Wiadomości
    not-enough-time: &cNie masz wystarczająco czasu! Potrzebujesz jeszcze %time%.
    purchase-success: &aZakupiono %item% za %cost%!
    current-playtime: &7Twój czas gry: &e%time%
    no-space: &cNie masz miejsca w ekwipunku!
    
# ========================================
# FUNKCJA: Pobierz czas gry gracza w minutach
# ========================================
function getPlaytimeMinutes(p: player) :: number:
    set {_ticks} to {_p}'s play time
    set {_seconds} to {_ticks} / 20
    set {_minutes} to {_seconds} / 60
    return {_minutes}

# ========================================
# FUNKCJA: Formatuj czas (minuty -> tekst)
# ========================================
function formatTime(minutes: number) :: text:
    set {_hours} to floor({_minutes} / 60)
    set {_mins} to {_minutes} mod 60
    
    if {_hours} > 0:
        if {_mins} > 0:
            return "%{_hours}%h %{_mins}%min"
        else:
            return "%{_hours}%h"
    else:
        return "%{_mins}%min"

# ========================================
# FUNKCJA: Sprawdź czy gracz ma miejsce w ekwipunku
# ========================================
function hasInventorySpace(p: player, amount: number) :: boolean:
    loop {_amount} times:
        set {_slot} to first empty slot in {_p}'s inventory
        if {_slot} is not set:
            return false
    return true

# ========================================
# KOMENDA: /sklepczas
# ========================================
command /sklepczas:
    aliases: /timeshop, /czasshop
    trigger:
        set {_minutes} to getPlaytimeMinutes(player)
        set {_timeText} to formatTime({_minutes})
        
        # Otwórz GUI
        open chest with 3 rows named "{@gui-title}" to player
        
        # Slot informacyjny - czas gracza
        set slot 4 of player's current inventory to clock named "&e&lTwój czas gry" with lore "&7Spędzony czas: &e%{_timeText}%" and "" and "&aWybierz przedmiot aby kupić!"
        
        # ==================== PRZEDMIOTY SKLEPU ====================
        
        # 1. 10x Diament - 60 minut (1h)
        set {_cost1} to 60
        set {_canAfford1} to {_minutes} >= {_cost1}
        if {_canAfford1} is true:
            set slot 10 of player's current inventory to 10 of diamond named "&b&l10x Diament" with lore "" and "&7Koszt: &e1 godzina" and "&7Otrzymasz: &b10x Diamentów" and "" and "&aKliknij aby kupić!"
        else:
            set {_needed1} to {_cost1} - {_minutes}
            set slot 10 of player's current inventory to 10 of diamond named "&b&l10x Diament" with lore "" and "&7Koszt: &e1 godzina" and "&7Otrzymasz: &b10x Diamentów" and "" and "&cPotrzebujesz jeszcze: &e%formatTime({_needed1})%"
        
        # 2. 32x Żelazo - 30 minut
        set {_cost2} to 30
        set {_canAfford2} to {_minutes} >= {_cost2}
        if {_canAfford2} is true:
            set slot 11 of player's current inventory to 32 of iron ingot named "&f&l32x Żelazo" with lore "" and "&7Koszt: &e30 minut" and "&7Otrzymasz: &f32x Żelaza" and "" and "&aKliknij aby kupić!"
        else:
            set {_needed2} to {_cost2} - {_minutes}
            set slot 11 of player's current inventory to 32 of iron ingot named "&f&l32x Żelazo" with lore "" and "&7Koszt: &e30 minut" and "&7Otrzymasz: &f32x Żelaza" and "" and "&cPotrzebujesz jeszcze: &e%formatTime({_needed2})%"
        
        # 3. 16x Złoto - 45 minut
        set {_cost3} to 45
        set {_canAfford3} to {_minutes} >= {_cost3}
        if {_canAfford3} is true:
            set slot 12 of player's current inventory to 16 of gold ingot named "&6&l16x Złoto" with lore "" and "&7Koszt: &e45 minut" and "&7Otrzymasz: &616x Złota" and "" and "&aKliknij aby kupić!"
        else:
            set {_needed3} to {_cost3} - {_minutes}
            set slot 12 of player's current inventory to 16 of gold ingot named "&6&l16x Złoto" with lore "" and "&7Koszt: &e45 minut" and "&7Otrzymasz: &616x Złota" and "" and "&cPotrzebujesz jeszcze: &e%formatTime({_needed3})%"
        
        # 4. 5x Szmaragd - 90 minut (1.5h)
        set {_cost4} to 90
        set {_canAfford4} to {_minutes} >= {_cost4}
        if {_canAfford4} is true:
            set slot 13 of player's current inventory to 5 of emerald named "&a&l5x Szmaragd" with lore "" and "&7Koszt: &e1.5 godziny" and "&7Otrzymasz: &a5x Szmaragdów" and "" and "&aKliknij aby kupić!"
        else:
            set {_needed4} to {_cost4} - {_minutes}
            set slot 13 of player's current inventory to 5 of emerald named "&a&l5x Szmaragd" with lore "" and "&7Koszt: &e1.5 godziny" and "&7Otrzymasz: &a5x Szmaragdów" and "" and "&cPotrzebujesz jeszcze: &e%formatTime({_needed4})%"
        
        # 5. Księga Ostrość V - 120 minut (2h)
        set {_cost5} to 120
        set {_canAfford5} to {_minutes} >= {_cost5}
        set {_book} to enchanted book of sharpness 5
        if {_canAfford5} is true:
            set slot 14 of player's current inventory to {_book} named "&d&lKsięga Ostrości V" with lore "" and "&7Koszt: &e2 godziny" and "&7Otrzymasz: &dKsiążkę z Ostrością V" and "" and "&aKliknij aby kupić!"
        else:
            set {_needed5} to {_cost5} - {_minutes}
            set slot 14 of player's current inventory to {_book} named "&d&lKsięga Ostrości V" with lore "" and "&7Koszt: &e2 godziny" and "&7Otrzymasz: &dKsiążkę z Ostrością V" and "" and "&cPotrzebujesz jeszcze: &e%formatTime({_needed5})%"
        
        # 6. 1x Netherite - 180 minut (3h)
        set {_cost6} to 180
        set {_canAfford6} to {_minutes} >= {_cost6}
        if {_canAfford6} is true:
            set slot 16 of player's current inventory to netherite ingot named "&8&l1x Netherite" with lore "" and "&7Koszt: &e3 godziny" and "&7Otrzymasz: &81x Netherite" and "" and "&aKliknij aby kupić!"
        else:
            set {_needed6} to {_cost6} - {_minutes}
            set slot 16 of player's current inventory to netherite ingot named "&8&l1x Netherite" with lore "" and "&7Koszt: &e3 godziny" and "&7Otrzymasz: &81x Netherite" and "" and "&cPotrzebujesz jeszcze: &e%formatTime({_needed6})%"

# ========================================
# EVENT: Kliknięcie w GUI
# ========================================
on inventory click:
    if name of player's current inventory is "{@gui-title}":
        cancel event
        
        set {_minutes} to getPlaytimeMinutes(player)
        set {_slot} to slot index of clicked slot
        
        # Slot 4 = informacja (nie rób nic)
        if {_slot} is 4:
            stop
        
        # ==================== ZAKUPY ====================
        
        # Slot 10 - 10x Diament (60 min)
        if {_slot} is 10:
            if {_minutes} >= 60:
                if hasInventorySpace(player, 10) is true:
                    # Odejmij czas (zapisz w zmiennej)
                    set {sklepczas.spent.%player's uuid%} to {sklepczas.spent.%player's uuid%} + 60
                    give 10 of diamond to player
                    send "{@purchase-success}" to player
                    replace "%item%" with "10x Diament" in last sent message
                    replace "%cost%" with "1 godzinę" in last sent message
                    play sound "entity.experience_orb.pickup" to player
                    close player's inventory
                else:
                    send "{@no-space}" to player
            else:
                set {_needed} to 60 - {_minutes}
                send "{@not-enough-time}" to player
                replace "%time%" with formatTime({_needed}) in last sent message
        
        # Slot 11 - 32x Żelazo (30 min)
        else if {_slot} is 11:
            if {_minutes} >= 30:
                if hasInventorySpace(player, 32) is true:
                    set {sklepczas.spent.%player's uuid%} to {sklepczas.spent.%player's uuid%} + 30
                    give 32 of iron ingot to player
                    send "{@purchase-success}" to player
                    replace "%item%" with "32x Żelazo" in last sent message
                    replace "%cost%" with "30 minut" in last sent message
                    play sound "entity.experience_orb.pickup" to player
                    close player's inventory
                else:
                    send "{@no-space}" to player
            else:
                set {_needed} to 30 - {_minutes}
                send "{@not-enough-time}" to player
                replace "%time%" with formatTime({_needed}) in last sent message
        
        # Slot 12 - 16x Złoto (45 min)
        else if {_slot} is 12:
            if {_minutes} >= 45:
                if hasInventorySpace(player, 16) is true:
                    set {sklepczas.spent.%player's uuid%} to {sklepczas.spent.%player's uuid%} + 45
                    give 16 of gold ingot to player
                    send "{@purchase-success}" to player
                    replace "%item%" with "16x Złoto" in last sent message
                    replace "%cost%" with "45 minut" in last sent message
                    play sound "entity.experience_orb.pickup" to player
                    close player's inventory
                else:
                    send "{@no-space}" to player
            else:
                set {_needed} to 45 - {_minutes}
                send "{@not-enough-time}" to player
                replace "%time%" with formatTime({_needed}) in last sent message
        
        # Slot 13 - 5x Szmaragd (90 min)
        else if {_slot} is 13:
            if {_minutes} >= 90:
                if hasInventorySpace(player, 5) is true:
                    set {sklepczas.spent.%player's uuid%} to {sklepczas.spent.%player's uuid%} + 90
                    give 5 of emerald to player