#help-development

1 messages · Page 394 of 1

dark bridge
#

Ok

undone yarrow
#

Yeah but location in the bottom most line is not available. How do I get that location?

#

Do I need to do a loop?

lost matrix
#

Then all you need to do is add and remove objects from the map. No need to handle hundreds of tasks.

undone yarrow
lost matrix
undone yarrow
eternal oxide
#

you don't

#

you add a counter to your ChestObject

undone yarrow
#

And every second you remove 1 from the counter?

eternal oxide
#

yes, or add one, untill it matches the countdown

#

is the cooldown only used once?

undone yarrow
#

But if I add a variable to my chestObject, I'd also have to fill in another argument when I try to add a location

                    ChestObject chest = new ChestObject(false, blockLoc, particle, cooldown, items, "cooldown argument?");
undone yarrow
#

It loops

#

So you can harvest it, then it cools down, then you can harvest it again, etc.

eternal oxide
#

no you don;t add another arg

#

the value is internat to he chest objewct

#

all it does is count down from the cooldown to zero

undone yarrow
#

and then set isLootable to true again, right

eternal oxide
#

you tick it every second

undone yarrow
#

and restart the counter

eternal oxide
#

yep

undone yarrow
#

So that should go in my chestobject class?

eternal oxide
#

yes

undone yarrow
#

And how do I run it every second

eternal oxide
#

you add a method to decrease/reset it

undone yarrow
#

Where

#

now Im confused

undone yarrow
#

Thats what I'm asking

wet breach
#

That is what the task is for

eternal oxide
#

you should have a task running that loops over your chests

undone yarrow
#

ohh alright

#

so I need a task in a seperate class that runs the method in the chestObject class

eternal oxide
#

in that task you loop over chests, decrease counter, check if zero, flag chest as lootable and reset counter

undone yarrow
#

oh

eternal oxide
#

it shoudl also trigger the particle

undone yarrow
#

You guys are frying my brain atm

wet breach
eternal oxide
#

no

#

single task for all chests

#

not one per chest

wet breach
wet breach
undone yarrow
#

Ill just do this:

  1. Add a method to ChestObject called Cooldown, that, when run, will decrease the cooldown time by one if it's not isLootable, and will check if it's 0 (then reset it and set isLootable to true)
  2. Add a task in a seperate class, maybe onEnable, that calls Cooldown every second
  3. Go over all my chestObjects in my spawnParticle class, check which are isLootable, then add a particle there.
#

I know what you guys are going to say right now

#

dont put it in onEnable

lost matrix
#

Honestly all the logic should be contained within the ChestObject

undone yarrow
#

...

#

well that's what makes my brain fry. What I posted above still makes it fairly understandable to me

lost matrix
#

And it has a method called tick()
Your runnable just calls tick() every second on every ChestObject and does nothing else.

undone yarrow
#

is tick() a standard method called every tick then?

wet breach
lost matrix
#

Usually you would call it every tick.

#

It depends on how you structure your clock cycle. If your lowest time frame is one second then
you call it every second.

#

Just remember that your Object now needs to know its own location as a field.

wet breach
vast raven
#

?paste

undone axleBOT
vast raven
lost matrix
#

Garbage

#

Using reflections for this is bad. And those reflections are not even cached.

vast raven
#

So how I am supposed to avoid this

vast raven
#

I don't have the player texture

lost matrix
#

What version are you on?

vast raven
#

I just have the texture value, like the one you find on HeadDB

vast raven
lost matrix
#

Well then you have to use reflections. Search for an old tutorial from a few years ago.

vast raven
#

Wasn't my snippet good for this purpose?

lost matrix
#

Pass true to your update method and try again

vast raven
#

@lost matrix

lost matrix
#

try getDeclaredField

vast raven
#

wooo that works finally thanks

tardy delta
#

thats some weird salad

vast raven
#

That's not salad

lost matrix
#

Broccoli

vast raven
remote swallow
#

is there anyway to get all pdc on an item, types, values, keys etc without knowing its specific type or needing to call get for each type on one key without needing to use NBTBase stuff

tardy delta
#

and whats the weed plant doing there

lost matrix
#

Rotten Broccoli

vast raven
tardy delta
#

pov: the silent kid in minecraft

lost matrix
remote swallow
remote swallow
lost matrix
remote swallow
#

save all types i can

#

save as many keys&values

vast raven
remote swallow
#

i managed to do it on yaml with NBTBase and jank methods

#

but sadly gson doesnt have addProperty(String key, Object value)

quaint mantle
#

Hellooar How do set motd to middle with gradient

undone yarrow
# lost matrix Honestly all the logic should be contained within the ChestObject

What about this?```java
private ScheduledExecutorService executor;

public void startCooldownTimer() {
    if (!isLooted) {
        isLooted = true;
        executor = Executors.newSingleThreadScheduledExecutor();
        executor.schedule(() -> {
            isLooted = false;
            executor.shutdown();
            executor = null;
        }, cooldown, TimeUnit.SECONDS);
    }
}``` I call it when I right click a block that is registered as ChestObject
tardy delta
#

and thats within what class?

undone yarrow
#

In the ChestObject class

tardy delta
#

?scheduling tho

undone axleBOT
vast raven
remote swallow
#
if (!itemMeta.getPersistentDataContainer().getKeys().isEmpty()) {
                PersistentDataContainer pdc = itemMeta.getPersistentDataContainer();
                Map<String, NBTBase> stringNBTBaseMap = new HashMap<>();
                stringNBTBaseMap.putAll(Utils.getCustomDataTags(pdc));
                stringNBTBaseMap.forEach((key, value) -> {
                    configurationSection.set("pdc." + key + ".type", value.getClass().getSimpleName().toUpperCase(Locale.ROOT).replace("NBTTAG", ""));
                    configurationSection.set("pdc." + key + ".value", Utils.convertToCorrectType(value.toString(), value.getClass().getSimpleName().replace("NBTTag", "")));
                });

            }
``` that was a very fun method to somehow come up with
tardy delta
#

ig you just want to execute logic in there that runs every second

vast raven
tardy delta
#

create a manager class that actually calls those methods every second

undone yarrow
remote swallow
#

i wonder if i can store an entire pdc container with b64 , idk how i would deserialize it

tardy delta
#

7smile7 is gonna come up with a genial solution, i feel it

remote swallow
#

100%

#

is 7smile secretly a better version of chatgpt

lost matrix
# undone yarrow What about this?```java private ScheduledExecutorService executor; publ...

You are going to park a metric ton of system threads just to enable some cooldowns.
Its nice that you look into other ways of doing this, by all means keep exploring, but you
cant create a new executor service for every single running cooldown.

