#help-development

1 messages · Page 2145 of 1

sacred mountain
#

any ideas?

lethal coral
#

Doesn't do everything in console, only when I specifically do System.out.println() which when I look at it now makes sense I suppose.

#

This may be because spigot uses a logger instead...?

sacred mountain
halcyon mica
#

My question remains

sacred mountain
#

rip

radiant cedar
#

how can I detect if a player right clicked and or left clicked on a which block with a specific item

#

what event should i be looking to use

sacred mountain
#

PlayerInteractEvent*

#

check player's hand item and check the Action.LEFT/RIGHT_CLICK_BLOCK

halcyon mica
#

Is it possible to reload a datapack during runtime?

#

Or just select parts of it for that matter

sacred mountain
halcyon mica
#

I know

#

Because this is not regarding datapack writing

#

This is about datapack loading

chrome beacon
umbral spindle
#

How would I go about changing the max tps?

sacred mountain
#

hey olivo

#

did you find anything with my pom xml

chrome beacon
#

Yeah

sacred mountain
#

oh what was it

halcyon mica
sacred mountain
#

bc its still not working during runtime

crisp steeple
halcyon mica
#

Though I don't believe those changes would be applied to works generated with its type

umbral spindle
crisp steeple
#

it might be possible but it would be a horrible idea

sacred mountain
#

21 tps

#

lmao

crisp steeple
#

you would pretty much be speeding up your entire server

ivory sleet
#

You can have a billion tps if you rly want to

umbral spindle
ivory sleet
#

but that woulnt help the server's "health"

sacred mountain
#

best optimization tehnique

crisp steeple
#

also might break stuff in the client

#

i don’t think it’s equipped to handle more than 20 tps

sacred mountain
#

hacked clients moment

ivory sleet
#

pretty much

umbral spindle
#

I'm aware that it would result in lag if many things rae happening and some issues regarding physics, although if I just wanted to do something that requires teleporting an entity 20+ times a second then it would not be possible like this.

ivory sleet
#

afaik tho, almost nothing is hardcoded towards the 20 tps

#

server sided animations?

#

like w/ entities?

crisp steeple
umbral spindle
#

With armor stands and stuff, yes.

chrome beacon
crisp steeple
#

ex: every mob on your server would move faster, food would deplete faster, etc

umbral spindle
#

I'm aware.

sacred mountain
crisp steeple
#

if you are really intent on doing it it would probably be in nms somewhere

sacred mountain
#

how does that afect my gson error though

ivory sleet
#

could alternatively pipe the netty channel

#

and spam it with packets

chrome beacon
crisp steeple
#

that sounds like a better idea tbh

sacred mountain
#

oh

crisp steeple
#

although it might crash the client

sacred mountain
#

so do u have any ideas about that tho

chrome beacon
#

I think you need to relocate gson

sacred mountain
#

yeah idk how to do that

chrome beacon
#

Or use the one provided

sacred mountain
#

is that in maven shade plugin

chrome beacon
fading carbon
#

Not directly spigot, but does anyone have experience with using shadowJar plugin along side the maven-publish plugin within gradle?

sacred mountain
#

bever done it

chrome beacon
#

You can read the wiki

fading carbon
ivory sleet
#

sure

fading carbon
#

one sec then

fading carbon
halcyon mica
#

Ok, so reloading a datapack with modified world height does not actually update dimension types that are already used

#

(i.e. overworld)

#

So how would I update them instead

ivory sleet
fading carbon
# ivory sleet whats the issue?

So, the shadow jar does get published with everything included, however my plugin simply won't recognise that they're there in the lib package

ivory sleet
#

oh so stuff isnt relocating?

fading carbon
#

Well

#

It is

#

I can see it is, but the other gradle project just won't accept that they are yet my maven repo says it has

ivory sleet
#

so they're not relocated and shaded when other maven artifact projects try to add your maven artifact as a dependency?

fading carbon
#

Yes that is correct

lethal coral
#

What does bukkit use to log command feedback from CommandSender#sendMessage() to the console if the sender is a console?

fading carbon
lethal coral
lethal coral
hexed orbit
#

Is there any way to make the custom name of an armor stand completely invisible? Even if the player looks at the armor stand? I'm using the setCustomNameVisible method, but if the player looks, the custom name appears 😭

arctic moth
#

finished making a java code flattener anyone want it

#

turns an entire file into one line

#

no idea why i made it

#

?

#

oh is he the one that gave me the idea?

#

i remember someone told me to make one

#

its in python btw because i was lazy and it took like 10 seconds

shadow gazelle
#

I'm working on a plugin that lets players enchant up to double the level of enchantments in an anvil and everything but enchantment books seem to work with this if statement, any ideas?

#
final ItemStack input = Objects.requireNonNull(anvilInventory.getItem(0));
final ItemStack input1 = Objects.requireNonNull(anvilInventory.getItem(1));
crisp steeple
#

ah yes

#

the curse of Objects.requireNonNull

shadow gazelle
#

wait, I checked if those were null right before that 🤔

crisp steeple
#

discord status?

#

i can’t see it on mobile ;-;

shadow gazelle
#

Anyway

arctic moth
shadow gazelle
#

any ideas?

arctic moth
#

Y E S

#

imagine

#

using an obfuscator

crisp steeple
arctic moth
#

cringe

crisp steeple
#

people just put it in because intellij recommends it

shadow gazelle
crisp steeple
#

why are you using it then

crisp steeple
#

where?

shadow gazelle
#

right above those since my event relies on those not being null

#

regardless, that's not what I asked

crisp steeple
#

well for one you should use == for enum types

arctic moth
#

also works with xml

crisp steeple
#

try just printing out the type of the items

arctic moth
#

OH yes

arctic moth
shadow gazelle
#

Other items do

crisp steeple
crisp steeple
shadow gazelle
#

nope

crisp steeple
#

is the method getting triggered at all?

shadow gazelle
#

yes

#

it works with everything other than enchantment books

crisp steeple
#

i would have to assume the item is null somehow because it doesn’t make sense for the type to not get printed

arctic moth
# arctic moth

if anyone wants to know, this only takes 36 lines to make

#

and works with any coding language that allows compressed lines

