#development

1 messages ยท Page 13 of 1

cinder forum
#

because you need to use

shell moon
#

well

lyric gyro
#

just note how it allows me to use the vertical bars in one if statement but not on the other

shell moon
#

because you used it wrong

#

๐Ÿ‘‡

cinder forum
#

because you need to use if action == Action || action == Action and not just if action == Action || Action

#

whqt

#

ooh

#

xd

lyric gyro
#

i used what wrong

lyric gyro
#

OHHH

#

I see

#

rookie mistake

#

guys do I also put Action.RIGHT_CLICK_BLOCK

#

some blocks can be right clicked

#

and it would be annoying if you accidentally sounded the horn while trying to right click a block

shell moon
#

thats up to the developer

#

(and how horn works)

lyric gyro
#

can I just send the whole code here

#

so you guys can check it out?

#

just to make sure

#

if there are anything that could

#

you know, break the code idk

#

ah

#

I can't even send it

#

oh well

#

i'll just test it in game

shell moon
#

dosnt work?

#

test it first

#

if it doesnt, feel free to ask, someone will reply

#

(eventually xd)

robust flower
#

how do I solve this generics issue?

lyric gyro
#

get rid of the <?>

robust flower
#

I thought that there would be a way of keeping the <?>, seems like suppressing the "raw type" warning is the only solution then...

lyric gyro
#

mhm

dusky harness
#

or can't you pass in a generic to newUpdater?

#

assuming that's your own class

#

or would that change too much stuff

lyric gyro
#

it's jdk

dusky harness
#

ah

dark garnet
#

im using paper's AsyncChatEvent, and im not sure how to achieve the same thing i had with PlayerAsyncChatEvent with the setFormat and setMessage thing

shell moon
#

Dont use that

#

i mean, why not simply using AsyncPlayerChatEvent?

dark garnet
#

is there a way to get rid of the deprecated warning?

shell moon
#

pretty sure it is like that

#

if you open spigot docs, its not deprecated

#

they deprecated it in favour of his AsyncChatEvent

#

which supports audience and component i guess

dark garnet
#

they made a ton of things deprecated

#

in favor of adventure

shell moon
#

i know, i'll never use those events as i support Spigot

dusky harness
shell moon
#

i just hope they dont remove them

dusky harness
#

they won't remove them as they keep spigot compatibility

shell moon
#

otherwise people asking "its not workingggggggggggggg"

dark garnet
#

its just too much

shell moon
#

yeah, i know, i just hope they dont remove it

#

(eventually)

dark garnet
#

so is there anyway to get rid of the deprecated warnings?

shell moon
#

mmm ignore it?

#

(if you support spigot, why not simply use spigot api)

dusky harness
#

since you can probably do what you want in AsyncChatEvent

dusky harness
#

unless you're trying to say spigot > paper

#

then um

#

AsyncChatEvent lets you get the final message, original message, and the player

shell moon
#

If that requires paper, people using spigot will have errors

#

thats what i mean

#

not encouraging people to use spigot over paper

dusky harness
#

alr

shell moon
#

but i wont tell them to switch to paper, even when its better

dark garnet
shell moon
#

so, basically a chat plugin

dusky harness
#

hmm

olive dirge
#

so i'm getting contents in prepareitemcraftevent

#

are those contents the same exact copy as the one placed?

dark garnet
#

cause rn this is what i have:

format = format.replace("%playerprefix%", new MetaManager(player).getPrefix());
format = format.replace("%player%", "%1$s");
format = format.replace("%playersuffix%", new MetaManager(player).getSuffix());
format = format.replace("%message%", "%2$s");```
dusky harness
#

wait for asyncchatevent

#

if you do event.message(Component.text("a")) for example

#

does it say <srnyx> a?

#

or a

dark garnet
#

sry gimme a sec ive gotta fix some other small bugs before i can build

dusky harness
#

alr

olive dirge
dusky harness
olive dirge
#

hmm will get inventory only get the items from the crafting part

#

not the whole inventory

dark garnet
# shell moon mmm ignore it?

theres no other way? cause it marks sendTitle, broadcastMessage, setLore, setDisplayName, AsyncPlayerChatEvent, etc... all as deprecated

#

basically anything that doesnt use components lmao

shell moon
#

if you plan to support spigot api

#
  1. Ignore all warnings
#
  1. Supress all warnings
dusky harness
#

if you plan to support spigot api

shell moon
#
  1. use spigot api
dusky harness
#

don't use paper api

dark garnet
#

one of my dependencies requires it

dusky harness
#

but since you're using paper api I'm assuming this is on a priv server or something

dark garnet
#

it is yeah

dusky harness
#

there's also Component.join (I think that's the name?) to combine multiple colors, etc

dark garnet
#

no point when bungee colors have been working fine tbh

dusky harness
#

migrate to adventure if you're already using bungee ๐Ÿ˜Œ

#

avoids the deprecation

dark garnet
dusky harness
#

although if you have a lot it might take a bit of time

dusky harness
#

still migrate to adventure ๐Ÿ˜Œ or create a method to convert legacy to components

dark garnet
#

but like, no, ๐Ÿ’ค

dusky harness
#

unless you have like 50 it shouldn't take too long to create a method to convert legacy to components

#

with find & replace

#

I mean you'll still have to manually do a lot of work

#

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

dark garnet
#

(if any)

dusky harness
#

No deprecation ๐Ÿ˜Œ

#

I mean that's why I did it

#

๐Ÿคท

#

not required

#

paper won't remove it

dark garnet
#

๐Ÿ˜ญ

#

paper is sooo silly

dusky harness
#

or you can just write new code with adventure

#

:))

#

and then your project will be half adventure half legacy

#

lol

dark garnet
#

nO

dusky harness
#

and then for config you can use minimessage ๐Ÿ˜Œ

dark garnet
#

NOOOO

dusky harness
#

paper slowly converting you to adventure

#

๐Ÿ˜Œ

dark garnet
#

ok sorry

dusky harness
#

lol

dark garnet
#

not minimessage PLEASE

#

anything but MINImessage

dusky harness
#

minimessage ๐Ÿ˜Œ

dark garnet
#

no... nooo... NOOO

dusky harness
#

bad barry

dark garnet
#

haha

dusky harness
#

YES

dark garnet
#

NOO!!

dusky harness
#

IT MUST HAPPEN_ _

dark garnet
#

PLEASE

dusky harness
#

IT IS INEVITABLE _ _

#

ok anyways

dark garnet
#

omg i love github copilot

dusky harness
#

same

#

useful in things when I'm writing repetitive stuff

#

I don't really use it for what people think of it as

#

like commenting something and copilot doing that

#

for that I just use google ๐Ÿ˜Ž

dusky harness
#

lol

#

ok but besides that

#

github copilot is pretty neat

dark garnet
dusky harness
#

๐Ÿ’€

dark garnet
#

fr

dusky harness
#

okay copilot

dark garnet
#

its been thru some stuff

olive dirge
#

is there an event that checks for when a player is hitting a block?

dusky harness
#

aw

dark garnet
#

:)

olive dirge
#

interesting, alright thanks

dark garnet
#

use PlayerInteractEvent#getAction

olive dirge
#

left click im guessing?

dark garnet
#

i think there is left click block (and right click too)

dusky harness
#

yes

#

๐Ÿ‘

dusky harness
#

hehehehehe

#

Hehehehehehe

#

:)

dark garnet
#

:(

#

omg there is more

#

it didnt load everything

dusky harness
#

:)))

dark garnet
dusky harness
#

weird

#

maybe I'll experiment with it tomorrow

dark garnet
#
public class ChatListener implements Listener {
    @EventHandler
    public void onChat2(AsyncChatEvent event) {
        event.message(Component.text("a"));
    }
}```
dusky harness
#