Also: Your variables are not thread safe. If you want to do it this way:

  • Create 1 Executor and schedule all your cooldown reset tasks on this executor
  • Make your cooldown variable an AtomicBoolean so that you dont run into threading problems
undone yarrow
#

Fourteenbrush mentioned schedulers?

lost matrix
remote swallow
#

nbt stuff is too much for my brain to get its head around

#

wait a god damn minute

kind hatch
#

NBT is just JSON though. :p

remote swallow
#

isnt all the data on an item stored in json

remote swallow
smoky oak
#

can someone explain why this isn't working? do strings get generated at compile time?

vast raven
lost matrix
kind hatch
eternal oxide
#

wtf is a field so is set before yoru constructor runs

tardy delta
#

dunno what the point of that isLooted is but ig you want smth like this:

class LootThingie {
  boolean looted;

  void tick() {
    looted = false;
  }
} 

class LootManager() {
  List<LootThinie> loot;
  scheduler.runTaskTimer(plugin, () -> loot.forEach(LootThingie::tick), 0, 20);
}```
smoky oak
tardy delta
#

where you just call tick on the loot thing every second, probably want to remove it too

remote swallow
#

i wonder how i can get the entire nbt json of an item

tardy delta
#

im feeling your pain, deserializing recipes goes even more brr

lost matrix
kind hatch
lost matrix
undone yarrow
remote swallow
#

whats it called

smoky oak
#

if the constructor sets that value?

hybrid spoke
#

your ide will just complain because at the given time its null

#

you would need to reinitialize your var after object creation

tardy delta
#

arent fields with an explicit intializer initialized before fields that are initialized in the constructor?

hybrid spoke
#

yes

#

but with that class structure i would also be confused

kind hatch
smoky oak
#

might be

#

using code thats provided without explanation is always 'fun'

undone yarrow
#

What about this. It gets run whenever the block gets looted. The runtasktimer makes sure it gets run every second right? java public void startCooldown() { if (!isLooted) { return; } countdown = cooldown; new BukkitRunnable() { @Override public void run() { if (countdown <= 0) { this.cancel(); isLooted = false; } else { countdown--; } } }.runTaskTimer(plugin, 0, 20); // run every second (20 ticks) }

smoky oak
#

why's there no sql spigot tutorial apart from that 2015 thing urgh

smoky oak
undone yarrow
smoky oak
undone yarrow
#

no?

smoky oak
kind hatch
#

Oh, sqlite.

smoky oak
#

ye i need it local

undone yarrow
#

aah my wifi wtf

smoky oak
#

dont have an actual db server available

lost matrix
tardy delta
remote swallow
kind hatch
tardy delta
smoky oak
kind hatch
#

Pretty much yea.

tardy delta
#

for sqlite? yes

smoky oak
#

hm

#

ill try and annoy yall when it failed

lost matrix
# remote swallow nah

Then this serializes the ItemStack to a Base64 String:

  public static String itemStackToBase64(final ItemStack item) {
    try {
      @Cleanup final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      @Cleanup final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
      dataOutput.writeObject(item);
      return Base64Coder.encodeLines(outputStream.toByteArray());
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }

And this deserializes it again:

  public static ItemStack itemStackFromBase64(String base64) {
    try {
      @Cleanup final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(base64));
      @Cleanup final BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
      return (ItemStack) dataInput.readObject();
    } catch (IOException | ClassNotFoundException e) {
      e.printStackTrace();
      return null;
    }
  }
lost matrix
tardy delta
#

uh oh

remote swallow
#

you do that everyday

#

right

tardy delta
#

currently got 300 lines of code to deserialize certain shaped recipes

#

and that only works half of the time

remote swallow
#

im gonna be smart

#

what does @Cleanup do

tardy delta
#

try with resources ig

quaint mantle
#

How do set motd to middle with gradient

tardy delta
#

for lazy fuckers

quaint mantle
#

Help

tardy delta
lost matrix
remote swallow
#

fun

quaint mantle
#

I use mctools

rotund ravine
#

Just use kotlin hehe

tardy delta
#

?img

undone axleBOT
quaint mantle
#

👋

tardy delta
#

dang github

lost matrix
# remote swallow fun

Btw you can also use Spigots serialize method which serializes the ItemStack to a Map<String, Object> and let Gson have its way:

  public static String itemStackToSpigotString(ItemStack itemStack) {
    return GsonProvider.toJson(itemStack.serialize());
  }

  public static ItemStack itemStackFromSpigotString(String str) {
    return ItemStack.deserialize(GsonProvider.fromJson(str, new TypeToken<Map<String, Object>>() {}.getType()));
  }

But this breaks with PlayerHead items.

remote swallow
#

its very fun

quaint mantle
#

Does anyone kno

#

Ive been restarting my server to see if something changes

#

Nothing happens

tardy delta
#

heehee

quaint mantle
#

AH NVM

eternal oxide
quaint mantle
#

IT DOESNT HAVE SPACES but I have put spaces already

#

._.

#

wlep how

#

Any recommendations

#

I use purpur

remote swallow
#

okay im back to being confused how gson works

#

trying the b64 thing first and im very confused how to get a value from a JsonReader

tardy delta
#

just use jsonobjects

remote swallow
#

but how

tardy delta
#

implement JsonSerializer<ItemStack> and optionally deserializer instead of typeadapters

remote swallow
#

i had that earlier on my other method

tardy delta
#

jsonreader is pretty useless

#

im doing smth like this

remote swallow
#

json objs are a lot better

tardy delta
#

not using the reflective stuff of gson tho

#

as i cant inject any context into a typeadapter

remote swallow
#

do i need to in.beginObject before parsing

tardy delta
#

you just told you were using jsonobjects

remote swallow
#

with the parser stuff

tardy delta
#

oh thats also a thing

#

no

#

JsonParser should handle everything

quaint mantle
#

best way to increase natural health regen?

#

Seriously i need help on motd

undone yarrow
#

Can anyone please help me fix my entire plugin? Nothing works.
When I do /sc add SCRAPE 5 sand, it says "location added" in the chat, but when I do /sc list it says that I dont have locations added yet.
When I rightclick a block I get an error longer than godzilla's male-parts
No particles show up when I try adding something. Here's the code
https://paste.md-5.net/upiladotub.java - Particle Handler
https://paste.md-5.net/itawicemey.java - ChestObject
https://paste.md-5.net/igalamazix.java - EventListener
https://paste.md-5.net/witifijefa.java - AddParticleCommand
https://paste.md-5.net/bicepudobu.cs - error 😠

remote swallow
#

minimotd prob works for what you want

quaint mantle
#

The space keeps getting removed

quaint mantle
#

Will “ works

#

What do u call thee

#

These

#

Lol

remote swallow
#

quotes and it should

#

b64 appears to work

#

party

undone yarrow
#

imagine making code that actually works

remote swallow
#

i didnt make it

#

thats the fun part

remote swallow
#

now to add this to my lib so i never have to remember it

tardy delta
#

?conventions

remote swallow
#

and change my toB64 methods

undone yarrow
#

shit I think Im in the wrong department

#

I give up

#

this code can suck my ass

dry yacht
quaint mantle
#

LOL

remote swallow
dry yacht
remote swallow
#

i started this like 2 days ago i dont remember what i wanted lol

#

just some form of item stack type adapter

dry yacht
#

Adapter? That sounds like something mediating between versions. Were there ever any breaking changes on NBT keys? I'm actually not sure...

remote swallow
#

gson type adapter

dry yacht
#

Oh, right, sry, xD

eternal oxide
eternal oxide
#

You also have two, one in yoru onCommand and one in your event listener

#

you shoudl only have ONE particle handler

undone yarrow
#

hmm I see

undone yarrow
eternal oxide
#

?di dependency injection

undone axleBOT
undone yarrow
#

But how I can access it in onCommand still confuses me

worn tundra
#

😭

undone yarrow
sinful kiln
#

I recommend checking out the examples of the linked page

undone yarrow
#

I did

#

and I read the thing

#

and asked AI to explain it to me lol

#

I get what it means after chatgpt explained it to me like Im a 5 year old

#

but implementing it in code is just.... weird imo

sinful kiln
#

Well its simple, create an instance in for example your plugin class

#

And then create a getter in that class

#

Then every class / object that has a reference to your plugin instance can call that getter to retrieve the instance of the thing you want

undone yarrow
#

All of that just to pass 1 variable

sinful kiln
#

You could also pass the variable directly in the constructor

#

You theoretically don’t need to use a getter there, but it might make things easier if you want to use that instance somewhere else

undone yarrow
#

I only need to use it in onCommand and ther other class afaik

sinful kiln
#

Yeah then create a field for that class in your command and your listener

#

Create the object in your plugin class

#

And pass it to the command and the listener via the constructor

undone yarrow
#

plugin class?

#

constructor?

sinful kiln
#

Ah I see you don’t even know the basics of Java yet

glad prawn
#

?learnjava

undone axleBOT
sinful kiln
#

They should add w3schools to it, they explain it step by step - is easy to understand and free ofc

#

I think its fine tbh

undone yarrow
#

I dont plan on learning java though lol. I just needed to make quite a simple plugin

sinful kiln
#

The bascis are enough to get started imo - I learned everything I can today by myself mostly through trial and error

#

Back then it would‘ve been great to have w3schools xD

#

The basics of w3 help a lot understand other sites imo - so its a good starting point.
I think the official website is hard to learn from

#

Yeah

#

Idk if something changed since I started to learn Java

#

Probably did x)

#

(Hopefully)

#

Welp then it didn’t

brisk estuary
#

Could anybody tell me what's the difference between the method dropItem() and dropItemNaturally? I did a little research but I don't finish understanding it.

sinful kiln
#

If I remember correctly dropItemNaturally will give it random velocity

#

While dropItem doesn’t

hybrid spoke
#

basically dropped with an extra touch

brisk estuary
#

in terms of efficiency is there much difference between them?

hybrid spoke
#

none

brisk estuary
#

ok, ty guys

dry yacht
#

Well, not none, but it's negligible. Except for when you want to drop a thousand items all at once, xD.

hybrid spoke
#

yeah no, none.

brisk estuary
#

yeah, that's not my case XD

#
@EventHandler
    public void onBlockBreak(BlockBreakEvent e){
        Block b = e.getBlock();
        if (b.hasMetadata("placed") || !SpecialOre.FOUNT_ORE_MAP.containsKey(b.getType())) return;

        NosamPickaxe nosamPickaxe = NosamPickaxe.getByItemStack(e.getPlayer().getInventory().getItemInMainHand());
        if (nosamPickaxe == null) return;

        SpecialOre ore = SpecialOre.FOUNT_ORE_MAP.get(b.getType());
        int random = ThreadLocalRandom.current().nextInt(100) + 1;

        if (random > nosamPickaxe.getProbability(ore)) return;
        b.getLocation().getWorld().dropItemNaturally(b.getLocation(), ore.clone());
    }
#

does it look clean for u guys?

undone yarrow
#

Looks cleaner than my bedroom

brisk estuary
#

lol

tardy delta
#

damn 556 recipe files could be deserialized

#

probably have to clean this up

tardy delta
dry yacht
tardy delta
#

thats what im saying

dry yacht
#

Yep, was just clarifying. It's not so clear for people why that's two lookups. "I was only calling contains, not get", xDD

tardy delta
#

contains calls get

undone yarrow
# sinful kiln Yeah then create a field for that class in your command and your listener

What about this?

public class EventListener implements Listener {
    private final ParticleHandler pHandler;

    public EventListener(main plugin) {
        plugin.getServer().getPluginManager().registerEvents(this, plugin);
        pHandler = new ParticleHandler();
    }```
