#help-development

1 messages · Page 1961 of 1

grim ice
#

to know what something is

lavish hemlock
#

A lot

waxen plinth
#

Not all

grim ice
#

o

lavish hemlock
#

Not all but a lot yeah

waxen plinth
#

You can write a parser that doesn't use bnf

#

Bnf is just a way to can make it simpler

grim ice
#

ic

lavish hemlock
#

It's typically used as a regex-like format that parser generators read to generate code that does the same thing

grim ice
#

nah this aint simple ._.

waxen plinth
#

What, the bnf?

grim ice
#

yes

lavish hemlock
#

You just have to learn it

waxen plinth
#

It is though

grim ice
#

how is this simple at all

waxen plinth
#

​integer ::= [0-9]+

lavish hemlock
#

If it weren't simple, Groovy wouldn't use ANTLR, which uses an extended form of BNF.

waxen plinth
#

"an integer is a series of digits"

#

​decimal ::= [0-9]+ "." [0-9]+

lavish hemlock
waxen plinth
#

"a decimal is a series of digits, then a dot, then another series of digits"

lavish hemlock
#

That's what that represents.

waxen plinth
#

Yes

#

​boolean ::= "true" | "false"

lavish hemlock
lavish hemlock
waxen plinth
#

"a boolean is either the literal word true or the literal word false"

grim ice
#

list ::= "[" sep (object ("," sep object))? sep "]"
map ::= "{" sep (mapEntry ("," sep mapEntry)
)? sep "}"
mapEntry ::= string sep ":" sep object

#

what the is this

waxen plinth
#

Start with list

lavish hemlock
#

I imagine if there were no sep then it would be easier to read

waxen plinth
#

Yes get rid of sep for now

#

​list ::= "[" (object ("," object)*)? "]"

#

Sep just matches whitespace

#

Now you have a list

#

It starts with [

#

It optionally has an object in it

#

Where an object can be any value

grim ice
#

and the object can have another object

waxen plinth
#

That object is followed by a comma and another object repeated between 0 and infinity times

grim ice
#

o

waxen plinth
#

So it can be []

#

Or [1]

#

Or [1,2,3]

#

If you put the seps back in it just allows you to have whitespace between those tokens

#

So it can be [1, 2, 3] or [ 1 , 2,3 ]

#

Make sense?

vale ember
#

how can i disable natural mob spawn in specific area but be able to spawn mobs there from code?

grim ice
#

yes

lavish hemlock
#

So yeah BNF is really easy to understand you just need to understand the syntax and break it down like any language.

grim ice
#

i guess its simpler than what it looks like

waxen plinth
#

Yeah it's really powerful

#

Too bad I haven't had a good use for it

#

I'll use it next time I make a custom format I guess

grim ice
#

i should learn json

waxen plinth
#

It's easy as hell

lavish hemlock
#

Typically people write grammars (language descriptions) in BNF before actually writing their parser

waxen plinth
#

You can learn json in a few minutes

lavish hemlock
#

It's like an outline of what to do

grim ice
#

o

waxen plinth
#

Yeah

#

I have a library that creates a lexer out of a bnf file

lavish hemlock
#

BNF essentially becomes the bridge between machine and human understanding of language.

waxen plinth
#

That spits out a token tree you can then parse much more easily than a raw string

lavish hemlock
#

Oh that's p'cool

waxen plinth
grim ice
#

thats cool

waxen plinth
#

RedLex-JSON is basically just a demo of how to use it

#

But there's no real reason to use that as an actual JSON parser

sacred mountain
#

how do i apply knockback to a player

#

using a vector or sum

grim ice
#

Making a parser for json is probably way too good for me atm, or am I overestimating it

hybrid spoke
waxen plinth
#

Because it's ~5x slower than my regular json parser

waxen plinth
hybrid spoke
#

everytime i see @waxen plinth in this channel he is selfadvertising for his libs

sacred mountain
waxen plinth
#

You can start with simpler parsers

grim ice
#

ic

hybrid spoke
sacred mountain
#

i can do

double distance = e.getEntity().getLocation().distanceSquared(le.getLocation));

#

thats the distance but thats all ive done

waxen plinth
#

That won't help

#

Get the vector from the explosion to the player

sacred mountain
#

itll do more knockback

hybrid spoke
#

then get the vector of the explosion in relation to the players

waxen plinth
#

player.getLocation().subtract(tnt.getLocation()).toVector()

#

That gives you the vector from the tnt to the player

lavish hemlock
#

Writing an HTTP server is also a pretty good exercise imo

waxen plinth
#

Then you can normalize it and add it to the player's velocity

sacred mountain
sacred mountain
#

oh ok

waxen plinth
#

No need to invert

#

That would make it pull them in

waxen plinth
sacred mountain
#

that would be a cool idea for a black hole thing lol

lavish hemlock
#

I mean you don't need to make a full server

waxen plinth
#

No I mean an http server can be just about anything

lavish hemlock
#

Ah well

#

A webserver then

waxen plinth
#

That's arguably more broad

lavish hemlock
#

A server that displays a page when you visit it in a browser

waxen plinth
#

Yeah but what

lavish hemlock
#

What page?

waxen plinth
#

A file server could be a good project

lavish hemlock
#

Literally fucking anything :p

waxen plinth
#

A chat room

#

Yeah that's a bit like saying "writing a program is a good project" lol

#

"try making a plugin"

grim ice
waxen plinth
#

Though for anyone trying to write an http server and wanting to make it use https

grim ice
#

But I don't have that much of a clue

#

of how to do that

lavish hemlock
#

Not hard, just need a bit of socket magic

waxen plinth
#

It's a huge fucking pain to do with java

#

But easy to do with certbot and caddy

grim ice
waxen plinth
#

🧠

lavish hemlock
waxen plinth
#

Huh

#

Just use HttpServer

lavish hemlock
#

Netty is also a decent choice?

#

What's the fun in that though?

waxen plinth
#

If it's gonna be a web server anyways

#

I guess

lavish hemlock
#

The entire idea is to code the requests yourself

sacred mountain
waxen plinth
#

I mean

lavish hemlock
waxen plinth
#

I guess that could work

#

I think normalize mutates?

#

So yeah

sacred mountain
#

wdym

grim ice
waxen plinth
#

But you might wanna add instead of setting

grim ice
#

it accepts input

#

then writes it in the website

sacred mountain
#

maybe im wrong

grim ice
#

But like

#

where do I host it

waxen plinth
grim ice
#

@waxen plinth is it possible to make a website to write the messages that chatroom receives?

#

i mean it is possible but do you know some keywords I can use to search?

sacred mountain
#