it's almost midnight for me ๐Ÿฅฒ

dark garnet
#

true devs dont sleep

dusky harness
dark garnet
#

r u a fake dev?

dusky harness
#

yes I do actually

#

I do see you sleeping

dusky harness
#

zzz only happens when you're sleeping ๐Ÿคจ

dark garnet
#

omg omg omg

#

noooo

#

u caught me lacking ๐Ÿ˜ญ

dusky harness
#

hehehe

#

I must go to sleep now

#

๐Ÿ›๏ธ

#

๐Ÿ›Œ

#

๐ŸŒ›

#

๐ŸŒ

#

๐ŸŒœ

#

๐ŸŒš

#

๐Ÿ‡ฌ๐Ÿ‡ด๐Ÿ‡ด๐Ÿ‡ฉ ๐Ÿ‡ณ๐Ÿ‡ฎ๐Ÿ‡ฌ๐Ÿ‡ญ๐Ÿ‡น

#

??

#

๐Ÿ‡ฌ ๐Ÿ‡ด ๐Ÿ‡ด ๐Ÿ‡ฉ ๐Ÿ‡ณ ๐Ÿ‡ฎ ๐Ÿ‡ฌ ๐Ÿ‡ญ ๐Ÿ‡น

dark garnet
#

spam spam ban ban

olive dirge
#

anyone familiar with mongodb api?

#

I think I kinda have 500+ connections after reloading the plugin that many times

#

Do I create a connection everytime I create a mongoclient thinkblob

merry knoll
#

just close the client on disable

#

and cache only one instance

dense galleon
#

Why is it that when I try setting the display name of an item drop, those two [] square brackets appear?

high edge
#

Code

dense galleon
#

item.customName(stack.displayName());

