#development

1 messages ยท Page 32 of 1

unborn ivy
#

is there any way to do this without another loop

hoary scarab
#

Yes just don't return;

#

and set the original block outside the loop

unborn ivy
#

ah kk

#

i also noticed that if i break a torch thats below another torch they both break

#

gotta add a check to see if the block broken is attachables

river solstice
#
@EventHandler
public void AttachedBlocks(BlockBreakEvent e) {
    Player p = e.getPlayer();
   
    if (!p.getGamemode().equals(GameMode.CREATIVE)) {
        return;
    }
   
    Block b = e.getBlock();
    
    for (BlockFace f : faces) {
        Block relative = b.getRelative(f);

        if (!attachables.contains(relative.getType())) {
            continue;
        }
        
        e.setCancelled(true);
        relative.setType(Material.AIR);
    }
    
    b.setType(Material.AIR);
}

๐Ÿ˜Œ

edgy lintel
#

turns out to be a bug of bungeecord chat, where can i report this issue?

#

issue: translatablecomponent does not work as a child component of textcomponent

hoary scarab
river solstice
#

forgor !

hoary scarab
hoary scarab
#

I hate when I do that xD

#
@EventHandler
public void AttachedBlocks(BlockBreakEvent e) {
    Block b = e.getBlock();
    
    List<Block> attachedBlocks = Stream.of(faces) // Creates a stream of BlockFaces
            .filter(face -> attachables.contains(b.getRelative(face).getType())) // Tests the relative block if its type is attachable
            .map(face -> b.getRelative(face)) // Maps the block to be collected
            .collect(Collectors.toList()); // Collects all blocks.
    
    if(!attachedBlocks.isEmpty()) {
        e.setCancelled(true); // Cancels the event (So physics are not applied)
        attachedBlocks.forEach(attached -> attached.setType(Material.AIR)); // Removes all attached blocks
        b.setType(Material.AIR); // Removes originally broken block
    }
}
```Somewhat cleaner. Does double loop but with the "variablizing" of the attached blocks list.
unborn ivy
#

i need a moment to understand this

hoary scarab
#

I'm surprised Attachable doesn't include blocks that attach xD
You either have to make your own list or use multiple object types (Ex; Directional) to test whether a block can attach to another.

hoary scarab
unborn ivy
#

cool

#

i was just adding a check to see if player was in creative and if the block broken contains attachables

hoary scarab
#

๐Ÿ‘

edgy lintel
unborn ivy
#

Unlikely argument type for equals(): List<Material> seems to be unrelated to Material

#

uh

#

do i have to worry about this or no

river solstice
#

Context?

#

Are you comparing a list of materials to a material with equals?

unborn ivy
#

Trying to add a check to see if:
player is in Creative
if a player broke an attachable

#
       if (gm == GameMode.CREATIVE && b.getType().equals(attachables)) {
           p.sendMessage("Tried breaking, didnt work");
           return;
       }
#

I have tried this

#

and it gave me the "info" above

river solstice
#

Well, use atachables.contains b.getType

unborn ivy
#

wait what

river solstice
#

You're comparing object list to an object

unborn ivy
#

ohhhhhhhh

#

ok makes sense now

#

thanks

#

well the item frames dont seem to be working

#

I think its because item frames are an entity

#

and trying to set it to air wouldnt do anything

river solstice
#

well, you're probably not even 'setting it to air', because the method probably doesn't find them in the first place.

unborn ivy
#

yes because they are an entity

#

when they are attached to a block

#

idk how to get an entity attached to a block

hazy summit
#

is it possible to create placeholders without an identifier, so instead of %identifier_param% its just %param% ?

wheat carbon
#

from a single expansion?

dense drift
#

you can not, papi checks for %identifier_ first, and considers anything else as parameters, until the first %

hazy summit
#

damn I guess I gotta use an empty string then and have %_<param>%

dense drift
#

you can not

wheat carbon
#

why

dense drift
#

^

hazy summit
#

empty string works fine

dense drift
#

but why do you want that?

hazy summit
#

I was asked to make configurable placeholders via a config
its either that or Ill have a "identifier" variable in config

dense drift
#

if you dont use an identifier, where's the "customization"? ๐Ÿ™‚

hazy summit
#

true ig

dense drift
#

also, customization is pretty vague, are you sure you don't want it for the result of the placeholders?

proud pebble
#

why would ypu want your placeholder's id to be customizable

#

like normally its never seen so it doesnt mske sense for it to be customizable

hazy summit
#

I dont know, I was just asked to do this

proud pebble
#

would make sense if they want the output to be customizable rather then the actual placeholder id to be

silk ginkgo
#

How can I write in a specific/custom config file?

proud pebble
# silk ginkgo How can I write in a specific/custom config file?
BukkitWiki

The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...

silk ginkgo
#

thank u

trail wigeon
#

does anyone know how you would take on renaming the vanilla enchants so instead of ya know it being like Efficiency X or Efficiency enchant.level.100 and instead its Efficiency 10 or Efficiency 100

proud pebble
tacit belfry
#

I'm trying to execute commands in gradle, for example cd, and whenever I try to cd into a directory, I always get the error that the directory can't be found.

#

Does anyone know how to execute command line commands from gradle?

wet fox
#

I am getting a NPE with no error message when publishing my artifact

Execution failed for task ':publishMavenPublicationToMavenRepository'.
> Failed to publish publication 'maven' to repository 'maven'
> java.lang.NullPointerException (no error message)
publishing {
    publications {
        create<MavenPublication>("maven") {
            from(components["java"])
        }
    }
    repositories {
        maven(url = "https://repo.lightdream.dev/") {
            credentials(HttpHeaderCredentials::class){
                name = project.findProperty("gitlab.header.name") as String
                value = project.findProperty("gitlab.header.value") as String
            }
        }
    }
}
vital drum
#

pls help me its not working: diamond_block.json```{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "minecraft:blocks/diamond_block"
},
"overrides": [
{ "predicate": {"custom_model_data": 123456}, "model": "block/ruby_block"}

]

}```

#

ruby_block.json: ```{
"credit": "Made with Blockbench",
"textures": {
"0": "blocks/ruby_block",
"particle": "blocks/ruby_block"
},
"elements": [
{
"from": [0, 0, 0],
"to": [15, 16, 16],
"faces": {
"north": {"uv": [0, 0, 15, 16], "texture": "#0"},
"east": {"uv": [0, 0, 16, 16], "texture": "#0"},
"south": {"uv": [0, 0, 15, 16], "texture": "#0"},
"west": {"uv": [0, 0, 16, 16], "texture": "#0"},
"up": {"uv": [0, 0, 15, 16], "texture": "#0"},
"down": {"uv": [0, 0, 15, 16], "texture": "#0"}
}
}
],
"display": {
"thirdperson_righthand": {
"translation": [0, 0, -1.5],
"scale": [0.35, 0.35, 0.35]
},
"thirdperson_lefthand": {
"translation": [0, 0, -1.5],
"scale": [0.35, 0.35, 0.35]
},
"firstperson_righthand": {
"translation": [1.5, -1, 0]
},
"firstperson_lefthand": {
"translation": [1.75, -1.25, 0]
},
"gui": {
"rotation": [36.5, -33.5, 0],
"scale": [0.7, 0.7, 0.7]
}
}
}

#

if i give me diamondblock with custom daa 123456 its still normal dia block

feral raptor
river solstice
#

My favorite ide is netbeans

#

Its the best

#

Better them IJ by far!

dusky harness
#

i have used netbeans

proud pebble
# vital drum pls help me its not working: diamond_block.json```{ "parent": "minecraft:block...

Custom blocks are a really fun and useful feature that can be created with data packs. In this video, I go over two similar methods for creating custom blocks depending on the transparency of the base block you need.

Some other ideas that this method can be used for are custom machines, crafters, hidden doors, mob boss summoning altars, or eve...

โ–ถ Play video
#

you cant actually add custom blocks, this is just a work around

trail wigeon
dusky harness
#

i am half joking
I actually did load up a project and attempt to work on it but failed because i couldn't get netbeans to work with gradle ๐Ÿฅฒ