ty

gritty urchin
#

hey

#

is there is a list of yaw and their direction values

#

e.g. NORTH, EAST, SOUTH, WEST

grim ice
#

either way I need to learn html so fuck

naive bolt
#

whats the maven version for 1.8

#

just 1.8-R0.1-SNAPSHOT ?

grim ice
#

1.8.8 is what i use

tidal hollow
#

I have created an item but I want to make it only have one use, that is, when it is used it disappears. how could i do it?

sterile token
grim ice
#

if its a breaking tool then check for break event then player's main hand

#

and replace it with air

sterile token
tidal hollow
#

it is not a tool

dusk flicker
#

So in the end, 1.8.8-R0.1-SNAPSHOT

tranquil viper
#

I'm using essentials to give me a spawner, however, when I break the spawner it always says the .getSpawnedType() is PIG. Does anyone know how I should go about getting the real spawnedType?

storm crescent
#

Is there a way to clear out player data for all plugins?

tranquil viper
#

otherwise just clear the database

storm crescent
#

Alright thanks

gritty urchin
#

How to set look direction

#

of a bat?

#

yaw seems to be always 0

#

despite changing the direction with #setDirection()

#

of the entity

midnight shore
# tidal hollow it is not a tool

Then listen for a PlayerInteractEvent and if the action is click air or click block check if the amount of the ItemStack clicked is greater or equal to 2, if yes, subtract one from the ItemStack if no, set the ItemStack to be air

midnight shore
#

To set the yaw, make a new location, change the yaw and then teleport the bat to it

main dew
#

Hi how I can copy all world region? Exists API to do it without problems?

sturdy ivy
#

Like if I wanted to take a block by location how can I do that. I know there is getWorld().getBlockAt(x, y, z); but I have a problem because I want to loop this about 8mil times.

tranquil viper
#

Is it possible to copy a blocks persistentDataContainer?

#

And if so, how do you set one blocks persistentDataContainer to another block

restive abyss
#

why does it show an error i have the spigot jar added to the modules

opal juniper
delicate lynx
restive abyss
#

whats that supposed to mean

delicate lynx
#

use a proper dependency handler like maven or gradle

severe folio
#

?maven

undone axleBOT
severe folio
#

?gradle

#

kthen

lavish hemlock
#

I denounce Gradle

#

Maven is just

#

superior

severe folio
#

i like both

#

i just use maven

low temple
#

Gradle is for people who wash paper plates

severe folio
#

lmfao

restive abyss
#

ok thank you

grim ice
#

remove item from inventory

restive abyss
#

is the "minecraft developement" intelliji plugin good or no like should i set it up normally without it or is it actually helpful?

opal juniper
#

its good

#

doesnt require setting up really

gloomy arch
#

Hi, does anybody have suggestions for software that renders Minecraft chunks into like an isometric view 2d image?

restive abyss
#

ok thank you

gloomy arch
grim ice
#

not just spigot

gloomy arch
#

Not create NFTs but just the images

grim ice
#

even forge, paper, velocity, bungeecord

restive abyss
#

thx

grim ice
#

its amazing

sturdy ivy
opal juniper
#

but the game does that for you

grim ice
#

does using a method that returns an object for example

#

World.getAtBlock(x, y, z)

#

will the block

#

object keep it self in memory

#

(if we dont assign it to a variable)

opal juniper
#

The jvm should chuck the memory back in the heap eventually but it will exist for a little bit

grim ice
#

o

midnight shore
grim ice
#

so will creating a new thread every 100 blocks and doing operations for 8m blocks lag it

opal juniper
#

the jvm is pretty smart, but im not sure exactly how it will work with that

sick herald
#

I am trying to use components for chat. I am using the component builder however the text I want is already colored so i cannot just do .color(ChatColor.something). An example of this is I am trying to allow users to type [item] in chat and display the item that they are currently holding. I am using hex colors for this so it has made my life a lot more complicated and i do not want to over complicate things if there is an easier solution. please let me know if you know one.

grim ice
#

for example:
(pseudo code)

for 8m blocks each 100 blocks make a new thread, and in that thread save the 100 blocks with their material name in a hashmap

#

not sure if thats even psuedo code

sick herald
grim ice
#

it isnt but yes

lavish hemlock
grim ice
#

most arent

lavish hemlock
#

Bukkit isn't thread-safe so you can't have shared mutable state.

#

But you could still easily have a bunch of asynchronous operations.

midnight shore
midnight shore
grim ice
#

imagine if the hashmap suddenly disappears

#

will the memory still have something related to what we just did

midnight shore
grim ice
#

Yes, deleted

sick herald
#

real name

midnight shore
#

Oh do you want precisely hex colors?

#

That’s not as easy as I thought

sick herald
grim ice
#

how about the blocks

#

the getBlockAt method, will it keep the blocks on memory

midnight shore
grim ice
#

I know

#

ahhhh 1s lemme say it simpler

#

i looped through 8 million entries without creating new variables, printed out each one, what will happen to memory after the process is finished

sick herald
# midnight shore That’s not as easy as I thought

in order to do that I would have to do something like new ComponentBuilder().color(ChatColor.of("#0000FF")).append(text to be colored).create however the string that I am appending is already pre colored

midnight shore
#

Anyways Why would you save that amount of blocks?

sturdy ivy
#

Is there a faster way to do it?

midnight shore
midnight shore
grim ice
#

:o

sick herald
midnight shore
midnight shore
sick herald
# midnight shore So why would you color it again?

thats how the component builder works, thats how you should color things, however it makes it complicated for me to get hex colors from a string like this §x§0§0§F§B§2§8D§x§0§0§F§4§4§9i§x§0§0§E§D§6§Aa§x§0§0§E§7§8§Am§x§0§0§E§0§A§Bo§x§0§0§D§9§C§Cn§x§0§0§D§2§E§Dd §x§0§1§B§F§F§9P§x§0§4§9§F§F§2i§x§0§6§7§F§E§Bc§x§0§9§6§0§E§4k§x§0§B§4§0§D§Ca§x§0§E§2§0§D§5x§x§1§0§0§0§C§Ee

midnight shore
#

?

opal juniper
grim ice
#

Not minecraft related

#

just java

sick herald
#

well

#

thats a whole different story

sturdy ivy
ancient jackal
#

is there a way to remove warnings for CommandExecutor onCommand overrides?

sick herald
midnight shore
#

Then you can trim the colors off and color it after?

sick herald
# grim ice just java

can you try to explain what you are trying to do exactly so we can give you a definitive answer without a bunch of unknowns/whatifs?

midnight shore
#

No no

#

Wait

opal juniper
grim ice
#

