#help-development

1 messages Β· Page 327 of 1

gleaming grove
#

Right?

regal scaffold
#

Yes but it's a path down classes

#
public interface CmdImplement {

    Plugin plugin = JavaPlugin.getPlugin(Plugin.class);
    ChatManager chatManager = plugin.getChatManager();
    default void register(Object object) {
        plugin.getCommandFramework().registerCommands(object);
    }

    static void registerCommands() {
        new AdminCommands();
        new PlayerCommands();
    }
}
#

I could pass it straight down i guess

#

Not sure if it's the best practice tho

hazy parrot
#

i wouldn't call that good practice for interface lmao

humble tulip
#

Wat tf

regal scaffold
#

It

#

It's a framework

compact haven
#

you are still converting it. instead of storing it in the database as a long equivalent, you are storing it as an int equivalent. regardless of which you use in the database, you would still need to convert it to either long or Instant, regardless of which of the two you want to use in code. I've included how to get long because that's what you wanted, although am not a fan of it

gleaming grove
humble tulip
#

That's not good practice tho

regal scaffold
#

A framework is not good practice?

#

Or passing the class down

#

lol

humble tulip
#

Why does the omterface have amything to do woth the implementations

hazy parrot
#

that kind of interface you made is not interface

humble tulip
#

Interface*

regal scaffold
#

It automatically registers every command in any file I give it

#

Without having to add it to plugin.yml

#

Including permissions, cooldown, etc

humble tulip
#

Use abstract classes

#

Have a command manager to register and handle commands

regal scaffold
#

Alright but that wasn't the question at hand

#

But I understand

#

public class MyClass {

    {
        register(this);
    }

    public PlayerCommands(CooldownManager cooldownManager) {
        register(this);
        this.cooldownManager = cooldownManager;
    }
}
#

Is that gonna call twice?

#

So no bueno?

hazy parrot
#

why are you using init block ?

regal scaffold
#

Because that's how the framework works?...

#

Alright guess that means remove the init and keep the construcvtor

#

Thanks

gleaming grove
#

What do you mean by "framework"?

hazy parrot
regal scaffold
#
@Command(
            name = "spawn",
            permission = "br.player",
            senderType = Command.SenderType.PLAYER
    )
    public void spawnCommand(CommandArguments arguments) {}
#

No plugin.yml needed

#

1 line to register the file and all commands get registered

gleaming grove
#

Like if you ask about good code practice use constructor or method instead init block because later your code will be easier to deal with in unit tests

regal scaffold
#

Alright I appreciate that advise. Much better than what I got before\

#

I will start doing that from now on

gleaming grove
#

The whole point of avoiding static stuff is mostly motivated making code that is easy to mock in unit tests

meager wharf
#

does anyone know why this happens

[17:50:55 ERROR]: Could not pass event ProjectileHitEvent to Plugin v1.0.0
java.lang.ExceptionInInitializerError: null
        at me.fury.plugin.MushroomBowEvents.onProjectileHit
gleaming grove
#

I hope soon or later every project will use them

wet breach
#

I don't use them for plugins

#

quite pointless

hazy parrot
#

imagine writing tests, just see how program behaves in production

wet breach
#

also depending on what you are doing, it is more of a hassle to set it up then it would be to toss in a server

wet breach
#

the point of avoiding static is so you are not holding objects in heap that don't need to be there. Static objects, methods, classes do not get GC'ed and will exist through the entire time using up resources whether its being used or not

#

also, statics always point to the same instance

#

so if the instance were needed to change, that isn't going to happen

#

Not saying you should never use them, but you shouldn't be using them everywhere either lol

kind hatch
#

I might have misinterpreted something that was said previously and responded with that. What I meant by that was I already have existing interface methods that use long as a parameter. I don't want to have to change them to both input and return ints. Most of the time methods in java use longs.
I feel like I'm not getting my point across and might just have to make an example to explain what I mean.

gleaming grove
kind hatch
wet breach
#

saves on storage

#

4bytes doesn't seem like a lot

regal scaffold
#

If I make a custom event variation @Eventhandler will still have to be the event I'm extending my custom event right?

wet breach
#

but times that by like a million

#

and its a considerable difference lol

#

up to you, if you have the storage space for it then I guess it doesn't matter

compact haven
#

the code I gave you already gives you the column as a long

kind hatch
compact haven
#

2nd code block, last line..

#

and idk what u mean by proper datatype, if you mean long then it's not

#

mysql can't give you the unix milliseconds, so saving it as a long is meaningless

#

the proper data type is either DATETIME, TIMESTAMP, or INT

#

BIGINT if you want millisecond precision, but then the client needs to provide that

kind hatch
#

Right, but what if I don't care about MySQL giving me that info? What if I just want to store it as is?

compact haven
#

then do whatever you want

regal scaffold
#

If I make a custom event variation @Eventhandler will still have to be the event I'm extending my custom event right?

compact haven
#

because I'm frankly done with debating how to store a time

#

just know I'm not updating that sql or the examples anymore to reflect that specific change

regal scaffold
#

Like if I make a PlayerDamageByPlayerEvent I need to call my event from inside the EntityDamageToEntityEvent right?

hazy parrot
#

lmao

regal scaffold
#

Nice, thanks for the help

compact haven
#

@regal scaffold no

#

if PlayerDamageByPlayerEvent extends EntityDamageToEntityEvent

#

then you do not need to call PlayerDamageByPlayerEvent from an EntityDamageToEntityEvent, because @EventHandler will work on subclasses

regal scaffold
#

Really πŸ‘€

#

That's sick

compact haven
#

uh well actually

#

technically sorry

#

you need to dispatch it

regal scaffold
#

Ok so what I said lol

compact haven
#

but you can listen to EntityDamageToEntityEvent and PlayerDamageByPlayerEvent will trigger that

regal scaffold
#

Rip