spiral prairie
#

specifically for one username -> one uuid

dense drift
signal grove
#

hm, so if i made a plugin that just constantly calls Bukkit.getPlayer(name).getUniqueIdentifier(), would this be stopped by the ratelimit?

#

it's never really been a concern for me

spiral prairie
#

600 per 10 minutes

#

damn

signal grove
#

1 every second?

spiral prairie
#

jeez

#

thats slow

signal grove
#

well i guess it's only a problem for jumbo servers, since they would all be spread out

dense drift
#

Paper (spigot?) caches the uuids

spiral prairie
#

guess what im not making a plugin xD

dense drift
#

Cache the uuids as well

signal grove
dense drift
#

Idk

#

The cache probably expires after some hours and then it is requested from the api again

#

I think thats what cached-players.json is for

signal grove
#

oh you mean each server has its own cache

#

i thought you meant spigot had one massive

dense drift
#

Ah yes, each server

lyric gyro
#

it has an expiry date pretty sure

#

no clue for how long they're kept by default

signal grove
#

so we can hit the rate limit by generating random names xD

lyric gyro
#

i mean

#

the server you create the requests on is the only one that's gonna be affected

#

i don't think mojang servers will particularly flinch

spiral prairie
signal grove
#

yeah i know it wont affect anything

dense drift
#

Could try to use proxies if you need a lot of requests I guess @spiral prairie

signal grove
#

mojang flinching when i delete the cache after each request ๐Ÿ˜Ž

spiral prairie
#

proxies?

#

i could just store in plain text so

#

the reason im calling the api is to verify the uuid name pairs

#

im currently trying a ratelimit bucket

dense drift
#

In computer networking, a proxy server is a server application that acts as an intermediary between a client requesting a resource and the server providing that resource.Instead of connecting directly to a server that can fulfill a request for a resource, such as a file or web page, the client directs the request to the proxy server, which evalu...

#

Yeah but I guess the rate limits are for an ip as well?

spiral prairie
#

yea

signal grove
#

they cant really check anything else except for ips

dense drift
#

I thought the endpoint has an auth, nvm

proud pebble
#

its only getOfflinePlayer(string) that does

signal grove
#

ah

proud pebble
#

its why its deprecated

mortal scaffold
#

how can i get an item in inventory and delete it (a certain amount) ? MC Version: 1.16.5 Paper (paper-794)

signal grove
#

maybe like this

#
public void deleteItems(Player player, Material material, int numDelete)
    {
        PlayerInventory inv = player.getInventory();
        for(int i=0; i<inv.getSize(); i++)
        {
            ItemStack itemStack = inv.getItem(i);
            if(itemStack.getType() == material)
            {
                int numStack = itemStack.getAmount();
                if (numStack <= numDelete)
                {
                    inv.setItem(i, null);
                    numDelete -= numStack;
                }
                else
                {
                    itemStack.setAmount(numStack - numDelete);
                    inv.setItem(i, itemStack);
                }
            }
        }
    }
formal locust
#

Hello, could anyone tell me how to listen for incoming packets to server through netty?

river solstice
sharp cove
#

Anyone here that has experience with LunarClient-API on the topic of teamviewer?

dense drift
#

add a null check before accessing item.getType

vital drum
mortal scaffold
#

how do I add a null check to org.bukkit.inventory.ItemStack.getType() and if the player has an item, then it was picked up when player clicking on the menu icon

https://pastebin.com/S2F213Mx

shell moon
#

you check if itemstack is null

#

getType wont return null

mortal scaffold
shell moon
#

mmm

#

item == null

#

before checking type

mortal scaffold
#

let's go to private messages, I'll explain

shell moon
#

no need to

#

i'm answering your question

#

how do I add a null check

#

itemstack == null

mortal scaffold
shell moon
#

i didnt understand your question honestly

river solstice
#

How do I detect when player finishes editing the sign?

shell moon
#

SignChangeEvent maybe?

#

or it was SignUpdateEvent, dont remember

river solstice
#

Change

river solstice
#

hey, uh, this is my structure for the project

#
    <form action="http://localhost:3000/test" method="POST">
        <input type="text" name="example">
        <br>
        <button type="submit">Send to backend</button>
    </form>
#

hello.js

const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const app = express();

app.use(express.json());
app.use(express.static("express"));
app.use(bodyParser.urlencoded({ extended: true }));

app.use('/', function (req, res)
{
    res.sendFile(path.join(__dirname + '/express/index.html'));
});

app.post('/hello', (req, res) =>
{
    console.log("Hello " + req.body.name);
});

const server = http.createServer(app);
const port = 3000;

server.listen(port);
console.debug('Server listening on port ' + port);
#

but when I submit, I don't get a log in POST /hello

#

any idea?

dense drift
#

You have localhost:3000/test in there, not /hello

river solstice
#

๐Ÿ’€

#

I was changing it up

#

thought I changed them both

tardy cosmos
#

random thought I just had, but should you always use the Bukkit scheduler for async tasks or is it fine to use your own thread system? Doesn't the scheduler always run the tasks on the next tick even if it has a delay of 0?

lyric gyro
#

it's fine to use your own executors so long as you do the necessary cleanup on disable, bukkit automatically cancels and waits for your existing tasks to finish when disabling a plugin
and yes the scheduler does that delay thing, most of the time it probably doesn't matter tho

raven oar
#
  • it would be really nice in the deluxetag plugin to add in the config an option that if you activate it, it allows to put a space automatically after each tag, because those who don't have a tag end up with a space in front of their nickname
  • and add deluxetags.tag.all ?
dense drift
#

Wrong channel dont you think? @raven oar

raven oar
dusky harness
#

#coding

#

๐Ÿ˜Œ

leaden sinew
#

#real-developers

lyric gyro
#

#coding-and-gaming

edgy lintel
dusky harness
#

what

edgy lintel
burnt storm
#

inside of your custom placeholder, is it possible to return an already existing placeholder?

#

would i do return "%some_placeholder%"; or would I have to do something else to parse it?

dusky harness
dark garnet
#

hello, if i can do CreatureSpawnEvent.getHandlerList(), why cant i do CreatureSpawnEvent.class.getHandlerList()?
anti-xy: i have a Class<? extends Event> event and i need to get the handler list of it to unregister that event from a listener

dusky harness
dusky harness
#

I'd recommend caching it

#

I haven't ran any benchmarks on how fast it is/if it is cached but iirc you're supposed to cache it

#

(caching the Method)

dark garnet
#

i dont think its possible to cache it in my scenario

dusky harness
dark garnet
#

actually

dusky harness
#

here ill give an example

dark garnet
#

nvm yea i think it is

dusky harness
#

im not sure

#

ยฏ_(ใƒ„)_/ยฏ

dark garnet
#

it should be... right?

dusky harness
#

i dont remember how static reflection works

#

and if you can use it for different impls

#

i don't think you can

dark garnet
#

i wont just in case

#

it doesnt need to be cached anyways i dont expect it to be used a lot

dusky harness
#

just make sure you don't run it on the main thread while the server is running ig

dark garnet
#

what

#

i hate threads

#

why?

dusky harness
dark garnet
#

threads r just confusing

#

i understand y to not run on main thread now tho

dusky harness
#

so

#

main thread = most of the stuff handled by the server

dark garnet
#

yeye i understand what threads "are"

dusky harness
#

ah ok

dark garnet
#

but i just never know when its good/bad to use

#

like wth is async

#

does async just mean its on its own thread?

dusky harness
#

in spigot programming, typically it's just when it's not on the main thread

dark garnet
#

and then sync means it on main thread?

#

or whatever the opposite of async is lmao

dusky harness
#

yes

#

d;spigot bukkitscheduler

uneven lanternBOT
dusky harness
#

huh

dark garnet
#

๐Ÿ’€

dusky harness
#

d;methods bukkitrunnable

