#help-development

1 messages · Page 83 of 1

flint coyote
#

and what do you wanna filter?

ornate mantle
#

TRAPDOORS TAKE 0.8125

twilit roost
#
public void flushAllWorlds(){
    NightWatch.getInstance().getLogger().warning("Flushing all worlds!");
    int outOf = getAvailableWorlds().size();
    int successful = 0;
    for(World w : getAvailableWorlds()){
        w.save();
        if(WatchUtil.deleteDirectory(w.getWorldFolder()))
            successful++;
    }
    NightWatch.getInstance().getLogger().info("Successfully flushed " + successful + " / " + outOf);
}

public static boolean deleteDirectory(File path) {
        if (path.exists()) {
            final File[] files = path.listFiles();
            for (final File file2 : files) {
                if (file2.isDirectory()) {
                    deleteDirectory(file2);
                } else {
                    file2.delete();
                }
            }
        }
        return (path.delete());
    }
ornate mantle
#

END PORTAL FRAME 0.8224

#

HEADS 0.74

#

DAYLIGHT SENSOR 0.375

flint coyote
#

ye I understand. But what are you trying to achieve? like what do you wanna do? Do you actually need those values?

ornate mantle
#

i dont even know anymore mate

flint coyote
#

💀

ornate mantle
#

intellij shows that the method is being used

#

so im guessing its important

#

plus if i remove the method the file goes from 1126 to 642

#

i think

flint coyote
#

check where it is used then?💀

ornate mantle
#

the plugin is an npc pathfinding api

#

uses A*

flint coyote
#

Ok ok I'm on my phone so I can't open the .java file. What does the huge switch method return?

ornate mantle
#

this method is used to change the npc's Y

quaint mantle
#

Hey, how can I create a sphere in Minecraft with armor stands?

ornate mantle
#

-1 if the material isnt block

#

y if full block

flint coyote
#

ok so -1 when isBlock() is false.
Next?

ornate mantle
#

y + 0.5 if slab

#

y + 0.375 if daylight sensor and so on

chrome beacon
#

So what's the goal

#

?

flint coyote
#

wait so all the 0.xxxx is hardcoded? 💀

ornate mantle
#

yes 😭

chrome beacon
#

But you're using nms??

#

actually nvm

ornate mantle
#

no way

#

fr

chrome beacon
#

Spigot has api for this 1.19

ornate mantle
#

i had no clue

chrome beacon
#

You can get the bounding box of a block

ornate mantle
#

if this works im killing myself

#

no way i tried changing each value

chrome beacon
ornate mantle
#

just when

#

oh my god

#

rope time

#

"This isn't exact"

#

LETS GOO

#

I LIVE ANOTHER DAY

#

also lemme clarify another thing

flint coyote
#

ok hear me out

#

we go full crazy

ornate mantle
#

this method isnt JUST for each block

flint coyote
#

huh

ornate mantle
#

its for each block AND EVERY ONE OF THEIR BLOCKSTATES

#

AND EVERY COORDINATE OF IT

chrome beacon
#

What is the goal here?

ornate mantle
#

change npc y level 💀

flint coyote
#

he doesn't know 💀

ornate mantle
#

ive edited the files so much intellij refuses to show me usages

flint coyote
#

I know a hacky workaround that I'd love to see implemented but it's dirty af 💀

ornate mantle
#

i do not care anymore

#

if it works i'll do it

chrome beacon
ornate mantle
#

"This isn't exact"

chrome beacon
#

Well that's because it's a box

ornate mantle
#

yeah

chrome beacon
ornate mantle
#

the workaround this maniac used

#

was hardcode each value

#

for each corner

#

for each block

#

and each one of their blockdatas

#

honestly i might as well just use citizens

errant narwhal
#

hey how to make player.setCooldown() cooldown itemstack not material?

rough drift
#

Got a better idea

ornate mantle
#

what 💀

flint coyote
#

You create a file to save all of the blocks and states and heights and also the servers version.
Then for each new version (or when file empty or whatever) you iterate all blocks and states to update the values by (now the crazy part) - spawning each block in each state and dropping a snowball on it. Then when the snowball hits the block you check it's y-Level

rough drift
#

I'll just check which chunks the player can see from that location, and send them in as ghost-chunks

chrome beacon
ornate mantle
#

fuck google and its shit fucking SEO

chrome beacon
#

Or use Citizens :p

ornate mantle
#

fucking sucks

#

stupid fucking idiot

#

this was all i needed

flint coyote
#

Will take like a minute per update (or you serve it from a database and run it with each update)

ornate mantle
#

and google decided to put this on the second fucking page

flint coyote
#

second page on google💀

ornate mantle
#

im tempted to say the n word

#

fabsi

marble copper
#

Google is best

ornate mantle
#

look at the project

flint coyote
#

no don't say nickelback

ornate mantle
#

I HATE NIGER'S

#

ECONOMIC POLICY

errant narwhal
marble copper
#

Bro is having a mental breakdown

ornate mantle
#

brother

#

the terminator project

#

it makes the npcs

#

as human as possible

#

it uses the same exact algorithm

#

this shit fucking 1.8 project uses

#

AND ITS 10X FASTER

#

PLUS ITS UPDATED

#

and the guy who made it is a youtuber

#

with yt rank on hypixel

