#help-development
1 messages ยท Page 832 of 1
you dont need to use nms to break blocks in an area yeah but for the breaking animation you do
in the consumer you sety invisible and it's never seen
nope you just send fake block damage
ok thanks
yeah so you either use nms or like protocollib
theres a particle now
fake block damage is API
oh is there
ah i see
seems some support was added in 1.19 and a bit more specific implementations in 1.20
if you want your plugin to be compatible with older versions than that you'll still need to do stuff with packets though i reckon
lol
anyone know how i can make a custom mob system were mobs spawn in a rigon with custom names and all that
i mean anytime you spawn an entity you get it returned and so you can edit it with equipment or custom names or whatever
so thats not an issue
spawning them within a region means you gotta hook into worldguard and go through a region to get its valid spawning spaces
spawning mechanics themselves you gotta figure out in what way you wanna do that
or the easy method would be to listen to mob spawn events and edit those mobs if they spawned within that region, if you dont mind using vanilla spawn mechanics
depends on what you want to do
@cyan void
guys
Non-static method 'getInventory()' cannot be referenced from a static context
So
im trying to make
a command
that gives players
a item like /give
when the command is run
but the problem is
that
getInventory() isnt static
i mean
im kinda confused
so a instance of bukkit api?
An instance of the object you're getting the inventory from
Could be a chest, furnace anything really
??
im trying to use getInventory
to add a item
to a players inventory
so i have to instance
getInventory
right
no
If you want the players inventory
you need the players instance
to get the inventory from
k
How else would it know what player you're referencing?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Might be a good idea
You're supposed to do that before starting with Spigot
event.getPlayer().getInventory()....
๐ฅฒ
i thnk
yeah thats valid
does anyone know how i can make my plugin work with old versions?
Write code for the oldest version you want to support
If you want 1.8-1.20 write the plugin code for 1.8
so if i write it for 1.8?
it'll work till 1.20?
and then if you want to specifically support newer features you'll need a version check and only run code supported
is there a wiki for this or like a page that can help with examples?
Example for what part?
like these two only
Location location = player.getLocation();
player.playSound(location, sound.ENTITY_ENDER_DRAGON_DEATH, 1f, 1f);
Player player = e.getPlayer();
player.sendMessage("Welcome to RomanMc!");
Here's an example of a relatively easy way to only use new features if they are available.
https://raw.githubusercontent.com/stargate-rewritten/Stargate-Bukkit/nightly/src/main/java/org/sgrewritten/stargate/property/NonLegacyMethod.java
then just do something like
if (!NonLegacyMethod.NAME.isImplemented()) {
//Fallback
return;
}
//use of the new method
I need the slot number
for?
I want to check if player clicked on helmet slot
thanks ;)
I'm several years in and I've still not done it, what are you going to do about it
Sorry magma, you have to be put down now.
Rebel ๐
this is what a programmer looks like
I've got a concealed manual memory management license and I'm not afraid to use it ๐ซ
slander and liabel
Fight me
get in line, you can be the one I throw into the cliff right after imillusion
I actually wonder when the last time I posted a pic of myself here was
it's been a long-ass time
Ha small beard
I've a bigger beard, but mines grey and unkempt.
Thr imillusin \^.^ beef continues
not my fault, the doctor shaved part of it off for a surgery
I was going for a big santa beard this xmas
oh well
I was updating one of my friends old projects what uses nms and I forgot.... nms is all obfuscated ;-;
I'm not too bothered about doing it though, he's helped me a lot by making this project so it's the least I could offer
is there any item persistence method that saves all details of an item but not including some version
i would like spigot to not care if an item made in higher versions is deserialized on older versions
I was recently deving for (craft)bukkit b1.7.3 and it's so shitty, for custom inventories you need nms because there was no api at all for invs it seems lol
1.7.3 ?
Whats wrong
No no, I'm just asking if you meant 1.7.3 or if I was reading wrong
The beta 1.7.3, yes
Ah wow, long time since I heard those numbers!
Very nice version, very not nice bukkit and even worse mcp
1.7.3 is july 8, 2011.
Is it sad I can remember the exact patch version I started mc on?
:kappa:
No, that's cool
1.6.4 ๐ฅฒ
Time flies fast
Well, oof
lemme just check the version history
I remember the date exactly so would be easy
1.7.4 oof
I was on xbox for a lot longer though
Lol, I started playing on a friends playstation. Bought minecraft java right before 1.12.2 released
I was defo before 1.12
I am starting to look at retiring my mc account soon, gonna suck to do it but gotta grow up :/
Whaa
Haven't actually played for ages ๐
lol I'm way into my 50's and I've never grown up
anyone know any good and populated modded minecraft servers?
Is there a list of v1_19_R1 numbers anywhere so I don't go wasting my time making code what won't be used?
Sorry no I worded that wrong I mean for the different minecraft versions
like these https://i.imgur.com/J2C3lAA.png
Thank you very much
Does anyone else have an irrational hatred of nms?
Sure, it's powerful, but it's a pain to maintain, makes more work for oneself, and means that every time someone else wants to do the same sort of thing, they basically need to duplicate your implementation or reimplement it themselves.
Every time that nms is needed, it's easier in the long term just to pr it into or downstream of spigot.
NMS should be a last resort.
Making a pr every time we need nms is a pain, but it's saved us a lot of long term maintenance work
im glad to have never needed nms
just make it easy for yourself so you barely have to use nms lmao, makes things future proof
We are currently nns free. But it's taken a lot of paper and spigot PRS to get to that point
or through a bridge like protocollib
Thats what PR's are for. Add functionallity to the API
The only thing worse than nms is nmc, but I just hate reflection in general.
nmc?
net.minecraft.client as opposed to net.minecraft.server
ah
They are both a nuisance, but nmc is slightly worse
The one negative of this approach is that our releases for past versions are comparatively limited since it's only logical to pr to the recent version.
But a degraded legacy experience is still better than needing to maintain a load of reflection throughout every version of MC.
Also, there's really no need for legacy esrs to be fully featured
If the people on our ancient esrs want modern features, they should just update to 1.20.x
Opposite, I barely use the API anymore. Its way too dated in a lot of areas
oh god no
Maybe I just have an irrational hatred of enums
Tbf I don't make public plugins, so its mostly own server fork + internal plugins
using 1.20.3 is pretty pointless
alright
however
i didnt ask
need it just as dependency just to have that version covered
not using it
I'm pretty sure it's done intentionally
its done intentionally
1.20.3 = 1.20.4 there was one line of code changed
and it was a item deletion bug
any servers on 1.20.3 should be 100% compatable with 1.20.4
vise versa unlses a plugin's NMS interacts with the 1 line of code changed there should be no discrepencies @hushed spindle
BuildTools 1.20.3 builds 1.20.4
as spigot-version i mean
But therein lies the problem;
The dated sections encourage more people to use NMS instead of making prs for publicly beneficial changes. This leads to those sections becoming even more dated, resulting in more people using NMS.
Even though making changes into public prs is more work, in the long term, it's better for everyone. Without that, everyone is just working on reimplementing things others have already privately done.
is there any way i can tell bukkit to not care if serialized items have a higher version than the server they're deserialized on
no
darn
do you then happen to know of an itemstack (de)serialization method that covers all metadata and custom nbt
so that it doesnt include a version at all
Realistically that would break a lot
It's backwards compatible, but not forwards compatible
btw i think paper stopped relocating nms in more recent ones
not yet โข๏ธ
ahh alright, just saw it mentioned somewhere and thought you were starting to do it. my bad
This won't break Bukkit#getServerVersion or whatever right
I use that for my NMS and manually map into the release versions
nah
that is fine
the thing that basically breaks is parsing the thing from like Bukkit.getServer().getClass()
oh why would you do it like that? seems kinda weird
String craftBukkitPackage = Bukkit.getServer().getClass().getPackage().getName();
// This is the *bad* part, including any other parsing of the version
String version = craftBukkitPackage.substring(craftBukkitPackage.lastIndexOf('.') + 1);
if (version.equals("v1_20_R1")) {
// ...
} else {
// Unsupported
}
like, that would explode
but like, idk why you'd do that
weirds
yea, weird nms people