uneven lanternBOT
#
Methods:
org.bukkit.scheduler.BukkitRunnable#cancel
org.bukkit.scheduler.BukkitRunnable#runTaskLaterAsynchronously
org.bukkit.scheduler.BukkitRunnable#runTaskTimer
org.bukkit.scheduler.BukkitRunnable#runTask
org.bukkit.scheduler.BukkitRunnable#runTaskLater
org.bukkit.scheduler.BukkitRunnable#BukkitRunnable
org.bukkit.scheduler.BukkitRunnable#runTaskTimerAsynchronously
org.bukkit.scheduler.BukkitRunnable#getTaskId
org.bukkit.scheduler.BukkitRunnable#isCancelled
org.bukkit.scheduler.BukkitRunnable#runTaskAsynchronously```
dark garnet
#

lmao

dusky harness
#

there we go

#

runTask = sync

#

runTaskAsynchronously = async

dark garnet
#

so would it be be better to always use async?

#

i remember seeing something that said to not use api stuff on async things

dusky harness
dusky harness
dark garnet
#

ah

dusky harness
#

so blocks, entities, etc etc etc

dark garnet
#

yeye

dusky harness
#

and maybe some bukkit api but idk

#

but an issue with async is that every time you go async, when you want to go back to the main thread, it's delayed by a tick (theres also issue with concurrency but im not gonna go in depth in it rn)

#

since runTask/runTaskLater runs in at min 1 tick later

dark garnet
#

oh

#

does this look all right? is there a better way to do it?

    /**
     * Unregisters a specific event from the {@link #getPlugin()}
     *
     * @param   event   the {@link Event} to unregister
     */
    default void unregister(@NotNull Class<? extends Event> event) {
        try {
            final HandlerList handlerList = (HandlerList) event.getMethod("getHandlerList").invoke(event);
            handlerList.getClass().getMethod("unregister", Listener.class).invoke(handlerList, this);
        } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
    }```
#

o right

#

no main thread

dusky harness
#

well

#

the code won't work because you're making the instance a Class

#

Class does not have a method named getHandlerList

#

so do invoke(null)

dark garnet
#

oh?

dusky harness
#

then you don't need to do reflection again on handlerList because it's already a HandlerList

leaden sinew
dark garnet
leaden sinew
#

That's not really a reason

dark garnet
#

and dkim said it might not work

dusky harness
#

no thats not what i meant
i was just saying general downsides in response to your comment of why people say not to use async for everything

leaden sinew
#

Also dkim are you sure event stuff can be run off the main thread?

dusky harness
#

no

#

likely yes

#

1% chance of concurrency issue since i doubt it uses thread safe map

dark garnet
leaden sinew
dark garnet
dusky harness
#

i was talking about different kind

leaden sinew
#

anti-xy: i have a Class<? extends Event> event and i need to get the handler list of it to unregister that event from a listener
Is this your class, or a class from somewhere else?

dusky harness
#

this is probably overkill but I'd have a cache map and if the server is not starting/stopping (is running), and is running async, throw an exception

lol
u dont have to do this
or you shouldn't even unregister anyways

leaden sinew
#

I'm confused what your point is

dark garnet
#

an example input would be CreatureSpawnEvent.class

dusky harness
#

why are you unregistering listeners

leaden sinew
#

The real question is why are you unregistering listeners like this

dusky harness
#

or just make it require a HandlerList

#

no reflection needed

dark garnet
leaden sinew
#

Is this a listener that you are registering yourself then unregistering?

dark garnet
#

but its not unregistering the listener

#

its unregistering an event from a listener

leaden sinew
#

So you want to unregister a single event from the listener?

dark garnet
#

yea

leaden sinew
#

Why not just have it be it's own class then?

dusky harness
#

or have a boolean variable

#

๐Ÿ‘

leaden sinew
#

This seems a bit unnecessary

leaden sinew
dark garnet
leaden sinew
#

But if you're registering and unregistering the same listener repeatedly, I'd use a boolean like Dkim said

dark garnet
# leaden sinew Apparently not

well before i had it take in an Event event, but i just realized that means it can only be unregistered from the event

leaden sinew
#

What took in an Event event

dusky harness
#

if you really want to unregister

dark garnet
dark garnet
leaden sinew
#

You're making your own unregister method?

dark garnet
leaden sinew
dusky harness
#

param

dark garnet
#
    /**
     * Unregisters a specific event from the {@link AnnoyingListener} using it's {@link HandlerList}
     * <p>Use the event's {@code #getHandlerList()} to get the {@link HandlerList}
     *
     * @param   handlerList the {@link HandlerList} of the {@link Event} to unregister
     */
    default void unregister(@NotNull HandlerList handlerList) {
        handlerList.unregister(this);
    }```
dusky harness
#

or at that point u could prob just do it manually

dark garnet
dark garnet
leaden sinew
#

Yes

#

Why are you trying to unregister a single method, is there a purpose?

dark garnet
#

easier to do ig

leaden sinew
#

Because if I was someone who wanted to use your plugin and I looked at the source to try to figure out why one specific listener wasn't being called, I would be confused

dark garnet
#

this is for my api btw (but doesnt change ur point ik)

leaden sinew
#

This is something I do for listeners
https://github.com/Fisher2911/FisherLib/blob/master/src/main/java/io/github/fisher2911/fisherlib/listener/GlobalListener.java
Where you explicitly can register individual methods, like this:
https://github.com/Fisher2911/Kingdoms/blob/efd59077d7f75e8366a7b19ec874679c16377b8e/src/main/java/io/github/fisher2911/kingdoms/listener/ChatListener.java#L44
I didn't add unregistering methods, but all you would have to do for that is remove it from the list in the RegisteredListener class

dark garnet
#

how is that different from what im doing tho?

leaden sinew
#

Because you're using reflection and it's not clear that some listeners will be registered / unregistered

dark garnet
#

ok yeah i see what ur saying now about not knowing which will be registered / unregistered

#

ok i removed method i wont unregister singular events now

#

ill make separate classes

#

wait since its an api should i deprecate the method instead of completely removing it?

dusky harness
#

i thought u just added it

#

u can just remove it completely

dark garnet
# dusky harness i thought u just added it

