#help-development

1 messages · Page 396 of 1

hybrid turret
#

random question that i definitely should know bc it's basic knowledge but...
what does super.<method here> do?

torn shuttle
#

fucking lmao get rekt kid you thought crossProduct and getCrossProduct were the same method

#

lmao loser

hybrid turret
#

what

#

Ahhhh!

torn shuttle
#

have fun wasting 4 hours

hybrid turret
#

I see

charred blaze
#

where do i need my config.yml file in? in my resources folder?

hybrid turret
#

doesn't really matter but that's the place for it these days ig

ivory sleet
#

I mean its the convention, so it does matter in that aspect

charred blaze
#

help

regal scaffold
#

Is it really necessary to use Objects#requireNonNull() to get rid of the warning in intelliJ

charred blaze
#

??

regal scaffold
#

What's better? Using that or Objects#requireNonNull()

remote swallow
#

Objects.requireNonNull should only really be used in apis or libs, suppressing is better or just ignoring it

eternal oxide
#

by default Eclipse doesn;t complain about possible nulls

#

IJ does

remote swallow
#

intellisense more like intellinnoying

hybrid turret
#

true

ivory sleet
#

I actually have this code inspection as strong instead of weak cause null in Java sucks

ivory sleet
tardy delta
#

@SuppressWarnings("ConstantConditions")

charred blaze
#

how do i cancel scheduleSyncRepeatingTask from inside?

smoky oak
charred blaze
#

i dont save BukkitTask variable

smoky oak
#

i mean

#

just call this.cancel() inside?

#

doesnt it extend runnable?

charred blaze
#

can i do that???

chrome beacon
#

Runnables only have a run method

#

The BukkitRunnable does have a cancel method

smoky oak
#

ah you thought i meant the default one

#

i just assumed ur using the bukkit version

remote swallow
#

is there a default port for http to check on, like if i had http://198.168.0.2/ what port would it check for it attempt to resolve

smoky oak
#

443 iirc

chrome beacon
smoky oak
#

definitively a default port but im not sure on which one

#

probs 80 then

#

lmc

remote swallow
#

like attempting to load the page

eternal oxide
#

no port is used to resolve an address, thats DNS

#

the port used for communications is down to which protocol

remote swallow
#

this is very tragic

#

im testing how reposlite works before i get my domain so im not just fucking about trying to get it all working and if im even gonna stick with reposlite

#

and gradle doesnt like the port on the ip

#

ive got that done

#

gradle just doesnt like the port and i dont want to setup its proxy to work

smoky oak
#

ye shells 8080

remote swallow
#

ive got the insecure stuff enabled

charred blaze
#

i cant

eternal oxide
#

maven requires https and probably ssl so port 8080 and 443?

charred blaze
#

"cannot resolve method scheduleSyncRepeatingTask"

#

in the bukkitscheduler

ivory sleet
#

runTaskTimer

charred blaze
#

whats difference

eternal oxide
#

they havn't removed it but in many instances providing just http will fail with an error

smoky oak
ivory sleet
#

scheduleSyncRepeatingTask is old and arguably legacy

smoky oak
#

nvmind im dumb

ivory sleet
#

runTaskLater, runTask and runTaskTimer are superior options 99% of the times

smoky oak
#

on a completely different topic, does anyone know why Blob::getBytes(long, int) doesnt take a long as 2nd argument if Blob::length() returns a long? Blob::getBytes args are int position, long copycount

charred blaze
#

thanks

eternal oxide
smoky oak
#

i realized that 3 seconds after i wrote that

eternal oxide
#

🙂

smoky oak
ivory sleet
#

Blob?

smoky oak
#

ye

#

sql data type

#

binary large object

ivory sleet
#

Ah

smoky oak
#

like it will work if i just put an int there

#

but it feels wrong

#

if a blob can have a long size why can it onlny spit out int bytes of that

ivory sleet
#

Yeah that’s a bit counter intuitive

smoky oak
#

i mean that also means a DB can, at max, store a 2.1GB object

#

whic

#

well i wont reach

#

but if you want to store images or video files

ivory sleet
#

Seems like you otherwise have to retrieve the blob part by part

smoky oak
#

luckily i really doubt that a serialized anything from minecraft reaches gigabytes in size

ivory sleet
#

Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes.

#

(getBytes)

#

part of the BLOB value

#

Tho in that case I assume you have to manually keep track of the parts, sounds like a hassle

smoky oak
#

yea

#

ill just say 'if your inventory is over 2 GB in size... how did you even do that'

ivory sleet
#

Poor api :>

smoky oak
#

i mean

ivory sleet
#

Lol ye

smoky oak
#

you get kicked if you exceed what

#

3Meg?

#

or did they bump it to 30

ivory sleet
#

Used to be the case

#

Think you can fit plenty nowadays

smoky oak
#

eh w

#

*whatever

#

wont be my problem

ivory sleet
#

🥲

smoky oak
#

though my documentation is my problem lol

/**
     * Black magic out
     * @param data
     * @return
     */
ivory sleet
#

So useful

smoky oak
#

i mean

#

i just use the code

#

i dont understand it

#
byte[] blobData = data.getBytes(1,(int) data.length());

ByteArrayInputStream bis = new ByteArrayInputStream(blobData);
BukkitObjectInputStream ois = new BukkitObjectInputStream(bis);

int length = ois.readInt();
ItemStack[] stack = new ItemStack[length];

for (int i = 0; i < length; i++) {stack[i] = (ItemStack) ois.readObject();}

ois.close();
return stack;
remote swallow
#

its not even gradle causing it KEKW

#

wait

#

oh wait

#

im very dumb

smoky oak
#

nice path

remote swallow
#

i question how ive managed to get this far a lot

smoky oak
#

?????

remote swallow
#

does maven like http domains

ivory sleet
#

Also moterious

#

getBinaryStream exists, just saw that

#

Which takes length as a long data type

smoky oak
#

hm

#

i wonder if i can slot that into it

#

ill make a note and test it later

ivory sleet
#

(Cause I assume you can just go with InputStream::readAllBytes, altho u might wanna avoid that as if the array is large enough it could cause the system to hang)

smoky oak
#

i mean

#

the only reason to use getBinaryStream is if you either read ur data one by one or a large amount at once

#

so i expect lag with that one either way

ivory sleet
#

Mye

#

target.spigot().sendMessage(finalMessage)

#

Probably

charred blaze
#

what does spigot() do?

ivory sleet
#

It provides the player’s Player.Spigot object

#

Which has a set of methods involving bungee chat api amongst other stuff

charred blaze
#

ok

tardy delta
#

oh god mojang thought it was fun to put references to other groups in a group file

remote swallow
#

anyone got or know of a doc that explains how to get java docs jar from a repo and convert that to the javadoc site automatically

