#help-development

1 messages · Page 183 of 1

hasty prawn
#

Which is required iirc

tardy delta
#

inserts command framework

frail swift
#

commands:
command:
description: blahblah

eternal oxide
#

^

charred blaze
#

still not working

eternal oxide
#

?paste your plugin.yml

undone axleBOT
eternal oxide
#

um, check yrou startup log you will see an error about Main

#

something about Main not found

charred blaze
#

i see no errors

#

umm?

eternal oxide
#

what is the package your Main is in?

#

very top of the Main.class

#

is it even in a package?

sterile token
#

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

charred blaze
frail swift
#

uhh

sterile token
eternal oxide
#

ok

sterile token
#

Why!!

charred blaze
#

i mean

#

default package

eternal oxide
#

You can do that, but it's not normal

sterile token
charred blaze
#

hhhhhh

eternal oxide
#

add in your onCommand a sysout to show it's being callled. I say it will not be

floral drum
#

my brain does not work

#

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

floral drum
#

hm

eternal oxide
#

When you find your onCommand never fires, you need to fix your project setup and add a package

#

also fix your plugin.yml to point main to the new location

#

put it above the 'if`

#

ok

charred blaze
#

it prints

#

1

#

2

#

haa?

eternal oxide
#

then I see no reason for your issue

charred blaze
#

umm

#

so its just

#

magically

#

doesnt work?

eternal oxide
#

unless

#

wrap the code inside your executor in a try/catch

#

I'm going to bet teh executor is consuming an error

sterile token
#

eclipse 🤢

#

I mean i dont like it as personal experiences hahaha

#

Just dont give attention to my msg

eternal oxide
#

Exception not IOException

sterile token
#

I dont want to sound rude but i dont think he learn it

charred blaze
#

not working

#
  • no errors
sterile token
# charred blaze you sound rude

I mean its okay, but you should self realize that if you dont learn how a language work or learn it its really diffuclt to code

charred blaze
sterile token
#

And people will get tired of helping because they will explain u in a technical way which you should not really understand them

eternal oxide
#

I recommend getting rid of your executor service and use teh Bukkit Scheduler

charred blaze
#

ok.

raw prairie
#

Hello

untold jewel
#

?hello

#

hm

#

did they remove the command

raw prairie
#

Can someone help me with the ChunkGen class?

untold jewel
#

Have you searched for the answer on google first tahd?

golden turret
#

guys

raw prairie
untold jewel
#

I'm sure if I search up what you are asking I will find an answer rather quickly

charred blaze
#

what the

golden turret
#

in real spigot versions we have the PersistentDataContainer on entities

#

what is the similar on 1.8?

#

before you say anything, it is for a client

charred blaze
#

hello buddy

frail swift
warm token
raw prairie
untold jewel
untold jewel
#

So what is the problem

warm token
#

I'm trying to add some attributes modifiers adding some armor points, this actually works, but somehow when I try to use it, it doubles the damage

untold jewel
#

Did you not read it?

warm token
untold jewel
# raw prairie Already done lmao

Also this guy has a video about it https://www.youtube.com/watch?v=8qlnlvigodM

Love the video or need more help...or maybe both?
💬Join us on Discord: http://discord.gg/invite/fw5cKM3
Thank you for tuning in to this episode of TheSourceCode! ❤️

If you enjoyed this video make sure to show your support by liking , commenting your thoughts, and sharing for all your friends to see and learn!

All code is available on Github:
...

▶ Play video
raw prairie
#

thanks

#

Il come back with a error

zealous osprey
#

Anyone know a good resource I could read up on how to postpone a method continuing to run?
Like if a method is run, I want the function to stop, until that method says that it should continue.

I thaught about having a kind of manager class in a different thread and then just stopping the main thread until the the method is done.
But this has the issue, that it would also stop any processing of other incoming events... soooo
Ping me, if you got something. Still need to do some more research

untold jewel
#

?scheduling

undone axleBOT
untold jewel
#

there u go conorsmine

#

?paste

undone axleBOT
zealous osprey
warm token
eternal night
#

I mean, usually you'd wait for a future to complete

#

that represents the other data

raw prairie
untold jewel
#

go ahead

raw prairie
raw prairie
zealous osprey
#

The main issue I have, was that I don't want to use a bunch of lambdas and create a "power tower" of lambdas, cause the api I am using has a bunch of things async.
That's why I want to have like an annotation or smth which just goes: "Hey, wait until this is done ;P" and just does it, without having to do a lot with lambdas

untold jewel
eternal night
#

I mean, lambda wise you just want to flatten your thing or well join on the same thread. Depends on what you want.

#

Could also just use a super straight forward locking mechanism

#

like a plain semaphore

golden turret
#

can i teleport entities through worlds?

charred blaze
#

how to rotate armostand to an location?

frail swift
#

Greened123, you gotta learn some stuff on your own my man

#

if you type that exact thing into google and add "spigot" before it will show up

untold jewel
#

?google

undone axleBOT
untold jewel
#

u definitely did not

#

since there are hundreds of armor stand tutorials out there

warm token
#

put that into a timerRunnable and change the delay / the rotation increment if you need to

charred blaze
#

i know how to add yaw

#

how to rotate it to location?

warm token
#

wdym

charred blaze
#

turn it's head to be straight to some location

warm token
#

so basically the armorstand has to look at a location?

frail swift
#

you mean you need the math to find the angle between two points?

charred blaze
#

yes.

charred blaze
#

wait

#

angle?

#

i mean yaw

warm token
frail swift
#

yaw is the angle the entity looks up and down

#

pitch is the 360 degree rotation

charred blaze
#

pitch then

frail swift
#

sorry, reverse those

#

but you want the angle of it

charred blaze
#

what

#

soo

#

i just want to rotate armorstand's head to some location

untold jewel
#

dud

frail swift
#

yes

charred blaze
#

do i need to use math? :/

untold jewel
#

are you wanting to make a plugin on ur own

frail swift
#

...

untold jewel
#

or do you want someone else

#

to make it for you

#

since you can apply for someone to make it in the spigot forums

#

this channel is for helping, not spoon feeding every line

frail swift
#

there isnt some magical thing already implemented to do every math equation you would ever need

