#help-development

1 messages · Page 1992 of 1

sterile token
#

@vagrant stratus - Spam please ban

woeful crescent
ancient plank
#

?ban @torn coyote very funny, didn't laugh

undone axleBOT
#

Done. That felt good.

woeful crescent
#

nvm

sterile token
woeful crescent
viral crag
#

if its not about actually seeing the other player, what is the purpose..

smoky oak
#

whats that method?

woeful crescent
#

ack just chill it's about if you're facing the other player

smoky oak
#

i need it

lost matrix
woeful crescent
smoky oak
#

thanks

smoky oak
#

thanks again i guess?

viral crag
#

then just vector check ...

woeful crescent
#

YES THAT IS WHAT WE'RE DOING

#

THANKS SO MUCH

sterile token
#

After a unit testing i have discovered its caused here:

Map<String, Object> object = new Gson().fromJson(new BufferedReader(new FileReader(this.file), Map.class);

woeful crescent
#

lol

viral crag
#

not with vision, just face

woeful crescent
#

yes

#

lmao

#

also ty 7smile7, this will work

lost matrix
viral crag
#

location gives you the facing vector directly

true shuttle
#

Hi! I have some questions about Spigot development, and is wondering if someone could help me out.

So I'm not at all new to coding or Minecraft datapack/resource pack creation, but I've been trying to get into modding the past few months and have been very interested. I've been using MCreator, but have found it very limited and I'm looking for something a bit more advanced. Is Spigot what i'm looking for?

#

if not could someone point me in the right direction

rough drift
#

its way better than forge

hexed hatch
#

Spigot is server-side mod development, they’re called plugins

rough drift
#

and they have a friendly comunity

hexed hatch
#

You can’t add assets to the game and it only works for servers

true shuttle
#

r there any benefits to fabric or spigot?

hexed hatch
#

Spigot is strictly server-side

#

They’re not really that comparable

#

Fabric is full-on mod development

rough drift
#

plugins are just extensions of a server

sullen marlin
#

plugins dont need updating every version

rough drift
#

and fabric is full on editing of the game

rough drift
true shuttle
#

ooh ok. i see what u mean

#

any tips or anything for getting started in Fabric?

rough drift
#

check the fabric wiki

true shuttle
#

i'm not really sure where to start

rough drift
#

and join their disc

true shuttle
#

besides google

#

will do, thanks!

hexed hatch
#

Learn Java

rough drift
#

its fine if i put fabricord link right?

hexed hatch
#

Having a full understanding of Java is imperative

rough drift
#

^

quiet ice
#

Fabric is also extra complicated compared to fabric as you may need to have some understanding of java bytecode

#

Though I think you can just skip that requirement

true shuttle
hexed hatch
#

No

#

Not at all

quiet ice
#

The java bytecode knowledge requirement

hexed hatch
#

You must have a good understanding of Java concepts before even looking at Fabric modding

#

Otherwise you’re going to be throwing yourself at walls

quiet ice
#

Java knowledge is imperative, and java bytecode knowledge is highly recommended otherwise you'll get confused with mixins (which is a hard-requirement for fabric modding)

#

Bukkit is thankfully much more beginner-friendly there

rough drift
#

^

true shuttle
#

ok so imma be honest here, i have experience in coding, but no experience at all with java

#

im prepared to learn tho

hexed hatch
#

Start there

quiet ice
#

Otherwise you could just start contributing to already existing projects (or just try to learn it).
However honestly said, fabric projects have terrible structure mostly and many fabric tutorials teach things that are mostly against common java conventions

true shuttle
hexed hatch
#

Learning unadulterated Java

quiet ice
#

The the most usefull concepts you should be familiar with before starting with modding is
a) reading & Understanding Compiler errors
b) Reading & Understanding Stacktraces
c) Reading & Understanding Javadocs

hexed hatch
#

Geol, if I wanted to familiarize myself more with bytecode and how it works, where would you recommend starting?

quiet ice
#

More than half of the issues we solve in #help-development can be answered without consulting us if you were to be familiar with all three steps

quiet ice
hexed hatch
#

I appreciate the advice, I’ll poke around there. I’d like to think I’m a pretty competent Java developer, but when it compiles it’s black magic to me beyond that point.

true shuttle
quiet ice
#

Bukkit is impressively powerful.

#

Sure, you cannot add new blocks or mobs or anything without going into really complex territory, but you can get accustomed to minecraft basics.
Just note that bukkit is completely different to forge or fabric for example especially in the way it is built. Another alternative would be sponge, but that one is more complicated even though many contributors of bukkit are now working on sponge

true shuttle
#

i have a few questions tho

#

what's the difference between bukkit and spigot, and is this the wrong server to talk about bukkit?

quiet ice
#

nowadays they are the same thing

#

The bigger difference is spigot and paper (latter is a fork of spigot) but for starters they are mostly the same things until you get into the details

true shuttle
#

is there a reason to choose one over the other?

#

bukkit v spigot

quiet ice
#

Bukkit is dead for half a decade now, there is no choice

true shuttle
#

oh ok

sterile token
#

bUKKIT ITS dead

#

Now you should fork Spigot or Paper

quiet ice
#

If you touch on a site claiming to distribute bukkit you are most likely on the wrong size

#

You shouldn't fork spigot either

true shuttle
#

wait so spigot or paper?

quiet ice
#

Yeah, though of course here we support spigot

#

?bt is the only legitimate way of obtaining it

undone axleBOT
true shuttle
#

ok so i dont wanna offend u guys, but imma start with paper. After reading a bit about it, it seems to be slightly better and have a larger community, so imma start there

#

unless theres something im missing

quiet ice
#

A few people find paper's community less welcoming but honestly as long as you are on online mode and on the latest version you are pretty much welcome anywhere while if you are not on either you aren't welcome anywhere (though here many are far more accepting towards 1.8 in particular)

eternal oxide
#

Things written for Paper stand a good chance of not running on Spigot. Write for Spigot and it works on both.

quiet ice
#

In the end, it's a personal choice, just like choosing a linux distro
Also yeah, Elgar's advice stands true plus you cannot distribute paper-only plugins on spigotmc

rapid vigil
#

Hey, I have a question that is probably from the java basics but if I had some checks with or (two of |) and then had an else does the else also work if one of the checks is true so doesn't have to be both true?
Example:

if(isPlayerFlying() || isPlayerCrying()) {
  //Do something
} else { //If one of the checks above is true and the other is false will this run?
  //Do something
}```
tall dragon
#

no

#

the else statement will not run

rapid vigil
#

Will it only run if both are true?

tall dragon
#

if both are false

#

the else will run

rapid vigil
#

I meant false**

tall dragon
#

well yes then

rapid vigil
#

Alright thanks for the quick answer

tall dragon
#

no problem

storm crescent
#

How would I create a client-side lightning strike at a specific location?

young knoll
#

Define client side

#

Like only 1 player can see it?

sterile token
#

Anyone has experience with parsing a json file to a Map?

storm crescent
young knoll
#

Probably a packet

#

Idk if lightning has its own packet

storm crescent
#

The closest packet i could find was the game state change

tall dragon
#

isnt lightning a particle effect as far is client is concerned?

young knoll
#

No

#

It’s an entity

tall dragon
#

oh irght

#

indeed

young knoll
#

So it’s probably the SpawnEntity packet

tall dragon
#

yea

storm crescent
#

Alright, thanks

sterile token
#

Hi i have discovered, that im getting Null Pointer Exception on my json handler, when the file.json is empty. But if the file contains "{}" inside. It doesnt throw anymore the exception

#

So what do you recommend? I tried writing via code the "{}" inside the file. But still getting NPE

smoky oak
#

cant u just do a null check

#

n' return an empty json

sterile token
#

Do you wanna see my code?

smoky oak
#

sure

#

use md's website tho

sterile token
#

Yes of course

#

There you have

#

Really thanks i try many things

smoky oak
#

what's the first function called of that?

sterile token
#

I didnt understand

smoky oak
#

is the error thrown when you create an object instance of the class

silent hound
#

is there an interactwitharmorstand event?

smoky oak
#

prob only playerInteractEvent

tall dragon
#

playerinteractatentityevent

silent hound
#

thanks

tall dragon
silent hound
#

ik

sterile token
silent hound
#

i was just trying to do it with EntityInteractEvent and that wasn't workign

#

tyvm

smoky oak
#

wait

#

there's a good chance parsing '{}' to json results in an empty string

#

since it does not contain any values

waxen plinth
#

Why would it

#

That would be empty map not empty string

smoky oak
#

stack trace please

sterile token
#

Allright

#
Exception in thread "main" java.lang.NullPointerException
    at dev.alex.net.utilities.file.json.JsonFile.set(JsonFile.java:44)
    at dev.alex.net.utilities.file.testing.Main.main(Main.java:11)```
#

That happen when try to add a value to map

#