shadow gazelle
ivory sleet
#

yup

shadow gazelle
#

The items aren't null and they're both ENCHANTED_BOOK

ivory sleet
#

according to java it isnt

#

not for the components at least

#

sure you could have a setter that mutates sth else

#

oh yeah

#

but thats because of the limiting target api in annotations

shadow gazelle
#

Oh wait, how do enchanted books store enchantments?

#

what

#

no?

unkempt peak
#

No

#

...

shadow gazelle
#

I asked how enchantment books store their enchantments

#

They don't store them with lore

unkempt peak
#

Enchanted book enchantments are stored in json similar to enchantments

shadow gazelle
#

no, they don't

ivory sleet
#

I mean

#

they have an nbt tag

#

Enchantments which takes a list of nbt compounds

#

{Enchantments:[{id:id,lvl:x}]} or sth

shadow gazelle
#

yeah, that's not lore

#

the name is provided by the locale

ivory sleet
#

but I mean

#

custom enchants would also go under that tag

#

its just that they're not handled when it comes to lore

#

but ye

shadow gazelle
#

yes, but I'm talking about vanilla enchantments

ivory sleet
#

mm

#

asså java har ju en @Target för annoteringar

unkempt peak
ivory sleet
#

men den tillåter inte dig att specificera så specifikt

ivory sleet
#

yup

shadow gazelle
#

So they aren't stored the same way as on items

unkempt peak
#

No it's different from regular item enchantments

shadow gazelle
#

:yay:

ivory sleet
#

zacken ye I agree to some extent

#

but its good enough

ivory sleet
#

but Ig it makes sense

unkempt peak
#

Yeah it's basically the same format for both just stored under a different name

shadow gazelle
#

But that adds more ifs to my event

#

big yay

arctic moth
#

just remade my code flattener to work with an entire project, so now i can turn the entire spigot api into one class

radiant cedar
#

how cna i set where the player is looking when i tp them to a place

#

which way

tepid ore
#

player.setYaw() & player.setPitch()

#

I guess is what you are asking

radiant cedar
#

ohh i didnt realise u can set them in location

#

for a player

#

ty

tepid ore
#

NP :>

sterile token
#

Hi im stucked trying to do this on my menu

MenuButton button = new MenuButton(itemstack, ClickType.LEFT, (player, click, slot) -> player.sendMessage("Click " + click + " on " + slot));

#

My goal is to run the black section only when the click type equals to the one from the event

#

Thanks!

tepid ore
#

Cuz I've made an Icon class and ClickAction class

#

Which allows me to do that, but it's a lot of code

sterile token
#

Snis 1 sec i send code ok?

tepid ore
#

Kk

sterile token
#
public class MenuButton {

    private final ItemStack item;
    private final ClickType click;
    private final Consumer<MenuAction> action;

    public MenuButton(ItemStack item, ClickType click, Consumer<MenuAction> action) {
        this.item = item;
        this.click = click;
        this.action = action;
    }

    public ItemStack getItem() { return this.item; }

    public ClickType getClick() { return this.click; }

    public void onClick(MenuAction event) { this.action.accept(event); }
}

public class MenuAction {

    private final Player player;
    private final ClickType click;
    private final int slot;

    public MenuAction(Player player, ClickType click, int slot) {
        this.player = player;
        this.click = click;
        this.slot = slot;
    }

    public Player getPlayer() { return this.player; }

    public ClickType getClick() { return this.click; }

    public int getSlot() { return this.slot; }
}

quaint mantle
#

why can't players be tped into locations with negative x & z coordinates