what if u get an object from an arraylist, then without assigning it to a variable, u perform operations to it

#

will the memory still keep the object in memory

#

if so for how long

sick herald
# midnight shore Then you can trim the colors off and color it after?

my thought process is strip the color, turn it into a char[] (since each letter has a different color because of the gradient) and then translate the color of that letter to a hex color so §x§0§0§0§0§F§F -> #0000FF and then apply the color one by one, but i dont want to overlook an easier solution first lol

ancient jackal
midnight shore
lavish hemlock
#

Yeah

ancient jackal
#

I wouldn't worry about memory in java for a start unless you're using large amounts of data, then you should just worry about how much you're actually taking up

lavish hemlock
#

Also there is no real difference between assigning a variable and not assigning it

sick herald
lavish hemlock
#

You're still pushing the reference to the stack internally

midnight shore
lavish hemlock
#

Difference is if the reference persists in that method through the frame's locals

#

(Which it will if the variable is then used later on, e.g. loading it through ALOAD <index>)

#

So yeah no there is no real difference.

midnight shore
#

Could you say what are you trying to do with 8 mil blocks? Maybe there is a simpler way… just explain

grim ice
#

its not my problem it's someone elses and he just dipped but im wondering how would u replace 8 million blocks

sick herald
# grim ice o

i learned java a couple months ago and it took months for me to understand pointers and such but if memory usage is a concern, i would try to get a good understanding of pointers (assuming you dont have one already)

midnight shore
ancient jackal
midnight shore
#

Cause by counting them one by one you are adding bytes to the for loop I guess

lavish hemlock
midnight shore
#

So by making more you free some space

lavish hemlock
#

Technically blocks are just syntactic sugar.

ancient jackal
lavish hemlock
#

Primitive values are bound to a method while the method is being executed.

ancient jackal
#

gc will get it

lavish hemlock
#

This is because they are either:

  • Locals from the method's parameters (which are copied to the method on invocation by the JVM)
  • Constants from the class's constant pool
sick herald
lavish hemlock
#

Meanwhile, references are cleaned by the GC, instead of just cleaning out the method's operand stack after execution.

grim ice
#

ic

#

anyone knows a guide to performance optimization

ancient jackal
#
for(int i = 0; i < 5; i++) {
  int x = 2;
  System.out.println(x);
}```
what happens to x and i @lavish hemlock
lavish hemlock
#

Uhh you mean for code or for servers?

grim ice
#

code

#

I wanna make my code faster

sick herald
#

what is your code

midnight shore
#

Faster to write or faster to read for minecraft?

grim ice
#

Not a certain project

#

Faster to run

sick herald
#

you cant just ask your code to run faster generically, you have to optimize it piece by piece

grim ice
#

Yes but what are rules to follow

#

to make performing software

sick herald
lavish hemlock
grim ice
#

while(true) will still make a memory leak even if u have ultra gaming cpu

lavish hemlock
#

Oh and actually x is likely an ICONST_2 instruction considering it is never used beyond the println

ancient jackal
midnight shore
#

There aren’t a lot of ways to boost performance, whatever you handle will count towards your performance. It doesn’t really change if you have an array or a list

lavish hemlock
#

Well they don't exist after the for loop because they were used (popped) by previous instructions.

#

Syntactically, they are bound to that scope.

#

Compiled, they are just values.

lavish hemlock
#

It's true on a language level but when it comes to how the program actually executes it's false.

midnight shore
#

FAWE Does a lot of calculations, for example if you have a plain 512x512 it will divide into smaller pieces to decrease the amount of data processed

sick herald
ancient jackal
#

well I'm coding in java and understand that the variables will quickly go away from memory after leaving a block

lavish hemlock
#

This is then stored and loaded because the compiler is shit

#

We push another constant of value 5 and compare it to the previous 0 (which we just loaded)

#

(i < 5)

gloomy arch
lavish hemlock
#

Push constant 2, that's the x = 2, which gets stored so we can shift its position around in the operand stack.

glossy venture
glossy venture
#

and invokevirtual

ancient jackal
#

what happens to the variables and constants in the end

lavish hemlock
#

Uhhh we get System.out, load x again, invoke println and then increment i

#

Then we go back to pc 2 and do another comparison

lavish hemlock
grim ice
#

I get that they're always marked alive, but how did they end up like that

lavish hemlock
#

That one points to a Fieldref

#

Which is a combination of a Class and NameAndType constant

gloomy arch
# grim ice why do they not get deallocated

In languages like C, you have to allocate the memory for your objects yourself. So you also have to take care of deallocating that memory. In Java, to allocate memory you just call new Object()

lavish hemlock
glossy venture
#

why are they constant integers, couldnt the bytecode just contains fully qualified names and then the jvm can map them directly to memory addresses once the class is loaded

ancient jackal
#

and what makes them disappear?

lavish hemlock
#

They're not passed to the GC.

#

They disappear because the instructions in front of them use them.

ancient jackal
#

why can't you use them anymore?

grim ice
#

damn C must be literal pain

lavish hemlock
#

There's no scoping.

grim ice
#

also to get rid of them early you can do object = null

#

right

lavish hemlock
#

You can just throw in a ILOAD to retrieve i or x again.

grim ice
#

but what if if u dont have a variable of it, how to clean it from memory

lavish hemlock
ancient jackal
#

so a for loop with 10,000,000 iterations will leave 10,000,000 extra values in your memory until you exit the program?

gloomy arch
lavish hemlock
grim ice
#

what

lavish hemlock
#

They're stored as Utf8 constants which other constants refer to.

glossy venture
grim ice
#

btw pls ping me when u reply to my msg

glossy venture
#

except if you make more

#

but any variables inside the loop are cleared from the stack per iteration i think

lavish hemlock
#

And stack memory is pretty different from heap memory.

grim ice
#

"You can delete an object in Java by removing the reference to it by assigning null. After that, it will be automatically deleted by the Garbage Collector. You set it to null. Java doesn't give you the option to deallocate memory."

#

F

ancient jackal
glossy venture
#

it would be cleaned by the garbage collector

#

when it sweeps

ancient jackal
#

and that's my point

lavish hemlock
#

Yeah but the GC doesn't take into account scope here

grim ice
#

del object;

#

L

glossy venture
grim ice
#

lol

lavish hemlock
#

It just knows that, since nothing in the program has used that reference, it should clean the reference.

glossy venture
#

it would make stuff a lot faster, that developers can choose to manually manage memory if they want performance

grim ice
#

i mean object = null; does the thing as google says

lavish hemlock
glossy venture
#

yeah

lost matrix
lavish hemlock
#

But you'd struggle with the problem of "what happens to object"

glossy venture
lost matrix
#

Or do you mean that you want to manually free memory on the spot?

ancient jackal
#

well we're using Java here so try to use a variable from a nested block

glossy venture
#

yeah

glossy venture
#

or even a System.finalize(Object) to force the gc to clean it

grim ice
#

yeah like System.gc.collect(Object)

ancient jackal
#
{
  int x = 1;
}
System.out.println(x);```
grim ice
#

