#help-development

1 messages ยท Page 24 of 1

rough drift
#

IeffLib

#

ohk

tender shard
#

I just checked it

simple silo
#

in onEnable you usually setup things like registering commands and listeners

rough drift
#

@rain mason read this btw

#

it tells you all the methods you can use

rain mason
rough drift
#

if you want to run it async you can use acceptAsync iirc

rough drift
#

nvm

tender shard
#

onLoad() basically gets called after your plugin instance was created

charred blaze
#

two of my players reported that they are lagging on join. screen prints loading terrain and lags...

tender shard
#

so yeah, ofc it runs after /reload

gray merlin
#

I... I really don't know how one would enable or disable a plugin...

charred blaze
gray merlin
#

I thought you just got the .jar, put it in /plugins and that's that.

tender shard
charred blaze
rain mason
#

wait just a qucik question, why is intellij complaining?

rough drift
#

so like

#

CompletableFuture<YourType>

gray merlin
tender shard
tardy delta
#

the server does that, you dont have to care bout that

rough drift
tender shard
gray merlin
#

Alright then, thank you.

quaint mantle
rough drift
gray merlin
rough drift
rain mason
rough drift
simple silo
#

any ideas?

rough drift
#

you can't do the same to enable

rough drift
tender shard
gray merlin
rough drift
#

but you can't enable it back

rain mason
rough drift
#

onEnable and onLoad

tender shard
willow widget
#

anyone knows how to get the villager involved in a TradeSelectEvent event?

subtle folio
#

csnt register commands and listeners in onload ๐Ÿ˜ญ

gray merlin
tender shard
echo granite
#

when onLoad is used over onEnable?

subtle folio
rough drift
echo granite
tender shard
#

if you ever need onLoad(), that's a very rare thing

#

I got like 20 plugins on spigotMC and none of those requires the onLoad method

gray merlin
rough drift
#

IG it's cleaner

gray merlin
#

Because it would also make sense to do that during "loading" semantically.

tender shard
#

you really only need onLoad if you need some custom class loading things or similar

gray merlin
#

I see.

#

Thanks!

tender shard
#

np

#

just put everything you have in onLoad at the "start" of your current onEnable method

#

then you are totally fine

#

it basically works like this

  1. CraftBukkit does new YourPlugin(...)
  2. CraftBukkit calls your onLoad()
  3. CraftBukkit calls your onEnable()
#

and on reaload. it does the same thing

gray merlin
#

Yep, I understood that. Oh, I will also have to apologise for the frequent questioning, I'm just starting out on plugin-making, and it's a huge relief from Forge, so I'm kind of excited, lol.

severe turret
#

oh yeah alex

gray merlin
severe turret
#

Should I use a BukkitRunnable in runTaskAsync or a normal runnable

severe turret
#

it tells me runTaskAsync with BukkitRunnable is deprecated

#

ty

tender shard
#

you can of course also use a Consumer<BukkitTask>

tardy delta
#

Runnable

severe turret
#

does that work just like Runnable

#

or some special stuff required

tardy delta
#

works

#

() -> yourstuff

tender shard
#

so, either use a Runnable, or a Consumer<BukkitTask>

tardy delta
#

im wondering, isnt a return required to stop at that moment?

tender shard
#

but never use a BukkitRunnable i nthe scheduler

severe turret
#

oki

tardy delta
#

@urban grotto kekw

tender shard
tardy delta
#

smh

severe turret
#

oh yeah

#

if I have an event cancel

#

should I also return?

#

like

tender shard
#

depends

severe turret
#

if theres code after the event cancel as well

earnest forum
#

if u have further lines of code then no

tender shard
severe turret
#

aight

tender shard
#

this for example would quit running the whole thing when someone "is doing weird things". If they don'T, it says "it's fine"

gleaming grove
#

is there any efficient and quick way to load yml file to Map<String,String>() like ('gui.base.insert','a'), ('gui.base.remove','b')....

severe turret
tender shard
#

you'll have to parse the ConfigurationSection yourself if you want to get it as Map<String, String>

severe turret
#

can you not use ConfigurationSection().getKeys() for that?

gleaming grove
#

I've make research on YAML library itself but It only case content of yaml file to objects

tender shard
gleaming grove
#

ok then I going to read file by myself

tender shard
#

whut

#

you dont have to do that

#

pls explain what you are trying to achieve

gleaming grove
#

the Map keys are all pathes in yaml file

#

full paths

gray merlin
#

Is there a way to get a player's playerdata? I saw that player.saveAll returns void, so yeah.

chrome beacon
#

What do you need to do with it?

gray merlin
#

moving the playerdata file around in directories.

tardy delta
#

lmao

gray merlin
#

No, no, that's incorrect.

#

Moving a player's data around through worlds.

#

It would be easier to just use the entire playerdata

chrome beacon
#

Why do you need to do that?

gray merlin
#

It's the culmination of a very, very outdated version in a server I play with, alongside a giant amount of stuff that goes on there. It would take loads of time to explain the entire context, lol. I just need to have the player in different states across worlds.

gleaming grove
#

could't you just get the playerdata folder and copy 'data' for selected player to another folder?

chrome beacon
#

If you just have multiple worlds loaded in spigot you don't need to move the data around yourself

gray merlin
gray merlin
chrome beacon
#

oh so an unsupported version

#

Yeah just copy the file around

gray merlin
#

I can use saveAll to force the playerdata to be saved, right?

chrome beacon
#

Yeah

gray merlin
#

Alright, thank you.

rain mason
chrome beacon
#

No idea if that works with modded data

#

I wouldn't expect it to

gleaming grove
#

but does copying files would be safe?

#

i mean playerdata might constains some world properies

chrome beacon
#

It contains the location

#

Other than that it's fine

#

Can't say the same for modded data

gray merlin
rain mason
#

@rough drift i'm guessing something like this? i'm gonna test it rq, but i just wanna check with you just to be sure ```java
pl.closeInventory();
pl.sendMessage(String.format(plugin.makeMessage("messages.clanstuff.messages.prompt-string"), clanstuff[1]));

            CompletableFuture<String> futr = new CompletableFuture<String>();
            waitForChat.put(pl.getUniqueId(), futr);
            try {
                String yippee = futr.get();
                clann.set("settings."+clanstuff[1], futr);
                waitForChat.remove(pl.getUniqueId());
            } catch (InterruptedException|ExecutionException ignored) {}```
rough drift
#

it will block the whole thread

#

so make sure to use a separate thread

tardy delta
#

new CompletableFuture<>().get() ๐Ÿค”

visual tide
#

the other way would have been gitignoring .gitignore

tardy delta
#

anyways does this make sense?

class ChatChannel {
  Set<User> joinedPlayers;
}