brisk estuary
#
@ParametersAreNonnullByDefault
public NewAbstractMachine(ItemGroup itemGroup, SlimefunItemStack item,
RecipeType recipeType, ItemStack[] recipe) {

        super(itemGroup, item, recipeType, recipe);
        createPreset(item.getItemId(), getItemName());
        addItemHandler(onBreak());

}``` This is the constructor of an abstract class. The createPreset() method has already a default implementation. If I create an instance of a child class which has its own implementation of that method, when the super() is called in the constructor of that child instance it will use its implementation of the method createPreset(), right?
ivory sleet
#

Yes

remote swallow
ivory sleet
#

createPreset() is effectively equivalent to this.createPreset() which refers to the most concrete implementation of the method, so if you were to have class FinalNewMachine extends NewAbstractMachine and assuming FinalNewMachine::createPreset is defined in the class itself then that would be the method used.

brisk estuary
#

okay, ty : )

ivory sleet
#

Most object oriented languages usually work like this speaking of which fyi (:

tender shard
#

I'm in rehab, I don't have time to explain people how to read blog posts lol

analog thicket
rotund ravine
#

Gj

eternal oxide
#

Alex is our resident hobo

regal scaffold
#

@lost matrix I am making a "panel-type extension" to your GUI implementation which you showcased in your guide. So you can keep specific parts of the GUI "loaded" while you need it.

Like for example if you always want to have a "go back" button in every inventory that you would need it

#

Once I'm done I'll take some criticism

regal scaffold
#

This is interesting

#

Mind if I ask you some questions regarding it smile?

#

In your example

this.guiManager.openGUI(new PianoInventory(), player);

is how you create a new inventory for piano.

But what if you need another variable inside the PianoInventory class?

for example:

this.guiManager.openGUI(new PianoInventory(int inventorySize), player);

#

Do you need to adapt the GUIManager or just change stuff inside the PianoInventory?

lost matrix
#

Just the inventory. The manager doesnt need to change for that

regal scaffold
#

But I made a new constructor for it and I'm getting NPE

#
    private UltraChest ultraChest;

    public MainMenuInventory(UltraChest ultraChest) {
        this.ultraChest = ultraChest;
    }
#

Either I'm messing up with something basic that I shouldn't be or I am a bit confused

lost matrix
#

Nothing here can throw a NPE

regal scaffold
#

Ah so that answers it

#

createInventory() gets called first, right

#

That means changing the title of the inventory to something that comes from the parameter is not possible

#

Because it hasn't been assigned yet

#

So doing ultra.getName() throws NPE

#

Makes sense

lost matrix
#

If MainMenuInventory extends InventoryGUI then you need to call super() in your constructor ofc

regal scaffold
#

Yes I did that

#

In my next debugging test

#

But still throws npe on return Bukkit#createInventory

#

Cause of the name

#

I'm thinking how to do dynamic inventory names then

lost matrix
#

I see the problem. Then move the createInventory from the constructor somewhere else

regal scaffold
#

makes sense

#

Won't look as pretty but that is a good solution

#

Thanks

#

Not the prettiest but can't I just take it out of the constructor call it manually in each Inventory.java constructor?

#
    public MainMenuInventory(UltraChest ultraChest) {
        super();
        this.ultraChest = ultraChest;
        createInventory();
    }
lost matrix
#

Eh maybe in the open method or in the manager. Else you will just pass the problem to the next
extension of your class.

regal scaffold
#

True

#

eh

charred blaze
#

how do i get rid of this warnings without object.requirenonnull?

lost matrix
river oracle
#

Supresswarnings or disable it in ijs settings

charred blaze
river oracle
charred blaze
charred blaze
lost matrix
charred blaze
#

which suppresswarning

#

???/

#

@SuppressWarnings("null")

#

i tried this

#

but warnings are still there

lost matrix
#

🤨

#

Data in the key?

charred blaze
lost matrix
#

It should be more like

{
  "locationX":5,
  "locationY":5,
  "locationZ":5,
  "locationYaw":5.0,
  "locationPitch":5.0,
  "identifier": "bedwars:position"
}

Right?

#

Yeah just create a custom TypeAdapter for whatever Object your "identifier" is

#

You should create one adapter which implements JsonSerializer<YourObject> and JsonDeserializer<YourObject>

#

Then register this adapter for your class

#

TypeToken will make this pretty easy

ivory sleet
# charred blaze whats wrong

@SuppressWarnings("ConstantConditions, NullableProblems") i think? Havent been on intellij for quite a while now

charred blaze
#

not working

regal scaffold
#

I have a question

#

How would you extract duplicate code for this method?

What if you need 10 different ones, there has to be a better way to do this

https://paste.md-5.net/nininikoka.cs

Each one of these items should have a different consumer event, and as you can see the data used to create the metadata is different. Otherwise it's exactly the same

#

?paste

undone axleBOT
left plover
#

You could make an enum and a single function that takes the enum, and other additional arguments and process it through some switch cases, or put values into the enum that get pulled inside that one function

regal scaffold
#

I was thinking on that

#

Since these items are always gonna be there, just their itemmeta is configurable but an enum would help

#

But how would I diferenciate the stuff.. hmmm

#

I could make an enum with a bunch of parameters for each item

undone yarrow
#

Can anyone please help me save this variable? Because it's a map and uses Location, it needs to be serialized and deserialized (I think), but Ive already spent so many hours trying to fix it but nothing worked.
public Map<Location, ChestObject> chests = new HashMap<>();
https://paste.md-5.net/olujoqoqux.java the code

eternal oxide
#

locations are serializable

#

you only have to use getConfig().getLocation(path)

undone yarrow
regal scaffold
#

That still doesn't allow me to have different consumer methods I think

#

I mean I think I can simplify the item creator part but I still need to do the cases 1 by 1 obviously

eternal oxide
regal scaffold
eternal oxide
#

if you want to save a location to config you simply do java getConfig().set(path, location);
and to retrievejava getConfig().getLocation(path);

undone yarrow
#

Unless I misunderstand your code, you're misunderstanding my question I think? I dont need to get a location of a config or anything, but what everyone has told me so far is that the problem is the Location object

regal scaffold
#

I mean, copilot just really wants me to amke them 1 by 1 hehe

undone yarrow
#

But anyways Ill try what you recommend

regal scaffold
#

It autocompleted them all lol..

#

Copilot is nuts

eternal oxide
#

you are trygin to use a byte stream which is not appropriate for a config

undone yarrow
#

oh

#

So I need to use a save&load system using configs?

eternal oxide
#

yes

undone yarrow
#

hmm alright, thanks. Ill give it a try

eternal oxide
#

you could make this very simple by making yoru ChestObject implement ConfigurationSerializable

undone yarrow
#

What if I use the YamlConfiguration class?

eternal oxide
#

add teh apropriate methods it requires, register the class and yoru save code would be java getConfig().set("chests", choests);With load being a reversal

undone yarrow
#

So that would turn into something like this


public void saveChestData() {
    File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE);
    YamlConfiguration config = new YamlConfiguration();
    int i = 0;
    for (Map.Entry<Location, ChestObject> entry : chests.entrySet()) {
        Location loc = entry.getKey();
        ChestObject chest = entry.getValue();

        config.set(i + ".location", loc);
        config.set(i + ".particle", chest.getParticle().name());
        config.set(i + ".items", chest.getItems());
        config.set(i + ".cooldown", chest.getCooldown());

        i++;
    }

    try {
        config.save(file);
    } catch (IOException e) {
        e.printStackTrace();
    }
}```
charred blaze
#

