#help-development
1 messages · Page 674 of 1
hey
so my friend is installed every build tool from the repo
is it normal each take a few minutes
yea
oh okay
just asked so he dont do it all in vain
we are in the right path
thanks illusion
@echo basalt ight so installed everything that it would let me (java versions yk)
i cant install more cuz im using java 17 not 8
Inb4 they are all hard referenced in the code
try to build it
k
It'll toss errors but at least you'll know where
same error
uhh no
I wonder if I can just pull and build
I think I already did this before wait
you can
Just make sure you always have that config setting enabled
Problem solved
tf man i keep gettin the same error
you're simply inferior ¯_(ツ)_/¯

can you send the .jar file
anyways first and last time I'm doing this
tysm
don't ever bother us again
💀
just want to say huge thanks for everyone who helped us
oh god this is getting icky I just merged the profile system with the player stuff
this class has over 100 lines, it's too big
end result is clean though
Will it make diffirence if i use spigot api on PaperMC?
it generally shouldnt
thanks
paper has some methods which wont be backwards compatible on spigot
So ive been noticing this alot with my guis, but if I shit click on an item and press E or escape at just the right time, the canceel event doesnt work and the item gets added to my inventory. How do I fix this?
It happens with all my guis*
Whats the event name directly?
InventoryDragEvent
Gotcha, ill cancel them
Fixed, but that seems really weird however
Why would that be an issue in the first place
if you move your mouse 1px while grabbing an item it counts as a drag
Ah I see
Still seems to happen.
Infact, it seems that there is also a duplication glitch as well.
If a user places an item, and swaps it and immediately presses esc and e, the item gets duped.
Does creative mode or having op affect any of this
creative likes to mess with you
Yep, turns out the dude finding the issue was in creative.
I didn’t know you could do that, I thought Mojang wanted to keep it PG
When testing the dupe in survival, ceases to function.
Yes and for the previous if this is happening in survival its not a glitch rather a failure to do appropriate checks in regards to guis.
Nope its not happening at all in survival
Only creative, which I had no idea had an affect on UIs
Yes and there is some creative mode specific events too
Huh
However even so you have to do more checks for creative due to how that works still
Ops has an effect if your checks are flawed and just let them do whatever lol
:/
Not usually an issue with ops because well they are op
Yeah
And nobody except ops in my server are actually
Supposed to have creative so
It shouldnt be a major issue
Instead you should check for perms and not just op or treat op differently from normal perms because realistically people shouldnt just be opped lol
Speaking of, is there a way I can create perms without a plugin like luckperms or smth
Is it easy or is it a pain to setup
Oh awesome
oh yeah frosty
I ditched the player system for non-server platforms
and nuked the generic type
You would have to still implement the whole making perms system this class just lets you check dynamic and static perms easily
Gotcha
I figured proxies shouldn't track player data individually because well.. that's a point of failure
Correct
Well yes but no
now I'm working on actually converting all the spigot-specific code to be a lot more generic
Haspermission doesnt let you check dynamic perms
so.. hasPermission with a concat string
Replace
single responsibility principle isn't applied here I see
why tf is this mesage being sent on a permissions class
Because it catches if its done from console and removed adding this check in all my commands
Well I usually just have a boolean field on an abstract command class for that kind of stuff
Well my command class for that peoject wasnt setup that way lmao
still need to convert to generic
So instead of duplicating that check i moved it there instead lol
but that involves making an entire abstract command system
and I just can't bother tonight
Lol
I love writing classes that have no code
Is it bad that ive been just looping thru packages using reflections to load stuff like commands and items events
yes
ah
just do it manually
I hate manually doing stuff for some reason
11 abstract classes, 24 interfaces out of 119 classes
if its only onenable its not that bad
still not a 50% abstract ratio
It is possible to load a class via reflection without invoking the constructor and this would be bad lol
I always thought that Reflections project was black magic
but now that I'm no longer 100% an idiot I know that the only black magic out there is ASM
Well I make sure that its the first think loaded upon getting that class
Constructor<?> inst = cls.getDeclaredConstructor();
inst.setAccessible(true);
Heres my random issue with reflections
if(!cls.getName().contains("$2") && !cls.getName().contains("$1")) {
Half the time ill get duplicated classes with these at the end, and it messes with my stuff
And it confuses the hell outta me, had to add a check to only let regular ones in
Never been able to fix it
they're anonymous classes
Those numbers refer to inlined classes
aka lambdas n shit
Ah
Yeah my browser will sometimes do that. Crash the discord app all because javascript
Yeah probably because only one javascript engine can be used more so of they are the same but differing versions
a "fix" for it is turning off hardware acceleration
Yep because of the issue i stated
but that fix is awful and causes crashes when doing other things
And I can't watch Undercover Boss™️ with my homie on call because it's a solid 2fps
Lmao
wait until you hear about MethodHandles and indy and condy and all the ways the jvm can optimise your shitty code 😄
ActionBar
Weird question, so I'm registering some ConfigurationSerialization classes, and was wondering if someone were to reload my plugin, would those classes stay registered? Or would I need to unregister them to prevent memory leaks?
public final class OfflineCommands extends JavaPlugin {
static {
ConfigurationSerialization.registerClass(UserStorage.class);
ConfigurationSerialization.registerClass(CommandStorage.class);
ConfigurationSerialization.registerClass(SoundStorage.class);
}
// more code
Ugh I got no clue how static variables behave with classloaders
I've done some debugging and apparently they are
for now I'm going to unregister them onDisable, hopefully nothing will break 😏
people just shouldn't reload anyways lol
iirc
It should flush it no?
it depends, usually static stuff persists between reloads
Between restarts?
you'd have to have something like ConfigurationSerialization.unregisterAll
or use proper objects
to store your serializations
Doesnt plugin manager invoke that after all onDisable calls?
sorry, i meant reload
🤷 This is what my onDisable looks like now lol
@Override
public void onDisable() {
this.userConfigData = null;
HandlerList.unregisterAll(this);
Bukkit.getScheduler().cancelTasks(this);
ConfigurationSerialization.unregisterClass(UserStorage.class);
ConfigurationSerialization.unregisterClass(CommandStorage.class);
ConfigurationSerialization.unregisterClass(SoundStorage.class);
}```
plugin manager deregisters ur listeners and cancels all ur scheduler tasks
so no need to call that
i'd still suggest using a non static class system
Yeah I have to use statics or the bukkit api flips out
It would otherwise claim those files don't exist (sad)
wait, is ConfigurationSerialization. a bukkit class?
Yes
oh wow
It’s essentially an IdentityHashMap<Class<? extends ConfigurationSerializable>,ConfigurationSerializable>
https://www.spigotmc.org/resources/deluxeasyncjoinleavemessage-fully-optimized-async-everything-open-source.88129/ - GitHub - conclube/DeluxeAsyncJoinLeaveMessage: https://www.spigotmc.org/resource...
Lmao pls
why not
You know what, it does deserve an update
oh my god the code is worse than i remembered
"//make all IDEs stfu
@SuppressWarnings("all")"
i never looked at the coude becasue my browser would die
it's
art.
all least no warnings
Lmao
This made me exhale more than usual XD
as does it
downgrade to 1.7.10?
folia support?
It does
fancy seeing you here!
sometime i’ll show you the plug-in I made
my o3c has almost arrived
Issue of instancing
is there a reason why mojang has a random per living entity?
i mean using a single one should give the same randomness or am i wrong?
O.o
you use a random per object when you want a "random" but repeatable result
ie a world seed will always generate the same terrain, even though it's "random"
If multiple objects pull from a single random the result will be random but unrepeatable, unless you perfectly preserve the sequence
which is what 1.20 is doing now I think?
am i get ProxiedPlayer's ip adress ?
oh i see
why does this say?
that runtasklater cannot be applied to my main class as the whole plugin is in my main class
} else if (this == LIGHTNING) {
// Make thunderstorm by right clicking
player.getWorld().setStorm(true);
player.getWorld().setThundering(true);
new BukkitRunnable() {
@Override
public void run() {
player.getWorld().setStorm(false);
player.getWorld().setThundering(false);
}
**}.runTaskLater(this, 2400);**```
well
?tryandsee
so whats the issue? that code looks fine to me
'runTaskLater(org.bukkit.plugin.@org.jetbrains.annotations.NotNull Plugin, long)' in 'org.bukkit.scheduler.BukkitRunnable' cannot be applied to '(org.sveaty.powerv2.PowerPlugin.Power, int)'
thats the problem descripitonđ
Pass the plugins main class, not your Power class
oh is that what you mean by "the whole plugin is in my main class "
whats usage of setLastDamage();
i tried player.setLastDamage(646);
but it doesnt even work
maybe 646D?
its double in the docs
idk then
Can u send code?
are you sure you are setting it in the right timeframe
player.setLastDamage(6354D);?
with context
wym
k
"Sets the damage dealt within the current no damage ticks time period."
@EventHandler
public void onDamagePlayer4(EntityDamageByEntityEvent e) {
Entity attacker = e.getDamager();
if (!(attacker instanceof Player player)) return;
if (Objects.requireNonNull(player.getItemInHand().getItemMeta()).getDisplayName().equals(ChatColor.BLUE + "Emerald Katana")) {
ItemStack emerald = new ItemStack((Material.EMERALD));
if (player.getInventory().contains(emerald)) {
player.sendMessage("a");
player.setLastDamage(6354D);
}
}
}
}```
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent
use the events method
and pls use pdc
🫡
hi bro can u give me idea for connect minecraft account to discord account
i was think this ip minecraft member ip adress equals discord member ip
send connect request to discord member in dm is this good?
uh
i have no clue what are u trying to say
hes just asking if its smart to compare ips to see if the discord account and mc account user is the same
that's not smart
the usual way is to send a verification code (e.g. a 5 digit number) to either the discord user that they have to enter in minecraft, or vice versa
basically just like !verify works here
Is there a feature in the essentialsDiscord api for that?
i gotta say that u may link minecraft account to discord using bot with console stuff
but it doesnt look smart anyways
You can use microsofts verification system
Is there a library that generates these random codes?
Microsoft has api end points to verify accounts
well im offline
will work in my server ?
No. At that point not even sure why you are trying when you cant guarantee accounts
^
why’s that tho?
forgot to say i have bot
because people could share the same IP and also how would you get a discord user's IP address in the first place
kindly ask them 😄
well jda don't do this ?
i mean get ip address
yes can't
wait you have an offline server?
At this point it is useless to continue with trying to resolve the issue because they only way you can do this is making people register an account. Doing this however is considered circumventing drm and thus puts you at high risk of being in mojangs and microsofts crossair
And since spigot doesnt support piracy nor myself you are at the mercy of no support.
yeah offline mode is not supported also due to the lack of things you can actually do without a proper account
like this kinda stuff
md5 is support offline ?
Md5 does not support offline mode
he doesnt develop bungeecord ?
bungee runs online
I have not heard of anyone supporting offline mode if tehy arent using it themselves xD
Mojang is the one that put offline mode in their game to support organizations that are ran offline such as lan parties or families that want to run servers not connected to the internet
thats minecraft
.
offline mode was never intended to be used for illegitimate accounts
Md5 does not remove vanilla features and does what he can to keep such things intact
its not called illegal mode for a reason
hey can we add like this on our plugin page
for other payment methods
- polymart
- kofi shop
- bbb
However that doesnt mean he supports such features either
I dont think you can
u sure?
shd i mail?
So what would you do if you were in my place?
example
customers likes melon ice cream but you insist that you will produce strawberry ice cream
You are right not to help with my questions for offline
but it's stupid to judge me on other issues because of that
well its just that those issues heavily depend on you having an account
No one is judging but since i dont support piracy nor does spigot i cant help you further circumvent
ur right mb
I already told you what would be required and told you the possible risk you run
when i generate the terraing the server freezzes for 5-7 seconds is there a way to prevent the freeze?
?flags
Aikar's garbage collection flags: https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
Other then that link better hardware or better hosting provider
split the generation into parts, chunks if you will
do it over several ticks
ok thank you
how would that be possible?
you want to get the ProxyPlayers IP? get from his connection in bungee
he was talking about your discord ip
ah ok, he was talkign about ProxyPlayer before so I assumed
is there a way i can make a gui icons texture invisible
so the player can see the name and the lore when they hover over the slot but they just dont see the item
yes, a resourcepack
Are there any player head textures that show up as nothing?
not that I know of, no
The closest to nothing you can get is light gray stained glass pane
or the other gray idk
im using a custom gui so that wouldnt look right
ill just add something to the resource pack
You probably know this but, you can use customModelData to not have to replace an item model
How do I ban players forever?
It does not let me put null as the date of the ProfileBanList#addBan
my IDE is telling me to fix it by puting (Date) null in there. is that the right way to do it?
I tried to put null. it does not let me
@echo basalt I can smell your jealousy from here
if only you could write code like this
3D-String-indexed object ?
Also, please new HashMap<>();
Your ide is crying about it
bungeecord have schedulers ?
they should
Yo everyone, quick question. I have a loop in my code, and when I run the metohod for calculate some data, server is freezing for some secounds. I was try use Taksers from okaeri and bukkit async but not help. Whats can by best solution for it?
?paste
and the method with for loop is in findSafeRandomLocation
i have a question for u i wanna send 2 message to player in same time
if someone sends a message at this time, will there be a problem with my message?
i mean like this
So what exactly is the problem ?
When the position is searching server is freezing(losing ticks)
Hello, simple question, is this;
public class Category {
YamlConfiguration file;
String name = file.getString("Name");
Double multip = file.getDouble("Multiplier");
String perm = file.getString("Permission");
public Category(YamlConfiguration file) {
this.file = file;
}
better than this? :
public class Category {
YamlConfiguration file;
String name;
Double multip;
String perm;
public Category(YamlConfiguration file) {
this.file = file;
this.name = file.getString("Name");
this.multip = file.getDouble("Multiplier");
this.perm = file.getString("Permission");
}
I guess you're searching in unloaded chunks ?
Also, why not use bukkit schedulers ?
u don't need get path ? for file
it's not better, it won't work
okay, thx
can u reply my question ?
no because, yml has already path
File file = new File(path);
YamlConfiguration yaml = YamlConfiguration.load(file);
ah aight
Yup I thing so. I not use the shedulers becouse my friend say "use okaeri, is more simple to use" xD
Idk what that is but the scheduled tasks might not get cleared when the server reloads.
So bukkit scheduler is safer in this manner.
okey I will try bukkit scheduler
Also, I think you can't load chunks async
(Or it is version dependant)
my silkspawners plugin don't work, when i destroy spawner with silk touch pickaxe spawner just destory and i don't get any spawner item
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Probably need to drop a spawner at the place the block broke
does someone know how to stop players from turning off candles and enlightened blocks
by cancelling the interactevent upon those blocks
you can also tell players that you're disappointed in them if they put out candles
"Listen, I am not angry, I'm just disappointed"
Or when they right click it, create an explosion, that'll make em scared
spawners are a restricted item?
or play the creeper ignite sound
wdym?
define restricted? Like can't get normally?
like worldguard saying NO.
can't break you mean or what?
dont matter they prob left
How does the speed effect work internally? Does it modify the walk speed attribute?
I imagine so considering you can modify attributes
use a potion see if it gets changed?
https://pastebin.com/z6b50cMt is this a proper way to get a yaml file?
it changes the velocity
Ah yes, that's correct
you should be using File.separator() instead of hardcoded \ separators
also where the hell is your messages file?
in resources folder
if I remember right default walk speed is a velocity of 0.2 or 0.3
the client when you walk sends coordinates, not directions of where you are going
the server uses this to calculate your velocity
as well as the client
Hey guys, I'm planning a larger project soon, in which moderation tools as well as mini-game components and events will be installed. Now my question is, does it make more sense to pack the individual areas into their own plugin or should I do everything in one plugin
separate it out
I can second this
why don't you just save the file inside the normal plugin's datafolder?
|-- main
| |-- java
| | |-- xd
| | |-- command
| | |-- utils
| | |-- MessageConfig.java
| |
| |-- resources
| |-- messages.yml
where?
that's the path included in your .jar
you get that using JavaPlugin#getResource("messages.yml")
or maybe JavaPlugin#getResource("/messages.yml")
but definitely not using a File object
a File object represents an actual file that's saved in the file system, not something included in your .jar
ok ty
try (FileSystem fileSystem = FileSystems.newFileSystem(zipFile, null)) {
Path fileToExtract = fileSystem.getPath(fileName);
Files.copy(fileToExtract, outputFile);
}```
what's the purpose of doing it that complicated, one can read a file using JavaPlugin#getResource, or get is as Reader with getTextResource, or directly save it into the datafolder using #saveResource
its better then what getResource does
how
the fact this uses the NIO java package and not the IO package
but how is that better if saveResource works totally fine and it's just one line
I never said it didn't work fine, I just said it was better
There are so many things that you can do with the input stream
maybe it'd be helpful if the person who originally asked this question would tell us what they're actually trying to do
indeed and more error prone as well 🙂
but, you can just create a filesystem though to pluck your magical file from as well
All io is error prone
some more then others, but the NIO package is what should be used whenever possible
IO if you need blocking or more compatiblity I suppose
I wonder how late my train comes today
It will arrive before tomorrow
if all they wanna do is to load the included messages.yml then all that's needed is this:
public YamlConfiguration getMessageConfig() {
return YamlConfiguration.loadConfiguration(getTextResource("/messages.yml"));
}
again you missed the point
No developing today?
all you see is 1 line missing the fact there is an entire implementation behind that
do you intentionally pretend to not understand?
no, I#m just trying to tell the person how to load their yaml file
So, actually, how would I make a system where the player can right click on mobs to morph into them? I thought of how I could do that but I got no idea
sometimes you make it seem that way and ignoring facts
you could send them into spectator mode
Nah, then they can't really control them and just be them
That's what I mean
Hard to explain
set them to spectator to get the effect of them morphing into them, then reset them back with a disguise
you would need to use a lot of packet manipulation
I thought of like just manipulating packets to make the player look like the entity but that sounds like a shit idea
As I have to implement all the mob abilities
you don't need to do that
Idk how
I mean you would need to have some methods or whatever but you don't actually have to implement anything in the methods
you can just use a throws unsupported exception
for anything you don't use
matchMaterial ?
worse that happens is you come back
Im trying to setResourcePack to a player, but have msg:
Server resource pack couldn`t be applied. Any functionality that requiers custom resources might not work as expected
here is code - https://pastebin.com/Ugig9Rbm
resource pack is working if i load it from client
server is 1.19.4
how do I get an enchantment by key when the enchantment is a normal minecraft enchantment?
getbykey requires an actual key
you're generating the SHA1 hash of the link o0
you need to create the hash of the actual file
NamespacedKey.minecraft ?
so i need to download file from link?
huh been using these for ages and I never even realized that existed for mc, thanks
or you simply don't send any hash
Yea, just make sure to never use the minecraft namespace
for anything in your plugin
but yeah if you DO send a hash, you have to hash the actual file
beyond accessing vanilla stuff
thank u
cough enchantment plugins often use NamespacedKey.minecraft for their custom enchantments
and they can suck it 
yeah... it was either EcoEnchants or AdvancedEnchantments that did this
like wtf, that's exactly the reason NamespacedKeys exist lol
What is the texturepack hash even for?
so clients can check whether they should re-download the file
same hash = unchanged file
not like Files.copy is non blocking anyway 🤨
Can someone help me with packets ?
I’ll ask java professionals where did you get information on java at the beginning of training (1-2 years) so that you know all the subtleties, etc.
how can i use .env with spigot?
Files.copy doesn't block
last I checked, in fact it isn't even defined and left to whatever implementation decides
what are you trying to do?
books
it might not be defined but it does block in practice
as of hotspot openjdk 20.0.2 🤓
i have classes in my plugin which relate to JDA and i need to store bot token
it doesn't
it does
alright prove that it does then
In a config
just use a normal config file for the token?
once Files.copy finishes the file exists and has the contents, to get there it has to block
literally look at the implementation, it reads the file whole, it writes the bytes whole
okay
once it finishes, which once its finished and you want to fetch contents that is a completely different operation
during the copy it doesn't block
my favorite java book is only available in german 🥲
no way
"Java ist auch eine Insel"
exception however if there is some kind of weird error or something pulls the stream out from under it
it does, mate, the channel is not opened in non-blocking mode
I will believe you if you can demonstrate it

the FileChannel for the zip file does not configure blocking(false), and neither is the fc for the target file
do you know how filesystem is implementated?
do you?
yes
clearly not
so demonstrate using the FileSystem API that it blocks as you claim
the filechannel used to read from the zip file is not configured to be used non-blocking
given that, you know, FileChannel doesn't even implement SelectableChannel which is the base for multiplexed non-blocking IO
surely you must know that
Filechannel isn't used here
no
yes
it is
show the source
github dot com slash openjdk slash jdk
so you can't got it
FileChannel is literally accessible only via FileSystem
or rather, the source of them
FileSystem is what may produce FileChannels, but FileChannels is not what is exclusively used in the FileSystem Object

There is Directory-Streams which is not a channel
but neither of them are what is used in the implementation for what FileSystem does
anyways, time for bed for me
https://github.com/openjdk/jdk/blob/9ded86821b01d6d790850e9b49eedfc597c0c9a2/src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java#L177
given that the zfpath is a Path from the default filesystem, it will be a regular FileChannel
and since copying between two different filesystems uses a regular newInputStream transferTo newOutputStream, it read from that FileChannel, which does not implement non-blocking IO because it is not a selectable channel which is the jdk's way of doing nio
check the ZipFileSystem source xx
Hello, is it possible te get file from yamlconfiguration ?
no
a YamlConfiguration does not "have" any file
ofc yo ucan just extend YamlConfiguration and add a File field
okok; because when i try to get my yamlConfiguration.getName() it return me null
if you specifically use zipfilesystem
FileSystems.newFileSystem(myFunnyJarFile) will use the ZipFileSystem
because it's the only registered provider for that file type
maybe you both could open a thread for your useful "discussion" about filesystem stuff lol
just admit that you're wrong, it's okay
I think the javadoc would even say non blocking if Files::copy would be non blocking to any degree per say
Hello, do a lot of spawners (who do not makes mob spawn) but with a mob defined inside can make the server lag ?
Bungeecord have a scheduler methods ?
Yes Bungee has a scheduler. ProxyServer#getScheduler()
its undefined
which means it depends on the implementation and if it chooses to block or not
It says that if the input stream is closed asynchronously, then it may be specific to the file system provider how that is handled
But thats it (async != non-blocking, and its for closing or interrupting only)
The behavior for the case that the output stream is asynchronously closed or the thread interrupted during the copy is highly output stream and file system provider specific and therefore not specified.
its left undefined
input is reading and reading doesn't inherently block
that doesn't mean it isn't blocking
if that weren't true, memory mapping files wouldn't be a thing
are you gonna close the FileSystem before the copy is finished?
because if it truly is non blocking then Files.copy will exit before the copying finishes
no it doesn't lmao??
It says in case of that the stream closed asynchronously or the thread u run it on is interrupted then yeah unspecified and handled by the file system provider
there is nothing in the source you gave nor in the api that states that the methods involved block or prevent anything from continuing. Reading doens't block and the writing doesn't block either. Blocking means that nothing can move forward and only those things must be done before anything else could ever happen
could ask you the same question
just because it's inside java.nio doesn't mean it doesn't block
have you been able to demonstrate the blocking behavior yet?
do you understand how file io works, do you understand how jdk filechannel works, do you understand how zipfilesystem works
you have given no proof that it doesn't block
so go ahead and provide source
i pointed you to it yes
no you didn't demonstrate it
you haven't deminstrated your point either
I don't need to because I am not the one contesting what I have said
you were the one that did
again, zipfilesystem uses a filechannel to read from the file, file io is blocking
filechannel literally cannot operate in non-blocking
well it can
it literally cannot
that means it can't be halted?
other things can't be done while it is also doing that?
the thread reading from/writing to the filechannel will halt until the read/write is finished, doesn't mean other threads will or can't use the fc
The FileChannel javadocs seem to support ^
I literally said this
that is not what it's about lmfao
now prove it
am I reading this right? From the FileChannel javadocs
but according to emily, File IO is syncronized for everything
in my dream
You are probably arguing about completely different things. This happened between Frost and myself in the past.
read the last part
synchronized != blocking same as asynchronous != non blocking
Other operations can be done other then writing at the same time
you have to use selectors for that, FileChannels are not selectable channels, SocketChannels and such are instead
you cannot do non-blocking IO on FileChannels
doesn't that directly support what Emily said? that reading write is blocking, but other stuff isn't?
channel's position is reading right?
That is literally not at all what I was saying anyway
i am saying the IO operations themselves have to halt the current thread
,
that is what non-blocking is all about, not blocking the current thread for the IO ops, which FileChannel cannot do
oh yeah ok, even I read that wrong.
and again you have given absolutely no proof that the thing actually is non-blocking, SelectableChannels can be configured to be non-blocking to be used with a Selector for multiplexed NIO, FileChannels are not selectable channels, using a FileSystem to read from a jar/zip file will use a FileChannel as I have literally pointed to in the source code, but even if that was implementation detail, Files.copy has to block given that "On return, the input stream will be at end of stream", that can only happen if all bytes have been read by that point, which can only be the case if the current thread is blocked, it also uses InputStream.transferTo which says the same, and it also says that it may block indefinitely to consume the input stream (and writing to the output stream)
now please provide proof of your claims that it actually is non-blocking, just how i showed it is blocking, because all you have said until now is "it is non blocking" and nothing more
i have never seen someone who is more confidently wrong about anything than you
and that is quite the achievement
Yeah both copy methods that do take an input or output stream return the amount of bytes read/written, wouldn’t make sense if it now were non blocking or async for that part such that the functions return earlier than when the io ops complete
well its not atomic
you could technically have Java report it completed something before it actually did complete something lol
it's not atomic with respect to other processes doing IO on the same file (unless you pass the option)
but that has nothing to do with what i'm talking about
But there is no set standard in regards to the OS and FS in relation to when an operation completes and is released
hence why the events can appear in an order you weren't expecting
ok?
in other words when Files.copy says its done and you check you can get filenotfound exception, consequently you can also just get a partial of the file instead
partial copy != non-blocking
well OS and FS doesn't block
do you understand what non blocking even is
@EventHandler
public void onDamagePlayer4(EntityDamageByEntityEvent e) {
Entity attacker = e.getDamager();
if (!(attacker instanceof Player player)) return;
if (Objects.requireNonNull(player.getItemInHand().getItemMeta()).getDisplayName().equals(ChatColor.BLUE + "Emerald Katana")) {
ItemStack emerald = new ItemStack((Material.EMERALD_BLOCK));
if (player.getInventory().contains(emerald, 10)) {
player.sendMessage(ChatColor.GRAY + "Spent " + emerald.getAmount() + " Emerald block, Dealt " + emerald.getAmount() + " Damage.");
player.getInventory().remove(emerald);
int damage = (int) (emerald.getAmount() * 0.2);
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 30, damage));
}else{
player.sendMessage(ChatColor.RED + "You don't have emerald...");
}
}
}
}```
help it didnt work even i have 10 emerald block in inventory i still dont get effect and only got prints out "You don't have emerald"
what is this
emerald
kantna
i mean its like emerald blade
in hypixel skyblock
its 1.14
Yeah frost its def not atomic, you’re correct there, that would make it absurdly unoptimized I’d imagine, but I think Emily was arguing about that you asserted it doesn’t block which we concluded it does
Still should work fine unless you are in a far earlier version
idk if it works with 1.18.2
It should
1.14 and higher
Many reasons, I believe comparings strings are typically slower, using data is uniqe and more reliable, etc
idk if it would be unoptimized, but it would definitely be interesting to see two opposing events appear at the same time for the same thing
XD
I don't have a quantum computer
idk but i gotta say im lazy af so 😅
only way I can think of where you could have two things happen at the same time that would be opposing since you know super positions
Lol, it's not terrible to use names, it's just not reccomened
anyways can someone help me with
@EventHandler
public void onDamagePlayer4(EntityDamageByEntityEvent e) {
Entity attacker = e.getDamager();
if (!(attacker instanceof Player player)) return;
if (Objects.requireNonNull(player.getItemInHand().getItemMeta()).getDisplayName().equals(ChatColor.BLUE + "Emerald Katana")) {
ItemStack emerald = new ItemStack((Material.EMERALD_BLOCK));
if (player.getInventory().contains(emerald, 10)) {
player.sendMessage(ChatColor.GRAY + "Spent " + emerald.getAmount() + " Emerald block, Dealt " + emerald.getAmount() + " Damage.");
player.getInventory().remove(emerald);
int damage = (int) (emerald.getAmount() * 0.2);
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 30, damage));
}else{
player.sendMessage(ChatColor.RED + "You don't have emerald...");
}
}
}
}```
help it didnt work even i have 10 emerald block in inventory i still dont get effect and only got prints out "You don't have emerald"
this
it depends how you compare them
True beans
ah i highly recommend use name to detect item
instead of tags idk if tag works stuff like enchantment but
itemname will never have kinda issue like if u add an enchantment entire ability wont work
What if I rename my item in an anvil
if you use .equals() its super quick as it isn't comparing the string literally
rather just that its contents match
yep
i think u wont have an anvil in a skymine server
💀
Objects.requireNonNull 
intellij be like ^
i mean i can just cancel every anvil event tho smh
IntelliJ does this to annoy me on purpose
Yeah, well I was more thinking similarly to how normal weak-compare-exchange low level shit happens, altho a file copy is quite the step from merely a variable mutation

Does your thing still not work?
yes, the code you pasted
yea not workin
it does work but it wont allow me to get more then one emerald block
You can give yourself more than one emerald block by setting the amount next to Material. Emerald_Block
uh
i mean
@EventHandler
public void onDamagePlayer4(EntityDamageByEntityEvent e) {
Entity attacker = e.getDamager();
if (!(attacker instanceof Player player)) return;
if (Objects.requireNonNull(player.getItemInHand().getItemMeta()).getDisplayName().equals(ChatColor.BLUE + "Emerald Katana")) {
ItemStack emerald = new ItemStack((Material.EMERALD_BLOCK));
if (player.getInventory().contains(emerald)) {
player.sendMessage(ChatColor.GRAY + "Spent " + emerald.getAmount() + " Emerald block, Dealt " + emerald.getAmount() + " Damage.");
player.getInventory().remove(emerald);
int damage = (int) (emerald.getAmount() * 0.2);
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 30, damage));
}else{
player.sendMessage(ChatColor.RED + "You don't have emerald...");
}
}
}
}```
look at this
the ability works
but if i have more then one emerald block
boom player.sendMessage(ChatColor.RED + "You don't have emerald...");
i dont have emerald
bruh
Don't you need 10 when it checks the inventory?
You have 4 onDamagePlayer methods?
lol
naw thats just a random name
the four at the end is just vibing there?
4 is a party, 3 is a an awkward duo
Try adding a check to see if the inventory has more than 1 emerald
oh, lol , party party.
If I remember correctly, you need to specify the amount when it comes to inventory stuff
revives
🫡
dies of cringe
its 2023...
among us
i wonder if i can do player.getInventory().contains(emerald.getAmount)
or smh
don't remind me 🥲
that would just return an Int
then how do i check if player's inventory have emerald
I believe you were on the right track, you just need to make a seperate if statement involving the amount of emeralds
.contains() returns an ItemStack, which you already specified.
Now you need to check the amount of the emeralds which you already pointed out by using .getAmount()
you good. 1 line, amount, emeralds, check
^
or "I have not undergone the verification process."
gotta love how people is ready to be second mee6 when i type something wrong
Well, we are correcting you so you don't make those mistakes again
Otherwise you will continue writing it that way and be wrong
This type of english correcting is over used
and starting to be a roast
many people just correcting english for fun and having beef
like this? if(emerald.getAmount() > 0)
I don't think you want a negative emerald amount right?
You're good
Hey, i'm trying to prevent the tab complete and make a custom one to handle it by myself.
but when i try to press tab there's some bungee commands appears with it, how can i prevent this? and that's the code using protocollib
manager.addPacketListener(
new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.TAB_COMPLETE) {
public void onPacketReceiving(PacketEvent event) {
if (!event.getPacketType().equals(PacketType.Play.Client.TAB_COMPLETE))
return;
event.setCancelled(true);
String[] x = new String[] {
"hiu", "meow", "xd"
};
PacketContainer container = manager.createPacket(PacketType.Play.Server.TAB_COMPLETE);
container.getStringArrays().write(0, x);
manager.sendServerPacket(event.getPlayer(), container);
}
});
that's what appears
oh i'm using bungee btw
won't that crash the server as you keep cancelling the event, then send a new packet, cancel that again, etc ...
Is it possible to check if the server is in a bungee network? I want to register commands only if there is no proxy infront, otherwise I want to let Bungee handle it
i have no clue tbh, what do u recommend to me? i'm all ears
create a field "ignoreNextPacket" and set that to true before you send your own packet, then set it to false again after sending it, and at the top of the listener, return immediately if taht field is true
You could try to edit the packet if possible
also TAB_COMPLETE is sent when a player presses tab inside a command, you seem to want to change the command list instead
i need to remove every tab command/chat in the server and remove the defaults too
i'm sorry but i understand nothing what should i do
what do you not understand?
No it's a field alex just told you to create
wait can i handle this from bungee?
private boolean ignoreNextPacket = false;
// Event handler
public void onPacketSend(PacketEvent event) {
if(ignoreNextPacket) return;
// ...
ignoreNextPacket = true;
// send packet
ignoreNextPacket = false;
}
ohhh
otherwise you listen to your own outgoing packet
wait i understand
i guess it will loop cuz i recieving a packet and making the same so it fires again and again
also you have to listen to this packet instead
it contains the list of all commands
@tender shard but there's bungee commands too, so should the bungee handle this?
ofc, you must do that from bungee
or you simply don't give permissions for those commands, then they won't show up
interesting but how can i tell you that i'm not registered any commands
xD
?
and if i register them, still i need to handle the tab commands for another things too
no clue what you're talking about
forget about it xd
the list of commands is completed client-side
the top-level command names are sent to players right after they joined, and it will only include commands the player has permissions to
probably only with protocollib. in spigot there is PlayerCommandSendEvent but it won't include the bungee commands
i'll try the bungee event hopefully it work :3
and if not i'll try to depends on protocollib
ProtocolLib packets can hold metadata
wait i can insert some additonal data to a packet?
wait when recieving the packet i will read the data?
give me an example please 🥺
*opening vscode*
what's the point of the unused type parameter there
autocasting or something
wdym?
getMeta could autocast your stuff
no clue about setMeta but maybe to look better than just passing any object
how would it know which type something is
just unsafely casts
it's an optional
it's an optional
yeah well but still
it'll throw cast errors in runtime
exactly
try this packet.getMeta("asd").orElse(default here) and you can check
and for the set method, the T is completely useless, isnt it?
it is
I know how optionals work, I'm just here to say the type parameter is useless
and uhmm it works for me, but still i locating the bungeecord commands, how can i remove them?
you'll need to make a bungee plugin
it is
plugin do what?
bungeecord injects its own commands on top
so you'll have to look for them in bungee and not in spigot
you cant remove bungeecord commands with a backend server plugin
i know i need to remove them from the suggestions or smth
As I said
also with a bungee plugin?
The backend server doesn't have context of what's on bungee
i already said 15 minutes ago that you need to use protocollib on bungeecord
doubt plib supports bungee
it doesn't?
wait protocollib supports bungee?
it isn't
can someone give me a quick example
multi-platform code is icky to make
one more reason not to ever touch protocollib
takes 19 years
you gotta make interfaces and abstract classes for everything
and plib is hacky
it's literally just an nms reflection thing
with wrappers
nah i'm not gonna do anything with plib thank you xd
i dont really like using protocollib ngl
would rather not depend on a hacky system updating
well
protocollib is quite garbage imho
plib isn't super hacky
You lgbtq+-=><[] 123434 ??
it's just a huge wrapper
yes
wgat
i got an idea
i will cancel the tab complete event from bungee and send a tab complete from spigot
help me then 😢
Just dont assign permissions to players for commands they shall not see
i'll try it ig i have no choice
nah i'm just built diff
i disabled the commands on bungee and it works
Does the crops tag only include stuff on farmland? I am running a test right now to prevent crops tagged blocks from being destroyed, and it works on seeds but not sugarcane.
Is there a tag for stuff like sugarcane, cactus, cocoa, etc?
these are all crops
sniffer 1.20
?paste
who has ideas how to check your code for quality and optimization
create unit tests
use your eyes
Is it possible to get the pushed block in a piston extend event, or should I find it by using the direction of the piston?
getBlocks()
getBlock() is the piston, getBlocks() is the list of pushed blocks
declaration: package: org.bukkit.event.block, class: BlockPistonExtendEvent
Oh, I was looking at the BlockPistonEvent
that's an abstract class, you cannot even listen to that directly
is there a "vanilla" way in the bukkit api to bind the compass to the player so that the arrow points in his direction (and does not freak out in hell if he is also there)
In modern versions yes
declaration: package: org.bukkit.inventory.meta, interface: CompassMeta
hello, with redis to avoid update problems (for example, if a piece of data is supposed to no longer exist but the request hasn't arrived yet and the db is being queried on another server, this can lead to duplication bugs). That's why I came up with the idea of making a boolean so that when a request is made, we wait for it to be false and then synchronize it on each of the servers using a borker message system to inform us that the database is in use (it's a kind of multi-server redis lock system). The only small problem/risk: if 2 servers make a request at the same time, the var cannot be acted upon. Is it a good system?
i think gridbaglayouts are great
i used jframes myself and it's not that bad
tho i haven't made anything too complex
i'm looking for design api
Try to implement an atomic design that is, all or nothing
unless you don't mean by jframes swing
Hey currently I have an armor stand I created with packets but it follows the player as a nametag but it prevents players from placing and hitting things because the hitbox is in the way
How do I prevent that
Its great, it includes a few different themes and you basically only need one line of code to use it
Set it to be a marker
wym?
declaration: package: org.bukkit.entity, interface: ArmorStand
They have a smaller hitbox (or none at all?) iirc
but you can never be 100% sure that there's no desynchronization?
thanks @tender shard
Well there are certain algorithmic designs one can use, and other so called principles such as being disciplined in the way ur data exchanges work
For instance consider a tree
- SQL (Persistence cache)
- Redis (In memory, fast cache)
- Server1
- World37
- World_Nether
- Server2
- Overworld
On read u only go up in principle (sometimes u might have to cache respective layers if said entry isn’t already there)
On write you’d have to invalidate all layers that have to be written to, that is for all layers x, for all parent layers y of x, if x does end up being written from then y needs to be written from too as well
redis has like 5x less write latency than sql
but they're not that far apart in read speed
and then you make sure that either:
concurrent writes are doable, this by maybe comparing time or if the writes can be done in any order, for instance lets say I’m adding money to a bank account twice , the order in which the operations actually take place can happen two ways, as long as I still know which one was initiated first (which we can sorta do by using time sortable snowflakes or just timestamps)
or u make it so that if one write happens it makes sure all other writes that may have tried to take place approximately the same time are discarded and have to be re written
This mode requires discipline and ensuring high durability, availability and isolation along with atomicity is hard
but even then, if the request is sent a few ms before the lock is activated^^.
Redis lock is just an exclusive lock tho
No?
I mean locks are great just fucking slow
Take ReentrantLock in java
Good shit but slow
StampedLocks, mye somewhat better since they don’t need that reentrant implementation but they’re still slow
Hence why if you can get an atomic design, then that may sometimes be quite rewarding
but I guess StampedLocks only work on one server?
