#help-development

1 messages ยท Page 138 of 1

next stratus
#

It can change at anytime.

vast raven
#

I always get the configsection instead of using the "."

tender shard
#

if you want to get the whole thing, you just do it like this

ConfigurationSection materials = getConfig().getConfigurationSection("materials");
vast raven
tender shard
#

then you can do materials.getDouble("STONE");

next stratus
#

So, I'm making it so players can set the blocks in their mine so this list will update whenever they change their blocks.

tender shard
#

so?

echo basalt
#
ConfigurationSection materials = config.getConfigurationSection("materials");

for(String key : materials.getKeys(false)) {
  Material type = Material.matchMaterial(key);
  double cost = materials.get(key);
}
vast raven
next stratus
#

No, I made a private mines plugin and the players can change the blocks within their mine by running a command.

echo basalt
#

then it's up to you to make that structure and code

#

idk what to tell you man

tender shard
echo basalt
#

getDeclaredField

tender shard
#

why do you need reflection for this? o0

echo basalt
#

.get(object)

tender shard
#

you can just do ClassName.fieldName

echo basalt
#

probably privaet

next stratus
tender shard
#

then you have to do setAccessible(true) on that field

echo basalt
tender shard
eternal oxide
#

Im and big brain ๐Ÿ™‚

echo basalt
#

Illusion

#

๐Ÿ’€

vast raven
#

๐Ÿช

tender shard
#

thanks for the cookie

echo basalt
#

at least you're not the guys at work

tender shard
#

so erm

#

are you awake?

echo basalt
#

no

tender shard
#

oh ok sorry

#

I will reply to you later then

#

when you're not sleeping

#

โค๏ธ

echo basalt
#

ah okay

tender shard
#

you usually do not have to check this in the first place

#

why do you need to check this?

echo basalt
#

getModifiers & Modifier.FINAL != 0 iirc

#

getModifiers is a bitmask so yeah

tender shard
#

if you access fields via reflection and only want to "retrieve" the value, you can safely ignore whether it's final or not

next stratus
#

thanks for helping, I feel stupidly dumb now I fixed it.

echo basalt
#

I don't really feel like saving via reflection is the most ideal

tender shard
#

then make an API to create those objects

echo basalt
#

o nvm I actually used reflections for my skyblock core

vast raven
#

I was thinking: who in the world still uses bukkit in 2022

echo basalt
#

Just convert your object into a Map<String, Object>

tender shard
#

how else are you going to create spigot plugin s

next stratus
vast raven
echo basalt
vast raven
#

Not the spigot or paper

echo basalt
#

pretty sure spigot is a 1.8 thing so hypixel is definitely not using it

next stratus
vast raven
icy beacon
#

it's like a version determiner, if i ever change the serialization i'll identify the old runes with this

next stratus
#

Is the Pattern Bukkit -> Spigot -> Paper?

icy beacon
#

yep

vast raven
#

Paper > *

icy beacon
#

why not

next stratus
#

or did craft bukkit come first

icy beacon
#

i mean

#

bukkit came first

#

then spigot

#

then paper

vast raven
icy beacon
#

did you mean that

vast raven
#

then spigot

next stratus
#

I mean what came first

vast raven
#

then Bukkit

icy beacon
#

bukkit came first

#

vanilla minecraft even firster

next stratus
#

like bukkit came first, then spigot forked bukkit then paper forked spigot?

icy beacon
#

yeah pretty much

#

you can sometimes hear people saying paperspigot

echo basalt
#

purpur is modified paper which is modified spigot which modified / runs on top of craftbukkit that is the implementation of bukkit which is a wrapper for mojang's server

tender shard
#

Craftbukkit, Spigot and Paper all implement Bukkit API

echo basalt
#

simple enough

next stratus
#

PaperSpigot is rare to hear lol

icy beacon
#

yeah

#

but it sometimes exists

next stratus
#

paper is so successful though

echo basalt
#

paper and bukkit had different goals

#

paper did their best

#

and it showed

vast raven
tender shard
vast raven
#

tho I still code plugin in spigot and not in paper

next stratus
vast raven
next stratus
#

I'm fairly sure my friend has a custom fork with the size of his server lol.

echo basalt
#

even small servers can be running forks

vast raven
echo basalt
#

I always wished that spigot had ways of disabling parts of NMS that simply weren't used

#

so servers could disable stuff like advancements at a classloader level

next stratus
#

My friend has over 3k people on so likely using a fork don't you think?

echo basalt
#

oh wow you have friends

vast raven
tender shard
#

i'll go to bed now, have a nice day everyone โค๏ธ

echo basalt
#

the guys on my friends list are all hypixel developers so I guess they're also running a fork

next stratus
#

I mean, I got the owners of mchub on my friends list. Helping make the server helps a bit ig.

vast raven
#

๐Ÿ˜Ž

tender shard
tardy delta
#

pff have to get out of my bed at 7am

#

was used to 11am in holidays

next stratus
vast raven
echo basalt
tardy delta
#

idk

#

brussels

echo basalt
tardy delta
#

lmfao

#

when did you go to bed

echo basalt
#

like

#

fuckin

#

1pm

next stratus
#

I helped my friend get his server going finding bugs etc and now he has the players he forgot me ๐Ÿ˜”

vast raven
iron glade
#

this dude literally called devbukkit

echo basalt
#

hol'up

iron glade
#

lol

echo basalt
#

๐Ÿ’€

next stratus
tardy delta
#

smh i have parents that tell me to go to bed at 10pm

echo basalt
#

mfs called "McDevelopment" asking for coding help

echo basalt
next stratus
#

He's barely on, so yeah.

#

mchub was known as mcprison

vast raven
echo basalt
#

help I have a romanian military song stuck on my head

next stratus
#

Hm?

#

It was.

#

It's got good content, but they moved to a shitty coin system making stuff much more expensive.

#

I helped design it at the start, so I'd hope it was.

#

What about the 4 digits it brings in each day?

#

yeah

#

I was joking in a call with the owner once and he shown me buycraft

#

People sell their skins for like 20k coins, 10k is about $120 so that's $239.98 per skin