any ideas why?

regal scaffold
#

Remove him from the list too

left plover
regal scaffold
#

Well, they are GUIitems events

#

So they just do stuff internally

#

Haven't been able to get the ItemAdapter working just yet

frail gale
#

guys does someone know how I can make an item which name colors are constantly changing in gradient way?

regal scaffold
#

But don't I still need to specify each parameter like I'm doing it rn?

#

It'll still require 10 methods for 10 different custom items

frail gale
#

I'm mostly confused in the way of how I can make the gradient flow

regal scaffold
#

I am using configs

frail gale
#

basically the gradient animation

regal scaffold
#

For these 10 items, cause the metadata is customizable

#

Hmmm

#

That might be the only way

#

But still will need 10 methods then

#

I was wondering if maybe doing stuff with an enum would allow me to simply it

#

Lik

frail gale
#

@quaint mantle do you have an idea about the gradient animation?

regal scaffold
#

If I have an enum containing all the stuff I need for each item, getConfig# and everything

#

I can just do a loop on all the values and make the items accoringly

#

It'll be long code but somewhere else not 10 different methods

#

No clue how to implement that tho, was just an idea, could easily not be good practice

frail gale
#

I understand about the Builder and thanks for showing it to me. I know what a Builder is, but I didn't knew really the deep details about it. I'm just confused about the String Gradient Animation

#

alright

#

Do you know how I can make it look like a wave?

tawdry echo
#

for what creating next class to create itemstack from builder, just method build which return itemstack

regal scaffold
#

@lost matrix Using your gui implementation, how would you make a button open another GUI, would you do it just like the first one? GUIManager#openGUI(new Inventory())?

undone yarrow
#

