#help-development

1 messages ยท Page 1944 of 1

sturdy ivy
quiet ice
#

Nothing changed there for quite some time now

chrome beacon
#

.world isn't going to work

sturdy ivy
#

It worked in 1.15.2

chrome beacon
#

1.18 is either unmapped or using Mojmaps

#

Neither have the .world

#

Mojmaps should be calling it level

sturdy ivy
#

Oh

#

Its entity

main dew
eternal night
#

why not

dusk flicker
#

why need more?

sturdy ivy
#

Do you guys know why is that? ```
C:\Users\Paweล‚\IdeaProjects\Pinecraft-Core\src\main\java\me\plytki\core\api\APICommand.java:13:18
java: cannot access org.bukkit.Bukkit
bad class file: /C:/Users/Paweล‚/.m2/repository/io/papermc/paper/paper-api/1.18.1-R0.1-SNAPSHOT/paper-api-1.18.1-R0.1-20220205.195405-118.jar!/org/bukkit/Bukkit.class
class file has wrong version 61.0, should be 55.0
Please remove or make sure it appears in the correct subdirectory of the classpath.

dusk flicker
#

wrong java ver

eternal night
#

You need to run your 1.18 server with java 17

#

also, you are running paper ๐Ÿ˜…

dusk flicker
#

You should also be asking Paper

next stratus
#

Stupid question but is there any plugins using MiniMessage so I can get an idea how to get going? ๐Ÿ˜…

chrome beacon
#

There is a pretty detailed wiki

next stratus
#

I must just be stupid then? I'm finding it a bit complex

chrome beacon
next stratus
#

ya, i'm looking at it atm

#

Just seems complex ๐Ÿ˜…

chrome beacon
#

Is there anything specific that you don't understand?

next stratus
#

I just can't understand how to create a new string what I can send to a player

dusk flicker
#

I can send u a snippet

eternal night
#

I mean, the most basic one is just ```java
final Component parsed = MiniMessage.get().parse("<red>A red piece of text");

next stratus
#

I'm someone who likes to see how things are done at first

eternal night
#

tho afaik the wiki is outdated af

dusk flicker
#

adventure docs are horrible lmao

eternal night
#

They are just outdated ye

next stratus
#

So I'm not just dumb?

dusk flicker
eternal night
#

Well the docs are not optimal but the concept of mini message and the java interface is pretty straight forward

dusk flicker
#

Exactly what Lynx said

next stratus
#

I was worried that it was just me being dumb finding this confusing

dusk flicker
#

no, adventure is just confusing on the first go around

#

Took me a few days to figure it out lol

next stratus
#

thanks for making me feel better by confirming it's not just me

dusk flicker
#

Let me know if you need any other examples, I dont have many but anything can help lol

next stratus
eternal night
#

What version of mini message are you using

#

it went through a bit of changes here and there

dusk flicker
#

Or what ver of Paper

next stratus
#

I think i got it

dusk flicker
#

Assuming you are using Paper, otherwise it might be a nightmare lol

eternal night
#

e.g. MIniMessage.get was replaced with MiniMessage.miniMessage()

next stratus
#
        String test = "hi";
        Component component = MiniMessage.get().parse(test);

?

eternal night
#

Yes

dusk flicker
#

Should work ye

dusk flicker
eternal night
#

papar api does not include mini message

#

you must be shading it yourself

dusk flicker
#

Nope, not in my pom

eternal night
#

It is being pulled from somewhere

#

paper does not shade it

dusk flicker
#

Would it be as I have an actual server jar as well as the api?\

#

Not just the api

eternal night
#

no, paper also does not use mini message as an impl detail

dusk flicker
#

If not I got no idea lol

eternal night
#

something is pulling it in and it definitely isn't paper-api ๐Ÿ˜… ยฏ_(ใƒ„)_/ยฏ

dusk flicker
#

lmao yeah

#

No idea what

next stratus
#

Sorry, but how do I send this message to the player? ๐Ÿ˜…

eternal night
#

on spigot ?

#

or with paper-api

#

spigot will be rather painful

next stratus
#

I got a component and I don't know how to use it

dusk flicker
#

With Paper you should just be able to pass it through Player#sendMessage

#

Spigot would be not so much fun lol

next stratus
#

is it better to import paper over spigot or?

dusk flicker
#

For Adventure yes

#

If you're server is running it, absolutely

eternal night
#

Well thing is you cannot publish a plugin that only works on paper to spigot

next stratus
#

Will it mess up any of my other code?

eternal night
#

no

dusk flicker
#

Is this a public or private plugin?

eternal night
#

paper does not break spigot plugin compat

next stratus
#

Public ๐Ÿ˜ฌ

dusk flicker
#

oh

#

well

#

have fun

eternal night
next stratus
#

lmao thanks

eternal night
#

you basically need to also include the bukkit adventure platform

#

which basically links bukkit servers to adventure (e.g. allows you to send messages etc)

next stratus
#

please excuse me when I go scream. ๐Ÿ™‚

dusk flicker
#

lmao

eternal night
#

understandable xD

next stratus
#

"this'll be a easy 5 minute thing to add hex colors" *TAKES 20 COMMITS TO SET IT UP"

dusk flicker
#

lmao

#

hex colors are live changes

next stratus
#

Is it obvious i'm going crazy yet?

eternal night
#

Technically legacy format does support rgb colours :>

next stratus
#

So if I add this adventure will the plugin still be useable on spigot servers or just paper?

eternal night
#

You will have to shade (or use the library loader) both adventure and the bukkit platform

#

but yes

next stratus
#

so i can just shade it?

eternal night
#

yes

next stratus
#

I wanna curse my life away

main dew
sullen marlin
#

BuildTools.jar --rev <version> will check out the appropriate commit

main dew
sullen marlin
#

just use the directory

main dew
sullen marlin
#

last

#

you can also just browse the commit logs to find what you want

main dew
#

oh good thanks

main dew
neon minnow
#

World myWorld = Bukkit.getWorld("world");
Location spawnLocation = new Location(myWorld, 0, 10, 0);
Entity spawnedPig = myWorld.spawnEntity(spawnLocation, EntityType.PIG);

i know how to spawwn an entity, like above
but how do i add no ai to them? Thanks โค๏ธ

young knoll
#

spawnedPig.setAi

neon minnow
#

ty