My test code

    public static void main(String[] args) throws Exception {
        FileHandler json = new JsonFile("C:\\Users\\Usuario\\Desktop\\Pruebas\\test.json");
        json.set("test", "My test value");
    }```
smoky oak
#

hm

#

what's the caused by say?

#

or rather

#

the full stack trace

#

thts probably a lot easier to deal with

sterile token
#

That the full strack trace

#

And doing: getCause() say null

smoky oak
#

how the fuck do you have a stack trace not saying 'caused by'

sterile token
#

That the full stracktrace

#

Im not lying

smoky oak
#

huh

#

wait

#

surround with try/catch do e.printStackTrace()

sterile token
#

So i finally find that the problem its caused when the file inside doesnt contain any "{}"

smoky oak
#

told ya so

sterile token
smoky oak
#

huh?

sterile token
#

I changed before you told me and i test it

#

And giveme the same info

smoky oak
#

I'm amazed how that did not result in anything more

sterile token
#

Yes i dont know too

smoky oak
#

well maybe it's because you're using that class in particular

#

but seriously getting an error without an caused by is a once in a blue moon thing in java

sterile token
#

Just say me that something its null on line 44:

smoky oak
#

actually it says 'caused by null on line 44 which results in an error on line 13' if i read that right

sterile token
#

Could be caused because im doing?

FileHandler json = new JsonFile()

#

Instead of doing JsonFile file = new JsonFile?

smoky oak
#

maybe

#

i dont know for sure

#

but it could be that the @Override doesnt get loaded

sterile token
#

No it isnt, its the same

smoky oak
#

this is uncharted waters for me tho

sterile token
#

Hmn

#

Im like okay hat happening them

#

But dont worry i just want to know how i can add "{}" inside the file?

#
if (this.file.length() == 0) new BufferedWriter(new FileWriter(this.file)).write(this.gson.toJson("{}")); 

Cuz doesnt work

smoky oak
#

lemme check smth

sterile token
#

Allright

#

Im using Gson

smoky oak
#

ah

#

welllllll

#

considering this is what the docs say

#

i dont think you can just write "{}" to a file

#

im not 100% sure but i think toJson("{}") just returns an empty json tree

#

as such

#

it writes nothign to the file

#

just creates it

tall dragon
#

why not write {} without converting to json

smoky oak
#

(if im right)

#

well

#

thats a solution too

#

ima go sleep now

#

gl

sterile token
#

Hmn, because if i write manually "{}" inside the json file. And then try to set values it doesnt throw error

#

So i dont understand

tall dragon
#

i usually have a file in my jar that i just copy to the directory

#

with {} in it

sterile token
#

Oh how?

#

Can i see yours?

#

That what you mean Epic?

tall dragon
#

yea

sterile token
#

I will try

tall dragon
#

and when json converts it back it should just be an empty json element

sterile token
#

Nop, still getting the error

#

Idk why, but it doesnt write to the file

tall dragon
#

uhh

#

let me see if i can find some json work i made

sterile token
#

Yeah im feeling like you right now

#

Because everything works except that yeath

tall dragon
#

this is what i do to save json

#
@Override
    public void save(IslandCache cache) {
        try {
            StackerPlugin.sendDebug("Island Cache " + cache.getUUID() + " has been unloaded and saved.");
            createFileIfNotExists(storage.resolve(cache.getUUID() + ".json"));
            Files.write(storage.resolve(cache.getUUID() + ".json"), GlobalGson.GSON.toJson(cache).getBytes(StandardCharsets.UTF_8));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
#

for example

sterile token
#

I have Files.class marked as @Beta

#

That why i dont use it

tall dragon
#

but its so nice

sterile token
#

Ah allright you are saving a custom object

tall dragon
#

yes

sterile token
#

That what i dont want

tall dragon
#

in my case i am

sterile token
#

I want to be able to save what ever i need, json element, json array, class object

tall dragon
#

yes but that should work practically the same

sterile token
#

Where does GlobalGson came from?

sterile token
tall dragon
#

its just a class that holds the Gson object

#
public class GlobalGson {

    private static GsonBuilder BUILDER = new GsonBuilder()
            .registerTypeAdapter(StorageBenchmark.DataObject.class, new StorageBenchmark.DataObject())
            .registerTypeAdapter(IslandCache.class, new IslandCacheTypeAdapter())
            .registerTypeAdapter(StackerBlock.class, new StackerBlockTypeAdapter())
            .setExclusionStrategies(new ExclusionStrategy() {
                @Override
                public boolean shouldSkipField(FieldAttributes f) {
                    return f.hasModifier(Modifier.STATIC) || f.hasModifier(Modifier.TRANSIENT)
                            || (StrictCollection.class.isAssignableFrom(f.getDeclaringClass()) && (f.getName().equalsIgnoreCase("cannotRemoveMessage") || f.getName().equalsIgnoreCase("cannotAddMessage")));
                }

                @Override
                public boolean shouldSkipClass(Class<?> clazz) {
                    return false;
                }
            })
            .disableHtmlEscaping();

    public static Gson GSON;

    static {
        GSON = BUILDER.setPrettyPrinting().create();
    }
}
sterile token
tall dragon
#

not sure what you mean

sterile token
#

Yeah

#

Hmn

#

I ill prob have to look on github

#

:sad_face:

atomic niche
#

Is there any way to modify an entity's data without NMS or executing vanilla commands?

tall dragon
#

what kind of data

atomic niche
#

the kind you get from data get entity @e[type=!player,limit=1]

tall dragon
#

pretty sure that gets you all data

lost matrix
#

For most of this data spigot has api methods

atomic niche
#

it does, but it is a vanilla command

#

I would prefer to use a method

tall dragon
#

well as said

#

most thing are editable with api methods

atomic niche
#

This particular data key does not have an existing method in paper or spigot -- would prefer not to use NMS or PR

tall dragon
#

well, what is this particular data key

atomic niche
#

PushX and PushZ

lost matrix
#

What entity is this from?

atomic niche
#

org.bukkit.entity.minecart.PoweredMinecart

hexed hatch
#

I think you can edit tags like that with Bukkit#getUnsafe

atomic niche
#

😮

lost matrix
#

Yeah i dont see any method corresponding to that data.

hexed hatch
#

Don't quote me on that

#

and don't ask me how

atomic niche
#

Unsafe sounds like the best option, if we can get that to work.
Otherwise, NMS or PR time... hurray

hexed hatch
#

I would shoot a PR out anyways

#

regardless of your solution

atomic niche
#

There is also the super sketchy option of dispatching vanilla commands.
But that is too sketchy for a major plugin, so yeah... PR time with NMS or Unsafe in the interim

hexed hatch
#

disgusting

tall dragon
#

@lost matrix would you have time to talk about Evenly distributed workloads?, you send your link to me. & i tried to implement that. but i think your implementation is meant for if you have a set number of workloads and you can run them evenly distributed but in my case i have a workload every 5 ticks so im kind of confused on how to implement that. unless im wrong and yours is suitable for looping like that.

atomic niche
#

Btw, how likely do you think this would be to get approved as a spigot-level PR?
Is it too niche? Would it be more suited to a downstream PR?

lost matrix
tall dragon
#

no, its an object its looping over

#

but ofc when evenly distributing it would proccess 1/5 every tick

hexed hatch
tall dragon
#

could show you my shitty implementation if that helps

hexed hatch
#

but I don't really follow up with it. The only features I ever got added to spigot were from conversations with Choco lol

lost matrix
tall dragon
atomic niche
#

eewwwww

#

How is that still a thing

#

:L

hexed hatch
#

Honestly

#

I think it would be better to make a jira ticket than a pr

atomic niche
#

What is the usual response time for Jira tickets? How does that compare to PRs?
For that matter, how does it compare to downstream PRs?

#

if we have to do NMS in the interm, would prefer not to have to update to 1.19

hexed hatch
#

I don't really keep up with it all

atomic niche
#

Thanks anyways!

hexed hatch
#

But: why not both? Get a JIRA ticket out there and if you have time throw together a pr

young knoll
#

small PRs have been accepted pretty quickly in my experience

vernal basalt
#

i haven't played mc in a while

#

how do i update my 1.17 to 1.18

#

i dont think the plugin it's self would be broken but how do i make it normally 1.18

young knoll
#

Change the dependency in maven or gradle or whatever

vernal basalt
#

currently it's set to 1.16.5-R0.1-SNAPSHOT what is it for 1.18?

#

but is it necessary? if im not changing the code

#

the only thing i could think of is

#

in the code it makes a list of all blocks and items. would it do it on the plugin version or server version

young knoll
#

Should be the server version

torn oyster
#

how would i regenerate just 1 chunk with a specific chunkgenerator (different from the world's)

young knoll
#

World has a regenerateChunk method

ebon coral
#

How do I obtain NMS in 1.18?

#

Can't find the classes 4 some reason :>

vocal cloud
#

Build tools rev 1.18.x?

young knoll
#

Maven or gradle?

stuck flax
#

How does the plugin messaging channel work? Can a plugin just send some text to another plugin for it to process and do something depending on it

young knoll
#

You could

#

Probably easier to just hook the plugin directly though

#

Plugin messaging is good for communicating between servers or for talking to client mods

subtle folio
#

does it matter if I send conole chatColor.red type stuff?

#

idc if it actually appears or not

ebon coral
#

It should be red

#

Depends on the console though

#

Ptero supports it

subtle folio
#

minehut lol

young knoll
#

It doesn’t matter, no

subtle folio
young knoll
#

You may see the raw color codes though

jade knot
#

Now, I am using Kotlin in my plugin and, dependency plugin is also Kotlin plugin
and if i depend Kotlin plugin and using libraries function in plugin.yml(libraries are for Kotlin), plugin throw LinkageError

brave sparrow
#

@tender shard btw I just did the compile

#

the unobfuscated client is 21017 kb, the obfuscated client is 19789 kb

#

so you save about 1000 kb by obfuscating, saving a fraction of a second on download time

ebon coral
subtle folio
ebon coral
young knoll
#

1mb saves me almost a whole second on download!

#

Very significant

brave sparrow
#

how low is your download speed

young knoll
#

10 megabits

brave sparrow
#

puts you close to a second i suppose

young knoll
#

About 1.3mb a second

#

So yeah, think of all the things I can do in that second

ebon coral
vocal cloud
#

It adds the NMS mapping to maven

ebon coral
#

Ok so I just built 1.18

#

So what now?

young knoll
#

Add spigot via maven or gradle

ebon coral
#

Ehh not about that life, just wanna add the JAR as a depend

#

So where do I obtain a JAR with NMS?

vocal cloud
brave sparrow
#

it's in your local maven repo

vocal cloud
#

NoT ABoUt ThAT liFE

young knoll
#

It’s also in the buildtools folder somewhere

#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

young knoll
#

Actually that’s just for the API

ebon coral
#

Yeah I found that but NMS :}

young knoll
#

NMS is probably in spigot-server

ebon coral
#

Prob the remapped one

#

Or smthn

solid forge
#

in the event EntityBreedEvent
is the breeder the player?

young knoll
#

I’d imagine it’s usually the player

#

But it can be null

#

Or any LivingEntity

solid forge
#

alr thx a lot,i will assume its the player then

#

if it doesnt work imma sue bukkit for scam

young knoll
#

For what

#

The return type is LivingEntity for a reason

solid forge
#

what can possibly be the breeder besides Player

young knoll
#

null

#

A villager maybe? Do they feed animals

solid forge
#

ohh,

#

maybe im too outdated

#

didnt know there are these villagers in the updates

ebon coral
#

How would I set a custom skull head using Base64 situation with 1.18?

#

Seems GameProfile doesn't exist anymore

ebon coral
#

I don't wanna use getTextures().setSkin either because it's Base64 and that requires a URL :>

hardy swan
#

Wtf is a herder villager

hardy swan
ebon coral
#

I have spigot-api and spigot-server as depends, which one is it cuz I cannot find GameProfile?

#

In 1.18

brave sparrow
hardy swan
ebon coral
#

Hm alright

hardy swan
brave sparrow
#

Basically

#

But shepherds are only for sheep

hardy swan
#

Yes sheep-herds

torn oyster
#

how would i regenerate just 1 chunk with a specific chunkgenerator (different from the world's)

grim oak
#

how do i do this since getUnsafe() is depricated

#
return Bukkit.getUnsafe().modifyItemStack(skull,
                "{SkullOwner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + headId + "\"}]}}}"
        );```