@eternal oxide is something like this what you mean? It still doesn't completely work, but it does generate a yaml file with correct syntax. To be honest I don't completely understand what every line does in the save/load system, but I need to get this part done to finish my plugin 😕
https://paste.md-5.net/lacikunixe.java - ParticleHandler
https://paste.md-5.net/uvasonupor.java - ChestObject
The same error I get each time (most likelycaused by calling the save method) is: Cannot load plugins\ScrapCollection\chest_data.dat org.bukkit.configuration.InvalidConfigurationException: could not determine a constructor for the tag tag:yaml.org,2002:me.JustinS_2006.particles.ChestObject in 'string', line 2, column 3: - !!me.JustinS_2006.particles.Ches ...
(full error: https://paste.md-5.net/cuguzimiro.sql)

dry yacht
# frail gale Do you know how I can make it look like a wave?

Do you have an example of what you're trying to build? Is it a static or a changing wave? If it's the latter, it's likely some resource pack stuff, which I have no idea about. It wouldn't be hard to calculate gradients and update them on every tick, for example, but that would be expensive.

eternal oxide
#

one sec

undone yarrow
#

Thanks so much for the help so far btw. I appreciate it 🙂

regal scaffold
#

He meant an ingame example loll

dry yacht
#

Yeah, I mean how fast does it have to change

charred blaze
frail gale
#

I don't know how fast it could be

#

There are some plugins who does that kind of name formatting in their GUIs

lost matrix
regal scaffold
#

But then, pressing esc won't take you to the back the the previous menu

frail gale
regal scaffold
#

And overriding the inventoryCloseEvent to make it open a new inventory of the previous one is a nasty infinite bug loop

dry yacht
undone yarrow
#

ElgarL 3528 is something like this what

frail gale
regal scaffold
#
    @Override
    public void onClose(InventoryCloseEvent event) {
        super.onClose(event);
        plugin.guiManager.openGUI(new MainMenuInventory(ultraChest), (Player) event.getPlayer());
    }
``` but doing this is not working
frail gale
charred blaze
#

code not working as expected

frail gale
regal scaffold
#

Oh that's right I forgot

#

Ok then I'm sorted

#

Thanks

frail gale
frail gale
regal scaffold
#
        new BukkitRunnable(){

            @Override
            public void run() {
                     plugin.guiManager.openGUI(new MainMenuInventory(ultraChest), (Player) event.getPlayer());
            }
        }.runTaskLater(plugin, 1);

#

Looks so ugly to make it run 1 tick later

#

Annoying

#

Why is there not a 1 liner

tardy delta
#

dont instantiate bukkitrunnables, use the scheduler

undone axleBOT
regal scaffold
#

Oh

#

alr

charred blaze
#

help

minor garnet
#

i can get all entities inside of a chunk async?

regal scaffold
#
    @Override
    public void onClose(InventoryCloseEvent event) {
        super.onClose(event);
        Bukkit.getScheduler().runTaskLater(plugin, () -> {
            plugin.guiManager.openGUI(new MainMenuInventory(ultraChest), (Player) event.getPlayer());
        }, 1L);
    }
#

now that looks a lot better

regal scaffold
minor garnet
regal scaffold
#

Is that a pepper lol?

#

🌶

#

It's a pepper

#

rip

#

Was similar

dry yacht
minor garnet
#

i know these are two completely different things but i would need this for read only

dry yacht
frail gale
dry yacht
frail gale
#

For now I don't really know because I haven't tried and I haven't researched a lot about it

minor garnet
#

how does bukkit detect if im accessing this data async?

frail gale
#

I know that you can add hex colors by using of() in ChatColor class from md_5

dry yacht
#

Because I never got it to work properly with bukkit, which is why I wrote my own component system. But that's rusty and not ideal, as it's quite old, which is why I'd prefer to only show you the actual color generation. I think you could make the rest work out.

charred blaze
sinful kiln
untold stirrup
#

some one know how i can change the combat pvp on 1.19 to 1.8.9

smoky oak
#

On a different topic

CREATE TABLE IF NOT EXISTS uuid (
  inventoryNumber INT NOT NULL,
  inventory BLOB NOT NULL,
  PRIMARY KEY (vaultNumber),
  CONSTRAINT constraint UNIQUE (inventoryNumber), --Error here
);```
SQL error or missing database (near "constraint": syntax error)
well yes im trying to create said database. Can someone explain why this isnt working here?
lost matrix
frail gale
smoky oak
lost matrix
#

Try again. Without is the proper syntax

smoky oak
#

i told you i already did and it didnt work

#

and it once again didnt work

sinful kiln
#

Wait you are creating a table for each player?
Wouldn’t be one table enough?
Like you can have multiple uuid-inventory number pairs

dry yacht
smoky oak
sinful kiln
#

He said „uuid is a placeholder for the player uuid“ therefore I assume he does

#

No it doesnt

smoky oak
#

alright ill start. 1: you cannot easily isolate a player

sinful kiln
#

You can sill make unique pairs out of the uuid and the inventory numver

#

You can

lost matrix
smoky oak
#

well i mean you cant just open it and check

sinful kiln
#

That’s why you have query statements

smoky oak
#

you need to do more sql

lost matrix
#

Sure. Every proper db tool lets you filter by column values

sinful kiln
frail gale
# untold stirrup some one know how i can change the combat pvp on 1.19 to 1.8.9

even on Modding aspect this is also hard to be done. I have an MCP setup and there are many methods to look for Attack Cooldown and that kind of stuff. I know that there is one plugin which claims to do that called DeluxeCombat, but I don't how accurate it is for 1.8 PvP.
You can't really bring back the 1.8 PvP in 1.19 to look exactly the same with plugins

sinful kiln
#

CONTRAINT <constraint_name> UNIQUE (<keys>)

smoky oak
#

ye isnt that exactly whta im doing

#

CONSTRAINT constraint UNIQUE (inventoryNumber)

frail gale
quaint mantle
#

constraint is a keyword, I don't think you can name things after keywords

sinful kiln
#

Sql isn’t case sensitive

smoky oak
#

ah

#

that did it

sinful kiln
#

You could use it if you quote it probably

smoky oak
#

new issue tho

#

'java.sql.SQLException: not implemented by SQLite JDBC driver'

#

apparantly im missing libraries?

quaint mantle
#

I've seen that error before, but I have no memory of how I personally fixed it. It's been too long since I tried to mess with databases

sinful kiln
#

I think PRIMARY KEY itself doesn’t exist with SQLite

#

You need to define it as a constraint

smoky oak
#

i mean it works now

#

but apparantly my sql doesnt have the PreparedStatement::setBlob function

#

wtf am i supposed to do then

#

store it as LONG TEXT

sinful kiln
#

Use binary instead?

sinful kiln
smoky oak
#

well its variable size

#

sooooo

sinful kiln
#

Use <size> as a max size?

#

Each entry doesn’t have to be exactly that size

#

It’s just how much can be in one entry

smoky oak
#

urgh i wrote all my code for blob

quaint mantle
# sinful kiln Use <size> as a max size?

Quick question about that, wouldn't the database still append zeros (or whatever) to the end to read the required size, or would the database provide the correct amount of data when queried?

hazy parrot
sinful kiln
molten hearth
#

MySQL supports blobs

#

This might be a java skill issue

hazy parrot
#

Sqlite ^

sinful kiln
molten hearth
#

Sqlite also supports blobs

sinful kiln
#

Well doesn’t seem like the JDBC driver does though

molten hearth
#

Java skill issue indeed lol

#

base64 encode the data ig

smoky oak
#

@molten hearth
trace:

java.sql.SQLException: not implemented by SQLite JDBC driver
...
at io.github.moterius.vaults.SQLite.VaultDatabase.insertInventoryAt(VaultDatabase.java:188)

code:

ps = getSQLConnection().prepareStatement("REPLACE INTO " + uuid + " (vaultNumber, inventory) VALUES(?,?)"); 
ps.setInt(1, position);
ps.setBlob(2, stackToBlob(inventory));//error here
sinful kiln
#

@smoky oak try setBytes with BLOB

#

Maybe it works?

molten hearth
#

SO says to use setBytes

#

Still not implemented since 2011

smoky oak
hazy parrot
#

I just have to ask, are you using different table for each player?

sinful kiln
#

Yes he does

quaint mantle
#

Tf is blob in sql

quaint mantle
molten hearth
quaint mantle
#

So whats use of this?

smoky oak
molten hearth
#

To store binary data? Lol

dry yacht
quaint mantle
#

Oh

hazy parrot
#

But you surely should be using table for each player

molten hearth
#

You might wanna store icons or some binary buffer that you wanna reuse or such

quaint mantle
molten hearth
#

It might work with Php but not with java

quaint mantle
#

Strange

dry yacht
quaint mantle
#

My bad then

molten hearth
#

You need to expose your code to sql injection format the string yourself

dry yacht
#

Just enclose it in backticks and call it a day, xD

quaint mantle
dry yacht
#

And remove all backticks from the parameter, I forgot, xDD

#

But other than that, I think you're out of luck in Java

#

PreparedStatement#setString always adds single quotes, and there's no setIdentifier or what it would be called.

sinful kiln
#

I hate that the PreparedStatement set methods all use indexes starting at 1

quaint mantle
dry yacht
smoky oak
#

urgh

sinful kiln
#

No thanks x)

smoky oak
#

nice javadoc mate

quaint mantle
dry yacht
sinful kiln
dry yacht
quaint mantle
#

I didn't actually write wrapper methods, I was making a joke.

smoky oak
#

anyways is the only solution using a different method? How do i know which methods work and which dont?

dry yacht
smoky oak
#

can i use that on BLOB or do i need to change that?

sinful kiln
#

Just try if it works

#

If it doesn’t you need to change the type otherwise you got a solution

quaint mantle
#

Information that is easily obtainable via the javadoc (or as @sinful kiln already said, trying it yourself)

regal scaffold
#

How can I make a optional, default parameter for a function

smoky oak
sinful kiln
quaint mantle
regal scaffold
#

For example:

public ItemStack getButton(final String materialOrBase64, final String name, @Nullable final List<String> lore) {}

I want to have

public ItemStack getButton(final String materialOrBase64, final String name, @Nullable final List<String> lore, OPTIONAL BOOLEAN DEFAULT TO FALSE) {}
quaint mantle
sinful kiln
smoky oak
#

the only blob method in preparedstatement is setBlob

regal scaffold
smoky oak
#

the one that says 'not supported'

quaint mantle
sinful kiln
regal scaffold
#

2 lines aren't but the other 20 are

#

It's just like a flag to add an enchantment or not

#

That's it

tardy delta
quaint mantle
regal scaffold
#

Maybe one day

sinful kiln
regal scaffold
#

Oh I was thinking about it the oposite way so it was wrong

#

Gotcha

#

Thanks

kind hatch
regal scaffold
#

Yes, I didn't wrap my head around it correctly even tho it was basic

#

Got it now

quaint mantle
regal scaffold
#

I've even seen people do it exactly this way

#

idk I just got a brain melt

smoky oak
#

so what i want to know now is why BLOB allows bytes to be set lol

#

it just looks like it shouldnt work

kind hatch
sinful kiln
kind hatch
#

It's just not as common to see it done that way.

regal scaffold
#

yeah fair

smoky oak
#

declaring one data type and stuffing in another

sinful kiln
#

Not really

tardy delta
#

what are you doing this whole day for me with your blobs now?

sinful kiln
#

There is no byte array or bytes type in SQL if I remember correctly