i had this before:

    /**
     * Unregisters a specific event from the {@link #getPlugin()}
     *
     * @param   event   the {@link Event} to unregister
     */
    default void unregister(@NotNull Event event) {
        event.getHandlers().unregister(this);
    }```
leaden sinew
#

You can deprecate it and mark it for removal

#

Or if you're API isn't released / in beta I would just remove it

dark garnet
leaden sinew
#

Unless you've said that it will be backwards compatible

dusky harness
#

isn't it part of annotation libs

leaden sinew
#

Yeah

dusky harness
#

i dont think java has any annotations like this

#

including NotNull, etc

leaden sinew
#

You can use Jetbrains annotations

dark garnet
dusky harness
#

full compat with servers that use java 8

dusky harness
#

wait

#

deprecated

dark garnet
#

yea

leaden sinew
#

Oh yeah that is

dark garnet
#

the tags exist in later java versions

dusky harness
#

๐Ÿฅฒ

#

tbh id just remove

leaden sinew
#

Can't 1.11 run on later Java versions?

dusky harness
#

but its up to you

dusky harness
dark garnet
dusky harness
#

but many servers use java 8

dark garnet
#

^

leaden sinew
#

You could also just make it a javadoc comment

leaden sinew
dark garnet
#

imma just remove cause im 100% sure im the only developer using the api ๐Ÿค“

dusky harness
#

but thats about it afaik

dark garnet
#

also who even starts 1.8 servers

dusky harness
#

and i think spigot caps the java version

#

and paper removes the cap

dark garnet
leaden sinew
dark garnet
#

lets make a pack (agreement) to make all of our plugins not work on servers below 1.13

dusky harness
#

rip bedwars

#

:(

#

well its already ๐Ÿชฆ

#

but

dark garnet
#

oldcombatmechanics

dusky harness
#

๐Ÿ‘Ž

#

well its fine

dark garnet
#

hypixel will just make their own thats better

dusky harness
#

i dont really play mc anymore anyways

#

so i dont have a strong opinion anymore

dark garnet
dusky harness
#

!

leaden sinew
#

Completely forgot that was a channel

shell moon
#

if i wanna check if a string is most likely an uuid or a username

#

would it be better to check String#length() >= 20 (for example)
or simply check if contains a dash

signal grove
#

all uuids will have 32 chars

#

and no usernames will have that many, so it's not most likely, it will be 100% accurate

#

(im assuming it must be either a username or a uuid, ignoring the possibility it's neither)

hoary scarab
#

Could just do try catch on UUID.fromString()

shell moon
#

no need to actually know if its a real one or not

#

i just want to differentiate if its most likely to be a uuid

#

or a username

#

i gues length is faster than contains dash

hoary scarab
#

Like if its a mojang UUID?

shell moon
#

admin provides a string in a command which can be uuid or username

#

i just want to filter which could be uuids and which names so ic an search it and delete it

hoary scarab
#

Yeah so just try catch on UUID.fromString

shell moon
#

doesnt mind if its a valid user, or valid one

#

but i dont need the uuid as UUID object

#

just want to know if it as long as a uuid so i can search in uuids

#

or a name so i can search in names

#

xdd

hoary scarab
#

Ok...

public boolean isUUID(String input) {
    try {
        UUID.fromString(input);
        return true;
    } catch(IllegalArgumentException e) {
         return false;
    }
}
shell moon
leaden sinew
#
public boolean isUUUD(String string) {
    return System.OS.answerQuestion(โ€œIs this a UUID?โ€, string);
}
#

All operating systems come built in with an AI now

#

Make sure to update to the latest version

signal grove
#

makes a chatgpt api request ๐Ÿ˜Ž

lyric gyro
#

isUUUD

bright pier
#

usersUniquelyUltimateData

leaden sinew
# lyric gyro isUUUD

Well I had to name it something else because Yapperyapps stole the method name

#

Definitely not because Iโ€™m on mobile

bright pier
hoary scarab
bright pier
#

True. isUniqueID Then ๐Ÿ˜›

hoary scarab
#

Both are viable. Its up to who's using it really.

tired olive
#

or just isUUID

#

isUniqueId could be interpreted as checking if the input is unique

sterile hinge
#
public boolean isUUID(String string) {
  return string instanceof UUID;
}
tired olive
#

ew

#

2 space tabs

#

also amazing code

sterile hinge
#

no, a String is never a uuid

#

it can only represent one

hoary scarab
#

Just making sure lol

stuck hearth
#

String#toUUID is much easier

river solstice
#

just cast the string to UUID ๐Ÿ˜Œ

tired olive
river solstice
#

question for sql experts 'round here

SELECT
YEAR(FROM_UNIXTIME(ROUND(`join_time`/1000))) AS YEAR,
MONTH(FROM_UNIXTIME(ROUND(`join_time`/1000))) AS MONTH,
DAY(FROM_UNIXTIME(ROUND(`join_time`/1000))) AS DAY,
SUM(`leave_play_ticks` - `join_play_ticks`) AS PLAY_TICKS
FROM sessions
WHERE  name = 'M0dii' AND ROUND(`join_time`/1000) > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 day))
GROUP BY YEAR, MONTH, DAY
ORDER BY `YEAR` DESC, `MONTH` ASC, DAY DESC

yields me the result shown in the picture.
is there a way to count in the missing values?
missing values would be
2023 | 1 | 8 | 0 (sunday)
and
2023 | 1 | 7 | 0 (saturday)

#

what I want are the results of the current week
so let's say if it's thursday, I would get all the days below (wednesday, tuesday, monday) and above friday, saturday sunday (which would return 0 for play_ticks)

dense drift
#

If you count the amount of rows, you can do a SELECT COUNT(*) FROM .. (or something similar)
or

int size =0;
if (rs != null) 
{
  rs.last();    // moves cursor to the last row
  size = rs.getRow(); // get row id 
}```
river solstice
#

I mean it would probably be easier to modify the data I need in the backend

#

I might as well select day-of-week and do the do in the backend

#

also, is there a way for me not to repeat the same
FROM_UNIXTIME(ROUND('join_time'/1000))?

#

I tried selecting is as something and reuse it, but it doesn't work like that I suppose

south brook
#

Hi guys, just wondering, is there an API to integrate deluxe menu with my plugins?

shell moon
#

wdym by "integrate deluxe menu with your plugins"?

south brook
#

I would like to let the users define the GUI through deluxe menu and then uses some event provided by deluxe menu to populate a gui and intercept some clicks

mortal scaffold
#

i have a code for having an item in inventory, and if there is then boolean a = true, but for some reason it always evaluates to true, how can i fix this?

https://pastebin.com/ya4Tahi3

stuck hearth
#

When would the amount of items in a stack be 0

mortal scaffold
# stuck hearth When would the amount of items in a stack be 0
    public boolean checkItems(Player player, Material material, int numItems, boolean a) {
        PlayerInventory inv = player.getInventory();
        for (int i = 0; i < inv.getSize(); i++) {
            ItemStack itemStack = inv.getItem(i);
            if (itemStack == null) {
                return true;
            }
            if (itemStack.getType() == material) {
                int numStack = itemStack.getAmount();
                if (numStack >= 1) {
                    return a = true;
                }
                if (numStack == 0)
                    return a = false; // numStack == 0
            }
        }
        return false;
    }

i have a checking amount of items == 0, but i's not working

stuck hearth
#

I saw that, but when would the amount be 0

#

What conditions in-game happen for a stack to have 0 items

mortal scaffold
#

in inventory

#

@stuck hearthcheck DM

dense drift
stuck hearth
# mortal scaffold in inventory

If you have a cobblestone block in your inventory and you drop it, you no longer have cobblestone.
Your code checks if there's a stack of 0, which doesn't make sense.
If there's a stack of 0, there is no item so the itemstack should return null, which is already an early return in your current code.

mortal scaffold
south brook
#

I assume that there isn't any API for deluxeMenu

stuck hearth
#

Kenuna is RUS if anyone knows how to better assist them/has more time

hoary scarab
lyric gyro
#

Hey, so I've made a function which registers every command automatically, gets the name, aliases, description, etc.. but when I add the plugin to my plugins folder, i get this message: ```
[16:41:03 ERROR]: Could not load 'plugins\coffin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml

#

But I do have a plugin.yml

stuck hearth
#

Is it packed in the jar?

lyric gyro
#

yes

#

i cant send images here

neat pierBOT
lyric gyro
#

there you can see my path in the project

stuck hearth
#

Well it's apart of the project, but is it in the jar when you build it

lyric gyro
#

yes

proud pebble
stuck hearth
frozen flax
#

Hello, I premise that I am new to java programming and just learning to program. I am trying to make a placeholder for my first plugin, the placeholder works and if I replace it in the joinmessage it works. But if I try to place it in the leaderboard or try to launch it with the command /papi bcparse I don't get the result. Could you please help me?

river solstice
#

how the hell do I get -1

#

as a list size

lyric gyro
#

I mean

#

"the list implementation returns -1 for size"

#

That's all anyone can say with just that information

river solstice
#

well, getPlayersInsideRegion returns
Map<K, List<V>>

#

and I don't have any custom implementation of it, if that's what you mean

#

it's an ArrayList

slim vortex
#

Itโ€™s probably got something to do with the region object then

lyric gyro
#

print the class names of the lists in the map

mortal scaffold
#

How can I find out if a player doesn't have an item?

    public boolean checkItems(Player player, Material material, boolean a) {
        PlayerInventory inv = player.getInventory();
        for (int i = 0; i < inv.getSize(); i++) {
            ItemStack itemStack = inv.getItem(i);
            if (itemStack == null) {
                return true;
            } else {
                if (itemStack.getType() == material) {
                    int numStack = itemStack.getAmount();

                    if (!inv.containsAtLeast(itemStack, 1)) {
                        return a = true;
                    }
                    if (p.getInventory().getType() == PLAYER && !inv.contains(material)) {
                        return a = false;
                    }
                }
            }
        }
        return a;
    }