untold jewel
#

Teams

#

for tab and scoreboard

#

prefix is just adding it to the format

#

in chat

charred blaze
#

what is atan2?

frail swift
#

?google

undone axleBOT
frail swift
#

haha, look at me using commands

untold jewel
#

;)

balmy valve
#

Anyone here know what im doing wrong?
if I use ```java
location.getWorld().spawnParticle(Particle.SHRIEK, new Location(location.getWorld(), location.getX(), location.getY()+1, location.getZ()), 1, 0);

A. it spawns it at 0,1,0 when thats not the location's values
B. it will kick me and spew that error below (the photo)

But if I try using
```java
location.getWorld().spawnParticle(Particle.SHRIEK, new Location(location.getWorld(), location.getX(), location.getY()+1, location.getZ()), 1);

I just get java.lang.IllegalArgumentException: Particle SHRIEK requires data, null provided
For Context this was why I thought the first option would work: https://www.spigotmc.org/threads/comprehensive-particle-spawning-guide-1-13-1-19.343001/

raw prairie
#

how do I make a try-within-resources statement?

hoary quartz
#

?paste

undone axleBOT
untold jewel
tardy delta
#

Map::of doesnt seem to decide whether it should be a identityhashmap or normal one right?

#

is there like a builder for an identityhashmap?

raw prairie
jolly gust
#

public static Map<Player, BukkitTask> tasks = new HashMap<>()
How save this map into config ?

tardy delta
#

you cant save a runnable to a config, its not serializable

jolly gust
#

For example <Player, Long>

tardy delta
#

you can perfectly serialize that, use uuid however

balmy valve
raw prairie
balmy valve
#

✨ google ✨

raw prairie
balmy valve
#

?

raw prairie
balmy valve
#

Going to need more info then that XD

#

Do you mean how to paste a schematic where the player is looking?

raw prairie
#

But it was too laggy

#

So I want the schematic to paste where the players are looking at

balmy valve
#

and if the player walks backwards

raw prairie
balmy valve
#

probably whatever you have your view distance on the server set to

raw prairie
balmy valve
#

sure

raw prairie
balmy valve
#

And you said that was to laggy?

raw prairie
balmy valve
#

Were there any errors?

raw prairie
#

xD

tardy delta
#

says enough

balmy valve
#

In that case I would just try using a different method to paste in the schematics, or you just need more memory

raw prairie
#

but even with 4 GB ram,

#

it still crashes

balmy valve
raw prairie
balmy valve
#

Then I would try to use a different method to paste in the schematics

balmy valve
#

Hooking into WorldEdit or FastAsyncWorldEdit maybe, there are definitely more efficient and memory saving methods than the one you used. Because i have pasted in schematics and it didnt kill the server.

Alternatively, what you could do is add a buffer, instead of trying to paste them all in at the exact same time (probably why you run out of memory), do it 1 at a time

raw prairie
#

Im relatively new to java

balmy valve
#

What I would do, make a list and on the chunk load event it adds the event to the list.
Have a runnable that runs at whatever interval you want that takes the first thing in the list and pastes it then removes it from the list

raw prairie
#

Unfortunately

tardy delta
#

check the impl of worldedit ig

balmy valve
balmy valve
# raw prairie Lmao