main dew
neon minnow
main dew
#
World myWorld = Bukkit.getWorld("world");
Location spawnLocation = new Location(myWorld, 0, 10, 0);
Entity spawnedPig = myWorld.spawnEntity(spawnLocation, EntityType.PIG);```
neon minnow
young knoll
#

1.8?

neon minnow
young knoll
#

L

#

Use NMS

ancient jackal
#

how would I get a creature spawner's default properties? say I'm changing a spawner's properties like the timer and max spawn count, how would I get the default values back?

young knoll
#

Iโ€™d just hardcode them somewhere

ancient jackal
#

that's what I was thinking and was wondering if there's a better way but I'll go along with that, thank you

thick gust
#

yo is any1 used to blazor development?

#

@young knoll you maybe? ๐Ÿ˜ฎ

young knoll
#

No idea what that is

sullen marlin
#

I mean you could make a new spawner and get the values from that

woeful crescent
neon minnow
woeful crescent
#

then new NBTEntity(yourentity).setBoolean("NoAI", true);

eternal night
#

if only there was like

#

API to set NoAI flags

woeful crescent
#

yep

#

can't tell if you're being sarcastic, but that's what i sent

eternal night
woeful crescent
#

bro read chat messages

#

we're not just talking about APIs for kicks lol

eternal night
#

oh

#

1.8

#

mb

upper vale
#

Is it possible to get the exact coordinates where an arrow hits a player?

maiden tree
#

I opened a server, but when I use spigot, useful mobs spawn, but creatures do not spawn, how can I solve the problem?

wet breach
#

if you meant like the arrows cords

#

I assume you could get the Arrow entity involved and get its coords and just use some math with player information like we know how tall players are

#

so use the player coords, along with their height, then you can measure where it hit the player

#

So I suppose the answer to your question is, yes you can

minor otter
#

How would I test if a tripwire is disarmed?

minor otter
#

thanks

quaint mantle
#

how do I get the location of a nether portal that the player made?

worldly ingot
#

As in when they made it? Or some arbitrary amount of time after they've made it?

#

Because the latter is not possible

#

But you can always listen to a PortalCreateEvent

quaint mantle
worldly ingot
#

Yeah if you want to get the blocks when they've made the portal, PCE is your friend

quaint mantle
#

what is PCE

#

nvm

quaint mantle
worldly ingot
#

some arbitrary amount of time after they've made it?
Because the latter is not possible

quaint mantle
#

oof

worldly ingot
#

Unless you keep track of that yourself

#

PCE, save the location in memory and in a file or something, load up on start

quaint mantle
#

how would I do that?

worldly ingot
#

Well, you can getBlocks() in the PCE. That gets you all the blocks that belong to the portal. (You can just select one if you want, I don't know what location you want, exactly. Calculate the center, whatever). Then just add that location to a Multimap<UUID, Location> or something that you can refer to later

#

(multimap because they might create more than one portal. If you only care about the most recent, you can just use a regular hash map)

quaint mantle
#

ok because I was trying to make a type of manhunt plugin so yea that helps a lot thx u :)

worldly ingot
#

Oh then yeah, if it's temporary, a simple Map will do then

#

If you need it across restarts as well, you have to write that Map to a file as well. Keep that in mind

#

If needed, Google has a bunch of resources on how to read/write from files. Standard Java for that

sharp flare
#

does #setVelocity work on 1.18.1 for armorstands, I've already tried updating it per tick but the armor stand is not moving. #setGravity is set to true

woeful crescent
#

will it work to cancel a bukkitrunnable then start it up again later?

eternal night
#

no

lost matrix
minor otter
#

so youre able to cancel the tripwire from being being activated while you step on it, but that would create a large loop of it being activated from you stepping on it, then it being deactivated through the blockphysics event over and over, is there a way to prevent this?

sly trout
#

guys how to use serializable interface?

#

I looked at the docs but it aint that clear

low temple
sly trout
#

I'm trying to serealize this class

#

    private static ArrayList<Report> _allReports = new ArrayList<>();



    private int _questionsIndex=0;

    private UUID _creatorUUID;

    private String _creatorUsername;

    private ReportType _reportType = null;

    private List<String> _answers;

    private String _creationDateToString = "Non-specified";

    private int _reportId = -1;```
#

ok but how do i use it

low temple
#

All u gotta do is then pass it as an object when writing it to a file

lost matrix
sly trout
#

i used this

#

file.getConfig().set(data.getPlayer().getUniqueId() + ".PlayerData.ActiveReports", data.getActiveReports());

#

this should be correct

#

but the fetching from config part is what i'm stuck at

low temple
#

Oh youโ€™re trying to serialize in yml format. Nvm

full forge
#

i'm making a really simple discord-minecraft link using jda, but whenever i call Bukkit.broadcastMessage() with color codes in the string, it sends strange characters like "ร„". here's my code: Bukkit.broadcastMessage("ยง9Discord > ยงe" + event.getGuild().getMember(event.getAuthor()).getNickname() + ": ยงf" + event.getMessage().getContentDisplay());. it's not a jda issue because when i remove the color codes everything actually works

low temple
#

So if ur getting by UUID pass the UUID as a string into the path

sly trout
#

So I have to make the serialize method

#

that @Override the one from ConfigurationSerializable?

low temple
#

That depends if you want it to be readable or not

#

You could probably serialize the object into a byte array then store it into the UUID index. OR create a method to serialize all the primitive values into a string.

low temple
sly trout
#

doesn't ConfigurationSerializable support ArrayLists?

#

pretty sure it does

low temple
#

It might, im not sure how they handle those kind of arrays

#

if it does then you'd serialize those two object however ConfigurationSerializable does

#

just make sure ur serialize method is consistent with ur deserialize method

#

like the order and placement of each data value

vale cradle
#

May I ask what is the reason why entities cause a lot of lag?

#

Like, bounding boxes, behaviors, etc?

#

or something else?

low temple
#

Probably cause entities have dynamic states

#

they can move and stuff while most blocks for example are pretty static

lost matrix
vale cradle
eternal night
#

๐Ÿ‘€

eternal night
#

The CPU has 50ms to process a tick

#

if it has to tick 20 entities vs 500 that is a difference

vale cradle
#

unless it's iterating them what would make a difference

eternal night
#

it is tho ?

vale cradle
#

I don't need them to tick

lost matrix
eternal night
#

don't think spigot has a way for you to stop stop ticking completely for certain entities

lost matrix
eternal night
#

Just as a heads up, disabling AI will not reduce the tick to just a method call

#

the server will still do stuff and throwing a crap load of entities onto it might still have a noticeable impact

