#help-development

1 messages · Page 450 of 1

weak meteor
#

clean package

wet breach
#

Try making config yamlconfiguration instead

young knoll
#

Alright so that should move it to the root dir in the jar

wet breach
#

If refreshing doesnt work

weak meteor
#

i think.

wet breach
#

Not quite

weak meteor
#

nah i have to make all the code of loading stuff

#

ive tried it before

#

what if i build with gradle?

#

(Im in vscode, btw)

young knoll
#

Shouldn’t make a difference

weak meteor
#

it shouldnt

#

but idk

#

that code is good

wet breach
#

Are you sure npe is for config?

weak meteor
#

[21:29:01 ERROR]: Error occurred while enabling Core v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
at volt.dev.vcore.Core.onEnable(Core.java:27) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[Spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [Spigot.jar:git-Spigot-21fe707-741a1bd]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [Spigot.jar:git-Spigot-21fe707-741a1bd]

#

is the config

flint coyote
#

I guess I'll install the plugin you sent on a server to see it in action. Could you elaborate what checks you are talking about?

I'd have expected that I can simply do

"Description of the field"
<player input>

or for lists:
"Description of the list"
<player input>
<player input>
<player input>

and I'd just collect all inputs of all pages and seperate by linebreaks.
Unless I take it one step further and put all fields in one book (one field per page, unless it's a list)

icy beacon
#

I'm pretty sure this means that you don't have your command in the plugin.yml

weak meteor
#

OMG

#

IT WAS THAT

icy beacon
weak meteor
#

IM GONNA KILL MYSELF

icy beacon
#

xd

wet breach
icy beacon
#

the error would point there then

#

but there's no trace of it

wet breach
weak meteor
#

it isnt

#

yesterday i was getting the same error of npe on other plugin

#

there, appeared 3 times, in main, then class

#

i

icy beacon
#

I mean, the constructor can take null values, and if it shouldn't, it also will say that in the constructor/error

weak meteor
#

lemme try adding the commands

#

BRO

#

IT WAS THE PLUGIN.YML

icy beacon
#

gg

wet breach
flint coyote
#

that's alright, I can downgrade

wet breach
#

Also with conversation api you can add explanations etc

#

As you go through the settings

#

Which you decide is ultimately up to you of course. I just think using a book is not the best for this

flint coyote
#

Does the conversation api utilize that clickable text in chat? I don't remember how it's called.

weak meteor
#

idk i never used vscode, just better than IntelliJ idea

wet breach
#

You can use chat components with it if i recall

flint coyote
#

Chat components would be cool for going back and forward

zenith crescent
sullen marlin
#

never seen that before

zenith crescent
#

Me either, i was able to build fine on my macbook earlier

sullen marlin
#

do you have weird maven environment variables defined from a previous install?

zenith crescent
#

Not that im aware of

sullen marlin
#

type set into a command prompt and share the results

zenith crescent
sullen marlin
#

powershell maybe try Get-ChildItem Env:

zenith crescent
sullen marlin
#

hmm no idea

wet breach
#

I have always encountered problems with cmd

zenith crescent
#

Let me try it in bash, iirc i got the same error the other day but didnt have a chance to look back at it as i had to leave for work.

#

Same error

wet breach
#

You need to set the maven variable

#

Or put maven on the path

sullen marlin
#

buildtools is doing that automatically

zenith crescent
#

Where would i do that at?

wet breach
#

Try clearing buildtools directory

#

But issue seems to be with maven since it doesnt get to the actual building phase.

young knoll
#

Generally nuking everything but the buildtools jar is my first step

#

Second step is panic

wet breach
#

Lol

sullen marlin
#

your java is kind of old (2021) maybe try updating it?

worldly ingot
#

That's very rude. Maybe you're old >:(

zenith crescent
#

lol, whats the default path for buildtools? I cant find it

young knoll
#

MD and Java can both be old

sullen marlin
#

It's where you downloaded it, D:/Downloads

zenith crescent
#

that would make sense lol

#

Alright, give me a minute my downloads is still on a HDD so it takes forever

#

Alright, so iv deleted all the files i think are build tools in my downloads directory, but im still getting the same error.

wet breach
#

Try moving buildtools jar to its own directory

#

Next step would be to install maven and there is plenty of guides in how to do that

#

Anyways. Got work to do. Be back in like an hour or so

zenith crescent
sullen marlin
#

restart your pc

zenith crescent
#

I just restarted it after removing all the old version and just installing the newest, i setup my Java_Home so that should be fine, but java --version still says can not be found

sullen marlin
#

How did you install ot

#

It

zenith crescent
#

Just straight form the exe

torn shuttle
#

How do I turn a Field object from clazz.getDeclaredField into a map? It's been a hot minute since I last looked at this

sullen marlin
#

Exe from where

ivory sleet
#

field.get(instance)

sullen marlin
#

.get(

ivory sleet
#

field.get(null) if static

torn shuttle
#

instance of the object I am getting the field from right?

ivory sleet
#

Yea

torn shuttle
#

and I can just cast the output?

ivory sleet
torn shuttle
#

got it thanks

ivory sleet
#

Cheers

hushed pawn
#

Should i use netty to transfer some data?
(Between servers)

torn shuttle
#

ngl the brain logic mojang has makes me want to eat glass

lost matrix
ivory sleet
#

To setup ur own sockets between servers?

lost matrix
hushed pawn
ivory sleet
#

Anyway im gonna predict this and say u need a message queue, use sth like redis or rabbitmq

hushed pawn
#

I want to send a message to the server before connecting the player to it (something about like in what party it will appear)

ivory sleet
#

there are other alternatives but those are the most common ones around here

lost matrix
# hushed pawn project

Then i would suggest using Redis. More specifically topics.
As java framework Redisson. You can literally send data and receive data in 3 or 4 lines

lost matrix
ivory sleet
#

Yeah well if he just needs a couple of bytes sent sth minimal like Jedis is fine

#

Since redisson is a bit bigger

lost matrix
#

True

#

Getting familiar with this framework might help in the long run

ivory sleet
#

Indeed

#

Redisson is after all a popular one in terms of enterprise

hushed pawn
#

Okay thanks 👍

ivory sleet
#

Good luck

torn shuttle
#

it's called the brain class because it's going to give me a brain aneurysm in about 5 minutes

lost matrix
#

@ivory sleet have you injected a channel handler (netty) in spigot before?
Im currently a bit lost. I got a duplex handler for outgoing packets working
but i cant seem to get incoming packets to work...

torn shuttle
#

how there are no uncancelable behaviors in the brain system is beyond me

ivory sleet
#

Yeah I have done it in the past

torn shuttle
#

it's like i'm popping crazy pills

ivory sleet
#

Lol magma

young knoll
#

I think he’s having fun

torn shuttle
#

I have been on this for over a week

lost matrix
torn shuttle
#

I can't even write proper debug messages anymore

young knoll
#

So you’re ready to PR an api right?

#

🤓

torn shuttle
#

get acquainted with my shorts because you're about to huff them

lost matrix
#

Ah i just noticed the decouple method makes no sense. I need to remove my channel names ofc

ivory sleet
#

Hmm smile it looks all fine to me

#

Oh

#

But ye most of it looks correct

lost matrix
#

But when testing both duplex handler only listen to outgoing packets...

ivory sleet
#

Get the pipeline and invoke addBefore that’s how its supposed to be done

torn shuttle
#

so yeah the only way to guarantee no overriding behaviors seems to be through lobotomizing the AI for as long as you don't want to get overriden

lost matrix
#

Wait im adding both after the default encoder

#

And both the incoming and outgoing encoder name is just "packet_handler" if i interpreted that right

ivory sleet
#

yeah

#

the base name should be just that

#

Yea maybe try to use addBefore instead, also aren’t you having the same if statement twice?

#

Or am I just seeing things

lost matrix
#

One is for encoder name and the other for decoder.
In the case of bukkit, its the same

ivory sleet
#

Ah I see

torn shuttle
#

I just don't understand what mojang is thinking here

lost matrix
#

Hm and that makes both handlers be inserted after the default "packet_handler"
How is this even supposed to differentiate between incoming and outgoing packets?

torn shuttle
#

they have a brain system, why is the brain not managing activities

#

why do they have ai classes for individual mob types but still hold key parts of the AI logic in entity classes

#

how come brains are simultaneously stupidly in-depth intricate systems but also don't actually manage important aspects of behavior

ivory sleet
#

and I think u can use the same duplex handler for incoming and outgoing

torn shuttle
#

how come entities go back to idle from combat after every single hit and idle manages part but not all of the combat pathfinding

#

did the guy that came up with the module system for brains get paid by the class he wrote?

young knoll
#

Wait

#

So if you wack something in the combat stage it goes back to idle

torn shuttle
#

no

#

after every single hit they do they enter a cooldown state

#

for the duration they are in idle

#

even if they keep following you around

#

because following is idle

young knoll
#

So when they hit you they revert to idle

torn shuttle
#

attack seems to be strictly the tick they hit you on except it also has some pathfinding logic somehow and also it's a per-entity implementation because obviously no two mobs in minecraft hit you quite the same way

#

states are for losers and priorities are for nerds, the brains use both and neither work in way that makes sense

#

all the priorities seem to be the same and the states will flip in ways that are hardcoded to each entity

young knoll
#

I see why they haven’t updated the old entities

torn shuttle
#

let me bring up the wisdom of the ancients if I can find it

#

It’s important to remember that when you start from scratch there is absolutely no reason to believe that you are going to do a better job than you did the first time.

#

Joel on software april 6th 2000 on the demise of netscape navigator

ivory sleet
#

@lost matrix packet_handler might listen to both?

#

whilst encode encodes, decoder decodes (names)

#

I think

lost matrix
ivory sleet
#

So it may also terminate?

#

Hmm, yea idk much more but it wouldn’t be out of scope to think that it stops delegation

lost matrix
# ivory sleet also this (maybe?)

Yeah i found the problem. I appended my handlers after
[timeout, splitter, decompress, decoder, protocol_lib_inbound_interceptor, prepender, compress, encoder, protocol_lib_wire_packet_encoder, pe-encoder-grimac, packet_handler, DefaultChannelPipeline$TailContext#0]
the packet_handler which does not forward incoming packets. So at least the inbound listener needs to be
injected before the packet_handler

ivory sleet
#

Oh yeah that makes sense, packet handler is the final connection after all

#

👍

young knoll
#

Oh look it’s protocollib and grimac

ivory sleet
#

🥲

young knoll
#

Protocollib twice for good measure

lost matrix
ivory sleet
#

Very nice :>

torn shuttle
#

that is hilarious, mojang has a method that just throws a CME if you use it

#

it can't ever actually work

wet breach
#

Just toss synchronized in there

#

Should be fine lol

torn shuttle
#

what the hell

#

no wonder set aggressive does nothing

#

it's hardcoded to be set to aggressive on every tick

wise mesa
#

I would like to build a plug-in that uses nms and special source with maven

#

Sorry not maven

#

Already doing that just fine

#

With Jenkins

lost matrix
#

You need jenkins to run BuildTools

wise mesa
#

My initials thought was to have a job that runs build tools with —remapped

#

Okay yea so I did that

#

Works great

lost matrix
#

So that the remapped sources are in your local maven repo

wise mesa
#

But my plugin won’t build

#

Lemme send the error

#
[INFO] --- specialsource:1.2.4:remap (remap-obf) @ mcplanes ---
org.apache.maven.artifact.resolver.ArtifactNotFoundException: The following artifacts could not be resolved: org.spigotmc:minecraft-server:txt:maps-mojang:1.19-R0.1-SNAPSHOT (absent): org.spigotmc:minecraft-server:txt:maps-mojang:1.19-R0.1-SNAPSHOT was not found in https://repo.dmulloy2.net/repository/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of dmulloy2-repo has elapsed or updates are forced
lost matrix
#

Make sure that --rev is used for exactly the version you define in your pom.xml
This looks like an old version to me

wise mesa
#

That might be it

lost matrix
#

org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT should be for the latest

wise mesa
#

Ah

#

So first of all I wasn’t using rev for build tools

#

So it was probably building 1.19.3

#

But also yes my Pom was just wrong

#

Since you put the version in the special source part twice

#

I changed it in one part but not in the other

#

Alright I’ll let you know if it builds

lost matrix
#

Create a property in your pom and insert it using {}
Thats what i do when using special sources

#

In the parent pom

    <properties>
        <java.version>17</java.version>
        <spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
        <velocity.version>3.1.1</velocity.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

Then i use ${spigot.version} for the version everywhere

torn shuttle
#

so fun fact if you clear behaviors on minecraft AI even using mojang methods it just throws a NPC

#

guess I'm trying a brain transplant instead

wise mesa
#

It built 👍

lost matrix
lost matrix
#

I should pay more attention to IJ makros...

analog valley
#

1.19.3-R2 NPC resources (request)

tender shard
sullen canyon
#

can you code spigot plugins with cpp?

#

like jni or smth

tender shard
#

you could, but why would you want to do that

lost matrix
#

Imagine actually wanting to write cpp

tender shard
#

sorry but I cannot imagine that

#

I would have to be drunk to be able to imagine it

#

at least when it comes to spigot plugins

lost matrix
#

Yeah i converted to Rust for my low-level projects. Cpp is a dumpster fire in comparison.

tardy delta
#

heh

pure dagger
#

i have a problem because in onCommand methods thinks that there are 2 arguments and its correct but onTabComplete method thinks its 3 arguments cause ther is double space between arg1 and arg2, why is that and how to fix it ?

tardy delta
#

isnt that still 2 args 🤔

pure dagger
#

tab completer shows another arg

#

command will work but tabcompleter is weird

tardy delta
#

just print args.length

eternal oxide
#

its 2 args, even when the first arg is empty

#

as soonm as you press space it adds an empty arg

#

so space after the command, tab complete will show 1 arg but that arg will be empty

#

each arg fills as you type

pure dagger
#

what

#

but how to fix it

#

thats weird

hushed spindle
#

does anyone know how this singleAmmo.setAmount(1) could cause an AssertionError: TRAP?

eternal oxide
#

post the error

#

?paste

undone axleBOT
hushed spindle
#

that line being ProjectileListener: 90 btw

eternal oxide
#

you are removing an item in the interact event

hushed spindle
#

?

eternal oxide
#

if you want to modify it do it outside the event

#

?scheduling

undone axleBOT
hushed spindle
#

what interact event

#

there is none

eternal oxide
#

you are in teh shoot bow event

hushed spindle
#

no?

eternal oxide
#

its the only place a getConsumable() exisdts

hushed spindle
#

oh

#

thats not an interact event

#

wait, i cant modify a clone of the consumable within the event?

#

why?

eternal oxide
#

you should be able to, but thats what your TRAP error is saying

#

its an assertion failure

hushed spindle
#

weird

eternal oxide
#

ProjectileListener.java:90

hushed spindle
#

yeah thats the setamount part

eternal oxide
#

I'm going to guess yoru stack only had 1 in it?

hushed spindle
#

i dont think that really matters since im setting it to 1 anyway

#

this error also doesnt occur consistently

jagged bobcat
#

Is there Material for light block? I can't find it in 1.17.1 or 1.19.3

hushed spindle
#

isnt it just called LIGHT

remote swallow
jagged bobcat
hushed spindle
#

what version of spigot are you using in pom.xml

remote swallow
jagged bobcat
#

1.19.3

hushed spindle
#

revalidate dependencies?

jagged bobcat
#

1 sec

eternal oxide
#

does your TRAP error happen when using Spigot?

jagged bobcat
#

Invalidated Caches and it still doesn't find it.
Dependencies should not override anything

rotund ravine
jagged bobcat
#

Pretty sure. Used Material.valueOf("LIGHT") gave the material in the server, but it isn't showing in the ide

hushed spindle
#

i mean i guess there was a chance for the consumable to be null by the time it gets to line 90 but that would cause a different exception

rotund ravine
granite owl
#

is there a way to change a players name / prefix above their head without the use of the scoreboard and preferably without the use of sending packages?

jagged bobcat
jagged bobcat
#

Checked info of Material and it says it uses 1.13 jar for Material. I switched to Spigot-API and it still uses 1.13 material.
Removed dependencies which are compiled in astrolminiapi and it still doesn't show.
edit: Doesn't show any netherite items too

ivory sleet
#

But like, scoreboard can do it for u

#

W/O having to manually push packets

remote swallow
verbal slate
remote swallow
#

?paste the code

undone axleBOT
verbal slate
verbal slate
ivory sleet
#

Original poster

#

Anyway it looks fine, but like

remote swallow
#

the cancel doesnt stop the current task iirc

ivory sleet
#

That too

#

You should really try to split up all that logic, quite hard to read and maintain

verbal slate
#

Hmm.. how to stop the task?

ivory sleet
#

?scheduling goes over it iirc

undone axleBOT
remote swallow
#

cancel it and return

ivory sleet
#

Both inside and outside

verbal slate
#

Thank you both!

ivory sleet
#

As epic said, cancel() will only deny future runs from being called

verbal slate
ivory sleet
#

You’d have to use the return keyword to terminate the execution within run()

#

That’s good (:

verbal slate
#

Got it

scarlet mural
#

maybe i'm being rly stupid but I'm trying to setup a basic plugin that makes a locked item in the hotbar run the command /menu from the player. Ive got it all working but the command. Currently when a player right clicks it just says in chat "menu". This is what i'm using for the perform command:

player.performCommand("menu");

anyone got any idea?

pseudo hazel
#

try /menu

scarlet mural
#

I did

#

unknown command

#

but if I type /menu

pseudo hazel
#

okay then the command is invalid

scarlet mural
#

it opens a menu

pseudo hazel
#

does the console say anything?

scarlet mural
#

Hm, I'm using DeluxeMenu for the menu, do I need to link it directly?

#

nothing in console at all.

remote swallow
#

/menu isnt a registered command

scarlet mural
#

Oh I see

remote swallow
#

use player.chat("/menu") instead

scarlet mural
#

Alright ill try that out thank you

trim lake
#

How can I change max durability of item?

#

Mby I cant change that?

pseudo hazel
#

in the inventory iirc

#

but its kinda buggy

#

oh wait

#

im dumb

#

ignore what I said

#

idk about durability, I was talking about stack sizes

trim lake
#

I was googling that and I did not find anything useful, so mby thats not even possible,

scarlet mural
quaint mantle
#

hi, is there an event for a block changing like being broken, placed, or changed like a redstone dust being powered?

#

an event for any changes that happen to a block?

granite owl
quaint mantle
granite owl
#

generally speaking, if i develop plugins designed for personal use only, is it poor practice to incorporate native code? ive written for myself a sophisticated iniparser lib in c++ and exported it to a multitude of languages incl java(couple of months ago the project v 1.0 finished)

quaint mantle
#

nvm.

ivory sleet
#

Its not like native code is a bad practice

#

Its just that its often not needed

bold crane
# trim lake How can I change max durability of item?

You can do this.

        ItemStack itemname = new ItemStack(Material.ITEMNAME);

        // Get the item meta and modify the max durability
        ItemMeta meta = itemname.getItemMeta();
        meta.setUnbreakable(true); // Make the item unbreakable```
quaint mantle
ivory sleet
#

setItemMeta ?

#

:>

remote swallow
#

imajin go to bed

trim lake
ivory sleet
#

Cast the ItemMeta instance to Damageable

#

and then set the durability

chrome beacon
#

Though you can simulate the effects by modifying the item damage event

bold crane
#

You can always use setDurability()

quaint mantle
trim lake
quaint mantle
#

isnt there an attribute for that

chrome beacon
ivory sleet
#

Ehm well that’s not really possible

trim lake
#

sorry miss you message. Sad thanks

ivory sleet
#

You’d need client mods for that

quaint mantle
#

just make a durability pdc tag

ivory sleet
#

However you can make an item lose durability half of the times its supposed to lose durability, that way the item seems twice as durable

#

Or go with the op imajin strategy

#

(And then scale with actual durability)

trim lake
#

Ye, the pdc tag sounds like solution. But still will need (not rly) to edit damge of item to show durability for player.

ivory sleet
#

Yes

#

You scale it

trim lake
#

I can make item unbreakable and then just remove from inventory if pdc tag od durability is 0

chrome beacon
#

Unbreakable removes the durability bar

ivory sleet
#

Or you make the durability of the item the same percentage based of ur pdc durability

#

That way the scale remains untouched

trim lake
#

not rly need durability bar probably. I was think about ezy way how to doit xD

ivory sleet
#

Alr your choice :)

ivory sleet
#

You got the idea now, just need to implement it accordingly

trim lake
#

or just I can display durability in lore of item

#

but bar will be gone

ivory sleet
#

Yup

#

Don’t use longs I’d say btw

#

You can take advantage of the Instant class

#

it will because you will be able to write a cooldown system much easier

trim lake
#

thanks guys for help. I was looking for nbt tag or just something I can change. I know damage can be changed but thats not enough.

#

Wait... there is not ntb tag for max dur?

ivory sleet
#

Yeah I’m suggesting a robust and easy design by switching out an implementation detail

#

Map<String,Instant> map = …;

//set cooldown
String string, Duration cooldown
map.put(string, Instant.now().plus(cooldown))

//has cooldown
String string
var cooldown = map.get(string)
//null check
return Instant.now().isBefore(cooldown)

//remove cooldown
String string
return map.get(string)

//get cooldown
String string
var cooldown = map.get(string)
//null check
if has cooldown
return Duration.between(Instant.now(),cooldown)
else
return Duration.ZERO

#

you’d have sth like this

remote swallow
ivory sleet
#

True

#

Its the same as System.currentTimeMillis()

#

but its more useful

#

Because it abstracts over just a long

ivory sleet
remote swallow
#

i could

ivory sleet
#

That’s one issue for sure :>

#

We didn’t even need to help you, you’re a capable problem solver (:

#

Send the entire class

remote swallow
ivory sleet
#

But presumably you’ll have to create a variable somewhere to store some data, including the map

ivory sleet
remote swallow
ivory sleet
#

Hmm, that should only keep one map instance, no?

tardy delta
#

where private final

tender shard
#

using a plain map instead of creating a cooldown object 🥲

ivory sleet
#

Mind sending entire class?

tardy delta
#

Instant 😍

desert loom
#

I think they might be reinserting the cooldown every time possibly.

tardy delta
#

you dont want to know how many students in my class dont know what access modifiers are

#

either that or they make everything public

desert loom
#

you should send the entire class

tender shard
tardy delta
#

well you arent showing any code either

ivory sleet
tender shard
#

Its needed to be able to remove elements while iterating 😦

sullen marlin
#

big brain

ivory sleet
tardy delta
#

discord getting even more pay to win

tender shard
tardy delta
#

ugh no syntax highlighting

ivory sleet
#

Well mfnalex I thought you could maybe just have a public constructor that takes the map

tender shard
ivory sleet
#

And then its up to the lib consumer to choose

#

Ah

remote swallow
#
import java.time.Duration;
import java.time.Instant;
import java.util.Map;
import java.util.HashMap;
import java.util.UUID;

public class CooldownMap {
    private final Map<UUID, Instant> map = new HashMap<>();

    // Set cooldown
    public void setCooldown(UUID key, Duration duration) {
        map.put(key, Instant.now().plus(duration));
    }

    // Check if cooldown has expired
    public boolean hasCooldown(UUID key) {
        Instant cooldown = map.get(key);
        return cooldown != null && Instant.now().isBefore(cooldown);
    }

    // Remove cooldown
    public Instant removeCooldown(UUID key) {
        return map.remove(key);
    }

    // Get remaining cooldown time
    public Duration getRemainingCooldown(UUID key) {
        Instant cooldown = map.get(key);
        if (cooldown != null && Instant.now().isBefore(cooldown)) {
            return Duration.between(Instant.now(), cooldown);
        } else {
            return Duration.ZERO;
        }
    }
}
``` i made chatgpt do it for me because i didnt wanna open an ide
tender shard
#

Not sure though, i dont remember how it works, only on the phone rn

tardy delta
#

and insert some early returns there

ivory sleet
#

And then for the other constructors that takes just the long supplier and time unit, maybe have some static factory methods for those instead? Being quite nitpicky, take this with a pinch of salt

tardy delta
#

looks awful

ivory sleet
#

The class is good (:

tender shard
#

Thx, yeah i just made it to avoid writing cooldown logic over and over again

#

Its not perfect lol

remote swallow
#

i still have the time stamp cooldown thing

#

i should update that

#

ill do it after editing the cooldowns wiki page

#

should i add it as another method or as main method

#

ill do another method

tardy delta
#

could cache Instant.now()

remote swallow
#

ah true

#

pain

#

now i have to open an ide

ivory sleet
#

🥲

tardy delta
#

text editor

remote swallow
#

yeah but that means i can probably fuck it p

tender shard
#

Real coders can code remotely by manually switching bits on the ssd with telekinesis

tardy delta
#

real coders write assembly

#

wait

#

shouldnt be talking about all the traumas i already got

desert loom
#

what's the issue you're having?

ivory sleet
tardy delta
#

nah i had the genius idea to start writing this in class

#

what all happens when im bored 🥺

ivory sleet
#

Next month you be writing 4d gpu accelerated ai in quantum physics with assembly

ivory sleet
#

“Just bored”

tardy delta
#

i was thinking about rendering tho

#

but not in assembly 💀

wet breach
vocal cloud
#

Real coders wait for cosmic rays to flip the bits for them

wet breach
#

Lol

tender shard
#

Real coders have extreme social anxiety and hence are afraid to use discord

tardy delta
#

🥺

#

discord their new emotes go brr

ivory sleet
#

I must be the most fake coder to exist on this planet

tardy delta
#

its just your dog whos coding for you

vocal cloud
#

Such a cute puppy

daring lark
#
 @EventHandler
    private void onEvent(PrepareInventoryResultEvent event) {
        ItemStack item = event.getResult();

        if(item == null) {
            Logger.log("null");
            return;
        }

        ItemMeta meta = item.getItemMeta();
        String name = meta.getDisplayName();

        if(name.length() < 1) {
            Logger.log("male");
            return;
        }

        Logger.log(name);
        Logger.log(TextFormatter.color(name));

        meta.setDisplayName(TextFormatter.color(name));

        item.setItemMeta(meta);
    }```
why this code works on my local server but on my survival server does not?
color deosn't change but on my lcoal does
edit: this code just implements color does into anvil.
tender shard
#

?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.

thick oracle
#

Is there a dedicated discord for Bungeecord support or can I ask here?

tender shard
#

Here

thick oracle
desert loom
#

The problem is that your if statement here does not check if the sender is on a cooldown.

if (cooldown.get(sender.getName()) > System.currentTimeMillis())

To check if a sender is on cooldown, check if the result of sender-cooldown - now is > 0

final long now = System.currentTimeMillis();
final long remaining = cooldowns.getOrDefault(sender, now) - now;

if (remaining > 0) {
    // sender on cooldown
    return;
}

// Do code stuff

cooldowns.put(sender, now + 10_000); // put sender on a 10 second cooldown

Use getOrDefault instead of get to avoid an NPE when unboxing the boxed primitive from the map

Also, you should prefer early returning instead of nesting your if statements.

ivory sleet
paper venture
#

Hello I need to make a constant sound around one specific location. If I do playSound in a loop it would play millions instances of that sound. I want it to play only one instance of sound in a specific area, but this sound should be infinite. Is it possible?

tender shard
daring lark
#

it looks like event is not called

tender shard
#

Add some debug stuff so you see whether the event gets called. Are you using the latest build of spigot on both servers?

thick oracle
tender shard
paper venture
# tender shard Just add a delay?

Yes it will work too but at first I need to find out the exact time this sound plays, also I should store the delay, and if I have a lot of places of this sound effect I would store the delay for everything... Is there the ultimate way of doing this?

tender shard
paper venture
#

I will add the delay if there is no other way...

thick oracle
daring lark
tender shard
#
    public static MemoryConfiguration map2Config(Map<String,Object> map) {
        MemoryConfiguration config = new MemoryConfiguration();
        map.forEach(config::set);
        return config;
    }
tender shard
tender shard
paper venture
tender shard
#

color does not belong into console, with two exceptions:
warnings may be yellow
errors may be red

#

everything else is supposed to have the default color

tender shard
#

what you can however do is to stop the existing, already playing sound for players

#

Player#stopSound or sth

#

anyway, you will need a loop with a delay

paper venture
#

Okay, thanks!

tender shard
#

np

tender shard
wet breach
#

for playing a sound at a specific location

tender shard
#

yeah that's not the problem, they want to play the sound "continuosly"

#

or however that's written

wet breach
#

they can do that but the issue is they are going to have to measure the time length of the sound as that isn't provided

tender shard
#

exactly

#

and people could have another resource pack

#

with another sound

wet breach
#

and then once they know how long the sound is, they can just make a repeating task with that as a delay

tender shard
#

for my JukeboxPlus plugin, I just have a config file where people can enter the amount of seconds that their songs take, in case they use custom songs

wet breach
tender shard
#

well you can force players to use the server resource pack, and if that includes all the sounds they need, I think one would be fine

wet breach
#

yeah if the server has a specific resource pack to be used lol

tender shard
#

I think resource packs should be renamed to TurtlePack™

trim lake
#

Why percent is 0?

short durability = data.get(new NamespacedKey(RoleJob.getPlugin(), "durability"), PersistentDataType.SHORT);
        short maxDurability = data.get(new NamespacedKey(RoleJob.getPlugin(), "maxDurability"), PersistentDataType.SHORT);        
        short dmg = (short) e.getDamage();
        int newDurability =  durability-dmg;
        data.set(new NamespacedKey(RoleJob.getPlugin(), "durability"), PersistentDataType.SHORT, (short) newDurability);
        double percent = (int) newDurability/ (int)maxDurability;
        p.sendMessage("percent: " + percent);
#

durability = 93 and maxDurability = 100

glossy venture
#

you are doing integer division

tender shard
#

Because 93/100 is 0.93 and as an int, its 0

glossy venture
#

cast your newDurabiliy and maxDurability to double

#

before doing the calculation

trim lake
chrome beacon
trim lake
#

so all number needs to be double?

glossy venture
#

it casts the whole expression

#

to double

wet breach
#

if the max is 100, then division isn't needed here

glossy venture
#

which is an int at that point

trim lake
tender shard
#

double result = (double) first/ (double) second

glossy venture
icy beacon
#

i always love when intellij sees there are no uses, yet highlights the variable as if there were some

#

totally convenient

tender shard
icy beacon
#

the fact that it isn't fixed

icy beacon
#

yeah?

wet breach
#

just like how its worded

trim lake
tender shard
#

I also hate that it cannot find references in decompiled classes

glossy venture
tender shard
glossy venture
#

oh

tender shard
#

Or maybe its just broken for me? Idk

#

It works neither on my mac nor on windows

chrome beacon
#

Not just you

#

Never worked for me either

icy beacon
#

intellij is good but sometimes i wanna throw hands

tender shard
#

Yeah maybe i should take a look at eclipse or nb again

wet breach
#

I hear all these complaints with intellij and here I am with like no issues using netbeans XD

icy beacon
#

let's go, nb ftw

#

😳

tender shard
#

For example netbeans has an awesome gui debugger that is lacking completely in IJ

wet breach
#

md_5 uses netbeans too

tender shard
#

Yeah ik

#

Its not bad

chrome beacon
#

When I did school work with Swing I used NB for gui and IJ for the rest

icy beacon
#

having an uncontrollable desire to code in sublime text

trim lake
#

So the solution is cast number witch are in calculation to double. Okey thanks.

wet breach
#

soon NB will take over as the prominent IDE 😉

icy beacon
#

and eclipse is nervously standing there

wet breach
tender shard
#

eclipse is also not bad, but their quickfixes are a joke sometimes

#

and the maven integration is shit

icy beacon
#

😛

tender shard
#

haven't tried eclipse + gradle but tbh I dont hate myself, hence I don't use gradle voluntarily

#

hate* myself, not mate

#

ugh

#

"i don't mate myself" ok ok

trim lake
tender shard
#

the two other numbers

#

the divisor and the divident

wet breach
#

nothing you have in the code specifically needs to be a short or int

#

you could just make all them numbers doubles

#

and then no need or worry about casting

trim lake
#

double maxDurability = data.get(new NamespacedKey(RoleJob.getPlugin(), "maxDurability"), PersistentDataType.SHORT);
I just made this

tender shard
#

I'd much rather order a double shot than a single one

#

does that even work?

#

it would return a Short

#

you cannot just cast it

trim lake
#

yep it does work

tender shard
#

huh

wet breach
#

yeah it works

#

its called autoboxing or unboxing or whatever

tender shard
#

yeah ik but I didnt knew it worked for other primitive types

trim lake
#

this is mby best soultion 😄 its double that what I need for percentage calculation

tardy delta
#

oh hell ye

tender shard
# tardy delta oh hell ye

that's what eclipse imagines when it wants you to cast ItemStack to Player so you can use getDisplayName()

tardy delta
#

thats what people in my class do

tender shard
tardy delta
#

ahah

tender shard
#

and after clicking on "Add cast":

tardy delta
#

oh man goofy eclipse

desert loom
#

Looks good to me

tender shard
#

also looks good to javac

tardy delta
#

💀

tender shard
#

however I don#t get it, eclipse should be able to see that ItemStack does not implement Player

#

I could understand it if ItemStack would be an interface - but it isnt

#

it's a regular class

young knoll
#

Eclipse is just 1000 parallel universes ahead of you

#

It’s living in 3023 where ItemStack does implement Player

tender shard
#

hm I wish it'd stick to the spigot version I declared in my pom though lol

tardy delta
tender shard
#

I own at least 4 toilet seats

#

5 if one also counts the "stand-up toilet" as toilet seat lol

#

although that makes little sense

#

as one doesn't sit while standing up

#

so nvm

tardy delta
#

lol

young knoll
#

You have a dedicated stand up toilet?

tender shard
#

yes, in the bar in the basement

granite owl
# ivory sleet na that’s fine

aight🙏 hehe yea its just that ive already written the library and it works good. since i write in a couple of languages including c, c++, c#, java etc and require an IniParser in almost all of them for config files ive once put alot of effort to write one lib that can be used by every language with the respective interfaces

icy beacon
tardy delta
#

ddamn chrome starts to break after leaving pc on for two days

#

prev time it crashed, it took down my whole system

young knoll
#

Firefox >

tardy delta
#

i might

#

but google account is just so easy to use everywher

icy beacon
#

++++

tardy delta
#

whats the dmesg variant of windows again?

young knoll
#

Yeah 10_000 is the same as 10000

unique sable
sick edge
#

Hi, is there any way to reference an item in an inventory for future changes or is it the case that once you set an item to an inventory you can't modify it anymore meaning you would need to find it in the inventory and replace it with a new ItemStack?

#

And is there any way to monitor interactions with bundles through spigot?

young knoll
#

I assume it fires regular click events

sick edge
desert loom
#

What's your code look like now?

#

you're missing a return in the if statement.

#

in the block*

#
                        if (remaining > 0) {
                            ProxyServer.getInstance().getLogger().info("Sixth condition!");
                            String message = Everywhere.getColors(config.getString("AntiSpam.message"));
                            message = Everywhere.Replace(message, "{cooldown}", String.valueOf(intCooldown));
                            event.setCancelled(true);
                            sender.sendMessage(message);
// missing a return here
                        }
#

you are constantly refreshing the player's cooldown whenever they type the command without that return statement

#

if that's your problem, that return should fix it.

eternal oxide
#

final long remaining = cooldown.getOrDefault(sender, now) - now; is returning the default

#

now

#

the one you provide

#

?paste yoru full class

undone axleBOT
eternal oxide
#

sender is not a string

#

final long remaining = cooldown.getOrDefault(sender, now) - now;nneeds to be final long remaining = cooldown.getOrDefault(sender.getName(), now) - now;

desert loom
#

try again with those changes

eternal oxide
#

your if test is also invalid

#

once they have a cooldown if (remaining > 0) { is ALWAYS going to be true

#

you need if (remaining - now > 0) {

#

no

#

thats fine, but your if is wrong

#

you are adding in the map now + cooldown

#

soi it's always going to be a value greater than 0

#

?paste your current class

undone axleBOT
eternal oxide
#

oh I see

#

you are subtracting it already

#

I didn;t see that

#

line 22 needs a return

#

yes

#

you could return or use else

#

it depends

#

if you can't early return, yes

hazy parrot
#

?arrowcode, this should explain early returns of you have much nested ifs

#

OK that doesn't exist

undone axleBOT
young knoll
#

Commas are the enemy

hazy parrot
#

Alright ,

eternal oxide
#

how do you kow?

#

you are accessing the config before calling saveDefaultConfig() in you ronEnable

#

ah

#

no clue if comments are retained on bungee

quaint mantle
#

hello.

#

i have a question.

young knoll
#

You should ask it

quaint mantle
#

but not about bukkit.

chrome beacon
#

Ask it anyway

quaint mantle
#

is anyone here familiar with mongodb?

chrome beacon
#

...

flint coyote
#

?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!

quaint mantle
#

um, i was reading the mongodb manual for indexes.

#

and i am a bit confused on how to use it for sort orders.

icy beacon
chrome beacon
#

?nohello

icy beacon
undone axleBOT
icy beacon
#

cafebabe you dumb bitch chat isn't infinitely high

quaint mantle
#

so, if i have an index on (fieldA: -1, fieldB: -1, fieldC: -1), does doing a sort on (fieldB: -1) not use the index to get the sort order?

flint coyote
young knoll
#

But the bot doesn’t

#

Sad

icy beacon
#

yeah

young knoll
#

Although the embed does help

flint coyote
#

oh I didn't notice xD true

quaint mantle
#

please dont bury my question.

icy beacon
#

?cba

undone axleBOT
#

Pluggg#0001 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.

quaint mantle
#

although i wonder if anyone knows the answer.

#

maybe too niche of a question for this chat.

flint coyote
#

I'm sadly not too familiar with noSQL dbs

wary mauve
#

This works once without using a runTaskTimer. the generateChunkSquare method is a loop that looks at different chunks to generate them. When I put the runTaskTimer back, it doesn't work at all, and just freezes the server. It only runs one loop and gets stuck at generateChunkSquare. Any ideas?

chrome beacon
#

I've used Mongo. Just don't understand the question

icy beacon
#

^

quaint mantle
wary mauve
eternal oxide
#

no

flint coyote
#

No it's still on the main thread

wary mauve
#

What could the issue be?

#

Why does the task make it not work?

quaint mantle
eternal oxide
#

your job has to end. You can;t perform HUGE tasks and take up all server resources

#

running a timer means you are running it repeatedly

wary mauve
#

the task is generating chunks with a slow custom generator and it takes about 12 seconds

#

Yes I need to run it repeatedly

eternal oxide
#

very slow

wary mauve
#

Is there a way I could make this happen? The goal with the runTaskTimer was so that 1 tick would pass for every time generateChunkSquare was called

eternal oxide
#

?workdistro

wary mauve
#

I always see 7smile7 around spigot plugins

#

just everywhere

eternal oxide
#

yes

icy beacon
#

means he's a good contributor 🙂

eternal oxide
#

He's who you go to when everyone gets stuck

icy beacon
#

haha, especially acf

wary mauve
#

He helped me with my other custom world gen issues because I couldnt find anyone that knew how to do what I was trying to do

fresh timber
#

How can I get the amount of a specific item in a players inventory.. for example, I want to check how many stone blocks with the lore "xd" and with certain tag and name or whatever like the specific itemstack and get the amount total (for example, if there are 2 full stacks, 128)

quaint mantle
#

idk why i am arguing.

#

i am bored.

icy beacon
quaint mantle
#

i might go play minecraft.

#

bye.

icy beacon
#

i don't think there's a spigot built in methd

young knoll
#

There is not

eternal oxide
#

Not many can criticise 7smile7. I give him advice now and then but generally he's ahead of me.

young knoll
#

Sadge

fresh timber
#

whatever

icy beacon
#

that shouldn't be slow imho

fresh timber
#

I mean

young knoll
#

I have a method for it already

fresh timber
#

like

young knoll
#

If ya want it

fresh timber
#

a one line or smthin

icy beacon
fresh timber
#

ill make my own

young knoll
#

public static int getTotalAmount(Inventory inventory, ItemStack target) {
        int amount = 0;

        for (ItemStack item : inventory) {
            if (item == null) {
                continue;
            }

            if (item.isSimilar(target)) {
                amount += item.getAmount();
            }
        }
        return amount;
    }
icy beacon
#

i think this could be cooler with streams xd

#

but not sure about efficiency

young knoll
#

Muh cpu cycles

remote swallow
icy beacon
#

i can't write streams code without an ide

#

lmao

chrome beacon
#

Compiler plugin to transform streams when?

young knoll
sage patio
#

player.setVelocity(player.getEyeLocation().getDirection().normalize()
How i can made this slower

icy beacon
#

multiply by 0.5?

remote swallow
young knoll
#

.multiply <1

remote swallow
#

save that extra tiny bit of cpu

sage patio
#

afer normalize?

icy beacon
#

yeah

young knoll
#

Yes

#

Does iterating over an inventory even return air items

#

Or does it return null

fresh timber
#

or stops the loop

flint coyote
icy beacon
fresh timber
#

ok

icy beacon
#

in the loop

fresh timber
#

alr

young knoll
#

^

icy beacon
#

break breaks out of the loop

fresh timber
#

that makes more sense

young knoll
#

I usually exit my loops early by crashing the JVM

#

It’s the most efficient option

flint coyote
icy beacon
#

true

remote swallow
#

yeah

grizzled oasis
#

Hi im making a wanderer that spawns every week at monday, how can i run a task that every monday spawns the wanderer.

I have a check already for the spawn i just need to make the task run, without lagging the server

icy beacon
#

i usually exit my programs my tracking my cpu with my bare eyes, and when i see that everything is done, i slamdunk on my CPU so that it 100% stops the execution without any memory leaks

flint coyote
icy beacon
#

do something like 1 hour

#

60 * 60 * 20 i think

flint coyote
#

If you just want it on monday checking every minute should be enough. If you need more precision you can also go for every second. Depends on your usecase.
Even every tick wouldn't lag the server but it still sounds unreasonable

icy beacon
#

perhaps a minute is better for precision yeah

flint coyote
#

If you wanna take it one step further you can do an async task for the time checking and then run a sync task on monday. But it's really not required for something as simple as that

icy beacon
#

||don't do this||
run a task every 1ms, check the System.currentTimeMillis(), if it's divisible by a number that symbolises a monday, execute

eternal oxide
#

ScheduledExecutorService. Calculate time until Monday at server start and schedule the task.

young knoll
#

Could do that

icy beacon
#

smart

#

yeah

#

probably best for precision

young knoll
#

But what if the real world time chang- wait

icy beacon
#

dst

#

hehe

grizzled oasis
young knoll
#

Edge case

#

won’t-fix

icy beacon
#

"ScheduledExecutorService usage example"

flint coyote
#

Is there a decent book gui lib? I noticed that a lot of stuff is clientside and workarounding this is tedious

flint coyote
#

You can't even forceopen a writable_book...

icy beacon
young knoll
#

Is it?

icy beacon
#

i did look it up a long time ago

#

that's just what i recall

#

it was moved from server side to client side later or smth

icy beacon
#

take this with a grain of salt

flint coyote
#

Big thanks to mojang for not giving us a decent text editor for larger texts in java.

flint coyote
#

No it requires a WRITTEN_BOOK

icy beacon
#

yeah

flint coyote
#

which can not be changed

young knoll
#

I see

#

Rip

icy beacon
#

tbh just use chat conversation api or anvilgui

#

not worth the hassle

flint coyote
#

Why anvil?

icy beacon
#

i find anvilgui convenient

#

if you want long texts chat is your go-to i think

flint coyote
#

I need them to type (possibly) infinitly long lists

icy beacon
#

ah shit

sage patio
young knoll
#

Make them build the text in pixel art with blocks

icy beacon
#

TRUE

young knoll
#

.setY(0)

sage patio
#

yea

fresh timber
#

wait so ehm

icy beacon
#

^

young knoll
#

You can’t chain that though

sage patio
#

good, thanks

fresh timber
#

can I make an itemstack with like 100 items in it?

young knoll
#

Yes

fresh timber
#

k

icy beacon
#

i think you can make as many items as you want, but at SOME point they will get clamped to [-128, 127]

#

not sure when exactly

fresh timber
#

im using for compressing blocks for a mining server

#

so like I make an itemstack and add items to it through then at end give player all the items

icy beacon
#

i recall having a bug where my item amount would get to -127 or -128 idr

#

so i just deduced that they get clamped to this interval at some point

fresh timber
#

hmm

#

ill just make an amount variable

grizzled oasis
eternal oxide
#

sysout the period you are scheduling for

#

you can use that to calculate when it will happen

wary mauve
#

@eternal oxide this workload distribution you sent feels quite a bit advanced for me. I'm trying to piece it together but I'm still a little confused

eternal oxide
#

read it a few times. it's a good thing to get to grips with. Yes it is advanced

wary mauve
#

So I get the concept of the linear processing I think. It fills up the remaining time in the tick with what you want to do, but doesnt delay the tick.

eternal oxide
#

correct

#

you only have 50ms

wary mauve
#

So what if I wanted to generate a chunk, which I think would take 150ms with the generator Im using

#

No one's on the server when Im generating this btw

eternal oxide
#

could you split up the generation? Are you actually creatign a proper chunk generator or a block populator?

wary mauve
#

Im using a plugin that is a generator. I am pretty sure its a real chunk generator

eternal oxide
#

why is it so slow?

wary mauve
#

dont know

#

But it looks cool

#

Would the workload distribution 100% fix the issue of why the server freezes when this bit of code is in a runTaskTimer task?

eternal oxide
#

try adding a longer delay between tasks. Give the server some time to catch up

wary mauve
#

when its in a tasktimer, it doesnt finish the generateChunkSquare method. It's fine when its not inside a task

eternal oxide
#

If your task takes 150ms to run you should give at least 3 ticks between tasks

wary mauve
#

It never gets to that point

eternal oxide
#

if each chunk is 150ms then it needs 3 ticks between each chunk gen

wary mauve
#

so I need to break up the loops into an individual task per chunk?

eternal oxide
#

yep

#

with 3 ticks between

wary mauve
#

can I have a task inside a task?

eternal oxide
#

you'd do better pushing your tasks to a queue

zenith crescent
#

Any suggestions for an API to use for player heads? Thats not Headdatabase, or is it worth just buying it?

eternal oxide
#

which is what the workdistro is really for

#

only process one chunk/task per 4 ticks

grizzled oasis
#
 public static void startScheduler() {
        Calendar with = Calendar.getInstance();
        Map<Integer, Integer> dayToDelay = new HashMap<Integer, Integer>();
        dayToDelay.put(Calendar.FRIDAY, 0); //2
        dayToDelay.put(Calendar.SATURDAY, 0); //1
        dayToDelay.put(Calendar.SUNDAY, 0);
        dayToDelay.put(Calendar.MONDAY, 0); //6
        dayToDelay.put(Calendar.TUESDAY, 0); //5
        dayToDelay.put(Calendar.WEDNESDAY, 0); //4
        dayToDelay.put(Calendar.THURSDAY, 0); //3
        int dayOfWeek = with.get(Calendar.DAY_OF_WEEK);
        int hour = with.get(Calendar.HOUR_OF_DAY);
        int delayInDays = dayToDelay.get(dayOfWeek);

        System.out.println("RUN");

        int delayInHours = 0;
        if(delayInDays == 6){
            delayInHours = hour;
        }else{
            delayInHours = delayInDays*24+(24-hour);
        }
        ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
        scheduler.scheduleAtFixedRate(new CheckUpdate(), delayInHours,
                1, TimeUnit.MINUTES);
    }

i tried starting it and the println works just fine but i really don't understand why it doesn't start the check

wary mauve
eternal oxide
#

🙂

sage patio
#

can i made this particle to stay at where whey got spawned?
event.getPlayer().spawnParticle(Particle.CLOUD, event.getPlayer().getLocation(), 1, 0.1, 0.1, 0.1);

young knoll
#

You can set the speed value to 0

#

But if that doesn't work then no

eternal oxide
#

Do you mean it moves, or are you wantign it permanently in place?

wary mauve
# eternal oxide 🙂

Do I even need to have it in a task? If there isn't a task, I could just do it all in one tick. The server would be on one tick for tens of minutes if I wanted to generate a lot (maybe even hours). As long as the world is saving, wouldn't it be fine?

eternal oxide
sage patio
young knoll
#

You'll need to disable the watchdog

#

double extra is the speed

wary mauve
young knoll
#

For most particles

eternal oxide
sage patio
wary mauve
#

Last time I tried doing a lot, it crashed after like 90*81 chunks and the memory was going up consistently. If I save it the world, will it clear that cache?

eternal oxide
#

you could unload the chunks after generating/dsaving

sage patio
eternal oxide
#

particles have a fixed animation speed

sage patio
#

and i can't change them?

eternal oxide
#

no

sage patio
#

ok then

storm isle
#

hello i have a quick question for you guys how do i make a bow be able to damage endermen i have been testing a few stuff but cant figure it out this is my code so far

    public void onPlayerInteract(PlayerInteractEvent e) {
        Player p = e.getPlayer();
        if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR) {
            ItemStack item = p.getInventory().getItemInMainHand();
            if (item.getType() == Material.BOW && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Terminator")) {
                if (cooldownMap.containsKey(p)) {
                    long lastShotTime = cooldownMap.get(p);
                    if (System.currentTimeMillis() - lastShotTime < cooldownTime) {
                        plugin.getLogger().log(java.util.logging.Level.INFO, "Terminator cooldown " + p);
                        e.setCancelled(true);
                        return;
                    }
                }
                p.setItemInHand(item);
                p.launchProjectile(Arrow.class);
                cooldownMap.put(p, System.currentTimeMillis());
            }
        }
    }```
grizzled oasis
# eternal oxide <https://stackoverflow.com/questions/22118116/how-to-run-a-particular-task-every...

im not sure if this run, but in theory should

        Calendar with = Calendar.getInstance();
        Map<Integer, Integer> dayToDelay = new HashMap<Integer, Integer>();
        dayToDelay.put(Calendar.FRIDAY, 2);
        dayToDelay.put(Calendar.SATURDAY, 1);
        dayToDelay.put(Calendar.SUNDAY, 0);
        dayToDelay.put(Calendar.MONDAY, 6);
        dayToDelay.put(Calendar.TUESDAY, 5);
        dayToDelay.put(Calendar.WEDNESDAY, 4);
        dayToDelay.put(Calendar.THURSDAY, 3);
        int dayOfWeek = with.get(DAY_OF_WEEK);
        int delayInDays = dayToDelay.get(dayOfWeek);

        System.out.println("Started Event");

        ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();

        service.scheduleAtFixedRate(() -> {
            try {
                checkUpdate();
            } catch (ParseException e) {
                throw new RuntimeException(e);
            }
        }, delayInDays, 7, TimeUnit.DAYS);

I wanted to ask you only for be sure

zenith crescent
#

Any suggestions for API to get custom heads?

ivory sleet
#

Can’t you just use spigot stuff

storm isle
zenith crescent
#

I think you can for player heads, but im not sure about custom ones

tender shard
ivory sleet
#

Or r u looking for a texture index api like that one^

zenith crescent
#

I guess like that, is it worth buying?

storm isle
#

the actual api is free i think

#

only the plugin is paid

tender shard
zenith crescent
#

Ok, ill try it again. I thought last time it wouldnt load bc i didnt have the plugin

ivory sleet
#

There is probably a free variant on the market just as good, and ftr the api does not work without the plugin iirc

young knoll
#

If you are on modern spigot there is an API for custom heads

#

By modern I mean like

#

1.17? 1.18?

zenith crescent
#

yeah im using 1.19.3

young knoll
#

You got the PlayerProfile API then

ivory sleet
#

I think he is looking for an api that indexes textures based of searches also?

young knoll
#

Ah

ivory sleet
#

Not entirely sure still what they really need 😅

zenith crescent
young knoll
#

I generally prefer using a UUID made from the string

#

But yeah jeffs tutorial will work

storm isle
zenith crescent
#

Ok thank you

sterile token
#

Because all people here are volunteers none getting paid for instant help

storm isle
#

i know im not trying to be rude i was just asking

young knoll
#

Hmm

sterile token
#

oh my bad

young knoll
#

Idk if cancelling the EntityTeleportEvent would be enough

storm isle
#

wont that like cancel all the endermans teleports?

tender shard
young knoll
#

Ah

tender shard
#

And i didnt want to have thousands of useless files

young knoll
#

It makes a file

#

Interesting

tender shard
#

At least it did when i wrote that blog post. Maybe its different now, idk

wary mauve
#

@eternal oxide the memory goes up slowly even when I save the world. This will crash my server eventually. How do I prevent this? Im generating chunks btw

tender shard
#

Its supposed to go up until GC runs

#

Did your server crash?

wary mauve
#

what's gc?

tender shard
#

Garbage collection

wary mauve
#

but look at the slope of the lowest point. That's the issue

tender shard
#

Yeah i see. Did it crash anytime, though?

wary mauve
#

It will soon

tender shard
#

Wait until/whether it actually crashes

wary mauve
#

okie

#

Ive done this before

tender shard
#

Hm do you know where its coming from?

young knoll
#

They are doing a bunch of worldgen stuff

wary mauve
#

Yes only one thing is happening. Im generating chunks. This gets called in different areas

tender shard
#

Are you returning a new instance of your chunk generator instead of reusing the existing instance?

wary mauve
#

No. It's all in one tick. Not sure if that matters.

#

That's promising:

#

It's on area 41/100. Last time it crashed at 89

sterile token
wary mauve
#

Yes it is

#

It's generating them

sterile token
#

Are you trying to load worlds?

wary mauve
#

It's all in one world

sterile token
#

In case of loading worlds you have to use a work distribuitor**

wary mauve
#

I probably should for this too, but if it works the way it is, I don't want to figure that out

sterile token
wary mauve
#

Im fine with the tps being 0. It's pregenerating areas and no one would be on when this happens

sterile token
#

ok

#

So whats issue itself?

wary mauve
#

It slows down dramatically when the memory gets like this

#

and last time I tried it, it crashed when it got super high