compact haven
#

lmfao

regal scaffold
#

yeah yeah lol was in the middle of doing that tohught I was saved

#

That means all the checks should be done before calling MyCustoMEvent

#

I was so happy

#

When is that getting added :/

compact haven
#

never

#

how else would it know how to construct your custom event

#

that makes no sense

regal scaffold
#

If you extend a event class

#

Wait you're right

compact haven
#

yes I know

regal scaffold
#

Didn't even think it rhough lol

compact haven
regal scaffold
#

Are custom events even that powerufl then?

compact haven
#

of course they are, but they arent meant for your own code

remote swallow
#

my fucking god nbtapi

compact haven
#

custom events are meant for APIs

regal scaffold
#

ohhhh I see

compact haven
#

for example in a permission plugin PermissionAddedEvent might exist

regal scaffold
#

Oh I see that makes sense

compact haven
#

no internal code would listen for that event, but it would dispatch it for other plugins to use

regal scaffold
#

So then the permission plugin makes a listener

#

for that event

#

That's sick

compact haven
#

no

#

"no internal code would listen for that event"

regal scaffold
#

ok im idiot

compact haven
#

idk why I hear that so much

#

maybe its because I'm talking to Epic a lot

regal scaffold
#

wait yeah that's what I meant

#

if my api has CustomEvent

#

My actual plugin can listen to customevent

#

and then other plugins can use that event

remote swallow
compact haven
#

this is true

#

ehm @regal scaffold I dont understand

#

but u do u

remote swallow
#

how dafuq is it running ItemFactory.Builder().write

#

i dont get it

regal scaffold
#

Fair enough

remote swallow
#

im holding air

compact haven
#

are u sure it's calling .write

#

and u arent talking about the line that uses getConfig().set

remote swallow
#

that doesnt touch nbtapi

#

but nbtapi dies about it

compact haven
#

uhm

#

add sout

remote swallow
#

will do

meager wharf
#

guys how to fix this

Caused by: java.lang.ClassNotFoundException: com.github.shynixn.structureblocklib.bukkit.Main
quaint mantle
remote swallow
#

its the dropping thats causing an npe

eternal oxide
remote swallow
#

its all from the itembuilder dying

#

tf

#

im so confused rn

#

sout time

quaint mantle
eternal oxide
#

yes

#

you have to check teh slot/warSlot

#

if slot != rawSlot its not the top

regal scaffold
#

Ummm so, I followed this guide to making a custom event https://www.spigotmc.org/threads/why-arent-there-playerdamagebyplayerevent-bowshootevent-etc.532429/

But I'm wondering what the guy that posted means when he said "now you can handle the PlayerDamageByPlayerEvent". What would be different than just using the default event

remote swallow
#

i love when ij dies if i crtl+Z something that has Material. anything in it

eternal oxide
#

or vice versa, I forget

ruby mesa
#

kotlin code moment

eternal oxide
#

no

#

a view is not an Inventory

ruby mesa
#

ohhh wait I just realized that xD

eternal oxide
#

The drag event can return multiple slots. You compare the slot to raw slot, if they are the same it's the top inventory, if different it's bottom. Or the other way around, he needs to test

rigid loom
remote swallow
#

how the fuck is the Material AIR

regal scaffold
#

epic can you try to explain what I asked plz πŸ™‚

remote swallow
#

whats ur issue

remote swallow
wet breach
#

there is a file that IJ uses for settings

compact haven
#

The difference is you can directly call event.getPlayer() @regal scaffold

wet breach
#

also use some JVM arguments with it too

compact haven
#

the difference is that u have an object of your custom event instead

#

that’s it

regal scaffold
#

Oh so that makes me believe that in my use case it’s not needed

rigid loom
#

it also doesnt save the permissions of the player to be able to disband the kingdom anytime i reload the server

wet breach
#

if nothing implements it to fire it, then nothing can listen for the event

#

now you could have the event purely in api for the sake other plugins are supposed to implement it instead

#

and your plugin listens for it

#

which is a bit backwards but still works lol

regal scaffold
#

Well I don't think I personally have a use in my situation. Cause all I really need is to check when a player hits another player and interact with both player objects

rigid loom
#

Kingdom create command will say "<kingdom> was disbanded" even though its not supposed to

frank kettle
#

@wet breach finally found a way to do it πŸ˜‚ holy shit

#

this game me a huge headache

#

like several "crashes"(not crashes but huge lag) cause threads were lagging sever so much

#

99x99 chunks in just 1 minute πŸ—Ώ 🍷 without lagging server at all

#

async is fun

wet breach
#

make your own threads πŸ˜‰

#

jk, nice job though

frank kettle
#

ty for the help

regal scaffold
#

Is there any way to interact with mob drops on death
Only evet I see is EntityDeathEvent

regal scaffold
#

Well if that's a side effect so be it but I wanna get the drops and how many it dropped. the itemstacks

humble tulip
#

there's a getDrops methods

regal scaffold
#

Can't get drops from that

#

Doesn't apply for that

humble tulip
#

wdym?

#

you can get drops

regal scaffold
#

I tried the same method for BlockBreak and it wouldn't give the amount

#

I'll try for mobs

humble tulip
regal scaffold
#

Yes but the itemstacks don't contain the amount

#

Let me actually try this time

#

brb

humble tulip
#

event.getDrops() is a list

#

you can iterate the list and use drops.get(i).getAmount

#

also there's this event to set what a block drops

regal scaffold
#

Because getdrops doesn't get the amount

#

But I'll try and show you

humble tulip
regal scaffold
#

Yessir

subtle temple
#

hey everyone, im trying to detect block collision with an item that has a set velocity. anyone have any idea how to solve this?

regal scaffold
#

That's why I thought same would happen for mobdeath

humble tulip
#

the drops aren't determined until after blockbreakevent is called and it's not cancelled by any plugin

