#help-development

1 messages ยท Page 1400 of 1

wraith rapids
#

i never remember his full name

#

or the name of the plugin

#

or anything really

young knoll
#

Damage history sounds neat

#

Not very useful but a fun concept

vast quest
#

just a little flex

lost matrix
#

And you can expand on that plugin for learning json messages to scroll through your history.
And writing it first without a persitence layer and later adding flatfile and then database support...

young knoll
#

Ah yeah you could hook up clickable components to /damagehistory <page>

vast quest
#

What does this do when I try to implement listener it sometimes adds this aswell @Override public @NotNull Logger getSLF4JLogger() { return super.getSLF4JLogger(); }

wraith rapids
#

you probably clicked something or told your ide to override a method

#

which it then did

vast quest
#

o well

#

huh... ok this is going to sound stupid but how can I uh save smth on the player

#

sry im new

#

like store a value on a player

wraith rapids
#

get the player's PersistentDataContainer

vast quest
#

like a varuable

wraith rapids
#

if you want the data to be persistent, that is

#

get the pdc

wraith rapids
#

if you don't care about the data poofing when the server restarts

#

create a Map<UUID, yourdata>

#

and then hold that in your main plugin instance of whatever

#

if you want to save something simple, like a single String, make it Map<UUID, String>

#

but if you want to store lots of stuff

vast quest
#

nah I need to save it

wraith rapids
#

like first join date and other things

#

then create a class that holds each of those things

#

and make it Map<UUID, that class>

vast quest
#

I just need to store 1 thing

mellow crest
#

hi

vast quest
#

for the damage history

wraith rapids
#

if you want to persist it, use the persistent data container

mellow crest
#

how i can use event uhc

wraith rapids
#

Player implements PersistentDataHolder

#

PersistentDataHolder declares a method getPersistentDataContainer

mellow crest
#

?

wraith rapids
#

for large amounts of data you'd probably want to look into a db but that's probably excessive by this point

eternal night
#

^

mellow crest
#

how i get customitems

eternal night
#

what custom items ?

wraith rapids
#

/give me customitems

eternal night
#

lol

mellow crest
#

can someone call me pls ๐Ÿ™‚

young knoll
#

Storing damage history does seem like a bit much for pdc

mellow crest
#

in discord

eternal night
#

๐Ÿ‘€

young knoll
#

It would fit well into sql, but json is another option

wraith rapids
#

bukkit config api is the obvious choice

young knoll
#

I mean it is quite simple

#

But after using gson for the first time itโ€™s great

mellow crest
#

can y

wraith rapids
#

no

#

go away

lavish nacelle
#

Is there a better method for loading a datapack from a plugin jar than copying it to the world's datapack folder?

wraith rapids
#

i haven't really screwed with datapacks, but tbh, probably not

#

i don't think bukkit really acknowledges the existence of datapacks quite yet

mellow crest
#

can someone pls pm me ๐Ÿ˜ฃ

lavish nacelle
#

I guess a method to register tags at runtime would also work

wraith rapids
#

that sounds like something that might exist, but I haven't really looked into it at all

young knoll
#

There is a bukkit datapack

#

But itโ€™s not really a finished system

lavish nacelle
#

Ya I noticed it while looking for solutions

young knoll
#

So yeah, copying it and reloading data packs is probably the best option

mellow crest
#

how to use spingot 1.14

wraith rapids
#

lmao

mellow crest
#

??

young knoll
#

1.14 is outdated

#

Also

#

?bt

queen dragonBOT
wraith rapids
#

and also the wrong channel

lavish nacelle
#