sterile token
#
@EventHandler
public void onClick(InventoryClickEvent event) {
  Player player = (Player) event.getWhoClicked();
  Menu menu = this.handler.getMenu(player.getUniqueId());
  if (menu == null) return;
  if (!event.getView().getTopInventory().equals(menu.getInventory())) return;
  MenuButton button = menu.getButton(event.getSlot());
  if (button == null) return;
  MenuAction action = new MenuAction(player, event.getClick(), event.getSlot());
  if (!action.getClick().equals(button.getClick())) return;
  button.onClick(action);
  event.setCancelled(true);
}```
sterile token
#

There you have all Snikus

#

I will open a thread

#

So its easy to help

tepid ore
#

Wait, what is your question again? What do you need help with?

ivory flume
#

How would I get a List of objects from a config

quaint mantle
#

getStringList

#

then cast it

river oracle
tepid ore
#

Errors?

river oracle
quaint mantle
ivory flume
sterile token
river oracle
#

Vs strings

ivory flume
#

I really don't know if i am working with my config correctly... it's confusing

sterile token
#

And also my issue is that it told me that (action) -> bla bla = Is not an interface

#

So im annoyed how to do it

ivory flume
tepid ore
ivory flume
#

is that possible

tepid ore
#

For?

sterile token
#

For that

#

Because im stucked

#

Lmao

#

I losted too much time and i want to understand how to fix it

tepid ore
#

It's like a few hundred rows tho. In like 3 classes

sterile token
#

And no one of my friends know how to do it

#

Dont worry

#

I dont care

tepid ore
#

So like, what part

#

No but I do lol

river oracle
tepid ore
#

No offense, but I don't wanna give away the code I spent hours making just like that

sterile token
#

Have you read my code?

tepid ore
#

Yeah

sterile token
#

So let try to use my code

tepid ore
#

I can share some, but not all

sterile token
#

Allright so let try to fix my code so we dont use yours

#

From where i can start?

tepid ore
#

You have a menubutton class

#

That is good

ivory flume
tepid ore
#

However, don't require click actions

#

I suggest adding them with a funciton

#

As you might want filler items or smth later

sterile token
#

Before adding MenuAction class, i used to have a Consumer<InventoryClickEvent> on MenuButton class

tepid ore
#

Noop

#

Don't do that

sterile token
#

Oh ok

#

So i will need to use a function?

#

So:

MenuButton button = new MenuButton(ItemStack, ClickType, Function<T>) ?

tepid ore
#

I identify the gui by using NBT tags stored in the items. And when I know what gui it is, i get the icons from that gui. Then I get the icon in the clicked slot and (if the click types are correct for that icon) use a "run" function for that icon, and send the event to get values.

sterile token
#

Something like me, but instead of NBT i use player uuid for storing them

tepid ore
#

Hmm? In like a hash map or...?

sterile token
#

Menu => Interface

PaginatedMenu => Implements menu class
InventoryMenu => Implements menu class

Map<UUID, Menu> menus

tepid ore
#

But menu isn't a class tho?

sterile token
#

Menu makes reference either a normal menu or a paginated one

tepid ore
#

I still don't understand what part you need help with if this is working as it should

#

:V

sterile token
#

The MenuButton class

tepid ore
#

What part? Is it not showing up? Doesn't it do anything on click? Any errors?

sterile token
#

I couldnt find how to do it

#

So i couldnt test it

tepid ore
#

Wat...

sterile token
#

Oh messed up you

tepid ore
#

Do what?

#

Hmm?

sterile token
#

Im really bad on english

tepid ore
#

No it's fine. I'm just confused what isn't working

sterile token
#

There nothing working, because i dont have the code to doing what i want

#

Do i explained now?

tepid ore
#

The code for what?

#

Sort of lol

sterile token
#

Yeah

#

let me send full code

tepid ore
#

Sure

sterile token
#

Menu#getButton(slot) return a MenuButton object

public class MenuButton {

    private final ItemStack item;
    private final ClickType click;

    public MenuButton(ItemStack item, ClickType click) {
        this.item = item;
        this.click = click;
    }

    public ItemStack getItem() { return this.item; }

    public ClickType getClick() { return this.click; }
    
}
#

Up to know udnerstand right?

tepid ore
#

Yeah ok, so this returns a gui icon. And you want to add a click action yeah?

sterile token
#

Yeah

#

That my bro

tepid ore
#

Ahh, ok then

sterile token
#

But an action like this:

MenuButton button = new MenuButton(ItemStack, ClickType, (action) -> run code here);

tepid ore
#

I do something like this

#
private List<ClickAction> actions = new LinkedList<ClickAction>();
@Nonnull
public Icon addClickAction(@Nonnull Iterable<ClickAction> actions) {
  assert actions != null;
  for (ClickAction action : actions) {
    this.actions.add(action);
    action.setOwner(this);
  }
  return this;
}
sterile token
#

Hmn im a bit nightmare

tepid ore
#

And then I have a click action class that looks sort of like this java @Nonnull public static ClickAction exitGUI(@Nonnull Player viewer, @Nullable ClickType... reactTo) { ClickAction act = new ClickAction(Action.EXIT_GUI, viewer, reactTo); return act; }

tepid ore
#

Why?

waxen plinth
#

Its behavior is defined by jvm flags

#

Unless a specific jvm flag is given assertions do nothing

tepid ore
#

Really?

#

Ok then

sterile token
#

Im stucked between passing the function to MenuButton and parsing it on InventoryClickEvent

tepid ore
#

Guess no more assert

waxen plinth
#

Also why are you using a LinkedList

sterile token
tepid ore
waxen plinth
#
public Icon addClickActions(Collection<ClickAction> actions) {
  actions.forEach(a -> a.setOwner(this));
  this.actions.addAll(actions);
}```
tepid ore
#

Isn't it?

waxen plinth
#

ArrayList is faster

#

And has O(1) random access instead of O(n)

tepid ore
#

I mean yeah, if it does not have to grow

#

Right?

waxen plinth
#

No either way

tepid ore
#

Or an I wrong?

#

Wat

waxen plinth
#

It will average out to have better performance

tepid ore
#

Really?

#

Cool

waxen plinth
#

Yes

tepid ore
#

Fuq the linkedlist then

waxen plinth
#

I can run a basic benchmark right now

tepid ore
#

What good is it

#

Sure

#

Please do

sterile token
#

redempt is correc tthis:

Map<Integer, MenuButton> its correct right?

tepid ore
#

Mhm

sterile token
#

That how i manage my buttons

tepid ore
#

I do it sort of like that

#

It's fine

ivory flume
#

How do I get a Material from a NamespacedKey

sterile token
#

Snikus i also want to do this:

MenuButton button = new MenuButton(ItemStack, ClickType, (action) -> run code here);

How do i do the black part lmao?

ivory flume
#

do i have to myself do the iteration and check

river oracle
waxen plinth
#

27967μs for 1 million adds to ArrayList, 198200μs for 1 million adds to LinkedList

#

That's actually so much slower than I expected linked lists to be

#

Roughly 7x slower

waxen plinth
onyx fjord
#

How fast is an if statement

tepid ore
tepid ore
waxen plinth
#

Stop prematurely optimizing

onyx fjord
#

Nah I'm just curious

ivory flume
waxen plinth
ivory flume
#

okay

sterile token
quaint mantle
#

is only way to save and get location from config is to do String.valueOf(the location)

ivory flume
#

but is that reliable?

quaint mantle
#

how

sterile token
#

Menu API - Help

waxen plinth
#

You can save a Location directly in config

quaint mantle
#

oh ik that

waxen plinth
#

And get it with ConfigurationSection#getLocation

quaint mantle
#

but how do i get it

#

oh fr

waxen plinth
tepid ore
waxen plinth
#

At least in modern versions, the material versions match the in-game keys except for casing

waxen plinth
onyx fjord
#

Its first time hearing that for me

waxen plinth
#

In 99.9% of cases, ArrayList will outperform it

#

I have only ever had a single use case where linked lists were the better choice

tepid ore
waxen plinth
#

I actually had to implement my own linked list for this because java's LinkedList doesn't expose the nodes and I needed them for this

tepid ore
#

So it wasn't even useful?

waxen plinth
#

The built-in one was not

tepid ore
#

It is just pure garbage

waxen plinth
#

Linked lists as a concept were

tepid ore
#

Hmm

#

No more linked lists then

#

Thank you, I would have continued using them otherwise

#

lol

waxen plinth
#

Do you want to know the reason for it?

#

Why linked lists suck?

tepid ore
#

Shoot

waxen plinth
#

To add to a linked list, what do you have to do

sterile token
#

Snisk i think that its better if you help using my own code

waxen plinth
#

You have to create a new linked list node

tepid ore
#

Ohh

waxen plinth
#