#

nah

regal scaffold
#

Ahhhh gotcha

#

Alright thanks then gonna use that!

humble tulip
#

see if u hit any blocks

regal scaffold
#

How would you know if there are any checks you need to do to the entity so no errors come?

regal scaffold
#

But how would you know

#

So I can learn and use in other situations

humble tulip
#

because you're just modifying drops right?

regal scaffold
#

Yes

#

I guess check if drops exist

#

And if it's a mob

humble tulip
#

it's not null

#

so it's safe

regal scaffold
#

Gotcha

#

Thanks ❀️

humble tulip
#

if there are no drops, it'll be empty but not null

regal scaffold
#

(event.getDrops().isEmpty()) return;

#

Already added

#

Appreciate it a lot

humble tulip
#

np

regal scaffold
#

Man copilot is so nice

#

Once you start you can never go back

#

Now 1 more question @humble tulip

#

What if

humble tulip
#

what if?

regal scaffold
#

a mob drops 2 different items

humble tulip
#

it's a list

regal scaffold
#

Can I cancel the drop for 1 of them

humble tulip
#

remove it from the list

regal scaffold
#

Lets say, autocollect

#

Oh

#

Just like that huh

humble tulip
#

yes

regal scaffold
#

So sick

humble tulip
#

you can clear drops by clearing the list

regal scaffold
#

Does priority matter for clearing stuff?

#

Or is it that fast it doesn't matter

humble tulip
#

what do you mean?

regal scaffold
#

Will the drops drop before I clear it

#

Or does the entire event finish first

humble tulip
#

here's how bukkit events work

#

well most of them (cancellable ones)

#

some thing is about to happen -> event get's called -> all listeners process them. (LOWEST process first, MONITOR is processed last) -> if not cancelled, server processes what happened

#

so all listeners get's called before the server processes anything

regal scaffold
#

Oooooo

#

Ok that's one of the best explanations I've gotten

#

Thank you a lot

humble tulip
#

np

regal scaffold
#

Now there is a issue

#
[22:03:50 ERROR]: Could not pass event EntityDeathEvent to DeepStorage v1.0-SNAPSHOT
java.util.ConcurrentModificationException: null
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1013) ~[?:?]
at java.util.ArrayList$Itr.next(ArrayList.java:967) ~[?:?]
at me.tomisanhues2.deepstorage.events1.ChestEvents.onMobDeath(ChestEvents.java:160) ~[deepstorage-1.0-SNAPSHOT.jar:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor1677.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:git-Paper-381]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:672) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at com.bgsoftware.wildstacker.utils.entity.logic.DeathSimulation.lambda$null$3(DeathSimulation.java:148) ~[WildStacker-2022.6-b414.jar:?]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.3.jar:git-Paper-381]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1473) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:440) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1397) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-381]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
#

Something is null

humble tulip
#

you're removing in the for loop aren't you?

regal scaffold
#

But I thought I didn't have to check

#

lol

#

You're a genius

#

Why is that

humble tulip
#

store the stuff to remove in a set or something and remove it after

eternal oxide
#

use an iterator to remove

regal scaffold
#

Is it cause threads?

humble tulip
regal scaffold
#

Ummm

humble tulip
#

you can use iterator.remove();

regal scaffold
#

Alright gotta read on it

humble tulip
#

nah not threads

regal scaffold
#

How would I use a iterator for that

humble tulip
#

pretend you're reading a word doc and someone is typing/deleting stuff, it can get confusing

regal scaffold
#

I'm reading on what they are

humble tulip
#

Iterator<ItemStack> itreator = event.getDrops.iterator();

eternal oxide
humble tulip
#
while (iterator.hasNext()) {
  ItemStack item = iterator.next();
  if (item.whatever) {
    iterator.remove();
  }
}
#

like this @regal scaffold

regal scaffold
meager wharf
#

you could also iterate backwards

regal scaffold
#

Easy enough

#

Thanks a lot!

#

Ummm

#

Isn't it bad practice

#

To do ItemStack item inside a loop

humble tulip
#

to do what?

#

why?

regal scaffold
#

Declare outside

humble tulip
#

no

regal scaffold
#

And initalize inside

#

really no?

humble tulip
#

nope

#

where'd you read that?

regal scaffold
#

I actually don't remember but a while ago

#

Is it not better

#

or is it the same

#

or worse

humble tulip
#

you shouldn't be declaring stuff out of scope

regal scaffold
#

Cause it could end up null?

humble tulip
#

well sometimes you should

#

but not really

humble tulip
regal scaffold
#

I mean if you declare outside scope just add a null check after no?

#

Oh nvm "one reason" lol

humble tulip
#

if you wanted to find a specific item from the loop and do something after, you can totally decalre item outside the loop

regal scaffold
#

Gotcha

#

Wait last question

#

iterator.remove

humble tulip
#

you can also follow that logic and declare item outside the method

regal scaffold
#

Does it automatically know which obnject im currently on

#

Cause of iterator.next()

humble tulip
regal scaffold
#

Damn iterators are sick

wet breach
regal scaffold
#

Minion

humble tulip
#

yes?

regal scaffold
#

With your help I've finally added mobfarm autocollect, mine autocollect to my infinite storage plugin

humble tulip
#

nice

regal scaffold
#

And auto furnace smelt collect too, forgot

remote swallow
#

god that lore colour hurts my eyes

humble tulip
#

infinite πŸ‘€ max amount

regal scaffold
#

lol

#

2.1bil is pretty much infinite

remote swallow
#

int limit probably

#

or bigint limit

regal scaffold
#

No one ever gonna grind 2.1m of items

#

Especially when it's made to autosell too

remote swallow
#

wait until you find out about paper and their per player mob caps

#

and that i have 3 accounts

#

and as much time as i want

regal scaffold
#

Oh

#

Papar has no cap?

remote swallow
#