or smth idk

lavish hemlock
#

Just never use managed memory :) @glossy venture Only ever Unsafe

lost matrix
#

This would fk with the garbage collector because the freed space could be anywhere.
Would pretty much decrease performance because all that out of order memory management
would be quite expensive.

glossy venture
#

best idea ever

lavish hemlock
#

It basically becomes like

#

a higher-level C

#

at that point

gloomy arch
glossy venture
#
Object o = unsafe.allocateInstance(MyClass.class);
unsafe.invokeMethod("<init>", o, ...); // idk if this is an actual method
lavish hemlock
#

I should make a project that allows you to use Java as if it were a low-level language.

gloomy arch
lost matrix
grim ice
glossy venture
ancient jackal
glossy venture
#

but with reflection you might be able to just call the <init> method

#

on an object

lavish hemlock
#

I don't think reflection allows you to do that unfortunately :p

glossy venture
#

bruh

gloomy arch
glossy venture
#

top 10 biggest bruh moments

lavish hemlock
#

If there were a way to inject an invokespecial though...

glossy venture
#

there is with asm right

lavish hemlock
#

Welllll

#

If you use classloading hacks, then yeah

grim ice
#

i can close the class block of code and then access the var from another class

#

it will not get cleaned, will it

lavish hemlock
#

Y'know what I am totally gonna make the world's hackiest Java library

glossy venture
#

i wonder how hard it is to implement a System.free(Object)

ancient jackal
lavish hemlock
#

A combination of Unsafe and classloading/ASM hacks >:)

lost matrix
quaint mantle
#

Who needs it anyways

lavish hemlock
#

@glossy venture Quick, Orby, give me a name for a manual memory management Java lib

lost matrix
#

How about we leave the poor memory alone? The biggest benefit of java is that we dont have to worry about that.

glossy venture
glossy venture
lavish hemlock
#

meman

ancient jackal
#

maneman

lavish hemlock
#

yes

glossy venture
#

manenemaneman

lost matrix
ancient jackal
#

manemanemanemamenamenamnamen

lavish hemlock
grim ice
#

what are tips to make software more performing though

grim ice
#

even the least bits of performance is good for me

gloomy arch
gloomy arch
#

Generally, multi threading and lowering computational complexity

grim ice
#

man has guides on everything

#

tysm

ancient jackal
glossy venture
#

i am currently looking through the jdk hotspot source to find the sacred someMagicJvmMethodToDestroyObject

grim ice
#

alright and i also need

#

some thing like SOLID to learn

#

to make my projects more OOP styled ig?

lost matrix
# grim ice some thing like SOLID to learn

Program alot. You will see that if you try to think about how to write cleaner code you will discover most of those principles by your own.
The SRP (Single Responsibility Principle) kind of leads to the rest. So focus on that first.

tranquil viper
#

Can you copy a blocks persistentDataContainer and put it on a different item?

ancient jackal
#

wait so @lavish hemlock in this code segment from one of my plugins,

            Map<EntityType, Integer> entityMap = new HashMap<>();
            for(Entity e : c.getEntities()) {
                EntityType k = e.getType(); // k is EntityType in entityMap
                if(entityMap.containsKey(k)) {
                    entityMap.put(k, entityMap.get(k) + 1); // Sets EntityType key to previous value +1
                } else {
                    entityMap.put(k, 1); // Sets amount of EntityType to 1
                }
            }```
the variable k isn't actually created but e is just referenced 4 times? or would e only be referenced if there was only 1 reference to k?
lost matrix
hexed hatch
grim ice
lavish hemlock
#
INVOKEVIRTUAL Entity::getType
ASTORE <index>
ancient jackal
#

oh that's cool, I didn't know

lavish hemlock
#

And actually that for loop there

#

Is just syntactic sugar

#

It compiles down to iterator access

#

So e comes from like iterator.next()

ancient jackal
#

so what would that actually look like?

#

oh

lavish hemlock
#

I am breaking your perception of Java, aren't I?

ancient jackal
#

the way it works yeah

#

but not the way to write it or anhthing that like

#

like that*

tranquil viper
lavish hemlock
lost matrix
tranquil viper
#

Either way, still wouldn't know what to put in //what goes here

grim ice
#

in a way that it doesnt break SRP

lost matrix
tranquil viper
lost matrix
grim ice
#

O ok

#

what does stateless mean

lost matrix
blazing scarab
#

new Copied(from, to).copy() you know

fervent gate
#
package me.cosmic.farmingpluginfordvddevroom;

import org.bukkit.plugin.java.JavaPlugin;

public final class Farming extends JavaPlugin {

    @Override
    public void onEnable() {
        // Plugin startup logic

        getConfig().addDefault("FarmLevelIncrement", 10);
        getConfig().addDefault("PercentChanceOfGettingRewardOnBreakingCrops", 0.001);
        getConfig().addDefault("Pools.Tier1Pool.FarmLevelMax", "200");
        getConfig().addDefault("Pools.Tier1Pool.Rewards", "diamond");
        getConfig().options().copyDefaults(true);
        saveDefaultConfig();

    }
}
```The config doesn't have any values. This is the class, there are no errors and the config is successfully created.
delicate lynx
#

create a new config and try to add the values to that instead

lost matrix
tranquil viper
# lost matrix Hm i just realised that this is a bit tricky because you dont know the persisten...

Let me explain my issue and see if you can help then, since I'm not sure where to go from here now. I having a plugin that stacks spawners (custom coded). When giving myself a spawner through essentialsx and stacking it, it works, however, when I try to break the spawner it drops the proper spawner. Then upon placement, instead of going to the correct spawner type it goes to a pig spawner.

tranquil viper
fervent gate
lost matrix
quaint mantle
#

yo smile, how would i serialize an array<itemstack> with this instead of just an itemstack?

glossy venture
#

the java parser implementation is 5000 lines and its somehow very readable

#

i severely misread the number lmao

lavish hemlock
# ancient jackal wait so <@!186621822253400069> in this code segment from one of my plugins, ```j...
??? = What I don't know, since it's a small code snippet.
Also some of the store/load indices are obviously gonna be off, but I tried my best.