That's an object creation, which involves a heap allocation

#

Then you have to set that as the next of the tail

#

Then you have to set that node's prev as the previous tail

#

Then you have to update the tail of the list

#

That's an object allocation and multiple memory writes

#

Sure, you never have to copy memory around to expand a linked list

tepid ore
waxen plinth
#

But while each add may be O(1), there's a lot of overhead to what they do

#

Now consider what it takes to add to an array-backed list

#

It's literally just a single memory write

tepid ore
#

Yeah

#

..

waxen plinth
#

You put the pointer to the object at the location in the array

#

And if you have to expand, the cost is actually very low

#

Because every modern processor has SIMD instructions

tepid ore
#

You just extend the array

#

Yeah

waxen plinth
#

No you can't do that

tepid ore
#

I mean yeah

waxen plinth
#

You can't just extend it, you do have to reallocate

tepid ore
#

"Extend"then

waxen plinth
#

Nope

#

You have to copy

#

But SIMD makes it not that slow

#

SIMD stands for Single Instruction Multiple Data

#

System.arraycopy uses SIMD instructions to copy the contents of an array

tepid ore
#

I know how an array works, I was just to lazy to write copy ig

waxen plinth
#

SIMD can operate on up to 16 "lanes" at once

#

And copying memory from one location to another is one of the fastest operations there is because of this

#

So it doesn't actually take n pointer writes to copy the list, with n being the new capacity

#

On most modern processors it will take n/8 or n/16 writes

#

CPUs are just designed to be good with arrays

tepid ore
#

tldr, linked lists suck

waxen plinth
#

Yeah

#

That being said I still did not expect adding to a linked list to be 7x slower

tepid ore
#

I just blindly trusted the video I watched and assumed that making a new node object was faster than growing an array

#

But ig not

waxen plinth
#

Growing the array doesn't have to be done that often and is a very cheap operation

tepid ore
#

I didn't think about it lol

#

Yeah

waxen plinth
#

I'm pissed at my college because they spent the majority of the time in the data structures and algorithms class talking about linked lists

tepid ore
#

:V

waxen plinth
#

Linked lists have their niche but in the vast majority of cases they are useless

#

Only case they're really useful is for making data structures like LinkedHashSet/LinkedHashMap and for uses like mine where I have to assemble an expression tree from a list of tokens

tepid ore
#

Why would that be faster tho?

waxen plinth
#

Why would what be faster

tepid ore
#

With a linked instead of an array i mean

sterile token
#

Why the fu** it doesnt allow to run multiple lines???

#

Im really stressed lmao

waxen plinth
#

What do you even mean

#

Talking to verano there

#

Though I still do not know what you're asking snis

sterile token
#

Redemp can you help me please?

tepid ore
waxen plinth
tepid ore
#

^

waxen plinth
tepid ore
#

Ohhh

waxen plinth
#

Basically you have an expression like 1 + 2 * 3

#

All of those get tokenized

#

So your tokens end up being [1] [+] [2] [*] [3]

#

With each thing in [] being a token

#

You iterate over those tokens and sort them into their own lists based on priority

#

Storing the node of the token rather than the token itself

sterile token
#

Im trying to run code when you click a specific item and slot, but on that function i want to be able to use a variable which can provide getter for the player, slot, click type from InventoryClickEvent

#

Do i explaine?

waxen plinth
#

Then when I get to * I can remove the 2 before it and the 3 after it and replace it with an Operation token that acts as a value and is lazily evaluated to the result of applying the operator to the two operands

#

Then you have something like [1] [+] [2*3]

tepid ore
sterile token
waxen plinth
#

And then you repeat the step for + and you're left with one token that represents the whole expression

waxen plinth
#

Have some patience

tepid ore
sterile token
#

I dont know how to execute a function having a variable served

tepid ore
#

Make a click action class, and add the variables you want to use when you create the instance

waxen plinth
#
public void doThing(Consumer<Integer> func) {
  func.accept(1);
}```
sterile token
#

Oh jesus why it so diff to get understand

waxen plinth
#
doThing(a -> System.out.println(a + 1));```
sterile token
#

I will send again full code

waxen plinth
quaint mantle
#

how to compare locations without comparing yaw and pitch

#

without setting it to 0, 0

waxen plinth
#

Write your own comparison function that only compares x y and z

sterile token
#

I dont why its diff to explain whati want if its easy to understand :annoyed:

tepid ore
#

Imma go try to squeeze a few hours of sleep in. Cya redempt, thanks for the lecture :> Hope you manage to help verano

waxen plinth
#

I probably won't

tepid ore
#

lol

#

gl hf

sterile token
#

Oh :/

#

Hurt break moment

tepid ore
#

Yeah, I have to be up in 4.5 hrs. Sorry lol

waxen plinth
#

Get some sleep

sterile token
#

Me?

waxen plinth
#

.-.

sterile token
#

Yeah prob yes i will go to sleep its 4am

waxen plinth
#

This is kind of why it's hard to help you

tepid ore
#

I will, thanks for again for the linked list help lol

waxen plinth
#

You gotta provide more context and read the conversation closely

tepid ore
#

Gn

waxen plinth
#

Gnight

sterile token
#

Allright redempt please 1 more oportunity

sterile token
#

I promise i ill explain really carefully

waxen plinth
#

I didn't even see the beginning of your post so what's the full problem

terse raven
#

https://i.imgur.com/Zfn78Lr.png the particles and armorstand should be both teleported / spawned at the same place, but then why do the armorstands only get teleported correctly after 10-20 seconds?

waxen plinth
#

Clientside bug

terse raven
waxen plinth
#

When an invisible armor stand is teleported sometimes the client doesn't get the memo for some reason

#

Especially in older versions

#

What version are you using

terse raven
#

1.18.2

sterile token
#

My issue is that i want to execute code and be able to use a custom object like this here:

MenuButton button = new MenuButton(ItemStack, ClickType, (action) -> run a custom function);

waxen plinth
#

Hm

waxen plinth
waxen plinth
# terse raven

You might just have to kill and respawn the armor stands instead of teleporting them

terse raven
sterile token
terse raven
#

same problem with visible armor stands

waxen plinth
#

I mean come to think of it, using armor stands like that is probably not gonna work out very well