lost matrix
#

Because this sounds like you dont need entities at all. Just packets that tell the player that an entities is at a certain position.

minor otter
#

can I load a structure without it updating the blockstates once loaded

vale cradle
vale cradle
lost matrix
eternal night
#

sounds like redoing citizens for fun

vale cradle
#

haha no and no. I have other plans in mind ;p

eternal night
#

Ahhh, well NoAI is as close as you'll get

#

without packets or a custom server fork

vale cradle
#

while ticking I mean

eternal night
#

pretty much a tryitandsee

lost matrix
prisma salmon
#

Im looking for skripters
that are good
like at least a 6 month experiance?

eternal night
#

this is not the place for service requests

prisma salmon
#

Im new so idk anything

vale cradle
#

idk, like 20k per server

eternal night
#

your clients will have fun

lost matrix
vale cradle
eternal night
#

I mean, there is nothing for you to do on the client side of things

vale cradle
eternal night
#

But all potentially loaded at the same time ?

vale cradle
#

yes

eternal night
#

Well, with those numbers

undone axleBOT
eternal night
#

?tryandsee

#

aww

vale cradle
lost matrix
#

Are you planning on having hordes of mobs?
Because ive done this and this is best approached with a hive AI which can get quite complicated.

lost matrix
#

parallelization is key there ๐Ÿ˜„

eternal night
#

If you are only planning on doing armorstands for example, paper would have API for that

#

but beyond that, NoAI it is

lost matrix
eternal night
#

Well they still tick around

vale cradle
#

if I remove their gravity

#

I mean

lost matrix
#

They still collide and are interactable

eternal night
#

๐Ÿ™ collisions

vale cradle
#

Not if I remove their gravity

#

they don't collide if I do it

prisma salmon
#

MrTommy

vale cradle
#

yes?

prisma salmon
#

How do u post on spigotmc?

#

idk how

eternal night
#

create an account

prisma salmon
#

I did

#

idk how to post tho

eternal night
#

and then you click the

prisma salmon
#

I cant

#

It says I need 20 posts and 1 week of age

sly trout
#

what does this error mean ? @w@

#
09.02 21:38:25 [Server] INFO org.yaml.snakeyaml.constructor.ConstructorException: could not determine a constructor for the tag tag:yaml.org,2002:java.util.UUID```
prisma salmon
#

no

#

There is no error

sly trout
#

there is @w@

lavish hemlock
#

Are you serializing something?

prisma salmon
#

I have this --> please note that in order to be able to post new threads in this section you must have an account with at least 20 posts and at least 1 week of age. Upon reaching these amounts you will automatically be promoted within a few hours.

vale cradle
prisma salmon
#

Wait

#

I want to post a conversation

#

not a post thing u showed

eternal night
#

do you even want to hire a skript dev ?

#

or just need help with skript

prisma salmon
#

Just need help

eternal night
#

there is a discord for skript

prisma salmon
#

there is!!!

#

Please give me it im despreate ๐Ÿ™

hexed hatch
#

just

#

google

eternal night
#

can't send you the discord invite I think our cafe babe dislikes that

prisma salmon
#

dm me it then

eternal night
#

literally just click

#

the link

lost matrix
#

What i dont understand is why someone would bother learning skript?
You have a way more powerful tool when just learning java. And its a
also a great skill outside of Spigot.

eternal night
#

it is right there

prisma salmon
#

does java work on a mc server??

lavish hemlock
#

YES

#

MINECRAFT IS MADE IN JAVA

eternal night
#

does it tho

hexed hatch
#

no java does not work in minecraft

#

don't lie to them, furry

lavish hemlock
hexed hatch
#

minecraft is made with computer

#

not java

#

idiot

prisma salmon
#

@eternal night Just dm me the dc server

vale cradle
#

and so are Spigot Plugins

lavish hemlock
eternal night
#

@prisma salmon dude

#

just

#

click the link

#

to their github

prisma salmon
#

I DID

hexed hatch
#

this is why children should not have internet access

lavish hemlock
#

Lmao yeah

prisma salmon
#

Im 13 idiot

eternal night
hexed hatch
#

case in point

vale cradle
lavish hemlock
eternal night
#

13 year old can't read these days ?

prisma salmon
lavish hemlock
#

You're a minor.

sly trout
#

does configurationserializable not work with UUID??

hexed hatch
#

basically an infant

sly trout
#

does it not allow to store it

lavish hemlock
#

Like just because you're an adolescent doesn't mean you're not a child.

eternal night
#

uuid does not implement configuration serializable

lavish hemlock
#

(Even then, 13 is like "barely teen")

sly trout
#

frick

#

cuz i need to access that UUID when the player is online

#

is there a way?

lost matrix
# sly trout frick

Ive been through this. I would recommend you to skip spigots serialization and go straight to Gson or Jackson.

sly trout
#

I don't know how those work unfortunately

#

any tutorials?

lavish hemlock
hexed hatch
#

I managed to just figure gson out on the fly

lavish hemlock
#

Yeah

#

It is that easy to use

sly trout
#

does Gson store in the ylm file?

lavish hemlock
#

No it stores json

hexed hatch
#

I don't think I even used the docs

#

nope it's json

lavish hemlock
#

Which is preferred over yaml

dawn hazel
#

anyone have any idea whats going on here?

ProxyServer.getInstance().getConfig().getServers().containsValue(config.getString("TargetServer")``` im trying to detect if a server exists on the bungee config yet it just constantly says the server does not exist despite it existing
hexed hatch
#

which is really better for your purposes

lavish hemlock
#

yaml is designed/used for config, not storage

sly trout
#

okay

vale cradle
lost matrix
eternal night
#

json is valid yaml anyway

lavish hemlock
sly trout
#

any tutorial on how to get started on json?

eternal night
#

real devs just store json in yaml files

vale cradle
lost matrix
#

real devs just write stuff into .bin files

eternal night
#

^^ nah tommy

lavish hemlock
#

I actually serialize to binary

vale cradle
hexed hatch
#

psychopath

sly trout
#

UUID gets saved to Gson?

lavish hemlock
#

DataOutputStream and DataInputStream are very easy to use :p

sly trout
#

also where do i start

eternal night
#

a database is for people just don't know to save all of your data into a single huge binary blob

sly trout
#

any docs?

vale cradle
hexed hatch
#

jarvis go to google.com and type gson documentation

lavish hemlock
#

Well I shouldn't need to modify my serialized data in any editor

dawn hazel
lavish hemlock
#