#

7 figures when I saw likely higher.

#

But they got so many dedis to pay off every month.

#

They have 350 dedicated servers as of July 2017.

#

He bought another 150 at once in 2020

waxen plinth
#

I should get them to hire me and give me all their money

next stratus
#

Oh hi redempt!

waxen plinth
#

Hi

next stratus
#

It's the RedLib guy!

waxen plinth
#

It is

#

Hi

next stratus
#

RedLib is a Spigot plugin development library, designed to make your life easier and soothe the pain points of plugin development. Below, find instructions for the various components of RedLib.

waxen plinth
#

Ok

#

Lots and lots of tools

next stratus
#

It has an incredible config system

waxen plinth
#

I should get around to replacing RC with Ordinate

next stratus
#

It does, yeah!

#

Honestly, it's worth a shot. You might work out how damn incredible it is and start using it daily. Redempt gives amazing support too!

#

Ah yes! the 3 classes

waxen plinth
#

It has one but I've since made a better one

#

And I'm looking to replace the one in RedLib with it eventually

echo basalt
#

I'm fine with my own command framework

next stratus
#

I like this one because it's really lightweight but it works real well.

echo basalt
#

no annotations, auto-registers commands without plugin.yml

tardy delta
#

im fine with acf

echo basalt
#

supports wildcards and wildcard tab completion

#

arguably it might be a bit annoying given each subcommand has its own class

#

but that's how I like to handle it

#

ehh this is just an example

#

as of right now it's somewhat private

#

code's a bit garbage but it's present on my skyblock core ig

#

like?

#

you can put as many *'s as you want

#

and aliases are a thing iirc

#

uhhhhh

#

don't think so

waxen plinth
#

Mine does

echo basalt
#

let me ...

#

ask around

