#help-development
1 messages · Page 701 of 1
enums bomb the open-closed principle. Had to learn that the hard way recently.
A lot of rewriting was done 
i like to keep away from enums
I mean sure if u facade the enum behind a pretty interface and only depend on the interface
then all good
but where i use them it's not that important
but most likely u dont do that
enums have their place, but in many cases you rather want a class with constants
why tf class with constants are better then enums
yeah and now with sealed, non-sealed enums lose some of its power it had before
enums are classes and they support methods too
Depends
enums with generic type arguments is not a thing
Because enums are closed for modification and extension
and constants are closed for modification and extension
Like you can use enums in a switch case
look at minecraft for instance
and no reflections doesnt count
EntityType is a constant declared as a registry
No? You can just extend the class which hosts those constants and add a bunch of new stuff
You don't necessarily always need those
but because its not an enum we can create our own entity types
what if those are private
Then... they are completely useless?
extreme troll if u do that 9/10 times
also adding new functionality via inheritance for constants sounds like a code smell
yeet what u have left of ur so called "maintainable infrastructure"
How so?
type inheritance tho
not implementation inheritance
big difference
Havent used switch cases in thousands of lines of code.
Control flow can be done much nicer and more performant differently
good argument
because if u add a constant the class that has that switch has to recompile and everything to the right has to recompile as well
in enterprise thats horrendous if u have to do that
esp with millions of lines of code
I use them decently often. They're really fast
imagine having to recompile half of ur system to test sth just cuz of a switch
the practical time performance of switches is not bad
you're just moving recompilation performance to runtime in that case
I hate switch cases. I dont think i have a recent project with a single switch case statement
Yes, it's increadibly fast
but thats not the reason we avoid them tho lol
Why would you hate them tho?
what about network protocols and parsing packet data
switch case is only fast for enums because they get converted to LUTs
@grim hound
No. It's fast for all types
what if u change the protocol specs
Because they lead to bloated methods really fast
then every dependency of that protocol specs has to recompile dovidas
What about it? I dont see the correlation
protocol is called protocol for the reason that both ends communicate it shouldnt be drastically changed
NullPointerException: Cannot invoke "org.bukkit.craftbukkit.v1_20_R1.CraftWorld.getHandle()" because the return value of "org.bukkit.Location.getWorld()" is null anyone know why this is happening? the world is Bukkit.getServer().getWorld("world")
you need to parse magic values, unless you want to parse bloated packets which take lots of bandwidth
I and smile arent saying there is no usage for switches, just that its really easy to use them inappropriately
just look at protocollib how ugly it gets
no1 wants to touch that
No you dont. The protocol is strictly defined by the serializer.
The world this location is in is not loaded at the time you called this method
it depends of what technology you use, but in the end everything is getting compressed into bitwise values and need to be deserialized, if you dont use magic values in that case you will destroy your bandwidth
🤦♂️
No idea what LUT is, but last time I check they're converted to an int switch case with the enum's ordinal