waxen plinth
#

Because even if you do kill and respawn them

#

When you respawn them, even if you make them invisible immediately, the client will still see them for a tick

waxen plinth
terse raven
waxen plinth
#

In your case you would just take a Consumer<InventoryClickEvent>

#

If you're not familiar with functional interfaces and how they work you should familiarize yourself

waxen plinth
terse raven
#

yea

waxen plinth
#

Ah I fucking love botania lol

sterile token
terse raven
#

same

waxen plinth
#

Hm

#

Don't teleport them

terse raven
#

i mean teleporting works

waxen plinth
#

Leave gravity on for them and give them velocity

terse raven
#

after about 10 seconds

sterile token
waxen plinth
#

Are you trying to say that rather than having it take an InventoryClickEvent, you want to have it take specific properties of the event, like the clicker and the slot?

waxen plinth
#

What would be the point

sterile token
#

Eactly that

#

My point would be:

(player. click, slot) -> {
code
code
code
}

terse raven
waxen plinth
#

..ok, then define your own functional interface

sterile token
lethal coral
#

is there a reliable way to copy each message sent to console

waxen plinth
#
@FunctionalInterface
public interface ClickListener {
  public void onClick(Player player, Action clickType, int slot);
}```
waxen plinth
#

Again, if you don't understand functional interfaces, go familiarize yourself with them

lethal coral
#

but most plugins use their own logger

sterile token
#

But then i would be able to use:

(player, click, slot) -> code code here?

river oracle
lethal coral
#

and I tried to go through all of the loggers but it doesn't show the loggers from some of the plugins

waxen plinth
#

You don't NEED to

sterile token
#

Oh allright

river oracle
#

okay I was like i've never done that

waxen plinth
#

But there's nothing wrong with it

sterile token
#

Sorry

waxen plinth
#

It's kinda like @Override

terse raven
#

maybe?

sterile token
#

So how would it look?

waxen plinth
#

How would what look

river oracle
sterile token
#

Consumer<ClickListener> action right?

waxen plinth
#

No

#

Just ClickListener

sterile token
#

HMn

#

OHHH

#

OK

#

I catch it lmao

#

Thanks

waxen plinth
#

This is really cursed but you can get logs another way

sterile token
#

So will be:

MenuButton button = new MenuButton(ItemStack, ClickType, ClickListener) right?

lethal coral
river oracle
lethal coral
#
        PrintStream myStream = new PrintStream(System.out) {
            @Override
            public void println(String msg) {
                CompletableFuture.runAsync(() -> logConsoleMSGToDiscord(msg));
                super.println(msg);
            }
        };
        System.setOut(myStream);

this is what I had (courtesy of 7 something I forgot his name)

river oracle
terse raven
river oracle
#

why are we ignoring the fact you can just trail the latest.log

terse raven
#

the response from minex

river oracle
#

seriously just read the file

waxen plinth
#

Intercepted Hello!

#

Oh wait

#

Yeah don't use that lol

#

Just get the parent logger of the bukkit logger

#

And if that's not the root, then repeatedly get the parent until the parent is null and bam, root logger

sterile token
#

Redempt i finally understand really thanks

#

I didnt understand, so i calm down. And try again, so i fixed it

#

😮‍💨 🤙

#

And sorry for being annoyed

#

@waxen plinth really thanks. Have peacefull night/day, regards

lethal coral
terse raven
#

uhm

#

yea

#

i have no idea then

#

sorry

lethal coral
#

nevermind

#

just had to cast

#

now time to see if it works 🙏

terse raven
#

🙏

last sleet
#

Hi, I,m trying to implement custom enchantments, but when I try and add one to a book, it doesn't work. No error messages, and when I try and output the enchants, it just isn't there.

Code:

ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
EnchantmentStorageMeta bookta = (EnchantmentStorageMeta) book.getItemMeta();        bookta.addStoredEnchant(CustomEnchantments.TELEPORT, 2, true);
book.setItemMeta(bookta);
((HumanEntity) sender).getInventory().addItem(book);
player.sendMessage(book.getEnchantments().keySet().toString());```
waxen plinth
#

Well you're reading from book.getEnchantments()

#

That's not going to give you the same result as the stored enchantments

ivory flume
#

Do I need to register every Listener? Is there anyway I can avoid registering it?

waxen plinth
#

Applied enchantments and stored enchantments are different

gleaming olive
#

1.8 Boss Bar

waxen plinth
terse raven
waxen plinth
#

Because the client doesn't know how to display the custom enchantment

#

It's entirely possible that the enchantment is on the book but there's no display

terse raven
#

yea just do it like hypixel and add the enchantment to the lore

crisp steeple
ivory flume
#

say im writing my own Menu class and one of the methods allows you to get the event without having to register its own listener class, like this:

@EventHandler
    public void clickHook(InventoryClickEvent event) {
        Inventory playerInv = event.getClickedInventory();
        if (playerInv != null && this.inventory != null) {
            if (playerInv.getHolder() == this && inventory.getHolder() == this) {
                this.handleMenu(event);
            }
        }
    }
    public abstract void handleMenu(InventoryClickEvent event);
last sleet
waxen plinth
#

Sidenote

#

If you want, I've got a custom enchantments library that makes it super easy

#

It looks something like this

#
public class HelloEnchant extends CustomEnchant {