Just make a List of the Chunk Load Events some where and inside of your listener, add the 'e' object to the list
Then make a bukkit runnable (if you don't know how there are loads of tutorials just look it up), that runs at whatever interval you think would be good.
And in the runnabble it grabs the event at the index of 0, and does the logic that you currently have in your listener

#

does that make more sense?

raw prairie
#

Somewhat

raw prairie
tardy delta
#

tf discord

raw prairie
#

?

tardy delta
#

ah yes now my image comes

raw prairie
raw prairie
raw prairie
#

Is there a variable, etc

solid cargo
#

how would you explain on how for loops work? (I know what they do, i just idrk how they work. )

  1. make variable

  2. make boolean

  3. increment?

  4. for loop checks if the boolean is still true, if so, it does the code?

balmy valve
raw prairie
#

ok,

#

Ill try

balmy valve
#

I wish you luck

tardy delta
#

cant you just do stuff async?

raw prairie
#

as the dependacy

tardy delta
#

fawe is shit and crashes the server easily

raw prairie
balmy valve
#

I have never had fawe crash a server ???

#

It's always been better then normal WE

#

In my experience

fluid river
#

hey

#

how WE defined commands with //

#

can you do this using plugin.yml

raw prairie
#

/br

#

//br

fluid river
#

i mean

#

you can do that with plugin yml or what

raw prairie
fluid river
#
commands:
  /set:
    description: blah
#

or was it some kind of PlayerCommandPrePocessEvent listener

floral drum
remote swallow
#

probably just registering the command with an extra /

fluid river
#

well iirc WE had tab completion

#

so probably that was commandexecutor

#

nah

#

breaks the entire thing

remote swallow
#

just register it double command on setExecutor

fluid river
#

?

eternal oxide
#

you need around the command to make it a string

raw prairie
#

how can I make a List of the Chunk Load Events

eternal oxide
#

`

fluid river
remote swallow
#

yeah

floral drum
remote swallow
#

just add a slash to that

fluid river
#

will it work lol

remote swallow
#

can only test

raw prairie
#

Im trying to load schematics 1 at a time

#

so it doesn't crash servers

fluid river
#

testing

floral drum
#

what

fluid river
#

well it easily started with /banhammer in yml

#

time to see ingame

raw prairie
fluid river
#

you cant

raw prairie
fluid river
#

and why do you need that

raw prairie
fluid river
#

List<ChunkLoadEvent> events = new ArrayList<>();

raw prairie
#

instead of loading all at once

fluid river
#

ez

#

bro what

#

you mean you want to store all chunks which loaded with all events

#

and then paste schematic to every chunk

#

one by one

raw prairie
#

yea

fluid river
#

create global chunk list and just fill it every event

floral drum
#

What are you using to paste the schematic?

fluid river
#

List<Chunk> chunksToPaste = new ArrayList<Chunk>();

floral drum
#

FAWE?

raw prairie
fluid river
#

isn't there a pasting queue in FAWE tho?

raw prairie
fluid river
#

yeah /banhammer worked

#

i see now

floral drum
#

dude I have admin access on so many people consoles

fluid river
floral drum
#

why do these people trust me

fluid river
#

and run a task timer which pastes in first chunk in the list

#

like each 2 seconds

tardy delta
#

?workloaddistribution

#

?workloads

#

?workload-distro

fluid river
#

?workload

fluid river
#

no way

tardy delta
#

fuck it

raw prairie
#

Lmao

fluid river
#

work distro

floral drum
#

in FAWE

fluid river
#

distrophic

floral drum
#

you can change "extra-time-ms"

#

to like -25

#

to make it place slower

tardy delta
#

time to think about reflections in my bed

floral drum
#

@raw prairie

raw prairie
fluid river
#

what exactly isn't working

floral drum
#

if it isn't executing, be sure to register your event!

fluid river
#

does your tab work tho

fluid river
#

header and footer

floral drum
#

W

fluid river
#

L

balmy valve
floral drum
#

is the ign correct?

fluid river
#

well then default tab in spigot uses getName()

floral drum
#

omegalul

fluid river
#

not displayname

raw prairie
#

Lmao

fluid river
#

does it throw errors in console tho

raw prairie
fluid river
#

you pasted 2 different codes

#

and your problem is location where particle spawns i guess

balmy valve
fluid river
#

and in first code you have 0, 1);

fluid river
#

it might be my english level causing me to die from cringe

#

commas i guess

balmy valve
#

A. No need to be toxic, B. I'm just not focusing on grammar because it isn't really necessary?

fluid river
#

i mean i'm not native, so it's hard to read messages sometimes

#

what happens when you run your first code

balmy valve
#

The player is kicked, you can see the error in the photo attached to the original message

#

There are no errors on the server side

echo basalt
#

Don't mind nuker

hasty prawn
echo basalt
#

He's the only person in this server that had the privilege of being blocked

hasty prawn
#

That's a weird error Thonk

balmy valve
echo basalt
#

It might be a codec thing

balmy valve
#

? Afraid I don't know what that means

fluid river
#

tho nobody else blocked me except Immlusion

#

cuz i say "FREE JAVA LESSONS" sometimes

echo basalt
#

It's like a protocol issue

balmy valve
#

(Also if you guys want the full error from my log I can provide it)

fluid river
#

and he is disgusted for no reason

echo basalt
#

Gotta decompile the client n all

balmy valve
hasty prawn
#

What if you don't make the number 0?

#

Maybe it doesn't like that

balmy valve
#

Same issue

echo basalt
#

Just look at how nms does it

fluid river
#

where do you spawn particle tho

echo basalt
#

It could just be a bukkit bug honestly

balmy valve
#

Wouldn't be the first time I've run into one XD, had one with the allay not that long ago

#

I can change the visual ig

fluid river
#

allay?

balmy valve
#

mob in 1.19

fluid river
#

oh

#

i guess i need to play minecraft more

raw prairie
#

You dev mc plugins

#

Yet you don't know abt mc

hasty prawn
#

tbh I think there's a lot of devs that don't play MC

fluid river
#

exactly

hasty prawn
#

When you spend hours coding in it you don't necessarily want to spend your freetime playing it

fluid river
#

i heard something about mob voting year ago

#

is that the one

remote swallow
#

there is a mob vote on currently

fluid river
#

yeah

#

well basically

#

how are u storing your "time-before-banned"

balmy valve
#

Should be pretty simple

fluid river
#

as milliseconds to map or in pdc

#

or in file or smth

#

oh

#

well basically have a task timer which gets currentTimeMillis()

#

and then compares current time to player's stored number

#

if current time is greater -> ban the player

daring lark
#
            if(k.equalsIgnoreCase(e.getMessage())) {
                log("adada");
            }
        });``` how could i get Configuration section(i'm getting null error)
#
combatTime: 15
blockedCommandsWhilePvp:
  -"sethome"
  -"home"
  -"spawn"
  -"tpa"``` this is my config
delicate lynx
#

that's not a section

#

that's a list

daring lark
#

ok so, how can i get it from config

delicate lynx
#

use getStringList or whatever it's called

daring lark
#

thanks

raw prairie
#

how can I queue schematic pasting?

#

basically, I am trying to load schematics into new chunks, 1 at a time

bright cedar
balmy valve
#

You can use the method I gave :P

#

(tahd)

fickle mist
#

how to find out that the player has broken the block (I just think that the BlockBreakEvent event will not be very accurate in this situation)

balmy valve
graceful tartan
#

Hey, I need help with creating an npc...
im trying to make a custom npc in 1.19.2 adn it was going fine until I realised that the construction of EntityPlayer now requires 4 args and I dont know how to get the profilepublickey.

bright cedar
hasty prawn
#

I know you can get an actual player's key with
ServerPlayer serverPlayer = ((CraftPlayer) playerEntry).getHandle().getProfilePublicKey();

#

But that probably wouldn't work with NPCs

chrome beacon
eternal oxide
wary topaz
#

Is my source outdated or is buildtools outdated?

opal juniper
#

are you depending on spigot api or spigot

wary topaz
#

spigot

graceful tartan
onyx fjord
#

can i somehow force ij to use double quotes in certain file types?

#

its annoying when they mix

raw prairie
#

How can you get a method to list chunk events?

daring lark
#

log(plugin.getConfig().getStringList("blockedCommandsWhilePvp").toString()); why am i getting empty list

combatTime: 15
blockedCommandsWhilePvp:
  -"sethome"
  -"home"
  -"spawn"
  -"tpa"``` this is my config
raw prairie
#

    public void getChunksQueue(){
        
    }```
fickle mist
#

Hi! how to drop items from a block(example: Diamond Ore)

sand vector
#

So I have a pre made config.yml file in my plugin, and im trying to save these defaults and getting this error, any clue on why? I thought it might be spacing but it doenst seem to be that

zealous osprey
eternal oxide
#

You are using the wrong comment prefix

worldly ingot
#

YAML uses # for comments

sand vector
#

ah 🤦‍♂️

worldly ingot
#

(see bukkit.yml)

twilit wharf
#

I am using BungeeCord, have a proxiedplayer instance, and I need to broadcast a chat message on their server. How can I go about doing this without a bukkit/spigot plugin?\

fluid river
#

send plugin message to server

#

in spigot plugin recieve this message

raw prairie
#

Nuker

fluid river
#

and broadcast it's contents

raw prairie
#

Can you help me with something in dms

#

@fluid river can you help me with somehting in dms

fluid river
#

dm me then

#

lol

fluid river
#

check if you saved your config with saveDefaultConfig() on plugin enable

fickle mist
fluid river
#

world.dropItem or smth

shut field
#

how do I set the color of the Spell particle?

fluid river
#

since particle is enum(not a class), you can't directly modify spawned particle

#

particles are rendered by client

shut field
#

I've seen it done on a server

#

also redstone dust particles can have any color

fluid river
fluid river
#

but this is only for dust

#

redstone dust actually

shut field
elfin atlas
#

Question when I place a sign and typing something in line 0 and 1 can I get this with the block place event or do I need the SignChange Event?

fluid river
#

test it out i guess

#

probably would run BlockPlace when right clicking

#

and when confirming line changes would call SignChange

elfin atlas
#

Thx then I know what I need

fluid river
#

i'm not sure tho

fluid river
#

cuz it wraps some packets

mental sorrel
#

Hey guys,
What could be a reason for my Tabcomplete list to be shown, but not respond to typing (sticking to the first item of the list) ?

#

my Snipped:

    public List<String> commandComplete(CommandSender sender, Command command, String alias, String[] args){
        if(command.getName().equalsIgnoreCase("additem")){
            List<String> list = new ArrayList<>();
            // /addshopitem <material> <sellprice> <buyprice>
            // arg - 1 = Materials
            if (args.length == 1){
                for(Material material : Material.values()){
                    list.add(material.toString());
                }
            }
            return list; //returns the possibility's to the client
        }
        return null;
    }
elder ingot
#

You want to filter everything that isn't starting with args[0]

eternal oxide
#

everything that contains

mental sorrel
#

I use this example on my other plugin, with a fixed list, which works like a charm :|

elder ingot
#

like that

return list.stream().filter(s -> s.toLowerCase().startsWith(args[0].toLowerCase())).toList();
worldly ingot
#

I'd be hesitant using a stream in a method called every time a key is pressed

#

A traditional for loop will work fine

mental sorrel
#

but the only diff, is my for loop, which gives this 'weird' effect

elder ingot
worldly ingot
#

Yeah, you need to filter out the options that don't start with the input arg

hard socket
#

how do I make when I type player name small or capital it returns player name?

worldly ingot
#

An if statement in your for loop matching the one ikfir mentioned above will suffice

mental sorrel
#

Ok, thnx will try that!

elder ingot
#
    public List<String> commandComplete(CommandSender sender, Command command, String alias, String[] args){
        if(command.getName().equalsIgnoreCase("additem")){
            List<String> list = new ArrayList<>();
            // /addshopitem <material> <sellprice> <buyprice>
            // arg - 1 = Materials
            if (args.length == 1){
                for(Material material : Material.values()){
                    String s = material.toString();
                    if (!s.toLowerCase().startsWith(args[0].toLowerCase()) continue;
                    list.add(s);
                }
            }
            return list; //returns the possibility's to the client
        }
        return null;
    }

@mental sorrel

elder ingot
mental sorrel
#

is casting both to lower, better than using equalsIgnoreCase ?

hard socket
#

how do I make when I type player name small or capital it returns player name?

wary topaz
elder ingot
mental sorrel
#

Yeah makes sense for this case, was just wondering about the casting vs equals. performance wise.

elder ingot
#

for example
material is DIAMOND
args[0] is diam

there aren't equals but material start with args[0] if we lower case both of them

elder ingot
elder ingot
# wary topaz Bump

Did you try to clear .m2 cache and reuse BuildTools?

if you didn't go to there and delete org/spigotmc

Windows: C:\Users\<user>\.m2\repository\org\spigotmc
Linux: ~/.m2/repository/org/spigotmc

mental sorrel
wary topaz
manic furnace
#

?paste

undone axleBOT
manic furnace
#

I try to create an EntityPig like this:

Object entityPig = ReflectionUtils.getNMSClassInstance("EntityPig", ReflectionUtils.getNMSClass("EntityTypes").getField("PIG").get(null), entityPlayerObj.getClass().getField("world").get(entityPlayerObj));

But I get this exception:
https://paste.md-5.net/enajojiyuw.css
Im on 1.16.5 to test with the old nms-structure

eternal oxide
#

thats half an error

manic furnace
#

sorry

eternal oxide
#

net.minecraft.server.v1_16_R3.EntityPig would be a deobfuscated name

#

actually, its saying the class was found but no constructor which takes EntityType and WorldServer

manic furnace
#

But there is one

#

I used it without reflections

eternal oxide
#

When you used it without reflections, did you use specialsource to compile your plugin?

manic furnace
#

No mojang mappings, if you mean that

eternal oxide
#

If you are using Mojmaps are you running the remapped server?

manic furnace
#

I didnt even know there is one

#

so no

#

The classes are with the normal names

eternal oxide
#

ie WorldServer will not be called that once you are on a live server

manic furnace
#

Yeah thats strange

echo basalt
#

what if... the constructor is just flipped

eternal oxide
#

no clue I've only done NMS since 1.18

echo basalt
#

elgar you've had 10 years to do nms and you only decided to do it now

#

smh my head

eternal oxide
#

It never interested me before Spigot adopted Majang mappings 😉

elder ingot
raw prairie
#

Is it possible to build a chunk generator based on a schematics??

#

Dms now

#

How might someone generate schematics a certain amount of chunks from the player

#

Like 2-3 chunks

#

From the player

#

Right now I use a ChunkLoadEvent to generate schematics

#

Which is extremely laggy

onyx fjord
#

hi yall i have a problem with registering aliases in code

#
        getCommand("withdraw").setAliases(config.getStringList("withdraw.aliases"));
        System.out.println(config.getStringList("withdraw.aliases"));
        System.out.println(getCommand("withdraw").getAliases());
#

so this is the code

#

and output looks like this

[banknote]
[]
#

no idea why that happens

#

don tell me i must use reflection

#

that wont do in my scenario

#

mine are defined by user in config.yml

#

thats what im using in code above

#

it doesnt seem to work

#

i think it has to do with aliases needing to be registered when command is, and that part executes if command is already registered

#

so yea what i need is a way to dynamically register command aliases

worldly ingot
#

By the time you invoke setAliases(), the command and all its aliases have already been registered

river oracle
golden turret
#

guys

#

in 1.8

river oracle
#

💀 💀 🔥

delicate lynx
#

1.8 💀

golden turret
#

is this responsible for how many mobs will spawn?

#

it is for a client

#

i dont like 1.8

river oracle
# onyx fjord Yes plz

you can strip out a lot of my bullshit I still need to go back and fix this for sub commands and such

onyx fjord
#

Thx

river oracle
#

?paste

undone axleBOT
river oracle
raw prairie
#

How can you paste a schematic based on players

#

Like paste a schematic 1-3 chunsk from the player

tender shard
#

do you know how to paste a schematic in general?

raw prairie
#

I already have code to generate it every 16 blocks

eternal oxide
#

Then we don't really understand your question. You already know how to paste a schematic

raw prairie
#

like paste schematics on 2-3 chunks near the player

young knoll
#

Get player location

#

Add random value to X or Z coordinates

raw prairie
#
        if(cmd.getName().equalsIgnoreCase("name")){
            try (EditSession editSession = WorldEdit.getInstance().newEditSession(BukkitAdapter.adapt(world))) {
                if(sender instanceof Player){
                    Player player = (Player) sender;
                    Location loc = player.getLocation();
                    Operation operation = new ClipboardHolder(clipboard)
                            .createPaste(editSession)
                            .to(BlockVector3.at(loc.getX() * 11, 40, loc.getZ() * 11))
                            .build();
                    Operations.complete(operation);
                }

            }
        }

        return false;
    }```
ocean ginkgo
#

how might i run a light of code every frame for a player? I cant seem to find an "PlayerUpdate" event, and onUpdate doesnt refer to a player

#

currently am using playermoveevent but thats making it kinda janky

eternal oxide
#

The server doesn;t have any idea about frames

#

you can use teh scheduler to run code every tick

ocean ginkgo
#

maybe not frames but ticks

#

ah ok

eternal oxide
#

?scheduling

undone axleBOT
tender shard
#

usually you would call this in your onEnable() method

ocean ginkgo
#

and what if its not to be called in my main?

#

anything i have to change

#

?

tender shard
#

you can create a class that extends/implements BukkitRunnable, overriding the void run() method

#

but in 99.9% of cases, you'd want to start the scheduler from your main class

eternal oxide
#

depending on what you are trying to do

raw prairie
#

How can I paste a schematic up to a certain distance from a player?
This is what I have so far.

            try (EditSession editSession = WorldEdit.getInstance().newEditSession(BukkitAdapter.adapt(world))) {
                    Player player = (Player) world;
                    Location loc = player.getLocation();
                    Operation operation = new ClipboardHolder(clipboard)
                            .createPaste(editSession)
                            .to(BlockVector3.at(loc.getX() * 11, 40, loc.getZ() * 11))
                            .build();
                    Operations.complete(operation);

            }

        return false;
    }```
ocean ginkgo
#

(lmk if im doing this way wrong)
im trying to make it so an armorstand follows my cursor, and with playerMoveEvent, it is quite jank

eternal oxide
#

Do not multiply X and Z. add or subtract from

ocean ginkgo
#

however i also only want to do it after I click

tender shard
#

e.g. this is a runnable in it's own (anonymous) class. of course you could just create a "proper" class instead. but technically, the BukkitRunnable is NOT part of the main class

eternal oxide
#

yes

raw prairie
#

Ok

#

So I should add/subtract

eternal oxide
#

if you multiply it may look ok near to spawn, but the further away you go it grows exponentially.

raw prairie
#

So + 11

ocean ginkgo
eternal oxide
raw prairie
tender shard
#

e.g. you can call "cancel()" inside your BukkitRunnable to cancel "yourself"

ocean ginkgo
#

i would like to make an armorstand follow my cursor for a set time, and then stop

tender shard
#

okay, then you are going to want to do something like this: (gimme a minute, gotta write sth down)

ocean ginkgo
#

so far i am simply just spawning an armorstand playerMoveEvent, which is creating new armorstands everytime, instead of making it follow the cursor

tender shard
winged anvil
#

whats the plugin to change the >=

tender shard
#

something like this should do what you want. now whenever you create one of your armor stands, you'D just create a new ArmorStandFollower(...), then call runTaskTimer() on it

tender shard
tender shard
winged anvil
#

love you

tender shard
#

np

ocean ginkgo
#

could you extend BukkitRunnable and also listener? or better to just have multiple classes

tender shard
#

well

#

BukkitRunnable is a class. you can extend that

#

Listener is an interface, you can implement that

winged anvil
#

whenever you create a new bukkitrunnable, thats not the same as running on a separate thread or ?

tender shard
#

you can implement as many interfaces as you want, and you can always extend exactly one class

#

however, you shouldnt register a new listener for every of your armor stands. you should rather have only one listener for all of them

ocean ginkgo
#

ok

tender shard
#

e.g. runTaskTimer() runs on the main thread

winged anvil
#

yaya

ocean ginkgo
#

im spawning the armorstand withing an PlayerInteractEvent, how do I reference it outside of it, or do I just put the public void run inside the event

tender shard
#

runTaskTimerAsynchronously() runs on a random thread from the scheduler's thread pool

tender shard
#

why do you need to access it from outside?

ocean ginkgo
#

as in

#

the run wouldnt reference the stand spawned in the interact event

#

right

#

?

tender shard
#

you really shouldnt mix up listeners and runnables in one class

#

you should have one listener, and one runnable. you don't even need one runnable per armor stand

#

I'll send you some example in a minute or 5

ocean ginkgo
#

alright

raw prairie
#

OH IM SO DUMB

#

LMAo

ocean ginkgo
#

forgot to save it? xd

raw prairie
#

instead of true

#

💀

ocean ginkgo
#

💀

tender shard
#

VERY DIRTY CODE, but you get the idea:

#
public class NMS extends JavaPlugin implements Listener {

    private final Map<ArmorStand, Player> armorStandMap = new ConcurrentHashMap<>();
    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
        Bukkit.getScheduler().runTaskTimer(this, () -> {
            for(ArmorStand armorStand : armorStandMap.keySet()) {
                Player player = armorStandMap.get(armorStand);
                if(!player.isOnline()) continue;
                armorStand.teleport(player.getLocation());
                if(armorStand.getTicksLived() >= 20) {
                    armorStand.remove();
                    armorStandMap.remove(armorStand);
                }
            }
        }, 1, 1);
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        ArmorStand armorStand = event.getPlayer().getWorld().spawn(event.getPlayer().getLocation(), ArmorStand.class);
        armorStandMap.put(armorStand, event.getPlayer());
    }

}
#

this will spawn an armor stand for every new joined player and make it follow them for 20 ticks, then after that, remove the armor stand again

#

normally, you should NOT put entities into a map, but rather only store their UUIDs

ocean ginkgo
#

what does map mean?

#

?map

tender shard
#

a map is like a phone book

#

it "maps two values together"

ocean ginkgo
#

ohhh

#

ok

tender shard
#

e.g. imagine John has phone number 12345 and Lea has phone number 9876

#

then you can do map.get("John") and it returns 12345

ocean ginkgo
#

kinda similar to like an array but instead of index being ints, it can be any var

tender shard
#

yeah, kinda like that, but still different

#

?learnjava

undone axleBOT
tender shard
#

you should check out one of those tutorials, I'm sure they all have a good explanation about maps ^

ocean ginkgo
#

sorry lol im a migrant from C# in unity

tender shard
#

otherwise, google "baeldung java map"

#

baeldung always has awesome descriptions

tender shard
#

this explains maps perfectly

ocean ginkgo
tender shard
#

oh that's just the name of the class I used for my example code

#

it doesnt mean anything in this case

#

I just put the example code into the first class I had open

raw prairie
#

what should I iniatlize world

#

to ?

eternal oxide
#

location.getWorld()

#

or Player#getWorld()

tender shard
#

You cannot cast a player to world

#

And you probably need the WorldEdit world, not the bukkit one

tender shard
#

What exactly is the error you got?

raw prairie
tender shard
#

Oh i see

#

Mb

raw prairie
tender shard
#

You never set „world“ to anything

raw prairie
tender shard
#

Do not do „World world“ but do „World world = myPlayer.getWorld())“

eternal oxide
#

I've not used WorldEdit so I've no idea what it requires

tender shard
tender shard
raw prairie
tender shard
raw prairie
#

I should set player to something

#

but what

eternal oxide
#

That isn;t valid Spigot code. EventHandler annotation is for actual events

#

command is not one

tender shard
#

right now, you only tell java "yo, I have a Player, and I will call it "player" from now on". but you never told java WHO this player is.

String myName; // Okay, we got a variable called name, but it has no value

String myName = "mfnalex"; // Now we're talking!
#

btw your whole command() method cannot work, you annotated it with EventHandler but it doesnt take any Event object as argument

raw prairie
#

🤦‍♂️ oh

tender shard
#

if this is supposed to be a command, then it should implement CommandExecutor and have a onCommand(CommandSender, Command, String, String[]) method instead

#

if it's supposed to listen to events, you need an EventHandler annotated method that takes only one event as argument and nothing else

#

so - is it supposed to be a listener for events, or a command executor?

raw prairie
tender shard
#

yeah, but when? when someone does something "ingame", e.g. when they die, when they spawn, when the left-click something, ... ? (listener)
or when they enter /dosomething ? (command)

dawn hazel
#

?paste

undone axleBOT
raw prairie
tender shard
#

erm

#

pls open a thread quickly, I'll answer you there again

dawn hazel
tender shard
dawn hazel
#

thats this code

        try {
            loadConfiguration();
        } catch (IOException e) {
            e.printStackTrace();
        }```
eternal oxide
#

this would be his line 26 if (config.getFloat("Config-Version") != 1.0) {

#

you don;t set a config value

dawn hazel
#

should mention this is bungeecord btw

#

if that helps

eternal oxide
#

the line I posted is where your error is (from what you have shown)

dawn hazel
#

thats odd

#

because line 26 is the try loadconfig thing

#

line 32 is the one that checks the value

eternal oxide
#

its failing on .getFloat(String) as config is null

dawn hazel
#

but if i remove that return; at the end of the value checker the issue seems to be completely not existent

#

and it shows the message

ocean ginkgo
#

im wondering about the maps thing, wouldnt it be easier to just assign the armorstand to the player at the time of armorstand spawn, which is on intteract?

eternal oxide
#

do you attempt to read a float anywhere else?

eternal oxide
#

then your error is you never assign a value to your config field

dawn hazel
#

thats odd tho

eternal oxide
#

Configuration config;

tender shard
dawn hazel
#

because loadconfiguration() runs before the value checker and if i keep the return; in if (config.getFloat("Config-Version") != 1.0) { commented it shows it just fine

eternal oxide
#

then you should be doing config = loadConfiguration();

#

if loadConfiguration() returns a config

dawn hazel
#

loadconfiguration doesnt return a config. it simply loads the config itself

#
    public void loadConfiguration() throws IOException {
        File configFile = new File(getDataFolder(), "config.yml");
        if (!configFile.exists()) {
            getDataFolder().mkdir();
            Files.copy(this.getResourceAsStream("config.yml"),
                    configFile.toPath());
            getLogger().info(ChatColor.translateAlternateColorCodes('&', "&aConfig Created"));
        }
        config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
    }```
#

hack jobby ik

eternal oxide
#

make sure you config.yml has actually been saved

#

and make sure the very last line runs without error

dawn hazel
#

ill try that

eternal oxide
#

else paste you full Main class

#

?paste

undone axleBOT
tender shard
#

yeah please paste the full class

dawn hazel
tender shard
dawn hazel
#

yeah

#

bungee

tender shard
#

ah I see

dawn hazel
#

bungee configs are weird

eternal oxide
#

yeah that error you posted does not align with that code

tender shard
#

yeah, I need the javadocs

#

?jd-bc

eternal oxide
#

line 26 is impossible to throw that error

fading spindle
#

i cant import JavaPlugin, even though im running on JDK 17 and i am using maven, everything seems fine to me anyone know why thi is happening?

dawn hazel
eternal oxide
#

Your config loading code is fine

#

then the jar you have on yoru bungee proxy is not the same as that code

#

its impossible for a try { to throw an NPE error

dawn hazel
#

ok thats weird

#

this time it did what it was suppost to do with zero error

eternal oxide
#

You must have had an old jar on yoru bungee

dawn hazel
#

i guess

#

its working fine now

tender shard
#

maybe you accidentally only restarted the backend server and not the proxy

dawn hazel
#

its a localhosted server

#

and im running only the proxy

tender shard
#

oh then no idea

#

lol

dawn hazel
#

weird

eternal oxide
#

My guess would be tried to replace teh jar with proxy still running without realizing

dawn hazel
#

must just be a case of old jar syndrome

eternal oxide
#

yep

dawn hazel
#

cause its working fine now

tender shard
sand vector
#

Question with mysql. I got a playerData table and want to take all the info from it and store it in memory so I don't have to keep pulling from the database. What would be the best way of doing this? (I have searched, but nothing that I think would work has shown yet)

eternal oxide
#

it depends what playerData contains

tender shard
#

and it should have the same fields as your table

#

e.g. if your table looks like this:
INT age;
VARCHAR(32) name;
then your class should look like this:

public class PlayerData {
  int age;
  String name;
}
#

then just construct this class with all the data you need when a player joins, or whenever you need it

#

you should NOT load the whole database of course, but always only the players you need

#

otherwise using sql in the first place makes no sense

sand vector
#

Ok cool, last thing then is how would I do this per player?

tender shard
eternal oxide
#

Did you not create the table and store the data?

tender shard
eternal oxide
#

This seems like deja vu

#

are you trying to read Essentials SQL data?

tender shard
#
final Map<UUID,PlayerData> map = new HashMap<>();

@EventHander
pubic void onJoin(PlayerJoinEvent event) {
  UUID uuid = event.getPlayer().getUUID();
  // Do your SQL stuff here
  String name = ...;
  int age = ...;
  // End of your SQL stuff
  map.put(uuid, new PlayerData(name, age));
}
#

this is a very dirty solution

#

you should normally NOT do it like this

#

you should run your SQL stuff async and use futures

#

it depends on how fast you need the data, ofc.

#

do you need it right when they join? or is it okay if you only get it 5 ticks later? etc etc

floral drum
sand vector
#

then delete it from memory when they leave

#

what are futures, just so I can google the correct thing 😛

tender shard
#

you can google "java CompletableFuture"

#

but

#

do you ever need data of offline players?

#

and do you save tons of data, or just a tiny bit?

#

because this sounds like you'd be way better off using the player's PDC instead

#

then you don't need any external mysql databases

raw prairie
#

How might I paste a schematic at the middle/corner of the chunk the player is currently located at?

tender shard
#

and you always have the data instantly

tender shard
tender shard
#

it's just pseudo code

raw prairie
#

lmao

tender shard
#

pseudo code is "that's the general idea but not valid java"

sand vector
#

yeah id need to access curtain bits of data. also need to store other things like clans and other things like it

tender shard
sand vector
#

yes

tender shard
#

then you need to take a look at CompletableFutures. Doing SQL stuff is a pain in the ass if you don't wanna block the main thread, and you really don'T want to block it :/

#

basically EVERYTIME you ask for data, you will have to check if the data is already there

#

you can never directly do myPlayerData.getClan(), you always have to deal with futures

raw prairie
#

[ERROR] Failed to read chunk [1, 1]

java.util.concurrent.CompletionException: java.nio.file.FileSystemException: /home/gs-41479/./world/entities: Disk quota exceeded

#

?paste

undone axleBOT
raw prairie
#

its spamming this

eternal oxide
#

disk quota exceeded

raw prairie
eternal oxide
#

not enough disk space

raw prairie
#

Or memeory

eternal oxide
#

storage

raw prairie
#

oh

#

its cause the logs were spammed 😅

raw prairie
#

Like it kept spamming history file

#

for WE

#

How do I get the chunk of the player?

fluid river
#

player.getLocation().getChunk()

fluid river
#

i don't

sand vector
tender shard
#

no

#

that will completely ignore the advantages of it

#

you block the main thread by calling .get()

#

so, whoever calls your getPlayerBal() method will do this:

  1. Create a nice async completable future, that will try to get the balance async, in the background
  2. but in the next second you immediately use .get(), telling the future to "GET IT RIGHT NOW!!!!!!!11111", blocking the whole thread
worldly ingot
#

Your method should return the CompletableFuture

tender shard
#

your method should not return a Double (it should, at all, return a double instead of a Double anyway), but rather a Future<Double> or sth

worldly ingot
#

CompletableFuture specifically. Returning a Future doesn't grant you access to a lot of CF's useful methods

tender shard
#

sure, true

#

return values should always be as specific as possible anyway

#

there's no reason to ever return a Map<?,?> if you could return a HashMap<?,?>

worldly ingot
#

The opposite, actually

tender shard
#

no

#

the opposite is true for parameters (input)

worldly ingot
#

You should be as generic as possible so that if implementation ever changes, then nothing breaks

tender shard
#

the output should always declare what it returns as specific as possible

#

if you return a HashMap, why not declare that it returns a HashMap?

worldly ingot
#

Because what if it becomes a ConcurrentHashMap later?

#

You broke ABI

tender shard
#

doesn't that also extend HashMap?

worldly ingot
#

Nope

tender shard
#

Huh okay

#

weird

#

the name suggests that it does

worldly ingot
#

It's just that in the case of CompletableFuture, there are methods you will absolutely need when working with futures

#

Things like whenComplete() or thenAccept() don't exist on Future

tender shard
#

anyway, if I'd have a method that returns a List, I'd rather declare it to return a List instead of a Collection

#

I mean, otherwise we could just make everything return Object

worldly ingot
#

If you specifically have a reason to return a List (i.e. to denote that it's ordered or for the sake of random accessibility), then yes

#

You can't Collection.get(0), but you can with a List

tender shard
#

yeah but now one could also say "you broke ABI" if the List ever changes to something that's not a list anymore

worldly ingot
#

Correct, but that's more of an API design fault than anything

#

You would almost never return ArrayList for instance

tender shard
#

I'd rather make the return values as specific as possible, and the "input things" as generic as possible. and when something changes, well, then whoever depends on it has to change it too

tender shard
worldly ingot
#

You accept what you need, and you return when you want to expose and guarantee. It's the whole purpose of polymorphism. It's how Bukkit works

tender shard
#

I actually meant to say "as input: take the most generic INTERFACE possible. as output: return the most specific INTERFACE possible"

#

not implementations, but interfaces

#

that's what I wanted to say

fluid river
#

well tho

#

You need to find balance

#

Cuz if you return object you will only have like .clone() and .equals()

#

but if you return a collection instead of list

#

you won't lose much

tender shard
#

yeah obviously, I didnt ask people to return Object everywhere

fluid river
#

you would still be able to use .get() and .add()

tender shard
#

I used this example to say that "using the most generic super-class/interface is a bad idea"

fluid river
#

well the most is bad

#

but returning a Collection instead of ArrayList isn't bad

tender shard
#

i dont see any reason to not use the most specific one in return values

#

well choco gave one example, but that was for implementations, not interfaces, so I adjusted my statement

#

I think you should give the most specific return value and the least specific input thingy

fluid river
#

i mean that's a genereic programming paradigm pattern

#

i guess

#

you should have a super-interface as a return type if it doesn't break anything

tender shard
#

But how would you know if it breaks anything

#

Eg i remember when bukkit changed the return type of getOnlinePlayers

#

Used to be Player[] now its collection<Player>

#

If they just used Iterable, there woukd be no problem

fluid river
#

arrays don't implement iterable tho

tender shard
#

I think they do

fluid river
#

only serializable and clonable

#

no they dont

#

😭

#

They have JNI realization

tender shard
#

Hm okay i have to trust you on that, im only on the phone

fluid river
#

instead

#

so most of arrays code is implemented into jvm itself

#

so under the hood it's always type*

#

I mean for List and ArrayList and LinkedList

#

they definitely have all same methods

#

and List is a superinterface to both AL and LL

#

So if you return a list instead of linked list nothing's gonna break

#

all of the methods would still be accessable

#

the only thing which is gonna break is performance

#

Cuz if guys would cast list to ArrayList and loop through it, it would be slower than looping through list which was casted to LinkedList

tender shard
#

yeah sure, I think I misphrased my above statement. I wanted to say "you should return the most specific interface that makes sense". If you return a List but might think that it could also be a Set in the future, then return a Collection. But if you're sure that I'll keep staying a List, then it makes no sense to say "yeah this is a Collection"

fluid river
#

the main reason arrays don't implement iterable

#

are primitive types which iterable can't store

#

blame java devs i guess

#

In Rust this is fixed probably

tender shard
#

yeah this whole boxing/unboxing stuff is a bit weird

#

anyway, I'm almost first in line at the security now, gotta put my phone into the xray, brb lol

fluid river
#

cya

#

is that you on profile picture tho

tender shard
fluid river
#

sad i can't see full

#

pfp limits in discord

tender shard
fluid river
#

bruh tih coat

sand vector
fluid river
#

i never used completable future

#

ask questions

tender shard
#

Join() and get() both block. You must make your code wait until the future has completed. That means, everywhere you need the balance, you need to do it with a scheduler

#

you cannot just magically do ```java
double balance = myBalanceFuture.get();

and expect it to both, work without blocking but still immediately get you the result
#

you either must wait until the result is there (async, whatever), or block.

fluid river
#

isn't there some thing like

#

Future#whenHappened()

#

() -> {}

tender shard
#

yes, but if they e.g. need the result in an event, this wouldnt work

#

I imagine they want do so something like this:

fluid river
#

well you can cancel the event and when future is like happened

#

manually do the work

#

not the best solution

#

but i don't know what guy needs

#

goin' up

tender shard
#
@EventHandler
public void onTradeWithTrader(VillagerTradeEvent event) {
  double balance = getBalanceOfPlayer(event.getPlayer());
  if(balance <= 10) {
    event.setCancelled(true);
  }
}

so that will obviously need the balance RIGHT NOW.

There is one solution to your problem:

Fetch all the data you need on player join, and save it, e.g. in your Map<UUID,PlayerData> thing. If the result isn't there yet, block ALL interactions made by this player, until the information is there.

fluid river
#

but he gets balance from SQL or smth?

tender shard
#

they want to gather the data on join from SQL, yes

fluid river
#

can't you modify out-of-block variables like in scheduler tho

#

in completable future

#

like

tender shard
#

how would you cancel the event when it already happened?

fluid river
#

oh true

#

wouldn't work for cancel

#

but you can modify player in scheduler

tender shard
#

if you use a whenComplete(() -> { ... event.setCancelled(true); }

#

wouldnt work

fluid river
#

even after the event is cancelled

#

like if you declare Player p = event.getPlayer();

#

and next line run task timer

tender shard
#

in the event, you need to have the data. or you cancel the event immediately and tell them "You cannot interact with this villager yet, please try again in a second, we still need to load your player data"

#

that's the only reasonable solution I see

fluid river
#

well yeah

#

save to map or pdc

tender shard
#

well, or to block the whole server, but that sounds like a shitty idea

fluid river
#

pdc gonna be slower

tender shard
#

IIRC it's for a clan system or similar

fluid river
#

Map<UUID, Double>

#

String[][] xD

tender shard
#

in theory, they could ofc just load all data from a flat file or similar on join. unless they have 2 million players, this shouldnt be a problem

fluid river
#

UUID ID = UUID.fromString(arr[0][0]);

#

Double balance = Double.parseDouble(arr[0][1]);

#

ez

#

where is realloc at java hmm

tender shard
#

if I was them, I'd use the PDC and if I ever needed to access it while the player isn't online, I'd just create a new PersistentDataContainer and directly load the .dat file into it

#

.dat file -> PDC is only 2 lines with NMS

fluid river
#

i guess instead realloc you would need 2 for loops

#

bad java arrays

tender shard
#

yeah java arrays suck

#

and not in the good way