new java/util/HashMap
invokespecial java/util/HashMap, <init>()V
astore 1
aload ???
invokevirtual ???, getEntities()Ljava/util/List;
invokevirtual java/util/List, iterator()Ljava/util/Iterator;
astore 2
aload 2
invokevirtual java/util/Iterator, hasNext()Z
if_icmpeq 0, /* SNIPPET END > */
invokevirtual Entity, getType()LEntityType;
astore 3
aload 1
aload 3
invokevirtual java/util/Map, containsKey(Ljava/lang/Object;)Z
if_icmpeq 0, /* ELSE BRANCH > */
aload 1
aload 3
dup2
invokevirtual java/util/Map, get(Ljava/lang/Object;)Ljava/lang/Object;
// I actually don't know if this is how the compiler auto-unboxes, but I assume so:
checkcast java/lang/Integer
invokevirtual java/lang/Integer, intValue()I
iconst 1
iadd
invokevirtual java/util/Map, put(Ljava/lang/Object;Ljava/lang/Object;)V
// > ELSE BRANCH
aload 1
aload 3
iconst 1
invokevirtual java/util/Map put(Ljava/lang/Object;Ljava/lang/Object;)V
// > SNIPPET END
#

That should be it ^

quaint mantle
#

do i do .tojson

waxen plinth
glossy venture
#

what happens if you remove the checkcast

lavish hemlock
glossy venture
#

will it attempt to cast anything

lavish hemlock
#

Just realized I didn't cast anything else

#

So that is not the full method

#

But I do not care

glossy venture
lavish hemlock
lost matrix
# tranquil viper I was just copying the block data but since essentialsx uses psd to store the sp...

Try if this works

  private static final List<PersistentDataType<?, ?>> types = new ArrayList<>(){{
    add(PersistentDataType.TAG_CONTAINER_ARRAY);
    add(PersistentDataType.TAG_CONTAINER);
    add(PersistentDataType.STRING);
    add(PersistentDataType.LONG_ARRAY);
    add(PersistentDataType.INTEGER_ARRAY);
    add(PersistentDataType.BYTE_ARRAY);
    add(PersistentDataType.LONG);
    add(PersistentDataType.DOUBLE);
    add(PersistentDataType.INTEGER);
    add(PersistentDataType.FLOAT);
    add(PersistentDataType.SHORT);
    add(PersistentDataType.BYTE);
  }};

  @SuppressWarnings("unchecked")
  public static void copyContents(PersistentDataHolder donor, PersistentDataHolder receiver) {
    Preconditions.checkArgument(donor != null && receiver != null);
    PersistentDataContainer donorContainer = donor.getPersistentDataContainer();
    PersistentDataContainer receiverContainer = receiver.getPersistentDataContainer();
    for (NamespacedKey key : donorContainer.getKeys()) {
      for (PersistentDataType<?, ?> type : types) {
        if (donorContainer.has(key, type)) {
          receiverContainer.set(key, type.getClass().cast(type), Objects.requireNonNull(donorContainer.get(key, type)));
        }
      }
    }
  }

If not you need to switch-case your way through the keys

glossy venture
#

maow human compiler

quaint mantle
lavish hemlock
brave sparrow
lavish hemlock
#

Java was not a language meant to be hand-compiled, though.

mortal hare
#

lets say i have map:

Map<Integer, ItemStack> map = new HashMap<>();

is there any way to get this class object safely without generic warnings?
by using .getClass() is get Class<capture ? extends Map>, and in order to get Class<Map<Integer, Object>>, i need to cast it, but that prompts me as a warning that the variable is not safe to cast

lavish hemlock
#

Perhaps with a decent assembler, stuff like Jasmin could've kicked off :p

quaint mantle
lost matrix
brave sparrow
quaint mantle
#

which i need

brave sparrow
#

?learnjava

undone axleBOT
mortal hare
#

generics

lost matrix
karmic grove
#
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
``` anyone know what this means when i try to build
lost matrix
#

Unsupported class file major version 61

#

Use a newer gradle version

karmic grove
#

ok

ancient jackal
#

It does 3 specific things

#

Checks if the key is in the map, if it is then add 1 to the key’s value

#

Other wise add the key with a value of 1

waxen plinth
ancient jackal
#

Without a stream?

waxen plinth
#
for (Entity entity : c.getEntities()) {
  entityMap.compute(entity.getType(), (k, v) -> v == null ? 1 : v + 1);
}```
ancient jackal
#

I think it’s quicker to understand a simple if else tbh

grim ice
#

nah what redempt did is more readable imo

#

if else looks ugly

lost matrix
waxen plinth
#

lol

#

If you don't wanna use compute you could even do it with put

eager hazel
#

Anyone can help?

ancient jackal
#

Well if you want to fork it and replace it then go ahead but personally I think the if else is easier to understand

waxen plinth
#
for (Entity entity : c.getEntities()) {
  EntityType type = entity.getType()
  entityMap.put(type, entityMap.containsKey(type) ? entityMap.get(type) + 1 : 1);
}```
#

But that's gonna be much slower than compute

#

Since compute only needs to do one hash operation and one lookup, it should be a bit faster than the other methods which involve performing multiple lookups on the map

lost matrix
#

I mean... "much slower". We are still speaking of O(1) ops here.

waxen plinth
#

Right sorry

#

I'm a micro-optimizations guy lol

lost matrix
#

Noticed that ^^

waxen plinth
#

It won't make a noticable difference

#

But you could use an EnumMap!

lost matrix
#

...

waxen plinth
#
Map<EntityType, Integer> entityMap = new EnumMap<>(EntityType.class);
Arrays.stream(c.getEntities()).forEach(e -> entityMap.compute(e.getType(), (k, v) -> v == null ? 1 : v + 1));```
#

Slightly faster 🔥

mortal hare
#

compute is way much cleaner and better in some cases

#

at least for me

#

especially for creating new objects

waxen plinth
#

I mean I guess you shouldn't use a stream if you want the fastest but still

mortal hare
#

that are not existant in the map

grim ice
#

I think that's faster, right?

lost matrix
#

Nothing else you can do besides carefully reading the article, looking at a chunk with an nbt explorer and reverse engineering your way through it.

grim ice
#

what redempt and others said is faster either way but yes

mortal hare
#

its way better to use computeIfAbsent(key, (key) -> new RandomObject()) than putIfAbsent(key, new RandomObject()) since the argument init in the first case would be lazy (it wouldnt create a new object if the key already present in the map)

grim ice
#

but I've heard that using streams in hot loops can be bad, so if you use stream in loops often it can become slower than a normal loop

eager hazel
lost matrix
#

And dont get me started on lighting the chunks afterwards...