Also what constitutes a "powerful" hex editor?

#

I use HxD and it's kinda meh

vale cradle
eternal night
#

you are trying to check for values

#

you should check if the map contains keys

lost matrix
lavish hemlock
#

containsValue checks if a value is in the map

#

You're checking if a String is in your values

#

When your values are only of type ServerInfo

#

You want containsKey iirc

dawn hazel
#

thank you

#

ill try it out and see if it works

ancient jackal
lavish hemlock
ancient jackal
sly trout
#

when I get the Gson.toJson

#

how do i store it to the file?

#

a yml or json file is better

lavish hemlock
#

You want to pass a FileWriter or FileOutputStream to it

#

If you don't know what those are

#

Go learn Java IO

dawn hazel
lavish hemlock
#

Yw

#

Always check the type of your parameters btw

dawn hazel
#

yeah

sly trout
#

yes but the file name

#

should it be like data.json?

lavish hemlock
#

It can be anything as long as you keep it consistent between read/write

#

You should go for a descriptive name

lost matrix
sly trout
#

it doesn't matter?

#

okay thank you !

lavish hemlock
#

Yeah

sly trout
lost matrix
lavish hemlock
#

Yeah file extensions are kind of an illusion

#

They exist just to aid programs in detecting the type of a file

#

But in reality they're just another part of the name

#

I recommend you do the following:

#
  • Have it end with .json so people aren't (more) confused
  • Make sure to specify the plugin name so people know where it comes from
  • Make sure to specify what its for so people know why it exists
#

e.g. if you're converting something like a bunch of User objects to a file

#