regal scaffold
#

Can I not enchant items that are not supposed to be enchanted?

sinful kiln
#

There’s only Binary and Blob

regal scaffold
#

For example, heads?

tardy delta
#

yes

smoky oak
regal scaffold
#
        if (doEnchant) {
            meta.addEnchant(org.bukkit.enchantments.Enchantment.DURABILITY, 1, true);
            meta.addItemFlags(org.bukkit.inventory.ItemFlag.HIDE_ENCHANTS);
        }
real fable
#

Is there a way to make commands (and its tab completer) that take a double quotes argument in ?
e.g.
/myplugin thing create "This is a name" "This is a description"
With the tab completer working a little bit like the /title command when you need to put the <text> value

regal scaffold
#

Does HIDE_ENCHANTS remove the glow?

quaint mantle
smoky oak
quaint mantle
#

I think I remember something about that

smoky oak
#

also is 60ms write to db slow or fast?

regal scaffold
#

Testing rn

sinful kiln
regal scaffold
#

Nah it's not doing it

#

I'm trying to enchant a playerhead

sinful kiln
tardy delta
#

reflection my beloved

quaint mantle
ivory sleet
#

Brig >>>

sinful kiln
#

Isn’t there like a addUnsafeEnchant or something like that?

regal scaffold
#

Nope

ivory sleet
#

There is

regal scaffold
ivory sleet
#

Its on the ItemStack

regal scaffold
#

tf

ivory sleet
#

Not ItemMeta interface

regal scaffold
#

How does that make any sense

quaint mantle
sinful kiln
smoky oak
#

yo wtf
where my error at

quaint mantle
ivory sleet
#

But at any rate, if you just want glow, and have nms on ur side, just inject an empty compound into ur stack for the enchantments key :>

sinful kiln
smoky oak
sinful kiln
#

Nope

regal scaffold
#

Lovely lmao

#

Ok nms it is

#

Hopefully it's not that hard

sinful kiln
#

xD

#

Try Infinity

#

Maybe that one works

dry yacht
#

@frail gale

Ugh, that was quite the journey through some old code. I've now created a little playground project which just animates the name on the item you're holding in your main hand: https://github.com/BlvckBytes/AnimatedItemPlayground

I hope you can extract what you need from this. It shows you how to calculate gradients and how to apply components to items. If you already have a component system which can convert itself to json, you can use that too, of course. I don't know if I'd use my old components even myself, xD.

Go to AnimatedItemTest.java and then just traverse from there.

smoky oak
#

so i did have an error

#

console just decided to not show it until i started typing in it

#

wtf

regal scaffold
#

Now to figure out how to do enchantment glow using jefflib

dry yacht
sinful kiln
regal scaffold
#

I'm using the lib already

#

For a lot of other stuffs

dry yacht
#

Alrighty, I see

regal scaffold
#

Actually using a combination of my lib and jefflib

smoky oak
regal scaffold
#

But he has nms support as well so

frail gale
dry yacht
ivory sleet
dry yacht
smoky oak
#

well

#

spigot is debatably one

frail gale
regal scaffold
#

Big library

#

Don't use

dry yacht
regal scaffold
#

Make an entire plugin using nms

ivory sleet
#

Most libs don’t provide any guarantee hence not a big fan of it

#

For instance how many libs do u see with intergration, or well unit tests

smoky oak
#

whats integration

ivory sleet
#

Integration tests

smoky oak
#

(i know what unit tests are but idc, i test in prod)

dry yacht
# frail gale One thing I don't understand is AnimationState class

It's the animation state used per player, which stores the gradient information as well as a boolean whether the center point that's shifted currently moves forwards or backwards. It's basically a little state machine that shifts this point left to right and right to left forever, xD.

regal scaffold
#

Is this best site for nms?

smoky oak
#

no

#

good luck

regal scaffold
#

Or any other suggestions

dry yacht
frail gale
ivory sleet
#

Well, I don’t think the quantity of tests is important unless you’re religiously committed to tdd, but def the quality and what your tests validate.

dry yacht
ivory sleet
#

So prob one of the better libs out there

#

:>

smoky oak
#

arent gradients hard coded to always have a minimal size of 4³?

worldly ingot
ivory sleet
#

🥲

dry yacht
smoky oak
regal scaffold
worldly ingot
#

TDD makes me want to commit self-die

smoky oak
#

whats that short for?

worldly ingot
#

but writing tests is a must if you can

#

Test-Driven Development

ivory sleet
#

Test driven development

worldly ingot
#

Basically write tests before you write any code, then write the code that makes it compile

smoky oak
#

i mean

ivory sleet
#

It is a standard almost in most companies to ensure quality code

frail gale
smoky oak
#

90% of my code is spigot stuff u can only see on the server

#

good luck writing tests for that

dry yacht
#

TDD is only good for strictly defined algorithms. If you're trying to figure out the best way to implement/architect something, it's for the birds.

ivory sleet
#

I myself plead to use design driven development or behavior driven development if companies allow that

dry yacht
smoky oak
#

most of us just write the code to barely work dont we

dry yacht
regal scaffold
#

How can I add the enchantment glow to an item using nms

smoky oak
dry yacht
vivid hill
#

Is there a event that checks when you like hold right click on a bow?

smoky oak
regal scaffold
#

I don't want to do that

#

I don't want to enchant with useless and hide it

smoky oak
#

kiss mate

regal scaffold
#

I want to do it using nms

dry yacht
#

You know that that's the only way, right?

regal scaffold
#

It can't be

dry yacht
#

What do you think NMS does? it also adds this to the NBT data, I bet

smoky oak
#

actually nms would do it

dry yacht
#

There's no "glow funnily" flag

regal scaffold
#

nms does do it

smoky oak
#

but you could use protocollib to fake it

ivory sleet
smoky oak
#

by doing what i suggested but to just pretend its enchanted

regal scaffold
#

I can't give enchantments to a player_head so nms is the best way

regal scaffold
kind hatch
#

Well yea, heads are incompatible with the enchantment glint.

regal scaffold
#

So nms with plib best solution?

#

Final answer?

worldly ingot
#

You can give enchantments to player heads but the glint will not display. That's a client limitation

#

Regardless of whether or not you use NMS, it will not make a difference. Bukkit interfaces with NMS

regal scaffold
#

I want the glow not the enchantment

smoky oak
#

client limits are dumb in a few ways

worldly ingot
#

the glint will not display. That's a client limitation

smoky oak
#

for example custom keys or right clicking air

#

or culling

dry yacht
# ivory sleet Sounds interesting, system test or just integration tests?