class User {
  ChatChannel joinedChannel;
}```
gleaming grove
#

instead of Set<User> consider map<UUID,User> to make it faster

severe turret
#

User is probably his object that contains all that no?

rain mason
severe turret
#

from what I've heard

#

you should never really use Thread

#

instead use Runnables

willow widget
#

Anyone knows how to get the villager involved in a TradeSelectEvent?

severe turret
#

new Runnable() = () -> {};

gleaming grove
#

but thread is runnable

severe turret
#

yes

#

but less typing

#

and there's other things why you shouldnt really explicitly use Thread

rain mason
gleaming grove
severe turret
#

yes

#

Runnable is interface of Thread

severe turret
#

maybe something like this

#

idk if its wrong

proper notch
#

From what I can tell, your approach should be different although I'm not 100% sure what you're trying to accomplish.

Instead of creating a new thread for every time you want to wait for someone to chat, you should instead just track the state of a user (are we waiting for them to type it in chat, in a map) then listen for chat events.

cunning canopy
#

what directory is plugins run from?

chrome beacon
#

plugins

gray merlin
#

What is it called when a player is riding something? I know that the something has the player as the passenger, but what's the other way around?

#

Alternatively, how do I get the entity a player is riding?

gleaming grove
#

you can get entitis from specific location and check if one of then has player as passager

#

var entities = loc.getWorld().getNearbyEntities(player.getLocation(), 3, 3, 3);

tardy delta
#

var ๐Ÿคฎ

gleaming grove
#

'var` ๐Ÿ˜„

#

3, 3, 3 this parameters means how huge scanning area is

gray merlin
#

My personal opinion is that var is underrated. In production code, sure, never. But for quick scripting, proof of theory, or similar, it's very much usable.

gray merlin
gleaming grove
#

var is more handy than figuring out that kind of obejct a function returns

tardy delta
#

and you have to figure out what it actually returns all yourself

#

if you need it

cunning canopy
#

why is all the materials deprecated?

gray merlin
chrome beacon
gleaming grove
gray merlin
gleaming grove
#

but I'm working in as C# developer maybe in java people use diffrent approach

gray merlin
gleaming grove
#

like for me it makes sence because in production you have classes like UserManagementAccountService

#

so it is better to write var service = new UserManagementAccountService() then UserManagementAccountService service = new UserManagementAccountService()

tardy delta
#

foreach (var s in list)

#

i did C# too and i didnt really like it

tardy delta
gray merlin
#

I just realised, i've been saying "type safety", but I meant "type inference", in my head it made sense.

#

I'll correct everything lol, but still, I understand your point.

gleaming grove
#

the thing i hate the most in java is that i could not make new instance of generic type

gleaming grove
willow widget
#

I got

java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMerchant cannot be cast to class org.bukkit.entity.Villager (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMerchant and org.bukkit.entity.Villager are in unnamed module of loader 'app')

when doing

    @EventHandler
    public void onTradeSelect(TradeSelectEvent event) {
        // Fuck villager trading lmao
        Villager villager = (Villager) event.getMerchant();
        Player player = (Player) event.getWhoClicked();
        event.setCancelled(true);
        event.getView().close();
        
        villager.setHealth(0);
    }

Any clues why?

hybrid spoke
#

otherwise reflection

gleaming grove
gray merlin
chrome beacon
#

Well you don't really know what constructor that generic type has

cunning canopy
#

does materials have an id in a number value or something?

chrome beacon
#

No

#

Not anymore

cunning canopy
#

why did they remove it?

willow widget
gleaming grove
#

System.out.printLine( event.getMerchant());

#

check the class of your merchant

chrome beacon
cunning canopy
#

oh

carmine nacelle
chrome beacon
#

show code

#

?paste

undone axleBOT
willow widget
carmine nacelle
chrome beacon
#

use isEmpty

carmine nacelle
#

still no

cunning canopy
carmine nacelle
#

this makes no sense ong

willow widget
golden turret
#

do someone know how to use only these decimals on double?

willow widget
#

how could I get the actual villager from the event?

carmine nacelle
#

๐Ÿ’€

chrome beacon
cunning canopy
#

hmm

#

the thing is

#

im making my own file format

#

for saving builds

opal juniper
#

use the material name

cunning canopy
#

and I want to use numbers

#

for the blocks

opal juniper
#

idk - seems inefficient

chrome beacon
#

Map material name to an id in the file format

#

or you know use the existing nbt format that already does this

#

or schematic for that matter

cunning canopy
#

is it possible to get a material by its name?

chrome beacon
#

Yes

#

matchMaterial

cunning canopy
willow widget
#

anyone knows how to get the villager involved in a trading? ๐Ÿ˜ฆ

chrome beacon
cunning canopy
#

how else?

chrome beacon
#

an array could work

cunning canopy
#

maybe a list with indexes

#

which would be more efficient?

#

array would maybe take less memory

#

but other then that?

rain mason
#

okay uhh it almost works

chrome beacon
#

Did you forget to get()

visual tide
rain mason
rain mason
visual tide
#

you set futr

#

not yipee

rain mason
#

oh

#

thanks

#

wouldnt have noticed

visual tide
#

also please
your variable names

rain mason
#

all my variable names are either weirdly shortened class names, something related to what im currently watching on youtube, just "lmao", "lol", "xddddd" etc

chrome beacon
#

You will regret that later

loud haven
#

I thought my variable names were terrible, but yikes that's worse

visual tide
#

since you are using intelliJ i would like to introduce you to: right click on the variable -> refactor -> rename

#

jetbrains ides have excellent refactoring tools ๐Ÿ™‚

rain mason
rain mason
willow widget
#

if I have an inventory event how can I get the entity from there?

visual tide
#

its just gonna bite you in the bum when you have bigger projects or are working with others on a single project

rain mason
#

but I mostly just code alone because I hate when people go through my code

echo basalt
#

yeah it sounds like you're doing something very wrong

#

and then shamed of it so hard that you don't want other people to see

#

just code like any decent human being

rain mason
echo basalt
#

instead of naming it "yipee" and not knowing what it means 5 years later

rain mason
echo basalt
#

it also makes it harder to build a public portfolio to apply for jobs

old cloud
#

If I have a class A and a Supplier s = A::new, why is Java going to load A even if I never get the value from the Supplier?

old cloud
#

It does

echo basalt
#

it only loads whenever you call get

old cloud
#

No, I get NoClassDefFoundError

echo basalt
#

I mean

#

if A doesn't exist

#

you're referencing A's existence when initializing the supplier

#

which loads static values and all

old cloud
#

The NoClassDefFoundError is caused by some import of something that is imported in A

echo basalt
#

๐Ÿค”

tender robin
#

is 1.13+ API the same as the newest so if I code my plugin 1.13 it will work on any version above 1.13?

echo basalt
#