you might want something like <my-plugin>-users.json (replacing <my-plugin> with your plugin's name)

#

Simple shit honestly

hexed hatch
#

or make a folder and store each user in their own json file like a gigachad

lavish hemlock
#

You can do that too

#

Although it makes me wonder whether or not it's faster to read a big file or a bunch of files

#

I think it depends on how much you'll be reading at a time

hexed hatch
#

this is spigot minecraft game server

#

I don't think there is any major difference in efficiency between the two

lavish hemlock
#

Well file IO does perform native calls

#

It's gotta open the files

#

(Plus it's all synchronized since java.io is thread-safe)

lost matrix
#

It shouldnt really matter if it takes .01 or .1 second because it should be done async anyways.

lavish hemlock
#

Unless like

#

It's at the start of the server

#

Then it's negligible imo

sly trout
#

I'm kinda lost tho once u got the fileinputStream how do you get the json object or string?

lavish hemlock
#

Are you looking at fromJson?

#

You need to use toJson when serializing.

#

Unless by "json object" you mean Object

#

In which case you pass your instance in

sly trout
#

so for example

#

or exemple

lavish hemlock
#

gson.toJson(myData, inputStream);

sly trout
#

okay but i can't store multiple different json things in a single file?

lavish hemlock
#

You can store a list

sly trout
#

so one file means one list?

lavish hemlock
#

Just one instance in general

#

e.g. you could store an array, a list, a map, a single object, a primitive (int, float, etc.)

lavish hemlock
#

Also wait

#

You need an output stream for toJson lol

sly trout
#

?

lavish hemlock
#

So

#

OutputStream = Writing
InputStream = Reading

#

toJson = Serializing to JSON
fromJson = Deserializing from JSON

#

yeah that's my point

#

you need a FileOutputStream

sly trout
#

?

lavish hemlock
#

Can you show your actual method call

vale cradle
#

FileOutputStream is what you're looking at, If you need something to store there just put the bytes of the string the toJson method returned

#

with the ByteArrayOutputStream I think

lavish hemlock
#

Unnecessary

#

toJson is able to write to a stream

sly trout
lavish hemlock
#

swap your args around

#

it goes outputStream then object

sly trout
#

okay

#

still the same

lavish hemlock
#

oh

#

nvm

#

okay so

vale cradle
#

only JsonWritters

lavish hemlock
#

Nope, notice Appendable?

#

That's the supertype of Writer

#

I am terribly sorry for misleading you @sly trout You actually need a FileWriter

#

My brain isn't working well :p

vale cradle
#

there it is

lavish hemlock
#

I'll just give you an example

sly trout
lavish hemlock
#
// This is a try-with-resources statement - It closes the writer after you're done using it to free up resources.
try (FileWriter fw = new FileWriter("myfile.json")) {
    gson.toJson(object, fw);
}
sly trout
#

ayyy !

#

thank you ๐Ÿ™‚

lavish hemlock
#

Btw if a type implements Closeable

#

You should always make sure to close it after you're done using it

#

either via .close() or a try-with-resources

sly trout
#

okay ๐Ÿ™‚

lavish hemlock
#

There's actually some types that will fail to write correctly if not closed (e.g. ZipOutputStream)

sly trout
#

no need to save?

lavish hemlock
#

What, with Bukkit's methods?

#

Those are only for the plugin's YAML configuration.

#

Writing to a stream or writer means that it outputs the bytes immediately (or at least after a .flush(), although most types auto-flush on close)

#

So yeah you don't need to save.

sly trout
#

okay

vale cradle
#

still, make sure you're writting into the file every time you make a change

sly trout
#

also to fetch the json from the file

#

its Gson.fromJson

#

String Type?

#

what is Type

lavish hemlock
#

Type is Type and Class

#

Object.class is Class

vale cradle
#

and a type

lavish hemlock
#
try (FileReader fr = new FileReader("myfile.json")) {
    Object o = gson.fromJson(fr, Object.class);
}
#

(I recommend generics here)

sly trout
#

thank you you've really been of great help !

lavish hemlock
#

Learn them immediately

#

You will be glad you did.

sly trout
#

u mean (String)

#

those things?

lavish hemlock
#

Like

#

List<T>

#

T is a type parameter

sly trout
#

I'm french sorry I don't really know every term in english

lavish hemlock
dawn hazel
#

Anyone know how i can do this function in another class? i cant make the function static and i cant implement the main class or create a new instance of it. ive run out of ideas. even tried referencing it by itself manually the other class but that doesnt work either because i cant do GetDataFolder() in a class that isnt main

sly trout
#

lol

sly trout
#

we just get Object

lavish hemlock
#

e.g. myFunction(getDataFolder())

sly trout
#

wouldn't that work : ArrayList<PlayerData> data = (ArrayList<PlayerData>) _gson.fromJson(fileReader, Object.class);

lavish hemlock
#

It actually probably wouldn't

#

Gson needs to know the type so it can find the correct fields

#

Gson's generic types are...

#

not easy to work with

dawn hazel
lavish hemlock
#

for complicated reasons you can't do List<PlayerData>.class

lavish hemlock
#

Just make a util function :p

sly trout
#

what should i do then

lavish hemlock
#

I'll just tell you because you'll be confused otherwise lol

#

gimme a sec

vale cradle
lavish hemlock
#

Btw what version of Gson are you using...?

sly trout
#

I just did Gson in intelliJ

#

didn't have to add anything

dawn hazel
lavish hemlock
#

Ah so the one that comes with Minecraft? That's probably older then

sly trout
#

no the Google. something

vale cradle
#

but you can create a static function in other place and then call that function is that what you're looking at?

lavish hemlock
sly trout
dawn hazel
sly trout
#

why not

dawn hazel
#

if i do that is says plugin is already initialized

sly trout
#

i'll show u

dawn hazel
#

side note i am working with the bungeeapi

sly trout
#
private static Main plugin;

public void onEnable() {
  plugin=this;
}


public static Main getPlugin() {
  return plugin;
}

#

this should work

#

to get the instance of the main class

lavish hemlock
#

Java is fucking great sometimes no sarcasm intended whatsoever

sly trout
#

what the hell

#

why is

#

Gson so complicated

#

to deal with

lavish hemlock
#

Because Java is complicated when it comes to type parameters

#

See

#

To explain why

#

I have to walk you through what type params really are

#

They're basically like method parameters but for a type

#

Meaning you can safely say a List contains Strings

#

e.g. List is declared like uhh

#
public interface List<T> implements ...
#

T is then specified when you create a new List (or ArrayList)

#

like List<String>

next stratus
#

Don't ya hate it when you find your dream api but you can't import it due to the gradle thing being broken? :/

sly trout
next stratus
lavish hemlock
next stratus
#

It does exactly what I want, but I can't import due to the gradle thing being broken

sly trout
#

that's stupid

lavish hemlock
#
List<String> list = new ArrayList<>();
list.add(""); // The compiler knows that we must pass a String to 'add' because it's a List<String>

// Before Java added generics, it looked more like:

List stringList = new ArrayList();
list.add("");
list.add(0); // Oops, we just passed an integer in a situation where we want *strings*
#

Now

#

Since Java didn't start with generics

#

adding them broke some backwards compatibility or smthn

#

so they had to figure out a way to make it compatible

#

and because of that

#

Type parameters don't exist at runtime.

#

List<String> compiles down to just a raw List

#

Which is why we can't state List<String>.class bc there's no way for the compiler to make that work

#

TypeToken is a hack that allows us to keep that type parameter information

#

I don't really know how it works so I won't explain it.

lavish hemlock
lavish hemlock
#

That's all I can offer since "the gradle thing is broken" isn't descriptive enough.

sly trout
#
09.02 22:44:18 [Server]  at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
09.02 22:44:18 [Server]  at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)```
next stratus
sly trout
#

public static void saveAllDataToConfig() throws IOException {
Data file = Main.getPlugin().getDataFile();
try {
file.saveToFile(getPlayerReportData());
}
catch (Exception ec) {
ec.printStackTrace();
}

lavish hemlock
lavish hemlock
#

Show me that

sly trout
next stratus
minor otter
#

how would I go about loading a structure without updating the blockstates

lavish hemlock
#

It's always the caches lol

lavish hemlock
#

Yeah I saw it

#

You need a more specific type

dawn hazel
lavish hemlock
#

I assume it's trying to access the fields on Object but Object denies access to those fields

lavish hemlock
#

?di

undone axleBOT
sly trout
#

bruh what

lavish hemlock
#

You're passing in player report data, right?

#

Actually y'know what I'm probably wrong about that specific type part hm

#

I don't know why that's doing that gimme a sec

lavish hemlock
#

Send the full error

sly trout
#
09.02 23:00:34 [Server]  at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
09.02 23:00:34 [Server]  at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
09.02 23:00:34 [Server]  at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
09.02 23:00:34 [Server]  at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
09.02 23:00:34 [Server]  at com.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44)
09.02 23:00:34 [Server]  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
09.02 23:00:34 [Server]  at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
09.02 23:00:34 [Server]  at com.google.gson.Gson.getAdapter(Gson.java:458)
09.02 23:00:34 [Server]  at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:53)

09.02 23:00:34 [Server]  at CoolReports-1.0.jar//me.alexandre.files.Data.saveToFile(Data.java:27)
09.02 23:00:34 [Server]  at CoolReports-1.0.jar//me.alexandre.playerdata.PlayerData.saveAllDataToConfig(PlayerData.java:54)
09.02 23:00:34 [Server]  at CoolReports-1.0.jar//me.alexandre.Main.onDisable(Main.java:106)
09.02 23:00:34 [Server]  at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:266)```
sly trout
#

i really have no clue how to make this work

lavish hemlock
sly trout
#

It was a hashmap and not a List

#

so i just changed things to a hashmap but still doesnt work

sly trout
minor otter
#

How could I stop commands like /fill or things like loading structures from sending block updates? I already have a physics listener thats supposed to stop them but doesnt work on /fill or structures

lavish hemlock
#

Or

#

Maybe I am

#

I honestly don't know what could cause that error

#

...well I do, I just don't know how it was caused.

sly trout
#

bro im lost im really trying to save that data but i don't have a clue how

lavish hemlock
#

Actually wait

#

What is the type returned by getPlayerReportData()?

#

@sly trout

sly trout
#

Hashmap<UUID, PlayerData>

lavish hemlock
#

hmm

#

yeah I don't think I can really help...

#

besides, I gotta study rn so

sly trout
#

Okay

karmic grove
#
Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().
> Could not create service of type PluginResolutionStrategyInternal using BuildScopeServices.createPluginResolutionStrategy().
``` anyone know what this mean in gradle im not sure what happned
nocturne trail
#

I'm wanting to place a block roughly once every 5 or 10 ticks, but anywhere I put a runnable within

                for (int x = 0; x < 16; x++) {
                    for (int z = 0; z < 16; z++) {
                        String blocks = chunkFile.getString("blocks");
                        for (Iterator<String> it = Arrays.stream(blocks.split("/")).iterator(); it.hasNext() && (placed <= count); ) {
                            String[] balls = it.next().split("(?<=\\D)(?=\\d)");

                            mat = Material.valueOf(chunkFile.getStringList("palette").get(CharIndex.charToIndex(balls[0])));
                            count = Integer.parseInt(balls[1]);

                            p.getChunk().getBlock(x, y, z).setType(mat);

                            placed++;

                            if (count == placed) {
                                placed = 0;
                            }
                        }
                    }
                }
            }``` doesn't change my outcome, what is the best way to approach this?
quaint mantle
#

how to sort advancements from recipes in event PlayerAdvancementDoneEvent?

quaint mantle
glossy venture
#

is there a way to get the command line arguments unparsed as a string

#

so lets say i call it with java -jar myjar.jar a --o="b c" i want to get a --o="b c"

#

right now im concatenating all arguments passed in with a StringBuilder with spaces

#

but i dont think thats the best way to do it and i havent tested it yet

short raptor
#

How can I stop players from removing items from an inventory by shift clicking and closing the inventory really fast

#

I already try to cancel it by doing this

glossy venture
# lavish hemlock Not afaik

because iirc i coded an agent using a premain which passes in the command line arguments as a string (void premain(String, Instrumentation)), but i dont want to use the premain mechanism in a simple program so im wondering if theres another way

low temple
#

Does the item stay even after rejoining?

short raptor
#

Yea it's not ghost item

#

E.g. an elytra gotten from it can be used to fly

low temple
#

if so then maybe add a delay to it by 1 tick

chrome beacon
#

If you're just cancelling you don't need to force an inventory update

low temple
#

yeah id guess updating the inventory is updating it with the added item somehow

short raptor
#

I'll remove it since it didn't seem to do anything

low temple
#

pretty hard to stop ghost items

#

ghost items arent really problematic cause they usually appear from doing wonky stuff on purpose. And since they dont exist they arent exploitable

ivory sleet
#

To my knowledge they have a bigger chance of emerging given low tps

quaint mantle
#

why blockplaceevent calls when the block is not placed in 1.8

#

for example you place a block under yourself

#

and it calls

#

is there anyway to find out that if the event is valid ?

quasi flint
#

?

#

1.8 reeeeeeeeeeee

ivory sleet
#

I mean 1.8 is ancient so that doesnโ€™t surprise me the least

quasi flint
#

maybe try version = 1.18

quaint mantle
#

no im not changing versions

#

cringe

#

for example you place like this

worn tundra
#

youre cringe

quaint mantle
#

the event get called

ivory sleet
#

Not implying you should change, however it does not go without saying you will have to deal with the bug yourself

eternal night
#

Imagine asking for support for a version old enough to go to school

quaint mantle
#

listen im getting payed for a 1.8 plugin

#

and i have my own reasons

#

if you can, help

quasi flint
#

1.8 bug so good luck

ivory sleet
#

I donโ€™t think most of us can

#

Not trying to be a dickhead

#

But seriously

eternal night
#

If you want to use 1.8 there is, was it taco spigot or smth?

#

There are some forks at least that are maintained for 1.8

quaint mantle
#

it is

#

we are using a fork

ivory sleet
#

Yuh, maybe they could assist you further

eternal night
#

Yes but why ask here then

quasi flint
#

ask them why the bug happens

quaint mantle
#

i tested in spigot & paper

#

now what

ivory sleet
quasi flint
#

we are not maintaining 1.8

eternal night
#

If you use a maintained 1.8 fork they should be able to help and maybe fix your issue

ivory sleet
#

Anyhow pmzhero sounds like you should switch dev env to the production jar perhaps?

quaint mantle
#

what

ivory sleet
#

Use the same jar youโ€™re using in production for testing basically

quaint mantle
#

for example i cannot set the item in main hand to null, air or ANYTHING

#

in the block place event

#

why is that

ivory sleet
#

Maybe use the scheduler and do it a tick after

quaint mantle
#

done it

quasi flint
#

ask the maintainer of your fork

quaint mantle
#

not working for some materials

#

im currently using paper

#

tested on spigot

#

tested on fork

eternal night
#

Latest paper ?

quaint mantle
#

none of them works

#

yes

#

1.8

#

latest

quasi flint
#

we are not supporting it

eternal night
#

Like. Unless you are using a fork that is maintained for 1.8 you are out of luck

quasi flint
#

last version was from 6 years

#

jesus

ivory sleet
#

Itโ€™s very unclear what youโ€™re using to test your plugin on

eternal night
#

Neither spigot nor paper are

quaint mantle
#

spigot paper tacho

ivory sleet
#

Well donโ€™t use spigot nor paper

#

They wonโ€™t bring you any succulent results

quasi flint
#

the last update was from 6 years. why shall we fix bugs for ancient versions?

#

which are long outdated

quaint mantle
#

im not asking for a bug fix

#

im asking for any workaround to that bug

eternal night
#

Oh lol taco spigot was discontinued as a 1.8 fork ๐Ÿ˜‚

quaint mantle
#

is anyone forcing you to chat ?

#

im asking for a help

quasi flint
#

why shall we know that fix. didnt even programm when 1.8 was relevant

#

for me

eternal night
#

Yes, no one has an answer for you

quaint mantle
#

if you cant help

#

no one is forcing you to chat

#

and mock me and 1.8

#

i have my own reasons maybe ?

quasi flint
#

i will mock 1.8.8 every day.

#

it should be long ded

quaint mantle
#

this is a help channel

eternal night
#

You do you but I think it was rather clearly stated that spigot discord in general does not support 1.8

quaint mantle
#

not 100 reasons why 1.8 is trash and you should run a server with 1.8 pvp on 1.18.1

quasi flint
#

viaversion, oldpvpmechanics plugins

#

viabackwards

quaint mantle
#

sure sure sure very stable

#

not buggy at all

#

ocm opm not buggy

#

very stable

#

exactly copies 1.8 sure sure

#

๐Ÿ‘

quasi flint
#

more stable than 1.8.8๐Ÿ˜‚

quaint mantle
#

i shouldn't ask for help in a channel full of these idiots i guess

ivory sleet
#

I donโ€™t think 1.8 is bad itself

#

But it turns into an awkward situation when the software for that very version is no longer supported

#

Especially now since youโ€™re coming to us complaining about a bug which to some extent is probably patched in newer versions.

quasi flint
eternal night
#

Also I don't see the point of asking here. Why not ask in the help channel of the maintained fork you are using. The developers there work on 1.8 code a lot more then people here :/

quaint mantle
#

i have the problem also on spigot

#

and i ask for a help or a workaround or anyway to detect

eternal night
#

Yes but again, the likelihood of people knowing 1.8 code and quirks here is so so so much lower than asking people that actively maintain a 1.8 fork

quasi flint
#

last 1.8 version built is a few years ago

quaint mantle
#

last was log4j exploit

ivory sleet
#

Yeah but thatโ€™s quite different

#

Conversely to just bug hunting

eternal night
#

Fixing a remote code execution exploit does not make a version maintained XD

#

It's more of a "we don't want to be complete devils and have everyone not on latest be vulnerable to a pretty devastating exploit"

quasi flint
#

just let 1.8 servers burn

main matrix
blazing scarab
quasi flint
#

but they do the job at the expense of no buggy af 6 year old not supported versions

blazing scarab
#

Cool people just use 1.9 pvp

eternal night
#

Just flame Mojang to overhaul PvP in 1.20

ivory sleet
#

๐Ÿฅฒ

quasi flint
vivid cave
#

guys i really need to know where (and when) do the MapRender.render(...) trigger

#

i know its when the player tries to render a map, but its too vague, i need more context on this

short raptor
#

Oh wait hold on

#

I didn't try the new version

#

Peak dumb right here

#

Hmm, I think it's only occurring in creative mode now

#

I think it should be ok

#

Thanks

eternal night
#

which sends update packets for every complex item in the players inventory (which rn is just maps xD)

#

the update packet for maps is only send every 5 ticks or if the map palette is dirty (e.g. a pixel was set)

vivid cave
#

@eternal night thank you! and what if the map is not in players inv but on an item frame

eternal night
#

Eehh I think it loads the map from the server based on id ?

#

and from there on it is just static

#

at least I don't recall any map item ticking for item frames

chrome beacon
#

Yeah it should be from id

quaint mantle
#

hi guys, ages ago someone taught me how to listen to incoming packets without protocollib (i think it involved a custom playerconnection class) does anyone know how?

#

i'm making a pvp server so it's only on 1.8.9 so version dependence doesn't matter lol

#

delving into NMS is super interesting

short raptor
chrome beacon
#

Ugh that's a pain to do

#

Doubt anyone here will guide on that

eternal night
vivid cave
quaint mantle
#

@chrome beacon xd

eternal night
#

note that the tutorial is trashing java conventions

#

but the concept is there

quaint mantle
#

thanks lynx

#

ill go read

#

๐Ÿ˜„

chrome beacon
eternal night
#

Generally if you want to dive deep into NMS, setup a server source locally

#

makes this a lot easier

quaint mantle
#

yea fair enough

#

i could've sworn the way that someone taught me to listen for packets ages ago was much simpler

#

maybe my memory is just bad xD

chrome beacon
#

Maybe you just used Protocollib

quaint mantle
#

yeah maybe lol

#

i don't know tho

#

i would've remembered installing another plugin lol

chrome beacon
#

If I were you I would use it. Many servers have it installed anyway

quaint mantle
#

trueee

#

but NMS is interesting haha

#

i recall that i had used packets to spawn in a PlayerEntity and then on right click i made it print a message in chat lol. time to go work out how to do that xD

#

thanks for the help btw guys

#

have a good day ๐Ÿ˜„

onyx fjord
next stratus
#

Hey, so I wanna allow people to either use WorldEdit or FAWE in my code, I currently have WorldEdit as a depend can I just set them both as softdepend or??

#

from how it seems ye i can use softdepend

young knoll
#

Yes

#

Although softdepend means they can load the plugin without it

floral flare
#

Hi, I am having an unknown problem when trying to load the Bungee config and I was wondering if anyone could help me with this if possible.

chrome beacon
tender shard
#

why do you create a new file?

#

just do saveDefaultConfig()

floral flare
tender shard
#

oh it's bungee

#

sorry

floral flare
#

np

tender shard
#

well your error is in line 55

#

what is line 55?

tender shard
#

you didn't send line 55

floral flare
#

config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));