#
    @EventHandler(priority = EventPriority.LOWEST)
    public void onItemDropSpawn(ItemSpawnEvent event) {
        Item item = event.getEntity();
        ItemStack stack = item.getItemStack();
        item.customName(stack.displayName());``` more specifically
high edge
#

print out the values

dense galleon
#

But yeah, the stack doesnt have those brackets in the name

high edge
#

Does setting it add it?

dense galleon
#

Yeah that's what it seems to do

dense drift
#

That's intended

#

get it from meta

dense galleon
#

Huh what why is it intended

dense drift
#

e.g. when you get killed, the item showed in chat has [] around + hover

dense galleon
#

Aah I see

dense drift
#

will get the same result if you use ItemStack#displayName in a chat message

icy shadow
#

it's for stuff like the death messages i presume

#

yaeh

dense galleon
#

Yeah there we go

icy shadow
#

player was killed by player using [blah]

dense galleon
#

Another question: I noticed that when clicking twice in an inventory, the game thinks it's three clicks?

#

Ahhh there's a double_click click type

dense galleon
#

Can I set the color of a SPELL particle?

echo igloo
#

Hey, I want to make custom textured rank tags but I don't know the sizes. If anyone knows please help me ๐Ÿ™‚

#

and If there's a suggested font to use that would help as well

dense galleon
#

How is PlayerItemConsumeEvent#setReplacement supposed to work? Trying to prevent bottled honey from giving players a glass bottle after being consumed.

if (item.getType() == Material.HONEY_BOTTLE) {
    event.setReplacement(new ItemStack(Material.AIR));```
What this seems to do though is, if the player has multiple honey bottles in a single stack, it sets the whole stack to air and gives the player an empty bottle
fiery pollen
#

Does something exist where:

If I have two keys for one object in a map, for example a string and a integer. And if I get this object using 1 key, and change it and put it back in the "map". It will also be changed for the other key in the map?

dense galleon
merry knoll
#

if you wrap that with another object and keep the reference the same

#

then you can change the wrapped object inside the object you store it in

#

so you can edit the object, but cant change it and hope it stays the same on the other map

fiery pollen
#

Ah I see

lyric gyro
#

so i have a system where when you put on a certain block, you get a rainbow glass helmet. it constantly checks if the item on your head has certain nbt data, and if so, continues the loop. the issue, i want it so when you click on your helmet slot with the same item it stops the loop. although i do not know how to do this since they are same exact item. (clicking on rainbow glass helmet currently on head with glass would continue the loop as it would check for nbt data and obviously it would have that since same item).

merry knoll
#

keep a state variable

#

its on - off

#

click - put variable true - enable loop

#

click put variable false - end loop

lyric gyro
#

the issue is it would have to be a player based variable since there could be multiple people wearing it

#

also, can i cancel a bukkitrunnable from outside the bukkitrunnable?

merry knoll
lyric gyro
#

someone helped me organise and make my code more readable and less confusing

#

although its way more complex now

#

and I don't understand some parts of it

#

    public void addHorn(String name, Horn horn) {
        this.horns.putIfAbsent(name, horn);

    }

    @Nullable
    public Horn getHorn(String hornMaterial){
        return this.horns.get(hornMaterial);
    }```
#

what is this part doing

#

I don't know much about HashMaps and I don't know what this 'putIfAbsent' method is about

proud pebble
#

it adds the horn to the map, but wont replace it if you try to add the same one again

lyric gyro
#

why does it need a hashmap though

#

is it because there are multiple horns?

wary dust
#

anyone got any clue about SWM mem leaks on 1.8

next pivot
#

SQLUtils.getTopByPoints(Integer.parseInt(params.split("_")[2])).getName();

        return ordered.get(position - 1);
    }```
This is literally all it is, and it works completely normal anywhere else, but with DeluxeMenus it takes way too long.
dawn viper
#

when is it executed?

#

do you have an event or smth?

#

does PAPI even have any events ๐Ÿ‘€

next pivot
#

The first line is actually what is returned when a certain custom PAPI placeholder is called/requested.

dawn viper
#

oh okay I think I see

#

can you send the menu you're using?

broken elbow
dawn viper
broken elbow
#

ah

#

I was looking for it

dawn viper
#

yeah, forgot the context, sorry ๐Ÿ˜…

merry knoll
#

i feel like they are doing some sql

#

stuff on placeholder

broken elbow
#

I saw SQLUtils and I thought maybe they're doing sql queries

#

in a placeholder request

#

which would definitely be the cause

merry knoll
#

ye exactly

next pivot
merry knoll
#

how would it not affect other placeholders though

#

and only affect deluxemenus

dawn viper
#

maybe he just have an update_interval of 3 in his menu

#

which would explain why

next pivot
dawn viper
next pivot
broken elbow
#

or get the menu

#

from them. yeah

next pivot
#

Yeah, I will ask them for it now.

merry knoll
#

unless they are doing some io on the placeholder call

dawn viper
merry knoll
#

thats what i am gathering from "slow"

broken elbow
#

aki, it's just slow to open the menu

dawn viper
#

from what I understood it's that is that the method is called when opened, and then every 3s instead of 1s or smth

broken elbow
#

since DeluxeMenus creates the items and the menu when the open command is executed

next pivot
#

So, let me explain exactly what happens.

merry knoll
broken elbow
merry knoll
#

exactly what i am saying as well

#

but that doesnt make sense

#

if its doing it on deluxe menus only

broken elbow
#

yeah.

#

it should happen every the placeholder is parsed

#

@next pivot how did you end up figuring out it's your placeholder that causes this? is there like a lag dump or whatever they're called?

merry knoll
#

3 seconds is hella slow

#

even for sql

next pivot
#

2. There is a total of 18 placeholders to be called, but all of them are just a simple ArrayList#get methods, so it shouldn't take long at all.

3. A single get() method call takes a few seconds, it takes about 15-60 seconds for all of them to be executed.

4. The GUI opens.```
merry knoll
#

15 - 60 seconds for the gui

#

what

next pivot
#

Yup...

merry knoll
#

feel like you would disconnect no?

#

keepalive is like 30 seconds by default

next pivot
#

Weirdly - you don't.

broken elbow
#

it doesn't block the main thread Aki

#

DM creates the menus async

next pivot
#

Oh, that's alright than.

merry knoll
#

ah, that makes more sense

next pivot
#

But it still takes waaay to long.

broken elbow
#

just the menu will take long to open

merry knoll
#

i know some forks send keep alive

#

on another thread

broken elbow
#

ImDaMilan. Any chance you're actually loading a bunch of head- materials in the menu?

next pivot
#

As I said, the placeholder runs just fine however I call it, just not on DeluxeMenus.

dawn viper
#

what if you remove every instance of the placeholder in the menu

#

and try to open it?

#

does it still take 60 seconds to open?

merry knoll
#

i feel like this is not a placeholder issue

dawn viper
#

yeah

broken elbow
#

yeah same.

next pivot
#

We tested it using some other plugins as well as our own, the placeholder call was instant, but with DM it takes so long, we don't know why.

dense drift
#

do you have anything else that needs to be loaded, beside that placeholder?

#

e.g. heads as blitz said

merry knoll
#

dont heads get cached after the first call?

broken elbow
#

now they do

#

but on older version they didn't

next pivot
merry knoll
#

ah

dense drift
#

are you sure, blitz?

broken elbow
#

yeah

dense drift
#

or only baseheads were cached?

broken elbow
#

all heads except the ones that were taking in player names

#

were

next pivot
#

He sent me the file, where can I send it?

dense drift
#

ah ic

broken elbow
neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
โ€ข HelpChat Paste - How To Use

dense drift
#

uh weird @ blitz

broken elbow
#

what's weird?

dense drift
#

that they were not cached

next pivot
dense drift
#

but there's very few use for head- anyways

#

basehead ftw

broken elbow
#

there are a few heads

#

there's just so few of them tho.

dense drift
#

yeah exactly

next pivot
dense drift
#

please use a filler item instead of 30 separated glass panes

broken elbow
broken elbow
#

someone that reported this

dense drift
#

oh sorry

next pivot
merry knoll
#

semi unrelated, i got a method for pulling uuid out of mojang how long do you think is safe as a cache?

dense drift
#

if you use another material does it load instantly?

#

for how long do you need it though?

merry knoll
#

its needed as its needed

#

used for anything done for offline players / not logged in before players

broken elbow
# next pivot Alright, give me a sec.

yeah. like gaby said, can you recommend them to temporarily change the material:s for the top items to something like dirt? see if that still takes seconds to load or not

next pivot
#

He also said that all other menus load fine, but still, the placeholder also runs just fine on anything but DM, and it's literally just one return statement...

merry knoll
#

but the head call using the placeholder

#

after

next pivot
#

1.13.5

broken elbow
#

I'll just write 1 long message explaining what I think happens lol.

next pivot
#

Sending it to him now.

dense drift
#

could try to update to latest version, or is the cache not new?

next pivot
#

"the other menus are the same as this one and work perfectly"
"if that was the issue it would take forever for the other leaderboard menus"

-His messages.

broken elbow
# next pivot 1.13.5

For head- materials, DeluxeMenus used to make the Bukkit#getOfflinePlayer request every time the menu was opened and sometimes that ends up making a request to Mojang. This was fixed in version 1.13.6 (DeluxeMenus) by caching the heads so it will only make the requests to Mojang when the menu is first opened and then any time the menu is opened after it will open basically instantly until the server restarts.

next pivot
#

He is still arguing that that is not the issue.

broken elbow
dense drift
#

How do they know it is not?

next pivot
#

He told me to send you this and tell you that this one works fine.

broken elbow
#

yeah but you can still set up and test this yourself. and it would take them seconds to change the materials to dirt and back. it's just part of the debugging process

merry knoll
#

i mean its highly probable that one menu has cached players

#

and other doesnt

dense drift
#

Whats different beside every item having update true?

merry knoll
#

since its just offlinePlayer call

broken elbow
#

one uses ajlb, one uses airidalegangs.

merry knoll
dense drift
#

Ah, sorry

merry knoll
#

one menu opening fast

#

proves nothing

#

one could be doing an api call, other loading from file

broken elbow
next pivot
#

As I said, the placeholder is just a return statement that gets an index from an ArrayList, I see no reason why that could be bad for performance.

broken elbow
#

yeah. and that's how we feel as well

#

that's why we want them to do that step. so we can prove or disprove our theory and move to other theories

dense drift
#

All heads are loaded in the same way, Aki, so if both placeholders return a value instantly it should behave the same.

broken elbow
#

but we can't really do that if all they say is "no it's not it" with no proof

vapid tangle
#

changed all the materials to dirt and it still takes forever to load

broken elbow
merry knoll
#

why not just run the new version

dense drift
merry knoll
#

and see if that fixes it

#

its just a jar swap

vapid tangle
#

removed placeholder from display name and it loads instantly

dense drift
#

Blitz, what is the fallback value for update_interval ?

dense drift
#

Hm, ok

broken elbow
next pivot
#

If it is an issue with our plugin, I'm more than willing to fix it, but I just can't see any reason at all why a single get() method could cause any issues, especially only when ran trough DeluxeMenus.

broken elbow
#

@next pivot mind showing us your entire Placeholder class?

dense drift
#

Is the data cached?

broken elbow
#

gaby, they are saying it's just a list#get

#

so yes

#

in theory.

dense drift
#

Well, the data can also be loaded from a db as a list

next pivot
next pivot
dense drift
#

Okay

vapid tangle
#

I wont pretend I know anything about plugin coding, but it seems to be if 9 menus with the exact same material as a head, and placeholder in the displayname work perfectly, and this one specific menu take 5-15 seconds to load. its not an issue with the menu, its an issue with the plugins placeholders somehow.

dense drift
#

@vapid tangle update to latest version of DM just in case

vapid tangle
#

sure

dense drift
#

Is not worth to test bugs on older versions

broken elbow
vapid tangle
#

I understand

vapid tangle
#

my apologies if I came across as being rude

merry knoll
#

if all heads are the exact same name, then its true

vapid tangle
#

well shit

#

latest version of DM fixes it

next pivot
#

Hahaha, I just pasted the class!

dense drift
#

Hmm

vapid tangle
#

still would be nice to know what the issue actually was

dense drift
#

Caching

broken elbow
#

the simplest explanation I Could give

dense drift
#

Make sure you test the original config, with heads and placeholder as display name

broken elbow
#

basically deluxemenus wasn't actually caching heads and that would sometimes lead to requests made to mojang

#

which can take time

vapid tangle
broken elbow
#

I mean it could very well be that maybe ajlb already does some caching or something

vapid tangle
#

could be

#

well thanks for your help and sorry, I should have updated the plugin before coming here

dark garnet
#

how can i accurately simulate setting an armor stand's velocity using teleportation?

next pivot
#

Thank you all guys!

vapid tangle
#

is there a donation link somewhere? lol

dense drift
broken elbow
broken elbow
merry knoll
#

go from there

dense drift
#

Fair

#

But shouldnt that also be the case with dm? XD

#

Weird anyways

broken elbow
dark garnet
merry knoll
#

divide by period

#

lets say you want to move 1 block per second

#

then you gotta move the armor stand 1/20th of a block

#

each tick

#

so you can just do speed in blocks / 20

#

and move that much each tick

dark garnet
#

but how do i make sure its going in the right direction

merry knoll
#

wha

#

speed has 3 dimensions

#

you set the speed accordingly

#

you might want to check some basic geometry

broken elbow
#

math ๐Ÿ˜ญ

#

hurts

dark garnet
#

ok so what would go in stand.teleport(Location)

merry knoll
#

lmao

#

if you got a speed already then you just add speed / 20 as offset

#

to last location

#

but teleport wont work with what you want to do afaik

#

you need to do packetwise move packet

#

not teleport

lyric gyro
#

is there an event for hitting an entity?

#

or is it just interact event?

dark garnet
lyric gyro
#

for player

#

specifically

dark garnet
#

if (!(event.getAttacker() instanceof Player)) return;

lyric gyro
#

k

merry knoll
#

you get direction vector by doing b - a / length

#

then you multiply that by a speed to get your speed vector

lyric gyro
#

hmm

#

is there a way to create a new potion effect?

merry knoll
#

a custom one?

lyric gyro
#

I wanted to make so that when you play a horn, it makes every damage you do to someone or to some mob

#

summon a lightning

#

it needs to be a potion effect

#

because you will only summon lightnings on hit for a short period of time

merry knoll
#

it does not have to be a potion effect no

#

you can do temporary stuff without them being potions

lyric gyro
#

oh

merry knoll
#

record the time it starts

#

record how long

#

check when someone hits if it expired

#

??

#

profit

lyric gyro
#

i think a potion effect is easier though idk

merry knoll
#

no

torpid raft
#

no

merry knoll
#

dont rely on other systems

lyric gyro
#

idk how ill do that

merry knoll
lyric gyro
#

yeah

#

"record the time it starts"

merry knoll
#

System.currentTimeMillis

torpid raft
#

get the system.currentTimeMilis

merry knoll
#

can also use the new way

#

with instant class

#

instant.now i think

torpid raft
#

can also use game ticks if you want the effect to persist between restarts without progressing

lyric gyro
#

i think before i try to continue developing this plugin i have to understand it

#

some dude just helped me make it more safe and readable

#

but it also made it a lot more complex and confusing for me to understand

#

some parts of it i just can't understand

torpid raft
#

send code

robust flower
#

I just discovered a new way of spawning particles using ParticleBuilder, since when does this exist? Did you guys used it already?

#

d;paper ParticleBuilder

uneven lanternBOT
dense drift
#

I used it on 1.16, is probably older

#

d;paper-1.13 ParticleBuilder

uneven lanternBOT
lyric gyro
torpid raft
#

yes

lyric gyro
#

on intellij

#

it's easier

#

too many classes

#

it will get confusing if i just post everything here

dusky harness
#

Or smth like that

lyric gyro
torpid raft
#

im on mobile + at work

#

just gimme the juiciest screenshot you can muster

lyric gyro
#

fine

#

but after that

#

go do your job

#

the world depends on you

torpid raft
#

very horny method call you have there

lyric gyro
#

these parts I could not understand

lyric gyro
#

im basically becoming the horn master

#

no one i've talked to so far understand how horns work

#

or knew very little about it

torpid raft
#

so far you've shared the class responsible for tracking what horns exist

#

seems pretty easy to decipher so far, it just gives you a horn of a certain name when you ask for it

lyric gyro
#

what is hashmap and put if absent doing

torpid raft
#

although its weird that in the one snippet it calls the string key an instrument but the other class calls it the material

torpid raft
#

it lets you use one object (a name) to retrieve a different object (a horn)

#

put if absent essentially only adds a new entry into that hashmap if no horn by that name exists yet

#

preventing the user from overriding a horn with a name that was already taken

lyric gyro
#

i wonder why this is important

#

because the plugin is basically modifying the goat horns

torpid raft
#

brb back in 30

#

working

lyric gyro
#

not creating new items

dusky harness
lyric gyro
#

can you help me understand this thing?

lyric gyro
#

here it is

#

@dusky harness

dusky harness
#

I'm on phone rn

#

Can't look

lyric gyro
#

you did?

#

you didnt

dusky harness
#

Although u have to login to github in intellij

merry knoll
lyric gyro
#

these two parts

#

specifically

#

but

#

I'd like a better understanding of the whole thing

merry knoll
#

so you got a horn manager

#

that holds different types of horns

#

idea is that you can get the horn you want (each of these hold different logics in them)

#

this.hornspawn.getHorns.getHorn

#

just gets you the logic

lyric gyro
#

mhm

#

the logic

#

is the thing inside each horn class right?

#

import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class SingGoatHorn implements Horn{

    @Override
    public void action(Player player) {
        player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 400, 1));

    }
}```
#

like this

merry knoll
#

yes

#

so SingGoatHorn

#

when you call .action on it

#

applies potioneffect

#

each horn has to have an action

#

since its implementing Horn interface

#

for the map

#

imagine it as a variable of sorts

#

but instead of having to define them one by one, you can define as many as you want

#

then you can pull it as needed dynamically

lyric gyro
#

kinda like an arraylist?

merry knoll
#

kinda

#

in arraylist

#

your pulling thing is the index

#

as in 0 -> obj 1

dusky harness
#

Do you understand inheritance

merry knoll
#

1 -> obj2

dusky harness
#

Extending classes

lyric gyro
merry knoll
#

he doesnt no

#

but no need its not his code

#

with maps

#

instead of numbers

#

you can put anything as the left side

#

in your case its these texts

torpid raft
#

yeah aki describes it well

merry knoll
#

so when you ask a map

torpid raft
#

a map is like an array / list but instead of using a numerical index you can use an object as the index

merry knoll
#

hey give me "minecraft:ponder_goat_horn"

#

it will give you the instance holding the logic

#

for ponder goat horn

lyric gyro
#

I see

#

and what more?

merry knoll
#

putifabsent

#

thing

#

is basically telling it

#

hey, does "minecraft:blabla" exist already?

#

if yes do nothing

#

if not put the one i give you there

#

as its defined in the name itself

#

put IF ABSENT

#

its kinda useless in your use case, you could use just put as well

#

but it avoids overriding the old value

#

if an old value exists

#

i would personally make an enum instead of using raw texts

#

as the left side on the map

#

but its up to you

lyric gyro
#

well, i didnt came up with most of this stuff

#

a guy just helped me making the plugin better

#

before I just did everything in the same class

#

with switch statements

merry knoll
#

yes, thats the main advantage of a map

#

instead of a switch case that will get longer and longer

#

you get to seperate the logic

#

into separate classes

#

so its easier to understand

lyric gyro
#

i think it even makes the code run faster

merry knoll
#

nah

#

both switch and map are O(1)

#

in your use case

torpid raft
#

switches are likely a little faster but not in a way that matters

#

just because there's less objects to unbox and jump through

merry knoll
#

if you have performance issues, chances are you are doing something way worse somewhere else

torpid raft
#

yeah

#

premature optimization is the root of all evil

#
  • some comp sci guy
merry knoll
lyric gyro
#

now

#

I need to find a way to make all attacks summon lightnings everytime you damage someone or a mob

#

this after you sound a horn

merry knoll
#

you need to do some time calculations then

#

System.currentTimeMillis()

#

gives you the amount of milliseconds passed since epoch

#

so, it allows you do this:

#

get time when horn is used

#

then get time when someone hits something

#

if you do time 2 - time 1

#

it tells you how many milliseconds passed

#

you divide that by 1000 to see how many seconds passed

#

lets say you want the buff to last 10 seconds, you just check if the difference is less than 10 * 1000

#

if yes, apply lightning on that hit

#

if not, return out of the event

lyric gyro
#
    public void onHitEvent (final EntityDamageByEntityEvent event){

        World world = event.getEntity().getWorld();
        if (!(event.getDamager() instanceof Player)){

        }```
#

is this a good start?

#

(no)

merry knoll
#

yes

#

then you want to return out

#

in that if

#

since attacker is not a player

lyric gyro
#

right

#

I was about to say

#

I could barely understand that if statement

#

given the amount of parenthesis

lyric gyro
#

this event will trigger only when I sound the goat horn?

merry knoll
#

nope

#

it will trigger every time

#

an entity damages another entity

lyric gyro
#

how do I make it so that it will only trigger when the horn is sounded?

merry knoll
#

you need to store who has the buff

#

hint, you want a map for this

lyric gyro
#

y

merry knoll
#

another hint, you want to have player uuid on the left

#

so you can be like

#

hey does this player have buff

lyric gyro
merry knoll
#

its unique id of the player

lyric gyro
#

but if programming was easy

#

then everyone would be a nasa engineer

#

nasa engineers dont code

#

but anyways

torpid raft
#

some of them do

#

how else did curiosity know how to sing happy birthday

lyric gyro
#

how do I create a hash map

#

i forgot

torpid raft
#

new HashMap<>();

merry knoll
#

new HashMap<Type1, Type2>()

lyric gyro
#

I feel like this one will be the hardest one to do

#

the other one just summons goats that attack mobs

indigo apex
#

Hey guys how, can i fix it

#

yaml menu_title: '&7Previewing: ' open_command: potionkit size: 9 open_requirement: requirements: permission: type: has permission permission: deluxemenus.admin deny_commands: - '[message] &cYou don''t have permission to do that!' items: '1': material: POTION potion_effects: - SPEED;10;1 amount: 1 slot: 0

wintry grove
#

So I'm back, and it is still regex time pain

I have done some improvements to the system I'm working on, but I'm still dancing in my ass because the regex doesnt work, and thats something that doesnt surprise me.
Right now the regex is this:
(๏ ก๊‘ก๏ |๏ ก๊‡๏ |๏ ก๊†๏ |๏ ก๊…๏ |๏ ก๊„๏ ) ([a-zA-Z0-9]+): ([a-zA-Z 0-9\W]+)

It matches 3 groups:

  • The rank, which is a 3 unicode character thing
  • The Username,
  • And the Message

The part I'm having problems with is the fucking rank part, although it should work, according to my brain and google, it doesnt.

For example, this is a message that it is supposed to be able to parse:
๏ ก๊„๏  StarL0stGaming: imagine suffering to a fricking set of characters called string that supposed to make my life easier

But, it throws this error:
https://paste.helpch.at/ewasucuped.apache
The method that uses the regex is this one:
https://paste.helpch.at/kicimitotu.js

I'm in pain

dusty frost
#

i imagine there's a unicode problem somewhere, of something not supporting it

#

also of note, a valid minecraft username can have _ in it lol

wintry grove
#

ik

#

forgor the //W thing

#

I'll add it

#

but thats not my problem

dusty frost
#

i mean yeah, my guess is unicode

wintry grove
#

pretty much

#

according to google java should support that

#

IJ parse the first and third unicodes into the number thing

#

the mid one or the second is not parsed into that

#

should I try changing it to the number code?

dusty frost
#

To match a specific Unicode code point, use \uFFFF where FFFF is the hexadecimal number of the code point you want to match. You must always specify 4 hexadecimal digits E.g. \u00E0 matches ร , but only when encoded as a single code point U+00E0

#

In Java, the regex token \uFFFF only matches the specified code point, even when you turned on canonical equivalence. However, the same syntax \uFFFF is also used to insert Unicode characters into literal strings in the Java source code. Pattern.compile("\u00E0") will match both the single-code-point and double-code-point encodings of ร , while Pattern.compile("\\u00E0") matches only the single-code-point version. Remember that when writing a regex as a Java string literal, backslashes must be escaped. The former Java code compiles the regex ร , while the latter compiles \u00E0. Depending on what youโ€™re doing, the difference may be significant.

wintry grove
#

I'm confused

broken elbow
dusty frost
broken elbow
#

idk man. I think gaby posted a link to a paper regex where they also match dots

#

in player names

#

like inside a paper patch

dusty frost
#

probably for like Geyser or something

broken elbow
#

yeah but those prefixes are customizable tho

dusty frost
broken elbow
#

I guess the default one is indeed dot.

dusty frost
broken elbow
#

maybe old usernames?

#

I Know they used to allow 3 char names

#

2*

#

not 3

#

but very long time ago

dusty frost
#

yea yea

#

weird stuff

wintry grove
#

it pretty much follows what it says there

#

I'm confused

lyric gyro
#

how do you extend an entity

dusty frost
#

i thought of like 6 different jokes to that question and none of them were funny

#

but also this sounds like an xy problem, unless you're making a mod?

dusty frost
wintry grove
#

wait

broken elbow
dusty frost
#

oh shit lol wtf

#

that's so bizarre

wintry grove
#

is that supposed to be a regex kekwhyper

#

its so weird

broken elbow
#

I'm going to assume you're trolling now? XD

wintry grove
#

I dont even know either lmao

broken elbow
lyric gyro
wintry grove
broken elbow
#

btw starlost. maybe instead of throwing errors check if there 's a match first? XD and just log it

wintry grove
#

wait how

#

and wdym lmao

#

do I log the result of matcher.group()?

lyric gyro
#

you need to check if there's a match before doing anything

#

if matcher.matches

dusky harness
#

don't you also have to do matcher.find?

lyric gyro
#

no

#

they check different things

dusky harness
#

oh

wintry grove
#

let me get the shotgun rq

#

then why does it throw an error then bruh

#

the it must be that I'm using matcher.group()

broken elbow
wintry grove
broken elbow
#

what's at ChatHandler line 66

wintry grove
#

nothing lmao

broken elbow
#

oh noes.

wintry grove
#

changed the code

broken elbow
#

please do not compile the regex pattern

#

every time

broken elbow
broken elbow
#

yeah but like 66 specifically. was it String test = matcher.group();

#

?

wintry grove
broken elbow
wintry grove
#

hehe funny number

lyric gyro
#

you're still not checking if it matches

wintry grove
lyric gyro
#

you must check either matcher.matches/.find before using group and other stuff

broken elbow
#

he does

#

this is the current code

broken elbow
lyric gyro
#

yeah okay and it works

broken elbow
#

yeah. but he's wondering why it works when he checks

#

but not when he doesn't

wintry grove
#

yeah

lyric gyro
#

because you have to check

#

it's a must

wintry grove
#

really

broken elbow
#

well here's your answer

lyric gyro
#

read the javadoc for pattern

broken elbow
#

yup lmao

#

well idk about Pattern but on Matcher#group

wintry grove
#

my bad

#

so if I do matcher.group() it should work now right?

broken elbow
#

as long as you use Matcher#matches first

wintry grove
#

aight

#

also what exact group does that method return

#

bc it doesnt return an array

#

just a single string

#

so I'm guessing it returns only one group

broken elbow
#

the next one

#

there is a group method

#

that takes in an integer parameter

#

that is to specify the group you want to get by index

wintry grove
#

does it work like an array

#

from 0 to infinity

#

or just 1 2 3

lyric gyro
#

group() (or group(0)) will return the matched string, if your pattern has capturing groups you pass in the group indexes (obviously starting from 1, because 0 is the whole match)

wintry grove
#

aight

broken elbow
wintry grove
#

aight

#

so the classic 0 = 1

wintry grove
#

good

#

tysm then

#

oh

broken elbow
#

no no star. read what emily said

wintry grove
#

aight

broken elbow
#

I Did not know that

wintry grove
#

yeah

broken elbow
#

actually. unless I Did and just forgot lol

#

which is very much possible

wintry grove
#

let me try then

broken elbow
#

d;jdk Matcher#group-int

uneven lanternBOT
#
String group()
throws IllegalStateException```
Description:

Returns the input subsequence matched by the previous match.

For a matcher m with input sequence s , the expressions m. group() and s. substring(m. start(),
m. end()) are equivalent.

Note that some patterns, for example a*, match the empty string. This method will return the empty string when the pattern successfully matches the empty string in the input.

Returns:

The (possibly empty) subsequence matched by the previous match, in string form

Throws:

IllegalStateException - If no match has yet been attempted, or if the previous match operation failed

wintry grove
broken elbow
#

this sucks

#

why is there n group with parameters method

wintry grove
#

ye

#

its building rn

lyric gyro
#

why is bukkit the default

broken elbow
lyric gyro
#

d;jdk Matcher#group(int)

uneven lanternBOT
#
String group(int group)
throws IndexOutOfBoundsException, IllegalStateException```
Description:

Returns the input subsequence captured by the given group during the previous match operation.

For a matcher m , input sequence s , and group index g , the expressions m. group(g ) and s. substring(m. start(g ),
m. end(g )) are equivalent.

Capturing groups are indexed from left to right, starting at one. Group zero denotes the entire pattern, so the expression m.group(0) is equivalent to m.group().

If the match was successful but the group specified failed to match any part of the input sequence, then null is returned. Note that some groups, for example (a*), match the empty string. This method will return the empty string when such a group successfully matches the empty string in the input.

Returns:

The (possibly empty) subsequence captured by the group during the previous match, or null if the group failed to match part of the input

Parameters:

group - The index of a capturing group in this matcher's pattern

Throws:

IndexOutOfBoundsException - If there is no capturing group in the pattern with the given index
IllegalStateException - If no match has yet been attempted, or if the previous match operation failed

wintry grove
#

someone tell that bot that I'm not in bukkit or spigot lol

lyric gyro
#

surprisingly, reading the things you're using helps

wintry grove
#

imagine reading

broken elbow
#

this tbh

#

why do that when you can debug for 6 hours and also make other lose brain cells in a discord server with you?

wintry grove
#

yes

#

but not for 6 hours

#

change it for a week or two lmfao

#

it isnt returning the first group skull

#

and also turns out that it is also able to parse the character

broken elbow
#

code maybe?

wintry grove
#

wait I'm the stupidest person alive

#

I forgot to change it from 0 to 1

lyric gyro
#

why do i even bother

wintry grove
#

I mean you have a fair reason

broken elbow
#

to not bother

wintry grove
#

yes

#

tysm to both of you

lyric gyro
#

so

#

will anyone help me creating a custom entity?

#

wanted to create a custom goat that targets hostile mobs

wintry grove
#

I mean

#

spigot forums exist

lyric gyro
#

they havent been that helpful

wintry grove
thick oyster
#

How can i make something that when a player joins for the first time the players uuid gets loads into a yml file like this:

Players:
uuidofplayer1:
SomeValue: ""

when a other player joins for the first time it needs to be looking like this:

Players:
uuidofplayer1:
SomeValue: ""
uuidofplayer2:
SomeValue: ""

lyric gyro
#

i cant extend any entities

#

why

#

why is goat a fucking interface

#

i cant understand

dark garnet
wintry grove
#

dont know

#

I have never touched custom entities

dark garnet
robust flower
#

if I have an hierarchy of Listeners aka one abstract class implementing Listener and a concrete implementation, and both concrete class and parent class got methods annotated with @EventHandler, will PluginManager register the methods on parent class(es) too?

lyric gyro
dark garnet
#

but everything is outdated Sadge

lyric gyro
#

i'm just trying to create a goat that attacks hostile mobs

dark garnet
#

i hate nms

lyric gyro
#

but I can't extend entitygoat because it literally doesnt exist

#

i cant extend anything

#

the closest thing i found was "goat"

dark garnet
lyric gyro
#

yes

dark garnet
#

compileOnly("org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT")

#

so u have that?

lyric gyro
dark garnet
#

does CraftGoat exist

lyric gyro
#

1.19 for me

lyric gyro
dark garnet
lyric gyro
#

yes

dark garnet
#

im using CraftArmorStand

#

try extending that

#

wth is craftserver bruh ๐Ÿ˜ญ

lyric gyro
#

i think this solved my problem

lyric gyro
#

but good

dark garnet
#

ah i think i got it

#
    public Stand(Location loc) {
        super((CraftServer) Bukkit.getServer(), new EntityArmorStand(EntityTypes.d, ((CraftWorld) loc.getWorld()).getHandle()));
        this.b(loc.getX(), loc.getY(), loc.getZ());
    }```
#

but b doesnt exist sooo

lyric gyro
#

why is the tutorial different

dark garnet
#

i think a lot of stuff is version-dependent

lyric gyro
#

literally 2017

dark garnet
#

yea might be outdated

lyric gyro
#

jesus fucking christ why is firefox lagging my computer

dark garnet
#

w h a t

'addEntity(net.minecraft.world.entity.Entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason)' has private access in 'net.minecraft.server.level.WorldServer'

#
final Stand entity = ((CraftWorld) location.getWorld()).getHandle().addEntity(new Stand(location), CreatureSpawnEvent.SpawnReason.CUSTOM);```
robust flower
#

compiled against a different version than the one being executed, probably

lyric gyro
#

for god's sake just WORK

#

what am I doing wrong

stuck hearth
#

What does the error say

lyric gyro
#

i cant extend any entity

stuck hearth
#

Where is EntityGoat from?

lyric gyro
#

im extending a class that comes with spigot or something like that

stuck hearth
#

This Goat?

lyric gyro
#

it's not what im looking for

stuck hearth
#

What are you looking for then?

#

d; spigot EntityGoat

uneven lanternBOT
#
public interface Entity
extends Nameable, CommandSender, PersistentDataHolder, Metadatable```
Entity has 4 extensions, 6 super interfaces, 154 sub interfaces, and  66 methods.
Description:

Represents a base entity in the world

dusky harness
#

prob an NMS class

stuck hearth
#

Oh maybe

dusky harness
#

or craftbukkit

#

i don't know what EntityGoat is in

lyric gyro
#

what does that mean

stuck hearth
#

The package you're looking for isn't in spigot, which begs the question as to where you got the name from to begin with

lyric gyro
#

public class CustomPig extends EntityPig {

stuck hearth
#

Okay yeah that's NMS

lyric gyro
#

but I have nms

#

why doesn't the goddamn class show up

stuck hearth
#

I've never touched NMS, so no clue, good luck

lyric gyro
#

i cant believe no one in this server knows how to create a custom entity