  public HelloEnchant() {
    super("Hello", 1);
    addTrigger(EnchantTrigger.BLOCK_BREAK, (e, l) -> e.getPlayer().sendMessage("Hello!"));
  }

}```
crisp steeple
waxen plinth
ivory flume
waxen plinth
#

You can register multiple listeners if needed

#

But using just one is preferable there

#

It's better for performance, though it'll probably never really make a difference

crisp steeple
#

yeah, but performance is worse

#

what he said

last sleet
unkempt peak
#

That's part of redlib right?

lethal coral
#

just gotta make sure you stop the appender in your onDisable method 🙂

waxen plinth
terse raven
#

lets gooo

lethal coral
#

thank you kind sir

last sleet
#

Upon further testing, it actually adds the enchantment, but when I give the bow to the player, the enchant's not there. Any ideas why?

waxen plinth
#

Is the enchantment not there, or is it just not being rendered by the client?

river oracle
last sleet
river oracle
last sleet
river oracle
#

hm

waxen plinth
#

Why are you casting to HumanEntity

river oracle
#

^

#

shouldn't you cast it to player?

last sleet
#

sender is a CommandSender type and my idea tells me to cast to humaneentity

river oracle
#

idea is wrong

#

use Player

waxen plinth
#

Don't blindly cast, either

#

Sidenote if you want a better way to do commands I've got that too

last sleet
river oracle
#

I use lamp for commands 🤷‍♂️

last sleet
#

What's lamp?

waxen plinth
#

A command library

river oracle
#

commands lib

#

oop

waxen plinth
#

There's a good number to choose from

river oracle
#

what one do you use redempt

waxen plinth
#

The one I wrote

river oracle
#

nice

waxen plinth
#

I can show you how it works if you want

river oracle
#

is it on github or private

waxen plinth
#

It's public and fully documented

river oracle
#

send me a link

waxen plinth
#

To the wiki or what?

river oracle
#

wiki/source

last sleet
#

It still doesn't work, even when casting to player

waxen plinth
#

Also if you want to compare you can give me an example of a command to implement and I'll show you how it'd look

waxen plinth
#

I think doing enchantments that way is just finnicky

#

Did you register the enchantment?

#

Can you even register it anymore?

#

I don't remember how honestly

river oracle
#

You have to use reflection to register it

#

iirc

waxen plinth
#

Mm

river oracle
#

oh

#

try ItemStack add unsafe enchant

#

that will probably work better too

last sleet
#

I watched a tutorial some time ago when implementing custom enchantments and I just kind of copy-pasted the registering code, as I don't know how reflection or registering works. Here's the code.

waxen plinth
#

If it's being applied but then erased when it's given to the player I doubt addUnsafe would make a difference

river oracle
#

I don't think its even being applied

waxen plinth
river oracle
#

I watched the same tutorial for the wrapper than exited out

#

Its a pain to dig through source code ASakashrug

lethal coral
#
        if(plugin.getBot() != null && plugin.isEnabled()){
            plugin.getBot().logConsoleMSGToDiscord(MiniMessage.miniMessage().stripTags(message));
        }

How can I strip that down?

waxen plinth
#

What do you mean

#

Just use ChatColor.stripColors, does that not work?

lethal coral
#

no

#

the message is constructed through MiniMessage

#

I tried both though

waxen plinth
#

Oh I know why

#

Wait no I don't

#

Can I see the actual string printed by the bot

#

Copy and paste it into a hastebin

#

?paste

undone axleBOT
lethal coral
#

doesn't look helpful

waxen plinth
#

No

#

What the BOT prints

#

The raw contents of that string

#

Then I'll write you a method to clean the string

lethal coral
#

oh

#

I could just try to do that myself

#

for fun

#

if I fail I'll come back to you 😂

waxen plinth
#

Ok

last sleet
lethal coral
#

my attempt did not go well 😅

waxen plinth
#

Hmm

#

I think I know what's going on

#

You're getting the message at a weird phase

lethal coral
#

yes

waxen plinth
#

Where some of the metadata has been stripped but it has not yet been turned into the raw string to be displayed

ivory flume
#

How do I save data to an item stack so I can recognize it later?

#

naming it?

waxen plinth
#

?pdc

terse raven
#

you just need to spawn them outside of the players render distance

#

and then teleport them

#

then it works

waxen plinth
#

lol

terse raven
#

dont ask me why

#

but i am happy it does atleast

lethal coral
#

doesn't do anything

#

I could probably remove the minimessage thing

waxen plinth
#

Yeah let's see the raw message prior to calling stripTags on it

#

Can you show me that

lethal coral
#

it was the same thing

waxen plinth
#

Oh, interesting

#

There's no good way to do that then

#

Because if someone just said #000000 in chat you would want to leave that unchanged

#

There's no way to separate contents from formatting like that

lethal coral
#

that's terrible

#

for user experience

waxen plinth
#

Right, which is why you need to get the message at a different phase of processing

#

Ok another warning

#

This is super cursed

#

But you can open a reader on the log file and have a separate thread watching it for new messages

lethal coral
#

yeaaaah I don't think so

#

hmm

#

🥶 this just looks so bad

tall furnace
#

Yes it does

waxen plinth
#

Hm

lethal coral
#

whenever my plugin uses hex or whatever I could strip it before I send if the sender is the console, but I can't account for other plugins

tall furnace
#

Why use hex colors instead of chat colors?

lethal coral
#

minimessage

dusk flicker
#

hex colors look good

lethal coral
#

and ^

tall furnace
#

Apparently idk minimessage

dusk flicker
#

its just a lib for handling them

tall furnace
#

Can it send hex colors in-game?

dusk flicker
#

yep

lethal coral
tall furnace
#

o-o-o-o

dusk flicker
#

yeah it's really nice

tall furnace
#

Noooooo

#

That's insane

lethal coral
#

and the best part is the syntax

dusk flicker
#

I handle all of my hex colors and everything through it now

lethal coral
#
    private void sendHelp(CommandSender sender){
        sender.sendMessage(mm.deserialize(" <newline>" +
                "<gradient:#B600FF:#FFF700><b><u>            Discord Server Panel            <reset><newline>" +
                " <newline>" +
                "<hover:show_text:'<green>Click to suggest command'><click:suggest_command:/panel reload>" +
                "reload <dark_grey>- <grey>Starts a new bot with the token from the config<reset><newline>" +
                " <newline>" +
                "<gradient:#B600FF:#FFF700><b><u>                                                  <reset><newline> "));
    }
tall furnace
#

I bet

lethal coral
#

gradient is SO easy

tall furnace
#

Yeah gradients are great anyways, everything is handled internally

#

So it uses an HTML-like syntax

dusk flicker
#

ye

tall furnace
#

Wonder how they pulled it off inside the lib?

dusk flicker
#

no idea but minidigger is smart

tall furnace
#

I would be interested in seeing the internal workings

dusk flicker
#

it's part of the Adventure family that paper now runs

tall furnace
#

I've hacked my way through a few things in MC but not chat colors

#

That's gorgeous

dusk flicker
#

I didnt want to switch to adventure and what not but like, once I figured it out its the best thing ever

lethal coral
#

same

tall furnace
#

I bet

#

Ty for showing me

lethal coral
#

yup

tall furnace
#

I have advanced a level today XDD

ivory flume
#

If I wanted to have custom spawning of an ArmorStand with information saved on the ItemStack

#

could I cancel a PlayerInteractionEvent and do my own logic?

waxen plinth
#

Yes

tall furnace
#

Could you be a bit more clear? What itemstack? Why is there a playerInteractionEvent?

ivory flume
#

thanks redempt

tall furnace
#

It sounds like an easy yes but I'd like to be sure

ivory flume
waxen plinth
#

I'm guessing they want to cancel when the player right-clicks a block with an armor stand and do their own custom logic

ivory flume
#

yes, i want to handle the actual armor stand spawning logic

tall furnace
ivory flume
#

i am

#

😄 Redempt showed it to me a fe wminutes ago

tall furnace
#

Ok, cool

#

Yeah it's one of the best things in all of Spigot imo; you can store so much data in various entities and items

#

I used them to make ravagers tameable and breedable

ivory flume
#

is this how you spawn an armor stand?...

#

ArmorStand stand = player.getWorld().spawn(event.getInteractionPoint(), ArmorStand.class);

winged anvil
#

how exactly did you do this? im having the same error

tender shard
deft wadi
#
permissions:
  aetherislesplugin.join.admin: false
  aetherislesplugin.join.mod: false
  aetherislesplugin.join.member: false
``` ignoring the weird names, is this how I would register permissions in plugin.yml (the false means they are not enabled by defualt, right?)
tender shard
#

