#help-development

1 messages · Page 462 of 1

lost matrix
#

Because setStorm fires the WeatherChangeEvent again
resulting in an infinite loop

wet breach
#

Maybe it is just a language you dont quite grasp like some others.

#

Nothing wrong with that

frank kettle
#

Wrong way of doing it

tall dragon
#

u just need to cancel the wheather change

#

it implements cancellable

tawny pine
#

Wait are you using path tracing?

wet breach
#

Unless your complaint is with boiler plate code with c++

#

In which case you can tailor your ide to handle most of that lmao

young knoll
#

Can’t you just disable weather with a gamerule now

lost matrix
# wet breach Maybe it is just a language you dont quite grasp like some others.

Ive learned everything to C17 in uni for 2 years. Ive written games, a database, website backends
and machine learning applications with it. I think i have a pretty decent understanding of the
language and i can confidently say that writing C++ is the worst experience i had with any
programming language so far. And dont get me started with CMake. Absolutely abysmal.

wet breach
#

Lol

lost matrix
#

Rust is literally a superior language

wet breach
#

No, rust doesnt run hardware or os's

young knoll
#

Can’t wait for them to release C—

tardy delta
#

i cant really get used to the structs and impl blocks lol

#

impl blocks everywhere

wet breach
#

Cant call something superior when it doesnt do what c++ does. I agree that it might be better when you dont quite need a language like c++ but to say it is superior is not quite right either

lost matrix
quaint mantle
#

anyone got some example source code for custom block drops i cant find any

lost matrix
#

And writing an OS with a language doesnt make it good

wet breach
#

Not sure what drivers you are talking about, but it is a mixture of C and C++

#

C++ however can load c libs but c cant load c++

lost matrix
quaint mantle
#

well i just so happend to fnd this

chrome beacon
#

Or you can use a datapack uwu

wet breach
quaint mantle
#

i wanna know how to use trhat

lost matrix
#

And even if C++ was pleasent to write, CMake catapults it right back

tardy delta
#

oh now i know whats waiting for me

lost matrix
wet breach
#

Java os was great for anything java

#

And you dont have to use cmake

lost matrix
#

There arent any good build systems for C++
Only Cmake and some abominations nobody uses or
which havent been updated since 1996

wet breach
#

There is alternatives like gnu make, apache buildr, apache ant, automake

#

All of those are maintained that i listed

#

Maybe not apache buildr would have to check when i get home, but the others are.

lost matrix
#

By all means, write C++ if you want to. But its dead to me. I would rather
write in any other language unless im writing some ultra low-level applications
or embedded code. Well even for embedded id use Rust.

brisk estuary
#

It's a dumb question, but I should use equals() to check if two inventories are the same, right?

lost matrix
#

For what purpose? This would trigger every tick.

young knoll
#

/gamerule doDaylightCycle false

tall dragon
brisk estuary
#

thanks

tall dragon
#

only gets triggered for stuff like all players tho

#

when it jumps to day

lost matrix
tawny pine
#

in bukkit how do I set a parameter to null? do i just leave it blank or write "null" or what?

young knoll
#

If you want always day just use the gamerule

tawny pine
#

ah ok thanks 😉

lost matrix
#

If you have to do that then you are doing something wrong

tawny pine
#

wrong emoji

#

🙂

#

😄

tardy delta
#

😏

wet breach
#

So cant say it is wrong when the implementation is the one that is wrong

young knoll
#

Bukkit makes it clear what is nullable

lost matrix
#

There should never be something on your heap that needs to be set to null...

wet breach
#

Sure i agree, doesnt change the implementation expectations

languid radish
#

How to enable fly on spigot server

languid radish
#

Ok

lost matrix
wet breach
#

Lol

tardy delta
#

i thought are we getting into stack and heap now

nocturne steppe
#

@eternal oxide help since i did your thing i can't look at bukkit/spigot's file without using intellij's decompiler
ping me when you respond ❤️

tall dragon
#

@lost matrix how do u handle stuff that can be empty tho, using Optional<> ?

wet breach
#

Very carefully

lost matrix
tall dragon
#

i usually allow null as well tbh

#

and handle it appropiately

tardy delta
#

the billion dollar mistake 🙏

lost matrix
young knoll
#

If my code was worth a billion dollars I wouldn’t have to worry about null ever again

tardy delta
#

where woiuld they be otherwise?

lost matrix
#

stack

tawny pine
#