``` Doesn't work
river solstice
#

what is this monstrocity of a code

#
public boolean hasItemType(Player player, Material material) {
    return Arrays.stream(player.getInventory().getContents()).anyMatch(i -> material.equals(i.getType());
}
#

use noneMatch - to check if does not have.

stuck hearth
#

Beautiful

river solstice
#

true

silver horizon
#

is PlaceholderAPI.setPlaceholders(player, string); threadsafe? (can i do it from an async bukkit runnable?)

icy shadow
#

depends on the placeholders

#

assume not

signal grove
#

wait... nvm most of this code is broken

#
if (!inv.containsAtLeast(itemStack, 1)) {
``` if this is a real function, isnt that what you're looking to implement?
#

actually maybe not, this probably returns true only for a very specific stack of the item

stuck hearth
#

That is not the behavior I would expect

#

d;spigot PlayerInventory#containsAtLeast

uneven lanternBOT
#
@Contract
boolean containsAtLeast(@Nullable ItemStack item, int amount)```
Description:

Checks if the inventory contains ItemStacks matching the given ItemStack whose amounts sum to at least the minimum amount specified.

Returns:

false if item is null, true if amount less than 1, true if enough ItemStacks were found to add to the given amount

Parameters:

item - the ItemStack to match against
amount - the minimum amount

signal grove
#

I think it should work for his purposes, assuming all items have the same meta

#

otherwise heโ€™ll have to do just material matching

calm loom
#

any idea why this isnt working ingame
package me.notdew.com.roboref;

import me.notdew.com.roboref.Commands.TimerCommand;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

public class ChallengeBlockListener implements Listener {

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.RED_CONCRETE) {
            Bukkit.broadcastMessage(event.getPlayer().getName() + " HAS CALLED FOR A CHALLENGE ON THE PREVIOUS PLAY!");
            TimerCommand.pauseTimer();
    }
}

}

calm loom
#

when i right click on red concrete nothing happens

proud pebble
calm loom
#

red concrete in my hand

proud pebble
#

thats why

calm loom
#

how do i make it in my hand

proud pebble
#

getClickedBlock() returns the block clicked in the world

#

player.getInventory().getItemInMainHand()

calm loom
#

so

#

if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.player.getInventory().getItemInMainHand()) == Material.RED_CONCRETE) {

#

like that?

proud pebble
#

event.getPlayer

#

so event.getPlayer().getInventory().getItemInMainHand()

signal grove
#

and

#

the Action should not be RIGHT_CLICK_BLOCK

calm loom
#

if (event.getAction() == Action.RIGHT_CLICK && event.getPlayer().getInventory().getItemInMainHand() == Material.RED_CONCRETE) { so like this?

calm loom
proud pebble
#

looks right

signal grove
#

but it should be RIGHT_CLICK and not BLOCK

calm loom
#

if (event.getAction() == Action.RIGHT_CLICK && event.getPlayer().getInventory().getItemInMainHand() == Material.RED_CONCRETE) { does this look good?

signal grove
#

hang on

proud pebble
#

RIGHT_CLICK isnt an option

calm loom
#

in intellj its saying it cant deal with the ==

proud pebble
calm loom
#

no with right click air

proud pebble
#

paste the if statement

calm loom
#

if (event.getAction() == Action.RIGHT_CLICK_AIR && event.getPlayer().getInventory().getItemInMainHand() == Material.RED_CONCRETE) {

#

it starts erroring after the &&

#

its got a red line

#

its saying the operator cant handle

signal grove
#

ah i see

proud pebble
#

your trying to compare an itemstack and material

#

after getiteminmainhand put .getType()

signal grove
calm loom
#

i just want air

signal grove
#

ok

calm loom
# signal grove ok

if (event.getAction() == Action.RIGHT_CLICK_AIR && event.getPlayer().getInventory().getItemInMainHand().getType() == Material.RED_CONCRETE) {
Bukkit.broadcastMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "" + getPlayer().getName() + " Has Called For A Challenge On The Previous Play!");

It works fine its just it says paper could u help me

#

like if i does it it says paper has called for a challenge

#

@proud pebble could u help me with dis

signal grove
#

what doesnt work

calm loom
#

instead of saying the persons name it says paper

signal grove
#

use event.getPlayer()

#

instead of just getPlayer()

lyric gyro
#

what is that getPlayer even ๐Ÿ—ฟ

calm loom
#

becuase i dont want it to broadcast to everyone

#

just in the local channel

#

@signal grove

#

but like how would i make the dependenacy for it like what link do ic ite

signal grove
#

i dont think it's complete actually

calm loom
signal grove
#

yeah, you could just use this. im honestly just guessing at half these parameters

#
Location location = player.getLocation();
float rad = 100; // radius
List<Entity> entities = location.getWorld().getNearbyEntities(location, rad, rad, rad);
for(Entity entity : entities)
  entity.sendMessage("hi"); // I don't know if entity has sendMessage, but if not just check instanceof player and cast it.
calm loom
#

how would i fit that into public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_AIR && event.getPlayer().getInventory().getItemInMainHand().getType() == Material.FLINT) {
Bukkit.broadcastMessage(ChatColor.RED + "" + ChatColor.BOLD + "" + "REFS HAVE CALLED FOR A DEAD PLAY!");

signal grove
#

you could highlight the Bukkit line and paste

calm loom
#

how do i get my chat colors back in

spiral prairie
signal grove
#

the same way they were before, you need more practice with this i think

spiral prairie
#

Do you have a basic understanding of Java / OOP?

calm loom
#

shit im sped

signal grove
#

static oriented programming >>>

calm loom
#

java.lang.NullPointerException: null
at me.notdew.com.roboref.DeadPlayListener.onPlayerInteract(DeadPlayListener.java:29) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor4.execute(Unknown Source) ~[?:?]

#

help

spiral prairie
#

not responding to pings

calm loom
#

sorry

spiral prairie
#

wait for somebody to answer when they have time

calm loom
#

k

#

java.lang.NullPointerException: null
at me.notdew.com.roboref.DeadPlayListener.onPlayerInteract(DeadPlayListener.java:29) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor4.execute(Unknown Source) ~[?:?]

proud pebble
calm loom
#

this is sepereate

proud pebble
calm loom
#

no im trying to fix the error

#

idc about that

proud pebble
#

still do what i said

calm loom
#

okay but thats not causing the error

proud pebble
#

yeah ik

calm loom
#

i wanna fix the error then ill do it

proud pebble
#

whats on line 29 then

calm loom
#

i think i edited it since so imma relaunch and make sure its still 29

proud pebble
#

you might aswell still say what was on line 29

calm loom
#

k

#

lemme grab it

#

yeah its 28 now

#

Location location = player.getLocation();

#

thats what i have

spiral prairie
calm loom
#

the color is not my concern rn

spiral prairie
#

yeah, keep it like that

calm loom
#

i can figure that out on my own

#

i just need to fix error

spiral prairie
#

and we just need the whole error

spiral prairie
#

and code?

spiral prairie
#

yeah what the fuck is that

#

do you know Java and OOP?

#

Have you learned it before going to Spigot

calm loom
#

no im being forced do somthing for an unban

#

and am having to error my way around

#

its not fun

spiral prairie
#

jeez

calm loom
#

im just trying to get it over with

spiral prairie
#

what is the thing you gotta do for an unban?

proud pebble
# spiral prairie uh no

i said to use that cus having to type of ChatColor.<color> and adding extra empty string space is just pointless and repetative when you can just use the translatecolorcpde method

calm loom
#

after this im gonna learn

spiral prairie
#

what does it do?

calm loom
proud pebble
#

its not s bad practise to use translate color code

spiral prairie
#

having ยงc is bad practice and anything related

#

or &

#

Its much better to have a clear divider between text and color changing

calm loom
spiral prairie
#

ShareX

calm loom
#

okay im guessing notnull is incorrect lol

#

what should i change to

spiral prairie
#

imma give you it

#

what you want the code to do

proud pebble
#

isnt having to write out the enum and empty quotes more of s bad practise since thats just stsntly repeating yourself

spiral prairie
#

i am a clear hater against sponfeeding but this is a loose loose situation

calm loom
#

I just want it to do the same general thing just with it not erroring lol

spiral prairie
calm loom
#

i just wanna have it say in a radius

spiral prairie
#

Repeated code is

spiral prairie
proud pebble
calm loom
spiral prairie
#

probably a dev application

calm loom
#

they want it and told everyone banned that whoever makes it gets unbanned

proud pebble
proud pebble
#

you make this, they arent unbanning you

calm loom
calm loom
spiral prairie
#

what radios do you want?

proud pebble
#

they just want free plugin dev

spiral prairie
#

i cant spell

calm loom
spiral prairie
#

you know it's radius

#

so 600 in diameter

calm loom
#

oh im stupid

#

150 then lol

spiral prairie
#

alright

calm loom
proud pebble
calm loom
#

this seems like a very contriversial topic lol

spiral prairie
#

it generally isnt

#

so im confused

spiral prairie
#

not tested

calm loom
#

i dont have radius as a dependancy

spiral prairie
calm loom
#

which radius do i want

dark garnet
#

HELLO, if i want to detect if a player is standing on a block thats green (grass), would i have to make my own list of green blocks?

spiral prairie
calm loom
spiral prairie
#

just copy my code

#

yes copy everything

calm loom
#

i did

#

i copyed all

spiral prairie
#

sorry

calm loom
dark garnet
spiral prairie
#

ChatColor.RED is much more defined than &c and thus improves readability by great lengths

#

lmao, do it xD

calm loom
spiral prairie
#

can you remove that to List and switch out List<Enitiy> to Collection<Entity>

#

i have no idea if that will work

dark garnet
spiral prairie
#

d;World#getNearbyEntity

uneven lanternBOT
#
@NotNull
Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z, @Nullable Predicate filter)```
Description:

