#help-development
1 messages · Page 861 of 1
maybe has("password") or something
is jObject.get("password").getAsString() exists
idk
How can I check if a path belonging to a yml file is a config section or not
isConfigurationSection
Thanks 🙂
singleton abstract classes aren't possible, right?
how?
public abstract class Test {
public static final Test INSTANCE = new Test() {
//...
};
private Test(){}
}
yeah but the new Test() will create a new object?
I mean yeah, that's a singleton. Having at maximum one instance
There is no point in abstract singleton
idk what you're trying to achieve
Hi , can others use ( login ) my uuid if they have my uuid ?
Every uuid is public
the point of abstraction is the disconnection between declaration and definition
if you're making an abstract singleton it basically is declaration & definition
thus it doesn't make much sense
i have classes that are the same that are singleton and i dont want to write the code for each one, therefore i was thinking to inherit the code
i knew but can they login with my uuid ?
Then make child classes singleton, not abstract one
You can instantiate an abstract class?
well if you think about OOP you can just inherit a parent that has all the commonalities and make the constructor of your subclasses private and deny any more inhertiance
yeah
in fact you can overload any object
Yes, same as interface
what do you mean ? because you said if get uuid can login with my uuid
Damn
i guess i could make the child classes singleton but then i would have to write 4 lines of code each time :/
I mean it's not really abstract class object
Object object = new Object() {
@Override
public int hashCode() {
return 31;
}
};
But a anonymous class which extends abstract one
Damn
When I said that
well that's the pain of java
boilerplate and verbose code
Wait, anonymous classes and functions are just those without a name?
Hence ANONYMOUS xd
lmao
Lambdas are syntax sugar for making anonymous class
as long as you don't end up in callback hell ig
Thats paper api
It is?
Cancellation states like that are
if you check out the new minecraft source code, it is full of lambdas and callbacks
the legacy code wasn't like this, but the new are since it got into fashion
no they aren't
But thats fine, we have computation builders like monad patterns to avoid that pretty much
how do i make sure there are aliases, there is not hasAliases method? (yellow because of NPE)
well the NPE is possible because getCommand might be null
you can safely use Objects.requireNonNull(getCommand(label), "Do not edit plugin.yml manually oyu imbecile!")
no, its a message for admins
sometimes they think it's a good idea to change command names and aliases by editing the plugin.yml in the .jar
this might work fine if they only change the aliases and stuff like permissions, but if they change the actual command name, then ofc getCommand("mycommand") will return null
so you can tell them to not do it if getCommand returns null
oh
alternatively just use an empty Objects.requireNonNull but I like to leave this warning for stupid admins lol
Thats why you register through the command map :P
Is this exposed on spigot??
No but it's like one method handle
Tut tut tut
Actually 2 cuz you gotta reflect plugin command
But like still
can you use #getCommand(command) also with one of the main command's aliases to get the command?
i doubt it
hey so, i have this scoreboard code that makes certain player able to see life, which works perfectly, but now, i want certain other players to see a certain value on the below name slot. For instance, every player has a value assigned to him (a string value) and what i want is to display the players value on top of his head.
basically more nametag lines?
or do i understand wrong
there is a below_name slot. here this code displays the health value.
i want to code it so that it doenst display the health value, but a custom String assigned to each player
yeah basically you want more nametag lines?
?no?
im using the Below_name thing with scoreboard, i wanna use that
oh mb so yeah
yeah, so i might be wrong, but as far as i know you can display stuff there but with the compromise of there always being a score a heart or whatever minecraft display type you use
i think if you want to freely create nametag lines with all the stuff that you want to type there, you would need to create fake nametags with armor stands or textdisplay
you still here?
yeah i read what u wrote
ok so
what if i want it to be like this for instance :
PlayerName
1 stone
1 being the custom int i get from each players assigned value
and stone being the custom String value each player has
i think that is possible
Criteria.DUMMY
there is a string i think, and the number 0 next to it as the score
i would recommend creating your own nametags, its more customizable and less of a headache than this, but you could try the criteria
ok so, for instance would this code to show the X coordonate of each player work?
i dont know you can try, if it doesnt work, im here to help :)
ok so i achieved to show the player each players coordonate, by modifying the score.
But i have NO IDEA how to modify the displayName of the objectif for each player
cuz if i juste do setDisplayName it will change it for everyone
tbh just code your own nametags its much less of a headache, if you still want to stay with scoreboards, im not really able to help you as iam not super experienced (with scoreboards)
the problem with nametags is that all players can see it right?
no im talking about your own custom nametags, if you would do that and design a proper system you can have as many nametags as you want
and code everything as you like
OK so with ur name tags could i do that ONLY 1 player sees every other player with the name tag PlayerName and a custom string that is different for every player?
you can do everything, you can let one player see not nametags at all another see different nametags and one see everything normal
OK so then, i d need to use packets correct?
packets are safer, as if your server crashes these nametags would be gone too
if crashing is no issue and you dont care having millions of armorstands after a crash floating in the air you could use the api too
ok so one other question. TO use packets like PacketPlayOutPlayerInfo what do i need to import?
Cuz when just importing PorotocolLib API i cant access it
what else do i need to import
i dont know all the imports it depends on what you are doing with the packets
what exactly happens when you are trying to use protocllib
but i think i saw somewhere i had to import smth like CraftBukkit or smth
i wouldnt recommend using nms
why?
you should use protocollib
?nms
what do you even need that packet for?
idk he told me to use packets
i didnt tell you to
for what?
i told you what happens if you dont
.
i want just 1 player to see everyone name tag like :
PLayerName and next to it a String that is specific to each player ( that i get from a hashmap )
i'd use a displayentity that has a custom PDC tag so you can delete them if they're accidentally leftover
like i create an entity displaying it?
i want to alter the display name, not just show smth next to it
yes, just spawn a TextDisplay
oh then I misread
i want to alter the players display name, no way of doing that?
wait
i only saw that you were talking about "leftover entities" or sth so I thought you wanted to use packets instead of creating normal entities for holograms
Player#setdisplayName() is a thing would it work?
Does it change it in chat?
cuz i want just 1 player to see those custom names
so were back to my old question, what do i need to import to use
Not in vanilla but chat plugins would use it i guess
?nms
imma be honnest , i dont really understand how to import nms
or are you using gradle?
nah maven
did you read the blog post?
but usually i just modify repistory and dependency and thats all
yeah
yeah but the whole maven part i dont really get
which part exactly don't you understand? I mean it tells you to run buildtools, then it tells you what to add to your pom, and that's it basically
ok then, to start, where do i run the buildtool
- Run BuildTools with --remapped flag
- Add the specialsource plugin (the <plugin> thing) into your <build><plugins> including that config
- Add the dependency for remapped-mojang
im kinda confused tho how does buildtools register the nms into your local repository
doesnt matter. anywhere on your PC
btw: latest buildtools has a GUI now
what do you mean anywhere , in my cmd for instance?
- download latest buildtools
- run it with double click
- select version, and select remapped in the settings
- click compile, wait until it's done
- now you can move to the stuff where you change your pom
be sure to check this
like ok when i click it, i have this? no download or anything
yeah tbh the download link is quite hidden in the text
found it
I said thousand times that the whole article needs to get yeeted and replaced with a simple
"Download BuildTools here: <link>"
ok so its compiling
did you check the remapped flag?
this?
yes
ok good
yeah :P you can see their args at the top of the console
then you can now wait 3 minutes
yes
i dont have to wait until the end?
https://paste.md-5.net/iyilewoquf.xml here is my current pom
well you can't use it until buildtools is done but ofc you can already start changing your pom
what do i need to add
read the blog post pls
you need to add the specialsource-maven-plugin into your <build><plugins> section
and then you have to change your spigot dependency to use artifactId "spigot" with classifier "remapped-mojang"
the whole
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc
1.18.2-R0.1-SNAPSHOT🫙remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc
1.18.2-R0.1-SNAPSHOT🫙remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
thing?
yes
i get this error : org.spigotmc:spigot-api🫙remapped-mojang:1.20.2-R0.1-SNAPSHOT was not found in https://repo.dmulloy2.net/repository/public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of dmulloy2-repo has elapsed or updates are forced
https://paste.md-5.net/vigaziqami.xml here is my pom
as I said, the artifactId is spigot and not spigot-api
https://paste.md-5.net/vomilapeze.xml
i did this and now have those errors :
Could not find artifact org.spigotmc:spigot🫙remapped-mojang:1.20.2-R0.1-SNAPSHOT in dmulloy2-repo (https://repo.dmulloy2.net/repository/public/)
has buildtools finished?
no, is that why?
yes
ok ill get to u when its over
wtf
the purpose of buildtools is to create that dependency and install it on your computer
then you probably used one of those "illegal repos" that host the spigot dependency
or you've been using paper's gradle plugin that basically does more or less the same as buildtools
now you can reload your pom
and then you're done
although I see that you still haven't properly read the blog post because your pom is still incorrect
oh mb the version
I see. you have added the whole remapping part into the maven-shade-plugin
that's wrong
this is one <plugin> section
you have only copied the executions part and pasted it into another plugin
i just installed it locally
thats all i remember
then included it in dependneis
yeah well installing locally = running buildtools
oh i see
all of the selected text is one plugin. do not just copy parts of it and put it into another plugin - copy/paste the whole thing
yes sure, mojang maps
ok it ran
aint nobody wanna deal with a() b() c()
thats what i worked with 💀
RIP
mojang maps give you proper method names, and they will be consistent over updates
Ok now its installed
but I wasn't that knowledgably prepared anyway
like
the most I did was send an action bar
since 1.8 doesn't have that
yeah 1.8 api lacks many things
and mojang maps are only available in spigot 1.17 and newer
so now , if i wanna send custom packets to a certain player to change other players nametag, what do i do?
cuz what i see online tells me to use PacketPlayOutPlayerInfo
do u know how to send PacketPlayOutPlayerInfo ?
Okay so PacketPlayOutPlayerInfo is the old name
check out this tutorial, it will explain how you can find out the correct name:
?switchmappings
dw it's short and easy lol
dude you really need to learn to properly read
you always just read 30% and then wonder why you missed certain steps
bro i just did what i saw here
then why is your search bar in your screenshot set to Mojang and not Spigot?
cap
ok mb i didnt see it
if you would just read my tutorials (read EVERY sentence in the correct order), then there will be no questions left lol
if however you just take quick glances at the code snippets or the screenshots, then ofc you'll miss all the important information
ok what am i dont wrong then..
hm seems like PacketPlayOutPlayerInfo isnt the correct spigot-mapped name
where did you get that packet name from?
from a spigot forum
it's for <1.19.3
Ohh yeah ok i found the packet i need to use
do u know how to send them ?
you can try to use ClientboundPlayerInfoUpdatePacket, maybe that's the correct one
(that's already the mojang mapped name)
yeah i figures
figured*
Like for instance, if i wanna try smth simple, like putting everyones name to red
as I said, i dont know which packet you need for that, I haven't messed with changing player's names. I can only tell you how to setup mojang maps (which we did now) and how you can use that website to translate the PacketPlayOut... names into the proper names
Java or spigot has some limitation in the JAR? I am making a POST request in my plugin and testing the jar in a Test class everything works fine but inside the server (localhost) no, I don't have a cloud server at the moment so I can't test it there.
probably windows firewall?
spigot doesnt mess with outgoing http requests or anything
ok.
i might
have done a lot for nothing
@tender shard if i wanted to add a prefix to a player name (or suffix) would that require packets?
i think you can do that with scoreboard teams
so i put all players in teams and create a prefix for each team?
Yea
wont that have any repercution on the game?
no
ok and that will change it also on top of the players head? or just in tab
just create one team per player, set each team's prefix/suffix to whatever you like, then set each team's Option.NAMETAG_VISIBILITY to "for everyone" https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/scoreboard/Team.html#setOption(org.bukkit.scoreboard.Team.Option,org.bukkit.scoreboard.Team.OptionStatus)
declaration: package: org.bukkit.scoreboard, interface: Team
oh wait
i think it should work for the name above the head too
but then i have a problem
i want only 1 player to be able to see this prefix
or suffix
then add these 2 players to one team and set the visibility to "only same team"
yeah but i cant put 1 player in different teams right? cuz i want to make this 1 player see everyones teams
players can be in multiple teams
wait ok that would help me a lot
you would create one team per player and set all their visibility to "same team", then you take the special player and add them to all teams you created
i need to create 1 variable per player or how
Quick question: Adding to a location does NOT give you a copy, right? It gives the original one?
How do You get a player instance, if the one using the name is deprecated. And since that, you can't get the uuid
Yes
It’s deprecated cause names cna change
Not because you shouldn’t use it if you absolutely need to
I perfecto understamd, buts is clown that. Becuase how do You get uuid if You can't player object with his name? 🤔🤔
You have to get it by UUID. If anything you can't, and the player has been on the server before, you can loop over the offline players on the server and filter by name. Then grab the first from the filter. Note that this is unsafe, since (as mentioned before) names can change
What are you trying to do? It seems like your design has a flaw or your approach is bad practice
why?
correct
Again
u told me to create one team per player
Nope, i havent seen any plugin where You ban players by taking his uuid as an argument for banning. Have You? I mean i don't see that really good approch
yes. I would use a Map<UUID,Team> to store the teams you created
Most of time i ask why spigot does weird things on their api
Use the Mojang API to get the UUID by a current player's username --> https://wiki.vg/Mojang_API#Username_to_UUID
Again
Spigot already has API for this
It was deprecated cause names can be changed now
Not because you shouldn’t use it
Right thanks. Why isnt already implemented on api? More reasons for not using public apis
so doing just this wont work?
But you should prefer uuid when possible
Oh really? I was unaware
It is
i'm lost Jan sorry
I mean getOfflinePlayer has always done this as well as the new PlayerProfile stuff
So i use get player vÃa name without any issue. Thanks
oh and also, there would be 1 problem with what u told me to do. I want just 1 player to see teams, but then everyone would see His team too
thanks to spigot i have yo disable the shity deprecated warning

Yes, if there is no other way sure
Does "Bukkit.getPlayer(String s)" provide this?
You’ll encounter that a lot more
No
getOfflinePlayer or smth
SO for getting player what do i use 
Use PlayerProfiles though, there you can control it a bit more
Depends
Offline or Player
What makes sense in your application
For example a banning plugin, they use Offlineaplayer right?
Well, it could do
Damn, I have been making http requests to that endpoint on the Mojang API my whole life and there is a method for it? Damn...
declaration: package: org.bukkit, class: Bukkit
But You have told me that getPlayer name is deprecated. How i would it be a "could be"
Again, you should prefer ways in which you do not attempt to ban with a name of an offlineplayer. In most cases it will be just fine though
So i can just vÃa name get offline player and ban it. Isnt that ok?
In most cases that is just fine
Right thanks i was asking about that.
yea prob is that
What does that last line say?
windows by default makes you use ondrive
Desktop is onedrive by default
Or do what I do and yeet onedrive
Can I somehow create a Proxy class that'd have it's methods invoked without using an actual class instance? For example I just input "Map.class" and every method invocation of that class of any instance is delegated there
?
So that I don't need to input an actual instance to the Proxy
I explained it
Have the Proxy class have it's methods invoked
On any instance of the given class
Why
Without passing in the class' instance
Is it possible?
Probably?
A lot of things are possible
With a lot of dark magic
Next on the todo list. More obvious error messages.
Then how?
Give us a good reason
make it red and fat
and put a fat ERROR!!!!!!!!!!!!!!!!!!!:
I had a screenshot of a potential error message format in the GUI thread.
For example any method on any Map class will be invoked on that proxy instance
Without giving any map instances to the proxy's creation
So it has to find all map instances
Seems like ur trying to do something useless
That’s probably a lot
It was just an example
That's disrespectful
No
I mean I’m sure you could find all instances of a given object at runtime
But like
Why not just... Extend HashMap
😩
Because it was just an example
Dynamic classes
¿
I'm unfamiliar with term dynamic class
Does anyone know?
Give us an example on how it would work with some pseudocode it seems weird
Thing you explained earlier is basically done by extending HashMap
I literally explained exactly what I wanna do
Then you have solution
I'm asking you for the advice
Shadow you gotta remember not everyone lives inside your brain
Why the fuck would I be asking that question if I could do that?
Are we like
Why ask me that 
How can I get offline players from all servers with bungeecord?
That is only thing I can think of when I hear term dynamic class
Well no, I just wanted to implicate that the classes are not the same so nms stuff
Different names
plugin messages
But that requires a player on each server
Otherwise something like redis
messages?
?pmc
You could send a list of player nicknames
Through this
Seperate them with like ";"
Can’t you just handle the bans on the proxy
And then find the one you wanna ban
But why? It's pretty non sense. You would need to go through every object in memory and get them.
You people really have no idea how this dark magic works
Google probably does!
Yes, it's completely possible - what the hell even is the point of using a Proxy class then? Just beware that if you wrap an HashMap, it will be proxied as a Map - not as a HashMap
If you are really unsure chances are you can easily generate the needed code via ASM (or comparable) - the code can then be dynamically loaded via MethodHandles.Lookup#defineClass
Did you forget to reobfuscate your jar file?
If so, you are out of luck - this is spigot, not paper. In paper world you need to use paperweight and as such the procedures differ.
how can that even compile?
Please don't say you are using reflection in this day and age
eclipse compiler will give you the option in a silver platter to compile even if there are errors
That would throw an assertion error iirc
Well you're wasting your own time and that is basically all
Making use of Mojmap will allow you to develop like everything else without risking any typos and having to wrangle with obfuscated names
?mojmap I don't know if there is a command for that though, but does not hurt to try
?nms
Yeah
oh god, don't tell me you are using your IDE to build your stuff
Sadly we do not have AW/AT/whatever access in runtime.
Would be cursed anyways
mojang's official deobfuscation mappings
it breaks with every update
Compare different mappings with this website: https://mappings.cephx.dev
Technically you can get away with not updating sometimes
But I guess that also applies to reflection
The objects would all be created after the interceptor
So it’s not every object in memory
Well it is
All of the given instances of a class would only be created after the interceptor
?paste
Im having an issue:
My vein mine code for a pickaxe isnt taking away the tools durability. Any reason why?
https://paste.md-5.net/ojizobuzip.cs
Notes: There is no error, but it just doesnt account for durability when breaking a tree.
I thought that breakNaturally would break it naturally, and account for the tool used, but It doesnt seem to be.
The tool parameter is used for calculations with enchantments. It won't change the durability as the parent method #breakNaturally() just breaks the block and spawns the item.
I see, how would I simulate durability then, that is also affected by the factors of:
- The tools durability enchantment level
- If the tool has the unbreakable stat
You could try using Player#breakBlock()
Ill try that right now
This works, thank you!
you dont need the minecraft-server dep
you need a spigot dep
read the blog page again
you dont need it
all you need is the spigot dep and the special source plugin
have you ran buildtools
with --remapped?
?paste your pom
no
craft server is the craft bukkit impl
for the actual entity EntitiyPlayer is the spigot mapping, ServerPlayer is the mojmap
And now im even more confused.
After doing the change, I then made slight improvements to my code.
https://paste.md-5.net/afeziracej.cs
Now, sometimes only 3 pieces of wood get broken, sometimes it only goes up to where the leaves come, its not breaking all the wood.
Any idea why?
Notes: EnchantmentManager is just the handler ive created for custom enchants in the plugin, that code works and the main issue is in veinMineWood.
Keep in mind Player.breakBlock will fire another block break event
Hm. okay.
Location is mutable. You need to create a copy of the location when performing arithmetic operations through the clone method
Depends on how you get it
I swear 95% of all location related issues stem from location being mutable
So I need to clone the location first?
Then add onto it
Try if that fixes your issue
Player.getLocation doesn't or didn't in legacy versions at least
Idk why the code would be inconsistent
Hmm
But I'd say just give it a try
That worked I think, imma try it a couple more times.
Alright
Yeah it seems to randomly not work, it stops randomly thru it.
Ill send my updated code.
That's seems like a separate issue then
If there's a change in behaviour the block location is definitely backed
So what's the issue now
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
if two objects are exactly the same (same class and same data in them) will the hashcode be the same?
Depends on their hashcode definition
By default, no
Unless it's a record
Ohhh thats why, I verified on an older account that ended up being thrown away.
okay
@young knoll Is there any way I can reverify for this new discord account?
My old one was deleted and that one was the one I verified one back in march 2020
Ah okay
The hashcode is just the object's VM memory address by default I think
Used for referential equality
Smae issue as before, its just not breaking all the blocks.
It seems to end randomly.
And now for some reason its not dropping blocks for #breakBlock() either
My goal is to vein mine any blocks that are wood
Its a vein mine for logs
I realize why its doing that now and I feel very stupid.
order of operations.
Nope that didnt fix it either
Remind me to yoink Chocos vein mining code at some point
Thought maybe it was because i was breaking the block first but now tis not working at all
So it just stops working?
Yeah.
Try to debug your startBlock and is wood function
@young knoll reminder to yoink chocos vein miner code
Might be that the types differentiate without you realizing
This was in the past the case. No longer do they do this.
Alright
What’s the default hashcode impl now then
What are they using now?
Objects.hashCode
In Java 8 you could check with some flags and by default it was an XOR-Shift algorithm
That was using the memory address as a baseline no?
I like to use the current system time in my hashcode
Or misunderstood
But yes it was memory based
Its the same as System::identityHashCode in principle
Also you could make your own VM and change the implementation if you wanted to
So I wouldn’t rely on it
@minor junco Print statements are only returning grass blocks and such, no logs whatsoever.
Which is odd.
Note to self: Become a script kiddie and steal someone elses vein mine code lmao
Someone knows why BoostedYAML removes String?
Ex: Transforms "stringexample" into stringexample
But thats in general a very bad argument as vms should aim to be consistent with the api
Because It's redundant in yaml
Usually*
If a vm impl changes general api behavior then thats a bad vm
I mean values
Theres any way to disable this change?
Ask the author
Very odd indeed
Ok
Whats even odder:
While the drops arent being made, durability is still affected.
I pissed off the api 💀
thats my conclusion
Sounds like you are breaking air or something weird
Erm
Thing is my code checks to see if the object is a log or not
So how would I get the ability to break air
public static boolean isWood(Material material) {
return switch (material) {
case OAK_LOG, SPRUCE_LOG, BIRCH_LOG, JUNGLE_LOG, ACACIA_LOG, DARK_OAK_LOG, STRIPPED_OAK_LOG,
STRIPPED_SPRUCE_LOG, STRIPPED_BIRCH_LOG, STRIPPED_JUNGLE_LOG, STRIPPED_ACACIA_LOG, STRIPPED_DARK_OAK_LOG ->
true;
default -> false;
};
}
A wild solution: break the block after interating over your range
Tried that and then it just
didnt work at all
What?
Have you tried to debug the outcome of isFuncs.isWood? Maybe the types are different
For some reason
Try printing the type and the result of that invocation
I have not I will try right now
@minor junco https://paste.md-5.net/dogivitipe.cs
The prints are returning, and it is attempting top find blocks to vein mine, but it just doesnt do so.
Ill reword:
- Its able to find blocks to mine
- It does invoke the function to attempt to mine
So it finds all the blocks but it doesn't break them all?
@vapid grove imma sleep now but please feel free to keep me updated, quite interesting
So.. I realized it might be going into an infinite back and forth loop.
Oh erm
Of finding the same wood
And I tried making a table of wood that has been located already
yeah but it is getting broken
So it shouldn't
private void veinMineWood(Block startBlock, Player player, HashMap<Location, Boolean> veinMines) {
Material woodType = startBlock.getType();
veinMines.put(startBlock.getLocation(), true);
if (isFuncs.isWood(woodType)) {
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
Block currentBlock = startBlock.getLocation().clone().add(x, y, z).getBlock();
if((x + y + z != 0) && veinMines.get(currentBlock.getLocation()) == null && currentBlock.getType() != Material.AIR && isFuncs.isWood(currentBlock.getType())){
veinMineWood(currentBlock, player, veinMines);
}
}
}
}
}
If you break it before iterating
Yeah please
Wait why is it a map instead of a set
honestly
i do not know
just decided to use a map idk lol
Im going to try recoding this from scratch
how can i freeze the player?
Like stop them from moving?
wtf
Set walk speed to 0 and give jump boost > 128
?
Or jump boost -1, don’t remember which of those work
just a tip but try to make your code not so nested
if (!isFuncs.isWood(woodType)) {
return;
}
called gaurd clauses im pretty sure
thats early returns
Oh I see
Thank you, ill try doing that instead
i think they're basically the same
@vapid grove
Ohhh
@minor junco My last update on this:
Coll called it, the reason it wasnt working was because player.breakblock calls the blockbreak event, and caused an infinite loop breaking the code.
After switching back to breakNaturally and instead just manally lowering durability for the item, it works fine.
You could also just use a Boolean to ignore the break event
How so?
set Boolean
Player.breakBlock
un set Boolean
And then ignore event while Boolean is set
thanks lol
public final class PitPlayerFactory {
private final DataContainerProvider<PersistentData>
persistentDataContainerProvider = new DataContainerProvider<>();
private final DataContainerProvider<SessionData>
sessionDataContainerProvider = new DataContainerProvider<>();
public <D extends PersistentData> void
registerPersistentDataFactory(Class<D> persistentDataClass,
DataFactory<D> persistentDataFactory) {
this.persistentDataContainerProvider.registerFactory(persistentDataClass, persistentDataFactory);
}
public <D extends SessionData> void
registerSessionDataFactory(Class<D> sessionDataClass,
DataFactory<D> sessionDataFactory) {
this.sessionDataContainerProvider.registerFactory(sessionDataClass, sessionDataFactory);
}
public PitPlayer create(UUID uuid) {
DataContainer<PersistentData> pitPlayerPersistentData =
this.persistentDataContainerProvider.createDataContainer();
DataContainer<SessionData> pitPlayerSessionData =
this.sessionDataContainerProvider.createDataContainer();
return new PitPlayer(uuid, pitPlayerPersistentData, pitPlayerSessionData);
}
}
Few questions:
Should I work with shorter names or keep these long names
Is this a factory method? I'm asking this because you can register your own session/persistent data factories before initialization
is this a good system or nah
Max 🤨
What
Hi
Hi
See you in minehut discord every once and a while
I would help but I'm on my phone and cant see anything
lmao
I can explain you the system
PitPlayer:
DataContainer persistentData
DataContainer sessionData
yeah then you can add your own data to the player's data containers, but you should register them to their factories
So when the player joins all the data loads
The data container api follow these 3 classes
DataFactory
DataContainer
DataContainerProvider (might rename to factory who knows)
So it might look like this
interface PersistentData
class PlayerStats impl PersistentData
class PlayerStatsFactory impl DataFactory<PlayerStats>
DataContainer<PersistentData>
DataContainerProvider<PersistentData>
dataContainerProvider.registerFactory(PlayerStats.class, new PlayerStatsFactory())
And so on
Set<Object> randomSet = randomSetHashMap.containsKey(uuid) ? randomSetHashMap.get(uuid) : new HashSet<>();```
Is there a cleaner way to do this?
what are you trying to do
i need to get a the set from the hashmap, but i dont know if there is one
i want to know if this is the cleanest approach
randomSetHashMap.getOrDefault(uuid, new HashSet<>());
depending on what you want to you could probably use Map#putIfAbsent and then Map#get after
okay, i will be going to implement these cleaner methods
generally though getOrDefault works best if you aren't going to edit the sets at all
if the sets are mutable and you plan to mutate their state I'd reccomend the second approach
oh
otherwise getOrDefault is perfect since it prevents non null values
i was going to mutate them actually
L distro choice
in all realness though looks good
tbh i like ubuntu cuz is user friendly
I'm not used to default gnome xD it looks so polarizing
i don't really need something so hacker or idk
Ew ubuntu desktop
:(
I mean for reference this is the same display environment
like we are both using gnome
I just customized mine a bit
yeah
well idk
i'll just stay with what i have until i get tired
are you fully on linux?
ig i could get a windows-ish look with some apps? don't really know about customizing ubuntu
nope, i have win11 for fortnite and gta lol
kek I dual boot for Siege and Some other games
I acutally got genshin impact working on linux at one point
its compatibility
insane
but well
it runs on phones
but it's not supposed to beable to run on linux
put genshin on a freezer lol
its not but yeah
you got it
HAHAHA
I stopped playing though since It got boring after 300-400 hours
yeah and it only really even has that because of its monpollistically large market share
BRO
THAT'S A SHITLOAD OF HOURS
yeah ig
but yeah
dualbooting is really good
but now i gotta reinstall epic games and rockstar
on windows
cuz i formated from win10
do you do it on separate drives? because otherwise it can get fucky
nope
same 500gb drive
and it works pretty well
I'd actually reccomend going to get a new drive if possible eventually
beacuse windows likes to override grub sometimes
yeah i want to get an 1tb nvme
other than the 500gb nvme i have
but they're expensive
im saving for it
you can get a pretty nice one from Western Digital for like $60
which isn 't bad tbh
yeah that's the same price i have here on colombia
but i'll check it out
but im on laptop
don't really now if i can add one
never opened it before
might be saudered
I'd reccomend just saving for a desktop
it'll take longer but def be worth
or buy a Thinkpad
Framework
thinkpoads generally don't
bro ive seen
that laptop
of modules
don't know the name
but they got a pretty good idea
imagine being in class
Thinkpads are used in business so you can guarentee the parts won't dissapear either
Thats framework
and just start disassembling your laptop mid class
Blegh making that your whole shtick is annoying. I'm assuming you can only buy parts from them though
Probably
yeah see ThinkPad is better in that sense because I could just buy parts from elsewhere. Though I'd prob just buy from lenovo till they stop selling the parts
If you move a lot framework is good because it will last and when stiff breaks you can just replace it and upgrade
i think a full laptop without extra parts
its
$9000 usd
but yk
you can dissasemble it on starbucks
lol
@remote swallow actually doesn't seem bad tbh
looks like you can use whatever parts you get your hands on
Id hope so bc ltt invested like 100k or smth in it
I think I'll buy one of these next. Maybe I'll save up and get one for my GF
Is this a pineapple dev promotion
I ought to try and get kubuntu or fedora on my chromebook again
Im sorry why are we disassembling a laptop on top of Starbucks
Why not
HAHAHAH
cuz we can
Not related to coding but I was curious if there was a way to make a quest book look better?
ItemStack is an enchanted book named "Quest Book" with green text.
Lore is:
Quest Difficulty: (easy medium or hard recolored to be fitting)
Quest Info: Mine Iron Ore
Progress: 50% complete. (5/10) (recolored based on the percentage of completion)
I cant send images cause I gotta get my verification fixed lol
I see you like that anime
what's the way to get the entity the player is looking at?
Thank you!
i totally forgor
about searching it up before asking
lol that what happens after long time of non coding
Hello, looking for some guidance here so bear with me. I have a chat channels plugin that I am looking to add Bungeecord support to, previously, I had used the plugin messaging channel which worked relatively ok but not sure if it scales well. Essentially, any time an update occurs to a global channel, I simply want to propogate that update to all servers (such as new member joining channel etc.). I've seen some people have a project that is able to load into Spigot and Bungeecord servers with seperate build paths for both. However, I am not sure if I really would need a proxy plugin to achieve this or if it would be better performance since I am just unfamilar with proxy plugins. Any advice is appreciated
Idk what exactly interprecetor is 💀 but you could just add Annonnation and at initiation of your code you add them to list
ideally you should avoid adding plugins to the proxy server
the proxy is only there to do one job, and you shouldn't add to it if its not needed
to accomplish your goal you just need a DB server
You don't know what an interceptor is?
It's what is on the tin: It intercepts the call of a method
https://github.com/Starloader-project/smatterDI/blob/main/src/main/java/org/stianloader/smatterdi/CDObjectAllocator.java would be another of my numerous examples of a generated interceptor
Although that one achieves it via subclassing, not by proxying or wrapping
knowing the use case would probably help
a proxy with an invocationhandler that calls the original methods would be the most straightforward if you control the instantiation, otherwise read the class file and pop your code where you want it and redefine - bytebuddy can do it easily if you're not familiar with bytecode
Ahhh I see
i made a plugin bc i needed to change the biome of large areas based on an image. i used Block#setBiome, but for some reason, even after reconnecting or restarting the server, the biomes dont change unless i make a change to the chunk (i assume), like placing a block (or something like that, i didnt test it too much tbh, i just set min Y to bedrock just to try stuff out). any idea why does that happen? any idea how to apply the biomes without placing blocks? placing blocks makes like 2 or 3 times slower, not a problem but idk, id like to know why that happens
Uhh with the spigot api you mean? How is it different to restarting the server?
Reconnecting or restarting should fix it
Make sure you're running Spigot and that you're up to date
also you can always share your code so we can try to recreate the issue
Not on my pc rn
try recreating the issue on Spigot
But its just a simple for loop with block.setBiome depending on some conditions and thats it
Ok, ill do it later just to be sure
I keep forgetting, but how do you rotate a vector around itself? Imagine this is a top-down view, and the black line is where the vector is currently pointing towards, how could I rotate it such that it goes in the direction of the red line?
Add the vector between the two points
I don't have the 2nd point, I only have the black line and an angle
I should've explained better lmao
point refering to the tip of the arrows
not new
Yeah its good :P
hello humans*
How would I go about changing a tool's speed and breakable materials?
(For example, a wooden pickaxe that acts like an Iron Shovel)
Modify the item attributes
hello :)
You don't
Best you could probably do is a resourcepack that adds a custom model data for the items to make them look like different ones.
But this item property is client side and not modifiable
If you do change it for the server, there will be desyncs
You can give mining fatigue and then calculate breaking on the server
It works quite well
Or this painful solution
Which is lag dependant tho
(has noone made a library/api (dunno correct term) for this ?)
I would rather have delay for break start than block desync
I've seen it done in Minestom 
All hail Minestom
Hmmmm, that's bad :/
Painful... But I'll try it, I guess
what do yall think would be better, if I need 33% chance on something should I get a random number between 1-100 and check if its below 33, or just get a number between 1 and 3 and check if its 1?
Ok
Or use nextDouble and .33 :p
That is if you want to be really precise
The higher your upper bound the more "true" your random will seem, so I'd go 1-100
Math.random() <= 0.3333333333333333333333D
simplest
oh true
Does this return a boolean?
ok so true if the 33% chance happens?
no we need full precision Math.random() <= 1.0/3.0
oh yeah
IEEE hates this trick
0.1 + 0.2 = 0.3000000004
Gotta love floating point issues
well banks usually use two integers to define a decimal value
How can I get the block before a raytrace hits?
How do you register custom enchantments in spigot 1.20.4?
I used to do it like this:
public static void registerEnchantment(Enchantment enchantment) {
boolean registerd = true;
try {
Field f = Enchantment.class.getDeclaredField("acceptingNew");
f.setAccessible(true);
f.set(null, true);
Enchantment.registerEnchantment(enchantment);
} catch(Exception e) {
registerd = false;
e.printStackTrace();
}
if(registerd) {
// send message to console
}
}
However Enchantment.registerEnchantment doesn't exist anymore
Or use PDC
i think i got too many projects open
the only valid reason to register your own enchantment is to create a "dummy" enchantment to apply the glow effect to items that contain your other custom enchantments, which should be using PDC instead
you were able to register enchantments just fine using spigot-api and one line of reflection, until 1.20.3 came
NMS is not relocated btw
only craftbukkit is
Wasn't it tho
i think it was until 1.17
"register"
create, whatever
I mean yea, API "registration" was scuffed af anyway
is there a better way to check if a file is a jarfile, except by creating a JarFile and checking for exceptions?
You can add method declaration and definition to classes outside their class scope in Kotlin?
alrighty thx
yes
for example, here I declared String.placeholders(...)
and here's how one can use it:
But I unfortunately hate the rest of Kotlin so not gonna program in that unless im forced to by my workplace
iirc the compiled code is just a static function that takes in "this" as first parameter, e.g. String.doSth() would become public static void doSomething(String $$this)
Ah okay, makes sense
If you'd use Kotlin and java interchangeably it might be a mess no?
Since the Kotlin compiler is doing so much bytecode magic
Yeah using Kotlin stuff from java is pain
Yeah no thank you, I'm staying with my old java 😂
Using java classes in kotlin is fine, other way around is probably not so great lol
it depends. Since the java spec is already outlined in what is to become what in terms of java bytecode, for the most part it only needs to worry about transcribing kotlin specific stuff
it's possible to design idiomatic java apis with kotlin as well
Extension methods surely are a great concept 
e.g. minestom's Hephaistos (NBT library)
what's wrong with them?
I find the concept of object methods outside of the scope of the object concerning given nothing guarantees you the score of the extensionmethods is imported
You end up with nice syntax sugar sure
but they just become messy as fuck imo when overused
there isn't really a difference between these two:
class FileUtils {
public static boolean isJar(File file) { ... }
and this
fun File.isJar(): Boolean { ... }
You'd either import FileUtils and use FileUtils.isJar, or you import your extensions class and use myFile.isJar()
and ofc the IDE will tell you it's a method declared in another file
Yea but the name of say extension class is completely unknown
like, from my end as a consumer
how is it unknown? You import it like you'd import any other class
if a documentation references new File().isJar() i have 0 idea that I have to import FileUtils so I can use said extension function
that problem does not exist if I use a proper static method
I always know exactly what type that function is part of
then you'd have to blame the documentation that advises you to use random extension function sthough. Kotlin's builtin extension functions don't need to be imported, and your own ones also don't need importing if they're declared in the same package
idk i never had issues with not knowing where my own extension functions come from
Yea because its your own codebase lol
I also don't have issues knowing where my stuff is
I mean its fine if you organize them in utility classes still
you probably shouldn't just throw them around in random classes
than you can direct to Utility classes you can use as both Extension functions and used normally as regular functions
guess so. ¯_(ツ)_/¯
in the end it just hijacks the syntax of object methods for a static method
as great as inventory PR 
speaking of Inventory PR
the only place I really wish I had this was actually with NMS
cuz then you can just slap extension functions on the related classes
Inventory PR will be the greatest thing in Bukkit history though stupid question nothing is as great as Inventory PR

biggest PR of history was goat horn api
fastes merge of a lifetime
well I figured goat horn API was a given
that API was very important its the foundation of modern spigot
all those stupid 1.8 players cant use goat horns lol
they dont even know what theyre missing
lol idiots and their goat hornless version
yeah stupid plebs kek
pfft, 1.8 players don't even have PDC or sendTitle 
yeah but like who tf cares about that s hit
Well, you could also have ItemStack#removeEnchantments
i wonder if this works - can I really just turn a file from resources into a file object?
resources can be turned into a File only if they are an actual file
I wanna know how a resource can't be a file wtf are you people storing in the resources directory!!
well you can have resources in JARs or outside
you can't reference it as a file if it's in a JAR
sad, that would be very handy
can't i do it with a JarFileSystem or however its called
yea