#help-development

1 messages · Page 2034 of 1

young knoll
#

Da!

vivid cave
#

do you know how we could use reflection to import CraftPlayer according to current version server is running? (so we don't need to update this code every update)

tender shard
#

either you access all it's methods and fields using reflection

#

or you do it properly by writing a module per version

vivid cave
#

yeah haha i remember it was called like that before remapped, i had crazy fun finding those fields when they got obfuscated this way lmao

young knoll
#

?Jd-bcc

#

?jd-bcc

patent horizon
#

?

vivid cave
young knoll
#

Wut

#

All of it

patent horizon
young knoll
#

That’s the docs for component builder

sacred mountain
#

when u get an exception in your exception catch

young knoll
#

If you want to access a class with reflection you have to use class.forName

#

And then getMethod and getField

patent horizon
# patent horizon

@ivory sleet which one of these would i use instead of protocolVersion?

last sleet
#

Is there a way to add an enchantment, but only if it's compatible?

ivory sleet
#

oh u use 1.18.1 or 1.18.2?

#

might be a difference between the two

patent horizon
ivory sleet
#

let me check

young knoll
#

Iirc

last sleet
young knoll
#

Material.getMaxDamage I think exists

#

Or getMaxDurability

ivory sleet
#

weird

#

@patent horizon

#

((CraftPlayer) null).getHandle().connection.connection.protocolVersion still works just fine

#

import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;

patent horizon
pliant oyster
#

Y'all wanna know something crazy

#

Zlaio was able to comprehend my small brain and help me without the need of ?learnjava

ivory sleet
#

this is strange

pliant oyster
#

Exactly

#

Idk how he does it

lime jolt
#

starts having flashbacks

patent horizon
patent horizon
ivory sleet
#

"1.18.1-R0.1-SNAPSHOT"

#

thats what Im using

#

supposedly

#

I will look at 1.18 also

pliant oyster
wooden fable
#

Hey, i've been trying to turn off sprint swimming for a week now.

However, it doesn't work for me, I've tried a lot, but nothing works.

I'm now trying to use nms but I also can't find a packet how to get the player out of that swim state.
Does anyone know what I can use or does anyone know of another solution?

pliant oyster
#

I can help u in dms @lime jolt

patent horizon
#

idk why it would work

ivory sleet
#

im just as confusrd

upper crater
#

what's the thing that's writes text here?
idk remember the name or anything

kind hatch
#

Actionbar

patent horizon
# ivory sleet

i got the same error a while ago but with like Materials and whatnot

#

some people told me to fix my dependency and those went away

#

could be the same thing

#
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.1-R0.1-SNAPSHOT</version>
            <classifier>remapped-mojang</classifier>
            <scope>provided</scope>
        </dependency>```
upper crater
fossil lily
#

Anyone know why my config isnt updating when I change it? This is my code:

this.saveConfig();
ConsoleCommandSender console = getServer().getConsoleSender();
String botToken = getConfig().getString("discord-token");
console.sendMessage(botToken);
kind hatch
#

How are you changing it? Manually or with code?

fossil lily
tender shard
#

why didn't you do that

kind hatch
#

You need to reload the config.

fossil lily
#

And restarting the server reloads it

tender shard
#

it must have worked unless you did it wrong

fossil lily
#

:C

tender shard
#

also why are you saving your config?

fossil lily
#

idk

tender shard
#

instead of saving it, you should load the config

#

replace saveConfig() with reloadConfig()

fossil lily
#

mph

#

aight im doing excactly that

#

lets see what happens

lime jolt
#

does anyone why this line does not work "players" is an arraylist of Player objects if(sender.getName().equals(players.get(0).getName())){}

kind hatch
#

The array may be empty.

lime jolt
#

it is not empty

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

lime jolt
#

the code works

#

and runs

fossil lily
#

guess what????

lime jolt
#

but I think it is because it is ignoring the if statmnet

fossil lily
#

it still didnt work

#

this.reloadConfig();
ConsoleCommandSender console = getServer().getConsoleSender();
String botToken = getConfig().getString("discord-token");
console.sendMessage(botToken);

elfin atlas
#

Does someone know how I can raycast if a player is looking in a BoundingBox?

lime jolt
#

actually Ima just keep trying random stuff until this works

tender shard
fossil lily
tender shard
#

send your config with censored bot-token

#

the one that's in your plugin folder, not the one in your IDE

young knoll
#

Why reloadConfig in onEnable

#

It’s just been loaded

tender shard
fossil lily
tender shard
#

exactly

fossil lily
#

huh

tender shard
tender shard
fossil lily
#

interesting

#

k 1 sec

#

YAY

#

I changed it NOT in my IDE

#

thanks

patent horizon
#

@ivory sleet could u dm me your pom

ivory sleet
#

I use gradle

patent horizon
#

the only thing i can conclude is that my pom is different than yours

#

oh

ivory sleet
#

but I could dm u that

#

in case u'r interested

patent horizon
#

ok

vivid cave
#

how to convert itemframe entity to itemframe itemstack (that holds all the data ofc including "fixed" "invisible" "item"

#

is it possible without nms

young knoll
#

The frame itself?

vivid cave
#

ye

young knoll
#

You would have to store a bunch of stuff in the pdc of the item

#

Manually

vivid cave
#

ah ok then nms will be an easier road

#

oki thx

#

do u know how to convert bukkit (itemframe) entity to nms (itemframe) entity?

young knoll
#

Cast to CraftItemFrame

#

And getHandle

lime jolt
#

I am trying to make a game, where multiple people can join, but the game is running it for every player that joins, is there any work around to this problem, so that when a player joins once, the game will only run once, even when the other players join

#

so the first player that does the command sorta starts it all

#

the rest dont have that ability

vivid cave
#

so i thought i needed to do sth similar for entities

#

but i can't find such method so ig ur right

vivid cave
young knoll
#

That gets the NMS entity from the craft entity

vivid cave
#

oh

#

clever

#

thx

brave sparrow
#

you’re casting the ItemFrame to CraftItemFrame because CraftItemFrame is the craftbukkit implementation of ItemFrame

#

CraftItemFrame#getHandle is returning the NMS instance

vivid cave
#

ah okay makes sense, also just cuz we're talking about that, even tho i could google it, why is there bukkit and craftbukkit impls?
i suppose craftbukkit is the most abstract one? like an api for bukkit?

brave sparrow
#

No

young knoll
#

Bukkit is the API

brave sparrow
#

Bukkit is an API, it provides no implementation

young knoll
#

CraftBukkit is the imp

vivid cave
#

ahh

brave sparrow
#

CraftBukkit is the implementation of Bukkit’s API, and Spigot is a fork of CraftBukkit with additional changes made

vivid cave
#

i see

fervent gate
#

Is there a way to avoid this throwing an error in the console? Player target = Bukkit.getPlayer(args[0]);
I don't want to get spammed when a player makes a typo, or spams it

young knoll
#

Make sure args.length > 0

vivid cave
#

thx alex & coll 🙂

young knoll
#

And make sure you check if target is null after

brave sparrow
#

^

pliant oyster
#

If I click on an item, it doesnt detect that I clicked it for some reason

brave sparrow
#

if args is an empty array there is no args[0]

fervent gate
young knoll
#

Yes

fervent gate
#

Alright

brave sparrow
#

Null if they aren’t online

#

Not if they don’t exist

pliant oyster
#
if (clickedItem == emeraldOreItem) {

                System.out.println("emerald ore clicked");
                player.openInventory(emeraldConfirmGui);
young knoll
#

Well, yeah

brave sparrow
#

They could exist and be offline lol

fervent gate
#

If they don't exist, then error?

brave sparrow
#

If they aren’t online it will be null

pliant oyster
#

does that make a difference?

young knoll
#

Yes

fervent gate
#

Just if a player makes a typo and the typed name doesn't exist

brave sparrow
#

== is only for primitives, it compares memory locations only

pliant oyster
#

alr ill try it

brave sparrow
#

Equals is for objects, it checks equality by value

young knoll
#

.equals can be overridden to do whatever comparison you want

brave sparrow
#

Yeah

young knoll
#

(But also defaults to memory comparison)

pliant oyster
#

thanks!

brave sparrow
tender shard
#

does someone know how I can add a marker (like on treasure maps) to a map?

#

I know I can create a custom renderer but it allows me to draw text, images or pixels, I just want the default red X to be added

quaint mantle
tender shard
#

aren't those the player markers?

#

OOOH

#

there's a CurserType

#

thanks, I didnt even look at that class because I thought it was just the normal player makers

quaint mantle
#

balls

young knoll
#

You can show and hide them too

#

And mess with the caption

#

That’s really cool

patent horizon
#

which of these builds is the one i wanna use on my server

unkempt peak
#

should be the first one

tender shard
#

other question: when creating a MapCursor, what's the center of the map? Is it 0,0?

young knoll
#

I would guess 0,0 is top left

#

But I could be wrong

tender shard
#

yeah I thought so too, I'll just try out some values

young knoll
#

If that’s the case there is no exact middle

#

Well there isn’t regardless

patent horizon
tender shard
#

0,0 is the center

young knoll
#

Did you read why

young knoll
#

Ah, fair enough

tender shard
quaint mantle
#

make drakes map in minecraft

patent horizon
#

ah no i see why

young knoll
#

I kinda wanna do something fancy with maps now

#

No idea what tho

quaint mantle
#

gta in minecraft

#

with a working minimap

unkempt peak
#

make a display that you can play videos on

young knoll
#

A zoomable mini map would be cool

quaint mantle
unkempt peak
#

or better yet stream a pc or vm on maps

young knoll
#

Lol

quaint mantle
#

Omg

unkempt peak
#

and have inputs ingame

young knoll
#

Someone did it with blocks, not a map tho

quaint mantle
#

i could make a screenshare in minecraft

#

holy shit

young knoll
#

Yeah someone captured live feed from a connect into blocks

#

It was cool

quaint mantle
#

bruh

#

i can do it in plugins tho

#

i dont want to though

young knoll
#

Imma look into a fancy mini map with maps

#

Could be fun

unkempt peak
#

You should stream a vm to maps and somehow have controls for the player to use the mouse and type in chat for keyboard

tender shard
#

My code is so awesome, it throws an internal server error

quaint mantle
tender shard
#

if you want to reproduce

quaint mantle
unkempt peak
#

it would make a great youtube video

tender shard
#
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onDeath(PlayerDeathEvent event) {
        Location location = event.getEntity().getLocation();
        ItemStack map = new ItemStack(Material.FILLED_MAP);
        MapMeta meta = (MapMeta) map.getItemMeta();
        MapView view = Bukkit.createMap(location.getWorld());
        view.setCenterX(location.getBlockX());
        view.setCenterZ(location.getBlockZ());
        view.setUnlimitedTracking(true);
        view.setTrackingPosition(true);
        view.addRenderer(new MapRenderer() {
            @Override
            public void render( MapView mapView,  MapCanvas mapCanvas,  Player player) {
                System.out.println("render");
                mapCanvas.getCursors().addCursor(new MapCursor((byte) 0, (byte) 0, (byte) 0,marker,true));
                mapView.removeRenderer(this);
            }
        });
        meta.setMapView(view);
        meta.setLocationName("Test");
        map.setItemMeta(meta);
        Bukkit.getScheduler().runTask(this, () -> {
            event.getEntity().getInventory().addItem(map);
        });
    }

Removing the MapRenderer from inside the MapRenderer causes this InternalServerError thingy

quaint mantle
#

why

#

oh cause its accessing it but it doesnt even exist

#

oooo thats some trippy java logic

tender shard
#

I have no idea, I basically just wanted to do add the cursor once instead of every tick

#

but it seems like you can only add them in the render method that gets called every tick

patent horizon
vivid cave
#

concerning map renderers

tender shard
vivid cave
#

maprenderer#render triggers when?
(i mean when they are displayed on item frames)
ik they keep spamming the render method when someone is "viewing" it but i couldnt' really find out when it considers as being viewed/when it should be rendered

tender shard
young knoll
#

I doubt it runs in a frame

vivid cave
#

no i mean in item frame

young knoll
#

Since it takes a player

vivid cave
#

oh it does!

young knoll
#

Iirc maps do not update in frames anyway

vivid cave
#

they do:

tender shard
#

it gets called everytime a map gets updated

#

so yeah, like in vanilla

vivid cave
#

(i made a whole gif system so i know what i'm taliing bout)

tender shard
#

when you have it in your hand, it gets called, when it'sj ust in your inv, it doest get called

vivid cave
#

im talking in item frames not in inv

#

oh and they do trigger #render like every 100 ticks orso

#

even if the map isn't changed

#

and even if its in item frame

young knoll
#

“If a player holds a map whose clone is on display in an item frame, then that map updates while holding its clone.”

#

Sorta implies they don’t by default

vivid cave
#

lemme give you an example:

tender shard
#

as someone already stated, the render method takes a player

#

maps in itemframes do not update, neither in spigot nor vanilla

young knoll
#

Unless you hold a clone of them

tender shard
#

no idea, all I know is that Player in render is annotated with NotNull

#

so it'll never get called without having a player holding the map

vivid cave
#

I login for the first time on my server since last reboot
my inv is empty
I look at my wall, it has an item frame holding a map
On startup, i removed all renderers of this map and added a renderer which #render(...) only executes System.out.println("rendering")
You will see, it will spam "rendering" to your console

#

Guys you all are wrong here

#

test it if u dont trust me

tender shard
#

okay one minute

vivid cave
#

its just like anvilprepareevent, it keeps triggering

tender shard
#

oh fun fact

#

it keeps rendering, but WAY slower

#

with a player holding it, it keeps spamming it like 5 times per second

#

without a player it goes down to once per second

vivid cave
#

^^

young knoll
#

But

#

Who’s the trigger player

tender shard
#

well, me

#

lol

#

probably the nearest player

young knoll
#

Hmm

#

Guess so

tender shard
#

I don't have alt accounts right now since I'm too lazy to migrate them to M$

warm trout
#

Lets say the stone block to the right is the starting location, and the stone block the left is the ending location, how would I get the location right in front of the starting location (jungle wood block) that's in between both locations

warm trout
#

I'm having trouble with that 😭

tender shard
#

you can get the vector between both locations which is basically an arrow pointing from start to end. then you can normalize that vector so it has a lengh of one, add it to the original location, and get the block at that location

#

done

vivid cave
# young knoll Who’s the trigger player

see i told you; anyway back at my question, i really wanna find out when this method triggers (when in item frame)
I mean the answer "when a player is viewing it is vague", cuz when does it consider that a player is viewing it? does it have a brainy logic to check if player is watching it specifically, like checking the angle of vision and big brain maths stuff to determine if its in his visibility? (Spoiler alert, no, i tested it)

young knoll
#

I would imagine like

#

As long as the entity is in activation range?

#

Or what’s it called

#

Simulation distance

tender shard
vivid cave
#

ah okay

#

makes sense yes

tender shard
#

IIRC the view distance for stuff in itemframes is 64 or 48 blocks

#

so probably the maps will use a similar distance

warm trout
#

Would that be how to get the vector in between

tender shard
#

I always confuse it, it's either end - start or start - end

#

you'll have to try it

warm trout
#

Alright

young knoll
#

Ugh making a mini map with maps is gonna be annoying

warm trout
#

Thanks

young knoll
#

I gotta like, manually render each pixel

tender shard
#

yo guys, I don't see another solution as this to only add a cursor to a map - does anyone know if there's a better way?

        view.addRenderer(new MapRenderer() {
            boolean done = false;
            @Override
            public void render( MapView mapView,  MapCanvas mapCanvas,  Player player) {
                if(done) return;
                mapCanvas.getCursors().addCursor(new MapCursor((byte) 0, (byte) 0, (byte) 0,marker,true));
                done=true;
            }
        });
#

I basically just cancel the render() if done is true

#

which is a bit dirty since I still have the maprenderer object being around now

#

I actually don't need any renderer, I just wanna add one cursor that will stay at the same location forever

warm trout
#

before I test this does this look fine 😭

currLoc.clone().add(loc.toVector().subtract(currLoc.toVector()).normalize());```
#

I'm trying to make a mob pathfind into a certain type of ore and mine the blocks in front of it, it's killing me lmao

warm trout
#

Alright, and if I want to get the 2 blocks in front of that, would I just multiply the whole thing by 2/3?

tender shard
#

exactly

young knoll
#

I’ll have to just look at how Mojang renders maps and copy borrow that I guess

warm trout
#

Alralr thank you

tender shard
young knoll
#

Well yeah

#

This is for me looking to make a mini map

warm trout
#

Can never escape NMS 😈

tender shard
#

ooh okay

#

I thought you replied to my question

tender shard
#

only problem is when an update gets released

#

when 1.18.2 came out I was on vacation >.<

warm trout
#

Don't know why I'm doing this to myself, but it works

tender shard
#

because

#

they allow you to recompile all your stuff with the same code

#

if 1.18.3 comes out, all you have to do is to recompile it without any code changes

warm trout
#

Ah for cross version compability?

tender shard
#

well, mostly without code changes

versed wren
#

Hi folks! how can i send bungeecord messages directly to another server on the network?

tender shard
#

but yeah you can always just copy paste your stuff

warm trout
tender shard
#

yep. for example:

#

all I had to do to go from 1.17 to 1.18 was to change
playerConnection to connection.connection

#

when sending packets

#

no other change was needed

vivid cave
# tender shard I actually don't need any renderer, I just wanna add one cursor that will stay a...

Well unfortunately you're obliged to use a mapRenderer (i've been dealing with that myself and i'm 99% sure u need a renderer here, mainly cuz the mapcanvas object where ur drawing ur stuff is only received over there in #render)
Concerning cursors, i think you could do image editing; add your cursor on top, and render your image on mapCanvas.drawImage(...) (kinda overkill for what ur trying to do tho i think)

tender shard
vivid cave
#

yeah its what i've been using :p

tender shard
#

e.g. this, just having a banner_orange in the middle, that's all I need

warm trout
tender shard
#

mojang mappings are heaven sent and cursed at the same time

#

cursed because ability to use reflection is completely gone

#

heaven sent for the rest

warm trout
#

Then I realized I didn't need reflection at all 😆

#

At first it was also confusing to adjust to it because of all the name changes

#

More used to Hsjqwdhjqwdhu then Mob

tender shard
#

I highly suggest to create a lib that you use for all your NMS stuff

vocal cloud
#

I love reflection happy

tender shard
warm trout
vivid cave
warm trout
vivid cave
#

lol

tender shard
warm trout
#

Not great times 😆

vivid cave
#

🤣

vocal cloud
warm trout
warm trout
#

Class loader>?

vocal cloud
#

It's for auto registration of listeners and commands

warm trout
#

Ohhh bro I got a cleaner version of that

tender shard
#

Another question: Look at this map. This is the code:

        meta.setMapView(view);
        meta.setLocationName("Test");
        map.setItemMeta(meta);

what's the location name for? it nowhere shows up on the map

vivid cave
#

are u guys trying to make remapped nms usable at runtime or sth? or what are all these sc

warm trout
#

Google Commons lib in clutch

#

Saw that somewhere on spigot 2 years ago LOL

vocal cloud
#

Mine requires no external dependencies

#

Which is why it's so ugly.

warm trout
#

Makes sense

tender shard
warm trout
#

I mean if it's just for spigot then the google commons lib is prolly a good idea

young knoll
#

Huh

#

Map location name isn’t documented properly

#

It has the same javadocs as setMapColor

patent horizon
#

which of these should i use

warm trout
#

Maybe it's supposed to set the text when you hover over a location on the map or something

ivory sleet
#

probably the second wally

tender shard
#

the second one

warm trout
lime jolt
#

does anyone know how ticks count, do they count for each individual player or togheter

tender shard
#

so for all players the same

lime jolt
#

dang

tender shard
#

why?

lime jolt
#

this is confusing then

tender shard
#

what are you trying to do?

lime jolt
#

all my code bugs out because mutlipel players do a command that loads the entire game

patent horizon
#

so my chat format goes away when i use %s in my message. how can i fix this?

        if (player.hasPermission("chat.color")) event.setFormat(u.f("&8[&e" + level + "&8] " + prefix + "&7" + event.getPlayer().getName() + " &8» " + chatColor + message));
        else event.setFormat(u.f("&8[&e" + level + "&8] " + prefix + "&7" + event.getPlayer().getName() + " &8» " + chatColor ) + message);```
lime jolt
#

I only want the first player who does the command to load the game

#

and the rest who use it just join

#

I have a peratmeter that makes it do that

#

but

tender shard
vivid cave
# tender shard Another question: Look at this map. This is the code: ```java meta.setM...

i think but (really i'm not even 50% sure here) that location is just a meta data string which isn't relevant that much, just for some "checking what type of map it is" like "this map is the map of a shipwreck so location=beach?" or "this map leads to the illagers place" etcetera
Actually MapMeta is NOT interfering with actual stuff that it rendered on it, it's just a class to hold data; MapCanvas is the one where u'll be able to make appear some stuff on it like cursor text etc

lime jolt
#

it no work

warm trout
patent horizon
#
java.util.UnknownFormatConversionException: Conversion = 'p'
    at org.bukkit.event.player.AsyncPlayerChatEvent.setFormat(AsyncPlayerChatEvent.java:105) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
    at net.plexpvp.core.listeners.ChatListener.onChat(ChatListener.java:50) ~[core-1.0-SNAPSHOT.jar:?]
    at com.destroystokyo.paper.event.executor.MethodHandleEventExecutor.execute(MethodHandleEventExecutor.java:37) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:git-Paper-177]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
    at io.papermc.paper.adventure.ChatProcessor.post(ChatProcessor.java:230) ~[paper-1.18.1.jar:git-Paper-177]
    at io.papermc.paper.adventure.ChatProcessor.processingLegacyFirst(ChatProcessor.java:115) ~[paper-1.18.1.jar:git-Paper-177]
    at io.papermc.paper.adventure.ChatProcessor.process(ChatProcessor.java:64) ~[paper-1.18.1.jar:git-Paper-177]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.chat(ServerGamePacketListenerImpl.java:2204) ~[?:?]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2115) ~[?:?]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2081) ~[?:?]
    at net.minecraft.network.protocol.game.ServerboundChatPacket$1.run(ServerboundChatPacket.java:40) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