Returns a list of entities within a bounding box centered around a Location.

This may not consider entities in currently unloaded chunks. Some implementations may impose artificial restrictions on the size of the search bounding box.

Returns:

the collection of entities near location. This will always be a non-null collection.

Parameters:

location - The center of the bounding box
x - 1/2 the size of the box along x axis
y - 1/2 the size of the box along y axis
z - 1/2 the size of the box along z axis
filter - only entities that fulfill this predicate are considered, or null to consider all entities

spiral prairie
#

there you go

#

proof

dark garnet
#

oh

#

in spigot 1.11 it returns a list

calm loom
#

can i paypal u like 5$

proud pebble
#

also if your wanting to send a message to all players ina certain radius, wouldnt it make more sense to for loop over all players and not entities

#

no point sending s message to a non player

edgy anchor
#

Quick question, which types ItemStacks cannot be serialised without being converted into a hashmap? Is there a list anywhere?

spiral prairie
#

lunaiskey is right

calm loom
#

okay what do i edit

spiral prairie
#

gime a sec

spiral prairie
proud pebble
calm loom
spiral prairie
#

jde

edgy anchor
calm loom
proud pebble
spiral prairie
#

alright

#

ill go the safe way

proud pebble
#

id assume java 8

#

seems to be the default afaik

edgy anchor
calm loom
spiral prairie
#

you replace the thing in the braces

edgy anchor
#

Certain itemstacks are not serialisable without running the .serialise method on them first, but this method is not exclusive to itemstacks that need to have that method run before being serialised, meaning I can run it on all itemstacks rather than just specific ones

spiral prairie
#

for example you want red text saying amogus!

#

ChatColor.RED + "Amogus!"

calm loom
#

and place that with a space after send message right

proud pebble
spiral prairie
#

^

proud pebble
#

since your being spoonfed the answers and you wont learn anything

spiral prairie
#

i had to blur stuff because it spit out shit

calm loom
#

ty both could i paypal both of u like 5$?

proud pebble
#

no

#

i still believe that you wont get unbanned by making this plugin

spiral prairie
#

same

calm loom
#

The Head Dev Is high ranking at sparked

#

they wouldnt do that

#

bad look for them

spiral prairie
#

well then have fun ig?

edgy anchor
#

Wait... they are trying to get themselves unbanned by making a plugin for a minecraft server?

spiral prairie
#

yeah i dont understand either

#

very scuffed

calm loom
#

its that or 400$

spiral prairie
#

and you want to be UNBANNED???

#

jesus just leave the server and

#

touch grass lmao

calm loom
#

no!

edgy anchor
#

Look, this is going to be super blunt, and probably a sound a bit mean, but I am saying this in the nicest way possible, its absolutely awesome that you are trying to learn to code, and make minecraft plugins, but if this server is of any scale they will not want you making a minecraft plugin for them, You asked everyone here how to make text a different colour, if its a public server, they want people who have experience programming, otherwise security issues and various other problems begin to wreak havoc, you would need to have some 5+ years of experience if you wanted to make a plugin good enough that a large server will want to take it

spiral prairie
#

no he isnt trying to learn

#

and the server wants to save money

calm loom
#

im trying to finish this and then learn

spiral prairie
#

good devs know what they are worth

#

ive experienced this, trust me

edgy anchor
#

@calm loom Why do you care about this server this much anyway?

calm loom
#

idk

spiral prairie
#

whats the name anyways?

proud pebble
#

once you give them the plugin they could and probably will take the plugin and run, giving no unban

spiral prairie
#

plugin and run, new us felony

edgy anchor
spiral prairie
#

thats what all p2w servers are

calm loom
#

im gonna shut up after this

spiral prairie
#

figure it out

#

google

edgy anchor
#

google it

#

if you truely want to learn, you need to find this information on your own

calm loom
spiral prairie
#

i dont have magical powers, sorry

edgy anchor
calm loom
spiral prairie
#

no that doesnt mean anything

#

figure it out

#

its not that hard to change the version

edgy anchor
#

I still dont understand why they care so much about being unbanned

spiral prairie
#

its something else pretty sure

edgy anchor
#

Likely, there must be more than we are being told

calm loom
#

im not withholding anything

edgy anchor
#

For what reason do you want to be unbanned so bad?

spiral prairie
#

good luck then

edgy anchor
#

Why did you even get banned?

neat pierBOT
#
Seems things are getting a bit off topic here.

Please either stick to the topic or move over to #off-topic

edgy anchor
#

Made me so curious

edgy anchor
spiral prairie
#

BEan Gal thinking Barry is sentient

edgy anchor
#

I dont! An admin triggered it, but it deleted their command message, so I replied to that to acknowledge

spiral prairie
#

imagine thinking Barry is sentient

neat pierBOT
edgy anchor
#

Oh, the dev has a console for it, cool!

spiral prairie
#

im dreaming

edgy lintel
tight prairie
#

Barry wyd?

dark garnet
#

HELLO, i have string with lets say ChatColor.RED + "super epic string " + ChatColor.GOLD + " wow " + ??? + " rest of string"
would what i replace ??? with to get the formatting the string had before ChatColor.GOLD was applied (so before wow)

tired olive
#

ChatColor.RED?

dark garnet
tired olive
#

otherwise you can't do it unless u use minimessage or smth

#

oh thats what u want

dark garnet
dense drift
#

Wrong channel or are you looking to make your own?

subtle onyx
#

no sorry

lethal lava
#

Hey, does anyone know how to make it so when you die you spawn with a kit?

signal grove
#

So maybe you could have a config that stores a list of commands to run on respawn

#

And the respawn event just executes them

vital drum
#

if i make my command it dont get executet

signal grove
#

are you doing the same thing as him?

vital drum
#

no

signal grove
#

what context is physically possible to gather, to answer your question then ๐Ÿ˜‚

vital drum
#

wait i send surce

#

de file```package Drache;

import commands.BankCommand;
import listtener.BankListener;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
//import listener.Inventory.DeathRespawnListener;
// import listener.Inventory.Navigator;
//import listener.Inventory.Rucksack;
//import listener.FireStick;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;

public final class de extends JavaPlugin {

public static  de INSTANCE;


public de() {
    INSTANCE = this;
}
public void getMoney(Player player){
    String money = String.valueOf(getConfig().getInt(String.valueOf(player.getUniqueId())));
    BankListener.INSTANCE.moneyinlisener(money);
}
public void Join(Player player){
    if (getConfig().isSet(String.valueOf(player.getUniqueId()))){

    } else {
        getConfig().set(String.valueOf(player.getUniqueId()), "3");
    }
}
@Override
public void onEnable() {
    // This sets the name of the item.
    // Our custom variable which we will be changing around.
}

@Override
public void onDisable() {
}
public void log(String text) {
    Bukkit.getConsoleSender().sendMessage(text);
}
private void register() {
    //listener
    PluginManager pluginManager = Bukkit.getPluginManager();
    pluginManager.registerEvents(new BankListener(3), this);
    //commands
    Bukkit.getPluginCommand("bank").setExecutor(new BankCommand());

}

}

#

Bank Listener```package listtener;