ebon coral
visual tide
#

if you mean shepherds they just sell wool stuff they dont interact with animals

terse lily
#

What is minecraftHash in BuildData/info.json? What is it a hash of?

visual tide
#

might be of the vanilla jar

#

but idk

terse lily
#

It doesn't seem to match any hash in the version's manifest

visual tide
#

cuz its sha256

#

the hashes in the manifest are md5

terse lily
#

I'll look at the uses of this value in specialsource or buildtools later then

#

Thx anyway

visual tide
#

good idea

lapis widget
quiet ice
ebon coral
#

Why isn't there .getProperties() in PlayerProfile?

short raptor
#

I know this is extremely dumb but how do I access this plugin thing

ebon coral
#

The class that extends JavaPlugin

#

lol

lapis widget
short raptor
#

So I do JavaPlugin.saveDefaultConfig();? lol

ebon coral
#

No

lapis widget
#

smh

short raptor
#

Because I tried using my class name and it doesn't have that function

ebon coral
#

No offense, but I suggest you learn a little bit of Java before entering plugin development.

short raptor
#

And getPlugin() has some red squiggle I don't understand'

short raptor
#

I haven't had any issue with actual java knowledge until rn

#

Oh well

ebon coral
#

It makes it a bit difficult without it

#

Just a little, and learn as you go.

#

That's what I did :>

ivory sleet
#

@short raptor the plugin there is a variable which probably references your plugin instance/object

solid forge
#

how do you detect when player successfully tame horses

#

its not notified in entitytameevent

#

for some reasons

ivory sleet
#

Sounds like a bug then which should be reported on the JIRA

ebon coral
#

playerProfile.setTextures(new ProfileProperty("textures", base64));

#

Or something like that

ivory sleet
#

Ehm

lapis widget
ebon coral
#

Oh boy, one moment.

ivory sleet
#

@ebon coral

ebon coral
#

So i gotta use this and somehow get a signed one

ivory sleet
#

Basically

#

You use Server::createPlayerProfile

ebon coral
#
            playerProfile.getTextures().sets
            skullMeta.setOwnerProfile(playerProfile);```
#

Yeah I know

#

I just can't figure out the setting base64 part

ivory sleet
#

Oh

ebon coral
ivory sleet
#

Well the base64 is just an url iirc

ebon coral
#

And I do not want to use Mineskin's API and do some magic stuff for no reason if there's a way to impl it through basic Spigot API.

#

Yes, it just returns the texture though.

#

Unsigned

#

I'm not sure if the setSkin wants it signed

ivory sleet
#

Try and see

ebon coral
#

Alright one second

#

So decode the base64 and use the URL

#

From the decoded base64 json

#

Let's see if dis works

ivory sleet
#

Like I didn’t know this api existed until like a week or so, so I’m not really experienced regarding this btw lol

#

Yeah hopefully

molten hearth
#

Still need help with this

#

(Code)

lapis widget
# molten hearth Still need help with this

// This is the most important method when registering an expansion from your plugin
public boolean persist() {
// This tells PlaceholderAPI to not unregister this hook when /papi reload is executed
return true;
}

ebon coral
#

That's why I cant figure it out XD

ivory sleet
#

I feel like you should ask in HelpChat where the placeholder api maintainers are, they probably know their api much better than people here genuinely speaking

molten hearth
#

Nobody replied there 🥲 but true

ivory sleet
#

Ah rip

#

I actually don’t know much about the new way papi implementation works

#

But is that marriage plugin yours?

molten hearth
#

yeah it's a fork of another marriage plugin that got outdated

ivory sleet
#

Because it’s a pretty unorthodox way of registering your papi expansion

#

Ah

#

But it works fine until you use papi reload from the command line interface of papi?

solid forge
molten hearth
#

It all works fine until /papi reload in which case I need to reload my plugin for it to work again

#

So maybe I need to re register them but there's no papireloadevent or such and I thought persist took care of that but apparently not so I'm not sure what to do

solid forge
ivory sleet
#

If you have a persistent papi expansion

#

Then reloads should be up to you to control

molten hearth
#

Uh how exactly

ivory sleet
#

But what if you moved the register part into onEnable

#

As opposed to having that listener

molten hearth
#

Oh god

#

The plugin has a weird way of handling stuff I'll have to see if that's possible

ivory sleet
#

Yeah good luck

molten hearth
#

I think there's a custom plugin system on top of it

ivory sleet
#

🥲

quaint mantle
#

?learn-maven

#

no command, blame md

tardy delta
#

i'm wondering if i'm doing this, will the connection be opened twice?

try (Connection conn = connectionFactory.getConnection()) {
  // do something with it
  try (Connection conn1 = connectionFactory.getConnection())   {
    //
  }
}```
crimson marsh
#

Do you still need help?

ebon coral
#

How do I do the .getConnection() on players (1.18)?

#

NMS breaks the brain