celest isle
#

How do I get and check if world has thunderstorm?

red plover
#

so uh i'm trying to get top values from a hashmap when a player does /topmoney <page> they get 10 top richest ppl on the server here's my current code

    public void execute(CommandSender sender, String[] args) {
        int page;

        if (args[0].isEmpty()) {
            page = 1;
        } else page = Integer.parseInt(args[0]);
        if (page < 1) page = 1;

        final int[] place = {((page - 1) * 5)};
        sender.sendMessage(Formats.DEFAULT + " Richest players on the server (Page " + page + "):");
        AsyncPlayerData data = new AsyncPlayerData(Insidious.getInstance(), dataSource);
        data.getTopBalance(place[0]).queue(result -> {
            if (result.isPresent()) {
                HashMap<Player, Long> map = new HashMap<>();
                List<InsidiousPlayer> list = result.get();
                for (InsidiousPlayer info : list) {
                    map.put(Insidious.getInstance().getServer().getPlayer(info.getUuid()), Long.valueOf(info.getValues().get("balance")));
                }
            }
        });
    }

i don't know how to return top values from the hashmap

young knoll
#

Hashmaps arenโ€™t sorted

red plover
#

oh any alternative way of doing it?

floral flare
# celest isle How do I get and check if world has thunderstorm?
    @EventHandler(priority= EventPriority.HIGHEST)
    public void onWeatherChange(WeatherChangeEvent e) {
        boolean rain = e.toWeatherState();
        if (rain) {
            e.setCancelled(true);
        }
    }

    @EventHandler(priority=EventPriority.HIGHEST)
    public void onThunderChange(ThunderChangeEvent e) {
        boolean storm = e.toThunderState();
        if (storm) {
            e.setCancelled(true);
        }
    }```
young knoll
#

I mean

#

You can just check from a world instance

#

Without needing events

celest isle
#

what is this for actually

floral flare
floral flare
lost matrix
celest isle
#

because I just want to check if the weather and time are night or thundering... im quite new to this

lost matrix
celest isle
#

thunderstorms count as thundering?

floral flare
floral flare
young knoll
#

Yes thunderstorms are thundering

buoyant viper
#

isnt that just how beds work...

#

either night or thunder...

celest isle
#

yes but when you enterbed event in daytime and it kicks you out it stills runs

buoyant viper
#

why reinvent the wheel

floral flare
celest isle
#

ahh thanks a lot of the clear explanation!

floral flare
floral flare
buoyant viper
#

cant u just instantiate a YamlConfiguration directly

floral flare
buoyant viper
#

hmm

lost matrix
young knoll
#

^ online parsers are goat

lost matrix
# floral flare

Hm. It could be a problem regarding your special characters like accent aigu.
Make sure every String is quoted.

lost matrix
floral flare
tender shard
#

well

floral flare
# lost matrix After doing what?

It turned out that the jar generated a faulty config file within config, so no matter how many times I tried to change it in the code, it could only be changed in config

tender shard
#

are you trying to read an empty YAML @floral flare ?

#

because the stacktrace suggests that

#

since it says length is 1 (only EOF)

young knoll
#

They fixed it

lost matrix
tender shard
#

oh

#

what was the problem

floral flare
#

The plugin started correctly, with no apparent problems

#

Thanks for helping ^^

thorny python
#

is it safe to use Chunk object as key in hashmap?

lost matrix
young knoll
#

^

#

I really should PR that

thorny python
#

um I do need also consider world

young knoll
#

Paper has it

lost matrix
thorny python
#

uh

#

ok...so how to map xz to long?

#

x * IntegerMax + z?

smoky oak
#
public static long hashPositions(int x, int y) {
        // We make use of (y & 0xFFFFFFFFL) as otherwise y values such as -1 would completely override the x value.
        // This is because `long | int` automatically casts the int to a long, where as the cast is by decimal value
        return (((long) x) << 32) | (y & 0xFFFFFFFFL);}```