```java
public class AddParticleCommand implements CommandExecutor {

    private final ParticleHandler pHandler;

    public AddParticleCommand(ParticleHandler pHandler) {
        this.pHandler = pHandler;
    }``````java
public final class main extends JavaPlugin{

    @Override
    public void onEnable() {
        registerCommands();
        new EventListener(this);
        ParticleHandler particleHandler = new ParticleHandler();
        particleHandler.spawnParticlesEverySecond(this);

    }

    private void registerCommands() {
        ParticleHandler particleHandler = new ParticleHandler();
        Objects.requireNonNull(getCommand("sc")).setExecutor(new AddParticleCommand(particleHandler));
    }
tardy delta
#

why are you using naming conventions and suddenly not

#

and dont create particle handlers everywhere

undone yarrow
#

Im not creating them everywhere?

#

oh wait

tardy delta
#

3 times

undone yarrow
#

I think theres an issue in main

#

yeah

tardy delta
#

only create the in the main class

undone yarrow
#

somethings wrong with main

undone yarrow
#

alright

tardy delta
#

and pass them to the listener and command

undone yarrow
#

k

undone yarrow
river oracle
#

Yeah your fine with this one

undone yarrow
#

Alright, now time to fix the other 529329104 errors

river oracle
#

What data does particle handler hold

undone yarrow
#

At the current rate, it will take me approximately 529329104 * 2 / 24 = ~44.110.759 days

#

ah shit

undone yarrow
#

it's been so long I forgot

river oracle
#

💀

#

I was gonna say if it doesn't hold any data just use static methods

#

Then you ain't gotta worry about unnecessary DI which can get long and annoying

undone yarrow
#

idk man. im just going to test this code and see what errors I get

#

If I dont get any errors Ill jump out of my window

#

Alright, heres my observations:

/sc add SCRAPE 5 sand - no particles, no error. It says it added it to the list
/sc list - works. no errors
/sc remove - works. no errors

#

When I right click, it says "looted block" and I get no errors, somehow.

#

This is not looking good

#

Ah shit it's working

#

@tardy delta it's working 🥹

#

Only thing is, particles arent working

#

Oh well it's only like 50% of my plugin

onyx fjord
#

What is that

undone yarrow
#
    public void spawnParticlesEverySecond(Plugin _plugin) {
        plugin = _plugin;
        BukkitRunnable runnable = new BukkitRunnable() {
            public void run() {
                for (Map.Entry<Location, ChestObject> entry : chests.entrySet()) {
                    Location location = entry.getKey();
                    if(!chests.get(location).isLooted()) {
                        Particle particle = chests.get(location).getParticle();
                        Objects.requireNonNull(location.getWorld()).spawnParticle(particle, location, 7, 0.1, 0.2, 0.1);
                    }
                }
            }
        };
        runnable.runTaskTimer(plugin, 0L, 20L);
    }```
