#help-development

1 messages ยท Page 2043 of 1

tender shard
#

probably shift + the key left of backspace

grizzled pier
#

at worst: copy and paste

#

lol

spring minnow
#

XDD

spring minnow
tender shard
#

hm

muted sand
#

how do I know if methods are intensive?
looking at how many lines of code it has :kek:?
or nanoTime?

ivory sleet
#

lines wont tell u that much

muted sand
#

:(

ivory sleet
#

but I suggest benchmarking

#

which can be done in combo with unit tests

#

if you for instance use mockbukkit

#

altho if u use paper (which if i remember you do) then eventexecutors are generated by asm or sth iirc

tender shard
# spring minnow no

The basic Italian keyboard layout as shipped with Windows 7 has no way of typing the backtick (`) or the tilde (~)

#

You can use Alt + 96

ivory sleet
#

so being afraid of playermoveevent lag is the least of your concerns

grim ice
#

No

#

Well

#

Actually nvm yea

muted sand
granite owl
#

better to just go sleep for me

tender shard
#
    public static UUID getUuidFromName(final String playerName) {
        final Player player = Bukkit.getPlayerExact(playerName);
        if(player != null) return player.getUniqueId();
        final Optional<UUID> uuid = Arrays.stream(Bukkit.getOfflinePlayers()).filter(offlinePlayer -> {
            final String name = offlinePlayer.getName();
            if(name == null) return false;
            return name.equalsIgnoreCase(playerName);
        }).map(OfflinePlayer::getUniqueId).findFirst();
        return uuid.isPresent() ? uuid.get() : null;
    }

this get's the UUID without deprecated methods lol

granite owl
#

aight ty xD

#

sec lemme read trough it

tardy delta
#

is Bukkit.getOfflinePlayers and array?

granite owl
#

all players who have connected once are mapped

#

@tender shard teye ill apply that tomorrow, tbh its like 4-5 years ago since ive worked with the bukkit/spigot api

tall dragon
verbal mauve
#

do any of u guys know why @p doesnt work on my server anymore

tardy delta
#

ah thats why

verbal mauve
#

been trying to get around the issue but i cant have players teleport to towns with command blocks now and idk if theres a plugin to make @p @r and all that work

tender shard
desert musk
#

can you block the "respawn point set" message or messages like it using a plugin

grim ice
#

give lib ideas

maiden thicket
#

ez

desert musk
grim ice
maiden thicket
tender shard
maiden thicket
#

u can put null

#

in the parameter

tender shard
#

oh I thought they were using guava's optionals

maiden thicket
#

oh lol

#

no stream returns java optionals

tender shard
#

in guava somehow null is not allowed in orElse lol

maiden thicket
#

yeah i dont use guava except for things i cant remember right now

#

oh right

#

guava comes with Maps and Lists

#

iirc

tender shard
#

yeah I was confused because I always use Enums.getIfPresent, and that doesn't accept null

maiden thicket
#

ah yeah

#

i think for enums i check using apache commons io

#

its like EnumUtils.isValidEnum

tender shard
quaint mantle
#

your website looks cool

#

imma build this in rust

#

ooohh

#

html builder in rust

#

htmlrs

grim ice
#

i suck at making websites

#

idk html or css or js or python

quaint mantle
#

same

lean gull
#

hey so im using this tutorial [https://bukkit.fandom.com/wiki/Developing_a_World_Generator_Plugin] to learn world gen, and in the tree populator section they said to add this method to the main custom chunk generator class:

    @Override
    public List<BlockPopulator> getDefaultPopulators(World world) {
        return Arrays.asList((BlockPopulator)new TreePopulator());
    }```so i did that, but it doesn't seem to do anything and the `BlockPopulator` is gray in my IDE
quaint mantle
grim ice
#

so i cant make a website lol

#

well php works

quaint mantle
grim ice
#

so ig i know one thing

quaint mantle
#

its redundant

grim ice
#

i rly wanna make websites and shit

#

but it seems so hard to learn 3 coding languages

#

just for front end

lean gull
#

learn it with mimo ๐Ÿ‘

#

cool app

grim ice
#

doubt

quaint mantle
#

if you learn languages with apps you're not learning anything

#

i literally learn every language with google

grim ice
#

imajin tell me

#

is it hard to learn html and css

quaint mantle
#

i learned java now i can learn any language i want to tbh

grim ice
#

and js

lean gull
river oracle
#

I learn every language by having a project and make it

quaint mantle
lean gull
#

y

grim ice
#

smh someone just make a click and drop website front end generator

tall dragon
quaint mantle
# lean gull y

not every method has a printline telling you that its being ran ๐Ÿ˜ฑ

tall dragon
#

html isnt that hard either

grim ice
#

css is doe

tall dragon
#

css is just very boring in my opinion

quaint mantle
tall dragon
#

:D

lean gull
#

i did

#

a bit too well

quaint mantle
#

does it work?

lean gull
#

does what work

quaint mantle
#

i hate being a helper sometimes

lean gull
#

i hate inpatient people sometimes

quaint mantle
#

touche

grim ice
#

Lmao

lean gull
#

checkmate

tall dragon
#

lmao

lean gull
#

:sunglas:

river oracle
#

Development isn't for everyone that's for sure.

lean gull
#

ouch

grim ice
#

stfu

quaint mantle
grim ice
#

i hate him as a whole

river oracle
#

You don't like my websit?!

grim ice
#

i dont like your existence

river oracle
#

Why

grim ice
#

Because I want to

tardy delta
#

i dont like ur mom

grim ice
#

Good

#

though I like yours uwu

river oracle
#

Fair can't please everyone

lean gull
#

guys pls im not big brain i need help

#

why no work!1!?/

tall dragon
#

๐Ÿคทโ€โ™‚๏ธ

grim ice
#

because

tardy delta
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

grim ice
#

it doesnt like you

quaint mantle
#

thats useful

grim ice
#

beg it to wowrk

lean gull
#

fourteen i already said the problem like 2 mins ago

tardy delta
#

like we dont know that

tall dragon
#

im sure at one point it will work!

lean gull
#

yes that is so big brain

river oracle
#

Don't use Google throw your router out your window and set your pc on fire

lean gull
#

y2k_ you were cool once

tender shard
#

what is the treepopulator supposed to do?

lean gull
#

make tree on world

#
    @Override
    public void populate(World world, Random random, Chunk chunk) {

        if (random.nextBoolean()) {
            int amount = random.nextInt(4) + 1;  // Amount of trees
            for (int i = 1; i < amount; i++) {
                int X = random.nextInt(15);
                int Z = random.nextInt(15);
                int Y;
                for (Y = world.getMaxHeight() - 1; chunk.getBlock(X, Y, Z).getType() == Material.AIR; Y--)
                    ; // Find the highest block of the (X,Z) coordinate chosen.
                world.generateTree(chunk.getBlock(X, Y, Z).getLocation(), TreeType.TREE); // The tree type can be changed if you want.
            }
        }
    }```
#

imma be honest idk what im doing im just copying the code from the tutorial

grim ice
#

then understand it

tender shard
#

why are you overriding the old deprecated method?

#

try to use the proper method instead

#
    public void populate(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull LimitedRegion limitedRegion) {
    }
lean gull
#

wat u mean?!?!?

#

i did proper method >:O

quaint mantle
tender shard
#

you've overridden the deprecated method

#

you should use the correct one instead

river oracle
lean gull
#

i copy paste teh thing from tutorial i know better

quaint mantle
#

@lean gull worldgen changed this update so the tutorials kinda out of date

#

@tender shard you should update it

tender shard
tender shard
lean gull
#

i know i'm gonna get ratio'd and 1 million no's but can someone teach me how to do world gen then

tender shard
#

I already told you

#

override the proper method

lean gull
#

who told me when what why

#

yeah but then i have to change the code and idk how to do that

tender shard
#

then print out some text in that method to see if it actually gets called

tender shard
#

obviously you get an instance of WorldInfo, Random, and a LimitedRegion

#

and also x,z but you can ignore that

#

and then, well, obviously you can use the LimitedRegion to change blocks

lean gull
#

btw this is not what im tryna do, i don't want to replace the main world of the server, i wanna make a customizable generator where it generates a different world than the main one with like presets and sliders and whatnot

tender shard
#

since when does discord support forms

tall dragon
#

๐Ÿคทโ€โ™‚๏ธ

tender shard
#

this is awesome

#

finally I can make people actually force to tell me the name of the plugin they opened a ticket for

tall dragon
#

does it support set answers?

#

like where u can choose from 4 answers

tender shard
#

only Text fields and paragraph fields

tall dragon
#

aw

#

still thats pretty cool

tender shard
#

well at least my ticket bot only supports text and paragraph

#

maybe discord actually supports more

hybrid spoke
#

can you spam people with it?

#

so there is no escape?

tender shard
#

haven't tried, already removed it again lol

#

I'll do some testing tomorrow then change my ticket stuff to ask some questions first

grim ice
#

so uh i wanna make a train sort of thing

#

so multiple minecarts followed by each other

#

in the front theres a player that can move all the carts with the keys (w,a,s,d)

#

any ideas?

tender shard
#

sounds complicated

#

I don't have any idea lol

desert musk
#

reasking this question for the last time: can you suppress minecraft's messages to a player such as when you right click a bed and it says "Respawn point set"

tender shard
desert musk
#

alright i see

tender shard
#

maybe you can cancel the interact event?

desert musk
#

yeah but wouldn't that disallow them from sleeping?

tender shard
#

you can make them sleep manually

desert musk
#

how's that

#

do tell me because this is something i've been trying to figure out for a while

tender shard
#

Player#sleep

desert musk
#

what does that refer to?

#

i'm new to plugins

#

oh i see what you're saying

tender shard
#

Player has a method sleep(Location, boolean)

desert musk
#

ok

#

so you cancel minecraft's default event and just make your own sleep thing

#

smart

tender shard
#

exactly

#

but I havent checked if that actually suppresses the message

#

one sec

desert musk
#

probably would

tall dragon
#

as would happen when you try to sleep at day?

desert musk
#

not when you just cancel the right-click event

tender shard
#

cancelling the event still prints a message

desert musk
#

hm

#

nvm

#

feel like this is basic enough to be a gamerule

#

bedsSetSpawn

worldly ingot
#

Should be able to cancel that instead

tender shard
#

yeah but that doesn't prevent the "Respawn point set" message

desert musk
#

but what if they don't enter it

tall dragon
#

@desert musk do you just want to remove the message?

#

or the respawn being set as well

desert musk
#

the respawn being set as well

#

but i conceded and decided that I could just hack in a way to sloppily reset the player's spawnpoint when they enter bed

#

but i want a more concise approach

worldly ingot
desert musk
#

it should be simple, right?

#

oh hell yeah

#

why couldn't i find that??

#

what magic are you using

worldly ingot
#

I don't know if that also does it when a player clicks a bed during daytime, but it might get called?

tall dragon
#

actually @desert musk u think u can use PlayerBedLeaveEvent

desert musk
#

probably

worldly ingot
tall dragon
desert musk
#

huh,

#

why would that be in leave and not enter

#

so strange

#

well thanks guys

worldly ingot
#

lol, apparently there's no setter for it either

worldly ingot
#

Oh you can

#

mbmb

#

Weirdly named

tall dragon
#

yea agreed

#

you would think that would take a location

#

and set the location instead

desert musk
#

mmm

worldly ingot
#

Based on the name yeah that's what I thought it implied heh

desert musk
#

well don't write to mojang i don't wanna have to update my plugin lol

worldly ingot
#

That'd be an us thing aPES_Laugh

desert musk
#

hehe

worldly ingot
#

It'll stay though. We like to keep compat

desert musk
#

respectable

tall dragon
dawn hazel
#

my plugin is returning an exception even though im pretty sure this shouldnt cause an NPE

        Ambiance.isMusicEnabled.putIfAbsent(e.getPlayer().getUniqueId(), true);

        Bukkit.getScheduler().runTaskLater(Ambiance.plugin, () -> {
            if (Ambiance.isMusicEnabled.get(e.getPlayer())) {
                List tracks = Ambiance.config.getStringList("Soundtracks");

                int trackCount = tracks.size();
                int soundNumber = new Random().nextInt(trackCount);

                Sound track = Sound.valueOf((String) tracks.get(soundNumber));
                String volume = Ambiance.config.getString("volume");

                e.getPlayer().playSound(e.getPlayer(), track, Float.parseFloat(volume), 1);
            }
        }, 3);
tender shard
#

what's join event line 20?

dawn hazel
#

if (Ambiance.isMusicEnabled.get(e.getPlayer())) {

tender shard
#

your hashmap doesn't contain the player

dawn hazel
#

except it should put it in the hashmap if its not there

#
Ambiance.isMusicEnabled.putIfAbsent(e.getPlayer().getUniqueId(), true);```
tender shard
#

no, you add the UUID

dawn hazel
#

hense this

tender shard
#

your hashmap contains UUIDs and not players

dawn hazel
#

i just realized

#

im big dumdum

#

forgot to put the uuid getter on it

tall dragon
#

woulnt yout ide warn you?

#

i think intellij would at least

dawn hazel
#

it does

#

but i dont always read the warnings

tall dragon
#

:D

tender shard
#

btw you can also use boolean enabled = map.computeIfAbsent

boolean enabled = map.computeIfAbsent(player.getUniqueId(), __ -> true);
#

this gets the stored value, or returns and stores true

tender shard
tall dragon
#

yee thats what i thought

tall dragon
#

always been too lazy to find out

#

actually pretty usefull

tender shard
#

yep I use that all the time for caching stuff

#

e.g. for namespacedKeys

    public static NamespacedKey getValueKey(final String name) {
        return VALUE_KEYS.computeIfAbsent(name, __ -> NamespacedKey.fromString("v:" + name));
    }```
tall dragon
#

yea, thats pretty nice actually

desert musk
#

is there a way to just return the number of achievements a player has?

#

sounds niche but

#

would be nice to put on a scoreboard

tall dragon
#

i guess u could loop all achievements and test with Player#hasAchievement

hexed hatch
#

Achievements no longer really exist, I assume you mean advancements?

low temple
#

Does anyone know how to get the durability of an itemstack? ItemStack#getDurability() is depricated and returns 1

hexed hatch
#

I know you can retrieve advancements from the Player object

desert musk
#

so there's just an individual function for each achievement? rip

#

that'll do though

desert musk
#

oh

#

lemme see

worldly ingot
#

I actually don't know if there's a way to get a list of all advancements ToadEyes

#

At least I don't recall one

hexed hatch
#

Oh

#

So it is

desert musk
#

f

hexed hatch
#

I could have sworn I had messed with advancements before

#

But it appears I am schizophrenic

desert musk
#

๐Ÿคทโ€โ™‚๏ธ

low temple
eternal night
#

wrong one

hexed hatch
#

that's entity Damageable

#

There's two Damageable interfaces

worldly ingot
#

Because realistically you'd have to do,

for (Advancement advancement : Bukkit.getAdvancements()) { // Which doesn't exist
    if (!player.getAdvancementProgress(advancement).isDone()) {
        return false;
    }
}

return true;```
low temple
worldly ingot
#

Oh, wait, there is

quaint mantle
chrome beacon
#

Ouch too slow

worldly ingot
#

Yep

tall dragon
quaint mantle
#

im better at javadoc reading than you Choco

#

get good

worldly ingot
#

There's also the Registry.ADVANCEMENT you could iterate over but the Iterator works as well

tender shard
#

you probably also have to get rid of all the Recipe "Advancements"

    public static int getAchievements(final Player player) {
        Iterator<Advancement> it = Bukkit.advancementIterator();
        int advancements = 0;
        while(it.hasNext()) {
            Advancement advancement = it.next();
            if (advancement.getKey().getKey().startsWith("recipe/")) continue;
            if (hasAdvancement(advancement, player)) advancements++;
        }
        return advancements;
    }

    private static boolean hasAdvancement(Advancement advancement, Player player) {
        return player.getAdvancementProgress(advancement).isDone();
    }```
worldly ingot
#

+1

hexed hatch
worldly ingot
#

Well, advancements aren't really stored like that. Only their progress is

#

So a player has all advancements on the server, but what's stored is how far they've progressed in it

hexed hatch
#

Yeah I feel like if it were that simple, there would have already been a method for it

desert musk
#

right

#

alright

inland warren
#

Hey, this might be a dumb question, but anyone knows why this isn't working?

#

NBTEditor isn't working at all.

eternal night
#

sounds like you are not properly including whatever library that comes from

tender shard
inland warren
worldly ingot
#

Or... directly on the classpath

#

*shivers*

tender shard
inland warren
#

Do I need to download it?

tender shard
#

there is no such thing as NBTEditor in bukkit

inland warren
#

bruh thats why then

tender shard
#

what do you need it for?

#

chances are high that you can use PDC instead, which is builtin since 1.14.1

inland warren
#

I'm in 1.12.2

tender shard
#

RIP then

inland warren
#

where can I get it?

chrome beacon
#

You mean how to update???

tall dragon
#

depends on what lib its from

chrome beacon
#

Ah yeah the NBTEditor class

tender shard
#

whoa

#

noteblockAPI is using java 7

#

now that's something I haven't seen in a long time

#

RIP lambdas

#

RIP everything

chrome beacon
#

Well so was Minecraft for a while

#

Like until 1.12 iirc

tall dragon
#

because it doesnt work like that

tender shard
#

it does work but you also have to set back the changed itemmeta to the item

tall dragon
#

getItemMeta() returns a clone iirc

#

that doesnt matter

tender shard
#
ItemMeta meta = itemStack.getItemMeta();
// change your meta
itemStack.setItemMeta(meta);
clever silo
#

Hey guys, what's the right way to use external libraries in your plugin? Specifically, I'm trying to use Apache Cayenne ORM for persisting my data, but its dependency injection mechanism fails when I try to initialize it and execute a sample insert query. I do this in my onEnable hook. It's weird because everything works fine when I try and execute the plugin's jar through the main method, so it must be some runtime quirk of Spigot. I'm using maven-shadow-plugin to package deps into my jar. It seems that, somehow, the initialization code for the DI system is not executed and it has no instances to provide...

ember estuary
ember estuary
#

wtf why

#

thats so weird

#

weird design decision, i dont think any experienced developer would expect that method to return a copy

tender shard
ember estuary
#

true lol

tender shard
#

I think the reason is that

#

an ItemMeta object doesn't exist

#

it simply wraps around the NBT stuff etc

#

so it gets created once you need one

#

I guess

ember estuary
#

ah i see, that makes sense

tender shard
#

this for example is the setItemMeta method

ember estuary
#

i see, yeah

#

now it makes sense, thank you

tender shard
#

np ๐Ÿ™‚

quaint mantle
#

just a &ItemMeta

tender shard
#

what does & do

quaint mantle
#

because you cant turn a reference mutable

#

& = reference

tender shard
#

rusty

#

someone should write a rust compiler written in C called Crust

eternal night
#

I mean, java could also just return a mutable reference

quaint mantle
#
struct Food {
    amount: usize
}

fn consume(food: Food) {
    // this function now owns `food`
}

fn main() {
    let food = Food { amount: 5 };
    consume(food);
    println!("{}", food.amount); // ERROR!
}
#

i wish someone taught it to me like this

tender shard
#

this is all I can do in rust

fn main() {
    println!("Hello, md_5!");
}
tender shard
echo sentinel
#

Hi, I don't have much experience with spigot programming, but I made some plugins to spigiot, but I see that above version 1.18 the way you download spigots has changed, now you do it with buildTools, and I do not know how to do it. I did java -jar BuildTools.jar --rev 1.18.2, and I got file spigot-1.18.2.jar but I can't make plugin with this jar, this jar contains only 1 folder: org\bukkit\craftbukkit\bootstrap. So how I download jar that I can make plugin with.

quaint mantle
#

you dont need it

#

are you using maven

echo sentinel
#

I am using gitbash and BuildTools

clever silo
#

Right way to use external libs?

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

tender shard
#

do you actually need any NMS code?

#

I guess you're not using maven or gradle, right?

echo sentinel
#

yes I am not, as I told I am not that experienced programmer and I don't know why I would need to use those

tender shard
#

but sure, you don't have to do that, you can also use the proper "spigot-api-VERSION-shaded.jar" file

tender shard
#

because I'm so bright

echo sentinel
#

ok thanks I will look up that

warped shell
#

Im about to go crazy, I created a hashmap but when I try to do anything to it, it just errors out and says its null. Ive been using hashmaps for so long so maybe somthing is gettiing past me but Im going nuts trying to figure this out Please somone help.

tender shard
#

?paste the stacktrace

undone axleBOT
warped shell
#

its a null pointer exception ik

#

but i have no clue why

#

i just tried hashmap.put(.....)

#

and bam error

echo sentinel
#

@tender shard I have one more question, Where do I get 1.18.2 spigot jar for making server from?

tender shard
echo sentinel
#

but can this file be used to make server, or do I have to use 1.18.2-R0.1-SNAPSHOT

tender shard
#

use the file that's called "spigot-1.18.2.jar" and is about 66mb in size

#

that's the one you can use to run a server

echo sentinel
#

ok thanks

warped shell
#

was trying to make multiple hashmaps in one statement

#

didnt realize that doesnt work

tender shard
#

no that doesn't work

#
Object a, b = new Object();
// a is still null
#

what the?? Vector is a List?!

quaint mantle
#

in c++ its vec

tender shard
#

I always thought java.util.Vector was a math-like vector lmao

#

but it's actually a weird arraylist like thing

worldly ingot
#

Yeah it's a List. One of the older collections in the stdlib

#

iirc this was pre-Collections API

#

Though tbh, well-established libraries like JOML are pretty standard now for things like matrix and vector math in Java

quaint mantle
#

oh

#

thought we were talking about rust ๐Ÿฅฒ

tender shard
#

wow wtf

#

<> is actually called "diamond type inference operator"

echo basalt
#

Gotta love miss-importing the wrong vector

tender shard
#

whoa who knew that this is valid syntax?

Rocket<String> rocket = hasRocket ? Rocket.<String>newInstance() : null;
#

I didn't

worldly ingot
#

In some cases it's required

tender shard
#

it looks weird to have the <> behind the dot

worldly ingot
#

iirc there are some oddities with ImmutableMap builders from Guava

#

Where a type operator is required to specify key/value types

#

In fact...

#

If those types weren't there, it would throw a compile error

tender shard
#

this hurts my eyes lol

#

I don't like this at all

#

But I love the exception message "This is a bug."

worldly ingot
#

It's needed when the types aren't known on the called method ;p

#

Static method, declares types K and V, but no args to help imply what K or V is

tender shard
#

yeah makes sense

worldly ingot
#

very weird to read though, I agree lol

#

Just wait until you learn that this is valid as well,

public final class Main {

    {
        this.print("Hello!");
    }

    public void print(Main this, String message) {
        System.out.println(this.getClass().getName() + ": " + message);
    }

}```
tall dragon
#

does any1 know if its possible to show a fake beacon beam at a specific location?

worldly ingot
#

Not to my knowledge. That's calculated by the client last I recall

tall dragon
#

i saw a server do it once im pretty sure

#

but maybe with packets

#

since it was player specific too

worldly ingot
#

If there is a packet for it, I'm unfamiliar with it

young knoll
worldly ingot
#

Yes

#

So you can annotate it

#

akin to Python's self that needs to be declared in every single method definition. It doesn't imply. Java does

young knoll
#

Canโ€™t you also declare arrays in some weird ways

#

Like public int numbers[];

worldly ingot
#

Yeah that's valid afaik, though that's just a preference thing

#

C style

#

You can also do jagged arrays. private final int[][] array = new int[3][];

#

Java has some nice oddity features that rarely get used PES_Hypers

young knoll
#

Wait how does that work

worldly ingot
#

It's an array of variable-sized arrays

#
private final int[][] array = {
    new int[] { 1, 2, 3 },
    new int[] { 4, 5, 6, 7, 8, 9 },
    new int[] { 10 },
};```
#

If that's any help

young knoll
#

I see, so you donโ€™t have to define the size of the second array

worldly ingot
#

Mhmm

quaint mantle
#

or

#
let rocket = if has_rocket { Some(Rocket::<String>::new()) } else { None };
weary mulch
#

Hi looking to hired a Minecraft developer to create a tokenization project.

young knoll
#

?services

undone axleBOT
weary mulch
weary mulch
#

oh I see

#

it's on the forums.

weary mulch
tall dragon
lavish hemlock
#

Is there a benefit to reactive programming in Spigot?

cobalt tinsel
#

i want to kill someone if he touchs water
which event will check that?

young knoll
#

Move event

cobalt tinsel
#

oh

#

thx

#

and how i check the water

young knoll
#

Check the block at the players location

#

I think there is a method for it too, but Iโ€™m not sure if itโ€™s for touching water or being underwater

worldly ingot
# lavish hemlock Is there a benefit to reactive programming in Spigot?

You mean like making use of ReactorCore? Likely not. A lot of Bukkit is designed to be operated on the primary server thread, and anything that needs to be asynchronous (like IO and whatnot) can be done with the scheduler. Bukkit doesn't really design anything around asynchronous behaviour outside of events specifically labeled as async, and even that's fairly trivial

#

Unlike Discord APIs that make use of reactive programming patterns because most operations require some query to Discord's REST API

cobalt tinsel
#

event.getPlayer().getLocation().getBlock().equals(Material.WATER);
event.getPlayer().setHealth(0);
event.getPlayer().spigot().respawn();

young knoll
#

A block will not equal a material

cobalt tinsel
#

event.getPlayer().getLocation().getBlock().equals(Block.getByName("WATER"));???

worldly ingot
#

Compare its type, not the block itself

#

getBlock().getType() == Material.WATER

quaint mantle
#

hey guis i make a gui and how can i get if a item clicked send a message?

young knoll
#

Use the InventoryClickEvent and sendMessage

night torrent
#

how would I make it so the player gets a permenant elytra upon joining the server?

quaint mantle
night torrent
#

or even give the player something upon joining

quaint mantle
night torrent
#

could i do that in on load?

quaint mantle
night torrent
#

how do i make it so a player gets something upon joining?

quaint mantle
hexed hatch
#

You clearly do not understand Java well enough to tackle this yet

quaint mantle
hexed hatch
#

but you would use an inventory event and get the meta of the item to determine what is being clicked

#

I would recommend using PDC to identify said items

subtle folio
#

better yet- inventory gui frameworks are nice

hexed hatch
#

they should probably start from scratch since they seem to have little understanding of how to approach it

#

but before that, from the questions they were asking earlier, they definitely need a better grasp on Java

muted sand
#

how do i get around 10-25 players with mockbukkit, and make them run / jump around randomly? ||the same way i do when i am bored||

theres uh

PlayerMock player = server.addPlayer();
/// then just like, something..
#

and uhm, what's generally a some good resources to perfomance benchmark?
i can use mockbukkit for simulating, and JMH? junit?

vagrant stratus
#

Sup weebs.

So, I'm trying to get a specific a specific day every year via the following

    private long computeDelayUntilNextStart() {
        LocalDateTime localNow = LocalDateTime.now();
        ZoneId currentZone = ZoneId.systemDefault();
        ZonedDateTime zonedNow = ZonedDateTime.of(localNow, currentZone);
        ZonedDateTime zonedNextTarget;
        MonthDay monthDay = holiday.getMonthDay();
        zonedNextTarget = zonedNow.withMonth(monthDay.getMonthValue()).withDayOfMonth(monthDay.getDayOfMonth())
                .withYear(zonedNow.getYear() + 1);
        Duration duration = Duration.between(zonedNow, zonedNextTarget);
        return duration.getSeconds();
    }

The issue however is... what would be the best way to get the day after without copying the method.
Just return a hash-map with both values or what? This would be used for events that should only last a single whole day

young knoll
#

So you want to return both the time stamp for the day itself and the day after

vagrant stratus
#

Yes, two different executors.
One to handle starting, one to handle stopping.
I however can't really think of a good way of handling it properly lol

young knoll
#

Canโ€™t you just return an array

vagrant stratus
#

true. I'll probably have to handle the scheduling differently in any case... hmm

#
public void startExecution() {
        Runnable startRunnable = () -> {
            // some code here, no spoilers!
            startExecution();
        };
        long delay = computeDelayUntilNextStart();
        executor.schedule(startRunnable, delay, TimeUnit.SECONDS);
    }
#

Is how I'm doing it currently ๐Ÿ˜‚

wet breach
#

localdate.plusDays(1);

#

change the one to whatever is 1 year + 1 day

#

anyways not hard to get the next day

#

or which ever day ๐Ÿ™‚

vagrant stratus
#

oof, still doesn't help with how I should handle the runnables though ๐Ÿค”

wet breach
#

well at least you don't have to repeat your code

#

which is what you asked originally

vagrant stratus
#

I guess only have the end runnable call startExecution again? ๐Ÿคทโ€โ™‚๏ธ

wet breach
#

you can have a task or runnable self cancel or self reschedule

vagrant stratus
#

oh?

wet breach
#

generally works most of the time

vagrant stratus
#

How would I go about that?

wet breach
#

anyways if a condition is met before the runnable completes or if you just want it to keep getting rescheduled you put the code to schedule the runnable initially at the end of the runnable

#

if that method is located outside of the class where that runnable is at, then you need a method in that class that is static capable of doing it

#

so that the runnable can still invoke it

vagrant stratus
#

It would all be in a single class, so that's not an issue

wet breach
#

then yeah shouldn't have any issues then

#

this is one of the few times where statics are handy

vagrant stratus
#
    private long[] computeStartAndEndDelays() {
        long[] delays = new long[2];
        LocalDateTime localNow = LocalDateTime.now();
        ZoneId currentZone = ZoneId.systemDefault();
        ZonedDateTime zonedNow = ZonedDateTime.of(localNow, currentZone);
        MonthDay monthDay = holiday.getMonthDay();
        ZonedDateTime zonedNextTarget = zonedNow.withMonth(monthDay.getMonthValue()).withDayOfMonth(monthDay.getDayOfMonth()).plusYears(1);
        delays[0] = Duration.between(zonedNow, zonedNextTarget).getSeconds();
        delays[1] = Duration.between(zonedNow, zonedNextTarget.plusDays(1)).getSeconds();
        return delays;
    }

Yea?

#

though.. that does mean it would still have to re-call the method..

wet breach
#

where is the code that schedules the runnable?

#

or is that what we are not looking at yet

vocal cloud
#

Could make yourself a pair util

#

If it's just gonna be 2 items

wet breach
#

delays[][] would work

vagrant stratus
wet breach
#

since you only have 2 items, you can do it with a single array ๐Ÿ™‚

#

well technically it is still 2, but just one object

vagrant stratus
#

i.e. once one scheduler is finished, it's re-scheduled for the next time.
The fun part however, is this is setup for a specific day only, which means starting & ending that day or at least the beginning of the next lol

#

I can easily half-ass it by breaking DRY and doing an extra method, but I wanna try to make it as clean as possible lol

wet breach
#

idk what that is

vagrant stratus
#

?

#

DRY?

#

?paste

undone axleBOT
vagrant stratus
wet breach
#

I don't follow that principle

#

it works for refactoring, but when creating something a pain to follow

#

I am of the mind set, just get it working. If you can't get it working nothing else really matters ๐Ÿ™‚

vagrant stratus
#
    private long[] computeStartAndEndDelays() {
        long[] delays = new long[2];
        LocalDateTime localNow = LocalDateTime.now();
        ZoneId currentZone = ZoneId.systemDefault();
        ZonedDateTime zonedNow = ZonedDateTime.of(localNow, currentZone);
        MonthDay monthDay = holiday.getMonthDay();
        ZonedDateTime zonedNextTarget = zonedNow.withMonth(monthDay.getMonthValue()).withDayOfMonth(monthDay.getDayOfMonth()).plusYears(1);
        delays[0] = Duration.between(zonedNow, zonedNextTarget).getSeconds();
        delays[1] = Duration.between(zonedNow, zonedNextTarget.plusDays(1)).getSeconds();
        return delays;
    }

Would be following it, however having two methods with almost the exact same code but with a .plusDays(1) breaks it

wet breach
#

so use a different api

#

there is like 5-6 different ways you could do this I believe before resorting to some outside API lol

vagrant stratus
#

I'm not resorting to an outside API though lol

#

I'm using java API

wet breach
#

I know, but Java's API isn't always nice

vagrant stratus
#

Well yea, I know this

#

I could probably find a dependency, but I don't want to add a bunch of dependencies if not needed

wet breach
#

but if this is a task that is delayed by days

#

wouldn't the code I used work without needing all the extra stuff you have?

#

I mean, not sure why the time zone even matters here, if its local anyways

vagrant stratus
#

Removing the time-zone in this case removes only two lines of code. It would still leave the need for an array lol

wet breach
#

sure, but remove everything you don't need

#

and why do you need an array anyways?

vagrant stratus
#

two delays, two different executors. One for starting & one for stopping, seeing as it's a single day thing and must end at the end of the day

wet breach
#

you don't know how many seconds in a day?

#

well I guess some people don't have it memorized

vagrant stratus
#

Meh, i could just add it to the initial delay but either way I'd still have to deal with two delays and two executors lol

wet breach
#

anyways, if you do a lot of networking and dns stuff you get accustomed to knowing how many seconds in 1-2-3 days

#

same with milliseconds

#

why do you need a delay for stopping?

#

86400000ms in a day
86400 seconds in a day

#

in case you were curious

vagrant stratus
#

What happens is a single day thing, which means it shouldn't last more than a single day. This means there'd have to be some way to stop it after said day is up

wet breach
#

idk what we are stopping

#

but you only need 1 runnable for this

vagrant stratus
#

Could be anything, in this case a specific event that should only last a single day

wet breach
#

create a condition in the runnable that would return true only when you want said runnable to stop. If condition is met, runnable cancels itself

#

in this case, compare the time

#

if the time reaches a day, stop

#

you know when you started it, and you know already with math when 1 day from that time is.

vagrant stratus
#

sure, but the Runnable runs once per specified day.
I could use a while loop, but that's a lot of pointless code execution

wet breach
#

if the runnable isn't running who cares, its not running lol

vagrant stratus
#

That my dude is a full 24 hours of non-stop loop just to check to see if it should end

wet breach
#

Why would it be looping unnecessarily?

vagrant stratus
#

If we're using a single Runnable that runs once per specified day, we'd need a loop to see when it should end

wet breach
#

you already said you want it to end when a day has elapsed

#

however I assume the task shouldn't last that long

#

so you can have 2 conditions

vagrant stratus
#

It should however, in this case it would be used for a day long event lol

#

i.e. entire day

wet breach
#

ok then....I don't see the problem

#

the runnable is going to be looping

#

anyways

vagrant stratus
#

No

#

It runs once, then sets a new delay for when it should be ran again

#

All the runnable does is handle starting the event

sharp bough
#

but still i get this

#

is Json not a thing or smth?

lavish hemlock
#

It's part of the enterprise API, you'd need to import it via your buildsystem

#

Don't use javax.json anyway

#

Use Gson

#

(you don't need to import Gson as a dependency manually either since it's a dependency of MC)

wet breach
#
ScheduledExecutorService executor = Executors.newScheduledThreadPool(2);
Future future = executor.submit(new LongRunningTask());
executor.schedule(new Runnable(){
    public void run(){
        future.cancel(true);
    }
}, 1000, TimeUnit.MILLISECONDS);
executor.shutdown();
vagrant stratus
#

Cool, however both the stop and start have to be given new delays for the next time they should be run, not shut down entirely

wet breach
#

then tweak it

vagrant stratus
#

This would be for things like birthdays and such.
So the executor has to be ran once a specified day with a way to start/stop the event without doing some loop constantly, and then re-scheduled for the same day the following year.

wet breach
#

well, unless you plan to not have the application ever quit, then you could just use a single task for that

#

otherwise, you are going to need to save the day it is supposed to run and have some function method upon load up that checks the day

vagrant stratus
#

These would be started every plugin startup

#

and I know that lol

wet breach
#

then this thing isn't really an issue

#

not sure why you are making it seem like it is harder then it really is

vagrant stratus
#

Yea?
I'd still need some way to stop it when needed, shockingly servers can run ages without being turned off

wet breach
#

true, so the easiest way is to make use of an event in the server that doesn't happen often

#

like, day night cycle, where every so often you check the day of the actual host

vagrant stratus
#

or..i just use schedulers and don't go about it in a hacky method that could result in things start/stopping at the wrong times

wet breach
#

it won't?

vagrant stratus
#

and it's still unnecessary checking, seeing as the day/night cycle would have no purpose other than this specific use case

wet breach
#

and?

#

not sure why that would be a problem

vagrant stratus
#

I don't want to do unnecessary stuff when there's a better solution

wet breach
#

solves your issue of having an unnecessary task scheduled that only runs once a year or something

vagrant stratus
#

and instead I'm doing multiple unnecessary checks a day instead ๐Ÿ™‚

wet breach
#

as if the day night cycle stops?

vagrant stratus
#

It still has to pick a specific point in the cycle to check

wet breach
#

event only gets thrown when the cycle completes

#

not hard to know what time it is for the host and have it record an offset so you are always accurate

vagrant stratus
#

Cool, every 20-ish minutes then

wet breach
#

yeah...if the code does nothing

#

it doesn't add anything o.O

young knoll
#

Thereโ€™s an event for that?

wet breach
#

you are only using the event to schedule a task because the event is predictable

vagrant stratus
#

Which is still an unnecessary check every 20-ish minutes

wet breach
vagrant stratus
#

Shockingly, that shit adds up ๐Ÿ™‚

wet breach
#

and no it does't add up

vagrant stratus
#

Yea, depending on the amount of events that specific day

wet breach
#

this isn't going to consume much resources hardly any at all

vagrant stratus
#

That's still more and more unncessary calls ๐Ÿ˜„

wet breach
#

still better then a task occupying memory and being useless the entire time

#

I guarantee you, the event is more optimal then scheduling a task or two, that do nothing except on a specified day whenever that day is

vagrant stratus
#

There could easily be 100s of checks every 20-ish minutes

wet breach
#

72

#

the check is a native call

#

since that is what Java would use

#

and adds no extra resources to it

vagrant stratus
#

Dude, the limit depends on how many events there are

wet breach
#

since your method only compares the current time with the time you want to run something, if they don't match

#

don't do anything

wet breach
#

the event doesn't get ran if someone changes the time either

#

since the way MC commands work, it rewinds time, not make it go forward

#

but that isn't really relevant because a 1 line method isn't resource intensive to begin with

vagrant stratus
#

Cool, so 72 times + however many other calls that need to be made.
Bare minimum it's still 72 unnecessary calls

wet breach
#

that don't add much to the resources, not exactly what you are worried about here o.O

young knoll
#

I still wanna know what event this is

vagrant stratus
#

I'm also doing the bare minimum currently

wet breach
#

TimeSkipEvent *

#

maybe should make a PR to add such an event lol

vagrant stratus
#

so not even possible under your idea lol

young knoll
#

Yeah Iโ€™ve used a timer to make such an event several times

#

Maybe I should do some PRs again

vagrant stratus
wet breach
young knoll
#

What exactly would that entail

wet breach
#

basically would just at certain tick intervals, throw the event because it is day or it is night

#

or full mc day completed one of those

#

I mean the server already keeps track of that so not like much needs to be added except that an event gets thrown lol

young knoll
#

Yeah full day competed should be easy

wet breach
#

since the day/night cycle is pretty regular it would just be a handed utility in the server you could use instead of scheduling stuff

#

since that event would happen at regular intervals that would be predictable ๐Ÿ™‚

young knoll
#

Yeah

#

Gotta figure out where to inject that tho

vagrant stratus
wet breach
#

could be implemented in the server where you might need to inject into

young knoll
#

True

#

Thankfully IDEs are magical and can find usage

vagrant stratus
#

guess I could just half-ass it and wait for the maybe eventual PR that's like Yo, fix this shit

young knoll
#

lol

vagrant stratus
#

Timer wouldn't really be useful in this case, unless it can be re-ran but at that point it's just a scheduled executor lol

vagrant stratus
# wet breach I mean, not sure why the time zone even matters here, if its local anyways

Use ZonedDateTime class to handle Time Zone specific calculation including Daylight Saving issues.

ZonedDateTime is an immutable representation of a date-time with a time-zone. This class stores all date and time fields, to a precision of nanoseconds, and a time-zone, with a zone offset used to handle ambiguous local date-times. For example, the value "2nd October 2007 at 13:45.30.123456789 +02:00 in the Europe/Paris time-zone" can be stored in a ZonedDateTime. 
wet breach
#

I know what it is for. Just don't think time zone matters, unless this is something the user can schedule?

vagrant stratus
#

Might allow it

wet breach
#

if this isn't something the user schedules then the time is always local to the application

vagrant stratus
#

Kinda need something that works first before allowing it to be configurable..

vagrant stratus
#

Guess I could also just reset the list of active events every day, regardless of if there's one running or not lol

#

Can't really think of a better method xD

wet breach
#

with something like this, I would probably just utilize the OS

#

linux already has a system in place for such things

#

windows does too but a bit more pain to access

#

setup a cron job while the application is alive, if its shutting down remove the cron job

vagrant stratus
#

Cool, doesn't deal with the java code...

#

I'm pretty sure you forgot that part when writing that response

wet breach
#

I didn't forget about cron jobs lol

#

most people just want something in code so I generally provide to facilitate that

vagrant stratus
#

cron jobs don't run java code afaik ๐Ÿ˜‰

wet breach
#

personally I am all for dropping out of java if there is something better while also being able to use it from java

wet breach
#

but you can make use of unix sockets however which both can access

#

for old java versions similar thing would be using memory mapped file to communicate with each other

#

with unix socket you are always listening for input

#

cron job sends input, voila you now do something

vagrant stratus
#

...so...an even hackier way

wet breach
#

it isn't an hack

vagrant stratus
#

Compared to pure java ways yes

wet breach
#

don't see why it would need to be pure java

#

just because you drop out of a language doesn't mean it is a hack

#

cron just invokes commands at specidied times, which can include bash scripts

#

bash supports using utilities to connect via a socket even unix ones

#

java supports unix sockets since Java 17

#

there is no hack in that, you didn't change how either of them work

#

all I did was identified a medium in which both could communicate with each other

#

and there is 2

#

unix sockets or memory mapped files

#

which memory mapped files are actually designed to be used by more then just the process that created it

vagrant stratus
#

(of a piece of computer code) that provides a quick but often badly designed solution to a problem, allowing the user to continue working until a better solution can be provided. It's just a hacky workaround.

wet breach
#

I don't see how it is badly designed

#

cron jobs are native to linux, its like saying lets not use cruise control in a car because you can just push the gas yourself

smoky oak
#

all temporary workarounds just become permanent at some point

vagrant stratus
#

I'd have to do extra work to support windows, and it means I'd have to test on both OS's

wet breach
#

it doesn't need to be temporary, cron job is built into linux, specifically designed to do something at a specified time

#

in this case all you need it to do, is just tell the java process hey do something

golden kelp
#

hey guys, i m trying to make a plugin which checks the version of all plugins in the server, what my current system is the user enters all the resource IDs into the plugin.yml and then execute the cmd /versionChecker checkYML and that loops through all the resource IDs, gets their latest version, their name, now the problem is, how can I get the version isntalled on the server using the plugin's name

chrome beacon
#

Spiget

vagrant stratus
#

Dude, I'd still have to make sure both work properly and properly implemented. This means checking the OS, figuring out how to do this mess with both windows & linux, and other dumb shit like macos. A lot of work just for something that should be simple

wet breach
#

on linux it is super easy

#

if you know how to use bash you can use cron jobs

#

not hard to communicate from bash to a socket

golden kelp
vagrant stratus
#

Even then I'm still stuck massively overcomplicating something that should be simple

wet breach
#

its not complicated o.O

#

I suppose its complicated if you don't know how sockets work

#

or if you never messed with memory mapped files

vagrant stratus
#

dude... compared to an executor it is complicated

#

I'm not too sure why you think this is easier than two runnables

#

lol

wet breach
#

well you are the one that wants to have this runnable hanging around consuming resources doing nothing

#

I would never use something like that

vagrant stratus
#

Sockets and having to do per-os support isn't any better ๐Ÿ™‚

golden kelp
wet breach
#

both windows and linux support scheduled events natively

#

they have them built in, the OS routinely already checks them

vagrant stratus
#

This is still something I'd have to implement different per-os, and have a socket constantly open among other dumb stuff for something that could be simple

#

not overengineered

wet breach
#

unix socket

#

this is something implemented in many programs

#

where they use unix socket or memory mapped file for timed events

#

from the OS

#

anyways, its your application ๐Ÿ™‚

#

not that I use it anyways, just this is the primary reason I don't use other people's stuff as well. I wouldn't bother holding an object for something that will happen 1 year from now

#

it is just a waste

#

you have the OS that already checks the scedule/tasks and it probably will do it more efficiently then the JVM itself

#

and you are not wasting space with a useless object for however long

vagrant stratus
wet breach
#

what resources does that socket use?

#

do you know?

#

unix socket uses up just a file descriptor

vagrant stratus
#

Still needs some way to interact with java ๐Ÿ˜‰

wet breach
#

unix sockets are implemented into Java

vagrant stratus
#

Cool, so a useless object that'll only be used a small amount of time

wet breach
#

alright, like I said, you do it your way

#

not like I use it anyways

vagrant stratus
#

and even if I were to implement it, I'd still have to do a windows equivalent. This doubles the amount of testing I have to do, even more so if I expand on functionality

quaint mantle
vagrant stratus
vagrant stratus
wet breach
golden kelp
wet breach
#

but like I said it is your thing

vagrant stratus
wet breach
#

for making a cron job?

golden kelp
# quaint mantle Can you show code?
 sender.sendMessage("Starting Search");
                ArrayList<String> resources = (ArrayList<String>) getConfig().getList("versionID.versionList");
                for (String s : resources) {
                    JSONObject info = getInfo(s);
                    if(info.containsKey("code")){
                        sender.sendMessage("Error: " + info.toString());
                        return false;
                    }
                    String latestVersion = info.get("current_version").toString();
                    String currentVersion = getInstalledVersion(info.get("title").toString());
                    if (latestVersion != currentVersion) {
                        sender.sendMessage(ChatColor.GOLD + info.get("title").toString() + " " +
                                ChatColor.GREEN + latestVersion + " | " +
                                ChatColor.RED + currentVersion);
                        sender.sendMessage(ChatColor.GOLD + info.get("title").toString() + " Link: " + getPluginLink(s));
                    } else {
                        sender.sendMessage(ChatColor.GOLD + info.get("title").toString() + " " +
                                ChatColor.GREEN + latestVersion + " | " +
                                ChatColor.GREEN + currentVersion);
                    }
                }
vagrant stratus
#

handling them java side

golden kelp
# golden kelp ```java sender.sendMessage("Starting Search"); ArrayList<String...
public JSONObject getInfo(String resourceId) {
        try {
            String sURL = "https://api.spigotmc.org/simple/0.1/index.php?action=getResource&id=" + resourceId;
            URL url = new URL(sURL);
            URLConnection request = url.openConnection();
            request.connect();
            JSONParser jp = new JSONParser();
            JSONObject root = (JSONObject) jp.parse(new InputStreamReader((InputStream) request.getContent()));
            return root;
        } catch (IOException | ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
    public String getInstalledVersion(String name) {
        return Bukkit.getPluginManager().getPlugin(name).getDescription().getVersion();
    }
    public String getPluginLink(String resourceId) {
        try {
            String sURL = "https://api.spiget.org/v2/resources/" + resourceId;
            URL url = new URL(sURL);
            URLConnection request = url.openConnection();
            request.connect();
            JSONParser jp = new JSONParser();
            JSONObject root = (JSONObject) jp.parse(new InputStreamReader((InputStream) request.getContent()));
            return ((JSONObject) root.get("file")).get("externalUrl").toString();
        } catch (IOException | ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
wet breach
#

well, not sure why you would be worried about it. You want everything pure java

#

when not all problems have to be solved with pure java

vagrant stratus
#

Maybe because that's easier than having to add support for two different operating systems and having to deal with the mess that comes with that?

worn tundra
#

Yeah ^

golden kelp
#

hey guys do u mind moving to #general or dms?

vagrant stratus
#

this still applies to my question actually lol

buoyant viper
vagrant stratus
golden kelp
vagrant stratus
buoyant viper
vagrant stratus
#

Eh, bit late now. Too much of it wouldn't be able to be moved to a thread

#

Too much context lost at this point I'm afraid

quaint mantle
buoyant viper
#

also kinda off-topic but wtf URLConnection#getContent? why not just like getInputStream, or is that introduced by HttpsURLConnection instead

golden kelp
vagrant stratus
#

and tbf @buoyant viper didn't think it was going to be this long of a convo.

golden kelp
buoyant viper
#

hmm

#

the one introduced in java 11?

golden kelp
#

yes

wet breach
vagrant stratus
#

Even then, I'd still have a complete mess for the first half of that message.

wet breach
#

what mess?

vagrant stratus
#

I have to make it work with multiple events that may or may not be the same day every year
This of course doesn't even take into account the possibility of there being events that last longer than a day

wet breach
#

they haven't changed

#

not sure how to say that more simpler

#

one year from now, odds are they still won't change

#

even in linux

vagrant stratus
#

That does not have anything to do with the part I quoted

quaint mantle
#

I would just loop the plugins and put them on a hashmap (name,version) then get the create connections to get the "latest version" and compare that to the ones in the hashmap.

vagrant stratus
#

Assuming that last part wasn't hinted at lol

#

though tbf I still have people that manage to miss big red text, so who knows anymore ๐Ÿคทโ€โ™‚๏ธ

quaint mantle
#

I was not :p I'm not that familiar with spigot/bukkit api.

vagrant stratus
#

plugin.getDescription().getVersion()

wet breach
#

proper spigot/bukkit libs don't get loaded

#

at least I don't recall they do ๐Ÿค” anyways proper libs extend BasePlugin instead of JavaPlugin

#

for those curious

vagrant stratus
#

A lot get loaded as plugins actually, e.g CMI's CMILib

#

even something like vault gets loaded as a plugin lol

vocal cloud
#

Vault does a lot though that would require being such

vagrant stratus
#

of course, however it's still a proper lib ๐Ÿ˜‰

vocal cloud
#

I get sad with my lib on the limitations of not being a plugin.

vagrant stratus
#

Make it a plugin then lol

#

just risk getting called not a proper lib by frost

#

lol

vocal cloud
#

Then I'd have to add it to the plugins folder YanSigh that's a lot of work

vagrant stratus
#

but the freedom ๐Ÿ‘€

wet breach
#

library is different from an API

vagrant stratus
#

some libraries do have to load spigot stuff though ๐Ÿ˜„

wet breach
#

yes and they can when a plugin needs it

#

said plugin would grab an instance of the library which then allows it to do such

vagrant stratus
#

or they just be a plugin and load that stuff on load that way a plugin isn't waiting for that to all be initalized

wet breach
#

The it isn't a library in that case

#

not a proper one anyways

vagrant stratus
#

Meh

wet breach
#

There is a reason BasePlugin exists still, and its for those libraries that don't require to do anything until something needs it

#

mostly for utility purposes

worn tundra
#

What's BasePlugin

wet breach
#

As the name implies, it is the Base for making a plugin

vocal cloud
#

If I can't solve it with reflection I'll make it an actual plugin

wet breach
#

the bare minimum required

worn tundra
#

Something outside of spigots api?

wet breach
#

no

worn tundra
#

Why is it not in the javadocs then

wet breach
#

It is

vocal cloud
#

?jd-s

undone axleBOT
worn tundra
#

Ah, PluginBase

vagrant stratus
wet breach
#

yeah sorry

#

I was saying it backwards

worn tundra
#

Yeah np

vocal cloud
#

Using java methods that would get it labeled as a virus on the spigot site? Check

vagrant stratus
#

:p

plain helm
#

guys how would you get doors from PlayerInteractEvent and then opening/closing it?

vocal cloud
#

How much would I be willing to bet the first google result has an answer to this. Hmmmm

plain helm
#

I googled it already bruh

#

The code I found on google doesn't work either

#

I'm not new to spigot, I always take a look on google before requesting help here

muted sand
#

I am trying to show a player an armor stand via packets, but my ide keeps saying Cannot resolve symbol 'PacketPlayOutSpawnEntityLiving'

vocal cloud
#

The getClickedBlock is null?

earnest forum
#

have u imported nms?

muted sand
earnest forum
#

what version are u on

muted sand
#

1.18.2

#

its telling me to make a param, and not showing classes to improt

earnest forum
#

how are u importing spigot

buoyant viper
#

native api support for per-player entities when?

earnest forum
#

maven?

buoyant viper
muted sand
earnest forum
#

have u imported the minecraft dependency

quiet ice
#

Cancel Event
Get clicked Block
Get BlockState
Cast to openable
Set Open to value
Apply BlockState
Do the same with the other Dior block

muted sand
#

using that weird paper thing

earnest forum
#

or just the spigot

muted sand
earnest forum
#

the nms dependency

#

not paper or spigot

#

the actual vanilla jar

muted sand
#

oh

earnest forum
#

because that has the packets

muted sand
#

i should import that then

earnest forum
#

you should

#

search up how to on gradle

#

i dont use gradle

muted sand
#

oke
thanks!

earnest forum
#

np

plain helm
#

i mean, it returns null

earnest forum
#

thats air then

plain helm
#

no, i made sure i rightclicked the door

#

gives me an error when i try to cast the clicked block to a Door

quiet ice
#

You might have been to far away

earnest forum
#

yeah

quiet ice
plain helm
#

want the full error?

worn tundra
#

Yes

quiet ice
#

Ideally yes, but the top Line suffices

plain helm
quiet ice
#

My guess ist that you casted the Block to an openable, which Resultat in a CCE

worn tundra
#

Forgot to

Door door = (Door) event.getBlock().getBlockData()

quiet ice
#

Yep, you did that

worn tundra
#

Just went to cast the block to a door

plain helm
#

and then use BlockState?

wet breach
#

yes, because then its a matter of doing door.setOpen(boolean);

quiet ice
#

Beware to apply it though

worn tundra
#

And updating the block

wet breach
#

^

plain helm
#

Alr, ty guys

wet breach
quiet ice
#

They still have

wet breach
#

I do recall there sometimes being some weird bugs with doors requiring to set the halves XD

quiet ice
#

You need to cast to bisected and get the other half that way

wet breach
#

well at least there is a way to resolve that then if such issue is encountered

worn tundra
#

Doors, beds and double chests in code are โค๏ธ๐Ÿ˜

quiet ice
#

(technically door extends bisected so the cast is Not need, but eh)

wet breach
#

well never know

#

also, at least door halves are still a thing then ๐Ÿ™‚

quiet ice
#

I don't think that there will ever be a Block larger than a block

wet breach
#

hmmm

vocal cloud
#

Not vanilla anyways kiritohehe

wet breach
#

I wonder if snow can be larger then a block

#

or if it gets stacked as two

quiet ice
#

It probably gets stacked as two

buoyant viper
#

just starts a new snow block pretty sure

quiet ice
#

Otherwise breaking the top layer would Break all layers

plain helm
#

Door door = (Door) e.getClickedBlock().getBlockData();
door.setOpen(true);
e.getClickedBlock().setBlockData(door);

#

does the block get updated like this?

wet breach
#

you would probably want its blockstate

#

to update it

plain helm
#

(I'm sorry that i'm not formatting the code correctly but EU keybard doesn't have those weird apostrophes)

#

Door door = (Door) e.getClickedBlock().getBlockData();
                             door.setOpen(true);
                            BlockState state = e.getClickedBlock().getState();
                            state.update(); ```
#

like this?

vocal cloud
#

``

buoyant viper
#

```java
code here
```

plain helm
#

ty

#

` i don't have this character

#

I'll paste it somewhere

vocal cloud
#

What keyboard doesn't have a backtick thonk

plain helm
#

mine

wet breach
plain helm
wet breach
#

almost looks like there is a second key

#

in the top left

#

by that backslash

#

but I can't tell because of how dark pic is XD

plain helm
#

|

#

this is the 2nd key on the backslash

vocal cloud
#

If you have numlock on use alt+96

wet breach
#

or do what some sane programmers do, keep a list of special characters in a file ๐Ÿ™‚

vocal cloud
plain helm