Only way to actually fix it, is by initializing the class that inits the supplier of A, only when you can be sure that A actually exists

echo basalt
#

and backwards-compatible

#

it's weird

old cloud
visual tide
tender robin
#

test it on every version above 1.13?

visual tide
#

trying it ๐Ÿ™‚

tender robin
#

lmao

visual tide
#

if it works on both 1.13 and latest its gonna be fine

tender robin
#

ok ty

old cloud
echo basalt
#

thing with reflection is that you're not doing import statements directly

#

which doesn't try to init the class's static methods and all

#

Any reference to any class initializes its static methods

old cloud
#

But why does importing a class initializing its static stuff

#

Even if I wrap that function in another class and just supply that it will throw NoClassDefFoundError

#

And A doesnt even have any static stuff

#

makes no sense

noble lantern
echo basalt
#

I mean

#

that's fine

gray merlin
#

If I serialize an Inventory object into JSON, will it have all of the tags existent in all the items, or is it not possible to serialize an Inventory?

rain mason
river oracle
#

You can't serialize an inventory object itself

rain mason
# river oracle You can't serialize an inventory object itself

yeah, this is how I did it java List<Map<String, Object>> items = new ArrayList<>(); int i = 0; for (ItemStack it : p.getInventory().getContents()) { if (it != null) { Map<String, Object> ser = it.serialize(); ser.put("slot", i); items.add(ser); } i++; } config.set("items", items);

river zealot
#

how do I know at which stage a crop block is being broken?

river oracle
gray merlin
#

I see, I have to serialize each item individually. Thanks.

river zealot
#

Thanks

fervent marsh
#

Heyo, not sure if this is allowed as it's not stated in the rules. I would like to commission a super simple plugin to make it so that users can right click a horse with a stick and have it spit out their statistics in their chat.

If anyone is interested, send me a PM. I imagine this is pretty easy to accomplish! For a vanilla server, just to enhance horse breeding

undone axleBOT
eternal night
#

?services

undone axleBOT
boreal seal
#

Statics ?

eternal night
#

damn I was beaten xD

fervent marsh
#

Site is down

river zealot
#

@river oracle The cating to ageable breaks it somehow

fervent marsh
boreal seal
#

Oh