undone yarrow
onyx fjord
#

How

undone yarrow
#

idk man

onyx fjord
#

How is that valid syntac

#

Syntax*

undone yarrow
#

what line is it

#

you mean the "main plugin" part?

onyx fjord
#

Ye

undone yarrow
#

"main plugin" refers to the instance of the main class that extends the JavaPlugin class. It is used to register the EventListener instance to the Bukkit event system, so that the EventListener can listen to events being triggered by the server.

onyx fjord
#

I don't know man

#

Does it compile?

undone yarrow
#

it uses a feature called "lambda expressions" in Java.

A lambda expression is a way to define a method without using the traditional method declaration syntax. Instead, it provides a shorthand way to write a single method that takes in one or more parameters and returns a value, if necessary.

undone yarrow
onyx fjord
#

Bro I know what lambda is

frail basin
#

brothers i am the master builder what is this

onyx fjord
#

Why u sending definitions of everything

frail basin
#

to infrom you

onyx fjord
#

I feel like I'm talking with some form of AI

undone yarrow
#

I took a "how human am I test"

#

And Im actually an android

#

so you're correct

frail basin
#

thats smoldring with ezxcitment

undone yarrow
#

It also said that I can only get a girlfriend if she's severely disabled and blind

tawdry echo
frail basin
#

yay wheel chair photo shoot

undone yarrow
frail basin
#

ight thats rude my man

undone yarrow
undone yarrow
frail basin
#

makes a disabled joke and then bashes someone for chiming you a whole bitch

undone yarrow
#

yes

frail basin
#

atleast you know

undone yarrow
#

And all different chest objects are stored in a Map

#

with a location to make it easy to reference them

tawdry echo
#

ChestObject chobj = map#get

If chobj#isLooted
...

#

Or there it will be entry#getValue

eternal oxide
undone yarrow
#

ohhh

#

like that

#

I see

eternal oxide
#

you are already looping the Map so use teh entry

undone yarrow
#

I was already wondering if there's a better way because it looked like a bad piece of code

eternal oxide
#

if (!entry.getValue().isLooted())

undone yarrow
# eternal oxide if (!entry.getValue().isLooted())
               for (Map.Entry<Location, ChestObject> entry : chests.entrySet()) {
                    if (!entry.getValue().isLooted()) {
                        Particle particle = entry.getValue().getParticle();
                        Objects.requireNonNull(entry.getKey().getWorld()).spawnParticle(particle, entry.getKey(), 7, 0.1, 0.2, 0.1);
                    }
                }```
#

I replaced the locations with entry.getKey instead of making a new var for location bcs it didnt seem very organizd. I also changed the particle thingy

eternal oxide
#

yes but remove the Objects.requireNonNull( its annoying auto fix suggestion by inteliJ

#

it's always wrong

undone yarrow
#

oh

#

why is it wrong

#

I used that in a lot of places lol

eternal oxide
#

all it does is stop teh IDE complaining but fixes nothing

undone yarrow
#

otherwise it can throw null errors

hoary otter
#

hey i got a problem, in my Spawn.java i got a "spawn" variable and i want to use it in my Listener.java so how do I do ?

unkempt peak
#

Pass it into your Listener constructor

smoky oak
#

i found this code snippet online

 try{
            PreparedStatement ps = connection.prepareStatement("SELECT * FROM " + table + " WHERE playerUUID = ?");
            ResultSet rs = ps.executeQuery();
            close(ps,rs);
        }
```but where does the argument for the statement come from? There's nothing passed to it, so how does it find the UUID?
lost matrix
#

Yeah, dont do that. Thats not what he needs.

undone axleBOT
lost matrix
#

Read this

unkempt peak
#

What is Spawn.java? you should instantiate it onEnable and pass it into your Listener

smoky oak
tardy delta
#

they never set the uuid

undone yarrow
#

?paste

undone axleBOT
undone yarrow
#

Again

#

that error

#

It just keeps appearing

#

every single time

smoky oak
#

so it just doesnt work

#

uuuuurgh

undone yarrow
#

Everything works apart from the particles

hybrid turret
#

i wanna override the /kill-command for custom messages and everything works fine when in survival but in creative it doesn't play the little screen jiggle for taking damage (which it does with the normal /kill-command) and it's freaking me out. Does someone know how to fix that?

eternal oxide
#

ParticleHandler.java:57

undone yarrow
#

the return

#

so that must return null huh?

eternal oxide
#

it means that Loc does not exist in the Map

undone yarrow
#

oh

smoky oak
#

@tardy delta do u recon the purpose of that is to check if the field is present and spit out an error if not?

eternal oxide
#

Did you normalize it before checking?

undone yarrow
eternal oxide
#

is the loc you pass to CHeckLock a normalized location?

undone yarrow
hoary otter
undone yarrow
#

good spot lol

unkempt peak
tawdry echo
#

At first get chestobject and if is null return false else return chestobject#islootted

undone yarrow
#

Round it

unkempt peak
#

it floors an int