mortal hare
#

that's actually the case due to everhead the stream api adds up

#

but for example you can do parallel streams which could be faster than for loops

#

since it utilise parallelism internally

quaint mantle
#

Yo! Is this the channel where I can ask for help with coding problems??? 🙂

grim ice
lost matrix
eager hazel
grim ice
#

o

mortal hare
olive lance
#

does onDisable get ran on /reload?

grim ice
#

Yes

mortal hare
#

yes

olive lance
#

ok

#

not sure what happening with my thing then

lost matrix
olive lance
#

ill keep u updated

quaint mantle
eager hazel
chrome beacon
#

It's a good start

mortal hare
#

sometimes

chrome beacon
#

Agreed

sterile token
mortal hare
#

hehe i used to write skripts 2 years ago

#

i jumped on java since then

#

i swear you saw my old posts on skunity

eager hazel
quaint mantle
#

So, if anyone can help me with like ehm, a bunch of things! First of all, I just started to learn to do coding with Java. So everything is new. But I've managed to setup the foundation of a Spigot plugin. That when I click run from IntelliJ. It completes perfectly.

But anyway, basically I would like to know now how do I make a loading screen? Is it possible? So I created a class under src > main > ehm I forget the rest after that. But it's how it should be. Down the line I created a class called 'Startup Loading Screen'.

Now I just gotta put in some code to get it running. To be clear, I wouldn't want anyone to write me code. Although I would love that. But I would rather learn like the building blocks for it. So what exactly is that Spigot page on the web where it lists all of these Classes, Tree, etc. All Bukkit things. That's the API, I know that much. But what do I use that for? What exactly is an API? Is it syntax that falls under Java syntax? Like a made up language that Spigot uses to make it easier for people to code with Spigot? Or is it something else?

Sorry about the long post. Just very new is all. I would really like to know if I can use that site to understand how to make some code for the 'loading screen'.

Okay I'll stop typing now 😛

mortal hare
#

😄

#

i literally used java's packages inside skript back then

drowsy helm
#

as in like a black screen when the player joins or something?

mortal hare
#

do you want a title text

#

that says Loading...

quaint mantle
#

Oh like, I would like to just place a blank black screen when loading up the majority of things in my server :)))

#

And yeah a loading . . . thing also would be nice 😛

mortal hare
#

Minecraft is not a game engine remember that, you need to be creative to do these sorts of things

#

i would suggest you to build a room inside your server filled with itemframes with a white background

#

and teleporting player there

#

or just use end dimension blocks or end dimension itself

#

as a background

wooden fable
#

Hey, i'm trying to compile a plugin with WorldGuard as a dependency. But it doesn't compile:

cannot access com.sk89q.worldguard.WorldGuard

pom.xml:

        <repository>
            <id>sk89q-repo</id>
            <url>https://maven.enginehub.org/repo/</url>
        </repository>

        <dependency>
            <groupId>com.sk89q.worldguard</groupId>
            <artifactId>worldguard-bukkit</artifactId>
            <version>7.0.6</version>
            <scope>provided</scope>
        </dependency>

1.12.2 btw

wooden fable
#

Maven install

delicate lynx
#

do package

chrome beacon
#

Install works fine

wooden fable
#

Package doesn't work to

lost matrix
wooden fable
#

No

quaint mantle
# mortal hare Minecraft is not a game engine remember that, you need to be creative to do thes...

I'll look into that.

Is there a way to manipulate the default minecraft loading screen though? Like get into its source code and stuff and tweak it to use another image? Or would that be only for Forge mods and stuff to do that??? I don't know how limiting Spigot is. That's why was wondering about the API thing that Spigot links where it has all this information about all the different things the API does :>

delicate lynx
#

loading screen cannot be changed via server unless it's a resource pack

quaint mantle
#

Bugger D:

delicate lynx
#

but I don't think the loading screen will even show

#

since when you disconnect it unloads it

mortal hare
#

you cant modify that unless you prompt players to download your own resource pack

#

then you can have some wizardry of customizability

quaint mantle
#

Oh dam dam dam XD Trying to make it that the client doesn't have to download anything :S

mortal hare
#

well server allows you to send resource pack to players

wet breach
mortal hare
#

all they need to do is to click allow

#

whenever they join a server

#

^ nice resolution google

#

loving it

quaint mantle
#

Yeah I'm gonna make a resource pack then. 😛 I'll Google on how to and stuff. Thank you all for the help! I'll ask away later on if I'm having trouble again 🙂

mortal hare
#

but you can do it without that, but it would be limited loading screen

#

you cant do that stuff as flexible as resource packs can be

chrome beacon
#

So basically Spigot is server side only. This means things are limited. For example you cannot change rendering, add custom blocks and items. You can however use resourcepacks to simulate more items and blocks by using model data and unused block states.

If you're new I suggest starting with something easy and work your way up. I've seen too many people try to do advanced things right away and get stuck.

lost matrix
quaint mantle
#

With a resource pack, can I change the HUD, etc? Like creating bars and stuff around the screen or do anything basically, visually????

chrome beacon
#

Yes but it's tricky

#

I suggest starting with something easier

lost matrix
quaint mantle
mortal hare
#

Minecraft is a sandbox game, you need to creative to be play it and modify it to your needs

lost matrix
#

?learnjava

undone axleBOT
wooden fable
chrome beacon
#

?jd-s

undone axleBOT
lost matrix
lost matrix
mortal hare
#

this turned:

Map<Player, List<Pair<Integer, Pair<ItemStack, ObjectDataFile<List<ItemStack>>>>>>

into:

Map<Player, InventoryDataStorage> 
#

how great

wooden fable
quaint mantle
#

Okay just oooonnnneeee last little thing? What exactly is an API???? I've tried reading into it. But it doesn't make much sense for my brain XD Is it an additional language thing used, to make coding/programming easier for the person writing code????

tranquil viper
chrome beacon
tranquil viper
#

shouldn't the capture of ? be Z?

lost matrix
quaint mantle
mortal hare
#

Lets say you have a car, you have crucial components like engine, and you have a car salon (radio, wheel, hand brakes), API is literally that. it allows you to safely tinker with the "engine", without thinking too much about its technical characteristics

#

Engine makes your car drive, but wheel makes your car drive wherever you want

chrome beacon
olive lance
#

or perhaps a better way to compare them

wooden fable
olive lance
lost matrix
chrome beacon
olive lance
#

it generated this public int hashCode() { return Objects.hash(f1, f2); } but i want them to be equal even if the 2 factions exist in the different variable

#

unordered

#

maybe i could use a unordered set

mortal hare
#