glossy scroll
#
                            do {
                                do {
                                    do {
                                        do {
                                            if (!var1.hasNext()) {
                                                var0.pop();
                                                this.tickRunningGoals(true);
                                                return;
                                            }

                                            var2 = (WrappedGoal)var1.next();
                                        } while(var2.isRunning());
                                    } while(goalContainsAnyFlags(var2, this.disabledFlags));
                                } while(!goalCanBeReplacedForAllFlags(var2, this.lockedFlags));
                            } while(!var2.canUse());```
#

thats what im coming here for

#

can anyone let me know what this does

#

var1 = this.availableGoals.iterator(); btw

#

i think its filtering...

mint mesa
#

heya. im making a 1.19 plugin for the first time and experimenting with potion effects for the first time too.

Im tryna make a dragon head that when equipped, gives you keep inventory, no fall damage, haste 2 and resistance 3. However, im not exactly sure how to check if the head is equipped or uneqipped

glossy scroll
#

itemStack.isSimilar

mint mesa
#

is there an armorequipevent?

carmine nacelle
#

Still trying to figure out why my empty arraylist is saying its got a size of 1 and isnt empty..

glossy scroll
#

show more than 0 lines of code

carmine nacelle
glossy scroll
#

are you modifying either of these lists between multiple threads?

river zealot
#
@EventHandler
    public void onHarvest(BlockBreakEvent event){
        Block block = event.getBlock();
        BlockData blockdata = block.getBlockData();
        Ageable age = (Ageable) blockdata;
        System.out.println("Block is " + block.getType().toString());
        System.out.println("Is this wheat?"+ block.getType().toString().equals("WHEAT"));
        int blockAge = age.getAge();
        System.out.println("Age " + blockAge);
    }
#

it thows a null eventexception error

lost matrix
carmine nacelle
#

look at the screenshot, the first 2 messages are the values of both lists then I remove both items and its empty as u can see from the last 2 messages

#

but my isEmpty and size==0 return doesnt trigger

river zealot
#

@river oracle am I casting it wrong ?

carmine nacelle
#
        List<String> beeUUIDs = cadiaBees.hivePDCManager.getBeeUUIDS(container);
        List<String> beeNames = cadiaBees.hivePDCManager.getBeeNames(container);

        if(beeUUIDs.isEmpty() || beeNames.isEmpty()) return;
carmine nacelle
#

it is empty but it doesnt think it is.

river zealot
#

1 sec

lost matrix
river zealot
#
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[spigot-api-1.19-R0.1-
glossy scroll
river zealot
#

the first few lines @lost matrix

carmine nacelle
#

It is....

glossy scroll
#

or at least the code you're showing us isnt the code youre executing

lost matrix
carmine nacelle
#

?

river zealot
#

too long it says

lost matrix
#

?paste

undone axleBOT
lost matrix
#

I need the "cause by" line

river zealot
lost matrix
#
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.block.impl.CraftGrass cannot be cast to class org.bukkit.entity.Ageable

Should be clear

#

Grass is not Ageable

river zealot
#

I need to check if it's a crop?

mint mesa
#

I got that jefflib thing @last temple but it doesnt have armorequipevent

#

whats the latest version of it? for me it says 3.3.0

lost matrix
gray merlin
river zealot
lost matrix
mint mesa
#

smh

#

xd

#

ty anyawy

carmine nacelle
#

apparently theres an item in my array thats a blank string..so the size is 1

#

tf

#

There shouldnt be any spaces

#
    public void setBeeNames(PersistentDataContainer container, List<String> beeNames) {
        NamespacedKey hiveStoredBeeNamesKey = new NamespacedKey(cadiaBees, "hive-stored-bee-names");
        container.set(hiveStoredBeeNamesKey, PersistentDataType.STRING, String.join(",", beeNames));
    }
#

this is my method for setting it

#
    public List<String> getBeeNames(PersistentDataContainer container) {
        List<String> beeNames = new ArrayList<>();
        NamespacedKey hiveStoredBeeNamesKey = new NamespacedKey(cadiaBees, "hive-stored-bee-names");

        //Get stored bee names from metadata, separated by !*!
        if(container.has(hiveStoredBeeNamesKey, PersistentDataType.STRING)) {
            String[] storedBeeNames = container.get(hiveStoredBeeNamesKey, PersistentDataType.STRING).split(",");

            for (String storedBeeName : storedBeeNames) {
                beeNames.add(cadiaBees.colorUtil.color(storedBeeName));
            }

            return beeNames;
        }

        return new ArrayList<>();
    }
#

and getting

dry forum
#

if i was making an abstraction class and i need to store smthn like a location for example and the class works like: Class cl = new Class(loc); if i stored it in a private variable wouldnt it get overriden by the next time the class is called? then i dont see how to store data

lost matrix
carmine nacelle
#

I mean I guess

#

it would be null tho

lost matrix
lost matrix
#
    public List<String> getBeeNames(PersistentDataContainer container) {
        List<String> beeNames = new ArrayList<>();
        NamespacedKey hiveStoredBeeNamesKey = new NamespacedKey(cadiaBees, "hive-stored-bee-names");

        if(container.has(hiveStoredBeeNamesKey, PersistentDataType.STRING)) {
            String[] storedBeeNames = container.get(hiveStoredBeeNamesKey, PersistentDataType.STRING).split(",");

            for (String storedBeeName : storedBeeNames) {
                beeNames.add(cadiaBees.colorUtil.color(storedBeeName));
            }
        }

        return beeNames;
    }
dry forum
carmine nacelle
#

ok i changed it

#

but

undone axleBOT
carmine nacelle
#

still not the issue

dry forum
brave sparrow
#

Lol

dry forum
lost matrix
#

Then why are you asking a very basic java question?

brave sparrow
#

^

lost matrix
#

Like really basic

dry forum
#

i havent found any answer only

#

*online

brave sparrow
#

If you knew Java that wouldnโ€™t be a question of yours

dry forum
#

well it is

brave sparrow
#

Hence, you donโ€™t know Java

dry forum
#

i do though thats the thing

brave sparrow
#

You know some Java

lost matrix
dry forum
#

i started java 1 1/4 years ago which id say is decent

brave sparrow
#

Thatโ€™s irrelevant to the topic at hand

#

It doesnโ€™t matter when you started using something

dry forum
#

well you are saying i dont know java

brave sparrow
#

If you donโ€™t understand key principles, you donโ€™t know the language

dry forum
#

ive been using java for those 1 1/4 years

lost matrix
dry forum
brave sparrow
dry forum
lost matrix
#

We cant make any sense of those bits and pieces

brave sparrow
carmine nacelle
#

theres like 20+ classes

#

I shared all the relevant stuff

lost matrix
gray merlin
#

Do item and itemStack exist here?

lost matrix
gray merlin
#

If so, is Item one that is one-of-a-kind, and ItemStack the representation of Item that can exist in the world?

gray merlin
#

The logical implementation of item

lost matrix
#

Both are one-of-a-kind in their own scope...

glossy scroll
#

the actual implementation of ItemStack in Bukkit is a little bit gray because its meddled in a lot of things

#

an ItemStack represents a Material, a Count, and NBT associated with that item

carmine nacelle
#
  List<String> beeNames = cadiaBees.hivePDCManager.getBeeNames(container);
                List<String> beeUUIDs = cadiaBees.hivePDCManager.getBeeUUIDS(container);

                if(beeUUIDs.contains(bee.getUniqueId().toString())) {
                    Player hiveOwner = Bukkit.getPlayer(cadiaBees.hivePDCManager.getHiveOwner(container));
                    if (hiveOwner != null & hiveOwner.isOnline()) {
                        hiveOwner.sendMessage(ChatColor.RED + "One of your bees from the hive " + ChatColor.translateAlternateColorCodes('&', cadiaBees.hivePDCManager.getHiveName(container)) + ChatColor.RED + " has died!");
                        hiveOwner.playSound(hiveOwner.getLocation(), Sound.ENTITY_BEE_DEATH, 1.0f, 1.0f);
                    }

                    beeNames.removeIf(beeName -> beeName.equalsIgnoreCase(bee.getCustomName()));
                    beeUUIDs.removeIf(beeUUID -> beeUUID.equalsIgnoreCase(bee.getUniqueId().toString()));

                    cadiaBees.hivePDCManager.setBeeNames(container, beeNames);
                    cadiaBees.hivePDCManager.setBeeUUIDs(container, beeUUIDs);
        List<String> beeUUIDs = cadiaBees.hivePDCManager.getBeeUUIDS(container);
        List<String> beeNames = cadiaBees.hivePDCManager.getBeeNames(container);

        if(beeUUIDs.get(0).equalsIgnoreCase("") || beeNames.get(0).equalsIgnoreCase("")) return;

Ok so if I check if the first item is "" it works but if I check if the array size is empty or size = 0 it doesnt return

gray merlin
glossy scroll
#

what is getBeeUUIDS

#

show us that

gray merlin
#

and Item I assume is like the placeholder that serves for itemstack to clone off it and have it be used in the normal items?

carmine nacelle
#
    public List<String> getBeeUUIDS(PersistentDataContainer container) {
        List<String> beeUUIDs = new ArrayList<>();
        NamespacedKey hiveStoredBeeUUIDsKey = new NamespacedKey(cadiaBees, "hive-stored-bee-uuids");

        //Get stored bee names from metadata, separated by !*!
        if(container.has(hiveStoredBeeUUIDsKey, PersistentDataType.STRING)) {
            String[] storedBeeUUIDs = container.get(hiveStoredBeeUUIDsKey, PersistentDataType.STRING).split(",");

            for (String storedBeeUUID : storedBeeUUIDs) {
                beeUUIDs.add(storedBeeUUID);
            }

            return beeUUIDs;
        }

        return new ArrayList<>();
    }

    public void setBeeUUIDs(PersistentDataContainer container, List<String> beeUUIDs) {
        NamespacedKey hiveBeeUUIDsKey = new NamespacedKey(cadiaBees, "hive-stored-bee-uuids");
        container.set(hiveBeeUUIDsKey, PersistentDataType.STRING, String.join(",", beeUUIDs));
    }
lost matrix
carmine nacelle
#

?

gray merlin
carmine nacelle
#

why not

glossy scroll
#

& vs &&

#

theyre different

carmine nacelle
#

that part works fine

mint mesa
#

@last temple would iot be something along the lines of

#
    public void onClick(InventoryClickEvent e) {
        Player player = (Player) e.getView().getPlayer();
        if (!(player.getInventory().getHelmet().equals(DragonHead.head))) {
            player.removePotionEffect(PotionEffectType.FAST_DIGGING);
        } else {
            player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 999999, 2));
            player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 9999999, 3);
            
        }
    }```
glossy scroll
#

I would also store UUIDs as an array of longs

#

(LONG_ARRAY)

mint mesa
#

wdym?

carmine nacelle
#

they can have dashes though

glossy scroll
#

a UUID is two longs

lost matrix
# carmine nacelle ?

Use a Set<UUID> instead of a List<String> and then use remove instead of removeIf

mint mesa
#

delay what a few ticks

#

the click event?

lost matrix
carmine nacelle
#

Before I was using remove and it wasnt actually removing from the list for some reason