visual tide
#

its a field

#

not a method

ebon coral
#

Ah okay

#

Do you know which field specifically?

fading lake
#

its called connection in EntityPlayer

ebon coral
#

Not there for me?

fading lake
#

oh I thought you were using NMS, give me a sec

#

it might be called playerConnection

ebon coral
#

Nope

fading lake
#

strange

#

CTRL+Click EntityPlayer and it should tell you

lost matrix
#

Are you using mojmappings?

ebon coral
#

Yes

#

The remapped one actually

#

Is that why?

#

Should I use the normal one

cerulean jasper
#

I changed up some command code in an opensource spigot plugin and when I build the .jar and drop it in my server it tells me it is missing plugin.yml even though it is in the hierarchy

lost matrix
#

Then its just connection

cerulean jasper
#

How can I manually add existing plugin.yml in jar via IDEA then?

fading lake
#

pom.xml

#

if youre mavening

cerulean jasper
#

What do I put in it?

#

Let me check

ebon coral
#

It's just a dependency, I just built the JAR with BuildTools

cerulean jasper
ebon coral
#

I have both spigot-server and spigot-api

cerulean jasper
#

I dont see pom.xml

lost matrix
fading lake
#

oh thats gradle

cerulean jasper
#

Okay, how do I make sure to include plugin yml?

#

kinda bad at this

lost matrix
#

Compile it as a gradle project. Dont build artifacts.

cerulean jasper
#

Just run the gradlew thing? or is there spigotmc instructions on this

#

I tried rebuilding via idea or whatever, it told me its missing target "16" even though I have java 16 and 17

#

not sure if this is it

lost matrix
#

just call ./gradlew build

cerulean jasper
#

Okay

lost matrix
#

It uses the wrapper provided by the project.

cerulean jasper
cerulean jasper
ebon coral
#

Is this it?

#

Yeah looks like it, sick.

lost matrix
ebon coral
lost matrix
#

ProtocolLib will assure some compatability with other versions. Using nms will only work for your exact version.

ebon coral
#

Am I not using this?

lost matrix
ebon coral
#

Not worried about version support, this is a custom application.

cerulean jasper
#

I think me changing to java 17 target just fixed it, 1 sec

#

nvm, checking gradle file

lost matrix
#

alright and then build.gradle

cerulean jasper
#

Well I didnt change anything, but both java 16 and 17 seems to be having same error

#

I also found these

ebon coral
#

The remapped JAR is the correct one right?

ebon coral
#

Gonna try to build it again on BuildTools with --remapped

#

Hope that does the trick

#

Yeah that did the trick :>

brave goblet
#
public void onEntityHit(EntityDamageByEntityEvent event){
        Entity entity = event.getEntity();
}

Required type:
net.minecraft.world.entity.Entity
Provided:
org.bukkit.entity.Entity

#

how can i make this work?

vocal cloud
#

Import the right entity class?

brave goblet
#

e

#

true

tardy delta
#

is it worth to do something like Map<name, object> when that object already holds the name internal? for more easy lookup

lavish hemlock
#

Absolutely not

#

Unless

#

You are in a situation where you have a lot of objects of different names

#

And must convert between name and object

#

But if it's just to remove a getName() call, no.

#

Absolutely not.

tardy delta
#

it was to use a map instead of a set 👉👈

#

so i dont have to use .stream().filter() and i can just use Map#get

lavish hemlock
#

Well, I mean...

#

Wouldn't you want a Map<name, Set<object>> or Multimap?

ivory sleet
#

SetMultimap :3

tardy delta
#

assume i have something liek this
so i could do a Map<String: name, Home: home> if i dont have a field for the name in the home obj

#

instead of a set

ivory sleet
#

That looks scary

lavish hemlock
tardy delta
#

🤷

ivory sleet
#

Location is mutable right

#

👀

lavish hemlock
#

Huh

#

Yeah I think so

tardy delta
#

why would that matter

lavish hemlock
#

Specifically thread-safety and state validity.

ivory sleet
#

Ugh it doesn’t matter to you but well immutability 🙌TownHall14 TownHall14

lavish hemlock
#

In the world of Java

#

If you don't need mutability, don't use it

#

(Although it's a lil hard to know when you need mutability)

tardy delta
#

so would i put it in a map or not lol

lavish hemlock
#

How often are you getting the objects?

tardy delta
#

only when sending the whole list of homes to an user

#

so thats just looping over them

lavish hemlock
#

Couldn't you just iterate over the list of homes then?

tardy delta
#

mye

#

was just thinking for easier lookup

#

and Map#remove with returns the object itselfs vs Set#remove which returns nothing

ivory sleet
#

boolean iirc

tardy delta
#

ah ye right

#

cant do anything with that either lol

ivory sleet
#

Myeah

#

Really depends on what you need

#

But probably not in this case

lavish hemlock
#

That boolean is also very implementation-specific

#

I'm pretty sure most sets don't ever return false

tardy delta
#

when the thing was already present?

somber sequoia
#

how could I make something above a players name

tardy delta
#

a plane?

lavish hemlock
#

Pfft

#

Uh you'd wanna use scoreboards

somber sequoia
#

ah

sacred mountain
#

hey im trying to create a cooldown manager class for my custom item abilities.
how would i store multiple cooldowns for one player and then send a message when the cooldown is over? would i have to use a scheduler/timer if i wanted a message sent?
HashMap<UUID, <ItemStack, Long>>

tardy delta
#

and whats better to use in a set with about 5 elements? foreach or Stream#filter?

lavish hemlock
#

Streams on collections are eagerly created (as is the nature of a collection), so there's not great gain.

tardy delta
#

👍

lavish hemlock
#

Yeah you want to use the scheduler, most likely.

sacred mountain
lavish hemlock
rough drift
tardy delta
#

Multimap is <K, V, V> right?

lavish hemlock
#

(Also: Why does Guava not have Pair- fuck that, why does Java not have Pair?)

upper mica
#

Hello, should I keep all event listeners in one class and register only once? Because my plugin have some minigames, tools with stuff happening after interaction to block or entity and etc. And almost every one of them have Listener implementation and they are registered. My question is: Will this impact the server? Like I'm not sure if I should do this or not. The reason I'm doing this because I don't want to have a mess, like tools interaction with minigame interactions in same method.

lavish hemlock
tardy delta
#

create it yourself lol

rough drift
tardy delta
#

oh right

rough drift
#

itemmeta uses that iirc

lavish hemlock
#

Having multiple listener classes vs. one is basically the same afaik

#

Only difference is the small classloading overhead

rough drift
#

thats in item meta

lavish hemlock
#

But like, don't fuckin' micro-optimize to the point where your code is worse.

rough drift
#

quick thing

#

can you show custom recipe in recipe book?

lavish hemlock
#

Probably

#

If it uses data files then yeah

rough drift
#

found it

#

Player#discoverRecipe(Collection<NamespacedKey>)

tardy delta
#

ye

lost matrix
lavish hemlock
#

Technically Guava's Multimap supports multiple collection types

ivory sleet
#

Collection iirc

lavish hemlock
#

Yes

ivory sleet
#

SetMultimap would be Map<K,Set<V>>

rough drift
#

it also takes one

ivory sleet
#

Yes really

lavish hemlock
#

MultimapBuilder.hashKeys().arrayListValues().build() ;)