paper has per player mob cap

regal scaffold
#

I see I see

remote swallow
#

i could make 3 insane mob farms

regal scaffold
#

Now you can autocollect them with my plugin πŸ™‚ xd

remote swallow
#

ez items

humble tulip
regal scaffold
#

No shot

#

collect 1231321 items lol

#

Bad idea

humble tulip
#

all possible

#

not all all

remote swallow
#

just a bit of lag for 5 minutes

regal scaffold
#

Fair, all ivnentory slots

remote swallow
#

shulkers

#

shulkers of shulkers

#

shulkers of shulkers of shulkers of chests

regal scaffold
#

All that lets for my plugin is to finish adding the gui features and fully done

humble tulip
#

i hate gui

#

i LOVE writing backend stuff

subtle temple
# humble tulip Just get the position, and raytrace using the velocity as direction, the magnitu...

This is what I have, but stuff like this is still happening

// projectile collided with block
RayTraceResult pathRayTrace = item.getWorld().rayTraceBlocks(item.getLocation(), item.getVelocity(), getVectorMagnitude(item.getVelocity()));
if (pathRayTrace != null) {
    Bukkit.getLogger().info("projectile collided with block");
    item.remove();
    return;
}

public static Double getVectorMagnitude(Vector vector) {
    return Math.sqrt(Math.pow(vector.getX(), 2) + Math.pow(vector.getY(), 2) + Math.pow(vector.getZ(), 2));
}
#

was kinda hoping that would upload correctly... lol one sec

humble tulip
subtle temple
#

true

regal scaffold
#

@humble tulip Is the iterator usage the same for blockdropitemevent

#

event.getItems() returns an item instead of a otemstack