hoary otter
# unkempt peak Can you send the spawn class and your onEnable?

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String str, String[] args) {
        if(str.equalsIgnoreCase("spawn")) {
            if(sender instanceof Player) {
                Player player = (Player) sender;
                Spawn spawnClass = new Spawn();
                Location spawn = new Location(Bukkit.getWorld("world"),0,1000,0);
                player.teleport(spawn);
        }
    }
        return false;
    }
}```
undone yarrow
#

If I change a plugin in my plugin folder, and type /reload whilst keeping the server online when changing the plugin folder, will it reload the plugin folder?

#

oh ok

unkempt peak
# undone yarrow Round it

It doesn't round it floors, which is basically like removing the decimal. It takes a float and always rounds down to the nearest int.

lost matrix
undone yarrow
#

isnt that bad though

#

because it can change the block I specified

#

Or not?

#

wait no it wont do that

hoary otter
unkempt peak
#

Yep

hybrid turret
#

or 1.99 to 1.0

smoky oak
#

like i said 2015

#

all other spigot posts refer to a library

unkempt peak
#

The opposite would be ceil (ceiling) which would make 1.33 2

undone yarrow
tardy delta
#

man just forgot or smth

unkempt peak
unkempt peak
hoary otter
#

i am trying to take the variable spawn and use it on another file

unkempt peak
#

So your question is just how to reference a variable in another class?

hybrid turret
#

getter?

unkempt peak
#

First off, you should not be creating Spawn in your onCommand unless you need a defferent version of Spawn for every command execution. Variables like that should be declared at the top of the class. And if you want to use the same instance of Spawn in multipole classes put it in your main class and pass it into your other classes.

#

If you for some reason want/need the variable to be initialized in your CommandExecutor class then make a getter and pass a reference of your CommandExecutor class to the other classes you want to use it in.

hoary otter
#

oh ok

regal scaffold
#

Ummm

#

My intelliJ suddenly doesn't have a maven menu

#

tf

#

How do I get it back

hoary otter
unkempt peak
#

Initialize Spawn in your onEnable and pass it into the command executor classes that you want to use it in

coral kelp
#

Anyone want to be a developer for me must be really experienced for coding and scripting.

coral kelp
onyx fjord
#

?services

undone axleBOT
coral kelp
#

thanks!

unkempt peak
regal scaffold
coral kelp
unkempt peak
regal scaffold
#

It's actually gradle not maven

#

No clue why it's just not there

charred blaze
#

can i pass instance like this?:
public static Duels plugin;
public GUIManager(Duels plugin) {
GUIManager.plugin = plugin;
}

charred blaze
hoary otter
regal scaffold
#
    public static Duels plugin;
    public GUIManager(Duels plugin) {
        this.plugin = plugin;
    }
regal scaffold
#

Yeah

#

But why make duels static

#

The idea of that is that you can have an instance of it

#

Remove static

charred blaze
#

because the method i use it in is static

regal scaffold
#

Then fix it

#

Because it shouldn't be static

#

The correct way is

unkempt peak
charred blaze
#

but then how do i access the method from other classes?

regal scaffold
#
    private final Duels plugin;
    public GUIManager(Duels plugin) {
        this.plugin = plugin;
    }
#

You pass an instance

#

To each class you need

#

Exactly how you just did

charred blaze
unkempt peak
#

Why do so many people struggle with this... smh

regal scaffold
#

Remember that every time you call a new MyClass() the constructor gets called

#

?paste @charred blaze code

undone axleBOT
unkempt peak
#

Everyone please read this

#

?di

undone axleBOT
regal scaffold
#

xd

#

They will never read that

unkempt peak
#

If you want help, then use the resources that have been given to you.

undone yarrow
charred blaze
regal scaffold
#

No

#

Close

#

Really close

#

you almost got it

charred blaze
#

so how

regal scaffold
#

Show me your project structure

#

Like a image

#

Ok so

#

All you do

#

I assume

#

You want to be able to use GUIManager

#

From a command, correct?

charred blaze
regal scaffold
#

Duels.java


GUIManager manager;

public void onEnable() {

  this.manager = new GUIManager(this);
  getCommand("duel").setExecutor(new DuelCommand(this, manager));
}

DuelCommand.java


GUIManager manager;

public GUIManager(Duels plugin, GUIManager manager) {
  this.plugin = plugin;
  this.manager = manager;
}

#

I didn't use an ide so might be typo

#

@charred blaze

#

No

#

Literally point 2 in Dependency injection

unkempt peak
#

God no

regal scaffold
#

lol

charred blaze
regal scaffold
#

What I sent is the most used by far, it's the most correct method

regal scaffold
unkempt peak
#

Seriously everyone in this channel right now needs to read this, PLEASE

charred blaze
#

so what

unkempt peak
#

?di

undone axleBOT
regal scaffold
#

Greened you asked how to do it. I provided you with the best way

regal scaffold
#

?di @quaint mantle

undone axleBOT
regal scaffold
#

Doesn't matter if you need 1 or 10 instances, di

unkempt peak
unkempt peak
undone yarrow
#

Ahh alright

regal scaffold
#

However an unjustified reason to use a static singleton would be if your system is only ever going to need one instance of a class.

#

Why not use object oriented programming in a language that's object oriented... w/e

charred blaze
regal scaffold
undone yarrow
#

then translate the page

unkempt peak
#

What's your native langauge?

regal scaffold
#

You will understand once it works, just see what it does

charred blaze
unkempt peak
#

?di

undone axleBOT
charred blaze
#

in my code?

regal scaffold
#

?di

undone axleBOT
regal scaffold
#

?di

undone axleBOT
unkempt peak
#

?di

undone axleBOT
regal scaffold
#

?di

undone axleBOT
unkempt peak
#

Everything you need to know is right there

regal scaffold
#

Doesn't seem like it, I suggest reading over ?di

#

?di

undone axleBOT
charred blaze
#

didnt you

unkempt peak
#

Yeah maybe you should read ?di

#

?di

undone axleBOT
regal scaffold
regal scaffold
undone yarrow
#

I found that chatgpt is usually better at explaining things like this. I usually use this server for when AI doesnt know it

regal scaffold
#

Because that's how object oriented programming works

unkempt peak
#

I can, It's quite simple. But i don't need to when someone has already written a very clear article on it that you refuse to read

#

Ok, explain it then

undone yarrow
#

Tell me your question exactly

regal scaffold
#

He's just upset

#

At nothing

undone yarrow
#

because now all of you are just wasting time

regal scaffold
#

I gave up at this point

#

So I've just been spamming di cause he took it personal

#

?di

undone axleBOT
regal scaffold
#

However an unjustified reason to use a static singleton would be if your system is only ever going to need one instance of a class.

#

Can this guy not read?

#

W/e just blocked him cba just flooding the channel while refusing to read

#

?di

undone axleBOT
unkempt peak
#

Static on the other hand is not object-oriented and is in Java a way to declare things as global. While it may seem handy at first being able to use something like MyPluginDataManager.getInstance() all over your classes, it will also leave some devastating issues. Any class which directly relies on that static singleton will be tightly coupled to that instance of which the static singleton returns. This is inherently bad as it will be difficult to unit test an instance of that class, since we will inherently test the static singleton as well. Secondly, we will not be able to reuse the class for another MyPluginDataManager instance. Thirdly, by using a static singleton you have complexified your code architecture.

charred blaze
unkempt peak
#

I do, seems like you don't actually understand how to read
😦

regal scaffold
unkempt peak
#

Ok I'm out guys, there is no hope for you

regal scaffold
charred blaze
regal scaffold
#
GUIManager manager; <--------------- this 

public void onEnable() {

  this.manager = new GUIManager(this);
  getCommand("duel").setExecutor(new DuelCommand(this, manager));
}
charred blaze
#

i know i know

regal scaffold
#

You can but then when you need it in a different command

#

You won't be able to pass the same

charred blaze
regal scaffold
#

And you don't want to make different instances for that

#

I did

#

I said, you want to keep an instance of GUIManager in your main class. and pass that as a parameter to each class that you will need to use it from

#

So you can pass it to other classes that you will need

charred blaze
#

IO? wdym

#

ah

regal scaffold
#

mb was answering the guy about ?di

charred blaze
regal scaffold
#

Because there's a different between english talk and java talk

#

Of course I could say bad, but just saying "it's bad" isn't an explanation

charred blaze
#

"why?"

rotund ravine
#

I disagree that the GUIManager should be singleton. Singleton is a bad design pattern that has many drawbacks and disadvantages.
Some of them are:

Singleton violates the single responsibility principle by controlling its own creation and lifecycle.
Singleton introduces global state and tight coupling, making the code hard to test and maintain.
Singleton can cause concurrency issues and memory leaks if not implemented carefully.
Singleton can break modularity and scalability, especially in a distributed or clustered environment.

Instead of using singleton, I would suggest using dependency injection or service locator to manage the GUIManager instance.

These patterns allow you to decouple the GUIManager from its clients and control its scope and lifecycle more easily. They also make your code more testable and flexible.

regal scaffold
#

Are you gonna keep complaining or is your question answered? Yes it's bad

#

Jan

#

Give up

charred blaze
#

whats going on here

regal scaffold
#

He's been going at it for 15 minutes

charred blaze
#

why did i even ask for support xd

#

sorry guys

rotund ravine
hybrid spoke
#

singleton LUL

regal scaffold
#

xd

charred blaze
hybrid spoke
#

rather make it static

charred blaze
#

how do i turn it on

unkempt peak
hybrid spoke
undone axleBOT
regal scaffold
#

I mean that guy was so committed to using a singleton lol

undone yarrow
rotund ravine
regal scaffold
#

Bro there was no point

#

He just doesn't understand

#

I wish I didn't get the option to "show message"

hybrid spoke
#

a singleton doesnt fail. a singleton is just a bad design you should dodge whereever you can.

regal scaffold
#

Cipher

#

Give up lol

#

It's been about 16 minutes now

#

He won't drop singleton

rotund ravine
#

I disagree that most of the reasons are on a large scale. They can affect any application that uses singleton, regardless of its size or complexity. For example:

Singleton can violate the single responsibility principle even in a small project, making the code less cohesive and more coupled.

Singleton can introduce global state and tight coupling even in a simple application, making the code hard to test and maintain.

Singleton can cause concurrency issues and memory leaks even in a single-threaded environment, if the singleton object is not thread-safe or has references to other objects that are not properly released.

Singleton can break modularity and scalability even in a standalone application, if the singleton object depends on external resources or configurations that are not consistent across different environments.

Just because it can fail doesn’t mean it will is not a good justification for using singleton. Anything can break if not implemented correctly anyways is also not a valid argument. It implies that we should ignore good design principles and practices and rely on luck or trial-and-error. That’s not how we write reliable and maintainable software. We should always strive to use the best patterns and techniques for our problems, and avoid those that have proven to be problematic or harmful. Singleton is one of those patterns that should be avoided as much as possible.

charred blaze
hybrid spoke
rotund ravine
charred blaze
#

opt? wdym

charred blaze
#

lmao

rotund ravine
young knoll
#

People use edge?

charred blaze
rotund ravine
#

and click the bing icon

#

then opt in

#

join the waitlist

charred blaze
#

and itll enable the AI?

rotund ravine
#

No

#

you'll be on a waitlist

charred blaze
#

why

unkempt peak
regal scaffold
#

xd

rotund ravine
#

Cause it's still a dev feature

unkempt peak
#

Not sure exactly how that's going to work

hybrid spoke
#

who?

regal scaffold
#

Microsoft put in so much money into it

#

Soon it'll beat everything else

#

Just wait

hybrid spoke
#

so it will be chatgpt vs bing

regal scaffold
#

bing gonna destroy

rotund ravine
#

no?

#

bing is chatgpt

charred blaze
regal scaffold
#

Not for long

hybrid spoke
regal scaffold
#

Remember microsoft bought OpenAI

#

10bil invested

rotund ravine
#

^^

charred blaze
unkempt peak
#

Microsoft invested like 10b in OpenAI

rotund ravine
#

Microsoft is a partner to openai

#

obviously they are using chatgpt

regal scaffold
#

Well yeah obviously

rotund ravine
#

though a model that can search the net.

regal scaffold
#

mb I worded wrong

young knoll
#

Does that mean they’ll add chatgpt to minecraft

regal scaffold
#

To do what?

unkempt peak
#

Yoo

rotund ravine
#

maybe

#

probably not

regal scaffold
#

No use for it probably

hybrid spoke
#

chatgpt plugin when

young knoll
#

ChatGPT for mob ai

unkempt peak
#

new random feature coming to 1.20??

young knoll
#

Don’t question it

hybrid spoke
#

live modding with chatgpt could be cool

#

"add fancy particles to it"

regal scaffold
#

Jan does spigot start working on 1.20 before release?

#

Do we know what we're getting in NMS and spigot?

#

As in new

young knoll
#

Well you get NMS right away

#

Since you know

regal scaffold
#

I mean, new stuff

young knoll
#

It’s just minecraft

regal scaffold
#

I wonder what we can do in 1.20 that we can't do rn

unkempt peak
#

Can't you technically look at nms for the snapshots?

tardy delta
young knoll
#

Yes

regal scaffold
#

rip chatgpt

#

And yes you can

undone yarrow
#

I think chatsonic can do it for you

unkempt peak
#

It would just be without mappings

undone yarrow
#

chatsonic uses more recent data

#

but Im not sure how well chatsonic is at coding

rotund ravine
#

Singleton is bad not only because it introduces a global state, but also because it violates other design principles and practices. People are not scared of a global state, they are aware of its drawbacks and risks. Some of them are:

Global state makes the code less predictable and more prone to errors, as any part of the code can change or access the state without any control or restriction.

Global state makes the code less testable and maintainable, as it introduces hidden dependencies and side effects that are hard to isolate and mock.

Global state makes the code less reusable and extensible, as it creates tight coupling between the singleton object and its clients, making them hard to replace or modify.

#

Just because it can doesn’t mean it will is not a good justification for using singleton. It implies that we should ignore good design principles and practices and rely on luck or trial-and-error. That’s not how we write reliable and maintainable software. We should always strive to use the best patterns and techniques for our problems, and avoid those that have proven to be problematic or harmful. Singleton is one of those patterns that should be avoided as much as possible.

I’d like to disagree with the modularity and scalability as well due to that not having anything to do with the pattern rather or how it’s implemented is also not a valid argument. It implies that we can implement singleton in a way that does not affect modularity and scalability. However, that’s very unlikely or impossible in most cases. Some examples are:

Singleton can affect modularity if the singleton object depends on external resources or configurations that are not consistent across different environments. For example, if the singleton object connects to a database or a web service, it may break if the connection parameters change or if the service is unavailable.

Singleton can affect scalability if the singleton object is not thread-safe or has references to other objects that are not properly released. For example, if the singleton object holds a lock or a cache, it may cause concurrency issues or memory leaks if multiple threads access or modify it concurrently.

Therefore, using singleton can have negative impacts on modularity and scalability regardless of how it’s implemented.

regal scaffold
#

Good old no mapping nms days

#

?di

undone axleBOT
unkempt peak
#

?di

undone axleBOT
charred blaze
#

?di

undone axleBOT
undone yarrow
#

bruh

young knoll
#

You can remap the snapshot jars

regal scaffold
#

I have him blocked but jan still going at it

hybrid spoke
regal scaffold
#

xd

rotund ravine
#

Hahah

#

Zaken gave up

#

he went to the "oh so u don't agree, so it's bad"

regal scaffold
#

Jan

#

It's been 20 minutes

#

I hope he gave up...

unkempt peak
#

zacken just take the L man...

regal scaffold
#

Jan you working on any projects rn?

hoary otter
#

guys I can use a variable in another file when I initialize it in the top of a class but when I initialize it in onEnable() i cant use it

rotund ravine
charred blaze
#

which one is to use?

rotund ravine
charred blaze
#

shaded?

#

how do i config it like to replace it

#

?

coral kelp
#

Can anyone help me sort server plugins, Featherboard, Tab, And Oraxen I need help working with them and also to add prefix tags such as oraxen better prefixes are in the files to!

unkempt peak
tardy delta
#

lemme guess, i gotta handle a few thousand files more

undone yarrow
#

So I have this code that lets me add a block to a list, that adds particles to it and makes it "lootable" (with a cooldown). Thing is, I want to give players a random item when they right click it. The random items are specified when using the /sc add command:

switch (args[0]) {
            case "add" -> {
                if (args.length == 4) {
                    // convert args[1] to particle
                    Particle particle = Particle.valueOf(args[1].toUpperCase());
                    // convert args[2] to int
                    int cooldown = Integer.parseInt(args[2]);
                    // convert args[3] to List<ItemStack>
                    List<ItemStack> items = new ArrayList<>();

                    ChestObject chest = new ChestObject(false, blockLoc, particle, cooldown, items);
                    pHandler.AddLoc(chest, sender);
                    return true;
                }
                sender.sendMessage(ChatColor.RED + "Incorrect usage! Simply look at the block you want to add.");
                return true;
            }``` 