i've never implemented equals() before, but i think if (o == null || getClass() != o.getClass()) return false; could be replaced with if (!(object instanceof Alliance)) return false; since instanceof allows you to check for null values and the class type at the same time, and you're casting to Alliance object after the comparison, it would fail if the classes would be different than the Alliance

brave sparrow
olive lance
#

that part was generated by intellij

#

just the last line i did

brave sparrow
#

Which is an important distinction

mortal hare
#

yes, it wouldnt fail because its checking the same class type its overriding

#

but i think the second version is a bit, BIT faster

brave sparrow
#

I mean it’s doing the same thing under the hood

#

You’re not bypassing the null check

olive lance
#

I basically am just trying to make an unordered pair

mortal hare
#

but this is not important here

brave sparrow
olive lance
#

true

#

I think instead of 2 variables i will just have a set

#

and make sure it only has 2 values

brave sparrow
#

That’s overkill if you’re using a fixed 2 elements

#

You’re better off using 2 fields like you are currently

olive lance
#

i wish java had a data type for this

lost matrix
brave sparrow
#

Sets are for many elements, it’s a waste if you’re only ever gonna have two

olive lance
#

Right but a set with only 2 elements. an "UnorderedPair" we can call it

#

def should be a thing

waxen plinth
#

Map.Entry

#

lol

#

If they're the same type then you could use an array size 2

#

If they're not you could use a record

brave sparrow
waxen plinth
#

Okay why do they specifically need to be unordered

brave sparrow
#

They’re saying they want an object such that (a, b) = (b, a)

waxen plinth
#

Then store it in an array size 2 and sort on creation

mortal hare
#

i literally powered compiler explorer online too see which one is cheaper

waxen plinth
#

Yeah lol

#

You could just do Set.of(a, b)

mortal hare
#

instanceof is cheaper in terms of bytecode operations

#

unless i did something wrong

brave sparrow
#

Lol

#

Instanceof has to get broken down into those steps eventually

brave sparrow
gloomy arch
#

What’s the overhead?

brave sparrow
#

Creating the set and the backing hashmap with its buckets

mortal hare
#

yes , but its broken down by jvm internally since its a separate bytecode operation rather by multiple bytecode operations

#

which should be in theory still cheaper

brave sparrow
#

At that point it’s basically a micro optimization though

mortal hare
#

haha

#

I WON

brave sparrow
#

Lmao

#

Premature optimization is the root of all evil

mortal hare
#

i know

#

i was just curious if i was right

#

lol

#

i still might be wrong tho

#

it depends on jvm

lost matrix
#

Using Class == Class odes not yield the same result as instanceof. You should
always use instanceof in equality checks.

olive lance
#

Ok well I guess im just gonna use a Set

lost matrix
#

Disregarding the performance.

brave sparrow
lost matrix
olive lance
#

Yeah i think its coming from the other room

#

Ok well ill go way back then to the main problem

#

got a factions plugin. i keep a list of factions and a map of players that are in factions and their faction

#

bad design?

rapid shale
#

Hy

olive lance
#

which is the main thing alliances pertain to

gloomy arch
#

If it’s always just two factions, you could just have two class variables faction1 and faction2

brave sparrow
#

And now we’re back where we started

#

Lol

lost matrix
# olive lance bad design?

This is the typical problem you also get when doing friendlists for example.
Who is in charge of handling this cross reference data.

brave sparrow
#

Use a graph @olive lance

#

Google has a lib for it

lost matrix
olive lance
#

Im reading about them rn

#

this is quite the data type

ancient jackal
#

Whatever I do, I just cannot get an instance of another plugin [10:05:14] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to PlotsForRanks v0.8-SNAPSHOT java.lang.ClassCastException: class sh.okx.rankup.RankupPlugin cannot be cast to class sh.okx.rankup.RankupPlugin (sh.okx.rankup.RankupPlugin is in unnamed module of loader 'Rankup-3.13.2.jar' @69b4a744; sh.okx.rankup.RankupPlugin is in unnamed module of loader 'plotsForRanks-0.8-SNAPSHOT.jar' @f83dd35) at me.grovre.plotsforranks.PlotsForRanks.getRankupPlugin(PlotsForRanks.java:41) ~[plotsForRanks-0.8-SNAPSHOT.jar:?]

#

and it's come to the point it's telling me this

