#help-development
1 messages · Page 89 of 1
== compact, readable, works, null safe, slightly faster than equals
all of these are negligible
and you straight up copied that off stack overflow btw
for you
i saw that post a few months ago
since both can be used just let people use whatever they prefer
I already did answer it.
- it's not necessary
- no problems with null
- better performance (equal has an overhead)
- just why
yeah so
- thats not an argument
- compare constants from the left.
- no, if you know what youre doing
- its the standard
you can't say equals is the standard either. Or are you comparing two numbers with equals, too?
2.equals(2) lol
my argument is an indecisive 12 year old SO thread https://stackoverflow.com/questions/1750435/comparing-java-enum-members-or-equals
enums are a special case of funk in a language full of already funky stuff
that's like using streams instead of loops because it's "compact", "readable" is subjective and not agreed on as a convention, "works" all of them work, "null safe" is not an actual agreement since you should compare constants from the left eitherway, slight faster is non sense if u know whaat the heck ur doing
2 is a primitive type
are you okay?
you had a small argument, you just ruined it
"works" all of them work - correct, so let people use whatever they wanna use
the only difference between equals and == on enums is whether it throws an NPE or not
new Integer(2).equals(2) 😎
really no difference
that doesnt matter because you should compare constants from the left nonetheless
I know. That was part of the joke
shame triumph gui doesn't work seems so cool
so like u doin
EnumClass.ENUM_CONST.equals(getValue())
or
getValue().equals(EnumClass.ENUM_CONST)
enum first
sane method of checking i guess
null safety built in for one side at least, who knows what dirty checks exist in the .equals implementation of EnumClass tho, if it overrides
If you want a real reason, fine.
Each enum only exists once. While it is an object there is only one if each object. Every time you access an enum value you get the same object (the same pointer). Since that is the case you never have to use equals(). And doing it because it's standard is just weird. Yes it won't make a huge difference but why don't you just get used to == when .equals() is never needed
ever heard of poe's law?
give this man a /j /srs
Lol what
No, just because its initialized only once doesnt make it better to use an unsafe instance comparison operator
it's fine in this case, but not better than .equals()
cause they're equally good
haha equally
somewhat, yes
I mean you have good points
sry havent slept in a while
And I get them
sleep for the weak
lmao
thats not how it works
you decrease the framerate
not increase it
increasing the framerate will make it slower
increasing it would only make it smoother
it was hard enough getting the .gif under discords upload limit without having it look like trash
had the word in my head but not in my hands
Since it isn't unsafe in this case why would you not use it? In programming there's always a thousand ways to achieve your goals. Usually I'm "readability over performance". But in this case == is (atleast for me) more reasonable and readable than .equals()
I mean you can use whatever you like but idk why you try to convince people to use equals() when there's no reason for it
tell that to Kdenlive
up the framerate on that bitch and videos go zooooom
and yes i mean framerate not a speed slider
"reasonable"? bad argument
"readable"? subjective, and not agreed on as a convention
"no reason for it"? its the standard, using something requires a reason
kdens just shit enough to not have one and is genuinely not a fun video editor but still works and is free so i use it
how can i make a custom entity able to fly?
That's like those people that try to convince others that their own religion is better
No, religions are social constructs and cannot be proven physically
unlike concepts in code
winn go sleep dude hahaha
i gotta be up in like 4.5 hrs
what if i break your body
is it even worth it
no physical proof
sleep is always worth it
youd get me out of work for today
lol
how is it the standard? It's the standard for Objects, yes. And while enums are compiled into classes with a private constructor and static instances they are definitly not your usual object in OOP
enum values are objects
static objects that only exist once
ur comparing enum values here, not enums
So if you know the pointers will always be the same by specification it would be useless to assume they are not
that's like always calculating 2/2 instead of just writing 1 inside your code imo
sometimes 2/2 can show clarify and the intention
mhm and?
just any expression
then use 2/2 in those cases and 1 every other case
like why do we calculate 2*PI
As I already said: Use what you want but don't try to convince others to swap to something that you prefer while there's no benefit of doing so.
I didnt tell you to swap
I asked to stop recommending things, with no reason whatsoever
and to not stop doing things when you dont know why to stop
btw
Math.TAU in java when?
You are the first person I've seen that uses .equals for enums. And just because you don't like the arguments given to you that doesn't mean that .equals() is better. It's pretty much personal preference. I've just never seen anyone do it before
is having a public static instance of your plugin in your main class, without a getter for it, static abuse??
for others reading this, don't reply, this question is directed to fabsi
If you make it public you will enable others to override your plugin instance.
Why would you do that
my question began with "is" so im expecting yes or no
And don't tell me "reflection can do that anyway"
Define what "static abuse" is for you lol
i would never go with a static instance and instead pass it via DI
Nope, it's not my definition
it's a concept that's agreed on by many developers
if i have my own opinion on it then im simply wrong
Your definition seems to be to use equals for enums aswell🤷♂️
in this case there is no agreed on convention
therefore having opinions is okay
was thinking of this when i saw something in bukkit api so i questioned why it was exposed and then realized people would just use reflection to do it anyway lol
as long as you back them up
now just
answer my question please
why r u taking this long to answer with yes or no lo
I already did. It wouldn't make sense to make it public static. So the answer is yes
That's just a bad way of handling objects
You need to shade and relocate it. Its not a standalone plugin.
It is a singleton but you still wouldn't need a static variable if you use DI
I can't remember matt posting that anywhere 🤔
Whats this about
It's on the github page
.
🤔
this @lost matrix
I don't understand arrow code, I found the gradle format but thanks for pointing that out
arrow code lol
I wouldn't ever suggest using static unless it's necessary or you want to define constants.
I did that in some older plugins of mine but I swapped to not doing so
7smile do you use.equals or == on enums?
Hi, I need some help, can anyone help me?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
.equals literally does a single == internally for enums. So why bother with the extra method call?
Oh.
thank you
Guys
Benefits of == is
you wont run into NPEs
So my plugin doesn't want to add +1 lvl to items that are already enchanted.
we already mentioned that == is null safe
ok
Having a public static instance of your JavaPlugin class isnt exactly static abuse but its very fragile design.
public static should always be final. Otherwise you have no control over access.
so use it
but, items with no enchant, enchant.
I am
eminem
Anyone knows why this doesn't delete the file? The file is set because it broadcasted the name of it
show code @empty laurel
Ok
It seems more like a nbt bug
our friend 2hex says the null safety is no argument as you should compare from left
?paste actually
No
our friend
public void Transformar(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
ItemStack espada = new ItemStack(Material.DIAMOND_SWORD);
ItemStack machado = new ItemStack(Material.DIAMOND_AXE);
if (e.getClickedInventory().equals(p.getInventory())) {
if (p.getItemOnCursor().isSimilar(runaAfiacao(p.getItemOnCursor().getAmount()))) {
if (e.getCurrentItem().equals(espada) || e.getCurrentItem().equals(machado)) {
int a = (int) Math.round(Math.random() * 100);
int level = e.getCurrentItem().getEnchantmentLevel(Enchantment.DAMAGE_ALL);
if (a <= 50) {
e.getCurrentItem().addUnsafeEnchantment(Enchantment.DAMAGE_ALL, level + 1);
p.getItemOnCursor().setAmount(p.getItemOnCursor().getAmount() - 1);
p.sendMessage("§eVocê conseguiu utilizar a runa em sua ferramenta.");
return;
}
p.getItemOnCursor().setAmount(p.getItemOnCursor().getAmount() - 1);
p.sendMessage("§cFalha! Você não conseguiu encantar sua ferramenta.");
}
}
}
}```
you should compare constants from the left
https://paste.md-5.net/udezuxukal.bash - This is the error log I'm getting I don't think RedLib is conflicting but idk
if you dont then youre doing something wrong
yes
You are trying to delete everything but the config.yml?
you can do that and still use ==
I send on chat.
?paste
if both are null
Oh.
cope
iirc javac actually optimizes enum equals into == doesnt it
pff spaghetti code
so unless u really need a deep equals check
essentially its same behavoir, all enums are are integers really
yeah? does it matter? I tried getPlugin().getDataFolder().delete(); and that did nothing too
integers with a meaning
It does. Just unsure if it happens during compile time
yes iirc
.equals() is the standard for objects though? you would need a reason to use something other than it
yeah haven’t had time to look into java with its vms in the way but c++ deals with it
Any exceptions? Be aware that this will not delete folders.
like that
Console's clean
my first thought was folders with items in them but idek
im trying to delete yml files so there won't be folders
you gotta be kiddin me for not using early returns
have u tried just file.delete()
yeah take a look at the code xd
nice name method bozo
not even camelCase
ah nice
taht indentation
well if the compiler already changes it then I'd really say it's full personal preference. I'll stick with == tho.
that part is just copy paste issue probably
dont blame me lol not my code
same, 2 chars against 9
probably started copy at @ instead of the start of the line
tell that the dude who made this
??
Are you running this inside a CompletableFuture?
Fourteen, What do you mean by that? my english is so bad.
Not that i'm aware of, what's that?
I used to do that when I started coding years ago 💀
java concurrency
Well more code and more context then
thats what my teacher learnt me
didnt even know return; without value existed
bru i never early returned for like 6 years🙏
literally didnt start until someone here yelled at me few months ago
My teacher told me to not declare variables in loops and I stuck with that for a long time.
Ok, but.. How to resolve the error?
Pretty sure that nothing else is relevant
Ah another possible problem: Are you deleting the files and then creating them again?
ay using titles
so a lot of my variables had a horrible scope lol
why do i get errors in the ide when i import other classes in the project?
the errors are only visually and do not effect the package or inside the minecraft
Is trail not your plugin? Why are you performing a command for a player. You should avoid that.
it is my plugin
I'm making the player execute /trails which is the main menu (that slot acts as a go back arrow)
do you create the inventory when running the command?
#1012313792488681492 since smile is here
never mind
maybe he has a clue
think id rather try to abstract the gui handler instead of run command imo
i just reopend the ide and
yes but how is that related to my issue
well usually I have a method like openGuiX(Player p) or smth that I can call where ever I want
Anyways the problem is most probably some output stream that you have forgotten to close.
file.delete() returns a boolean. Print that out.
When I go to enchant an item, it doesn't enchant if it's enchanted,
but when it's out of enchantment, it enchants, WTF?
When you are writing a utils class...
Do you go full static methods since it doesn't have any variables and no state?
Or would you still pass an instance around?
Feels like every second day I change my mind and swap from one to the other because I dislike static but then again it's a wasted instance in memory
private constructor
no fields (stateless)
everything static
Otherwise its not a utility class
And should be handled differently
prints false
Yeah then you opened a stream and forgot to close it. The File has still handles locked in.
When I go to enchant an item, it doesn't enchant if it's enchanted,
but when it's out of enchantment, it enchants, someone help me?
then I'll stick to that now ^^ ty
okay, when are these opened? so I'll know what to look for
everything should be static
When you read/write
Usually by using an InputStream or OutputStream of some sorts.
what about like private static final constants
like maybe u want a cached Random in there or something
or regex
doesn't this close it tho
ThreadLocalRandom!
I only used @Getter @Setter and the constructor annotations of lombok so far. What are you referring to?
bru
@UtilityClass
same principle just easier to say Random
A utility class cannot be instantiated. By marking your class with @UtilityClass, lombok will automatically generate a private constructor that throws an exception, flags as error any explicit constructors you add, and marks the class final. If the class is an inner class, the class is also marked static.
All members of a utility class are automatically marked as static. Even fields and inner classes.
I think i found the issue, an unclosed buffered reader ty 7smile7
If the object is immutable and the field is final then this is fine.
Random: No. Use ThreadLocal.
random was just an example of something that would be understandably instantiated once and reused
Meh. Not my favourite lombok annotation
Hmm I don't know if I like the "make non static methods static" part. That kinda hides too much. That's why I sticked with the simple annotations that I mentioned before
yeah somewhat
and there isnt that much boilerplate anyways
I mean I can use it and declare everything static myself but that would feel weird aswell
im trying to build the 1.19.2 server jar, but it says 'started to download https://piston-data.mojang.com/.
heres the issue.
task manager says im not sending or recieving any data
yes
well i didnt use rev --latest but it said building 1.19.2 anyways
that's pretty obvious, though it doesnt require that much knowledge to "now what you're doing"
you can pretty much just google it
simple, if u dont plan on ever changing it and use it in multiple places, make it static 😎
give examples of valid/working and valid/not working nums
wtf is var
let me show you the exit lol
When I go to enchant an item, it doesn't enchant if it's enchanted,
but when it's out of enchantment, it enchants, someone help me ? (5)
4137894711755904 for example
Hey, moterius
i stg if you make that joke
stg?
swear to god
i have REALLY had enough of people joking about my handle
i made my account before that movie was announced
now I'm interested. What movie and what joke?
I suppose the movie is named Moterius, so what's the joke?
that im such a fan i made a similar sounding name
and its really, really annoying
*morbius
oh for gods sake
[WARNING] The requested profile "remapped" could not be activated because it does not exist.
scuse me
does that no longer exist in 1.19.2 or something
so the remapped stuff still got generated in .m2 ur saying?
yes otherwise you can't compile if your pom has the plugin
anyone here experienced with github workflows and can tell my why https://github.com/Luziferium/randomizer-csgo/blob/stage/.github/workflows/build_and_pre-release.yml creates a javafx application which is seemingly not a javafx application or at least not a "real" one? > missing toolkit
what script? You mean the pom entry?
yea the pom remap rebuild
I'm surprised that adoptium with JFX is a thing
was the wrong branch but i believe that its the default anyways -
I can't find the original from md_5 either rn. Just some blog
Must be a github thing, adoptopenjdk/adoptium does not ship with JFX at all usually
found it
hm, i could try zulu or corretto which should have jfx
i have a string [ItemStack{MUSHROOM_SOUP x 1}, ItemStack{MUSHROOM_SOUP x 1}, ItemStack{MUSHROOM_SOUP x 1}, ItemStack{MUSHROOM_SOUP x 1}] how do i loop through all of the itemstacks? (they arent always the same)
like seperate them
Split on ,?
If you obtained that String through ItemStack#toString - don't.
how do i get the player and way they died from a PlayerDeathEvent?
Ah, so in reality it is an array of Itemstacks and you want to turn it in an arraylist?
Arrays.asList(yourString.split(“,”))
uh
Then you have to read the strings to itemstacks
that wont work the waya he thinks
e
new ArrayList(Arrays.asList(array));
the event has some fields. you should be able to do getplayer on the event and something similar for the death type
i cant do getplayer
getEntity
hm ok
what an interesting image hosting domain
ty
wtf
getEntity
ballrape
that seems to think it's a string
https://ashgrab.shop/ guys is this legit?
no : l
getEntity should not be a string
whats the fun in passing the array there? just make a new one when u get to it
I do not understand
new ArrayList<>(Arrays.asList(new String[] {"hello"}));
still nothing
And in what way does that convert an array of Itemstacks in an arraylist of itemstacks?
it doesnt
To be honest JFX is a MASSIVE pain.
its just a wasteful line 
exactly.
Sometimes you gotta give the compiler a workout when optimizing
it is, but usually it works. built via github workflow it doesnt. thats the weird thing
Otherwise it gets lazy
gotta keep the javac on its toes
just code the bytecode yourself if you know better
I’ll just write assembly like Chris Sawyer
Recaf uses https://github.com/Col-E/Recaf/blob/master/.drone.yml for workflows I think
You cannot optimise much on the bytecode layer
you shouldnt use the toString to stora item stacks
eh fair
Unless you pass -noverify that is
whatever you do just dont do it like yanderedev
Hello, I am trying to make shop in my minigame. I am trying to make, if player have Itemstack "price" in his inventory, it will remove "price" form his inventory and give him "sword". But when I am testing it in minecrafft, it's playing enderman teleport sound, witch mean, I dint have enough coins. But If I will paste Material.SUNFLOWER instead of price, its working. But here is problem, I cant remove amount of items. Can someone help me with this?
Here is my code:
https://pastebin.com/fysthtDt
Use containsAtLeast and removeItem
do Player p = e.getWhoClicked(); pls
It’s not a player
wym
Thx, I will try it.
i'am with problems.
it is
will not solve your problem but create a static final variable for the price
someone help?
vai se fude
Caralho vc aq
KKKKKKKKKK
tu ta aqui tbm
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
?learn-java
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
InventoryClickEvent#getWhoClicked is a HumanEntity
?jd-s
It's not. It's a HumanEntity. Which is essentially a safe cast to Player at this point, but technically speaking, it's not a Player lol
?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.
?learnjava
Enfim, @golden turret , fiz com math.random, mas não adiantou nada.
tá a mesma coisa..
ta
bukkit api is so funny and quirky and weird sometimes
gringo vai reclamar do pt
Pode ir na gdd?
unnecessary necessary casting of event objects
?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.
F u
Blame Mojang for the HumanEntity stuff
true
Mojang: Let’s make HumanEntity a thing
Also Mojang: Armorstands are a living entity
I'm using ProtocolLib to get packets being sent to the client, and some of these packets just send an integer entity ID. Is there a way to get an in-world entity by that ID?
@golden turret Dude, flirt. The error is like: items that are enchanted do not enchant.
either protocollib or bukkit has a method to get entity by id iirc
dont ask me what it is though bc idk
?jd-s try looking around
they are living entities because they can have equipment and stuff
You'll need nms for the int id
?paste
Why does this method causes my server to lag for 4 seconds?: https://paste.md-5.net/ejasewacim.cs
Loading chunks
hm, that doesnt tells me what im doing wrong
Yeah, I haven't got an idea either
but thanks anyways
Yeah, I can do this without a lot of slowdown because I just need to search for players
The NMS method does that anyway
hmm theyre using corretto in recaf
GitHub Workflow
maybe that builds with uh
jfx
havent used that in so long i forgot what it was called
Any ideas?
I didn’t even know you could load chunks async on spigot
1.18.2
How can I get a random location then?
Hello guys, i've got a question. I want to create an "obsidianjail" command, where you can add the amount how much obsidian he has to mine. When i execute the sendjail command, the database will create with the UUID + how much he has to mine. Everything works just fine. But at the remove command, the player(UUID + jailcount) should be deleted from the database... I tried but there are just errors. Can someone help me fix this?
https://paste.gg/p/anonymous/1ba3f14f6c9843a7b70d7345c88d1541
The Error: ||MrIllusion issued server command: /obsididanjailremove MrIllusion
[14:46:23 WARN]: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '* FROM obsidianjail WHERE uuid=┤929bbc61-2f89-45cd-a351-84f439842832┤' at line 1||
MySQL Issue
load a certain region once and then use chunk snapshots
Can you share your sql query
Like full one
x = RandomUtils.nextInt(maxCoordinateValue) - RandomUtils.nextInt(maxCoordinateValue/2);
if(x < minCoordinateValue) x = minCoordinateValue;
z = RandomUtils.nextInt(maxCoordinateValue) - RandomUtils.nextInt(maxCoordinateValue/2);
if(z < minCoordinateValue) z = minCoordinateValue;
I'd assume that x < minCoordinateValue (same with the z thing) almost always applies
why do you have those weird symbols in the UUID string
Idk but i think its like that isn't it?
Can you just share og query
can u provide an example?
I do not think that you are loading chunks async there
And you probably want to save uuid as binary, if you don't already
new Location(world, x, y, z); at least does not load chunks
getHighestBlockAt
Sure gimme a sec
I believe it loads the chunk since you're getting the block instance
ah right lol
Although yes, it probably just queries the highmap which should be rather fast
will it work normally with int y = world.getHighestBlockYAt(x, z)+1;?
I hope thats it, what you need
Your query, not stacktrace
In Php? Or where
Assume maxCoordinateValue is 500 and minCoordinateValue is 50. Then on average x will be 250 - 125 = 125. This means that you do many computations over and over again
Your mysq query, where you call it in code
Yes that's better
We coding spigot in php now?
-5000 and 5000
For a minCoordinateValue of -maxCoordinateValue/2 (or lower) it probably is impossible to reach a settlement
already did that, its called PocketMine
It is in there
Sorry, I'm blind
it does load the chunk
-5000 being the min value?
Didn't know there were two pastes
Take a look at essentials /tpr
haha no worries xd
yes
essentials has a rtp? must be essX addition
Myeah, then the while loop CAN be an infinite loop if I am right
The chunk could also be partially/lazily loaded
Can you send line 27 in removefromobsiildian case class
You doesn't seem to send that
Doesn't say too much for me
And what is remove jail method doing
it's lagging with that method as well
Yeah as mfnalex showed that loads the chunk as well
You're just going to have to do less checks per tick
If the User exists, if should remove the UUID from the database
And spread out the checks over multiple ones
Can you share that code
And when im adding it, will create the player
https://paste.gg/p/anonymous/1ba3f14f6c9843a7b70d7345c88d1541
isn't it in there? _D
RemoveFromJailCommand
It's really hard to look when you send 10 classes
They are using Paper methods, I want to do it using only Spigot API
PaperLib delegates to spigot if it is on spigot
Mhm
ok, I'll try it, ty
yes, that is called mysql query
first dont save uuid as string
and use prepared statements
This JDBC Java tutorial describes how to use JDBC API to create, insert into, update, and query tables. You will also learn how to use simple and prepared statements, stored procedures and perform transactions
also this ` might be cause for sql syntax error
It does not work at inventory
You mean cant move items?
Probably the InventoryClickEvent
Then its InventoryClickEvent
When i use those inventory events the events not triggering
@EventHandler
public void onDrag(InventoryClickEvent e) {
CustomStacks.addingComponents();
if(e.getCursor() == null) {
System.out.println("AAAAAAAAAAAA");
return;
}
for(CustomStack stack: CustomStacks.list) {
if(e.getCursor().isSimilar(stack.getItemStack())) {
System.out.println("BBBBBBBBBBBBBB");
e.setCancelled(true);
}
}
}
uh what was groupid again? io.github.<name> or <name>.github.io?
https://goksi.tech/ something along those lines
probably inventory move item event
Spigot has slf4j-api shaded in, right?
Could you make me an example please? Cause im too dumb for that haha
What
@EventHandler
public void onDrag(InventoryMoveItemEvent e) {
e.setCancelled(true);
}```
its on man
it is man
?stash oh right, I can check that myself 🤦
InventoryMoveItemEvent is for hoppers
craftbukkit has, yes
I want to prevent player to move anything from normal inventory
ClickEvent and DragEvent, yeah
anyoone has concepts to learn about?
also mfnalex do u have a take on #1012313792488681492
🤓
no idea
what are you trying to do
like one social media that everyone uses
get a color from a string, I have this string String color = "WHITE";
And I want to get Color.WHITE
Color.valueOf(color);
I am attempting to send actionbar messages using spigot 1.18.2 using:
player.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("This message will be in the Action Bar"));
But there is no such thing as ChatMessageType
that method doesn't exist
nah, looks like you would to do switch/case yourself
no
its a static variable
bump
give me the class import
ok and ?
import org.bukkit.Color;
dont do that
player.spigot().sendMessage(...)
for what reason ?
cuz i said so
inefficient and boringg
¯_(ツ)_/¯
you have no other way
or look trough all vars and match toString
nah bs there must be a way
reflection or switch/case, i see no other way
That doesn't matter since ChatMessageType is needed there aswell
What's reflection
an enum like this
believe me, its better to use switch/case
slowing down your descent into madness since you have to rewrite less
int r = ChatColor.valueOf("RED").asBungee().getColor().getRed();
int g = ...;
int b = ...;
Color bukkitCOlor = Color.fromRGB(r,g,b);
but that's deprecated
o its the bungee one
BaseComponent[] component = TextComponent.fromLegacyText(Main.getInstance()
.getString("Messages.SuccessfullyCreated"));
Arrays.stream(component).forEach(c -> c.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, key.getKey())));
player.spigot().sendMessage(component);
this is how i do it
it should work
actually no
mfnalex thats a pain to do
u will have to get the green and blue of each color
and theyre constatns anyways so
anyways
just make an enum 🧠
Hold on, for some reason my Spigot API is missing the bungee-api parts it usually is ment to have?
Where could I download bungeecoords api?
I know, the Color class is weird. One liner would be using reflection
public static Color fromName(String name) throws ReflectiveOperationException {
return (Color) Color.class.getDeclaredField(name).get(null);
}
this is not part of bungee api ?
It is. Figured it out already x)
nice 👍
Spigot uses some parts of the bungeecoord api.
@hazy parrot ur website dude
its so fucking
amazing
god
how did u make that?? this makes me want to learn front end
I'd probably do it like this
public class MyColor {
private static final Map<String, Color> COLORS = new HashMap<>();
static {
for(Field field : Color.class.getDeclaredFields()) {
if(field.getType() == Color.class) {
try {
COLORS.put(field.getName(), (Color) field.get(null));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
public static Color getColor(String name) {
return COLORS.get(name);
}
}
its a library actually
particlesjs or something along those lines
but thanks 😄
why use reflection for constants...
so that it will also work when new stuff gets added or stuff gets renamed or whatever
I mean it only gets the values once
and then saves it to a map
Damn it is pretty clean
it wasnt updated in like
8 months
and the latest updates didnt add much
just changed some internal stuff
man this is so annoying
It's a very cool library, I'll have to do something like this for my own website. It's literally just one sentence on a page that I left untouched for like 3 years lol
i really wanna play 1.19
I hate particlejs
why, its cool
the math behind it isn't cool at all
its not laggnig ?
People abuse it
Everything being abused isn't good, right 😄
Gotta write your own impl that's 10x slower and looks ugly
packets
let them lag out themself
also 1.16+ the particles should be only clientside anymore
lol
Not talking about that lol wrong convo
Unfortunately I’m not qualified or understand enough to give suggestions, stay determined!
is there any particular reason for why the InventoryClickEvent sometimes doesn't make anything, when i left click a bit fast?
yeah
listen to InventoryDragEvent
if you move the mouse a little while clicking, it's considered a DragEvent, even if you only touch one slot
np
I use this to detect whether the drag affects the upper inventory or not
just in case you need that
i'm updating an item whenever it gets moved from a chest to player's inventory
so that should be useful
I hate that that fires the drag event
same
yeah it sucks
tasks {
assemble {
dependsOn(shadowJar)
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
withType<JavaCompile> {
options.encoding = "UTF-8"
}
shadowJar {
val relocate = "net.shibacraft.simpleblockregen.libs"
relocate("net.shibacraft.api", "$relocate.shibacraftAPI") // this
minimize()
}
}```
how do I relocate a dependency? if I run with shadowJar it would be like this, but I'm compiling this project as a library in jitpack and it doesn't relocate, what should I do to relocate the package that is inside shadowJar?
Was such a pain making a custom inventory due to that
actually that looks correct
does your shadowJar task run at all?
if I run shadowJar yes, but the problem is that I'm using this project as a library in jitpack and it won't relocate as it will use another way of compilation instead of shadowJar I guess
what happens if you move shadowJar outside of the tasks things?
try something like this. no idea if it works
tasks {
..
}
shadowJar {
...
}
artifacts {
archives shadowJar
}
plugins {
id("java")
id("maven-publish")
id("com.github.johnrengelman.shadow") version ("7.1.2")
}
group = "${project.property("group")}"
version = "${project.property("version")}"
plugins.apply("maven-publish")
plugins.apply("com.github.johnrengelman.shadow")
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "${project.group}"
artifactId = project.name
version = "${project.version}"
from(components["java"])
}
}
}
repositories {
mavenCentral()
maven("https://jitpack.io")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}
dependencies {
implementation(libs.shibacraftApi)
compileOnly(libs.spigot)
compileOnly(libs.lombok)
annotationProcessor(libs.lombok)
}
tasks {
assemble {
dependsOn(shadowJar)
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
withType<JavaCompile> {
options.encoding = "UTF-8"
}
shadowJar {
val relocate = "net.shibacraft.simpleblockregen.libs"
relocate("net.shibacraft.api", "$relocate.shibacraftAPI")
minimize()
}
}```I have it like this right now, if I put it outside, it gives an error
It's ok, but for example for this, which is the first time I do it, I don't know how it works with jitpack :l
tbh i'd just open an issue on their github https://github.com/jitpack/jitpack.io/issues
whats the issue
in their FAQ they tell you to open an issue if you have a any question
how to run shadowJar when deploying over jitpack
thx, i will ask
tried a JavaExec task?
JavaExec? i don't know what it is
but I don't know how jitpack works, I mean, maybe jitpack compiles the project in a different way and that task is useless. I will open a thread where alex said to see if they give me a solution or I will ask jitpack support who might know
how do i turn string "ItemStack{MUSHROOM_SOUP x 1}" into an itemstack
Format the string to remove the unnecessary strings, split it to grab the material name, then the amount
Might differ if you have also itemmeta on it
But the thing I recommend is to serialize properly the itemstack
So you can properly deserialize
what is serialize
Transform an itemstack to string
But properly with all info
And in a properly way to quickly deserialize
Add fly controller to him
hava a look at entityBat class
also Leash event for smoother movement
is it possible to cast a object to a certain version of bukket, then its current version?
nms ?
thatd probably do it
just came across it
they can all fly and blaze seem not to have a fly controller
if you leash a cow u are a leash holder
Why do some spigot versions only work "up to" specific java versions and is there any workaround?
I also wonder, it's weird
I know that you can skip the buildtools check, but I dont think you can easily skip the check when running the actual server
but tbh if you have java 8 and java 17 installed, you can basically run EVERYTHING
there is no spigot version that wouldn't run on either 8 or 17
yeah java 10, best version ever lol
i think on my macbook I got 6 different versions
I have at least java 8, 11, 14, 15, 16, 17 and 18 there
java 11 is what macOS came with
how do i write something on the boss barbtw
menawhile they don't include java anymore and link you to the java 8 download
Player.Spigot#sendMessage(ChatMessageType, Component)
oh mb
bossbar
you have to create one
Bukkit.createBossbar
then add the player
I usually keep a Map<UUID,Bossbar> of all bossbars if I need to change the text later on
Right, that should work ig, thanks
quick mnemonic: 1.17+ works on java 17+, everything else works on java 8
so much easier to handle playerdata if you create a player wrapper
How can i make a player ride a clicked armorstand?
I wonder what happens if you try to set entries in the PersistenDataContainer on a different thread.
Does it work? Or does it throw an error?
some versions between mc 1.12 and 1.16, i dont rec all which, run another java than those two
So if I have a 1.12 plugin it should be compiled to java 8 and if I have a 1.16 plugin I need to compile it into java 16 right?
Because a friend is arguing about that a plugin compiled with Java 8 can work on 1.19
That does work
Hmn
thats because java mostly only adds stuff, so its almost 100% backwards compatible
the server itself has to run on the corresponding java though
and you cant comiple a 1.12 plugin using java 17
I have a few plugins on spigotmc which are compiled with Java 8, but work for 1.8.8 - 1.19
how do I change the pitch and yaw of the default spawn point?
Weird
iirc you can add those as parameters four thorugh six
How litch
is there smth as Bukkit.setSpawnLocation?
theres a command yes
It seems just 3
get Server(). SetSpawn()
Or smth line that
maybe its exclusive to the teleport command
no, they all run fine using java 8
You can though 🤔
Probably
ofc you can. 1.12 even runs using java 17 without problems
Mfalex can u explain me that versión ing between java and spigot?
Yes, already did something similar by accident
the only reason it wouldn't work is if you have a Java 8 server trying to run a Java 17 plugin
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#setSpawnLocation(org.bukkit.Location)
declaration: package: org.bukkit, interface: World
Oh I see thanks
ah yes thats why i said it wouldnt work
1.12.2 works fine on java 17. 1.16.5 however complains that it needs java 8 to java 16
retrieve the spawn loc, change yaw and pitch and set it back
my server host says 'select version' which forces me to select java 8, 16 or 17 for the corresponding server jar
I am 100% sure that everything between 1.8 and 1.16 works fine on java 8 while everything 1.17+ works fine on java 17+
as said, java 8 works for 1.8 - 1.16 and java 17 works for everything 1.17+
1.17 required java 16+ but also works fine on java 17
(and java 16 is EOL anyway)
how can i make a custom entity fly?
using path find
im guessing here but
make a flying entity path find
then try to force the entity to follow that path
Still lagging: https://paste.md-5.net/doxofipebu.coffeescript
im using a blaze? is that possible?
^
Is it possible to compile java 17 code to a java 8 jar while using stuff from > java 8 versions?
i dont think so
no
java compiles to jvm bytecode
take a look at NMS' Blaze.BlazeAttackGoal class
sucks
no
however there isn't really anything in java 17 you couldnt do with java 8 code
it's just a bit more writing
ofc but now i have to change everything
i already did
What an epic idea to clamp java versions for spigot
But a java 17 jvm will be able to run a java 8 jar right?
yes
ofc
yea ok, just wanted to be sure before wasting another couple hours
there are VERY VERY FEW things that are not possible with higher version JVMs that were previously possible
e.g. accessing Unsafe without reflection IIRC
already did, still cant find a solution
is my install botched or am i being an idiot again
what are you trying to override?
right
methodsAreAlwaysLowerCamelCase
orRatherShouldBe*
why the fuck did I write my own plugin name in lower case
lol
Is it possible to check if any part of a player's bounding box is visible to another player without sending out multiple ray traces? I was thinking about sending one for each corner of the BB but didn't know if there was a better way.
That's not guaranteed to work either
If only the center of the player is visible that would fail
True 😅
to be fair
tnt just throws 1000 rays
its not THAT hard for a modern computer to do something similar
just spread those 1000 rays over the bounding box of the player youre trying to check for
So i can compile spigot plugins from 1.13 up to 1.19 using java 8?
And what about the error from spigot which told you on 1.19 that you are compiling it with old versión
This runs way too often for 1000 rays 😂 I could probably just use a few dozen rays and see how much of a performance hit that gives.
maybe you can do it on a separate thread off the main thread
Hello. Why does my code causes the server to lag for 4 seconds every time it executes?: https://paste.md-5.net/anaxiguqen.cpp
The line that causes this problem (I don't understand why, cause I've already loaded that chunk asynchronously, so there shouldn't be any problems): int y = world.getHighestBlockYAt(x.get(), z.get()) + 1;
I'm using PaperMC 1.18.2
Good idea, I'll look into that
store activation time in that
plus cooldown time
then if its tried again check against that
system gettimemilis
plus cooldown in seconds times 1000
thats your bar
Ditto i can help you
But wait some minutes I need to turn on pc
But more or less could you understand?
Ok
1 first question
Please tell that you know how works java atleast and the learnt the lang before
Because if not its like talking to you in chinese
You wont understand anything
Not wondering to sound rude
Are you spanishP
Because im also Spanish and i can help you vía dm in spa ish
Because here we must speak english
Ok
Perfect I will dm you
Your welcome
how do I set the progress of a bosses bossbar
like a bosses natural bossbar not one of my own bossbars
I tried boss.getBossbar().setProgress() but that doesn't actually change the progress of it
try changing their health
I want a wither to spawn with half health but I want their bossbar to show that they have full health
Any ideas?
double alll damage they take
wwithehrs at half health have a "shield" for a lack of a better term
so I want the wither to spawn with the shield (they have to spawn with half their max health) but I want the bossbar to not show that they have half health
and I also want them to have a bossbar
cant u hide their bossbar and make a custom one and link that bossbar to their healt
You might be able to hide their bossbar and create/link your own
I guess I can do that
i dont think there's an easy way to get existing bossbars of a player
I would just make a Map<UUID, Bossbar> bossbars = new HashMap<>();
tf are you doing with player bossbars in the first place anyways
yeah for your own bossbars, but I thought they were talking about removing existing ones from other plugins / vanilla ones
although since 1.16 or so, Bossbars are Keyed
and you can even do Bukkit.getBossBars()
this definitely wasnt possible a few versions prior
Hello, does anyone know what version the Consumer class was introduced in? I think it was 1.11 but I'm not sure.
8
Lambdas and funct interfaces are interduced in 8
Well certain classes like Runnable was introduced earlier
but yeah java.util.function is all java 8
spigot has its own consumer class smh
Oh I was talking about the spigot one
oh been there since a very long time
I tried using it for 1.8 but I've been getting noclassDefFoundError
Yeah it wasn’t in 1.8
anyone has an idea?
bump
reinstall mc smh
How are you using that method
which one
Oh sorry I trough you are another guy
Which method return compfuture
what do i use for player#canSee(Entity) since its deprecated
It’s deprecated since it’s draft api
Yeah ok Consumer appeared in version 1.11
it's draft api, meaning "it's new and might change"
but 99% sure it will not change
is it possible to kill a entity with a given itemstack? exactly like Block#breakNaturally(ItemStack)
like imagine a sword with sharpness or looting.
how do i calculate the armor points
more info, you see the armor icon above the hearts, i want to calculate that.
well idk how to do that but i found a guy that made a method to calculate the damage reduced with the user's armor
doesnt help 😢
Hi, I tried to complete the plugin build but it gives me this error (I think it's about "OnEnable" and "OnDisable")
How can I solve?
Thank you! ❤️
damn you're the second one with this problem today
looks like someone released a shitty tutorial in the last days
methodNamesAreAlwaysLowerCamelCase
thatsAPrettyLongNameForAMethodButAtleastItDescribesItWell
oh you havent seen my exception names