mint mesa
#

ahh

lost matrix
river zealot
#

Any easy way to double the amount of items dropped from a block break event?

mint mesa
#

yep

mint mesa
#

how do I get thge clicked slot?

lost matrix
mint mesa
#

the*

carmine nacelle
#

Yes

#
                List<String> beeNames = cadiaBees.hivePDCManager.getBeeNames(container);
                List<String> beeUUIDs = cadiaBees.hivePDCManager.getBeeUUIDS(container);

                if(beeUUIDs.contains(bee.getUniqueId().toString())) {
                    Player hiveOwner = Bukkit.getPlayer(cadiaBees.hivePDCManager.getHiveOwner(container));
                    if (hiveOwner != null & hiveOwner.isOnline()) {
                        hiveOwner.sendMessage(ChatColor.RED + "One of your bees from the hive " + ChatColor.translateAlternateColorCodes('&', cadiaBees.hivePDCManager.getHiveName(container)) + ChatColor.RED + " has died!");
                        hiveOwner.playSound(hiveOwner.getLocation(), Sound.ENTITY_BEE_DEATH, 1.0f, 1.0f);
                    }

                    beeNames.remove(bee.getCustomName());
                    beeUUIDs.remove(bee.getUniqueId().toString());

                    Bukkit.broadcastMessage(beeNames.toString());
                    Bukkit.broadcastMessage(beeUUIDs.toString());
#

It removes the uuid but not the name

lost matrix
carmine nacelle
#

it is tho

lost matrix
#

As stated before: We cant make any sense of this convoluted, small piece of code.
Send the whole code.

carmine nacelle
#

ugh.

#

dont really like the idea of giving out my hundreds of hours worth of work but i guess.

tall dragon
#

well i hardly think we want to steal code that does not work

lost matrix
#

^

carmine nacelle
#

hahaha hilarious.

#

a small piece of a badass plugin is still in the works.

gray merlin
#

I have a serialized inventory in JSON (So, just all of the contents of the inventory in a map), and I was making the deserialization method.
I came across this issue though: I can't create a new instance of Inventory and put items into it, can I?

lost matrix
ancient plank
#

fk

gray merlin
#

Thank you, I would've never guessed.

gray merlin
#

So, thank you!

mint mesa
#

if(e.getClickedInventory() == player.getInventory() && e.getSlotType() == InventoryType.SlotType.ARMOR)

hopefully this works

gleaming grove
#

how could I read all files from selected directory from resources?

lost matrix
#

?jd-s

undone axleBOT
gray merlin
#

I wasn't using the javadocs ๐Ÿ˜…

#

But i'll switch to the javadocs if I can find the 1.7.10 version of it

lost matrix
#

Ah yes. Brand new software from half a decade ago

gray merlin
gleaming grove
gray merlin
#

It's been so long since 1.7.10... It's honestly scary.

lost matrix
mint mesa
#

I can have multiple eventhandlers in one file right?

#

I keep forgetting

#

or I've never actually tried it

lost matrix
hybrid spoke
gray merlin
# ancient plank

Honestly the only time I haven't shared my code in order to improve it was when I was under an NDA, lol.

mint mesa
#

ok great

lost matrix
mint mesa
#

so one simple event file

#

B)

gleaming grove
#

but how to get folder from resources?

carmine nacelle
mint mesa
#

oh also guys. one more question

#

can I set keep inventory to true for 1 person?

hybrid spoke
lost matrix
#

?paste

undone axleBOT
mint mesa
#

? spigot web down?

carmine nacelle
#

@lost matrix files in question are gui/HiveGUI and HiveGUIListeners

lost matrix
carmine nacelle
#

oof

carmine nacelle
#

tf

carmine nacelle
lost matrix
carmine nacelle
#

๐Ÿ‘

lost matrix
#

Print out the File and see if its the location you are expecting

#

Are you trying to load the image from inside your plugin?

#

owner can be null

#

That is not a File

gray merlin
#

Yep, I realised it was an unnecessary question and deleted it, apologies.

carmine nacelle
#

Currently testing:

  • Kill a bee (listeners/BeeDamageListener)
  • Open gui (gui/HiveGUI and gui/HiveGUIListeners)
gray merlin
#

Does the inventory slot count start at 1 here, too?

carmine nacelle
#

0

gray merlin
#

Oh, that's nifty, thank you.

lost matrix
# carmine nacelle 0

Sry but im not reading a gui that doesnt use the delegation pattern. All those nested ifs are really obfuscating the code and im too tired for this rn.

#

idk just save the image into your plugin folder and load it from there

carmine nacelle
#

what does that even mean

ivory sleet
#

Generally speaking, huge functions are impolite to the reader

#

Because you need to read the entire function to understand what it does

#

Having small functions that call more detailed functions allows the user to exit early

#

Which is polite

carmine nacelle
#

wasnt originally meant for other people to go through, i know what it all does so i didnt care

ivory sleet
#

Well when you ask for help you basically imply others are gonna read it

carmine nacelle
#

would take hours to rename and change everything

ivory sleet
#

Probably not

carmine nacelle
#

the entire code shouldnt be needed for this tiny issue anyway

ivory sleet
#

Readability issues have bigger impact on productivity than what you may think

carmine nacelle
#

the issue is somehow it thinks the array has a value when it doesnt

ancient plank
#

I'm ngl reading code on mobile rlly is not easy

hybrid spoke
#

just care for your code from the beginning on

carmine nacelle
#

it makes perfect sense to me anyway

#

so i dont get how it could be "simpified" anyway

hybrid spoke
#

looks like it dont otherwise you wouldnt be here

carmine nacelle
#

????

#

lmao

ancient plank
#

Solution: just code 4head

lost matrix
gleaming grove
carmine nacelle
#

how

ancient plank
#

Optimalize

carmine nacelle
#

k so here im checking the entity name

#

and removing it from the list

#

but it doesnt remove it with remove, but it does with a removeIf which makes 0 sense.

lost matrix
#

Btw. Why are you using pdcs like that? Just store everything in your CustomHive when the chunk loads and
write the CustomHive inside the BeeHive when the Chunk unloads.
Create a CustomHivePersistentDataType. This way you only have a single point of failure.

carmine nacelle
#

it was originally all in the customhive then i split it out cause i thought it would be more simple using pdc and i was learning it so it seemd more fun

#

proving to be aids.

#

im trying to store as much as possible in the pdc

lost matrix
#

Well pdc is really nice if you treat it as a persistent storage medium and not like a memory one.

carmine nacelle
#

isnt that the same thing

lost matrix
#

...

arctic moth
#

back again, still have this weird hanging thing that not even thread dump works during

#

anyone have and idea?

#

its during a world generation

lost matrix
#

?workingwithdata

#

?dataworking