waxen plinth
#
report player:target string...:something {
}```
#

With mine you write a description of each command like this, then annotate methods with @CommandHook and they'll be run when the command is run

#
add int[]:nums {
  hook = add
}```
#
@CommandHook("add")
public void add(CommandSender sender, int[] nums) {
  sender.sendMessage(Stream.of(nums).sum() + "");
}```
#

Simple example

#

You could run it like /add 1 2 3 and it would show you the sum of the inputs

echo basalt
#

yeah but annotations

waxen plinth
#

One annotation

echo basalt
#

still more than 0

waxen plinth
#

And one method per command instead of a class

#

It's a tradeoff I'm willing to make

#

You cut back on so much boilerplate with it

#

I don't like the annotation spam of other frameworks which is why this only uses one and has a separate file to describe the metadata

#

Yeah

#

Feel free to DM me or join my support server if you want to use it and need help with it

tardy delta
#

meanwhile me with the annotations ๐Ÿคก

#

heeheehee

waxen plinth
#

.-.

tardy delta
#

looks like rust

waxen plinth
#

vanish || EnumSet.of(GameMode.CREATIVE, GameMode.SPECTATOR).contains(player.getGameMode())

tardy delta
#

smh

waxen plinth
#

I do like rust though

tardy delta
#

i stopped using it because of the weird syntax and lifetimes lol

#

didnt really get far anyways

#

into c++ rn

waxen plinth
#

For anything except one-off uses they often make things more effort than they're worth

#

So. Many. Kinds.

echo basalt
#

that shit's cursed

waxen plinth
#

&, Box, Cow, RefCell, Rc, Arc

echo basalt
waxen plinth
#

It's definitely worth learning

waxen plinth
tardy delta
#

hopefully jit will optimize that call

echo basalt
#

unecessary to create a new enumset just for a contains check

waxen plinth
#

It's so fast that unless it's being called thousands of times per second it's not an issue

echo basalt
#

still not good practice

waxen plinth
#

I would take the code cleanliness for a slight performance hit

tardy delta
#

no way to see who cloned stuff?

#

didnt even know this existed

waxen plinth
#

Making it a constant is good but not always needed

echo basalt
tardy delta
#

i didnt clone it

echo basalt
#

8 views, 35 clones

waxen plinth
#

I love optimizing too

tardy delta
#

heh my parser

waxen plinth
#

But I know that sometimes it's pointless

tardy delta
waxen plinth
#

Nah it's often very necessary

echo basalt
#

I can't sleep at night without having top-tier performance measured in tens of microseconds

waxen plinth
#

You just need to know when to pursue performance

echo basalt
#

running async ofc

waxen plinth
#

Illusion I'm still kind of miffed at you

vivid skiff
#

Why is this check not working if (player.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals("&e&lTaser ยง6[4]")) { ?

waxen plinth
#

Yes

echo basalt
tardy delta
lost matrix
waxen plinth
#

Yeah that's not the problem

#

Having different goals is fine

echo basalt
#

You find that consistently abstracting features is clean, I find that simple, basic code is clean

vivid skiff
echo basalt
#

And don't mind going the extra mile

waxen plinth
#

I do both in different scenarios

echo basalt
#

I am consistent regardless of scenario

waxen plinth
#

Was never my issue though

#

You insulted me as a developer and never apologized or took it back and it's hard not to be reminded of it when seeing you

echo basalt
#

ยฏ_(ใƒ„)_/ยฏ

waxen plinth
#

Alright, if you don't want to do anything about it then we'll just go on being adversarial

echo basalt
#

That's perfectly fine

waxen plinth
#

I'd rather not have things that way

#

Like when I see you in chat it just puts me on guard because I know you're judgemental about my code and have a superiority complex or something

echo basalt
#

no, I simply have different code standards

#

We can both help people here

waxen plinth
#

Yes, we can

lost matrix
#

Which dev isnt cycling between imposter syndrome and god complex?

echo basalt
#

And that's what we're here to do

echo basalt
#

god complex when dealing with people that don't know how to code, feeling like a brick when dealing with people who are better than you

#

and impostor syndrome when applying for new jobs

waxen plinth
#

I just feel bored when helping beginners

echo basalt
#

Well, people doing crazy funky NMS can help themselves

#

Just pick up a very complex project, like let's say..

#

synchronize 2 servers

#

idk

waxen plinth
#

I got a bit of impostor syndrome at intern presentations because some of the people had really good presentations

echo basalt
#

I'm in a programming course, interned at school replacing computers ๐Ÿ’€

waxen plinth
#

But I stalked their contributions and we all had pretty comparable levels of productivity

lost matrix
#

I smell dunning kruger in here. Whoever claims to be sublime like this doesnt know how little he actually knows.

echo basalt
#

I know about spigot and nothing else

#

and that's what makes me extremely doubtful of my future

waxen plinth
#

You know java

#

You know design principles

#

It's not hard to branch out but it's not like you're behind

eternal night
#

hopefully databases

ivory sleet
#

(and presumably a decent skill in googling)

echo basalt
#

I know enough about databases

#

Like

eternal night
#

so yea, already probably better than the 90% out there kekw

echo basalt
#

I know how the entire internet works but I also locked myself out of the new work server like 3x before outsourcing my job to an "underpaid chinese worker" according to my source

#

and had to ask the guy what dns flags to set ๐Ÿ’€

lost matrix
echo basalt
#

keywords in google are so nice

#

"spigot <1-3 words that describe your problem>"

#

fake death ๐Ÿ’€

vivid skiff
echo basalt
#

nbt api if you're willing to have dependencies

#

but also ItemStack#isSimilar

#

or equals

harsh totem
tardy delta
#

cuz thats how real world works ๐Ÿ˜‚

boreal seal
#

idk guys

#

why

#

i cant check

#

if entity has pessenger

river oracle
boreal seal
#

Entity#getPessenger == null < failed Entity#getPessenger#isEmpty < failed

#

it doesnt return correct value

#

always false

tardy delta
#

well learn like basic concepts of programming lol

boreal seal
#

but in fact i put pessenger

tardy delta
#

i dont even have to go to lesson if i want lol

river oracle
tardy delta
#

idk here

#

they dont care if youre present or not ig

river oracle
#

I'm in "Intermediate Java" and we learned how to print with sysout through 3 lectures

tardy delta
#

smh

river oracle
#

225 minutes of learning sysout

tardy delta
#

well learn like basic java and javafx this year lol

boreal seal
#

Y2K_ you can get job in htech company now adays

#

most of employes there are 2 digit iq

#

u know all of those who think begin a dev is good money

#

and easy

#

alot of idiots

#

just go to google

#

they will give u some tasks

river oracle
#

true good developers are in need lol

boreal seal
#

not something difficult

#

i cloud go

#

and probably pass the tasks

#

it will be like reverse a string

#

and some simple shit

river oracle
#

The thing is i suck at interview questions lol

boreal seal
#

they dont do interview questions oftenly

#

the self test

river oracle
#

idk how to do all hte obscure bs they ask in interviews

tardy delta
#

if only one instance is permitted

boreal seal
#

never

#

di 1#

tardy delta
#

f.e MinecraftServer

river oracle
#

when there will only be ever one instance and should only ever be one instance of an object example Database Connections

boreal seal
#

i used to use singletons its really bad

tardy delta
#

same

boreal seal
#

just learn depndecy injection

#

the concept is really simple

tardy delta
#

Main.getPlugin(Main.class) aa

boreal seal
#

when i started learning i always used to create static main class

#

like instance

#

not static class yeah

#

not good

#

DI

#

is good

#

clear code easy to understand

#

no need to make 10thousand constracturs

#

or abusing static

#

like guys you only saw mojang code

#

so u can say who works there 2 digit iq monkeys

#

the community is way better

river oracle
#

basically if your questioning whether you should DI or Singleton just think if there would ever be a scenario where there would be a second object of that type if yes DI otherwise singleton generally singleton makes your code less portable though

boreal seal
#

either the reason why the code is obsf probably because they are ashamed of it

river oracle
boreal seal
#

C+V

#

not really headache

#

either i have premade temple for it

river oracle
#

depends what does the message handler do

boreal seal
#

so like if its listener...

#

many things cloud

#

its just not better

#

u dont know if u will need to accses it somewhere else later

#

so

river oracle
#

Singleton Could be fine, but honestly just sounds like you'd need a better design pattern for this

#

MessageHandler seems pretty useless to me

#

just fetch the data from the configs and send the message

#

at the most make 1 static method to handle it

boreal seal
#

The singleton pattern is an easy to understand design pattern.

#

how ever

#

idk if your project is few classes

#

then use it

river oracle
#

just overload a static util method I don't really see a reason for a whole class here ๐Ÿคทโ€โ™‚๏ธ util methods should cover your use cases

#

With configs generally best to stick to DI imho mostly because there is a reason to create / manage more than one instance of a config

#

just stick to DI and pass MessageHandler around it'll be cleaner than the singleton regardless and easier to manage / more portable which would be useful for something like MessageHandler class

river oracle
#

pvbble simply asked which would be preferable

jovial helm
#

Hi Im new to making plugin, why do i get error Could not pass event BlockPlaceEvent to MCPluginDev when I place a block

river oracle
#

Scalability, Readability, and better design patterns. It also makes your classes purposes clear and concise, You also benefit from being easier to integrate people into your codebase.

undone axleBOT
boreal seal
#

?stacktrace

#

aw

river oracle
#

DI is easier to manage at scale than singletons

river oracle
#

therefore increasing your scalability

#

you can technically scale with singletons but it becomes unmanagable after a certain time

boreal seal
jovial helm
#

i can

boreal seal
#

learning to use an API without knowing java is ussless

#

learn and come back

jovial helm
#

i know java

boreal seal
#

u didnt do an instance

jovial helm
#

oh...

boreal seal
#

so what oh

#

you dont know java

#

man i'm here to help those who are in trouble

#

not to those who have no idea what they are doing

river oracle
#

because you know what ever class does and what classes are used inside of it. This makes it easier to bug fix issues as its easier to trace back. Again also makes it easier to look back and know what old code does. Very useful at a large scale. Easier maintain due to if you need to compeltely overhaul a class DI will lend better to telling you where everything is used and what you need to upgrade vs singleton which will be all over the place

boreal seal
#

i learned java

#

for half year

#

before even coding something

#

even for a year

#

not sure

#

how long it was

river oracle
#

Minescule amounts more if you want to sacrifice a good design pattern for slightly lower memory usage go ahead but it'd be equivalent to shooting yourself in the foot

opal juniper
#

i mean it would be a tiny amount cause it is literally that, a reference

#

itโ€™s just saying โ€œgo here in memoryโ€

#

you probs wouldnโ€™t even notice it

boreal seal
#

false

river oracle
boreal seal
#

well

#

he wont feel it

#

even if he have 500 classes

river oracle
#

but it is true

boreal seal
#

well my brain did 7 > 10

#

if it was 6 > 5

#

that what my brain did

#

he doesnt have to worry about such a thing

#

what he gonna do next use an to queries each time instead of storing things in cache

#

(sql)

#

then why you ask

#

in first place

river oracle
#

singletons aren't bad if used properly but very rarely do people actually use them properly

boreal seal
#

i send u an whole article

river oracle
#

imho MessageHandler is not an example of a good singleton

boreal seal
#

?paste

undone axleBOT
boreal seal
#

how bad this is

#

yeah because you asked a wierd question

#

if it use memory

#

like how much it would use

#

i'm not into singleton topic

river oracle
#

generally my final input to you is that I wouldn't reccomend making MessageHandler a singleton class hell it doesn't seem like a worth while class at all to me, however you are free to do as you please.

boreal seal
#

you ask same questions in loop

boreal seal
#

since this is what i felt we went thru rn

ember estuary
#
0 -> 0
1 -> 1
2 -> 2
3 -> 3
4 -> 4
5 -> 3
6 -> 2
7 -> 1
8 -> 0
9 -> 1
10 -> 2
11 -> 3
12 -> 4
13 -> 3
14 -> 2
15 -> 1
16 -> 0

How can i achieve this, using arithmetic operations (modulo, subtraction ...) only, given a counter-variable i going from 0 to 16 and a "limit" of n = 5, where the numbers "turn around" ?

#

nope, that will give

0 -> 0
1 -> 1
2 -> 2
3 -> 3
4 -> 4
5 -> 0
6 -> 1
7 -> 2
8 -> 3
9 -> 4
10 -> 0
...
#

if you mean i should do i%n

#

see how at 5 it restarts at 0 instead of turning around

ember estuary
#

get it?

#

for example when the number is 5, it should output 4 and not 0

grim galleon
ember estuary
#

well that way its easy

#

i wanna use just arithmetic operations

#

no if

#

just modulo, division, etc

eternal night
#

not like that would work anyway kekw

ember estuary
#

the purple line is kinda wrong

eternal night
#

at least that code

ember estuary
#

how did u make that, pvbble?

#

ah

#

well if i knew the formula i could show u on there haha

#

i dont know the formula, thats the problem.. xD

#

green is using modulo

kindred valley
#

Why the fuck the itemstacks takes the customModelData number of the last item i clicked

ember estuary
#

purple is what i want

charred blaze
#

How to check if config is empty in bungeecord?

eternal night
#

just mod the x ?

#

xD

#

at least make it a fancy LaTeX formula then

ember estuary
eternal night
#

no

#

like

#

what they mod

#

did you not check their formula ?

ember estuary
#

what formula

eternal night
#

notably tho the c here is wrong

charred blaze
#

How to check if config is empty in bungeecord?

eternal night
#

Well, their n (or c) was 5

#

but that should be an easy fix

#

to yield the desired output they'd c = (n-1)*2

#

for c=8

#

oh

#

yea

#

hence, if they are going to feed 5 as their turning point

#

make sure to smack it through a - 1 and *2 first

#

das all I am saying ๐Ÿ˜…

floral drum
ember estuary
#

lol

floral drum
#

sorry, horrible joke

ember estuary
#

yea

#

wasnt fully correct but nearly

#

oh maybe cuz my c was wrong

eternal night
ember estuary
#

like lynx said

#

xD

jovial helm
#

i already knew tbhj i just like how kotlin looks

ember estuary
#

well it only went up to 2.5/2.5 instead of to 4/4

#

but yeah Lynx already said the fix

#

cuz (5-1 )* 2 right

eternal night
#

all depends on where you come from ๐Ÿ˜‚

ember estuary
#

nah but given the limit c

eternal night
#

if they think of a number t being the turning point that the series should never reach

#

then c = (t-1)*2

ember estuary
#

yea

eternal night
#

you are thinking of the limit that the series reaches, which means c = 2L

#

just a question of โœจ perspective and expectations โœจ

ember estuary
#

true xD

gloomy sedge
#

is it possible to modify minecraft enchantments - spigot? (without needing to make them from scratch). I've already looked it up on google but nothing shows up.

#

ok yeah. that's what i thought

weak bear
#

I have a problem, I just have create a ArrayList for a command vanish but when the player join my list dont take the right arguments


    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String s, String[] strings) {
        if(cmd.getName().equalsIgnoreCase("vanish")){
            if (!(sender instanceof Player)){
                sender.sendMessage(errorMessage + "Vous ne pouvez pas utiliser cette commande.");
            }

            Player p = (Player) sender;

            if (sender instanceof Player) {
                if(!vanished.contains(p)){
                    for(Player pl : Bukkit.getOnlinePlayers()){
                        pl.hidePlayer(p);
                    }
                    vanished.add(p);
                    p.sendMessage(label + "Vous รชtes maintenant en vanish.");
                    Bukkit.broadcastMessage(String.valueOf(vanished));
                }
                else{
                    for(Player pl : Bukkit.getOnlinePlayers()){
                        pl.showPlayer(p);
                    }
                    vanished.remove(p);
                    p.sendMessage(label + "Vous n'รชtes plus en vanish.");
                    return false;
                }
            }

        }
        return true;
    }
    @EventHandler
    public void onJoin(PlayerJoinEvent e){
        for(Player player : vanished){
            e.getPlayer().hidePlayer(player);
        }
        Bukkit.broadcastMessage(String.valueOf(vanished));
    }```