[01:07:22 INFO]: <WallyTube> %haha
#

oops

warm trout
#

LOL

patent horizon
#

u saw nothing

patent horizon
#

how so

tender shard
#

you have to set the format to sth like htis:

fast path
#

Hi all

tender shard
#

"[%s] %s"

fast path
#

I woke up

tender shard
#

this will make it show like [mfnalex] hi

#

you can use two %s: one for the playername, one for the message

lime jolt
#

I created a static arraylist and asked if you are the last person in the array list, if so you start the game

tender shard
#

DO NOT add your message manually into it

warm trout
#

then check if its true, and if it's true, make them join, if it isn't true, make it start the game

#

@tender shard I love you for the vector math it finally worked

lime jolt
#

is using a runTaskTimer important or can I use something else to count ticks

vivid cave
# vocal cloud

is this code to be able to use non obfuscated nms classes at runtime (with reflection)

tender shard
vocal cloud
warm trout
#

Yeah that's great, I might've been have been able to do it myself if I learned how vectors worked

young knoll
#

Hmm I wonder think my minimap idea will work for anything bigger than 128x128

warm trout
#

And what are intermediary/searge mappings?

young knoll
#

Way too laggy to scan a large area constantly

#

Unless I cache the crap out of things

tender shard
#

old_growth_spruce_taiga