rough drift
#

wait what are you talking about

ivory sleet
#

Multimap is just Map<K,Collection<V>>

rough drift
ivory sleet
#

Then we have ListMultimap<K,V> which is Map<K,List<V>>

lost matrix
#

*Was referring to the default HashMultimap

sacred mountain
lost matrix
#

I think multi map is badly designed. It hides a nested collection that deserves its own class.

sacred mountain
#

but then how would i check for itemstacks

#

i would have to use strings to check and thats a bit weird

#

or some kind of key

tardy delta
#

check for itemstacks?

ivory sleet
lost matrix
#

custom ItemStacks should be identified using a pdc

sacred mountain
#

=can i put different types in the multimap key

#

?

rough drift
#

oh yeah PDC

ivory sleet
#

But I can see it being a good abstraction to provide in apis

lavish hemlock
#

There is no point in not hiding the collection when you shouldn't be caring about the collection type from an API standpoint

rough drift
#

@sacred mountain make a namespaced key, then on use add that namespaced key with a certain cooldown to the item, and decrease it/check if enough time passed

sacred mountain
#

so is it better to use Hashmap<UUID, <ItemStack, Long>> or the multimap

rough drift
#

use PDC

lavish hemlock
#

My problem with Multimap (and other Guava types) is the lack of Gson support.

ivory sleet
#

Maow don’t they ship type adapters for those

lavish hemlock
rough drift
#

wrong one

ivory sleet
#

(Then ofc you need to use it with type tokens)

lavish hemlock
#

Not even in their type adapter repo

rough drift
ivory sleet
#

Oh that’s odd

lost matrix
lavish hemlock
#

I mean I can see what you mean

ivory sleet
#

Thought I read some code where they registered guava coll type adaps

tardy delta
lavish hemlock
#

But I think that they didn't design Multimap for that purpose or smthn

ivory sleet
#

Yeah

lavish hemlock
#

True that the second type should be specified properly tho

#

SetMultimap/ListMultimap would fix that

ivory sleet
#

For instance it can be very nice as when you pass an argument to a function

#

Where you just need a generic one to many

lavish hemlock
#

Oh yeah also it's obnoxious to do certain operations on a multimap

#

I don't remember which ones

#

But-

#

ah right

#

getting a key from a value

lost matrix
#

Quite a bit of code in guava is outdated. Example Maps.newHashMap(). This was designed because java 7 didnt allow empty diamonds for generic types.

ivory sleet
#

Ye

lavish hemlock
#

The versions with arguments are better tho

tardy delta
#

ye

lavish hemlock
#

Since they allow you to declare maps in single lines

#

As opposed to the fucking

create map
put
put
put
put
return map
#

behemoth

lost matrix
#

I think we lost someone on the way that needed help...

lost matrix
tardy delta
lavish hemlock
#

ImmutableMap builders are cool

#

except for the fuckin'

#

type parameters...

#

those... type parameters

#

Eh, Rust has it worse

#

fuckin' uhh

#

turbofish

#

MyStruct.help::<&str>()

#

I think that's it I'm not sure

sacred mountain
lost matrix
#

100%

#

Wait... are the abilities on the ItemStack?

sacred mountain
#

yea kind of

lost matrix
#

If you have the same ItemStack 2 times, should you be able to cast the spell 2 time in succession?