is it possible to use components or smth with inventory names? because i'd like to change the font of an inventory name
:paper:
@worldly ingot was working on adding components to stuff
I mean if there's another way of setting the font that is also fine
does this somehow fix those version-dependent imports?
via reflection?
nms is always an option
@eternal night https://jd.papermc.io/paper/1.20/org/bukkit/inventory/InventoryView.html I only see a way to get the title component not set it, am i braindead?
declaration: package: org.bukkit.inventory, class: InventoryView
\
oh wait
thank you xpdz
but still setting the title after ๐
since when is gpt chat available without a phone number.....
Guess it's not supported for some reason
idk ask openai
I wish that existed in b1.7.3, would've saved me a lot of time working with obfuscated nms
you just do what you always have done? Each version is a different module
you use the Versions to get which module you should load with reflection
relocating?
my project is open source if you wanna look
thats the issue we wanna get away
yea pretty sure we just didn'T end up creating an adventure version
please, spigot team, DO NOT RELOCATE
feel like maybe you could create a jira feature request for this
or you could just talk to MD_5 about it
gonna do some more testing with it rn, and if it goes poorly im just gonna advocate deprecating for removal on paper if its untenable to fix
hel
would anyone know of why on certain items you can't click them out of an anvil inventory? there isn't anything cancelling it
hello
hello
minecraft totally
We would need much more information to atleast try to guess.
Like what are you trying to click out
which spot is it in
the result item?
Congrats, the result item is what when you are trying to click it out?
?
I give up
are you working with an anvil in the physical world
if not expect trouble
you will recieve no help regarding such issues as well. This is already a well known issue and it has a PR to address it if you want virtual Anvil Inventories you'll have to use NMS
Physical anvils,
Can anyone suggest the best way to get mob heads for 1.20?
i'm manually setting the result item because im making a certain item enchantable
there are no restrictions on Physical Anvils or issues
WHAT ARE YOU SETTING IT TO
Bro
tbf you are nearly un intelligable
Let me give you a guide on how to ask a question.
leave
What happened.
What did i do?
Code.
you can't ask a vague question and expect a good answer
I'm not sure how to explain the issue.
Requote in #general
/give
its pretty great
Oh i got that guy blocked
if you wanna use code you can always add items ot the player's Inventory
if you aren't going to be more specific don't expect a better answer
It's just the item in the result slot is not able to be moved, the item is being set manually when paper and a enchant book and then it puts the enchantments on the piece of paper and sets it to a cloned item stack in the result slot.
My issue or?
Listen to the InventoryClickEvent on priority MONITOR and make sure the event is not cancelled.
ok hopefully this works
I should of thought of that, thank you will look into it real quick. Other than that would anything else that you know of prevent the item from being able to be dragged?
A issue where the result item can't be pulled out of a physical anvil.
if it works it works
What does your plugin do?
yes
which is why it doesn't make sense
yes
i know my plugin isn't cancelling it
Thank you, i don't much care for the description, but the code since that's where the trouble seems to be.
Who's LG
*** Please download a new build as per instructions from https://papermc.io/downloads/paper ***```
They make TVs I think
I had an LG phone once i think
So they make tech stuff in general?
Oliver, please follow those instructions ๐ซ
is having a lot of static methods bad? People seem to hate them
Static is great
its only 21 versions out of date
In util classes, probably not. But otherwise, burn it.
It's not great when used in properly
Ok cause I have like 20 static methods in my whole plugin
It ruins encapsulation and it can be called everywere.
Well there are other use cases too like singletons for example
Static is dangerous. They are only fine when completely stateless.
They should not exist in any other context.
Yeha that's fine
Many people are going crazy whenever they see the static keywoard inside some source code. Thatโs ridiculous, because it alleges the people who developed Java were totally stupid. It is true that the static keyword gets abused by many people, but thereโs a difference between static abuse and proper use of the keywoard. What does...
Only use it for util classes
@lost matrix I feel like that question warrants a macro
I have felt the need to throw that out a lot
Maybe static can be used to share a value across instances of the same class or something
Hmm
I wonder when that could be the case though
never
Singleton
Most of my static methods are private static
The question is: Are they stateless
huh whats that
how do I find out
Ask them
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
By looking at them ๐
If they modify data outside their scope, then they are not stateless.
heres an example of one
Modifies itemstack ๐ ๐
Hello everyone! It's me - geolykt - and I have another highly specific query: Is a object that is stored in a local variable but isn't actively being referenced anywhere considered strongly reachable? Aside from asking why the hell geolykt would do this sort of thing, would I need to do
void myMethod(Object o) {
someReference = new WeakReference<>(o);
someOperation();
Reference.reachabilityFence(o);
}
or is that plainly superfluous?
Yes, because I have no true idea what classifies as "it can be reached by some thread without traversing any reference objects"
Yes. Imagine getting your objects collected while executing a method.
A method scope strongly binds Objects.
Without JIT this question is nonsensical, but with JIT one might think there is no real difference between discarding some object and keeping it in the local variables
But you can easily test this by starting a thread and keeping the object hostage in a while loop ๐
Nah, I just wanted to check whether I could do a quick and dirty check whether someone was actually calling my method with an autocloseable that was properly wrapped in a try-with-resources. But in that case I'll just drop that idea
I would say that this should not be a static method.
If you pass a String to it in addition to the ItemStack, it could be considered a utility method.
A lot of my static methods are just methods to obtain which items I should put in a GUI menu
Yeah, though I assumed if the reference goes poof that there is great evidence that something was highly wrong with the caller. But as smile says it isn't that easy.