import Drache.de;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.Arrays;

public class BankListener implements Listener {
public static BankListener INSTANCE;

public BankListener() {
    INSTANCE = this;
}
public static Inventory BankGui;


public  void moneyinlisener(String money){
    BankGui.setItem(15, createGuiItem(Material.CHEST, "Current Balance: &6" + money));
}
public BankListener(int rows) {
    BankGui = Bukkit.createInventory(null, rows * 9, " ยงdBank");
    BankGui.setItem(3, createGuiItem(Material.SUNFLOWER, "&6Deposit 1"));
    BankGui.setItem(5, createGuiItem(Material.SUNFLOWER, "&6Deposit 64"));
    BankGui.setItem(7, createGuiItem(Material.SUNFLOWER, "ยง6Deposit all"));

    BankGui.setItem(20, createGuiItem(Material.SUNFLOWER, "&6Withdraw 1"));
    BankGui.setItem(22, createGuiItem(Material.SUNFLOWER, "&6Withdraw 64"));
    BankGui.setItem(24, createGuiItem(Material.SUNFLOWER, "&6Withdraw all"));
    for (int i = 0; i < 30; i++) {
        if (BankGui.getItem(i) == null) {
            BankGui.setItem(i, createGuiItem(Material.GRAY_STAINED_GLASS, ""));
        }
    }


}


protected static ItemStack createGuiItem(final Material material, final String name, final String... lore) {
    final ItemStack item = new ItemStack(material, 1);
    final ItemMeta meta = item.getItemMeta();

    // Set the name of the item
    meta.displayName(Component.text(name));
    // Set the lore of the item
    meta.setLore(Arrays.asList(lore));

    item.setItemMeta(meta);

    return item;
}


@EventHandler
public void onInventoryClick(final InventoryClickEvent e) {
    if (!e.getInventory().equals(BankGui)) return;

    e.setCancelled(true);

    final ItemStack clickedItem = e.getCurrentItem();

    // verify current item is not null
    if (clickedItem == null || clickedItem.getType().isAir()) return;

    final Player player = (Player) e.getWhoClicked();

    //Gets the slot of the clicked item
    if (e.getSlot() == 0) {
        player.performCommand("warp Spawn");
        //player.sendMessage("You clicked at slot " + e.getRawSlot());
    }

    if (e.getSlot() == 1) {
        player.performCommand("warp Vanilla");
        //player.sendMessage("You clicked at slot " + e.getRawSlot());
    }
    if (e.getSlot() == 2) {
        player.performCommand("warp Box");
    }
}
@EventHandler
public void PlayerJoin(PlayerJoinEvent event){
    Player player = event.getPlayer();
    de.INSTANCE.Join(player);
}

}```

#

Bank Command```
package commands;

import listtener.BankListener;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class BankCommand implements CommandExecutor {

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {

    Player player = (Player) sender;
    if (!(sender instanceof Player)) {
        return true;
    }
    if (player.hasPermission("bank.open")){
        player.sendMessage("[ยง4Bankยงr] ยงlยง7you have opened The Bank");
        player.openInventory(BankListener.BankGui);
    }
            return true;
        }
    }
signal grove
#

you never call register() on onEnable

vital drum
#

my name is lost

signal grove
#

what do you mean

vital drum
#

im always so lost

signal grove
#

ah, did that fix your problem though

signal grove
# vital drum im always so lost

to you can solve most problems like this by going through the chain of calls. For example,
-> does the command open the gui? (no)
-> does the command method even get called (no)
-> is the command method even registered (no - this is the problem)
and just keep going back until you find what goes wrong

neat pierBOT
vital drum
signal grove
#

there is an out of bounds exception
-> what is the size of the array
-> where it it going outside of that size

#

(hint: it's your inventory slots)

vital drum
#

inv dont have that much slots for (int i = 0; i < 30; i++) {
if (BankGui.getItem(i) == null) {
BankGui.setItem(i, createGuiItem(Material.GRAY_STAINED_GLASS, ""));
}
}

#

i must be 26

signal grove
#

yes

#

but a good practice is to use inv.length() instead of hardcoding the value (it would be 27 actually)

vital drum
#

ok

vital drum
#

it take not all and only first slot in the inventar ``` for (int i = 0; i < 36; i++) {
if (player.getInventory().getItem(i).getType() == Material.SUNFLOWER && player.getInventory().getItem(i).getLore().contains("Used to buy items from shop")) {
ItemStack coin = player.getInventory().getItem(i);
for (int j = 0; j < coin.getAmount(); j++) {
coin.setAmount(coin.getAmount() - 1);
int money = de.INSTANCE.getConfig().getInt(String.valueOf(player.getUniqueId()));
de.INSTANCE.getConfig().set(String.valueOf(player.getUniqueId()), money + 1);
de.INSTANCE.saveConfig();
}
} else if (i == 35) {
player.sendMessage("[ยง4Bankยงr]ยงlยง7 You don't have enough Coins");
}

hoary scarab
vital drum
#

danke

#

whats with the other problem?

hoary scarab
#

Whats the other problem? I only read that message.

vital drum
#

it takes only stuff out of first slot and not all stuff from first slot

#

and it dont sends the error massge

hoary scarab
#
ItemStack coin = null;
public ItemStack getCoin() {
    if(coin != null)
        return coin;

    coin = new ItemStack(Material.SUNFLOWER);
    ItemMeta coinMeta = coin.getItemMeta();
    coinMeta.setLore(Arrays.asList("Used to buy items from shop."))
    coin.setItemMeta(coinMeta);
    return coin;
}

// where you want to withdraw
ItemStack coinClone = getCoin().clone();
coinClone.setAmount(5); // Set amount you want to take

PlayerInventory playerInv = Player.getInventory();
if(playerInv.containsAtleast(coindClone, coinClone.getAmount())) {
    playerInv.removeItem(coinClone);
    de.INSTANCE.getConfig().set(String.valueOf(player.getUniqueId()), money + coinClone.getAmount());
}else {
    Player.sendMessage("Not enough funds.")
}
vital drum
#

thanks

#

how i take all

#

what should this for? ItemStack coin = (Coin item);

#

what is Coin Item (Coin item)

vital drum
#

it only takes items from first slot: ``` if (player.getInventory().containsAtLeast(coin, 1)){
int left = 1;
for (int i = 0; i < 36; i++) {
if (player.getInventory().getItem(i) == null) return;
if (player.getInventory().getItem(i).getType() == Material.SUNFLOWER){
if (player.getInventory().getItem(i).getLore().contains("Used to buy items from shop")){
player.getInventory().getItem(i).setAmount(player.getInventory().getItem(i).getAmount() - 1);
left = left - 1;
if (left == 0){
int money = de.INSTANCE.getConfig().getInt(String.valueOf(player.getUniqueId()));
de.INSTANCE.getConfig().set(String.valueOf(player.getUniqueId()), money + 1);
return;
}
}
}
}
} else {
player.sendMessage("[ยง4Bankยงr] Not enough Coins");
}

little surge
proud pebble
#

which returns an itemstack[]

#

tho they shouldnt set the amount by one, they should just do the full stack or partial stack

vital drum
#

ok

paper venture
#

i dont really know if this is the right place to ask but how do i start with server side mods for fabric? I only find guides on how to create client side mods. Or can client side mods also be installed as server mods?

lyric gyro
#

The ways to create a mod is the exact same, the only difference is that you don't use stuff that is annotated with @Environment(EnvType.CLIENT) because that is not present in the server

#

Then there are events, you will find stuff like ServerLifecycleEvents vs ClientLifecycleEvents, obvs you don't want to use the client related events

river solstice
#

I heckin love minecraft modding!!

#
[20:14:14] [Render thread/ERROR]: Error executing task on Client
java.lang.NullPointerException: Cannot invoke "net.minecraft.class_638.method_2935()" because "this.field_3699" is null

java.lang.NullPointerException: Cannot invoke "net.minecraft.class_1937.method_8469(int)" because "$$0" is null

these stacktraces are so helpful!!

#

Nothing worse than trying to update a mod from one version to another

#

nothing works anymore

#

and crashes in 3 seconds of running the client

lyric gyro
#

a) skill issue
b) there was a site that would translate stack traces to yarn mappings from intermediary though I don't remember what it was, there's also a bot in the fabric discord that tells you the yarn name from an intermediary named class/method/field, there's also that site that shows different class names for different mappings, though it's server things only I think