I guess my next question than is, is there any not painful way to copy a directory from a plugin jar to the world folder =[

rapid vigil
#

Hey, I am using Packets / nms, and I've heard that using :

```<dependencies>
    <dependency>
        <groupId>org.spigotmc</groupId>
        <artifactId>spigot</artifactId>
        <version>1.12.2-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

</project>```

Is so much better than using :

        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.12.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>```
#

But when trying to use the spigot one it doesn't find it

young knoll
#

Pretty sure mc can load zipped datapacks

wraith rapids
#

there is extract all resources, but that will extract all resources

lavish nacelle
#

Ya...

wraith rapids
#

and yeah, the server can handle zips

young knoll
#

Which I imagine you can copy quickly with plugin.getResource

lavish nacelle
#

Oh well ok that helps

lavish nacelle
#

So I'll just zip it on compile and than extract that

dusk flicker
#

You can't use the api for nms either way

wraith rapids
#

sounds about right

rapid vigil
#

I know

young knoll
#

To use spigot you need to run buildtools for that version

wraith rapids
#

real men just reflect into everything

#

only reason to even depend on spigot-api is that you can't reflectively extend a class

rapid vigil
young knoll
#

No

rapid vigil
#

What then

young knoll
#

It should be in your local maven repo

rapid vigil
#

I don't think it is

lavish nacelle
#

If you're using an ide

#

Restart it

rapid vigil
#

Ah

#

I'll try restarting it

wraith rapids
#

you can always just path into .m2 manually and check if it's there

lavish nacelle
#

Ya thats also a good idea

rapid vigil
#

Restarted, but still the

        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.12.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project> ``` Doesn't work with the error : Dependency 'org.spigotmc![spigot](https://cdn.discordapp.com/emojis/728421352721088542.webp?size=128 "spigot")1.12.2-R0.1-SNAPSHOT' not found (line 70)
#

Line 70 is the :
<artifactId>spigot</artifactId> btw

young knoll
#

I assume you ran buildtools for 1.12

rapid vigil
#

I am running build tools for 1.12.1

lavish nacelle
#

Well there's your issue

wraith rapids
#

i've sometimes had an issue with ij where I had to manually declare the local maven repo as a local repository

#

which was weird as fuck

lavish nacelle
#

You're trying to use 1.12.2 but you've built 1.12.1

rapid vigil
#

Wait it works..

#

Yes

#

Literally works, but I've ran another buildtools for 1.11.2, When I try to use : <version>1.11.2-R0.1-SNAPSHOT</version> it doesn't work, basically doesn't find the version

#

I've added a 1.11.2 jar to the libraries, while the version in pom is 1.12.1, will it still work in 1.11.2?

wraith rapids
#

if you use your ide's libraries, maven can't build it properly

#

because your ide is not maven and maven is not your ide

rapid vigil
#

I am using Intellij

wraith rapids
#

yes

#

if you use your ide's dependency management, that is, import libraries with your ide, you need to build it with your ide

#

if you use maven for depencency management, that is, import libraries via pom, you need to build it with maven

#

intellij has a fancy button to build it with maven

#

but if you add a library with your ide, maven won't know about it, and can't then build the project

rapid vigil
#

I am adding libraries from : Project Structure > Libraries and then I add the jar

wraith rapids
#

yes, that is adding libraries through the IDE

#

maven does not know about those libraries

#

it can't build your project

rapid vigil
#

How do I add it via pom?

wraith rapids
#

you add the dependency information to your pom

#

as you would with any other dependency

vast quest
#

NNY do you know any easy way to get the particlepackets

wraith rapids
#

the what

vast quest
#

since well uh I believe WORLD_PARTICLES packet dont really work

#

with every particle

wraith rapids
#

why do you need packets

vast quest
#

since like for sum reason doin other stuff does not generate particle pacekts

rapid vigil
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.12.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>``` This is how do you import the libararie via pom?
wraith rapids
#

you can spawn particles through the api

vast quest
#

yes but I need to remove the particles

wraith rapids
#

yes, that is how you add a dependency to your maven project

#

not all particles are server-side

#

the client spawns some of the particles on its own

#

same with sounds

vast quest
#

u also need the repository

#

pretty sure

wraith rapids
#

you shouldn't need the repository here, since it should be in your local maven repository

#

check whether it is there; open up your .m2

rapid vigil
#

Yes but, There's only 1.12.1, and If I do <version>1.11.2-R0.1-SNAPSHOT</version> It doesn't find it

wraith rapids
#

then you need to build 1.11.2-R0.1 shapshot blah blah

#

you can't depend on something you don't have

minor garnet
#
        String[] sword = { "DIAMOND_SWORD", "IRON_SWORD", "GOLDEN_SWORD", "STONE_SWORD", "WOODEN_SWORD"
                + "DIAMOND_PICKAXE", "IRON_PICKAXE", "GOLDEN_PICKAXE", "STONE_PICKAXE", "WOODEN_PICKAXE"
                + "DIAMOND_AXE", "IRON_AXE", "GOLDEN_AXE", "STONE_AXE", "WOODEN_AXE", "DIAMOND_SHOVEL"
                + "IRON_SHOVEL", "GOLDEN_SHOVEL", "STONE_SHOVEL", "WOODEN_SHOVEL", "DIAMOND_HOE" 
                + "IRON_HOE", "GOLDEN_HOE", "STONE_HOE", "WOODEN_HOE", "BOW", "FISHING_ROD", "BLAZE_ROD"
                + "STICK", "BONE"};
        for (String string : sword) {
            LootManager.items.add(string);
        }```
NNY
wraith rapids
#

you can't have something you don't build

#

i suppose that is vaguely better

rapid vigil
wraith rapids
#

LootManager.items is a Set, yes?

minor garnet
#

public static Set<String> items = new HashSet<>();

wraith rapids
#

if you want to depend on 1.11.2-R0.1-SNAPSHOT, then you need to build 1.11.2-R0.1-SNAPSHOT

#

if you want to depend on 1.12.1, you need to build 1.12.1

minor garnet
#

I would like to use at least the end of SWORD to not have to define each type of item

rapid vigil
#

How do I build the snapshot?

wraith rapids
#

i don't know

#

i don't use spigot

rapid vigil
#

What do you use

wraith rapids
#

paper

#

yeah, the compiler doesn't care about newlines

rapid vigil
#

You use the :

        <dependency>
            <groupId>com.destroystokyo.paper</groupId>
            <artifactId>paper-api</artifactId>
            <version>1.12.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>``` right?
wraith rapids
#

you can iterate over all Materials and check name().contains("_SWORD") if you want all swords

#

or you can use one of the material tags

#

that is how you add paper API of version 1.12.2-R0.1-SNAPSHOT as a dependency, yes

rapid vigil
#

Yes, that's what I use too, but with paper you can't use packets / nms right?

wraith rapids
#

for nms and packets and shit, you want paper instead of paper-api for 1.12.2-R0.1-SNAPSHOT

#

and the only way to get paper instead of paper-api is to build paper locally

#

read their github readme, clone the repo, and run the build script

#

same principle as with spigot, but instead of buildtools, there's a build script

rapid vigil
#

What's the difference between coding in paper or spigot?

wraith rapids
#

paper is better

minor garnet
#

its working xd

rapid vigil
#

I code in paper too

wraith rapids
#

paper contains everything spigot contains, but has more utility methods and stuff that makes your life easier

rapid vigil
#

But when trying to build the project while using packets, It gives me errors and doesn't build

wraith rapids
#

yes, that is because you haven't imported paper

minor garnet
#

my view of the paper and that it has methods that spigot doesnโ€™t have

wraith rapids
#

you've imported paper-api

rapid vigil
#

Yeah I use paper-api

wraith rapids
#

which does not contain NMS or packets

minor garnet
#

#Block.getHitBlockFace();
#OnCollideEvent etc

rapid vigil
#

Yes but, when I build artifacts the plugin works good

eternal oxide
#

Only build against a fork if you NEED some method from that fork.

minor garnet
#

but is there a way to make a projectile not collide with another one in the spigot?

wraith rapids
#

server owners who want your plugin to perform well will probably disagree with the concept of 'NEED' though

eternal oxide
#

Build against Spigot and it runs on everything

rapid vigil
#

Yes but, how do you use paper instead of paper-api?

wraith rapids
#

like I explained

#

you build paper locally

rapid vigil
#

Oh

wraith rapids
#

and then change the paper-api text in your pom.xml to paper

rapid vigil
#

Just like BuildTools?

wraith rapids
#

pretty much

#

spigot has build tools, paper has a build script

rapid vigil
#

Yeah but how do I build paper locally

wraith rapids
#

read their readme

#

it's explained on their github

rapid vigil
#

Where do I find the readme

wraith rapids
#

on the fucking github

rapid vigil
#

Ok that's enough acting dumb XD

wraith rapids
#

you'll have to select a 1.12 branch of the github repo

#

assuming they even have one

sharp bough
#

is there something wrong here?
(Main.get().getConfig().get("tiers." + currentTier + ".items." + (itemCount + 1))) == null

wraith rapids
#

depends on your definition of wrong

rapid vigil
#

There right?

wraith rapids
#

yes

mortal hare
#

is arraylist's setting reference implementation atomic?

eternal night
wraith rapids
#

select the 1.12 branch

eternal night
#

is the branch you want

eternal night
#

you build paper locally by checking out the repository and running ./paper jar in a bash environment

wraith rapids
#

define "setting reference implementation"

sharp bough
mortal hare
sharp bough
mortal hare
#

ik its not synchronised

#

but im wondering if setting the reference data

#

is atomic

rapid vigil
#

I don't find the readme..

wraith rapids
#

it's the page you land on

rapid vigil
wraith rapids
#

the readme is the text you see on the "front page" of a repository

#

what do you mean by atomic in this context

#

there are no two actions happening concurrently

#

or two actions happening at all

#

you are just setting data

#

at some index in the underlying array

rapid vigil
#

This one right?

wraith rapids
#

yes, now read the text

#

"how to (compiling jar from source)"

vast quest
#

How can I give a mob an enchanted armor?

wraith rapids
#

if you mean the retrieved value that set method returns, no, it's not atomic

vast quest
#

nah like

#

mob.getEquipment().setItemInMainHand(new ItemStack(Material.DIAMOND_AXE)); this<

eternal night
#

there is setHelmet ?

rapid vigil
#

Do I need GitBash to build paper locally?

eternal night
#

yes

wraith rapids
#

yes

vast quest
eternal night
#

or any other bash based shell

#

what is your question then xD

vast quest
#

uh

eternal night
#

create an enchanted item stack

vast quest
#

to make it enchanted

eternal night
#

and pass it in there

rapid vigil
#

So the code is :

./paper jar

in the gitbash right?

vast quest
#

uh that was kinda my question on how to do it

eternal night
mortal hare
#
    public E set(int index, E element) {
        Objects.checkIndex(index, size);
        E oldValue = elementData(index);
        elementData[index] = element;
        return oldValue;
    }
``` it seems setting data to array list index is atomic, since primitive arrays need synchronisation for multiple threads to see results properly, but their setting is atomic but i don't care for that, since i don't need to synchronise it in orderto work
#

am i right?

wraith rapids
#

probably not

mortal hare
#

Well array index write according to my sources is atomic

eternal night
#

I mean, is it guaranteed tho that the entire set call is executed at once ?

wraith rapids
#

write is yes

#

i mean, there isn't anything to be atomic with

#

it's a single operation

rapid vigil
#

I need Paper jar in a File and gitbash in that file?

mortal hare
#

that's what matters for me

eternal night
#

I mean, it is two operations.

#

a read and a write

wraith rapids
#

ArrayList set is yes

#

but array[n] = value is just a single operation

minor garnet
mortal hare
#

bad mafs

eternal night
#

but the write itself is fine

mortal hare
#

eh

rapid vigil
#

To build paper locally Is it just like BuildTools? Paper jar in a file and gitbash in that file?

wraith rapids
#

well... ArrayLists can shuffle and shift elements

mortal hare
#

my arraylist is guaranteed to be

#

fixed sized

eternal night
#

you navigate to the paper repository and simply run ./paper jar

#

that is it

wraith rapids
#

so if someone does like insert in the middle of this, the index you're writing to might be inaccurate

mortal hare
#

this possibility is impossible in my case

eternal night
#

if no one can do that, why care if it is atomic xD

mortal hare
#

well no one can shift the array or extend it

#

but set index of it

#

its like primitive array

eternal night
#

ah. well in that case you should be fine then

wraith rapids
#

atomic is when multiple operations behave as if they were one operation; they can't be split and their execution order can't be changed, and they will either all fail, or all succeed

mortal hare
#

i was just asking if i do write arraylist with async runnables without sync wouldnt i get undefined results

eternal night
rapid vigil
#

Yes

eternal night
#

in the folder you downloaded buildtools in

#

yes

#

instead of downloading a jar

#

you clone the paper repository

#

using git

rapid vigil
#

clone the paper repository?

wraith rapids
#

well, arrays aren't volatile

eternal night
#

yes

rapid vigil
#

How..

eternal night
#

๐Ÿ‘€

wraith rapids
#

so yes, you may get memory visibility issues if you are both reading and writing

eternal night
#

Have you never cloned a git repository ?

#

o.O

#

aight

rapid vigil
#

I don't think so

wraith rapids
#

and there is no guarantee that a write on thread A is visible on thread B

eternal night
#

basically somewhere on your file system you run git clone https://github.com/PaperMC/Paper.git

mortal hare
#

well fuck then

wraith rapids
#

what're you doing though

mortal hare
#

im modifying packet handling

#

inside async method

rapid vigil
mortal hare
#

and the arraylist is in NMS

#

and its not concurrent implementation

eternal night
#

just. wherever you want the project to be located

mortal hare
#

i guess i would need to synchronise the writes with the main thread

rapid vigil
#

It's not like download paper jar and place it in a file then run the code : ./paper jar right?

eternal night
#

no

wraith rapids
#

no, do not download paper jar

eternal night
#

there is no "build tools jar" for paper

rapid vigil
#

Yes sadly

mortal hare
#

just download paperclip

rapid vigil
wraith rapids
#

you clone the repository, then you build the repository

#

and you're done

rapid vigil
eternal night
#

paperclip doesn't work

wraith rapids
#

step 1

#

basically somewhere on your file system you run git clone https://github.com/PaperMC/Paper.git

eternal night
#

but, but I literally send you the command

mortal hare
wraith rapids
#

this clones the repository

eternal night
#

๐Ÿ˜ญ

wraith rapids
#

then, you run ./paper jar

mortal hare
#

i import the build to the maven

wraith rapids
#

this builds the repository

#

and you are done

mortal hare
#

although

#

i should do that instead

rapid vigil
#

I need to gitbash somewhere in the files?

eternal night
wraith rapids
#

you just gitbash anywhere

#

and then you run the clone command in gitbash

mortal hare
wraith rapids
#

and then you run the paper jar command in gitbash

rapid vigil
#

Oh

wraith rapids
#

it's not rocket science

eternal night
#

and how did you get it there ?

mortal hare
#

via maven command?

eternal night
#

and did you have to clone paper for that ?

mortal hare
#

maven:install-file

eternal night
#

oh

#

my

#

ew

mortal hare
#

ik

wraith rapids
#

lol

mortal hare
#

im just lazy

eternal night
#

you install paperclip ??

#

does that even work

mortal hare
#

no

#

lol

eternal night
#

that file contains the patch

rapid vigil
#
Cloning into 'Paper'...
remote: Enumerating objects: 71857, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 71857 (delta 5), reused 12 (delta 4), pack-reused 71839
Receiving objects: 100% (71857/71857), 31.92 MiB | 5.78 MiB/s, done.
Resolving deltas: 100% (62283/62283), done.
eternal night
#

yeah

#

lol

rapid vigil
#

This is right?

mortal hare
#

i run the paperclip

#

and install the build from cache folder

eternal night
#

๐Ÿ˜‚

mortal hare
#

im lazy

eternal night
#

lol

mortal hare
#

look how much time he spent just for importing it to the repo ๐Ÿ˜„

eternal night
#

I mean, if you know any form of git this should not take that long

rapid vigil
#

Then I must do ./paper jar right?

eternal night
#

also since when is slowmode enabled o.O

#

you open the git bash inside the cloned Paper folder

#

and then yes, run ./paper jar

rapid vigil
#

Then done right?

eternal night
#

You already cloned paper right ? You ran the git clone command

#

my aggression towards a 5 second slow mode is immeasurable

solemn shoal
#

Why is slowmode on? Tf happened

eternal night
#

well no, git clone https://github.com/PaperMC/Paper.git creates the paper folder

chrome beacon
#

Why are we supporting Paper here

#

Also hi Poreyy

rapid vigil
#

hi Olivo

#

Paper is cool, so It's supported everywhere

solemn shoal
#

So is yatopia

sharp bough
#

why does

                    //gets the material of the item
                    mat = Material.valueOf(Objects.requireNonNull(material).toUpperCase().replace(" ", "_"));

                    getServer().getConsoleSender().sendMessage(ChatColor.GOLD + "test3 material: " + material + "mat: " + mat + "items: " + items);

                } catch (Exception e) {
                    getServer().getConsoleSender().sendMessage(ChatColor.RED + "Fatal Error: Item Type Not Found");
                }```
run, shows test3 with no errors but fatal error still prints? doesnt that work when theres an error?
rapid vigil
eternal night
#

yes

chrome beacon
#

What exactly are you trying to do

rapid vigil
#

Yeah but looks like It doesn't work : bash: ./paper: No such file or directory

eternal night
#

install paper into the local maven repo

#

Are you inside the Paper folder with your git bash ?

rapid vigil
#

Yes

eternal night
#

the file definitely exists ยฏ_(ใƒ„)_/ยฏ

rapid vigil
#

hmm

#

Did it work

#

I've got a Paper folder with some files in it

chrome beacon
#

Which version are you using?

rapid vigil
#

Olivo 1.12.1

chrome beacon
#

Omg why

rapid vigil
#

What

chrome beacon
#

At least use 1.12.2

rapid vigil
#

What's the problem If I use 1.12.1

#

Am trying to do it so I can use paper instead of paper-api

#

In the pom

chrome beacon
#

Security issues

dawn phoenix
#

Having an armor stand "ride" the player and show a chest, would that require NMS or can spigot support that?

chrome beacon
#

Use 1.12.2

rapid vigil
#

Yeah

#

This is my pom :

        <dependency>
            <groupId>com.destroystokyo.paper</groupId>
            <artifactId>paper-api</artifactId>
            <version>1.12.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>```
wraith rapids
#

you need to cd into the cloned directory before running ./paper jar, iirc

eternal night
eternal night
rapid vigil
#

owo

chrome beacon
rapid vigil
#

Olivo that gives me an error

#

It doesn't find the paper

wraith rapids
#

did you build it

rapid vigil
#

No I didn't

wraith rapids
#

then that's why

#

build it you doofus

rapid vigil
#

I am already trying to build it

eternal night
#

my man can't find the paper script

rapid vigil
#

But It's kinda not working

wraith rapids
#

you're doing it wrong

#

send a screenshot or something

chrome beacon
#

What does it tell you when you try to build it

eternal night
#

run ls and send the result lol

rapid vigil
#

I basically made a Paper folder, right click gitbash then I ran : ./paper jar

eternal night
#

sigh

#

you don't make the paper folder yourself

rapid vigil
#

And it says : bash: ./paper: No such file or directory

eternal night
#

it is created through git clone https://github.com/PaperMC/Paper.git

rapid vigil
#

I already tried that

eternal night
#

and ?

chrome beacon
#

Are you inside the folder that it generated

rapid vigil
#

Generated a folder with some files in it

eternal night
#

yes

wraith rapids
#

are you inside this folder

eternal night
#

and then you open the git bash inside of it

rapid vigil
#

Oh

#

Then use ./paper jar?

eternal night
#

yes sir

rapid vigil
#

mvn` command was not found in the path and is a required dependency

eternal night
#

do you not have maven installed ?

rapid vigil
#

Maven installed on my PC?

chrome beacon
#

Doesn't look like you have maven

wraith rapids
#

did you forget to read the thing I told you to read

rapid vigil
#

no

wraith rapids
#

To compile Paper, you need JDK 8, maven, and an internet connection.

#

does not have maven

rapid vigil
#

I got jdk 8

wraith rapids
#

maven is not a part of jdk 8

dawn phoenix
rapid vigil
#

I know

wraith rapids
#

you need jdk 8 AND maven AND an internet connection

#

not just 1 of the 3

rapid vigil
#

So do I need to install Maven now?

wraith rapids
#

yes

rapid vigil
#

This link?

chrome beacon
#

Yes

rapid vigil
#

Download it from the 'Link' section right?

chrome beacon
#

Yeah

rapid vigil
#

apache-maven-3.8.1-bin.zip?

chrome beacon
#

Yes

wraith rapids
#

are you able to do anything without several people instructing you for every single step

unreal quartz
#

no i can't read

rapid vigil
#

Yes

#

I can feed my mc chickens

wraith rapids
#

๐Ÿ•‹

rapid vigil
#

Lol

eternal night
#

can't wait for him to have to modify system path to include the mvn bin folder

#

kekw

rapid vigil
#

Do I need to extract the zip folder?

#

Life is much easier while using Eclipse

#

There's no pom on eclipse

chrome beacon
#

What

wraith rapids
#

gsand

eternal night
#

this is entertaining

chrome beacon
#

Poreyy you're installing maven not installing a maven project

#

So there is no POM

rapid vigil
#

ok

wraith rapids
#

@mellow crest

rapid vigil
#

Stop tagging random people

mellow crest
#

what

wraith rapids
#

nothing

mellow crest
#

say

#

what did you want say

rapid vigil
#

I don't want that anymore, I am okay with paper-api

chrome beacon
#

F

wraith rapids
#

lol

rapid vigil
#

Thanks for help everyone

mellow crest
#

what help you neeed itv

rapid vigil
#

What's the problem

mellow crest
#

nothing

#

your ?

olive lance
#
    @Override
    public void perform(Player p, String[] args, HCFPlugin plugin){
        Faction f = plugin.getData().getFaction(p);
        if(f == null) {
            p.sendMessage(ChatColor.RED + "You must be in a faction to use this command!");
            return;
        }
        if(!f.getLeader().equals(p.getUniqueId())){
            p.sendMessage(ChatColor.RED + "You must be the faction leader");
        }

    }
}
``` So i have like a lot of these classes and some of them do both of these checks, just one, or none what other ways could I shrink this down? I keep repeating this check in like 70% of my subcommands
wraith rapids
#

you could have static methods in a class like Preconditions

#

MyPreconditions.hasFaction(plugin, player)

#

if you want you can also include the error message as a parameter so you don't need to send it manually

#

if (MyPreconditions.hasFaction(plugin,p, ChatColor.RED + "You must be in a faction to use this command!")) return;

olive lance
#

ok thanks

wraith rapids
#

if you want to shrink it down even more, you can create a class to hold your localized strings and give it that instead

#

if (MyPreconditions.hasFaction(plugin,p, Messages.MUST_HAVE_FACTION)) return;

#

if you want to shrink it down even more, you can make the preconditions class throw an exception that will be caught by the code that invokes your perform method, so you can drop the if and return

#

MyPreconditions.hasFaction(plugin,p,Messages.MUST_HAVE_FACTION)

#

if you want to shrink it down even more, you can make specific methods in your data retriever class to throw do it for you

#

@NotNull Faction f = plugin.getData().getFactionOrError(player);

olive lance
#

i like that one

#

and the strings too are gonna be config. im just saving that for the last thing i do so i can just end up not doing it

#

lol

wraith rapids
#

throwing exceptions willy nilly is kinda expensive but it should be fine for stuff that is as infrequent as commands are

left swift
#

How can I make armorstand always in the player's place when he walks? Tried with PlayerMoveEvent and teleportation, but then this armorstand is late for the player

wraith rapids
#

there isn't really any way to do that

#

because movement is client-side

mortal hare
wraith rapids
#

the player will always see themselves moving before your server can react to it and move the armorstand

mortal hare
#

i should synchronise this with server main thread right?

wraith rapids
#

the only way would be to mount the armorstand to ride the player, but that kind of fucks with teleportation

#

the list impl absolutely has to be arraylist?

mortal hare
#

yes

#

i can't edit the NMS

#

its predefined as ArrayList

#

its not thread safe

wraith rapids
#

you could always sneakily replace it with some class that extends arraylist ๐Ÿ‘€

#

or is that final

#

i don't rememer

mortal hare
#

well yeah

#

but i don't want to modify it

#

it could lead to bad consequences both for gameplay and for the plugins

wraith rapids
#

i suppose

#

not really anything else to be done than syncing with the main thread

left swift
wraith rapids
#

uh

#

do you need the riding player to be able to see the armorstand?

#

or is it for other players

#

you can hide the armorstand by intercepting and dropping its packets sent to that player if so

eternal oxide
young knoll
#

Couldn't you just send the EntityDestroy packet to that player

eternal oxide
#

slime hitbox

wraith rapids
#

i'm not sure what the client does with entity update packets and shit that are sent for a nonexistent entity

young knoll
#

hmm, good point

wraith rapids
#

it might just ignore them or it might shit itself

young knoll
#

I remember doing it with snowballs in the past, that seemed to work fine

wraith rapids
#

yeah, i haven't really fucked with entity related protocol at all

solemn shoal
#

can i run buildtools to build a spigot jar without decompiling mc again?

wraith rapids
#

paperclip reigns supreme

sudden raft
wraith rapids
#

fair point

left swift
cold tusk
#

How to change the Itemstack enchantment visibility?

solemn shoal
#

idk who was challenging me with spigotav

#

but whoever it is, you'll see ;)

olive lance
#

does potioneffect implement hashcode

young knoll
#

Check the source

solemn shoal
#

@vagrant stratus nice constructor

vagrant stratus
#

Ye

solemn shoal
#

anyways

vagrant stratus
#

constructors not needed, however it runs sooner โ˜บ๏ธ

solemn shoal
#

i just came up with that idea before inspecting your plugin

vagrant stratus
#

your plugin would still get dealt with, just by loading before it i believe

solemn shoal
#

anyways headerless constructors ๐Ÿคค

vagrant stratus
#

It'll probably still be easy to deal with, it just loads sooner :p

solemn shoal
#

also im adding the option to run standalone too

#

incase you want to add it in a startup script

vagrant stratus
#

I wonder how easy it would be to abuse that ๐Ÿค”

wide galleon
#
public class ChatCommand implements CommandExecutor, TabCompleter {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if(sender.hasPermission("ducky.chat")) {
                if (args[0] == "enable") {
                        UI.setChatDisableTrue();
                        sender.sendMessage("ยงaChat is now ยงcยงlEnabled.");
                    }
                } else if (args[0] == "disable") {
                        UI.setChatDisableFalse();
                        sender.sendMessage("ยงChat is now ยงcยงlDisabled.");
                    }
        return false;
    }```
when I do /chat disable or /chat enable, nothing happens
unreal quartz
#

.equals is ur friend

vagrant stratus
#
  1. Check to make sure you have the permission
  2. use .equals
#

You know what's amusing? Having a List you can just easily clear ๐Ÿ‘€

#

gonna be fun OwO

dusty herald
#

loadbefore: */s

vagrant stratus
#

I do that ๐Ÿคฃ

dusty herald
#

wait that works?

vagrant stratus
#

Nah, i do loadbefore: SpigotAV

dusty herald
#

ah

#

does SpigotAV boot at STARTUP?

vagrant stratus
#

however if there's a standalone option, I'm very certain i have ways to fuck around with that

#

I've done this since 2019, pretty sure i can think of some ideas ๐Ÿคฃ

unreal quartz
#

replace spigot jar

dusty herald
#

just get every spigot plugin and add it to an array on plugin.yml's loadbefore

vagrant stratus
#

don't need to actually

#

who wants to be the first to point out the issue?

unreal quartz
#

the username

vagrant stratus
#

nope

#

it's in the class

unreal quartz
#

thearcanebrony

dusty herald
#

totally not the > "Debug.Log Debug Info"

vagrant stratus
#

ScanResults ๐Ÿคฃ

#

that shits public static

dusty herald
#

it's asking for manipulation ASkek

vagrant stratus
#

exactly

dusty herald
#

for some reason i really really hate the naming of the methods

#

it looks so fucking wrong

vagrant stratus
#

probably because it's not following conventions?

dusty herald
#

yes

#

that could be it

vagrant stratus
#

just check for net.thearcanebrony.spigotav.RuntimeStore, get the ScanResults list and empty that bitch every tick

vagrant stratus
#

your ScanResults list

#

all one has to do is empty it โ˜บ๏ธ

solemn shoal
#

oh lol

vagrant stratus
#

clear it constantly and their golden ๐Ÿ‘

solemn shoal
#

obfuscation 100

young knoll
#

Just override the empty method

solemn shoal
#

just obfuscate it

#

yes

vagrant stratus
young knoll
#

You think obfuscation has stopped anyone before?

solemn shoal
#

report me to who?

young knoll
#

Do you know what game we are working with

solemn shoal
#

true

vagrant stratus
#

also... they could just update shit every update..

unreal quartz
vagrant stratus
#

It'll be fun abusing the shit outta SpigotAV

dusty herald
#

or better yet, you know what you could do? Corrupt one of the SpigotAV's class files

vagrant stratus
#

I can find ideas

#

I've got a few hundred jars to work with if I'm gonna abuse an AV ๐Ÿ‘

quaint mantle
#

hey how can i make intellij idea to build artifacts and then upload the jar to the sftp?

young knoll
#

Wait, is spigot AV an antivirus powered by a spigot server?

cold tusk
#

How to get the IP of a player (for a ban)

unreal quartz
vagrant stratus
quaint mantle
dusty herald
cold tusk
#

thanks

solemn shoal
#

lol

young knoll
#

Perfect

mortal hare
#

does synchronised block work outside the codeblock itself, for example in one thread it locks the object using monitor inside synchronised block but in other thread the object was used inside another method?

#
1st thread:
public void bar() {
  synchronized (#Object) {
    #code
  }
}

2nd in parallel:
public void foo() {
  #code...
  #Object is used...
}
vagrant stratus
# solemn shoal

can probably still find a way to abuse it โ˜บ๏ธ

solemn shoal
#

fine time to fill it with integrity checks

vagrant stratus
#

go ahead, a challenge is always fun ๐Ÿ™‚

hidden torrent
#

what is the most performant way of detecting if a player entered specific coordinates?

dusty herald
#

PlayerMoveEvent, check cords

hidden torrent
#

if he continues to move, that event is fired each tick?

dusty herald
#

yes

#

it's fired whenever the player moves

hidden torrent
#

shall I throttle it so it doesn't check each tick?

dusty herald
#

should be fine

glass sparrow
#

might make some of your plugins funky so just make sure it doesnt fuck stuff up

hidden torrent
#

what do you mean?

glass sparrow
#

ohh

#

nvm

hidden torrent
#

ok :D

crisp iron
#

?paste

queen dragonBOT
crisp iron
glass sparrow
dusty herald
#

nah / works fine in Linux

crisp iron
#

i need to know why the config is not setting correctly

dusty herald
#

show us saveFile code

crisp iron
dusty herald
#

this.configuration

#

try making a local FileConfiguration variable and save that instead of relying on the information from that class as it won't be updated

#

so FileConfiguration config = this.worldConfig().getConfig()
config.set("blah", "blah");
this.worldConfig().saveFile(config);

crisp iron
#

it was working earlier though... i had to move things around though because it was throwing a NPE and i changed not one thing. I just don't get why it won't work. My worldConfig is a personalized Config class so the information is being updated...

olive lance
#

is there a way to write a method that may return out of the method from which it is called

#

prob not

crisp iron
#

wdym @olive lance

#

you mean like a loop?

olive lance
#

like a null check basically

#

but i use it a lot and dont want to repeat it so many times

young knoll
#

I mean you can return a boolean and then do if (!method()) return;

crisp iron
#

oh

#

just replace void with whatever you want to return

hidden torrent
#

Java? use optional?

young knoll
#

Yeah optional is nice

#

Optional.ifPresentOrElse

olive lance
#

the method returns an object, but if the object is null then i want to return from the method which i called it from

#

ok

hidden torrent
#

yea, when using Optional and the result is null, return Optionl.empty()

vagrant stratus
solemn shoal
#

Inb4 signed jar

vagrant stratus
#

inb4 finding a way to bypass it

#

java, as a programming language, is the most insecure thing ever

#

I'll probably find a way around it in some way, shape or form

hidden torrent
#

then imagine using a computer

#

I mean: holy smoke. data in the RAM?

#

imagine what you could read if accessing it

young knoll
#

Slow down you lost me

#

What is a computer

solemn shoal
#

Inb4 i make a linux service to scan for bukkit malware

vagrant stratus
#

inb4 it gets so convoluted no one will use it

#

it's like denuvo

wraith rapids
#

are we still talking about anti malware

vagrant stratus
#

yes

wraith rapids
#

why

vagrant stratus
#

no fucking clue

hidden torrent
#

ever heared of Internet?

wraith rapids
#

anti malware is like the most useless thing ever

vagrant stratus
#

well... unless it's good

#

like mine

#

I've found almost 400 malicious plugins since 2019 after all...

#

so.. i wouldn't really call it the most useless thing ever

wraith rapids
#

the only people who use anti malware of any kind are a) people who don't know what it does b) employees using it because the insurance company mandates that the employer use one or they won't reimburse data loss costs and shit

olive lance
#

@hidden torrent should I let the NoSuchElementException handle breaking out of the method or is that bad practice

wraith rapids
#

most useless and redundant software ever invented

hidden torrent
#

depends

vagrant stratus
#

While true, Anti-Malware can still be useful @wraith rapids
For example.. me mass-scanning with my Anti-Malware found malicious resources from 2016

wraith rapids
#

active anti malware, anyway

#

i guess virus scanners that you can run after the fact are useful

hidden torrent
#

@olive lance is that question legit? I mean, I feel trolled ^^

wraith rapids
#

whoever is dumb enough to get infected by dumb shit deserves to get infected

vagrant stratus
#

as of the first release of my Anti-Malware

383 malicious plugins have been found
73 different malicious devs get automatically banned
257 different checks have been implemented

again i wouldn't really call it useless

olive lance
#

@hidden torrent sorry it was dumb

hidden torrent
#

it wasn't.

wraith rapids
#

and anything that gets past a not dumb user won't be caught by anti malware anyway so it's redundant

vagrant stratus
#

Gimme a sec

solemn shoal
#

@vagrant stratus i mean, if you want to fix my structure go ahead

vagrant stratus
#

Who said I'd give away everything i find ๐Ÿ˜›

wraith rapids
#

this is a prime example of dumb shit

#

they're obviously hiding something; don't use it

vagrant stratus
#

that is a prime example of a dev uploading malware long after first release once they're trusted by the community

solemn shoal
#

Its not only plugins

#

Ever heard of phobos?

wraith rapids
#

only trust open source and look at the changelog and changes whenever you update

#

good practice to begin with

#

i don't update something unless I know what's been changed

solemn shoal
vagrant stratus
#

That's usually the case actually

#

If it's open source only the binary release has malware

young knoll
#

That would be lying, everyone knows you can't lie on the internet

olive lance
#

so if I call get() on an Optional object in method A, then proceed to call methods on the retrived object(which may be null) would the NoSuchElementException already have stopped method A

hidden torrent
#

@olive lance ok, sorry. I have time now :D What was your problem? if it takes longer and this channel is too active, pm me

wraith rapids
#

yes, it would have stopped it

#

with a huge explosion

#

an exception being thrown stops everything

#

and everything explodes one stack frame at a time

hidden torrent
#

@olive lance When using Optional, you can check if there is some value present with isPresent()

wraith rapids
#

until something catches the exception

#

if nothing catches the exception at all the server dies

olive lance
#

oh ok lol

solemn shoal
#

I mean

#

Windows in itself is malware

vagrant stratus
#

also @solemn shoal if anything, I'd just show proof that i bypassed your shit without revealing how

hidden torrent
#
if (optValue.isPresent()) {
// do something
}
solemn shoal
#

If you really go that far

wraith rapids
#

optionals are gay anyway

hidden torrent
#

if you like to use lambda, you even have ifPresent(Consumer<T> consumer)

wraith rapids
#

don't hate 'em, just don't like 'em
simple as

vagrant stratus
hidden torrent
#
optValue.ifPresent(value -> {});
olive lance
#

i feel like this may just end up making my code longer

wraith rapids
#

what are you doing, anyway

hidden torrent
#

depends. wanna share your code?

olive lance
#

yea sure

#

ill show what i have right now

wraith rapids
#

wat

olive lance
#
    @Override
    public void perform(Player p, String[] args, HCFPlugin plugin){
        
        Faction f = plugin.getData().getFactionOrError(p).get();
        if(!f.getLeader().equals(p.getUniqueId())){
            p.sendMessage(ChatColor.RED + "You must be the leader to use this command!");
            return;
        }
        if (f.hasClaim()) {
            p.sendMessage(ChatColor.RED + "Your team already has a claim!");
            return;
        }
        if (!plugin.getData().hasSelection(p)) { . . . . ```
young knoll
#

Why are you using the minecraft namespace

wraith rapids
#

and why are you using minecraft keys

#

"but what is plugin"

olive lance
#

the getleader check is next on my list

cold tusk
#

Is it possible to send the Totem-Animation to a player?

hidden torrent
#

getFactiononError() returns your optional?

olive lance
#

yes

wraith rapids
#

are you trying to implement that throw fast return shit I talked about earlier

hidden torrent
#

yea, do not call get()blindly on an optional

olive lance
#

and if it return optional.empty it sent a error message

hidden torrent
#

it is not designed for that

olive lance
#

ok

wraith rapids
#

create a new exception called BreakCommandParse or something

hidden torrent
#

capture it in a variable

wraith rapids
#

make it a checked exception

#

then, whatever code invokes that 'perform' method

#

make it catch that exception

#

and then make perform throw that exception

eternal night
#

mans really using minecraft namespaced key for their pdc

#

๐Ÿ‘ฎ

wraith rapids
#
    @Override
    public void perform(Player p, String[] args, HCFPlugin plugin) throws BreakCommandParse {
        
        Faction f = plugin.getData().getFactionOrError(p); //throws the exception
         ```
hidden torrent
#
public class ClaimCommand implements SubCommand {
    @Override
    public void perform(Player p, String[] args, HCFPlugin plugin){
        
        Optional<Faction> optFaction = plugin.getData().getFactionOrError(p).get();
        optFaction.ifPresent(faction -> {
          if(!f.getLeader().equals(p.getUniqueId())){
              p.sendMessage(ChatColor.RED + "You must be the leader to use this command!");
              return;
          }
          if (f.hasClaim()) {
              p.sendMessage(ChatColor.RED + "Your team already has a claim!");
              return;
          }
        });
        if (!plugin.getData().hasSelection(p)) { . . . . 
wraith rapids
#

and then in your subcommand handler or whatever

try {
    subcommand.perform();
catch (BreakCommandParse) { return; }
hidden torrent
#

that that is hard to format

olive lance
#

thank you guys for this major help seirousky

wraith rapids
#

that way you don't need to fuck with optionals

#

you will also have to declare the getFactionOrError method to throw BreakCommandParse

#

and then do the if condition of the player having a faction there, and if not, throw new BreakCommandParse()

#

you may also want to create a string based constructor for the exception, and have that string being sent to the player in the catch block

hidden torrent
#

that data object is probably not responsible to throw exceptions associated with a command.

wraith rapids
#

that it's an exception associated with a command is irrelevant

hidden torrent
#

and I don't want to teach him exception design rules

#

it is not

wraith rapids
#

it is simply an exception that breaks the operation that is being performed

#

and happens to be used in command parsing

hidden torrent
#

Responsibility pattern. always teach it properly

wraith rapids
#

ok, well

#

rename the exception, then

#

PlayerHasNoFactionException

#

done

hidden torrent
#

indeed.

olive lance
#

Luckily I learned about making exceptions the other week

#

in class

hidden torrent
#

What framework is that?

#

I can't recall SubCommand

wraith rapids
#

probably their own

olive lance
#

mine

hidden torrent
#

or HCFPlugin

#

oh.

wraith rapids
#

towny is one plugin that uses, or used, this approach

#

that is, instead of checking everywhere whether a location has a town block or something

#

instead of returning null and checking for null

#

the getter method throws NotRegisteredException

#

which saves them a bunch of nullchecking

hidden torrent
#

yea. I prefer the Always return something approach as well.

wraith rapids
#

but comes at the cost of fucking bullshit code because the exception is checked and there is no nullable alternative

olive lance
#

my exception body could just be blank right

#

its just there to be caught

wraith rapids
#

so they end up having to try catch shit everywhere constantly for no reason

#

they're currently in the process of reverting that design approach

hidden torrent
#

a good indicator for using Optional.

#

Optional<Command> getCommand(String);

olive lance
#

i guess i could send the player a message within it but prob not necessary, just better to do it before i throw it?

wraith rapids
#

optionals are gay

ivory sleet
#

Isfirs null would accomplish the same thing roughly?

hidden torrent
#

what a bullshity argument to make

hidden torrent
wraith rapids
#

you can send it before throwing or you can throw the exception with a message argument and then send that message

#

either works

#

what do you even mean error prone

ivory sleet
#

Elaborate error prone

wraith rapids
#

the data either is there or is not there

#

whether it's wrapped as an empty optional or a null pointer reference is not relevant

hidden torrent
#

null can throw NPE when operating on an absent value while Optionals (when used correctly) will never do that.

ivory sleet
#

Wat

wraith rapids
#

yeah, well, see, there's the catch

#

"when used correctly"

#

references, too, "when used correctly" don't throw NPE

hidden torrent
#

yea, same woth other code

#

you have to implement both properly

wraith rapids
#

then what's the point

hidden torrent
#

so both have the same caveat

ivory sleet
#

In regards to prefer Optional argument then?

hidden torrent
#

don't have null values

wraith rapids
#

optional is literally just a reference wrapper

#

it's still null, you just don't call it null

ivory sleet
#

null is great tho

wraith rapids
#

it literally even throws a fucking exception if you try to access it without null-checking it first lmao

hidden torrent
#

you could still set up code on it. I do it all the time. if the value is missing, yea well it will not run anything.

wraith rapids
#

that is, get throws nosuchelement if the optional is empty

hidden torrent
#

but my chains and streams are set up and run perfectly fine

wraith rapids
#

yeah, streams are pretty much the only argument for optionals

#

that said, streams are also gay

#

so your argument is invalid

hidden torrent
#

Java is gay. don't use it then

wraith rapids
#

i agree

hidden torrent
#

go back to assembler.

novel lodge
#

Is there a way to add Advancements with a plugin or should I just use a datapack>

hidden torrent
#

or even binary code

olive lance
#

dang so i have to add the throws statement in every method override

#

it should be able to know if it throws in the interface

wraith rapids
#

your IDE should insert the throws statement to the method declaration automatically

hidden torrent
glass sparrow
wraith rapids
#

you can also make it a runtime exception so you don't need to add throw clauses and declarations anywhere ๐Ÿ‘€

#

but that's probably not a good idea

olive lance
#
    @Override
    public void perform(Player p, String[] args, HCFPlugin plugin) throws NotInFaction {
        Faction f = plugin.getData().getFactionOrError(p);```
```public interface SubCommand {
    abstract void perform(Player player, String[] args, HCFPlugin plugin) throws NotInFaction;
}```
```public Faction getFactionOrError(Player p) throws NotInFaction {
        if(!fPlayers.containsKey(p)){
            p.sendMessage(ChatColor.RED + "You are not in a faction!");
            throw new NotInFaction();
        }
        return fPlayers.get(p);
    }```
#

heres what im working with i think it looks right?

ivory sleet
#

NotInFaction is an odd name for an exception but I guess

olive lance
#

oh yes you see I am going for world record of least bytes in my jar

#

exception too many letters

ivory sleet
#

Lol ok

wraith rapids
#

big brain

olive lance
#

just kidding but besides that lol

ivory sleet
#

getFactionOrError feels kinda contradictory to your goal then

wraith rapids
#

just barcode everything

#

iiIIiII()

olive lance
#

all my method names will be hex values

olive lance
ivory sleet
#

Well, if we for instance take a look at java you wonโ€™t find something like
getAppropriateClassOrLinkageError, getDeclaredConstructorOrReflectiveOperationException

wraith rapids
#

lol

olive lance
#

there is already a getFaction method

wraith rapids
#

the orError is there to make it distinct from the nullable alternative

#

it's a poor name I agree

#

but I couldn't come up with anything better on the spot

ivory sleet
#

Hmm yeah well thought he only had one method for it

wraith rapids
#

he definitely wants to keep the nullable alternative

#

otherwise he runs into the same issue as towny

#

where he has to wrap literally every fucking get in try catch ignore

ivory sleet
#

Yeah which is horrific in every way lol

wraith rapids
#

yeah, it was absolute cancer

#

they even had performance issues because of it

#

they had like a entity spawn listener somewhere that tried to check if the town area had mob spawning disabled

#

but because the get town area method wasn't nullable, it threw an exception that was caught every time instead of just returning null

ivory sleet
#

lmfao

wraith rapids
#

so for all of the thousands of mobs spawning outside town areas, it'd constantly spam like 400 element stack traces

hidden torrent
#

and then try printing it with the logger. gg performance

wraith rapids
#

nah they were caught at least

#

but just getting the stack trace in the exception ctor is expensive enough

#

was like 5-10% tick time just from fillInStackTrace or whatever that method was in when I looked at it in spark

olive lance
#

ill probably get around to testing this in like a week and then nothing works at all so i just go afk for months then decide to come back and try to fix it

wraith rapids
#

i made and use a really strange command framework

vital ridge
#

Hey

wraith rapids
#

it was originally something I'd call oop purism

vital ridge
#

can anyone help me out with tabcompletion?

wraith rapids
#

but that was too verbose

#

so i made it half functional

vital ridge
#

i made a tabcompletion, but it only completes arguments when i type something

wraith rapids
#

now it's just weird

#

isn't that how tab complete works?

vital ridge
#

Yeah but example when you type /give

#

with just a space

#

it gives you automatically a list of args[1]

#

you dont have to type any letter as args[1]

#

if you get what i mean

wraith rapids
#

uh

#

share code i suppose

olive lance
#

args[0] u mean

#

or no

vital ridge
#

i mean

#

argument after the main command

#

example /kill Player

#

I mean the player as the argument

olive lance
#

yes

#

ok

vital ridge
#

Ill show my code

#
@Override
    public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {

        if (args.length == 1) {
            ArrayList<String> autoComplete = new ArrayList<>();

            if (!args[0].equals("")) {

                if (main.eventStatus) {

                    if (!main.confirmation) {

                        autoComplete.add("disable");
                    
                    } else {

                        autoComplete.add("confirm");

                    }

                } else {

                    autoComplete.add("enable");

                }

            }

            Collections.sort(autoComplete);
            return autoComplete;
        }

        return null;
    }
eternal oxide
#

thats not right

wraith rapids
#

args will be length 0

#

/kill has no arguments

#

it's just the command label

#

args.length == 0

eternal oxide
#

you present a full tab complete List depending on what arg length is

vital ridge
#

so i should replace 1 with 0

wraith rapids
#

/kill n
will create the first argument at args[0] with the value of "n"

vital ridge
#

but if i currently did /fm e

#

it autocompleted

#

with enable

wraith rapids
#

yes

#

if (args.length == 1) {

#

this is your issue

#

see what I said earlier

vital ridge
#

so i need to put 0 there?

#

yeah I understood

#

I think

wraith rapids
#

depends on what you want to do i guess

vital ridge
#

If i need to put 0 there then i understood

wraith rapids
#

try <= 1

vital ridge
#

aight will do

wraith rapids
#

if you set it to 0, it will stop auto completing once you write the first character

#

since /kill n will have 1 argument, but /kill will have 0

#

so you need to return auto complete lists for both 0 and 1 arguments

olive lance
#

should singleton instances be final

wraith rapids
#

an instance can't be final

olive lance
#

oh ok

wraith rapids
#

a field that holds a class can be final

#

a class that the object is an instance of can be final

hidden torrent
#

a class can be final

wraith rapids
#

but an object itself can't be final

vital ridge
#

i mean where im adding it to the list

#

i tried just changing == to <>

#

<=*

wraith rapids
#

just drop the args clause

vital ridge
#

clause?

wraith rapids
#

remove the if args length condition altogether

hidden torrent
#
public final class Foo  {
  public static final Foo INSTANCE = new Foo();
  private Foo() {}
}

final instance

wraith rapids
#

that's not a final instance

hidden torrent
#

best we can get

wraith rapids
#

that's a final field holding an object

#

but like yeah i guess that is what he meant

#

singletons by definition should only ever have one instance of them floating around

#

so it only makes sense that the something holding onto that instance is final

vital ridge
#

Now it instantly auto corrects me with args[2]

#

and my args[2] requires a player

wraith rapids
#

best practice for singletons iirc is to make them enums which makes the jvm enforce the singleton property

jagged badge
#

I want to open a menu in a protocolLib event, but I have this error.
java.lang.IllegalStateException: InventoryOpenEvent may only be triggered synchronously.
The menu works correctly (tested with commands for example)
According to my research, protocolLib would handle all incoming packets asynchronously. Does anyone know how to solve this?

  public void onPacketReceiving(PacketEvent event){
    if(event.getPacketType() == PacketType.Play.Client.USE_ENTITY){
      try {
        event.getPlayer().openInventory(................);
    } catch (Exception e){
      Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "ERROR");
      e.printStackTrace();
    }
}
}});```
wraith rapids
#

yeah to be honest i don't know if you can do that with the tab executor

ivory sleet
#

that onPacketReceiving method isnt called on the server thread

wraith rapids
#

it kinda seems like you can't

ivory sleet
#

probably need to wrap it in a sync task (runs on server thread)

wraith rapids
#

since the new argument only appears in the args[] array after the player starts writing that argument

#

it doesn't appear as a "" in it after they press a space i don't think

#

could be wrong, never used the tab executor

vital ridge
#

but example

#

if i do /kit<space>

#

then it gives me a tabcomplete with kits

#

without typing any args

wraith rapids
#

that's from essentials; they probably use something more robust than the tab executor class