gloomy sedge
#

i just wanted to make sure before i spent time doing it

eternal night
#

if I had to guess you are creating two instances of the class

#

or is that your main class ?

weak bear
#

No it's not my main class

eternal night
#

yes so presumably you create two instances of it

weak bear
#

Yes

eternal night
#

which, vanished is a non-static field

#

e.g. each instance of the class has its own array list

#

they don't share one

weak bear
#

Okay I understand but How can I do so for store information when I execute command /vanish and retake it on my Event?

eternal night
#

Well

#

either you just slap a static on the field or you properly do object oriented coding

#

and create some type that holds onto the vanished players

ornate patio
#

how can i get the itemstacks that drop from a block in BlockBreakEvent

eternal night
#

(or in this case, you create th e instance once and use the same instance when registering commands and listener)

weak bear
#

Okay thank you very much that's work

#

What's the difference between static and non-static?

eternal night
#

static means its on the level of the class

#

while not static means its on the level of the object instance created from the class

weak bear
#

Okay ! Thx a lot !

ornate patio
#

also how difficult would it be to modify world generation to make the amount of ores in veins smaller?

charred blaze
ornate patio
#

how hard would it be to learn how to do it

high pewter
#

I'm only now getting round to trying what I was suggested earlier, but I've came across an issue. I was recommended to use Maven build profiles (settings.xml) to set the directory (my testing server's plugins directory) for Maven to package my plugin's JAR to. However, to set this directory you need to use Maven build plugins, but you can't set build plugins (or anything under 'build') from settings profiles. Is there a way to do something similar to the below settings.xml but that is allowed in Maven?xml <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> <profiles> <profile> <id>spigotTestingServer</id> <build> <finalName>${project.name}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.1</version> <configuration> <outputDirectory>D:/hoppe/Documents/Testing server/plugins/</outputDirectory> </configuration> </plugin> </plugins> </build> </profile> </profiles> </settings>

ornate patio
#

mmm okay

#

where do i start

patent onyx
#

MyEvent cannot be triggered asynchronously from another thread.

high pewter
#

Maven package to testing server

stiff knot
#

hey does anyone know why spigot plugins won't load at all on pufferfish?

small current
#

?whereami

stiff knot
#

it is related to development i promise!

#

i also dont know if they have their own support server

eternal night
#

they do ๐Ÿ‘

small current
#

@stiff knot which plugin

#

Is not loading

stiff knot
#

its one i've made myself

#

just using the spigot setup in intellij

small current
#

Does it work on spigot?

stiff knot
#

it does

high pewter
#

Have you tried other plugins?

stiff knot
#

yeah other plugins seem to work fine

small current
#

What plugin is it

#

What is its purpose

stiff knot
#

literally just kills players below a certain y level

small current
#

How you check

#

Runnables?

#

MoveEvent?

stiff knot
#

moveevent

#
    @EventHandler
    public void onPlayerY(PlayerMoveEvent event) {

        if (event.getPlayer().getLocation().getY() <= -10) {
            event.getPlayer().setHealth(0.0);
        }

    }
small current
#

Try runnables
Idk if the pufferfish limits the moveevent or whatever

stiff knot
#

idk if that is the issue

#

it just doesnt load the plugin at all

small current
#

Error?

stiff knot
#

/pl just brings up "plugins(0)"

small current
#

Console

stiff knot
#

nothing in console either

small current
#

Does it start loading

#

Like loading plugin darfWsddsarfz

stiff knot
#

oh hold on

#

there was an error

#

unsupported api version 1.19

#

๐Ÿ˜ญ

small current
#

And what is the pufferfish?

stiff knot
#

1.18.2

small current
#

Try changing the api version to 1.18 in plugin.yml

stiff knot
#

alright

#

is that all i need to do to change it?

small current
#

Yep

small current
stiff knot
#

alright

small current
#

A player changes 0.1 yaw or pitch, this gets called
Moves 0.01 block it gets called

stiff knot
#

imma be honest, i started plugin development literally today so im not sure what the more optimised way to do it would be

small current
#

Check if the from and to have moved at least 1 full block

#

And return

eternal night
#

what

#

that is some not good advise

small current
#

PlayerMoveEvent is just not okay

stiff knot
#

that doesnt seem like it would change much?

eternal night
#

I mean, generally it should be fine to just run something every like half second or so instead

high pewter
#

But you're suggesting to still use PlayerMoveEvent but just put more code in the function

small current
#

Alright

stiff knot
#

yeah im not 100% sure why you'd do that

#

as i said i have no idea what the alternatives are

small current
#

Cause it might spam kill

#

Try it

eternal night
#

no

stiff knot
#

would it not make more sense to check if the player health is 0 and return if true

eternal night
#

just stick with the move event

stiff knot
#

and kill them if false

eternal night
#

yes

charred blaze
#

I'm doing something like this:

String code;
while (line!=null) {
   code = "something"
}
and when I'm using code variable here, it says it's not initialized
stiff knot
#

thought so

high pewter
#

Actually, why is there not just separate more specific forms of the PlayerMoveEvent? Like PlayerRotateEvent, PlayerShiftEvent (idk a better way to say 'move but not just rotate') or PlayerShiftBlockEvent

small current
#

If you just started

#

Stick with the move

#

Event

#

You will learn the alternatives

eternal night
high pewter
#

To reduce function calls?

stiff knot
#

okay, will it have a big impact on server performance?

eternal night
#

not like you can just not call player move event

#

should be perfectly fine dw

stiff knot
#

with like

#

40 - 60 players

eternal night
#

should still be fine, you are doing two checks

stiff knot
#

alright

#

if stray dies, its on my head!

small current
#

I listened for the fly packet and called an event
It worked fine and not like move event

Idk what bukkit did

high pewter
#

But what would the alternative be for plugins that 100% need to know every time a player changes position, but doesn't care about rotation?

eternal night
#

to listen to the move event and check that ?

small current
#

Or packet listening booo

eternal night
#

you'd be horribly breaking API contracts if you changed when move event is triggered

#

not to mention, then the server has to do all those checks

#

all the time

#

for any player move packet

high pewter
#

But wouldn't it be better for performance if your function was only called for changes in position?

eternal night
#

not really

high pewter
eternal night
#

the server would still have to compute that

#

yea sure this will be benefitial if more plugins use move event

#

but like

#

such a negligible difference

high pewter
#

Which I feel like quite a few plugins do lol

eternal night
#

definitely not worth breaking half the plugins on the earth for

small current
#

packet listening

stiff knot
#

dude i just need to know if im gonna get fired if i use PlayerMoveEvent

high pewter
#

How would it break plugins? You wouldn't have to change PlayerMoveEvent, you'd just add a few more events

stiff knot
#

alright

eternal night
#

I am a 1.18 plugin

#

i listen to the move event for rotation

#

now you come along and change it

eternal night
#

move event is only called for movement now

#

my plugin completely breaks

#

until I release an update that replaces that with your new event for rotation

#

which, that event does not exist in 1.18

small current
#

Your plugin was a mistake from the start

eternal night
#

so kekw

small current
#

No plugin listens for rotation

high pewter
#

I'm not saying to make move event only get called for changes in position- I'm saying have a separate event for changes in position. PlayerMoveEvent would still be for position AND rotation

small current
#

Realy who does that

small current
eternal night
#

if you are still calling the move event for everything

charred blaze
eternal night
#

and on top of that actually have to also call all other events

charred blaze
#

code variable

#

ok

#

it is 80 lines

small current
#

Listen for packets instead of moveevent

high pewter
#

By your logic, wouldn't the optimal solution be that all plugins just listen to all events and determine whether it's the event they're looking for? We have loads of events so that plugins only need to listen to what they need to

charred blaze
undone axleBOT
eternal night
#

not really ? the issue with the move event is that there is only a single point where it originates from

#

like, server receives player move packet and there ya go

high pewter
#

Ohhh I see what you mean now, fair enough

small current
#

Well there is that flying packet

#

And not for rotation

eternal night
#

if prior to the addition of the move event they split it

#

yea that could be nice

charred blaze
#

it does not longer because i added = null; on code variable

small current
#

I guess it gets called in both rotation and fly (move) packet

charred blaze
#

ok but

#

Will the while loop change that variable first, or will the other method call it first outside the while loop?

small current
#

Guys did you ever questioned life and what was going on in that mojang dev's head while doing nms specially supporting all versions?

charred blaze
#

what

#

mhm

#

ok ill test it

#

thats what im trying to

#

but i cant change that variable without while loop

#

wdym

#

the thing i want it to set to is in while loop

minor palm
charred blaze
#

yes but how to change it

#

no idea

echo basalt
#

bungee's chatcolor

charred blaze
#

i dont get it

minor palm
echo basalt
#

ChatColor.of("#123123")

#

gives the rgb color

minor palm
#

I didn't test it on 1.16 though

green prism
echo basalt
#

ChatColor#of

#

does this internally

minor palm
#

yea but ChatColor.of also gives dark green

#

for some reason

minor palm
#

๐Ÿค”

echo basalt
#

actually

#

For example, calling less repeated code (common clause)

#

reusing variables instead of calling getters

#

making your static values as constants

#

and constants are formatted LIKE_THIS

#

not like_somethingWeird

#

ehhh somewhat debatable, striving to enforce the best standards ever since the start is extremely nice

charred blaze
#

Will variable.replace() method edit the original string variable??

green prism
#

Well, that's perfect, but a way to keep my mind off uninstalling intellij as long as I don't see this code?

echo basalt
green prism
#

Anyone got any idea?

fleet comet
#

OKAY HEY GUYS im teleporting players, not even to another world and it only. tps. them. if. they. are OPERATOR

echo basalt
#

no need to go ham on the caps

#

it's probably just some permission check

#

show code

charred blaze
# echo basalt no, strings are immutable

So why is this loop spamming "2" on every tick?

                        while(line!=null) {
                            System.out.println("2");
                            if (!line.replace("'", "").substring(6).equalsIgnoreCase(sender.getName())) {
                                contains = true;
                                code = line.replace(line.substring(4), "");
                                if (plugin.verifiedconfig.contains(line.replace(line.replace("'", "").substring(4), ""))) {
                                    verified = true;
                                }
                            }
                        }
fleet comet
#

its just player.teleport(Main.getCourseLocation("trade"))

#

and ik the getcourselocation is a thing bc it works for me

echo basalt
#

maybe a check before that

chrome beacon
#

Show all the code

fleet comet
green prism
#

Nothing much, I was looking for someone to recommend a style to improve my code....
I know the style has to be my own, but you learn by imitation, and so, I was asking

fleet comet
#

@chrome beaconjava @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) { Player player = (Player) sender; if (args.length == 0) return true; switch (args[0]) { case "start": if (a.getData().contains("courses." + args[1])) { Location loc = a.getData().getLocation("courses." + args[1]); player.teleport(loc); player.getInventory().setChestplate(a.elytra); player.getInventory().setItemInOffHand(a.rockets); player.sendMessage(Artifact.construct("&aStarted course &f" + a.getData().get("courses." + args[1]))); a.inCourse.put(player, args[1]); } player.sendMessage(Artifact.construct("&cThat's not a course")); break; case "create": if (player.hasPermission("course.create")) { a.getData().set("courses." + args[1], player.getLocation()); player.sendMessage(ChatColor.GREEN + "Created new course " + args[1]); } } } return false; }