no

#
permissions:
  aetheriswhatever:
    default: op
  somethingelse:
    default: false
deft wadi
tender shard
#

here's also an example

deft wadi
#

will take a look, ty

ivory flume
#

I have a record class that implements ConfigurationSerializable but it didn't serialize when i did

#
            section.set(name, category);
earnest forum
#

look at the docs for configuration serializable

#

you probably have to add a method

ivory flume
#

those are for deserializing

earnest forum
#

plugin doesnt know how to serialize it

#

tho

ivory flume
#

huh

earnest forum
#

u have to tell it how to serialize

ivory flume
#

wait i think it did serialize correctly

#
Trashcan:
    ==: us.iears.pixiedustgenerator.models.ModelCategory
    materialId: cauldron
    name: Trashcan
#

is that ==: for the class?...

#

ew

#

is there anyway to not have that 💔

earnest forum
#

theres a serialize method

ivory flume
#

yes its working correctly i presume, i just thought that it broke because its now spouting straight up java like that

#

its a bit ugly but oh well

#

api is api, what can you do

worldly ingot
#

It has to be there, otherwise Bukkit wouldn't know how to deserialize it when you get it

#

So if you're using ConfigurationSerializable, yes. Though if you opt not to use it and just do your own serialization/deserialization (which is certainly an option), you don't have to have it. Though you're going to have to be a bit more careful with how you parse it

humble tulip
#

Should i be dynamically adding columns to my sql table or should i create a new table for each column

#

I'm storing stats but i may want to store a lot of stats in the future

#

I'm wondering if i should do column per stat or tabler per stat

crisp steeple
#

probably just have one table for stats

#

doesn’t make sense to make a table for every stat

humble tulip
#

That's how I've done it then i see the innodb limit for columns is only 1000 ish

#

I'm never gonna store that much but i read that more columns is worse performance

#

Generally worse*

crisp steeple
#

well you could probably have a different stat table for every gamemode

#

and then just link the gamemodes in one separate table

#

presuming you have multiple gamemodes

worldly ingot
#

Table per stat is probably insane. You'll want to keep that in one table and if you really want to add more stats in the future, you may just have to ALTER TABLE

humble tulip
#

Yikes

worldly ingot
#

Yeah, ALTER TABLE isn't great

humble tulip
#

I guess its A solution though right?

worldly ingot
#

It's probably the most sane solution tbh. Because again, you're going to end up with a hell of a lot of tables that contain nothing more than 2 columns

humble tulip
#

True

worldly ingot
#

The select statement on that would be a nightmare as well lol

#

so many joins

humble tulip
#

Joins are expensive too i think right?

#

Alter table is just a one time thing at most

worldly ingot
#

Yeah. Unless you have millions of entries it shouldn't be terrible either

humble tulip
#

Cool :)

#

Thank you

crisp steeple
#

honestly a lot of the time i just store data as json in sql

#

definitely not the most structured but it makes things simple

river oracle
#

I just use mongodb

crisp steeple
#

mongolian database

river oracle
#

Aboslute Based DB

golden kelp
#

MongoDB is so secksy

worldly ingot
#

ngl, Mongo would probably be ideal for statistics over SQL

#

NoSQL is best if you really can't predict what data you're inserting

#

@humble tulip if that's an option for you, ^

#

Or if you're writing a public plugin, at least make Mongo an option as well

quaint mantle
#

hey guys with bossbars

#

how do i show progress changes

#

is it just bar.setProgress(1-100)

#

and then it should update

#

or is there something im missing

slate spruce
#

Looking for a Part-Time / Full-Time Developer for an upcoming project.

Must be up-to-date with the newest plugins / news as well as being familiar in JS.

Message me if you're interested in knowing more.

quaint mantle
#

ok nvm i fixed that issue

#

how do u remove boss bars on reload

#

or just remove them in general

quaint mantle
#

bossBar.removeAll() doesnt remove the bar at all unfortunately

visual tide
#

i'm trying to get all cane blocks above the current block, would this be inefficient?

for (Block current = e.getBlock(); current.getType() == Material.SUGAR_CANE_BLOCK; current = current.getRelative(BlockFace.UP)) {
    blocks.add(current);
}
summer scroll
quaint mantle
#

nvm its on reload

#

i guess this is the first time ive experienced reload being bad

summer scroll
#

You need to destroy your bossbar on plugin disable

#

So it will work fine with bukkit reload maybe, I don't recommend using bukkit reload tho

mellow edge
#

what is bla*kspigot WEBSITE?

rough drift
#