#
x = (int) (hashed >> 32);
y = (int) (hashed & 0xFFFFFFFFL);```
thorny python
#

oh ya bit manipulate xd

#

ty

smoky oak
#

So i have a set of values per player where almost every value is null.
Should i do a HashMap<UUID, HashMap<Enum, int>> or a HashMap<UUID + Value_Name, int>, then null check, or is there a better solution than either?

lost matrix
smoky oak
#

no

#

null check after calling get

#

so that i know if it should be 0

#

bc it aint there

#

thats what the null checks for

tender shard
#

map also has getOrDefault

smoky oak
#

that'd do it

#

the issue is that i need a simple way to map two keys to one value

#

how to do that

#

(String, Enum all probabilit afater)

tender shard
#

you mean two values to one key?

smoky oak
#

yes

#

ah no

tender shard
#

I#d just create a data class that I'd use for the values

smoky oak
#

two keys to one value

tender shard
#

that's no problem at all?

smoky oak
#

I'd rather not have a map inside a map

lost matrix
#

Mapping two values to one key sounds like you should create an extra class for that

smoky oak
#

hence the question

#

other way

#

two keys one value

lost matrix
#

If you want two keys for one value then you should use a Table

smoky oak
#

my brainded arse googled table and was surprised to see tables

lost matrix
#

Table<UUID, Enum, Integer> dataTable = HashBasedTable.create();

tender shard
#

wait do you want to use something like <Object1,Object2> as key? or do you just want Object1 -> Value1 and Object2 -> also Value1 ?

smoky oak
#

I need some different values for different interactions, which apply to the same values. Like interaction + HEALTH_CHANGE for example

#

and I'd rather not read in the config every single time

young knoll
#

Config is stored into a map when read

smoky oak
#

what's the O(n) for FileConfiguration.getInteger(two_layer_deep_path)

#

if its small that might be a solution

#

if i grab that map

lost matrix
smoky oak
#

so

#
FileConfiguration rcfg = Bukkit.loadResource(config_path)
...
rcfg.getStringList(path).contains(value)```
?
young knoll
#

