#help-development
1 messages · Page 2042 of 1
Can I check if a server is online, and how many players are in it in bukkit?
If so how
oh crap true
boolean online = false;
try (Socket s = new Socket() {
s.connect(new InetSocketAddress(ADDRESS, PORT), 15);
online = true;
} catch (UnknownHostException | IOException ignored) {}```
so my bot wont be online either
oh ur checking for the server running
|| -> |
i thought u meant another server
lmao
also run it async
I can't wait for someone to ask again on how to save a map or list into a PDC lol
xD
yeah man, i would wish to see that :(
hello i want to get the tps with (double currentTPS : net.minecraft.server.v1_8_R3.MinecraftServer.getServer().recentTps) { but i get the follwing eror cannot find symbol
isn't that a private field?
also 1.8 lol
public Double getServerTPS() { Double tps = null; for (double currentTPS : net.minecraft.server.v1_8_R3.MinecraftServer.getServer().recentTps) { tps = (Double) (Math.round(currentTPS * Math.pow(10, 2)) / Math.pow(10, 2)); break; } if (tps > 20) tps = (Double) 20.0; return tps; }
that my method
check whether recentTps is a private or public field
in proper MC versions, the field is public
public
then show the full error
java: cannot find symbol
symbol: variable recentTps
location: class net.minecraft.server.v1_8_R3.MinecraftServer
hm no idea, I don't have such an old version installed so I can't test
recentTps is not a method/field in Spigot
well it is in in 1.17 and 1.18
Hi guys! Any way to check if an item is damageable in 1.8? Instance checking item meta to see if it implements damageable doesn't work on legacy versions
doesnt work on modern versions either
maybe theres a material flag
you can check for
what doesn't work?
x instanceof Damageable always returns true
look
every item meta extends this
its ridiculous
maybe try ```java
Material.DIRT.getMaxDurability()
if it returns anything above 0, it's damagable
Oh, I wasn't aware
yeah its stupid
Wouldn't blocks like wool and stained glass return values over 0?
I have no idea, who tf uses 1.8 lol
People living in the dark ages
I also don't get why they used 1561 for diamond and 2031 for netherite. why not just 1500 and 2000 lol
Yeah, trying to achieve cross version support since a lot of users want it
gold is 32, that makes sense, and iron is 250, that also makes sense. but 1561?
maybe mojang has some standard equation to calculate new durability for materials
idk
they probably just throw a dice 4 times
that also explains why the numbers 7,8,9 never appear in any durability
and they use 0 when the dice falls from the table
fun fact, if you roll 2 dice, the result 7 is the most common
yeah
most combinations
32 / 250 = 0.128 (ok decent)
250 / 1561 = 0.1601537475976937860345932094811 (tf)
1561 / 2031 = 0.76858690300344657804037419990153 (why)
It might have been the protocol id at that time
Will ItemStack#getDurability() return the same value as Damageable#getDamage()?
how
2031 is 0b11111101111 in binary. Why they didn't go with 2047 is a bit beyond me but eh good enough
Could be that there was some random bit mask that noone wanted to change but would otherwise break if an item had that much durability
Where I can find help about quests plugin?
github most likely
if (false) {
System.exit(0);
}
you normally shjouldn't let this situation occur in the first place
Can I get discord from this plugin?
Alex don't you have a blog post about exception flow
It only errors for me.
yes
cause its a bot, and it cant change nicknames.
Oh
That the owner is.
yessss that
Errors at runtime or compile time
How can I get discord server of quests plugin?
Probably doesn't have permissions
Is my guess
look on their spigot website
https://github.com/PikaMug/Quests also has that link
is there any method exist to check if player is not found or not ever joined my server?
hasPlayedBefore iirc
try {
throw new NullPointerException();
} catch (NullPointerException e) {
throw new NullPointerException();
}
wdym i shouldnt catch Runtime exceptions, it works perfectly fine

try {
} catch (Exception e) {
throw new RuntimeException(e);
}
ah yes
guys can someone help me using world edit api 💀
?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!
if i search for this char (from the ascii table) ```java
(char)0
(which would be desired, trying to null the argument seperator from my ini parser which defaults to ',')
so it never matches
Is it possible to get a users display name from their unique id?
example: 193ff4d4-68cd-4f4b-8877-a31f41f88aa2
as a string
I built build-tools. Does anybody know where the jar with the nms stuff is placed, so I can add it to my maven-local repo?
it doesnt seem to work for me
dont place it, add a repository to it
for example:
Ok, but at first, where is it placed?
compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT-shaded'
if you dont know hwo to do it research it first
or better yet learn gradle
as thats a basic thing in gradle
thats me assuming you know how to code java however
and that your using gradle
I am using maven
then research maven?
Yes, but my main question was, where it is placed in the folder
you dont place it anywhere..
you download it so you can get the jars name
so you can add it to the repository
i just want to know where it is placed after running build-tools
as i just stated:
you dont place it anywhere..
you download it so you can get the jars name
so you can add it to the repository
but i don't know where the jar is placed when i run build-tools
If you run build tools it will put the files into your local repo so you don't need to do anything.
Just add it as a dependency
Really?
Yes.
Ok thanks
Hi, trying to make an Entity/Zombie not despawn. Had a look here (https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Zombie.html) but does not look like there is an "easy" way of doing it. setPersistent did not do the job, if my understanding of the word persistent means "continuing to exist or occur over a prolonged period". Do I need to create a event listener, did not find a EntityDespawnEvent tho...
Also, @vocal cloud while your here, can I convert a string to a UUID?
Example: Turn this into the UUID: 193ff4d4-68cd-4f4b-8877-a31f41f88aa2
UUID.fromString
Yeah but be careful about it
huh
You can't instantiate UUID it has static methods only.
UUID id = UUID.fromString(someStr)
I see
Well you can but not the way you want
I downloaded the dependency and can't import all the nms-specific stuff
The nms package don't even exist in my case
tysm, now my verification command and bot changes the persons nickname
on discord
?
did you change spigot-api to spigot?
How would I get a list of everything in the getConfig?
Would i just do .get(".")
or smth
Zombie zombie = (Zombie) world.spawnEntity(location, EntityType.ZOMBIE); zombie.setAI(false); zombie.setCustomName("Zombie"); zombie.setCustomNameVisible(true); zombie.setPersistent(true); zombie.setInvulnerable(true); zombie.setRemoveWhenFarAway(false);
Will this zombie continue continue to exist? Looks like it works in game...
Yes cuase it has a custom name
They wont despawn with a custom name set usually
@quaint mantle the custom name thing was not enough. Tested it, and it just despawned
Unsure then
hey guys how can i make if in my gui i click a item player teleports in other world?
Hi guys! How can i modify a vanilla command tab completion? I tried using the TabCompleteEvent but it didnt work
verify that the player clicked on the compass and then teleport him to a specific location
so InventoryClickEvent
?
okaaaaaaaaaaaaaaaaaaaaaaaaay
This for a command u have?
Im making custom items
If so look into TabCompleter
Not my command
???
Vanilla command
Oh vanilla command
Did u register the event class?
Yes
Show code
Ok
whats in the config?
GINVE:
user: 193ff4d4-68cd-4f4b-8877-a31f41f88aa2
time: 1648050883
thats it
i want to get GINVE
and if there is other codes
get them as well
loop over a config section
for(String id: EmeraldsPlugin.disc.getConfig().getStringList("")){
System.out.println(id);
if(EmeraldsPlugin.disc.getConfig().getLong(id + ".time") + 300 <= unixTime){
EmeraldsPlugin.disc.deleteVerify(id);
}
}
i dont see how
@tardy delta is this correct or
so how to i get a section?
what are you trying to do?
im using the id to check the config if the time is past 5 minutes of it being generated
if so delete the ID from the config
im trying, to errors stating that its not a valid arraylist
lol there is only one section so what
is GINVE a person or something and are there multiples such things?
its an identifier string
its a 5 letter string used for verifying
if you want to get the time use config.getLong("GINVE.time")
ill give another example ig
so there are multiple?
oml im trying to get the ID
get ALL of the ids
inside the config
so i can loop thru
to get the time for them
and delete em if expired
Okay but you JUST stated arraylist wouldnt work
you need a root section
so like
data:
GINVE:
user: '193ff4d4-68cd-4f4b-8877-a31f41f88aa2'
time: 1648050883
SOMETHING_ELSE:
user: 'some uuid'
time: 1234567890```
Id have to rewrite my code but i guess sure
then get the section "data"
var keys = config.getKeys(false);
not sure if you can iterate over the root section if you know what i mean
for all keys on the first level of the config file
the root is a section
so yes you can
thank you
owh right
i couldnt remeber the type, so replace var with whatever it returns if you dont want var
Thank god it works
yeah
i stopped using yaml and switched to database lol
YamlConfiguration -> FileConfiguration -> MemoryConfiguration -> MemorySection -> ConfigurationSection
yeah i recommend a proper database too
refactoring my command system atm kek
smth liek this
it kinda goes brr
but its already much shorter than string parsing in every command class
nice
dont know what database is
just anything that persitently stores data
have you ever wondered how facebook saves your data? well in databases
for example mySQL
yaml is technically also a database but its not very performant or expandable
or it can be used as a database
yaml is just a file with some formatting rules
ye but its not really used for keeping a lot of data
it could be, its just that noone does it
its completely in-memory right?
its saved to a file
just like mysql
mysql is also partially stored in memory
i assume at least
but yaml has a backing map
reading a file every time you want to access something is stupid
I do 🥺
imagine saving a whole playerbase in yaml
sql is more scalable in my opinion
on join you just get the player's name and set it as path for it's UUID in a yml file
also you can easily use ORDER BY stuff to order the result instead of doing it yourself
so whenever you need a player's uuid you just get his name from the yml file
yep
why not just calling Player#getUniqueId?
so basically you're storing its last known name?
yes
and gets updated whenever they join
i do that because in one of my plugin there is command /release <name>
that has to work offline too
i don't think that making the user type the whole UUID is a good thing so they can type the name and so my code can get the UUID from the yml file
could use Bukkit::getOfflinePlayer
offline mode 🤮
altho I'd suggest creating a name -> uuid cache
offline mode ew
I think they meant for when the player is offline
and btw offline mode has its use-case
i knew the existence of this, buuuuut, too lazy to learn it
lol
idk how the offline player works as i tried using it many times and gave me errors
sounds a lot like a you-problem, anyhow I'd advocate looking at javadocs
yes it's my problem
I make a NMS patch for Spigot-Server. I compiled it with mvn clean install.
But didn't create remapped-mojang version of jar in maven local repository.
How can i create this jar.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Yeah looks like it isn't installing it
You can always do that manually or specify it in the pom
There is a install file command you can use to add it to your maven repo
What? Can you be more specific?
Where is file?
for some reason it only works in the console and with commands i made
Weird, I’d have to do some testing on my own. If it’s an event it should work with any command but I’m not sure.
Can you post code?
?paste
is there a way to intergrate a mod into a plugin? AKA the plugin requires a mod to run
like as a dependancy
i've seen that with veinminer
Weird, does it work with any non-vanilla commands
Like have u tried a different plugin’s command?
Try that, if it does work then it means spigot isn’t creating events for vanilla commands
from every plugin
Yeah then there’s no way to do it from my knowledge
The mod is optional
protocol lib time..
Why do you even need this
Might need to override the give command urself
He wants to add his custom item to the give command tab completer
yeah, i'll see, thnx anyway
ye i know but maybe looking at that could help
Just make your own give command it will be much easier
Prob easier to just make ur own command to give the item tbh
Does spigot supports java 18?
I think versions past 1.18 do
Can’t remember if it’s Java 17 or 18 tho
I’ve only tried 17
when I tried yes
altho j18 is still considered unstable afaik
so you wont get any support for using j18
It released yesterday so have some patience
Just use 17. LTS
yeah LTS better
how could generate a custom world this is constact structure:
I added a plugin dependency to pom.xml and every time I compile my plugin it also copies the packages and classes from that plugin in my plugin and adds a bytebuddy folder, how can i make it stop doing this?
send pom
i forgot the setting but change the thing from >compile< to >provided<
the file or the code?
?paste it
scope compile to provided
ok
isnt that good tho
not for plugins
what happens if the repo dies tho
and for the bytebuddy folder?
then use a different dependency
wtf is bytebuddy
with compile that wouldnt happen?
or wait no
yeah cause you're literally including another plugin
i find that better
idk what that was
since itll work no matter what
thats annoying asf for server owners
thnx
wait wdym
u just assumed every dependency
is a plugin
Byte buddy is for editing the good stuff 
literally every plugin does that
so every dependency is a plugin??
are you dumb
👀
ok so
adding a plugin as a dependency should mean its not shaded into the plugin
and if you shade other plugins like that you're dumb and annoying to server owners
like essentials doesnt shade vault
you only have to depend on the api?
sir
Depend on api but don't need to add it to your jar
^^
you literally just assumed every dependency is a plugin
it mainly annoys developers tbh bc there's an upload limit on spigot -.-
??
so basically the 'provide' scope in maven?
????
a dependency doesnt mean its always a plugin
so you have access to the api code but dont compile it into your plugin
no shit
im talking about plugin dependencies
like plugin APIs and libraries
What do you mean I'm not supposed to shade the spigot jar??
and did he specify "plugins"
like libraries yeah
i did that for galaxylib
well those still get loaded
only into the plugin that shades it
like a bunch of utility classes
not a standalone plugin
<dependency>
<groupId>com.github.ImajinDevon</groupId>
<artifactId>GalaxyLib</artifactId>
<version>latest_commit</version>
<scope>compile</scope> <!-- Shade the JAR -->
</dependency>
👀
then you have access to all of the classes without having another plugin
nope
i think its cause i originally deleted the repo and it also deleted the wiki repository
for some reason on github they're two seperate repositories for easier editing
yea
if you need all the data like get the nbt as string idk
a library idea
and then parse it back or something
thank you
i know i can try to stuff it into a data stream and serialize it as a base64 string but not how
BookMeta meta = (BookMeta) book.getItemMeta();
StringBuilder builder = new StringBuilder();
for (String page : meta.getPages()) {
builder.append(page).append('\n');
}
@smoky oak
probably the most simple way
oh
u wanna serialize the item?
^ you can use json
nbt should always be abstracted, its cringe
yeah i hate that craftbukkit uses the version in the package
because the nms stuff is mapped to just net.minecraft
now
so no need for shitty relfection
would work
that looks incredibly complicated for no reason
im sure i could write an easier method
one sec
jUsT grAB tHe nBT
the error handling makes it look complex
its quite simple tho
yeah still a lot of code for no reason
what is the easiest way to differentiate between a cracked and premium player
premium server
on a offline server
idk maybe use the mojang auth api
with GameProfile
Don't allow cracked accounts by using authentication?
there is no way
does FastLogin have an API
you have to manually auth premium users
or anything
You either auth with mojang or you don't auth at all
ye but premium players
it is possible if your server uses a mixed mode auth plugin so everyone has an online uuid
are not their actual uuids either
premium players on cracked servers are not their actual mojang uuid
just an offline uuid
from personal experience, premium players are treated as separate on the same server running in online and offline mode. This is probably because their online uuid stems from mojang's servers and their offline uuid from their name
which is why you need a plugin to change that
as stated in the post
yeah but what if I use a cracked account of an existing premium player name
wat
password ingame?
Sigh. Just don't allow cracked accounts.
yea its a pain
well its not really if ur starting out
if ur struggling to find players cracked ones arent that bad
I mean you're pirating software I'd say that's pretty bad
why is there even an option in the default spigot jar to run a server offline?
is that purely for bungee?
Let's say you and some friends hang out in a place with no internet and want to play together. Voila offline mode
how would that work without internet
pertty sure u still cannot play together if u have no internet
yea but that works with a local network?
where everyone has to be connected to the same network?
It's also useful if you're playing on a version of MC where the new auth isn't
No need for wifi
If their auth servers go down you can still play with people
hm, i guess thats fair yea
Like og Technic stuff needs to be played in offline mode
Because not all entities are players.
Don't use lore to detect things
I know that
😭
The problem is not with the lore, nor with the try catching. My issue with with the potion effect. It does not apply the potion effect even when the try block runs perfectly.
ok no but you have issues wit hyour code
I didn't include it in the pasted code, but earlier I had the code send me a message whenever an exception was caught. I did not get the error message even though the potion effect was not applied, so I think it might be something with how I am applying it.
Is your message sending
The poison message sends.
But the mob being attacked does not get poison as far as I can tell.
why are you try catching exception
I think you might want to try and increase the time of the potion effect. I'd expect that to be in ticks
if (!(e.getDamager() instanceof Player)) {
return;
}
Player player = (Player) e.getDamager();
I forgot that it is in ticks instead of seconds like the in-game command
wrap it
?pdc
if(!(e.getDamager() instanceof Player player)) return;
ive forgot java
rust is so much better
i keep forgetting java syntax and having to google it
I keep not knowing java syntax in the first place
thats the bad part of working with multiple langauges
no need to cast and make a variable
Always wrap it 😉
until you want a bebe
tere is still quite some problems with ur code tho
you probabaly also wanna check if the item even has an itemmeta & lore
But that is the beauty of the try and catch
false
why the heck does #hasLore exist then
If it is anything I don't want, it just doesn't happen
Oh
pretty sure u should not abuse catching like that
your code is bad
isnt that kinda stupid
Don't try catch something that you can avoid try catching
i mean no need for unnecessary allocations
@strong parcel sir u confused catching with if statements
Don't worry, I used both
😛
read the blog i sent
Anyway, what is a persistent data container?
a container
It takes a lot of processing power to handle an error. Best to avoid it whenever possible.
abstraction of nbt
Okay, I will
Eek, not really an abstraction of NBT
you won't be able to use it to modify minecraft relevant tags
think of it as a fancy map that is persisted on entities/items/whatever provides it through server restarts
Well it abstracts away the nbt from you, i guess it just doesn't let you mess with stuff you wouldn't mess with usually
Well, yea i uses NBT but it shouldn't be seen as designed to be an NBT interface
Checkout:
- https://blog.jeff-media.com/persistent-data-container-the-better-alternative-to-nbt-tags/
- https://www.spigotmc.org/threads/a-guide-to-1-14-persistentdataholder-api.371200/
and after you finish learning that check this library out (it basically allows for more persistent data types to use) - https://github.com/JEFF-Media-GbR/MorePersistentDataTypes
@strong parcel
point is, if minecrafts persistence data format or general implementation were to change PDC would most likely be completely unaffected by that change (in high terms)
2Hex is just Alex's alt account at this point lol
lul
Lmao
I have many things saved up
even 7smile7's
useful stuff
Anyways I need a lib idea :(
An idea for a new library?
googles serializing
just steal some lib features from other libs and make them better
e z
I would want to make something original
Pick something that makes people's toes curl. Like excessive reflection where it's not needed :D
😒
curl https://to.es
interesting
I might start writing replies again
tho I dont have any good quotes to come with atm
I am a bit embarrassed about the seemingly almost but not really 5 star review, though amused at the same time :]
wowow
okay
so
very epic grandest of grand moments 🙂
lets see if my phone wants to help me login into spigot for ONCE
lmao
indeed
its peculiarly intriguing, ye
ultra spectacularly blazing performance
lol
yupp
to think a single plugin could be the solution
it did cost me some lines, but we gotta look at the bigger picture riteeee
What is the default value of a sound effect's volume and pitch?
Asking for the command
player.playSound()
I imagine it's in the source
I need to enter a value though, do I just insert "1"?
alr
and then ofc hit save(File) as well
ye you rite
IO operation hence resource intensive hence bad :xxx /s
Wait that's another idea for reflection. Object serialization 
Unsafe is better suited for serialization
which is alr done by gson (so moshi also :))))altho it as maow just stated uses unsafe as well
My problem with Gson is that it only works with JSON :p
And my problem with Moshi is that kotlinx-serialization exists lmao
lmao
ye
well
I dont use kotlin now so hehe that thing gets defenestrated the moment I see it
kotlinx-serialization is like... serde for the JVM
ugh discord auto correct is uhm... interesting
guys
I personally like TOML as a configuration format
myeah toml or hocon
YAML and XML are icky and most other formats are not designed for configuration
I mean I do see yaml being quite powerful since you have anchors and that shit
if the map can be resized and the canvas uses bytes to cursor, pixels and etc, how am i supposed to draw pixels at 132, for example
but yeah it kinda becomes nested as you go unfortunately
(unless you use StrictYAML, which disallows anchors since they're a symptom of poor structure)
lmao ye
(also YAML anchors make the language susceptible to recursive expansion attacks)
well to some extent they imo can add manageability and readability
altho conversely they're sort of (unrestricted) gotos which is bad
eh its useless
oh btw have you ever coded in Batch, Conclure?
truly is
as soon as you need to do anything more than if statements and jumps
I used to fake hack people mostly
lol deplorably unfortunate cause you'll get loaded with demonic spikes trying to slaughter you
I used to make games
text-based games that uhh... weren't very good
the most complicated feature was savefiles
myes
which aren't that complicated tbh
Gotta add pong to the spigot log
I really like developing in Fabric
it's super easy to launch a Minecraft client straight from IDEA
also mixins are ✨ great
you get the status thing error due to offline modee
dont leave me alone 😭
just add DevLogin
literally single modImplementation dependency + program argument
oo
let me look that up
cuz I asked a while back
and they said most work arounds would be hacky one way or another
Hey, this might be a bit of an X-Y problem but does anyone know if default minecraft command tab completion is handled clientside on 1.16? I'm at my wit's end here trying to remove some entries from minecraft commands and chat tab completions, but no packets are sent between client and server so it seems like this is clientside.
The context for this is that I am using custom entries in the tablist to sort it properly, e.g. using GameProfiles with names like 001, 002, etc to order them, but this causes those numbers to be suggested rather than the actual usernames. I don't have this issue with plugin commands, only for minecraft commands like /teleport and chat.
can some one help me (command Prompt closed automatically when i open it.)
I believe the server sends packets that add to the client's playerlist.
oh yeah btw Maow how do u structure classes into packages
cuz rn
no clue what to put where
I'
how do I suppress the "Respawn point set" message on interacting with a bed (and how do I actually make it not set the spawnpoint)
Tip: Never use plurals
and uhh
or actually 4
you probably want like a item, entity, util structure here...
hmm yeah
Right, like PlayerInfoData. Problem is, I can't really change those since I'm already using custom ones to sort the tab. I would need a secondary mechanism to remove things from command / chat suggestions but not from the tablist, which AFAIK is impossible using that packet.
I personally use client for client-side only, but never server
ah
in client you'd include your gui and render stuff
when i hide playerA from playerB using playerB.hidePlayer(playerA), will playerB see playerA in tab?
nope
how do i go about suppressing automatic messages like this
but they will see them in chat, unless you add custom logic to handle for that
that is an answer to me, right?
fair, its kinda interesting since mc itself doesn't pay much attention in separating those two apart from what's fundamentally necessary
yes
thx man
help pls
amount of blocks * byte?
wait maths
/ Byte.MAX_VALUE?
🤔 🤔
idk what im saying lol
if the scale is like default, is the max cursor value 128?
it will be always 128
pain lol
A good inventory lib
make a lib to stream anime through minecraft :]
And detect if they try to stream non-anime, and blow up their server if they do.
Is the Beacon laser actually clientside?
Yes
Oof
Yes, please
sounds like a infectious cat
🥲
make a lib to blow up the server if theyre using 1.8
rip most the servers
I feel like most server owners are 13-14 year olds who stole their parents credit card for commissioning people
lib that runs in outdated servers and automatically upgrades them
Which isn't exactly what I wanted, but it's going to be good enough
Mapping problem with SpecialSource (using gradle and spigot 1.18.1)
this actually a good idea
updates on restart?
lib that shutdowns 1.8 servers :>
i already said that :)
1.7.10 servers too?
yes
everything under 1.12
if under 1.8 the explosion should be a nuclear reaction at the very least
Advice on storing crafting recipes
Thread.sleep(Integer.MAX_SIZE) is funnier
what do you think, does it make sense to already cache the keys from 0 to 100? or should I just ignore it and only get them when needed?
public final class NamespacedKeyUtils {
private static final Map<String, NamespacedKey> KEY_KEYS = new HashMap<>();
private static final Map<String, NamespacedKey> VALUE_KEYS = new HashMap<>();
static {
// Caching the first 100 keys. I think that's reasonable for most use cases
IntStream.range(0,100).forEach(number -> {
getValueKey(number);
getKeyKey(number);
});
}
public static NamespacedKey getKeyKey(final String name) {
return KEY_KEYS.computeIfAbsent(name, String -> NamespacedKey.fromString("k:" + name));
}
fn main(){loop{}}
why Integer.MAX_VALUE when you can go Long.MAX_VALUE 
mhm ye
y
oki
🥴 streams and lambda
brain no work
they are fun
Streams and Lambdas are great
streams are... interesting
my brain wasnt understanding concurrency either
readability itsvollx
it looks so functional
functional programming
oh gosh
Stream::peek and Stream::forEach isn't purely functional
oo
there you mentioned something rather good
lol im more using forEach than an actual for loop
Runnable runnable = () -> System.out.println("Hi");
Runnable ugly = new Runnable() {
@Override
public void run() {
System.out.println("hi");
}
};
I think there's a clear winner here
do data science use this?
data science might
one part of data science is programming language paradigms
in which for instance functional programming is a topic
specifically lambda calculus and group as well as category theory
if you wanna look into the mathematics of it
"->" is heavily embedded into programming
I mean anonymous classes with a single function, or well just a function generally
anyways -> is usually called a lambda, or arrow function but its just an anonymous pure function at most
pretty basic and probably not even correct explanation but that's how I learnt to understand what lambdas etc actually are
🙏 thank you! ღ
🙃
how many bytes is a UUID
16 bytes iirc
t-> t.doSOmething()
can i access n in the {} ?
yes
i mean as n
ye
ok
sure, that's what it's for
Would be pretty worthless if you couldn't
yeah lol
I hate the fact that you can't use "__" as parameter name in java 9+ anymore
python user right here
fr...
also
public static NamespacedKey getValueKey(final String name) {
return VALUE_KEYS.computeIfAbsent(name, __ -> NamespacedKey.fromString("v:" + name));
}
this works in java 8 but not 9
I've always used __ for unused parameters
wait why do you need to put it into a consumer anyways then?
oh i just gave them the first letter of the parameter name
because computeIfAbsent takes a consumer
I always just use o -> if it's unused usually
Function actually :>
sorry for the nitpick, I just had to 😅
also seems fine for me?
D:
__ 😐
try to compile that on java 9+
that looks awful
watch me
state -> {...} is enough tho 😄
worked
It worked for me too ^
your argument is invalid @tender shard
was there even an argument to begin with?
god ( )
It was more alex being sad over his imagination than an argument
I mean I believe $ has become gradually less legal
(god == null) is true
unsure if that applies to _ as well
weird, I've read a book that said it's not allowed in java 9+ but "might be allowed again on later versions"
Oh
waitaminit
I'm on 17 so maybe it got readded
ah
mind sharing code?
since, provided that you wrote the correct code that ought to work just fine
The second possibility can look like this, adding two underscores
use - the use of an underscore for an identifier
has been banned since Java 9, but might be in later Java versions
to be reintroduced:
did it print anything?
maybe it's really just in java 9 but allowed in java 10 again? 😄
Hm maybe
what
getInventory() simply prints the toString() of the inventory
which likely consists of just the Class name and the hashcode
yes that's correct
can i somehow return values from a consumer? It's a unfortunate requirement of the library I'm using
Use Function<> instead of Consumer<>
lol sucks for you then
fork the library ig
he lp ful
change it :)
You're the one who decided to get mouthy 🤷♂️
static abuse time
😒
you are shooting yourself in the foot in the end by doing that
you could simply put your return value into a variable and use it after the forEach is done 😄
if i call a consumer does it still run before anything after that?
Guys can i use Main main = new Main(); instead of dependency injection ?
no
you may not instantiate your plugins main class on your own
oh wait
JavaPlugin can only be instantiated once
^^
oh I wanted to reply to Moterius
how do I see if a player crossed a specific line?
PlayerMoveEvent could, but wouldn't that be intensive as fuck when they're not even remotely near the line?
yea you cant do new Main() but you can store your main instance in a static variable
I always quote the wrong people
oh i see thank you guys 🙂
if you only do a tiny bit of math, it's no problem
My solution would be: HashMap for playerNearArea with uuid->boolean mapping. I believe HashMap O(n) for get was either O(n) or O(1)
does, getting the block location and seeing where the player is, a "tiny bit of math"?
very often thrown events can still work lag-free if the checks are simple
is there a non deprecated method like getOfflinePlayer?
why do you need a block?
for example blockPhysicsEvent block.getType
o, hm
can't you just use locations?
to get them by name, no
oh, yea, that exists
get them via UUID iirc
well but thats what ive wanted, get them by name so they can be resolved into their uuid
xD
you can use it, it'll work fine
so just suppress the warning?
it's just deprecated because it can be inconsistent
e.g. if a player changed their name and havent joined your server yet, it will still need the old player name
yea but i need it exactly for its inconsistent behavior xD
ik
ItemMeta#getLore, change the first line, then setLore again
cause i wanna resolve igns to uuids
would i just compare the locations then-?
if player.getLocation() == myLocationObject {}
no! first of all, you'd have to use equals
and second of all, this would require a player to be EXACTLY at this location
if their location differs by 0.0000001 blocks, it won't work
how do i use something that is deprecated? i'm tryna do world gen but biomegrid is deprecated
by just using it
pfft -_-
alrighty then!
i'll just make my checks simple
public static void getUUIDByName(CommandSender sender, String str)
{
Object p = Bukkit.getPlayer(str);
if (p == null) p = Bukkit.getOfflinePlayer("");
if (p != null)
{
}
}
```this okay to do then?
123912431284975328567 Iq
will it let me?
of course
ok, ty
probably there is an updated api, but if you want you can still use the deprecated api
i'm using an old tutorial
yeah something never gets just deprecated without replacement
mfnalex can you help me with a code?
there's BiomeProvider
what's that supposed to do?
it says "get..." but it's a void?
what do you need the CommandSender for?
also Bukkit.getOfflinePlayer(""); wont return anything that you can use
btw you can also get offline players by name without deprecated methods
by simply looping over them 😄
why don't you just do this
public static UUID getUuidFromName(final String playerName) {
return Bukkit.getOfflinePlayer(playerName).getUniqueId();
}
okay give me a few minutes to write it out
@SuppressWarnings("deprecation")
public static UUID getUUIDByName(String str)
{
Player p = Bukkit.getPlayer(str);
if (p == null) p = (Player) Bukkit.getOfflinePlayer(str);
if (p != null)
{
return p.getUniqueId();
}
return null;
}
you can't cast an OfflinePlayer to a Player
actually he could if it would
like
Player extends to offlinePlayer
but in this case
well getOfflinePlayer returns an OfflinePlayer
public static UUID getUuidFromName(final String playerName) {
final Player player = Bukkit.getPlayer(playerName);
return player != null ? player.getUniqueId() : Bukkit.getOfflinePlayer(playerName).getUniqueId();
}
exactly but OfflinePlayer doesn't extend Player
you could just always use Bukkit.getOfflinePlayer
cuz
its same thing, both give uniqueId
public static UUID getUuidFromName(final String playerName) {
return Bukkit.getOfflinePlayer(playerName).getUniqueId();
}
would work the same way
btw how can i do the '''java thing to write code?
```java
code