river solstice
#

well, considering how (usually) easy it is to update a plugin, this is legit cancer

lyric gyro
#

I mean they aren't really comparable

river solstice
#

yes

lyric gyro
#

no

#

Unless your entire plugin uses none of the API and is purely internals

river solstice
#

yes as in agree

lyric gyro
#

ah

restive vapor
#

I have a hard time trying to connect my plugin, which has it's own currency to placeholder. Anyone know how I can do this?

restive vapor
forest jay
#

Have you read the docs? It should have a full tutorial/docs for how to do so.

restive vapor
forest jay
#

You shouldn't need a economy plugin as a dependancy for papi. What does your expansion class look like?

restive vapor
forest jay
#

I would create a class for organization purposes, along with overall ease of access and easy debugging, but you can do what you are comfortable with. Your class needs to extend PlaceholderExpansion. Your IDE should give you the required methods and such for registering it. You can see a full example here, although it is a separate class, rather than on the plugin class. https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/PlaceholderExpansion#without-a-plugin

restive vapor
forest jay
#

yep

restive vapor
#

Great, but then how do I make it so for example %balance% is something that takes my balance from my plugin and if I'd like it to be in my scoreboard it works?

spiral prairie
#

btw i recommend learning java first

forest jay
#

This too lol.

spiral prairie
#

cause you'll be here for the next issue too

forest jay
#

On the example, the method onRequest(OfflinePlayer player, String params) is where it listens to the placeholder requests. You can use a switch statement or ifs to check for what the placeholder is. params is the placeholder. Depending on its value, you give a different value, which would be handled in the switch/if statement.

restive vapor
restive vapor
forest jay
#

Its all good, everyone starts somewhere. I would recommend taking a course before hand though, places like JetBrains have really good courses.

spiral prairie
#

^

proud pebble
spiral prairie
#

Cause Spigot isn't Java

#

And if you know Java principles, you'll move much faster with Spigot

proud pebble
#

it would be more like %<pluginname>_balance%

restive vapor
proud pebble
#

or whatever you put as the identifier

spiral prairie
restive vapor
forest jay
spiral prairie
#

same lmao

#

although i took like a 2 month java course after

restive vapor
#

Thank you guys a lot for the help, appreciate you all! I'll probably try and learn a little bit more Java basics now lol ๐Ÿ˜„

spiral prairie
#

but im still plagued by bad practices built into bukkit

forest jay
#

I took a class in my highschool, which was a introduction to CS, structured around Java. Even though it was a whole year long, we never covered Maps, we only covered ArrayLists, no other kind. We did 0 sorting, we didn't learn dependency management or build tools, we also learned nothing about performant/efficient code or how to test for it. I was better off watching a YouTube tutorial.

spiral prairie
#

haha yup lmao

#

although spigot was intruiging

#

cause yay plugins

forest jay
#

I primarily use my Java knowledge for spigot.

#

I don't know what else to use it for.

spiral prairie
#

i have expanded into other things like rest apis and discord bots

#

but rust is just better KEKW_laugh

proud pebble
#

ngl spigot was the only reason i actually learned java

forest jay
#

same here lol

#

I know how to make discord bots, its just that I have never had a use for one.

spiral prairie
#

i have made a pretty simple paste uploader but everything else already exists lmao

restive vapor
#

Is rust great? I've heard a lot about it

spiral prairie
#

yes

#

although im a rust noob i already love it

#

no gc, but lifetimes n stuff

forest jay
#

supposedly it is like C but without all the headaches

spiral prairie
#

yes

restive vapor
#

Maybe I should learn that instead lol

forest jay
#

What is it used for in a real world application? Is it server/backend related?

spiral prairie
#

huh?

forest jay
#

like, what would a company use Rust for?

spiral prairie
#

everything youd use C++ for

#

rest apis

#

backends

forest jay
#

Oh, interesting.

spiral prairie
#

and maybe app frontends

#

but i havent experimented with it yet

forest jay
#

I forgot that since it is related to C it is related to C++.

spiral prairie
#

its more like c++ tbh

forest jay
#

ah. I tried to learn C++, I can make a basic console game with it, but it is too complicated for me to learn atm. The learning curve ridiculous. It takes a ton of knowledge to make the simplest of applications (in my experience).

spiral prairie
#

its fine actually

#

you just need good guides

forest jay
#

I tried to learn through Code.org, but it was too slow for me.

#

It was structured for people with no experience with programming.

spiral prairie
#

i dont recommend websites for learing those languages except jetbrains

#

books are pretty good for that

forest jay
#

I just dont have money right now for courses.

#

From what I remember, the JetBrains ones were paid.

#

Although, I do have the GitHub Student Developer Pack, which includes all JetBrains IDEs, I bet it probably includes their courses as well.

spiral prairie
#

i dont think so, no

forest jay
#

oh, you'd think of all things in a student developer pack there would be programming courses

spiral prairie
#

nvm looks like it contains them

forest jay
#

From the looks of it they dont have a Rust course

spiral prairie
#

yeah sadly

proud pebble
#

you dont have to pay for a course to learn to code

spiral prairie
#

but the offical rust book is awesome

forest jay
#

The python course mentions how it is extremely popular for backend applications. From my experiences, python is a sloth compared to other programming languages (specifically C++). Wouldn't something faster be better for backend work?

forest jay
spiral prairie
forest jay
spiral prairie
#

Many people use it for data science, although I never understood its haype

#

Its so ugly

forest jay
#

yeah, I never liked it.

icy shadow
hushed badge
spiral prairie
#

jesus whats up with yall

#

youre like the boomers that are the hackers in 90s movies

#

i LiKe To UsE vIsUaL bAsIc

lyric gyro
#

why tf would you use C/C++/Rust for a REST API ๐Ÿ’€

dusky harness
#

r u sure

spiral prairie
#

im doing a not free one right now

dusky harness
#

๐Ÿ‘€

#

why didn't it show on the main page

#

>:(

#

at least for me it didn't

dusky harness
lyric gyro
spiral prairie
#

i have no idea if it will start billing me hundreds of dollars but i dont have any payment info given

dusky harness
#

theres nothing on pricing page

#

ohhhhh

#

its a trial

#

smhhh

#

3 months

spiral prairie
#

ive used mine already afaik or not?

#

idk

dusky harness
#

how long has it been?

spiral prairie
#

2 years or smh

#

idk

dusky harness
#

oh

spiral prairie
#

ah shit it is trail

#

my bad

dusky harness
#

well i guess my 3 months start now

#

ยฏ_(ใƒ„)_/ยฏ

#

i am so confused

spiral prairie
#

same

dusky harness
#

oh

spiral prairie
#

right my message lmao

#

i had used another account

#

rip

dusky harness
#

is there a better one-liner than doing new HashSet<>(Set.of(something))?

river solstice
#

YourClass.StaticMethod

#

๐Ÿค 

dusky harness
dusky harness
#

๐Ÿฅฒ

#

MUTABLE

#

A

lyric gyro
#

no

#

disregard mutability

dusky harness
#

but then i have to create a new set every time

lyric gyro
#

๐Ÿฅฑ

tired olive
#

with guava tho

#

also if u can't use guava, new HashSet<>(Arrays.asList(...)) is slightly faster

icy shadow
#

Vavr my beloved