just store using PDC

kindred valley
#

Hello, when i always try to do something with a loop in condition it always breaks the loop

#

how can i provide while loop to wait

undone axleBOT
kindred valley
#

I mean if there is anything i can prevent it related with while loop

#

?paste

undone axleBOT
kindred valley
#

I am not dealing with bukkit

#

and when i use Thread.sleep(); its already leaving from loop and my scanner.nextLine(); answering the more topped loop

mortal hare
#

wtf

#

It requires getHandlersList() implemented, but IDE expects from you to implement getHandlers(), which btw I implemented

#

and no API versions are not mismatching im using the same version of Spigot both for plugin via gradle (Spigot-API) and for minecraft server

mortal hare
#

nvm, getHandlersList is static and its not extendable from the class since its static

#

my bad

rough drift
#

If i use BaseComponent#addExtra(BaseComponent) and the 2nd component is bold and the first is not, will the 2nd component remain bold

harsh totem
#

When I use player.getinventory().addItem(ItemStack item) if the player doesn't have enough space in his inventory, the items that are supposed to be added are just not added

#

is there a way to make the items drop on the floor like in vanila?

drowsy harness
#

best obfuscator w/ string encryption?

mellow edge
#

because my friend uses it

#

is it legal or not

chrome beacon
#

Don't use it

#

They are almost always outdated and modified

harsh totem
#

How do I make my plugin execute a vanilla command?

chrome beacon
#

What command are you trying to run?

#

And why

harsh totem
chrome beacon
#

Why not use the api?

harsh totem
#

they are not dropped

chrome beacon
#

They are returned in the map

#

Drop them yourself

harsh totem
#

I don't know how and I tried searching

#

idk how to work with hashMaps

chrome beacon
#

?learnjava

undone axleBOT
chrome beacon
#

Or just google Java Hashmap

brave goblet
#

drop item stack

#

getWorld().dropItemNaturally(Location, Item);

#

oh wait nvm i miss read ur question

amber lake
#

what's the proper way to get the block sub type (magic value)?

#

since Block.getData() is deprecated, I'm looking a the right way to do it

knotty meteor
#
package nl.stefanokeizers.grabbelton.listeners;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

import nl.stefanokeizers.grabbelton.Main;
import nl.stefanokeizers.grabbelton.utils.Utils;

public class GrabbeltonOpenListener implements Listener {

    @EventHandler
    public void onInteract(PlayerInteractEvent e) {
        Player p = (Player) e.getPlayer();
        final Integer grabbel = (Integer) Main.grabbelConfig.getConfig().get(p.getUniqueId() + ".Pogingen");
            if (e.getAction().equals(Action.LEFT_CLICK_BLOCK) || (e.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
                if (e.getClickedBlock().getType() == Material.LIME_GLAZED_TERRACOTTA) {
                    if (grabbel == 0) {
                        p.sendMessage(Utils.colorize("&cJij hebt geen grabbelton poging(en)."));
                        e.setCancelled(true);
                    }
                    if (grabbel > 1) {
                        Main.grabbelConfig.getConfig().set(p.getUniqueId() + ".Pogingen", (Integer) grabbel - 1);
                        Main.grabbelConfig.save();
                        p.sendMessage(Utils.colorize("&7Je hebt de grabbelton geopend, succes!"));
                        // Open grabbelton menu
                        e.setCancelled(true);
                }
            }
        }
    }
}

Hello why does it execute 2 times
Can someone help

urban kernel
#

can someone help me fix a pom.xml error

visual tide
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

urban kernel
#
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
#

how do i fix it

urban kernel
visual tide
#

either the underscore or the plus is problematic

urban kernel
#

i removed both from the artifactid

#
    <artifactId>UltraMinions</artifactId>
visual tide
#

what happens then

urban kernel
#

same err

#

do i need to rename the .iml to the same as the artifactid

urban kernel
#

how do i fix this

#

build failed

hot panther
#

@urban kernel you are working with ultra minions?

urban kernel
#

er yeh

#

downloaded from src and im trying to compile it

quaint mantle
radiant cedar
#

yo guys how can I access each block or location in a bounding box

quaint mantle
#

i copied an repository and it needs an jar from this derkades repository

radiant cedar
#

so that I can fill it with any blocks i want

quiet ice
urban kernel
#

how do i "provide a goal"

quiet ice
#

mvn install, in this case install is the goal

quaint mantle
#

okay

hot panther
quaint mantle
#

thanks

quiet ice
#

For mvn package, package is the goal

urban kernel
#

im using mvn run

#

and plus, where o i put the goal

quiet ice
#

that does not exist

harsh totem
quiet ice
#

After the arguments

urban kernel
quiet ice
#

It's mvn install or mvn package in 90% of cases

#

Ah right, people these days do not know how to use a CLI...

urban kernel
#

where do i put "the goal"

quiet ice
#

I am an eclipse user, so you are on your own

urban kernel
#

oof

hot panther
#

@urban kernel Can I send you a DM?

urban kernel
#

where do i put "the goal"

urban kernel
quiet ice
#

Just run maven for the terminal..

urban kernel
#

howtftm

#

i dont have "maven" installed

#

on my pc

quiet ice
#

Maven can be installed in a portable fashion (similar to gradle), it is just a bunch of scripts after all

harsh totem
#

When I execute giveAmount(player, Coin, 21875751) is gets an error that says can't drop air

        is = is.clone();
        is.setAmount(amount);
        final Map<Integer, ItemStack> map = p.getInventory().addItem(is);
        for (final ItemStack item : map.values()) {
            if (!(item.getType().equals(Material.AIR)))
            p.getWorld().dropItemNaturally(p.getLocation(), item);
        }
    }```
#

idk why

earnest forum
#

what line

#

oh

#

empty slot in inventory is air

#

thats why

harsh totem
#

so I need to check if the item is not null

earnest forum
#

not air

#

or null actually ye

harsh totem
#

is says Condition 'is != null' is always 'true'

#

why is that

earnest forum
#

dont do equals for materials

#

just ==

harsh totem
earnest forum
#

enums

harsh totem
earnest forum
#

thats weird

lost matrix
#

The ItemStack in the players hand is never null. If its empty then its air.