Don't know the exact terminology. System tests, probably. I'm thinking about the following: Compile a server jar for each available version, set up a firecracker VM with the right java version installed, boot up the vanilla server, take a snapshot of each to later be able to rapidly spawn up "warm" instances. Then, write a plugin that loops all loaded plugins and calls their testing interfaces and writes the report into a test-file. There could be some sort of orchestration software on top of that, which even lets fake players join and analyzes packets and the like. No idea how I'm going to pull all of that off, as I'm actually literally drowning in other projects to finish at the moment. But I think you get the idea. Since my reflection library disables the plugin if it didn't work and exactly describes the errors, I could rapidly implement massive version support this way. Ugh, wall of text.

smoky oak
#

gods culling

regal scaffold
#

What is glint am I dumb?

kind hatch
#

It's the glow you are referring to

regal scaffold
#

Is that the glow?

charred blaze
regal scaffold
#

Oh

#

So there's no real way to display glow on a player_head

#

Not even with protocollib

worldly ingot
#

You cannot give a glint without an enchantment. The client has a isFoil() method (or something similarly named) that determines whether or not an item has an enchantment glint. By default it returns true if the enchantment tag is not empty. The only items that override that are the ones that are glinted by default (like golden apples)

ivory sleet
kind hatch
#

Nope

ivory sleet
#

Or well, maybe acceptance tests

smoky oak
#

the head glint i mean

worldly ingot
#

The client just can't render it

#

Nothing you can do about that

smoky oak
#

actually you can

#

but it requires a stupid amount of bandwitdh

regal scaffold
#

Wait

#

So

smoky oak
#

you could fake the glint by continuously changing the skin to reflect the enchantment glint going over it

regal scaffold
#

If I can't put an enchantment on a player_head normally, using nms would allow me to force an enchantment on it

#

No?

#

Therefore it would actually display the glow

worldly ingot
#

I don't know why you're not understanding this

smoky oak
dry yacht
# dry yacht ...

As if you could create all of those permutations for each displayable skin within reason

smoky oak
#

you dont need to

vivid hill
#

shouldnt u use the getIteminHand methode?

regal scaffold
frail gale
#

@dry yacht It seems for me that making animated gradients is really hard

regal scaffold
#

But I guess there is none

worldly ingot
#

There is no workaround. You can't workaround the client when you're working on the server

smoky oak
#

you can just cycle through the glint and keep the skin in memory, then add the current glint rgb values to the skin values

worldly ingot
#

If you want to work around this, you're going to be writing a client mod with Fabric or Forge

smoky oak
#

and thats what you send as the displaying skin

dry yacht
smoky oak
#

the problem is idk if you can tell the client to update skins

dry yacht
dry yacht
frail gale
#

is it valid?

worldly ingot
#

NMS isn't black magic that can do things that Bukkit can't. Bukkit calls upon NMS. It exists so that you don't have to do it and be version-dependent

smoky oak
dry yacht
smoky oak
#

thats about it

smoky oak
#

wdym

dry yacht
#

You can, using some sort of API that uploads your pixel data to their account to invoke a new skin generation on mojangs API, but that's about it

smoky oak
#

ive seen binary data strings getting converted to skins

dry yacht
#

You don't send pixel data, you send skin sprite URLs

crimson mulch
frail gale
smoky oak
worldly ingot
#

I mean it's true. The people that continue to make scoreboards using packets are just stupid. Bukkit has API for all of it

vivid hill
#

if(e.getItem() == Material.ENDER_PEARL) {} whats wrong here?

dry yacht
dry yacht
smoky oak
# dry yacht I *really* don't think so. Do you have an example of this