#
public static RankupPlugin getRankupPlugin() {
        return (RankupPlugin) getPlugin().getServer().getPluginManager().getPlugin("Rankup");
    }```
lost matrix
ancient jackal
#

scope -> provided?

lost matrix
#

How do you get the other plugin on your classpath?

#

Do you use maven/gradle?

ancient jackal
#

I use maven

lost matrix
#

Show your pom dpendencies

ancient jackal
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.palmergames.bukkit.towny</groupId>
            <artifactId>towny</artifactId>
            <version>0.97.5.15</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>okx-code</groupId>
            <artifactId>Rankup3</artifactId>
            <version>3</version>
        </dependency>
    </dependencies>
lost matrix
#

Rankup3 needs to have a "provided" scope

ancient jackal
#

what do you mean by that?

lost matrix
#

Look at your other dependencies

ancient jackal
#

it's in its own dependency

#

oh

#

I see, thank you

stray crescent
#

Items dissapear like after 2 minutes on ground

#

I don't have clearlag or any plugin for that

#

they jsut dissapear quicker than usual

#

how do I changed the it to 10 minutes on like paper cause I guess thats what it is

karmic grove
#

does anyone have the link for the guide spigot forum i remember it but cant seem to find it now

tender shard
#

heck is wrong with towny

#

0.97.5.15

#

lmao

ancient jackal
#

It’s the version a server uses for some reason

#

But it should work with. Erosions moving forward

#

Versions

#

It just listens for players joining, joining towns, leaving towns, and ranking up

#

And adds bonus blocks based on what happens

daring lark
#

how could i check if player is holding fishing rod in left or right hand?

young knoll
#

Check both hands for Material.FISHING_ROD

daring lark
#

not working

young knoll
#

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

daring lark
# daring lark not working

if(p.getInventory().getItemInMainHand().equals(Material.FISHING_ROD)) {
fortune = (p.getInventory().getItemInMainHand().getItemMeta()).getEnchantLevel(Enchantment.LUCK);
}

young knoll
#

getType

#

Itemstack is not a material

daring lark
young knoll
low temple
daring lark
#

thanks

#

it's working

young knoll
#

But it’s not the end of the world

stray crescent
#

Does anybody know a plugin were I can have a tellraw/broadcast being sent in chat for everybody every 10 minutes?

#

For instance having "Join our discord blabla"

young knoll
#

There’s gotta be tons of auto broadcast plugins

#

?google

undone axleBOT
stray crescent
#

I just dont know what to search for

#

I did that i just got a thread of someone wanting to make a plugin like that

#

Sending me google isn't gonna help when I literally asked if you knew a plugin

river oracle
#

#help-server this is help-development we are assuming your making the plugin lol.

young knoll
#

Spigot auto broadcast plugin

river oracle
#

doesn't essentials have something like that

stray crescent
#

ye thx

young knoll
#

Essentials didn’t have that last I recall

#

Surprisingly

#

But maybe it does now

river oracle
young knoll
#

That’s very overkill for an auto broadcast

sharp flare
#

Can replace essentials itself

river oracle
worldly ingot
#

almost guarantee you there's one called "autobroadcast"

#

lol

young knoll
#

Apparently you have to use mini-message formatting

vague swallow
#

How can I add a custom texture to my SkullMeta?

young knoll
#

Version?

vague swallow
#

1.18

vague swallow
#

thanks man

#

.setOwnerProfile() is not available. Just .setOwner()

young knoll
#

Update spigot

vague swallow
#

I'm using paper

young knoll
#

Talk to paper then

vague swallow
#

alr

stray crescent
#

im using stone

vague swallow
#

okay...

#

but yk I won then

stray crescent
#

Does anybody know a plugin that let's me run a command when're at a specific coordinate

quaint mantle
#

that would be extremely non-performant

#

unless you're not checking every tick

young knoll
#

Meh

#

PlayerMoveEvent has been used for more

quaint mantle
young knoll
#

Okay

stray crescent
#

There is no music that allows for regional music with music discs. So I'm trying to do

/playsound minecraft:music_disc.otherside music <p>

#

whenever you enter a store, and when u leave it will do /stopsound <p>

young knoll
#

Worldguard extra flags has entry and exit commands

#

I think

stray crescent
#

wow

#

ur right

#

holy damn

vague swallow
#

Does anyone here know how to change the texture of a SkullMeta?

#

1.18

stray crescent
#

@young knoll

#

playsound <sound> <source> <targets> [<pos>] [<volume>] [<pitch>] [<minVolume>]

#

how would I skip a string?

#

after <sound> <source> <targets>

#

I just want to put in volume

#

so how would I skip "pos"

#

cause it wants me to fill in pos

#

as for the next stream after target obviously

young knoll
#

I don’t know if you can

#

Maybe just do ~ ~ ~

#

I think a sound needs to have a location

stray crescent
#

ahh yes

#

thanks

lofty fern
#

So, not sure if I am dumb or something. But I am new to plugin development and want to make a plugin where the player goes like "/show add firework [type] [color] [effect]" I think I know how to do that part but right now I am trying to work on grabbing the players location and writing it down on some document so that the plugin can go back later and grab that data. However I cant seem to find a proper way of grabbing a players location (using coordinates) or finding a way of putting that on some sort of document (preferably txt) if you know of any tutorials or know of a way of doing this help is appreciated.

vague swallow
#

for some reason there is no ".setOwnerProfile()"

young knoll
#

Make sure you are up to date

#

Like I said

#

Why did you

sterile token
#

Every class should be final class right? If not people will be able to extend the class

young knoll
#

You know you can just set location directly

sterile token
#

you can directly save the loation with: cfg.set("location". loc);

vague swallow
young knoll
#

Maven or gradle?

lofty fern
#

Did someone answer my question? I saw a ping but dont see me being pinged here.

vague swallow
vague swallow
sterile token
#

Ahh

#

You didnt change your IDE

#

You change the api

vague swallow
sterile token
#

For developing on spigot you have the ?jd

sterile token
lofty fern
sterile token
lofty fern
vague swallow
#

I just gave him the code of my /spawn plugin. But it was not what he wants

sterile token
lofty fern
young knoll
#

Spigots config API can handle location directly

lofty fern
young knoll
#

Yes

lofty fern
#

So how would you store that?

sterile token
vague swallow
young knoll
#

YanlConfiguration#set(“key”, location)

sterile token
#

I will sent you a class, please add it to your project

#

And then i explain how it works

young knoll
#

Yes a third party class to save a location

#

Very necessary

lofty fern
sterile token
#

I make a FileHandler, called FileHandler

lofty fern
#

Gotcha.

sterile token
#

Itself its a FileHandler, because it help you to manage files

lofty fern
#

New to this all. First day coding so the overall goal is to make a show plugin that can syncronize things to openaudioMC but I am working on each individual command one at a time.

sterile token
#

If you are new* i straigth recommend a lot learning about the SpigotAPI and Java API

delicate lynx
#

literally just make a FileConfiguration and tell it to add a new key with the location, then call the save function on it

young knoll
#

?learnjava

undone axleBOT
delicate lynx
#

no need for this extra class

young knoll
#

It takes like, 5 lines to do it with the existing API

sterile token
lofty fern
young knoll
#

Clearly that’s way too many

sterile token
#

?afk eating

lofty fern
sterile token
#

Allright i will be eating, prob im back in 10-15m

vague swallow
#

?learnspigot

#

F @vague swallow

sterile token
sterile token
#

Go ahead

vague swallow
#

ty

lofty fern
#

So I guess when he gets back from AFK he will send me it or do I need someone else to help me with this?

young knoll
#

I mean

#

Just create a file with the Java API, and then use YamlConfiguration.loadConfiguration(file)

lofty fern
#

Can the plugin create it based off an arg a player said in chat or do I have to make that manually?

#

I want each show to haves its own file.

young knoll
#

Sure why not

lofty fern
#

How would I go about doing that?

young knoll
#

Learn the java file API

#

JavaPlugin#getDataFolder will be useful as well

lofty fern
#

So if a player runs a command like "/show create [arg1]"
then java will create a file with the name of the arg1 with what I tell it to put in the file?

young knoll
#

Mhm

lofty fern
#

Sweet. Thanks. My dad is a java developer and luckily works from home and being home schooled I can easily get him to help me with java API.

young knoll
#

Is the spigot class you’ll want to use

lofty fern
#

@young knoll second thing, how can I store the coordinates of a player in this file? I want the players coords and not spigot stuff. Any way of doing that?

#

Like how do you get player coords.

#

So many spigot documentation to go through and when I search "coordinates" can't find anything.

young knoll
#

Player.getLocation

lofty fern
#

Will that give all the x, y, and z, or do I need to specifically do "Player.getY()" "Player.getX()" "Player.getZ()"

young knoll
#

It will give X Y Z pitch yaw and world

sterile token
#

Please read the javadocs

#

Javadocs are the documention