My question is, how do you type in the items in-game? 
Using /sc add EXPLOSION 10 sand,grass doesn't work
/sc add EXPLOSION 10 sand, grass also doesnt work, so what does?
#

How can you fill in multiple items (ItemStack) in a command

#
 private final List<ItemStack> items;```
icy beacon
#

place your bets, will it do it

rotund ravine
#

lel

icy beacon
#

eh not exactly

tardy delta
#

ew

young knoll
icy beacon
#

let's torture it

unkempt peak
icy beacon
#

it actually sorta did it

#

idk

#

"you'll do this yourself"

unkempt peak
#

lol I actually got it to make a fully functional plugin after enough iterations. It was horribly coded, but functional. It's actually pretty cool to see how it combines what it knows in a new context. Some of it's solutions for things are so different than what I would come up with

icy beacon
#

yeah that's what i wanted to see

icy beacon
charred blaze
#

whats wrong with this code

unkempt peak
#

You need to add a null check for "org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem()"

charred blaze
#

have it

#

look in the screen

unkempt peak
#

Send it in a code block or pastebin

charred blaze
#

you mean whole click event?

echo basalt
#

oh hell naw

unkempt peak
#

wtf is this boolean isBowEnabled = true; boolean isTotemEnabled = true; boolean isGPEnabled = true; boolean isNotchEnabled = true; boolean isPotionsEnabled = true; boolean isShieldsEnabled = true;

undone yarrow
#

Is that what you meant

hybrid spoke
#

all of this is scuffed

charred blaze
#

its returning the same value everytime

#

its in my todo

#

ill re code it

hybrid spoke
#

your booleans will always be true

#

your displaynames never set

charred blaze
charred blaze
hybrid spoke
#

you just get a new meta, edit it and throw it away

charred blaze
#

oh right

hybrid spoke
#

also switch exists

#

this is a bunch of boilerplate

#

and never check the inv by the title

unkempt peak
#

Good god it just gets worse the more you look at it

undone yarrow
#

what does

unkempt peak
#

I'm sorry but i think you need to just start from the beginning lmao

charred blaze
#

does .getSlot start from 0?

kind hatch
#

Yes

unkempt peak
#

yes

#

It's an array.

kind hatch
#

All arrays start at 0

echo basalt
#

still bad

#

and won't work, too

charred blaze
echo basalt
#

this is the fun part

#

figure it out ;)

charred blaze
#

you mean

#

variables?

#

is enabled ones?

#

i already know about them

#

its in my todo list

echo basalt
#

Perhaps

#

I already gave you a properly efficient gui tutorial

unkempt peak
echo basalt
#

your current structure isn't really scalable

smoky oak
#

Could someone who knows sql translate this please?

<stack trace here>```
code:
```java
Statement s = connection.createStatement();
s.executeUpdate(CreateIfNotPresentStatement);//<Error here

the statement is

CREATE TABLE IF NOT EXISTS "+table+" (" +
"playerUUID CHAR(36) NOT NULL," +
"number INT NOT NULL" +
"inventory BLOB NOT NULL" +
"PRIMARY KEY (playerUUID)" +
"CONSTRAINT vConstraint UNIQUE (playerUUID, vaultNumber));"
#

wait

kind hatch
#

Put a space at the end of your strings to ensure that when they get concatenated, you aren't joining words accidentally.

charred blaze
#

what about this one

smoky oak
#

alright it wasnt the not anymore existing slotNumber one

charred blaze
#

please read it someone

tardy delta
#

hmm if i needed a hashmap with always 379 elements, would i use new HashMap<>(379, 1) or not?

smoky oak
#

it now says inventory instead of NULLinventory

regal scaffold
#

I can't see a gradle menu in my IntelliJ ide

#

I've already restarted

smoky oak
#

stack trace still points to the executeUpdate line

regal scaffold
charred blaze
kind hatch
coral kelp
#

Anyone know how to make a rainbow text like this into a hex code?

smoky oak
vast raven
# vast raven

When trying to place the head, somehow it doesn't fill the gap between the block

#

Any ideas?

kind hatch
charred blaze
coral kelp
charred blaze
coral kelp
charred blaze
#

no

tardy delta
kind hatch
coral kelp
regal scaffold
#

Do not use anything from maxmvdw

coral kelp
smoky oak
kind hatch
smoky oak
#

for context

vast raven
regal scaffold
#

Inactive, doesn't develop anymore

charred blaze
#

[17:02:38 ERROR]: Could not pass event InventoryClickEvent to Duels v1.0-SNAPSHOT
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem()" is null

#

still the same issue

#

someone help

smoky oak
#

im using sqlite so that i dont stuff megabytes of inventory information into PDC which is the easier to code but REALLY stupid solution

tardy delta
charred blaze
#

i already got check of getCurrentItem() is null

smoky oak
#

but issue is i dont know how sql works

unkempt peak
coral kelp
tardy delta
regal scaffold
#

XD

vast raven
unkempt peak
#

You want a map with exectly 379 elements right?

smoky oak
#

so im not sure what that guy thinks either

regal scaffold
#

final does not do that

#

Read on final...

smoky oak
#

alright heres what final does

charred blaze
#

fixed. it was pointing to other class im dumb

smoky oak
#

it says 'object may only be INITIALIZED once'

regal scaffold
#

@tardy delta Collections.unmodifiableList(synapses);

smoky oak
#

and since a map doesnt reinitialize when methods of it are called

#

final maps can still be modified

#

just not remade entirely

regal scaffold
#

^

#

yES

unkempt peak
#

Wait really?

regal scaffold
#

Yes of course

#

That's what final means

kind hatch
tardy delta
#

well if i set the init capactiry to 379 and the load factor to 1, wont it have enough space for 379 elements and it will resize the moment you add one more?

charred blaze
tardy delta
#

well that should work then

regal scaffold
#

@tardy delta Collections.unmodifiableList(synapses);

#

Do you need to change the contents?

tardy delta
#

what are you on

#

need an add impl

kind hatch
tardy delta
#

im clearly not understanding what the load factor is then

regal scaffold
#

I might be wrong

kind hatch
# tardy delta im clearly not understanding what the load factor is then

The load factor is a measure of how full the hash table is allowed to get before its capacity is automatically increased. When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the hash table is rehashed (that is, internal data structures are rebuilt) so that the hash table has approximately twice the number of buckets.

Taken straight from the docs.

tardy delta
#

how full as in the size?

kind hatch
#

Yes

#

It's basically this.

if list size is greater than threshold
  increase hashmap capacity
quiet ice
#

full as in elements it contains versus the buck size (i.e. the elements it supports without resizing)

tardy delta
#

ah A loadFactor of 1.0f means "don't grow until the HashMap is 100% full

#

couldnt i use that?

#

new HashMap<>(379, 1f)?

quiet ice
kind hatch
# tardy delta new HashMap<>(379, 1f)?

Yea, but that wouldn't limit it to only 379 elements. It would just have the initial capacity for 379 elements reserved.
You'd still be able to add and remove like normal.

quiet ice
#

so new HashMap<>(380, 1F)

crimson mulch
#

Okay ! (This is gradle stuff, so if you've never used gradle please pass your way)

So I try to create a "parent module" which will use sub modules (depend on the server version), but I can't compile correctly !

So here's my structure
RisenCore (parent module)

  • src (parent src with all the stuff no depend on the child modules)
  • build.gradle
  • module1
    • build.gradle (dependence on parent module)
  • module2
    • build.gradle (dependence on parent module)

So I want to compile all that stuff in a single jar file.

But when I compile with the jar task from the parent build.gradle it compile only the "parent", I would like to compile the whole stuff

So here's my 3 build.gradle
(parent)

plugins {
    id 'java'
}

group 'net.krisp'
version '1.0.0'

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    compileOnly 'org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT'
}


setLibsDirName("../exports")

module1

plugins {
    id 'java'
}

group 'net.krisp'
version '1.0.0'

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    implementation project(path: ':')
    compileOnly 'org.spigotmc:spigot:1.8-R0.1-SNAPSHOT'
}

module2

plugins {
    id 'java'
}

group 'net.krisp'
version '1.0.0'

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    implementation project(path: ':')
    compileOnly 'org.spigotmc:spigot:1.8.3-R0.1-SNAPSHOT'
}

Thanks again for reading 😭

undone axleBOT
quiet ice
#

myeah - paste may be premature here

crimson mulch
#

Calm down, don't need paste, It's like 2 line block code

quiet ice
#

That is also premature deoptimisation here

quiet ice
kind hatch
# tardy delta couldnt i use that?

Can you clarify a little more? Is this list supposed to be able to add and remove elements like normal or is it only ever going to hold 379 elements and do nothing else?

quiet ice
#

Or are the submodules more or less independent of each other?

crimson mulch
#

include 'module1'

#

include 'module2'

quiet ice
#

That sounds right

crimson mulch
regal scaffold
#

I believe he said, set the elements and then readonly

coral kelp
#

Can anyone make a Dynamic rainbow text into a hex code?

tardy delta
quiet ice
#

he just wants to optimize his map

tardy delta
#

so ye ig (380, 1) will do the work

regal scaffold
#

Fourteen, make a hasmap, populate it then create another unmodifiable or immutable hashmap with the contents of the first

quiet ice
#

By making it only hold a given number of elements.
Of course that is not clear but it is ultimately what they want

crimson mulch
quiet ice
#

Collections#unmodifiableMap is just a wrapper

tardy delta
regal scaffold
#

ImmutableMap

quiet ice
#

there kinda is but just as a wrapper

quiet ice
#

Collections#unmodifableMap

#

Collections.unmodifableMap(new HashMap<>(x)) to be more exact

#

that being said you have a minimal performance overhead from doing so

tardy delta
#

does it matter?

#

you

#

unmodifiablemap just wraps the source map iirc

#

ah i never use imutable maps

twilit roost
#

how do I know that Player clicked the result item in Anvil?

regal scaffold
#

I think

#

Pretty sure most anvil stuff is nms based

lament swallow
#

can BaseComponents have custom colors?

#

or TextComponents