Guys I'm using the code:
meta.hasChargedProjectiles().equals){
but equals "cannot be resolved".
I'm trying to get it to be .equals(true).
Where did I go wrong and how should I fix this?

tardy delta
#

i clearly havent learnt good enough

tender shard
#

if(meta.hasChargedProjectils())

#

or if(meta.hasChargedProjectiles() == true)

#

it returns a boolean (primitive)

#

?learnjava

undone axleBOT
tawny pine
#

ah ok ty 🙂

young knoll
mighty pier
#

wtf

tardy delta
#

my classmates code like that

tardy delta
tall dragon
#

if ((meta.hasChargedProjectiles() == true) ? true : false) better <

tardy delta
#

im confused lol

young knoll
lost matrix
tardy delta
#

objects are on the heap but objects consists of primitives which are on the stack again 🤔

#

i have no idea what im saying

mighty pier
lost matrix
tall dragon
#

id lost it

#

i need some laughing in my life rn

lost matrix
tardy delta
#

just too late

lost matrix
#

Im even a proud contributor of this.
Laughed so hard when pushing my PR

tardy delta
tall dragon
#

the best thing are the comments actually trying to justify everything

#

so fking funny

mighty pier
#

its actually a style of programming, please do not harass the author

tender shard
tardy delta
#

best random

lost matrix
tall dragon
#

lmfaoooo

tardy delta
lost matrix
#

I love the comments

tender shard
#
try {
  throw new RuntimeException("Something went not really wrong");
} catch (RuntimeException ex) {
  if(ex.getMessage().equals("Something went not really wrong")) {
    // All good
  } else {
    throw ex;
  }
}
tall dragon
#

yea the comments are so good

tardy delta
#

reminds me of someone who can barely speak english but when he does it sounds funny

tall dragon
tardy delta
#

realizing all plugins can do that 💀

dense geyser
#

what does HandlerList#bake do? the javadoc says it bakes a handlerlist which is not the most helpful of things

young knoll
#

I do like the sql storage system they have

lost matrix
#

Why doesnt spigot use this method? It looks better than the current getOnlinePlayers() implementation

  public Stack<Player> getEveryPlayerWhichIsCurrentlyOnlineOnTheServer() {

    Stack<Player> allPlayers_which_arOnline = new Stack<>();

    for (OfflinePlayer player_that_is_not_online : Arrays.stream(Bukkit.getOfflinePlayers()).collect(Collectors.toList())) {
      if (player_that_is_not_online.isOnline()) {
        Player player_that_might_be_online = player_that_is_not_online.getPlayer();
        if (isThisThingReallyOnTheServer((Entity) player_that_might_be_online)) {
          allPlayers_which_arOnline.push(player_that_might_be_online);
        }
      }
    }

    return allPlayers_which_arOnline;
  }
tall dragon
tardy delta
#

😂

lost matrix
granite owl
#

got a question not directly related to spigot, anyhow: do i understand it correctly that i can implement actual new mobs with only a data pack and resource pack?

dense geyser
#

ah alright, thank you

tall dragon
#

any1 tried actually running this plugin?

#

pretty sure it would nuke ur server

young knoll
#

What counts as actual new mobs

tardy delta
#

zombies in disguise

granite owl
young knoll
#

You can do a lot of stuff with display entities

#

Or armorstands if you’re feeling 2022

lost matrix
#

And we can also not add new entity models to the game using resourcepacks.
You will always need some sort of magic to make that happen.

granite owl
lost matrix
tender shard
#

We should stop calling it nms and start calling it slughorn

tardy delta
#

nms not persistent accross restarts uh oh

young knoll
#

What

tender shard
#

„How can i spawn an npc using slughorn“

tardy delta
#

uh no my server is gone

young knoll
#

Where did you come up with slughorn

tender shard
#

„Ugh why are you using slughorn to send action bar messages“

tender shard
tardy delta
#

is that some german thing?

tender shard
#

No its from harry potter 6

tardy delta
#

💀

granite owl
# tardy delta nms not persistent accross restarts uh oh

i mean if i inherit the zombie class to modify its behavior incl pathfinder goals, and then spawn one it behaves as desired, but once i shutdown the server, save the entity and restart the server its going back to the defaulting zombie class

#

maybe i did do it wrong idk

lost matrix
granite owl
#

but from my exp its not persistent by default

tardy delta
#

i have no idea actually

#

havent done much with nms

young knoll
#

Good luck adding new biomes and structures with a plugin

lost matrix
young knoll
#

Well you can

#

But it’s NMS

tardy delta
#

minestom is way funnier

lost matrix
granite owl
#

i havent figured out how to inject my custom mob behavior into the maps that in the end store entity states

young knoll
#

Datapacks are fine for most static features

lost matrix
#

Since we have mojang mappings i find writing nms to be decent

young knoll
#

It’s only functions that start to impact performance

granite owl
#

hm

#

well tbh its been a while

#

i think last time i did custom mob behavior in nms was

#

hmm, 1.15? xD

#

maybe the api changed idk really

paper venture
#

I'm working on lobby and minigames system, I'm making it from scratch. On other servers when you select some lobby or a game you will be put in a new world and in tab you see only players that are currently in the same world. I know that I can do it by managing tab system, but it seems to me it's incorrect... I guess that these servers use bungeecord to separate players, but I don't know exactly...

young knoll
#

Probably

tall dragon
#

probably?

granite owl
tall dragon
#

pretty sure every single self respecting minigame server does it that way

tardy delta
#

isnt that how its supposed to work?

granite owl
#

and since its a minigame, these 20ish players playing their game have no business with the rest 3.9k anyways

wise mesa
#

That’s why it’s annoyed

#

You don’t compile headers just cpp or c files

tardy delta
#

ah

granite owl
wise mesa
#

Should I avoid using the Bukkit class

tardy delta
#

makes sense lmao

granite owl
#

and source files definitions

wise mesa
#

Like the static class that has the same functions as Server

granite owl
#

@tardy delta ud rather do namespace...

extern constexpr int max_class_size;
``` in ur header file
#

and then define it in the same named .cpp file

tardy delta
#

that was the exercice i got

#

and tbh i dont understand what half of those keywords does

granite owl
#

c/c++ is completly different from managed languahes

tardy delta
#

to me it feels like they all do the same

granite owl
#

wdym

#

xD

#

did u #pragma once in ur .cpp file?

#

@tardy delta ^?

hazy parrot
#

You shouldnt have pragma once in cpp

#

As you are not including it

granite owl
#

i think an explanation what it does is more helpful

tardy delta
#

no just in header

hazy parrot
#

Pragma one only include file once by the compiler if its included by user multiple times

tardy delta
#

ik

granite owl
#

#pragma once is a guard clausel to tell the compiler to not include the same header multiple times as this could cause an infinity loop if 2 headers include each other

#

right

hazy parrot
#

Also why not just use Class and static fields for constants, I means it's nearly same as namespace but I guess it would be easier to you as its close to java

tardy flame
#

Is there any way for displaying transparent blocks? Or even a schematic from world edit?

granite owl
#

macros, typedefs, constants

tardy delta
#

imma miss java switch

granite owl
#

why

#

cause u cant pass hashed strings?

#

🤣

#

in a switch statement

tardy delta
#

no need for return

#

or break whatever

granite owl
#

huh

#

i always use break and returns in java for switch statements

hazy parrot
#

Ig he is talking about enhanced switch

#

From java 11 or what

tardy delta
#

ig

#

yes

granite owl
#

if i may ask why r u learning c++?

tardy delta
#

want to learn smth new

granite owl
#

i mean its my personal fav lang xD but

granite owl
tardy delta
#

mmmh

#

that has no classes

granite owl
#

C++ is the same as C but more advanced with classes

#

well yes but the only reason to learn C/C++ is to learn an unmanaged language

hazy parrot
granite owl
#

and c++ has so many abstractions that u can basically use it like java

granite owl
# tardy delta that has no classes

exactly c is more barebone, dont get me wrong i prefer c++ over c by far, but to learn the fundamentals C is better from a didactic pov

quaint mantle
#

i cant export my maven shit it always says acsess denied no matter where

granite owl
#

esp for conditional compiling

hazy parrot
granite owl
#

one should understand as many different methods as possible

#

to have a broad view

hazy parrot
#

It's not strongly typed, you have inlined functions for same purpose

granite owl
#

i do use inline members for my own project

hazy parrot
#

Cpp is somewhere between functional and object oriented

#

That it's why you can do many weird things

granite owl
#

just because something is bad practice in a particular circumstance

#

it doesnt mean its not worth to be known

#

i barely use macros too, but if u really need em its good to be able to

#

and conditional compiling is one such instance in for example ive written cross plattform code thats able to compile from windows and unix plattforms using the same code base by replacing the plattform specific functions and includes with macros @hazy parrot

granite owl
hazy parrot
#

Good to know ig

granite owl
#

if u want i can dm u an example cause i dont want to spam here any more xD

smoky adder
#

@last temple what you explained to me today worked, now it works without making the variable static thanks a lot

hazy parrot
true perch
#

I wrote a static hashmap within the main class which stores some Custom ItemData based on an ID system. Is this good design? It will get referenced throughout the codebase.

/**
 * A HashMap of every item's ItemData.
 *
 * Integer - The number used to represent this item's unique identification.
 * ItemData - All the data associated with 7 Realm's Custom Item system.
 */
public static final HashMap<Integer, ItemData> ITEM_DATA = new HashMap<>();```
lost matrix
#
  1. Dont make it static
  2. Dont make it public
true perch
#

That'd mean I would need access to the main class object throughout the code though, right?

compact haven
#

you’d have a class responsible for sharing that data with proper methods

lost matrix
# true perch That'd mean I would need access to the main class object throughout the code tho...
public class ItemDataManager {
  
  // Never expose the map directly
  private final Map<Integer, ItemData> itemDataMap;
  
  public ItemDataManager() {
    this.itemDataMap = new HashMap<>();
  }
  
  public void addData(ItemData itemData) {
    this.itemDataMap.put(itemData.getId(), itemData);
  }
  
  public ItemData getData(int id) {
    return this.itemDataMap.get(id);
  }
  
  public void removeData(int id) {
    this.itemDataMap.remove(id);
  }
  
}

Something like this. Create one single instance of this class and pass it around.

compact haven
#

^ exposing a hash map is shit api

tardy delta
#

tell that my teacher

#

ill invite you to have a talk to her

granite owl
#

doesnt it only make sense to write a proper wrapper layer if thats gonna be an actual api and not only used by one plugin only

true perch
tardy delta
#

it looks shit to call SomeClass.someMap.get() anywyas

lost matrix
compact haven
#

to be honest I prefer designing the API first and using the API in the implementation, not the other way around

lost matrix
compact haven
#

it does create problems where you can’t do internally unsafe things that you don’t want in the API, but it leads to a better API in the end imo

granite owl
true perch
compact haven
#

my fucking Java code is horrendously beautiful though, I constructor DI each manager that I use instead of the plug-in instance (unless that instance is also needed, then I DI both)

granite owl
#

like i wanted an ini parser i can use in every language, and by now im writing it for 6 months

#

even though it was supposed to be a 2 week project

compact haven
true perch
lost matrix
compact haven
#

it’s called having a manager class for related data and passing that

#

once again, you don’t expose collections it just isn’t proper

granite owl
compact haven
#

correct, that’s dependency injection

granite owl
#

🙏

true perch
#

Alright noted. I feel I've learned a lot about what's proper now thanks guys 😄

#

Haven't learned why though

lost matrix
granite owl
#

basically a copy of a pointer?

tardy delta
#

the value of the reference

#

so just an address

compact haven
#

the reference isn’t duplicated though, the reference is the same for the original object and injected object

lost matrix
granite owl
#

man i prefer the freedom to choose though as to what is passed xD

compact haven
#

Unless there’s two references that point to the same memory address

#

but that doesn’t sound right

lost matrix
tardy delta
#

a reference is just a fancy name for a pointer

granite owl
#

isnt it like

class foo = new foo();//heap allocation

class foo2 = foo;// pointing to the same unmanaged address?

#

and then java wraps it

#

so we dont have direct access to it

lost matrix
cunning pendant
#

should I learn java with spigot or should I learn java before spigot

compact haven
#

new foo() has a reference, and both foo and foo2 have the same reference

lost matrix
tardy delta
#

maybe its better that i dont have a c++ teacher then

eternal oxide
#

learn java basics

granite owl
tardy delta
#

hmm

compact haven
#

Java is pass by value, but the value is the reference unless it’s a primitive

cunning pendant
granite owl
#

like a java reference is not a pointer but it behaves the same

ivory sleet
compact haven
#

there’s no 2 references that point to the same object @lost matrix

#

right?

tardy delta
#

depends what you consider being two same references 🤔

ivory sleet
#

pass by reference is when the language has semantics that allows you to pass semantic variables/references as values

lost matrix
compact haven
#

same reference just in 2 spots

wet breach
wise mesa
#

For-each loops are enhanced for loops

granite owl
wise mesa
#

Pattern matching is enhanced switch

wet breach
granite owl
#

only the new keyword actually allocates heap memory in java

compact haven
#

so yes I’m right 7smile

eternal oxide
#

Should we go with switch 2.0 then?

wise mesa
#

Like everyone else

lost matrix
compact haven
#

the field is still separate, which is why I can reassign foo2 without foo changing at all

ivory sleet
granite owl
#

although thats not entirely true

compact haven
#

but the reference is the same

ivory sleet
#

but u have stuff like the foreign memory api and unsafe

lost matrix
granite owl
#

if u for example increase the size of a map by injecting an entry

#

theres also a heap alloc

#

hence the trim_to_size member

wet breach
ivory sleet
#

tim well lets say ur map entry push causes the map to resize the backing array

wet breach
#

and normal for loops are not bad either

#

if you misuse them sure

ivory sleet
#

then there's a new keyword somewhere to ensure thats happening

compact haven
#

enhanced for: for (X e : z)
for: for (int i=0;i<5;i++)

granite owl
compact haven
#

it’s so fucking hard to type code in a phone with autocorrect

granite owl
#

basicslly just corrected myself cause ik absoloute expressions are rarely valued xd

green prism
#
    public static ItemStack getItemStack(Material material, Component displayName, List<Component> lore, boolean glow) {
        ItemStack itemStack = new ItemStack(material);
        ItemMeta meta = itemStack.getItemMeta();

        meta.setDisplayName(Translate.translate(displayName));
        meta.setLore(Translate.translate(lore));

        if(glow) {
            itemStack.addUnsafeEnchantment(Enchantment.WATER_WORKER, 1);
            meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        }


        itemStack.setItemMeta(meta);
        return itemStack;
    }

Glow is not working is 1.19.4.
Could you please help me?

wet breach
#

the JIT can decide that it should go on the stack memory instead

granite owl
#

yea

ivory sleet
#

well implicitly the bytecode instruction new anewarray multinewarray or newarray is called somewhere @granite owl

#

which is compiled from new

ivory sleet
compact haven
#

for example if I do Sand.test(new Random()), then the instance of Random will go on the stack instead

granite owl
#

and then theres native code

green prism
granite owl
#

where the .dll / .so whatever can return pointers to heap allocated objects

#

which i for example used

#

hence im really annoyed tha java doesnt have actual destructors only autocloseables

wet breach
# granite owl yea

also in more recent Java versions, the new keyword doesn't guarantee any allocation of memory on the heap or stack and the JIT can sometimes optimize it away

granite owl
ivory sleet
#

or no?

compact haven
#

Wait seriously? If I do new Integer(5) it’ll return the pre-made one?

ivory sleet
#

Integer.valueOf maybe

#

but like afaik, by specification all objects go on heap

compact haven
#

well Integer has the first few hundred integers cached

wet breach
ivory sleet
#

ye

wet breach
#

then no allocation is made

compact haven
#

what’s considered optimizable though

granite owl
# ivory sleet or no?

it should go on the heap as new Random() returns a reference to the newly created random and since we dont know how many new randoms it should be the heap

ivory sleet
#

well there's whats called an escape analysis

#

but ye apart from that

tardy delta
#

so arent those on the stack then

#

what have we started lol

ivory sleet
#

primitives live on the stack

granite owl
compact haven
#

oh well yeah it would go on the heap

granite owl
#

in a consequtive array of bytes

compact haven
#

the reference to the object from the heap is on the stack

#

but that’s just how methods are called

granite owl
#

in memory

tardy delta
#

but if the object contains primitives, those are on the stack?

granite owl
#

why do i deserve the clown

wet breach
quaint mantle
#

how do i create blocks with blockdata that i can later use in a event

wet breach
#

when that happens, the objects is slower to work with

#

hence why it is best to optimize for stack size 🙂

compact haven
#

StackOverflowError 😏

granite owl
granite owl
#

🐒

compact haven
#

yes because the stack is too large

wet breach
compact haven
#

^ you can only have Short.MAX_VALUE methods iirc

tawny remnant
#

Any idea how the Midas Staff on skyblock was created?

wet breach
compact haven
#

well it’s intending to allocate past the size

granite owl
#

i like how java is supposed to manage everything for u and in the end to be an effective developer u still need to have a good understanding of how a computer works on hardware level🤣

compact haven
#

yep too small, my bad for the wording

dawn hazel
tawny remnant
#

burh

compact haven
#

it was meant to be too large how I was wording it, but I worded it oddly

tardy delta
#

large guy

compact haven
#

it’s “too large” for the size that’s already allocated

wet breach
tawny pine
#

guys how can i declare variables within an event handler?

granite owl
compact haven
#

having good knowledge of the internals of whatever language you use is most helpful anywhere

wet breach
#

software engineer is the person that should be telling you where something needs to be optimized or needs to be done differently, so that your developers don't need to actually know that stuff

compact haven
#

even though you don’t technically need to know how the JVM works to use Java, it definitely helps a ton 🤷‍♂️

granite owl
wet breach
#

yep especially in the those unique cases where you need to know some specific thing

wet breach
#

for example the endianness of Java. Java stores objects/data in Big Endian format or network order as it is referred to sometimes

tardy delta
granite owl
#

id say learning C for the basics is a really good thing but most ppl whom i suggest that to tell me they dont have time for that

tardy delta
#

lol

#

but they have time to be on discord

tawny pine
#

guys how to declare variable in event handelr?

#

handler*

tawny pine
#

🙂

tardy delta
#

declare a variable bruh

tawny pine
tardy delta
#

show code

wet breach
tawny pine
#

wait dw i think i got it

granite owl
mighty pier
tardy delta
#

so the reference is just the address?

granite owl
#

basically but wrapped

#

in javas fancy i do what i want

tardy delta
#

in java everything is fancy for smth low level

#

thats the hpp file actually

#

💀

granite owl
#

is that a jni header?

#

for type declaration

tardy delta
#

is it?

granite owl
#

must be a rather new iteration since inline members are a c++ 17 standard

true perch
#

Is it good practice to access static methods in this fashion? java public class ItemManager { public static void giveItem(Player player, int id) { ItemData itemData = Realms.ITEM_DATA.get(id); player.getInventory().addItem(itemData.getITEM_STACK()); } }

granite owl
#

well it declares javas primitives in c++

#

ik this type of definition from the jni.h

true perch
tardy delta
#

hmm

#

is ITEM_DATA a collection?

#

then dont

granite owl
#

but i really dont wanna read trough the whole repo to figure the exact purpose

true perch
tardy delta
#

dont expose it

#

pass in the stuff you need

tardy delta
#

or create some itemmanager thing

#

bruh thats the itemmanager

#

whys that map in the realms class and is that the main class?

true perch
#

I'm going to rewrite it don't worry

green prism
true perch
#

Yes, I'm rewriting it sorry xD

ivory sleet
granite owl
#

btw serious question, if i load a native library and store 64bit pointers to functions so to speak function pointers in a long, is it bad practice to do so in private static fields?

ivory sleet
#

but as frostalf said

true perch
ivory sleet
#

jit might do an escape analysis i believe

tardy delta
#

my brain is even more fucked up after reading this conversation

wet breach
#

in most cases yes

granite owl
ivory sleet
#

it can sometimes

#

like class unloading might allow it

#

but thats too arbitrary to rely on

wet breach
wise mesa
#

Set everything to null?

wet breach
#

but you would have to some how unload the class fully and there really isn't a way to check if it happened or if it like half unloaded

granite owl
ivory sleet
granite owl
#

ill post what i mean here once ive written it

#

rn im at the c# importer

#

xD

#

after finishing c, and c++ for both static and dynamic libs

wet breach
ivory sleet
#

indeed

tawny pine
#

Guys I'm trying to update the lore on an item.
I'm trying to get the first word on the first line of it's lore.
How would I do this?

green prism
#

substring

tardy delta
#

getLore().get(0)?

granite owl
#

by seperating the string into an array based on the seperator which is a space?

granite owl
tawny pine
#

Wouldn't that get only the first line?

tardy delta
#

isnt lore a list of strings?

tawny pine
#

I'll try using the substring thingy then

tardy delta
#

line.substring(0, line.indexOf(' '))

granite owl
granite owl
tardy delta
#

dont laugh at me

granite owl
#

no i laugh at my low level approach

tardy delta
#

no need to split whole line

#

performance my friend

granite owl
#

yea ik

tardy delta
#

think about the nanoseconds

granite owl
#

i was more thinking of a ranged for loop iterate each char individually and then memcpy them over

#

xD

tardy delta
#

wtf

tawny pine
twilit roost
#

How can I make Wrappers?
I tried like so:

public abstract class PlayerWrapper implements Player {
    private Menu lastOpenedMenu = null;

    public Crew getCrew(){
        return CrewLedger.getCrew(this);
    }
    public Menu lastOpenedMenu(){
        return lastOpenedMenu;
    }
    public SlotLock getSlotLock(){
        return SlotLock.slotLock(this.getUniqueId());
    }

    public PlayerWrapper lastOpenedMenu(Menu lastOpenedMenu) {
        this.lastOpenedMenu = lastOpenedMenu;
        return this;
    }
}

resulted in error:

Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer cannot be cast to class io.tomko.bonestreasures.wrappers.PlayerWrapper (org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer is in unnamed module of loader java.net.URLClassLoader @45fe3ee3; io.tomko.bonestreasures.wrappers.PlayerWrapper is in unnamed module of loader 'BaT-0.0.1-shaded.jar' @41c2c70)
tardy delta
#

it gets the index of a space

granite owl
tardy delta
#

probably want to look into thr string javadocs

tawny pine
tardy delta
#

indexof('/')?

#

or lastIndexOf whatever u need

granite owl
#

🤔

tawny pine
tardy delta
#

the what

granite owl
#

🤣

tardy delta
#

hmm

round finch
#

what about string . split

#

😄

granite owl
#

ranged for loop?uwu

tawny pine
rotund ravine
tardy delta
#

as the server doesnt give a fuck about your impl

#

well you can

#

but the server will happily keep constructing craftplayers

rotund ravine
#

He just needs to delegate properly

tardy delta
#

yah

rotund ravine
#

Obv he can’t cast it

round finch
#

lore is list

twilit roost
tawny pine
round finch
#

1 sec

tardy delta
#

just a wrapper

tawny pine
#

ok

round finch
#

i mean list

tawny pine
#

ohhhh dw i needed to put .tostring first

#

got it

#

🙂

granite owl
#

is Player a private class?

tardy delta
#

always fun looking at internals , what is this crap bruh

granite owl
#

wait

#

its an interface

#

🐒

granite owl
tawny pine
#

I'm now using meta.setLore((List<String>) Collections.singletonList(meta.getLore().toString().split("/")));
But where should I go from there to get the first half of the string?

granite owl
#

xD

round finch
compact haven
tardy delta
#

brr

tardy delta
#

maybe

compact haven
#

I’ve never seen that actually be used in random Java code before

granite owl
tawny pine
tardy delta
#

who will ever say

twilit roost
tardy delta
#

you forgot the best part bruh

granite owl
compact haven
#

because an empty list is not a null list

#

it’s make sense it’s just odd

granite owl
#

still redundant conditioning. if lore == null then lore = Collections.EmptyList();

and then

this.lore.set

#

please ignore the pseduo before the code

eternal oxide
#

pretty sure EmptyList() is immutable

granite owl
#

🤷‍♀️

twilit roost
tardy delta
#

basically

tawny pine
#

guys i'm using getlore but how can i specify a specific line of lore?

tardy delta
#

its a list

#

find a method to get a specific item of a list

desert tinsel
#

How can you send emotes like these with spigot?

rotund ravine
granite owl
rotund ravine
#

Store it locally

tardy delta
#

resourcepack probably

desert tinsel
#

nope, its normal chat

rotund ravine
#

Then either delegate each function or make a getPlayer method @twilit roost

tawny pine
tardy delta
#

idk if minecraft font supports those characters?

granite owl
#

its like 1000 useless lines of msg and 1 line containing the actual error rest is just where it occured which is so large that it doesnt fit the console

desert tinsel
#

yes, I saw many of them

regal scaffold
#

How to register alias commands in bukkit command system

tardy delta
#

the list is

index 0; first line
index 1; second line
...

tardy delta
granite owl
regal scaffold
#

Oh yeah i just saw it

granite owl
#

in the plugin.yml yes

#

or

#

u inject it directly into the map at runtime

desert tinsel
#

and there are many "emotes" plugins

granite owl
#

i did

#

its a pain in my ass

#

🤣

desert tinsel
#

but I need just to send an emote through a message

tardy delta
#

bruh my brother is cleaning his laptop internals with the vacuum cleaner

granite owl
pseudo hazel
#

pressurized air ftw

granite owl
#

hmm somehow i need a new lappy

tardy delta
#

quick ways to fuck things up

granite owl
# tardy delta throught plugin.yml?

remember my attempt from a year ago to manipulate the command list at runtime by directly accessing the private maps with reflection? yea it worked

#

its nasty but i managed to completly delete vanilla commands at runtime

#

🤣

tardy delta
#

why wouldnt it

granite owl
#

yea but its a nasty hassle

tardy delta
#

i use reflections when i really shouldnt be using it

#

instead of making my field not final, i used reflections to change the internals of some lib i used 💀

granite owl
#

i tried to inherit a zombie class

#

and change its size

tardy delta
#

💀

granite owl
#

which is a private field of like 10 child classes

#

good news is i did manage to change it

#

bad news is server didnt like it and crashed

tardy delta
#

💀

granite owl
#

like actual crash not throwing an exception

#

🤣

granite owl
#

but its a rigid approach and if they change something in their code ur code just goes full nuclear karen

twilit roost
#

What would be the most resource friendly way to check if player holds item and then display action bar if he does

rotund ravine
#

There’s a event for player hotbar switch or smth

pseudo hazel
#

yes but you need to send an action bar message every so often anyways

twilit roost
granite owl
tardy delta
#

isnt java 18+ supposed to use var- and methodhandles for reflection? cant seem to find anything?

twilit roost
pseudo hazel
#

you would probably always have a timer

#

and then just either show the held item or nothing

#

on each timer update

rotund ravine
#

One task that runs over the set

#

Double checks they’re holding the item then display it.

#

On that event add and remove from the set

twilit roost
#

yee just thought of this
imma implement it
thx

granite owl
#

have a recursive bukkit runable

pseudo hazel
#

why double check

granite owl
#

jk

rotund ravine
pseudo hazel
#

you dont even need the event

rotund ravine
#

He asked for a resource friendly way

pseudo hazel
#

yeah, having a single timer is most resource friendly is it not

granite owl
#

isnt it action based = events and state based = ticks?

#

to accurately check for behavior?

pseudo hazel
#

what behaviour

granite owl
#

like if the player takes the item off their hand

#

its an event

#

and to measure the time they helt it

#

its based on ticks

pseudo hazel
#

well yes

#

it would be based of a tasktimer

rotund ravine
pseudo hazel
#

yes but also this set with players

rotund ravine
#

He’s just not looping all players, but all players from the event.

granite owl
rotund ravine
#

Not the way i suggested.

granite owl
#

id prob have a timer per player and only when they hold it for as long as they hold it

granite owl
pseudo hazel
#

no

rotund ravine
#

It’s mostly useless optimizing, but whatever he wants he gets.

granite owl
#

as in the runnable holds a map with players who hold the item

rotund ravine
#

Not a map.

granite owl
#

which is determined by the event

rotund ravine
#

A simple weak set

granite owl
#

that must be thread safe then

#

doesnt it?

#

have a thread safe interface

pseudo hazel
#

for what reason is it not

granite owl
#

isnt a runable a dedicated thread? xD

rotund ravine
#

A weak set does not lock the player interface.

#

He’s using a bukkit tasktimer

granite owl
#

uh

rotund ravine
#

Or should be atleast

granite owl
#

just read quickly trough it

#

a single threaded event called at fixed ticks?

granite owl
rotund ravine
#

Sigh. Yes, it’s a mai. Thread task

#

main*

regal scaffold
#

Is the event called if someone is holding X item and switches off of it

#

Is it InventoryMoveItemEvent?

#

?jd-s

undone axleBOT
regal scaffold
#

:/

pseudo hazel
#

use PlayerItemHeldEvent

rotund ravine
#

👍

regal scaffold
rotund ravine
#

👍

jovial shadow
#

i need help

regal scaffold
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

jovial shadow
#

oh thx

granite owl
#

this is how HR thinks problems are solved xD

jovial shadow
#

im trying to make my own server using spigot but the run.bat file wont open, instead cmd prompt opens saying this: "Error: Unable to access jarfile spigot.jar"

granite owl
#

erm

#

doesnt the spigot server have a version number behind its name

#

u need to use the explicit file name

jovial shadow
#

oh

#

ohhhhh

#

thanks

rotund ravine
jovial shadow
#

oh thanks

granite owl
#

and its correct that the command prompt pops up

#

as u run the JRE from the prompt

tender shard
#

How can people literally not even read the error message lol

compact haven
#

you’re asking for a lot

rotund ravine
#

The average iq is 5

tender shard
#

Sorry

#

You‘re right

compact haven
#

forgiven

regal scaffold
#

How you been alex

#

How you feeling?

granite owl
#

astounding how 4 ppl bash on someone who clearly has never run a server before

#

👍

regal scaffold
tender shard
#

^

granite owl
regal scaffold
#

mb wrong tag, not that deep

#

As a matter fact, the first 4 links

#

Actually, the first 4 pages

granite owl
#

are you telling me how to google

regal scaffold
#

I'm telling the guy that asked the question how to google

#

mb wrong tag, not that deep

granite owl
#

yes he couldve done better, no i do not agree with the SO mentality

tender shard
#

idk I think when people are smart enough to blindly copy/paste some random bat file without knowing what it does nor trying to understand what it does, then they should at least copy/paste the error message they get into google too, instead of heading into a plugin development channel to throw it in there without any further context

river oracle
#

you should never paste code you don't know what it is / or what it does

#

that's how people get hacked

true perch
#

My main class stores a static singleton. This instance of the ItemManager will be heavily used to reference a HashMap found in the singleton. Is this acceptable?

public static final ItemManager ITEM_MANAGER = new ItemManager();```
river oracle
#

?di

undone axleBOT
river oracle
#

however, this could be acceptable

regal scaffold
#

I also like DI more but it's fine

river oracle
#

I'd just switch from a static field to a static method

true perch
#

oh okay. So I'll make the singleton non static and make a static method used to reference the singleton?

tender shard
#

Thats basically the same thing

regal scaffold
#

Lately I've just been having a public ItemManager itemManager;
field and initialize in onEnable then just with DI use plugin.itemManager

regal scaffold
#

I like it, it looks clean and does everything correctly

true perch
#

and just pass the itemManager instance into every class that needs it?

regal scaffold
#

    public PhoneManager phoneManager;

    @Override
    public void onEnable() {
            phoneManager = new PhoneManager(this);
    }
#

Yup

granite owl
true perch
#

Oke, you guys are the pros. I'll do that 😄

regal scaffold
#

Then inside the "manager class"

tender shard
true perch
# regal scaffold Then inside the "manager class"
public class ItemManager {

    /**
     * A HashMap of every item's ItemData.
     *
     * Integer - The number used to represent this item's unique identification.
     * ItemData - All the data associated with 7 Realm's Custom Item system.
     */
    private final HashMap<Integer, ItemData> itemDataMap;

    public ItemManager() {
        this.itemDataMap = new HashMap<>();
    }

    /**
     * Give a Player a Custom Item.
     */
    // TODO Create a command to execute this method
    public void giveItem(Player player, int id) {
        ItemData itemData = itemDataMap.get(id);
        player.getInventory().addItem(itemData.getITEM_STACK());
    }

    /**
     * Get item data based on unique ID.
     */
    public ItemData getData(int id) {
        return this.itemDataMap.get(id);
    }
}```is this acceptable?
regal scaffold
#

public class PhoneManager {

    private final MainPlugin plugin;

    public PhoneManager(MainPlugin plugin) {
        this.plugin = plugin;
    }

#

If you do not need a instance of the main class yes

true perch
#

What would be a good way to access the singleton when a player is executing a command though? for example.

regal scaffold
#

We just said it no?

true perch
#

Just not sure how to pass it in without a constructor

granite owl
#

btw intellij throws alot of warnings because i did not create an instance of my main class(obv), do i need some spigot plugin or so to have the IDE interpret the syntax correctly?

regal scaffold
#

Show me what you're tring to do

regal scaffold
true perch
#

I haven't done it yet, but I'll get started on the idea give me several minutes

regal scaffold
#

Use method 2

granite owl
#

like im getting a warning that i never use it

#

obviously

tender shard
regal scaffold
#

Interesting

#

^

granite owl
#

xD

tender shard
#

or add that class as entry point

#

in the inspections window

regal scaffold
#

I don't get those errors tho

#

I wonder why

tender shard
#

or just ignore the "unused declaration" things

regal scaffold
#

Are you using maven?

granite owl
#

ya

tender shard
granite owl
#

i mean is there another way but maven now

regal scaffold
#

I don't use it

granite owl
#

that they remapped the server jar

regal scaffold
#

I think

#

Oh wait yeah it's installed

#

Install the plugin teminator

granite owl
#

xD

#

aight

regal scaffold
granite owl
#

also i do admit that using maven has its advantages, like u dont need to download a copy of the repo as maven does that for u

regal scaffold
#

Make sure you still make new projects using maven but it's nice to have it in the backgrouhnd

#

tbh if you're not using maven/gradle I would reconsider

granite owl
#

tbh i hated to start using it cause its just overly complex

#

but it does have benefits

regal scaffold
#

The days of adding dependency libraries using the jar file are dead

granite owl
#

yea ik

regal scaffold
#

If you want a quicker maven start for new plugin, use alex's architecture

granite owl
#

i already set it up

regal scaffold
#

Then you're ready to go

granite owl
#

after like 2 hours of testing i also finally managed to install the jdk and jre 20 on both my windows machine and my WSL distro

paper venture
#

I want to initiate a enum value with ItemStack. But I need this ItemStack to be modified (add lorelist, set title, etc.), this can't be done in one line. What should I do then?

granite owl
#

and correctly load it everywhere

#

🤣

remote swallow
#

item builders is the simple answer

regal scaffold
#

They have arrived

remote swallow
#

or you'd need to use some lambda or consumer/callable for it

granite owl
regal scaffold
#

?nms

granite owl
#

i heared there would be one

remote swallow
paper venture
regal scaffold
#

BuildTools is just better

granite owl
true perch
#
public class Gi implements CommandExecutor {

    private final Realms main;

    public Gi(Realms main) {
        this.main = main;
    }
    
    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Must be executed by a player.");
            return false;
        }
        main.ITEM_MANAGER.giveItem((Player) sender,1);
        return false;
    }
}```If this is what I'm supposed to do, how should I store the instance of the `Gi` class?
paper venture
granite owl
#

where can i find the nms dependencies

remote swallow
granite owl
#

kk

regal scaffold
true perch
regal scaffold
#

Let it float

#

Into oblivion

#

It'll be happy there

remote swallow
#

$USER_HOME/.m2/repository/org/spigotmc/spigot/ver/spigot.version-remapped.jar

true perch
#

😂 okay cool haha

#

this works

regal scaffold
#

Wandering around your memory

granite owl
#

that path

regal scaffold
#

No

#

Maven will always search local repo first

#

So you don't need a repo

true perch
#

Are static imports frowned upon or acceptable? I'm interested in using them for easier readability

regal scaffold
#

Just fill the dependency section

granite owl
#

kk

regal scaffold
granite owl
#

will do so once im home haha

#

🙏

regal scaffold
#

So teaching to not use it when not needed is better at the start

sacred mountain
#

i am so done, ive spent the past half hour figuring out why my listener doesnt work, now realising that i didnt register it

#

ffs

regal scaffold
#

xd

true perch
#

When is an okay time to use a static import?

regal scaffold
#

Happens to the best

river oracle
regal scaffold
#

y2k can prob answer that better

sacred mountain
#

NOW IT WORKS

#

AHAHA

granite owl
#

xD

rotund ravine
#

Oh wait nvm @paper venture Function<Void, ItemStack>

regal scaffold
#

but I assume static is mostly just used when you're making a Utility class or something that does not require a instance like a Utility methoid

remote swallow
#

i wonder if i could make an annotation processor to auto register my classes

true perch
river oracle
paper venture
rotund ravine
paper venture
#

Okay thanks!

tardy delta
sacred mountain
#

these are some big scary words imma stick with String

eternal oxide
#

not for MC

river oracle
#

way to complex for my brain

tardy delta
#

javax annotation processor

remote swallow
#

you know who would know

granite owl
#

i think im going to wrap a function inside a native library in which i write my code in inline assembly. then i load that to my plugin and unlimited power

nocturne steppe
#

hello yesterday i could look at bukkit and spigot's code but now intellij wants me to decompile it to see it

rotund ravine
tardy delta
#

still waiting for pritimives support in generics

#

project valhalla when

night verge
#

I'm trying to modify the cauldron level but I have failed.
Is there anything wrong with my code?

This is my code. ("block" is the specific block that I want to modify)

Levelled cauldron = (Levelled) block.getBlockData();
cauldron.setLevel(0);
block.setBlockData(cauldron);
nocturne steppe
# granite owl the what

I mean yesterday i could just ctrl+click for example StructureManager to see the class, but now when i do that it asks if i want to decompile it

granite owl
#

not entirely sure what went wrong there but do u have the correct api?

#

because decompiling sounds as if u have byte code

nocturne steppe
#

i did deactivate filtering in my pom.xml

#

but apart from that i changed nothing

granite owl
#

idk man but im pretty sure the api is supposed to provide source code

#

🤣

nocturne steppe
#

ugghhhhh

vital sandal
#

what is the best way to create constantConfig?

pseudo hazel
#

whats that

tardy delta
#

lol

#

the questions are very weird here sometimes

eternal oxide
#

you also ran mvn clean. I don;t use InteliJ so perhaps you don;t have sources

vital sandal
#

like I want to change the sound of clicking UI which is configurable

nocturne steppe
vital sandal
#

class/enum/inferface?

pseudo hazel
#

just make normal config file

vital sandal
river oracle
#

unsure what you are really asking then

vital sandal
#

nvm

eternal oxide
vital sandal
#

like this :l

#

there are reasons for me to create custom config

nocturne steppe
pseudo hazel
regal scaffold
#

Static abuser!

vital sandal
regal scaffold
#

It can be static, just not recommended, people usually make too much stuff static which is called static abuse when it doesn't have to be static

#

So learning to not spam static from the start is good

vital sandal
#

It should be static

#

It is constant value and no need to be like that

#

and it is editable so not final

regal scaffold
#

Once again, never said it can't be static, just said it's not recommended

vital sandal
#

why?

#

why not recommended?

pseudo hazel
regal scaffold
#

people usually make too much stuff static which is called static abuse when it doesn't have to be static

pseudo hazel
#

read this

#

having it static is fine

vital sandal
pseudo hazel
#

hiw else would you be able to use it everywhere

regal scaffold
#

instance and di?

sacred mountain
#

anyone know if it's possible to reduce the size of the initial lingering potion bounding box before it splashes

regal scaffold
#

Which is the principle of oop

pseudo hazel
#

di makes everything messy for bigger plugins

#

since you have to pass the same thing 50 times in every constructor to just get some config value

regal scaffold
#

Which is why I said

It can be static, just not recommended

pseudo hazel
#

the file only exists once

vital sandal
#

It should be recommeded

regal scaffold
#

I've explained 3 times why it's not recommended but sure, it's your code, go ahead

pseudo hazel
#

anyways what is the issue?

regal scaffold
#

No idea, I stopped reading when he took advice as a personal attack

sacred mountain
#

another question can you splash a potion forcefully, or does it have to land somewhere

#

like i want to spawn a splash potion that just splashes instantly

#

does it do that anyway

chrome beacon
#

Does it have to be a splash potion or are you just trying to apply potion effects?

sacred mountain
#

it's for particle effects

#

so no there are no actual potion effects

chrome beacon
#

Any reason why you can't just spawn particles without the potion?

sacred mountain
#

it might have functionality later

#

so i'd like to keep that open

#

if i want it to do anything in future

chrome beacon
#

Not really

#

You can highlight blocks but not make them transparent

tardy flame
#

What do you mean highlight?

true perch
#

What's the acceptable way to reference a Material enum object from a config file?
My first thought was doing something like Material.valueOf("AMETHYST_SHARD"); as an example.

#

However this seems to produce an error, unsure why

regal scaffold
#

String is the best way

true perch
#

No enum constant org.bukkit.Material.LEGACY_AMETHYST_SHARD

regal scaffold
#

How are you reading it?

#

Show the config line

#

In code

true perch
#
public ItemData(int id, String name, String description, String material, int customModelData, ItemRarity rarity, ItemStats stats, ItemAttributes[] attributes, ItemEffects[] effects) {
        this.ID = id;
        this.NAME = name;
        this.DESCRIPTION = org.bukkit.Color.WHITE + description;
        this.MATERIAL = Material.valueOf(material);
        this.CUSTOM_MODEL_DATA = customModelData;
        this.RARITY = rarity;
        this.STATS = stats;
        this.ATTRIBUTES = attributes;
        this.EFFECTS = effects;
        this.ITEM_STACK = generateItemStack(this);
    }```
regal scaffold
#

Before that

chrome beacon
regal scaffold
#

You're either doing config.getMaterial or config.getString

sacred mountain
#

is it bad to have empty interfaces just to call instanceof on

#

for categorizing things

vital sandal
sacred mountain
#

i used DI

regal scaffold
true perch
# regal scaffold You're either doing config.getMaterial or config.getString

I wrote this to simulate reading data from a config filejava public ItemManager() { this.itemDataMap = new HashMap<>(); ItemStats stats = new ItemStats(1, 1, 10, 0, 0, 0, 0, 0, 0, 0); ItemData itemData = new ItemData(1, "Test", "This is a test item.", "AMETHYST_SHARD", -1, ItemRarity.MYTHIC, stats, null, null); this.itemDataMap.put(1, itemData); }

sacred mountain
#

use*

echo basalt
true perch
#

okay thanks guys

vital sandal
regal scaffold
#

?di

undone axleBOT
true perch
#

thank you as well @chrome beacon

vital sandal
#

I mean why?