subtle folio
#

๐Ÿ˜…

arctic moth
#

its like a hang but with not much cpu/ram usage

lost matrix
#

If i could just remember the commands...

lost matrix
#

Like >95%

carmine nacelle
#

the only thing im storing in files is the location

arctic moth
carmine nacelle
#

and in the object

arctic moth
#

ill send code

carmine nacelle
#

the rest is in the pdc.

arctic moth
#

the world creation is the standard WorldCreator setup with an amplified world

lost matrix
arctic moth
#

my guess is certain biomes arent compatible with amplified

#

oh cave biomes thats probably why

carmine nacelle
#

The only reason im storing in files is so i know where to load the holograms and stuff.

#

on server load.

lost matrix
arctic moth
#

sublist is just to get rid of biome.custom

carmine nacelle
#

Working with PDC has proven to be a pain in the ass.

carmine nacelle
#

might just go back to the object and save/load with gson.

lost matrix
arctic moth
#

it was there before that

#

ill just comment it out ig for now

#

but wait how am i supposed to generate it then

#

the other things use it

carmine nacelle
#

so should i just do away with pdc then..

arctic moth
#

not map

#

i should probably rename that

lost matrix
#

The fk are you doing?

arctic moth
#

trying to make it so each chunk has a random biome

arctic moth
lost matrix
#

Then for now just do this:

public class CorruptedWorldBiomeProvider extends BiomeProvider {
    private final List<Biome> biomes = Arrays.asList(Biomes.values());

    @NotNull
    @Override
    public Biome getBiome(@NotNull WorldInfo worldInfo, int i, int i1, int i2) {
        return biomes.get(ThreadLocalRandom.current().nextInt(biomes.size()));
    }

    @NotNull
    @Override
    public List<Biome> getBiomes(@NotNull WorldInfo worldInfo) {
        return biomes;
    }
}

And see if it works.

lost matrix
#

Thats why i told you to remove the line for now

vast raven
#

Is there a way to change the item you take in the EntityPickUpEvent

#

without touching the inventory

carmine nacelle
#

so...

lost matrix
#

If you want to react on loaded chunks you should listen to the ChunkLoadEvent and check if its a new Chunk.

lost matrix
vast raven
arctic moth
vast raven
lost matrix
carmine nacelle
#

@lost matrix

#

pls

#

i need guidance from the almighty.

vast raven
arctic moth
vast raven
#

I even tried cancelling the event and cancel the cancellation with a delay of 2 ticks but still doesn't work, debugging I saw that the item actually changes, btw doesn't work .

lost matrix
vast raven
vast raven
carmine nacelle
#

ok im switching back to the object and gson only. fuck pdc

lost matrix
vast raven
#

Since for my scope I need to change the actual itemstack you take from the ground.

echo basalt
#

yoo 7smile7 is back

#

ayo @lost matrix I beg you to make a tutorial on armorstand rotations and quaternions

#

I've been looking into it all night and I think I'm dumber now

lost matrix
arctic moth
#

@lost matrix

lost matrix
arctic moth
#

doing biomes.remove(Biome.CUSTOM) errors for some reason

#

thats why i had sublist

lost matrix
vast raven
#

Maybe is the spigot version?

echo basalt
lost matrix
echo basalt
#

so you have roll

vast raven
echo basalt
#

I've been messing with it all night, even made a quick plugin

lost matrix
vast raven
#

btw

#

1.12.2

lost matrix
#

Ah thats not too bad

arctic moth
vast raven
quiet ice
#

But anything below 1.13 is Bad either way

vast raven
#

๐Ÿฅฒ

arctic moth
#

oh saving stuff to file

lost matrix
#

Should work actually. Make sure the listener is registered. Do a clean setup so you can be sure that no other listener interferes.

arctic moth
#

forgor

quiet ice
#

Bad as in anoyying that is

vast raven
#

I'mma actually import your code without any changes.

glossy scroll
#

really wish mob pathfinding goals wasnt so limiting

#

whatever tho

lost matrix
glossy scroll
#

well yea im using nms

echo basalt
#

paper has pathfinding

glossy scroll
#

i just generally dislike how its hard to specify goals for a limited amount of time

echo basalt
#

you can add, remove and set goals

glossy scroll
#

?whereami

echo basalt
#

but pathfinders weren't made to be dynamic like that

arctic moth
#

ok found a way for it to work thx

glossy scroll
#

why

vast raven
#

Same code.

minor garnet
#

why do you dont use the api of cs ?

#

or wait 1 tick

patent fox
#

how can i set a skull's skin using a skull value?

vast raven
minor garnet
#

debug it

vast raven
#

the result is that the item changes as it shoulds

#

but only in the console, not in the pratic

minor garnet
#

why do you need this?

vast raven
#

I have all code I need, but this doesn't work, I would have cancelled and set the item manually using the sounds, but the animations when you take the item, can be made just from the original event

vast raven
eternal oxide
#

skull value?

vast raven
#