#
        Iterator<Item> iterator = event.getItems().iterator();
        while (iterator.hasNext()) {
            ItemStack item = iterator.next().getItemStack();
``` that would be same thing tho?
remote swallow
#

might need casting but probably

wet breach
#

you could do this instead

#
for(ItemStack items : event.getItems()) {
    //do stuff with the items
    items
}
regal scaffold
#

I do need an iterator cause 1 lower

#

I remove it from a getDrops list

#

Working perfectly now

#

Now the knowledge question. How would I know that I need a iterator there

wet breach
#

well be careful with the while loops

#

they will block the main thread

#

if it takes too long for it to complete

#

or worse case you set a condition that will never return XD

wet breach
#

a traditional loop is good for indices

#

you could replace what I have

#

and put an interator in there too

regal scaffold
#

oh really

#

But I can't use iterator methods like remove\

wet breach
#

for (Iterator<ItemStack> it = list.iterator(); it.hasNext();) {
    ItemStack items = it.next();
}
regal scaffold
#

-Ah gotcha

#

Any difference with the other one tho?

wet breach
#

if the iterator supports it, you can remove items as you loop

#

so that would be one reason you need an iterator

#

the difference between the for loop above I gave and the one I just gave just now is readability as well as preventing certain bugs

#

now a traditional for loop is like so

#
for (int i = 0; i <10; i++;) {
    //do something like access array indexes using i
}
#

but this for loop you won't be able to remove as you loop

regal scaffold
#

Gotcha gotcha

#

Appreciate the explanation

regal scaffold
#

Any thoughts on this

#

So that everytime you build a jar you can run a command on server and not have to drag and drop

humble tulip
#

sure

#

if it makes your workflow easier

wet breach
#

you could use deploy for remote uploads etc

regal scaffold
#

Wait

#

Really

#

wtf

#

Gonna look into that rn

compact haven
#

can also directly have a goal to run a test server

#

am using that for my current project, lets me run directly from a run configuration & attach a debugger

#

super neat

regal scaffold
#

I assume that's what allows me to maven remotely

compact haven
#

no

#

that'll be locally

#

not remotely, sadly

regal scaffold
#

Ah

wet breach
#

maven deploy plugin, but you also need to configure your server you are uploading to as well

regal scaffold
#

I imagined

#

Configure it how

wet breach
#

you could use maven deploy plugin, to use ssh to upload file

#

and put it where you want it

regal scaffold
#

wtf is maven deploy plugin

#

It's not from spigot right

#

It's from actually maven

compact haven
#

obviously lol

#

anything prefixed with maven- has been made by the Apache maven team

#

or at least, it was meant to

regal scaffold
#

Not really obvious could be a spigot plugin implementation for it

humble tulip
#

@regal scaffold you should look into the debugger btw

#

Really powerful tool

regal scaffold
#

I was just using intellij remote

#

Is that thing better?

wet breach
#

you can use what ever it is your comfortable with using

humble tulip
#

Do you set breakpoints?

regal scaffold
#

Yeah

humble tulip
#

Ok yeah that's ot

wet breach
#

don't worry about it being better, worry about if it works for you πŸ™‚

remote swallow
#

for non config testing stuff i just use winscp, keep remove directories upto date and my server on alex's ptero

#

and then just a button in game

#

it works as expected

#

does what i need

humble tulip
#

For testing stuff, whatever works works

regal scaffold
#

So

#

For this maven deploy

#

I assume I want project deployment?

#

Or do I straight up just use file deployment

humble tulip
#

Never use that

#

Used*

#

So can't say

regal scaffold
#

I'll wait for frost

#

Don't really understand what half of the words mean in this page and it's english...

#

Yeah full lost on this

#

How tf could I possibly get a built jar into my servers plugin folder lmao

humble tulip
#

Oh that's easy

regal scaffold
#

?

#

You can't leave me hanging like that brotha

humble tulip
#

One sec

regal scaffold
#

Clarification:

#

Remote

#

Either using sftp or something

#

Actually I just thought about something, could make a python plugin that does that

#

Always running, check folder for changes, use sftp to upload

humble tulip
#

nah

#

write a script

#

i think winscp generates them

regal scaffold
#

wym

humble tulip
#

and add a runafter in intellij

regal scaffold
#

Gonna need a bit more than that

#

Write a script where

humble tulip
#

here

#

generate session url/code

regal scaffold
#

Alright

#

Now what lol

humble tulip
regal scaffold
#

I see there's a script tab there

#

Yes

#

Ok so the script should

#

If Im gonna run it from intelliJ

#

maven package spefically

humble tulip
#

right so

#

create a maven package configuration

#

here

#

edit configurations

regal scaffold
humble tulip
#

select amven when you click the +

#

the command will be package

regal scaffold
#

Sorry wait

#

Ok yeah continue

humble tulip
#

then shell script

regal scaffold
#

wait wait

humble tulip
#

?

regal scaffold
#

working directory ntohing matters right

humble tulip
#

nah

regal scaffold
#

All that is in the script

humble tulip
#

huh

regal scaffold
#

Ok great

humble tulip
#

did you select script?

regal scaffold
#

yEP

humble tulip
#

add a before launch to the bottom

#

and run the maven package configuration before launch

regal scaffold
#

I only get maven goal

#

And I see it's not the same

humble tulip
remote swallow
#

or run maven goal

regal scaffold
#

Ok yes

remote swallow
#

both would work technically

humble tulip
#

ya both work

regal scaffold
#

Oh didn't know there were kinda the same

humble tulip
#

well the configuration runs a maven goal lol

regal scaffold
#

Ah that makes sense

humble tulip
#

do you have the script setup?

regal scaffold
#

I selected the maven yes

humble tulip
#

no i mean the script in a file

regal scaffold
#

Do I just copy paste from the generated?

compact haven
#

When is #hasItemMeta() going to be false, and #getItemMeta() going to be null?

humble tulip
#

air maybe

humble tulip
regal scaffold
humble tulip
#

so select script

regal scaffold
#

Yeah I see it says add here

humble tulip
#

ur gonna cd to ur directory

regal scaffold
#

Alright I got it pasted in a vsc

#

In the command section?

#

Ok we good

#

I cd'd

humble tulip
#
& "C:\Users\Saif Mohammed\AppData\Local\Programs\WinSCP\WinSCP.com" `
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul `
  /command `
    "open sftp://login here`"`"" `
    "cd /home/server/plugins" `
    "put target/Plugin.jar" `
    "exit"

$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
{
  Write-Host "Success"
}
else
{
  Write-Host "Error"
}

exit $winscpResult
#

like that

#

wait

regal scaffold
#

wait wait

humble tulip
#

you may need the absolute path

regal scaffold
#

why am I cding to my own plugin

humble tulip
#

ur not

#

ur cding to the folder on the server

regal scaffold
#

Oh so the path is all remote

#

Ok ok

humble tulip
#

put (Your buidl folder)

compact haven
#

will getItemMeta() also clone the PersistentDataContainer? as in, do I need to call setItemMeta after modifying the PDC?

humble tulip
#

you may need an absolute path for put

regal scaffold
#

Gotcha

humble tulip
#

it returns a deep clone iirc

regal scaffold
#

wait

humble tulip
#

?

regal scaffold
#

My build folder as in remote again?

humble tulip
#

no

regal scaffold
#

Ok local

humble tulip
#

build folder will be local

regal scaffold
#

Does it have to be alone in the folder?

humble tulip
#

in which folder?

regal scaffold
#

Like lets say I maven to my local server plugins folder

#

Then mirror to remote

remote swallow
#

actually no

#

if getItemMeta is null, how are you gonna add meta

humble tulip
#

gonna sleep

#

gn

regal scaffold
#

"put C:\Users\Random123\Desktop\Spigotmc\plugins\BorderRealm-1.0-SNAPSHOT.jar" `

#

I think that would work

humble tulip
#

Ye

summer scroll
#

I'm trying to spawn a particle 2D square but just the outline of the square, currently I can get the full square, how can I achieve it?

public List<Block> getBlocksInRadius(int radius) {
  List<Block> blocks = new ArrayList<>();
            
  for (int x = (this.location.getBlockX() - radius); x <= (this.location.getBlockX() + radius); x++) {
    for (int z = (this.location.getBlockZ() - radius); z <= (this.location.getBlockZ() + radius); z++) {
      blocks.add(new Location(this.location.getWorld(), x, this.location.getY(), z).getBlock());
    }
  }
  
  return blocks;
}
regal scaffold
#

That's crazy cool

regal scaffold
#

❀️

humble tulip
#

Np

#

Now test it

regal scaffold
#

cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.

#

lmao

#

Gotta fix that

humble tulip
#

Lmao

regal scaffold
#

Testing

#

Holy crap

#

Error

#

But almost lool

#

I'll sort it out

#

Nice error description tho

humble tulip
#

What's the error?

regal scaffold
#

No error

#

lmao

#

Legit just

#

error

humble tulip
#

Hm so it built and then?

regal scaffold
humble tulip
#

Hm

#

Delete the put line

#

See if the script runs then

regal scaffold
#

Error

#

I love descriptive error messages

humble tulip
#

Delete the cd line

#

And see then

regal scaffold
#

Oh yeah I see i messed it up

humble tulip
#

Lol

regal scaffold
#

Imagine not knwoing powershel scripting language

#

Oh wait nvm

#

Still broke

#

I had /plugins/

humble tulip
#

Remove the entire cd

#

See of it connects and exits no error

regal scaffold
#

Error

#

What protocol this using

humble tulip
#

Weird

regal scaffold
#

Says active session tho

#

Do folders in powershell go \ too?

humble tulip
#

Not sure

regal scaffold
#

It's using sftp too

#

Should work

#

How can I debug 3 lines

#

Bro how can powershell ju8st say error, with no actual error

humble tulip
#

Use the .net assembly script instead

#

Try that instead

regal scaffold
#

Alr 1 sec

humble tulip
#

Or u can configure the intellij terminal to not use powershell

regal scaffold
#

Is WinSCPnet.dll something I need to download?

humble tulip
#

And use a sh file

#

I rarely do remote testing before

#

But when i worked for a server a while bacl that's how it was setup

regal scaffold
#

Yeah this is weird but powerful

#

Ok so sh file instead

humble tulip
#

Probably

#

πŸ˜‚πŸ˜‚

regal scaffold
#

lmao

humble tulip
#

I cant even tinker

#

I'm not at my pc

#

Gonna sleep

regal scaffold
#

Yeah you good, appreciate it a lot

#

Good night

humble tulip
#

Gluck

#

Gnight

humble tulip
haughty tendon
#

how do i post one of my plugins on spigot?

remote swallow
haughty tendon
#

thanks

haughty tendon
remote swallow
#

are you signed in

haughty tendon
#

yep

remote swallow
#

dafuq?

#

take a ss of the page and send it on

#

?img

undone axleBOT
haughty tendon
#

i just dmed u

#

ty for the help

remote swallow
#

?premium @haughty tendon

undone axleBOT
fierce whale
#

I'm trying to use CountDownLatch in BukkitRunnable but it always throws serious error
In the first place is it possible to use CountDownLatch in anonymous async BukkitRunnable?

quaint mantle
#

does anyone know which packet to use in ProtocolLib for block breaking? I want to send a player a packet of a block breaking when in reality that block isnt broken

quaint mantle
#

HUH

#

HOW DID I MISS THIS

#

WAHT

tall dragon
quaint mantle
#

what things require NMS now then?

#

:brian:

tall dragon
#

luckily, less and less things

pseudo hazel
#

like nothing afaik xD

echo basalt
#

does printf seriously not work in the bukkit console output

#

can't even do System.out.printf or something

#

either that or my check is failing which I seriously doubt

#

yeah calling println(format(...)) works

#

stupid

quaint mantle
#

I want to get all classes that includes β€œMain” in class name.
I tried reflection, and Package#getPackages().
But NullPointerException returned.. 😒

Thanks for helping! md_5

quaint mantle
#

need to run (extends) implemented subplugin registration method in static block.

quaint mantle
humble tulip
#

Ohh

#

So you're not looking for main?

#

Anyhow

#

In this class there's FindLocaleResources

#

It's a method

#

It gets all files inside a jarfile

#

You can do this, get all class files and cjeck them for a main method

#

Or main in tje class name

onyx fjord
#

is it possible to make players not collide with entities? excluding players

dire marsh
quaint mantle
#

I’ve been fixed it with annotation!
thx for all

fierce whale
#

Does anyone know how to use CountDownLatch in BukkitRunnable?

quaint mantle
#

Hey there! I have had some issues compiling whilst using 1.19.2 NMS

#

Somehow my compiler cannot access any of the NMS classes during compile-time

#

"cannot access net.minecraft.network.protocol.game.PacketPlayOutPosition"

#

per example

#

Anyone knows what's going on?

#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.19.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
chrome beacon
quaint mantle
#

Oh, right

tender shard
#

yikes, why aren't you using mojang mappings

gray merlin
#

Is there a way I can check for the protection value of an item? Say, I want to check the prot value for an iron chestplate

tender shard
#

you mean the enchantment?

gray merlin
#

nope, the armour points they give

quaint mantle
#

I haven't been up-to-date with all the stuffz going on here

#

since 1.12 release

tender shard
tender shard
#

aaand:

#

?switchmappings

quaint mantle
#

Oh, cool

past wedge
#

Hello, I'm doing a little project, and when I right click with an iron hoe I want a message in the chat. The problem is that when I right-click with the hoe on a block, the message appears twice, how can I fix this please ? Thanks in advance πŸ™‚

grave plover
#

You can check if the main hand click is executed by getting the getEquipmentSlot() equipment enum

past wedge
#

I added e.getHand()==EquipmentSlot.HAND

#

in the if statement

#

Welp, it works perfect, ty ! πŸ˜„

grave plover
#

Np

undone axleBOT
#

The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.

For example, only executing code if the main hand was used:

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
        return; // do not progress past this point  |
    }
    // provide functionality
}
charred blaze
#

does spigot have a page list of projectiles?

rotund ravine
#

se subinterfaces on the second one

#

AbstractArrow, Arrow, DragonFireball, Egg, EnderPearl, Fireball, Firework, FishHook, LargeFireball, LingeringPotion, LlamaSpit, ShulkerBullet, SizedFireball, SmallFireball, Snowball, SpectralArrow, SplashPotion, ThrowableProjectile, ThrownExpBottle, ThrownPotion, TippedArrow, Trident, WitherSkull

charred blaze
#

thx

charred blaze
#

can i equal it to null? (entity) will it work?

frank kettle
#

how can we make "bundles inventory" for other items on the inventory?

#

like, when u put mouse hover it opens a small custom inventory on top

#

πŸ€” is there any thread about this?

#

well, they are out for any version in 1.19 already

#

so i was guessing this "was discovered" already with packets

#

i believe i saw a plugin doing it

#

how does he do it then? πŸ€” it looks a bit different than bundles

#

can I maybe "force" a BundleMeta on a different itemstack not a bundle?

warm light
#

currently I am using this way to register command(JDA). is it possible to get the instance & register all commands on the instance?

#

yes

#

I am making a spigot plugin. thats why asked here :)

#

to prove that, I keep the upper code :)

frank kettle
#

it's not a spigot api question πŸ€”

warm light
#

so here is the full code. & I want to register more one command with checking of another plugin.
that chunk should work on both if DiscordSRV enable & disable. idk how to do that. so I think if there is something like a command instance, I can register it individually

or any other way to do that

warm light
frank kettle
# warm light this one :)

I'm not against you asking it, just you said "im coding a spigot plugin" doesnt mean it's a question directly about spigot api.

warm light
#

thanks

#

wdym?

flat ruin
#

Question, using an external .JAR for my plugin (a mysql helper) - but no matter how I add it to IntelliJ the build fails because it can't find the package. It's already marked as a dependency with the "build" mode selected. The exported classes from the jar work perfectly fine in the editor, but on build it doesn't work.

onyx fjord
#

what do you use maven or gradle

flat ruin
onyx fjord
#

then add the dependency there

flat ruin
#

it's not in a repo?

onyx fjord
#

wdym

flat ruin
#

it's just a jarfile I have locally

onyx fjord
#

you can use system scope

flat ruin
#

oh

#

Nope, it's something I found on forms

onyx fjord
#

well otherwise its a pain if someone else needs to build it

flat ruin
onyx fjord
#

first, do you have the src for it

#

or just the jar file

flat ruin
#

just jar but intellj can read it

onyx fjord
#

where did you find it?

flat ruin
chrome beacon
#

System path is deprecated

onyx fjord
chrome beacon
#

If you only have the jar use the maven install command

onyx fjord
#

ill ask vagdedes

flat ruin
#

no need

#

already did

onyx fjord
#

and what did he say

flat ruin
#

they said that they didn't support it anymore

#

Β―_(ツ)_/Β―

onyx fjord
#

oh

#

would be nice to have it open source then

#

someone else could continue

flat ruin
#

^

#

thats what im going to do lol

onyx fjord
#

decompiled code != original code

flat ruin
#

fernflowℒ️

onyx fjord
#

no

chrome beacon
onyx fjord
#

or rather doubt

#

because i used at least 6 different decompilers for past two months

#

and

#

its not cool to reverse engineer and publish something with no license

onyx fjord
flat ruin
#

I think that this is the most cursed code I've ever written java @EventHandler public void shootBowEvent(ProjectileLaunchEvent event) { Projectile proj = event.getEntity(); float offX = ((random.nextFloat()) - 0.5f); float offY = ((random.nextFloat()) - 0.5f); float offZ = ((random.nextFloat()) - 0.5f); proj.setVelocity(proj.getVelocity().add(new Vector(offX, offY, offZ))); }

#

found it in an old project called "CursedPlugin"

onyx fjord
#
public void shootBowEvent(ProjectileLaunchEvent event)
{
#

this is the most cursed part

flat ruin
#

mmmmmmmmmmmm but of cource

#

c# style

onyx fjord
#

yeah

#

i saw bungeecord code style one day

flat ruin
#

rip

onyx fjord
#

its something like this

#
@EventHandler
public void shootBowEvent( ProjectileLaunchEvent event )
{
        Projectile proj = event.getEntity();
        float offX = ( (random.nextFloat()) - 0.5f );
        float offY = ( (random.nextFloat()) - 0.5f );
        float offZ = ( (random.nextFloat()) - 0.5f );
        proj.setVelocity(proj.getVelocity().add( new Vector( offX, offY, offZ ) ));
}
flat ruin
#

man

hasty prawn
onyx fjord
#

{ <-- this should be on the same line

pseudo hazel
#

nah

hasty prawn
#

Oh I didn't look at the original I looked at yours

#

I agree it should be on the same line yes

onyx fjord
#

even discord FIXES it

hasty prawn
pseudo hazel
#

how is that readable if its on the same line

onyx fjord
#

normally lol?

pseudo hazel
#

do you also do that with stuff like if statements?

onyx fjord
#

if you see public you already know it starts

hasty prawn
#

Yes??

onyx fjord
#

or

#

u click ending and start gets highlighted

hasty prawn
#

IntelliJs default is to format braces on the same line too

onyx fjord
#

yeah cuz its java not C#

pseudo hazel
#

doesnt mean it makes it better

#

i mean I guess its just preference

hasty prawn
#

It's preference yes, but the convention in Java is the same line

pseudo hazel
#

I more used to like any c language i guess

hasty prawn
#

just like not naming your methods Like_This is preference but not conventional.

onyx fjord
#

their conventions are weird af

pseudo hazel
#

then my plugin breaks that convention happily

hasty prawn
pseudo hazel
#

naming your methods like that is just pure evil though

onyx fjord
#

why...

hasty prawn
#

My JS professor does that for his functions

#

It makes me sad

#

Though, he's not consistent with it. I've seen updateAll and Paint_Scene

pseudo hazel
#

there are only 2 naming conventions I can approve of, that being java and pythons styles

onyx fjord
#

how can python have any form of conventions

quaint mantle
#

snake case ig

pseudo hazel
#

the same way java does

#

but yeah python uses a lot of snake case

#

which is still better then Cursed_Case

onyx fjord
#

iPreferThis

grave plover
#

caterpillar case :)

onyx fjord
#

im suprised this shit has names

tender shard
#

this looks like a bit like my phone address book.
person x, person x old, perosn x old old, ...

echo basalt
#

my phone book is like 2-3 pizzerias

#

and a family member or two

#

I don't have my parents on my contacts

wet breach
echo basalt
#

it's by choice

#

I also blocked my mom on facebook

west scarab
tender shard
opal juniper
#

how do you structure a config when you want like a list of config sections

wet breach
#

config section is really arbitrary as well, basically you could consider anything a config section as long as it has data below it

opal juniper
#

you have to have the itemx keys though?

tender shard
#

a config section is basically just a map

tender shard
wet breach
#

but basically a config section object, has data below it that can be mapped, it doesn't have to contain anything specifically

opal juniper
#

so i guess my question is then, with the config i gave, how would you iterate through the items

tender shard
#
for(Map<String,Object> map : (List<Map<String,Object>>) getConfig().getList("items"))```
#

and then you can do map.get("type"), map.get("amount"), etc

#

alternatively you could use getMapList

wet breach
#

you could also do it the old fashion way too

#

where you would put configsection in a for loop

#

and then have another loop to get your Lists

#

if you wanted say an array of lists

west scarab
#

ty

regal scaffold
#

Hey! how can I prevent natural mob spawning but still allow spawners

tender shard
regal scaffold
tender shard
#

wdym?

regal scaffold
#

There's a creatureSpawnEvent too

tender shard
#

SpawnerSpawnEvent extends EntitySpawnEvent

regal scaffold
#

Gotcha gotcha

tender shard
#

so listen to the EntitySpawnEvent and check if its instanceof SpawnerSPawnEvent

vagrant python
#

Hi,
is there a way to make the body and the head of an NPC player look in the same direction? At the moment I turn the head 45 degrees further and then back again, but this is error-prone and costs time.

twilit roost
#

I have List of Players and I want to split it in half.
Put half into Key and the second one as Value for those Keys

This is my current attempt || results in NullPointerException ||

regal scaffold
#

if (event instanceof SpawnerSpawnEvent) return; I have a feeling this is not how to do it

tender shard
#

that's correct

regal scaffold
#

lol

#

So how do I check if a class is a instance of a subclass

tender shard
#

as I said

#

it's correct

regal scaffold
#

Oh

#

I thought you meant

tender shard
#

oh no

regal scaffold
#

It's correct as it I said it wasn;t

tender shard
#

I meant it's correct like you're doing it

regal scaffold
#

Well i think it didn't work

opal juniper
#

Is this right?

regal scaffold
#

nvm we good

frank kettle
vagrant python
#

How do I align NPC player head and body identically with NMS?

frank kettle
#

cause server gives warning about it and ever since i changed

tender shard
#

only paper prints a warning

#

and obviously it's a debug statement lol

frank kettle
#

ah ok, good to know

tender shard
#

IJ's quickfixes suck. Instead of suggesting me to set the language level to java 16, it should rather suggest to use .collect(Collectors.toList())

tender shard
#

.<

#

good one

tall dragon
#

right? haha

tender shard
#

"Yo let's cast the Player to ItemMeta, I'm sure this will work bro"

#

eclipse moment

tall dragon
#

i see nothing wrong with that

meager wharf
#

surely

tall dragon
#

suuureely

regal scaffold
#

How can I prevent mobs from dropping exp if they die by anything other than a player

#
    @EventHandler(priority = EventPriority.HIGHEST)
    public void EntityDeathEvent(EntityDeathEvent event) {
        if (!event.getEntity().getWorld().equals(Utils.ISLAND_WORLD)) return;
        if (!(event.getEntity() instanceof Player)) return;
        if ((event.getEntity().getKiller() instanceof Player)) return;
        //Remove exp drops
    }
#

Ignore just read the docs one more time

rotund ravine
#

?jd-s

undone axleBOT
rotund ravine
#

yeah haha

regal scaffold
#

yup lmaoo

#

Apologies

rough drift
rotund ravine
#

Looks kinda like kotlin haha

rough drift
#

fr

#

but that's java

rotund ravine
#

yeah

#

I know java 9 var keyword

rough drift
#

kk

#

I got so used to it I only write types in params or fields

molten hearth
#

Wait you're telling me I can just var and stop using types

rough drift
#

You can't in fields/params

#

but ye

#
public void someMethod(YouNeedA typeHere);

private final Some type;
pseudo hazel
#

I literally only use var in for loops xD

rough drift
#

though if there is an easy enough way to figure out what it is it's fine

#

For example var scoreboard = this.getServer().getScoreboardManager().getNewScoreboard();

chrome beacon
#

The only time I used var was when I got stuck in generic hell when modding

#

I couldn't figure out how to get the variable right and Intellij wouldn't help

tall dragon
#

well u can also just write '.var' after specifying it

#

and it will generate the correct one

#

very usefull

#

as it also prompts you to replace any other usages by that variable right away

tender shard
#

var sucks

#

with var you have to look on the right side what type sth is. when declaring it normally, all the types are directly below each other

tall dragon
#

this is probably one of the nicest things from intellij imo

#

im smart

chrome beacon
#

I don't type .var. I just use the suggestions menu

#

It's usually there

tall dragon
#

yea haha

tender shard
#

no

tall dragon
#

some people make class templates for commands and stuff

#

im not that lazy

quiet ice
tender shard
#

where?

tall dragon
#

sounds like ur more lazy than me πŸ˜„

tender shard
#

well I'm on the latest version of IJ ultimate and there it doesnt suggest it

pseudo hazel
#

how do you see if your plugin is causing memory issues

#

like is there some sort of profiler

quiet ice
#

Alternatively, perform heapdumps en masse

tall dragon
#

then memory dump

#

or what geol said

quiet ice
#

However it is very unlikely that either solutions would bring up any non-obvious issues

#

Most common obvious issue is infinite loop, other one is autoboxing

#

Everything else is rather hard to detect

pseudo hazel
#

and im not good enough with java to make memory leaks myself

quiet ice
#

Patience is key there

wet breach
# tall dragon run spark

not sure if spark will actually inform you of potential memory leaks. Typically need a GC profiler to see such things

quiet ice
tall dragon
quiet ice
#

You will see high amounts of allocs and whatever, but yeah not the fine details

pseudo hazel
#

i thought java was like a memory managed languages or whatever xD

tall dragon
#

it is

tender shard
#

you can still fuck it up

tall dragon
#

there is always a way haha

pseudo hazel
#

but anyways, users of my plugin are reporting high ram usage, like full server capacity

tender shard
#

you could e.g. add player objects to a list everytime they join, then never clear it

#

then you have a huge list of dead player objects

pseudo hazel
#

which I was wondering if there is a way to see what the issue could be

tender shard
#

they wont get garbage collected because you keep them in a list

regal scaffold
#

Hey ummm

tall dragon