flint coyote
ornate mantle
#

NO

#

THIS GUY

#

HAS A BRAIN

flint coyote
#

pls let it be the snowball method 💀😂

ornate mantle
#

im actually intrigued

#

how DOES this guy get the lowest block

#

ALSO

#

wanna know how good terminatorplus is

grim ice
#

so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which ill send later,
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.
the jvm args are here: https://pastebin.com/3mK9yZFf

flint coyote
#

wdym by lowrst block

#

lowest*

ornate mantle
#

look on youtube "1000 dream speedrun horsenuggets"

flint coyote
#

I'm on vacation chilling in a pool reading #help-development . I don't wanna watch a video now 😂

ornate mantle
#

he replicated dream's playstyle 💀

chrome beacon
ornate mantle
#

sadly

flint coyote
#

Happens atleast 10 times a day anyway

chrome beacon
ornate mantle
#

brother

#

packet npcs

#

dont fall to the ground naturally

chrome beacon
#

They do if you use the tick method

grim ice
#

no

#

its client side

flint coyote
#

aren't packet npcs non existent for the server? How would he use the tick method

ornate mantle
#

yes

#

packet npcs are entirely clientside

#

even citizensNPC

#

to give them gravity they get the block under the npc

flint coyote
#

ye that's easy

ornate mantle
#

and make yo

#

oh my god

#

how did i not see this

#

they take an armorstand 💀

#

make it fall 💀

#

and get its height 💀

flint coyote
#

I told you

#

snowball method💀

#

just with an armorstand

ornate mantle
#

i didnt know what that is

#

they dont make the armorstand render to the player 💀

#

so it doesnt lag you 💀

azure hawk
flint coyote
#

update your servers java version

#

or compile with an older one

azure hawk
#

im coding in 1.8.9

errant narwhal
#

is there anyway to using player.setcooldown for itemstack?

azure hawk
#

and the server java version is 8

flint coyote
#

second option then

azure hawk
#

and how?

flint coyote
#

set the compile version in maven

azure hawk
#

it is

flint coyote
#

nah 1.8

quaint mantle
#