sacred mountain
#
    private final Map<ItemStack, Long> cooldownInnerHash = new HashMap<>();

    public void getCooldown() {
        cooldowns.put(UUID.randomUUID(), cooldownInnerHash);
        System.out.println(cooldowns);
    }```
sacred mountain
#

until that cooldown is up

lost matrix
#

So the ItemStack does not contain the spell at all? It just triggers it.

lost matrix
#

Then you should not used PDCs nor ItemStacks.
Something like

Map<UUID, Map<SpellType, Long>>

Would be the cleaner approach.
And even wrap the Map<SpellType, Long> in a serializable SpellCooldownDomain or SpellCooldownContainer

sacred mountain
#

SpellType would be my own class right

lost matrix
#

Yes it would be an enum. Ive chosen an enum because its easily serializable.

#

You could also make this a bit more dynamic if you wanted. But then serialization gets really complicated.

sacred mountain
#

public enum SpellType {
FIREBALL,
TNT,
}

lost matrix
#

right

sacred mountain
#

how do i like those enums to the correct items

#

link*

#

i would guess something like this

lost matrix
#

You add a pdc to the ItemStack.
Key: Spells
Value: SpellType[]

Then in the interact event you check if the ItemStack has this key and then you get all
values and let the player cast it.

lost matrix
sacred mountain
lost matrix
#
public enum SpellType {

    FIREBALL(1000L),
    TNT(2500L);

    SpellType(long coolDownMs) {
        this.coolDownMs = coolDownMs;
    }

    private final long coolDownMs;

    public long getCoolDownMs() {
        return coolDownMs;
    }

}
sacred mountain
#

ohhh right i did that for strings before

quaint mantle
#

How do I make a event like onServerLog so like when the console adds a log to the console i get it as a string

#

And do something with it

sacred mountain
#

.put(SpellType.FIREBALL, SpellType.FIREBALL.getCoolDownMs())

lost matrix
lost matrix
lost matrix
sacred mountain
#

uh

quaint mantle
tardy delta
#

uggggh

#

it basically logs string output to a console/ file

#

im not the best explaining this lol

#

7smile you can help me 🦈

lost matrix
# sacred mountain uh

Take one step at a time. Try to quantify your problem.
First: How do i "map" an ItemStack to a SpellType
So define 2 methods:

    public List<SpellType> getSpells(ItemStack itemStack) {
        
    }

    public void addSpell(ItemStack itemStack, SpellType spellType) {

    }

And think of them like a closed system. (Meaning those methods are not concerned about anything else but their single task)

quaint mantle
#

I think what 7smile said about the stdout data might work I will learn about it

lost matrix
# lost matrix Take one step at a time. Try to quantify your problem. First: How do i "map" an ...

If you still have problems defining the problem then try to first define the responsibility of this method with a doc comment:

    /**
     * This method returns all SpellTypes on this ItemStack.
     * If there are no SpellTypes present then an immutable
     * empty List is returned.
     * @param itemStack the input ItemStack
     * @return A List of SpellTypes
     */
    public List<SpellType> getSpells(ItemStack itemStack) {

    }

Now we just need to think on how to implement this properly

#

Hint: A PDC entry can contain several Strings and therefore several Enums

quaint mantle
#

How does logging data work?

lost matrix
#
    PrintStream yourCustomPrintStream = ...;
    System.setOut(yourCustomPrintStream);

This would be one approach. Its not a logger but replaces stdout.

#

Probably a good idea to just wrap the original stdout and delegate its data.

quaint mantle
#

Thanks I will try to go from here and some more research about this topic I am creating a nice php website that uses rcon to send commands and a plugin to get the console data

lavish hemlock
#

php

ivory sleet
tardy delta
#

why wrapping stdout if you can write a handler?

#

👀

lost matrix
#

Was about to say

sacred mountain
#

llol

#

i was gonna ask this previously, but is there a difference between the NMS itemstack and the org.bukkit one

quaint mantle
sacred mountain
#

when i import it it askes me

lost matrix
lavish hemlock
quaint mantle
#

Some people like php I don't think anything is wrong with it its actually quite nice when u use it for making stuff like a simple task

lavish hemlock
#

I feel like a common trend for very like

#

divided languages

#

where a lot of people hate them but a lot of people love them

#

is that they're always

ivory sleet
#

I know it had some major flaws, and ever since, it is sort of notoriously known for those very aforementioned things

lavish hemlock
#

"quite nice for simple tasks"

#

but then nobody uses them for just simple tasks

#

cough cough Skript

ivory sleet
ebon coral
#

Skript is gross

#

I am concerned it has been spoken about here

lavish hemlock
#

When a language is "quite nice for complex tasks" but then "real terrible for simple tasks," that's when you've reached Java territory ;)

ivory sleet
#

I find it decent if you’re just doing something small

lost matrix
#

If you want to quickly write a simple task then you can just write a SpringBoot app in no time. Or Quarkus.
Or if you feel really extra then even a nodejs app. Or Python Flask. Or a quick rails app.
I think all of those things are quicker written for simple tasks than php.

ebon coral
#

Yeah of course, but kids making servers off of it make me cringe.

#

Like straight up prison servers, jesus christ.

ivory sleet
#

But the implementation of Skript is probably not very solid in terms of performance I’d presume

lavish hemlock
ebon coral
#

An actual nightmare.

ivory sleet
#

Lol

sacred mountain
ebon coral
#

I did Skript for 4 years

ivory sleet
#

Prison Core Skript, all inclusive 💯

ebon coral
#

Nightmare

#

Look at this

#

LOL

#

Actually terrifying

ebon coral
#

Prison server in skript

#

I had to make

ivory sleet
ebon coral
#

$$ but still gross

#

Java > any day

#

Kids still try to argue you can use Java in Skript with addons and stuff but just why

#

Literally just learn Java

#

:(

ivory sleet
#

Myeah, but you have to recompile it just every so often

ebon coral
#

I encountered many arguments back in my Minehut era

#

About it

#

And for that reason, I left.

sacred mountain
ebon coral
#

Alright, time to make an NMS tablist... I might cry.

lost matrix
#

You basically extract the SpellTypes from that ItemStack

sacred mountain
#

so when would it be called?

#

oh right

lavish hemlock
# lavish hemlock Why do I think Java isn't good for simplicity? Well...

There is no way to use it as a small scripting language, although java MyClass.java exists and we have jshell as of 9.
...although it's also still a shithead to run since classpath + version management (praise our lord SDKMAN!).
(Also you have to declare a full class)
I know this isn't what it was meant for, but Java has a strong ecosystem that would be great with some proper scripting support.

My other reason is personal opinion: Too much ceremony.

sacred mountain
#

so if (itemstack.getType().equals(Material.FIREBALL) && itemstack.getItemMeta.getdisplayname(fireball) blahblah )
THEN
return spelltype.firebal

lost matrix
#

At this point you dont care where its gonna be called. Could be in the PlayerInteractEvent
Or the InventoryClickEvent if you want to prevent letting the player move it.
Or in any other event that has access to ItemStacks,.

sacred mountain
#

i dont need a list beacuse theres only one per item

#

im not going onto adding multiple abilities yet

lost matrix
lavish hemlock
lost matrix
#

And you should do that using pdcs

ebon coral
#

Is it possible to create a fake CraftPlayer or something (trying to make fake tab entries)

#

I haven't worked with NMS since 1.8 and this may not be so fun adapting to 1.18

sacred mountain
lost matrix
ebon coral
#

Why does this return GameProfile and yet I have no GameProfile class

#

Depression

sacred mountain
#

theyre fixed on one item

lavish hemlock
ebon coral
#

I am losing braincells

lavish hemlock
#

Essentially IDEA recognizes that the type exists in the source file

ebon coral
#

Yeah yeah but I have both spigot-server and spigot-api implemented

lavish hemlock
#

Buuut it also has no idea where the fuck it is

ebon coral
#

Where would the authlib library be then lol?

lavish hemlock
#

Probably under Mojang's repo

ebon coral
#

Which I think is where GameProfile is

lavish hemlock
#

One sec

ebon coral
#

Ok ily

lavish hemlock
#

That's probably not right

#

but

ebon coral
#

Kobe

#

About 2 find out XD

#

Ye ye it was

#

Ily

lost matrix
sacred mountain
#

i just use an interact event and check if the item name is the custom one and the material is the correct item

#

i guess its a bit of a bad way

#

i should store the data but eh its not like players can abuse it in my game

lost matrix
#

You shouldnt care about anything else but implementing those two methods

sacred mountain
#

ok

#

ill try

lost matrix
# sacred mountain ill try
    private final NamespacedKey spellKey = Objects.requireNonNull(NamespacedKey.fromString("spells:itemkey"));

    public SpellType getSpell(ItemStack itemStack) {
        if (itemStack == null) {
            return null;
        }
        ItemMeta meta = itemStack.getItemMeta();
        if (meta == null) {
            return null;
        }
        PersistentDataContainer container = meta.getPersistentDataContainer();
        String spellStr = container.get(spellKey, PersistentDataType.STRING);
        if (spellStr == null) {
            return null;
        }
        return SpellType.valueOf(spellStr);
    }

    public void setSpell(ItemStack itemStack, SpellType spellType) {
        Preconditions.checkArgument(itemStack != null && spellType != null);
        ItemMeta meta = itemStack.getItemMeta();
        Preconditions.checkArgument(meta != null);
        PersistentDataContainer container = meta.getPersistentDataContainer();
        container.set(spellKey, PersistentDataType.STRING, spellType.toString());
        itemStack.setItemMeta(meta);
    }

🥣 blobspoonfeed

tall dragon
#

hey @lost matrix i talked to you yesterday about evenly distributed workloads & i think i've wrapped my head around how it works and im very pleased with it. thanks again for a great explaination.

tardy delta
#

why people using Preconditions.checkArgument(obj != null) instead of Validate.notNull(obj) kekw

tardy delta
#

owo

lavish hemlock
#

hah furry

lost matrix
#

There is also Preconditions.checkNotNull(obj);
But checkArgument makes it more clear that the passed method arguments are invalid

tardy delta
#

💀

lavish hemlock
#

Okay but why are people using either when Objects.requireNonNull(obj)?

#

Oh yeah also

tardy delta
#

returns the obj if notnull instead of just throwing

lost matrix
#

Objects.requireNonNull is for fail fast delegation

#

not to check a state

lavish hemlock
ebon coral
#

fakePlayerProfile.getTextures().setSkin(new URL("http://textures.minecraft.net/texture/847b527998465154ad6c238a1e3c2dd3e32965352e3a64f36e16a9405ab8"));

#

Is there an easier way to do this besides this?

#

Like back in the day I could do .getProperties().put("textures", blah blah

#

Or does it have to be this way now?

lavish hemlock
#

Postcondition is easy enough to do if you create your own Result/Option classes (also yes, Option, because Optional would be lacking support for your new Result class)

lost matrix
lavish hemlock
#

Result is an Either type

#

Typically...

#

Result<T, E extends Exception>

#

It's a replacement for checked exceptions that, imo, gives devs more control

#

I created a lib for this kinda shit

tardy delta
#

is Command#getAliases a mutable collection? im trying to add an alias

lost matrix
lavish hemlock
#

Not true

#

They are not evaluated once

#

They are evaluated per call

#

While their code is lazy

#

Their result is not

tawny prawn
#

Hey, my PlayerAdvancementDoneEvent is being fired multiple times, when someone makes an achievement. any idea why or a fix?

lavish hemlock
#

I use the word "lazy" to describe the one-time caching of values too

lost matrix
#
@RequiredArgsConstructor
public class Lazy<T> {

  private T value;
  private final Supplier<T> supplier;

  public T get() {
    return this.value == null ? this.value = this.supplier.get() : this.value;
  }

}

I just called it "Lazy"
And yes suppliers are per definition always lazy. They just dont cache the result.

lavish hemlock
#

I don't call it Lazy bc of LazyFunction

lost matrix
#

i see

lavish hemlock
#

In fact actually

#

It would be more accurate to call it like

#

SupplierLazy and FunctionLazy

#

but honestly that looks worse so no

lost matrix
#

Yes it looks weird

lavish hemlock
#

Surprised you didn't comment on Erie's most controversial feature :)

tardy delta
#

call it LazyMaow

#

😳

lavish hemlock
lost matrix
lavish hemlock
#

Yes

lost matrix
#

So if the dev isnt careful you shoot him in the knee basically

lavish hemlock
#

Yeah exactly

lost matrix
#

lul

lavish hemlock
#

The idea behind it is:

#
  • Use unwrap for shit where you know the value will never fail
  • Use gracefully handling for everything else
#

It's also just good for prototyping

#

Yes I stole the design of that entire library from Rust

smoky oak
#

you're a programmer

#

not a designer

#

thats not really a issue

lavish hemlock
#

Exactly ✨

lost matrix
#

looks interesting. But sadly its not compatible with all the Optionals currently used

lavish hemlock
#

Actually you make a good point

#

I never thought about Optional -> Option compat (and vice-versa)

lost matrix
#

Maybe some conversion functions to easily pipe one into the other would be a good idea

lavish hemlock
#

Yeah that was the idea

#

e.g. uh

#

Option.from(Optional) and Option.toJava() // Optional/toOptional()

smoky oak
#

uh can i throw in two questions of my own, before you guys keep talking the next hour about code design?

lavish hemlock
#

Yeah

smoky oak
#

so 1) to write a library, do i need to do more than define public functions and import said library into a project?

lavish hemlock
#

I

#

suppose so?

#

I mean libraries aren't just public functions

#

Unless they're like a collection of interfaces

#

like uhh service providers, adapters (like Bukkit), etc.

#

Usually under the public stuff, you have some private implementation, which is where encapsulation comes in handy.

#

I mean my full username is an encapsulation joke

#

See uhh on GitHub my profile says

#

oh wait nvm

#

but anyway so MaowImpl but I usually go by Maow

#

Shit Java joke, yes

lavish hemlock
smoky oak
#

i think i know what you mean tho

lavish hemlock
#

At most you need basically

#

An entrypoint

#

That can be like, an abstract class, or maybe a final, uninstantiable class containing static methods.

smoky oak
#

does setting a class final make it unable to be extended/implemented?

lavish hemlock
#

Yeah

#

Uninheritable is the word you're looking for

#

Although you can't make a final interface

smoky oak
#

considering interfaces are meant to be inherited

last tulip
#

is there any simple code to send an action bar to player? like
player.sendActionBar(...args...)

smoky oak
#

I suppose that makes sense

lavish hemlock
#

I have this common pattern in my project for util classes:

public final class FuckUtils {
    private FuckUtils() {
        throw new UnsupportedOperationException():
    }

    public static void util() { ... }
}
tardy delta
lavish hemlock
smoky oak
#

huh manually throwing an exception might be useful tho

tardy delta
#

wait why throwing an exception in a private constructor

lavish hemlock
smoky oak
#

cant be created

tardy delta
#

grr reflection

lavish hemlock
#

It literally cannot be created unless you use Unsafe

#

But at that point I give up lol

smoky oak
#

eh fair

#

my second question is a bit more complicated tho

#

is there a simple way to check if a structure (resources/structure.nbt) is present in the world at specific coordinates?

#

if yes how

lavish hemlock
#

Probably not

#

Well

last tulip
lavish hemlock
#

Structures? Hmm

smoky oak
#

well

lavish hemlock
#

Definitely not schematics

smoky oak
#

either would be fine

lavish hemlock
#

You'd have to ask someone else I know fuck all about structures