public static ItemStack getHead(Player player) { ItemStack skull = new ItemStack(Material.PLAYER_HEAD); // Create a new ItemStack of the Player Head type. SkullMeta skullMeta = (SkullMeta) skull.getItemMeta(); // Get the created item's ItemMeta and cast it to SkullMeta so we can access the skull properties skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); // Set the skull's owner so it will adapt the skin of the provided username (case sensitive). skull.setItemMeta(skullMeta); // Apply the modified meta to the initial created item ItemMeta itemMeta = skull.getItemMeta(); skull.setItemMeta(itemMeta); return skull; }

patent fox
#

no

vast raven
#

@patent fox

patent fox
#

not like that

vast raven
#

using the skull value?

eternal oxide
#

you want to read teh skin off an already existing skull?

patent fox
#

its not a player

vast raven
#

NBTag

#

Use NBTApi

hybrid spoke
odd thicket
#

You can create a Player profile and set it to the skull using setOwningProfile

vast raven
hybrid spoke
#

as for the blocks

#

texture pack

vast raven
glossy scroll
#
    public static SkullMeta setProfile(final SkullMeta meta, GameProfile profile) throws ReflectiveOperationException {
        final Method profileMethod;
        profileMethod = meta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
        profileMethod.setAccessible(true);
        profileMethod.invoke(meta, profile);

        return meta;
    }```
eternal oxide
#

eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTJkZDExZGEwNDI1MmY3NmI2OTM0YmMyNjYxMmY1NGYyNjRmMzBlZWQ3NGRmODk5NDEyMDllMTkxYmViYzBhMiJ9fX0= Is the texture part

#

thats teh only part you need

glossy scroll
#
    public static GameProfile makeSkullProfile(String base64) {
        final GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null);
        gameProfile.getProperties().put("textures", new Property("textures", base64));
        return gameProfile;
    }```
vast raven
glossy scroll
#

idk if com.mojang.authlib.GameProfile is considered nms

eternal oxide
#

Using PlayerProfile ```java
/**
* Create a Skull with a texture using the new PlayerProfile
* Post 1.18.2
*
* @param id UUID to assign the skull.
* @param name a name for the skull
* @param texture a Base64 texture String
* @return Skull ItemStack
*/
public ItemStack getHeadByProfile(UUID id, String name, String base64Texture) {

    ItemStack head = new ItemStack(Material.PLAYER_HEAD);

    PlayerProfile profile = Bukkit.getServer().createPlayerProfile(id, name);

    try {
        profile.getTextures().setSkin(new URL(getURLFromBase64(base64Texture)));
        SkullMeta meta = (SkullMeta) head.getItemMeta();
        meta.setOwnerProfile(profile);
        head.setItemMeta(meta);
        
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    return head;
}

private String getURLFromBase64(String base64) {
    
    return new String(Base64.getDecoder().decode(base64.getBytes())).replace("{\"textures\":{\"SKIN\":{\"url\":\"", "").replace("\"}}}", "");
}```
glossy scroll
#

was that api in 1.12.2?

eternal oxide
#

1.18.2

quaint mantle
#

does minimessage have a relocation?

vast raven
glossy scroll
#

youre using 1.12.2

#

so no you should not

vast raven
glossy scroll
#

i mean sure, bugs exist

#

so you will need to find a workaround

vast raven
#

Sometimes the "other ways" are limited

vast raven
glossy scroll
#

part of the fun of signing up for legacy versions

sterile token
#

Any aproach?

glossy scroll
#

you should be skilled enough to find solutions to legacy bugs

sterile token
vast raven
glossy scroll
#

nope!

vast raven
glossy scroll
#

im not knowledgable in 1.12

vast raven
sterile token
glossy scroll
#

so even if i tried to help

vast raven
sterile token
#

Use 1.19

glossy scroll
#

i wouldnt be able to

vast raven
vast raven
sterile token
#

If you use legacy versions is your problem to solve the things

glossy scroll
#

at minimum 1.14 imo but i still likely wont help lol

sterile token
#

๐Ÿ˜‚

#

Sorry for being rude but the truth

vast raven
glossy scroll
#

don;t worry, the spigot forums were very popular around 1.12

sterile token
#

Legacy versions == Not being helped most of the time

glossy scroll
#

so your problem may be on there

vast raven
#

But if you help me at least..

#

๐Ÿฅฒ

glossy scroll
sterile token
glossy scroll
#

what is this

sterile token
#

And i dont want to initialize by hand and call the method enable/disable

vast raven
sterile token
vast raven
#

I think I'll just quit helping and start solving the problem before I get tired

glossy scroll
sterile token
vast raven
glossy scroll
#

well isn't that the point of an interface?

#

just for the shared enable/disable methods?

sterile token
#

yes but if you use, you also have to initialize each manually

#

๐Ÿค”

#

So is the same thing hahaha

glossy scroll
#

wdym

#

do all of their constructors have the same parameters?

glossy scroll
#

ok wonderful

#

so heres my solution

sterile token
#

Not abstract because i want to be optional the enable/disable hahah

glossy scroll
#

yes thats fair

#

dont worry about that

#

they all have "Prison" as a paramater

#

correct?

#

and they all return of type "Handler" (you should seriously consider renaming that)

sterile token
#

Wait wait

#

Each handler should contains enable/disable and also getters, setters and methods

glossy scroll
#

ok fair enough whatever

#

(what are these handlers?)

sterile token
#

So i dont want to do this with every handler:

void loadHandlers() {
    CoinsHandler coins = new CoinsHandler();
    coins.enable();
    UserHandler users = new UsersHandler();
    users.enable();   
}```
#

So that why im doing reflections

echo basalt
#
void registerHandler(Handler handler) {
  handler.enable();
  ...
}
sterile token
#

๐Ÿ˜‚

echo basalt
#
registerHandler(new CoinsHandler());
registerHandler(new UsersHandler());
glossy scroll
#

oh

#

that is very reasonable though

echo basalt
#

you can then add the handler to a collection

#

and disable them in bulk

sterile token
#

Because now i have just 10 handlers but waht about for 100 handlers?

#

๐Ÿค”

glossy scroll
#
public enum HandlerType {
    HANDLER_A(HandlerA::new),
    HANDLER_B(HandlerB::new);
    
    private final HandlerFactory factory;
    public HandlerType(HandlerFactory factory) {
        this.factory = factory;
    }

    Handler create(Prison prison) {
        return factory.create(prison);
    }

    private interface HandlerFactory {
        Handler create(Prison prison);
    }
}```
#

now you could call HandlerType.HANDLER_A.create(prison)

sterile token
#

But i dont want to get the handler obj

#

Because them i cannot call non handler interface methods

echo basalt
glossy scroll
#

true

sterile token
#

Because i dont overload the main class

glossy scroll
#

here is a similar pattern

#

heavily inspired by nms EntityTypes

#

now I could call DungeonEntityType.IRON_BEE.create(level, dungeon) and that will give me an "IronBee"

#

but idk if your handlers are meant to be singleton-esque

sterile token
#

I mostly ue Di

glossy scroll
#

ok

#

well

#

i would just do something that Imllusion did

sterile token
#

But wait i cannot do the thing you are doing

glossy scroll
#

your reflective way of doing things is too sloppy imo

sterile token
#

because them i cannot call the getters/setters of the TestHandler

glossy scroll
#

yes you could?

#
    public T create(Level level, Dungeon dungeon) {
        return spawnFactory.create(entityType, level, this, dungeon);
    }```
#

this gives me the type of the mob i want

#

if you used this with your handler pattern you would get an object of type TestHandler

#

what does javadocs say

#

Interactable materials include those with functionality when they are interacted with by a player such as chests, furnaces, etc. Some blocks such as piston heads and stairs are considered interactable though may not perform any additional functionality. Note that the interactability of some materials may be dependant on their state as well. This method will return true if there is at least one state in which additional interact handling is performed for the material.

#

my guess is yes

sterile token
#

Is possible to generate getters via reflections?

worldly ingot
#

generate? No. You can generate code with an annotation processor though

#

Though that's done at compile-time

glossy scroll
#

chests, furnaces, etc

#

im assuming yes

sterile token
glossy scroll
#

etcetera

#

idk

#

thats what the jd says

#

you could always jsut.... test it out

#

its not a very complicated thing to do

noble lantern
glossy scroll
#

i mean you read the docs yourself

gleaming grove
#

someone know why splitting by . is not working?

glossy scroll
#

. is a regex pattern

#

you would need to do \.

gleaming grove
#

thx

glossy scroll
#

. means any character actually

#

why use var

gleaming grove
#

em.. i not much into regex, why the error apperas?

gleaming grove
glossy scroll
#

๐Ÿ™„ ok

glossy scroll
gleaming grove
#

StringUtils.split(file, "."); ok, this should works

fossil lily
#
Bukkit.getScheduler().scheduleSyncRepeatingTask(Bedwars.getInstance(), () -> {
                for (int i = 0; i < 600; i++) {
                    World world;
                    world = arena.getWorld();
                    int min = - arena.getBuildWidth();
                    int max = arena.getBuildWidth();
                    int xrandom = (int) (Math.random() * (max - min + 1) + min);
                    int zrandom = (int) (Math.random() * (max - min + 1) + min);
                    Block up = world.getHighestBlockAt(xrandom, zrandom);

                    Location loc = up.getLocation();
                    if (!up.getType().equals(Material.BED_BLOCK) && !up.getType().equals(Material.CHEST) && !up.getType().equals(Material.ENDER_CHEST)) {
                        world.playSound(loc, Sound.CHICKEN_EGG_POP, .5f, 2f);
                        loc.getBlock().setType(Material.AIR);
                    }
                }
            }, 600, 5);

Why is it prioritizing glass blocks? Wtf?

#

1.8.9

sterile token
#

Oh 1.8 ๐Ÿคข

#

Mostly here doesnt like legacy versions

glossy scroll
#

?1.8

undone axleBOT
glass mauve
#

lmao

#

it's like programming software for win7 ๐Ÿ‘€

atomic niche
#

Speaking of super old versions, guessing it is no longer possible to make 9+ row GUIs now-a-days?
MC-108756 got patched a while ago; somehow only noticed just now

glossy scroll
atomic niche
#

๐Ÿ˜ฆ

kind hatch
glass mauve
#

1.8 not

glossy scroll
#

well yea i guess

atomic niche
#

^ If you were willing to live with it looking janky, you could have 100+ slots

kind hatch
#

There were bugs that allowed for slots to overflow, but those have been patched.

atomic niche
#

๐Ÿ˜ฆ giant ugly chest guis were surprisingly useful for things that didn't need much polish

#

anyways, at least its more consistent now

quaint mantle
#

how do i add something to a mask?

#
Mask mask = new BlockMask();```
eternal oxide
#

No one has any idea what your Mask is. Its not Spigot

lost matrix
#

Probably we

eternal oxide
#

Possibly

gleaming grove
#

Is Java engine caching strings? I'm currently adding the translations to my plugin so should I store translation's paths in some static field?

echo basalt
#

you have way too much hope

ancient plank
#

java engine

compact haven
#

๐Ÿคฃ

#

well technically

#

yes they are "cached"

#

you are not wrong

#

they are held in the constant/string pool

echo basalt
#

until the garbage collector pulls up

compact haven
#

Nope, they stay in the constant pool in JVM bytecode

echo basalt
#

hm

#

if the string is static

#

perhap

gleaming grove
#

as far as I know strings are catched in a function range

compact haven
#

no Java does not cache for you

echo basalt
#

otherwise strings would be prone to memory leaks extremely easily

gleaming grove
#

like when you make 2 string with same value in a function they are assigned to one pointer

compact haven
#

like a direct string in source code

#

similar to that translation path

#

"12" + v + "e" couldn't be stored in the constant pool

#

instead, "12" and "e" would be

compact haven
#

because strings are immutable

#

but you can bypass that by directly calling new String("test")

#

but it's not really a pointer, nor is it only limited to the function invocation

gleaming grove
#

Lang.get("gui.base.insert.desc") well so everytime I will be calling this method new string will be created?

compact haven
#

No

#

you're fine to do that

gleaming grove
#

oke

carmine nacelle
#

what does itemstack#issimilar account for

eternal oxide
#

it should be everything apart from stack size

vocal cloud
#

Read the docs and find outโ„ข๏ธ

carmine nacelle
vocal cloud
#

๐Ÿคก

#

I bruised a finger finding it in the docs sadge

severe turret
#

wat

eternal oxide
#

lol

severe turret
#

why so mad

#

if u don't know how to use a method

#

check it in javadocs

eternal oxide
#

Javadocs are your friend. I have them open in my browser 24/7

severe turret
#

that's literally why they exist

carmine nacelle
#

whos mad?

severe turret
#

you

carmine nacelle
#

no?

vocal cloud
#

Thanks for the real answer as if my answer wasn't good

ancient plank
#

hoes mad

severe turret
#

You could get an answer faster if u opened javadocs instead of asking here

#

ornns mad

carmine nacelle
#

I got an answer from the one dude in like 2 seconds

vocal cloud
#

Yeah but instead of typing it here you could have gotten it instantly from the docs

carmine nacelle
#

this discord is like early 2000s britney spears

#

toxic mfs

vocal cloud
#

Just annoyed at a question where the answer is free, online, and instantly accessible

eternal oxide
#

Leave Britney alone!

ancient plank
#

I liked early 2k britney

vocal cloud
#

Early 2k Britney would have used the docs ๐Ÿ˜ค

tender robin
#

is it possible to take an arg from a command and use it in a listener?

eternal oxide
#

Commands are instant. Listeners are event triggered.

#

Store the data from the command somewhere, like in a map for the player or on the player

tender robin
#

Hashmap?

eternal oxide
#

ie, player issues command, store in a map against teh players uuid.
event happens and your listener fetches data for the relevant player from the map

#

it depends on what you need to store and why

tender robin
#

so the players gets a book after using the command and the books name is the args[1] = player message. but I want to use it in a PlayerInteractEvent

strong parcel
#

I am making a GUI, and I am on the part where I need to check if the inventory clicked is the GUI in order to cancel the click event, but for some reason e.getInventory().equals(gui) returns false. Does anybody know why the inventory in-game is considered unequal to gui? https://paste.md-5.net/jidarotovo.java

eternal oxide
eternal oxide
#

you store the data on the book in its name, so when you click the book, just get the name

tender robin
#

yes but

ItemStack permpaper = new ItemStack(Material.PAPER);
ItemMeta papermeta = permpaper.getItemMeta();
papermeta.setDisplayName("ยง7ยป ยงe" + args[1]);
vocal cloud
#

If it has coloring store it in the PDC so you can know it's your book

tender robin
#

"ยง7ยป ยงe" + args[1] that's the name

carmine nacelle
#

isnt PaperMeta its own thing

vocal cloud
carmine nacelle
#

or BookMeta

eternal oxide
#

so not a book

vocal cloud
#

Use the PDC and store whatever you want to use later in it to prevent anvil exploits.

tender robin
eternal oxide
#

?pdc

tender robin
carmine nacelle
#

why not just check the inventory title

eternal oxide
#

noooo