/summon minecraft:armor_stand ~ ~1 ~ {ShowArms:1,NoBasePlate:1,ArmorItems:[{id:leather_boots,Count:1b},{id:leather_leggings,Count:1b},{id:leather_chestplate,Count:1b},{id:skull,Damage:3,Count:1b,tag:{SkullOwner:{Id:"b821f12f-8e14-44bb-9015-0df0a6055288",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjc4ZTM5ZTNhYTE0ZGFiNzdlYTNiNTFmMGE3MmZiMGNhNTU1ZDdlYjE2ZGM1OTJmNzBmYTEwYzQzMDI5ZDczNCJ9fX0="}]}}}}]}

frail gale
smoky oak
#

head skin is B64 encoded string

worldly ingot
#

e.getItem().getType()

smoky oak
#

so it stands to reason you can unpack and manipulate the texture to repack it as a 'glint skin'

worldly ingot
#

I don't know what event you're using but check to see if you have to make a nullability check on getItem() as well

dry yacht
kind hatch
lost matrix
vivid hill
dry yacht
#

If it would actually be binary image data, the world would be a different place, xD.

smoky oak
#

huh thats interesting

#

still

lost matrix
#

But with something like MineSkin you can upload and use whatever texture you like

smoky oak
#

couldnt you generate the skins and do the api calls to then display them?

dry yacht
#

You could upload all glint permutations of a skin to some API, but dude... that's gonna explode in the amount skins you'll have to upload real quick. Those APIs are rate limited, for good reason.

#

I totally get the idea tho, haha :,D

smoky oak
#

well i provide solutions

#

i never said they were good ones

kind hatch
#

Wouldn't you have better luck with a resource pack?

worldly ingot
#

Still waiting on Mojang to add a Glint NBT tag

tardy delta
#

still waiting for mojang to clean up their mess

smoky oak
#

HAH

#

mojang is owned by microsoft onw

#

that hope died with the 3Bn sale

regal scaffold
#
    private void addGlow(org.bukkit.inventory.ItemStack stack) {
        ItemStack nmsStack = (ItemStack) getField(stack, "handle");
        NBTTagCompound compound = nmsStack.tag;
        
        // Initialize the compound if we need to
        if (compound == null) {
            compound = new NBTTagCompound();
            nmsStack.tag = compound;
        }
        
        // Empty enchanting compound
        compound.set("ench", new NBTTagList());
    }

What's the up to date version of NBTTagCompound

#

Is that NamespaceKey?

worldly ingot
#

TagCompound

#

But again... just add an enchantment...

#

You can do that with the Bukkit API and you're doing the exact same thing

regal scaffold
#

I know I know

#

I want nms practice

dry yacht
#

You're still not convinced? :(

regal scaffold
#

It's not for production

#

I am, you both know a lot lot more

#

But nothing wrong in practicing it

dry yacht
charred blaze
dry yacht
regal scaffold
#

jesus it's confusing, not that part just overall

regal scaffold
#

i'm pretty sure I'm using this wrong

dry yacht
#

Sorry, can't help with that, I have a big phobia of foreign reflection libraries, xD.

ivory sleet
#

Wait why reflection?

regal scaffold
#

Yeah I just noticed that was wrong

#

1 sec

vast raven
#

How to make a fern grow in 1.12.2? Keep in note that growed fern is a double plant and not a long grass type

regal scaffold
#
        PDCUtils.set(item, Enchantment.ARROW_DAMAGE.getKey(), DataType.INTEGER, 1);
    }
#

Pretty sure that would work but obviously since the item is a player_head it won't show

#

Wasn't as bad as I thought

worldly ingot
#

That won't work. That makes use of the PDC which isn't on the root tag

regal scaffold
#

Oh

eternal oxide
#

Question, what class does Particle::getDataType return when the Particle requires no data?

worldly ingot
#

Void.class iirc

eternal oxide
#

ok thanks

worldly ingot
#

Yeah, it's Void

eternal oxide
#

k

vast raven
#

There is actually the LongGrass cast, but not in my case 'cause the large fern is a double plant, and I can't find a class tho

rough drift
#

@vast raven you need to set the lower half first, then the top part

rough drift
#

iirc you can use block data

#

Material.FERN or Material.TALL_FERN and see if you can set it's half

#

like a door

vast raven
#

Material.FERN isn't in legacy

#

tho you can set through LongGrass

rough drift
#

oh yeah it probs is a LongGrass

vast raven
#

That's for "FERN", "TALL_FERN" isn't a LongGrass

#

is a double plant

rough drift
#

hm

#

I don't know then

vast raven
#

actually there isn't a class like LongGrass to cast the block state / material data

vast raven
worldly ingot
#

You're looking for Bisected

rough drift
#

choco the savior

worldly ingot
#

It's a BlockData

#

Set the bottom half, then set the top half. Don't set them with physics though

vast raven
worldly ingot
#

Bisected

vast raven
#

Did you counted the legacy version in my case?

worldly ingot
#

oh you said 1.12

#

lol, well, you're kind of SOL because the MaterialData API was very much incomplete

#

You'll have to figure out what the byte data for those two blocks are

vast raven
#

The real solution is to find a class where you can cast the block data / state

#

For regular short fern is just LongGrass

opaque trellis
#

so Im getting a message when I try to login to our server saying you're not that awesome to be whitelisted and yet I am whitelisted and we turned whitelist off

vast raven
#

Since we're speaking of long fern, idk then

worldly ingot
#

I don't know if there is an actual MaterialData implementation for that

#

Again, it was incomplete

vast raven
#

I think there isn't then, searching through spigot docs / ide implementation didn't help

#

Setting the Block type to DoublePlant, and then setting the data to 3, spawns a short fern block 💀

regal scaffold
#

Question

#

public Map<String, Integer> items = new HashMap<>();

#

This is how I am serializing a map of Itemname -> amount

#

I was thinking of switching to

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

But I wonder if when I do
items.containsKey(itemstack) the amount of the item will also be included therefore unless it's the exact amount it won't match

#

Correct?

ivory sleet
#

Use Material,Integer maybe?

regal scaffold
#

Should I keep saving as Map<String, Integer> or switch do material,integer

#

Oh, sniped me

#

Is material, integer better than string, integer then?

ivory sleet
#

Yes

regal scaffold
#

Alright, ty

ivory sleet
#

It represents more accurately what you’re trying to do

#

String based design in programming should be avoided, at least regarding scenarios such as these ones

regal scaffold
#

Understood, thanks for detailed explanation

ivory sleet
#

Also, you might wanna use an EnumMap<Material,String>, dunno how far spigot has gotten regarding that pr

regal scaffold
#

What even is an enum map

ivory sleet
#

Its another Map implementation as opposed to HashMap

regal scaffold
#

But it acts like an enum right? values can't change

#

This is a list that needs to change a lot

worldly ingot
#

I'd avoid an EnumMap tbh

#

At this point in time

ivory sleet
#

Ah yeah nvm tomi, listen to choco and zacken

worldly ingot
#

(a) The Material enum is probably way too large for you to even get any benefit over a HashMap (unless you're mapping all entries in an enum for some reason), and (b) there are plans in the future to have Material not be an enum anymore

#

I actually used a HashSet internally in Bukkit recently lol

#

For both of those reasons

rough drift
#

It's within the standard java lib

#

oh wait nvm

#

I am a dumbass

regal scaffold
#

How can I force an inventory to be closed?

rough drift
#

player.closeInventory()

regal scaffold
#

Why was I overcomplicating this we will never know. thanks voodoo

rough drift
#

using a record or a class

#

Are you getting a value from JSONObjects

#

or whatever they are in gson

#

oh, I understand lmao

undone axleBOT
rough drift
#

then nah it's the best way

#

you can use a more optimized lib

regal scaffold
#

When working with Custom PDCs, if I make a change to the data inside the class that's being serialized, do I need to resave it?

rough drift
#

iirc yes

regal scaffold
#

Is that memory intensive?

#

Should I use a cache?

rough drift
#

wdym

#

depends

#

it can also be on an entity or itemstack

regal scaffold
#

I need to update a lot of the data that's being stored, constantly

rough drift
#

why do you need to do that

regal scaffold
#

Will saving the pdc every time I make the change screw up performance wise

#

Because my pdc has item storage data

rough drift
#

not that slow actually

regal scaffold
#

Maybe I have a cache and save the data into the pdc every minute or 5 minutes

rough drift
#

explain your use case

regal scaffold
#

The class i'm saving as a PDC contains
public Map<Material, Integer> items = new HashMap<>();

Among a lot of other properties

rough drift
#

why are you doing that

regal scaffold
#

Because it's a storage device

#

No, we already talked enummap

hasty prawn
#

If all you need is to convert a JSON string and start pulling from it

String json = "{identifier: 5}";
JsonElement element = JsonParser.parseString(json);
        
//prints "5"
System.out.println(element.getAsJsonObject().get("identifier"));
regal scaffold
#

They said not for now

rough drift
#

why not?

regal scaffold
#

Read above

rough drift
#

^

rough drift
regal scaffold
#

Allright fair

rough drift
#

forgot it loads everything

regal scaffold
#

But still

regal scaffold
#

I want to edit constantly stuff in there

#

Maybe I have a cache and save the data into the pdc every minute or 5 minutes

rough drift
#

Anyways, you should edit in there, and save every time it is closed or the server is shutting down

#

save only if it didn't change

#

so have like a dirty boolean

regal scaffold
#

It's a list of materials and the amount

#

But still, it's about PDC and serialization

rough drift
#

it's much more effective to have a global flag for the entire container

#

that way you avoid any saving if the container didn't change

regal scaffold
#

Is there a global server PDC?

rough drift
regal scaffold
#

Like if I want to save a list of something

rough drift
regal scaffold
#

To load when it starts

#

So I guess file?

rough drift
#

Why do you need a file

hasty prawn
regal scaffold
#

Well, I want to store the location of each item which has this custom PDC and when the server loads, I want to add them all to a list

hasty prawn
#

Why not just add them when the chunk that they're in loads

regal scaffold
#

Oh yes that works

#

I actually have a chunkpdc data already set

#

How do I even do that part tho

hasty prawn
#

ChunkLoadEvent I think is a thing

regal scaffold
#

❤️

#

I like that idea a lot I completely forgot

#

It's perfect

#

Except

#

Offline mode

hasty prawn
#

And I think it should let you get TileEntities and maybe entities? PeepoShrug

#

I rarely use that event so I don't remember exactly but you should be able to get what you need

#

?paste it

undone axleBOT
worldly ingot
#

This seems mildly over-engineered

#

You're deserializing that JSON string twice

regal scaffold
#

How can I get a specific block (placed chest) from ChunkLoadEvent() if I have the exact location value of the block

charred blaze
regal scaffold
#

I am idiot

#

chunk#getBlock()

#

Is a thing

charred blaze
#

can anyone look in my thread please

worldly ingot
#

You're deserializing to get the identifier, then deserializing again using that identifier as the type to deserialize it as

#

I don't really know why that identifier is there to begin with though

#

Why? What else do you expect it to be?

#
{
    "x": 0,
    "y": 0,
    "z": 0,
    "pitch": 0.0,
    "yaw": 0.0
}```
#

That should be the extent of your position

#

You should know what the type is. You're the one serializing it to begin with

#

Well I still think your structure is a bit backwards. Deserializing twice is kind of a no-go. imho I think adjusting your design to where you can have something along the lines of this is better:

{
    "id": "location",
    "data": {
        "x": 0,
        "y": 0,
        "z": 0,
        "pitch": 0.0,
        "yaw": 0.0
    }
}```
#

Then you can deserialize it once, get the id, then pass the data as a JsonObject to some registered deserializer

#

They're cringe

charred blaze
#

can anyone tell me whats wrong with my code? after i quit the server my opponent still cant use commands

sterile token
regal scaffold
#
        Chest chest = (Chest) event.getChunk().getBlock(location.getChunk().getX(), location.getBlockY(), location.getBlockZ()).getState();
#

So, #getBlock requires a number between 1-15 for coordinates, which makes sense cause it's the individual chunk

regal scaffold
#

If I have my location stored as an entire location tho

Would I use location.getChunk().getX() or is there a better way

#

Cause location.getX() returns the entire world location

sterile token
charred blaze
sterile token
#

You cannot abuse over it

#

But what are you doing Tomy?

tardy delta
#

then he says my code is ugly 🙄

regal scaffold
#

It's not a lot of blocks

#

It's just 1 block per chunk. and 1/20 chunks have it

ivory sleet
#

That’s debatable

fluid river
#

))

regal scaffold
#

How can i get a block from a Location on ChunkLoadEvent

fluid river
#

?jd-s

undone axleBOT
regal scaffold
#

Doesn't help which is why I'm asking

#

#getBlock requires a number between 1-15 for coordinates, which makes sense cause it's the individual chunk

#

If I pass it location.getX() it'll be for the world not for the chunk therefore IllegalArgumentException

eternal night
#

I mean % 16

fluid river
regal scaffold
# fluid river

#getBlock requires a number between 1-15 for coordinates, which makes sense cause it's the individual chunk

topaz moon
# charred blaze its very easy to tell me reason

in the past what? 3 hours? Have you tried solving it on your own? It's not that much code. Also you asked in your thread why your opponent can't use commands when you're offline. Isn't that supposed to happen?

regal scaffold
#

Between 0-15 sorry

regal scaffold
#

location.getX() it'll be for the world not for the chunk therefore IllegalArgumentException

eternal night
fluid river
#

i don't get what's the problem

regal scaffold
#

Huh?

fluid river
#

idk maybe my eng is bad but

regal scaffold
#

I'm trying to get a block at a specific Location location which was already saved

#

If I do location.getX() it returns the full world location

eternal night
regal scaffold
#

Meaning #getBlock will throw an exception cause it doesn't work

fluid river
#

Chunk.getX() * 16 + block x in chunk
Chunk.getZ() * 16 + block z in chunk
y

regal scaffold
eternal night
#

mod 16

ivory sleet
eternal night
#

% 16

regal scaffold
#

Yeah Im not gonna lie I had a autismo moment apologies

regal scaffold
#

Uh I assume I need to do absolute values

fluid river
#

idk

#

you can store chunkX + chunkZ

#
  • relative block xz in a chunk
#

and absolute y of block

lost matrix
#

You need one long for the chunk coord and one int for the relative block coord. So 96 bits in total.

regal scaffold
#

jesus

#

Anyone have an example of a data cache implementation

tardy delta
#

heehee java @SuppressWarnings("unchecked") private <T extends AutoCloseable & Iterable<E>, E, EX extends Exception> void loopAutoClosable(T autoClosable, ThrowingConsumer<E, EX> consumer) throws EX { try (autoClosable) { for (E item : autoClosable) { consumer.accept(item); } } catch (Exception e) { throw (EX) e; } }

#

kinda neat

ivory sleet
#

Caffeine

regal scaffold
#

That is massive

#

Alright brb lol

ivory sleet
#

Not that massive

#

I can lead you through the basics

regal scaffold
#

That would be very nice

ivory sleet
#

Whilst its certainly true one can take advantage of guava’s caches, that cache impl is not nearly as up-to-date and well designed as caffeine

regal scaffold
#

Well, I'm just trying to avoid doing bad memory stuff

ivory sleet
#

Anyway, assuming you do end up using Caffeine, what type of caching are you going for?

regal scaffold
#

Like setting a PDC every single time an action is done

#

I think i want to make my own even tho it won't be as well optimized as that

ivory sleet
#

An expiring cache?

regal scaffold
#

So here's the thing

eternal night
#

*how often are you mutating the PDC for there to be a need for a cache eyes_zoom *

languid tartan
#
        protocolManager.addPacketListener(new PacketAdapter(
                this,
                ListenerPriority.NORMAL,
                PacketType.Play.Server.ENTITY_EQUIPMENT
        ) {
            @Override
            public void onPacketSending(PacketEvent event) {
                PacketContainer packet = event.getPacket().deepClone();
                ItemStack stack = packet.getItemModifier().read(0);

                ItemMeta meta = stack.getItemMeta();
                ((Damageable) meta).setDamage(0);
                stack.setItemMeta(meta);
                packet.getItemModifier().write(0, stack);
                event.setPacket(packet);
            }
        });
    }

I'm trying to hide durability of items by modifying packets using ProtocolLib, but it doesn't work.

regal scaffold
#

Not at all just yet didn't get to implement that just yet

#

But I don't want to get to that point

#

But hear me out

ivory sleet
#

Yeah lynx question isn’t totally impertinent

languid tartan
#

I see

regal scaffold
#

I use PDC as my storage, meaning all the data for a specific class is saved in the block data itself.

I need to constantly access that data. read/write a lot, therefore I don't want to have to save it to the PDC every single time to then be able to read the updated version of it from other places.

So I was thinking on making a local storage system in the plugin. And only save the data to the PDC once every 5 minutes or once every restart

#

This is the class that is the core of the plugin

#

?paste

undone axleBOT
regal scaffold
lost matrix
#

When block loads -> put in map
When block unloads -> save back into PDC

regal scaffold
#

Yes

#

Exactly

#

So, I'm making a cache