Hey, is there anyway to modify the console output for chat logging? I'm currently making a plugin which gives the ability to change a player's name, which utilizes the Player#setDisplayName method, which changes the player's name in the chat, but also in the console.
This makes the server admin (or others with console access) unable to determine who the player is/was at the time. I was hoping to see a way to modify the console output, so that I can put their real name infront of their fake name.
Yes, I know I can do this via printing a message right under the original, but that'd just clutter up console imo
Make you won chatplugin @tribal cypress
That won't change console logging tho.. ?
It will depending on how you do it.
Cancel the message and send it using bukkit broadcast?
I guess I answered myself, but I'm still open to other suggestions, as I don't want to override the messaging just cuz of a nickname plugin, y'know
Other solutions will result in a lot of crap.
Ah, alright, thank you then for you advice
Ok so how I understand it - if I have the Bukkit.runTaskAsyncronously whilst another async task is already running it will wait until that async task is done and only then run the new one?
yeah, but that next tick could be in a few ยตs
What if the async task takes longer than a tick (the original one)
Or are async tasks usually fast
Well it depends on your code and how other tasks look like
I feel like the async executor should have multiple threads
Generally you wouldn't need that precision though - if you do, you should think about your design a bit
it does
Though, hardware limitations still apply
What would be the best way to check if a block is natural or not without having to make an async task on blockbreakevent to the coreprotect database
Have I use Java oder Java script for plugins ?
java
Thx
Yeah isnโt it just a cached thread pool underneath?
Yeah iirc it just uses a default configured thread pool
sounds fun
And I mean I think thatโs fine, like if you use it for longer surviving tasks then thats on u, kinda goofy
would running location.distance every tick cause lag?
but you didn't mean it, right?
Oops didnโt mean to
if you only do it once, not really - it is just some rather basic math
The only semi-serious thing is that it does a squareroot which is why you should prefer distanceSquared when comparing it with a hardcoded value. But even that is not a serious issue
alright thanks, also im asuming it returns the amount of blocks between 2 locations or?
so uhh having an issue where the config file no matter what i do keeps showing this even if i delete it or make a new one
https://paste.md-5.net/iwikijajez.php
can some help me
It just does dist = sqrt(distSq) and distSq = (this.x - x)ยฒ + (this.y - y)ยฒ + (this.z - z)ยฒ
oh k thanks
I'm more of circles
They are just awesome
And perfect
Not on a computer
It's impossible, as the computer draws pixels
The monitor*
You don't see a circle on a monitor, never
Just a set of pixels very close to each other making the shape of a circle
Depends on the screen being used
Crt's for example can draw circles
god I hate the cold
Do those still being used?
it's miserable to work in
I love the cold
does it hurt?
Of course
It's better than being all wet with sweat
You take out clotes and you still being hot
Cold is better
You put a little bit more of clotes
And done
I go to the gym even during winter time, I pay to get sweaty
and it's still miserably cold
Probably better if i list the advantages so you can gauge where they might still be used
Ye
high refresh rate is one, other displays have caught up
Crts have better color representation especially when it comes to gradients. They are more responsive and handle multiple resolutions better and with ease
to be fair you can buy specialized monitors that beat them in pretty much every aspect
they're just more expensive than a $90 lcd monitor
Also because its an electron beam and not little crystals they can display shapes far better and accurately
In theory assuming crt's are no longer produced this would be the case but electricity doesnt beat light or electrons in a vacuum
Downsides of crt is size and basically difficult to repair
I don't think crts have any single aspect that they still hold over modern display tech unless you are looking for a balance that is struck only specifically by crts
Now if you wanted to compare like a crt from the 90's with something modern sure we probably have some lcd that could beat it
Modern crt displays can represent colors accurately as i said also their refresh rates are far higher then what lcd can do. Again comparing modern crt with modern lcd
I mean, you can buy 8k monitors, you can buy 360hz monitors, you can buy monitors made specifically for color accuracy...
Yes
Oh thought you asked a question lol
Anyways my point is. There is advantages to having a crt. Does that mean you should switch to one? Probably not lmao
no, I'm just saying there's not much of a market for them outside of retro / vintage right now, at least I've never heard of any other group purchasing new crts
Medical, government, aero, space etc
let's be real everything under gvt is not doing it because crts are good, they are often doing it to fix old systems which used crts and they are not about to update them
Probably wont find much in the pure civilian consumer area except what you listed
Uh no this far from the case. Old tech is sometimes better because new tech isnt needed nor provides any significant advantage
yeah, that's called if it ain't broke don't fix it
you know what uses that logic? legacy systems
Me being from military side i know plent of areas you could use newer tech but it wouldnt improve anything.
if you're designing something new in 2023 you're not doing it with crts, least of which because they are getting harder to source by the year
They are harder to source for civilian consumers
Not everyone else
yeah for everyone else they're just more expensive
Cheaper
then you're getting scammed
hey guys how do i make an action bar lasts forever?
you'd pretty much have to reapply it even if it's just once in a while
so make it return to itself over and over?
Maybe outside the US. But us market this isnt true
if that's a bad way of saying using a repeating task then yes
okie then thanks ^^
Create a task which repeats every 40 ticks (2 seconds)
Anyways i am not trying to debate the market on them. Point i was making is they still have uses, they are still produced, and places still use them
what economic sense does it make that a piece of tech that is used by an absolutely tiny proportion of the total global market is cheaper against one of the most mass produced things humanity is currently dishing out
Well its only tiny to one area not the others
is this correct?
https://paste.md-5.net/guyisacovu.css
Nest your code
But yes
Because one area doesnt need it as much all it did was increase supply for the others and thus keeps them cheap
They just dont need to mass produce them anymore
I randomly opened aliexpress and I can buy 8inch lcd screens for 16 euros as a replacement for a samsung tab a 8.0 which should have a resolution of 1280x800 pixels which is an absolutely shockingly cheap price for display tech, and you're saying that you can source a crt for cheaper than these random sellers
nest?
Probably wouldnt be accurate to use tablets as a comparison
Yes but crts that small are niche and have been since the late 80's
You have everything in one line
sure, give me a size
Nesting a code is splitting it in lines
Bukkit.getScheduler().runTaskTimer(plugin, () ->
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("ยงaRomanยง5MC!")),
0, 40);
So it's a bit more readable
ohhh didn't know that nesting meaned that xd
Yeah, just avoid nesting it too much
cause errors don't worry
but thanks
15.6 inches, random laptop monitor, 61 euros including european tax and it's 1080p
and I'm sure you could find cheaper if you weren't just opening a random link
Well i am at work on mobile. If you dont mind i would prefer to use my computer lol. I will be home in like 7 hours
I'll be long gone by then, it's 1 am
this man is out here pinging me awake to win an argument about how crts are cheaper
Uh no not to wake you lmao
I'll believe you that it is cheaper if it's leftover stuff the US looted from countries it had military theaters in post ww2
that's how the english got a lot of cool stuff for cheap
portugal too
so luch has it the server had to many errors from that you know another way i can set it up?
Which error?
it just caused issues with the sound i was running from it and just made both not work with just a huge error line so i made it into the first one i made and they both worked fine now
question is getPluginDirectory remaned to getPluginLoader now?
no
You probably are looking for getDataFolder()
It's always been named that though
How do I remove the message that gets sent whenever a player dies?
similar to changing the playerJoinEvent message to null, is there something like that for player death event?
declaration: package: org.bukkit.event.entity, class: PlayerDeathEvent
Please read javadocs before asking
Np
anyone have an idea on how I could unify these regex statements
<(.*?[\"])>|<(.*?)>
Basically goal is to match everything inside the tags unless they're in quotes e.g.
With just <(.*?)> this would match out
<example:tag:"<example>text"> -> example:tag:"<example
With my first statement though it correctly matches
<example:tag:"<example>text"> -> example:tag:"<example>text"
couldn't you just add a ? after your []
no doing that puts me back to square one
this?
yeah, but unfortunately that doesn't match tags with non quotes
which is why I needed the ore
why doesn't * work
I wonder if writing a string parser is more efficient tha nregex
you making a minimessage clone?
megamessage
just need to adapt an implementation for BungeeChat
MineDown is nice and all but prefer the syntax of MiniMessage tbh
Keep in mind that MM is not regular so regex won't take you too far
๐คฎ
sure theirs more parsing to be done
was going to do it to grab the tags, but I guess I'll manually parse ๐ฅฒ.
granted I'm realizing since I'm simply adopting its syntax I don't need to reimpl all of MiniMessages features. Specifically some of the extra NBT stuff can definitely be left to a later date
true, but for most use cases you really don't need all MC compoents in reality I really just need to focus down on colors, hover and some click events
Does JUnit have an "assertNotThrows"?
assertDoesNotThrow
Don't exist
it should
Yes, JUnit 5 has it
๐ฅฒ my tokenizer works so far brings joy to my heart
legit so cursed thoguh ๐ช but we ball idk how to fucking make a parser
wdym?
I'm making a MiniMessage syntax parser for BungeeChat
idk how tf to make a sophisticated parser I've never made one outside of some basic stuff like string splitting and a little regex
Oh
so I'm basically going from no knowledge to rocket science ๐ but I have a feeling just like every crypto currency to ever exist I'm going to the moon babyyyy ๐
You might want to take a look at this?
Completely not sponsored
why did you make your own chat components ๐
unfortunately my problem is a tad more complex than that
My brain went brrrr
Which is it?
Like, where are you stuck at?
not stuck atm just balling. I'm tokenizing that shit up rn
e.g. you gotta put in your input string than tokenize the shit out of it
well when you tokenize a string you're essentially pulling shit out
Hmm should I make a reflection based packet system
So I don't have to do the BS writeUUID writeString stuff
e.g.
<red>hi</red>
is extracted into 2 tokens
[<red>, </red>]
I just make a mapper function and scan classes 
on each token you store a bit more info e.g. 2 ints start and end location
You could make it a regex
sure but regex is slower
why do multiple loop when 1 loop work fine
is there a way to have bukkit runnable executed at random tick intervals?
even if you use regex you still are required to parse your tokens
I don't get how regex is any faster here
I could do a benchmark but its 11:05pm
whatever fuck it
anyone
You are thinking about it as <red>hello</red> in red and <red>red</red> in red
The regex doesn't necessariliy need to go through all the match instances.
Make your regex like this:
\\<?<color>(red|blue|cyan|...)\\>\w+\\</red\\>
You parse that regex once, replace all the occurrences, and parse again, until you don't have matches/finds
no
you'll have to wrap something that runs every tick and use Random
cool but that regex gets crazy quick
Create an scheduler, as a "main scheduler" which runs repeatedly, for instance every tick. Inside that scheduler, run another task which tick is a random number
ok i see thanks
Not really
private final static Pattern COLOR_PATTERN = Pattern.compile("<(?<color>black|dark_blue|dark_green|dark_aqua|dark_red|dark_purple|gold|gray|dark_gray|blue|green|aqua|red|purple|yellow|white|reset)>", Pattern.CASE_INSENSITIVE);
๐ฟ
that's very legacy of you
are you forgetting everything components can support
gradients etc, hover and click events
private final static Pattern CHAT_PATTERN = Pattern.compile("(?<container><chat\\s*(?<click>click=\"(?<clickAction>OPEN_URL|COPY_TEXT|WRITE_TEXT|EXECUTE)\"\\s*content=\"(?<clickContent>\\bhttps?://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]|[\\w\\s&ยง]*)\")?\\s*(?<hover>hover=\"(?<hoverAction>SHOW_TEXT)\"\\s*content=\"(?<hoverText>[a-zA-Z0-9~@#$^*()_+=\\[\\]{}|\\\\,.?: -&ยง]*)\")?>(?<message>[a-zA-Z0-9~@#$^*()_+=\\[\\]{}|\\\\,.?: -&ยง]*)</chat>)", Pattern.CASE_INSENSITIVE + Pattern.MULTILINE);
Hover and click support ๐ฟ
I said I went crazy
For gradients is eazy
private final static Pattern COLOR_PATTERN = Pattern.compile("<(?<color>black|dark_blue|dark_green|dark_aqua|dark_red|dark_purple|gold|gray|dark_gray|blue|green|aqua|red|purple|yellow|white|reset)|(?<gradient>#[0-9]{3,6}\:[0-9]{3,6})>", Pattern.CASE_INSENSITIVE);
I think this would work
This takes <red>Hello I'm a <#fff:ff2fff>gradient
It depends on how you use them
But what do you prefer?
Have like 50 if statements?
Or a single statement?
Reminds me I need to turn my tokenizer into an iterator of sorts for true O(n) performance!
cuz rn It requires O(n^2) since I would parse my string twice
Why would it?
poor design I suppose?
ik I'm kinda doing it as I go here
?paste
I mean for example here
https://paste.md-5.net/viboyicopa.java
You can just turn this into an iterator like system and only iterate through once parsing tokens as you go with a next method
as of now its a queue, but I'm going to switch that
switches generally compile into a lookup table so that option is still pretty good
I guess OPEN is < and CLOSE is >
yea
Explain what would this code do to a string
I could also use a map, but then I'd have to deal with hashing
well it takes an input string and separates out every token. Ofc with this implementation than you would need to parse everything again
its about the same as this regex
((?<start><)(?<token>([^<>]+)|([^<>]+"(?<inner>[^"]+)"))(?<end>>))+?
So it takes
<red>Hello</red> into
Token@red - Hello?
major difference is its not separated into groups, however it can be done so pretty easily using iteration over separators :
example
String message = "<red>\"<Now>\"</red>";
Queue<Token> queue = Tokenizer.tokenize(message);
for (final Token token : queue) {
System.out.println(token);
System.out.println(token.details(message));
}
Output:
Token[start=0, end=5, type=OPEN]
red
Token[start=12, end=18, type=CLOSE]
red
Why is the text content between < >?
I'm testing my escaping
as you can see its inside quotes
however, my current approach for that in of itself is flawed so it needs a little rework
The problem with that is that you don't really know what that token is for. Like, it could be a color, an hover element etc, you will require tons of if statements for them
I need to ensure the tag has been opened inorder for my quote escape to work
sure but that's why I'm switching to a more Iterative design vs the current return of a Queue
so you can recieve a token and parse it and apply it to the next between it and the next token
You will also need to add an error control. We all know the user does the possible to break the application, he might write <i love cats>Hello world!</what?>
What will you do in this case?
nothing
I mean, what will you do in your application to manage that case?
For each case?
there aren't many cases
you have to remember regex does the same exact thing
the only difference is its not frontword facing
colors, hover components, click componentes (you can have both in one), gradients (as you mentioned before), title times, actionbars, contents of the hover and clicks
There're a lot of cases actually
at the end of the day that's how many cases? like 30. If i wanted to hyper optimize I could use a Trie to filter out all non-keys
this would give a considerable advantage
seeing as Trie's refuse an input as soon as it doesn't match with the 30 or so inputs it would have
so i am having an issue where the config yml keeps making this and not what i make in the code for it anyone know how to fix this?
https://paste.md-5.net/piwiqoyibi.makefile
the downside is it slows down an actual match which is why IMHO it'd be better to just use the if statements and chance it on the bad syntax having to run through all of them
I would use regex (as I did)
Seems simpler for me
actually I had an idea with this
?nocode
Itโs hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
a Trie would be perfect here I would simply need to modify it to support proccessig the tag as soon as we know its valid rather tahn doing it again
I couldn't be fucked tbh. We should benchmark our methods against eachother once I'm done :P might take a couple weeks though I'm a bit distracted of an individual
I also wanted to benchmark against MiniMessage cough my bad adventuretoo to see where I'm at
Fuck yeah, let's do it
I didn't benchmark mine
Probably will get a surprise
its pretty easy to do stuff with JMH
granted benchmarks take a long time
can be like 30 minutes xD
Yeah, but I'm toooooooooooo lazy for doing things like benchmarks
and you get to hear your computer die as JMH warms up the JVM
No, I simply ignore it ๐ฟ
As long as my code runs
๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ ๐ฟ
||joke, I just didn't know about benchmarking since a few weeks ago||
If I want to use "Bukkit.getServer().getOnlinePlayers()" but for all entities what is the easiest, do I have to first loop through all worlds and then loop through each world's entities?
okey
Bukkit.getWorlds().stream().flatMap(World::getEntities)
a nested loop works but I'm a streams addict
I have made a code where I save entities in a list. If I check if this entity tries to damage another entity by checking that damager is this entity in "EntityDamageByEntityEvent" should this make it so that no entity can take damage from that entity?
?tas
hey, how does redstone work on spigot? So I have heard it skips ticks to optimise it for performance. So like, if i had a 0-tick pulse generator, could it like not activate every single time?
I know this is not a discord server for paper but, i am currently running a paper server. I have heard paper servers do TPS catchup to compensate for the skipped ticks, how does it differ from spigot? So like do they move updates to the next game tick or something?
?fork
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
What I have experienced is that it has not worked, stupid of me not to say so in the question.
For example, I have entity as "FireRocket" but the player can still take damage from the explosion
oh ok.
that is fine, but regarding the first question, can i know more about how it skips ticks?
did you cancel the explosion event?
yes
as far as I know it doesn;t skip ticks
however I doubt you can have a zero tick pulse
i have heard literally everyone say it breaks redstone probably.
a pulse requires a down pulse
you can;t pulse up if you never pulse down
ie a zero tick pulse of power level 8 is just going ot give a constant level 8 signal
explosion not damage
or not explosion event just EntityDamageByEntityEvent
this is the 0-tick pulse generator i am currently using.
they are different damage events
whats a pulse up and pulse down??
if you have a pulse every tick there will never be a down time
Can you retrieve the one that damaged or caused the explosion and make it so that no one is harmed by it even though it should still happen as well as the animaiton should be shown as well
it will be a constant signal
ah okay.
yes, set the yield to zero
0-tick pulses are actually one gametick perhaps, but they are called 0-ticks because of it being almost 0 redstone ticks perhaps.
dont entirely remember how they named this mechanic in redstone but is sometimes used for certain contraptions.
0 ticks are used to do stuff in one gametick that shouldnt be done in one game tick
like opening a 5x5 piston door
cancel damage and set yield to 0
and why would you need to retrieve the damager
but yeah with .getDamager i believe you get the exploding entity and with that you can get the cause
are you only trying to cancel damage?
Here's what I thought ๐
@slate tinsel
yes
From a FireRocket entity contained in a list
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
yeah
use this
do
event#getDamager
and if its the rocket
e.setDamage(0)
Okey
hey so I forgot the most basic thing, when I do /setspawn, what could be the reasons that player isn't teleporting to the set spawn? Instead they teleport to a default world spawn?
Should I do setSpawnLocation() on a world? And if that's the case, what if player tries /spawn from the end or the nether, then I can't use setSpawnLocation()?
Should I teleport the player to spawn on PlayerRespawnEvent?
declaration: package: org.bukkit.event.player, class: PlayerRespawnEvent
/setspawn is only for the player performing the command isnt it
It's a custom plugin command
is this supposed to be used?
from what plugin
my plugin
well what is your current method that doesnt work
is it possible to get the number that a player has set is fov to?
or even force the fov
No
Purely clientside
no thats client stuff
ok
if you lucky you can give them slowness or speed to change their fov if they didnt disable that ig
thats about it
is it possible to get the death reason (last harm reason) in PlayerRespawnEvent
i dont think so
just log it
hashmap
cache it until player respawns
then remove
im trying to put a text placeholder on an item but annoyingly every time i rename an item or use /give to give myself an item with said placeholder as name it injects some color code on the 2nd character thats interrupting the placeholder
how does that work
I can't do that. player could log out before clicking the respawn button, and on top of that, I could shut down the server and start it up again xD
so hashMap would be gone
like i used the command /give @p diamond_sword{display:{Name:'[{"text":"<lang.material-diamond-dagger>","italic":false}]'}} 1 for example and still it puts that color code
same happens if i do it with code
well in case you need to put it in a database
but
cmon
its only respawn messages isnt it?
like
or just put it in their persistent data container for the time being
remove it on respawn
you can use that on a Player object?
yeah
yeag
how
Player#getPersistentDataContainer()
the same as on any other entity
player is a entity
I though it was only possible for itemstacks
You are right
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
im glad this is allowed but also wtf java
?
overriding a method with an abstract one lol
oh ok
Items, entities, block entities, chunks, and worlds all have pdc
:p
Oh and structures
So on PlayerDeathEvent, how do you get the reason why player died
hey why logic from inventory gui click does it apply to the player's inventory??
You can get the last damage cause
how get slot from open inventory
๐
I want to create customs GUI linked to a plugin, for that I will use shader but I'm finding 0 documentation or tutorial, someone know how that works ?
what
e.setDamage(0) and e.setCancelled(true)?
if you cancel you don;t need to alter damage
but if I didn't get it to work with cancel, then setDamage won't work?
did you register the event
ofc
?nocode <-
Itโs hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
will test once more if it doesn't work, you can see my code ๐
i mean technically u can also cancel the whole event
doesnt make a difference ih
just add some print statements
maybe the problem is the way you check the damager
what is the best way to change a final field via reflection
FieldUtils.removeFinalModifier isnt available in java 12+ so idrk
do I downgrade to java 8 ๐ ๐
yeah but i cant modify them if they're final
oh wait
sorry i misread
well
its a static final
theUnsafe.putObject(theUnsafe.staticFieldBase(field), theUnsafe.staticFieldOffset(field), value);
Can anyone advise on how to get a paticualr head from https://minecraft-heads.com/scripts/api.php?cat= api? I can only seem to get a whole category back? for example I want a pig head?
You can only get full categories
or more preferably, don't have a final field that you want to change
Ah okay, is there another provider who does supply direct method to a head?
the supported solution would be stripping the modifier off in a transformer with a premain agent
wouldn't the jvm just inline that since it's a constant
Ok so on initial plugin load, call category GET if local storage doesn't exist already , store locally then when entity type is killed lookup in the stored data for that entity - sound about right?
Ok might be the way to go
how do you make a player lay down on the floor after they die? for a few seconds? what packets do i have to use or how do achieve this
some of the default heads are way off the native mc ones for example pig isn't a regular pig head
Well there is no "regular" pig head
what does this mean?
you know what I mean, the standard
You could maybe send a player sleeping packet or something
Do you know how to send a packet? I haven't done that before
I haven't either
๐ฟ
why not just asBungee().getColor()
it returns java.awt.Color
not the bukkit one
likely that the awt color returns different values than the bukkit one expects then
has anyone already done this? thats public - just thinking of time saving
just looked at docs and getRGB returns argb actually
Vanilla Tweaks datapack has all the mob heads
Thanks guys
Found something - Just need to go through and add textures i guess,
Firework is an entity right?
not the JVM but javac lol
yes
ElgarL is "yes" to me? or is it to Emily
to you
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
DamageBlockedEntity damageBlockedEntity = getDamageBlockedEntity(event.getDamager());
if (damageBlockedEntity == null) return;
if (damageBlockedEntity.getEntity().equals(event.getDamager())) {
event.setCancelled(true);
}
}
So it succeeds in running "event.setCancelled(true);" but the players still take damage
is it possible to create a world that is just a cube and a structure inside it? I just need a structure in another dimension, but I don't want to create a whole flat world to do that
private void createBarooWorld() {
World world = WorldCreator.name(WORLD_NAME)
.generateStructures(false)
.type(WorldType.FLAT)
.createWorld();
}
``` that's what I have right now
put a sysout at the beginning of the event to see if it is firing more than once
not in launch, sysout at top of damage event
No, it doesn't run in the Launch event, it's just another event I have somewhere else in my code
Do as I said
I can't help if you ignore me
sorry, what should I do?
put a sysout at teh top of the damage event so we can see how many times it fires
okey, sorry :/
i added "Log.info("DamageBlockedManager");"
your logs look fine
should I try with another event or something?
declaration: package: org.bukkit.event.entity, class: FireworkExplodeEvent
you can't get teh target with that event though ๐ฆ
In this case, I only want to retrieve the entity that is "Firerocket" therefore no entity should be able to take damage from it
your code is perfect, there has to be something else messing with it
another plugin uncancelling the damage event?
or somewhere else in your code you uncancel
EntityDamageByEntity is the correct event
I only have my own plugin on the server, but can review my code and see if I've done something wrong elsewhere
unrelated question but i think i can interject here for a second
I've a small set of UUIDs that get adjusted when it's told to be adjusted (or gets regenerated), but potentially reads that set out much more often than its written to.
Is it better to use LinkedHashSets for very small (<200 entries) sets?
Do you need it ordered?
bump
no, i just need .contains
pretty sure you can tell flat worlds to generate with 'air' as its only layer
just a basic hashset then
when should i switch in that case?
This code checks that the projectile fired by the player does not damage other players, but does not see anything about it that could cause the problem. That is the only EntityDamageByEntityEvent I and the one in my DamageBlockedManager that we are trying to resolve now then
switch?
do you use any other damage event listeners?
use linkedhash instead of hash
no point in Linked
thats for iteration then?
What is an "Iterator" object? Recently stumbled upon that in mcp
lemme find the conversation
guess this asnwers that question
some people might want to iterate over it though
whats the overhead of a LinkedHashSet compared to a HashSet? anything relevant?
The ParachuteListener checks if a chicken is damaged
Both are teh same (ish) speed but Linked uses more memory. So unless you need it ordered you shoudl use the simpler HashSet
do any of your listeners setCancelled false?
like i probably dont, but this is for an api (would be accessible in classes extending it)
is iteration on HashSet not slower than iteration on LinkedHashSet? IkeVodoo said it is
I've only used setCanceled true so far when coding with events
no both are o(1)
I'm about 95% sure the best you can get for iteration is O(n)
then I have no clue why you can;t cancel the damage from teh firework, unless fireworks are bugged
or do you mean the time to obtain the iterator
in performance HashSet is slightly better as it only maintains one backing hashtable
"iteration speed" really does not matter
whatever you do inside the iterations is gonna be more costly
^
thats a fair point, i just like keeping things like that in mind
this.fireworkEntity = this.victim.getWorld().spawn(this.victim.getLocation(), Firework.class, firework -> {
FireworkMeta meta = firework.getFireworkMeta();
meta.addEffect(EFFECT);
firework.setFireworkMeta(meta);
firework.detonate();
});
DamageBlockedManager.getInstance().addBlockedDamageEntity(this.fireworkEntity);
private final FireworkEffect EFFECT = FireworkEffect.builder()
.flicker(false)
.trail(false)
.withColor(Color.RED)
.with(FireworkEffect.Type.BALL)
.build();
private Firework fireworkEntity;
um you detonate before you add to your manager
MAY be ok as it won;t actually detonate until the next tick (probably)
Regardless, something good to change, didn't think of it
it would be simpler to PDC
That sounds interesting, actually thought about it before
no manager then
I made a utility for it which I then removed :/
how does suppress warnings work?
It gets rid of the yellow
The yellow is the warning
it still is in the analysis
Could also just not use the deprecated event :p