He means store the string list itself into a variable

smoky oak
#

isnt FileConfiguration also extending Collection<T> ?

lost matrix
#

Its a MemoryConfiguration

#

Which is basically a glorified HashMap

#

But not quite

thorny python
#

hmm given two location x1, z1, x2, z2, is there any good algorithm to find all chunks which contain blocks within the rectangle form by that two location?

smoky oak
#

bit shift em to the right then grab the chunk coordinates. Difference between the x1/x2 and y1/y2 shows you how much you have to go east/south

lost matrix
thorny python
#

uh

#

ya probably just loop with increment 16 xd

smoky oak
#

im unsure if bigger values take longer to compare

#
x1 >> 4; x2 >> 4; z1 >> 4; z2 >> 4;
for(int x == x1, x<x2, x++){
  for(int z == z1, z<z2, z++){
    Bukkit.getChunkAt(x,z);
lost matrix
# thorny python uh

Something like this:

  public List<Chunk> allChunksBetween(final int x1, final int z1, final int x2, final int z2, final World world) {
    final List<Chunk> chunks = new ArrayList<>();
    final int minX = Math.min(x1, x2);
    final int maxX = Math.max(x1, x2);
    final int minZ = Math.min(z1, z2);
    final int maxZ = Math.max(z1, z2);
    for (int x = minX; x <= maxX; x++) {
      for (int z = minZ; z <= maxZ; z++) {
        chunks.add(world.getChunkAt(x, z));
      }
    }
    return chunks;
  }
smoky oak
#

iirc he is using coordinates, wouldn't that trigger 256 times per chunk

lost matrix
#

I thought he meant chunk coordinates

thorny python
#

block coords sorry

#

._.

smoky oak
#

'to find all the chunks that have blocks in that rectangle'

thorny python
#

but thanks anyway

smoky oak
#

(my code assumes x1<x2 & z1<z2)

#

his code doesnt take into account the division by 16

lost matrix
#
  public List<Chunk> allChunksBetween(final Location a, final Location b) {
    Preconditions.checkArgument(a.getWorld().equals(b.getWorld()));
    return allChunksBetween(a.getBlockX() >> 4, a.getBlockZ() >> 4, b.getBlockX() >> 4, b.getBlockZ() >> 4, a.getWorld());
  }
smoky oak
#

huh

thorny python
#

lol

smoky oak
#

imma copy that

thorny python
#

ya I may over complicate the problem

lost matrix
thorny python
#

but btw should use Set instead of List for the internal use I guess

#

wait

#

nvm it should be fine

lost matrix
thorny python
#

similar like res plugin

#

I want to map location to an area object

#

so I can know which area player currently inside

lost matrix
#

Oh. Then you should def not touch any chunks. You need to think more abstract for this.

thorny python
#

to avoid O(n) iteration, I am currently decide to use chunk as bucket

lost matrix
#

This makes a bit more sense.

thorny python
#

so map location to chunk first, then iterate over areas in the chunk bucket

lost matrix
#

Thats also what i did for my regions.
BoundingBoxes with chunks as buckets

thorny python
#

ya otherwise it could be slow when too many area or region