undone axleBOT
fleet comet
#

sorry

echo basalt
#

yeah the hasPermission whatever

fleet comet
#

not the create arg

green prism
#

There is a config called Inventories.yml.
It takes data for each item that needs to be inside the inventory by turning it into an ActionElement containing an Enum of the function they perform and the Item processed.

Thanks to the inventoryGui API, it adds the item and assigns an X click event to it if the Item enum is Y

In this case, the items, provide and set 3 possible genders based on what you click and open the next inventory of the Setup.

Setup consists of three parts: name, gender, age.

chrome beacon
fleet comet
#

okay

#

so it does what the rest of the code does

#

but doesnt teleport player unless they have operator

charred blaze
#

helpp

#

aah i get it

delicate obsidian
#

How does setCarriedMaterial method works correctly? I want to remove or replace the block that an enderman is holding

echo basalt
#

setCarriedBlock(BlockData)

#

setCarriedMaterial is if you're <1.13

#

You can pass anything you want

#

if the carried material is @NotNull, pass AIR

green prism
delicate obsidian
echo basalt
#

regardless, you'd only need that big block if the code you're doing was vastly different

charred blaze
#

if (plugin.verifiedconfig.contains(line.replace(line.replace("'", "").substring(4), ""))) {

echo basalt
#

Since it's just a message difference, I'd recommend some sort of registry

charred blaze
#

this gives me nullpointer

echo basalt
charred blaze
#

line isnt null

echo basalt
#

also that just looks horrible

charred blaze
#

verifiedconfig cant be null because im checking it in onenable

#

why plugin has to be null?

echo basalt
#

most cases*

#

I really hate these checks that go through all enum values

green prism
#

I completely understand,
That repeated code I'm afraid I can't do anything about it....
I think no matter how bad this code looks, to do these exact things, it has to stay that way.
Thank you for your answer anyway

echo basalt
#

it's so non-optimal

#

it really just needs to be organized in a different way

#

usually maps and lists are your best friend for this kind of stuff

green prism
#

I don't think so since it assigns an event to the click, it's not an action that can be extracted and repeated only once

echo basalt
#

ehh it can

green prism
echo basalt
#

let me make something in paint

green prism
#

Would you agree if:

.setClickListener(click ->
switch (element.getActionType()) {
    case case1:
        runA();
        break;
    case case2:
        runB();
        break;
    case case3:
        runC();
        break;
}```
echo basalt
#

Right now you have something like this

green prism
#

I must admit, I have outdone myself in intelligence xD
I understand now

#

The code was in mess...

echo basalt
#

which turns out to this

green prism
#

Well, I can fix that smallness but then, I would stop like a rock

echo basalt
#

add an extra column with the message value to the right btw

echo basalt
#

something like this

#

across your project

#

Translating this to a data structure

green prism
#

hmhmmhm

echo basalt
#

you either end up with:

  • a table
  • a Map<Role, Map<MessageType, String>>
  • an enhanced version of the method above, a MultiMap<Role, MessageType, String>
#

Google made a very simple class for this called HashBasedTable

#

Here's a basic example on how you can use it

green prism
#

WOW! I UNDERSTOOD!! I'm deadly serious

echo basalt
#
HashBasedTable<Role, String, String> table = HashBasedTable.create();

table.put(Role.SOMETHING, "no-permission", "The role SOMETHING doesn't have permission");
table.put(Role.SOMETHING_ELSE, "no-permission", "You suck");
green prism
#

wo

#

w

echo basalt
#

And then fetch it in a very simple way

green prism
#

Do I need to install some dependency?

echo basalt
#
String message = table.get(role, "no-permission");
echo basalt
green prism
#

Thank you!

#

Thank you @quaint mantle

echo basalt
#

You can use it for more than just messages

#

For example, cooldowns and all

#

This is a neat collection

green prism
jaunty crag
#

does anyone know how i would go about making throwables

#

sort of like the xp bottle and splash potions

green prism
echo basalt
#

yes?

green prism
#

How can I create a for-cycle with HashBasedTable?

#

Is there any obj?

echo basalt
#

cellSEt

green prism
#

Thank yuo!

green prism
# echo basalt cellSEt
        HashBasedTable<Action, String, String> table = HashBasedTable.create();

        table.put(Action.FEMALE, ConfigLoader.message_female, ConfigLoader.message_femaleClicked);
        table.put(Action.NONBINARY, ConfigLoader.message_non_binary, ConfigLoader.message_nonBinaryClicked);
        table.put(Action.MALE, ConfigLoader.message_male, ConfigLoader.message_maleClicked);

        for(ActionElement actionElement : inventoryBuilder.getElements()) {
            inventoryGui.addElement(actionElement.getCharPos(), actionElement.getStack(), click -> {
                for (Table.Cell<Action, String, String> genderCell : table.cellSet()) {
                    if (actionElement.getAction() == genderCell.getRowKey()) {
                        personUtil.getPerson(click.getWhoClicked().getUniqueId()).setGender(genderCell.getColumnKey());
                        click.getWhoClicked().sendMessage(genderCell.getValue());
                    }
                }
                if (!setup) {
                    customConfigsInit.saveInConfig(click.getWhoClicked().getUniqueId(), personUtil);
                    click.getWhoClicked().closeInventory();
                    return true;
                }
                return true;
            });
        }```
That's it now
echo basalt
#

ehh I'd just create that table elsewhere and cache all messages on it

green prism
#

hm

#

it's a getGenderChestGUI method which goes into an Inventory hashmap

#

idk

echo basalt
#

the table is structured like this

#

so it's a little weird

#

but also you don't need to loop through the entire table just to compare rowkey and all

#

it's a bit backwards

#

just add 2 separate entries under 2 keys

green prism
#

wat

green prism
#

hm

echo basalt
#

you can also just get all the rows or all the columns for a given id

green prism
# echo basalt you can also just get all the rows or all the columns for a given id

huh
like this:
java for(ActionElement actionElement : inventoryBuilder.getElements()) { inventoryGui.addElement(actionElement.getCharPos(), actionElement.getStack(), click -> { if(table.containsRow(actionElement.getAction())) { Table.Cell<Action, String, String> genderCell = table.cellSet().stream().filter(cell -> cell.getRowKey() == actionElement.getAction()).findFirst().get(); personUtil.getPerson(click.getWhoClicked().getUniqueId()).setGender(genderCell.getColumnKey()); click.getWhoClicked().sendMessage(genderCell.getValue()); }

#

Maybe it could be better with the for-cycle at this point

#

Idk

echo basalt
#

ehhhh

#

I mean this could make sense

#

it might be better to use nested maps

green prism
#

hmuhmmnhmm

#

huhh! You meant .column() method

echo basalt
#

no I meant like

#
HashBasedTable<Gender, MessageType, String> messages = ...

messages.put(Gender.SOMETHING, MessageType.SOME_MESSAGE, "test message 123");

for all messages on your project

#

inside your for loop, you'd do something like

Map<Character, Gender> genderMap = Map.of("1", MALE, "2", FEMALE, "3", OTHER);

#

so

#
Gender chosenGender = genderMap.get(...);

setGender(chosenGender);
sendMessage(messages.get(chosenGender, MessageType.GENDER_CHANGE))
green prism
#

Anyway, thank you!

#

Had I discovered HashBasedTable earlier, I would have done something awesome ahahah now, in at least every proj

ember estuary
#

Why is src null?

#

what am i doing wrong?

#

console

#

i try to use src later on

#

but its null

#

but why

#

yes

#

all u need to see

#

why is it null

#

src

#

why? that wont help

#

Cannot invoke "java.net.URL.toURI()" because "src" is null

green prism
ember estuary
#

here its null

#

the question is, why is it null

#

and my question is: why is it

ember estuary
#

that's the whole line

#

oh ok, ill try

green prism
#

Yeah

#

I quickly click 6 times and it gets to 30

#

Something similar

#

randomly

tender shard
#

whut? no

#

super is basically "this"

hazy parrot
tender shard
#

plus a few differences lol

hazy parrot
#

its not how it works

#

you must write input stream of every file

#

or using hacky jar entries

tender shard
#

no?

#

what are you trying to do?

green prism
#

y

tender shard
#

super IS the instance of your class

ember estuary
#

no way to copy a map easier?

tender shard
#

because a File object represents "itself" and not all it's contents

#

you can use FileUtils or similar

ember estuary
#

FileUtils.copyDirectory(srcDir, destDir);

tender shard
ember estuary
#

Tried all 4 combinations, nothing worked :/

green prism
ember estuary
#

what folder is getClass().getClassLoader().getResource() starting in?

#

the src or the resources folder?

#

anyone knows?

tender shard
#

why don't you just use getResource(...)

#

getting the classloader for a resource seems weird to me

ember estuary
#

cuz that returns a stream

#

i need a File object

tender shard
#

there is no file

#

it's inside your .jar

green prism
#

look at the msg

ember estuary
#

wym

tender shard
#

are you trying to read a "file" included in your .jar?

ember estuary
#

i wanna copy it from my jar

#

yea

tender shard
#

yes, you cannot do that

#

there is no File

ember estuary
#

what why

tender shard
#

because it's inside your .jar and not an actual file

ember estuary
#

so i cant copy stuff from the resources folder in my jar?

tender shard
#

of course you can

ember estuary
#

how

tender shard
#

but you won't have it as File object

ember estuary
#

ah

#

so i cant use FileUtils.copyDirectory cuz that takes a file and i dont have a file?

green prism
#

It is called within a process.
There is a setup that calls 3 different inventories in order, including that one. It simply takes the getAgeAnvilGUI method and does .show

#

It's so much code because there's also Type for each inventory, if you want I'll gladly pass it on to you :3

ember estuary
#

whats the workaround? is there a copyDirectory that takes a stream?

tender shard
ember estuary
#

yea .. :/

#

saw a solution like that on stackoverflow

#

every solution i find is like 50 lines

green prism
#

No, there is an OnJoinEvent that starts a setup method that takes 3 different inventories (including getAgeAnvilGUI().show()) in order and opens them one by one to complete the setup.

If you mean the age value that adds up, yes, in the onClick.

ember estuary
#

instead of a simple oneliner like FileUtils.copyDirectory

tender shard
#

with "copy" I mean "copy/paste the stackoverflow solution"

ember estuary
#

yea xD

green prism
#

ye

tender shard
#

you won't get it any shorter, a folder in resources is simply not a File :/

green prism
#

I think it's the AtomicInteger, I've never used it and it's pretty scary from the name

#

I can't use an int in a lambda

#

sadly

iron glade
#

Just use a final one size int array

green prism
#

wat?

iron glade
#

final int[] stuff = new int[1];

#

and then access it through stuff[0]

vocal cloud
#

Use an atomic int hes_UwU

vocal cloud
#

Brooooooooo

green prism
#

And this is the problem: Yeah I meant the age thing, ok so the problem is if you click it super fast it will go up a ton of values?

iron glade
#

then add some sort of cooldown

green prism
#

maybe a cooldown could do the job but...
Why does it do that? @vocal cloud

vocal cloud
#

Is it incrementing by 20?

green prism
#

Yeah, just by spam clicking few times

#

max 7 times

vocal cloud
#

I'd put a 3s cd on it

#

or something along that line of thought I agree with Mine

green prism
#

I'm going to try

vocal cloud
#

You can either do a ratelimit (max x per x seconds) or you can do a general cd (max every 50ms)

green prism
#

won't it become a server killer?

#

hm

#

hm

vocal cloud
#

Uh CD's should be lightening fast?

green prism
#

wdym

vocal cloud
#

It should be a currentTimeMillis - lastClickMillis > cdTime

green prism
#

currentTimeMillis?

iron glade
#

oh damn yeah don't use a boolean for that

#

actually check if enough time passed as Mike suggested

ember estuary
#

yea

green prism
#

huh

ember estuary
#

also looks like its global right now

#

so one person clicking gives everyone a cooldown

green prism
#

cool

ember estuary
#

unless u make an object for each thing idk

green prism
vocal cloud
#

It's the best way to do it. Make a HashMap with UUID,Long and you can store the last successful click time then compare to that for your cd

ember estuary
#

+1

vocal cloud
#

If it's inventory specific and only 1 person will view it you don't need a map obviously

green prism
#

I just figured out the problem, thank you!

iron glade
#

What was it?

vocal cloud
#

Uhhh you want to subtract currentTimeMillis with the time of the last successful trigger

#

wait nvm

green prism
#

currentTimeMillis - lastClickMillis > cdTime
as you said
:thonkForPoorPeople:

vocal cloud
#

You really like to inline all your variable code

#

Wait

#

I'm so tired nvm

#

Yeah that looks fine