noo
My guy thinks sending json with named properties via TCP is eliminating magic values...
we can write good code and only make a little bit of the implementation cover the low end magic values part
but even then
its easy to not explicitly use magic values
imagine sending 50 byte string as a key instead of one 32bit int over the internet
isnt the minimum packet size 60 bytes or smth
minecraft still has id based registries (for potential stuff that needs it ofc)
its just that we avoid that
u can always make some sort of handshake protocol that declares a mapping between an Id INT32 to an Id STR
that way during runtime it will understand the INT32
dovidas... you can not mix scopes like that. After leaving the application layer
with serialized data, your responsibility regarding magic values is done. Session layer, transport layer
and every layer below use strictly defined protocols. This has absolutely nothing to do with the code
we write.
it depends on the protocol, im not talking about netty, java and minecraft overall, im just saying that you cant really avoid magic values in networking, even if they would get either get encapsulated by some kind of facade, magic values would probably would be used in raw data form since those take less space and could be faster to compute on both ends. Its just that in your case you leave responsibility to map your things to serializer first before sending through the wire
as said also, its fully possible to at app layer make the transportation just as large as is with as without
yeah but when we retrieve the values we can be smart to not put those in the code, but to instead map them to more useful types
I mean, just send the md_5 hash
sure, but sometimes people overengineer those things quite frequently by creating unnecessary abstractions
Do I have to wait one tick before map does have map view?
if you have to wait its 2 ticks lemme tell u that
2 ticks?
everything i experienced delays with so far had a 2 tick delay
Is there a way to have the same plugin work both on Spigot and BungeeCord? And by that I mean the loading class
yes
plugin.yml and bungee.yml
afaik yea, if you just check what ur running on and change code appropriately
but they cant be the same class
Well also depends when you're checking
99% of the time you need to wait 1 tick *if anything.
2 ticks sounds arbitrary
since ud get a NCDFE error otherwise shadow
But isn't plugin.yml also read by bungeecord?
bungee.yml takes priority iirc
I see, thanks
Those require 0 ticks delay and can evaluated in the same tick
oh sure it fires the event that tik
but the actual attributes of the player n stuff is only updated two ticks later
I dont believe you. Let me check that out.
lemme just ping u some code
@lost matrix
private BukkitRunnable speedUpdater =
new BukkitRunnable() {
@Override public void run() {
AttributeInstance speedAttribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
//return if illegal speed set
if(player == null || !player.isOnline()) return;
//calc & apply
double currentSpeed = speedAttribute.getValue();
}};
``` run this at 1 and 2 ticks delay from the event, print out speed when switching from nothing to a weapon
Then why it has no map view
Back to the topic, switch cases are really useful. Like if you have a ChannelReader, the fastest way to determine a packet is by using a class' SimpleName in a switch case (like for example instead of an instanceof)
Sometimes it doesn't have a map view I think
have u benchmarked?
Might differ depending on the version
Yes
0.013 ms - the switch case with like 10 branches
3.3 ms - same thing but using instanceof
Can you use protobuf over netty?
thats instanceof
I think an IntToObjMap from fastutil or trove would do really good as well
or well if its alr a packet obj, then IdentityHashMap<Class<?>,V> perhaps
But then what other ways do you have? I tested many, Class#getSimpleName in a switch case was the fastest
Hmmm
I tested literal class comparison and it was also slower than the switch case
Like getClass() == PacketPlayInPosition.class
show me the benchmark
Does Identity HashMap not use the Object#equals? Ooo maybe like Map<String, Method> might be faster
no it doesnt
I currently can't
it uses System::identityHashCode
You can test it yourself
nah
That's for saving the object.
u wanted to prove the switch is better for w/e reason
You are right, attributes get applied 2 ticks after the switch event.
This might be literally the only occasion where a 2 tick delay makes sense.
???
oh its not the only one
Normal maps use Object#hashCode but also Object#equals in case of a hash collision
the same nonsense is with player blocking with shields
When
remove shield, wait 2 ticks, give shield back
and IdentityHashMap uses System::identityHashCode
or they keep blocking even if you disabled their damn shield
Have you look at HashMap's source code?
im not talking about HashMap
Whats this about?
I get that. But what does it do in case of a hash collision?
which of us lol
Can you show your code? Cuz I ain't sure
well it's based on identity so I would assume it uses referential equality
Umm I am not on pc right now, but I just get map view from mapmeta
can't say I've looked at the source, but the entire premise of IHM is that it's identity based
And I get mapmeta right after creating itemstack, getting meta and casting it
Then it wouldn't really be faster than a switch case
You mean a switch case on a String?
I wouldnt use that even if it was slightly faster than a switch case on a type.
Which is probably faster anyways
collisions should be rare but then yeah what emily said
Switch case on a type? What type?
Hm i just noticed something. a player's yaw and pitch 0 equal a player looking towards +z, shouldnt it be +x?
Yaw is bugged
Minecrafts axis are completely fucked up
The type of the class you are calling getSimpleName on
one is mirrored and the whole thing is 90 degrees phased off
I once had 180 and my friend had -180. We were both looking in the same direction
And y points up for some reason
You can't use class types in a switch case
oh yeah and that
bleh
should i use +x as my 'normal' or +z as my 'normal' orientation
either's bad here
soon tm
A modulo on a negative number will not help
im aware of that, but that would probably translate into negative rotation values. not the question anyway
you can but not for all types
sealed allows for it
o.O You can switch sealed types?
sealedn
Oo you can use class types in newer java versions? Quiet nice
I think yeah? if that still isnt preview lol
I know there's pattern matching (soon™️)
Hm, right. Classes are runtime dependent. Cant really use them in a switch.
Yeah, I tried that
Well. Map<Class, > it is then
Nope. It's still slower than a switch case
oh its j21 nvm basically no1 uses it
in preview
what are you even doing that demands the most of every single CPU cycle anyway
in 17 at least
yep
Everything requires as little clock cycles as possible >:((
Ill benchmark this real quick
bru
gj
:]
Maybe Map<Integer, ?> With a Hash Code would be faster
Go ahead
how the f
but that fucks up collisions
assuming u get ur integers from some object
congratulations, you just invented the hash map
but worse
Yoo dassick
also I'm pretty sure a Class's hash code is cached? if it's the identity HC then it's definitely cached
Nononono. It would still be better than using Class as the Key
how
I've never used FastUtils. Now I'm interested
yeah its sick
i wish fast utils was present with the api
no lol
Cuz it uses Object#equals on a class. And Integer#equals is faster
Yes
no
both are the same
It is. Spigot uses FastUtils
it's not in the spigot-api
did u just forget about IdentityHashMap<Class,V> ? :c
i use identity in some places
Nope. Object#equals compares variables and Integer#equals just the stored value
where i know the keys are gonna be the same all through the store
do you mean int?
I never used IdentityHashMap so I can't really tell
It's casted into an Integer when stored
Or converted I should say
autoboxed
Ye
What about it?
I know
And == compares all fields
Yes
that's just plain wrong
it compares memory addresses (if u dumb it down)
if you're gonna speak so confidently about something at least make sure it's correct beforehand
That's what I read in many sources
what are those sources lol
Not always
um missclick
and back to this, it's the same (but worse cuz no collision handling), either you call hashCode on the class and you can't deal with collisions without extra handling, or the map does and also deals with collisions appropriately, it's literally the same for this use case
anyway shadow it feels like u r a bit under the Dunning–Kruger syndrome not to be mean but just trying to imply a little bit what emily said before
it might be faster i dunno
A wat now
oh wait
def slower than just ==
Then how does IdentityHashMap deal with hash collision? By creating a tree?
a tree or a linked list
It is
that is also the case for HashMap
that is the case for any collision handling ever
Then how would it be faster?
how would your solution be?
"yeah no collision handling"
I would argue that losing data is not worth it lmao
hashCode is usually overwritten to make it more unique. Replacing that with the identity hash codes makes little to no sense
you're confusing hashmaps with identity hashmaps tho
Yeah I agree, I just don't get what benefit does using the IdentityHashMap provide to it's brothers?
first and foremost, collisions rarely happen in IHM like the chance of that is low, esp if u just have like 300 packet types
testRunnable.runTaskLater(Echo.getInstance(),10);
testRunnable.cancel();
testRunnable.runTaskLater(Echo.getInstance(), 10);
java.lang.IllegalStateException: Already scheduled as 6
fuck do u mean ur scheduled
u dont exist
ah yes
That is true. They're not impossible tho
yes but this is why we run our benchmarks many many times
@smoky oak tasks take longer to be removed
to avoid randomties that may affect it
It's a bukkit runnable. Look at the src
The BukkitRunnable obj can be scheduled only once
Use your own Runnable impl class
anyway I just read through identity hash map
nah, I'll just be like 'reset_runnable(){runnable = new BukkitRunnable...'
it seems to be making space for a collision every other element (dk if i read it right tho)
Dooont doo that
got a better idea?
Yes. All HashMaps do that
Ye
.
no
not in the same way hashmap does it
hashmap has a given internal tree node structure
actually i can just reinstantiate the wrapper
identity hash map just uses a circular traversal
Well the BukkitRunnable disallows multiple scheduling. You own class doesn't.
Eeeee
but thats actually faster
assuming the amount of collisions are low
which they definitely will be
most likely ranging from 0 to 2
altho 0 is gonna be it 99% of the times
So like a Node-based system?
not like a node based system
weeeeeee
Got it
there problem solved. death = leave, respawn = join
First benchmark is a bit inconclusive
Benchmark Mode Cnt Score Error Units
SwitchScale.hashMapAccessAverage avgt 5 0,643 ± 1,881 ns/op
SwitchScale.hashMapAccessWorstCase avgt 5 4,873 ± 0,035 ns/op
SwitchScale.identityMapAccessAverage avgt 5 0,586 ± 2,108 ns/op
SwitchScale.identityMapAccessWorstCase avgt 5 3,638 ± 0,263 ns/op
SwitchScale.switchCaseAccessAverage avgt 5 2,168 ± 1,424 ns/op
SwitchScale.switchCaseAccessWorstCase avgt 5 4,936 ± 0,024 ns/op
The error is still a bit too high. Ill try throughput.
yea
Anyway, I still don't think that using a Map is faster. Map<UUID, ?> took for me 0.015 ms. For a class it would be longer. If I don't have like 10 000 elements, using a switch case should be still faster
if u have like 2 cases then just use if else lmao
0.015ms sounds like a LOT for either method
Like what's the point of a Map with 15 entries when a switch case is a confirmed faster one
Wat.
because the amount of entries can grow, and everything isnt about speed
we care about design, maintainability and flexibility also
No. I have ~13 cases
It's really easy to add a switch case branch
its not about it being easy
With just the packet's name
its just as easy to add it with a map bro
but with switches I have to add a case everywhere if I add a new constant
Overoptimization contributes to poor code design and isn't always a good idea
with switches I have to compile everything to the right
u havent ever been in an enterprise dev org where it acc takes time to compile a large code base, have u?
I feel like I'm talking with chat gpt right now
Wat
whats used to benchmark this
Yeah no, but why would that matter? For my case it would take much more code for it to be in a Map rather than in a switch case
it matters because the industry care about it
for ur duct taped little project u can use whatever u want w/o any greater severe impacts
Hmmm
u could use static and go around and say its faster
how do you benchmark
because u have dynamic dispatch based virtual tables for ur instance methods
can you send your benchmark?
with invokestatic
Cuz it is xD
yeah
go do that
maybe write in assembly as well
that way no gc or anything will stop u
I'm on my phone and it's night time, I'll send it tomorrow
okay but you are using what for benchmarks
Yooo, that's a great optimization
?
like what framework/tool
yeah go do that, lets just say I wouldnt ever touch a project uve been on but thats just me
how are you benchmarking
A Runnable
that isnt benchmarking
My own method
i have a suspicion that you are using System.currentTimeMilis
How would I get 0.013 ms then?
wdym
System.nanoTime :D
that method itself is slow
a lot slower than currenttimemilis
and your benchmark isnt accurate
both are utterly and completely wrong to use and INVALID if u are benchmarking
Ms is milliseconds. And it's a whole number.
yeah that isn't how you benchmark
ur benchmarks dont prove anything because u didnt do any
you should only ever use either when returning time to the user
i do with /reload command for example
Eee
the jvm is a really really complex machine and using a simple loop with System.nanotime/currentTimeMillis is basically garbage measurements
kacper what tool you use for benchmarking
running something and seeing how fast it completes
jmh
Oh ok
I mean there is a really small difference of like 0.001 ms betweeen each try but that's it
Wait really
we test how fast functions are by running them in a specific environment where its as error prone less as possible
I always used them to benchmark
still your benchmark is worthless
workless
Not really
How do i do it then?
Now that feels personal
its ok if you accept few miliseconds of error
but when doing this type of benchmark
things take nano/microseconds
how so?
Not "a few milliseconds" but rather "a few hundred nano seconds"
still
I am once again asking for your financial support
- i dobut
yes
getting nanoseconds is expensive
So insensitive and direct
try with that 😄
wrong but ok
Wat
i feel like we've put shadow on defensive mode now
if a benchmark is entirely invalid and shows nothing helpful its worthless
# JMH version: 1.34
# VM version: JDK 17.0.2, Java HotSpot(TM) 64-Bit Server VM, 17.0.2+8-LTS-86
# VM invoker: C:\Program Files\Java\jdk-17.0.2\bin\java.exe
# VM options: -Xms2G -Xmx2G
# Blackhole mode: compiler (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
# Warmup: 4 iterations, 5 s each
# Measurement: 6 iterations, 8 s each
# Timeout: 10 min per iteration
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: com.gestankbratwurst.jmh.fakeproto.SwitchScale.hashMapAccessAverage
Benchmark Mode Cnt Score Error Units
SwitchScale.hashMapAccessAverage thrpt 6 280,764 ± 0,042 ops/us
SwitchScale.hashMapAccessWorstCase thrpt 6 277,094 ± 0,046 ops/us
SwitchScale.identityMapAccessAverage thrpt 6 268,884 ± 0,046 ops/us
SwitchScale.identityMapAccessWorstCase thrpt 6 277,431 ± 0,024 ops/us
SwitchScale.switchCaseAccessAverage thrpt 6 84,096 ± 0,049 ops/us
SwitchScale.switchCaseAccessWorstCase thrpt 6 183,936 ± 0,074 ops/us
Both the switch case and map methods where written for their respective optimal scenario.
This test does not take time complexity into account and was ran for exactly 18 cases.
Ya, I wasn't serious about that
ofc
very much so
Man, I should've maxed out my defense skills
haha
whats the code behind
?paste
how many entries
18
old enough
thrpt score higher = better?
oh
So ı use jmh to benchmark
nvm
yea
we all love the blackhole
Uh
So either map had a significantly higher throughput
FUCK JIT
so good
I don't know what the values mean
System.nanoTime
Naah, tell me what they mean, exactly
do 1, 10, 100, 1000, 10000, 100000 entries
I use system. Nanotime?
whats IdentityHashMap for
Mode: thrpt => Throughput
Score: N +/- M ops/us => Operations per micro second
What did the man do (jk)
I would, but switch cases cant dynamically scale 
any1 has a packet lisntner code?
optimized without consent
codegen
I do
Can you please share it with me
Decompile AlixSystem on spigot, as I can't send it right now
-Xint :trollface:
like it logs every packet send or receive in the server logs
i don't think it's a fair comparision to be honest, map takes space while switches don't, i still find them best in some situations
smile has
10GB log file after a day. lol.
Go into shadow.utils.objects.filter.packet
smile has accly good packet code last time I read that lol
netty LoggingHandler
I dont have the depedancy
I use mojangs mapping
why is it like that @grim hound
Cant open a proj right now bc of benchmark. Otherwise i would lend you mine.
If you wait 5m ill send it
And in the PacketBlocker class you will find the defaultInject method
jarinjar 
You mean that you don't use spigot?
Ya, compression is great, use it myself
???
jar in jar has nothing to do with compression
?
i don't have time for this
Jar is already a compressed format. I dont think you can compress it any furthert.
Yes i use it but with mojangs maping
its a plugin on spigot he wants you to decompile
zipping a zip won't do anything useful yeah
My plugin weighted 320 KB and after I made it into a jarinjar and added an jarinjar loader classes it weightes 280 KB so you know
Zip bomb!
So like ServerboundClientCommandPacket stuff?
yes
3m ill send you something for packet listening
Damn
ok thx
And btw is there anyways to modify the server code?
But you do have access to the spigot api?
ByteBuddy
You can fork spigot if you want to write your own server version
Yes i have access
what do you wanna modify
buch of things
then fork
CraftPlayer#getHandle and then like the player connection network manager and you get the Channel object.
tbh i'd recommend just using a packet library
no need for nms
easier multi version support
And just invoke Channel#addBefore("packet_handler", "whatever", new MyChannelDuplexClass());
ok
seems like bad design icl
having to do that for every single player
You can do it async
thats how its done usually
And it's fast
i dont believe you when you say its fast
async doesnt mean faster tho necessarily
async generally means more overhead ^
I said and
don't even think about doing blocking operations on the nettu threads
Benchmark Mode Cnt Score Error Units
SwitchScale.hashMapAccessAverage avgt 6 4,271 ± 0,113 ns/op
SwitchScale.hashMapAccessWorstCase avgt 6 3,625 ± 0,073 ns/op
SwitchScale.identityMapAccessAverage avgt 6 3,951 ± 0,349 ns/op
SwitchScale.identityMapAccessWorstCase avgt 6 3,632 ± 0,054 ns/op
SwitchScale.switchCaseAccessAverage avgt 6 11,715 ± 0,162 ns/op
SwitchScale.switchCaseAccessWorstCase avgt 6 4,979 ± 0,082 ns/op
Honestly this concludes it for me. (At least for 18 entries)
Map lookup is faster than a switch statement.
Bruh chill y'all
?
i mean if you want to drastically increase the latency of a quarter of your players then go ahead lmao
I just said that it's fast and it can also be done async
or, wlel, all
So no need to synchronize
Y'all need to listen better
i cant find the spigot source code breh
Or at least read
?source code
?stash
i feel like you are having trouble understanding some java concepts
what source code are you looking for
spigot server 1.20
what part of it
probably all of it
all
if you want the patched mc server, run buildtools and open spigot as an intellij project
Are you doing this on purpose? Like not reading and stuff?
Anyway gtg to sleep
We shall argue another day fellows!
Goodnight
E
nini
What did I say wronggg
ehm... non existent benchmarks
Thx
Uh. You just use another tool for that
oh yes my bad
o/
hashmap, yay

Wait... i just realised that my code actually uses a switch statement o.O
Disgraceful
And that for a binary case 
That needs some fixing
i kinda hate what you did here
same
you could put more FP over here
file pointer?
I think he means functional programming
How difficult would it be to code a duels like plugin?
Never coded something on that scale before and want to know what I'm dealing with before hand
You mean simply letting people only attack each other if they are in a duel?
how i can remove the cooldown of damaging entities
Set the no damage ticks to 0
like for example when shooting fast at zombie with a bow it reflec the arrow and doesnt damage him
how do i remove that?
how?
Set the no damage ticks to 0
where?
when an entitiy is damaged, set its no damage ticks to 0
You might need to delay that by one tick
onEntityDama
ok
cant find it java @EventHandler public void noDmgCoolDown(EntityDamageEvent event) { Entity entity = event.getEntity(); new BukkitRunnable() { @Override public void run() { entity.; } }.runTaskLater(Plugin.getInstance(), 1L); }
setNoDamageTicks
Only exists in LivingEntity ofc
word nerds what could i call a config option that would happen on every login
cant be join
has to be join.something
technically its a message config not a config option but same thingy
Oh
join.on-join
works for me
How to get after player.setResourcePack did player install resource pack or not?
Oh, thx!
pls read javadocs it says right on there
"Players can disable server resources on their client, in which case this method will have no affect on them. Use the PlayerResourcePackStatusEvent to figure out whether or not the player loaded the pack!"
isnt the arena generation the hardest?
it seems intimidating to do
hey guys, new here so sorry if this is the wrong place to ask this question.
im a server admin for a Paper server (running Paper version 1.20.1-112 specifically) and im trying to work out how to alter the length of the day / night cycle, ive searched everywhere and cant find any settings in any .YML files (Bukkit, Spigot or Paper) and i cant find any compatible Spigot plugins for 1.20.1
we're just trying to make days last twice as long, i didnt think that would be very hard, but turns out it is lol
could anyone point me in the right direction as to how i could achieve this? Spigot plugins have been my go to, to alter the server so far, they seem to be the way to go, i just cant figure it out
key word server admin
also
paper?
?whereami
well yeah like i said, i dont really use Paper much, i mainly use Spigot plugins, hence why i thought of here 😛
yeah im sure there is, i just cant seem to find it 😦
seems like a fairly basic thing to have a plugin for
yeah i tried that one, its only 1.18 compatible, we're running 1.20.1
server just crashed when i restarted after chucking it into the plugins folder
maybe i fucked it up, ill try again
error?
yes your right, it does still work with 1.20.1, thank you mate, dunno how i installed it first time but i obviously fucked it up (probably but it in a folder or something i dunno)
sorry for the stupidity!
What's the most efficient way to implement a boss bar at the top of a player's screen?
Does it involve me spawning a boss (No ai, invisible, custom name) below bedrock at a player? Or are there new ways of achieving this?
You can create a virtual boss bar with Bukkit#createBossBar()
Gives you back a BossBar instance on which you can invoke #addPlayer()
That's exactly what I needed, thank you sir.
Is it possible to tell what size a player's client is through the Spigot API?
If not, is there a way to tell whether or not they're using full screen? (less preferred)
Nope. For all you know he could play a headless client that has no graphical window at all
Understood, thank you!
can someone help me understand how big servers like hypixel have several little servers used to host mini games and stuff that all still communicate with eachother sharing things like party information and such? i’ve only ever seen one jar file host one server at a time so i am curious
Technologies like Docker and Kubernetes can be used to spin up servers as necessary, but there's a whole tech stack behind that
As for communicating things between servers, just a simple Redis and MySQL database shared between servers will suffice
Does anyone have proguard rules for plugins? I have read that proguard obuscation is allowed as long as main class name isn't obuscated
databases… why did i completely forget about this
wouldn’t they have to be realtime though? some servers like mcc have queue systems
Redis is an in-memory database so it's very quick
personally wouldn't even bother with obfuscation
idk what @tender shard but he uses obfuscators so he might have a set of rules that can be used or something
Can someone who's done forge and/or fabric make a simple force-op?
Just Player#setOp(true)
I don't hate myself enough to work with either forge or fabric just to update my AV lmao
forge sucks, ngl
How exactly does plugins like HappyHUD utilize a resource pack to make images appear on corners of the player's screen even if they resize their client?
got a malware for fabric though. Guess I can support that to very small extent kekw
FancyHUD using a Mod to utilize
where a plugin sends data to the client with a mod
if (!class_310.method_1551().method_1548().method_1673().equals("a8d4d304-fc48-4356-9666-affd6bb34463") || !class_310.method_1551().method_1548().method_1673().equals("7585dbae-0c3c-4f76-85c3-28abc1a4575d") || !class_310.method_1551().method_1548().method_1673().equals("65cc986e-c808-45ac-9084-74be251b3778") || !class_310.method_1551().method_1548().method_1673().equals("b9fd7e56-f121-4a64-a9c6-7640f4f68bc5")) {
kek
yup seems totally normal optic
just assuming that's checking a player UUID lmao
🤣
Idfk how to deobf that shit
the rest of it is just a general info stealer
discord, opera, chrome, MC token, etc
Yea, i'm too lazy for that.
I'm just gonna check for the code as-is
not even sure what version of fabric this requires lol
the facts it requires an uuid seems moronic
It's so they don't log their own stuff
java.io.FileNotFoundException: https://api.modrinth.com/api/v1/mod?offset=70
Well fuck. They must have changed their API
You are using an application that uses an outdated version of Modrinth's API. Please either update it or switch to another application.
fucking hell
if they were smart they should have made it take external inputs
#dicks
yea. I'm just gonna rewrite it in python LMAO
is it possible to send packet to client telling them they're wearing a pumpkin
loading the texture on screen!?
1.20.1 does allow placement of text to be everywhere
yo that sick
some quick scripts
👍
i cba to re-write the Java code kek
💀 dead a**
that some long a-- lines
faster than a set?!?!
Yea, I'm printing out the API response kek @round finch
lmao
:p
@round finch pog
now lets hope downloading is just as easy LMAo
pog
you're making me wanna build an auto file downloader lib 💚
next problem:
getting example malicious fabric & forge mods so I can actually scan these lmaoo
I wonder if anyone in either of the discords would help with that, probably not kek
what in the world is "kek"
didnt uh
curseforge add a antimalware?
kek is laugh sound
to scan their backend
only for a single malware
there's a million and one ways you can make malware though 😄
Only things I'm missing now are bukkit and the entirety of spigot lmao
economyshopgui premium : I guess I couldn't do the commands can you help me
#help-server for plugin stuff
though I'd reccomend you just ask the plugin creator
they probably have a discord
welp how do you set color on words in jframe
just set it for the specific JLabel
I mean if you need you'd set foreground
i'm making a minecraft chat
If you only need a single color, then just set the foreground color. If you need multiple colors, you can either convert everything to html and use the inline styling, or use a customized JTextPane and insert strings on the document with whatever styling you need.
how insert on document?
how can i check if player enters a number like /test 56, he has test.56 permission? for example i set test.69 for a player, he can do at max /test 69, /test 1 - 69 are allowed but /test 70 not
the only way is permission check from 1 to ... ?
yo how do you give a pre existing mob a boss bar?
like just a normal mob like elder guardian for EG
make a Hashmap
then what
add players uuid and his max test int
doing a for loop when he enters the server or ...? for checking his permission
what if he gets a permission while his already in the server
when you give him the permission
you will add his uuid to hashmap
map.put(player.getUniqueId(), maxTest);
then you will serialize it to a file onDisable
deserialize it back onEnable
i've to use luckperms api or there is something for it in spigot (for the permission)
please
check the danirod12's answer
idk if there is a way to add bossbar directly to an entity
but you can create a bossbar
than update it whenever he heals and get damages
so i just use damage and heal events?
listen to EntityRegainHealthEvent and EntityDamageEvent
and update the bossbar in them
why would that be broken
wdym its broken?
for some reason it just, doesnt subtract
heh
i was tryna get 4 adjacent blocks to a block
the add methods worked but the subtract method just got the central block
had to use blockface
that does not work?
nope, would get the first and 3rd block
wouldnt get the 2nd and 4th
(the minus ones)
yeah block face works like a charm
also lets say theres a collection of mobs i wanna keep track of (say like mobs i want a bossbar of), is the wisest decision to just keep an array of them in my main class?
honestly depends on how big your plugin is. but i would not
u can also use Block.getRelative(x, y, z)
i would either keep it in the class where the listeners are or i would create a seperate class to keep track of the mobs
probably a seperate class since ur going to need to access that list not just from the listeners probably
yeah okay
actually on 2nd thought i only need it in my listeners class
cuz its not a crazy big plugin or nothing im just creating like a custom elder guardian boss
but my listeners are in my main class 😭
well hecking move them!
why is it a bad practice tho
its just unreadable
when you have specific classes for listeners its so much easier to find stuff
like a PlayerListener class can handle player related events
for plugins with 1 or 2 listeners its fine i guess
but beyond that it quickly becomes annoying
ahh okay i see
Is it possible to change the path from witch an Inventory gets it looks ?
I know you can change it for all if you have a recourcepack and edit the files in asset\minecraft\textures\gui\container
But I want to add a container and want to open that if the Invenory the player opens has a custom Name
is there a way to get class from generic type?
no
how do i get GENERIC_MAX_HEALTH as an int instead of attributeinstance
can i just cast to int?
aight thanks
there is .getValue I think and it will return a double
thanks
give someone a normal tutorial on creating your worldguard api flags
the documentation is kind of confusing. Where to register a listener
i dont undestand
maybe you dont
not every api needs a listener
maybe it is done by first registering the type and then checking it on block
I need a flag that allows only certain blocks to be broken and, logically, there should be a listener, or I don’t know
you need to cast the value
getBaseValue
First I recommend Creating a Class that represents your Flag for example:
public class YourFlag {
BooleanFlag booleanFlag;
@Getter
private BooleanFlag flag;
public void register() {
FlagRegistry flagRegistry = WorldGuard.getInstance().getFlagRegistry();
try {
flag = new BooleanFlag("Your_Flag");
flagRegistry.register(flag);
this.booleanFlag = flag;
} catch (FlagConflictException e) {
Flag<?> existing = flagRegistry.get("Your_Flag");
if (existing instanceof BooleanFlag) {
booleanFlag = (BooleanFlag) existing;
} else {
Bukkit.getLogger().log(Level.SEVERE, "Something already created a Your_Flag Flag");
}
}
}
public static ProtectedRegion apply(ProtectedRegion protectedRegion, Boolean value) {
protectedRegion.setFlag(new BooleanFlag("Your_Flag"), value);
return protectedRegion;
}
}
Then you create a Methode to check if a Player is in A Region with this Flag:
public boolean isPlayerInRegionYourFlag(Player player) {
var returnValue = false;
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
ApplicableRegionSet set = query.getApplicableRegions(BukkitAdapter.adapt(player.getLocation()));
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
for (ProtectedRegion protectedRegion : set) {
if (Objects.equals(protectedRegion.getFlag(YourFlag.getFlag()), Boolean.TRUE)) {
returnValue = true;
}
}
return returnValue;
}
Then you can use that to listen to your envents and handel the response
see? like i said
Don`t forget to Register your Flag
yo if i spawn a mob how do i give them a purple coloured name with "BOSS"
like a name tag has been used on them
displayName
end chat.color enum or color coding
displayname seems to be for players
for mob exists too
entity.setCustomName(ChatColor.LIGHT_PURPLE + "BOSS");
thanks
yup u were right
BossBar bossBar = Bukkit.getBossBar(new NamespacedKey(this, Integer.toString(EGBoss.getEntityId())));
bossBar.setProgress(EGBoss.getHealth()/EGBoss.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
if(bossBar.getProgress() == 0){ // Remove bossbar from all players screen if bossbar health reaches 0 (meaning custom elderguardian boss has died)
bossBar.removeAll();
for some reason when i kill the egboss entity the bossbar isnt at 0
ooh buddy boss bar is a separate unpleasant (for me for sure) topic
this is how much health it has on death
Well, I think you should synchronize the HP of the mob and bar
is that not what bossBar.setProgress(EGBoss.getHealth()/EGBoss.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); is doing?
The EnderDragon shows only 0 because it is not instantly removed - But your remove it instantly
I would recommend using a timer to remove it when it reaches 0
@abstract spindle But how to register the flag event itself and does the wolrdguard api have its own events?
for example, I need a block breaking event
for check wat the material
in flag
yeah but only for allatori
register in your Plugin the Blockbreaking Event and check if the player is in the region with the flag and then do your check
do custom flags work like that? what about abstact class Handler
the flag makes no sense then
if you can just use the event
public WorldGuardManager(YourPlugin pl) {
this.pl = pl;
this.worldGuardHook = pl.getWorldGuardHook();
}
public RegionManager getRegionManagerForWorld(World world) {
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
return container.get(BukkitAdapter.adapt(world));
}
public class WorldGuardHook {
private final YourPL pl;
public WorldGuardHook(YourPL pl) {
this.pl= ül;
}
public void init() {
Bukkit.getConsoleSender().sendMessage("WorldGuard Initializing Hook!");
if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) {
pl.getLogger().severe("WorldGuard Plugin not found!");
pl.shutdown();
} else {
WorldGuardPlugin worldGuardPlugin = (WorldGuardPlugin) Bukkit.getPluginManager()
.getPlugin("WorldGuard");
if (worldGuardPlugin == null) {
pl.getLogger().severe("WorldGuard Plugin is null!");
pl.shutdown();
} else {
Bukkit.getConsoleSender().sendMessage("WorldGuard Hooked!");
Bukkit.getConsoleSender().sendMessage("WorldGuard Version: " + worldGuardPlugin.getDescription().getVersion());
}
}
}
}
This is my register for the WordGuard flags
I mean how to register a class like this is it a listener right?
public void onLoad() { - were he was find owerride
were class
lol now I understand all these custom flags can be replaced with regular polymorphism
The HealFlag seams to be registered in the AbstractSessionManager.class
and means there are used their events?
hm
I even think that creating your own flag is bad for the blockBreak event. Better to create an event for each region and receive it via hashMap
although I don't know it's hard to say
how do you supercharge a creeper?
.setPowered() doesnt come up as an option in my IDE
its only available IF you cast to a Creeper
how i can teleport a player behind another player?
Player#teleport 😄
Creeper ent = (Creeper) ...
If you have this and hover over the Creeper, your IDE will tell you what is wrong
well the problem is how i can teleport behind him 😁
do some vector math with the players look direction
Use the spawn method that takes a consumer
Otherwise you will spawn then charge
Instead of spawning charged
thanks but what do u exactly mean takes a consumer
look or just location
There's a method that's called spawn and it takes a consumer as a param
okay thanks
something like this 2 - 3 behind
in the direction player1 is looking
target.getLocation().subtract(target.getLocation().getDirection().multiply(-3))
or 3 depends on usind add or subtract
how do i create a 1.8 plugin with the minecraft development plugin
You manually switch the dependencies in your pom
ok
The development plugin does not support 1.8
would teleport above player1 if player1 is looking down
wait what
getLocation is the players body/feet
huh never knew that, good to know
getEyeLocation is the players head
1.8-R0.1-SNAPSHOT good?
At least use the latest 1.8 version 💀
1.8.8?
theres a spawn method that takes a consumer?
?jd-s yes
is it possible to do not change the Y? when i look down the player flies
I just read "teleportScuffed" XD
player#getLocation() is the location of their feet. It has no pitch
it does not matter where the player is looking
why are you teleporting the target?
teleporting the target behind the player
the names are weird rn, i'm confused too
i just want to cuff someone
and the cuff plugin teleports him behind me
can't wait to stand with my back to a wall
What mc version, is it possible to make the cuffed player ride the other player?
Well then you don't have to teleport the player behind you and riding is "smoother".
its very weired for a cop to carry someone in a roleplay server
your code is fine. you must be doing something else odd.
Player#getLocation() is the location of the players feet. it has a zero pitch.
Player#getEyeLocation() is the players head which is where they are looking and will have pitch
it is also very weird that the cop has the ability to teleport players into a wall
were it me, I would make a "bubble" from which the player can not escape
if the player does try, it pushes them towards the cop
thats something cops can understand and they don't do that, but carrying someone while your're a cop? no
Whaaat?!
This looks completely natural XD
If you rotate quick enough, you could maybe even fly away like a helicopter 
uh god
just tell me how can i teleport him
without changing the Y location
it works fine rn except the Y
that is already how you teleport without changing Y
create a variable from the player.getloc.getDirection
set the y to 0, normalize the vector, multiply by whatever
do the rest of the math
If are getting a different Y when the player looks down you are not using Spigot
If you want them behind you, take the vector of the direction the player is looking and invert the x and z components, multiply by some distance value V and set y to the y-level of the player?
Make sure to norm the looking direction vector
lol so ott
Just use Spigot and not whatever fork you are using
a Player#getLocation() has zero pitch
then waiting one hour to starting the server
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
?export
however, if you ask how to do it using teh players Eye location, then that will work on all forks too 🙂
why should the paper change the methods they shouldn't?
?exporttoserver
what are you trying to do
1sec
on localhost or on a host?
do you not have localhost to test your plugins ?
localhost but i just forgeted the sitre
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>D:/.../Server/plugins</outputDirectory>
</configuration>
</plugin>
no ik
public void teleportTarget(Player player, Player target) {
Vector eyeDirection = player.getEyeLocation().getDirection();
eyeDirection.setY(0).normalize();
target.teleport(player.getLocation().subtract(eyeDirection().multiply(2));
}```
yea this one is working fine, thanks
it was because of paper or what?
probably
you don;t need to zero pitch on Spigot as the player body/location has zero pitch on Spigot
Honestly surprised the body has yaw or whatever at all.
thought only eye loc has it
I can;t believe paper actually adds a pitch to the player location though
when they cuff each other at the same time i've 2 supermans in my server
server is single threaded for ticks so two players will never do it at the same time
i know they just get teleported behind each other each tick
you need to not allow a player to cuff another if they are already cuffed
yea sure
publishing proper maven artifacts from gradle is a pain