hybrid spoke
#

looks like an mmorpg

tender shard
hybrid spoke
#

oh ew

#

we'll stay with the map

tender shard
#

note: the golden platform is TOOOOTALLY vanilla

young knoll
#

Of course

hybrid spoke
#

show your mousebutton history

tender shard
#

do you people also have such weird config classes? or how are you handling default config values etc?

patent horizon
#
        name.setHoverEvent(
                new HoverEvent( HoverEvent.Action.SHOW_TEXT,
                        new ComponentBuilder("lorem ipsum").create())
        );``` how can i set a hover text with multiple lines?
vocal cloud
tender shard
#

but I'm not going to refactor 400 config options now

young knoll
#

RedLib makes it nicer

tender shard
young knoll
#

Yes

tender shard
#

that's nice

#

will take a look at it sometime again

#

for real, I have read so many blog posts and still don't understand why people think using a static instance getter is bad practice.

public class DeathMapManager {

    private static final Main main = Main.getInstance();

How is that bad? I don't get it

ivory sleet
#

tightly coupled so it reduces re usability to some extent

tender shard
ivory sleet
#

no lol

patent horizon
ivory sleet
#

and its hard to see the actual dependencies of a unit when u couple it that way

lime jolt
#

Every 20 ticks in one of my classes, a countdown from 10 starts. This is when a message and a title is sent to all the players in the game stating what the count is in the countdown (10, 9, 8, 7, 6, 5, 4, 3, 2, 1). However, the countdown is showing only even numbers for one player and odd numbers for another (when there are 2 players on the server) (One player sees; 10, 8, 6, 4, 2, 0, -2, -4, -6, - 8, -10 and other sees; 9, 7, 5, 3, 1, -1, -3, - 5, -7, -9). Why does this happen, and how can I fix this issue? the code below is what prints it, but this should not skip a count and have diffrent counts for each player every other 20 ticks .```for (int i = 0; i < MyFirstPlugin.players.size(); i++) {

            MyFirstPlugin.players.get(i).sendTitle("" + countDown, "Void Is Starting", 1, 20, 1);
            MyFirstPlugin.players.get(i).sendMessage(ChatColor.DARK_PURPLE + "Void Is Starting In: " + countDown + " seconds");
            MyFirstPlugin.players.get(i).playSound(MyFirstPlugin.players.get(i).getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 9999F, 1F);
            countDown--;
        }```
fast path
ivory sleet
#

You'd need power mocks to mock that dependency mfnalex

tender shard
ivory sleet
#

mockbukkit is for mocking certain bukkit interfaces

fast path
#

But you can use \n in string too

ivory sleet
#

power mocks is a lib in case you didnt know

tender shard
ivory sleet
#

?

#

sure

ivory sleet
#

but like you mock units to presuppose that no dependencies causes a unit's procedure to fail

tender shard
#

I just do MockBukkit.load(AngelChestPlugin.class)

fast path
ivory sleet
#

yes

#

that doesnt mock your unit tho

#

that loads it (with a special class loader)

lime jolt
tender shard
#

I'm not sure what you mean with "unit" tbh

ivory sleet
#

AngelChestPlugin

lime jolt
warm trout
tender shard
ivory sleet
#

really doesnt

tender shard
#

well not dirtier

#

but way more complicated

#

I don't want to have to pass 20 things to every new listener or class or whatever

ivory sleet
#

if your code is well designed your constructors will still take a maximum of like 4 dependencies

warm trout
#

Yea, and then you start having a bunch of managers that you have to call the instance for each time instead of just calling one single method

ivory sleet
#

then you're doing something wrong

tender shard
#

I am totally fine with a listener belonging to AngelChest depending on AngelChest's main class

fast path
#

Let me fix your code

lime jolt
#

?!?!?

#

but, it should go down by ones

tender shard
ivory sleet
#

The point of using dependency injection is make any outside dependency conspicuous, decouple the unit such that it does not tightly depend on a specific instance which static singleton pattern surrounds and it makes the unit more testable and reusable in case you have a different instance of whatever dependency you might have.

tender shard
ivory sleet
tender shard
#

but I don't see any advantage in doing so

patent horizon
tender shard
ivory sleet
#

decoupling, abstraction layering, separation of concerns etc

tender shard
#

I don't need to decouple a listener that is made specifically for plugin X to be independent from plugin X

ivory sleet
#

maybe not right now

tender shard
#

it's worthless without plugin X anyway

ivory sleet
#

but in the future its very possible radical changes may be encountered

#

people always assert and claim that future changes are predictable

tender shard
#

I am pretty sure I'll never need a listener that listens to player's deaths and creates an AngelcHest for them in any other plugin that won't be angelchest, ever

ivory sleet
#

thats 100% false without fail

tender shard
#

but yeah, sure, one could never know for sure

#

I just don't see any advantage in doing all this refactoring right now without getting anything in return right now

ivory sleet
#

business requirements change all the time, so making one's software as robust as possible is a substantial goal, if you cannot make software malleable and shapeable then your software is simply not soft

#

yes its mostly overkill for a mere spigot plugin

tender shard
#

I don't consider one class a software but the .jar as a whole though

lime jolt
ivory sleet
#

yes

tender shard
#

noone extracts a single class out of a project and expect it to work

ivory sleet
#

but that component is a part of your software system

#

no thats not point at all

young knoll
#

4 arguments?

young knoll
#

Just pass your plugin to everything

#

Boom 1 argument

ivory sleet
#

its just worse in long terms to couple DeathMapManager with Main::getInstance

ivory sleet
#

its quite coupled to the plugin context object

#

somewhat impossible to track dependencies

young knoll
#

I’m a bit guilty of that

#

It’s annoying how much you end up needing it sometimes

ivory sleet
#

yeah I do agree

tender shard
#

I still don't understand why I'd ever need to keep a listener running that was made for exactly one plugin without having that one plugin's main instance

ivory sleet
#

some people circumvent colossal argument constructors by using dependency injection frameworks

#

but those di frameworks just suck

tender shard
#

true

#

I really tried to use them

young knoll
#

Make a simple one just for plugins

tender shard
#

I always just hated them

young knoll
#

Injects your plugin instance into @Plugin annotated fields

vocal cloud
#

Did somebody say reflection?

tender shard
young knoll
#

Shhh

#

Details

#

Do you need to pass all instances you make to the di framework

tender shard
#

imho making everything testable and reusable is a huge waste of time

young knoll
#

Or can it just like, detect new instances being created

tender shard
#

one should just make stuff reusable if you actually intend of reusing it

young knoll
#

With magiks

ivory sleet
#

if your listener for instance encapsulates a static singleton call

#

then it will be impossible to substitute concretion of said higher abstraction

#

of course the disadvantage may seem rather subtle if you dont pay attention

#

but lets say you wanna test it, or you wanna swap concretion

#

then having that dependency injection from the beginning would have minimized the change you'd have to go through

tender shard
ivory sleet
#

now yes you rarely do unit tests as I understand so automated testing for you is probably not something you account for

ivory sleet
#

like in adventure, bungee chat api

tender shard
#

I do a huge amount of tests, angelchest takes about 2 minutes just to do all tests, but of course I have an instance of my plugin when running those tests

ivory sleet
#

I can name just so many libraries where spontaneous changes to details had to be made

young knoll
#

To be fair

#

Those are libraries

ivory sleet
#

well I mean even LuckPerms

tender shard
#

yeah there's a huge difference between a library and a listener that obviously does stuff only related to one specific plugin

ivory sleet
#

altho its abstraction hierarchy is flawed

lime jolt
ivory sleet
#

like at the end sure using getInstance wont destroy you

#

its just about maintainability, robustness and clarity

young knoll
#

Just

#

Never change your code

tender shard
ivory sleet
#

ending up with LinkageErrors eventually

young knoll
#

I’ve never seen a linkage error

ivory sleet
young knoll
#

Just do better

ivory sleet
#

I mean you've probably seen them

#

just their derivatives

young knoll
#

Shh

ivory sleet
#

NoSuchMethodError

#

etc

#

🙂

young knoll
#

I’ve seen NoClassDefFound

ivory sleet
#

ye one of them

young knoll
#

But that’s because I’m bad at shading

vocal cloud
#

Use annotations to avoid it

ivory sleet
#

mfnalex, like oop devs wouldn't have come up with all of these principles and patterns just because of mere fun

tender shard
#

so that's why I hate it when people say "oh no, static getInstance is baaaad" no that's not true, It's not bad in general. It might not be the best future proof option but that doesn't mean it's inherently bad. Like, everything we are coding depends on something and we can never go 100% independent, it's just a trade-off between "how abstract do I wanna go" and "how much time do I rather want to spend on adding new features" etc

ivory sleet
#

they had to address problems that oop generally had

#

the very flaws of developing with oop

fluid nacelle
#

For a projectile trail (for it to look a little smoother by being behind the projectile), do you think it'd be more efficient getting the projectile's velocity then subtracting it's x/y/z values based on the velocity and spawning the particle at that location until velocity = 0 (then it cancels)? Or do you think it'd be more efficient to use a BukkitRunnable timer, then another timer inside of it to grab the location currently then runTaskLater() lots of times until the previous and current locations match in which it cancels? More so thinking the 1st option but may as well ask to be safe lol

ivory sleet
#

there's a reason why most companies demand developers to have high abstraction ability for instance and thats for good reasons

#

yes getInstance isnt inherently bad and no one has ever claimed it to be

vocal cloud
#

Just use copium levels of reflection instead happycrab

ivory sleet
#

its just 16/17 times not gonna be the right design pattern due to the disadvantages it ultimately yields

tender shard
ivory sleet
#

Well, even for smaller ones

tender shard
#

but I really don't understand it for spigot plugins

ivory sleet
#

code bases under 100k lines

#

yeah

tender shard
#

oh wait

#

wasn't there a tool to check the code lines and also prints out the number of lines per language

#

a linux CLI tool

ivory sleet
#

lol

ivory sleet
#

idr

#

as aforementioned its not the most crucially integral thing as to a spigot plugin

#

but it sure helps once the plugin might scale to different platforms and what not

tender shard
#

Conclure wanna see something nasty?

ivory sleet
#

lol sure

young knoll
#

Oh no

tender shard
#

I wrote this class in 2018 when I just got started with MC plugins

#

every field is public

#

lol

ivory sleet
#

oh

#

guudness

young knoll
#

Why can’t final variables be public

#

Like

#

By convention

tender shard
#

I very often have private final fields

#

or private static final fields

ivory sleet
#

and

#

u know

#

oop

young knoll
#

No

#

I refuse

ivory sleet
#

abstraction heuheu

#

😔

young knoll
#

Private is banned

ivory sleet
tender shard
#

the most weird thing is "package-protected"

ivory sleet
#

thats a thing?

tender shard
#

that's using no modifier

ivory sleet
#

oh

#

packpriv

tender shard
#

it means same package can access it

ivory sleet
#

ye

tender shard
#

and also subclasses

#

even if from another package

young knoll
#

What’s the dif between protected and no mod

ivory sleet
#

mye I kinda hate packpriv

young knoll
#

I always forget

warm trout
#

does anyone even use that

ivory sleet
#

rarely ever needed

ivory sleet
warm trout
#

:thonk:

ivory sleet
#

but it becomes incredibly annoying if you use it for, for instance constructors, especially when you start unit testing

tender shard
young knoll
#

I see

ivory sleet
#

mfnalex so since you do unit test

young knoll
#

So it’s protected but it hecks subclasses

#

Weird

tender shard
ivory sleet
#

would you claim that unit tests make your code architecture better

#

or not?

#

out of curiosity

warm trout
#

How can I make this less laggy, it runs every tick and is kind of killing the server, it's checking to see if the path is done, and if it is, it will break the 3 blocks in front of the mob

tender shard
ivory sleet
#

iirc u can set the type w/o applying block physics

tender shard
#

yes, there's a boolean for that

ivory sleet
#

Im with u

#

unit tests at no point will give you better design

young knoll
#

Sysout also tends to slow things down a lot

tender shard
#

if at all, they make it worse by just writing the class to pass the test

ivory sleet
#

tho some claim the inverse

#

yeah

warm trout
tender shard
#

yeah it's a philosophical question I guess 😄

young knoll
#

setType(type, false)

warm trout
ivory sleet
#

well Ig tdd fans might be hunting us down soon

warm trout
#

Thank you Il, try it out

tender shard
fast path
ivory sleet
#

test driven development

warm trout
ivory sleet
#

every test must fail before getting it to work

#

every public function must be tested

warm trout
#

Oh wait that isn't nms

fast path
#

I mean setType

warm trout
#

You mean nms to remove it

#

Yeah

earnest forum
#

does a while loop create its own thread in java?

ivory sleet
#

and there's another rule to it (which idr)

#

nope yada0

warm trout
#

I'll try that

ivory sleet
#

but basically the cult of tdd enforces you to write humongous amount of tests

#

supposedly that will help you to code better or make sure no code goes unused

#

(tho im strictly against it)

young knoll
ivory sleet
#

yeah

#

you need to have like 99% test coverage

#

or sth

#

basically you wont be able to test priv, packpriv and prot functions

#

but all public functions should (in principle) be MUST tested

young knoll
#

Ew

ivory sleet
#

ye

young knoll
#

I’d rather just use the default code coverage

ivory sleet
warm trout
#

Ahhhhhh reflection is so slow

young knoll
#

Granted that’s harder on plugins

ivory sleet
young knoll
#

Reflection isn’t bad if you like

#

Cache it

ivory sleet
vocal cloud
young knoll
#

Or use them method handles

wet breach
#

I just don't write tests

ivory sleet
#

why?

#

unit tests can be to much help if you have a couple of non trivial functions you wanna make sure dont do the wrong thing

#

and when it comes to atomicity

#

testing is more or less crucial I'd assert

warm trout
wet breach
#

because it is faster to have beta testers test it out, then it is to create some test for it that may need to change later down the road

young knoll
#

Will j18 reflection make method handles obsolete?

ivory sleet
#

oh so the qa people gets to test it

young knoll
#

Well, in terms of performance at least

wet breach
#

while QA people are not perfect, it is still faster

ivory sleet
#

meh

wet breach
#

also, they will test for things you didn't think about as well

ivory sleet
#

they cant test everything unit tests are capable of

young knoll
#

I gotta admit

wet breach
#

which a unit test isn't going to do

ivory sleet
#

sure thing

young knoll
#

Users can find some weird bugs

tender shard
young knoll
#

Like how someone found a typo in the latest snapshot :p

tender shard
#

TestTests.java

ivory sleet
#

but you have tests which tests when units talk to units, and when the entire system talks with it self also frostalf

tender shard
#

Testing the unit tests

ivory sleet
#

like system tests

wet breach
wet breach
#

because you already know how it is supposed to work, or in other words biased

tender shard
#

at least you shouldn't write the test before writing the class itself lol

wet breach
#

it is the same reason why developers don't test their own stuff when it comes to QA

ivory sleet
#

if you implement a multi threaded 2d map then perhaps its best if you write the tests for its atomicity methods

tender shard
#

but yeah having another person to the tests will probably result in better testing

wet breach
#

I mean alpha testing is fine for developers to do, but beta testing is done with other people

tender shard
#

because you wanna show you coworker fucked up so you're trying to really break their code lol

#

for example imaine you have a math class that does stuff. now pass Double.NaN to it and watch it explode. you probably wouldn't do that in your tests for your own class

ivory sleet
#

And when qa people test they sometimes find a bug which to most extent is impossible to identify trivially, whereas if some tests were written could have easily tested the procedure out

tender shard
#

NaN is by far the weirdest construct in whole java

#

Double.NaN == Double.NaN returns FALSE!

young knoll
#

Double.NaN == “potato” should return true

tender shard
#

no that's false too

young knoll
#

Because “potato” is in fact NaN

tender shard
#

lol well yeah

ivory sleet
#

hehe JavaScript

tender shard
#
Double nan = Double.NaN;
if(nan != nan) {
  downloadCraftbukkit();
}

THis will actually download craftbukkit

quaint mantle
#

does nan mean not a number

tender shard
#

yes

fast path
# tender shard Double.NaN == Double.NaN returns FALSE!

An operation that overflows produces a signed infinity, an operation that underflows produces a denormalized value or a signed zero, and an operation that has no mathematically definite result produces NaN. All numeric operations with NaN as an operand produce NaN as a result. As has already been described, NaN is unordered, so a numeric comparison operation involving one or two NaNs returns false and any != comparison involving NaN returns true, including x!=x when x is NaN.

wet breach
tender shard
quaint mantle
fast path
quaint mantle
#

why not just add more safety instead of having that

tender shard
#

Math.sqrt(-1) also is NaN

#

oh but fun fact

wet breach
#

that is more dumb

tender shard
#

0 / 0 throws exception

wet breach
#

as it should...

tender shard
#

but when using 2 doubles, it results in no expection

wet breach
#

ok back to being dumb

fast path
#

sqrt(-1) is i

quaint mantle
#

javascript is such a horrible language

tender shard
#

I agree

young knoll
#

Wait

tender shard
#

NO

fast path
#

I don’t think so.

young knoll
#

So divide by zero exception or whatever

tender shard
young knoll
#

Is only for integers

fast path
#

Every language has its feature.

tender shard
young knoll
#

Well yeah

tender shard
#

it's only doubles and floats that can produce an NaN

fast path
ivory sleet
# wet breach Well, you can make tests, but the reason I don't is because generally it is me m...

well by any means I don't mean arbitrary tests, rather you just test that something is not false (double negation, but thats the only way to put it), of course qa people have the advantage if easily finding bugs between different layers, but a lot of bugs can simply be reduced to atoms by merely testing correctly. tho I do agree many people fail to write good tests (thus the guessing of tests)

but I mean should we avoid a tool because its hard to use?

young knoll
#

It just like Double.parseDouble can throw NPE, but parseInt can’t

tender shard
#

it throws NPE? when?

#

when you pass null?

#

or when

young knoll
#

Yep

tender shard
#

what does Integer throw instead?

young knoll
#

But parseInt just a throws NumberFormatException for null

tender shard
#

lol weird

wet breach
# ivory sleet well by any means I don't mean arbitrary tests, rather you just test that someth...

I am not saying to avoid it, just it isn't intuitive in terms of testing your own code if you are also creating the tests. Sure you can create some tests to just easily test certain things you know that shouldn't change, but like it is super hard to have broad coverage though if you are both the creator and the tester. But I wouldn't ignore it though because you can use it for certain functions that don't intend to change for example.

#

also it takes time to create the tests, I am of one that much rather utilize that time making more code or doing more things in the project then setting up tests

ivory sleet
#

I mean to begin with the name unit test is an immense mismatch since we're actually just testing procedures, and then of course knowing exactly how to test the procedure might not be trivial at all. That's for instance why we make everything loosely coupled and plausible mock dependencies to isolate the mere unit along with the procedure. And yes what you said applies to thread safety and atomicity pretty much, how do we test it? What is it that we want to test? But for the most part you will learn what to test and how to write them if you write a lot of tests. Sure the tool is hard to use but it is pretty advantageous, lets say something changed, instead of letting qa people test the entire system once again you could simply press a button to test if the change broke anything else.

And no tests do not take much longer time to write once you get used to it, for instance it has generally been proven more effective to enforce employees to test driven development than to just let them write whatever code they feel like writing.

sterile token
#

??

tender shard
#

why can i do 0f for a float, and 0d for a double, and 0l for a long, but not 0b for a byte

ivory sleet
#

binary iirc

wet breach
wet breach
#

in the beginning probably not an advantage to have tests

ivory sleet
#

im not totally pro tests either

tender shard
ivory sleet
#

but I believe its a substantial tool developers should learn (at least)

#

then whether you go full out testing is up to you shrug

tender shard
#

but did you know you can add underscores to numbers?

public static final int ONE_MILLION = 1_000_000;
public static final int ONE_BILLION = 1_000 * ONE_MILLION;
ivory sleet
wet breach
#

But if you get a nice established project going, where you are not making wild drastic changes

#

I can see it being a handy tool

young knoll
#

Isn’t 0b a bool

#

Or am I insane

wet breach
#

but, despite me acknowledging this, I probably still won't write tests 😂

tender shard
young knoll
#

Rip

tender shard
#

wait

tender shard
#

the error is weird

ivory sleet
#

I rarely test stuff

young knoll
#

Sad you can’t use , in numbers

ivory sleet
#

altho I got very committed to tdd for a time

tender shard
#

"Binary numbers must contain at least one binary digit"

#

what is that supposed to mean

ivory sleet
#

0b0

#

:d

#

0b1

young knoll
#

Wait

tender shard
#

0b0 is an int

ivory sleet
#

yup

young knoll
#

So the “0b” is the constant

tender shard
#

seems like it

#

very weird lol

young knoll
#

That’s weird

#

Why not like, 2b

#

Cuz base 2

ivory sleet
#

ye

tender shard
#

everything weird in java is just md's fault

fossil lily
#

Is something wrong here?

tender shard
#

did you log out and back in again after adding that var?

fossil lily
#

I just changed it

#

But I can try that

tender shard
#

reboot or log out and back in again

fossil lily
#

I did just add a maven var

#

k brb

tender shard
#

not sure if relogging is enough

fossil lily
#

i have to update anyways

vocal cloud
wet breach
ivory sleet
young knoll
#

You did the thing

ivory sleet
vocal cloud
#

What is guice

ivory sleet
#

thought u were using guice dependency injection framework

#

cuz it looks more or less identical

young knoll
#

I assume it’s custom

#

Does guice have @InjectPlugin

ivory sleet
#

hmm u can use custom annots if wanted

vocal cloud
#

Everything my lib does requires no external dep

young knoll
#

Ah

fossil lily
ivory sleet
#

if u go to cmd

young knoll
#

Fricken google always puttin U in things

vocal cloud
#

Only catch is this only works on listeners and commandexecutors that I register.

ivory sleet
#

and run echo %JAVA_HOME%

#

iirc

#

what does it say

fossil lily
#

Looks good to me

ivory sleet
#

hm

#

ye

#

im baffingly confused also

fossil lily
#

ay I fixed it

#

maven doesnt want /bin

wet breach
#

yeah Maven doesn't want bin

tender shard
wet breach
#

command prompt wants bin

tender shard
#

command prompt sucks ass anyway

#

git bash

wet breach
#

its the best 🙂

#

making them 100 lines of bat files to do something that takes like 3-4 lines in bash

#

always fun

tender shard
#

yeah lol

young knoll
#

Bin me UwU

lavish hemlock
wet breach
#

I am sure that can be arranged

lavish hemlock
wet breach
#

hence you know its home

#

It should be common sense but I suppose these days confusing lmao

#

what would be nice is if maven stopped using JAVA_HOME

lavish hemlock
#

Well there are some files that aren't available just from bin

#

I don't know which ones Maven would use though

wet breach
#

maven uses them all

#

it needs to be able to see the libs directory

lavish hemlock
#

Makes sense

fossil lily
#

Where can I download the spigot javadocs?

#

This isnt working for me:
javadoc -d javadoc -sourcepath ./java -encoding UTF-8 -subpackages org.bukkit:org.spigotmc

fossil lily
#

thanks :DDD

#

Whats this?

vocal cloud
#

Lmfao that's the java discord API

fossil lily
lavish hemlock
#

Source code jar

vocal cloud
#

The sources?

fossil lily
#

Why is that helpful?

vocal cloud
#

You can view the source code

fossil lily
#

Oki

vocal cloud
#

Comments and all

lavish hemlock
#

Also includes the javadoc comments

#

ofc

vocal cloud
#

The most important part

lavish hemlock
#

Indeed

fluid cypress
#

is there an earlier phase to generate-sources for the exec-maven-plugin?

tender shard
#

the first phase is validate

fluid cypress
#

what does that do?

fluid cypress
#

what if i want to modify the source code

#

can i do that in that phase?

tender shard
tender shard
fluid cypress
#

my eyes

#

ok ill use that thanks

fluid cypress
tender shard
#

hm lol

fluid cypress
#

but maybe a script to add commands to plugin.yml

#

i always forget that

tender shard
#

you can also register commands at runtime

#

the plugin.yml isn't really needed

#

for commands

fluid cypress
#

how

tender shard
#

1 sec

#

it's from my lib, you could just copy/paste that method

fluid cypress
#

ok, seems useful, thanks

tender shard
#

however most of the time I just use ACF for commands

fluid cypress
#

one thing about the pom file, how do i add a second script? and how will it know which one to execute on each phase?

<build>
        <plugins>
            <!-- exec scripts before and after the build -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>bash</executable>
                    <workingDirectory>${basedir}</workingDirectory>
                    <arguments>
                        <argument>./scripts/pre.sh</argument>
                    </arguments>
                </configuration>
            </plugin>
        </plugins>
    </build>

i want to run pre.sh on the validate phase, and post.sh on the package phase

vocal cloud
#

Wait the command map is in the simplecommandmap class? Damn now I can auto register commands and avoid plugin.yml all together thonk

tender shard
fluid cypress
#

why is executions a list and configurations isnt? is it supposed to run the same thing more than once?

low temple
#

is there a better way to do discord JDA integrations with a spigot server rather than just running the discord bot directly on the server as a plugin? Like maybe something with sockets?

lavish hemlock
fluid cypress
#

everything runs after the phase, right?

tender shard
#

they run during that phase

#

if you have more than one plugin for the same phase, they will be run in the order as defined in your pom

fluid cypress
#

so, how can i be sure that the new jar is already compiled

#

on the package phase

tender shard
#

package comes after compile

#

in package, everything already is compiled

fluid cypress
#

i thought that the package phase puts all .class files inside a .jar or something like that

tender shard
#

validate -> compile -> test -> package -> deploy
that's the most important phases in their default order

tender shard
#

compile turns .java into .class

#

and package puts all .class files into a .jar

#

basically

fluid cypress
#

so, what if i copy the jar or something in the package phase

#

but the jar isnt ready yet

#

or something

tender shard
#

you want to declare your maven-jar-plugin at the top to make it create the .jar first

#

or at the bottom if for some weird reason you want it to run last

#

you gotta understand the differences between phases and goals if you really wanna do such specific stuff

fluid cypress
#

is this the default config?

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
tender shard
#

well no, the default would be to not specify it at all, then it'd try to use java 5 as source and target and probably would use a 10 year old version of maven-compiler-plugin lol

tender shard
fluid cypress
#

ok, i tried to find the link to the repository of exec-maven-plugin and maven-compiler-plugin but i cant find it, any help?

tender shard
#

it's in maven central, it's incuded "by default"

fluid cypress
#

yea but i want to check the latest version and add it to the pom file

tender shard
#

oh

#

google "maven central maven-compiler-plugin"

#

3.10.1 is latest for compiler

fluid cypress