Hey, I want to make a sphere map generator. How this works is that you can enter a string (ex. ## # # #) and it will generate the required armor stands and wrap it around a sphere. How can I do this?

flint coyote
#

the sole number changed with v11 iirc

azure hawk
flint coyote
#

before it was 1.<version>

#

make it 1.8 instead of 8 for the compiler Version

azure hawk
#

like that

flint coyote
#

ye

azure hawk
#

k

flint coyote
azure hawk
#

still the same error :/

wary harness
flint coyote
#

might have to downgrade your java version then. Install jdk8 and use it for that project

azure hawk
#

ok

#

where can i change that in intellj

quaint mantle
# wary harness you want to do what

Hey, I want to make a sphere map generator. How this works is that you can enter a string (ex. ## # # #) and it will generate the required armor stands and wrap it around a sphere. How can I do this?
I literally replied to this text anyways

flint coyote
#

make sure you actually recompiled using mvn clean package before starting to downgrade tho

chrome beacon
bold crescent
#

Thank you for the elaborate reply.

Perhaps I should call it "observer input", but I meant just working with listeners, to get a good routine in. I guess it derails into general java practices, and not spigot specific things. I was just wondering if there is a "standard" among plugins, kind of like a boiler plate. (excluding the docs and the Intelj plugin)

chrome beacon
#

Math time :)

flint coyote
misty ingot
#

plugin ideas?

alpine urchin
#

theres a forum place for those i think

#

people submit plugins they would like to see made

misty ingot
#

I refuse to go there

alpine urchin
#

ok

#

well have fun getting no response

#

asking in help development

misty ingot
#

you wouldnt get it

harsh totem
#

Hi, i want to start learning how to make mods. Should i learn fabric or forge?

young knoll
#

This is spigot

#

Anyway, I hear fabric is easier to learn

eternal oxide
#

Fabric is cleaner

reef lagoon
#

mixin is pain

harsh totem
#

Ok thx. Ik this isn't related to spigot but thx anyways

grim ice
#

so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which ill send later,
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.

well then i tried reinstalling minecraft and other things, even with the bug existing i get 2.7gb usage, but that doessnt do anything.
the jvm args are here: https://pastebin.com/3mK9yZFf

hazy parrot
tardy delta
#

check timings

hazy parrot
#

as it preallocate all ram and makes container freeze

#

if you are not using container hosting, you should do as FourteenBrush said

grim ice
#

no i dont use that

grim ice
hazy parrot
grim ice
tardy delta
#

/timings enable wait few minutes and /timings paste

grim ice
#

um this is client side

#

lol

tardy delta
#

anything about client side lag shouldnt be asked here?

grim ice
#

well where do i ask then? not many people are knowledgeable about about jvm args and such

#

except in coding servers

tardy delta
#

youre just saying your fps is dropping every sec?

grim ice
#

yes

#

not dropping tbh, it literally freezes

#

meaning its not 10 or 20 fps

#

its 1

tardy delta
#

hmm got something related where i only had 2 fps on a good gpu for a while

grim ice
#

thats why im sure its not about my pc

tardy delta
#

other servers?

grim ice
#

i tried in single player

#

same thing

#

its even in the main menu dude

tardy delta
#

did you have the thing that the animation in the main menu is stuttering?

#

hoping thats an english word

iron glade
#

jk

tardy delta
#

had it on both my gpus

tardy delta
#

got nearly the same thing then

#

but my fps didnt went back up after a sec

grim ice
#

though, i get 300 fps after it freezes

#

then boom

#

back to 1 fps

#

and its only in minecraft 1.18 and above

tardy delta
#

like this? #general message

grim ice
#

No

#

for me it like

#

the animation is silky smooth then

#

it freezes completely

#

then continue

#

then freezes

tardy delta
#

hmm sounds like a mc issue

#

1.17+ only give me problems

azure hawk
#

does anyone know how i can change my jdk in intellij

tardy delta
azure hawk
#

thx

chrome beacon
tardy delta
#

cuz they have bugs and i needed to take another one

#

like assertion errors in the C code :/

chrome beacon
#

I just replace the existing install

flint coyote
#

are you sure you are rebuilding the jar and that you are updating it on your server?

ornate mantle
#

FABSI

#

I FIGURED IT OUT

dusty niche
#

Hello! I wanted to make my armor stand's head pose match the player's pitch and yaw and this works:

armorStand.setHeadPose(new EulerAngle(Math.toRadians(playerLocation.getPitch()), 0, 0));

but I don't understand why it does. How can it be the good yaw if I don't provide it?

marble copper
#

Ok

#

I have all spigot fork who need

echo basalt
#

which passes the yaw internally

dusty niche
#

yeah but isn't the head pose independant to the armorstand's entity rotation?

echo basalt
#

it's relative

dusty niche
#

oh

#

I see

torn shuttle
#

well this is a really weird one

#

?paste

undone axleBOT
torn shuttle
dusty niche
#

ah

torn shuttle
#

how did this happen

echo basalt
#

maybe your api version is out of sync with the server?

#

like

#

if you import the server jar directly

#

will that method exist?

#

🤔

torn shuttle
#

that doesn't sound like it makes sense

echo basalt
#

yeah idk

#

it just calls unsafe internally

tulip nimbus
#

It’s been a really long time since I have and I don’t have a computer at the moment to try and code the player hiding in parallel with you test it out, I’m sorry

ornate mantle
#

how do i include a gradle module into a maven project

torn shuttle
#

guess I'll go ask them

echo basalt
#

maybe it's just not a thing on 1.17.1 🤔

torn shuttle
#

uh

#

what's an easy way to check that

#

and boy I hope that's not the case

echo basalt
#

try catch

delicate lynx
#

it doesn't exist on paper 1.17, it was added in 1.18

echo basalt
#
Multimap<Attribute, AttributeModifier> defaultModifiers = ArrayListMultimap.create();

try {
  defaultModifiers = type.getDefaultAttributeModifiers(EquipmentSlot.HAND)
} catch (NoSuchMethodError expected) {

}
#

type deal

torn shuttle
#

so I'm guessing it also wasn't on spigot back then

#

well that's a bummer

#

what did exist back then?

delicate lynx
#

actually it was added in 1.18.1

torn shuttle
#

do you have a link for a 1.17.x api page that I can check out?

delicate lynx
#

for paper or spigot?

torn shuttle
#

spigot

delicate lynx
golden turret
#

I think you can simply see how it works now

#

then apply the same on 1.17

torn shuttle
#

I'm good, I was looking at it again and I should be using the attributes from the item meta anyway

#

which did exist back then

golden turret
#

yea

#

you can

flint coyote
torn shuttle
#

hm actually should I? this is going to take some testing

#

iirc the attribute modifiers on item meta did not include the default modifiers?

golden turret
#

maybe not

#

try

#

new ItemStack(Material.DIAMOND_SWORD).getItemMeta().getAttributeModifiers()

kindred valley
#

Death or respawn event triggers first?

golden turret
#

imagine respawning before dying

kindred valley
#

Under spigot 1.10 its like that ahahahahahh

#

Not sychronized

golden turret
#

1.1

#

1.1

#

1.1

torn shuttle
#

well maybe it's just time to tell people to update

#

there's about 5% of people using this plugin on a version older than 1.18.1 anyway

golden turret
#

▶️▶️▶️▶️__1.1__◀️◀️◀️◀️

kindred valley
#

i dont want wizardlybump17 to describe his emotions

#

wizardlybump17

kindred valley
grim ice
#

i love minecraaft new versions

kindred valley
#

Slanderer

grim ice
#

a bugs generator!

#

ive encountered more bugs with the new versions than with legacy ones

kindred valley
#

There is bugs

#

Such as spawning bed without a packet

#

Spigot's own

wary harness
#

would it be possible to use class as one of data parameters in enum

#

like this

#

so XpBottleAsset and CashNoteAsset extends AssetExetnsion

tardy delta
#

private final Class<?> clazz;

wary harness
#

I would need to be able to have getter

#

so I can loop thru all values

#

of enum

#

and make instance of each class

tardy delta
#

XpBottleAsset and CashNoteAsset both extend AssetExtension?

wary harness
#

yeah

tardy delta
#

so you want a getter to get the corresponding extension?

wary harness
#

yeah

tardy delta
#

you want wan to use a function or consumer then

#

instead of Class::newInstance

marble copper
#

1.18 is sucks

#

And also 1.19

tardy delta
#

your mom sucks

eternal night
marble copper
eternal night
#

Well both probably wrong statements

wary harness
marble copper
#

Why he told my mom sucks for no reason

eternal night
#

I guess if you start throwing baseless claims out into the wild

#

others are bound to appear

marble copper
#

Ok

tardy delta
#

how dare you to summon me

marble copper
#

Your mom also sucks brush guy

tardy delta
marble copper
#

@tardy delta ur mom sucks

#

😆

ornate mantle
#

and how to spawn npc

#

and make them move in a quite goofy fashion

azure hawk
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.

quaint mantle
#

because it's trying to drop it at -200 y? it will just despawn

tardy delta
#

also dont get the world twice

azure hawk
#

yes ik

#

"?notworking"

#

but i cant describe it

#

its an error

#

that comes up

azure hawk
#

that not the point

hazy parrot
#

you are trying to get index 244 while array length is 14

hybrid spoke
# azure hawk but i cant describe it

Caused by: java.lang.IndexOutOfBoundsException: Index: 244, Size: 14 at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[?:1.8.0_212] at java.util.ArrayList.get(ArrayList.java:433) ~[?:1.8.0_212] at de.itembingo.main.randomItem(main.java:35) ~[?:?] <------------------------------------------------------------------------------ at de.itembingo.commands.TestCommand.onCommand(TestCommand.java:16) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[server.jar:git-Spigot-db6de12-18fbb24] ... 15 more

tardy delta
#

your randomItem impl doesnt work

azure hawk
hazy parrot
#

why are you using unparametized arraylist

hybrid spoke
#

yeah your arraylist is not big enough for the length of Materials

tardy delta
#

so many things wrong there

hybrid spoke
tardy delta
#

is that the itemstack constructor with an int as data?

hazy parrot
#

also looks like that constructor is deprecated

tardy delta
#

dont even have that constructor anymore

azure hawk
#

im trying to get an random string out of my config

#

but i dont know how

#

xd

#

so i tried that

#

lol

hazy parrot
tardy delta
#

save the Material::name()

hybrid spoke
#

mhm, but how did you came to the idea to use Material.values() as your bound?

hazy parrot
#

of course you would get outofindex

hazy parrot
#

as bound

tardy delta
#

and instead of instantiating a new random every time, use Random random = ThreadLocalRandom.current()

hazy parrot
#

and find different way to implement it, other then using deprecated constructor

grim ice
tardy delta
#

probably the material id ot smth

azure hawk
grim ice
#

in most cases you want to use the ThreadLocalRandom

#

not its parent

#

it allows for more uses but in this case it probably doesnt matter

hybrid spoke
#

only use Random if you need a custom seed

tardy delta
#

it has a better performance

grim ice
#

fourteen brush

#

the reason I said that

#

is because you're using the superparent of ThreadLocalRandom

hybrid spoke
tardy delta
#

thought so

hybrid spoke
#

its literally the same only that for multithreaded design you should use ThreadLocalRandom.
also ThreadLocalRandom saves the instantiation of a new Random object everytime. the only advantage Random has is the custom seed you can invoke

grim ice
#

instead of
Random random = ThreadLocalRandom.current();
you would use

ThreadLocalRandom random = ThreadLocalRandom.current();
Because
nextInt(int origin,
int bound) only exists in the class ThreadLocalRandom, not in its parent class

tardy delta
#

you dont need that?

grim ice
#

though in this case it doesn't matter, since you dont really need an origin

#

with a list that starts with 0

tardy delta
#

you need an index from 0 to size - 1

grim ice
#

however if you use the Random type, you cant specify the origin for the random number

#

itll always start from 0

azure hawk
#

im im the learning process of java and i dont know what a "superparent" is

hybrid spoke
#

there is no superparent

grim ice
#

yeah i mis typed that

tardy delta
#

then you just do random.nextInt(max) + min or smth lol

azure hawk
#

bruh

#

xd

quaint mantle
#

got a small issue, so im setting a buyPrice and a sellPrice. since a double can't be null ive made transaction handling BigDecimal. now the issue is when i get the config section SECTION#get() which should return an object it keept returning a double, class java.lang.Double cannot be cast to class java.math.BigDecimal any reason why?

tardy delta
#

its set as a double so it returns a double?

#

yaml doesnt know how to serialize a bigdeccimal

azure hawk
#

Im not getting it... How can i choose a random String out of a config stringlist

tardy delta
#

list.get(random.nextInt(list.size()))

hybrid spoke
#

-1

quaint mantle
onyx fjord
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.

quaint mantle
hazy parrot
onyx fjord
hybrid spoke
#

and its dumb

grim ice
onyx fjord
#

btw config.getString("items." + item + ".type") equals command

azure hawk
onyx fjord
#

no serializing/unserializing should happen

wary harness
#

I got small problem

onyx fjord
#

don tell me i forgor to break;

wary harness
#

multiple parameters in constructor

delicate lynx
#

there are no breaks in that switch

onyx fjord
#

shouldnt it like umm

wary harness
onyx fjord
#

end anyway? cuz that doesnt match next cases

#

or it uses last as default maybe?

#

o i can use the lambda switch

agile anvil
tardy delta
#

is that string always the same?

wary harness
#

that is id of specific object

quaint mantle
#

Hey, so, what I'm trying to do is calculate a sphere (which I already did) and wrap a map around it

#

How would I wrap something around a sphere?

tardy delta
#

meh

wary harness
#

it is part of enum and should be taken from enum

quaint mantle
#

(as in changing the color of the armor stands using a string map like # ## #)

agile anvil
tardy delta
#

first thing i may think is using a bifunction string, plugin instead and ignoring the string in some cases

#

kinda sucks

#

enum isnt ideal

wary harness
#

I think I got better solution will just put string in PlayerPointsHandler class

dim palm
#

someone got a whitelist plugin?

wary harness
#

and add getter to AssetHandler for id

agile anvil
hasty prawn
tardy delta
#

or weaken the access of the function and call the function::apply method

#

outside of the enum hmm no wont work

dim palm
hasty prawn
#

wat

#

You shouldn't have to do that

formal comet
#

Hello, i have problème with my api

hasty prawn
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

tardy delta
#

dessie beat me

quaint mantle
#

means black and space means default color

novel lodge
#

Is there an event for when the player spawns in after death?

agile anvil
hasty prawn
novel lodge
quaint mantle
#

Black is a color and space is a key

agile anvil
azure hawk
#

will this work

hasty prawn
undone axleBOT
agile anvil
tardy delta
#

please store that list as a variable lmao

#

and use the generic version of the arraylist

tardy delta
#

List<String>

quaint mantle
tardy delta
#

Full tutorial for using Generics in Java!

Generics in Java can be very confusing for beginner Java learners. Generics are one of the coolest features in Java, but the syntax may not make a lot of sense at first.

In this beginner's Java tutorial video, we'll talk about why generics exist, why they are useful, and all the ways you can use generi...

▶ Play video
formal comet
#

I created an api and I store the list of my players. When I call the list but in another plugin, the list is empty. Have you idea ?

quaint mantle
#

Why don't you use the Bukkit API to get all the players

#

Oh wait my bad

hasty prawn
quaint mantle
#

😮‍💨

formal comet
agile anvil
hasty prawn
#

Some code or a picture of what you're trying to accomplish would probably be helpful

quaint mantle
#

Okay wait a minute

agile anvil
azure hawk
tardy delta
azure hawk
#

my brain is not working

agile anvil
undone axleBOT
hasty prawn
tardy delta
#

watch the vid i sent

agile anvil
#

You'd have to understand basics of ArrayList before using them

small current
#

delete this now

#

you offended java

hazy parrot
#

array list is an generic class, look that up on google

small current
#

learn arraylists

#

yes

hybrid spoke
#

or a player

tardy delta
#

or a dog

hybrid spoke
hazy parrot
quaint mantle
hybrid spoke
#

i have 3

quaint mantle
#

i have 3 and a half

azure hawk
#

like this?

hybrid spoke
delicate lynx
#

wtf

mighty aurora
#

Question. I created a public void in my main class to process specific events(not return things just process them). I then tried to access this class from another file to use it and it says I can't access it in a static environment without making it static. Is their a way to get around this? my reference code is TimeBoundItems.setEquipmentPacketProcessor(new allEquipmentPacketProcessor()); by the way

quaint mantle
hybrid spoke
#

then i have 7 1/4

quaint mantle
#

Nice

agile anvil
tardy delta
undone axleBOT
hazy parrot
quaint mantle
#

I also have a pet goose /njk

tardy delta
#

yummy

onyx fjord
#

is there a cool method to format seconds to hours minutes and seconds but for example without saying 0 hours and shit?

#

dynamic kinda

tardy delta
#

use a Duration and handle 0 cases yourself

agile anvil
#

@hasty prawn are you a wizard ? Please explain me that sphere map image

hasty prawn
#

Oh did they DM you the same image? lol

quaint mantle
#

Yeah

#

He didn't understand the image, and since I'm not a good explainer, I thought he could ask you

hasty prawn
#

# ## defines where the color goes in the sphere, when there's a hash, it's black in the sphere, when there's a space, there's a space of color in the sphere

agile anvil
azure hawk
delicate lynx
#

that is a golden image

delicate lynx
#

why are you loading the list twice

formal comet
agile anvil
formal comet
agile anvil
#

Are you sure you haven't shade your api in the plugin ?

agile anvil
#

Include the class of api in the plugin using it

formal comet
timid jetty
#

Hey so I need to set up a scheduler for multiple instances of cooldowns, delays, and so on. I could make a jank one myself, but because each player on a server will probably have multiple instances of schedulers allocated to them, I was wondering if anyone has a well designed one or knows how to make an efficient one

waxen plinth
#

All you need is a map

timid jetty
#

lmao jk

waxen plinth
#

Map<UUID, Map<Ability, Long>>

agile anvil
tardy delta
#

dont use schedulers for cooldowns tho

timid jetty
#

alright

waxen plinth
#

What

formal comet
waxen plinth
#

You should use the scheduler for cooldowns

tardy delta
#

you should use timestamps?

#

or instants whatever

waxen plinth
#

Yes

agile anvil
waxen plinth
#

But scheduling is part of that process too, often

agile anvil
tardy delta
#

implemented my cooldowns like this

waxen plinth
tardy delta
#

then yes

#

does he want to do that 👀

waxen plinth
#

fonction

tardy delta
#

you janked my KingdomPlayer class

waxen plinth
#

Dear god

#

You need a map my friend

timid jetty
waxen plinth
#

Don't be doing O(n) lookups like that

tardy delta
#

then use a task as redempt said

glossy venture
quaint mantle
tardy delta
#

heh

quaint mantle
tardy delta
#

and whats that supposed to be?

glossy venture
#

sphere

#

ball

tardy delta
#

lmao

quaint mantle
#

# ## defines where the color goes in the sphere, when there's a hash, it's black in the sphere, when there's a space, there's a space of color in the sphere

agile anvil
#

Spherical barcode

quaint mantle
#

my mom is a sphere

tardy delta
#

im out

glossy venture
#

the image

tardy delta
#

still no context

agile anvil
tardy delta
#

?

timid jetty
#

so redempt real quick so i should use a map with schedulers

#

kk

waxen plinth
#

Be more specific

#

What's your plan

agile anvil
waxen plinth
#

No

agile anvil
#

When 0, it's done

waxen plinth
#

Don't do that

quaint mantle
#

So what I am trying to do is wrap this string containing spaces and hashtags around a sphere made with armor stands

glossy venture
tardy delta
#

create your dedicated cooldown class i'd say

agile anvil
onyx fjord
#

gud code or shit

glossy venture
#

just see if it expired using some math every time you query it

waxen plinth
glossy venture
#

if you want like a timer

quaint mantle
waxen plinth
#

StringBuilder really doesn't matter here

quaint mantle
#

Yes

waxen plinth
#

The output is small enough that it won't make a difference

timid jetty
#

so im setting up a skills plugin, where you'll have activated abilities and such, these active abilities will have things like durations, cooldowns, etc. Also need to do something like attach metadata to dropped items and players for a specified duration

onyx fjord
#

betta?

onyx fjord
quaint mantle
#

and minutes > 0?

waxen plinth
onyx fjord
#

true true

waxen plinth
#

StringJoiner is probably what you want here actually

glossy venture
# glossy venture if you want like a timer

just do smth like

class Timer {
  String name;

  Runnable run;
  int ticksLeft;
  boolean active;

  public Timer(String name, int len, Runnable run) {
    // ...
    this.active = true;
  }

  public void tick() {
    if (!active)
      return;
    ticksLeft--;
    if (ticksLeft <= 0) {
      run.run();
      active = false;
    }
  }
}
tardy delta
agile anvil
#

And use enderpeal animation to animate your cooldown

timid jetty
onyx fjord
timid jetty
#

things like ability deactivate notifications for the player

glossy venture
waxen plinth
#

Which you pass in the constructor

onyx fjord
#

delimiter means separator right?

glossy venture
waxen plinth
#

Yes

onyx fjord
#

i have invalid second check before that btw

#

so i dont think it'll fail

glossy venture
#

ye

glossy venture
#

because ur checking > 0

#

so 30 minutes will fail

#

because thats 0 hours

#

not more than 0

#

and the string will be null

onyx fjord
#

i make it a string joiner ill check if it all works

waxen plinth
#

What's the point of that when you could just schedule a delayed task

glossy venture
#

oh ye

#

shit

#

forgot about bukkit scheduler

quaint mantle
#

I meant 0 <= hours

glossy venture
#

ok

glossy venture
onyx fjord
#

😄 it works

#

final code

#

thanks yall

#

W

azure hawk
#

How can i check if the String that getting gettet out of the config is an existing Material

waxen plinth
#

What

agile anvil
#

Did you mean Material ?

onyx fjord
#

i always create items by having config options for material and shit, initialize meta and the itemstack and then add stuff to meta and connect the modified meta to original itemstack

#

i think thats how it should be done

waxen plinth
#

Why

azure hawk
waxen plinth
#

You can store an ItemStack directly in config

onyx fjord
#

how does one look?

waxen plinth
#

What

onyx fjord
#

like how would example one look in config with meta and stuff

agile anvil
# azure hawk yeah sry

Try to get a material from the string, if it exists then it's good but if not it's not valid

waxen plinth
#

Set one and find out

onyx fjord
#

i was too lazy to do all the crazy configs so i just made serializer and deserializer 😴

cerulean jasper
#

Is it easy to develop some sort of a utility that redirects all native MC crashes on Ubuntu Server (you know, the one that gets logged in Spigot.jar root folder as 233564324.log or something)

#

to folder of my

#

choosing?

waxen plinth
#

That could be a bash script

agile anvil
old cloud
azure hawk
agile anvil
tardy delta
#

^^

#

3

old cloud
#

If you use valueOf it will throw an exception if it does not exist

tardy delta
#

stupid keyboard

cerulean jasper
agile anvil
#

getMaterial will return null if not found

old cloud
# azure hawk

You can do matchMaterial(String) != null
Which will mean it exists

cerulean jasper
#

is there some sort of input where i choose that dir?

#

to spigot jar

waxen plinth
azure hawk
#

and how can i turn it into an itemstack now

cerulean jasper
#

cool! will that include crash.log? since its not the one that goes into /logs/

besides, i am using docker so I was trying to move it as soon as its generated, since when i destroy the container as soon as it crashes, i lose data 😦

#

is there any way to redirect it ever before its created?

old cloud
agile anvil
undone axleBOT
onyx fjord
waxen plinth
azure hawk
cerulean jasper
#

process. i mean

#

hmm wait

#

is there any sort of event being called on crashes?

#

but its one of those internal thingies, i think it is even above paper and spigot

#

mojang vanilla server stuff? idk

old cloud
#

Maybe you could add a shutdown hook to know when it crashes

cerulean jasper
#

hook?

#

is it some OS thing?

iron glade
#

no on a fishing rod

cerulean jasper
#

nice

old cloud
#

Yea Runtime#addShutdownHook or something

cerulean jasper
old cloud
#

It’s from Java

#

lol

tardy delta
#

lol

cerulean jasper
#

oh java

#

well might be similar problem

#

but worth a try

tardy delta
#

it will be executed when the jvm cleans up right?

cerulean jasper
#

yeah thats the question i guess

tardy delta
#

wondering what a server crash means on jvm level

#

if the jvm crashed, no shutdown hooks are guaranteed to execute

cerulean jasper
#

yeah it is not even "paper" or "spigot" crash, i assume i ran out of RAM so whole core server of minecraft died

old cloud
#

„When the JVM begins its shutdown process, it will start all registered hooks in an unspecified order. After running all hooks, the JVM will halt.“

agile anvil
tardy delta
#

System.abort lol

#

System.exit you mean

azure hawk
#

why is there an error

grim ice
azure hawk
#

in line 16

tardy delta
#

it says that its null

onyx fjord
#

1.8 im out

grim ice
#

exceit if the system security manager is null

#

itll fail

azure hawk
delicate lynx
#

1.8 user with the best java coding ever

grim ice
#

or if permission for shut down hooks

agile anvil
grim ice
#

is not on then itll fail as well

tardy delta
#

securitymanager being null :/

iron glade
azure hawk
#

that wont change anything

iron glade
#

It changes the code from not being that nooby

agile anvil
azure hawk
#

ok wait

grim ice
#

fun fact

#

u can get all the shut down hooks

#

with reflection tho

#

cuz the field is private

tardy delta
#

makes sense

grim ice
#

private static IdentityHashMap<Thread, Thread> hooks in ApplicationShutdownHooks

#

just get the keyset, and there u go its all the hooks

dim palm
#

this will work if the file doesnt contains the player uuid?

tardy delta
#

applicationshutdownhooks??

#

compare strings with .equals, not ==

#

and there is a getString

grim ice
#

java.lang.ApplicationShutdownHooks

old cloud
tardy delta
#

doesnt seem to exist for me

old cloud
dim palm
#

im new to java and spigot

iron glade
#

if it's null just return false

#

or smth

tardy delta
#

if (blablabla.getstring().equals(blablabla))

tulip nimbus
tardy delta
#

"" + uuid will transform it into a string lol

#

no need to call toString

iron glade
#

yeah u don't need to do that

#

what she's doing is fine

tulip nimbus
#

Really?

#

I didn't know that, thanks

iron glade
#

string getting concatenated

grim ice
tardy delta
#

?

azure hawk
#

why is it still returning null

grim ice
#

that will throw NPE if its null

#

reverse it.

dim palm
#

it is possible to create a section that contains the uuids instead of this?

quiet ice
#

what exactly do you wish to achieve there?

grim ice
#

don't do
config.getString().equals("something")

do:
"something".equals(config.getString())

quiet ice
#

(the answer is most likely yes either way)

grim ice
#

the last one will not throw an npe

tardy delta
#

yes yes i was saying to use getString and equals smh

grim ice
iron glade
#

can't you just do java ItemStack itemStack = Material.getMaterial(randomItem) == null ? randomItem() : newItemStack(Material.getMaterial(randomItem));

tardy delta
#

2hex always showing up to say smth and then disapearing

azure hawk
iron glade
#

Or even better

grim ice
#

that will pretty much throw an npe

tardy delta
#

"".equals(config.getString("daddy"))

iron glade
ancient plank
#

UwU

azure hawk
grim ice
#

yeah nevermind that will work

tardy delta
#

i smell alot of bad practice here

agile anvil
#

If the config su**s

grim ice
#

why a stack overflow?

agile anvil
#

If there is no valid material

iron glade
#

even shorter

return Material.getMaterial(randomItem) == null ? randomItem() : newItemStack(Material.getMaterial(randomItem));```
agile anvil
#

Infinite loop

tardy delta
median trench
#

Is there a way to get the source location (or entity if possible) of ClientboundSoundEntityPacket (PacketPlayOutSoundEntity)? I don't want to use protocollib

tardy delta
#

looks ugly asf and you dont multiple methods

azure hawk
iron glade
grim ice
#

Minesuchtiii, is the code you sent inside randomItem()

agile anvil
atomic swift
#

How can I add a path this is what I have


                                config.createSection(namespace.replace(":",""));
                                config.set(namespace.replace(":", "") + ".whitelist", true);
                                config.set(namespace.replace(":", "") + ".can-float", true);
                                config.set(namespace.replace(":", "") + ".water-collision", true);
                                List<String> comments = new ArrayList<String>();
                                comments.add("blocks:");
                                comments.add("- Material");
                                config.setComments(namespace.replace(":", ""), comments);
                                BlockLimiter.getInstance().reloadConfig();
azure hawk
#

when i type "Sussy" in the config and thats not an Material it should try a new random thingy

tulip nimbus
azure hawk
grim ice
#

@agile anvil it shouldnt throw a stackoverflow, except if the code is inside randomItem()

onyx fjord
#

why does ij still scream at me

grim ice
#

does randomItem() call getRandomItem

iron glade
grim ice
#

god this chat is so random

#

i just had to say the pun

#

LOL

#

ok anyways, what's the problem here

onyx fjord
#

In AA, with an AK, melee, finna set it like a playdate better vacate, retreat like a vacay, mayday (ayy)

azure hawk
#

i will make smth out of it later

tardy delta
#
List<String> stringList = config.getStringList("materials");
if (stringList.isEmpty()) throw new IllegalStateException("badly implemented");

Random random = ThreadLocalRandom.current();
String materialString = materialList.get(random.nextInt(stringList.size()));

Material material = Material.matchMaterial(materialString);
if (material == null) throw new IllegalStateException("badly implemented");

return new ItemStack(material);```
#

whats so difficult about it lol

flint coyote
onyx fjord
#

bruh

grim ice
tardy delta
#

fuck that looks ugly

grim ice
#

never catch a runtime exception*

onyx fjord
#

k watch this

tulip nimbus
onyx fjord
#
        if (itemMeta.getPersistentDataContainer().get(getVoucherTimeKey(), PersistentDataType.INTEGER) == null) return 0;
        return itemMeta.getPersistentDataContainer().get(getVoucherTimeKey(), PersistentDataType.INTEGER);

it still complains

flint coyote
#

I do get what he means. IntelliJ wouldn't be complaining if he did actual null checks

#

because itemMeta might be null. Are you checking that?

tulip nimbus
#

I think it would be better practice to do .contains(player.getUniqueId().toString() instead of .contains("" + player.getUniqueId()) but the execution will be the same.

onyx fjord
#

not gonna mention it being null is impossible

#

because it triggers a function that checks if itemmeta is null

azure hawk
#

why is it still returning null wtf

dim palm
# tulip nimbus Yes

i have this, how can i remove the player without removing the entire list?

iron glade
tardy delta
#

you gotta be kiddin me with that randomItem method

#

just spoonfed you

iron glade
#

nothing's gonna change when its null once

onyx fjord
iron glade
# dim palm

"Whitelist.Players." + p.getUniqueId(), null

grim ice
#

wdym

grim ice
onyx fjord
#

wdym

grim ice
#

it wouldve compiled normally

onyx fjord
#

ah

grim ice
#

and ran normally

onyx fjord
#

not very intellij

rough drift
#

Over an array, which is faster, a for-i loop or an enhanced for loop?

tardy delta
#

this chat is weird

#

more like feeding java noobs

outer river
#

hello, do you know any way to exclude 0 in the java method Random().nextInt("int") pls ?

onyx fjord
#

this is where my confusion comes from

grim ice
#

depends @rough drift

agile anvil
grim ice
#

No @agile anvil

iron glade
# grim ice ??/

If Material.matchMaterial(randomItem) is null the function is called again checking for that exact thing again

grim ice
#

that's wrong

tulip nimbus
#

oops let me format that

rough drift
#

oh wait

#

ye

grim ice
#

the enhanced for loop is a lot faster

tardy delta
onyx fjord
grim ice
#

for low iterations

flint coyote
grim ice
#

which are under 2000 or so

rough drift
#

Math.max(1, Random().nextInt())

grim ice
#

however for higher numbers of iteration, the traditional forl oop

outer river
# rough drift `+ 1`

i thought about this, but over it double hance of getting 1 then, and i dont want this

grim ice
#

is faster

agile anvil
grim ice
#

so yeah, they're never the same

#

btw i meant 2000

#

not 200

agile anvil
outer river
# flint coyote huh no

if every time it is 0, i change this to 1, then, for every 0 and 1 i got 1 si yes it double

flint coyote
#

Random#nextInt(5);
returns 0-4. Do +1 at the end and you will get 1-5. How is that double the chance?

grim ice
#

Do not use Random

agile anvil
#

Getting item 290 needs you to go through all 289 first items

grim ice
#

literally

#

use ThreadLocalRandom

#

it has an origin+bound method

outer river
grim ice
#

u would do nextInt(1, max)

#

or something like that

outer river
#

oh i see

#

yeah i'm dumb alright

#

sry

grim ice
#

plus dont use Random even in other cases

#

except if u have a custom seed

timid jetty
#

so i see in some people code they add after integers an L or a D or something, does this do anything?

tardy delta
#

what

iron glade
#

long and double

outer river
tardy delta
#

ah

agile anvil
timid jetty
#

kk

grim ice
timid jetty
#

ty

flint coyote
#

You can use random with non custom seeds if it isn't meant to be secure. Although I also use threadlocalrandom

#

But for secure randoms you should use SecureRandom anyway

agile anvil
azure hawk
#

why is it still returning null wtf

grim ice
#

oh and btw

#

@timid jetty

#

java will automatically think of 100000 as an int

#

so u would need L to tell the jvm to use it as a long

frosty tinsel
grim ice
#

as far as i remember

grim ice
frosty tinsel
#

From Java 17

flint coyote
timid jetty
#

kk ty

#

thanks for the help

agile anvil
tardy delta
#

in their onCommand

grim ice
#

No it does not. @frosty tinsel

frosty tinsel